[flow-tools] byte ordering fix

Mark Fullmer maf@splintered.net
Sun, 19 May 2002 21:23:35 -0400


The following patch fixes a bug when using flow-tools across two
architectures with different byte ordering.  I guess this type of deployment
doesn't show up in practice since the bug has been around for a long
time.

Index: ftio.c
===================================================================
RCS file: /usr/home/djnz-cvsroot/flow-tools/lib/ftio.c,v
retrieving revision 1.36
diff -c -r1.36 ftio.c
*** ftio.c	2 Mar 2002 05:19:15 -0000	1.36
--- ftio.c	15 May 2002 16:34:02 -0000
***************
*** 1449,1455 ****
    ret = -1;
    nbytes = 0;
   
!   if (!ftio->flags & FT_IO_FLAG_NO_SWAP) {
  #if BYTE_ORDER == BIG_ENDIAN
      if (ftio->fth.byte_order == FT_HEADER_LITTLE_ENDIAN)
        ftio->swapf((void*)data);
--- 1449,1455 ----
    ret = -1;
    nbytes = 0;
   
!   if (!(ftio->flags & FT_IO_FLAG_NO_SWAP)) {
  #if BYTE_ORDER == BIG_ENDIAN
      if (ftio->fth.byte_order == FT_HEADER_LITTLE_ENDIAN)
        ftio->swapf((void*)data);
***************
*** 1540,1546 ****
  
  ftio_write_out:
  
!   if (!ftio->flags & FT_IO_FLAG_NO_SWAP) {
  #if BYTE_ORDER == BIG_ENDIAN
      if (ftio->fth.byte_order == FT_HEADER_LITTLE_ENDIAN)
        ftio->swapf((void*)data);
--- 1540,1546 ----
  
  ftio_write_out:
  
!   if (!(ftio->flags & FT_IO_FLAG_NO_SWAP)) {
  #if BYTE_ORDER == BIG_ENDIAN
      if (ftio->fth.byte_order == FT_HEADER_LITTLE_ENDIAN)
        ftio->swapf((void*)data);
***************
*** 2471,2483 ****
  
          case FT_TLV_AGG_VER:
            bcopy(tlv.v, &ihead->agg_version, 1);
-           if (flip) SWAPINT16(ihead->agg_version);
            ihead->fields |= FT_FIELD_AGG_VER;
            break;
  
          case FT_TLV_AGG_METHOD:
            bcopy(tlv.v, &ihead->agg_method, 1);
-           if (flip) SWAPINT16(ihead->agg_method);
            ihead->fields |= FT_FIELD_AGG_METHOD;
            break;
  
--- 2471,2481 ----