Commit 3c9083ff authored by yorn's avatar yorn

Fix indents

parent 41a2c814
......@@ -3,7 +3,7 @@
# autoconf/configure.in for RUDE and CRUDE
#
# Authors: Juha Laine <james@cs.tut.fi>
# Sampo Saaristo <sambo@cc.tut.fi>
# Sampo Saaristo <sambo@cc.tut.fi>
#
# Copyright (C) 1999 Juha Laine, Tampere, Finland
# All rights reserved
......@@ -54,16 +54,16 @@ AC_TYPE_UID_T
AC_CHECK_FUNCS(gettimeofday select strerror munlockall sigaction)
AC_CHECK_FUNC(gethostbyname,[true],
AC_SEARCH_LIBS(gethostbyname, nsl))
AC_SEARCH_LIBS(gethostbyname, nsl))
AC_CHECK_FUNC(socket,[true],
AC_SEARCH_LIBS(socket, socket nsl))
AC_SEARCH_LIBS(socket, socket nsl))
AC_CHECK_FUNC(inet_addr,[true],
AC_SEARCH_LIBS(inet_addr, xnet))
AC_SEARCH_LIBS(inet_addr, xnet))
AC_CHECK_FUNC(sched_setscheduler,[true],
AC_SEARCH_LIBS(sched_setscheduler, posix4))
AC_SEARCH_LIBS(sched_setscheduler, posix4))
AC_CHECK_FUNC(pow,[true],
AC_SEARCH_LIBS(pow, m))
......@@ -123,4 +123,4 @@ AC_ARG_WITH(debug-lvl,
###################
CFLAGS="$CFLAGS -I../include"
AC_OUTPUT(Makefile:autoconf/Makefile.in rude/Makefile crude/Makefile, \
echo timestamp > include/stamp.h)
echo timestamp > include/stamp.h)
......@@ -55,53 +55,53 @@ dst=""
dir_arg=""
while [ x"$1" != x ]; do
case $1 in
case $1 in
-c) instcmd="$cpprog"
shift
continue;;
shift
continue;;
-d) dir_arg=true
shift
continue;;
shift
continue;;
-m) chmodcmd="$chmodprog $2"
shift
shift
continue;;
shift
shift
continue;;
-o) chowncmd="$chownprog $2"
shift
shift
continue;;
shift
shift
continue;;
-g) chgrpcmd="$chgrpprog $2"
shift
shift
continue;;
shift
shift
continue;;
-s) stripcmd="$stripprog"
shift
continue;;
shift
continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift
continue;;
shift
continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift
continue;;
shift
continue;;
*) if [ x"$src" = x ]
then
then
src=$1
else
else
# this colon is to work around a 386BSD /bin/sh bug
:
dst=$1
fi
shift
continue;;
esac
fi
shift
continue;;
esac
done
if [ x"$src" = x ]
......@@ -115,7 +115,7 @@ fi
if [ x"$dir_arg" != x ]; then
dst=$src
src=""
if [ -d $dst ]; then
instcmd=:
chmodcmd=""
......@@ -125,7 +125,7 @@ if [ x"$dir_arg" != x ]; then
else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command
# might cause directories to be created, which would be especially bad
# might cause directories to be created, which would be especially bad
# if $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ]
......@@ -135,7 +135,7 @@ else
echo "install: $src does not exist"
exit 1
fi
if [ x"$dst" = x ]
then
echo "install: no destination specified"
......@@ -163,7 +163,7 @@ dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then
defaultIFS='
defaultIFS='
'
IFS="${IFS-${defaultIFS}}"
......@@ -180,7 +180,7 @@ while [ $# -ne 0 ] ; do
shift
if [ ! -d "${pathcomp}" ] ;
then
then
$mkdirprog "${pathcomp}"
else
true
......@@ -202,17 +202,17 @@ else
# If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ]
if [ x"$transformarg" = x ]
then
dstfile=`basename $dst`
else
dstfile=`basename $dst $transformbasename |
dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename
fi
# don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ]
if [ x"$dstfile" = x ]
then
dstfile=`basename $dst`
else
......@@ -243,7 +243,7 @@ else
# Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile
$doit $mvcmd $dsttmp $dstdir/$dstfile
fi &&
......
......@@ -68,13 +68,13 @@ to stdout. The
.IB flowlist
is a comma separated list of flow-identifiers. The statistics for each flow
include:
o number of received packets
o num. of packets received out of sequence
o estimated number of lost packets
o total bytes received
o average delay
o absolute maximum jitter
o throughtput
o number of received packets
o num. of packets received out of sequence
o estimated number of lost packets
o total bytes received
o average delay
o absolute maximum jitter
o throughtput
.IP \fB\-n
Set the
.IB number
......
......@@ -48,25 +48,25 @@
*/
struct flow_stat
{
unsigned long flowid;
unsigned long seqmin, seq; /* Seq number of the first and current packets */
unsigned long rec; /* Number of received packets */
unsigned long oos; /* Number of packets out of sequence */
long long js_sec; /* Jitter sum of seconds */
long long js_usec; /* Jitter sum of microsseconds */
long long ds_sec; /* Delay sum of seconds */
long long ds_usec; /* Delay sum of microsseconds */
long last_tx_sec;
long last_tx_usec;
long last_rx_sec;
long last_rx_usec;
long last_delay_sec;
long last_delay_usec;
long first_rx_sec;
long first_rx_usec;
long max_jitter_sec;
long max_jitter_usec;
unsigned long long s_size; /* Sum of all packet sizes */
unsigned long flowid;
unsigned long seqmin, seq; /* Seq number of the first and current packets */
unsigned long rec; /* Number of received packets */
unsigned long oos; /* Number of packets out of sequence */
long long js_sec; /* Jitter sum of seconds */
long long js_usec; /* Jitter sum of microsseconds */
long long ds_sec; /* Delay sum of seconds */
long long ds_usec; /* Delay sum of microsseconds */
long last_tx_sec;
long last_tx_usec;
long last_rx_sec;
long last_rx_usec;
long last_delay_sec;
long last_delay_usec;
long first_rx_sec;
long first_rx_usec;
long max_jitter_sec;
long max_jitter_usec;
unsigned long long s_size; /* Sum of all packet sizes */
};
......@@ -95,358 +95,358 @@ char preffix[] = "::ffff:";
int main(int argc, char **argv)
{
extern char *optarg;
extern int optind, opterr, optopt, errno;
char *ifipadd = NULL; /* pointer to interface IP address */
unsigned short port = 10001; /* default UDP port number */
long w_num = 0; /* # pkts to capture. 0=unlimited */
int priority = 0;
uid_t user_id = getuid();
int cmd_char = 0;
int retval = 0;
long temp1 = 0;
int ps_flag = 0;
struct sigaction action;
struct sched_param p;
char *sptr, *eptr;
struct flow_stat *newflows;
int use_ip6=0;
int ifindex = -1;
printf("crude version %s, Copyright (C) 1999 Juha Laine and Sampo Saaristo\n"
"crude comes with ABSOLUTELY NO WARRANTY!\n"
"This is free software, and you are welcome to redistribute it\n"
"under GNU GENERAL PUBLIC LICENSE Version 2.\n",VERSION);
struct sockaddr_storage test;
printf("Size of sockaddr_storage: %d ss_len:%d \n",sizeof(test),sizeof(test.ss_family));
while((retval >= 0) &&
((cmd_char = getopt(argc,argv,"hvd:p:i:l:P:n:s:6D:")) != EOF))
{
switch(cmd_char)
{
case 'v':
if((optind == 2) && (argc == 2))
{
printf("crude version is %s\n",VERSION);
retval = -1;
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'h':
if((optind == 2) && (argc == 2))
{
usage(argv[0]);
retval = -1;
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'd':
if((optind == 3) && (argc == 3) && (optarg != NULL))
{
if((main_file = open(optarg, O_RDONLY, 0)) < 0)
{
RUDEBUG1("crude: couldn't open file %s: %s\n",optarg,strerror(errno));
retval = -3;
}
else
{
retval = 1;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'p':
if(optarg != NULL)
{
errno = 0;
temp1 = strtol((const char *)optarg,NULL,0);
if(errno != 0)
{
RUDEBUG1("crude: '-p' number format error: %s\n",strerror(errno));
retval = -4;
}
else if((temp1 < 1025) || (temp1 > 65535))
{
RUDEBUG1("crude: port must be between 1025-65535!\n");
retval = -4;
}
else
{
port = temp1;
retval += 2;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'i':
if(optarg != NULL)
{
ifipadd = argv[(optind-1)];
retval += 4;
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'l':
if(optarg != NULL)
{
if((main_file = open(optarg, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0)
{
RUDEBUG1("crude: couldn't open file %s: %s\n",optarg,strerror(errno));
retval = -5;
}
else
{
retval += 8;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'P':
if(optarg != NULL)
{
priority = atoi(optarg);
if((priority < 1) || (priority > 90))
{
fprintf(stderr,"crude: priority must be between 1 to 90\n");
retval = -2;
}
if(user_id != 0)
{
fprintf(stderr,"crude: must be root to set the priority level\n");
retval = -2;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'n':
if(optarg != NULL)
{
errno = 0;
w_num = strtol((const char *)optarg,NULL,0);
if(errno != 0)
{
RUDEBUG1("crude: '-w' number format error: %s\n",strerror(errno));
retval = -6;
}
else if(w_num <= 0)
{
RUDEBUG1("crude: # of logged packets must be > 0!\n");
retval = -6;
}
else
{
retval += 16;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 's':
if(optarg != NULL)
{
sptr = optarg;
do
{
newflows = realloc(flows, (nflows + 1) * sizeof(struct flow_stat));
if (newflows == NULL)
{
RUDEBUG1("crude: failed to allocate memory for statistics!\n");
retval = -6;
break;
}
flows = newflows;
flows[nflows].flowid = strtoul(sptr, &eptr, 10);
if (eptr == sptr || flows[nflows].flowid == ULONG_MAX)
{
RUDEBUG1("crude: error reading flow IDs!\n");
retval = -6;
break;
}
if (*eptr && *eptr != ',')
{
RUDEBUG1("crude: flow IDs must be separated by a comma!\n");
retval = -6;
break;
}
sptr = eptr + 1;
flows[nflows].rec = 0;
flows[nflows].oos = 0;
flows[nflows].seq = ULONG_MAX;
flows[nflows].seqmin = ULONG_MAX;
flows[nflows].js_sec = 0;
flows[nflows].js_usec = 0;
flows[nflows].ds_sec = 0;
flows[nflows].ds_usec = 0;
flows[nflows].s_size = 0;
flows[nflows].last_delay_sec = 0;
flows[nflows].last_delay_usec = 0;
flows[nflows].max_jitter_sec = 0;
flows[nflows].max_jitter_usec = 0;
/* The other fields are initialized when the first packet arrives */
nflows++;
}
while (*eptr);
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case '6':
use_ip6 = 1;
break;
case 'D':
if(optarg != NULL){
RUDEBUG7("crude: using specified interface for multicast, name: %s\n",optarg);
if(0==(ifindex = if_nametoindex(optarg))){
extern char *optarg;
extern int optind, opterr, optopt, errno;
char *ifipadd = NULL; /* pointer to interface IP address */
unsigned short port = 10001; /* default UDP port number */
long w_num = 0; /* # pkts to capture. 0=unlimited */
int priority = 0;
uid_t user_id = getuid();
int cmd_char = 0;
int retval = 0;
long temp1 = 0;
int ps_flag = 0;
struct sigaction action;
struct sched_param p;
char *sptr, *eptr;
struct flow_stat *newflows;
int use_ip6=0;
int ifindex = -1;
printf("crude version %s, Copyright (C) 1999 Juha Laine and Sampo Saaristo\n"
"crude comes with ABSOLUTELY NO WARRANTY!\n"
"This is free software, and you are welcome to redistribute it\n"
"under GNU GENERAL PUBLIC LICENSE Version 2.\n",VERSION);
struct sockaddr_storage test;
printf("Size of sockaddr_storage: %d ss_len:%d \n",sizeof(test),sizeof(test.ss_family));
while((retval >= 0) &&
((cmd_char = getopt(argc,argv,"hvd:p:i:l:P:n:s:6D:")) != EOF))
{
switch(cmd_char)
{
case 'v':
if((optind == 2) && (argc == 2))
{
printf("crude version is %s\n",VERSION);
retval = -1;
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'h':
if((optind == 2) && (argc == 2))
{
usage(argv[0]);
retval = -1;
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'd':
if((optind == 3) && (argc == 3) && (optarg != NULL))
{
if((main_file = open(optarg, O_RDONLY, 0)) < 0)
{
RUDEBUG1("crude: couldn't open file %s: %s\n",optarg,strerror(errno));
retval = -3;
}
else
{
retval = 1;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'p':
if(optarg != NULL)
{
errno = 0;
temp1 = strtol((const char *)optarg,NULL,0);
if(errno != 0)
{
RUDEBUG1("crude: '-p' number format error: %s\n",strerror(errno));
retval = -4;
}
else if((temp1 < 1025) || (temp1 > 65535))
{
RUDEBUG1("crude: port must be between 1025-65535!\n");
retval = -4;
}
else
{
port = temp1;
retval += 2;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'i':
if(optarg != NULL)
{
ifipadd = argv[(optind-1)];
retval += 4;
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'l':
if(optarg != NULL)
{
if((main_file = open(optarg, O_WRONLY|O_CREAT|O_TRUNC, 0644)) < 0)
{
RUDEBUG1("crude: couldn't open file %s: %s\n",optarg,strerror(errno));
retval = -5;
}
else
{
retval += 8;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'P':
if(optarg != NULL)
{
priority = atoi(optarg);
if((priority < 1) || (priority > 90))
{
fprintf(stderr,"crude: priority must be between 1 to 90\n");
retval = -2;
}
if(user_id != 0)
{
fprintf(stderr,"crude: must be root to set the priority level\n");
retval = -2;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;
}
break;
case 'n':
if(optarg != NULL)
{
errno = 0;
w_num = strtol((const char *)optarg,NULL,0);
if(errno != 0)
{
RUDEBUG1("crude: '-w' number format error: %s\n",strerror(errno));
retval = -6;
}
else if(w_num <= 0)
{
RUDEBUG1("crude: # of logged packets must be > 0!\n");
retval = -6;
}
else
{
retval += 16;
}
}
else
{
RUDEBUG1("crude: invalid commandline arguments!\n");
retval = -2;