Learn the ARP entry of the DHCP server directly from the DHCP response
[project/relayd.git] / main.c
diff --git a/main.c b/main.c
index 1593583..a29be2c 100644 (file)
--- a/main.c
+++ b/main.c
@@ -1,3 +1,20 @@
+/*
+ *   Copyright (C) 2010 Felix Fietkau <nbd@openwrt.org>
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License v2 as published by
+ *   the Free Software Foundation.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
 #include <sys/ioctl.h>
 
 #include <arpa/inet.h>
@@ -519,6 +536,9 @@ static bool forward_dhcp_packet(struct relayd_interface *rif, void *data, int le
        if (!forward_dhcp)
                return true;
 
+       if (dhcp->op == 2)
+               refresh_host(rif, pkt->eth.ether_shost, (void *) &pkt->iph.saddr);
+
        DPRINTF(2, "%s: handling DHCP %s\n", rif->ifname, (dhcp->op == 1 ? "request" : "response"));
 
        dhcp->flags |= htons(DHCP_FLAG_BROADCAST);