21 copy(data.begin(), data.end(),
data_.begin());
46 snprintf(temp,
sizeof(temp),
"rt-import:%s:%u",
47 addr.to_string().c_str(),
num);
54 boost::system::error_code *errorp) {
59 size_t pos = str.find(
':');
60 if (pos == string::npos) {
62 *errorp = make_error_code(boost::system::errc::invalid_argument);
67 string first(str.substr(0, pos));
68 if (first !=
"rt-import") {
70 *errorp = make_error_code(boost::system::errc::invalid_argument);
75 string rest(str.substr(pos+1));
78 if (pos == string::npos) {
80 *errorp = make_error_code(boost::system::errc::invalid_argument);
85 boost::system::error_code ec;
86 string second(rest.substr(0, pos));
87 Ip4Address addr = Ip4Address::from_string(second, ec);
92 *errorp = make_error_code(boost::system::errc::invalid_argument);
98 uint32_t l_addr = addr.to_ulong();
102 string third(rest.substr(pos+1));
103 uint64_t value = strtol(third.c_str(), &endptr, 10);
104 if (*endptr !=
'\0') {
105 if (errorp != NULL) {
106 *errorp = make_error_code(boost::system::errc::invalid_argument);
112 if (value > 0xFFFF) {
113 if (errorp != NULL) {
114 *errorp = make_error_code(boost::system::errc::invalid_argument);
static uint64_t get_value(const uint8_t *data, int size)
static VrfRouteImport null_rt_import
uint16_t GetNumber() const
std::string ToString() const
boost::array< uint8_t, kSize > bytes_type
boost::asio::ip::address_v4 Ip4Address
static VrfRouteImport FromString(const std::string &str, boost::system::error_code *error=NULL)
Ip4Address GetIPv4Address() const
static void put_value(uint8_t *data, int size, uint64_t value)