mirror of
https://passt.top/passt
synced 2025-05-19 16:05:35 +02:00
inany: Add inany_pton() helper
We already have an inany_ntop() function to format inany addresses into text. Add inany_pton() to parse them from text, and use it in conf_ports(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
cbde4192ee
commit
b55013b1a7
3 changed files with 22 additions and 8 deletions
9
conf.c
9
conf.c
|
@ -215,9 +215,6 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
|
|||
if (ifname == buf + 1) { /* Interface without address */
|
||||
addr = NULL;
|
||||
} else {
|
||||
struct in6_addr a6;
|
||||
struct in_addr a4;
|
||||
|
||||
p = buf;
|
||||
|
||||
/* Allow square brackets for IPv4 too for convenience */
|
||||
|
@ -226,11 +223,7 @@ static void conf_ports(const struct ctx *c, char optname, const char *optarg,
|
|||
p++;
|
||||
}
|
||||
|
||||
if (inet_pton(AF_INET, p, &a4))
|
||||
inany_from_af(addr, AF_INET, &a4);
|
||||
else if (inet_pton(AF_INET6, p, &a6))
|
||||
inany_from_af(addr, AF_INET6, &a6);
|
||||
else
|
||||
if (!inany_pton(p, addr))
|
||||
goto bad;
|
||||
}
|
||||
} else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue