{
select_profile(ifp, NULL);
- add_options(ifp->options, argc, argv);
+ add_options(ifp->name, ifp->options, argc, argv);
configure_interface1(ifp);
}
ifdv = NULL;
ifo = read_config(cffile, NULL, NULL, NULL);
- add_options(ifo, margc, margv);
+ add_options(NULL, ifo, margc, margv);
/* We need to preserve these two options. */
if (options & DHCPCD_MASTER)
ifo->options |= DHCPCD_MASTER;
margv = argv;
margc = argc;
if_options = read_config(cffile, NULL, NULL, NULL);
- opt = add_options(if_options, argc, argv);
+ opt = add_options(NULL, if_options, argc, argv);
if (opt != 1) {
if (opt == 0)
usage();
-.\" Copyright (c) 2006-2013 Roy Marples
+.\" Copyright (c) 2006-2014 Roy Marples
.\" All rights reserved
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.Dd December 6, 2013
+.Dd January 18, 2014
.Dt DHCPCD.CONF 5
.Os
.Sh NAME
.It Ic iaid Ar iaid
Set the Interface Association Identifier to
.Ar iaid .
+This option must be used in an
+.Ic interface
+block.
This defaults to the last 4 bytes of the hardware address assigned to the
interface.
Each instance of this should be unique within the scope of the client and
.It Ic ia_pd Op Ar iaid Op Ar interface Op / Ar sla_id Op / Ar prefix_len
Request a DHCPv6 Delegated Prefix for
.Ar iaid .
+This option must be used in an
+.Ic interface
+block.
If no
.Ar interface
is given then we will assign a prefix to every other interface with a unique
Otherwise addresses are only assigned for each
.Ar interface
and
-.Ar sla_id
+.Ar sla_id .
+You cannot assign a prefix to the requesting interface.
A default
.Ar prefix_len
of 64 is assumed.
}
static int
-parse_option(struct if_options *ifo, int opt, const char *arg)
+parse_option(const char *ifname, struct if_options *ifo,
+ int opt, const char *arg)
{
int i, l, t;
unsigned int u;
break;
#endif
case O_IAID:
+ if (ifname == NULL) {
+ syslog(LOG_ERR,
+ "IAID must belong in an interface block");
+ return -1;
+ }
if (parse_iaid(ifo->iaid, arg, sizeof(ifo->iaid)) == -1)
return -1;
ifo->options |= DHCPCD_IAID;
i = D6_OPTION_IA_TA;
/* FALLTHROUGH */
case O_IA_PD:
- if (i == 0)
+ if (i == 0) {
+ if (ifname == NULL) {
+ syslog(LOG_ERR,
+ "IA PD must belong in an interface block");
+ return -1;
+ }
i = D6_OPTION_IA_PD;
+ }
+ if (arg != NULL && ifname == NULL) {
+ syslog(LOG_ERR,
+ "IA with IAID must belong in an interface block");
+ return -1;
+ }
ifo->options |= DHCPCD_IA_FORCED;
if (ifo->ia_type != 0 && ifo->ia_type != i) {
syslog(LOG_ERR, "cannot specify a different IA type");
np = strchr(p, '/');
if (np)
*np++ = '\0';
+ if (strcmp(ifname, p) == 0) {
+ syslog(LOG_ERR,
+ "%s: cannot assign IA_PD to itself",
+ ifname);
+ return -1;
+ }
if (strlcpy(sla->ifname, p,
sizeof(sla->ifname)) >= sizeof(sla->ifname))
{
}
static int
-parse_config_line(struct if_options *ifo, const char *opt, char *line)
+parse_config_line(const char *ifname, struct if_options *ifo,
+ const char *opt, char *line)
{
unsigned int i;
return -1;
}
- return parse_option(ifo, cf_options[i].val, line);
+ return parse_option(ifname, ifo, cf_options[i].val, line);
}
fprintf(stderr, PACKAGE ": unknown option -- %s\n", opt);
*(p - 1) != '\\')
*p-- = '\0';
}
- parse_config_line(ifo, option, line);
+ parse_config_line(NULL, ifo, option, line);
}
}
if (skip)
continue;
- parse_config_line(ifo, option, line);
+ parse_config_line(ifname, ifo, option, line);
}
fclose(f);
}
int
-add_options(struct if_options *ifo, int argc, char **argv)
+add_options(const char *ifname, struct if_options *ifo, int argc, char **argv)
{
int oi, opt, r;
r = 1;
while ((opt = getopt_long(argc, argv, IF_OPTS, cf_options, &oi)) != -1)
{
- r = parse_option(ifo, opt, optarg);
+ r = parse_option(ifname, ifo, opt, optarg);
if (r != 1)
break;
}
struct if_options *read_config(const char *,
const char *, const char *, const char *);
-int add_options(struct if_options *, int, char **);
+int add_options(const char *, struct if_options *, int, char **);
void free_dhcp_opt_embenc(struct dhcp_opt *);
void free_options(struct if_options *);