treewide: Avoid in_addr_t

IPv4 addresses can be stored in an in_addr_t or a struct in_addr.  The
former is just a type alias to a 32-bit integer, so doesn't really give us
any type checking.  Therefore we generally prefer the structure, since we
mostly want to treat IP address as opaque objects.  Fix a few places where
we still use in_addr_t, but can just as easily use struct in_addr.

Note there are still some uses of in_addr_t in conf.c, but those are
justified: since they're doing prefix calculations, they actually need to
look at the internals of the address as an integer.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson
2023-12-08 01:31:39 +11:00
committed by Stefano Brivio
parent 24d1f6570b
commit 5cada56186
2 changed files with 3 additions and 3 deletions

2
util.c
View File

@@ -161,7 +161,7 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto,
if (af == AF_INET) {
if (bind_addr)
addr4.sin_addr.s_addr = *(in_addr_t *)bind_addr;
addr4.sin_addr = *(struct in_addr *)bind_addr;
sa = (const struct sockaddr *)&addr4;
sl = sizeof(addr4);