Ethereal-cvs: [Ethereal-cvs] cvs commit: ethereal/gtk tcp_graph.c

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

From: Guy Harris <guy@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Dec 2001 15:19:13 -0600 (CST)
guy         2001/12/10 15:19:13 CST

  Modified files:
    gtk                  tcp_graph.c 
  Log:
  Get rid of the stuff to use bitfields to dissect IP and TCP headers -
  bitfields are a pain to use when dealing with structures with a fixed
  layout in memory (you have to worry about bit order, for example).
  
  Don't assume that the Ethernet header is aligned on a 2-byte boundary -
  use "pntohs()" to extract stuff from it.  (Perhaps C will force it onto
  a 2-byte boundary, but why take chances, and why leave the code
  vulnerable to changes outside this module?)
  
  Don't assume that the pointers to the IP and TCP headers are nicely
  aligned - use "memcpy()", not structure assignment, to copy the headers.
  (They're probably *not* nicely aligned on platforms that require 4-byte
  alignment of 4-byte integral quantities; the code was dumping core on
  SPARC with an alignment error.)
  
  Don't even make those pointers be pointers to structures, as that may
  cause the C compiler to generate in-line 4-byte loads and stores for
  "memcpy()" (in fact, it *did* do so with GCC 2.95.1 on SPARC), which has
  the same problem as structure assignment.
  
  Don't test the IP protocol number twice when handling PPP.
  
  Revision  Changes    Path
  1.5       +12 -62    ethereal/gtk/tcp_graph.c