]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Prefix dhcp definition type with OT_
authorRoy Marples <roy@marples.name>
Sun, 1 May 2016 14:20:21 +0000 (14:20 +0000)
committerRoy Marples <roy@marples.name>
Sun, 1 May 2016 14:20:21 +0000 (14:20 +0000)
dhcp-common.c
dhcp-common.h
dhcp.c
dhcp6.c
dhcpcd.c
if-options.c
script.c

index 3307ce43c2e18fd0afba1c77d66133ca18636c11..92ff8ceb6dd652c59c49e86a114a80e3c83c2cd0 100644 (file)
@@ -91,53 +91,53 @@ dhcp_print_option_encoding(const struct dhcp_opt *opt, int cols)
                cols++;
        }
        putchar('\t');
-       if (opt->type & EMBED)
+       if (opt->type & OT_EMBED)
                printf(" embed");
-       if (opt->type & ENCAP)
+       if (opt->type & OT_ENCAP)
                printf(" encap");
-       if (opt->type & INDEX)
+       if (opt->type & OT_INDEX)
                printf(" index");
-       if (opt->type & ARRAY)
+       if (opt->type & OT_ARRAY)
                printf(" array");
-       if (opt->type & UINT8)
+       if (opt->type & OT_UINT8)
                printf(" uint8");
-       else if (opt->type & INT8)
+       else if (opt->type & OT_INT8)
                printf(" int8");
-       else if (opt->type & UINT16)
+       else if (opt->type & OT_UINT16)
                printf(" uint16");
-       else if (opt->type & INT16)
+       else if (opt->type & OT_INT16)
                printf(" int16");
-       else if (opt->type & UINT32)
+       else if (opt->type & OT_UINT32)
                printf(" uint32");
-       else if (opt->type & INT32)
+       else if (opt->type & OT_INT32)
                printf(" int32");
-       else if (opt->type & ADDRIPV4)
+       else if (opt->type & OT_ADDRIPV4)
                printf(" ipaddress");
-       else if (opt->type & ADDRIPV6)
+       else if (opt->type & OT_ADDRIPV6)
                printf(" ip6address");
-       else if (opt->type & FLAG)
+       else if (opt->type & OT_FLAG)
                printf(" flag");
-       else if (opt->type & BITFLAG)
+       else if (opt->type & OT_BITFLAG)
                printf(" bitflags");
-       else if (opt->type & RFC1035)
+       else if (opt->type & OT_RFC1035)
                printf(" domain");
-       else if (opt->type & DOMAIN)
+       else if (opt->type & OT_DOMAIN)
                printf(" dname");
-       else if (opt->type & ASCII)
+       else if (opt->type & OT_ASCII)
                printf(" ascii");
-       else if (opt->type & RAW)
+       else if (opt->type & OT_RAW)
                printf(" raw");
-       else if (opt->type & BINHEX)
+       else if (opt->type & OT_BINHEX)
                printf(" binhex");
-       else if (opt->type & STRING)
+       else if (opt->type & OT_STRING)
                printf(" string");
-       if (opt->type & RFC3361)
+       if (opt->type & OT_RFC3361)
                printf(" rfc3361");
-       if (opt->type & RFC3442)
+       if (opt->type & OT_RFC3442)
                printf(" rfc3442");
-       if (opt->type & REQUEST)
+       if (opt->type & OT_REQUEST)
                printf(" request");
-       if (opt->type & NOREQ)
+       if (opt->type & OT_NOREQ)
                printf(" norequest");
        putchar('\n');
 }
@@ -239,7 +239,7 @@ make_option_mask(const struct dhcp_opt *dopts, size_t dopts_len,
                        errno = ENOENT;
                        return -1;
                }
-               if (add == 2 && !(opt->type & ADDRIPV4)) {
+               if (add == 2 && !(opt->type & OT_ADDRIPV4)) {
                        free(o);
                        errno = EINVAL;
                        return -1;
@@ -437,7 +437,7 @@ valid_domainname(char *lbl, int type)
                if (c == ' ') {
                        if (lbl - 1 == slbl) /* No space at start */
                                break;
-                       if (!(type & ARRAY))
+                       if (!(type & OT_ARRAY))
                                break;
                        /* Skip to the next label */
                        if (!start) {
@@ -499,7 +499,7 @@ print_string(char *dst, size_t len, int type, const uint8_t *data, size_t dl)
 
        while (data < e) {
                c = *data++;
-               if (type & BINHEX) {
+               if (type & OT_BINHEX) {
                        if (dst) {
                                if (len  == 0 || len == 1) {
                                        errno = ENOSPC;
@@ -512,19 +512,19 @@ print_string(char *dst, size_t len, int type, const uint8_t *data, size_t dl)
                        bytes += 2;
                        continue;
                }
-               if (type & ASCII && (!isascii(c))) {
+               if (type & OT_ASCII && (!isascii(c))) {
                        errno = EINVAL;
                        break;
                }
-               if (!(type & (ASCII | RAW | ESCSTRING | ESCFILE)) /* plain */ &&
+               if (!(type & (OT_ASCII | OT_RAW | OT_ESCSTRING | OT_ESCFILE)) &&
                    (!isascii(c) && !isprint(c)))
                {
                        errno = EINVAL;
                        break;
                }
-               if ((type & (ESCSTRING | ESCFILE) &&
+               if ((type & (OT_ESCSTRING | OT_ESCFILE) &&
                    (c == '\\' || !isascii(c) || !isprint(c))) ||
-                   (type & ESCFILE && (c == '/' || c == ' ')))
+                   (type & OT_ESCFILE && (c == '/' || c == ' ')))
                {
                        errno = EINVAL;
                        if (c == '\\') {
@@ -573,7 +573,7 @@ print_string(char *dst, size_t len, int type, const uint8_t *data, size_t dl)
                *dst = '\0';
 
                /* Now we've printed it, validate the domain */
-               if (type & DOMAIN && !valid_domainname(odst, type)) {
+               if (type & OT_DOMAIN && !valid_domainname(odst, type)) {
                        *odst = '\0';
                        return 1;
                }
@@ -589,15 +589,15 @@ dhcp_optlen(const struct dhcp_opt *opt, size_t dl)
 {
        size_t sz;
 
-       if (opt->type & ADDRIPV6)
+       if (opt->type & OT_ADDRIPV6)
                sz = ADDR6SZ;
-       else if (opt->type & (INT32 | UINT32 | ADDRIPV4))
+       else if (opt->type & (OT_INT32 | OT_UINT32 | OT_ADDRIPV4))
                sz = sizeof(uint32_t);
-       else if (opt->type & (INT16 | UINT16))
+       else if (opt->type & (OT_INT16 | OT_UINT16))
                sz = sizeof(uint16_t);
-       else if (opt->type & (INT8 | UINT8 | BITFLAG))
+       else if (opt->type & (OT_INT8 | OT_UINT8 | OT_BITFLAG))
                sz = sizeof(uint8_t);
-       else if (opt->type & FLAG)
+       else if (opt->type & OT_FLAG)
                return 0;
        else {
                /* All other types are variable length */
@@ -617,7 +617,7 @@ dhcp_optlen(const struct dhcp_opt *opt, size_t dl)
 
        /* Trim any extra data.
         * Maybe we need a settng to reject DHCP options with extra data? */
-       if (opt->type & ARRAY)
+       if (opt->type & OT_ARRAY)
                return (ssize_t)(dl - (dl % sz));
        return (ssize_t)sz;
 }
@@ -669,7 +669,7 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt,
        size_t l;
        char *tmp;
 
-       if (opt->type & RFC1035) {
+       if (opt->type & OT_RFC1035) {
                sl = decode_rfc1035(NULL, 0, data, dl);
                if (sl == 0 || sl == -1)
                        return sl;
@@ -684,7 +684,7 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt,
        }
 
 #ifdef INET
-       if (opt->type & RFC3361) {
+       if (opt->type & OT_RFC3361) {
                if ((tmp = decode_rfc3361(data, dl)) == NULL)
                        return -1;
                l = strlen(tmp);
@@ -693,14 +693,14 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt,
                return sl;
        }
 
-       if (opt->type & RFC3442)
+       if (opt->type & OT_RFC3442)
                return decode_rfc3442(s, len, data, dl);
 #endif
 
-       if (opt->type & STRING)
+       if (opt->type & OT_STRING)
                return print_string(s, len, opt->type, data, dl);
 
-       if (opt->type & FLAG) {
+       if (opt->type & OT_FLAG) {
                if (s) {
                        *s++ = '1';
                        *s = '\0';
@@ -708,7 +708,7 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt,
                return 1;
        }
 
-       if (opt->type & BITFLAG) {
+       if (opt->type & OT_BITFLAG) {
                /* bitflags are a string, MSB first, such as ABCDEFGH
                 * where A is 10000000, B is 01000000, etc. */
                bytes = 0;
@@ -732,26 +732,26 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt,
        }
 
        if (!s) {
-               if (opt->type & UINT8)
+               if (opt->type & OT_UINT8)
                        l = 3;
-               else if (opt->type & INT8)
+               else if (opt->type & OT_INT8)
                        l = 4;
-               else if (opt->type & UINT16) {
+               else if (opt->type & OT_UINT16) {
                        l = 5;
                        dl /= 2;
-               } else if (opt->type & INT16) {
+               } else if (opt->type & OT_INT16) {
                        l = 6;
                        dl /= 2;
-               } else if (opt->type & UINT32) {
+               } else if (opt->type & OT_UINT32) {
                        l = 10;
                        dl /= 4;
-               } else if (opt->type & INT32) {
+               } else if (opt->type & OT_INT32) {
                        l = 11;
                        dl /= 4;
-               } else if (opt->type & ADDRIPV4) {
+               } else if (opt->type & OT_ADDRIPV4) {
                        l = 16;
                        dl /= 4;
-               } else if (opt->type & ADDRIPV6) {
+               } else if (opt->type & OT_ADDRIPV6) {
                        e = data + dl;
                        l = 0;
                        while (data < e) {
@@ -779,37 +779,37 @@ print_option(char *s, size_t len, const struct dhcp_opt *opt,
                        bytes++;
                        len--;
                }
-               if (opt->type & UINT8) {
+               if (opt->type & OT_UINT8) {
                        sl = snprintf(s, len, "%u", *data);
                        data++;
-               } else if (opt->type & INT8) {
+               } else if (opt->type & OT_INT8) {
                        sl = snprintf(s, len, "%d", *data);
                        data++;
-               } else if (opt->type & UINT16) {
+               } else if (opt->type & OT_UINT16) {
                        memcpy(&u16, data, sizeof(u16));
                        u16 = ntohs(u16);
                        sl = snprintf(s, len, "%u", u16);
                        data += sizeof(u16);
-               } else if (opt->type & INT16) {
+               } else if (opt->type & OT_INT16) {
                        memcpy(&u16, data, sizeof(u16));
                        s16 = (int16_t)ntohs(u16);
                        sl = snprintf(s, len, "%d", s16);
                        data += sizeof(u16);
-               } else if (opt->type & UINT32) {
+               } else if (opt->type & OT_UINT32) {
                        memcpy(&u32, data, sizeof(u32));
                        u32 = ntohl(u32);
                        sl = snprintf(s, len, "%u", u32);
                        data += sizeof(u32);
-               } else if (opt->type & INT32) {
+               } else if (opt->type & OT_INT32) {
                        memcpy(&u32, data, sizeof(u32));
                        s32 = (int32_t)ntohl(u32);
                        sl = snprintf(s, len, "%d", s32);
                        data += sizeof(u32);
-               } else if (opt->type & ADDRIPV4) {
+               } else if (opt->type & OT_ADDRIPV4) {
                        memcpy(&addr.s_addr, data, sizeof(addr.s_addr));
                        sl = snprintf(s, len, "%s", inet_ntoa(addr));
                        data += sizeof(addr.s_addr);
-               } else if (opt->type & ADDRIPV6) {
+               } else if (opt->type & OT_ADDRIPV6) {
                        sl = ipv6_printaddr(s, len, data, ifname);
                        data += 16;
                } else {
@@ -849,7 +849,7 @@ dhcp_set_leasefile(char *leasefile, size_t len, int family,
        if (ifp->wireless) {
                ssid[0] = '-';
                print_string(ssid + 1, sizeof(ssid) - 1,
-                   ESCFILE,
+                   OT_ESCFILE,
                    (const uint8_t *)ifp->ssid, ifp->ssid_len);
        } else
                ssid[0] = '\0';
@@ -914,7 +914,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
 
        /* If no embedded or encapsulated options, it's easy */
        if (opt->embopts_len == 0 && opt->encopts_len == 0) {
-               if (!(opt->type & RESERVED)) {
+               if (!(opt->type & OT_RESERVED)) {
                        if (dhcp_envoption1(env == NULL ? NULL : &env[0],
                            prefix, opt, 1, od, ol, ifname))
                                return 1;
@@ -927,7 +927,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
 
        /* Create a new prefix based on the option */
        if (env) {
-               if (opt->type & INDEX) {
+               if (opt->type & OT_INDEX) {
                        if (opt->index > 999) {
                                errno = ENOBUFS;
                                logger(ctx, LOG_ERR, "%s: %m", __func__);
@@ -935,13 +935,13 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                        }
                }
                e = strlen(prefix) + strlen(opt->var) + 2 +
-                   (opt->type & INDEX ? 3 : 0);
+                   (opt->type & OT_INDEX ? 3 : 0);
                pfx = malloc(e);
                if (pfx == NULL) {
                        logger(ctx, LOG_ERR, "%s: %m", __func__);
                        return 0;
                }
-               if (opt->type & INDEX)
+               if (opt->type & OT_INDEX)
                        snprintf(pfx, e, "%s_%s%d", prefix,
                            opt->var, ++opt->index);
                else
@@ -970,7 +970,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                         * DHCP FQDN in RFC4702 have a string as the last
                         * option which is optional. */
                        if (env == NULL &&
-                           (ol != 0 || !(eopt->type & OPTIONAL)))
+                           (ol != 0 || !(eopt->type & OT_OPTIONAL)))
                                logger(ctx, LOG_ERR,
                                    "%s: %s %d.%d/%zu: missing embedded option",
                                    ifname, __func__, opt->option,
@@ -980,7 +980,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                /* Use the option prefix if the embedded option
                 * name is different.
                 * This avoids new_fqdn_fqdn which would be silly. */
-               if (!(eopt->type & RESERVED)) {
+               if (!(eopt->type & OT_RESERVED)) {
                        ov = strcmp(opt->var, eopt->var);
                        if (dhcp_envoption1(env == NULL ? NULL : &env[n],
                            pfx, eopt, ov, od, (size_t)eo, ifname))
@@ -1005,7 +1005,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                    i++, eopt++)
                {
                        eoc = opt->option;
-                       if (eopt->type & OPTION) {
+                       if (eopt->type & OT_OPTION) {
                                dgetopt(ctx, NULL, &eoc, NULL, NULL, 0, &oopt);
                                if (oopt)
                                        oopt->index = 0;
@@ -1018,7 +1018,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                            i++, eopt++)
                        {
                                if (eopt->option == eoc) {
-                                       if (eopt->type & OPTION) {
+                                       if (eopt->type & OT_OPTION) {
                                                if (oopt == NULL)
                                                        /* Report error? */
                                                        continue;
@@ -1026,7 +1026,7 @@ dhcp_envoption(struct dhcpcd_ctx *ctx, char **env, const char *prefix,
                                        n += dhcp_envoption(ctx,
                                            env == NULL ? NULL : &env[n], pfx,
                                            ifname,
-                                           eopt->type & OPTION ? oopt : eopt,
+                                           eopt->type & OT_OPTION ? oopt:eopt,
                                            dgetopt, eod, eol);
                                        break;
                                }
index 466c5221c98729e961cf0534b4a2b5d9106df25e..f576a172aa01cff42b6e6d3ad295b3561138b66d 100644 (file)
@@ -26,7 +26,7 @@
  */
 
 #ifndef DHCPCOMMON_H
-#define DHCPCOMMON_H
+#define        DHCPCOMMON_H
 
 #include <arpa/inet.h>
 #include <netinet/in.h>
 #include "dhcpcd.h"
 
 /* Max MTU - defines dhcp option length */
-#define MTU_MAX             1500
-#define MTU_MIN             576
-
-#define REQUEST                (1 << 0)
-#define UINT8          (1 << 1)
-#define INT8           (1 << 2)
-#define UINT16         (1 << 3)
-#define INT16          (1 << 4)
-#define UINT32         (1 << 5)
-#define INT32          (1 << 6)
-#define ADDRIPV4       (1 << 7)
-#define STRING         (1 << 8)
-#define ARRAY          (1 << 9)
-#define RFC3361                (1 << 10)
-#define RFC1035                (1 << 11)
-#define RFC3442                (1 << 12)
-#define OPTIONAL       (1 << 13)
-#define ADDRIPV6       (1 << 14)
-#define BINHEX         (1 << 15)
-#define FLAG           (1 << 16)
-#define NOREQ          (1 << 17)
-#define EMBED          (1 << 18)
-#define ENCAP          (1 << 19)
-#define INDEX          (1 << 20)
-#define OPTION         (1 << 21)
-#define DOMAIN         (1 << 22)
-#define ASCII          (1 << 23)
-#define RAW            (1 << 24)
-#define ESCSTRING      (1 << 25)
-#define ESCFILE                (1 << 26)
-#define BITFLAG                (1 << 27)
-#define RESERVED       (1 << 28)
+#define        MTU_MAX                 1500
+#define        MTU_MIN                  576
+
+#define        OT_REQUEST              (1 << 0)
+#define        OT_UINT8                (1 << 1)
+#define        OT_INT8                 (1 << 2)
+#define        OT_UINT16               (1 << 3)
+#define        OT_INT16                (1 << 4)
+#define        OT_UINT32               (1 << 5)
+#define        OT_INT32                (1 << 6)
+#define        OT_ADDRIPV4             (1 << 7)
+#define        OT_STRING               (1 << 8)
+#define        OT_ARRAY                (1 << 9)
+#define        OT_RFC3361              (1 << 10)
+#define        OT_RFC1035              (1 << 11)
+#define        OT_RFC3442              (1 << 12)
+#define        OT_OPTIONAL             (1 << 13)
+#define        OT_ADDRIPV6             (1 << 14)
+#define        OT_BINHEX               (1 << 15)
+#define        OT_FLAG                 (1 << 16)
+#define        OT_NOREQ                (1 << 17)
+#define        OT_EMBED                (1 << 18)
+#define        OT_ENCAP                (1 << 19)
+#define        OT_INDEX                (1 << 20)
+#define        OT_OPTION               (1 << 21)
+#define        OT_DOMAIN               (1 << 22)
+#define        OT_ASCII                (1 << 23)
+#define        OT_RAW                  (1 << 24)
+#define        OT_ESCSTRING            (1 << 25)
+#define        OT_ESCFILE              (1 << 26)
+#define        OT_BITFLAG              (1 << 27)
+#define        OT_RESERVED             (1 << 28)
 
 struct dhcp_opt {
        uint32_t option; /* Also used for IANA Enterpise Number */
@@ -95,11 +95,11 @@ struct dhcp_opt *vivso_find(uint32_t, const void *);
 ssize_t dhcp_vendor(char *, size_t);
 
 void dhcp_print_option_encoding(const struct dhcp_opt *opt, int cols);
-#define add_option_mask(var, val) \
+#define        add_option_mask(var, val) \
        ((var)[(val) >> 3] = (uint8_t)((var)[(val) >> 3] | 1 << ((val) & 7)))
-#define del_option_mask(var, val) \
+#define        del_option_mask(var, val) \
        ((var)[(val) >> 3] = (uint8_t)((var)[(val) >> 3] & ~(1 << ((val) & 7))))
-#define has_option_mask(var, val) \
+#define        has_option_mask(var, val) \
        ((var)[(val) >> 3] & (uint8_t)(1 << ((val) & 7)))
 int make_option_mask(const struct dhcp_opt *, size_t,
     const struct dhcp_opt *, size_t,
diff --git a/dhcp.c b/dhcp.c
index 03f822d176480ac8bc0efcbec94420148ae210e3..e3d1de999f8b7a84ad6a03472933dcb21d3c10d4 100644 (file)
--- a/dhcp.c
+++ b/dhcp.c
@@ -983,10 +983,10 @@ make_message(struct dhcp_message **message,
                    i < ifp->ctx->dhcp_opts_len;
                    i++, opt++)
                {
-                       if (!(opt->type & REQUEST ||
+                       if (!(opt->type & OT_REQUEST ||
                            has_option_mask(ifo->requestmask, opt->option)))
                                continue;
-                       if (opt->type & NOREQ)
+                       if (opt->type & OT_NOREQ)
                                continue;
                        if (type == DHCP_INFORM &&
                            (opt->option == DHO_RENEWALTIME ||
@@ -1007,10 +1007,10 @@ make_message(struct dhcp_message **message,
                                        break;
                        if (lp < p)
                                continue;
-                       if (!(opt->type & REQUEST ||
+                       if (!(opt->type & OT_REQUEST ||
                            has_option_mask(ifo->requestmask, opt->option)))
                                continue;
-                       if (opt->type & NOREQ)
+                       if (opt->type & OT_NOREQ)
                                continue;
                        if (type == DHCP_INFORM &&
                            (opt->option == DHO_RENEWALTIME ||
@@ -1320,12 +1320,12 @@ dhcp_env(char **env, const char *prefix, const struct dhcp_message *dhcp,
        }
 
        if (*dhcp->bootfile && !(overl & 1)) {
-               print_string(safe, sizeof(safe), STRING,
+               print_string(safe, sizeof(safe), OT_STRING,
                    dhcp->bootfile, sizeof(dhcp->bootfile));
                addvar(ifp->ctx, &ep, prefix, "filename", safe);
        }
        if (*dhcp->servername && !(overl & 2)) {
-               print_string(safe, sizeof(safe), STRING | DOMAIN,
+               print_string(safe, sizeof(safe), OT_STRING | OT_DOMAIN,
                    dhcp->servername, sizeof(dhcp->servername));
                addvar(ifp->ctx, &ep, prefix, "server_name", safe);
        }
@@ -2522,7 +2522,7 @@ log_dhcp1(int lvl, const char *msg,
                                free(a);
                                return;
                        }
-                       print_string(tmp, tmpl, STRING, (uint8_t *)a, al);
+                       print_string(tmp, tmpl, OT_STRING, (uint8_t *)a, al);
                        free(a);
                        a = tmp;
                }
@@ -2539,7 +2539,7 @@ log_dhcp1(int lvl, const char *msg,
        tfrom = "from";
        r = get_option_addr(ifp->ctx, &addr, dhcp, DHO_SERVERID);
        if (dhcp->servername[0] && r == 0) {
-               print_string(sname, sizeof(sname), STRING,
+               print_string(sname, sizeof(sname), OT_STRING,
                    dhcp->servername, strlen((const char *)dhcp->servername));
                if (a == NULL)
                        logger(ifp->ctx, lvl, "%s: %s %s %s `%s'",
diff --git a/dhcp6.c b/dhcp6.c
index 4b977867b273dafc1e27a5a045d2ca6f269d6822..9317cd5ae2236b3d602c2ba4c98aed0ef71570f2 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -538,8 +538,8 @@ dhcp6_makemessage(struct interface *ifp)
                        }
                        if (n < ifo->dhcp6_override_len)
                            continue;
-                       if (!(opt->type & NOREQ) &&
-                           (opt->type & REQUEST ||
+                       if (!(opt->type & OT_NOREQ) &&
+                           (opt->type & OT_REQUEST ||
                            has_option_mask(ifo->requestmask6, opt->option)))
                        {
                                n_options++;
@@ -550,8 +550,8 @@ dhcp6_makemessage(struct interface *ifp)
                    l < ifo->dhcp6_override_len;
                    l++, opt++)
                {
-                       if (!(opt->type & NOREQ) &&
-                           (opt->type & REQUEST ||
+                       if (!(opt->type & OT_NOREQ) &&
+                           (opt->type & OT_REQUEST ||
                            has_option_mask(ifo->requestmask6, opt->option)))
                        {
                                n_options++;
@@ -856,30 +856,30 @@ dhcp6_makemessage(struct interface *ifp)
                                }
                                if (n < ifo->dhcp6_override_len)
                                    continue;
-                               if (!(opt->type & NOREQ) &&
-                                   (opt->type & REQUEST ||
+                               if (!(opt->type & OT_NOREQ) &&
+                                   (opt->type & OT_REQUEST ||
                                    has_option_mask(ifo->requestmask6,
                                        opt->option)))
                                {
                                        u16 = htons((uint16_t)opt->option);
                                        memcpy(p, &u16, sizeof(u16));
                                        p += sizeof(u16);
-                                       o->len = (uint16_t)(o->len + sizeof(u16));
+                                       o->len = (uint16_t)(o->len+sizeof(u16));
                                }
                        }
                        for (l = 0, opt = ifo->dhcp6_override;
                            l < ifo->dhcp6_override_len;
                            l++, opt++)
                        {
-                               if (!(opt->type & NOREQ) &&
-                                   (opt->type & REQUEST ||
+                               if (!(opt->type & OT_NOREQ) &&
+                                   (opt->type & OT_REQUEST ||
                                    has_option_mask(ifo->requestmask6,
                                        opt->option)))
                                {
                                        u16 = htons((uint16_t)opt->option);
                                        memcpy(p, &u16, sizeof(u16));
                                        p += sizeof(u16);
-                                       o->len = (uint16_t)(o->len + sizeof(u16));
+                                       o->len = (uint16_t)(o->len+sizeof(u16));
                                }
                        }
                        if (dhcp6_findselfsla(ifp, NULL)) {
index c19c6ef8a501bc532de4885383fe950470ff80ce..0c9859428365aeee2e5a81595a09fef3167dc80c 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -574,7 +574,7 @@ dhcpcd_selectprofile(struct interface *ifp, const char *profile)
        if (ifp->ssid_len) {
                ssize_t r;
 
-               r = print_string(pssid, sizeof(pssid), ESCSTRING,
+               r = print_string(pssid, sizeof(pssid), OT_ESCSTRING,
                    ifp->ssid, ifp->ssid_len);
                if (r == -1) {
                        logger(ifp->ctx, LOG_ERR,
index 6b2052bbfa19b10a22c3ad9ca4a06f9ac34450fe..6353e2d0e7f145503d0fb4a5b1523ced4fe52ad5 100644 (file)
@@ -1626,7 +1626,7 @@ err_sla:
                }
                t = 0;
                if (strcasecmp(arg, "request") == 0) {
-                       t |= REQUEST;
+                       t |= OT_REQUEST;
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
@@ -1635,7 +1635,7 @@ err_sla:
                        }
                        *fp++ = '\0';
                } else if (strcasecmp(arg, "norequest") == 0) {
-                       t |= NOREQ;
+                       t |= OT_NOREQ;
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
@@ -1645,7 +1645,7 @@ err_sla:
                        *fp++ = '\0';
                }
                if (strcasecmp(arg, "optional") == 0) {
-                       t |= OPTIONAL;
+                       t |= OT_OPTIONAL;
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
@@ -1656,7 +1656,7 @@ err_sla:
                        *fp++ = '\0';
                }
                if (strcasecmp(arg, "index") == 0) {
-                       t |= INDEX;
+                       t |= OT_INDEX;
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
@@ -1666,7 +1666,7 @@ err_sla:
                        *fp++ = '\0';
                }
                if (strcasecmp(arg, "array") == 0) {
-                       t |= ARRAY;
+                       t |= OT_ARRAY;
                        arg = strskipwhite(fp);
                        fp = strwhite(arg);
                        if (fp == NULL) {
@@ -1676,72 +1676,72 @@ err_sla:
                        *fp++ = '\0';
                }
                if (strcasecmp(arg, "ipaddress") == 0)
-                       t |= ADDRIPV4;
+                       t |= OT_ADDRIPV4;
                else if (strcasecmp(arg, "ip6address") == 0)
-                       t |= ADDRIPV6;
+                       t |= OT_ADDRIPV6;
                else if (strcasecmp(arg, "string") == 0)
-                       t |= STRING;
+                       t |= OT_STRING;
                else if (strcasecmp(arg, "byte") == 0)
-                       t |= UINT8;
+                       t |= OT_UINT8;
                else if (strcasecmp(arg, "bitflags") == 0)
-                       t |= BITFLAG;
+                       t |= OT_BITFLAG;
                else if (strcasecmp(arg, "uint8") == 0)
-                       t |= UINT8;
+                       t |= OT_UINT8;
                else if (strcasecmp(arg, "int8") == 0)
-                       t |= INT8;
+                       t |= OT_INT8;
                else if (strcasecmp(arg, "uint16") == 0)
-                       t |= UINT16;
+                       t |= OT_UINT16;
                else if (strcasecmp(arg, "int16") == 0)
-                       t |= INT16;
+                       t |= OT_INT16;
                else if (strcasecmp(arg, "uint32") == 0)
-                       t |= UINT32;
+                       t |= OT_UINT32;
                else if (strcasecmp(arg, "int32") == 0)
-                       t |= INT32;
+                       t |= OT_INT32;
                else if (strcasecmp(arg, "flag") == 0)
-                       t |= FLAG;
+                       t |= OT_FLAG;
                else if (strcasecmp(arg, "raw") == 0)
-                       t |= STRING | RAW;
+                       t |= OT_STRING | OT_RAW;
                else if (strcasecmp(arg, "ascii") == 0)
-                       t |= STRING | ASCII;
+                       t |= OT_STRING | OT_ASCII;
                else if (strcasecmp(arg, "domain") == 0)
-                       t |= STRING | DOMAIN | RFC1035;
+                       t |= OT_STRING | OT_DOMAIN | OT_RFC1035;
                else if (strcasecmp(arg, "dname") == 0)
-                       t |= STRING | DOMAIN;
+                       t |= OT_STRING | OT_DOMAIN;
                else if (strcasecmp(arg, "binhex") == 0)
-                       t |= STRING | BINHEX;
+                       t |= OT_STRING | OT_BINHEX;
                else if (strcasecmp(arg, "embed") == 0)
-                       t |= EMBED;
+                       t |= OT_EMBED;
                else if (strcasecmp(arg, "encap") == 0)
-                       t |= ENCAP;
+                       t |= OT_ENCAP;
                else if (strcasecmp(arg, "rfc3361") ==0)
-                       t |= STRING | RFC3361;
+                       t |= OT_STRING | OT_RFC3361;
                else if (strcasecmp(arg, "rfc3442") ==0)
-                       t |= STRING | RFC3442;
+                       t |= OT_STRING | OT_RFC3442;
                else if (strcasecmp(arg, "option") == 0)
-                       t |= OPTION;
+                       t |= OT_OPTION;
                else {
                        logger(ctx, LOG_ERR, "unknown type: %s", arg);
                        return -1;
                }
-               if (l && !(t & (STRING | BINHEX))) {
+               if (l && !(t & (OT_STRING | OT_BINHEX))) {
                        logger(ctx, LOG_WARNING,
                            "ignoring length for type `%s'", arg);
                        l = 0;
                }
-               if (t & ARRAY && t & (STRING | BINHEX) &&
-                   !(t & (RFC1035 | DOMAIN)))
+               if (t & OT_ARRAY && t & (OT_STRING | OT_BINHEX) &&
+                   !(t & (OT_RFC1035 | OT_DOMAIN)))
                {
                        logger(ctx, LOG_WARNING, "ignoring array for strings");
-                       t &= ~ARRAY;
+                       t &= ~OT_ARRAY;
                }
-               if (t & BITFLAG) {
+               if (t & OT_BITFLAG) {
                        if (bp == NULL)
                                logger(ctx, LOG_WARNING,
                                    "missing bitflag assignment");
                }
                /* variable */
                if (!fp) {
-                       if (!(t & OPTION)) {
+                       if (!(t & OT_OPTION)) {
                                logger(ctx, LOG_ERR,
                                    "type %s requires a variable name", arg);
                                return -1;
@@ -1761,7 +1761,7 @@ err_sla:
                                }
                        } else {
                                np = NULL;
-                               t |= RESERVED;
+                               t |= OT_RESERVED;
                        }
                }
                if (opt != O_EMBED) {
index 195da69720f94e4b329d33c984b5b50131ab3fd7..0af7d7ecd7f009b61f69e20702ed7cf5c56aa71f 100644 (file)
--- a/script.c
+++ b/script.c
@@ -408,13 +408,13 @@ make_env(const struct interface *ifp, const char *reason, char ***argv)
                ssize_t psl;
 
                pfx_len = strlen(pfx);
-               psl = print_string(NULL, 0, ESCSTRING,
+               psl = print_string(NULL, 0, OT_ESCSTRING,
                    (const uint8_t *)ifp->ssid, ifp->ssid_len);
                if (psl != -1) {
                        EMALLOC(elen, pfx_len + (size_t)psl + 1);
                        memcpy(env[elen], pfx, pfx_len);
                        print_string(env[elen] + pfx_len, (size_t)psl + 1,
-                           ESCSTRING,
+                           OT_ESCSTRING,
                            (const uint8_t *)ifp->ssid, ifp->ssid_len);
                        elen++;
                }