libbgp  0.6
A C++ BGP Library.
prefix.h
Go to the documentation of this file.
1 
11 #ifndef BGP_PREFIX_H_
12 #define BGP_PREFIX_H_
13 #include <stdint.h>
14 #include <unistd.h>
15 #include "bgp-afi.h"
16 
17 namespace libbgp {
18 
19 uint32_t cidr_to_mask(uint8_t cidr);
20 
25 class Prefix {
26 public:
27  Afi afi;
28 
38  virtual ssize_t parse(const uint8_t *buffer, size_t buf_sz) = 0;
39 
49  virtual ssize_t write(uint8_t *buffer, size_t buf_sz) const = 0;
50 
58  virtual bool includes (const Prefix &other) const = 0;
59 
60  // test if length & prefix equals to other
61  virtual bool operator== (const Prefix &other) const = 0;
62 
63  // test if length smaller (prefix size bigger) then other. prefix must be
64  // same to do this.
65  virtual bool operator> (const Prefix &other) const = 0;
66 
67  // test if length bigger (prefix size smaller) then other. prefix must be
68  // same to do this.
69  virtual bool operator< (const Prefix &other) const = 0;
70 
71  virtual bool operator>= (const Prefix &other) const = 0;
72  virtual bool operator<= (const Prefix &other) const = 0;
73  virtual bool operator!= (const Prefix &other) const = 0;
74 
75  virtual ~Prefix() {}
76 };
77 
78 }
79 
80 #endif // BGP_PREFIX_H_
Afi
Address Family Identifiers.
Definition: bgp-afi.h:20
virtual ssize_t write(uint8_t *buffer, size_t buf_sz) const =0
Write a prefix to NLRI buffer.
virtual bool includes(const Prefix &other) const =0
Test if another prefix is inside this prefix.
The BGP AFI/SAFI.
uint32_t cidr_to_mask(uint8_t cidr)
Convert netmask in CIDR notation to network bytes integer.
Definition: prefix4.cc:33
Definition: bgp-afi.h:14
virtual ssize_t parse(const uint8_t *buffer, size_t buf_sz)=0
Parse a NLRI prefix from buffer.
Route/Prefix related utilities.
Definition: prefix.h:25