Ethereal-dev: [ethereal-dev] Minor bug fix and enhancement [Patch included]
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: Philip Gladstone <philip@xxxxxxxxxx>
Date: Wed, 08 Dec 1999 11:49:08 -0500
Hi, Attached is a minor fix so that the tree view displays nicely with more recent versions of gtk. (to be applied to gtk/main.c) Attached is a minor enhancement to packet-ip.c that tells you whether the IP checksum is correct or incorrect. I added this while trying to track down a bizarre problem that turned out to be that some packets had incorrect checksums! -- Philip Gladstone +1 781 530 2461 Axent Technologies, Waltham, MA
Index: gtk/main.c =================================================================== RCS file: /cvsroot/ethereal/gtk/main.c,v retrieving revision 1.65 diff -u -b -r1.65 main.c --- main.c 1999/12/07 22:59:18 1.65 +++ main.c 1999/12/08 16:46:30 @@ -1262,7 +1262,7 @@ gtk_tree_set_selection_mode(GTK_TREE(tree_view), GTK_SELECTION_SINGLE); /* XXX - what's the difference between the next two lines? */ - gtk_tree_set_view_lines(GTK_TREE(tree_view), FALSE); + gtk_tree_set_view_lines(GTK_TREE(tree_view), TRUE); gtk_tree_set_view_mode(GTK_TREE(tree_view), GTK_TREE_VIEW_ITEM); gtk_signal_connect(GTK_OBJECT(tree_view), "selection_changed",
Index: packet-ip.c =================================================================== RCS file: /cvsroot/ethereal/packet-ip.c,v retrieving revision 1.64 diff -u -b -r1.64 packet-ip.c --- packet-ip.c 1999/11/21 14:43:52 1.64 +++ packet-ip.c 1999/12/08 16:46:16 @@ -749,6 +749,26 @@ "Not set" }; +static char *ip_checksum_state(e_ip *iph) +{ + unsigned long Sum; + unsigned short *Ptr, *PtrEnd; + + Sum = 0; + PtrEnd = (unsigned short *) (lo_nibble(iph->ip_v_hl) * 4 + (char *)iph); + for (Ptr = (unsigned short *) iph; Ptr < PtrEnd; Ptr++) { + Sum += *Ptr; + } + + Sum = (Sum & 0xFFFF) + (Sum >> 16); + Sum = (Sum & 0xFFFF) + (Sum >> 16); + + if (Sum != 0xffff) + return "incorrect"; + + return "correct"; +} + void dissect_ip(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) { e_ip iph; @@ -864,7 +884,8 @@ proto_tree_add_item(ip_tree, hf_ip_ttl, offset + 8, 1, iph.ip_ttl); proto_tree_add_item_format(ip_tree, hf_ip_proto, offset + 9, 1, iph.ip_p, "Protocol: %s (0x%02x)", ipprotostr(iph.ip_p), iph.ip_p); - proto_tree_add_item(ip_tree, hf_ip_checksum, offset + 10, 2, iph.ip_sum); + proto_tree_add_item_format(ip_tree, hf_ip_checksum, offset + 10, 2, iph.ip_sum, + "Header checksum: 0x%04x (%s)", iph.ip_sum, ip_checksum_state((e_ip*) &pd[offset])); proto_tree_add_item(ip_tree, hf_ip_src, offset + 12, 4, iph.ip_src); proto_tree_add_item(ip_tree, hf_ip_dst, offset + 16, 4, iph.ip_dst); proto_tree_add_item_hidden(ip_tree, hf_ip_addr, offset + 12, 4, iph.ip_src);
- Prev by Date: [ethereal-dev] small buglet
- Next by Date: Re: [ethereal-dev] Minor bug fix and enhancement [Patch included]
- Previous by thread: [ethereal-dev] small buglet
- Next by thread: Re: [ethereal-dev] Minor bug fix and enhancement [Patch included]
- Index(es):
- Get Wireshark
- Download
- Code of Conduct