4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #pragma ident "%Z%%M% %I% %E% SMI"
36 #define DEFAULT_IP_LINE DEFAULT_IP"="
39 * Code to handle /etc/default/ file for IPv4 command output compatibility
41 * Note: Handles BOTH the same as IP_VERSION6.
43 * Returns 1 if IP_VERSION4; 0 for other versions.
44 * Returns -1 if the value of DEFAULT_IP found in /etc/default/inet_type is
48 get_compat_flag(char **value
)
50 if (defopen(INET_DEFAULT_FILE
) == 0) {
57 flags
= defcntl(DC_GETFLAGS
, 0);
58 TURNOFF(flags
, DC_CASE
);
59 (void) defcntl(DC_SETFLAGS
, flags
);
61 if (cp
= defread(DEFAULT_IP_LINE
))
65 (void) defopen((char *)NULL
);
68 if (strcasecmp(*value
, "IP_VERSION4") == 0) {
69 return (DEFAULT_PROT_V4_ONLY
);
70 } else if (strcasecmp(*value
, "BOTH") == 0 ||
71 strcasecmp(*value
, "IP_VERSION6") == 0) {
72 return (DEFAULT_PROT_BOTH
);
74 return (DEFAULT_PROT_BAD_VALUE
);
79 return (DEFAULT_PROT_BOTH
);