Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
ctspaddress.h
1 /*
2  * ctspaddress.h
3  *
4  * Created on: 24.10.2014
5  * Author: andreas
6  */
7 
8 #ifndef CTSPADDRESS_H_
9 #define CTSPADDRESS_H_
10 
11 #include <inttypes.h>
12 #include <rofl/common/caddress.h>
13 #include <rofl/common/logging.h>
14 
15 namespace rofl {
16 namespace common {
17 
18 class ctspaddress {
19 public:
20 
24  ctspaddress(uint16_t port = 0) :
25  port(port) {};
26 
30  virtual
31  ~ctspaddress() {};
32 
36  ctspaddress(const ctspaddress& addr) { *this = addr; };
37 
42  operator= (const ctspaddress& addr) {
43  if (this == &addr)
44  return *this;
45  port = addr.port;
46  return *this;
47  };
48 
52  bool
53  operator== (const ctspaddress& addr) const { return (port == addr.port); };
54 
58  bool
59  operator< (const ctspaddress& addr) const { return (port < addr.port); };
60 
61 public:
62 
66  uint16_t
67  get_port() const { return port; };
68 
72  void
73  set_port(uint16_t port) { this->port = port; };
74 
75 public:
76 
77  friend std::ostream&
78  operator<< (std::ostream& os, const ctspaddress& addr) {
79  os << rofl::indent(0) << "<ctspaddress port:" << (int)addr.get_port() << " >" << std::endl;
80  return os;
81  };
82 
83 protected:
84 
85  uint16_t port;
86 };
87 
88 class ctspaddress_in4 : public ctspaddress {
89 public:
90 
94  ctspaddress_in4() {};
95 
99  ctspaddress_in4(const rofl::caddress_in4& addr, uint16_t port) :
100  ctspaddress(port), addr(addr) {};
101 
105  virtual
106  ~ctspaddress_in4() {};
107 
111  ctspaddress_in4(const ctspaddress_in4& addr) { *this = addr; };
112 
117  operator= (const ctspaddress_in4& addr) {
118  if (this == &addr)
119  return *this;
120  ctspaddress::operator= (addr);
121  this->addr = addr.addr;
122  return *this;
123  };
124 
128  bool
129  operator== (const ctspaddress_in4& addr) const {
130  return ((this->addr == addr.addr) && ctspaddress::operator== (addr));
131  };
132 
136  bool
137  operator< (const ctspaddress_in4& addr) const {
138  return ((this->addr < addr.addr) || ctspaddress::operator< (addr));
139  };
140 
141 public:
142 
146  const rofl::caddress_in4&
147  get_addr() const { return addr; };
148 
152  void
153  set_addr(rofl::caddress_in4& addr) { this->addr = addr; };
154 
155 public:
156 
157  friend std::ostream&
158  operator<< (std::ostream& os, const ctspaddress_in4& addr) {
159  os << rofl::indent(0) << "<ctspaddress_in4 addr:" << addr.get_addr().str()
160  << " port:" << (int)addr.get_port() << " >" << std::endl;
161  return os;
162  };
163 
164 private:
165 
166  rofl::caddress_in4 addr;
167 };
168 
169 class ctspaddress_in6 : public ctspaddress {
170 public:
171 
175  ctspaddress_in6() {};
176 
180  ctspaddress_in6(const rofl::caddress_in6& addr, uint16_t port) :
181  ctspaddress(port), addr(addr) {};
182 
186  virtual
187  ~ctspaddress_in6() {};
188 
192  ctspaddress_in6(const ctspaddress_in6& addr) { *this = addr; };
193 
198  operator= (const ctspaddress_in6& addr) {
199  if (this == &addr)
200  return *this;
201  ctspaddress::operator= (addr);
202  this->addr = addr.addr;
203  return *this;
204  };
205 
209  bool
210  operator== (const ctspaddress_in6& addr) const {
211  return ((this->addr == addr.addr) && ctspaddress::operator== (addr));
212  };
213 
217  bool
218  operator< (const ctspaddress_in6& addr) const {
219  return ((this->addr < addr.addr) || ctspaddress::operator< (addr));
220  };
221 
222 public:
223 
227  const rofl::caddress_in6&
228  get_addr() const { return addr; };
229 
233  void
234  set_addr(rofl::caddress_in6& addr) { this->addr = addr; };
235 
236 public:
237 
238  friend std::ostream&
239  operator<< (std::ostream& os, const ctspaddress_in6& addr) {
240  os << rofl::indent(0) << "<ctspaddress_in6 addr:" << addr.get_addr().str()
241  << " port:" << (int)addr.get_port() << " >" << std::endl;
242  return os;
243  };
244 
245 private:
246 
247  rofl::caddress_in6 addr;
248 };
249 
250 }; // end of namespace common
251 }; // end of namespace rofl
252 
253 #endif /* CTSPADDRESS_H_ */
Definition: caddress.h:589
Definition: ctspaddress.h:169
Definition: ctspaddress.h:18
Definition: caddress.h:415
Definition: logging.h:76
Definition: ctspaddress.h:88