123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553 |
- #ifndef pcap_int_h
- #define pcap_int_h
- #ifdef __cplusplus
- extern "C"
- {
- #endif
- #include <pcap.h>
- #ifdef WIN32
- #include <Packet32.h>
- #endif
- #ifdef MSDOS
- #include <fcntl.h>
- #include <io.h>
- #endif
- typedef enum
- {
- NOT_SWAPPED,
- SWAPPED,
- MAYBE_SWAPPED
- }
- swapped_type_t;
- struct pcap_sf
- {
- FILE *rfile;
- int swapped;
- int hdrsize;
- swapped_type_t lengths_swapped;
- int version_major;
- int version_minor;
- u_char *base;
- };
- struct pcap_md
- {
- struct pcap_stat stat;
- int use_bpf;
- u_long TotPkts;
- u_long TotAccepted;
- u_long TotDrops;
- long TotMissed;
- long OrigMissed;
- char *device;
- #ifdef linux
- int sock_packet;
- int timeout;
- int clear_promisc;
- int cooked;
- int ifindex;
- int lo_ifindex;
- struct pcap *next;
- u_int packets_read;
- #endif
- #ifdef HAVE_DAG_API
- #ifdef HAVE_DAG_STREAMS_API
- u_char *dag_mem_bottom;
- u_char *dag_mem_top;
- #else
- void *dag_mem_base;
- u_int dag_mem_bottom;
- u_int dag_mem_top;
- #endif
- int dag_fcs_bits;
- int dag_offset_flags;
- int dag_stream;
- int dag_timeout;
- #endif
- #ifdef HAVE_REMOTE
- unsigned int TotNetDrops;
- unsigned int TotCapt;
- #endif
- };
- #if defined(ultrix) || defined(__osf__) || (defined(__NetBSD__) && __NetBSD_Version__ > 106000000)
- #define PCAP_FDDIPAD 3
- #endif
- struct pcap
- {
- #ifdef WIN32
- ADAPTER *adapter;
- LPPACKET Packet;
- int timeout;
- int nonblock;
- #else
- int fd;
- int selectable_fd;
- int send_fd;
- #endif
- int snapshot;
- int linktype;
- int tzoff;
- int offset;
- int break_loop;
- #ifdef PCAP_FDDIPAD
- int fddipad;
- #endif
- #ifdef MSDOS
- int inter_packet_wait;
- void (*wait_proc)(void);
- #endif
- struct pcap_sf sf;
- struct pcap_md md;
- int bufsize;
- u_char *buffer;
- u_char *bp;
- int cc;
- u_char *pkt;
- pcap_direction_t direction;
- int (*read_op)(pcap_t *, int cnt, pcap_handler, u_char *);
- int (*inject_op)(pcap_t *, const void *, size_t);
- int (*setfilter_op)(pcap_t *, struct bpf_program *);
- int (*setdirection_op)(pcap_t *, pcap_direction_t);
- 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 *);
- struct bpf_program fcode;
- char errbuf [PCAP_ERRBUF_SIZE + 1];
- int dlt_count;
- u_int *dlt_list;
- struct pcap_pkthdr pcap_header;
- #ifdef HAVE_REMOTE
- #ifndef WIN32
- int timeout;
- #endif
- int rmt_clientside;
- SOCKET rmt_sockctrl;
- SOCKET rmt_sockdata;
- int rmt_flags;
- int rmt_capstarted;
- struct pcap_samp rmt_samp;
- char *currentfilter;
- #endif
- };
- struct pcap_timeval
- {
- bpf_int32 tv_sec;
- bpf_int32 tv_usec;
- };
- struct pcap_sf_pkthdr
- {
- struct pcap_timeval ts;
- bpf_u_int32 caplen;
- bpf_u_int32 len;
- };
- struct pcap_sf_patched_pkthdr
- {
- struct pcap_timeval ts;
- bpf_u_int32 caplen;
- bpf_u_int32 len;
- int index;
- unsigned short protocol;
- unsigned char pkt_type;
- };
- int yylex (void);
- #ifndef min
- #define min(a, b) ((a) > (b) ? (b) : (a))
- #endif
- int pcap_offline_read (pcap_t *, int, pcap_handler, u_char *);
- int pcap_read (pcap_t *, int cnt, pcap_handler, u_char *);
- #ifndef HAVE_STRLCPY
- #define strlcpy(x, y, z) \
- (strncpy ((x), (y), (z)), \ ((z) <= 0? 0: ((x)[(z) - 1] = '\0')), \ strlen ((y)))
- #endif
- #include <stdarg.h>
- #if !defined(HAVE_SNPRINTF)
- #define snprintf pcap_snprintf
- extern int snprintf (char *, size_t, const char *, ...);
- #endif
- #if !defined(HAVE_VSNPRINTF)
- #define vsnprintf pcap_vsnprintf
- extern int vsnprintf (char *, size_t, const char *, va_list ap);
- #endif
- #if !defined(WIN32) && !defined(MSDOS)
- int pcap_getnonblock_fd (pcap_t *, char *);
- int pcap_setnonblock_fd (pcap_t *p, int, char *);
- #endif
- void pcap_close_common (pcap_t *);
- int pcap_platform_finddevs (pcap_if_t **, char *);
- int add_addr_to_iflist (pcap_if_t **, const char *, u_int, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, struct sockaddr *, size_t, char *);
- int pcap_add_if (pcap_if_t **, const char *, u_int, const char *, char *);
- struct sockaddr *dup_sockaddr (struct sockaddr *, size_t);
- int add_or_find_if (pcap_if_t **, pcap_if_t **, const char *, u_int, const char *, char *);
- #ifdef WIN32
- char *pcap_win32strerror (void);
- #endif
- int install_bpf_program (pcap_t *, struct bpf_program *);
- int pcap_strcasecmp (const char *, const char *);
- #ifdef __cplusplus
- }
- #endif
- #endif
|