- if (opt & OPT_a) {
- if (!arpping(packet.yiaddr,
- (uint32_t) 0,
- client_config.arp,
- client_config.interface)
- ) {
- bb_info_msg("offered address is in use "
- "(got ARP reply), declining");
-//NB: not clear whether it should be unicast or bcast.
-//Currently it is a bcast. Why?
- send_decline(xid, server_addr, packet.yiaddr);
-
- if (state != REQUESTING)
- udhcp_run_script(NULL, "deconfig");
- change_listen_mode(LISTEN_RAW);
- state = INIT_SELECTING;
- requested_ip = 0;
- timeout = tryagain_timeout;
- packet_num = 0;
- already_waited_sec = 0;
- continue; /* back to main loop */
- }
- }
-#endif
- /* enter bound state */
- timeout = lease_seconds / 2;
- {
- struct in_addr temp_addr;
- temp_addr.s_addr = packet.yiaddr;
- bb_info_msg("Lease of %s obtained, lease time %u",
- inet_ntoa(temp_addr), (unsigned)lease_seconds);
- }
- requested_ip = packet.yiaddr;
- udhcp_run_script(&packet,
- ((state == RENEWING || state == REBINDING) ? "renew" : "bound"));
-
- state = BOUND;
- change_listen_mode(LISTEN_NONE);
- if (opt & OPT_q) { /* quit after lease */
- if (opt & OPT_R) /* release on quit */
- perform_release(requested_ip, server_addr);
- goto ret0;
- }
-#if BB_MMU /* NOMMU case backgrounded earlier */
- if (!(opt & OPT_f)) {
- client_background();
- /* do not background again! */
- opt = ((opt & ~OPT_b) | OPT_f);
+ if (opt & OPT_a) {
+/* RFC 2131 3.1 paragraph 5:
+ * "The client receives the DHCPACK message with configuration
+ * parameters. The client SHOULD perform a final check on the
+ * parameters (e.g., ARP for allocated network address), and notes
+ * the duration of the lease specified in the DHCPACK message. At this
+ * point, the client is configured. If the client detects that the
+ * address is already in use (e.g., through the use of ARP),
+ * the client MUST send a DHCPDECLINE message to the server and restarts
+ * the configuration process..." */
+ if (!arpping(packet.yiaddr,
+ NULL,
+ (uint32_t) 0,
+ client_config.client_mac,
+ client_config.interface)
+ ) {
+ bb_info_msg("Offered address is in use "
+ "(got ARP reply), declining");
+ send_decline(xid, server_addr, packet.yiaddr);
+
+ if (state != REQUESTING)
+ udhcp_run_script(NULL, "deconfig");
+ change_listen_mode(LISTEN_RAW);
+ state = INIT_SELECTING;
+ requested_ip = 0;
+ timeout = tryagain_timeout;
+ packet_num = 0;
+ already_waited_sec = 0;
+ continue; /* back to main loop */