22 copy(data.begin(), data.end(),
data_.begin());
32 snprintf(temp,
sizeof(temp),
"soo:%u:%u", asn, num);
34 }
else if (data[0] == 2) {
38 snprintf(temp,
sizeof(temp),
"soo:%u:%u", asn, num);
44 snprintf(temp,
sizeof(temp),
"soo:%s:%u",
45 addr.to_string().c_str(),
num);
51 boost::system::error_code *errorp) {
56 size_t pos = str.find(
':');
57 if (pos == string::npos) {
59 *errorp = make_error_code(boost::system::errc::invalid_argument);
64 string first(str.substr(0, pos));
67 *errorp = make_error_code(boost::system::errc::invalid_argument);
72 string rest(str.substr(pos+1));
75 if (pos == string::npos) {
77 *errorp = make_error_code(boost::system::errc::invalid_argument);
82 boost::system::error_code ec;
83 string second(rest.substr(0, pos));
84 Ip4Address addr = Ip4Address::from_string(second, ec);
89 int64_t asn = strtol(second.c_str(), &endptr, 10);
90 if (asn == 0 || asn > 0xFFFFFFFF || *endptr !=
'\0') {
93 make_error_code(boost::system::errc::invalid_argument);
111 uint32_t l_addr = addr.to_ulong();
116 string third(rest.substr(pos+1));
117 uint64_t value = strtol(third.c_str(), &endptr, 10);
118 if (*endptr !=
'\0') {
119 if (errorp != NULL) {
120 *errorp = make_error_code(boost::system::errc::invalid_argument);
126 if (offset == 4 && value > 0xFFFFFFFF) {
127 if (errorp != NULL) {
128 *errorp = make_error_code(boost::system::errc::invalid_argument);
134 if (offset == 6 && value > 0xFFFF) {
135 if (errorp != NULL) {
136 *errorp = make_error_code(boost::system::errc::invalid_argument);
std::string ToString() const
static SiteOfOrigin FromString(const std::string &str, boost::system::error_code *error=NULL)
boost::array< uint8_t, kSize > bytes_type
static uint64_t get_value(const uint8_t *data, int size)
static SiteOfOrigin null_soo
boost::asio::ip::address_v4 Ip4Address
static void put_value(uint8_t *data, int size, uint64_t value)