libpcap版本1.3.0-PRE-GIT
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define __USE_BSD
#include <sys/types.h>
#include <pcap.h>
#define Debug(format, ...) fprintf(stderr, "%s:%d: "format "\n", __FILE__, __LINE__, ##__VA_ARGS__)
#define assert_(expr_) do {if (!(expr_)) {Debug("在函数 `%s'中: 断言错误: " #expr_, __FUNCTION__); exit (-1);} } while (0)
#define pcap_assert(func_) assert_(func_!=-1)
static char buf[10000];
注意这里在include "pcap.h"之前,一定要先#define __USE_BSD 然后再include "sys/types.h",否则会出现这样的错误:
/usr/local/include/pcap/pcap.h:126:2: 错误:未知的类型名‘u_short’
/usr/local/include/pcap/pcap.h:171:2: 错误:未知的类型名‘u_int’
/usr/local/include/pcap/pcap.h:172:2: 错误:未知的类型名‘u_int’
/usr/local/include/pcap/pcap.h:173:2: 错误:未知的类型名‘u_int’
/usr/loc