-
Notifications
You must be signed in to change notification settings - Fork 82
/
hashswitch.hh
50 lines (40 loc) · 1.15 KB
/
hashswitch.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
#ifndef CLICK_HASHSWITCH_HH
#define CLICK_HASHSWITCH_HH
#include <click/batchelement.hh>
CLICK_DECLS
/*
* =c
* HashSwitch(OFFSET, LENGTH)
* =s classification
* classifies packets by hash of contents
* =d
* Can have any number of outputs.
* Chooses the output on which to emit each packet based on
* a hash of the LENGTH bytes starting at OFFSET.
* Could be used for stochastic fair queuing.
* =e
* This element expects IP packets and chooses the output
* based on a hash of the IP destination address:
*
* HashSwitch(16, 4)
* =a
* Switch, RoundRobinSwitch, StrideSwitch, RandomSwitch
*/
class HashSwitch : public BatchElement {
int _offset;
int _length;
int _max;
public:
HashSwitch() CLICK_COLD;
const char *class_name() const override { return "HashSwitch"; }
const char *port_count() const override { return "1/1-"; }
const char *processing() const override { return PUSH; }
int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
int process(Packet *);
void push(int port, Packet *);
#if HAVE_BATCH
void push_batch(int port, PacketBatch *);
#endif
};
CLICK_ENDDECLS
#endif