-
Notifications
You must be signed in to change notification settings - Fork 81
/
flowswitch.hh
87 lines (59 loc) · 1.96 KB
/
flowswitch.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef CLICK_FLOWSWITCH_HH
#define CLICK_FLOWSWITCH_HH
#include <click/config.h>
#include <click/tcphelper.hh>
#include <click/multithread.hh>
#include <click/glue.hh>
#include <click/loadbalancer.hh>
#include <click/vector.hh>
#include <click/flow/flowelement.hh>
#include "flowipnat.hh"
#define LB_FLOW_TIMEOUT 60 * 1000
CLICK_DECLS
struct FlowSwitchEntry {
int chosen_server;
FlowSwitchEntry(int addr) : chosen_server(addr) {
}
};
/**
=c
FlowSwitch([I<KEYWORDS>])
=s flow
Port load-balancer
=d
Load-balancer among Click ports. The same modes than FlowIPLoadBalancer are available, but instead
of rewriting IP adresses this elements forward to specific ports.
Keyword arguments are:
=over 8
=back
=e
fl :: FlowSwitch(MODE RR);
fl[0] -> ...;
fl[1] -> ...;
=a
FlowIPLoadBalancer, FlowIPNAT */
class FlowSwitch : public FlowStateElement<FlowSwitch,FlowSwitchEntry>,
public TCPHelper, public LoadBalancer<int> {
public:
FlowSwitch() CLICK_COLD;
~FlowSwitch() CLICK_COLD;
const char *class_name() const override { return "FlowSwitch"; }
const char *port_count() const override { return "1/1-"; }
const char *processing() const override { return PUSH; }
int configure(Vector<String> &, ErrorHandler *) override CLICK_COLD;
int initialize(ErrorHandler *errh) override CLICK_COLD;
static const int timeout = LB_FLOW_TIMEOUT;
bool new_flow(FlowSwitchEntry*, Packet*);
void release_flow(FlowSwitchEntry*) {};
void push_flow(int, FlowSwitchEntry*, PacketBatch *);
void add_handlers() override;
private:
static int handler(int op, String& s, Element* e, const Handler* h, ErrorHandler* errh);
static String read_handler(Element *handler, void *user_data);
static int write_handler(
const String &, Element *, void *, ErrorHandler *
) CLICK_COLD;
friend class LoadBalancer;
};
CLICK_ENDDECLS
#endif