Changeset c8e8122


Ignore:
Timestamp:
11/22/09 00:56:10 (12 years ago)
Author:
Andreas Löf <andreas.lof@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
c988da9
Parents:
47a5c5e
Message:

added a function to calculate checksums

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracereplay/tracereplay.c

    r47a5c5e rc8e8122  
    2424#include <getopt.h>
    2525
     26#define FCS_SIZE 4
     27
    2628static libtrace_packet_t * per_packet(libtrace_packet_t *packet) {
    2729 
     
    3335  size_t wire_length = trace_get_wire_length(packet);
    3436
     37  if(linktype == TRACE_TYPE_ETH || linktype == TRACE_TYPE_80211) {
     38    wire_length -= FCS_SIZE;
     39  }
     40
    3541  trace_construct_packet(new_packet,linktype,pkt_buffer,wire_length);
    3642
    3743  return new_packet;
    3844 
     45}
     46
     47
     48/* This function assumes that the relevant fields have been zeroed out */
     49static uint16_t checksum(void * buffer, size_t length) {
     50  uint8_t * data;
     51  int i;
     52  uint16_t result = 0;
     53
     54
     55  data = (uint8_t) buffer;
     56
     57
     58
     59  for(i = 0; i < length; i++) {
     60    result = ~data[i];
     61  }
     62 
     63  return ~result;
     64
    3965}
    4066
Note: See TracChangeset for help on using the changeset viewer.