summaryrefslogtreecommitdiffstats
path: root/if-bsd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-04-11 16:14:55 +0000
committerRoy Marples <roy@marples.name>2008-04-11 16:14:55 +0000
commit1a60d14fa2f91876b9ec14d6e6c88d97dacf6c4c (patch)
tree9e992f64d969ddef2e7d3836afa0d4065f69706a /if-bsd.c
parent211da073490c5decd1deb46034385437a54ca977 (diff)
downloaddhcpcd-1a60d14fa2f91876b9ec14d6e6c88d97dacf6c4c.tar.xz
Normally I hate massive code drops, but heh.
The code has been drastically re-arranged. Instead of populating a custom structure while parsing dhcp messages, we now pluck what we need right out of the message itself. We have custom functions and a lookup table to make this really easy. This makes us more like dhclient and udhcpc, and will enable us to easily add (and remove!) more dhcp options without having to actually change the code (much). We now store the real dhcp message we got in /var/db/dhcpcd-$iface.lease, the mtime of the file being used as when we got the lease. This file is read in when re-using an old lease instead of parsing the .info file. The benefit of all of this means that we're actually ~15k smaller when compiled with the same features. This has been tested for quite some time, and I'm pretty sure most bugs with the 3.2 branch have been fixed whilst making this. Right now, we are 99% command line compatible with the 3.2 branch.
Diffstat (limited to 'if-bsd.c')
-rw-r--r--if-bsd.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/if-bsd.c b/if-bsd.c
index c6c64681..a352521d 100644
--- a/if-bsd.c
+++ b/if-bsd.c
@@ -48,7 +48,7 @@
#include "config.h"
#include "common.h"
#include "dhcp.h"
-#include "if.h"
+#include "net.h"
/* Darwin doesn't define this for some very odd reason */
#ifndef SA_SIZE
@@ -138,6 +138,8 @@ if_route(const char *ifname, const struct in_addr *destination,
else
rtm.hdr.rtm_type = RTM_DELETE;
rtm.hdr.rtm_flags = RTF_UP | RTF_STATIC;
+ if (netmask->s_addr == INADDR_BROADCAST)
+ rtm.hdr.rtm_flags |= RTF_HOST;
/* This order is important */
rtm.hdr.rtm_addrs = RTA_DST | RTA_GATEWAY | RTA_NETMASK;
@@ -153,15 +155,11 @@ if_route(const char *ifname, const struct in_addr *destination,
ADDADDR(destination);
- if (netmask->s_addr == INADDR_BROADCAST ||
- gateway->s_addr == INADDR_ANY)
+ if (gateway->s_addr == INADDR_ANY)
{
/* Make us a link layer socket */
- if (netmask->s_addr == INADDR_BROADCAST)
- rtm.hdr.rtm_flags |= RTF_HOST;
-
hwaddr = xmalloc(sizeof(unsigned char) * HWADDR_LEN);
- do_interface(ifname, hwaddr, &hwlen, NULL, false, false);
+ do_interface(ifname, hwaddr, &hwlen, NULL, 0, 0);
memset(&su, 0, sizeof(su));
su.sdl.sdl_len = sizeof(su.sdl);
su.sdl.sdl_family = AF_LINK;