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.
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.
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]
22 * Copyright 2014 Garrett D'Amore <garrett@damore.org>
24 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
28 #ifndef _DHCP_SYMBOL_H
29 #define _DHCP_SYMBOL_H
32 * This file, along with <dhcp_symbol_common.h>, contains the DHCP symbol
33 * constants and the definitions for the external interfaces to the parsing
34 * logic (contained in dhcp_symbol.c) for symbol definitions. These
35 * definitions can and should be used by all consumers of DHCP symbols.
38 #include <sys/types.h>
39 #include <dhcp_symbol_common.h>
46 * Vendor class length (and implicitly, the number of classes)
48 #define DSYM_CLASS_SIZE 128 /* Single class max */
49 #define DSYM_MAX_CLASS_SIZE (DSYM_CLASS_SIZE * 10) /* At least 10 */
52 * Maximum symbol length
54 #define DSYM_MAX_SYM_LEN 128
57 * symbol parsing error codes
64 DSYM_CODE_OUT_OF_RANGE
,
65 DSYM_VALUE_OUT_OF_RANGE
,
68 DSYM_EXCEEDS_CLASS_SIZE
,
69 DSYM_EXCEEDS_MAX_CLASS_SIZE
,
71 DSYM_INVALID_FIELD_NUM
77 #define DSYM_CAT_FIELD 0
78 #define DSYM_CODE_FIELD 1
79 #define DSYM_TYPE_FIELD 2
80 #define DSYM_GRAN_FIELD 3
81 #define DSYM_MAX_FIELD 4
82 #define DSYM_NUM_FIELDS 5
83 #define DSYM_FIRST_FIELD DSYM_CAT_FIELD
86 * This structure is used by the dhcp_symbol_t structure below
87 * when the option being defined is a vendor option. In which case,
88 * this structure contains the client classes for which the option
91 typedef struct dhcp_classes
{
97 * This structure is used to define a DHCP symbol. The structure is
98 * used by both the inittab parsing routines and by the dhcptab parsing
99 * routines to define a symbol definition in either of those tables.
100 * Note that ds_dhcpv6 is defined last so that it needn't be initialized
101 * as part of the inittab_table[] definition.
103 typedef struct dhcp_symbol
{
104 dsym_category_t ds_category
; /* category */
105 ushort_t ds_code
; /* option code */
106 char ds_name
[DSYM_MAX_SYM_LEN
+ 1]; /* option name */
107 dsym_cdtype_t ds_type
; /* type of parm */
108 uchar_t ds_gran
; /* granularity */
109 uchar_t ds_max
; /* maximum number */
110 dhcp_classes_t ds_classes
; /* client classes */
111 uchar_t ds_dhcpv6
; /* dhcpv6 flag */
114 extern void dsym_free_fields(char **);
115 extern void dsym_free_classes(dhcp_classes_t
*);
116 extern void dsym_close_parser(char **, dhcp_symbol_t
*);
117 extern dsym_errcode_t
dsym_init_parser(const char *, const char *, char ***,
119 extern dsym_errcode_t
dsym_parse_field(int, char **, dhcp_symbol_t
*);
120 extern dsym_errcode_t
dsym_parser(char **, dhcp_symbol_t
*, int *, boolean_t
);
121 extern dsym_errcode_t
dsym_get_cat_id(const char *, dsym_category_t
*,
123 extern dsym_errcode_t
dsym_get_code_ranges(const char *cat
, ushort_t
*,
124 ushort_t
*, boolean_t
);
125 extern dsym_errcode_t
dsym_get_type_id(const char *, dsym_cdtype_t
*,
132 #endif /* _DHCP_SYMBOL_H */