mirror of
https://github.com/servalproject/serval-dna.git
synced 2025-01-29 15:43:56 +00:00
Added instrumentation logging option.
This commit is contained in:
parent
554bb8cbae
commit
f024213414
7
dna.c
7
dna.c
@ -20,6 +20,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
#include "mphlr.h"
|
||||
|
||||
char *outputtemplate=NULL;
|
||||
char *instrumentation_file=NULL;
|
||||
|
||||
int debug=0;
|
||||
int timeout=3000; /* 3000ms request timeout */
|
||||
@ -216,6 +217,7 @@ int usage(char *complaint)
|
||||
fprintf(stderr," -A - Ask for address of subscriber.\n");
|
||||
fprintf(stderr," -b - Specify BATMAN socket to obtain peer list (flaky).\n");
|
||||
fprintf(stderr," -l - Specify BATMAN socket to obtain peer list (better, but requires Serval patched BATMAN).\n");
|
||||
fprintf(stderr," -L - Log mesh statistics to specified file.\n");
|
||||
fprintf(stderr," -n - Do not detach from foreground in server mode.\n");
|
||||
fprintf(stderr," -S - Run in server mode with an HLR of the specified size.\n");
|
||||
fprintf(stderr," -f - Use the specified file as a permanent store for HLR data.\n");
|
||||
@ -257,7 +259,7 @@ int main(int argc,char **argv)
|
||||
|
||||
srandomdev();
|
||||
|
||||
while((c=getopt(argc,argv,"Ab:B:S:f:d:i:l:np:P:s:t:vR:W:U:D:CO:")) != -1 )
|
||||
while((c=getopt(argc,argv,"Ab:B:S:f:d:i:l:L:np:P:s:t:vR:W:U:D:CO:")) != -1 )
|
||||
{
|
||||
switch(c)
|
||||
{
|
||||
@ -269,6 +271,9 @@ int main(int argc,char **argv)
|
||||
case 'l': /* talk peers on a BATMAN mesh */
|
||||
batman_peerfile=strdup(optarg);
|
||||
break;
|
||||
case 'L':
|
||||
instrumentation_file=strdup(optarg);
|
||||
break;
|
||||
case 'B': /* Set simulated Bit Error Rate for bench-testing */
|
||||
simulatedBER=atof(optarg);
|
||||
fprintf(stderr,"WARNING: Bit error injection enabled -- this will cause packet loss and is intended only for testing.\n");
|
||||
|
2
mphlr.h
2
mphlr.h
@ -122,7 +122,7 @@ struct mphlr_variable {
|
||||
};
|
||||
|
||||
extern char *outputtemplate;
|
||||
|
||||
extern char *instrumentation_file;
|
||||
extern char *batman_socket;
|
||||
extern char *batman_peerfile;
|
||||
|
||||
|
18
server.c
18
server.c
@ -22,6 +22,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
unsigned char *hlr=NULL;
|
||||
int hlr_size=0;
|
||||
|
||||
FILE *i_f=NULL;
|
||||
|
||||
struct sockaddr recvaddr;
|
||||
struct in_addr client_addr;
|
||||
int client_port;
|
||||
@ -177,6 +179,22 @@ int processRequest(unsigned char *packet,int len,
|
||||
case ACTION_EOT: /* EOT */
|
||||
pofs=len;
|
||||
break;
|
||||
case ACTION_STATS:
|
||||
/* short16 variable id,
|
||||
int32 value */
|
||||
{
|
||||
pofs++;
|
||||
short field=packet[pofs+1]+(packet[pofs]<<8);
|
||||
int value=packet[pofs+5]+(packet[pofs+4]<<8)+(packet[pofs+3]<<16)+(packet[pofs+2]<<24);
|
||||
pofs+=6;
|
||||
if (instrumentation_file)
|
||||
{
|
||||
if (!i_f) { if (strcmp(instrumentation_file,"-")) i_f=fopen(instrumentation_file,"a"); else i_f=stdout; }
|
||||
if (i_f) fprintf(i_f,"%ld:%08x:%d:%d\n",time(0),*(unsigned int *)&sender->sa_data[0],field,value);
|
||||
if (i_f) fflush(i_f);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ACTION_SENDSMS: /* Send an SMS to the specified SID. */
|
||||
/* You cannot use a DID */
|
||||
if (did[0]) return respondSimple(NULL,ACTION_DECLINED,NULL,0,transaction_id);
|
||||
|
Loading…
x
Reference in New Issue
Block a user