86 lines
2.1 KiB
C
86 lines
2.1 KiB
C
#ifndef _HEXAGRAM_PCAPNG_H
|
|
#define _HEXAGRAM_PCAPNG_H
|
|
|
|
#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_INTERFACE = 0x1,
|
|
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
|
|
|
|
typedef struct _hexagram_pcapng_section {
|
|
uint32_t magic;
|
|
uint16_t major, minor;
|
|
uint64_t length;
|
|
} hexagram_pcapng_section;
|
|
|
|
/*
|
|
* pcapng interface description block structure
|
|
*/
|
|
typedef struct _hexagram_pcapng_interface {
|
|
uint16_t linktype,
|
|
reserved;
|
|
uint32_t snaplen;
|
|
} hexagram_pcapng_interface;
|
|
|
|
/*
|
|
* pcapng packet block structure
|
|
*/
|
|
typedef struct _hexagram_pcapng_packet {
|
|
|
|
} hexagram_pcapng_packet;
|
|
|
|
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);
|
|
|
|
#endif /* _HEXAGRAM_PCAPNG_H */
|