diff options
author | Hans Dedecker <dedeckeh@gmail.com> | 2014-07-01 21:26:34 +0200 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2014-07-01 21:46:32 +0200 |
commit | 1bbf34a1df3e16865b3b9330b338952076bc26f9 (patch) | |
tree | bb78767e3f84b2683cc20ad00e5a20eaf8eb735d /src/odhcpd.c | |
parent | 4267915aef64aae345972c77148b11759a172b14 (diff) |
DHCPv6 destination address check
As described in RFC3315 §15 any solicit, confirm, rebind or information request message is discarded if the destination address is unicast
Likewise any request (§18.2.1), renew (§18.2.3), release (§18.2.6) or decline (§18.2.7) message is discarded and the server replies with the status code use multicast.
Diffstat (limited to 'src/odhcpd.c')
-rw-r--r-- | src/odhcpd.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/odhcpd.c b/src/odhcpd.c index bf9f16d..794bbfc 100644 --- a/src/odhcpd.c +++ b/src/odhcpd.c @@ -319,6 +319,7 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even // Extract destination interface int destiface = 0; int *hlim = NULL; + void *dest = NULL; struct in6_pktinfo *pktinfo; struct in_pktinfo *pkt4info; for (struct cmsghdr *ch = CMSG_FIRSTHDR(&msg); ch != NULL; ch = CMSG_NXTHDR(&msg, ch)) { @@ -326,10 +327,12 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even ch->cmsg_type == IPV6_PKTINFO) { pktinfo = (struct in6_pktinfo*)CMSG_DATA(ch); destiface = pktinfo->ipi6_ifindex; + dest = &pktinfo->ipi6_addr; } else if (ch->cmsg_level == IPPROTO_IP && ch->cmsg_type == IP_PKTINFO) { pkt4info = (struct in_pktinfo*)CMSG_DATA(ch); destiface = pkt4info->ipi_ifindex; + dest = &pkt4info->ipi_addr; } else if (ch->cmsg_level == IPPROTO_IPV6 && ch->cmsg_type == IPV6_HOPLIMIT) { hlim = (int*)CMSG_DATA(ch); @@ -363,7 +366,7 @@ static void odhcpd_receive_packets(struct uloop_fd *u, _unused unsigned int even syslog(LOG_DEBUG, "Received %li Bytes from %s%%%s", (long)len, ipbuf, (iface) ? iface->ifname : "netlink"); - e->handle_dgram(&addr, data_buf, len, iface); + e->handle_dgram(&addr, data_buf, len, iface, dest); } } |