- Timestamp:
- 03/07/05 16:52:29 (16 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:
- 3a3aa23
- Parents:
- dcc1343
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/protocol/protocol.c
rb535184 r5ed52b8 89 89 90 90 int do_cksum = 0; 91 int loop = 0; 91 92 int do_w_cksum = 0; 92 93 uint64_t rxerr = 0; … … 103 104 parse_cmdline(argc,argv); 104 105 105 trace = trace_create(uri); 106 if (filterstring) {107 filter = trace_bpf_setfilter(filterstring);108 } 109 110 for (;;) { 111 if ((psize = trace_read_packet(trace, &packet)) <= 0) {112 // terminate 113 break; 114 } 115 116 if (filter) {117 if (!trace_bpf_filter(filter,&packet)) {118 continue;106 if (!uri) { 107 printf("Incorrect usage: need a URI\n"); 108 usage(argv[0]); 109 } 110 do { 111 trace = trace_create(uri); 112 if (filterstring) { 113 filter = trace_bpf_setfilter(filterstring); 114 } 115 116 for (;;) { 117 if ((psize = trace_read_packet(trace, &packet)) <= 0) { 118 // terminate 119 break; 119 120 } 120 } 121 ipptr = trace_get_ip(&packet); 122 123 if (ipptr) { 124 if(do_cksum && IN_CHKSUM(ipptr)) { 125 badchksum ++; 126 } else if (do_w_cksum && ipptr->ip_sum) { 127 badchksum ++; 128 } else { 129 printf("%d:%d\n",ipptr->ip_p,trace_get_link_type(&packet)); 121 122 if (filter) { 123 if (!trace_bpf_filter(filter,&packet)) { 124 continue; 125 } 130 126 } 131 } 132 } 133 if (do_cksum || do_w_cksum) { 134 printf("Bad checksums seen: %llu\n",badchksum); 135 printf("RX Errors seen: %llu\n",rxerr); 136 } 137 trace_destroy(trace); 127 ipptr = trace_get_ip(&packet); 128 129 if (ipptr) { 130 if(do_cksum && IN_CHKSUM(ipptr)) { 131 badchksum ++; 132 } else if (do_w_cksum && ipptr->ip_sum) { 133 badchksum ++; 134 } else { 135 printf("%d:%d\n",ipptr->ip_p,trace_get_link_type(&packet)); 136 } 137 } 138 } 139 if (do_cksum || do_w_cksum) { 140 printf("Bad checksums seen: %llu\n",badchksum); 141 printf("RX Errors seen: %llu\n",rxerr); 142 } 143 trace_destroy(trace); 144 } while (loop); 138 145 return 0; 139 146 } … … 147 154 printf(" -u uri uri to connect to\n"); 148 155 printf(" -f filterstring BPF filterstring to apply\n"); 156 printf(" -l loop the input\n"); 149 157 printf("\n"); 150 158 printf(" The use of -c and -w are exclusive: -c is used for normal traces, while -w applies to traces taken from the Waikato Capture point\n"); … … 158 166 } 159 167 160 while ((opt = getopt(argc,argv, "hcwu:f: ")) != EOF) {168 while ((opt = getopt(argc,argv, "hcwu:f:l")) != EOF) { 161 169 switch(opt) { 162 170 case 'h': … … 175 183 filterstring = strdup(optarg); 176 184 break; 185 case 'l': 186 loop = 1; 187 break; 177 188 default: 178 189 usage(argv[0]);
Note: See TracChangeset
for help on using the changeset viewer.