summaryrefslogtreecommitdiff
path: root/lib/packets.h
diff options
context:
space:
mode:
authorMark Michelson <mmichels@redhat.com>2017-11-02 11:13:56 -0500
committerBen Pfaff <blp@ovn.org>2017-11-02 10:48:56 -0700
commite463f310b17d7dda864c33c8c3e6f19bd8f66c67 (patch)
tree90870dc5e0e803d9574a0a1f59472406887af618 /lib/packets.h
parent7b997d4f3d9996773537476d31a0643f96ed15c9 (diff)
downloadopenvswitch-e463f310b17d7dda864c33c8c3e6f19bd8f66c67.tar.gz
Add general-purpose IP/port parsing function.
OVS has functions for parsing IPv4 addresses, parsing IPv4 addresses with a port, and parsing IPv6 addresses. What is lacking though is a function that can take an IPv4 or IPv6 address, with or without a port. This commit adds ipv46_parse(), which breaks the given input string into its component parts and stores them in a sockaddr_storage structure. The function accepts flags that determine how it should behave if a port is present in the input string. Signed-off-by: Mark Michelson <mmichels@redhat.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
Diffstat (limited to 'lib/packets.h')
-rw-r--r--lib/packets.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/lib/packets.h b/lib/packets.h
index 057935cbf..c5915a0f8 100644
--- a/lib/packets.h
+++ b/lib/packets.h
@@ -1339,6 +1339,16 @@ struct in6_addr ipv6_create_mask(int mask);
int ipv6_count_cidr_bits(const struct in6_addr *netmask);
bool ipv6_is_cidr(const struct in6_addr *netmask);
+enum port_flags {
+ PORT_OPTIONAL,
+ PORT_REQUIRED,
+ PORT_FORBIDDEN,
+};
+
+char *ipv46_parse(const char *s, enum port_flags flags,
+ struct sockaddr_storage *ss)
+ OVS_WARN_UNUSED_RESULT;
+
bool ipv6_parse(const char *s, struct in6_addr *ip);
char *ipv6_parse_masked(const char *s, struct in6_addr *ipv6,
struct in6_addr *mask);