/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "defs.h"
#include "tables.h"
/*
* Parse the config file which consists of entries of the form:
* ifdefault [<variable> <value>]*
* prefixdefault [<variable> <value>]*
* if <ifname> [<variable> <value>]*
* prefix <prefix>/<length> <ifname> [<variable> <value>]*
*
* All "ifdefault" and "prefixdefault" entries must preceed any
* "if" and "prefix" entries.
*
* Values (such as expiry dates) which contain white space
* can be quoted with single or double quotes.
*/
/* maximum length of messages we send to syslog */
struct configinfo {
char *ci_name;
};
static void set_protocol_defaults(void);
static void print_defaults(void);
struct confvar *);
struct confvar *);
static void parse_if(struct configinfo *, char **, int);
static void parse_prefix(struct configinfo *, char **, int);
/*
* Per interface configuration variables.
* Min, max, and default values are from RFC 2461.
*/
/* Name, Min, Max, Default, Index */
parse_int },
parse_onoff },
/*
* No greater than .75 * MaxRtrAdvInterval.
* Default: 0.33 * MaxRtrAdvInterval
*/
/*
* MUST be either zero or between MaxRtrAdvInterval and 9000 seconds.
* Default: 3 * MaxRtrAdvInterval
*/
/*
* Tmp* variables from RFC 3041, where defaults are defined.
*/
parse_s },
{ NULL, 0, 0, 0, 0 }
};
/*
* Per prefix: AdvPrefixList configuration variables.
* Min, max, and default values are from RFC 2461.
*/
/* Name, Min, Max, Default, Index */
parse_s },
parse_s},
{ "AdvValidExpiration", 0, ~0U, 0, I_AdvValidExpiration,
parse_date },
{ "AdvPreferredExpiration", 0, ~0U, 0, I_AdvPreferredExpiration,
{ NULL, 0, 0, 0, 0 },
};
/*
* Data structures used to merge above protocol defaults
* with defaults specified in the configuration file.
* ifdefault is not static because new interfaces can be
* created outside of the configuration context.
*/
static int lineno;
/*
* Checks for violations of section 5.5.3 (c) of RFC 2462.
*/
static void
{
conferr("AdvPreferredLifetime (%u) is greater than "
}
conferr("AdvPreferredExpiration (%u) is greater than "
}
if (rollback) {
}
}
/*
* Check for invalid lifetime values for RFC3041 addresses
*/
static void
{
/*
* Only need to do this if tmp addrs are enabled.
*/
return;
conferr("TmpDesyncFactor (%u) is greater than "
}
conferr("TmpPreferredLifetime (%u) is greater than "
}
conferr("TmpRegenAdvance (%u) is greater than "
}
if (rollback) {
}
}
int
{
int argcount;
if (debug & D_DEFAULTS)
return (0);
return (-1);
}
int i;
for (i = 0; i < argcount; i++)
i, argvec[i]);
}
if (argcount == 0) {
/* Empty line - or comment only line */
continue;
}
if (defaultdone) {
conferr("ifdefault after non-default "
"command\n");
continue;
}
/*
* Save existing values in case what we read is
* invalid and we need to restore previous settings.
*/
sizeof (save));
if (defaultdone) {
conferr("prefixdefault after non-default "
"command\n");
continue;
}
/*
* Save existing values in case what we read is
* invalid and we need to restore previous settings.
*/
sizeof (prefixdefaults));
sizeof (save));
defaultdone = 1;
defaultdone = 1;
} else {
}
}
if (debug & D_DEFAULTS)
return (0);
}
/*
* Extract the defaults from the configinfo tables to initialize
* the ifdefaults and prefixdefaults arrays.
* The arrays are needed to track which defaults have been changed
* by the config file.
*/
static void
set_protocol_defaults(void)
{
if (debug & D_DEFAULTS)
}
}
}
void
{
}
}
void
{
}
}
static void
print_defaults(void)
{
}
/*
* Read from fp. Handle \ at the end of the line by joining lines together.
* Return 0 on EOF.
*/
static int
{
int got = 0;
errno = 0;
goto retry;
if (got != 0)
return (1);
else
return (0);
}
lineno++;
/* Look for trailing \. Note that fgets includes the linefeed. */
/* Skip \ and LF */
goto retry;
}
/* Remove the trailing linefeed */
if (got > 0)
return (1);
}
/*
* Parse a line splitting it off at whitspace characters.
* Modifies the content of the string by inserting NULLs.
* Returns argcount.
* Handles single quotes and double quotes.
*/
static int
{
int i = 0;
char *cp;
/* Truncate at the beginning of a comment */
*cp = '\0';
for (;;) {
/* Skip any whitespace */
line++;
if (*line == '\'') {
line++;
if (*line == '\0')
return (i);
} else if (*line == '"') {
line++;
if (*line == '\0')
return (i);
}
if (*line == '\0')
return (i);
i++;
/* Skip until next whitespace or end of quoted text */
if (insingle_quote) {
line++;
if (*line == '\'') {
*line = ' ';
} else {
/* Handle missing quote at end */
i--;
conferr("Missing end quote - ignoring <%s>\n",
argvec[i]);
return (i);
}
} else if (indouble_quote) {
line++;
if (*line == '"') {
*line = ' ';
} else {
/* Handle missing quote at end */
i--;
conferr("Missing end quote - ignoring <%s>\n",
argvec[i]);
return (i);
}
} else {
line++;
}
if (*line != '\0') {
/* Break off argument */
*line++ = '\0';
}
if (i > argcount)
return (argcount);
}
/* NOTREACHED */
}
static void
{
}
break;
}
return;
}
return;
}
conferr("Value %s is below minimum %u for %s\n",
return;
}
conferr("Value %s is above maximum %u for %s\n",
return;
}
conferr("MinRtrAdvInterval exceeds .75 * "
"MaxRtrAdvInterval (%u)\n",
return;
}
conferr("MinRtrAdvInterval (%u) exceeds .75 * "
"MaxRtrAdvInterval\n",
return;
}
val != 0 &&
conferr("AdvDefaultLifetime is not between "
"MaxRtrAdrInterval (%u) and 9000 seconds\n",
return;
}
conferr("AdvDefaultLifetime (%u) is not between "
"MaxRtrAdrInterval and 9000 seconds\n",
return;
}
}
}
}
/*
* Split up the line into <variable> <value> pairs
*/
static void
{
while (argcount >= 2) {
argcount -= 2;
argvec += 2;
}
if (argcount != 0)
}
/*
* Returns true if ok; otherwise false.
*/
static void
{
char *ifname;
if (argcount < 1) {
conferr("Missing interface name\n");
return;
}
argvec++;
argcount--;
/*
* Create the physical interface structure.
* Note, phyint_create() sets the interface
* defaults in pi_config.
*/
return;
}
}
while (argcount >= 2) {
argcount -= 2;
argvec += 2;
}
if (argcount != 0)
}
static void
{
int prefixlen;
if (argcount < 2) {
return;
}
argvec += 2;
argcount -= 2;
if (prefixlen == -1) {
return;
}
/*
* Create the physical interface structure.
* Note, phyint_create() sets the interface
* defaults in pi_config.
*/
return;
}
}
int i;
return;
}
/*
* Copy the defaults from the default array.
*/
for (i = 0; i < I_PREFIXSIZE; i++) {
}
}
while (argcount >= 2) {
argcount -= 2;
argvec += 2;
}
if (argcount != 0)
}
/*
* Returns true if ok (and *resp updated) and false if failed.
*/
static boolean_t
{
*resp = 1;
return (_B_TRUE);
}
*resp = 0;
return (_B_TRUE);
}
*resp = 1;
return (_B_TRUE);
}
*resp = 0;
return (_B_TRUE);
}
return (_B_TRUE);
}
return (_B_FALSE);
}
/*
* Returns true if ok (and *resp updated) and false if failed.
*/
static boolean_t
{
char *end;
int res;
return (_B_FALSE);
return (_B_TRUE);
}
/*
* Parse something with a unit of millseconds.
* Regognizes the suffixes "ms", "s", "m", "h", and "d".
*
* Returns true if ok (and *resp updated) and false if failed.
*/
static boolean_t
{
/* Look at the last and next to last character */
}
}
switch (*last) {
case 'd':
multiplier *= 24;
/* FALLTHRU */
case 'h':
multiplier *= 60;
/* FALLTHRU */
case 'm':
multiplier *= 60;
*last = '\0';
break;
case 's':
/* Could be "ms" or "s" */
/* "ms" */
*nlast = '\0';
} else {
*last = '\0';
}
break;
}
return (_B_FALSE);
*resp *= multiplier;
return (_B_TRUE);
}
/*
* Parse something with a unit of seconds.
* Regognizes the suffixes "s", "m", "h", and "d".
*
* Returns true if ok (and *resp updated) and false if failed.
*/
static boolean_t
{
/* Look at the last character */
}
}
switch (*last) {
case 'd':
multiplier *= 24;
/* FALLTHRU */
case 'h':
multiplier *= 60;
/* FALLTHRU */
case 'm':
multiplier *= 60;
/* FALLTHRU */
case 's':
*last = '\0';
break;
}
return (_B_FALSE);
*resp *= multiplier;
return (_B_TRUE);
}
/*
* Return prefixlen (0 to 128) if ok; -1 if failed.
*/
static int
{
int prefixlen;
char *cp;
char *end;
return (-1);
*cp = '\0';
cp++;
return (-1);
return (-1);
return (-1);
return (prefixlen);
}
/*
* Parse an absolute date using a datemsk config file.
* If the date has passed return zero.
*
* Returns true if ok (and *resp updated) and false if failed.
* XXX Due to getdate limitations can not exceed year 2038.
*/
static boolean_t
{
(void) putenv("DATEMSK=/etc/inet/datemsk.ndpd");
}
logperror("gettimeofday");
return (_B_FALSE);
}
str, getdate_err);
return (_B_FALSE);
}
}
*resp = 0;
return (_B_TRUE);
}
return (_B_TRUE);
}
/* PRINTFLIKE1 */
static void
{
}
static FILE *
{
return (NULL);
}
lineno = 0;
}