Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
clldpattrs.h
1 /*
2  * clldpattrs.h
3  *
4  * Created on: 03.03.2014
5  * Author: andreas
6  */
7 
8 #ifndef CLLDPATTRS_H_
9 #define CLLDPATTRS_H_
10 
11 #include <map>
12 
13 #include "rofl/common/protocols/clldpattr.h"
14 #include "rofl/common/logging.h"
15 #include "rofl/common/croflexception.h"
16 
17 namespace rofl {
18 namespace protocol {
19 namespace lldp {
20 
21 class eLLDPAttrsBase : public RoflException {};
22 class eLLDPAttrsInval : public eLLDPAttrsBase {};
24 
25 class clldpattrs {
26 
27  std::map<uint8_t, clldpattr*> attrs;
28 
29 public:
30 
34  clldpattrs();
35 
39  virtual
40  ~clldpattrs();
41 
45  clldpattrs(clldpattrs const& attrs);
46 
50  clldpattrs&
51  operator= (clldpattrs const& attrs);
52 
56  void
57  clear();
58 
62  void
63  insert(clldpattr const& attr);
64 
65 public:
66 
70  virtual size_t
71  length() const;
72 
76  virtual void
77  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
78 
82  virtual void
83  unpack(uint8_t *buf, size_t buflen);
84 
85 public:
86 
88  add_end();
89 
91  set_end();
92 
94  get_end();
95 
96  bool
97  has_end() const;
98 
99  void
100  drop_end();
101 
102 
103 
104  clldpattr_id&
105  add_chassis_id();
106 
107  clldpattr_id&
108  set_chassis_id();
109 
110  clldpattr_id&
111  get_chassis_id();
112 
113  bool
114  has_chassis_id() const;
115 
116  void
117  drop_chassis_id();
118 
119 
120 
121  clldpattr_id&
122  add_port_id();
123 
124  clldpattr_id&
125  set_port_id();
126 
127  clldpattr_id&
128  get_port_id();
129 
130  bool
131  has_port_id() const;
132 
133  void
134  drop_port_id();
135 
136 
137 
139  add_ttl();
140 
142  set_ttl();
143 
145  get_ttl();
146 
147  bool
148  has_ttl() const;
149 
150  void
151  drop_ttl();
152 
153 
154 
156  add_port_desc();
157 
159  set_port_desc();
160 
162  get_port_desc();
163 
164  bool
165  has_port_desc() const;
166 
167  void
168  drop_port_desc();
169 
170 
171 
172 
174  add_system_name();
175 
177  set_system_name();
178 
180  get_system_name();
181 
182  bool
183  has_system_name() const;
184 
185  void
186  drop_system_name();
187 
188 
189 
190 
192  add_system_desc();
193 
195  set_system_desc();
196 
198  get_system_desc();
199 
200  bool
201  has_system_desc() const;
202 
203  void
204  drop_system_desc();
205 
206 
207 
208 
210  add_system_caps();
211 
213  set_system_caps();
214 
216  get_system_caps();
217 
218  bool
219  has_system_caps() const;
220 
221  void
222  drop_system_caps();
223 
224 
225 
226 
227 
228 public:
229 
230  friend std::ostream&
231  operator<< (std::ostream& os, clldpattrs const& attrs) {
232  os << rofl::indent(0) << "<clldpattrs #attrs:" << attrs.attrs.size() << " >" << std::endl;
233  rofl::indent i(2);
234  if (attrs.has_chassis_id()) {
235  os << dynamic_cast<clldpattr_id&>( *(attrs.attrs.at(LLDPTT_CHASSIS_ID)) );
236  }
237  if (attrs.has_port_id()) {
238  os << dynamic_cast<clldpattr_id&>( *(attrs.attrs.at(LLDPTT_PORT_ID)) );
239  }
240  if (attrs.has_ttl()) {
241  os << dynamic_cast<clldpattr_ttl&>( *(attrs.attrs.at(LLDPTT_TTL)) );
242  }
243  for (std::map<uint8_t, clldpattr*>::const_iterator
244  it = attrs.attrs.begin(); it != attrs.attrs.end(); ++it) {
245  switch (it->first) {
246  case LLDPTT_END: {
247 
248  } break;
249  case LLDPTT_CHASSIS_ID: {
250 
251  } break;
252  case LLDPTT_PORT_ID: {
253 
254  } break;
255  case LLDPTT_TTL: {
256 
257  } break;
258  case LLDPTT_PORT_DESC: {
259  os << dynamic_cast<clldpattr_desc&>( *(it->second) );
260  } break;
261  case LLDPTT_SYSTEM_NAME: {
262  os << dynamic_cast<clldpattr_desc&>( *(it->second) );
263  } break;
264  case LLDPTT_SYSTEM_DESC: {
265  os << dynamic_cast<clldpattr_desc&>( *(it->second) );
266  } break;
267  case LLDPTT_SYSTEM_CAPS: {
268  os << dynamic_cast<clldpattr_system_caps&>( *(it->second) );
269  } break;
270  case LLDPTT_MGMT_ADDR:
271  default: {
272  os << dynamic_cast<clldpattr&>( *(it->second) );
273  };
274  }
275  }
276  if (attrs.has_end()) {
277  os << dynamic_cast<clldpattr_end&>( *(attrs.attrs.at(LLDPTT_END)) );
278  }
279  return os;
280  };
281 };
282 
283 }; // end of namespace lldp
284 }; // end of namespace protocol
285 }; // end of namespace rofl
286 
287 
288 
289 
290 #endif /* CLLDPATTRS_H_ */
Definition: clldpattr.h:128
Definition: clldpattr.h:504
Definition: clldpattrs.h:23
Definition: clldpattrs.h:22
Definition: clldpattr.h:416
Definition: clldpattr.h:245
Definition: clldpattr.h:299
Definition: clldpattrs.h:21
Definition: clldpattrs.h:25
Definition: logging.h:76
Definition: croflexception.h:27