-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsnoop.h
66 lines (56 loc) · 1.39 KB
/
snoop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#ifndef _PCAP_H_
#define _PCAP_H_ 1
#if defined(__cplusplus)
extern "C" {
#endif
enum {
PcapMagic = 0xa1b2c3d4,
PcapVersionMajor = 2,
PcapVersionMinor = 4,
MaxSnapLen = 65535,
GlobalHdrSize = 24,
RecordHdrSize = 16,
};
typedef struct GlobalHdr GlobalHdr;
typedef struct RecordHdr RecordHdr;
/*
* Global Header
*/
struct GlobalHdr {
uint32_t magic; /* magic number */
uint16_t version_major; /* major version number */
uint16_t version_minor; /* minor version number */
int32_t thiszone; /* GMT to local correction */
uint32_t sigfigs; /* accuracy of timestamps */
uint32_t snaplen; /* max length of captured packets */
uint32_t linktype; /* data link type (LINKTYPE_*) */
};
/*
* Record (Packet) Header
*/
struct RecordHdr {
uint32_t ts_sec; /* timestamp seconds */
uint32_t ts_usec; /* timestamp microseconds */
uint32_t caplen; /* length of packet saved in file */
uint32_t len; /* actual length of packet */
};
#define LINKTYPE_NULL 0
#define LINKTYPE_ETHERNET 1
/*
* read.c
*/
int readglobalhdr(FILE*, GlobalHdr*);
int readrecordhdr(FILE*, RecordHdr*);
int readrecord(FILE*, RecordHdr*, uint8_t*);
/*
* write.c
*/
int writeglobalhdr(FILE*);
int writerecordhdr(FILE*, int);
int writerecord(FILE*, uint8_t*, int);
int writerecordhdrts(FILE*, int, uint32_t, uint32_t);
int writerecordts(FILE*, uint8_t*, int, uint32_t, uint32_t);
#if defined(__cplusplus)
}
#endif
#endif