Update struct ws_ip with flow label and comments

Change field ip_v_hl to version.

Change-Id: Ic7ce8d6d083f6413284a7b9ba91a2387b11b29fb
Reviewed-on: https://code.wireshark.org/review/16555
Petri-Dish: João Valverde <j@v6e.pt>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: João Valverde <j@v6e.pt>
This commit is contained in:
João Valverde 2016-07-19 22:06:31 +01:00 committed by João Valverde
parent c11cdd6493
commit 904d9fc2c3
5 changed files with 23 additions and 20 deletions

View File

@ -2014,20 +2014,20 @@ dissect_ip_v4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void*
col_set_str(pinfo->cinfo, COL_PROTOCOL, "IPv4");
col_clear(pinfo->cinfo, COL_INFO);
iph->ip_v_hl = tvb_get_guint8(tvb, offset);
iph->ip_ver = tvb_get_bits8(tvb, 0, 4);
hlen = lo_nibble(iph->ip_v_hl) * 4; /* IP header length, in bytes */
hlen = tvb_get_bits8(tvb, 4, 4) * 4; /* IP header length, in bytes */
ti = proto_tree_add_item(tree, proto_ip, tvb, offset, hlen, ENC_NA);
ip_tree = proto_item_add_subtree(ti, ett_ip);
tf = proto_tree_add_item(ip_tree, hf_ip_version, tvb, offset, 1, ENC_NA);
if (hi_nibble(iph->ip_v_hl) != 4) {
if (iph->ip_ver != 4) {
col_add_fstr(pinfo->cinfo, COL_INFO,
"Bogus IPv4 version (%u, must be 4)", hi_nibble(iph->ip_v_hl));
"Bogus IPv4 version (%u, must be 4)", iph->ip_ver);
expert_add_info_format(pinfo, tf, &ei_ip_bogus_ip_version, "Bogus IPv4 version");
/* I have a Linux cooked capture with ethertype IPv4 containing an IPv6 packet, continnue dissection in that case*/
if (hi_nibble(iph->ip_v_hl) == 6) {
if (iph->ip_ver == 6) {
call_dissector(ipv6_handle, tvb, pinfo, tree);
}

View File

@ -30,16 +30,17 @@ extern int proto_ip;
typedef struct _ws_ip
{
guint8 ip_v_hl; /* combines ip_v and ip_hl */
guint8 ip_tos;
guint32 ip_len;
guint16 ip_id;
guint16 ip_off;
guint8 ip_ttl;
guint8 ip_nxt; /* IPv4: protocol; IPv6: next header */
guint16 ip_sum;
address ip_src;
address ip_dst;
guint8 ip_ver; /* 4 or 6 */
guint8 ip_tos; /* IPv4: type of service; IPv6: traffic class */
guint32 ip_flw; /* IPv4: (zero); IPv6: flow label */
guint32 ip_len; /* IPv4: total length; IPv6: payload length (minus extensions) */
guint16 ip_id; /* IPv4: identification; IPv6: (zero) */
guint16 ip_off; /* IPv4: fragment offset; IPv6: (zero) */
guint8 ip_ttl; /* IPv4: time-to-live; IPv6: hop limit */
guint8 ip_nxt; /* IPv4: protocol; IPv6: next header */
guint16 ip_sum; /* IPv4: checksum; IPv6: (zero) */
address ip_src; /* source address */
address ip_dst; /* destination address */
} ws_ip;
/* Differentiated Services Codepoint */

View File

@ -318,6 +318,7 @@ static expert_field ei_ipv6_invalid_header = EI_INIT;
#define IPv6_HDR_VERS(ipv6) (((*(guint8 *)(ipv6)) >> 4) & 0x0f)
#define IPv6_HDR_TCLS(ipv6) _ipv6_hdr_tcls(ipv6)
#define IPv6_HDR_FLOW(ipv6) (g_ntohl((ipv6)->ip6_ctl_flow) & 0x000fffff)
#define TVB_IPv6_HDR_VERS(tvb, offset) tvb_get_bits8(tvb, (offset) * 8, 4)
#define TVB_IPv6_HDR_TCLS(tvb, offset) tvb_get_bits8(tvb, (offset) * 8 + 4, 8)
@ -2162,8 +2163,9 @@ dissect_ipv6(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_
/* Fill in IP header fields for subdissectors */
iph = wmem_new0(wmem_packet_scope(), ws_ip);
iph->ip_v_hl = IPv6_HDR_VERS(ipv6);
iph->ip_ver = 6;
iph->ip_tos = IPv6_HDR_TCLS(ipv6);
iph->ip_flw = IPv6_HDR_FLOW(ipv6);
iph->ip_len = g_ntohs(ipv6->ip6_plen);
iph->ip_nxt = ipv6->ip6_nxt;
iph->ip_ttl = ipv6->ip6_hlim;

View File

@ -49,7 +49,7 @@
/* For checksum */
#define BYTES 8
#define BYTES 12
#define WRONG_CHKSUM 0
#define MERGED_FILES 2
@ -124,7 +124,7 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
}
/* Set up the fields of the pseudo-header and create checksum */
cksum_vec[0].ptr = &ci->ip_v_hl;
cksum_vec[0].ptr = (const guint8 *)&ci;
cksum_vec[0].len = BYTES;
/* skip TTL */
cksum_vec[1].ptr = &ci->ip_nxt;

View File

@ -74,7 +74,7 @@ void register_tap_listener_gtkcomparestat(void);
#define COLOR_N 1
/* For checksum */
#define BYTES 8
#define BYTES 12
#define WRONG_CHKSUM 0
#define MERGED_FILES 2
@ -185,7 +185,7 @@ comparestat_packet(void *arg, packet_info *pinfo, epan_dissect_t *edt _U_, const
}
/* Set up the fields of the pseudo-header and create checksum */
cksum_vec[0].ptr=&ci->ip_v_hl;
cksum_vec[0].ptr=(const guint8 *)&ci;
cksum_vec[0].len=BYTES;
/* skip TTL */
cksum_vec[1].ptr=&ci->ip_nxt;