Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
R
rude
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
rude
rude
Commits
78a4aaa3
Commit
78a4aaa3
authored
Jan 26, 2015
by
yorn
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Read hoplimit for IPv6 packets
parent
b4670094
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
4 deletions
+22
-4
crude/main.c
crude/main.c
+21
-3
include/rude.h
include/rude.h
+1
-1
No files found.
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
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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