diff options
author | Ben Pfaff <blp@ovn.org> | 2015-12-15 18:04:20 -0800 |
---|---|---|
committer | Ben Pfaff <blp@ovn.org> | 2015-12-15 18:04:24 -0800 |
commit | e769509208591fbe4f42ba098f98374ea8f78800 (patch) | |
tree | aa1ed0f01303f1b934f62c5be3679a0ccee2e863 /ovn | |
parent | 2b02db1b4cb2152e4aa2ac441bcc984ef3b929e3 (diff) | |
download | openvswitch-e769509208591fbe4f42ba098f98374ea8f78800.tar.gz |
Use ip_parse() and ipv6_parse() and variants in more places.
This saves some code and improves clarity, in my opinion.
Some of these changes just change an inet_pton() call into a similar
ip_parse() or ipv6_parse() call. In those cases the benefit is better
type safety, since inet_pton()'s output parameter is type "void *".
Signed-off-by: Ben Pfaff <blp@ovn.org>
Acked-by: Justin Pettit <jpettit@ovn.org>
Diffstat (limited to 'ovn')
-rw-r--r-- | ovn/lib/lex.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/ovn/lib/lex.c b/ovn/lib/lex.c index fd906fd9a..481f11efd 100644 --- a/ovn/lib/lex.c +++ b/ovn/lib/lex.c @@ -21,6 +21,7 @@ #include <stdarg.h> #include "dynamic-string.h" #include "json.h" +#include "packets.h" #include "util.h" /* Returns a string that represents 'format'. */ @@ -338,13 +339,9 @@ lex_parse_integer__(const char *p, struct lex_token *token) memcpy(copy, p, len); copy[len] = '\0'; - struct in_addr ipv4; - struct in6_addr ipv6; - if (inet_pton(AF_INET, copy, &ipv4) == 1) { - token->value.ipv4 = ipv4.s_addr; + if (ip_parse(copy, &token->value.ipv4)) { token->format = LEX_F_IPV4; - } else if (inet_pton(AF_INET6, copy, &ipv6) == 1) { - token->value.ipv6 = ipv6; + } else if (ipv6_parse(copy, &token->value.ipv6)) { token->format = LEX_F_IPV6; } else { lex_error(token, "Invalid numeric constant."); |