Ethereal-dev: Re: [Ethereal-dev] IP defragment

Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.

From: Guy Harris <gharris@xxxxxxxxxxxx>
Date: Tue, 17 Apr 2001 21:57:56 -0700
On Tue, Apr 17, 2001 at 05:55:48PM -0700, Guy Harris wrote:
> > Most noticeable in the gui is that the subtree for fragments has been
> > changed slightly.
> > A few other small fixes.
> 
> Here's a patch to bring it up to the current CVS version (1.130), fix
> some comments (the checksum being computed by the "ip_checksum()" call
> is the checksum of the header, not the entire packet) and fix a typo in
> a blurb for a field.

Checked in.

There was another fix to be added - the check for a valid checksum and a
non-truncated frame should be

    if ((ipsum==0) && (tvb_reported_length(tvb) <= tvb_length(tvb))) {

not

    if ((ipsum==0) || (tvb_reported_length(tvb)!=tvb_length(tvb))) {

(it should be an "and", not an "or", and the frame is non-truncated as
long as the reported length is <= the captured length).

I've attached a patch that's the result of a "diff -c" between your most
recently sent version and the checked-in version (although, as a
developer, you should be using anonymous CVS, unless you're behind a
firewall that prevents that, in which case you should be downloading the
nightly snapshots).
*** /tmp/packet-ip.c	Tue Apr 17 21:53:53 2001
--- ./packet-ip.c	Tue Apr 17 21:53:51 2001
***************
*** 1,7 ****
  /* packet-ip.c
   * Routines for IP and miscellaneous IP protocol packet disassembly
   *
!  * $Id: packet-ip.c,v 1.129 2001/03/28 21:33:31 guy Exp $
   *
   * Ethereal - Network traffic analyzer
   * By Gerald Combs <gerald@xxxxxxxx>
--- 1,7 ----
  /* packet-ip.c
   * Routines for IP and miscellaneous IP protocol packet disassembly
   *
!  * $Id: packet-ip.c,v 1.131 2001/04/18 04:53:51 guy Exp $
   *
   * Ethereal - Network traffic analyzer
   * By Gerald Combs <gerald@xxxxxxxx>
***************
*** 45,50 ****
--- 45,51 ----
  
  #include "packet.h"
  #include "resolv.h"
+ #include "ipproto.h"
  #include "prefs.h"
  #include "etypes.h"
  #include "greproto.h"
***************
*** 1190,1196 ****
    }
  
    /*
!    * Compute the checksum of the IP packet
     */
    ipsum = ip_checksum(tvb_get_ptr(tvb, offset, hlen), hlen);
  
--- 1191,1197 ----
    }
  
    /*
!    * Compute the checksum of the IP header.
     */
    ipsum = ip_checksum(tvb_get_ptr(tvb, offset, hlen), hlen);
  
***************
*** 1287,1294 ****
    if (ip_defragment && (iph.ip_off & (IP_MF|IP_OFFSET))) {
      /* We're reassembling, and this is part of a fragmented datagram.
         Add the fragment to the hash table if the checksum is ok
!        and the frame isnt truncated. */
!     if ((ipsum==0) || (tvb_reported_length(tvb)!=tvb_length(tvb))) {
        ipfd_head = ip_fragment_add(tvb, offset, pinfo, iph.ip_id, iph.ip_off);
      } else {
        ipfd_head=NULL;
--- 1288,1295 ----
    if (ip_defragment && (iph.ip_off & (IP_MF|IP_OFFSET))) {
      /* We're reassembling, and this is part of a fragmented datagram.
         Add the fragment to the hash table if the checksum is ok
!        and the frame isn't truncated. */
!     if ((ipsum==0) && (tvb_reported_length(tvb) <= tvb_length(tvb))) {
        ipfd_head = ip_fragment_add(tvb, offset, pinfo, iph.ip_id, iph.ip_off);
      } else {
        ipfd_head=NULL;
***************
*** 1941,1947 ****
  
  		{ &hf_ip_fragment_overlap_conflict,
  		{ "Conflicting data in fragment overlap",	"ip.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
! 			"Overlaping fragments contained conflicting data" }},
  
  		{ &hf_ip_fragment_multiple_tails,
  		{ "Multiple tail fragments found",	"ip.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
--- 1942,1948 ----
  
  		{ &hf_ip_fragment_overlap_conflict,
  		{ "Conflicting data in fragment overlap",	"ip.fragment.overlap.conflict", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
! 			"Overlapping fragments contained conflicting data" }},
  
  		{ &hf_ip_fragment_multiple_tails,
  		{ "Multiple tail fragments found",	"ip.fragment.multipletails", FT_BOOLEAN, BASE_NONE, NULL, 0x0,
***************
*** 2050,2053 ****
  {
    dissector_add("ip.proto", IP_PROTO_ICMP, dissect_icmp, proto_icmp);
  }
- 
--- 2051,2053 ----