aboutgitcodebugslistschat
path: root/ndp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2022-07-22 15:31:18 +1000
committerStefano Brivio <sbrivio@redhat.com>2022-07-30 22:14:07 +0200
commit16f5586bb811dd344c3bbeadc88f30568986adbc (patch)
tree5ddf4027edb4867adb94dcd62870d9d9a6f3ac49 /ndp.c
parent5e12d23acbda8871848c6221a4f14e5b7daff66f (diff)
downloadpasst-16f5586bb811dd344c3bbeadc88f30568986adbc.tar
passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.gz
passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.bz2
passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.lz
passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.xz
passt-16f5586bb811dd344c3bbeadc88f30568986adbc.tar.zst
passt-16f5586bb811dd344c3bbeadc88f30568986adbc.zip
Make substructures for IPv4 and IPv6 specific context information
The context structure contains a batch of fields specific to IPv4 and to IPv6 connectivity. Split those out into a sub-structure. This allows the conf_ip4() and conf_ip6() functions, which take the entire context but touch very little of it, to be given more specific parameters, making it clearer what it affects without stepping through the code. Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'ndp.c')
-rw-r--r--ndp.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/ndp.c b/ndp.c
index 4d13be3..29c4b14 100644
--- a/ndp.c
+++ b/ndp.c
@@ -107,7 +107,7 @@ int ndp(struct ctx *c, const struct icmp6hdr *ih,
p += 4;
*(uint32_t *)p = htonl(3600); /* preferred lifetime */
p += 8;
- memcpy(p, &c->addr6, 8); /* prefix */
+ memcpy(p, &c->ip6.addr, 8); /* prefix */
p += 16;
if (c->mtu != -1) {
@@ -121,7 +121,7 @@ int ndp(struct ctx *c, const struct icmp6hdr *ih,
if (c->no_dhcp_dns)
goto dns_done;
- for (n = 0; !IN6_IS_ADDR_UNSPECIFIED(&c->dns6[n]); n++);
+ for (n = 0; !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns[n]); n++);
if (n) {
*p++ = 25; /* RDNSS */
*p++ = 1 + 2 * n; /* length */
@@ -130,7 +130,7 @@ int ndp(struct ctx *c, const struct icmp6hdr *ih,
p += 4;
for (i = 0; i < n; i++) {
- memcpy(p, &c->dns6[i], 16); /* address */
+ memcpy(p, &c->ip6.dns[i], 16); /* address */
p += 16;
}
@@ -177,15 +177,15 @@ dns_done:
len = (uintptr_t)p - (uintptr_t)ihr - sizeof(*ihr);
if (IN6_IS_ADDR_LINKLOCAL(saddr))
- c->addr6_ll_seen = *saddr;
+ c->ip6.addr_ll_seen = *saddr;
else
- c->addr6_seen = *saddr;
+ c->ip6.addr_seen = *saddr;
ip6hr->daddr = *saddr;
- if (IN6_IS_ADDR_LINKLOCAL(&c->gw6))
- ip6hr->saddr = c->gw6;
+ if (IN6_IS_ADDR_LINKLOCAL(&c->ip6.gw))
+ ip6hr->saddr = c->ip6.gw;
else
- ip6hr->saddr = c->addr6_ll;
+ ip6hr->saddr = c->ip6.addr_ll;
ip6hr->payload_len = htons(sizeof(*ihr) + len);
ip6hr->hop_limit = IPPROTO_ICMPV6;