Revised OpenFlow Library  v0.6.0dev
 All Classes Files Functions Variables Friends Groups Pages
clldpmsg.h
1 /*
2  * clldpmsg.h
3  *
4  * Created on: 04.03.2014
5  * Author: andreas
6  */
7 
8 #ifndef CLLDPMSG_H_
9 #define CLLDPMSG_H_
10 
11 #include "rofl/common/cmemory.h"
12 #include "rofl/common/logging.h"
13 #include "rofl/common/caddress.h"
14 #include "rofl/common/croflexception.h"
15 #include "rofl/common/protocols/clldpattr.h"
16 #include "rofl/common/protocols/clldpattrs.h"
17 
18 namespace rofl {
19 namespace protocol {
20 namespace lldp {
21 
22 class eLLDPMsgBase : public RoflException {};
23 class eLLDPMsgInval : public eLLDPMsgBase {};
24 class eLLDPMsgNotFound : public eLLDPMsgBase {};
25 
26 class clldpmsg
27 {
28  clldpattrs attrs;
29  cmacaddr eth_dst;
30  cmacaddr eth_src;
31  uint16_t eth_type;
32 
33  static unsigned int const LLDP_ETHER_TYPE = 0x88cc;
34 
35 public:
36 
40  clldpmsg();
41 
45  virtual
46  ~clldpmsg();
47 
51  clldpmsg(clldpmsg const& msg);
52 
56  clldpmsg&
57  operator= (clldpmsg const& msg);
58 
59 public:
60 
64  size_t
65  length() const;
66 
70  virtual void
71  pack(uint8_t *buf = (uint8_t*)0, size_t buflen = 0);
72 
76  virtual void
77  unpack(uint8_t *buf, size_t buflen);
78 
79 public:
80 
84  clldpattrs&
85  set_attrs() { return attrs; };
86 
90  clldpattrs const&
91  get_attrs() const { return attrs; };
92 
96  cmacaddr&
97  set_eth_dst() { return eth_dst; };
98 
102  cmacaddr const&
103  get_eth_dst() const { return eth_dst; };
104 
108  cmacaddr&
109  set_eth_src() { return eth_src; };
110 
114  cmacaddr const&
115  get_eth_src() const { return eth_src; };
116 
120  uint16_t const&
121  get_eth_type() const { return eth_type; };
122 
126  uint16_t&
127  set_eth_type() { return eth_type; };
128 
129 
130 public:
131 
132  friend std::ostream&
133  operator<< (std::ostream& os, clldpmsg const& msg) {
134  os << rofl::indent(0) << "<clldpmsg length:" << msg.length() << " >" << std::endl;
135  os << rofl::indent(2) << "<eth-dst: " << msg.get_eth_dst() << " >" << std::endl;
136  os << rofl::indent(2) << "<eth-src: " << msg.get_eth_src() << " >" << std::endl;
137  os << rofl::indent(2) << "<eth-type: 0x" << std::hex << (int)msg.get_eth_type() << std::dec << " >" << std::endl;
138  rofl::indent i(2);
139  os << msg.get_attrs();
140  return os;
141  };
142 };
143 
144 
145 }; // end of namespace lldp
146 }; // end of namespace protocol
147 }; // end of namespace rofl
148 
149 
150 
151 #endif /* CLLDPMSG_H_ */
Definition: clldpmsg.h:22
Definition: caddress.h:152
Definition: clldpmsg.h:23
Definition: clldpmsg.h:26
Definition: clldpattrs.h:25
Definition: logging.h:76
Definition: croflexception.h:27