LCOV - code coverage report
Current view: top level - util/net - fd_pcapng_private.h (source / functions) Hit Total Coverage
Test: cov.lcov Lines: 7 14 50.0 %
Date: 2024-11-13 11:58:15 Functions: 0 0 -

          Line data    Source code
       1             : #ifndef HEADER_fd_src_util_net_fd_pcapng_private_h
       2             : #define HEADER_fd_src_util_net_fd_pcapng_private_h
       3             : 
       4             : #include "fd_pcapng.h"
       5             : 
       6             : /* FD_PCAPNG_BLOCK_SZ: max size of serialized block
       7             :    (including packet content)  FIXME allow for jumbos? */
       8             : #define FD_PCAPNG_BLOCK_SZ (4096UL)
       9             : 
      10             : /* FD_PCAPNG_BLOCK_TYPE_*: Block type identifiers */
      11             : 
      12           9 : #define FD_PCAPNG_BLOCK_TYPE_SHB (0x0A0D0D0AU) /* Section Header Block        */
      13           9 : #define FD_PCAPNG_BLOCK_TYPE_IDB (0x00000001U) /* Interface Description Block */
      14           0 : #define FD_PCAPNG_BLOCK_TYPE_SPB (0x00000003U) /* Simple Packet Block         */
      15          21 : #define FD_PCAPNG_BLOCK_TYPE_EPB (0x00000006U) /* Enhanced Packet Block       */
      16           9 : #define FD_PCAPNG_BLOCK_TYPE_DSB (0x0000000AU) /* Decryption Secrets Block    */
      17             : 
      18             : /* FD_PCAPNG_BYTE_ORDER_MAGIC: BOM in logical order */
      19             : 
      20           9 : #define FD_PCAPNG_BYTE_ORDER_MAGIC (0x1A2B3C4D)
      21             : 
      22             : /* fd_pcapng_option_t points to a variable-length option value.
      23             :    Kind of option value depends on option type.  Strings (char *) are
      24             :    UTF-8 encoded and are not zero terminated. */
      25             : 
      26             : struct fd_pcapng_option {
      27             :   ushort type;  /* FD_PCAPNG_*_OPT_* */
      28             :   ushort sz;    /* byte size of option data at value */
      29             :   void * value; /* points to first byte of option data */
      30             : };
      31             : typedef struct fd_pcapng_option fd_pcapng_option_t;
      32             : 
      33             : /* Common option codes */
      34             : 
      35             : #define FD_PCAPNG_OPT_END     ((ushort)0) /* end of options */
      36           0 : #define FD_PCAPNG_OPT_COMMENT ((ushort)1)
      37             : 
      38          15 : #define FD_PCAPNG_MAX_OPT_CNT 256
      39             : 
      40             : /* fd_pcapng_hdr_t: Common block header */
      41             : 
      42             : struct __attribute__((packed)) fd_pcapng_block_hdr {
      43             :   uint block_type;
      44             :   uint block_sz;
      45             : };
      46             : typedef struct fd_pcapng_block_hdr fd_pcapng_block_hdr_t;
      47             : 
      48             : /* fd_pcapng_shb_t: Section Header Block */
      49             : 
      50             : #define FD_PCAPNG_SHB_OPT_HARDWARE ((ushort)2)  /* char * hardware; max once */
      51             : #define FD_PCAPNG_SHB_OPT_OS       ((ushort)3)  /* char * os_name ; max once */
      52             : #define FD_PCAPNG_SHB_OPT_USERAPPL ((ushort)4)  /* char * app_name; max once */
      53             : 
      54             : struct __attribute__((packed)) fd_pcapng_shb {
      55             :   uint   block_type;       /* ==FD_PCAPNG_BLOCK_TYPE_SHB */
      56             :   uint   block_sz;         /* ==sizeof(fd_pcapng_shb_t) */
      57             :   uint   byte_order_magic; /* ==FD_PCAPNG_BYTE_ORDER_MAGIC */
      58             :   ushort version_major;    /* ==1 */
      59             :   ushort version_minor;    /* ==0 */
      60             :   ulong  section_sz;       /* ==ULONG_MAX (undefined) */
      61             : };
      62             : typedef struct fd_pcapng_shb fd_pcapng_shb_t;
      63             : 
      64             : /* fd_pcapng_idb_t: Interface Description Block */
      65             : 
      66           0 : #define FD_PCAPNG_IDB_OPT_NAME      ((ushort) 2) /* char * if_name;        max once */
      67           0 : #define FD_PCAPNG_IDB_OPT_IPV4_ADDR ((ushort) 4) /* uint   ip4;            multiple */
      68           0 : #define FD_PCAPNG_IDB_OPT_MAC_ADDR  ((ushort) 6) /* char   hwaddr[6];      max once */
      69           0 : #define FD_PCAPNG_IDB_OPT_TSRESOL   ((ushort) 9) /* uchar  tsresol;        max once */
      70           0 : #define FD_PCAPNG_IDB_OPT_HARDWARE  ((ushort)15) /* char * device_name;    max once */
      71             : 
      72             : struct __attribute__((packed)) fd_pcapng_idb {
      73             :   uint   block_type; /* ==FD_PCAPNG_BLOCK_TYPE_IDB */
      74             :   uint   block_sz;   /* ==sizeof(fd_pcapng_idb_t) */
      75             :   ushort link_type;  /* ==FD_PCAPNG_LINKTYPE_ETHERNET */
      76             :   ushort _pad_0a;    /* ==0 */
      77             :   uint   snap_len;   /* packet payload sz limit, 0==unlim */
      78             : };
      79             : typedef struct fd_pcapng_idb fd_pcapng_idb_t;
      80             : 
      81             : /* fd_pcapng_spb_t: Simple Packet Block */
      82             : 
      83             : struct __attribute__((packed)) fd_pcapng_spb {
      84             :   uint   block_type; /* ==FD_PCAPNG_BLOCK_TYPE_SPB      */
      85             :   uint   block_sz;   /* >=sizeof(fd_pcapng_spb_t)       */
      86             :   uint   orig_len;   /* Original packet size (bytes)    */
      87             : };
      88             : typedef struct fd_pcapng_spb fd_pcapng_spb_t;
      89             : 
      90             : /* fd_pcapng_epb_t: Enhanced Packet Block */
      91             : 
      92             : struct __attribute__((packed)) fd_pcapng_epb {
      93             :   uint   block_type; /* ==FD_PCAPNG_BLOCK_TYPE_EPB      */
      94             :   uint   block_sz;   /* >=sizeof(fd_pcapng_epb_t)       */
      95             :   uint   if_idx;     /* Index of related IDB in section */
      96             :   uint   ts_hi;      /* High 32 bits of timestamp       */
      97             :   uint   ts_lo;      /* Low 32 bits of timestamp        */
      98             :   uint   cap_len;    /* Captured packet size (bytes)    */
      99             :   uint   orig_len;   /* Original packet size (bytes)    */
     100             : };
     101             : typedef struct fd_pcapng_epb fd_pcapng_epb_t;
     102             : 
     103             : /* fd_pcapng_dsb_t: Decryption Secrets Block */
     104             : 
     105           9 : #define FD_PCAPNG_SECRET_TYPE_TLS (0x544c534bU)
     106             : 
     107             : struct __attribute__((packed)) fd_pcapng_dsb {
     108             :   uint   block_type;  /* ==FD_PCAPNG_BLOCK_TYPE_DSB */
     109             :   uint   block_sz;    /* >=sizeof(fd_pcapng_dsb_t)  */
     110             :   uint   secret_type; /* ==FD_PCAPNG_SECRET_TYPE_*  */
     111             :   uint   secret_sz;   /* byte sz of secrets data    */
     112             : };
     113             : typedef struct fd_pcapng_dsb fd_pcapng_dsb_t;
     114             : 
     115             : struct fd_pcapng_idb_desc {
     116             :   uint                 link_type;
     117             :   fd_pcapng_idb_opts_t opts;
     118             : };
     119             : typedef struct fd_pcapng_idb_desc fd_pcapng_idb_desc_t;
     120             : 
     121             : struct __attribute__((aligned(FD_PCAPNG_ITER_ALIGN))) fd_pcapng_iter {
     122             :   void * stream;
     123             :   int    error;
     124             : 
     125             : # define FD_PCAPNG_IFACE_CNT 16
     126             :   fd_pcapng_idb_desc_t iface[ FD_PCAPNG_IFACE_CNT ];
     127             :   uint                 iface_cnt;
     128             : };
     129             : 
     130             : #endif /* HEADER_fd_src_util_net_fd_pcapng_private_h */
     131             : 

Generated by: LCOV version 1.14