"Robert P. J. Day" | 63fc1a9 | 2006-07-02 19:47:05 +0000 | [diff] [blame] | 1 | /* vi: set sw=4 ts=4: */ |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 2 | /* dhcpd.c |
| 3 | * |
| 4 | * udhcp Server |
| 5 | * Copyright (C) 1999 Matthew Ramsay <matthewr@moreton.com.au> |
| 6 | * Chris Trew <ctrew@moreton.com.au> |
| 7 | * |
| 8 | * Rewrite by Russ Dill <Russ.Dill@asu.edu> July 2001 |
| 9 | * |
Rob Landley | 3f78561 | 2006-05-28 01:06:36 +0000 | [diff] [blame] | 10 | * Licensed under GPLv2 or later, see file LICENSE in this tarball for details. |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 11 | */ |
| 12 | |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 13 | #include <syslog.h> |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 14 | #include "common.h" |
Denis Vlasenko | d55fe3e | 2008-02-04 13:12:16 +0000 | [diff] [blame] | 15 | #include "dhcpc.h" |
Denis Vlasenko | 5a3395b | 2006-11-18 19:51:32 +0000 | [diff] [blame] | 16 | #include "dhcpd.h" |
| 17 | #include "options.h" |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 18 | |
| 19 | |
| 20 | /* globals */ |
| 21 | struct dhcpOfferedAddr *leases; |
Denis Vlasenko | deabacd | 2007-09-30 17:55:43 +0000 | [diff] [blame] | 22 | /* struct server_config_t server_config is in bb_common_bufsiz1 */ |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 23 | |
| 24 | |
Denis Vlasenko | 9b49a5e | 2007-10-11 10:05:36 +0000 | [diff] [blame] | 25 | int udhcpd_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE; |
Denis Vlasenko | a60f84e | 2008-07-05 09:18:54 +0000 | [diff] [blame] | 26 | int udhcpd_main(int argc UNUSED_PARAM, char **argv) |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 27 | { |
| 28 | fd_set rfds; |
| 29 | struct timeval tv; |
Rob Landley | 9ffd423 | 2006-05-21 18:30:35 +0000 | [diff] [blame] | 30 | int server_socket = -1, bytes, retval, max_sock; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 31 | struct dhcpMessage packet; |
Rob Landley | 9ffd423 | 2006-05-21 18:30:35 +0000 | [diff] [blame] | 32 | uint8_t *state, *server_id, *requested; |
| 33 | uint32_t server_id_align, requested_align, static_lease_ip; |
Denis Vlasenko | 42b3dea | 2007-07-03 15:47:50 +0000 | [diff] [blame] | 34 | unsigned timeout_end; |
| 35 | unsigned num_ips; |
Denis Vlasenko | 3d17d2b | 2007-08-14 16:45:29 +0000 | [diff] [blame] | 36 | unsigned opt; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 37 | struct option_set *option; |
Rob Landley | 9ffd423 | 2006-05-21 18:30:35 +0000 | [diff] [blame] | 38 | struct dhcpOfferedAddr *lease, static_lease; |
Denis Vlasenko | d55fe3e | 2008-02-04 13:12:16 +0000 | [diff] [blame] | 39 | USE_FEATURE_UDHCP_PORT(char *str_P;) |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 40 | |
Denis Vlasenko | d55fe3e | 2008-02-04 13:12:16 +0000 | [diff] [blame] | 41 | #if ENABLE_FEATURE_UDHCP_PORT |
| 42 | SERVER_PORT = 67; |
| 43 | CLIENT_PORT = 68; |
| 44 | #endif |
| 45 | |
| 46 | opt = getopt32(argv, "fS" USE_FEATURE_UDHCP_PORT("P:", &str_P)); |
Denis Vlasenko | 9f7b92a | 2007-08-15 20:03:36 +0000 | [diff] [blame] | 47 | argv += optind; |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 48 | |
Denis Vlasenko | 3d17d2b | 2007-08-14 16:45:29 +0000 | [diff] [blame] | 49 | if (!(opt & 1)) { /* no -f */ |
Denis Vlasenko | c82b510 | 2007-07-01 17:05:57 +0000 | [diff] [blame] | 50 | bb_daemonize_or_rexec(0, argv); |
Denis Vlasenko | 4b924f3 | 2007-05-30 00:29:55 +0000 | [diff] [blame] | 51 | logmode &= ~LOGMODE_STDIO; |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 52 | } |
| 53 | |
Denis Vlasenko | 3d17d2b | 2007-08-14 16:45:29 +0000 | [diff] [blame] | 54 | if (opt & 2) { /* -S */ |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 55 | openlog(applet_name, LOG_PID, LOG_LOCAL0); |
| 56 | logmode |= LOGMODE_SYSLOG; |
| 57 | } |
Denis Vlasenko | d55fe3e | 2008-02-04 13:12:16 +0000 | [diff] [blame] | 58 | #if ENABLE_FEATURE_UDHCP_PORT |
| 59 | if (opt & 4) { /* -P */ |
| 60 | SERVER_PORT = xatou16(str_P); |
| 61 | CLIENT_PORT = SERVER_PORT + 1; |
| 62 | } |
| 63 | #endif |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 64 | /* Would rather not do read_config before daemonization - |
| 65 | * otherwise NOMMU machines will parse config twice */ |
Denis Vlasenko | 9f7b92a | 2007-08-15 20:03:36 +0000 | [diff] [blame] | 66 | read_config(argv[0] ? argv[0] : DHCPD_CONF_FILE); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 67 | |
Denis Vlasenko | 80edead | 2007-08-02 22:31:05 +0000 | [diff] [blame] | 68 | /* Make sure fd 0,1,2 are open */ |
| 69 | bb_sanitize_stdio(); |
| 70 | /* Equivalent of doing a fflush after every \n */ |
| 71 | setlinebuf(stdout); |
| 72 | |
| 73 | /* Create pidfile */ |
| 74 | write_pidfile(server_config.pidfile); |
| 75 | /* if (!..) bb_perror_msg("cannot create pidfile %s", pidfile); */ |
| 76 | |
Denis Vlasenko | def8898 | 2007-10-07 17:06:01 +0000 | [diff] [blame] | 77 | bb_info_msg("%s (v"BB_VER") started", applet_name); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 78 | |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 79 | option = find_option(server_config.options, DHCP_LEASE_TIME); |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 80 | server_config.lease = LEASE_TIME; |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 81 | if (option) { |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 82 | memcpy(&server_config.lease, option->data + 2, 4); |
| 83 | server_config.lease = ntohl(server_config.lease); |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 84 | } |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 85 | |
| 86 | /* Sanity check */ |
Denis Vlasenko | c82b510 | 2007-07-01 17:05:57 +0000 | [diff] [blame] | 87 | num_ips = server_config.end_ip - server_config.start_ip + 1; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 88 | if (server_config.max_leases > num_ips) { |
Denis Vlasenko | 42b3dea | 2007-07-03 15:47:50 +0000 | [diff] [blame] | 89 | bb_error_msg("max_leases=%u is too big, setting to %u", |
| 90 | (unsigned)server_config.max_leases, num_ips); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 91 | server_config.max_leases = num_ips; |
| 92 | } |
| 93 | |
Denis Vlasenko | c82b510 | 2007-07-01 17:05:57 +0000 | [diff] [blame] | 94 | leases = xzalloc(server_config.max_leases * sizeof(*leases)); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 95 | read_leases(server_config.lease_file); |
| 96 | |
Denis Vlasenko | f1980f6 | 2008-09-26 09:34:59 +0000 | [diff] [blame^] | 97 | if (udhcp_read_interface(server_config.interface, &server_config.ifindex, |
Denis Vlasenko | 80edead | 2007-08-02 22:31:05 +0000 | [diff] [blame] | 98 | &server_config.server, server_config.arp)) { |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 99 | retval = 1; |
| 100 | goto ret; |
| 101 | } |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 102 | |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 103 | /* Setup the signal pipe */ |
| 104 | udhcp_sp_setup(); |
| 105 | |
Denis Vlasenko | 42b3dea | 2007-07-03 15:47:50 +0000 | [diff] [blame] | 106 | timeout_end = monotonic_sec() + server_config.auto_time; |
Denis Vlasenko | 5a3395b | 2006-11-18 19:51:32 +0000 | [diff] [blame] | 107 | while (1) { /* loop until universe collapses */ |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 108 | |
Denis Vlasenko | e2d3ded | 2006-11-27 23:43:28 +0000 | [diff] [blame] | 109 | if (server_socket < 0) { |
Denis Vlasenko | f1980f6 | 2008-09-26 09:34:59 +0000 | [diff] [blame^] | 110 | server_socket = udhcp_listen_socket(/*INADDR_ANY,*/ SERVER_PORT, |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 111 | server_config.interface); |
Denis Vlasenko | e2d3ded | 2006-11-27 23:43:28 +0000 | [diff] [blame] | 112 | } |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 113 | |
| 114 | max_sock = udhcp_sp_fd_set(&rfds, server_socket); |
| 115 | if (server_config.auto_time) { |
Denis Vlasenko | 42b3dea | 2007-07-03 15:47:50 +0000 | [diff] [blame] | 116 | tv.tv_sec = timeout_end - monotonic_sec(); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 117 | tv.tv_usec = 0; |
| 118 | } |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 119 | retval = 0; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 120 | if (!server_config.auto_time || tv.tv_sec > 0) { |
| 121 | retval = select(max_sock + 1, &rfds, NULL, NULL, |
| 122 | server_config.auto_time ? &tv : NULL); |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 123 | } |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 124 | if (retval == 0) { |
| 125 | write_leases(); |
Denis Vlasenko | 42b3dea | 2007-07-03 15:47:50 +0000 | [diff] [blame] | 126 | timeout_end = monotonic_sec() + server_config.auto_time; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 127 | continue; |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 128 | } |
| 129 | if (retval < 0 && errno != EINTR) { |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 130 | DEBUG("error on select"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 131 | continue; |
| 132 | } |
| 133 | |
| 134 | switch (udhcp_sp_read(&rfds)) { |
| 135 | case SIGUSR1: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 136 | bb_info_msg("Received a SIGUSR1"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 137 | write_leases(); |
| 138 | /* why not just reset the timeout, eh */ |
Denis Vlasenko | 42b3dea | 2007-07-03 15:47:50 +0000 | [diff] [blame] | 139 | timeout_end = monotonic_sec() + server_config.auto_time; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 140 | continue; |
| 141 | case SIGTERM: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 142 | bb_info_msg("Received a SIGTERM"); |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 143 | goto ret0; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 144 | case 0: break; /* no signal */ |
| 145 | default: continue; /* signal or error (probably EINTR) */ |
| 146 | } |
| 147 | |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 148 | bytes = udhcp_recv_kernel_packet(&packet, server_socket); /* this waits for a packet - idle */ |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 149 | if (bytes < 0) { |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 150 | if (bytes == -1 && errno != EINTR) { |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 151 | DEBUG("error on read, %s, reopening socket", strerror(errno)); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 152 | close(server_socket); |
| 153 | server_socket = -1; |
| 154 | } |
| 155 | continue; |
| 156 | } |
| 157 | |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 158 | state = get_option(&packet, DHCP_MESSAGE_TYPE); |
| 159 | if (state == NULL) { |
Denis Vlasenko | a959588 | 2006-09-29 21:30:43 +0000 | [diff] [blame] | 160 | bb_error_msg("cannot get option from packet, ignoring"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 161 | continue; |
| 162 | } |
| 163 | |
| 164 | /* Look for a static lease */ |
| 165 | static_lease_ip = getIpByMac(server_config.static_leases, &packet.chaddr); |
| 166 | |
Denis Vlasenko | 5a3395b | 2006-11-18 19:51:32 +0000 | [diff] [blame] | 167 | if (static_lease_ip) { |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 168 | bb_info_msg("Found static lease: %x", static_lease_ip); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 169 | |
| 170 | memcpy(&static_lease.chaddr, &packet.chaddr, 16); |
| 171 | static_lease.yiaddr = static_lease_ip; |
| 172 | static_lease.expires = 0; |
| 173 | |
| 174 | lease = &static_lease; |
Denis Vlasenko | 5a3395b | 2006-11-18 19:51:32 +0000 | [diff] [blame] | 175 | } else { |
| 176 | lease = find_lease_by_chaddr(packet.chaddr); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | switch (state[0]) { |
| 180 | case DHCPDISCOVER: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 181 | DEBUG("Received DISCOVER"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 182 | |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 183 | if (send_offer(&packet) < 0) { |
Denis Vlasenko | a959588 | 2006-09-29 21:30:43 +0000 | [diff] [blame] | 184 | bb_error_msg("send OFFER failed"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 185 | } |
| 186 | break; |
| 187 | case DHCPREQUEST: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 188 | DEBUG("received REQUEST"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 189 | |
| 190 | requested = get_option(&packet, DHCP_REQUESTED_IP); |
| 191 | server_id = get_option(&packet, DHCP_SERVER_ID); |
| 192 | |
| 193 | if (requested) memcpy(&requested_align, requested, 4); |
| 194 | if (server_id) memcpy(&server_id_align, server_id, 4); |
| 195 | |
| 196 | if (lease) { |
| 197 | if (server_id) { |
| 198 | /* SELECTING State */ |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 199 | DEBUG("server_id = %08x", ntohl(server_id_align)); |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 200 | if (server_id_align == server_config.server && requested |
| 201 | && requested_align == lease->yiaddr |
| 202 | ) { |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 203 | send_ACK(&packet, lease->yiaddr); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 204 | } |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 205 | } else if (requested) { |
| 206 | /* INIT-REBOOT State */ |
| 207 | if (lease->yiaddr == requested_align) |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 208 | send_ACK(&packet, lease->yiaddr); |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 209 | else |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 210 | send_NAK(&packet); |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 211 | } else if (lease->yiaddr == packet.ciaddr) { |
| 212 | /* RENEWING or REBINDING State */ |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 213 | send_ACK(&packet, lease->yiaddr); |
| 214 | } else { /* don't know what to do!!!! */ |
| 215 | send_NAK(&packet); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 216 | } |
| 217 | |
| 218 | /* what to do if we have no record of the client */ |
| 219 | } else if (server_id) { |
| 220 | /* SELECTING State */ |
| 221 | |
| 222 | } else if (requested) { |
| 223 | /* INIT-REBOOT State */ |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 224 | lease = find_lease_by_yiaddr(requested_align); |
| 225 | if (lease) { |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 226 | if (lease_expired(lease)) { |
| 227 | /* probably best if we drop this lease */ |
| 228 | memset(lease->chaddr, 0, 16); |
| 229 | /* make some contention for this address */ |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 230 | } else |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 231 | send_NAK(&packet); |
Denis Vlasenko | c82b510 | 2007-07-01 17:05:57 +0000 | [diff] [blame] | 232 | } else { |
| 233 | uint32_t r = ntohl(requested_align); |
| 234 | if (r < server_config.start_ip |
| 235 | || r > server_config.end_ip |
| 236 | ) { |
Denis Vlasenko | 6de8994 | 2008-05-21 07:05:06 +0000 | [diff] [blame] | 237 | send_NAK(&packet); |
Denis Vlasenko | c82b510 | 2007-07-01 17:05:57 +0000 | [diff] [blame] | 238 | } |
Denis Vlasenko | e6bce97 | 2007-07-01 17:11:54 +0000 | [diff] [blame] | 239 | /* else remain silent */ |
| 240 | } |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 241 | |
| 242 | } else { |
Denis Vlasenko | af1c843 | 2007-03-26 13:22:35 +0000 | [diff] [blame] | 243 | /* RENEWING or REBINDING State */ |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 244 | } |
| 245 | break; |
| 246 | case DHCPDECLINE: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 247 | DEBUG("Received DECLINE"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 248 | if (lease) { |
| 249 | memset(lease->chaddr, 0, 16); |
| 250 | lease->expires = time(0) + server_config.decline_time; |
| 251 | } |
| 252 | break; |
| 253 | case DHCPRELEASE: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 254 | DEBUG("Received RELEASE"); |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 255 | if (lease) |
| 256 | lease->expires = time(0); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 257 | break; |
| 258 | case DHCPINFORM: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 259 | DEBUG("Received INFORM"); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 260 | send_inform(&packet); |
| 261 | break; |
| 262 | default: |
Denis Vlasenko | 3538b9a | 2006-09-06 18:36:50 +0000 | [diff] [blame] | 263 | bb_info_msg("Unsupported DHCP message (%02x) - ignoring", state[0]); |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 264 | } |
| 265 | } |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 266 | ret0: |
| 267 | retval = 0; |
| 268 | ret: |
Denis Vlasenko | 42b3dea | 2007-07-03 15:47:50 +0000 | [diff] [blame] | 269 | /*if (server_config.pidfile) - server_config.pidfile is never NULL */ |
Denis Vlasenko | 6e6d331 | 2007-05-03 23:39:35 +0000 | [diff] [blame] | 270 | remove_pidfile(server_config.pidfile); |
| 271 | return retval; |
Mike Frysinger | 7031f62 | 2006-05-08 03:20:50 +0000 | [diff] [blame] | 272 | } |