"Fossies" - the Fresh Open Source Software Archive

Member "tcpflow-1.6.1/src/be13_api/pcap_fake.h" (19 Feb 2021, 3214 Bytes) of package /linux/misc/tcpflow-1.6.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "pcap_fake.h" see the Fossies "Dox" file reference documentation.

    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 
   12 __BEGIN_DECLS
   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     
   26 struct pcap_file_header {
   27     uint32_t magic;                     // d4 c3 b2 a1
   28     uint16_t version_major;             // 02 00
   29     uint16_t version_minor;             // 04 00
   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 
   82 __END_DECLS
   83 
   84