]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP_option -> DHO_option.
authorRoy Marples <roy@marples.name>
Fri, 8 Aug 2008 17:55:48 +0000 (17:55 +0000)
committerRoy Marples <roy@marples.name>
Fri, 8 Aug 2008 17:55:48 +0000 (17:55 +0000)
client.c
configure.c
dhcp.c
dhcp.h
dhcpcd.c

index 7b1ad813347416a26ed9290242904dd6e6d6db1e..ebf176421cf33beef82ba5b28e88e7f6cef3559f 100644 (file)
--- a/client.c
+++ b/client.c
@@ -360,17 +360,17 @@ ipv4ll_get_dhcp(uint32_t old_addr)
        dhcp = xzalloc(sizeof(*dhcp));
        /* Put some LL options in */
        p = dhcp->options;
-       *p++ = DHCP_SUBNETMASK;
+       *p++ = DHO_SUBNETMASK;
        *p++ = sizeof(u32);
        u32 = htonl(LINKLOCAL_MASK);
        memcpy(p, &u32, sizeof(u32));
        p += sizeof(u32);
-       *p++ = DHCP_BROADCAST;
+       *p++ = DHO_BROADCAST;
        *p++ = sizeof(u32);
        u32 = htonl(LINKLOCAL_BRDC);
        memcpy(p, &u32, sizeof(u32));
        p += sizeof(u32);
-       *p++ = DHCP_END;
+       *p++ = DHO_END;
 
        for (;;) {
                dhcp->yiaddr = htonl(LINKLOCAL_ADDR |
@@ -397,9 +397,9 @@ get_lease(struct dhcp_lease *lease, const struct dhcp_message *dhcp)
        lease->frominfo = 0;
        lease->addr.s_addr = dhcp->yiaddr;
 
-       if (get_option_addr(&lease->net.s_addr, dhcp, DHCP_SUBNETMASK) == -1)
+       if (get_option_addr(&lease->net.s_addr, dhcp, DHO_SUBNETMASK) == -1)
                lease->net.s_addr = get_netmask(dhcp->yiaddr);
-       if (get_option_uint32(&lease->leasetime, dhcp, DHCP_LEASETIME) == 0) {
+       if (get_option_uint32(&lease->leasetime, dhcp, DHO_LEASETIME) == 0) {
                /* Ensure that we can use the lease */
                t = 0;
                if (t + (time_t)lease->leasetime < t) {
@@ -409,9 +409,9 @@ get_lease(struct dhcp_lease *lease, const struct dhcp_message *dhcp)
                }
        } else
                lease->leasetime = DEFAULT_LEASETIME;
-       if (get_option_uint32(&lease->renewaltime, dhcp, DHCP_RENEWALTIME) != 0)
+       if (get_option_uint32(&lease->renewaltime, dhcp, DHO_RENEWALTIME) != 0)
                lease->renewaltime = 0;
-       if (get_option_uint32(&lease->rebindtime, dhcp, DHCP_REBINDTIME) != 0)
+       if (get_option_uint32(&lease->rebindtime, dhcp, DHO_REBINDTIME) != 0)
                lease->rebindtime = 0;
 }
 
@@ -1354,12 +1354,12 @@ log_dhcp(int lvl, const char *msg, const struct dhcp_message *dhcp)
        int r;
 
        if (strcmp(msg, "NAK:") == 0)
-               a = get_option_string(dhcp, DHCP_MESSAGE);
+               a = get_option_string(dhcp, DHO_MESSAGE);
        else {
                addr.s_addr = dhcp->yiaddr;
                a = xstrdup(inet_ntoa(addr));
        }
-       r = get_option_addr(&addr.s_addr, dhcp, DHCP_SERVERID);
+       r = get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID);
        if (dhcp->servername[0] && r == 0)
                logger(lvl, "%s %s from %s `%s'", msg, a,
                       inet_ntoa(addr), dhcp->servername);
@@ -1386,7 +1386,7 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp,
        state->messages = 0;
 
        /* We have to have DHCP type to work */
-       if (get_option_uint8(&type, dhcp, DHCP_MESSAGETYPE) == -1) {
+       if (get_option_uint8(&type, dhcp, DHO_MESSAGETYPE) == -1) {
                log_dhcp(LOG_ERR, "no DHCP type in", dhcp);
                return 0;
        }
@@ -1395,7 +1395,7 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp,
         * We should expand this to check IP and/or hardware address
         * at the packet level. */
        if (options->blacklist_len != 0 &&
-           get_option_addr(&addr.s_addr, dhcp, DHCP_SERVERID) == 0)
+           get_option_addr(&addr.s_addr, dhcp, DHO_SERVERID) == 0)
        {
                for (i = 0; i < options->blacklist_len; i++) {
                        if (options->blacklist[i] != addr.s_addr)
@@ -1437,7 +1437,7 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp,
 
        if (type == DHCP_OFFER && state->state == STATE_DISCOVERING) {
                lease->addr.s_addr = dhcp->yiaddr;
-               get_option_addr(&lease->server.s_addr, dhcp, DHCP_SERVERID);
+               get_option_addr(&lease->server.s_addr, dhcp, DHO_SERVERID);
                log_dhcp(LOG_INFO, "offered", dhcp);
                if (state->options & DHCPCD_TEST) {
                        exec_script(options, iface->name, "TEST", dhcp, NULL);
@@ -1466,7 +1466,7 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp,
        case STATE_REBINDING:
                if (!(state->options & DHCPCD_INFORM)) {
                        get_option_addr(&lease->server.s_addr,
-                                       dhcp, DHCP_SERVERID);
+                                       dhcp, DHO_SERVERID);
                        log_dhcp(LOG_INFO, "acknowledged", dhcp);
                }
                break;
@@ -1560,10 +1560,10 @@ handle_dhcp_packet(struct if_state *state, const struct options *options)
                 * if we have space for the terminator */
                if ((size_t)bytes < sizeof(struct dhcp_message)) {
                        p = (uint8_t *)dhcp + bytes - 1;
-                       while (p > dhcp->options && *p == DHCP_PAD)
+                       while (p > dhcp->options && *p == DHO_PAD)
                                p--;
-                       if (*p != DHCP_END)
-                               *++p = DHCP_END;
+                       if (*p != DHO_END)
+                               *++p = DHO_END;
                }
                retval = handle_dhcp(state, &dhcp, options);
                if (retval == 0 && state->options & DHCPCD_TEST)
index 536fd1fccf25d3fe6dfc4f664818580d28a8ebcf..0f50604911f231d4a3393daa8a647bd690347d35 100644 (file)
@@ -438,9 +438,9 @@ configure(struct interface *iface, const char *reason,
        else {
                addr.s_addr = dhcp->yiaddr;
                /* Ensure we have all the needed values */
-               if (get_option_addr(&net.s_addr, dhcp, DHCP_SUBNETMASK) == -1)
+               if (get_option_addr(&net.s_addr, dhcp, DHO_SUBNETMASK) == -1)
                        net.s_addr = get_netmask(addr.s_addr);
-               if (get_option_addr(&brd.s_addr, dhcp, DHCP_BROADCAST) == -1)
+               if (get_option_addr(&brd.s_addr, dhcp, DHO_BROADCAST) == -1)
                        brd.s_addr = addr.s_addr | ~net.s_addr;
        }
 
diff --git a/dhcp.c b/dhcp.c
index be59c9ba5ccef199a96139eb3f65b2acbe0c8b26..b0e962bd7ddbbf050951bd454e59412723d9297c 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -269,9 +269,9 @@ get_option(const struct dhcp_message *dhcp, uint8_t opt, int *len, int *type)
                        bl += ol;
                }
                switch (o) {
-               case DHCP_PAD:
+               case DHO_PAD:
                        continue;
-               case DHCP_END:
+               case DHO_END:
                        if (overl & 1) {
                                /* bit 1 set means parse boot file */
                                overl &= ~1;
@@ -285,7 +285,7 @@ get_option(const struct dhcp_message *dhcp, uint8_t opt, int *len, int *type)
                        } else
                                goto exit;
                        break;
-               case DHCP_OPTIONSOVERLOADED:
+               case DHO_OPTIONSOVERLOADED:
                        /* Ensure we only get this option once */
                        if (!overl)
                                overl = p[1];
@@ -657,10 +657,10 @@ get_option_routes(const struct dhcp_message *dhcp)
        int len;
 
        /* If we have CSR's then we MUST use these only */
-       p = get_option(dhcp, DHCP_CSR, &len, NULL);
+       p = get_option(dhcp, DHO_CSR, &len, NULL);
        /* Check for crappy MS option */
        if (!p)
-               p = get_option(dhcp, DHCP_MSCSR, &len, NULL);
+               p = get_option(dhcp, DHO_MSCSR, &len, NULL);
        if (p) {
                routes = decode_rfc3442_rt(len, p);
                if (routes)
@@ -668,7 +668,7 @@ get_option_routes(const struct dhcp_message *dhcp)
        }
 
        /* OK, get our static routes first. */
-       p = get_option(dhcp, DHCP_STATICROUTE, &len, NULL);
+       p = get_option(dhcp, DHO_STATICROUTE, &len, NULL);
        if (p) {
                e = p + len;
                while (p < e) {
@@ -687,7 +687,7 @@ get_option_routes(const struct dhcp_message *dhcp)
        }
 
        /* Now grab our routers */
-       p = get_option(dhcp, DHCP_ROUTER, &len, NULL);
+       p = get_option(dhcp, DHO_ROUTER, &len, NULL);
        if (p) {
                e = p + len;
                while (p < e) {
@@ -788,12 +788,12 @@ make_message(struct dhcp_message **message,
        dhcp->xid = xid;
        dhcp->cookie = htonl(MAGIC_COOKIE);
 
-       *p++ = DHCP_MESSAGETYPE; 
+       *p++ = DHO_MESSAGETYPE; 
        *p++ = 1;
        *p++ = type;
 
        if (type == DHCP_REQUEST) {
-               *p++ = DHCP_MAXMESSAGESIZE;
+               *p++ = DHO_MAXMESSAGESIZE;
                *p++ = 2;
                sz = get_mtu(iface->name);
                if (sz < MTU_MIN) {
@@ -806,20 +806,20 @@ make_message(struct dhcp_message **message,
        }
 
        if (iface->clientid) {
-               *p++ = DHCP_CLIENTID;
+               *p++ = DHO_CLIENTID;
                memcpy(p, iface->clientid, iface->clientid[0] + 1);
                p += iface->clientid[0] + 1;
        }
 
        if (type != DHCP_DECLINE && type != DHCP_RELEASE) {
                if (options->userclass[0]) {
-                       *p++ = DHCP_USERCLASS;
+                       *p++ = DHO_USERCLASS;
                        memcpy(p, options->userclass, options->userclass[0] + 1);
                        p += options->userclass[0] + 1;
                }
 
                if (options->classid[0]) {
-                       *p++ = DHCP_CLASSID;
+                       *p++ = DHO_CLASSID;
                        memcpy(p, options->classid, options->classid[0] + 1);
                        p += options->classid[0] + 1;
                }
@@ -837,14 +837,14 @@ make_message(struct dhcp_message **message,
                    lease->addr.s_addr != iface->addr.s_addr &&
                    !IN_LINKLOCAL(ntohl(lease->addr.s_addr)))
                {
-                       PUTADDR(DHCP_IPADDRESS, lease->addr);
+                       PUTADDR(DHO_IPADDRESS, lease->addr);
                        if (lease->server.s_addr)
-                               PUTADDR(DHCP_SERVERID, lease->server);
+                               PUTADDR(DHO_SERVERID, lease->server);
                }
 #undef PUTADDR
 
                if (options->leasetime != 0) {
-                       *p++ = DHCP_LEASETIME;
+                       *p++ = DHO_LEASETIME;
                        *p++ = 4;
                        ul = htonl(options->leasetime);
                        memcpy(p, &ul, 4);
@@ -857,13 +857,13 @@ make_message(struct dhcp_message **message,
            type == DHCP_REQUEST)
        {
                if (options->hostname[0]) {
-                       *p++ = DHCP_HOSTNAME;
+                       *p++ = DHO_HOSTNAME;
                        memcpy(p, options->hostname, options->hostname[0] + 1);
                        p += options->hostname[0] + 1;
                }
                if (options->fqdn != FQDN_DISABLE) {
                        /* IETF DHC-FQDN option (81), RFC4702 */
-                       *p++ = DHCP_FQDN;
+                       *p++ = DHO_FQDN;
                        lp = p;
                        *p++ = 3;
                        /*
@@ -887,12 +887,12 @@ make_message(struct dhcp_message **message,
 
                /* vendor is already encoded correctly, so just add it */
                if (options->vendor[0]) {
-                       *p++ = DHCP_VENDOR;
+                       *p++ = DHO_VENDOR;
                        memcpy(p, options->vendor, options->vendor[0] + 1);
                        p += options->vendor[0] + 1;
                }
 
-               *p++ = DHCP_PARAMETERREQUESTLIST;
+               *p++ = DHO_PARAMETERREQUESTLIST;
                n_params = p;
                *p++ = 0;
                for (opt = dhcp_opts; opt->option; opt++) {
@@ -900,8 +900,8 @@ make_message(struct dhcp_message **message,
                              has_reqmask(options->reqmask, opt->option)))
                                continue;
                        switch (opt->option) {
-                       case DHCP_RENEWALTIME:  /* FALLTHROUGH */
-                       case DHCP_REBINDTIME:
+                       case DHO_RENEWALTIME:   /* FALLTHROUGH */
+                       case DHO_REBINDTIME:
                                if (type == DHCP_INFORM)
                                        continue;
                                break;
@@ -910,14 +910,14 @@ make_message(struct dhcp_message **message,
                }
                *n_params = p - n_params - 1;
        }
-       *p++ = DHCP_END;
+       *p++ = DHO_END;
 
 #ifdef BOOTP_MESSAGE_LENTH_MIN
        /* Some crappy DHCP servers think they have to obey the BOOTP minimum
         * message length.
         * They are wrong, but we should still cater for them. */
        while (p - m < BOOTP_MESSAGE_LENTH_MIN)
-               *p++ = DHCP_PAD;
+               *p++ = DHO_PAD;
 #endif
 
        *message = dhcp;
@@ -941,12 +941,12 @@ write_lease(const struct interface *iface, const struct dhcp_message *dhcp)
        /* Only write as much as we need */
        while (p < e) {
                o = *p;
-               if (o == DHCP_END) {
+               if (o == DHO_END) {
                        bytes = p - (const uint8_t *)dhcp;
                        break;
                }
                p++;
-               if (o != DHCP_PAD) {
+               if (o != DHO_PAD) {
                        l = *p++;
                        p += l;
                }
@@ -1159,7 +1159,7 @@ configure_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
        char cidr[4];
        uint8_t overl = 0;
 
-       get_option_uint8(&overl, dhcp, DHCP_OPTIONSOVERLOADED);
+       get_option_uint8(&overl, dhcp, DHO_OPTIONSOVERLOADED);
 
        if (!env) {
                for (opt = dhcp_opts; opt->option; opt++) {
@@ -1185,14 +1185,14 @@ configure_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
                 * message but are not necessarily in the options */
                addr.s_addr = dhcp->yiaddr;
                setvar(&ep, prefix, "ip_address", inet_ntoa(addr));
-               if (get_option_addr(&net.s_addr, dhcp, DHCP_SUBNETMASK) == -1) {
+               if (get_option_addr(&net.s_addr, dhcp, DHO_SUBNETMASK) == -1) {
                        net.s_addr = get_netmask(addr.s_addr);
                        setvar(&ep, prefix, "subnet_mask", inet_ntoa(net));
                }
                i = inet_ntocidr(net);
                snprintf(cidr, sizeof(cidr), "%d", inet_ntocidr(net));
                setvar(&ep, prefix, "subnet_cidr", cidr);
-               if (get_option_addr(&brd.s_addr, dhcp, DHCP_BROADCAST) == -1) {
+               if (get_option_addr(&brd.s_addr, dhcp, DHO_BROADCAST) == -1) {
                        brd.s_addr = addr.s_addr | ~net.s_addr;
                        setvar(&ep, prefix, "broadcast_address", inet_ntoa(net));
                }
@@ -1215,7 +1215,7 @@ configure_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
                if (!p)
                        continue;
                /* We only want the FQDN name */
-               if (opt->option == DHCP_FQDN) {
+               if (opt->option == DHO_FQDN) {
                        p += 3;
                        pl -= 3;
                }
diff --git a/dhcp.h b/dhcp.h
index 0a92323a92cbe4d776222b1c8ac8f0f1d634e9f5..b5e0a33a504e8e0439fad085aed494b1daab3c63 100644 (file)
--- a/dhcp.h
+++ b/dhcp.h
 #define DHCP_INFORM         8
 
 /* DHCP options */
-enum DHCP_OPTIONS
+enum DHO
 {
-       DHCP_PAD                    = 0,
-       DHCP_SUBNETMASK             = 1,
-       DHCP_ROUTER                 = 3,
-       DHCP_DNSSERVER              = 6,
-       DHCP_HOSTNAME               = 12,
-       DHCP_DNSDOMAIN              = 15,
-       DHCP_MTU                    = 26,
-       DHCP_BROADCAST              = 28,
-       DHCP_STATICROUTE            = 33,
-       DHCP_NISDOMAIN              = 40,
-       DHCP_NISSERVER              = 41,
-       DHCP_NTPSERVER              = 42,
-       DHCP_VENDOR                 = 43,
-       DHCP_IPADDRESS              = 50,
-       DHCP_LEASETIME              = 51,
-       DHCP_OPTIONSOVERLOADED      = 52,
-       DHCP_MESSAGETYPE            = 53,
-       DHCP_SERVERID               = 54,
-       DHCP_PARAMETERREQUESTLIST   = 55,
-       DHCP_MESSAGE                = 56,
-       DHCP_MAXMESSAGESIZE         = 57,
-       DHCP_RENEWALTIME            = 58,
-       DHCP_REBINDTIME             = 59,
-       DHCP_CLASSID                = 60,
-       DHCP_CLIENTID               = 61,
-       DHCP_USERCLASS              = 77,  /* RFC 3004 */
-       DHCP_FQDN                   = 81,
-       DHCP_DNSSEARCH              = 119, /* RFC 3397 */
-       DHCP_CSR                    = 121, /* RFC 3442 */
-       DHCP_MSCSR                  = 249, /* MS code for RFC 3442 */
-       DHCP_END                    = 255
+       DHO_PAD                    = 0,
+       DHO_SUBNETMASK             = 1,
+       DHO_ROUTER                 = 3,
+       DHO_DNSSERVER              = 6,
+       DHO_HOSTNAME               = 12,
+       DHO_DNSDOMAIN              = 15,
+       DHO_MTU                    = 26,
+       DHO_BROADCAST              = 28,
+       DHO_STATICROUTE            = 33,
+       DHO_NISDOMAIN              = 40,
+       DHO_NISSERVER              = 41,
+       DHO_NTPSERVER              = 42,
+       DHO_VENDOR                 = 43,
+       DHO_IPADDRESS              = 50,
+       DHO_LEASETIME              = 51,
+       DHO_OPTIONSOVERLOADED      = 52,
+       DHO_MESSAGETYPE            = 53,
+       DHO_SERVERID               = 54,
+       DHO_PARAMETERREQUESTLIST   = 55,
+       DHO_MESSAGE                = 56,
+       DHO_MAXMESSAGESIZE         = 57,
+       DHO_RENEWALTIME            = 58,
+       DHO_REBINDTIME             = 59,
+       DHO_CLASSID                = 60,
+       DHO_CLIENTID               = 61,
+       DHO_USERCLASS              = 77,  /* RFC 3004 */
+       DHO_FQDN                   = 81,
+       DHO_DNSSEARCH              = 119, /* RFC 3397 */
+       DHO_CSR                    = 121, /* RFC 3442 */
+       DHO_MSCSR                  = 249, /* MS code for RFC 3442 */
+       DHO_END                    = 255
 };
 
-/* SetFQDNHostName values - lsnybble used in flags
- * byte (see buildmsg.c), hsnybble to create order
+/* FQDN values - lsnybble used in flags
+ * hsnybble to create order
  * and to allow 0x00 to mean disable
  */
 enum FQDN {
@@ -108,14 +108,6 @@ enum FQDN {
        FQDN_BOTH       = 0x31
 };
 
-struct fqdn
-{
-       uint8_t flags;
-       uint8_t r1;
-       uint8_t r2;
-       char *name;
-};
-
 /* Sizes for DHCP options */
 #define DHCP_CHADDR_LEN         16
 #define SERVERNAME_LEN          64
index 94cde5aff35a099492de760608d3bc7cca00e5e0..d38aa182dd04d2d2d359e3221bbaf87641e71bfa 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -952,7 +952,7 @@ main(int argc, char **argv)
        /* Terminate the encapsulated options */
        if (options->vendor[0]) {
                options->vendor[0]++;
-               options->vendor[options->vendor[0]] = DHCP_END;
+               options->vendor[options->vendor[0]] = DHO_END;
        }
 
        if (dhcp_run(options, &pid_fd) == 0)