#include <pcap.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <time.h>
#define SNAP_LEN 1518 // 以太网帧最大长度
#define SIZE_ETHERNET 14 // 以太网包头长度 mac 6*2, type: 2
#define ETHER_ADDR_LEN 6 // mac地址长度
struct packet_ethernet {
u_char ether_dhost[ETHER_ADDR_LEN]; /* destination host address */
u_char ether_shost[ETHER_ADDR_LEN]; /* source host address */
u_short ether_type; /* IP? ARP? RARP? etc */
};
/* IP header */
struct packet_ip {
u_char ip_vhl; /* version << 4 | header length >> 2 */
u_char ip_tos; /* type of service */
u_short ip_len; /* total length */
u_short ip_id; /* identification */
用libpcap打开读取cap文件
最新推荐文章于 2025-02-27 00:01:27 发布