1 /*
2  * CDDL HEADER START
3  *
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
7  * with the License.
8  *
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.
13  *
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]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright (c) 1999-2001 by Sun Microsystems, Inc.
24  * All rights reserved.
25  */
26 
27 #ifndef	_DHCP_INITTAB_H
28 #define	_DHCP_INITTAB_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/types.h>
33 #include <dhcp_symbol.h>
34 #include <limits.h>
35 
36 /*
37  * dhcp_inittab.[ch] make up the interface to the inittab file, which
38  * is a table of all known DHCP options.  please see `README.inittab'
39  * for more background on the inittab api, and dhcp_inittab.c for details
40  * on how to use the exported functions.
41  */
42 
43 #ifdef	__cplusplus
44 extern "C" {
45 #endif
46 
47 /*
48  * On-disk inittab attributes and limits.
49  */
50 #define	ITAB_INITTAB_PATH	"/etc/dhcp/inittab"
51 #define	ITAB_MAX_LINE_LEN	8192 		/* bytes */
52 #define	ITAB_MAX_NUMBER_LEN	30		/* digits */
53 #define	ITAB_COMMENT_CHAR	'#'
54 #define	ITAB_CODE_MAX		UCHAR_MAX	/* for now */
55 #define	ITAB_GRAN_MAX		UCHAR_MAX
56 #define	ITAB_MAX_MAX		UCHAR_MAX
57 
58 /*
59  * Return values from the inittab API.
60  */
61 #define	ITAB_FAILURE		0
62 #define	ITAB_SUCCESS		1
63 #define	ITAB_UNKNOWN		2
64 
65 /*
66  * Categories to pass to inittab functions; note that these may be
67  * bitwise-OR'd to request more than one.  Note that these should
68  * not be used otherwise.
69  */
70 #define	ITAB_CAT_STANDARD	0x01
71 #define	ITAB_CAT_FIELD		0x02
72 #define	ITAB_CAT_INTERNAL	0x04
73 #define	ITAB_CAT_VENDOR		0x08
74 #define	ITAB_CAT_SITE		0x10
75 #define	ITAB_CAT_COUNT		5
76 
77 /*
78  * Consumer which is using the inittab functions.
79  */
80 #define	ITAB_CONS_INFO		'i'
81 #define	ITAB_CONS_SERVER	'd'
82 #define	ITAB_CONS_SNOOP		's'
83 #define	ITAB_CONS_MANAGER	'm'
84 #define	ITAB_CONS_COUNT		(sizeof ("idsm") - 1)
85 
86 /*
87  * Extended error codes, for use with inittab_{en,de}code_e().
88  */
89 #define	ITAB_SYNTAX_ERROR	(-1)
90 #define	ITAB_BAD_IPADDR		(-2)
91 #define	ITAB_BAD_STRING		(-3)
92 #define	ITAB_BAD_OCTET		(-4)
93 #define	ITAB_BAD_NUMBER		(-5)
94 #define	ITAB_BAD_BOOLEAN	(-6)
95 #define	ITAB_NOT_ENOUGH_IP	(-7)
96 #define	ITAB_BAD_GRAN		(-8)
97 #define	ITAB_NOMEM		(-9)
98 
99 extern uint8_t		inittab_type_to_size(dhcp_symbol_t *);
100 extern int		inittab_verify(dhcp_symbol_t *, dhcp_symbol_t *);
101 extern dhcp_symbol_t	*inittab_load(uchar_t, char, size_t *);
102 extern dhcp_symbol_t	*inittab_getbyname(uchar_t, char, const char *);
103 extern dhcp_symbol_t	*inittab_getbycode(uchar_t, char, uint16_t);
104 extern uchar_t		*inittab_encode(dhcp_symbol_t *, const char *,
105 			    uint16_t *, boolean_t);
106 extern uchar_t		*inittab_encode_e(dhcp_symbol_t *, const char *,
107 			    uint16_t *, boolean_t, int *);
108 extern char		*inittab_decode(dhcp_symbol_t *, uchar_t *,
109 			    uint16_t, boolean_t);
110 extern char		*inittab_decode_e(dhcp_symbol_t *, uchar_t *,
111 			    uint16_t, boolean_t, int *);
112 
113 #ifdef	__cplusplus
114 }
115 #endif
116 
117 #endif	/* _DHCP_INITTAB_H */
118