Changeset ff7d949 for tools/tracereplay
- Timestamp:
- 11/23/09 14:08:03 (13 years ago)
- 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:
- 43351e9
- Parents:
- c988da9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/tracereplay/tracereplay.c
rc988da9 rff7d949 29 29 /* This function assumes that the relevant fields have been zeroed out. RFC 1071*/ 30 30 static uint16_t checksum(void * buffer, uint16_t length) { 31 //printf("length: %d\n",length);32 31 uint32_t sum = 0; 33 32 uint16_t * buff = (uint16_t *) buffer; 34 uint16_t i; 35 uint16_t result; 36 37 for (i=0;i<length;i=i+2) { 38 sum += ~ntohs(buff[i]); 39 } 40 41 result = sum; 42 result += sum >> 16; 33 uint16_t count = length; 34 35 while(count > 1 ) { 36 sum += *buff++; 37 count = count -2; 38 } 39 40 if(count > 0) { 41 sum += buff; 42 } 43 44 while (sum>>16) 45 sum = (sum & 0xffff) + (sum >> 16); 43 46 44 47 return ~sum; 48 } 49 50 static uint16_t udp_tcp_checksum(libtrace_packet_t *packet) { 51 52 uint32_t sum; 53 54 55 45 56 } 46 57 … … 67 78 if(header != NULL) { 68 79 header -> ip_sum = 0; 69 header -> ip_sum = htons(checksum(header,header->ip_hl*4));80 header -> ip_sum = checksum(header,header->ip_hl*sizeof(uint32_t)); 70 81 } 71 82 … … 132 143 } 133 144 145 /* int main(int argc, char *argv[]) { */ 146 147 /* /\* uint16_t buffer[] = {0x45,0x00,0x00,0x30, */ 148 /* 0x3b,0xa9,0x40,0x00, */ 149 /* 0x6e,0x06,0x44,0x5b, */ 150 /* 0x25,0xdb,0xef,0x28, */ 151 /* 0x7d,0xb6,0x6a,0xb1 */ 152 /* };*\/ */ 153 154 /* uint8_t buffer[] = {0x00,0x01, */ 155 /* 0xf2,0x03, */ 156 /* 0xf4,0xf5, */ 157 /* 0xf6,0xf7 */ 158 /* }; */ 159 160 /* uint16_t checksum = ip_checksum(buffer,8); */ 161 162 /* printf("checksum: %04X\n",checksum); */ 163 164 /* } */ 165 166 134 167 int main(int argc, char *argv[]) { 135 168 … … 243 276 244 277 } 278
Note: See TracChangeset
for help on using the changeset viewer.