xref: /titanic_52/usr/src/lib/libdhcputil/common/dhcp_inittab.h (revision b6c3f7863936abeae522e48a13887dddeb691a45)
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 #pragma ident	"%Z%%M%	%I%	%E% SMI"
30 
31 #include <sys/types.h>
32 #include <dhcp_symbol.h>
33 #include <limits.h>
34 
35 /*
36  * dhcp_inittab.[ch] make up the interface to the inittab file, which
37  * is a table of all known DHCP options.  please see `README.inittab'
38  * for more background on the inittab api, and dhcp_inittab.c for details
39  * on how to use the exported functions.
40  */
41 
42 #ifdef	__cplusplus
43 extern "C" {
44 #endif
45 
46 /*
47  * On-disk inittab attributes and limits.
48  */
49 #define	ITAB_INITTAB_PATH	"/etc/dhcp/inittab"
50 #define	ITAB_INITTAB6_PATH	"/etc/dhcp/inittab6"
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_V6		0x20
76 #define	ITAB_CAT_COUNT		6
77 
78 /*
79  * Consumer which is using the inittab functions.
80  */
81 #define	ITAB_CONS_INFO		'i'
82 #define	ITAB_CONS_SERVER	'd'
83 #define	ITAB_CONS_SNOOP		's'
84 #define	ITAB_CONS_MANAGER	'm'
85 #define	ITAB_CONS_COUNT		(sizeof ("idsm") - 1)
86 
87 /*
88  * Extended error codes, for use with inittab_{en,de}code_e().
89  */
90 #define	ITAB_SYNTAX_ERROR	(-1)
91 #define	ITAB_BAD_IPADDR		(-2)
92 #define	ITAB_BAD_STRING		(-3)
93 #define	ITAB_BAD_OCTET		(-4)
94 #define	ITAB_BAD_NUMBER		(-5)
95 #define	ITAB_BAD_BOOLEAN	(-6)
96 #define	ITAB_NOT_ENOUGH_IP	(-7)
97 #define	ITAB_BAD_GRAN		(-8)
98 #define	ITAB_NOMEM		(-9)
99 
100 extern uint8_t		inittab_type_to_size(const dhcp_symbol_t *);
101 extern int		inittab_verify(const dhcp_symbol_t *, dhcp_symbol_t *);
102 extern dhcp_symbol_t	*inittab_load(uchar_t, char, size_t *);
103 extern dhcp_symbol_t	*inittab_getbyname(uchar_t, char, const char *);
104 extern dhcp_symbol_t	*inittab_getbycode(uchar_t, char, uint16_t);
105 extern uchar_t		*inittab_encode(const dhcp_symbol_t *, const char *,
106 			    uint16_t *, boolean_t);
107 extern uchar_t		*inittab_encode_e(const dhcp_symbol_t *, const char *,
108 			    uint16_t *, boolean_t, int *);
109 extern char		*inittab_decode(const dhcp_symbol_t *, const uchar_t *,
110 			    uint16_t, boolean_t);
111 extern char		*inittab_decode_e(const dhcp_symbol_t *,
112 			    const uchar_t *, uint16_t, boolean_t, int *);
113 
114 #ifdef	__cplusplus
115 }
116 #endif
117 
118 #endif	/* _DHCP_INITTAB_H */
119