diff options
| author | Roy Marples <roy@marples.name> | 2019-02-17 09:36:11 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2019-02-17 09:36:11 +0000 |
| commit | 590fc45d1c373b99d4fae7f8397d63194806b33a (patch) | |
| tree | 0889093e4169a97c9018befe96c3e802879190f8 /src/ipv6.c | |
| parent | 30433665d5cdd7bc4bf34bd7d1b8bb933e33c427 (diff) | |
| download | dhcpcd-590fc45d1c373b99d4fae7f8397d63194806b33a.tar.xz | |
Remove the send/recv structures from dhcpcd context and allocate
on stack as and when required.
Rather than peaking and checking for truncation for receiving,
just allocate a large enough buffer upfront.
Diffstat (limited to 'src/ipv6.c')
| -rw-r--r-- | src/ipv6.c | 23 |
1 files changed, 4 insertions, 19 deletions
@@ -129,29 +129,14 @@ int ipv6_init(struct dhcpcd_ctx *ctx) { - if (ctx->sndhdr.msg_iovlen == 1) + if (ctx->ra_routers != NULL) return 0; - if (ctx->ra_routers == NULL) { - ctx->ra_routers = malloc(sizeof(*ctx->ra_routers)); - if (ctx->ra_routers == NULL) - return -1; - } + ctx->ra_routers = malloc(sizeof(*ctx->ra_routers)); + if (ctx->ra_routers == NULL) + return -1; TAILQ_INIT(ctx->ra_routers); - ctx->sndhdr.msg_namelen = sizeof(struct sockaddr_in6); - ctx->sndhdr.msg_iov = ctx->sndiov; - ctx->sndhdr.msg_iovlen = 1; - ctx->sndhdr.msg_control = ctx->sndbuf; - ctx->sndhdr.msg_controllen = sizeof(ctx->sndbuf); - ctx->rcvhdr.msg_name = &ctx->from; - ctx->rcvhdr.msg_namelen = sizeof(ctx->from); - 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->dhcp6_fd = -1; return 0; |
