Opened 10 years ago

Closed 10 years ago

#314 closed defect (fixed)

PATCH for trace_get_payload_from_ip6() doesn't get extension header length correctly

Reported by: Rong Zheng Owned by: salcock
Priority: major Milestone: libtrace3
Component: libtrace-library Version: 3.0
Keywords: ipv6 header_length Cc:

Description

The length of extension header field is defined in RFC as follows, take Hop-by-Hop header for example: 8-bit unsigned integer. Length of the Hop-by-Hop Options header in 8-octet units, not including the first 8 octets.

So the len filed in libtrace_ip6_ext_t should be: len=(((libtrace_ip6_ext_t*)payload)->len + 1) * 8;

I have attached a ipv6 packet(pcap file) within two extension headers for testing.

diff -Nur ./lib/protocols_l3.c ../libtrace-3.0.11_rong/lib/protocols_l3.c
--- ./lib/protocols_l3.c	2011-07-11 21:19:47.000000000 +0800
+++ ../libtrace-3.0.11_rong/lib/protocols_l3.c	2011-07-11 21:14:47.000000000 +0800
@@ -156,12 +156,10 @@
 		switch (nxt) {
 			case 0: /* hop by hop options */
 			case TRACE_IPPROTO_ROUTING:
-			case TRACE_IPPROTO_ESP:
 			case TRACE_IPPROTO_AH: 
 			case TRACE_IPPROTO_DSTOPTS: 
 				{
-					len=((libtrace_ip6_ext_t*)payload)->len
-					+sizeof(libtrace_ip6_ext_t);
+					len=(((libtrace_ip6_ext_t*)payload)->len + 1) * 8;
 
 					if (remaining) {
 						if (*remaining < len) {
@@ -191,7 +189,11 @@
 					payload=(char*)payload+len;
 					continue;
 				}
-
+			case TRACE_IPPROTO_ESP:
+				{
+					if (prot) *prot=TRACE_IPPROTO_ESP;	//the remain part of this packet is encrypted
+					return payload;
+				}
 			default:
 				if (prot) *prot=nxt;
 				return payload;

Attachments (1)

exheaders_16.pcap (140 bytes) - added by Rong Zheng <jeromezhr@…> 10 years ago.

Download all attachments as: .zip

Change History (2)

Changed 10 years ago by Rong Zheng <jeromezhr@…>

comment:1 Changed 10 years ago by salcock

  • Resolution set to fixed
  • Status changed from new to closed

Fixed in r1712 - thanks for reporting this.

Note: See TracTickets for help on using tickets.