Stub pcapng data structures into their own headers
This commit is contained in:
parent
58b1ea1b60
commit
e7b79a7118
8 changed files with 149 additions and 115 deletions
|
@ -4,119 +4,13 @@
|
|||
#include <stdint.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
/*
|
||||
* pcapng reader error states
|
||||
*/
|
||||
typedef enum {
|
||||
HEXAGRAM_PCAPNG_ERROR_OK = 0,
|
||||
HEXAGRAM_PCAPNG_ERROR_IO = 1,
|
||||
HEXAGRAM_PCAPNG_ERROR_TRUNCATED = 2,
|
||||
HEXAGRAM_PCAPNG_ERROR_FORMAT = 3,
|
||||
HEXAGRAM_PCAPNG_ERROR_HANDLER = 4
|
||||
} hexagram_pcapng_error;
|
||||
|
||||
/*
|
||||
* pcapng block option types and structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_END 0x0
|
||||
#define HEXAGRAM_PCAPNG_OPTION_COMMENT 0x1
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM1 0x0bac
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM2 0x0bad
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM3 0x4bac
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM4 0x4bad
|
||||
|
||||
typedef struct _hexagram_pcapng_option {
|
||||
uint16_t code,
|
||||
length;
|
||||
} hexagram_pcapng_option;
|
||||
|
||||
/*
|
||||
* pcapng block types and structure
|
||||
*/
|
||||
typedef enum {
|
||||
HEXAGRAM_PCAPNG_BLOCK_SECTION = 0x0a0d0d0a,
|
||||
HEXAGRAM_PCAPNG_BLOCK_IF = 0x1,
|
||||
HEXAGRAM_PCAPNG_BLOCK_IF_STATS = 0x5,
|
||||
HEXAGRAM_PCAPNG_BLOCK_PACKET = 0x6
|
||||
} hexagram_pcapng_block_type;
|
||||
|
||||
typedef struct _hexagram_pcapng_block_header {
|
||||
uint32_t type,
|
||||
length;
|
||||
} hexagram_pcapng_block_header;
|
||||
|
||||
typedef struct _hexagram_pcapng_block_footer {
|
||||
uint32_t length;
|
||||
} hexagram_pcapng_block_footer;
|
||||
|
||||
/*
|
||||
* pcapng section block structure and byte order magic
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_SECTION_MAGIC 0x1a2b3c4d
|
||||
|
||||
#define HEXAGRAM_PCAPNG_OPTION_SHB_HARDWARE 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_SHB_OS 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_SHB_USERAPPL 4
|
||||
|
||||
typedef struct _hexagram_pcapng_section {
|
||||
uint32_t magic;
|
||||
uint16_t major, minor;
|
||||
uint64_t length;
|
||||
} hexagram_pcapng_section;
|
||||
|
||||
/*
|
||||
* pcapng interface description block structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_NAME 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_DESCRIPTION 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_IPV4_ADDR 4
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_IPV6_ADDR 5
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_MAC_ADDR 6
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_EUI_ADDR 7
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_SPEED 8
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_TSRESOL 9
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_TZONE 10
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_FILTER 11
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_OS 12
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_FCSLEN 13
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_TSOFFSET 14
|
||||
|
||||
typedef struct _hexagram_pcapng_if {
|
||||
uint16_t linktype,
|
||||
reserved;
|
||||
uint32_t snaplen;
|
||||
} hexagram_pcapng_if;
|
||||
|
||||
/*
|
||||
* pcapng interface statistics block structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_STARTTIME 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_ENDTIME 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_IFRECV 4
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_IFDROP 5
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_FILTERACCEPT 6
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_OSDROP 7
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_USRDELIV 8
|
||||
|
||||
typedef struct _hexagram_pcapng_if_stats {
|
||||
uint32_t if_id,
|
||||
timestamp_high,
|
||||
timestamp_low;
|
||||
} hexagram_pcapng_if_stats;
|
||||
|
||||
/*
|
||||
* pcapng packet block structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_EPB_FLAGS 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_EPB_HASH 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_EPB_DROPCOUNT 4
|
||||
|
||||
typedef struct _hexagram_pcapng_packet {
|
||||
uint32_t interface,
|
||||
timestamp[2],
|
||||
caplen,
|
||||
origlen;
|
||||
} hexagram_pcapng_packet;
|
||||
#include <hexagram/pcapng/error.h>
|
||||
#include <hexagram/pcapng/block.h>
|
||||
#include <hexagram/pcapng/option.h>
|
||||
#include <hexagram/pcapng/section.h>
|
||||
#include <hexagram/pcapng/if.h>
|
||||
#include <hexagram/pcapng/if_stats.h>
|
||||
#include <hexagram/pcapng/packet.h>
|
||||
|
||||
/*
|
||||
* pcapng stream reading facilities
|
||||
|
@ -127,8 +21,6 @@ typedef int (hexagram_pcapng_block_handler)(int fd,
|
|||
uint32_t type,
|
||||
size_t length);
|
||||
|
||||
|
||||
|
||||
ssize_t hexagram_pcapng_stream_read(int fd,
|
||||
hexagram_pcapng_block_handler *handler,
|
||||
int *error);
|
||||
|
|
23
include/hexagram/pcapng/block.h
Normal file
23
include/hexagram/pcapng/block.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#ifndef _HEXAGRAM_PCAPNG_BLOCK_H
|
||||
#define _HEXAGRAM_PCAPNG_BLOCK_H
|
||||
|
||||
/*
|
||||
* pcapng block types and structure
|
||||
*/
|
||||
typedef enum {
|
||||
HEXAGRAM_PCAPNG_BLOCK_SECTION = 0x0a0d0d0a,
|
||||
HEXAGRAM_PCAPNG_BLOCK_IF = 0x1,
|
||||
HEXAGRAM_PCAPNG_BLOCK_IF_STATS = 0x5,
|
||||
HEXAGRAM_PCAPNG_BLOCK_PACKET = 0x6
|
||||
} hexagram_pcapng_block_type;
|
||||
|
||||
typedef struct _hexagram_pcapng_block_header {
|
||||
uint32_t type,
|
||||
length;
|
||||
} hexagram_pcapng_block_header;
|
||||
|
||||
typedef struct _hexagram_pcapng_block_footer {
|
||||
uint32_t length;
|
||||
} hexagram_pcapng_block_footer;
|
||||
|
||||
#endif /* _HEXAGRAM_PCAPNG_BLOCK_H */
|
15
include/hexagram/pcapng/error.h
Normal file
15
include/hexagram/pcapng/error.h
Normal file
|
@ -0,0 +1,15 @@
|
|||
#ifndef _HEXAGRAM_PCAPNG_ERROR_H
|
||||
#define _HEXAGRAM_PCAPNG_ERROR_H
|
||||
|
||||
/*
|
||||
* pcapng reader error states
|
||||
*/
|
||||
typedef enum {
|
||||
HEXAGRAM_PCAPNG_ERROR_OK = 0,
|
||||
HEXAGRAM_PCAPNG_ERROR_IO = 1,
|
||||
HEXAGRAM_PCAPNG_ERROR_TRUNCATED = 2,
|
||||
HEXAGRAM_PCAPNG_ERROR_FORMAT = 3,
|
||||
HEXAGRAM_PCAPNG_ERROR_HANDLER = 4
|
||||
} hexagram_pcapng_error;
|
||||
|
||||
#endif /* _HEXAGRAM_PCAPNG_ERROR_H */
|
27
include/hexagram/pcapng/if.h
Normal file
27
include/hexagram/pcapng/if.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef _HEXAGRAM_PCAPNG_IF_H
|
||||
#define _HEXAGRAM_PCAPNG_IF_H
|
||||
|
||||
/*
|
||||
* pcapng interface description block structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_NAME 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_DESCRIPTION 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_IPV4_ADDR 4
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_IPV6_ADDR 5
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_MAC_ADDR 6
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_EUI_ADDR 7
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_SPEED 8
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_TSRESOL 9
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_TZONE 10
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_FILTER 11
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_OS 12
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_FCSLEN 13
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_TSOFFSET 14
|
||||
|
||||
typedef struct _hexagram_pcapng_if {
|
||||
uint16_t linktype,
|
||||
reserved;
|
||||
uint32_t snaplen;
|
||||
} hexagram_pcapng_if;
|
||||
|
||||
#endif /* _HEXAGRAM_PCAPNG_IF_H */
|
21
include/hexagram/pcapng/if_stats.h
Normal file
21
include/hexagram/pcapng/if_stats.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#ifndef _HEXAGRAM_PCAPNG_IF_STATS_H
|
||||
#define _HEXAGRAM_PCAPNG_IF_STATS_H
|
||||
|
||||
/*
|
||||
* pcapng interface statistics block structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_STARTTIME 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_ENDTIME 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_IFRECV 4
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_IFDROP 5
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_FILTERACCEPT 6
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_OSDROP 7
|
||||
#define HEXAGRAM_PCAPNG_OPTION_ISB_USRDELIV 8
|
||||
|
||||
typedef struct _hexagram_pcapng_if_stats {
|
||||
uint32_t if_id,
|
||||
timestamp_high,
|
||||
timestamp_low;
|
||||
} hexagram_pcapng_if_stats;
|
||||
|
||||
#endif /* _HEXAGRAM_PCAPNG_IF_STATS_H */
|
19
include/hexagram/pcapng/option.h
Normal file
19
include/hexagram/pcapng/option.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef _HEXAGRAM_PCAPNG_OPTION_H
|
||||
#define _HEXAGRAM_PCAPNG_OPTION_H
|
||||
|
||||
/*
|
||||
* pcapng block option types and structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_END 0x0
|
||||
#define HEXAGRAM_PCAPNG_OPTION_COMMENT 0x1
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM1 0x0bac
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM2 0x0bad
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM3 0x4bac
|
||||
#define HEXAGRAM_PCAPNG_OPTION_CUSTOM4 0x4bad
|
||||
|
||||
typedef struct _hexagram_pcapng_option {
|
||||
uint16_t code,
|
||||
length;
|
||||
} hexagram_pcapng_option;
|
||||
|
||||
#endif /* _HEXAGRAM_PCAPNG_OPTION_H */
|
18
include/hexagram/pcapng/packet.h
Normal file
18
include/hexagram/pcapng/packet.h
Normal file
|
@ -0,0 +1,18 @@
|
|||
#ifndef _HEXAGRAM_PCAPNG_PACKET_H
|
||||
#define _HEXAGRAM_PCAPNG_PACKET_H
|
||||
|
||||
/*
|
||||
* pcapng packet block structure
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_OPTION_EPB_FLAGS 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_EPB_HASH 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_EPB_DROPCOUNT 4
|
||||
|
||||
typedef struct _hexagram_pcapng_packet {
|
||||
uint32_t interface,
|
||||
timestamp[2],
|
||||
caplen,
|
||||
origlen;
|
||||
} hexagram_pcapng_packet;
|
||||
|
||||
#endif /* _HEXAGRAM_PCAPNG_PACKET_H */
|
19
include/hexagram/pcapng/section.h
Normal file
19
include/hexagram/pcapng/section.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
#ifndef _HEXAGRAM_PCAPNG_SECTION_H
|
||||
#define _HEXAGRAM_PCAPNG_SECTION_H
|
||||
|
||||
/*
|
||||
* pcapng section block structure and byte order magic
|
||||
*/
|
||||
#define HEXAGRAM_PCAPNG_SECTION_MAGIC 0x1a2b3c4d
|
||||
|
||||
#define HEXAGRAM_PCAPNG_OPTION_SHB_HARDWARE 2
|
||||
#define HEXAGRAM_PCAPNG_OPTION_SHB_OS 3
|
||||
#define HEXAGRAM_PCAPNG_OPTION_SHB_USERAPPL 4
|
||||
|
||||
typedef struct _hexagram_pcapng_section {
|
||||
uint32_t magic;
|
||||
uint16_t major, minor;
|
||||
uint64_t length;
|
||||
} hexagram_pcapng_section;
|
||||
|
||||
#endif /* _HEXAGRAM_PCAPNG_SECTION_H */
|
Loading…
Add table
Reference in a new issue