Changeset c837874
- Timestamp:
- 07/21/04 11:03:53 (17 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:
- e9f521e
- Parents:
- be54c88
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/protocol/protocol.c
r781cf2c rc837874 41 41 42 42 #include <linux/types.h> 43 #include <linux/linkage.h> 44 #define access_ok(type,addr,size) 1 45 #include <asm/checksum.h> 43 //#include <linux/linkage.h> 44 //#define access_ok(type,addr,size) 1 45 46 static inline unsigned short ip_fast_csum(unsigned char * iph, 47 unsigned int ihl) { 48 unsigned int sum; 49 50 __asm__ __volatile__(" 51 movl (%1), %0 52 subl $4, %2 53 jbe 2f 54 addl 4(%1), %0 55 adcl 8(%1), %0 56 adcl 12(%1), %0 57 1: adcl 16(%1), %0 58 lea 4(%1), %1 59 decl %2 60 jne 1b 61 adcl $0, %0 62 movl %0, %2 63 shrl $16, %0 64 addw %w2, %w0 65 adcl $0, %0 66 notl %0 67 2: 68 " 69 /* Since the input registers which are loaded with iph and ipl 70 are modified, we must also specify them as outputs, or gcc 71 will assume they contain their original values. */ 72 : "=r" (sum), "=r" (iph), "=r" (ihl) 73 : "1" (iph), "2" (ihl)); 74 return(sum); 75 } 76 46 77 #define IN_CHKSUM(IP) ip_fast_csum((unsigned char *)(IP), 5) 78 47 79 48 80 #include "libtrace.h" … … 88 120 ipptr = get_ip(trace,buffer,4096); 89 121 90 if (do_cksum && IN_CHKSUM(ipptr)) {91 badchksum ++;92 } else if (do_w_cksum && ipptr->ip_sum) {93 badchksum ++;94 } else {95 if (ipptr){122 if (ipptr) { 123 if(do_cksum && IN_CHKSUM(ipptr)) { 124 badchksum ++; 125 } else if (do_w_cksum && ipptr->ip_sum) { 126 badchksum ++; 127 } else { 96 128 printf("%d:%d\n",ipptr->ip_p,get_link_type(trace,buffer,4096)); 97 129 }
Note: See TracChangeset
for help on using the changeset viewer.