Commit 42d327f7 authored by Olav Kvittem's avatar Olav Kvittem

option to setting udp receive buffer size. Default 1M.

parent dd6ea265
......@@ -122,6 +122,8 @@ int odata = 0; // next data pos
char *obuffer=NULL;
int pipefd[2]; // a pipe for writing to file in a subprocess
int udp_buffer_size=1024*1024; // default value
int main(int argc, char **argv)
......@@ -151,7 +153,7 @@ int main(int argc, char **argv)
"under GNU GENERAL PUBLIC LICENSE Version 2.\n",VERSION);
while((retval >= 0) &&
((cmd_char = getopt(argc,argv,"Ahvd:p:C:fi:kl:P:n:s:6D:")) != EOF))
((cmd_char = getopt(argc,argv,"Ahvd:p:C:fi:kl:P:n:s:6D:b:")) != EOF))
{
switch(cmd_char)
{
......@@ -207,6 +209,29 @@ int main(int argc, char **argv)
case 'f': // fork output write
opt_fork=1;
break;
case 'b': // adjust udp read buffer size
if(optarg != NULL)
{
errno = 0;
temp1 = strtol((const char *)optarg,NULL,0);
if(errno != 0)
{
RUDEBUG1("crude: '-b' number format error: %s\n",strerror(errno));
retval = -4;
}
else
{
udp_buffer_size = temp1;
retval += 2;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'p':
if(optarg != NULL)
{
......@@ -514,6 +539,7 @@ static void usage(char *name)
"\t-v = print the version number and exit\n"
"\t-d file = decode the file to stdout\n"
"\t-p port = port to listen to\n"
"\t-b size = UDP receive buffer size(1MB)\n"
"\t-i addr = numeric IP addres for the interface to listen to\n"
"\t-6 = use ipv6\n"
"\t-D if_name = interface name(e.g. eth0) to be used-use only with multicast and -i option\n"
......@@ -1277,6 +1303,10 @@ static int rec_n_print(unsigned short port, unsigned long limit)
msgh.msg_control = (caddr_t) cmptr;
msgh.msg_controllen = CONTROLLEN;
if(setsockopt(main_socket, IPPROTO_IP, SO_RCVBUF, &udp_buffer_size,sizeof(udp_buffer_size))>0)
{
RUDEBUG1("crude: unable to set UDP receive buffer : %s\n",strerror(errno));
}
if(setsockopt(main_socket, IPPROTO_IP, IP_RECVTTL, &ttl,sizeof(ttl))>0)
{
RUDEBUG1("crude: unable to receive TTL values for IPv4: %s\n",strerror(errno));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment