Logo Search packages:      
Sourcecode: paris-traceroute version File versions  Download package

IP4Header::IP4Header ( const uint8 *  data,
int  length,
int  offset 
)

Create a new IPv4 header and initialize it with 20 bytes of data array beginning at offset offset.

Definition at line 30 of file IP4Header.cc.

                                                               {
  const uint8* ptr = data + offset;
  // 'Version' field
  if ((ptr[0] & 0xf0) != 0x40)
    throw TrException(str_log(ERROR, "Bad IP version"));

  // 'Header length' field
  if ((ptr[0] & 0x0f) != 0x05) {
    printf("ihl=%d\n", (ptr[0] & 0x0f));
    dumpRawData(WARN, (uint8 *)ptr, length);
  
    /*throw TrException(str_log(ERROR,
      "IP4Header doesn't support IP options yet"));*/
  }
  
  // Initialize the header field
  header_len = (ptr[0] & 0x0f) << 2;
  header = new uint8[header_len];
  memcpy(header, ptr, header_len);
}


Generated by  Doxygen 1.6.0   Back to index