diff options
| author | Roy Marples <roy@marples.name> | 2009-01-01 14:23:36 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2009-01-01 14:23:36 +0000 |
| commit | 91a44b91b06f127a98ae7f64e377e59d47eba329 (patch) | |
| tree | 6efaf365bf98aec1aa3be0e08c870700efc6f4af /dhcpcd.c | |
| parent | 32dd1d3c3e47045db22ea6b0f65ff0b82a21a153 (diff) | |
| download | dhcpcd-91a44b91b06f127a98ae7f64e377e59d47eba329.tar.xz | |
Add a static directive that allows the configuration of variables, which
supercedes any DHCP configured variables.
If ip_address is configured then we don't bother with a DHCP
transaction.
Diffstat (limited to 'dhcpcd.c')
| -rw-r--r-- | dhcpcd.c | 30 |
1 files changed, 28 insertions, 2 deletions
@@ -1,6 +1,6 @@ /* * dhcpcd - DHCP client daemon - * Copyright 2006-2008 Roy Marples <roy@marples.name> + * Copyright 2006-2009 Roy Marples <roy@marples.name> * All rights reserved * Redistribution and use in source and binary forms, with or without @@ -25,7 +25,7 @@ * SUCH DAMAGE. */ -const char copyright[] = "Copyright (c) 2006-2008 Roy Marples"; +const char copyright[] = "Copyright (c) 2006-2009 Roy Marples"; #include <sys/file.h> #include <sys/stat.h> @@ -778,6 +778,28 @@ start_reboot(struct interface *iface) send_request(iface); } +static void +start_static(struct interface *iface) +{ + struct dhcp_message *dhcp; + struct if_options *ifo = iface->state->options; + uint8_t *p; + uint32_t u32; + + dhcp = xzalloc(sizeof(*dhcp)); + dhcp->yiaddr = ifo->request_address.s_addr; + p = dhcp->options; + *p++ = DHO_SUBNETMASK; + *p++ = sizeof(u32); + u32 = ifo->request_netmask.s_addr; + memcpy(p, &u32, sizeof(u32)); + *p++ = DHO_END; + + iface->state->offer = dhcp; + delete_timeout(NULL, iface); + bind_interface(iface); +} + void start_interface(void *arg) { @@ -800,6 +822,10 @@ start_interface(void *arg) start_discover(iface); return; } + if (ifo->options & DHCPCD_STATIC) { + start_static(iface); + return; + } if (ifo->request_address.s_addr) { /* This also changes netmask */ if (iface->state->options->options & DHCPCD_INFORM && |
