Commit 78a4aaa3 authored by Jørn Åne de Jong's avatar Jørn Åne de Jong

Read hoplimit for IPv6 packets

parent b4670094
......@@ -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,
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment