summaryrefslogtreecommitdiffstats
path: root/if-options.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2009-02-27 21:18:01 +0000
committerRoy Marples <roy@marples.name>2009-02-27 21:18:01 +0000
commite095a6ebb581216ef8369d1e468a6682332498a7 (patch)
tree0b4618baf77fe69ab9c3daa8cfe575b506de610c /if-options.c
parente0dd8b7e4a3011200972a9103d84081aca91843f (diff)
downloaddhcpcd-e095a6ebb581216ef8369d1e468a6682332498a7.tar.xz
Blacklist now accepts networks as well as addresses.
It also matches on the address offered as well as the server address.
Diffstat (limited to 'if-options.c')
-rw-r--r--if-options.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/if-options.c b/if-options.c
index 119d6dea..1e4ff981 100644
--- a/if-options.c
+++ b/if-options.c
@@ -287,6 +287,8 @@ parse_addr(struct in_addr *addr, struct in_addr *net, const char *arg)
syslog(LOG_ERR, "`%s' is not a valid IP address", arg);
return -1;
}
+ if (p)
+ *--p = '/';
return 0;
}
@@ -296,7 +298,7 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
int i;
char *p = NULL, *np;
ssize_t s;
- struct in_addr addr;
+ struct in_addr addr, addr2;
struct rt *rt;
switch(opt) {
@@ -624,15 +626,13 @@ parse_option(struct if_options *ifo, int opt, const char *arg)
}
break;
case 'X':
- if (!inet_aton(arg, &addr)) {
- syslog(LOG_ERR, "`%s' is not a valid IP address",
- arg);
+ addr2.s_addr = ~0U;
+ if (parse_addr(&addr, &addr2, arg) != 0)
return -1;
- }
ifo->blacklist = xrealloc(ifo->blacklist,
- sizeof(in_addr_t) * (ifo->blacklist_len + 1));
- ifo->blacklist[ifo->blacklist_len] = addr.s_addr;
- ifo->blacklist_len++;
+ sizeof(in_addr_t) * (ifo->blacklist_len + 2));
+ ifo->blacklist[ifo->blacklist_len++] = addr.s_addr;
+ ifo->blacklist[ifo->blacklist_len++] = addr2.s_addr;
break;
case 'Z':
/* We only set this if we haven't got any interfaces */