/
origin_vn.h
56 lines (42 loc) · 1.28 KB
/
origin_vn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*
* Copyright (c) 2013 Juniper Networks, Inc. All rights reserved.
*/
#ifndef SRC_BGP_ORIGIN_VN_ORIGIN_VN_H_
#define SRC_BGP_ORIGIN_VN_ORIGIN_VN_H_
#include <boost/array.hpp>
#include <boost/system/error_code.hpp>
#include <string>
#include "base/parse_object.h"
#include "bgp/bgp_common.h"
class OriginVn {
public:
static const int kSize = 8;
static const int kMinGlobalId = 8000000;
static OriginVn null_originvn;
typedef boost::array<uint8_t, kSize> bytes_type;
OriginVn();
OriginVn(as_t asn, uint32_t vn_idx);
explicit OriginVn(const bytes_type &data);
bool IsNull() { return operator==(OriginVn::null_originvn); }
bool IsGlobal() const;
as_t as_number() const;
int vn_index() const;
const bytes_type &GetExtCommunity() const {
return data_;
}
const uint64_t GetExtCommunityValue() const {
return get_value(data_.begin(), 8);
}
bool operator<(const OriginVn &rhs) const {
return data_ < rhs.data_;
}
bool operator==(const OriginVn &rhs) const {
return data_ == rhs.data_;
}
std::string ToString();
static OriginVn FromString(const std::string &str,
boost::system::error_code *error = NULL);
private:
bytes_type data_;
};
#endif // SRC_BGP_ORIGIN_VN_ORIGIN_VN_H_