summaryrefslogtreecommitdiffstats
path: root/usr.sbin/dhcrelay/dispatch.c
diff options
context:
space:
mode:
authorreyk <reyk@openbsd.org>2009-09-03 11:56:49 +0000
committerreyk <reyk@openbsd.org>2009-09-03 11:56:49 +0000
commit4be048dca4230a1352c5616d1a20fc42358a7133 (patch)
treef6937065bbc4ab8b033fd812b158590c0cd5e03e /usr.sbin/dhcrelay/dispatch.c
parentmust call scsi_done before returning complete. (diff)
downloadwireguard-openbsd-4be048dca4230a1352c5616d1a20fc42358a7133.tar.xz
wireguard-openbsd-4be048dca4230a1352c5616d1a20fc42358a7133.zip
Add support for "DHCP-over-IPsec" by implementing RFC 3046 (DHCP Relay
Agent Information Option) and RFC 3456 (DHCP Configuration of IPsec Tunnel Mode). This allows to configure various IPsec clients dynamically via DHCP; dhcrelay needs to listen on enc0 and forward requests to a DHCP server that supports RFC 3046, like I recently did for dhcpd(8). ok krw@
Diffstat (limited to 'usr.sbin/dhcrelay/dispatch.c')
-rw-r--r--usr.sbin/dhcrelay/dispatch.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/usr.sbin/dhcrelay/dispatch.c b/usr.sbin/dhcrelay/dispatch.c
index cec8edd4760..19155f9b6a8 100644
--- a/usr.sbin/dhcrelay/dispatch.c
+++ b/usr.sbin/dhcrelay/dispatch.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: dispatch.c,v 1.8 2008/09/15 20:39:21 claudio Exp $ */
+/* $OpenBSD: dispatch.c,v 1.9 2009/09/03 11:56:49 reyk Exp $ */
/*
* Copyright 2004 Henning Brauer <henning@openbsd.org>
@@ -44,6 +44,8 @@
#include <sys/ioctl.h>
#include <net/if_media.h>
+#include <net/if_types.h>
+
#include <ifaddrs.h>
#include <poll.h>
@@ -90,10 +92,15 @@ discover_interfaces(struct interface_info *iface)
if (ifa->ifa_addr->sa_family == AF_LINK) {
struct sockaddr_dl *foo =
(struct sockaddr_dl *)ifa->ifa_addr;
+ struct if_data *ifi =
+ (struct if_data *)ifa->ifa_data;
iface->index = foo->sdl_index;
iface->hw_address.hlen = foo->sdl_alen;
- iface->hw_address.htype = HTYPE_ETHER; /* XXX */
+ if (ifi->ifi_type == IFT_ENC)
+ iface->hw_address.htype = HTYPE_IPSEC_TUNNEL;
+ else
+ iface->hw_address.htype = HTYPE_ETHER; /* XXX */
memcpy(iface->hw_address.haddr,
LLADDR(foo), foo->sdl_alen);
} else if (ifa->ifa_addr->sa_family == AF_INET) {