-
Notifications
You must be signed in to change notification settings - Fork 78
/
packetlogger.hh
65 lines (50 loc) · 1.36 KB
/
packetlogger.hh
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
#ifndef CLICK_PACKETLOGGER_HH
#define CLICK_PACKETLOGGER_HH
#include <click/element.hh>
#include <click/glue.hh>
#include <click/deque.hh>
CLICK_DECLS
/*
* =c
*
* PacketLogger(ETHERTYPE ethertype)
*
* =s Grid
*
* Log packets for later dumping/analysis.
*
* =d
* expects packets with ethernet headers. records timestamp, source
* MAC address, and the first few bytes of every packet to pass through.
* the list of recorded data can be dumped by repeated calls to the
* read handler 'packets'.
*
* this is for logging received experiment packets on the roofnet.
*
* an NBYTES keyword would be nice.
*
*/
class PacketLogger : public Element { public:
PacketLogger() CLICK_COLD;
~PacketLogger() CLICK_COLD;
const char *class_name() const override { return "PacketLogger"; }
const char *port_count() const override { return PORTS_1_1; }
const char *processing() const override { return AGNOSTIC; }
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
bool can_live_reconfigure() const { return true; }
Packet *simple_action(Packet *);
void add_handlers() CLICK_COLD;
static String print_log(Element *, void *);
enum { NBYTES = 8 };
struct log_entry {
Timestamp timestamp;
uint8_t src_mac[6];
uint8_t bytes[NBYTES];
};
private:
uint16_t _et;
unsigned int _nb;
Deque<log_entry> _p;
};
CLICK_ENDDECLS
#endif