Commit 3c9083ff authored by yorn's avatar yorn

Fix indents

parent 41a2c814
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
# autoconf/configure.in for RUDE and CRUDE # autoconf/configure.in for RUDE and CRUDE
# #
# Authors: Juha Laine <james@cs.tut.fi> # 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 # Copyright (C) 1999 Juha Laine, Tampere, Finland
# All rights reserved # All rights reserved
...@@ -54,16 +54,16 @@ AC_TYPE_UID_T ...@@ -54,16 +54,16 @@ AC_TYPE_UID_T
AC_CHECK_FUNCS(gettimeofday select strerror munlockall sigaction) AC_CHECK_FUNCS(gettimeofday select strerror munlockall sigaction)
AC_CHECK_FUNC(gethostbyname,[true], AC_CHECK_FUNC(gethostbyname,[true],
AC_SEARCH_LIBS(gethostbyname, nsl)) AC_SEARCH_LIBS(gethostbyname, nsl))
AC_CHECK_FUNC(socket,[true], AC_CHECK_FUNC(socket,[true],
AC_SEARCH_LIBS(socket, socket nsl)) AC_SEARCH_LIBS(socket, socket nsl))
AC_CHECK_FUNC(inet_addr,[true], 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_CHECK_FUNC(sched_setscheduler,[true],
AC_SEARCH_LIBS(sched_setscheduler, posix4)) AC_SEARCH_LIBS(sched_setscheduler, posix4))
AC_CHECK_FUNC(pow,[true], AC_CHECK_FUNC(pow,[true],
AC_SEARCH_LIBS(pow, m)) AC_SEARCH_LIBS(pow, m))
...@@ -123,4 +123,4 @@ AC_ARG_WITH(debug-lvl, ...@@ -123,4 +123,4 @@ AC_ARG_WITH(debug-lvl,
################### ###################
CFLAGS="$CFLAGS -I../include" CFLAGS="$CFLAGS -I../include"
AC_OUTPUT(Makefile:autoconf/Makefile.in rude/Makefile crude/Makefile, \ 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="" ...@@ -55,53 +55,53 @@ dst=""
dir_arg="" dir_arg=""
while [ x"$1" != x ]; do while [ x"$1" != x ]; do
case $1 in case $1 in
-c) instcmd="$cpprog" -c) instcmd="$cpprog"
shift shift
continue;; continue;;
-d) dir_arg=true -d) dir_arg=true
shift shift
continue;; continue;;
-m) chmodcmd="$chmodprog $2" -m) chmodcmd="$chmodprog $2"
shift shift
shift shift
continue;; continue;;
-o) chowncmd="$chownprog $2" -o) chowncmd="$chownprog $2"
shift shift
shift shift
continue;; continue;;
-g) chgrpcmd="$chgrpprog $2" -g) chgrpcmd="$chgrpprog $2"
shift shift
shift shift
continue;; continue;;
-s) stripcmd="$stripprog" -s) stripcmd="$stripprog"
shift shift
continue;; continue;;
-t=*) transformarg=`echo $1 | sed 's/-t=//'` -t=*) transformarg=`echo $1 | sed 's/-t=//'`
shift shift
continue;; continue;;
-b=*) transformbasename=`echo $1 | sed 's/-b=//'` -b=*) transformbasename=`echo $1 | sed 's/-b=//'`
shift shift
continue;; continue;;
*) if [ x"$src" = x ] *) if [ x"$src" = x ]
then then
src=$1 src=$1
else else
# this colon is to work around a 386BSD /bin/sh bug # this colon is to work around a 386BSD /bin/sh bug
: :
dst=$1 dst=$1
fi fi
shift shift
continue;; continue;;
esac esac
done done
if [ x"$src" = x ] if [ x"$src" = x ]
...@@ -115,7 +115,7 @@ fi ...@@ -115,7 +115,7 @@ fi
if [ x"$dir_arg" != x ]; then if [ x"$dir_arg" != x ]; then
dst=$src dst=$src
src="" src=""
if [ -d $dst ]; then if [ -d $dst ]; then
instcmd=: instcmd=:
chmodcmd="" chmodcmd=""
...@@ -125,7 +125,7 @@ if [ x"$dir_arg" != x ]; then ...@@ -125,7 +125,7 @@ if [ x"$dir_arg" != x ]; then
else else
# Waiting for this to be detected by the "$instcmd $src $dsttmp" command # 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 $src (and thus $dsttmp) contains '*'.
if [ -f $src -o -d $src ] if [ -f $src -o -d $src ]
...@@ -135,7 +135,7 @@ else ...@@ -135,7 +135,7 @@ else
echo "install: $src does not exist" echo "install: $src does not exist"
exit 1 exit 1
fi fi
if [ x"$dst" = x ] if [ x"$dst" = x ]
then then
echo "install: no destination specified" echo "install: no destination specified"
...@@ -163,7 +163,7 @@ dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` ...@@ -163,7 +163,7 @@ dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'`
# Skip lots of stat calls in the usual case. # Skip lots of stat calls in the usual case.
if [ ! -d "$dstdir" ]; then if [ ! -d "$dstdir" ]; then
defaultIFS=' defaultIFS='
' '
IFS="${IFS-${defaultIFS}}" IFS="${IFS-${defaultIFS}}"
...@@ -180,7 +180,7 @@ while [ $# -ne 0 ] ; do ...@@ -180,7 +180,7 @@ while [ $# -ne 0 ] ; do
shift shift
if [ ! -d "${pathcomp}" ] ; if [ ! -d "${pathcomp}" ] ;
then then
$mkdirprog "${pathcomp}" $mkdirprog "${pathcomp}"
else else
true true
...@@ -202,17 +202,17 @@ else ...@@ -202,17 +202,17 @@ else
# If we're going to rename the final executable, determine the name now. # If we're going to rename the final executable, determine the name now.
if [ x"$transformarg" = x ] if [ x"$transformarg" = x ]
then then
dstfile=`basename $dst` dstfile=`basename $dst`
else else
dstfile=`basename $dst $transformbasename | dstfile=`basename $dst $transformbasename |
sed $transformarg`$transformbasename sed $transformarg`$transformbasename
fi fi
# don't allow the sed command to completely eliminate the filename # don't allow the sed command to completely eliminate the filename
if [ x"$dstfile" = x ] if [ x"$dstfile" = x ]
then then
dstfile=`basename $dst` dstfile=`basename $dst`
else else
...@@ -243,7 +243,7 @@ else ...@@ -243,7 +243,7 @@ else
# Now rename the file to the real destination. # Now rename the file to the real destination.
$doit $rmcmd -f $dstdir/$dstfile && $doit $rmcmd -f $dstdir/$dstfile &&
$doit $mvcmd $dsttmp $dstdir/$dstfile $doit $mvcmd $dsttmp $dstdir/$dstfile
fi && fi &&
......
...@@ -68,13 +68,13 @@ to stdout. The ...@@ -68,13 +68,13 @@ to stdout. The
.IB flowlist .IB flowlist
is a comma separated list of flow-identifiers. The statistics for each flow is a comma separated list of flow-identifiers. The statistics for each flow
include: include:
o number of received packets o number of received packets
o num. of packets received out of sequence o num. of packets received out of sequence
o estimated number of lost packets o estimated number of lost packets
o total bytes received o total bytes received
o average delay o average delay
o absolute maximum jitter o absolute maximum jitter
o throughtput o throughtput
.IP \fB\-n .IP \fB\-n
Set the Set the
.IB number .IB number
......
This diff is collapsed.
This diff is collapsed.
...@@ -25,44 +25,44 @@ ...@@ -25,44 +25,44 @@
int int
isMulticastAddr(struct sockaddr_storage *addr) isMulticastAddr(struct sockaddr_storage *addr)
{ {
int retVal; int retVal;
retVal=-1; retVal=-1;
switch (addr->ss_family) {
case AF_INET: {
struct sockaddr_in *addr4=(struct sockaddr_in *)addr;
retVal = IN_MULTICAST(ntohl(addr4->sin_addr.s_addr));
} break;
case AF_INET6: { switch (addr->ss_family) {
struct sockaddr_in6 *addr6=(struct sockaddr_in6 *)addr; case AF_INET: {
retVal = IN6_IS_ADDR_MULTICAST(&addr6->sin6_addr); struct sockaddr_in *addr4=(struct sockaddr_in *)addr;
} break; retVal = IN_MULTICAST(ntohl(addr4->sin_addr.s_addr));
} break;
default: case AF_INET6: {
; struct sockaddr_in6 *addr6=(struct sockaddr_in6 *)addr;
} retVal = IN6_IS_ADDR_MULTICAST(&addr6->sin6_addr);
} break;
return retVal; default:
} ;
}
return retVal;
}
int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_storage *addr,int interface) int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_storage *addr,int interface)
{ {
int r1, r2, r3, retval; int r1, r2, r3, retval;
retval=-1; retval=-1;
switch (addr->ss_family) { switch (addr->ss_family) {
case AF_INET: { case AF_INET: {
struct ip_mreq mreq; struct ip_mreq mreq;
//zjistit adresu interfacu(v parametru je jeho index),INADDR_ANY je pro defaultni //zjistit adresu interfacu(v parametru je jeho index),INADDR_ANY je pro defaultni
mreq.imr_multiaddr.s_addr= mreq.imr_multiaddr.s_addr=
((struct sockaddr_in *)addr)->sin_addr.s_addr; ((struct sockaddr_in *)addr)->sin_addr.s_addr;
if(interface < 0){ if(interface < 0){
mreq.imr_interface.s_addr= INADDR_ANY; mreq.imr_interface.s_addr= INADDR_ANY;
RUDEBUG7("joinGroup: using inaddr_any interface\n"); RUDEBUG7("joinGroup: using inaddr_any interface\n");
} }
else{ else{
...@@ -73,7 +73,7 @@ int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_st ...@@ -73,7 +73,7 @@ int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_st
RUDEBUG1("joinGroup: interface doesnt exist.\n"); RUDEBUG1("joinGroup: interface doesnt exist.\n");
return retval; return retval;
} }
strcpy(ifr.ifr_name, name); strcpy(ifr.ifr_name, name);
if(ioctl(sockfd,SIOCGIFADDR,&ifr)==-1){ if(ioctl(sockfd,SIOCGIFADDR,&ifr)==-1){
RUDEBUG1("joinGroup() - ioctl failed for getting interface address: %s\n",strerror(errno)); RUDEBUG1("joinGroup() - ioctl failed for getting interface address: %s\n",strerror(errno));
...@@ -83,66 +83,66 @@ int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_st ...@@ -83,66 +83,66 @@ int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_st
RUDEBUG7("joinGroup(): interface address: %s\n",inet_ntoa(si->sin_addr)); RUDEBUG7("joinGroup(): interface address: %s\n",inet_ntoa(si->sin_addr));
//mreq.imr_interface.s_addr = si->sin_addr.s_addr; //mreq.imr_interface.s_addr = si->sin_addr.s_addr;
memcpy(&mreq.imr_interface,&(si->sin_addr),sizeof(struct in_addr)); memcpy(&mreq.imr_interface,&(si->sin_addr),sizeof(struct in_addr));
//mreq.imr_interface = si->sin_addr; //mreq.imr_interface = si->sin_addr;
} }
r1= setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_LOOP, r1= setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_LOOP,
&loopBack, sizeof(loopBack)); &loopBack, sizeof(loopBack));
if (r1<0) if (r1<0)
RUDEBUG1("joinGroup:: IP_MULTICAST_LOOP:: "); RUDEBUG1("joinGroup:: IP_MULTICAST_LOOP:: ");
r2= setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL, r2= setsockopt(sockfd, IPPROTO_IP, IP_MULTICAST_TTL,
&mcastTTL, sizeof(mcastTTL)); &mcastTTL, sizeof(mcastTTL));
if (r2<0) if (r2<0)
RUDEBUG1("joinGroup:: IP_MULTICAST_TTL:: "); RUDEBUG1("joinGroup:: IP_MULTICAST_TTL:: ");
r3= setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP, r3= setsockopt(sockfd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
(const void *)&mreq, sizeof(mreq)); (const void *)&mreq, sizeof(mreq));
if (r3<0) if (r3<0)
RUDEBUG1("joinGroup:: IP_ADD_MEMBERSHIP:: "); RUDEBUG1("joinGroup:: IP_ADD_MEMBERSHIP:: ");
} break; } break;
case AF_INET6: { case AF_INET6: {
struct ipv6_mreq mreq6; struct ipv6_mreq mreq6;
memcpy(&mreq6.ipv6mr_multiaddr, memcpy(&mreq6.ipv6mr_multiaddr,
&(((struct sockaddr_in6 *)addr)->sin6_addr), &(((struct sockaddr_in6 *)addr)->sin6_addr),
sizeof(struct in6_addr)); sizeof(struct in6_addr));
if(interface < 0){ if(interface < 0){
mreq6.ipv6mr_interface= 0; mreq6.ipv6mr_interface= 0;
RUDEBUG7("joinGroup: using default interface\n"); RUDEBUG7("joinGroup: using default interface\n");
}else{ }else{
mreq6.ipv6mr_interface= interface; mreq6.ipv6mr_interface= interface;
RUDEBUG7("joinGroup: using interface with index: %d\n",interface); RUDEBUG7("joinGroup: using interface with index: %d\n",interface);
} }
r1= setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP, r1= setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
&loopBack, sizeof(loopBack)); &loopBack, sizeof(loopBack));
if (r1<0) if (r1<0)
RUDEBUG1("joinGroup(): IPV6_MULTICAST_LOOP error"); RUDEBUG1("joinGroup(): IPV6_MULTICAST_LOOP error");
r2= setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS, r2= setsockopt(sockfd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
&mcastTTL, sizeof(mcastTTL)); &mcastTTL, sizeof(mcastTTL));
if (r2<0) if (r2<0)
RUDEBUG1("joinGroup() IPV6_MULTICAST_HOPS error "); RUDEBUG1("joinGroup() IPV6_MULTICAST_HOPS error ");
r3=setsockopt(sockfd,IPPROTO_IPV6,IPV6_JOIN_GROUP,&mreq6,sizeof(mreq6)); r3=setsockopt(sockfd,IPPROTO_IPV6,IPV6_JOIN_GROUP,&mreq6,sizeof(mreq6));
//r3=setsockopt(sockfd,IPPROTO_IPV6,IP_ADD_MEMBERSHIP,&mreq6,sizeof(mreq6)); //r3=setsockopt(sockfd,IPPROTO_IPV6,IP_ADD_MEMBERSHIP,&mreq6,sizeof(mreq6));
if (r3<0) if (r3<0)
RUDEBUG1("joinGroup() IPV6_JOIN_GROUP error "); RUDEBUG1("joinGroup() IPV6_JOIN_GROUP error ");
} break; } break;
default: default:
r1=r2=r3=-1; r1=r2=r3=-1;
} }
if ((r1>=0) && (r2>=0) && (r3>=0)) if ((r1>=0) && (r2>=0) && (r3>=0))
retval=0; retval=0;
return retval; return retval;
} }
...@@ -45,43 +45,43 @@ extern struct flow_cfg *done; ...@@ -45,43 +45,43 @@ extern struct flow_cfg *done;
*/ */
static int remove_flow(struct flow_cfg *to_remove) static int remove_flow(struct flow_cfg *to_remove)
{ {
struct flow_cfg *flow = head; struct flow_cfg *flow = head;
struct flow_cfg *prev = NULL; struct flow_cfg *prev = NULL;
/* Look up the "to_remove" and the previous flow object. */ /* Look up the "to_remove" and the previous flow object. */
/* Check the results for possible "overflow" error(s). */ /* Check the results for possible "overflow" error(s). */
while((flow != to_remove) && (flow != NULL)){ while((flow != to_remove) && (flow != NULL)){
prev = flow; prev = flow;
flow = flow->next; flow = flow->next;
} }
if(flow == NULL){ if(flow == NULL){
RUDEBUG1("remove_flow(): flow to remove was not found!\n"); RUDEBUG1("remove_flow(): flow to remove was not found!\n");
return 0; return 0;
} }
/* Initialize the next block for this flow - if any */ /* Initialize the next block for this flow - if any */
if((flow = to_remove->mod_flow) != NULL){ if((flow = to_remove->mod_flow) != NULL){
flow->next = to_remove->next; flow->next = to_remove->next;
flow->send_sock = to_remove->send_sock; flow->send_sock = to_remove->send_sock;
flow->sequence_nmbr = to_remove->sequence_nmbr; flow->sequence_nmbr = to_remove->sequence_nmbr;
} else { } else {
if(to_remove->send_sock>0){ if(to_remove->send_sock>0){
close(to_remove->send_sock); close(to_remove->send_sock);
} }
to_remove->send_sock = 0; to_remove->send_sock = 0;
flow = to_remove->next; flow = to_remove->next;
} }
/* Unlink the object "to_remove" from the active list */ /* Unlink the object "to_remove" from the active list */
if(prev == NULL){ head = flow; } if(prev == NULL){ head = flow; }
else { prev->next = flow; } else { prev->next = flow; }
/* Link the object to the "done" list and return SUCCESS */ /* Link the object to the "done" list and return SUCCESS */
/* FIXME: to_remove->mod_flow = NULL; ???? */ /* FIXME: to_remove->mod_flow = NULL; ???? */
to_remove->next = done; to_remove->next = done;
done = to_remove; done = to_remove;
RUDEBUG7("remove_flow(): block removed from flow id=%ld\n",done->flow_id); RUDEBUG7("remove_flow(): block removed from flow id=%ld\n",done->flow_id);
return 1; return 1;
} /* remove_flow() */ } /* remove_flow() */
...@@ -92,37 +92,37 @@ static int remove_flow(struct flow_cfg *to_remove) ...@@ -92,37 +92,37 @@ static int remove_flow(struct flow_cfg *to_remove)
* list. * list.
*/ */
struct flow_cfg *find_next(void) struct flow_cfg *find_next(void)
{ {
struct flow_cfg *flow = head; struct flow_cfg *flow = head;
struct flow_cfg *prev = NULL; struct flow_cfg *prev = NULL;
struct flow_cfg *target = NULL; struct flow_cfg *target = NULL;
struct timeval now; struct timeval now;
/* Get the current time */ /* Get the current time */
gettimeofday(&now, NULL); gettimeofday(&now, NULL);
/* Find the next flow from which should send the packet */ /* Find the next flow from which should send the packet */
while(flow){ while(flow){
/* Remove the flows that are already "done". The remove_flow() */ /* Remove the flows that are already "done". The remove_flow() */
/* function modifies the active and passive lists (pointed by */ /* function modifies the active and passive lists (pointed by */
/* head and done respectively)... */ /* head and done respectively)... */
if(timercmp(&flow->flow_stop,&now,<) || if(timercmp(&flow->flow_stop,&now,<) ||
timercmp(&flow->next_tx,&flow->flow_stop,>)){ timercmp(&flow->next_tx,&flow->flow_stop,>)){
remove_flow(flow); remove_flow(flow);
if(prev != NULL){ flow = prev->next; } if(prev != NULL){ flow = prev->next; }
else { flow = head; } else { flow = head; }
continue; continue;
} }
/* Mark the current flow as target, if certain conditions are met... */ /* Mark the current flow as target, if certain conditions are met... */
if((target == NULL) || (timercmp(&flow->next_tx,&target->next_tx,<))){ if((target == NULL) || (timercmp(&flow->next_tx,&target->next_tx,<))){
target = flow; target = flow;
} }
prev = flow; prev = flow;
flow = flow->next; flow = flow->next;
} }
return target; return target;
} /* find_next() */ } /* find_next() */
...@@ -132,57 +132,57 @@ struct flow_cfg *find_next(void) ...@@ -132,57 +132,57 @@ struct flow_cfg *find_next(void)
* attention if one adds new flow types to this program... * attention if one adds new flow types to this program...
*/ */
void clean_up(void) void clean_up(void)
{ {
struct flow_cfg *tmp1; struct flow_cfg *tmp1;
/* /*
* Clear the active flow list * Clear the active flow list
*/ */
while((tmp1 = head) != NULL){ while((tmp1 = head) != NULL){
/* Close the open connections (if any) */ /* Close the open connections (if any) */
if(head->send_sock > 0){ if(head->send_sock > 0){
close(head->send_sock); close(head->send_sock);
head->send_sock = 0; head->send_sock = 0;
} }
/* Unlink this flow and update the pointers before destruction */ /* Unlink this flow and update the pointers before destruction */
if(head->mod_flow != NULL){ if(head->mod_flow != NULL){
head = head->mod_flow; head = head->mod_flow;
head->next = tmp1->next; head->next = tmp1->next;
} else { } else {
head = head->next; head = head->next;
} }
/*** DO THE EXTRA CLEAN-UP HERE ***/ /*** DO THE EXTRA CLEAN-UP HERE ***/
if(tmp1->params.ftype == TRACE){ if(tmp1->params.ftype == TRACE){
free(tmp1->params.trace.list); free(tmp1->params.trace.list);