22 copy(data.begin(), data.end(),
data_.begin());
47 snprintf(temp,
sizeof(temp),
"rt-import:%s:%u",
48 addr.to_string().c_str(),
num);
55 boost::system::error_code *errorp) {
60 size_t pos = str.find(
':');
61 if (pos == string::npos) {
63 *errorp = make_error_code(boost::system::errc::invalid_argument);
68 string first(str.substr(0, pos));
69 if (first !=
"rt-import") {
71 *errorp = make_error_code(boost::system::errc::invalid_argument);
76 string rest(str.substr(pos+1));
79 if (pos == string::npos) {
81 *errorp = make_error_code(boost::system::errc::invalid_argument);
86 boost::system::error_code ec;
87 string second(rest.substr(0, pos));
88 Ip4Address addr = Ip4Address::from_string(second, ec);
93 *errorp = make_error_code(boost::system::errc::invalid_argument);
99 uint32_t l_addr = addr.to_ulong();
103 string third(rest.substr(pos+1));
104 uint64_t value = strtol(third.c_str(), &endptr, 10);
105 if (*endptr !=
'\0') {
106 if (errorp != NULL) {
107 *errorp = make_error_code(boost::system::errc::invalid_argument);
113 if (value > 0xFFFF) {
114 if (errorp != NULL) {
115 *errorp = make_error_code(boost::system::errc::invalid_argument);
boost::asio::ip::address_v4 Ip4Address
static VrfRouteImport null_rt_import
boost::array< uint8_t, kSize > bytes_type
static VrfRouteImport FromString(const std::string &str, boost::system::error_code *error=NULL)
Ip4Address GetIPv4Address() const
uint16_t GetNumber() const
std::string ToString() const
static void put_value(uint8_t *data, int size, uint64_t value)
static uint64_t get_value(const uint8_t *data, int size)