tcpflow  1.6.1
About: tcpflow is a TCP/IP packet demultiplexer that captures data transmitted as part of TCP connections (flows), and stores the data in a way that is convenient for protocol analysis and debugging.
  Fossies Dox: tcpflow-1.6.1.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

pcap_fake.h
Go to the documentation of this file.
1 /* -*- mode: C++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2 /*
3  * pcap_fake.h
4  * A fake libpcap implementation that can only read files without a filter.
5  */
6 
7 #include <sys/cdefs.h>
8 #include <stdint.h>
9 #include <sys/time.h>
10 #include <stdio.h>
11 
13 
14 /*
15  * Version number of the current version of the pcap file format.
16  *
17  * NOTE: this is *NOT* the version number of the libpcap library.
18  * To fetch the version information for the version of libpcap
19  * you're using, use pcap_lib_version().
20  */
21 #define PCAP_VERSION_MAJOR 2
22 #define PCAP_VERSION_MINOR 4
23 #define PCAP_ERRBUF_SIZE 256
24 
25 
27  uint32_t magic; // d4 c3 b2 a1
30  int32_t thiszone; /* gmt to local correction - 00 00 00 00*/
31  uint32_t sigfigs; /* accuracy of timestamps */
32  uint32_t snaplen; /* max length saved portion of each pkt */
33  uint32_t linktype; /* data link type (LINKTYPE_*) */
34 } __attribute__((packed));
35 struct pcap_pkthdr {
36  struct timeval ts; /* time stamp; native */
37  uint32_t caplen; /* length of portion present */
38  uint32_t len; /* length this packet (off wire) */
39 }__attribute__((packed));
40 
41 /* What we need after opening the file to process each next packet */
42 typedef struct pcap pcap_t;
43 
44 /*
45  * Taken from pcap-int.h
46  */
47 //typedef int (*setfilter_op_t)(pcap_t *, struct bpf_program *);
48 typedef void (*pcap_handler)(uint8_t *, const struct pcap_pkthdr *, const uint8_t *);
49 
50 struct bpf_program {
51  int valid; // set true if filter is valid
52 };
53 
54 char *pcap_lookupdev(char *); // not implemented
55 pcap_t *pcap_open_live(const char *, int, int, int, char *); // not implemented
56 pcap_t *pcap_open_offline(const char *, char *); // open the file; set f
57 pcap_t *pcap_fopen_offline(FILE *fp,char *errbuf);
58 void pcap_close(pcap_t *); // close the file
59 int pcap_loop(pcap_t *, int, pcap_handler, uint8_t *); // read the file and call loopback on each packet
60 int pcap_datalink(pcap_t *); // noop
61 int pcap_setfilter(pcap_t *, struct bpf_program *); // noop
62 int pcap_compile(pcap_t *, struct bpf_program *, const char *, int, uint32_t); // generate error if filter provided
63 char *pcap_geterr(pcap_t *);
64 /*
65  * These are the types that are the same on all platforms, and that
66  * have been defined by <net/bpf.h> for ages.
67  */
68 #define DLT_NULL 0 /* BSD loopback encapsulation */
69 #define DLT_EN10MB 1 /* Ethernet (10Mb) */
70 #define DLT_EN3MB 2 /* Experimental Ethernet (3Mb) */
71 #define DLT_AX25 3 /* Amateur Radio AX.25 */
72 #define DLT_PRONET 4 /* Proteon ProNET Token Ring */
73 #define DLT_CHAOS 5 /* Chaos */
74 #define DLT_IEEE802 6 /* 802.5 Token Ring */
75 #define DLT_ARCNET 7 /* ARCNET, with BSD-style header */
76 #define DLT_SLIP 8 /* Serial Line IP */
77 #define DLT_PPP 9 /* Point-to-point Protocol */
78 #define DLT_FDDI 10 /* FDDI */
79 #define DLT_RAW 101 /* just packets */
80 
81 
83 
84 
#define __END_DECLS
Definition: dfxml_writer.h:56
#define __BEGIN_DECLS
Definition: dfxml_writer.h:55
unsigned int uint32_t
Definition: core.h:40
char * pcap_lookupdev(char *)
Definition: pcap_fake.cpp:59
int pcap_loop(pcap_t *, int, pcap_handler, uint8_t *)
Definition: pcap_fake.cpp:169
pcap_t * pcap_open_live(const char *, int, int, int, char *)
Definition: pcap_fake.cpp:65
pcap_t * pcap_fopen_offline(FILE *fp, char *errbuf)
Definition: pcap_fake.cpp:87
int pcap_datalink(pcap_t *)
Definition: pcap_fake.cpp:159
char * pcap_geterr(pcap_t *)
Definition: pcap_fake.cpp:35
int pcap_compile(pcap_t *, struct bpf_program *, const char *, int, uint32_t)
Definition: pcap_fake.cpp:150
void(* pcap_handler)(uint8_t *, const struct pcap_pkthdr *, const uint8_t *)
Definition: pcap_fake.h:48
pcap_t * pcap_open_offline(const char *, char *)
Definition: pcap_fake.cpp:47
int pcap_setfilter(pcap_t *, struct bpf_program *)
Definition: pcap_fake.cpp:163
void pcap_close(pcap_t *)
Definition: pcap_fake.cpp:218
uint32_t magic
Definition: pcap_fake.h:27
uint32_t sigfigs
Definition: pcap_fake.h:31
uint16_t version_major
Definition: pcap_fake.h:28
uint32_t linktype
Definition: pcap_fake.h:33
uint32_t snaplen
Definition: pcap_fake.h:32
uint16_t version_minor
Definition: pcap_fake.h:29
int32_t thiszone
Definition: pcap_fake.h:30
uint32_t caplen
Definition: pcap_fake.h:37
struct timeval ts
Definition: pcap_fake.h:36
uint32_t len
Definition: pcap_fake.h:38
unsigned short uint16_t
Definition: util.h:7
unsigned char uint8_t
Definition: util.h:6