63 snprintf(temp,
sizeof(temp),
"%u:%u", asn, value);
68 snprintf(temp,
sizeof(temp),
":%u", value);
69 return ip.to_string() + temp;
73 snprintf(temp,
sizeof(temp),
"%u:%u", asn, value);
76 snprintf(temp,
sizeof(temp),
"%u:%02x:%02x:%02x:%02x:%02x:%02x",
84 const string &str, boost::system::error_code *errorp) {
86 size_t pos = str.rfind(
':');
87 if (pos == string::npos) {
89 *errorp = make_error_code(boost::system::errc::invalid_argument);
94 boost::system::error_code ec;
95 string first(str.substr(0, pos));
96 Ip4Address addr = Ip4Address::from_string(first, ec);
100 if (ec.value() != 0) {
102 asn = strtol(first.c_str(), &endptr, 10);
103 if (asn >= 65535 || *endptr !=
'\0') {
104 if (errorp != NULL) {
106 make_error_code(boost::system::errc::invalid_argument);
120 string second(str, pos + 1);
121 uint64_t value = strtol(second.c_str(), &endptr, 10);
122 if (*endptr !=
'\0') {
123 if (errorp != NULL) {
124 *errorp = make_error_code(boost::system::errc::invalid_argument);
130 if (asn == 0 && value != 0) {
131 if (errorp != NULL) {
132 *errorp = make_error_code(boost::system::errc::invalid_argument);
138 if (offset == 4 && value > 0xFFFFFFFF) {
139 if (errorp != NULL) {
140 *errorp = make_error_code(boost::system::errc::invalid_argument);
146 if (offset == 6 && value > 0xFFFF) {
147 if (errorp != NULL) {
148 *errorp = make_error_code(boost::system::errc::invalid_argument);
static RouteDistinguisher FromString(const std::string &str, boost::system::error_code *error=NULL)
int CompareTo(const RouteDistinguisher &rhs) const
static uint64_t get_value(const uint8_t *data, int size)
static const size_t kSize
uint16_t GetVrfId() const
static RouteDistinguisher kZeroRd
boost::asio::ip::address_v4 Ip4Address
uint32_t GetAddress() const
std::string ToString() const
static void put_value(uint8_t *data, int size, uint64_t value)