summaryrefslogtreecommitdiffstats
path: root/ipv6.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-11-19 16:15:45 +0000
committerRoy Marples <roy@marples.name>2016-11-19 16:15:45 +0000
commitfb7ef64c08a6d89000110f9e14177a55c8a89967 (patch)
tree368f446cae0336f53fdae8084c4ae7d9f179a99f /ipv6.c
parent2e59c4575995f6972e11910094a8a0b711e89693 (diff)
downloaddhcpcd-fb7ef64c08a6d89000110f9e14177a55c8a89967.tar.xz
Move ipv6_ctx into dhcpcd_ctx.
Diffstat (limited to 'ipv6.c')
-rw-r--r--ipv6.c38
1 files changed, 13 insertions, 25 deletions
diff --git a/ipv6.c b/ipv6.c
index 80bb5f1e..c51a1efb 100644
--- a/ipv6.c
+++ b/ipv6.c
@@ -127,22 +127,17 @@ static void ipv6_regentempaddr(void *);
#define ipv6_regentempifid(a) {}
#endif
-struct ipv6_ctx *
-ipv6_init(struct dhcpcd_ctx *dhcpcd_ctx)
+int
+ipv6_init(struct dhcpcd_ctx *ctx)
{
- struct ipv6_ctx *ctx;
-
- if (dhcpcd_ctx->ipv6)
- return dhcpcd_ctx->ipv6;
- ctx = calloc(1, sizeof(*ctx));
- if (ctx == NULL)
- return NULL;
+ if (ctx->sndhdr.msg_iovlen == 1)
+ return 0;
- ctx->ra_routers = malloc(sizeof(*ctx->ra_routers));
if (ctx->ra_routers == NULL) {
- free(ctx);
- return NULL;
+ ctx->ra_routers = malloc(sizeof(*ctx->ra_routers));
+ if (ctx->ra_routers == NULL)
+ return -1;
}
TAILQ_INIT(ctx->ra_routers);
@@ -153,18 +148,15 @@ ipv6_init(struct dhcpcd_ctx *dhcpcd_ctx)
ctx->sndhdr.msg_controllen = sizeof(ctx->sndbuf);
ctx->rcvhdr.msg_name = &ctx->from;
ctx->rcvhdr.msg_namelen = sizeof(ctx->from);
- ctx->rcvhdr.msg_iov = dhcpcd_ctx->iov;
+ ctx->rcvhdr.msg_iov = ctx->iov;
ctx->rcvhdr.msg_iovlen = 1;
ctx->rcvhdr.msg_control = ctx->ctlbuf;
// controllen is set at recieve
//ctx->rcvhdr.msg_controllen = sizeof(ctx->rcvbuf);
ctx->nd_fd = -1;
- ctx->dhcp_fd = -1;
-
- dhcpcd_ctx->ipv6 = ctx;
-
- return ctx;
+ ctx->dhcp6_fd = -1;
+ return 0;
}
static ssize_t
@@ -1657,7 +1649,7 @@ ipv6_freedrop(struct interface *ifp, int drop)
ipv6_freedrop_addrs(&state->addrs, drop ? 2 : 0, NULL);
if (drop) {
- if (ifp->ctx->ipv6 != NULL) {
+ if (ifp->ctx->ra_routers != NULL) {
if_initrt(ifp->ctx, AF_INET6);
rt_build(ifp->ctx, AF_INET6);
}
@@ -1674,12 +1666,8 @@ void
ipv6_ctxfree(struct dhcpcd_ctx *ctx)
{
- if (ctx->ipv6 == NULL)
- return;
-
+ free(ctx->ra_routers);
free(ctx->secret);
- free(ctx->ipv6->ra_routers);
- free(ctx->ipv6);
}
int
@@ -2226,7 +2214,7 @@ inet6_raroutes(struct rt_head *routes, struct dhcpcd_ctx *ctx, int expired,
int n;
n = 0;
- TAILQ_FOREACH(rap, ctx->ipv6->ra_routers, next) {
+ TAILQ_FOREACH(rap, ctx->ra_routers, next) {
if (rap->expired != expired)
continue;
if (rap->iface->options->options & DHCPCD_IPV6RA_OWN) {