summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2014-05-29 12:52:27 +0000
committerRoy Marples <roy@marples.name>2014-05-29 12:52:27 +0000
commitc85baeae3e9f3e1a0965bf956b59c74a9aa208e9 (patch)
tree073be79121e18aaa644b38d8c0a0994e7b3b940f /dhcpcd.c
parent5b76368086cda67a399b2d5180ac4fc0c9d42fd4 (diff)
downloaddhcpcd-c85baeae3e9f3e1a0965bf956b59c74a9aa208e9.tar.xz
-4 and -6 are now mutually exclusive and when running on a single interface
per protocol pidfiles are created. This means that other control options suchs as -x and -n will require the -4 or -6 option as well.
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c29
1 files changed, 26 insertions, 3 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 5ec6b8f0..482764d4 100644
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -1116,7 +1116,7 @@ int
main(int argc, char **argv)
{
struct dhcpcd_ctx ctx;
- char pidfile[sizeof(PIDFILE) + IF_NAMESIZE];
+ char pidfile[sizeof(PIDFILE) + IF_NAMESIZE + 1];
struct if_options *ifo;
struct interface *ifp;
uint16_t family = 0;
@@ -1174,9 +1174,19 @@ main(int argc, char **argv)
{
switch (opt) {
case '4':
+ if (family) {
+ syslog(LOG_ERR, "cannot specify more than one"
+ " address family");
+ goto exit_failure;
+ }
family = AF_INET;
break;
case '6':
+ if (family) {
+ syslog(LOG_ERR, "cannot specify more than one"
+ " address family");
+ goto exit_failure;
+ }
family = AF_INET6;
break;
case 'f':
@@ -1278,16 +1288,29 @@ main(int argc, char **argv)
/* If we have any other args, we should run as a single dhcpcd
* instance for that interface. */
if (optind == argc - 1 && !(ctx.options & DHCPCD_MASTER)) {
+ const char *per;
+
if (strlen(argv[optind]) > IF_NAMESIZE) {
syslog(LOG_ERR, "%s: interface name too long",
argv[optind]);
goto exit_failure;
}
+ /* Allow a dhcpcd interface per address family */
+ switch(family) {
+ case AF_INET:
+ per = "-4";
+ break;
+ case AF_INET6:
+ per = "-6";
+ break;
+ default:
+ per = "";
+ }
snprintf(pidfile, sizeof(pidfile),
- PIDFILE, "-", argv[optind]);
+ PIDFILE, "-", argv[optind], per);
}
else {
- snprintf(pidfile, sizeof(pidfile), PIDFILE, "", "");
+ snprintf(pidfile, sizeof(pidfile), PIDFILE, "", "", "");
ctx.options |= DHCPCD_MASTER;
}
}