-
Notifications
You must be signed in to change notification settings - Fork 81
/
iploadbalancer.hh
110 lines (70 loc) · 2.35 KB
/
iploadbalancer.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#ifndef CLICK_IPLoadBalancer_HH
#define CLICK_IPLoadBalancer_HH
#include <click/config.h>
#include <click/tcphelper.hh>
#include <click/multithread.hh>
#include <click/glue.hh>
#include <click/batchelement.hh>
#include <click/loadbalancer.hh>
#include <click/vector.hh>
CLICK_DECLS
class IPLoadBalancerReverse;
/**
=c
IPLoadBalancer([I<KEYWORDS>])
=s flow
TCP&UDP load-balancer, without SNAT
=d
Load-balancer than only rewrites the destination.
Keyword arguments are:
=over 8
=item DST
IP Address. Can be repeated multiple times, once per destination.
=item VIP
IP Address of this load-balancer.
=back
=a
FlowIPLoadBalancer, FlowIPNAT */
class IPLoadBalancer : public BatchElement, public TCPHelper, public LoadBalancer<IPAddress> {
public:
IPLoadBalancer() CLICK_COLD;
~IPLoadBalancer() CLICK_COLD;
const char *class_name() const override { return "IPLoadBalancer"; }
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;
#if HAVE_BATCH
void push_batch(int, PacketBatch *) override;
#endif
void push(int, Packet *) override;
void add_handlers() override CLICK_COLD;
private:
static int handler(int op, String& s, Element* e, const Handler* h, ErrorHandler* errh);
static String read_handler(Element *handler, void *user_data);
IPAddress _vip;
bool _accept_nonsyn;
static int write_handler(
const String &, Element *, void *, ErrorHandler *
) CLICK_COLD;
friend class LoadBalancer;
friend class IPLoadBalancerReverse;
};
class IPLoadBalancerReverse : public BatchElement, public TCPHelper {
public:
IPLoadBalancerReverse() CLICK_COLD;
~IPLoadBalancerReverse() CLICK_COLD;
const char *class_name() const override { return "IPLoadBalancerReverse"; }
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;
#if HAVE_BATCH
void push_batch(int, PacketBatch *) override;
#endif
void push(int, Packet *) override;
private:
IPLoadBalancer* _lb;
};
CLICK_ENDDECLS
#endif