| 61 | } |
| 62 | |
| 63 | Ipv4Prefix::Ipv4Prefix(const std::string &prefix) { |
| 64 | size_t delim_pos = prefix.find('/'); |
| 65 | |
| 66 | // default values in case of parser failure |
| 67 | addr = be32_t(0); |
| 68 | mask = be32_t(0); |
| 69 | |
| 70 | if (prefix.length() == 0 || delim_pos == std::string::npos || |
| 71 | delim_pos >= prefix.length()) { |
| 72 | return; |
| 73 | } |
| 74 | |
| 75 | ParseIpv4Address(prefix.substr(0, delim_pos), &addr); |
| 76 | |
| 77 | const int len = std::stoi(prefix.substr(delim_pos + 1)); |
| 78 | mask = be32_t(SetBitsLow<uint32_t>(len)); |
| 79 | } |
| 80 | |
| 81 | } // namespace utils |
| 82 | } // namespace bess |
nothing calls this directly
no test coverage detected