diff options
author | Ido Barnea <ibarnea@cisco.com> | 2016-10-30 15:00:30 +0200 |
---|---|---|
committer | Ido Barnea <ibarnea@cisco.com> | 2016-10-30 15:00:30 +0200 |
commit | d08421c1d70528358537938443fdbc57fb7109da (patch) | |
tree | 82640266daeb8ad4c5a72de26cab87d79d1c28ac /src/utl_yaml.cpp | |
parent | 8839acd6400c3fc0a4bd490a46d7b4d80cd61888 (diff) |
Added inet_pton.cpp
Signed-off-by: Ido Barnea <ibarnea@cisco.com>
Diffstat (limited to 'src/utl_yaml.cpp')
-rwxr-xr-x | src/utl_yaml.cpp | 42 |
1 files changed, 2 insertions, 40 deletions
diff --git a/src/utl_yaml.cpp b/src/utl_yaml.cpp index 864c86f8..094a3de8 100755 --- a/src/utl_yaml.cpp +++ b/src/utl_yaml.cpp @@ -27,44 +27,8 @@ limitations under the License. #define INADDRSZ 4 -static int my_inet_pton4(const char *src, unsigned char *dst) -{ - static const char digits[] = "0123456789"; - int saw_digit, octets, ch; - unsigned char tmp[INADDRSZ], *tp; - - saw_digit = 0; - octets = 0; - *(tp = tmp) = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr(digits, ch)) != NULL) { - unsigned int _new = *tp * 10 + (pch - digits); - - if (_new > 255) - return (0); - if (! saw_digit) { - if (++octets > 4) - return (0); - saw_digit = 1; - } - *tp = (unsigned char)_new; - } else if (ch == '.' && saw_digit) { - if (octets == 4) - return (0); - *++tp = 0; - saw_digit = 0; - } else - return (0); - } - if (octets < 4) - return (0); - - memcpy(dst, tmp, INADDRSZ); - return (1); -} - +extern int my_inet_pton4(const char *src, unsigned char *dst); +extern int my_inet_pton6(const char *src, unsigned char *dst); bool utl_yaml_read_ip_addr(const YAML::Node& node, const std::string &name, @@ -270,8 +234,6 @@ YAMLParserWrapper::parse_map(const YAML::Node &node, const std::string &name) { uint32_t YAMLParserWrapper::parse_ip(const YAML::Node &node, const std::string &name) { - - try { std::string ip_str; uint32_t ip_num; |