summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2008-07-28 13:21:47 +0000
committerRoy Marples <roy@marples.name>2008-07-28 13:21:47 +0000
commiteceefd55549c60544e0303f1fb5101bbb4f6d17e (patch)
treec24a75c02b7c5e86cfe73226709aaf75d5de900f /dhcpcd.c
parent8d1fbeec1a4167bf1cb9d17decbe110f022df34a (diff)
downloaddhcpcd-eceefd55549c60544e0303f1fb5101bbb4f6d17e.tar.xz
Add -X, --blacklist option to reject DHCP messages with a matching serverid.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 46e39a37..3857b7c5 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -52,7 +52,7 @@ const char copyright[] = "Copyright (c) 2006-2008 Roy Marples";
/* Don't set any optional arguments here so we retain POSIX
* compatibility with getopt */
-#define OPTS "bc:df:h:i:kl:m:no:pqr:s:t:u:v:xABC:DEF:GI:KLO:TV"
+#define OPTS "bc:df:h:i:kl:m:no:pqr:s:t:u:v:xABC:DEF:GI:KLO:TVX:"
static int doversion = 0;
static int dohelp = 0;
@@ -89,6 +89,7 @@ static const struct option longopts[] = {
{"nooption", optional_argument, NULL, 'O'},
{"test", no_argument, NULL, 'T'},
{"variables", no_argument, NULL, 'V'},
+ {"blacklist", required_argument, NULL, 'X'},
{"help", no_argument, &dohelp, 1},
{"version", no_argument, &doversion, 1},
#ifdef THERE_IS_NO_FORK
@@ -160,12 +161,10 @@ read_pid(const char *pidfile)
static void
usage(void)
{
-#ifndef MINIMAL
printf("usage: "PACKAGE" [-dknpqxADEGHKLOTV] [-c script] [-f file ] [-h hostname]\n"
" [-i classID ] [-l leasetime] [-m metric] [-o option] [-r ipaddr]\n"
" [-s ipaddr] [-t timeout] [-u userclass] [-F none|ptr|both]\n"
- " [-I clientID] [-C hookscript] <interface>\n");
-#endif
+ " [-I clientID] [-C hookscript] [-X ipaddr] <interface>\n");
}
static char *
@@ -561,6 +560,17 @@ parse_option(int opt, char *oarg, struct options *options)
return -1;
}
break;
+ case 'X':
+ if (!inet_aton(oarg, &addr)) {
+ logger(LOG_ERR, "`%s' is not a valid IP address",
+ oarg);
+ return -1;
+ }
+ options->blacklist = xrealloc(options->blacklist,
+ sizeof(in_addr_t) * (options->blacklist_len + 1));
+ options->blacklist[options->blacklist_len] = addr.s_addr;
+ options->blacklist_len++;
+ break;
default:
return 0;
}
@@ -983,6 +993,7 @@ abort:
free(options->environ[len++]);
free(options->environ);
}
+ free(options->blacklist);
free(options);
#ifdef THERE_IS_NO_FORK