Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/networking/udhcp/leases.c

    r3232 r3621  
    1818     * and therefore can't ever match */
    1919    for (i = 0; i < server_config.max_leases; i++) {
    20         if (g_leases[i].expires < oldest_time) {
     20        if (g_leases[i].expires == 0 /* empty entry */
     21         || g_leases[i].expires < oldest_time
     22        ) {
    2123            oldest_time = g_leases[i].expires;
    2224            oldest_lease = &g_leases[i];
     
    6668                hostname_len = sizeof(oldest->hostname);
    6769            p = safe_strncpy(oldest->hostname, hostname, hostname_len);
    68             /* sanitization (s/non-ASCII/^/g) */
     70            /*
     71             * Sanitization (s/bad_char/./g).
     72             * The intent is not to allow only "DNS-valid" hostnames,
     73             * but merely make dumpleases output safe for shells to use.
     74             * We accept "0-9A-Za-z._-", all other chars turn to dots.
     75             */
    6976            while (*p) {
    70                 if (*p < ' ' || *p > 126)
    71                     *p = '^';
     77                if (!isalnum(*p) && *p != '-' && *p != '_')
     78                    *p = '.';
    7279                p++;
    7380            }
     
    113120
    114121/* Check if the IP is taken; if it is, add it to the lease table */
    115 static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac)
     122static int nobody_responds_to_arp(uint32_t nip, const uint8_t *safe_mac, unsigned arpping_ms)
    116123{
    117124    struct in_addr temp;
     
    121128            server_config.server_nip,
    122129            server_config.server_mac,
    123             server_config.interface);
     130            server_config.interface,
     131            arpping_ms);
    124132    if (r)
    125133        return r;
    126134
    127135    temp.s_addr = nip;
    128     bb_info_msg("%s belongs to someone, reserving it for %u seconds",
     136    bb_error_msg("%s belongs to someone, reserving it for %u seconds",
    129137        inet_ntoa(temp), (unsigned)server_config.conflict_time);
    130138    add_lease(NULL, nip, server_config.conflict_time, NULL, 0);
     
    133141
    134142/* Find a new usable (we think) address */
    135 uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac)
     143uint32_t FAST_FUNC find_free_or_expired_nip(const uint8_t *safe_mac, unsigned arpping_ms)
    136144{
    137145    uint32_t addr;
     
    178186        if (!lease) {
    179187//TODO: DHCP servers do not always sit on the same subnet as clients: should *ping*, not arp-ping!
    180             if (nobody_responds_to_arp(nip, safe_mac))
     188            if (nobody_responds_to_arp(nip, safe_mac, arpping_ms))
    181189                return nip;
    182190        } else {
     
    195203    if (oldest_lease
    196204     && is_expired_lease(oldest_lease)
    197      && nobody_responds_to_arp(oldest_lease->lease_nip, safe_mac)
     205     && nobody_responds_to_arp(oldest_lease->lease_nip, safe_mac, arpping_ms)
    198206    ) {
    199207        return oldest_lease->lease_nip;
Note: See TracChangeset for help on using the changeset viewer.