1
2
3 """Snoop file format."""
4 from __future__ import absolute_import
5
6 import time
7
8 from . import dpkt
9
10
11
12 SNOOP_MAGIC = 0x736E6F6F70000000
13
14 SNOOP_VERSION = 2
15
16 SDL_8023 = 0
17 SDL_8024 = 1
18 SDL_8025 = 2
19 SDL_8026 = 3
20 SDL_ETHER = 4
21 SDL_HDLC = 5
22 SDL_CHSYNC = 6
23 SDL_IBMCC = 7
24 SDL_FDDI = 8
25 SDL_OTHER = 9
26
27 dltoff = {SDL_ETHER: 14}
28
29
31 """snoop packet header.
32
33 TODO: Longer class information....
34
35 Attributes:
36 __hdr__: Header fields of snoop packet header.
37 TODO.
38 """
39
40 __byte_order__ = '!'
41 __hdr__ = (
42 ('orig_len', 'I', 0),
43 ('incl_len', 'I', 0),
44 ('rec_len', 'I', 0),
45 ('cum_drops', 'I', 0),
46 ('ts_sec', 'I', 0),
47 ('ts_usec', 'I', 0),
48 )
49
50
52 """snoop file header.
53
54 TODO: Longer class information....
55
56 Attributes:
57 __hdr__: Header fields of snoop file header.
58 TODO.
59 """
60
61 __byte_order__ = '!'
62 __hdr__ = (
63 ('magic', 'Q', SNOOP_MAGIC),
64 ('v', 'I', SNOOP_VERSION),
65 ('linktype', 'I', SDL_ETHER),
66 )
67
68
70 """Simple snoop dumpfile writer.
71
72 TODO: Longer class information....
73
74 Attributes:
75 TODO.
76 """
77
82
95
98
99
101 """Simple pypcap-compatible snoop file reader.
102
103 TODO: Longer class information....
104
105 Attributes:
106 TODO.
107 """
108
120
123
126
128 return NotImplementedError
129
132
133 - def dispatch(self, cnt, callback, *args):
134 if cnt > 0:
135 for i in range(cnt):
136 ts, pkt = next(self)
137 callback(ts, pkt, *args)
138 else:
139 for ts, pkt in self:
140 callback(ts, pkt, *args)
141
142 - def loop(self, callback, *args):
144
153