libbgp  0.6
A C++ BGP Library.
bgp-capability.h
Go to the documentation of this file.
1 
11 #ifndef BGP_CAP_H_
12 #define BGP_CAP_H_
13 #include "bgp-afi.h"
14 #include "serializable.h"
15 #include <stdint.h>
16 
17 namespace libbgp {
18 
24  MP_BGP = 1,
25  ROUTE_REFRESH = 2,
26  ORF = 3,
27  EXTENDED_NEXTHOP = 5,
28  BGPSEC = 7,
29  MULTIPLE_LABELS = 8,
30  GRACEFUL_RESTART = 64,
31  ASN_4B = 65,
32  ADD_PATH = 69,
33  ENHANCED_ROUTE_REFRESH = 70
34 };
35 
40 class BgpCapability : public Serializable {
41 public:
43 
44  uint8_t code;
45  virtual ~BgpCapability() {}
46 
60  virtual ssize_t parse(const uint8_t *from, size_t msg_sz) = 0;
61 
71  virtual ssize_t write(uint8_t *to, size_t buf_sz) const = 0;
72 protected:
73 
74  ssize_t parseHeader(const uint8_t *from, size_t msg_sz);
75 
84  uint8_t length;
85 };
86 
92 public:
94 
95  ssize_t doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const;
96  ssize_t parse(const uint8_t *from, size_t msg_sz);
97  ssize_t write(uint8_t *to, size_t buf_sz) const;
98 
103  uint32_t my_asn;
104 };
105 
111 public:
113 
114  ssize_t doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const;
115  ssize_t parse(const uint8_t *from, size_t msg_sz);
116  ssize_t write(uint8_t *to, size_t buf_sz) const;
117 
122  uint16_t afi;
123 
128  uint8_t safi;
129 };
130 
136 public:
139 
140  ssize_t doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const;
141  ssize_t parse(const uint8_t *from, size_t msg_sz);
142  ssize_t write(uint8_t *to, size_t buf_sz) const;
143 
144 private:
145  uint8_t *value;
146 };
147 
148 }
149 
150 #endif // BGP_CAP_H_
virtual ssize_t doPrint(size_t indent, uint8_t **to, size_t *buf_sz) const =0
Print implementation.
The BgpCapabilityMpBgp class.
ssize_t parseHeader(const uint8_t *from, size_t msg_sz)
Parse the capability header (code, length).
The BgpCapabilityUnknow class.
The BgpCapability base class.
uint8_t length
Length of the attribute. Used only when deserializer.
The serializable base class.
Definition: serializable.h:26
The BgpCapability4BytesAsn class.
The BGP AFI/SAFI.
virtual ssize_t write(uint8_t *to, size_t buf_sz) const =0
Serialize a BGP open message capability.
BgpCapability(BgpLogHandler *logger)
Construct a new Bgp Capability object.
uint8_t safi
Subsequent Address Family Identifier.
Definition: bgp-afi.h:14
The BgpLogHandler class.
uint16_t afi
Address Family Identifier.
virtual ssize_t parse(const uint8_t *from, size_t msg_sz)=0
Deserialize a BGP open message capability.
BgpCapabilityCode
BGP capability codes.
The serializable base.