10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*3431Scarlsonj * Common Development and Distribution License (the "License"). 6*3431Scarlsonj * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 22*3431Scarlsonj * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #ifndef _DHCP_SYMBOL_H 270Sstevel@tonic-gate #define _DHCP_SYMBOL_H 280Sstevel@tonic-gate 290Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 300Sstevel@tonic-gate 310Sstevel@tonic-gate /* 320Sstevel@tonic-gate * This file, along with <dhcp_symbol_common.h>, contains the DHCP symbol 330Sstevel@tonic-gate * constants and the definitions for the external interfaces to the parsing 340Sstevel@tonic-gate * logic (contained in dhcp_symbol.c) for symbol definitions. These 350Sstevel@tonic-gate * definitions can and should be used by all consumers of DHCP symbols. 360Sstevel@tonic-gate */ 370Sstevel@tonic-gate 380Sstevel@tonic-gate #include <sys/types.h> 390Sstevel@tonic-gate #include <dhcp_svc_private.h> 400Sstevel@tonic-gate #include <dhcp_symbol_common.h> 410Sstevel@tonic-gate 420Sstevel@tonic-gate #ifdef __cplusplus 430Sstevel@tonic-gate extern "C" { 440Sstevel@tonic-gate #endif 450Sstevel@tonic-gate 460Sstevel@tonic-gate /* 470Sstevel@tonic-gate * Vendor class length (and implicitly, the number of classes) 480Sstevel@tonic-gate */ 490Sstevel@tonic-gate #define DSYM_CLASS_SIZE DSVC_MAX_MACSYM_LEN /* Single class max */ 500Sstevel@tonic-gate #define DSYM_MAX_CLASS_SIZE (DSYM_CLASS_SIZE * 10) /* At least 10 */ 510Sstevel@tonic-gate 520Sstevel@tonic-gate /* 530Sstevel@tonic-gate * Maximum symbol length is defined by the libdhcpsvc. 540Sstevel@tonic-gate */ 550Sstevel@tonic-gate #define DSYM_MAX_SYM_LEN DSVC_MAX_MACSYM_LEN 560Sstevel@tonic-gate 570Sstevel@tonic-gate /* 580Sstevel@tonic-gate * symbol parsing error codes 590Sstevel@tonic-gate */ 600Sstevel@tonic-gate typedef enum { 610Sstevel@tonic-gate DSYM_SUCCESS, 620Sstevel@tonic-gate DSYM_SYNTAX_ERROR, 630Sstevel@tonic-gate DSYM_NULL_FIELD, 640Sstevel@tonic-gate DSYM_TOO_MANY_FIELDS, 650Sstevel@tonic-gate DSYM_CODE_OUT_OF_RANGE, 660Sstevel@tonic-gate DSYM_VALUE_OUT_OF_RANGE, 670Sstevel@tonic-gate DSYM_INVALID_CAT, 680Sstevel@tonic-gate DSYM_INVALID_TYPE, 690Sstevel@tonic-gate DSYM_EXCEEDS_CLASS_SIZE, 700Sstevel@tonic-gate DSYM_EXCEEDS_MAX_CLASS_SIZE, 710Sstevel@tonic-gate DSYM_NO_MEMORY, 720Sstevel@tonic-gate DSYM_INVALID_FIELD_NUM 730Sstevel@tonic-gate } dsym_errcode_t; 740Sstevel@tonic-gate 750Sstevel@tonic-gate /* 760Sstevel@tonic-gate * symbol fields 770Sstevel@tonic-gate */ 780Sstevel@tonic-gate #define DSYM_CAT_FIELD 0 790Sstevel@tonic-gate #define DSYM_CODE_FIELD 1 800Sstevel@tonic-gate #define DSYM_TYPE_FIELD 2 810Sstevel@tonic-gate #define DSYM_GRAN_FIELD 3 820Sstevel@tonic-gate #define DSYM_MAX_FIELD 4 830Sstevel@tonic-gate #define DSYM_NUM_FIELDS 5 840Sstevel@tonic-gate #define DSYM_FIRST_FIELD DSYM_CAT_FIELD 850Sstevel@tonic-gate 860Sstevel@tonic-gate /* 870Sstevel@tonic-gate * This structure is used by the dhcp_symbol_t structure below 880Sstevel@tonic-gate * when the option being defined is a vendor option. In which case, 890Sstevel@tonic-gate * this structure contains the client classes for which the option 900Sstevel@tonic-gate * applies. 910Sstevel@tonic-gate */ 920Sstevel@tonic-gate typedef struct dhcp_classes { 930Sstevel@tonic-gate char **dc_names; 940Sstevel@tonic-gate uint8_t dc_cnt; 950Sstevel@tonic-gate } dhcp_classes_t; 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* 980Sstevel@tonic-gate * This structure is used to define a DHCP symbol. The structure is 990Sstevel@tonic-gate * used by both the inittab parsing routines and by the dhcptab parsing 1000Sstevel@tonic-gate * routines to define a symbol definition in either of those tables. 101*3431Scarlsonj * Note that ds_dhcpv6 is defined last so that it needn't be initialized 102*3431Scarlsonj * as part of the inittab_table[] definition. 1030Sstevel@tonic-gate */ 1040Sstevel@tonic-gate typedef struct dhcp_symbol { 1050Sstevel@tonic-gate dsym_category_t ds_category; /* category */ 1060Sstevel@tonic-gate ushort_t ds_code; /* option code */ 1070Sstevel@tonic-gate char ds_name[DSYM_MAX_SYM_LEN + 1]; /* option name */ 1080Sstevel@tonic-gate dsym_cdtype_t ds_type; /* type of parm */ 1090Sstevel@tonic-gate uchar_t ds_gran; /* granularity */ 1100Sstevel@tonic-gate uchar_t ds_max; /* maximum number */ 1110Sstevel@tonic-gate dhcp_classes_t ds_classes; /* client classes */ 112*3431Scarlsonj uchar_t ds_dhcpv6; /* dhcpv6 flag */ 1130Sstevel@tonic-gate } dhcp_symbol_t; 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate extern void dsym_free_fields(char **); 1160Sstevel@tonic-gate extern void dsym_free_classes(dhcp_classes_t *); 1170Sstevel@tonic-gate extern void dsym_close_parser(char **, dhcp_symbol_t *); 1180Sstevel@tonic-gate extern dsym_errcode_t dsym_init_parser(const char *, const char *, char ***, 1190Sstevel@tonic-gate dhcp_symbol_t *); 1200Sstevel@tonic-gate extern dsym_errcode_t dsym_parse_field(int, char **, dhcp_symbol_t *); 1210Sstevel@tonic-gate extern dsym_errcode_t dsym_parser(char **, dhcp_symbol_t *, int *, boolean_t); 1220Sstevel@tonic-gate extern dsym_errcode_t dsym_get_cat_id(const char *, dsym_category_t *, 1230Sstevel@tonic-gate boolean_t); 1240Sstevel@tonic-gate extern dsym_errcode_t dsym_get_code_ranges(const char *cat, ushort_t *, 1250Sstevel@tonic-gate ushort_t *, boolean_t); 1260Sstevel@tonic-gate extern dsym_errcode_t dsym_get_type_id(const char *, dsym_cdtype_t *, 1270Sstevel@tonic-gate boolean_t); 1280Sstevel@tonic-gate 1290Sstevel@tonic-gate #ifdef __cplusplus 1300Sstevel@tonic-gate } 1310Sstevel@tonic-gate #endif 1320Sstevel@tonic-gate 1330Sstevel@tonic-gate #endif /* _DHCP_SYMBOL_H */ 134