~ubuntu-branches/ubuntu/wily/dhcpcd5/wily-proposed

« back to all changes in this revision

Viewing changes to dhcpcd.c

  • Committer: Bazaar Package Importer
  • Author(s): Roy Marples
  • Date: 2011-03-06 10:16:22 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110306101622-lhkyhvv9u9rm2qpw
Tags: 5.2.12-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
528
528
                        log_dhcp(LOG_WARNING, "reject DHCP", iface, dhcp, from);
529
529
                        return;
530
530
                }
531
 
        }               
 
531
        }
 
532
 
 
533
        /* Ensure that the address offered is valid */
 
534
        if ((type == 0 || type == DHCP_OFFER || type == DHCP_ACK) &&
 
535
            (dhcp->ciaddr == INADDR_ANY || dhcp->ciaddr == INADDR_BROADCAST) &&
 
536
            (dhcp->yiaddr == INADDR_ANY || dhcp->yiaddr == INADDR_BROADCAST))
 
537
        {
 
538
                log_dhcp(LOG_WARNING, "reject invalid address",
 
539
                    iface, dhcp, from);
 
540
                return;
 
541
        }
532
542
 
533
543
        /* No NAK, so reset the backoff */
534
544
        state->nakoff = 1;
631
641
        const uint8_t *pp;
632
642
        ssize_t bytes;
633
643
        struct in_addr from;
634
 
        int i;
 
644
        int i, partialcsum = 0;
635
645
 
636
646
        /* We loop through until our buffer is empty.
637
647
         * The benefit is that if we get >1 DHCP packet in our buffer and
639
649
        packet = xmalloc(udp_dhcp_len);
640
650
        for(;;) {
641
651
                bytes = get_raw_packet(iface, ETHERTYPE_IP,
642
 
                    packet, udp_dhcp_len);
 
652
                    packet, udp_dhcp_len, &partialcsum);
643
653
                if (bytes == 0 || bytes == -1)
644
654
                        break;
645
 
                if (valid_udp_packet(packet, bytes, &from) == -1) {
 
655
                if (valid_udp_packet(packet, bytes, &from, partialcsum) == -1) {
646
656
                        syslog(LOG_ERR, "%s: invalid UDP packet from %s",
647
657
                            iface->name, inet_ntoa(from));
648
658
                        continue;
919
929
                else
920
930
                        add_timeout_sec(ifo->timeout, start_ipv4ll, iface);
921
931
        }
922
 
        syslog(LOG_INFO, "%s: broadcasting for a lease", iface->name);
 
932
        if (ifo->options & DHCPCD_REQUEST)
 
933
                syslog(LOG_INFO, "%s: broadcasting for a lease (requesting %s)",
 
934
                    iface->name, inet_ntoa(ifo->req_addr));
 
935
        else
 
936
                syslog(LOG_INFO, "%s: broadcasting for a lease", iface->name);
923
937
        send_discover(iface);
924
938
}
925
939
 
2011
2025
                                }
2012
2026
                        }
2013
2027
                }
 
2028
                if (options & DHCPCD_MASTER)
 
2029
                        i = if_options->timeout;
 
2030
                else
 
2031
                        i = ifaces->state->options->timeout;
2014
2032
                if (opt == 0 &&
2015
2033
                    options & DHCPCD_LINK &&
2016
2034
                    !(options & DHCPCD_WAITIP))
2017
2035
                {
2018
2036
                        syslog(LOG_WARNING, "no interfaces have a carrier");
2019
2037
                        daemonise();
2020
 
                } else if (if_options->timeout > 0) {
 
2038
                } else if (i > 0) {
2021
2039
                        if (options & DHCPCD_IPV4LL)
2022
2040
                                options |= DHCPCD_TIMEOUT_IPV4LL;
2023
 
                        add_timeout_sec(if_options->timeout,
2024
 
                            handle_exit_timeout, NULL);
 
2041
                        add_timeout_sec(i, handle_exit_timeout, NULL);
2025
2042
                }
2026
2043
        }
2027
2044
        free_options(if_options);