17c478bd9Sstevel@tonic-gate /* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*d04ccbb3Scarlsonj * Common Development and Distribution License (the "License"). 6*d04ccbb3Scarlsonj * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 217c478bd9Sstevel@tonic-gate /* 22*d04ccbb3Scarlsonj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 237c478bd9Sstevel@tonic-gate * Use is subject to license terms. 247c478bd9Sstevel@tonic-gate */ 257c478bd9Sstevel@tonic-gate 267c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 277c478bd9Sstevel@tonic-gate 287c478bd9Sstevel@tonic-gate #include "defs.h" 297c478bd9Sstevel@tonic-gate #include "tables.h" 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate /* 327c478bd9Sstevel@tonic-gate * Parse the config file which consists of entries of the form: 337c478bd9Sstevel@tonic-gate * ifdefault [<variable> <value>]* 347c478bd9Sstevel@tonic-gate * prefixdefault [<variable> <value>]* 357c478bd9Sstevel@tonic-gate * if <ifname> [<variable> <value>]* 367c478bd9Sstevel@tonic-gate * prefix <prefix>/<length> <ifname> [<variable> <value>]* 377c478bd9Sstevel@tonic-gate * 387c478bd9Sstevel@tonic-gate * All "ifdefault" and "prefixdefault" entries must preceed any 397c478bd9Sstevel@tonic-gate * "if" and "prefix" entries. 407c478bd9Sstevel@tonic-gate * 417c478bd9Sstevel@tonic-gate * Values (such as expiry dates) which contain white space 427c478bd9Sstevel@tonic-gate * can be quoted with single or double quotes. 437c478bd9Sstevel@tonic-gate */ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* maximum length of messages we send to syslog */ 467c478bd9Sstevel@tonic-gate #define NDPD_LOGMSGSIZE 1024 477c478bd9Sstevel@tonic-gate typedef boolean_t (*pfb_t)(char *, uint_t *); 487c478bd9Sstevel@tonic-gate 497c478bd9Sstevel@tonic-gate struct configinfo { 507c478bd9Sstevel@tonic-gate char *ci_name; 517c478bd9Sstevel@tonic-gate uint_t ci_min; /* 0: no min check */ 527c478bd9Sstevel@tonic-gate uint_t ci_max; /* ~0U: no max check */ 537c478bd9Sstevel@tonic-gate uint_t ci_default; 547c478bd9Sstevel@tonic-gate uint_t ci_index; /* Into result array */ 557c478bd9Sstevel@tonic-gate pfb_t ci_parsefunc; /* Parse function returns -1 on failure */ 567c478bd9Sstevel@tonic-gate }; 577c478bd9Sstevel@tonic-gate 587c478bd9Sstevel@tonic-gate enum config_type { CONFIG_IF, CONFIG_PREFIX}; 597c478bd9Sstevel@tonic-gate typedef enum config_type config_type_t; 607c478bd9Sstevel@tonic-gate 617c478bd9Sstevel@tonic-gate static void set_protocol_defaults(void); 627c478bd9Sstevel@tonic-gate static void print_defaults(void); 637c478bd9Sstevel@tonic-gate static void parse_var_value(config_type_t, struct configinfo *, char *, char *, 647c478bd9Sstevel@tonic-gate struct confvar *); 657c478bd9Sstevel@tonic-gate static void parse_default(config_type_t, struct configinfo *, char **, int, 667c478bd9Sstevel@tonic-gate struct confvar *); 677c478bd9Sstevel@tonic-gate static void parse_if(struct configinfo *, char **, int); 687c478bd9Sstevel@tonic-gate static void parse_prefix(struct configinfo *, char **, int); 697c478bd9Sstevel@tonic-gate static boolean_t parse_onoff(char *, uint_t *); /* boolean */ 707c478bd9Sstevel@tonic-gate static boolean_t parse_int(char *, uint_t *); /* integer */ 717c478bd9Sstevel@tonic-gate static boolean_t parse_ms(char *, uint_t *); /* milliseconds */ 727c478bd9Sstevel@tonic-gate static boolean_t parse_s(char *, uint_t *); /* seconds */ 737c478bd9Sstevel@tonic-gate static boolean_t parse_date(char *, uint_t *); /* date format */ 747c478bd9Sstevel@tonic-gate static void conferr(char *fmt, ...); 757c478bd9Sstevel@tonic-gate static FILE *open_conffile(char *filename); 767c478bd9Sstevel@tonic-gate static int parse_line(char *line, char *argvec[], int argcount); 777c478bd9Sstevel@tonic-gate static int readline(FILE *fp, char *line, int length); 787c478bd9Sstevel@tonic-gate static int parse_addrprefix(char *strin, struct in6_addr *in6); 797c478bd9Sstevel@tonic-gate 807c478bd9Sstevel@tonic-gate /* 817c478bd9Sstevel@tonic-gate * Per interface configuration variables. 827c478bd9Sstevel@tonic-gate * Min, max, and default values are from RFC 2461. 837c478bd9Sstevel@tonic-gate */ 847c478bd9Sstevel@tonic-gate static struct configinfo iflist[] = { 857c478bd9Sstevel@tonic-gate /* Name, Min, Max, Default, Index */ 867c478bd9Sstevel@tonic-gate { "DupAddrDetectTransmits", 0, 100, 1, I_DupAddrDetectTransmits, 877c478bd9Sstevel@tonic-gate parse_int }, 887c478bd9Sstevel@tonic-gate { "AdvSendAdvertisements", 0, 1, 0, I_AdvSendAdvertisements, 897c478bd9Sstevel@tonic-gate parse_onoff }, 907c478bd9Sstevel@tonic-gate { "MaxRtrAdvInterval", 4, 1800, 600, I_MaxRtrAdvInterval, parse_s }, 917c478bd9Sstevel@tonic-gate { "MinRtrAdvInterval", 3, 1350, 200, I_MinRtrAdvInterval, parse_s }, 927c478bd9Sstevel@tonic-gate /* 937c478bd9Sstevel@tonic-gate * No greater than .75 * MaxRtrAdvInterval. 947c478bd9Sstevel@tonic-gate * Default: 0.33 * MaxRtrAdvInterval 957c478bd9Sstevel@tonic-gate */ 967c478bd9Sstevel@tonic-gate { "AdvManagedFlag", 0, 1, 0, I_AdvManagedFlag, parse_onoff }, 977c478bd9Sstevel@tonic-gate { "AdvOtherConfigFlag", 0, 1, 0, I_AdvOtherConfigFlag, parse_onoff }, 987c478bd9Sstevel@tonic-gate { "AdvLinkMTU", IPV6_MIN_MTU, 65535, 0, I_AdvLinkMTU, parse_int }, 997c478bd9Sstevel@tonic-gate { "AdvReachableTime", 0, 3600000, 0, I_AdvReachableTime, parse_ms }, 1007c478bd9Sstevel@tonic-gate { "AdvRetransTimer", 0, ~0U, 0, I_AdvRetransTimer, parse_ms }, 1017c478bd9Sstevel@tonic-gate { "AdvCurHopLimit", 0, 255, 0, I_AdvCurHopLimit, parse_int }, 1027c478bd9Sstevel@tonic-gate { "AdvDefaultLifetime", 0, 9000, 1800, I_AdvDefaultLifetime, parse_s }, 1037c478bd9Sstevel@tonic-gate /* 1047c478bd9Sstevel@tonic-gate * MUST be either zero or between MaxRtrAdvInterval and 9000 seconds. 1057c478bd9Sstevel@tonic-gate * Default: 3 * MaxRtrAdvInterval 1067c478bd9Sstevel@tonic-gate */ 1077c478bd9Sstevel@tonic-gate { "StatelessAddrConf", 0, 1, 1, I_StatelessAddrConf, parse_onoff }, 108*d04ccbb3Scarlsonj { "StatefulAddrConf", 0, 1, 1, I_StatefulAddrConf, parse_onoff }, 1097c478bd9Sstevel@tonic-gate /* 1107c478bd9Sstevel@tonic-gate * Tmp* variables from RFC 3041, where defaults are defined. 1117c478bd9Sstevel@tonic-gate */ 1127c478bd9Sstevel@tonic-gate { "TmpAddrsEnabled", 0, 1, 0, I_TmpAddrsEnabled, parse_onoff }, 1137c478bd9Sstevel@tonic-gate { "TmpValidLifetime", 0, ~0U, 604800, I_TmpValidLifetime, parse_s }, 1147c478bd9Sstevel@tonic-gate { "TmpPreferredLifetime", 0, ~0U, 86400, I_TmpPreferredLifetime, 1157c478bd9Sstevel@tonic-gate parse_s }, 1167c478bd9Sstevel@tonic-gate { "TmpRegenAdvance", 0, 60, 5, I_TmpRegenAdvance, parse_s }, 1177c478bd9Sstevel@tonic-gate { "TmpMaxDesyncFactor", 0, 600, 600, I_TmpMaxDesyncFactor, parse_s }, 1187c478bd9Sstevel@tonic-gate { NULL, 0, 0, 0, 0 } 1197c478bd9Sstevel@tonic-gate }; 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate /* 1227c478bd9Sstevel@tonic-gate * Per prefix: AdvPrefixList configuration variables. 1237c478bd9Sstevel@tonic-gate * Min, max, and default values are from RFC 2461. 1247c478bd9Sstevel@tonic-gate */ 1257c478bd9Sstevel@tonic-gate static struct configinfo prefixlist[] = { 1267c478bd9Sstevel@tonic-gate /* Name, Min, Max, Default, Index */ 1277c478bd9Sstevel@tonic-gate { "AdvValidLifetime", 0, ~0U, 2592000, I_AdvValidLifetime, 1287c478bd9Sstevel@tonic-gate parse_s }, 1297c478bd9Sstevel@tonic-gate { "AdvOnLinkFlag", 0, 1, 1, I_AdvOnLinkFlag, parse_onoff }, 1307c478bd9Sstevel@tonic-gate { "AdvPreferredLifetime", 0, ~0U, 604800, I_AdvPreferredLifetime, 1317c478bd9Sstevel@tonic-gate parse_s}, 1327c478bd9Sstevel@tonic-gate { "AdvAutonomousFlag", 0, 1, 1, I_AdvAutonomousFlag, parse_onoff }, 1337c478bd9Sstevel@tonic-gate { "AdvValidExpiration", 0, ~0U, 0, I_AdvValidExpiration, 1347c478bd9Sstevel@tonic-gate parse_date }, 1357c478bd9Sstevel@tonic-gate { "AdvPreferredExpiration", 0, ~0U, 0, I_AdvPreferredExpiration, 1367c478bd9Sstevel@tonic-gate parse_date}, 1377c478bd9Sstevel@tonic-gate { NULL, 0, 0, 0, 0 }, 1387c478bd9Sstevel@tonic-gate }; 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* 1417c478bd9Sstevel@tonic-gate * Data structures used to merge above protocol defaults 1427c478bd9Sstevel@tonic-gate * with defaults specified in the configuration file. 1437c478bd9Sstevel@tonic-gate * ifdefault is not static because new interfaces can be 1447c478bd9Sstevel@tonic-gate * created outside of the configuration context. 1457c478bd9Sstevel@tonic-gate */ 1467c478bd9Sstevel@tonic-gate struct confvar ifdefaults[I_IFSIZE]; 1477c478bd9Sstevel@tonic-gate static struct confvar prefixdefaults[I_PREFIXSIZE]; 1487c478bd9Sstevel@tonic-gate 1497c478bd9Sstevel@tonic-gate static char conf_filename[MAXPATHLEN]; 1507c478bd9Sstevel@tonic-gate static int lineno; 1517c478bd9Sstevel@tonic-gate 1527c478bd9Sstevel@tonic-gate /* 1537c478bd9Sstevel@tonic-gate * Checks for violations of section 5.5.3 (c) of RFC 2462. 1547c478bd9Sstevel@tonic-gate */ 1557c478bd9Sstevel@tonic-gate static void 1567c478bd9Sstevel@tonic-gate check_var_consistency(struct confvar *cv, void *save, int size) 1577c478bd9Sstevel@tonic-gate { 1587c478bd9Sstevel@tonic-gate boolean_t rollback = _B_FALSE; 1597c478bd9Sstevel@tonic-gate int prefl, prefe, valid; 1607c478bd9Sstevel@tonic-gate 1617c478bd9Sstevel@tonic-gate prefl = cv[I_AdvPreferredLifetime].cf_value; 1627c478bd9Sstevel@tonic-gate prefe = cv[I_AdvPreferredExpiration].cf_value; 1637c478bd9Sstevel@tonic-gate valid = cv[I_AdvValidLifetime].cf_value; 1647c478bd9Sstevel@tonic-gate 1657c478bd9Sstevel@tonic-gate if (prefl > valid) { 1667c478bd9Sstevel@tonic-gate conferr("AdvPreferredLifetime (%u) is greater than " 1677c478bd9Sstevel@tonic-gate "valid lifetime (%u)\n", prefl, valid); 1687c478bd9Sstevel@tonic-gate rollback = _B_TRUE; 1697c478bd9Sstevel@tonic-gate } 1707c478bd9Sstevel@tonic-gate 1717c478bd9Sstevel@tonic-gate if (prefe > valid) { 1727c478bd9Sstevel@tonic-gate conferr("AdvPreferredExpiration (%u) is greater than " 1737c478bd9Sstevel@tonic-gate "valid lifetime (%u)\n", prefe, valid); 1747c478bd9Sstevel@tonic-gate rollback = _B_TRUE; 1757c478bd9Sstevel@tonic-gate } 1767c478bd9Sstevel@tonic-gate 1777c478bd9Sstevel@tonic-gate if (rollback) { 1787c478bd9Sstevel@tonic-gate (void) memcpy(cv, save, size); 1797c478bd9Sstevel@tonic-gate } 1807c478bd9Sstevel@tonic-gate } 1817c478bd9Sstevel@tonic-gate 1827c478bd9Sstevel@tonic-gate /* 1837c478bd9Sstevel@tonic-gate * Check for invalid lifetime values for RFC3041 addresses 1847c478bd9Sstevel@tonic-gate */ 1857c478bd9Sstevel@tonic-gate static void 1867c478bd9Sstevel@tonic-gate check_if_var_consistency(struct confvar *cv, void *save, int size) 1877c478bd9Sstevel@tonic-gate { 1887c478bd9Sstevel@tonic-gate boolean_t rollback = _B_FALSE; 1897c478bd9Sstevel@tonic-gate int tpref, tvalid, tdesync, tregen; 1907c478bd9Sstevel@tonic-gate 1917c478bd9Sstevel@tonic-gate tpref = cv[I_TmpPreferredLifetime].cf_value; 1927c478bd9Sstevel@tonic-gate tvalid = cv[I_TmpValidLifetime].cf_value; 1937c478bd9Sstevel@tonic-gate tdesync = cv[I_TmpMaxDesyncFactor].cf_value; 1947c478bd9Sstevel@tonic-gate tregen = cv[I_TmpRegenAdvance].cf_value; 1957c478bd9Sstevel@tonic-gate 1967c478bd9Sstevel@tonic-gate /* 1977c478bd9Sstevel@tonic-gate * Only need to do this if tmp addrs are enabled. 1987c478bd9Sstevel@tonic-gate */ 1997c478bd9Sstevel@tonic-gate if (cv[I_TmpAddrsEnabled].cf_value == 0) 2007c478bd9Sstevel@tonic-gate return; 2017c478bd9Sstevel@tonic-gate 2027c478bd9Sstevel@tonic-gate if (tdesync > tpref) { 2037c478bd9Sstevel@tonic-gate conferr("TmpDesyncFactor (%u) is greater than " 2047c478bd9Sstevel@tonic-gate "TmpPreferredLifetime (%u)\n", tdesync, tpref); 2057c478bd9Sstevel@tonic-gate rollback = _B_TRUE; 2067c478bd9Sstevel@tonic-gate } 2077c478bd9Sstevel@tonic-gate 2087c478bd9Sstevel@tonic-gate if (tpref > tvalid) { 2097c478bd9Sstevel@tonic-gate conferr("TmpPreferredLifetime (%u) is greater than " 2107c478bd9Sstevel@tonic-gate "TmpValidLifetime (%u)\n", tpref, tvalid); 2117c478bd9Sstevel@tonic-gate rollback = _B_TRUE; 2127c478bd9Sstevel@tonic-gate } 2137c478bd9Sstevel@tonic-gate 2147c478bd9Sstevel@tonic-gate if (tregen > tvalid) { 2157c478bd9Sstevel@tonic-gate conferr("TmpRegenAdvance (%u) is greater than " 2167c478bd9Sstevel@tonic-gate "TmpValidLifetime (%u)\n", tregen, tvalid); 2177c478bd9Sstevel@tonic-gate rollback = _B_TRUE; 2187c478bd9Sstevel@tonic-gate } 2197c478bd9Sstevel@tonic-gate 2207c478bd9Sstevel@tonic-gate if (rollback) { 2217c478bd9Sstevel@tonic-gate (void) memcpy(cv, save, size); 2227c478bd9Sstevel@tonic-gate } 2237c478bd9Sstevel@tonic-gate } 2247c478bd9Sstevel@tonic-gate 2257c478bd9Sstevel@tonic-gate int 2267c478bd9Sstevel@tonic-gate parse_config(char *config_file, boolean_t file_required) 2277c478bd9Sstevel@tonic-gate { 2287c478bd9Sstevel@tonic-gate FILE *fp; 2297c478bd9Sstevel@tonic-gate char line[MAXLINELEN]; 2307c478bd9Sstevel@tonic-gate char pline[MAXLINELEN]; 2317c478bd9Sstevel@tonic-gate int argcount; 2327c478bd9Sstevel@tonic-gate char *argvec[MAXARGSPERLINE]; 2337c478bd9Sstevel@tonic-gate int defaultdone = 0; /* Set when first non-default command found */ 2347c478bd9Sstevel@tonic-gate 2357c478bd9Sstevel@tonic-gate if (debug & D_CONFIG) 2367c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_config()\n"); 2377c478bd9Sstevel@tonic-gate 2387c478bd9Sstevel@tonic-gate set_protocol_defaults(); 2397c478bd9Sstevel@tonic-gate if (debug & D_DEFAULTS) 2407c478bd9Sstevel@tonic-gate print_defaults(); 2417c478bd9Sstevel@tonic-gate 2427c478bd9Sstevel@tonic-gate fp = open_conffile(config_file); 2437c478bd9Sstevel@tonic-gate if (fp == NULL) { 2447c478bd9Sstevel@tonic-gate if (errno == ENOENT && !file_required) 2457c478bd9Sstevel@tonic-gate return (0); 2467c478bd9Sstevel@tonic-gate logperror(config_file); 2477c478bd9Sstevel@tonic-gate return (-1); 2487c478bd9Sstevel@tonic-gate } 2497c478bd9Sstevel@tonic-gate while (readline(fp, line, sizeof (line)) != 0) { 2507c478bd9Sstevel@tonic-gate (void) strncpy(pline, line, sizeof (pline)); 2517c478bd9Sstevel@tonic-gate pline[sizeof (pline) - 1] = '\0'; /* NULL terminate */ 2527c478bd9Sstevel@tonic-gate argcount = parse_line(pline, argvec, 2537c478bd9Sstevel@tonic-gate sizeof (argvec) / sizeof (argvec[0])); 2547c478bd9Sstevel@tonic-gate if (debug & D_PARSE) { 2557c478bd9Sstevel@tonic-gate int i; 2567c478bd9Sstevel@tonic-gate 2577c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "scanned %d args\n", argcount); 2587c478bd9Sstevel@tonic-gate for (i = 0; i < argcount; i++) 2597c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "arg[%d]: %s\n", 2607c478bd9Sstevel@tonic-gate i, argvec[i]); 2617c478bd9Sstevel@tonic-gate } 2627c478bd9Sstevel@tonic-gate if (argcount == 0) { 2637c478bd9Sstevel@tonic-gate /* Empty line - or comment only line */ 2647c478bd9Sstevel@tonic-gate continue; 2657c478bd9Sstevel@tonic-gate } 2667c478bd9Sstevel@tonic-gate if (strcmp(argvec[0], "ifdefault") == 0) { 2677c478bd9Sstevel@tonic-gate char save[sizeof (ifdefaults)]; 2687c478bd9Sstevel@tonic-gate 2697c478bd9Sstevel@tonic-gate if (defaultdone) { 2707c478bd9Sstevel@tonic-gate conferr("ifdefault after non-default " 2717c478bd9Sstevel@tonic-gate "command\n"); 2727c478bd9Sstevel@tonic-gate continue; 2737c478bd9Sstevel@tonic-gate } 2747c478bd9Sstevel@tonic-gate /* 2757c478bd9Sstevel@tonic-gate * Save existing values in case what we read is 2767c478bd9Sstevel@tonic-gate * invalid and we need to restore previous settings. 2777c478bd9Sstevel@tonic-gate */ 2787c478bd9Sstevel@tonic-gate (void) memcpy(save, ifdefaults, sizeof (ifdefaults)); 2797c478bd9Sstevel@tonic-gate parse_default(CONFIG_IF, iflist, argvec+1, argcount-1, 2807c478bd9Sstevel@tonic-gate ifdefaults); 2817c478bd9Sstevel@tonic-gate check_if_var_consistency(ifdefaults, save, 2827c478bd9Sstevel@tonic-gate sizeof (save)); 2837c478bd9Sstevel@tonic-gate } else if (strcmp(argvec[0], "prefixdefault") == 0) { 2847c478bd9Sstevel@tonic-gate char save[sizeof (prefixdefaults)]; 2857c478bd9Sstevel@tonic-gate 2867c478bd9Sstevel@tonic-gate if (defaultdone) { 2877c478bd9Sstevel@tonic-gate conferr("prefixdefault after non-default " 2887c478bd9Sstevel@tonic-gate "command\n"); 2897c478bd9Sstevel@tonic-gate continue; 2907c478bd9Sstevel@tonic-gate } 2917c478bd9Sstevel@tonic-gate /* 2927c478bd9Sstevel@tonic-gate * Save existing values in case what we read is 2937c478bd9Sstevel@tonic-gate * invalid and we need to restore previous settings. 2947c478bd9Sstevel@tonic-gate */ 2957c478bd9Sstevel@tonic-gate (void) memcpy(save, prefixdefaults, 2967c478bd9Sstevel@tonic-gate sizeof (prefixdefaults)); 2977c478bd9Sstevel@tonic-gate parse_default(CONFIG_PREFIX, prefixlist, argvec+1, 2987c478bd9Sstevel@tonic-gate argcount-1, prefixdefaults); 2997c478bd9Sstevel@tonic-gate check_var_consistency(prefixdefaults, save, 3007c478bd9Sstevel@tonic-gate sizeof (save)); 3017c478bd9Sstevel@tonic-gate } else if (strcmp(argvec[0], "if") == 0) { 3027c478bd9Sstevel@tonic-gate defaultdone = 1; 3037c478bd9Sstevel@tonic-gate parse_if(iflist, argvec+1, argcount-1); 3047c478bd9Sstevel@tonic-gate } else if (strcmp(argvec[0], "prefix") == 0) { 3057c478bd9Sstevel@tonic-gate defaultdone = 1; 3067c478bd9Sstevel@tonic-gate parse_prefix(prefixlist, argvec+1, argcount-1); 3077c478bd9Sstevel@tonic-gate } else { 3087c478bd9Sstevel@tonic-gate conferr("Unknown command: %s\n", argvec[0]); 3097c478bd9Sstevel@tonic-gate } 3107c478bd9Sstevel@tonic-gate } 3117c478bd9Sstevel@tonic-gate (void) fclose(fp); 3127c478bd9Sstevel@tonic-gate if (debug & D_DEFAULTS) 3137c478bd9Sstevel@tonic-gate print_defaults(); 3147c478bd9Sstevel@tonic-gate return (0); 3157c478bd9Sstevel@tonic-gate } 3167c478bd9Sstevel@tonic-gate 3177c478bd9Sstevel@tonic-gate /* 3187c478bd9Sstevel@tonic-gate * Extract the defaults from the configinfo tables to initialize 3197c478bd9Sstevel@tonic-gate * the ifdefaults and prefixdefaults arrays. 3207c478bd9Sstevel@tonic-gate * The arrays are needed to track which defaults have been changed 3217c478bd9Sstevel@tonic-gate * by the config file. 3227c478bd9Sstevel@tonic-gate */ 3237c478bd9Sstevel@tonic-gate static void 3247c478bd9Sstevel@tonic-gate set_protocol_defaults(void) 3257c478bd9Sstevel@tonic-gate { 3267c478bd9Sstevel@tonic-gate struct configinfo *cip; 3277c478bd9Sstevel@tonic-gate 3287c478bd9Sstevel@tonic-gate if (debug & D_DEFAULTS) 3297c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "extract_protocol_defaults\n"); 3307c478bd9Sstevel@tonic-gate for (cip = iflist; cip->ci_name != NULL; cip++) { 3317c478bd9Sstevel@tonic-gate ifdefaults[cip->ci_index].cf_value = cip->ci_default; 3327c478bd9Sstevel@tonic-gate ifdefaults[cip->ci_index].cf_notdefault = _B_FALSE; 3337c478bd9Sstevel@tonic-gate } 3347c478bd9Sstevel@tonic-gate for (cip = prefixlist; cip->ci_name != NULL; cip++) { 3357c478bd9Sstevel@tonic-gate prefixdefaults[cip->ci_index].cf_value = cip->ci_default; 3367c478bd9Sstevel@tonic-gate prefixdefaults[cip->ci_index].cf_notdefault = _B_FALSE; 3377c478bd9Sstevel@tonic-gate } 3387c478bd9Sstevel@tonic-gate } 3397c478bd9Sstevel@tonic-gate 3407c478bd9Sstevel@tonic-gate void 3417c478bd9Sstevel@tonic-gate print_iflist(struct confvar *confvar) 3427c478bd9Sstevel@tonic-gate { 3437c478bd9Sstevel@tonic-gate struct configinfo *cip; 3447c478bd9Sstevel@tonic-gate 3457c478bd9Sstevel@tonic-gate for (cip = iflist; cip->ci_name != NULL; cip++) { 3467c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "\t%s min %u max %u def %u value %u set %d\n", 3477c478bd9Sstevel@tonic-gate cip->ci_name, cip->ci_min, cip->ci_max, cip->ci_default, 3487c478bd9Sstevel@tonic-gate confvar[cip->ci_index].cf_value, 3497c478bd9Sstevel@tonic-gate confvar[cip->ci_index].cf_notdefault); 3507c478bd9Sstevel@tonic-gate } 3517c478bd9Sstevel@tonic-gate } 3527c478bd9Sstevel@tonic-gate 3537c478bd9Sstevel@tonic-gate void 3547c478bd9Sstevel@tonic-gate print_prefixlist(struct confvar *confvar) 3557c478bd9Sstevel@tonic-gate { 3567c478bd9Sstevel@tonic-gate struct configinfo *cip; 3577c478bd9Sstevel@tonic-gate 3587c478bd9Sstevel@tonic-gate for (cip = prefixlist; cip->ci_name != NULL; cip++) { 3597c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "\t%s min %u max %u def %u value %u set %d\n", 3607c478bd9Sstevel@tonic-gate cip->ci_name, cip->ci_min, cip->ci_max, cip->ci_default, 3617c478bd9Sstevel@tonic-gate confvar[cip->ci_index].cf_value, 3627c478bd9Sstevel@tonic-gate confvar[cip->ci_index].cf_notdefault); 3637c478bd9Sstevel@tonic-gate } 3647c478bd9Sstevel@tonic-gate } 3657c478bd9Sstevel@tonic-gate 3667c478bd9Sstevel@tonic-gate 3677c478bd9Sstevel@tonic-gate static void 3687c478bd9Sstevel@tonic-gate print_defaults(void) 3697c478bd9Sstevel@tonic-gate { 3707c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "Default interface variables:\n"); 3717c478bd9Sstevel@tonic-gate print_iflist(ifdefaults); 3727c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "Default prefix variables:\n"); 3737c478bd9Sstevel@tonic-gate print_prefixlist(prefixdefaults); 3747c478bd9Sstevel@tonic-gate } 3757c478bd9Sstevel@tonic-gate 3767c478bd9Sstevel@tonic-gate /* 3777c478bd9Sstevel@tonic-gate * Read from fp. Handle \ at the end of the line by joining lines together. 3787c478bd9Sstevel@tonic-gate * Return 0 on EOF. 3797c478bd9Sstevel@tonic-gate */ 3807c478bd9Sstevel@tonic-gate static int 3817c478bd9Sstevel@tonic-gate readline(FILE *fp, char *line, int length) 3827c478bd9Sstevel@tonic-gate { 3837c478bd9Sstevel@tonic-gate int got = 0; 3847c478bd9Sstevel@tonic-gate 3857c478bd9Sstevel@tonic-gate retry: 3867c478bd9Sstevel@tonic-gate errno = 0; 3877c478bd9Sstevel@tonic-gate if (fgets(line, length, fp) == NULL) { 3887c478bd9Sstevel@tonic-gate if (errno == EINTR) 3897c478bd9Sstevel@tonic-gate goto retry; 3907c478bd9Sstevel@tonic-gate if (got != 0) 3917c478bd9Sstevel@tonic-gate return (1); 3927c478bd9Sstevel@tonic-gate else 3937c478bd9Sstevel@tonic-gate return (0); 3947c478bd9Sstevel@tonic-gate } 3957c478bd9Sstevel@tonic-gate lineno++; 3967c478bd9Sstevel@tonic-gate got = strlen(line); 3977c478bd9Sstevel@tonic-gate /* Look for trailing \. Note that fgets includes the linefeed. */ 3987c478bd9Sstevel@tonic-gate if (got >= 2 && line[got-2] == '\\') { 3997c478bd9Sstevel@tonic-gate /* Skip \ and LF */ 4007c478bd9Sstevel@tonic-gate line += got - 2; 4017c478bd9Sstevel@tonic-gate length -= got - 2; 4027c478bd9Sstevel@tonic-gate goto retry; 4037c478bd9Sstevel@tonic-gate } 4047c478bd9Sstevel@tonic-gate /* Remove the trailing linefeed */ 4057c478bd9Sstevel@tonic-gate if (got > 0) 4067c478bd9Sstevel@tonic-gate line[got-1] = '\0'; 4077c478bd9Sstevel@tonic-gate 4087c478bd9Sstevel@tonic-gate return (1); 4097c478bd9Sstevel@tonic-gate } 4107c478bd9Sstevel@tonic-gate 4117c478bd9Sstevel@tonic-gate /* 4127c478bd9Sstevel@tonic-gate * Parse a line splitting it off at whitspace characters. 4137c478bd9Sstevel@tonic-gate * Modifies the content of the string by inserting NULLs. 4147c478bd9Sstevel@tonic-gate * If more arguments than fits in argvec/argcount then ignore the last. 4157c478bd9Sstevel@tonic-gate * Returns argcount. 4167c478bd9Sstevel@tonic-gate * Handles single quotes and double quotes. 4177c478bd9Sstevel@tonic-gate */ 4187c478bd9Sstevel@tonic-gate static int 4197c478bd9Sstevel@tonic-gate parse_line(char *line, char *argvec[], int argcount) 4207c478bd9Sstevel@tonic-gate { 4217c478bd9Sstevel@tonic-gate int i = 0; 4227c478bd9Sstevel@tonic-gate char *cp; 4237c478bd9Sstevel@tonic-gate boolean_t insingle_quote = _B_FALSE; 4247c478bd9Sstevel@tonic-gate boolean_t indouble_quote = _B_FALSE; 4257c478bd9Sstevel@tonic-gate 4267c478bd9Sstevel@tonic-gate /* Truncate at the beginning of a comment */ 4277c478bd9Sstevel@tonic-gate cp = strchr(line, '#'); 4287c478bd9Sstevel@tonic-gate if (cp != NULL) 4297c478bd9Sstevel@tonic-gate *cp = '\0'; 4307c478bd9Sstevel@tonic-gate 4317c478bd9Sstevel@tonic-gate for (;;) { 4327c478bd9Sstevel@tonic-gate /* Skip any whitespace */ 4337c478bd9Sstevel@tonic-gate while (isspace(*line) && *line != '\0') 4347c478bd9Sstevel@tonic-gate line++; 4357c478bd9Sstevel@tonic-gate 4367c478bd9Sstevel@tonic-gate if (*line == '\'') { 4377c478bd9Sstevel@tonic-gate line++; 4387c478bd9Sstevel@tonic-gate if (*line == '\0') 4397c478bd9Sstevel@tonic-gate return (i); 4407c478bd9Sstevel@tonic-gate insingle_quote = _B_TRUE; 4417c478bd9Sstevel@tonic-gate } else if (*line == '"') { 4427c478bd9Sstevel@tonic-gate line++; 4437c478bd9Sstevel@tonic-gate if (*line == '\0') 4447c478bd9Sstevel@tonic-gate return (i); 4457c478bd9Sstevel@tonic-gate indouble_quote = _B_TRUE; 4467c478bd9Sstevel@tonic-gate } 4477c478bd9Sstevel@tonic-gate argvec[i] = line; 4487c478bd9Sstevel@tonic-gate if (*line == '\0') 4497c478bd9Sstevel@tonic-gate return (i); 4507c478bd9Sstevel@tonic-gate i++; 4517c478bd9Sstevel@tonic-gate /* Skip until next whitespace or end of quoted text */ 4527c478bd9Sstevel@tonic-gate if (insingle_quote) { 4537c478bd9Sstevel@tonic-gate while (*line != '\'' && *line != '\0') 4547c478bd9Sstevel@tonic-gate line++; 4557c478bd9Sstevel@tonic-gate if (*line == '\'') { 4567c478bd9Sstevel@tonic-gate *line = ' '; 4577c478bd9Sstevel@tonic-gate } else { 4587c478bd9Sstevel@tonic-gate /* Handle missing quote at end */ 4597c478bd9Sstevel@tonic-gate i--; 4607c478bd9Sstevel@tonic-gate conferr("Missing end quote - ignoring <%s>\n", 4617c478bd9Sstevel@tonic-gate argvec[i]); 4627c478bd9Sstevel@tonic-gate return (i); 4637c478bd9Sstevel@tonic-gate } 4647c478bd9Sstevel@tonic-gate insingle_quote = _B_FALSE; 4657c478bd9Sstevel@tonic-gate } else if (indouble_quote) { 4667c478bd9Sstevel@tonic-gate while (*line != '"' && *line != '\0') 4677c478bd9Sstevel@tonic-gate line++; 4687c478bd9Sstevel@tonic-gate if (*line == '"') { 4697c478bd9Sstevel@tonic-gate *line = ' '; 4707c478bd9Sstevel@tonic-gate } else { 4717c478bd9Sstevel@tonic-gate /* Handle missing quote at end */ 4727c478bd9Sstevel@tonic-gate i--; 4737c478bd9Sstevel@tonic-gate conferr("Missing end quote - ignoring <%s>\n", 4747c478bd9Sstevel@tonic-gate argvec[i]); 4757c478bd9Sstevel@tonic-gate return (i); 4767c478bd9Sstevel@tonic-gate } 4777c478bd9Sstevel@tonic-gate indouble_quote = _B_FALSE; 4787c478bd9Sstevel@tonic-gate } else { 4797c478bd9Sstevel@tonic-gate while (!isspace(*line) && *line != '\0') 4807c478bd9Sstevel@tonic-gate line++; 4817c478bd9Sstevel@tonic-gate } 4827c478bd9Sstevel@tonic-gate if (*line != '\0') { 4837c478bd9Sstevel@tonic-gate /* Break off argument */ 4847c478bd9Sstevel@tonic-gate *line++ = '\0'; 4857c478bd9Sstevel@tonic-gate } 4867c478bd9Sstevel@tonic-gate if (i > argcount) 4877c478bd9Sstevel@tonic-gate return (argcount); 4887c478bd9Sstevel@tonic-gate } 4897c478bd9Sstevel@tonic-gate /* NOTREACHED */ 4907c478bd9Sstevel@tonic-gate } 4917c478bd9Sstevel@tonic-gate 4927c478bd9Sstevel@tonic-gate static void 4937c478bd9Sstevel@tonic-gate parse_var_value(config_type_t type, struct configinfo *list, char *varstr, 4947c478bd9Sstevel@tonic-gate char *valstr, struct confvar *confvar) 4957c478bd9Sstevel@tonic-gate { 4967c478bd9Sstevel@tonic-gate struct configinfo *cip; 4977c478bd9Sstevel@tonic-gate uint_t val; 4987c478bd9Sstevel@tonic-gate 4997c478bd9Sstevel@tonic-gate if (debug & D_CONFIG) { 5007c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_var_value(%d, %s, %s)\n", 5017c478bd9Sstevel@tonic-gate (int)type, varstr, valstr); 5027c478bd9Sstevel@tonic-gate } 5037c478bd9Sstevel@tonic-gate 5047c478bd9Sstevel@tonic-gate for (cip = list; cip->ci_name != NULL; cip++) { 5057c478bd9Sstevel@tonic-gate if (strcasecmp(cip->ci_name, varstr) == 0) 5067c478bd9Sstevel@tonic-gate break; 5077c478bd9Sstevel@tonic-gate } 5087c478bd9Sstevel@tonic-gate if (cip->ci_name == NULL) { 5097c478bd9Sstevel@tonic-gate conferr("Unknown variable: <%s>\n", varstr); 5107c478bd9Sstevel@tonic-gate return; 5117c478bd9Sstevel@tonic-gate } 5127c478bd9Sstevel@tonic-gate if (!(*cip->ci_parsefunc)(valstr, &val)) { 5137c478bd9Sstevel@tonic-gate conferr("Bad value: <%s>\n", valstr); 5147c478bd9Sstevel@tonic-gate return; 5157c478bd9Sstevel@tonic-gate } 5167c478bd9Sstevel@tonic-gate if (cip->ci_min != 0 && val < cip->ci_min) { 5177c478bd9Sstevel@tonic-gate conferr("Value %s is below minimum %u for %s\n", 5187c478bd9Sstevel@tonic-gate valstr, cip->ci_min, varstr); 5197c478bd9Sstevel@tonic-gate return; 5207c478bd9Sstevel@tonic-gate } 5217c478bd9Sstevel@tonic-gate if (cip->ci_max != ~0U && val > cip->ci_max) { 5227c478bd9Sstevel@tonic-gate conferr("Value %s is above maximum %u for %s\n", 5237c478bd9Sstevel@tonic-gate valstr, cip->ci_max, varstr); 5247c478bd9Sstevel@tonic-gate return; 5257c478bd9Sstevel@tonic-gate } 5267c478bd9Sstevel@tonic-gate /* Check against dynamic/relative limits */ 5277c478bd9Sstevel@tonic-gate if (type == CONFIG_IF) { 5287c478bd9Sstevel@tonic-gate if (cip->ci_index == I_MinRtrAdvInterval && 5297c478bd9Sstevel@tonic-gate confvar[I_MaxRtrAdvInterval].cf_notdefault && 5307c478bd9Sstevel@tonic-gate val > confvar[I_MaxRtrAdvInterval].cf_value * 0.75) { 5317c478bd9Sstevel@tonic-gate conferr("MinRtrAdvInterval exceeds .75 * " 5327c478bd9Sstevel@tonic-gate "MaxRtrAdvInterval (%u)\n", 5337c478bd9Sstevel@tonic-gate confvar[I_MaxRtrAdvInterval].cf_value); 5347c478bd9Sstevel@tonic-gate return; 5357c478bd9Sstevel@tonic-gate } 5367c478bd9Sstevel@tonic-gate if (cip->ci_index == I_MaxRtrAdvInterval && 5377c478bd9Sstevel@tonic-gate confvar[I_MinRtrAdvInterval].cf_notdefault && 5387c478bd9Sstevel@tonic-gate confvar[I_MinRtrAdvInterval].cf_value > val * 0.75) { 5397c478bd9Sstevel@tonic-gate conferr("MinRtrAdvInterval (%u) exceeds .75 * " 5407c478bd9Sstevel@tonic-gate "MaxRtrAdvInterval\n", 5417c478bd9Sstevel@tonic-gate confvar[I_MinRtrAdvInterval].cf_value); 5427c478bd9Sstevel@tonic-gate return; 5437c478bd9Sstevel@tonic-gate } 5447c478bd9Sstevel@tonic-gate if (cip->ci_index == I_AdvDefaultLifetime && 5457c478bd9Sstevel@tonic-gate confvar[I_MaxRtrAdvInterval].cf_notdefault && 5467c478bd9Sstevel@tonic-gate val != 0 && 5477c478bd9Sstevel@tonic-gate val < confvar[I_MaxRtrAdvInterval].cf_value) { 5487c478bd9Sstevel@tonic-gate conferr("AdvDefaultLifetime is not between " 5497c478bd9Sstevel@tonic-gate "MaxRtrAdrInterval (%u) and 9000 seconds\n", 5507c478bd9Sstevel@tonic-gate confvar[I_MaxRtrAdvInterval].cf_value); 5517c478bd9Sstevel@tonic-gate return; 5527c478bd9Sstevel@tonic-gate } 5537c478bd9Sstevel@tonic-gate if (cip->ci_index == I_MaxRtrAdvInterval && 5547c478bd9Sstevel@tonic-gate confvar[I_AdvDefaultLifetime].cf_notdefault && 5557c478bd9Sstevel@tonic-gate confvar[I_AdvDefaultLifetime].cf_value < val) { 5567c478bd9Sstevel@tonic-gate conferr("AdvDefaultLifetime (%u) is not between " 5577c478bd9Sstevel@tonic-gate "MaxRtrAdrInterval and 9000 seconds\n", 5587c478bd9Sstevel@tonic-gate confvar[I_AdvDefaultLifetime].cf_value); 5597c478bd9Sstevel@tonic-gate return; 5607c478bd9Sstevel@tonic-gate } 5617c478bd9Sstevel@tonic-gate } 5627c478bd9Sstevel@tonic-gate confvar[cip->ci_index].cf_value = val; 5637c478bd9Sstevel@tonic-gate confvar[cip->ci_index].cf_notdefault = _B_TRUE; 5647c478bd9Sstevel@tonic-gate 5657c478bd9Sstevel@tonic-gate /* Derive dynamic/relative variables based on this one */ 5667c478bd9Sstevel@tonic-gate if (type == CONFIG_IF) { 5677c478bd9Sstevel@tonic-gate if (cip->ci_index == I_MaxRtrAdvInterval && 5687c478bd9Sstevel@tonic-gate !confvar[I_MinRtrAdvInterval].cf_notdefault) 5697c478bd9Sstevel@tonic-gate confvar[I_MinRtrAdvInterval].cf_value = val / 3; 5707c478bd9Sstevel@tonic-gate if (cip->ci_index == I_MaxRtrAdvInterval && 5717c478bd9Sstevel@tonic-gate !confvar[I_AdvDefaultLifetime].cf_notdefault) 5727c478bd9Sstevel@tonic-gate confvar[I_AdvDefaultLifetime].cf_value = 3 * val; 5737c478bd9Sstevel@tonic-gate } 5747c478bd9Sstevel@tonic-gate } 5757c478bd9Sstevel@tonic-gate 5767c478bd9Sstevel@tonic-gate /* 5777c478bd9Sstevel@tonic-gate * Split up the line into <variable> <value> pairs 5787c478bd9Sstevel@tonic-gate */ 5797c478bd9Sstevel@tonic-gate static void 5807c478bd9Sstevel@tonic-gate parse_default(config_type_t type, struct configinfo *list, 5817c478bd9Sstevel@tonic-gate char *argvec[], int argcount, struct confvar *defaults) 5827c478bd9Sstevel@tonic-gate { 5837c478bd9Sstevel@tonic-gate if (debug & D_CONFIG) 5847c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_default: argc %d\n", argcount); 5857c478bd9Sstevel@tonic-gate while (argcount >= 2) { 5867c478bd9Sstevel@tonic-gate parse_var_value(type, list, argvec[0], argvec[1], defaults); 5877c478bd9Sstevel@tonic-gate 5887c478bd9Sstevel@tonic-gate argcount -= 2; 5897c478bd9Sstevel@tonic-gate argvec += 2; 5907c478bd9Sstevel@tonic-gate } 5917c478bd9Sstevel@tonic-gate if (argcount != 0) 5927c478bd9Sstevel@tonic-gate conferr("Trailing text <%s> ignored\n", argvec[0]); 5937c478bd9Sstevel@tonic-gate } 5947c478bd9Sstevel@tonic-gate 5957c478bd9Sstevel@tonic-gate /* 5967c478bd9Sstevel@tonic-gate * Returns true if ok; otherwise false. 5977c478bd9Sstevel@tonic-gate */ 5987c478bd9Sstevel@tonic-gate static void 5997c478bd9Sstevel@tonic-gate parse_if(struct configinfo *list, char *argvec[], int argcount) 6007c478bd9Sstevel@tonic-gate { 6017c478bd9Sstevel@tonic-gate char *ifname; 6027c478bd9Sstevel@tonic-gate struct phyint *pi; 6037c478bd9Sstevel@tonic-gate char save[sizeof (pi->pi_config)]; 6047c478bd9Sstevel@tonic-gate 6057c478bd9Sstevel@tonic-gate if (debug & D_CONFIG) 6067c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_if: argc %d\n", argcount); 6077c478bd9Sstevel@tonic-gate 6087c478bd9Sstevel@tonic-gate if (argcount < 1) { 6097c478bd9Sstevel@tonic-gate conferr("Missing interface name\n"); 6107c478bd9Sstevel@tonic-gate return; 6117c478bd9Sstevel@tonic-gate } 6127c478bd9Sstevel@tonic-gate ifname = argvec[0]; 6137c478bd9Sstevel@tonic-gate argvec++; 6147c478bd9Sstevel@tonic-gate argcount--; 6157c478bd9Sstevel@tonic-gate 6167c478bd9Sstevel@tonic-gate pi = phyint_lookup(ifname); 6177c478bd9Sstevel@tonic-gate if (pi == NULL) { 6187c478bd9Sstevel@tonic-gate /* 6197c478bd9Sstevel@tonic-gate * Create the physical interface structure. 6207c478bd9Sstevel@tonic-gate * Note, phyint_create() sets the interface 6217c478bd9Sstevel@tonic-gate * defaults in pi_config. 6227c478bd9Sstevel@tonic-gate */ 6237c478bd9Sstevel@tonic-gate pi = phyint_create(ifname); 6247c478bd9Sstevel@tonic-gate if (pi == NULL) { 6257c478bd9Sstevel@tonic-gate conferr("Unable to use interface %s\n", ifname); 6267c478bd9Sstevel@tonic-gate return; 6277c478bd9Sstevel@tonic-gate } 6287c478bd9Sstevel@tonic-gate } 6297c478bd9Sstevel@tonic-gate 6307c478bd9Sstevel@tonic-gate (void) memcpy(save, pi->pi_config, sizeof (save)); 6317c478bd9Sstevel@tonic-gate while (argcount >= 2) { 6327c478bd9Sstevel@tonic-gate parse_var_value(CONFIG_IF, list, argvec[0], argvec[1], 6337c478bd9Sstevel@tonic-gate pi->pi_config); 6347c478bd9Sstevel@tonic-gate 6357c478bd9Sstevel@tonic-gate argcount -= 2; 6367c478bd9Sstevel@tonic-gate argvec += 2; 6377c478bd9Sstevel@tonic-gate } 6387c478bd9Sstevel@tonic-gate if (argcount != 0) 6397c478bd9Sstevel@tonic-gate logmsg(LOG_ERR, "Trailing text <%s> ignored\n", argvec[0]); 6407c478bd9Sstevel@tonic-gate check_if_var_consistency(pi->pi_config, save, sizeof (save)); 6417c478bd9Sstevel@tonic-gate } 6427c478bd9Sstevel@tonic-gate 6437c478bd9Sstevel@tonic-gate static void 6447c478bd9Sstevel@tonic-gate parse_prefix(struct configinfo *list, char *argvec[], int argcount) 6457c478bd9Sstevel@tonic-gate { 6467c478bd9Sstevel@tonic-gate char *ifname, *prefix; 6477c478bd9Sstevel@tonic-gate struct phyint *pi; 6487c478bd9Sstevel@tonic-gate struct adv_prefix *adv_pr; 6497c478bd9Sstevel@tonic-gate struct in6_addr in6; 6507c478bd9Sstevel@tonic-gate int prefixlen; 6517c478bd9Sstevel@tonic-gate char save[sizeof (adv_pr->adv_pr_config)]; 6527c478bd9Sstevel@tonic-gate 6537c478bd9Sstevel@tonic-gate if (debug & D_CONFIG) 6547c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_prefix: argc %d\n", argcount); 6557c478bd9Sstevel@tonic-gate 6567c478bd9Sstevel@tonic-gate if (argcount < 2) { 6577c478bd9Sstevel@tonic-gate conferr("Missing prefix and/or interface name\n"); 6587c478bd9Sstevel@tonic-gate return; 6597c478bd9Sstevel@tonic-gate } 6607c478bd9Sstevel@tonic-gate prefix = argvec[0]; 6617c478bd9Sstevel@tonic-gate ifname = argvec[1]; 6627c478bd9Sstevel@tonic-gate argvec += 2; 6637c478bd9Sstevel@tonic-gate argcount -= 2; 6647c478bd9Sstevel@tonic-gate 6657c478bd9Sstevel@tonic-gate prefixlen = parse_addrprefix(prefix, &in6); 6667c478bd9Sstevel@tonic-gate if (prefixlen == -1) { 6677c478bd9Sstevel@tonic-gate conferr("Bad prefix %s\n", prefix); 6687c478bd9Sstevel@tonic-gate return; 6697c478bd9Sstevel@tonic-gate } 6707c478bd9Sstevel@tonic-gate 6717c478bd9Sstevel@tonic-gate pi = phyint_lookup(ifname); 6727c478bd9Sstevel@tonic-gate if (pi == NULL) { 6737c478bd9Sstevel@tonic-gate /* 6747c478bd9Sstevel@tonic-gate * Create the physical interface structure. 6757c478bd9Sstevel@tonic-gate * Note, phyint_create() sets the interface 6767c478bd9Sstevel@tonic-gate * defaults in pi_config. 6777c478bd9Sstevel@tonic-gate */ 6787c478bd9Sstevel@tonic-gate pi = phyint_create(ifname); 6797c478bd9Sstevel@tonic-gate if (pi == NULL) { 6807c478bd9Sstevel@tonic-gate conferr("Unable to use interface %s\n", ifname); 6817c478bd9Sstevel@tonic-gate return; 6827c478bd9Sstevel@tonic-gate } 6837c478bd9Sstevel@tonic-gate } 6847c478bd9Sstevel@tonic-gate adv_pr = adv_prefix_lookup(pi, in6, prefixlen); 6857c478bd9Sstevel@tonic-gate if (adv_pr == NULL) { 6867c478bd9Sstevel@tonic-gate int i; 6877c478bd9Sstevel@tonic-gate 6887c478bd9Sstevel@tonic-gate adv_pr = adv_prefix_create(pi, in6, prefixlen); 6897c478bd9Sstevel@tonic-gate if (adv_pr == NULL) { 6907c478bd9Sstevel@tonic-gate conferr("Unable to create prefix %s\n", prefix); 6917c478bd9Sstevel@tonic-gate return; 6927c478bd9Sstevel@tonic-gate } 6937c478bd9Sstevel@tonic-gate /* 6947c478bd9Sstevel@tonic-gate * Copy the defaults from the default array. 6957c478bd9Sstevel@tonic-gate */ 6967c478bd9Sstevel@tonic-gate for (i = 0; i < I_PREFIXSIZE; i++) { 6977c478bd9Sstevel@tonic-gate adv_pr->adv_pr_config[i].cf_value = 6987c478bd9Sstevel@tonic-gate prefixdefaults[i].cf_value; 6997c478bd9Sstevel@tonic-gate adv_pr->adv_pr_config[i].cf_notdefault = 7007c478bd9Sstevel@tonic-gate prefixdefaults[i].cf_notdefault; 7017c478bd9Sstevel@tonic-gate } 7027c478bd9Sstevel@tonic-gate } 7037c478bd9Sstevel@tonic-gate 7047c478bd9Sstevel@tonic-gate (void) memcpy(save, adv_pr->adv_pr_config, sizeof (save)); 7057c478bd9Sstevel@tonic-gate while (argcount >= 2) { 7067c478bd9Sstevel@tonic-gate parse_var_value(CONFIG_PREFIX, list, argvec[0], argvec[1], 7077c478bd9Sstevel@tonic-gate adv_pr->adv_pr_config); 7087c478bd9Sstevel@tonic-gate 7097c478bd9Sstevel@tonic-gate argcount -= 2; 7107c478bd9Sstevel@tonic-gate argvec += 2; 7117c478bd9Sstevel@tonic-gate } 7127c478bd9Sstevel@tonic-gate check_var_consistency(adv_pr->adv_pr_config, save, sizeof (save)); 7137c478bd9Sstevel@tonic-gate if (argcount != 0) 7147c478bd9Sstevel@tonic-gate logmsg(LOG_ERR, "Trailing text <%s> ignored\n", argvec[0]); 7157c478bd9Sstevel@tonic-gate } 7167c478bd9Sstevel@tonic-gate 7177c478bd9Sstevel@tonic-gate /* 7187c478bd9Sstevel@tonic-gate * Returns true if ok (and *resp updated) and false if failed. 7197c478bd9Sstevel@tonic-gate */ 7207c478bd9Sstevel@tonic-gate static boolean_t 7217c478bd9Sstevel@tonic-gate parse_onoff(char *str, uint_t *resp) 7227c478bd9Sstevel@tonic-gate { 7237c478bd9Sstevel@tonic-gate if (strcasecmp(str, "on") == 0) { 7247c478bd9Sstevel@tonic-gate *resp = 1; 7257c478bd9Sstevel@tonic-gate return (_B_TRUE); 7267c478bd9Sstevel@tonic-gate } 7277c478bd9Sstevel@tonic-gate if (strcasecmp(str, "off") == 0) { 7287c478bd9Sstevel@tonic-gate *resp = 0; 7297c478bd9Sstevel@tonic-gate return (_B_TRUE); 7307c478bd9Sstevel@tonic-gate } 7317c478bd9Sstevel@tonic-gate if (strcasecmp(str, "true") == 0) { 7327c478bd9Sstevel@tonic-gate *resp = 1; 7337c478bd9Sstevel@tonic-gate return (_B_TRUE); 7347c478bd9Sstevel@tonic-gate } 7357c478bd9Sstevel@tonic-gate if (strcasecmp(str, "false") == 0) { 7367c478bd9Sstevel@tonic-gate *resp = 0; 7377c478bd9Sstevel@tonic-gate return (_B_TRUE); 7387c478bd9Sstevel@tonic-gate } 7397c478bd9Sstevel@tonic-gate if (parse_int(str, resp)) { 7407c478bd9Sstevel@tonic-gate if (*resp == 0 || *resp == 1) 7417c478bd9Sstevel@tonic-gate return (_B_TRUE); 7427c478bd9Sstevel@tonic-gate } 7437c478bd9Sstevel@tonic-gate return (_B_FALSE); 7447c478bd9Sstevel@tonic-gate } 7457c478bd9Sstevel@tonic-gate 7467c478bd9Sstevel@tonic-gate /* 7477c478bd9Sstevel@tonic-gate * Returns true if ok (and *resp updated) and false if failed. 7487c478bd9Sstevel@tonic-gate */ 7497c478bd9Sstevel@tonic-gate static boolean_t 7507c478bd9Sstevel@tonic-gate parse_int(char *str, uint_t *resp) 7517c478bd9Sstevel@tonic-gate { 7527c478bd9Sstevel@tonic-gate char *end; 7537c478bd9Sstevel@tonic-gate int res; 7547c478bd9Sstevel@tonic-gate 7557c478bd9Sstevel@tonic-gate res = strtoul(str, &end, 0); 7567c478bd9Sstevel@tonic-gate if (end == str) 7577c478bd9Sstevel@tonic-gate return (_B_FALSE); 7587c478bd9Sstevel@tonic-gate *resp = res; 7597c478bd9Sstevel@tonic-gate return (_B_TRUE); 7607c478bd9Sstevel@tonic-gate } 7617c478bd9Sstevel@tonic-gate 7627c478bd9Sstevel@tonic-gate /* 7637c478bd9Sstevel@tonic-gate * Parse something with a unit of millseconds. 7647c478bd9Sstevel@tonic-gate * Regognizes the suffixes "ms", "s", "m", "h", and "d". 7657c478bd9Sstevel@tonic-gate * 7667c478bd9Sstevel@tonic-gate * Returns true if ok (and *resp updated) and false if failed. 7677c478bd9Sstevel@tonic-gate */ 7687c478bd9Sstevel@tonic-gate static boolean_t 7697c478bd9Sstevel@tonic-gate parse_ms(char *str, uint_t *resp) 7707c478bd9Sstevel@tonic-gate { 7717c478bd9Sstevel@tonic-gate /* Look at the last and next to last character */ 7727c478bd9Sstevel@tonic-gate char *cp, *last, *nlast; 7737c478bd9Sstevel@tonic-gate char str2[BUFSIZ]; /* For local modification */ 7747c478bd9Sstevel@tonic-gate int multiplier = 1; 7757c478bd9Sstevel@tonic-gate 7767c478bd9Sstevel@tonic-gate (void) strncpy(str2, str, sizeof (str2)); 7777c478bd9Sstevel@tonic-gate str2[sizeof (str2) - 1] = '\0'; 7787c478bd9Sstevel@tonic-gate 7797c478bd9Sstevel@tonic-gate last = str2; 7807c478bd9Sstevel@tonic-gate nlast = NULL; 7817c478bd9Sstevel@tonic-gate for (cp = str2; *cp != '\0'; cp++) { 7827c478bd9Sstevel@tonic-gate nlast = last; 7837c478bd9Sstevel@tonic-gate last = cp; 7847c478bd9Sstevel@tonic-gate } 7857c478bd9Sstevel@tonic-gate if (debug & D_PARSE) { 7867c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_ms: last <%c> nlast <%c>\n", 7877c478bd9Sstevel@tonic-gate (last != NULL ? *last : ' '), 7887c478bd9Sstevel@tonic-gate (nlast != NULL ? *nlast : ' ')); 7897c478bd9Sstevel@tonic-gate } 7907c478bd9Sstevel@tonic-gate switch (*last) { 7917c478bd9Sstevel@tonic-gate case 'd': 7927c478bd9Sstevel@tonic-gate multiplier *= 24; 7937c478bd9Sstevel@tonic-gate /* FALLTHRU */ 7947c478bd9Sstevel@tonic-gate case 'h': 7957c478bd9Sstevel@tonic-gate multiplier *= 60; 7967c478bd9Sstevel@tonic-gate /* FALLTHRU */ 7977c478bd9Sstevel@tonic-gate case 'm': 7987c478bd9Sstevel@tonic-gate multiplier *= 60; 7997c478bd9Sstevel@tonic-gate *last = '\0'; 8007c478bd9Sstevel@tonic-gate multiplier *= 1000; /* Convert to milliseconds */ 8017c478bd9Sstevel@tonic-gate break; 8027c478bd9Sstevel@tonic-gate case 's': 8037c478bd9Sstevel@tonic-gate /* Could be "ms" or "s" */ 8047c478bd9Sstevel@tonic-gate if (nlast != NULL && *nlast == 'm') { 8057c478bd9Sstevel@tonic-gate /* "ms" */ 8067c478bd9Sstevel@tonic-gate *nlast = '\0'; 8077c478bd9Sstevel@tonic-gate } else { 8087c478bd9Sstevel@tonic-gate *last = '\0'; 8097c478bd9Sstevel@tonic-gate multiplier *= 1000; /* Convert to milliseconds */ 8107c478bd9Sstevel@tonic-gate } 8117c478bd9Sstevel@tonic-gate break; 8127c478bd9Sstevel@tonic-gate } 8137c478bd9Sstevel@tonic-gate 8147c478bd9Sstevel@tonic-gate if (!parse_int(str2, resp)) 8157c478bd9Sstevel@tonic-gate return (_B_FALSE); 8167c478bd9Sstevel@tonic-gate 8177c478bd9Sstevel@tonic-gate *resp *= multiplier; 8187c478bd9Sstevel@tonic-gate return (_B_TRUE); 8197c478bd9Sstevel@tonic-gate } 8207c478bd9Sstevel@tonic-gate 8217c478bd9Sstevel@tonic-gate /* 8227c478bd9Sstevel@tonic-gate * Parse something with a unit of seconds. 8237c478bd9Sstevel@tonic-gate * Regognizes the suffixes "s", "m", "h", and "d". 8247c478bd9Sstevel@tonic-gate * 8257c478bd9Sstevel@tonic-gate * Returns true if ok (and *resp updated) and false if failed. 8267c478bd9Sstevel@tonic-gate */ 8277c478bd9Sstevel@tonic-gate static boolean_t 8287c478bd9Sstevel@tonic-gate parse_s(char *str, uint_t *resp) 8297c478bd9Sstevel@tonic-gate { 8307c478bd9Sstevel@tonic-gate /* Look at the last character */ 8317c478bd9Sstevel@tonic-gate char *cp, *last; 8327c478bd9Sstevel@tonic-gate char str2[BUFSIZ]; /* For local modification */ 8337c478bd9Sstevel@tonic-gate int multiplier = 1; 8347c478bd9Sstevel@tonic-gate 8357c478bd9Sstevel@tonic-gate (void) strncpy(str2, str, sizeof (str2)); 8367c478bd9Sstevel@tonic-gate str2[sizeof (str2) - 1] = '\0'; 8377c478bd9Sstevel@tonic-gate 8387c478bd9Sstevel@tonic-gate last = str2; 8397c478bd9Sstevel@tonic-gate for (cp = str2; *cp != '\0'; cp++) { 8407c478bd9Sstevel@tonic-gate last = cp; 8417c478bd9Sstevel@tonic-gate } 8427c478bd9Sstevel@tonic-gate if (debug & D_PARSE) { 8437c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_s: last <%c>\n", 8447c478bd9Sstevel@tonic-gate (last != NULL ? *last : ' ')); 8457c478bd9Sstevel@tonic-gate } 8467c478bd9Sstevel@tonic-gate switch (*last) { 8477c478bd9Sstevel@tonic-gate case 'd': 8487c478bd9Sstevel@tonic-gate multiplier *= 24; 8497c478bd9Sstevel@tonic-gate /* FALLTHRU */ 8507c478bd9Sstevel@tonic-gate case 'h': 8517c478bd9Sstevel@tonic-gate multiplier *= 60; 8527c478bd9Sstevel@tonic-gate /* FALLTHRU */ 8537c478bd9Sstevel@tonic-gate case 'm': 8547c478bd9Sstevel@tonic-gate multiplier *= 60; 8557c478bd9Sstevel@tonic-gate /* FALLTHRU */ 8567c478bd9Sstevel@tonic-gate case 's': 8577c478bd9Sstevel@tonic-gate *last = '\0'; 8587c478bd9Sstevel@tonic-gate break; 8597c478bd9Sstevel@tonic-gate } 8607c478bd9Sstevel@tonic-gate if (!parse_int(str2, resp)) 8617c478bd9Sstevel@tonic-gate return (_B_FALSE); 8627c478bd9Sstevel@tonic-gate 8637c478bd9Sstevel@tonic-gate *resp *= multiplier; 8647c478bd9Sstevel@tonic-gate return (_B_TRUE); 8657c478bd9Sstevel@tonic-gate } 8667c478bd9Sstevel@tonic-gate 8677c478bd9Sstevel@tonic-gate /* 8687c478bd9Sstevel@tonic-gate * Return prefixlen (0 to 128) if ok; -1 if failed. 8697c478bd9Sstevel@tonic-gate */ 8707c478bd9Sstevel@tonic-gate static int 8717c478bd9Sstevel@tonic-gate parse_addrprefix(char *strin, struct in6_addr *in6) 8727c478bd9Sstevel@tonic-gate { 8737c478bd9Sstevel@tonic-gate char str[BUFSIZ]; /* Local copy for modification */ 8747c478bd9Sstevel@tonic-gate int prefixlen; 8757c478bd9Sstevel@tonic-gate char *cp; 8767c478bd9Sstevel@tonic-gate char *end; 8777c478bd9Sstevel@tonic-gate 8787c478bd9Sstevel@tonic-gate (void) strncpy(str, strin, sizeof (str)); 8797c478bd9Sstevel@tonic-gate str[sizeof (str) - 1] = '\0'; 8807c478bd9Sstevel@tonic-gate 8817c478bd9Sstevel@tonic-gate cp = strchr(str, '/'); 8827c478bd9Sstevel@tonic-gate if (cp == NULL) 8837c478bd9Sstevel@tonic-gate return (-1); 8847c478bd9Sstevel@tonic-gate *cp = '\0'; 8857c478bd9Sstevel@tonic-gate cp++; 8867c478bd9Sstevel@tonic-gate 8877c478bd9Sstevel@tonic-gate prefixlen = strtol(cp, &end, 10); 8887c478bd9Sstevel@tonic-gate if (cp == end) 8897c478bd9Sstevel@tonic-gate return (-1); 8907c478bd9Sstevel@tonic-gate 8917c478bd9Sstevel@tonic-gate if (prefixlen < 0 || prefixlen > IPV6_ABITS) 8927c478bd9Sstevel@tonic-gate return (-1); 8937c478bd9Sstevel@tonic-gate 8947c478bd9Sstevel@tonic-gate if (inet_pton(AF_INET6, str, in6) != 1) 8957c478bd9Sstevel@tonic-gate return (-1); 8967c478bd9Sstevel@tonic-gate 8977c478bd9Sstevel@tonic-gate return (prefixlen); 8987c478bd9Sstevel@tonic-gate } 8997c478bd9Sstevel@tonic-gate 9007c478bd9Sstevel@tonic-gate /* 9017c478bd9Sstevel@tonic-gate * Parse an absolute date using a datemsk config file. 9027c478bd9Sstevel@tonic-gate * Return the difference (measured in seconds) between that date/time and 9037c478bd9Sstevel@tonic-gate * the current date/time. 9047c478bd9Sstevel@tonic-gate * If the date has passed return zero. 9057c478bd9Sstevel@tonic-gate * 9067c478bd9Sstevel@tonic-gate * Returns true if ok (and *resp updated) and false if failed. 9077c478bd9Sstevel@tonic-gate * XXX Due to getdate limitations can not exceed year 2038. 9087c478bd9Sstevel@tonic-gate */ 9097c478bd9Sstevel@tonic-gate static boolean_t 9107c478bd9Sstevel@tonic-gate parse_date(char *str, uint_t *resp) 9117c478bd9Sstevel@tonic-gate { 9127c478bd9Sstevel@tonic-gate struct tm *tm; 9137c478bd9Sstevel@tonic-gate struct timeval tvs; 9147c478bd9Sstevel@tonic-gate time_t time, ntime; 9157c478bd9Sstevel@tonic-gate 9167c478bd9Sstevel@tonic-gate if (getenv("DATEMSK") == NULL) { 9177c478bd9Sstevel@tonic-gate (void) putenv("DATEMSK=/etc/inet/datemsk.ndpd"); 9187c478bd9Sstevel@tonic-gate } 9197c478bd9Sstevel@tonic-gate 9207c478bd9Sstevel@tonic-gate if (gettimeofday(&tvs, NULL) < 0) { 9217c478bd9Sstevel@tonic-gate logperror("gettimeofday"); 9227c478bd9Sstevel@tonic-gate return (_B_FALSE); 9237c478bd9Sstevel@tonic-gate } 9247c478bd9Sstevel@tonic-gate time = tvs.tv_sec; 9257c478bd9Sstevel@tonic-gate tm = getdate(str); 9267c478bd9Sstevel@tonic-gate if (tm == NULL) { 9277c478bd9Sstevel@tonic-gate logmsg(LOG_ERR, "Bad date <%s> (error %d)\n", 9287c478bd9Sstevel@tonic-gate str, getdate_err); 9297c478bd9Sstevel@tonic-gate return (_B_FALSE); 9307c478bd9Sstevel@tonic-gate } 9317c478bd9Sstevel@tonic-gate 9327c478bd9Sstevel@tonic-gate ntime = mktime(tm); 9337c478bd9Sstevel@tonic-gate 9347c478bd9Sstevel@tonic-gate if (debug & D_PARSE) { 9357c478bd9Sstevel@tonic-gate char buf[BUFSIZ]; 9367c478bd9Sstevel@tonic-gate 9377c478bd9Sstevel@tonic-gate (void) strftime(buf, sizeof (buf), "%Y-%m-%d %R %Z", tm); 9387c478bd9Sstevel@tonic-gate logmsg(LOG_DEBUG, "parse_date: <%s>, delta %ld seconds\n", 9397c478bd9Sstevel@tonic-gate buf, ntime - time); 9407c478bd9Sstevel@tonic-gate } 9417c478bd9Sstevel@tonic-gate if (ntime < time) { 9427c478bd9Sstevel@tonic-gate conferr("Date in the past <%s>\n", str); 9437c478bd9Sstevel@tonic-gate *resp = 0; 9447c478bd9Sstevel@tonic-gate return (_B_TRUE); 9457c478bd9Sstevel@tonic-gate } 9467c478bd9Sstevel@tonic-gate *resp = (ntime - time); 9477c478bd9Sstevel@tonic-gate return (_B_TRUE); 9487c478bd9Sstevel@tonic-gate } 9497c478bd9Sstevel@tonic-gate 9507c478bd9Sstevel@tonic-gate /* PRINTFLIKE1 */ 9517c478bd9Sstevel@tonic-gate static void 9527c478bd9Sstevel@tonic-gate conferr(char *fmt, ...) 9537c478bd9Sstevel@tonic-gate { 9547c478bd9Sstevel@tonic-gate char msg[NDPD_LOGMSGSIZE]; 9557c478bd9Sstevel@tonic-gate size_t slen; 9567c478bd9Sstevel@tonic-gate 9577c478bd9Sstevel@tonic-gate va_list ap; 9587c478bd9Sstevel@tonic-gate va_start(ap, fmt); 9597c478bd9Sstevel@tonic-gate 9607c478bd9Sstevel@tonic-gate (void) snprintf(msg, NDPD_LOGMSGSIZE, "%s line %d: ", 9617c478bd9Sstevel@tonic-gate conf_filename, lineno); 9627c478bd9Sstevel@tonic-gate slen = strlen(msg); 9637c478bd9Sstevel@tonic-gate (void) vsnprintf(msg + slen, NDPD_LOGMSGSIZE - slen, fmt, ap); 9647c478bd9Sstevel@tonic-gate 9657c478bd9Sstevel@tonic-gate logmsg(LOG_ERR, "%s", msg); 9667c478bd9Sstevel@tonic-gate 9677c478bd9Sstevel@tonic-gate va_end(ap); 9687c478bd9Sstevel@tonic-gate } 9697c478bd9Sstevel@tonic-gate 9707c478bd9Sstevel@tonic-gate static FILE * 9717c478bd9Sstevel@tonic-gate open_conffile(char *filename) 9727c478bd9Sstevel@tonic-gate { 9737c478bd9Sstevel@tonic-gate if (strlcpy(conf_filename, filename, MAXPATHLEN) >= MAXPATHLEN) { 9747c478bd9Sstevel@tonic-gate logmsg(LOG_ERR, "config file pathname is too long\n"); 9757c478bd9Sstevel@tonic-gate return (NULL); 9767c478bd9Sstevel@tonic-gate } 9777c478bd9Sstevel@tonic-gate 9787c478bd9Sstevel@tonic-gate lineno = 0; 9797c478bd9Sstevel@tonic-gate 9807c478bd9Sstevel@tonic-gate return (fopen(filename, "r")); 9817c478bd9Sstevel@tonic-gate 9827c478bd9Sstevel@tonic-gate } 983