summaryrefslogtreecommitdiffstats
path: root/if-options.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-09-11 09:38:02 +0000
committerRoy Marples <roy@marples.name>2008-09-11 09:38:02 +0000
commitba97e49417ba7463405abdb7d62e834349f0d329 (patch)
tree1fb76674117bdf91b2325ab76536bdb52ef3b540 /if-options.c
parent03c2c87907acec01b024d525414bd76f7d001a15 (diff)
downloaddhcpcd-ba97e49417ba7463405abdb7d62e834349f0d329.tar.xz
Add allowinterfaces and denyinterfaces options to dhcpcd.conf for better multiple interface support.
Diffstat (limited to 'if-options.c')
-rw-r--r--if-options.c98
1 files changed, 63 insertions, 35 deletions
diff --git a/if-options.c b/if-options.c
index 3c45b0de..e51a09f6 100644
--- a/if-options.c
+++ b/if-options.c
@@ -51,41 +51,43 @@
#define OPTS "bc:df:h:i:kl:m:no:pqr:s:t:u:v:xABC:DEF:GI:KLO:Q:TVX:"
const struct option cf_options[] = {
- {"background", no_argument, NULL, 'b'},
- {"script", required_argument, NULL, 'c'},
- {"debug", no_argument, NULL, 'd'},
- {"config", required_argument, NULL, 'f'},
- {"hostname", optional_argument, NULL, 'h'},
- {"vendorclassid", optional_argument, NULL, 'i'},
- {"release", no_argument, NULL, 'k'},
- {"leasetime", required_argument, NULL, 'l'},
- {"metric", required_argument, NULL, 'm'},
- {"rebind", no_argument, NULL, 'n'},
- {"option", required_argument, NULL, 'o'},
- {"persistent", no_argument, NULL, 'p'},
- {"quiet", no_argument, NULL, 'q'},
- {"request", optional_argument, NULL, 'r'},
- {"inform", optional_argument, NULL, 's'},
- {"timeout", required_argument, NULL, 't'},
- {"userclass", required_argument, NULL, 'u'},
- {"vendor", required_argument, NULL, 'v'},
- {"exit", no_argument, NULL, 'x'},
- {"noarp", no_argument, NULL, 'A'},
- {"nobackground", no_argument, NULL, 'B'},
- {"nohook", required_argument, NULL, 'C'},
- {"duid", no_argument, NULL, 'D'},
- {"lastlease", no_argument, NULL, 'E'},
- {"fqdn", optional_argument, NULL, 'F'},
- {"nogateway", no_argument, NULL, 'G'},
- {"clientid", optional_argument, NULL, 'I'},
- {"nolink", no_argument, NULL, 'K'},
- {"noipv4ll", no_argument, NULL, 'L'},
- {"nooption", optional_argument, NULL, 'O'},
- {"require", required_argument, NULL, 'Q'},
- {"test", no_argument, NULL, 'T'},
- {"variables", no_argument, NULL, 'V'},
- {"blacklist", required_argument, NULL, 'X'},
- {NULL, 0, NULL, '\0'}
+ {"background", no_argument, NULL, 'b'},
+ {"script", required_argument, NULL, 'c'},
+ {"debug", no_argument, NULL, 'd'},
+ {"config", required_argument, NULL, 'f'},
+ {"hostname", optional_argument, NULL, 'h'},
+ {"vendorclassid", optional_argument, NULL, 'i'},
+ {"release", no_argument, NULL, 'k'},
+ {"leasetime", required_argument, NULL, 'l'},
+ {"metric", required_argument, NULL, 'm'},
+ {"rebind", no_argument, NULL, 'n'},
+ {"option", required_argument, NULL, 'o'},
+ {"persistent", no_argument, NULL, 'p'},
+ {"quiet", no_argument, NULL, 'q'},
+ {"request", optional_argument, NULL, 'r'},
+ {"inform", optional_argument, NULL, 's'},
+ {"timeout", required_argument, NULL, 't'},
+ {"userclass", required_argument, NULL, 'u'},
+ {"vendor", required_argument, NULL, 'v'},
+ {"exit", no_argument, NULL, 'x'},
+ {"allowinterfaces", required_argument, NULL, 'z'},
+ {"noarp", no_argument, NULL, 'A'},
+ {"nobackground", no_argument, NULL, 'B'},
+ {"nohook", required_argument, NULL, 'C'},
+ {"duid", no_argument, NULL, 'D'},
+ {"lastlease", no_argument, NULL, 'E'},
+ {"fqdn", optional_argument, NULL, 'F'},
+ {"nogateway", no_argument, NULL, 'G'},
+ {"clientid", optional_argument, NULL, 'I'},
+ {"nolink", no_argument, NULL, 'K'},
+ {"noipv4ll", no_argument, NULL, 'L'},
+ {"nooption", optional_argument, NULL, 'O'},
+ {"require", required_argument, NULL, 'Q'},
+ {"test", no_argument, NULL, 'T'},
+ {"variables", no_argument, NULL, 'V'},
+ {"blacklist", required_argument, NULL, 'X'},
+ {"denyinterfaces", required_argument, NULL, 'Z'},
+ {NULL, 0, NULL, '\0'}
};
static int
@@ -248,6 +250,22 @@ parse_string_hwaddr(char *sbuf, ssize_t slen, const char *str, int clid)
return l;
}
+static char **
+splitv(int *argc, char **argv, const char *arg)
+{
+ char **v = argv;
+ char *o = xstrdup(arg), *p, *t;
+
+ p = o;
+ while ((t = strsep(&p, ", "))) {
+ (*argc)++;
+ v = xrealloc(v, *argc);
+ v[(*argc) - 1] = xstrdup(t);
+ }
+ free(o);
+ return v;
+}
+
static int
parse_option(struct if_options *ifo, int opt, const char *arg)
{
@@ -417,6 +435,11 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
ifo->vendor[0] += s + 2;
}
break;
+ case 'z':
+ /* We only set this if we haven't got any interfaces */
+ if (!ifaces)
+ ifav = splitv(&ifac, ifav, arg);
+ break;
case 'A':
ifo->options &= ~DHCPCD_ARP;
/* IPv4LL requires ARP */
@@ -514,6 +537,11 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
ifo->blacklist[ifo->blacklist_len] = addr.s_addr;
ifo->blacklist_len++;
break;
+ case 'Z':
+ /* We only set this if we haven't got any interfaces */
+ if (!ifaces)
+ ifdv = splitv(&ifdc, ifdv, arg);
+ break;
default:
return 0;
}