Struct pcap [pcap-int.h]
{
Int FD;/* file description, which is actually socket */
/* On the socket, select (), Poll (), and other I/O multiplexing functions can be used */
Int selectable_fd;
Int snapshot;/* the maximum length of the captured data packet that the user expects */
Int linktype;/* device type */
Int tzoff;/* Time Zone location, which is not actually used */
Int offset;/* boundary alignment offset */
Int break_loop;/* mark of force bounce from read packet loop */
Struct pcap_sf SF;/* configuration data structure for saving data packets to files */
Struct pcap_md;/* The specific description is as follows */
Int bufsize;/* read buffer length */
U_char buffer;/* read buffer pointer */
U_char * bp;
Int cc;
U_char * Pkt;
/* Function pointers related to abstract operations, which ultimately point to the processing functions of a specific operating system */
INT (* read_op) (pcap_t *, int CNT, pcap_handler, u_char *);
INT (* setfilter_op) (pcap_t *, struct bpf_program *);
INT (* set_datalink_op) (pcap_t *, INT );
INT (* getnonblock_op) (pcap_t *, char *);
INT (* setnonblock_op) (pcap_t *, Int, char *);
INT (* stats_op) (pcap_t *, struct pcap_stat *);
Void (* close_op) (pcap_t *);
/* If the BPF filtering Code cannot be executed in the kernel, save it and run it in the user space */
Struct bpf_program fcode;
/* Function call error message buffer */
Char errbuf [pcap_errbuf_size + 1];
/* Number of Data Link types supported and changeable by the current device */
Int dlt_count;
/* List of changeable Data Link types, which is not used in Linux */
Int * dlt_list;
/* Customize the packet header to describe the packet capture time, capture length, and actual length [pcap. H] */
Struct pcap_pkthdr pcap_header;
};
/* Contains the capture handle interface, status, filter information [pcap-int.h] */
Struct pcap_md {
/* Capture status structure [pcap. H] */
Struct pcap_stat Stat;
Int use_bpf;/* if it is 1, the kernel filter is used */
U_long totpkts;
U_long totaccepted;/* Number of received packets */
U_long totdrops;/* Number of dropped packets */
Long totmissed;/* Number of data packets discarded by the interface during filtering */
Long origmissed;/* Number of data packets discarded by the interface before filtering */
# Ifdef Linux
Int sock_packet;/* if it is 1, it indicates that the sock_packet mode of the 2.0 kernel is used */
Int timeout;/* pcap_open_live () function timeout return time */
Int clear_promisc;/* set the interface to non-mixed mode when disabled */
Int cooked;/* use the sock_dgram type */
Int lo_ifindex;/* loop device Index Number */
Char * device;/* interface device name */
/* Open the pcap_t linked list of Socket of sock_packet type in hybrid mode */
Struct pcap * next;
# Endif
};