aboutgitcodebugslistschat
path: root/dhcpv6.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 /dhcpv6.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 'dhcpv6.c')
-rw-r--r--dhcpv6.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/dhcpv6.c b/dhcpv6.c
index 4124a3e..fbae88d 100644
--- a/dhcpv6.c
+++ b/dhcpv6.c
@@ -390,7 +390,7 @@ static size_t dhcpv6_dns_fill(const struct ctx *c, char *buf, int offset)
if (c->no_dhcp_dns)
goto search;
- for (i = 0; !IN6_IS_ADDR_UNSPECIFIED(&c->dns6[i]); i++) {
+ for (i = 0; !IN6_IS_ADDR_UNSPECIFIED(&c->ip6.dns[i]); i++) {
if (!i) {
srv = (struct opt_dns_servers *)(buf + offset);
offset += sizeof(struct opt_hdr);
@@ -398,7 +398,7 @@ static size_t dhcpv6_dns_fill(const struct ctx *c, char *buf, int offset)
srv->hdr.l = 0;
}
- memcpy(&srv->addr[i], &c->dns6[i], sizeof(srv->addr[i]));
+ memcpy(&srv->addr[i], &c->ip6.dns[i], sizeof(srv->addr[i]));
srv->hdr.l += sizeof(srv->addr[i]);
offset += sizeof(srv->addr[i]);
}
@@ -473,12 +473,12 @@ int dhcpv6(struct ctx *c, const struct pool *p,
if (mlen + sizeof(*uh) != ntohs(uh->len) || mlen < sizeof(*mh))
return -1;
- c->addr6_ll_seen = *saddr;
+ c->ip6.addr_ll_seen = *saddr;
- if (IN6_IS_ADDR_LINKLOCAL(&c->gw6))
- src = &c->gw6;
+ if (IN6_IS_ADDR_LINKLOCAL(&c->ip6.gw))
+ src = &c->ip6.gw;
else
- src = &c->addr6_ll;
+ src = &c->ip6.addr_ll;
mh = packet_get(p, 0, sizeof(*uh), sizeof(*mh), NULL);
if (!mh)
@@ -508,7 +508,7 @@ int dhcpv6(struct ctx *c, const struct pool *p,
if (mh->type == TYPE_CONFIRM && server_id)
return -1;
- if ((bad_ia = dhcpv6_ia_notonlink(p, &c->addr6))) {
+ if ((bad_ia = dhcpv6_ia_notonlink(p, &c->ip6.addr))) {
info("DHCPv6: received CONFIRM with inappropriate IA,"
" sending NotOnLink status in REPLY");
@@ -580,7 +580,7 @@ int dhcpv6(struct ctx *c, const struct pool *p,
resp.hdr.xid = mh->xid;
tap_ip_send(c, src, IPPROTO_UDP, (char *)&resp, n, mh->xid);
- c->addr6_seen = c->addr6;
+ c->ip6.addr_seen = c->ip6.addr;
return 1;
}
@@ -602,5 +602,5 @@ void dhcpv6_init(const struct ctx *c)
memcpy(resp.server_id.duid_lladdr, c->mac, sizeof(c->mac));
memcpy(resp_not_on_link.server_id.duid_lladdr, c->mac, sizeof(c->mac));
- resp.ia_addr.addr = c->addr6;
+ resp.ia_addr.addr = c->ip6.addr;
}