Ignore:
Timestamp:
Nov 4, 2007, 3:16:40 AM (16 years ago)
Author:
Bruno Cornec
Message:

Update to busybox 1.7.2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.5/mindi-busybox/networking/udhcp/options.c

    r821 r1765  
     1/* vi: set sw=4 ts=4: */
    12/*
    23 * options.c -- DHCP server option packet tools
     
    45 */
    56
    6 #include <stdlib.h>
    7 #include <string.h>
    8 
    97#include "common.h"
    108#include "dhcpd.h"
    119#include "options.h"
    12 #include "files.h"
    1310
    1411
    1512/* supported options are easily added here */
    16 struct dhcp_option dhcp_options[] = {
    17     /* name[10] flags                   code */
    18     {"subnet",  OPTION_IP | OPTION_REQ,         0x01},
    19     {"timezone",    OPTION_S32,             0x02},
    20     {"router",  OPTION_IP | OPTION_LIST | OPTION_REQ,   0x03},
    21     {"timesvr", OPTION_IP | OPTION_LIST,        0x04},
    22     {"namesvr", OPTION_IP | OPTION_LIST,        0x05},
    23     {"dns",     OPTION_IP | OPTION_LIST | OPTION_REQ,   0x06},
    24     {"logsvr",  OPTION_IP | OPTION_LIST,        0x07},
    25     {"cookiesvr",   OPTION_IP | OPTION_LIST,        0x08},
    26     {"lprsvr",  OPTION_IP | OPTION_LIST,        0x09},
    27     {"hostname",    OPTION_STRING | OPTION_REQ,     0x0c},
    28     {"bootsize",    OPTION_U16,             0x0d},
    29     {"domain",  OPTION_STRING | OPTION_REQ,     0x0f},
    30     {"swapsvr", OPTION_IP,              0x10},
    31     {"rootpath",    OPTION_STRING,              0x11},
    32     {"ipttl",   OPTION_U8,              0x17},
    33     {"mtu",     OPTION_U16,             0x1a},
    34     {"broadcast",   OPTION_IP | OPTION_REQ,         0x1c},
    35     {"nisdomain",   OPTION_STRING | OPTION_REQ,     0x28},
    36     {"nissrv",  OPTION_IP | OPTION_LIST | OPTION_REQ,   0x29},
    37     {"ntpsrv",  OPTION_IP | OPTION_LIST | OPTION_REQ,   0x2a},
    38     {"wins",    OPTION_IP | OPTION_LIST,        0x2c},
    39     {"requestip",   OPTION_IP,              0x32},
    40     {"lease",   OPTION_U32,             0x33},
    41     {"dhcptype",    OPTION_U8,              0x35},
    42     {"serverid",    OPTION_IP,              0x36},
    43     {"message", OPTION_STRING,              0x38},
    44     {"tftp",    OPTION_STRING,              0x42},
    45     {"bootfile",    OPTION_STRING,              0x43},
    46     {"",        0x00,               0x00}
     13const struct dhcp_option dhcp_options[] = {
     14    /* name[12]     flags                                   code */
     15    {"subnet",      OPTION_IP | OPTION_REQ,                 0x01},
     16    {"timezone",    OPTION_S32,                             0x02},
     17    {"router",      OPTION_IP | OPTION_LIST | OPTION_REQ,   0x03},
     18    {"timesvr",     OPTION_IP | OPTION_LIST,                0x04},
     19    {"namesvr",     OPTION_IP | OPTION_LIST,                0x05},
     20    {"dns",         OPTION_IP | OPTION_LIST | OPTION_REQ,   0x06},
     21    {"logsvr",      OPTION_IP | OPTION_LIST,                0x07},
     22    {"cookiesvr",   OPTION_IP | OPTION_LIST,                0x08},
     23    {"lprsvr",      OPTION_IP | OPTION_LIST,                0x09},
     24    {"hostname",    OPTION_STRING | OPTION_REQ,             0x0c},
     25    {"bootsize",    OPTION_U16,                             0x0d},
     26    {"domain",      OPTION_STRING | OPTION_LIST | OPTION_REQ, 0x0f},
     27    {"swapsvr",     OPTION_IP,                              0x10},
     28    {"rootpath",    OPTION_STRING,                          0x11},
     29    {"ipttl",       OPTION_U8,                              0x17},
     30    {"mtu",         OPTION_U16,                             0x1a},
     31    {"broadcast",   OPTION_IP | OPTION_REQ,                 0x1c},
     32    {"nisdomain",   OPTION_STRING | OPTION_REQ,             0x28},
     33    {"nissrv",      OPTION_IP | OPTION_LIST | OPTION_REQ,   0x29},
     34    {"ntpsrv",      OPTION_IP | OPTION_LIST | OPTION_REQ,   0x2a},
     35    {"wins",        OPTION_IP | OPTION_LIST,                0x2c},
     36    {"requestip",   OPTION_IP,                              0x32},
     37    {"lease",       OPTION_U32,                             0x33},
     38    {"dhcptype",    OPTION_U8,                              0x35},
     39    {"serverid",    OPTION_IP,                              0x36},
     40    {"message",     OPTION_STRING,                          0x38},
     41    {"vendorclass", OPTION_STRING,                          0x3C},
     42    {"clientid",    OPTION_STRING,                          0x3D},
     43    {"tftp",        OPTION_STRING,                          0x42},
     44    {"bootfile",    OPTION_STRING,                          0x43},
     45    {"userclass",   OPTION_STRING,                          0x4D},
     46#if ENABLE_FEATURE_RFC3397
     47    {"search",      OPTION_STR1035 | OPTION_LIST | OPTION_REQ, 0x77},
     48#endif
     49    /* MSIE's "Web Proxy Autodiscovery Protocol" support */
     50    {"wpad",        OPTION_STRING,                          0xfc},
     51    {"",            0x00,                                   0x00}
    4752};
    4853
    4954/* Lengths of the different option types */
    50 int option_lengths[] = {
    51     [OPTION_IP] =       4,
    52     [OPTION_IP_PAIR] =  8,
    53     [OPTION_BOOLEAN] =  1,
    54     [OPTION_STRING] =   1,
    55     [OPTION_U8] =       1,
    56     [OPTION_U16] =      2,
    57     [OPTION_S16] =      2,
    58     [OPTION_U32] =      4,
    59     [OPTION_S32] =      4
     55const unsigned char option_lengths[] ALIGN1 = {
     56    [OPTION_IP] =      4,
     57    [OPTION_IP_PAIR] = 8,
     58    [OPTION_BOOLEAN] = 1,
     59    [OPTION_STRING] =  1,
     60#if ENABLE_FEATURE_RFC3397
     61    [OPTION_STR1035] = 1,
     62#endif
     63    [OPTION_U8] =      1,
     64    [OPTION_U16] =     2,
     65    [OPTION_S16] =     2,
     66    [OPTION_U32] =     4,
     67    [OPTION_S32] =     4
    6068};
    6169
     
    7381    while (!done) {
    7482        if (i >= length) {
    75             LOG(LOG_WARNING, "bogus packet, option fields too long.");
     83            bb_error_msg("bogus packet, option fields too long");
    7684            return NULL;
    7785        }
    7886        if (optionptr[i + OPT_CODE] == code) {
    7987            if (i + 1 + optionptr[i + OPT_LEN] >= length) {
    80                 LOG(LOG_WARNING, "bogus packet, option fields too long.");
     88                bb_error_msg("bogus packet, option fields too long");
    8189                return NULL;
    8290            }
     
    8997        case DHCP_OPTION_OVER:
    9098            if (i + 1 + optionptr[i + OPT_LEN] >= length) {
    91                 LOG(LOG_WARNING, "bogus packet, option fields too long.");
     99                bb_error_msg("bogus packet, option fields too long");
    92100                return NULL;
    93101            }
     
    137145    /* end position + string length + option code/length + end option */
    138146    if (end + string[OPT_LEN] + 2 + 1 >= 308) {
    139         LOG(LOG_ERR, "Option 0x%02x did not fit into the packet!", string[OPT_CODE]);
     147        bb_error_msg("option 0x%02x did not fit into the packet",
     148                string[OPT_CODE]);
    140149        return 0;
    141150    }
    142     DEBUG(LOG_INFO, "adding option 0x%02x", string[OPT_CODE]);
     151    DEBUG("adding option 0x%02x", string[OPT_CODE]);
    143152    memcpy(optionptr + end, string, string[OPT_LEN] + 2);
    144153    optionptr[end + string[OPT_LEN] + 2] = DHCP_END;
     
    150159int add_simple_option(uint8_t *optionptr, uint8_t code, uint32_t data)
    151160{
    152     struct dhcp_option *dh;
     161    const struct dhcp_option *dh;
    153162
    154     for (dh=dhcp_options; dh->code; dh++) {
     163    for (dh = dhcp_options; dh->code; dh++) {
    155164        if (dh->code == code) {
    156165            uint8_t option[6], len;
     
    167176    }
    168177
    169     DEBUG(LOG_ERR, "Could not add option 0x%02x", code);
     178    bb_error_msg("cannot add option 0x%02x", code);
    170179    return 0;
    171180}
Note: See TracChangeset for help on using the changeset viewer.