Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
rude
rude
Commits
3c9083ff
Commit
3c9083ff
authored
Dec 11, 2014
by
yorn
Browse files
Fix indents
parent
41a2c814
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
autoconf/configure.in
View file @
3c9083ff
...
...
@@ -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)
autoconf/install-sh
View file @
3c9083ff
...
...
@@ -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
&&
...
...
crude/crude.8
View file @
3c9083ff
...
...
@@ -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
...
...
crude/main.c
View file @
3c9083ff
This diff is collapsed.
Click to expand it.
grude/grude
View file @
3c9083ff
This diff is collapsed.
Click to expand it.
include/mcast.c
View file @
3c9083ff
...
...
@@ -25,44 +25,44 @@
int
isMulticastAddr
(
struct
sockaddr_storage
*
addr
)
{
int
retVal
;
int
retVal
;
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
;
retVal
=-
1
;
case
AF_INET6
:
{
struct
sockaddr_in6
*
addr6
=
(
struct
sockaddr_in6
*
)
addr
;
retVal
=
IN6_IS_ADDR_MULTICAST
(
&
addr6
->
sin6_addr
);
}
break
;
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
;
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
r1
,
r2
,
r3
,
retval
;
int
r1
,
r2
,
r3
,
retval
;
retval
=-
1
;
switch
(
addr
->
ss_family
)
{
case
AF_INET
:
{
struct
ip_mreq
mreq
;
retval
=-
1
;
switch
(
addr
->
ss_family
)
{
case
AF_INET
:
{
struct
ip_mreq
mreq
;
//zjistit adresu interfacu(v parametru je jeho index),INADDR_ANY je pro defaultni
mreq
.
imr_multiaddr
.
s_addr
=
((
struct
sockaddr_in
*
)
addr
)
->
sin_addr
.
s_addr
;
mreq
.
imr_multiaddr
.
s_addr
=
((
struct
sockaddr_in
*
)
addr
)
->
sin_addr
.
s_addr
;
if
(
interface
<
0
){
mreq
.
imr_interface
.
s_addr
=
INADDR_ANY
;
mreq
.
imr_interface
.
s_addr
=
INADDR_ANY
;
RUDEBUG7
(
"joinGroup: using inaddr_any interface
\n
"
);
}
else
{
...
...
@@ -73,7 +73,7 @@ int joinGroup(int sockfd, int loopBack, unsigned int mcastTTL,struct sockaddr_st
RUDEBUG1
(
"joinGroup: interface doesnt exist.
\n
"
);
return
retval
;
}
strcpy
(
ifr
.
ifr_name
,
name
);
if
(
ioctl
(
sockfd
,
SIOCGIFADDR
,
&
ifr
)
==-
1
){
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
RUDEBUG7
(
"joinGroup(): interface address: %s
\n
"
,
inet_ntoa
(
si
->
sin_addr
));
//mreq.imr_interface.s_addr = si->sin_addr.s_addr;
memcpy
(
&
mreq
.
imr_interface
,
&
(
si
->
sin_addr
),
sizeof
(
struct
in_addr
));
//mreq.imr_interface = si->sin_addr;
}
r1
=
setsockopt
(
sockfd
,
IPPROTO_IP
,
IP_MULTICAST_LOOP
,
&
loopBack
,
sizeof
(
loopBack
));
if
(
r1
<
0
)
RUDEBUG1
(
"joinGroup:: IP_MULTICAST_LOOP:: "
);
r1
=
setsockopt
(
sockfd
,
IPPROTO_IP
,
IP_MULTICAST_LOOP
,
&
loopBack
,
sizeof
(
loopBack
));
if
(
r1
<
0
)
RUDEBUG1
(
"joinGroup:: IP_MULTICAST_LOOP:: "
);
r2
=
setsockopt
(
sockfd
,
IPPROTO_IP
,
IP_MULTICAST_TTL
,
&
mcastTTL
,
sizeof
(
mcastTTL
));
if
(
r2
<
0
)
RUDEBUG1
(
"joinGroup:: IP_MULTICAST_TTL:: "
);
r2
=
setsockopt
(
sockfd
,
IPPROTO_IP
,
IP_MULTICAST_TTL
,
&
mcastTTL
,
sizeof
(
mcastTTL
));
if
(
r2
<
0
)
RUDEBUG1
(
"joinGroup:: IP_MULTICAST_TTL:: "
);
r3
=
setsockopt
(
sockfd
,
IPPROTO_IP
,
IP_ADD_MEMBERSHIP
,
(
const
void
*
)
&
mreq
,
sizeof
(
mreq
));
if
(
r3
<
0
)
RUDEBUG1
(
"joinGroup:: IP_ADD_MEMBERSHIP:: "
);
r3
=
setsockopt
(
sockfd
,
IPPROTO_IP
,
IP_ADD_MEMBERSHIP
,
(
const
void
*
)
&
mreq
,
sizeof
(
mreq
));
if
(
r3
<
0
)
RUDEBUG1
(
"joinGroup:: IP_ADD_MEMBERSHIP:: "
);
}
break
;
}
break
;
case
AF_INET6
:
{
struct
ipv6_mreq
mreq6
;
case
AF_INET6
:
{
struct
ipv6_mreq
mreq6
;
memcpy
(
&
mreq6
.
ipv6mr_multiaddr
,
&
(((
struct
sockaddr_in6
*
)
addr
)
->
sin6_addr
),
sizeof
(
struct
in6_addr
));
if
(
interface
<
0
){
mreq6
.
ipv6mr_interface
=
0
;
memcpy
(
&
mreq6
.
ipv6mr_multiaddr
,
&
(((
struct
sockaddr_in6
*
)
addr
)
->
sin6_addr
),
sizeof
(
struct
in6_addr
));
if
(
interface
<
0
){
mreq6
.
ipv6mr_interface
=
0
;
RUDEBUG7
(
"joinGroup: using default interface
\n
"
);
}
else
{
mreq6
.
ipv6mr_interface
=
interface
;
}
else
{
mreq6
.
ipv6mr_interface
=
interface
;
RUDEBUG7
(
"joinGroup: using interface with index: %d
\n
"
,
interface
);
}
}
r1
=
setsockopt
(
sockfd
,
IPPROTO_IPV6
,
IPV6_MULTICAST_LOOP
,
&
loopBack
,
sizeof
(
loopBack
));
if
(
r1
<
0
)
RUDEBUG1
(
"joinGroup(): IPV6_MULTICAST_LOOP error"
);
r1
=
setsockopt
(
sockfd
,
IPPROTO_IPV6
,
IPV6_MULTICAST_LOOP
,
&
loopBack
,
sizeof
(
loopBack
));
if
(
r1
<
0
)
RUDEBUG1
(
"joinGroup(): IPV6_MULTICAST_LOOP error"
);
r2
=
setsockopt
(
sockfd
,
IPPROTO_IPV6
,
IPV6_MULTICAST_HOPS
,
&
mcastTTL
,
sizeof
(
mcastTTL
));
if
(
r2
<
0
)
RUDEBUG1
(
"joinGroup() IPV6_MULTICAST_HOPS error "
);
r2
=
setsockopt
(
sockfd
,
IPPROTO_IPV6
,
IPV6_MULTICAST_HOPS
,
&
mcastTTL
,
sizeof
(
mcastTTL
));
if
(
r2
<
0
)
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));
if
(
r3
<
0
)
RUDEBUG1
(
"joinGroup() IPV6_JOIN_GROUP error "
);
if
(
r3
<
0
)
RUDEBUG1
(
"joinGroup() IPV6_JOIN_GROUP error "
);
}
break
;
}
break
;
default:
r1
=
r2
=
r3
=-
1
;
}
default:
r1
=
r2
=
r3
=-
1
;
}
if
((
r1
>=
0
)
&&
(
r2
>=
0
)
&&
(
r3
>=
0
))
retval
=
0
;
if
((
r1
>=
0
)
&&
(
r2
>=
0
)
&&
(
r3
>=
0
))
retval
=
0
;
return
retval
;
return
retval
;
}
rude/flow_cntl.c
View file @
3c9083ff
...
...
@@ -45,43 +45,43 @@ extern struct flow_cfg *done;
*/
static
int
remove_flow
(
struct
flow_cfg
*
to_remove
)
{
struct
flow_cfg
*
flow
=
head
;
struct
flow_cfg
*
prev
=
NULL
;
/* Look up the "to_remove" and the previous flow object. */
/* Check the results for possible "overflow" error(s). */
while
((
flow
!=
to_remove
)
&&
(
flow
!=
NULL
)){
prev
=
flow
;
flow
=
flow
->
next
;
}
if
(
flow
==
NULL
){
RUDEBUG1
(
"remove_flow(): flow to remove was not found!
\n
"
);
return
0
;
}
/* Initialize the next block for this flow - if any */
if
((
flow
=
to_remove
->
mod_flow
)
!=
NULL
){
flow
->
next
=
to_remove
->
next
;
flow
->
send_sock
=
to_remove
->
send_sock
;
flow
->
sequence_nmbr
=
to_remove
->
sequence_nmbr
;
}
else
{
if
(
to_remove
->
send_sock
>
0
){
close
(
to_remove
->
send_sock
);
}
to_remove
->
send_sock
=
0
;
flow
=
to_remove
->
next
;
}
/* Unlink the object "to_remove" from the active list */
if
(
prev
==
NULL
){
head
=
flow
;
}
else
{
prev
->
next
=
flow
;
}
/* Link the object to the "done" list and return SUCCESS */
/* FIXME: to_remove->mod_flow = NULL; ???? */
to_remove
->
next
=
done
;
done
=
to_remove
;
RUDEBUG7
(
"remove_flow(): block removed from flow id=%ld
\n
"
,
done
->
flow_id
);
return
1
;
struct
flow_cfg
*
flow
=
head
;
struct
flow_cfg
*
prev
=
NULL
;
/* Look up the "to_remove" and the previous flow object. */
/* Check the results for possible "overflow" error(s). */
while
((
flow
!=
to_remove
)
&&
(
flow
!=
NULL
)){
prev
=
flow
;
flow
=
flow
->
next
;
}
if
(
flow
==
NULL
){
RUDEBUG1
(
"remove_flow(): flow to remove was not found!
\n
"
);
return
0
;
}
/* Initialize the next block for this flow - if any */
if
((
flow
=
to_remove
->
mod_flow
)
!=
NULL
){
flow
->
next
=
to_remove
->
next
;
flow
->
send_sock
=
to_remove
->
send_sock
;
flow
->
sequence_nmbr
=
to_remove
->
sequence_nmbr
;
}
else
{
if
(
to_remove
->
send_sock
>
0
){
close
(
to_remove
->
send_sock
);
}
to_remove
->
send_sock
=
0
;
flow
=
to_remove
->
next
;
}
/* Unlink the object "to_remove" from the active list */
if
(
prev
==
NULL
){
head
=
flow
;
}
else
{
prev
->
next
=
flow
;
}
/* Link the object to the "done" list and return SUCCESS */
/* FIXME: to_remove->mod_flow = NULL; ???? */
to_remove
->
next
=
done
;
done
=
to_remove
;
RUDEBUG7
(
"remove_flow(): block removed from flow id=%ld
\n
"
,
done
->
flow_id
);
return
1
;
}
/* remove_flow() */
...
...
@@ -92,37 +92,37 @@ static int remove_flow(struct flow_cfg *to_remove)
* list.
*/
struct
flow_cfg
*
find_next
(
void
)
{
struct
flow_cfg
*
flow
=
head
;
struct
flow_cfg
*
prev
=
NULL
;
struct
flow_cfg
*
target
=
NULL
;
struct
timeval
now
;
/* Get the current time */
gettimeofday
(
&
now
,
NULL
);
/* Find the next flow from which should send the packet */
while
(
flow
){
/* Remove the flows that are already "done". The remove_flow() */
/* function modifies the active and passive lists (pointed by */
/* head and done respectively)... */
if
(
timercmp
(
&
flow
->
flow_stop
,
&
now
,
<
)
||
timercmp
(
&
flow
->
next_tx
,
&
flow
->
flow_stop
,
>
)){
remove_flow
(
flow
);
if
(
prev
!=
NULL
){
flow
=
prev
->
next
;
}
else
{
flow
=
head
;
}
continue
;
}
/* Mark the current flow as target, if certain conditions are met... */
if
((
target
==
NULL
)
||
(
timercmp
(
&
flow
->
next_tx
,
&
target
->
next_tx
,
<
))){
target
=
flow
;
}
prev
=
flow
;
flow
=
flow
->
next
;
}
return
target
;
{
struct
flow_cfg
*
flow
=
head
;
struct
flow_cfg
*
prev
=
NULL
;
struct
flow_cfg
*
target
=
NULL
;
struct
timeval
now
;
/* Get the current time */
gettimeofday
(
&
now
,
NULL
);
/* Find the next flow from which should send the packet */
while
(
flow
){
/* Remove the flows that are already "done". The remove_flow() */
/* function modifies the active and passive lists (pointed by */
/* head and done respectively)... */
if
(
timercmp
(
&
flow
->
flow_stop
,
&
now
,
<
)
||
timercmp
(
&
flow
->
next_tx
,
&
flow
->
flow_stop
,
>
)){
remove_flow
(
flow
);
if
(
prev
!=
NULL
){
flow
=
prev
->
next
;
}
else
{
flow
=
head
;
}
continue
;
}
/* Mark the current flow as target, if certain conditions are met... */
if
((
target
==
NULL
)
||
(
timercmp
(
&
flow
->
next_tx
,
&
target
->
next_tx
,
<
))){
target
=
flow
;
}
prev
=
flow
;
flow
=
flow
->
next
;
}
return
target
;
}
/* find_next() */
...
...
@@ -132,57 +132,57 @@ struct flow_cfg *find_next(void)
* attention if one adds new flow types to this program...
*/
void
clean_up
(
void
)
{
struct
flow_cfg
*
tmp1
;
/*
* Clear the active flow list
*/
while
((
tmp1
=
head
)
!=
NULL
){
/* Close the open connections (if any) */
if
(
head
->
send_sock
>
0
){
close
(
head
->
send_sock
);
head
->
send_sock
=
0
;
}
/* Unlink this flow and update the pointers before destruction */
if
(
head
->
mod_flow
!=
NULL
){
head
=
head
->
mod_flow
;
head
->
next
=
tmp1
->
next
;
}
else
{
head
=
head
->
next
;
}
/*** DO THE EXTRA CLEAN-UP HERE ***/
if
(
tmp1
->
params
.
ftype
==
TRACE
){
free
(
tmp1
->
params
.
trace
.
list
);
}
/*** DO THE EXTRA CLEAN-UP HERE ***/
/* Clean up the rest of this block/flow */
free
(
tmp1
);
}
/*
* Clear the passive (already done) list
*/
while
((
tmp1
=
done
)
!=
NULL
){
/* Unlink the block from the list */
done
=
done
->
next
;
/*** DO THE EXTRA CLEAN-UP HERE ***/
if
(
tmp1
->
params
.
ftype
==
TRACE
){
free
(
tmp1
->
params
.
trace
.
list
);
}
/*** DO THE EXTRA CLEAN-UP HERE ***/
/* Clean up the rest of this block/flow */
free
(
tmp1
);
}
/* Free the globally reserver memory */
free
(
buffer
);
RUDEBUG7
(
"clean_up(): DONE
\n
"
);
return
;
{
struct
flow_cfg
*
tmp1
;
/*
* Clear the active flow list
*/
while
((
tmp1
=
head
)
!=
NULL
){
/* Close the open connections (if any) */
if
(
head
->
send_sock
>
0
){
close
(
head
->
send_sock
);
head
->
send_sock
=
0
;
}
/* Unlink this flow and update the pointers before destruction */
if
(
head
->
mod_flow
!=
NULL
){
head
=
head
->
mod_flow
;