2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 2001, 2007, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _DHCP_SYMBOL_H
2N/A#define _DHCP_SYMBOL_H
2N/A
2N/A/*
2N/A * This file, along with <dhcp_symbol_common.h>, contains the DHCP symbol
2N/A * constants and the definitions for the external interfaces to the parsing
2N/A * logic (contained in dhcp_symbol.c) for symbol definitions. These
2N/A * definitions can and should be used by all consumers of DHCP symbols.
2N/A */
2N/A
2N/A#include <sys/types.h>
2N/A#include <dhcp_svc_private.h>
2N/A#include <dhcp_symbol_common.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * Vendor class length (and implicitly, the number of classes)
2N/A */
2N/A#define DSYM_CLASS_SIZE DSVC_MAX_MACSYM_LEN /* Single class max */
2N/A#define DSYM_MAX_CLASS_SIZE (DSYM_CLASS_SIZE * 10) /* At least 10 */
2N/A
2N/A/*
2N/A * Maximum symbol length is defined by the libdhcpsvc.
2N/A */
2N/A#define DSYM_MAX_SYM_LEN DSVC_MAX_MACSYM_LEN
2N/A
2N/A/*
2N/A * symbol parsing error codes
2N/A */
2N/Atypedef enum {
2N/A DSYM_SUCCESS,
2N/A DSYM_SYNTAX_ERROR,
2N/A DSYM_NULL_FIELD,
2N/A DSYM_TOO_MANY_FIELDS,
2N/A DSYM_CODE_OUT_OF_RANGE,
2N/A DSYM_VALUE_OUT_OF_RANGE,
2N/A DSYM_INVALID_CAT,
2N/A DSYM_INVALID_TYPE,
2N/A DSYM_EXCEEDS_CLASS_SIZE,
2N/A DSYM_EXCEEDS_MAX_CLASS_SIZE,
2N/A DSYM_NO_MEMORY,
2N/A DSYM_INVALID_FIELD_NUM
2N/A} dsym_errcode_t;
2N/A
2N/A/*
2N/A * symbol fields
2N/A */
2N/A#define DSYM_CAT_FIELD 0
2N/A#define DSYM_CODE_FIELD 1
2N/A#define DSYM_TYPE_FIELD 2
2N/A#define DSYM_GRAN_FIELD 3
2N/A#define DSYM_MAX_FIELD 4
2N/A#define DSYM_NUM_FIELDS 5
2N/A#define DSYM_FIRST_FIELD DSYM_CAT_FIELD
2N/A
2N/A/*
2N/A * This structure is used by the dhcp_symbol_t structure below
2N/A * when the option being defined is a vendor option. In which case,
2N/A * this structure contains the client classes for which the option
2N/A * applies.
2N/A */
2N/Atypedef struct dhcp_classes {
2N/A char **dc_names;
2N/A uint8_t dc_cnt;
2N/A} dhcp_classes_t;
2N/A
2N/A/*
2N/A * This structure is used to define a DHCP symbol. The structure is
2N/A * used by both the inittab parsing routines and by the dhcptab parsing
2N/A * routines to define a symbol definition in either of those tables.
2N/A * Note that ds_dhcpv6 is defined last so that it needn't be initialized
2N/A * as part of the inittab_table[] definition.
2N/A */
2N/Atypedef struct dhcp_symbol {
2N/A dsym_category_t ds_category; /* category */
2N/A ushort_t ds_code; /* option code */
2N/A char ds_name[DSYM_MAX_SYM_LEN + 1]; /* option name */
2N/A dsym_cdtype_t ds_type; /* type of parm */
2N/A uchar_t ds_gran; /* granularity */
2N/A uchar_t ds_max; /* maximum number */
2N/A dhcp_classes_t ds_classes; /* client classes */
2N/A uchar_t ds_dhcpv6; /* dhcpv6 flag */
2N/A} dhcp_symbol_t;
2N/A
2N/Aextern void dsym_free_fields(char **);
2N/Aextern void dsym_free_classes(dhcp_classes_t *);
2N/Aextern void dsym_close_parser(char **, dhcp_symbol_t *);
2N/Aextern dsym_errcode_t dsym_init_parser(const char *, const char *, char ***,
2N/A dhcp_symbol_t *);
2N/Aextern dsym_errcode_t dsym_parse_field(int, char **, dhcp_symbol_t *);
2N/Aextern dsym_errcode_t dsym_parser(char **, dhcp_symbol_t *, int *, boolean_t);
2N/Aextern dsym_errcode_t dsym_get_cat_id(const char *, dsym_category_t *,
2N/A boolean_t);
2N/Aextern dsym_errcode_t dsym_get_code_ranges(const char *cat, ushort_t *,
2N/A ushort_t *, boolean_t);
2N/Aextern dsym_errcode_t dsym_get_type_id(const char *, dsym_cdtype_t *,
2N/A boolean_t);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _DHCP_SYMBOL_H */