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/common.c

    r3232 r3621  
    6363    { OPTION_U8                               , 0x85 }, /* DHCP_VLAN_PRIORITY */
    6464#endif
     65    { OPTION_STRING                           , 0xd1 }, /* DHCP_PXE_CONF_FILE */
     66    { OPTION_STRING                           , 0xd2 }, /* DHCP_PXE_PATH_PREFIX */
    6567    { OPTION_6RD                              , 0xd4 }, /* DHCP_6RD           */
    6668    { OPTION_STATIC_ROUTES | OPTION_LIST      , 0xf9 }, /* DHCP_MS_STATIC_ROUTES */
     
    129131    "vlanpriority" "\0"/* DHCP_VLAN_PRIORITY  */
    130132#endif
     133    "pxeconffile" "\0" /* DHCP_PXE_CONF_FILE  */
     134    "pxepathprefix" "\0" /* DHCP_PXE_PATH_PREFIX  */
    131135    "ip6rd" "\0"       /* DHCP_6RD            */
    132136    "msstaticroutes""\0"/* DHCP_MS_STATIC_ROUTES */
     
    139143 * xmalloc_optname_optval: to estimate string length
    140144 * from binary option length: (option[LEN] / dhcp_option_lengths[opt_type])
    141  * is the number of elements, multiply in by one element's string width
     145 * is the number of elements, multiply it by one element's string width
    142146 * (len_of_option_as_string[opt_type]) and you know how wide string you need.
    143147 */
     
    159163    /* Just like OPTION_STRING, we use minimum length here */
    160164    [OPTION_STATIC_ROUTES] = 5,
    161     [OPTION_6RD] =    22,  /* ignored by udhcp_str2optset */
     165    [OPTION_6RD] =    12,  /* ignored by udhcp_str2optset */
     166    /* The above value was chosen as follows:
     167     * len_of_option_as_string[] for this option is >60: it's a string of the form
     168     * "32 128 ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 255.255.255.255 ".
     169     * Each additional ipv4 address takes 4 bytes in binary option and appends
     170     * another "255.255.255.255 " 16-byte string. We can set [OPTION_6RD] = 4
     171     * but this severely overestimates string length: instead of 16 bytes,
     172     * it adds >60 for every 4 bytes in binary option.
     173     * We cheat and declare here that option is in units of 12 bytes.
     174     * This adds more than 60 bytes for every three ipv4 addresses - more than enough.
     175     * (Even 16 instead of 12 should work, but let's be paranoid).
     176     */
    162177};
    163178
     
    169184        char buf[256 * 2 + 2];
    170185        *bin2hex(buf, (void*) (opt + OPT_DATA), opt[OPT_LEN]) = '\0';
    171         bb_info_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
     186        bb_error_msg("%s: 0x%02x %s", pfx, opt[OPT_CODE], buf);
    172187    }
    173188}
     
    243258
    244259        if (optionptr[OPT_CODE] == code) {
    245             log_option("Option found", optionptr);
     260            log_option("option found", optionptr);
    246261            return optionptr + OPT_DATA;
    247262        }
     
    255270
    256271    /* log3 because udhcpc uses it a lot - very noisy */
    257     log3("Option 0x%02x not found", code);
     272    log3("option 0x%02x not found", code);
    258273    return NULL;
    259274}
     
    289304        return;
    290305    }
    291     log_option("Adding option", addopt);
     306    log_option("adding option", addopt);
    292307    memcpy(optionptr + end, addopt, len);
    293308    optionptr[end + len] = DHCP_END;
     
    372387        int length)
    373388{
    374     struct option_set *existing, *new, **curr;
    375     char *allocated = NULL;
     389    struct option_set *existing;
     390    char *allocated;
     391
     392    allocated = allocate_tempopt_if_needed(optflag, buffer, &length);
     393#if ENABLE_FEATURE_UDHCP_RFC3397
     394    if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
     395        /* reuse buffer and length for RFC1035-formatted string */
     396        allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length);
     397    }
     398#endif
    376399
    377400    existing = udhcp_find_option(*opt_list, optflag->code);
    378401    if (!existing) {
    379         log2("Attaching option %02x to list", optflag->code);
    380         allocated = allocate_tempopt_if_needed(optflag, buffer, &length);
    381 #if ENABLE_FEATURE_UDHCP_RFC3397
    382         if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
    383             /* reuse buffer and length for RFC1035-formatted string */
    384             allocated = buffer = (char *)dname_enc(NULL, 0, buffer, &length);
    385         }
    386 #endif
     402        struct option_set *new, **curr;
     403
    387404        /* make a new option */
     405        log2("attaching option %02x to list", optflag->code);
    388406        new = xmalloc(sizeof(*new));
    389407        new->data = xmalloc(length + OPT_DATA);
     
    405423
    406424        /* add it to an existing option */
    407         log2("Attaching option %02x to existing member of list", optflag->code);
    408         allocated = allocate_tempopt_if_needed(optflag, buffer, &length);
     425        log2("attaching option %02x to existing member of list", optflag->code);
    409426        old_len = existing->data[OPT_LEN];
    410 #if ENABLE_FEATURE_UDHCP_RFC3397
    411         if ((optflag->flags & OPTION_TYPE_MASK) == OPTION_DNS_STRING) {
    412             /* reuse buffer and length for RFC1035-formatted string */
    413             allocated = buffer = (char *)dname_enc(existing->data + OPT_DATA, old_len, buffer, &length);
    414         }
    415 #endif
    416427        if (old_len + length < 255) {
    417428            /* actually 255 is ok too, but adding a space can overlow it */
     
    425436                old_len++;
    426437            }
    427             memcpy(existing->data + OPT_DATA + old_len, buffer, length);
     438            memcpy(existing->data + OPT_DATA + old_len, (allocated ? allocated : buffer), length);
    428439            existing->data[OPT_LEN] = old_len + length;
    429440        } /* else, ignore the data, we could put this in a second option in the future */
Note: See TracChangeset for help on using the changeset viewer.