xref: /titanic_52/usr/src/lib/libdhcputil/common/dhcp_inittab.h (revision 948f2876ce2a3010558f4f6937e16086ebcd36f2)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*d04ccbb3Scarlsonj  * Common Development and Distribution License (the "License").
6*d04ccbb3Scarlsonj  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22*d04ccbb3Scarlsonj  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
23*d04ccbb3Scarlsonj  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate #ifndef	_DHCP_INITTAB_H
277c478bd9Sstevel@tonic-gate #define	_DHCP_INITTAB_H
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/types.h>
327c478bd9Sstevel@tonic-gate #include <dhcp_symbol.h>
337c478bd9Sstevel@tonic-gate #include <limits.h>
347c478bd9Sstevel@tonic-gate 
357c478bd9Sstevel@tonic-gate /*
367c478bd9Sstevel@tonic-gate  * dhcp_inittab.[ch] make up the interface to the inittab file, which
377c478bd9Sstevel@tonic-gate  * is a table of all known DHCP options.  please see `README.inittab'
387c478bd9Sstevel@tonic-gate  * for more background on the inittab api, and dhcp_inittab.c for details
397c478bd9Sstevel@tonic-gate  * on how to use the exported functions.
407c478bd9Sstevel@tonic-gate  */
417c478bd9Sstevel@tonic-gate 
427c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
437c478bd9Sstevel@tonic-gate extern "C" {
447c478bd9Sstevel@tonic-gate #endif
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate /*
477c478bd9Sstevel@tonic-gate  * On-disk inittab attributes and limits.
487c478bd9Sstevel@tonic-gate  */
497c478bd9Sstevel@tonic-gate #define	ITAB_INITTAB_PATH	"/etc/dhcp/inittab"
50*d04ccbb3Scarlsonj #define	ITAB_INITTAB6_PATH	"/etc/dhcp/inittab6"
517c478bd9Sstevel@tonic-gate #define	ITAB_MAX_LINE_LEN	8192 		/* bytes */
527c478bd9Sstevel@tonic-gate #define	ITAB_MAX_NUMBER_LEN	30		/* digits */
537c478bd9Sstevel@tonic-gate #define	ITAB_COMMENT_CHAR	'#'
547c478bd9Sstevel@tonic-gate #define	ITAB_CODE_MAX		UCHAR_MAX	/* for now */
557c478bd9Sstevel@tonic-gate #define	ITAB_GRAN_MAX		UCHAR_MAX
567c478bd9Sstevel@tonic-gate #define	ITAB_MAX_MAX		UCHAR_MAX
577c478bd9Sstevel@tonic-gate 
587c478bd9Sstevel@tonic-gate /*
597c478bd9Sstevel@tonic-gate  * Return values from the inittab API.
607c478bd9Sstevel@tonic-gate  */
617c478bd9Sstevel@tonic-gate #define	ITAB_FAILURE		0
627c478bd9Sstevel@tonic-gate #define	ITAB_SUCCESS		1
637c478bd9Sstevel@tonic-gate #define	ITAB_UNKNOWN		2
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate /*
667c478bd9Sstevel@tonic-gate  * Categories to pass to inittab functions; note that these may be
677c478bd9Sstevel@tonic-gate  * bitwise-OR'd to request more than one.  Note that these should
687c478bd9Sstevel@tonic-gate  * not be used otherwise.
697c478bd9Sstevel@tonic-gate  */
707c478bd9Sstevel@tonic-gate #define	ITAB_CAT_STANDARD	0x01
717c478bd9Sstevel@tonic-gate #define	ITAB_CAT_FIELD		0x02
727c478bd9Sstevel@tonic-gate #define	ITAB_CAT_INTERNAL	0x04
737c478bd9Sstevel@tonic-gate #define	ITAB_CAT_VENDOR		0x08
747c478bd9Sstevel@tonic-gate #define	ITAB_CAT_SITE		0x10
75*d04ccbb3Scarlsonj #define	ITAB_CAT_V6		0x20
76*d04ccbb3Scarlsonj #define	ITAB_CAT_COUNT		6
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate /*
797c478bd9Sstevel@tonic-gate  * Consumer which is using the inittab functions.
807c478bd9Sstevel@tonic-gate  */
817c478bd9Sstevel@tonic-gate #define	ITAB_CONS_INFO		'i'
827c478bd9Sstevel@tonic-gate #define	ITAB_CONS_SERVER	'd'
837c478bd9Sstevel@tonic-gate #define	ITAB_CONS_SNOOP		's'
847c478bd9Sstevel@tonic-gate #define	ITAB_CONS_MANAGER	'm'
857c478bd9Sstevel@tonic-gate #define	ITAB_CONS_COUNT		(sizeof ("idsm") - 1)
867c478bd9Sstevel@tonic-gate 
877c478bd9Sstevel@tonic-gate /*
887c478bd9Sstevel@tonic-gate  * Extended error codes, for use with inittab_{en,de}code_e().
897c478bd9Sstevel@tonic-gate  */
907c478bd9Sstevel@tonic-gate #define	ITAB_SYNTAX_ERROR	(-1)
917c478bd9Sstevel@tonic-gate #define	ITAB_BAD_IPADDR		(-2)
927c478bd9Sstevel@tonic-gate #define	ITAB_BAD_STRING		(-3)
937c478bd9Sstevel@tonic-gate #define	ITAB_BAD_OCTET		(-4)
947c478bd9Sstevel@tonic-gate #define	ITAB_BAD_NUMBER		(-5)
957c478bd9Sstevel@tonic-gate #define	ITAB_BAD_BOOLEAN	(-6)
967c478bd9Sstevel@tonic-gate #define	ITAB_NOT_ENOUGH_IP	(-7)
977c478bd9Sstevel@tonic-gate #define	ITAB_BAD_GRAN		(-8)
987c478bd9Sstevel@tonic-gate #define	ITAB_NOMEM		(-9)
997c478bd9Sstevel@tonic-gate 
100*d04ccbb3Scarlsonj extern uint8_t		inittab_type_to_size(const dhcp_symbol_t *);
101*d04ccbb3Scarlsonj extern int		inittab_verify(const dhcp_symbol_t *, dhcp_symbol_t *);
1027c478bd9Sstevel@tonic-gate extern dhcp_symbol_t	*inittab_load(uchar_t, char, size_t *);
1037c478bd9Sstevel@tonic-gate extern dhcp_symbol_t	*inittab_getbyname(uchar_t, char, const char *);
1047c478bd9Sstevel@tonic-gate extern dhcp_symbol_t	*inittab_getbycode(uchar_t, char, uint16_t);
105*d04ccbb3Scarlsonj extern uchar_t		*inittab_encode(const dhcp_symbol_t *, const char *,
1067c478bd9Sstevel@tonic-gate 			    uint16_t *, boolean_t);
107*d04ccbb3Scarlsonj extern uchar_t		*inittab_encode_e(const dhcp_symbol_t *, const char *,
1087c478bd9Sstevel@tonic-gate 			    uint16_t *, boolean_t, int *);
109*d04ccbb3Scarlsonj extern char		*inittab_decode(const dhcp_symbol_t *, const uchar_t *,
1107c478bd9Sstevel@tonic-gate 			    uint16_t, boolean_t);
111*d04ccbb3Scarlsonj extern char		*inittab_decode_e(const dhcp_symbol_t *,
112*d04ccbb3Scarlsonj 			    const uchar_t *, uint16_t, boolean_t, int *);
113*d04ccbb3Scarlsonj 
1147c478bd9Sstevel@tonic-gate #ifdef	__cplusplus
1157c478bd9Sstevel@tonic-gate }
1167c478bd9Sstevel@tonic-gate #endif
1177c478bd9Sstevel@tonic-gate 
1187c478bd9Sstevel@tonic-gate #endif	/* _DHCP_INITTAB_H */
119