45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * CDDL HEADER START
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * The contents of this file are subject to the terms of the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Common Development and Distribution License (the "License").
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * You may not use this file except in compliance with the License.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * See the License for the specific language governing permissions
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * and limitations under the License.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * When distributing Covered Code, include this CDDL HEADER in each
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * If applicable, add the following below this CDDL HEADER, with the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * fields enclosed by brackets "[]" replaced with your own identifying
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * information: Portions Copyright [yyyy] [name of copyright owner]
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * CDDL HEADER END
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Use is subject to license terms.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * From "tsol_tndb_parser.c 7.24 01/09/05 SMI; TSOL 2.x"
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * These functions parse entries in the "thrhdb" (remote host database) file.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Each entry in the file has two fields, separated by a colon. The first
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * field is the IP host or network address. The second is the name of the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * template to use (from tnrhtp).
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * In order to help preserve sanity, we do not allow more than one unescaped
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * colon in a line.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk#pragma ident "%Z%%M% %I% %E% SMI"
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * This routine deals with old pre-CIDR subnet address specifications. In the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * bad old days, a subnet was represented as:
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Expression Implied Prefix
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * 10.1.1.0 /24
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * 10.1.0.0 /16
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * 10.0.0.0 /8
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * 0.0.0.0 /0
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk return (0);
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk for (bits = IP_ABITS; bits > 0 && (addr & 0xFF) == 0; bits -= 8)
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * This routine deals with old pre-CIDR network address specifications. In the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * bad old days, a network was represented as:
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Expression Implied Prefix
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * 10.1.1 /24
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * 10.1 /16
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * This routine must compute the mask and left-align the address.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk for (bits = IP_ABITS; bits > 0 && addr < 0x01000000; bits -= 8)
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk /* IPv4 address */
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk /* IPv6 address */
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * Verify that there are no bits set in the "host" portion of the
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * IP address.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk if (*aptr++ != 0)
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpkrhstr_to_ent(tsol_rhstr_t *rhstrp, int *errp, char **errstrp)
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * The user can specify NULL pointers for these. Make sure that we
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * don't have to deal with checking for NULL everywhere by just
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk * pointing to our own variables if the user gives NULL.
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk /* The default, unless we find a more specific error locus. */
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk if (address == NULL || *address == '#' || *address == '\n') {
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk if (template && *template != '\0' && *template != '#' &&
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk if (template && *template != '\0' && *template != '#' &&
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk if (template == NULL || *template == '#' || *template == '\n' ||
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk if (errno != 0) {
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk sizeof (rhentp->rh_template)) >= sizeof (rhentp->rh_template)) {
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk#endif /* DEBUG */
45916cd2fec6e79bca5dee0421bd39e3c2910d1ejpk#endif /* DEBUG */