145916cd2Sjpk /* 245916cd2Sjpk * CDDL HEADER START 345916cd2Sjpk * 445916cd2Sjpk * The contents of this file are subject to the terms of the 545916cd2Sjpk * Common Development and Distribution License (the "License"). 645916cd2Sjpk * You may not use this file except in compliance with the License. 745916cd2Sjpk * 845916cd2Sjpk * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 945916cd2Sjpk * or http://www.opensolaris.org/os/licensing. 1045916cd2Sjpk * See the License for the specific language governing permissions 1145916cd2Sjpk * and limitations under the License. 1245916cd2Sjpk * 1345916cd2Sjpk * When distributing Covered Code, include this CDDL HEADER in each 1445916cd2Sjpk * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 1545916cd2Sjpk * If applicable, add the following below this CDDL HEADER, with the 1645916cd2Sjpk * fields enclosed by brackets "[]" replaced with your own identifying 1745916cd2Sjpk * information: Portions Copyright [yyyy] [name of copyright owner] 1845916cd2Sjpk * 1945916cd2Sjpk * CDDL HEADER END 2045916cd2Sjpk */ 2145916cd2Sjpk /* 22*7b0bedd4SRic Aleshire * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 2345916cd2Sjpk * Use is subject to license terms. 2445916cd2Sjpk * 2545916cd2Sjpk * All symbols and functions in this header file and library are private to Sun 2645916cd2Sjpk * Microsystems. The only guarantee that is made is that if your application 2745916cd2Sjpk * uses them, it will break on upgrade. 2845916cd2Sjpk */ 2945916cd2Sjpk 3045916cd2Sjpk #ifndef _LIBTSNET_H 3145916cd2Sjpk #define _LIBTSNET_H 3245916cd2Sjpk 3345916cd2Sjpk #include <stdio.h> 3445916cd2Sjpk #include <sys/tsol/tndb.h> 3545916cd2Sjpk 3645916cd2Sjpk #ifdef __cplusplus 3745916cd2Sjpk extern "C" { 3845916cd2Sjpk #endif 3945916cd2Sjpk 4045916cd2Sjpk #define TNRHTP_PATH "/etc/security/tsol/tnrhtp" 4145916cd2Sjpk #define TNRHDB_PATH "/etc/security/tsol/tnrhdb" 4245916cd2Sjpk #define TNZONECFG_PATH "/etc/security/tsol/tnzonecfg" 4345916cd2Sjpk 4445916cd2Sjpk #define TNDB_COMMA ", \t" 451f041b17Ston #define TN_RESERVED ",#;" 4645916cd2Sjpk 4745916cd2Sjpk /* 4845916cd2Sjpk * String parsing routines 4945916cd2Sjpk * 5045916cd2Sjpk * These functions are in four logical groups: one for template (tnrhtp) 5145916cd2Sjpk * entries, one for remote host (tnrhdb) entries, one for zone configuration 5245916cd2Sjpk * (tnzonecfg) entries, and a fourth for routing attributes. 5345916cd2Sjpk * 5445916cd2Sjpk * In each group, there are functions that parse from a string or database, and 5545916cd2Sjpk * a function to free returned entries. The parsing functions all take a 5645916cd2Sjpk * pointer to an integer and a pointer to a character pointer for returning 5745916cd2Sjpk * errors. On error, the returned entry pointer is NULL, the integer is set to 5845916cd2Sjpk * one of the LTSNET_* errors below, and the character pointer points to the 5945916cd2Sjpk * location of the error. (For the functions that iterate on a database, this 6045916cd2Sjpk * points into static storage in the library. This storage is associated with 6145916cd2Sjpk * the iterator.) 6245916cd2Sjpk * 6345916cd2Sjpk * The functions that do look-ups based on a value (name or address) do not 6445916cd2Sjpk * return errors other than "not found," which is signaled by a return value of 6545916cd2Sjpk * NULL. 6645916cd2Sjpk */ 6745916cd2Sjpk 6845916cd2Sjpk /* Template entry parsing */ 6945916cd2Sjpk extern tsol_tpent_t *tsol_gettpbyname(const char *); 7045916cd2Sjpk extern tsol_tpent_t *tsol_gettpent(void); 71909c1a33Ston extern tsol_tpent_t *tsol_fgettpent(FILE *, boolean_t *); 7245916cd2Sjpk extern void tsol_freetpent(tsol_tpent_t *); 7345916cd2Sjpk extern void tsol_settpent(int); 7445916cd2Sjpk extern void tsol_endtpent(void); 7545916cd2Sjpk extern int str_to_tpstr(const char *, int, void *, char *, int); 7645916cd2Sjpk extern tsol_tpent_t *tpstr_to_ent(tsol_tpstr_t *, int *, char **); 7745916cd2Sjpk 7845916cd2Sjpk /* Remote host entry parsing */ 7945916cd2Sjpk extern tsol_rhent_t *tsol_getrhbyaddr(const void *, size_t, int); 8045916cd2Sjpk extern tsol_rhent_t *tsol_getrhent(void); 81909c1a33Ston extern tsol_rhent_t *tsol_fgetrhent(FILE *, boolean_t *); 8245916cd2Sjpk extern void tsol_freerhent(tsol_rhent_t *); 8345916cd2Sjpk extern void tsol_setrhent(int); 8445916cd2Sjpk extern void tsol_endrhent(void); 8545916cd2Sjpk extern int str_to_rhstr(const char *, int, void *, char *, int); 8645916cd2Sjpk extern tsol_rhent_t *rhstr_to_ent(tsol_rhstr_t *, int *, char **); 8745916cd2Sjpk extern tsol_host_type_t tsol_getrhtype(char *); 8845916cd2Sjpk 8945916cd2Sjpk 9045916cd2Sjpk /* Zone configuration parsing */ 9145916cd2Sjpk extern tsol_zcent_t *tsol_sgetzcent(const char *, int *, char **); 9245916cd2Sjpk extern void tsol_freezcent(tsol_zcent_t *); 9345916cd2Sjpk 9445916cd2Sjpk /* Routing attribute parsing */ 95*7b0bedd4SRic Aleshire extern char *sl_to_str(const m_label_t *); 9645916cd2Sjpk struct rtsa_s; 9745916cd2Sjpk extern const char *rtsa_to_str(const struct rtsa_s *, char *, size_t); 9845916cd2Sjpk extern boolean_t rtsa_keyword(const char *, struct rtsa_s *, int *, char **); 9945916cd2Sjpk extern const char *parse_entry(char *, size_t, const char *, const char *); 10045916cd2Sjpk 10145916cd2Sjpk /* Convert LTSNET_* to a printable string */ 10245916cd2Sjpk extern const char *tsol_strerror(int, int); 10345916cd2Sjpk 10445916cd2Sjpk /* System calls; these return -1 on error and set errno */ 10545916cd2Sjpk extern int tnrhtp(int, tsol_tpent_t *); 10645916cd2Sjpk extern int tnrh(int, tsol_rhent_t *); 10745916cd2Sjpk extern int tnmlp(int, tsol_mlpent_t *); 10845916cd2Sjpk 10945916cd2Sjpk /* 11045916cd2Sjpk * Errors that can occur in the parsing routines. Note that not all errors are 11145916cd2Sjpk * possible with every routine. Must be kept in sync with list in misc.c. 11245916cd2Sjpk */ 11345916cd2Sjpk #define LTSNET_NONE 0 /* No error */ 11445916cd2Sjpk #define LTSNET_SYSERR 1 /* System error; see errno */ 11545916cd2Sjpk #define LTSNET_EMPTY 2 /* Empty string or end of list */ 11645916cd2Sjpk #define LTSNET_ILL_ENTRY 3 /* Entry is malformed */ 11745916cd2Sjpk #define LTSNET_NO_NAME 4 /* Missing name */ 11845916cd2Sjpk #define LTSNET_NO_ATTRS 5 /* Missing template attributes */ 11945916cd2Sjpk #define LTSNET_ILL_NAME 6 /* Illegal name */ 12045916cd2Sjpk #define LTSNET_ILL_KEYDELIM 7 /* Illegal keyword delimiter */ 12145916cd2Sjpk #define LTSNET_ILL_KEY 8 /* Unknown keyword */ 12245916cd2Sjpk #define LTSNET_DUP_KEY 9 /* Duplicate keyword */ 12345916cd2Sjpk #define LTSNET_ILL_VALDELIM 10 /* Illegal value delimiter */ 12445916cd2Sjpk #define LTSNET_NO_HOSTTYPE 11 /* Missing host type */ 12545916cd2Sjpk #define LTSNET_ILL_HOSTTYPE 12 /* Illegal host type */ 12645916cd2Sjpk #define LTSNET_NO_LABEL 13 /* Missing label */ 12745916cd2Sjpk #define LTSNET_ILL_LABEL 14 /* Illegal label */ 12845916cd2Sjpk #define LTSNET_NO_RANGE 15 /* Missing label range */ 12945916cd2Sjpk #define LTSNET_ILL_RANGE 16 /* Illegal label range */ 13045916cd2Sjpk #define LTSNET_NO_LOWERBOUND 17 /* No lower bound in range */ 13145916cd2Sjpk #define LTSNET_ILL_LOWERBOUND 18 /* Illegal lower bound in range */ 13245916cd2Sjpk #define LTSNET_NO_UPPERBOUND 19 /* No upper bound in range */ 13345916cd2Sjpk #define LTSNET_ILL_UPPERBOUND 20 /* Illegal upper bound in range */ 13445916cd2Sjpk #define LTSNET_NO_DOI 21 /* Missing DOI */ 13545916cd2Sjpk #define LTSNET_ILL_DOI 22 /* Illegal DOI */ 13645916cd2Sjpk #define LTSNET_SET_TOO_BIG 23 /* Too many entries in set */ 13745916cd2Sjpk #define LTSNET_NO_ADDR 24 /* Missing address/network */ 13845916cd2Sjpk #define LTSNET_ILL_ADDR 25 /* Illegal address/network */ 13945916cd2Sjpk #define LTSNET_ILL_FLAG 26 /* Illegal flag */ 14045916cd2Sjpk #define LTSNET_ILL_MLP 27 /* Illegal MLP specification */ 14145916cd2Sjpk #define LTSNET_BAD_TYPE 28 /* Unacceptable keyword for type */ 14245916cd2Sjpk 14345916cd2Sjpk #ifdef __cplusplus 14445916cd2Sjpk } 14545916cd2Sjpk #endif 14645916cd2Sjpk 14745916cd2Sjpk #endif /* _LIBTSNET_H */ 148