/*
* 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
*/
/*
*/
/*
* From "tsol_tndb_parser.c 7.24 01/09/05 SMI; TSOL 2.x"
*
* These functions parse entries in the "thrhdb" (remote host database) file.
* Each entry in the file has two fields, separated by a colon. The first
* field is the IP host or network address. The second is the name of the
* template to use (from tnrhtp).
*
* In order to help preserve sanity, we do not allow more than one unescaped
* colon in a line.
*/
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <strings.h>
#include <libtsnet.h>
#include <nss.h>
#include <errno.h>
/*
* This routine deals with old pre-CIDR subnet address specifications. In the
* bad old days, a subnet was represented as:
*
* Expression Implied Prefix
* 10.1.1.0 /24
* 10.1.0.0 /16
* 10.0.0.0 /8
* 0.0.0.0 /0
*/
static int
{
int bits;
if (addr == 0)
return (0);
addr >>= 8;
return (bits);
}
/*
* This routine deals with old pre-CIDR network address specifications. In the
* bad old days, a network was represented as:
*
* Expression Implied Prefix
* 10.1.1 /24
* 10.1 /16
* 10 /8
*
* This routine must compute the mask and left-align the address.
*/
static int
{
int bits;
addr <<= 8;
return (bits);
}
static boolean_t
{
int upper_lim;
int len;
/* IPv4 address */
s_addr);
} else {
return (B_FALSE);
}
} else {
/* IPv6 address */
return (B_FALSE);
}
return (B_FALSE);
/*
* Verify that there are no bits set in the "host" portion of the
* IP address.
*/
if ((len & 7) != 0) {
return (B_FALSE);
}
if (*aptr++ != 0)
return (B_FALSE);
len += 8;
}
return (B_TRUE);
}
{
int len;
int err = 0;
/*
* The user can specify NULL pointers for these. Make sure that we
* don't have to deal with checking for NULL everywhere by just
* pointing to our own variables if the user gives NULL.
*/
/* The default, unless we find a more specific error locus. */
*errp = LTSNET_EMPTY;
*template != '\n')
*errstrp = " ";
goto err_ret;
}
if (*address == '\0') {
*errp = LTSNET_NO_ADDR;
*template != '\n')
goto err_ret;
}
*template == '\0') {
goto err_ret;
}
*errp = LTSNET_SYSERR;
return (NULL);
}
*errp = LTSNET_ILL_ADDR;
goto err_ret;
}
cp++;
errno = 0;
if (errno != 0) {
*errp = LTSNET_SYSERR;
goto err_ret;
}
*errp = LTSNET_ILL_ADDR;
goto err_ret;
}
} else {
}
*errp = LTSNET_ILL_NAME;
goto err_ret;
}
*errp = LTSNET_ILL_ADDR;
goto err_ret;
}
#ifdef DEBUG
#endif /* DEBUG */
return (rhentp);
#ifdef DEBUG
#endif /* DEBUG */
return (NULL);
}
void
{
}