22 copy(data.begin(), data.end(),
data_.begin());
37 boost::system::error_code *errorp) {
42 size_t pos = str.find(
':');
43 if (pos == string::npos) {
45 *errorp = make_error_code(boost::system::errc::invalid_argument);
50 string first(str.substr(0, pos));
51 if (first !=
"target") {
53 *errorp = make_error_code(boost::system::errc::invalid_argument);
58 string rest(str.substr(pos+1));
61 if (pos == string::npos) {
63 *errorp = make_error_code(boost::system::errc::invalid_argument);
68 boost::system::error_code ec;
69 string second(rest.substr(0, pos));
70 Ip4Address addr = Ip4Address::from_string(second, ec);
76 if (second.c_str()[pos - 1] ==
'L') {
78 second = second.substr(0, pos - 1);
81 int64_t asn = strtol(second.c_str(), &endptr, 10);
82 if (asn == 0 || asn > 0xFFFFFFFF || *endptr !=
'\0') {
85 make_error_code(boost::system::errc::invalid_argument);
102 uint32_t l_addr = addr.to_ulong();
106 string third(rest.substr(pos+1));
107 uint64_t value = strtol(third.c_str(), &endptr, 10);
108 if (*endptr !=
'\0') {
109 if (errorp != NULL) {
110 *errorp = make_error_code(boost::system::errc::invalid_argument);
116 if (offset == 4 && value > 0xFFFFFFFF) {
117 if (errorp != NULL) {
118 *errorp = make_error_code(boost::system::errc::invalid_argument);
124 if (offset == 6 && value > 0xFFFF) {
125 if (errorp != NULL) {
126 *errorp = make_error_code(boost::system::errc::invalid_argument);
143 snprintf(temp,
sizeof(temp),
"target:%u:%u", asn, num);
145 }
else if (data[0] == 2) {
150 snprintf(temp,
sizeof(temp),
"target:%u:%u", asn, num);
152 snprintf(temp,
sizeof(temp),
"target:%uL:%u", asn, num);
158 snprintf(temp,
sizeof(temp),
"target:%s:%u",
159 addr.to_string().c_str(),
num);
boost::array< uint8_t, kSize > bytes_type
static uint64_t get_value(const uint8_t *data, int size)
static RouteTarget null_rtarget
static RouteTarget FromString(const std::string &str, boost::system::error_code *error=NULL)
boost::asio::ip::address_v4 Ip4Address
const uint64_t GetExtCommunityValue() const
std::string ToString() const
static void put_value(uint8_t *data, int size, uint64_t value)