hmmst, gotta handle another block type we encountered
This commit is contained in:
parent
bc62f8b3c9
commit
58b1ea1b60
2 changed files with 56 additions and 5 deletions
|
@ -35,7 +35,8 @@ typedef struct _hexagram_pcapng_option {
|
|||
*/
|
||||
typedef enum {
|
||||
HEXAGRAM_PCAPNG_BLOCK_SECTION = 0x0a0d0d0a,
|
||||
HEXAGRAM_PCAPNG_BLOCK_INTERFACE = 0x1,
|
||||
HEXAGRAM_PCAPNG_BLOCK_IF = 0x1,
|
||||
HEXAGRAM_PCAPNG_BLOCK_IF_STATS = 0x5,
|
||||
HEXAGRAM_PCAPNG_BLOCK_PACKET = 0x6
|
||||
} hexagram_pcapng_block_type;
|
||||
|
||||
|
@ -80,11 +81,28 @@ typedef struct _hexagram_pcapng_section {
|
|||
#define HEXAGRAM_PCAPNG_OPTION_IF_FCSLEN 13
|
||||
#define HEXAGRAM_PCAPNG_OPTION_IF_TSOFFSET 14
|
||||
|
||||
typedef struct _hexagram_pcapng_interface {
|
||||
typedef struct _hexagram_pcapng_if {
|
||||
uint16_t linktype,
|
||||
reserved;
|
||||
uint32_t snaplen;
|
||||
} hexagram_pcapng_interface;
|
||||
} 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
|
||||
|
@ -100,12 +118,21 @@ typedef struct _hexagram_pcapng_packet {
|
|||
origlen;
|
||||
} hexagram_pcapng_packet;
|
||||
|
||||
/*
|
||||
* pcapng stream reading facilities
|
||||
*/
|
||||
typedef struct _hexagram_pcapng_stream hexagram_pcapng_stream;
|
||||
|
||||
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 */
|
||||
|
|
24
src/pcapng.c
24
src/pcapng.c
|
@ -1,3 +1,4 @@
|
|||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
|
@ -6,6 +7,29 @@
|
|||
|
||||
#include <hexagram/pcapng.h>
|
||||
|
||||
struct _hexagram_pcapng_stream {
|
||||
int fd;
|
||||
uint32_t if_count;
|
||||
hexagram_pcapng_section *section;
|
||||
hexagram_pcapng_if *ifs;
|
||||
hexagram_pcapng_if_stats *stats;
|
||||
};
|
||||
|
||||
hexagram_pcapng_stream *hexagram_pcapng_stream_open_fd(int fd) {
|
||||
hexagram_pcapng_stream *stream;
|
||||
|
||||
if ((stream = malloc(sizeof(*stream))) == NULL) {
|
||||
goto error_malloc_stream;
|
||||
}
|
||||
|
||||
stream->if_count = 0;
|
||||
|
||||
return stream;
|
||||
|
||||
error_malloc_stream:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
ssize_t hexagram_pcapng_stream_read(fd, handler, error)
|
||||
int fd;
|
||||
hexagram_pcapng_block_handler *handler;
|
||||
|
|
Loading…
Add table
Reference in a new issue