23 copy(data.begin(), data.end(),
data_.begin());
33 snprintf(temp,
sizeof(temp),
"soo:%u:%u", asn,
num);
35 }
else if (data[0] == 2) {
39 snprintf(temp,
sizeof(temp),
"soo:%u:%u", asn,
num);
45 snprintf(temp,
sizeof(temp),
"soo:%s:%u",
46 addr.to_string().c_str(),
num);
52 boost::system::error_code *errorp) {
57 size_t pos = str.find(
':');
58 if (pos == string::npos) {
60 *errorp = make_error_code(boost::system::errc::invalid_argument);
65 string first(str.substr(0, pos));
68 *errorp = make_error_code(boost::system::errc::invalid_argument);
73 string rest(str.substr(pos+1));
76 if (pos == string::npos) {
78 *errorp = make_error_code(boost::system::errc::invalid_argument);
83 boost::system::error_code ec;
84 string second(rest.substr(0, pos));
85 Ip4Address addr = Ip4Address::from_string(second, ec);
90 int64_t asn = strtol(second.c_str(), &endptr, 10);
91 if (asn == 0 || asn > 0xFFFFFFFF || *endptr !=
'\0') {
94 make_error_code(boost::system::errc::invalid_argument);
112 uint32_t l_addr = addr.to_ulong();
117 string third(rest.substr(pos+1));
118 uint64_t value = strtol(third.c_str(), &endptr, 10);
119 if (*endptr !=
'\0') {
120 if (errorp != NULL) {
121 *errorp = make_error_code(boost::system::errc::invalid_argument);
127 if (offset == 4 && value > 0xFFFFFFFF) {
128 if (errorp != NULL) {
129 *errorp = make_error_code(boost::system::errc::invalid_argument);
135 if (offset == 6 && value > 0xFFFF) {
136 if (errorp != NULL) {
137 *errorp = make_error_code(boost::system::errc::invalid_argument);
boost::asio::ip::address_v4 Ip4Address
static SiteOfOrigin FromString(const std::string &str, boost::system::error_code *error=NULL)
static SiteOfOrigin null_soo
boost::array< uint8_t, kSize > bytes_type
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)