Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
rude
rude
Commits
78a4aaa3
Commit
78a4aaa3
authored
Jan 26, 2015
by
yorn
Browse files
Read hoplimit for IPv6 packets
parent
b4670094
Changes
2
Hide whitespace changes
Inline
Side-by-side
crude/main.c
View file @
78a4aaa3
...
...
@@ -940,6 +940,7 @@ static int rec_n_print(unsigned short port, unsigned long limit)
ssize_t
rec_bytes
=
0
;
/* Bytes read */
int
src_len
=
sizeof
(
struct
sockaddr_storage
);
int
ttl
=
64
;
int
hoplimit
=
64
;
int
received_ttl
;
struct
sockaddr_storage
src_addr
;
struct
msghdr
msgh
;
...
...
@@ -969,7 +970,11 @@ static int rec_n_print(unsigned short port, unsigned long limit)
if
(
setsockopt
(
main_socket
,
IPPROTO_IP
,
IP_RECVTTL
,
&
ttl
,
sizeof
(
ttl
))
>
0
)
{
RUDEBUG1
(
"crude: unable to receive TTL values: %s
\n
"
,
strerror
(
errno
));
RUDEBUG1
(
"crude: unable to receive TTL values for IPv4: %s
\n
"
,
strerror
(
errno
));
}
if
(
setsockopt
(
main_socket
,
IPPROTO_IPV6
,
IPV6_RECVHOPLIMIT
,
&
hoplimit
,
sizeof
(
hoplimit
))
>
0
)
{
RUDEBUG1
(
"crude: unable to receive HOPLIMIT values for IPv6: %s
\n
"
,
strerror
(
errno
));
}
for
(
;
;
)
{
...
...
@@ -985,7 +990,20 @@ static int rec_n_print(unsigned short port, unsigned long limit)
received_ttl
=
-
1
;
for
(
cmsg
=
CMSG_FIRSTHDR
(
&
msgh
);
cmsg
!=
NULL
;
cmsg
=
CMSG_NXTHDR
(
&
msgh
,
cmsg
))
{
if
((
cmsg
->
cmsg_level
==
IPPROTO_IP
)
&&
(
cmsg
->
cmsg_type
==
IP_TTL
)
&&
if
((
(
(
cmsg
->
cmsg_level
==
IPPROTO_IP
)
&&
(
cmsg
->
cmsg_type
==
IP_TTL
)
)
||
(
(
cmsg
->
cmsg_level
==
SOL_IPV6
)
&&
(
cmsg
->
cmsg_type
==
IPV6_HOPLIMIT
))
)
&&
(
cmsg
->
cmsg_len
)
){
ttlptr
=
(
int
*
)
CMSG_DATA
(
cmsg
);
received_ttl
=
*
ttlptr
;
break
;
}
if
((
cmsg
->
cmsg_level
==
SOL_IPV6
)
&&
(
cmsg
->
cmsg_type
==
IPV6_HOPLIMIT
)
&&
(
cmsg
->
cmsg_len
)
){
ttlptr
=
(
int
*
)
CMSG_DATA
(
cmsg
);
received_ttl
=
*
ttlptr
;
...
...
@@ -1001,7 +1019,7 @@ static int rec_n_print(unsigned short port, unsigned long limit)
get_str_addr
(
d_add
,
str2
);
printf
(
"ID=%lu SEQ=%lu SRC=%s:%hu DST=%s:%hu "
"Tx=%lu.%06lu Rx=%ld.%06ld
TTL
=%d SIZE=%ld
\n
"
,
"Tx=%lu.%06lu Rx=%ld.%06ld
HOPLIMIT
=%d SIZE=%ld
\n
"
,
(
unsigned
long
)
ntohl
(
udp_ptr
->
flow_id
),
(
unsigned
long
)
ntohl
(
udp_ptr
->
sequence_number
),
str1
,
ntohs
(((
struct
sockaddr_in
*
)
&
src_addr
)
->
sin_port
),
str2
,
port
,
...
...
include/rude.h
View file @
78a4aaa3
...
...
@@ -35,7 +35,7 @@
#define PMAXSIZE 32768
/* Maximum accepted UDP-data field/packet size */
#define MINDURAT 0.001
/* Minimum allowed flow duration in seconds (float) */
#define VERSION "0.8.
3
"
#define VERSION "0.8.
4
"
/*
* Enumeration definition for different (known) flow types
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment