|
|
| version 1.2.2.1, 2013/07/01 20:44:09 | version 1.4.12.2, 2016/08/11 16:23:43 |
|---|---|
| Line 1 | Line 1 |
| #ifdef __linux__ | |
| int main() | |
| { | |
| return 0; | |
| } | |
| #else | |
| #include <stdio.h> | #include <stdio.h> |
| #include <stdlib.h> | #include <stdlib.h> |
| #include <fcntl.h> | #include <fcntl.h> |
| Line 61 static void * | Line 68 static void * |
| ShowPkt(void *buffer) | ShowPkt(void *buffer) |
| { | { |
| char Proto = 0, szStr[BUFSIZ], szLine[BUFSIZ], szWrk[BUFSIZ], szShow[USHRT_MAX] = { 0 }; | char Proto = 0, szStr[BUFSIZ], szLine[BUFSIZ], szWrk[BUFSIZ], szShow[USHRT_MAX] = { 0 }; |
| struct bpf_hdr *bpf = buffer; | |
| #ifdef __FreeBSD__ | #ifdef __FreeBSD__ |
| struct bpf_zbuf_header *bzh = buffer; | struct bpf_zbuf_header *bzh = buffer; |
| struct icmphdr *icmp; | struct icmphdr *icmp; |
| Line 78 ShowPkt(void *buffer) | Line 84 ShowPkt(void *buffer) |
| assert(buffer); | assert(buffer); |
| snprintf(szLine, BUFSIZ, "#Packet length: %d\n>>> Ethernet ...\n", bpf->bh_datalen); | eth = (struct ether_header *) buffer; |
| strlcat(szShow, szLine, USHRT_MAX); | |
| eth = (struct ether_header *) (buffer + bpf->bh_hdrlen); | |
| switch (ntohs(eth->ether_type)) { | switch (ntohs(eth->ether_type)) { |
| case ETHERTYPE_ARP: | case ETHERTYPE_ARP: |
| Line 258 main(int argc, char **argv) | Line 262 main(int argc, char **argv) |
| char ch, mode = 'R'; | char ch, mode = 'R'; |
| struct timespec ts_start, ts_end; | struct timespec ts_start, ts_end; |
| void *bz = NULL; | void *bz = NULL; |
| ether_addr_t ea; | |
| while ((ch = getopt(argc, argv, "hvwzs:p:f:")) != -1) | while ((ch = getopt(argc, argv, "hvwzs:p:f:")) != -1) |
| switch (ch) { | switch (ch) { |
| Line 373 main(int argc, char **argv) | Line 378 main(int argc, char **argv) |
| printf("0.%09lu per/iteration\n", ts_end.tv_sec + ts_end.tv_nsec / i); | printf("0.%09lu per/iteration\n", ts_end.tv_sec + ts_end.tv_nsec / i); |
| return 0; | return 0; |
| } | } |
| #endif |