xref: /illumos-gate/usr/src/lib/libdhcputil/common/dhcp_inittab.h (revision 7a6d80f1660abd4755c68cbd094d4a914681d26e)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 #ifndef	_DHCP_INITTAB_H
27 #define	_DHCP_INITTAB_H
28 
29 #include <sys/types.h>
30 #include <dhcp_symbol.h>
31 #include <limits.h>
32 
33 /*
34  * dhcp_inittab.[ch] make up the interface to the inittab file, which
35  * is a table of all known DHCP options.  please see `README.inittab'
36  * for more background on the inittab api, and dhcp_inittab.c for details
37  * on how to use the exported functions.
38  */
39 
40 #ifdef	__cplusplus
41 extern "C" {
42 #endif
43 
44 /*
45  * On-disk inittab attributes and limits.
46  */
47 #define	ITAB_INITTAB_PATH	"/etc/dhcp/inittab"
48 #define	ITAB_INITTAB6_PATH	"/etc/dhcp/inittab6"
49 #define	ITAB_MAX_LINE_LEN	8192 		/* bytes */
50 #define	ITAB_MAX_NUMBER_LEN	30		/* digits */
51 #define	ITAB_COMMENT_CHAR	'#'
52 #define	ITAB_CODE_MAX		UCHAR_MAX	/* for now */
53 #define	ITAB_GRAN_MAX		UCHAR_MAX
54 #define	ITAB_MAX_MAX		UCHAR_MAX
55 
56 /*
57  * Return values from the inittab API.
58  */
59 #define	ITAB_FAILURE		0
60 #define	ITAB_SUCCESS		1
61 #define	ITAB_UNKNOWN		2
62 
63 /*
64  * Categories to pass to inittab functions; note that these may be
65  * bitwise-OR'd to request more than one.  Note that these should
66  * not be used otherwise.
67  */
68 #define	ITAB_CAT_STANDARD	0x01
69 #define	ITAB_CAT_FIELD		0x02
70 #define	ITAB_CAT_INTERNAL	0x04
71 #define	ITAB_CAT_VENDOR		0x08
72 #define	ITAB_CAT_SITE		0x10
73 #define	ITAB_CAT_V6		0x20
74 #define	ITAB_CAT_COUNT		6
75 
76 /*
77  * Consumer which is using the inittab functions.
78  */
79 #define	ITAB_CONS_INFO		'i'
80 #define	ITAB_CONS_SERVER	'd'
81 #define	ITAB_CONS_SNOOP		's'
82 #define	ITAB_CONS_MANAGER	'm'
83 #define	ITAB_CONS_COUNT		(sizeof ("idsm") - 1)
84 
85 /*
86  * Extended error codes, for use with inittab_{en,de}code_e().
87  */
88 #define	ITAB_SYNTAX_ERROR	(-1)
89 #define	ITAB_BAD_IPADDR		(-2)
90 #define	ITAB_BAD_STRING		(-3)
91 #define	ITAB_BAD_OCTET		(-4)
92 #define	ITAB_BAD_NUMBER		(-5)
93 #define	ITAB_BAD_BOOLEAN	(-6)
94 #define	ITAB_NOT_ENOUGH_IP	(-7)
95 #define	ITAB_BAD_GRAN		(-8)
96 #define	ITAB_NOMEM		(-9)
97 
98 extern uint8_t		inittab_type_to_size(const dhcp_symbol_t *);
99 extern int		inittab_verify(const dhcp_symbol_t *, dhcp_symbol_t *);
100 extern dhcp_symbol_t	*inittab_load(uchar_t, char, size_t *);
101 extern dhcp_symbol_t	*inittab_getbyname(uchar_t, char, const char *);
102 extern dhcp_symbol_t	*inittab_getbycode(uchar_t, char, uint16_t);
103 extern uchar_t		*inittab_encode(const dhcp_symbol_t *, const char *,
104 			    uint16_t *, boolean_t);
105 extern uchar_t		*inittab_encode_e(const dhcp_symbol_t *, const char *,
106 			    uint16_t *, boolean_t, int *);
107 extern char		*inittab_decode(const dhcp_symbol_t *, const uchar_t *,
108 			    uint16_t, boolean_t);
109 extern char		*inittab_decode_e(const dhcp_symbol_t *,
110 			    const uchar_t *, uint16_t, boolean_t, int *);
111 
112 #ifdef	__cplusplus
113 }
114 #endif
115 
116 #endif	/* _DHCP_INITTAB_H */
117