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, Version 1.0 only
   6  * (the "License").  You may not use this file except in compliance
   7  * with the License.
   8  *
   9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
  10  * or http://www.opensolaris.org/os/licensing.
  11  * See the License for the specific language governing permissions
  12  * and limitations under the License.
  13  *
  14  * When distributing Covered Code, include this CDDL HEADER in each
  15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  16  * If applicable, add the following below this CDDL HEADER, with the
  17  * fields enclosed by brackets "[]" replaced with your own identifying
  18  * information: Portions Copyright [yyyy] [name of copyright owner]
  19  *
  20  * CDDL HEADER END
  21  */
  22 /*
  23  * Copyright (c) 2000 by Sun Microsystems, Inc.
  24  * All rights reserved.
  25  */
  26 
  27 #ifndef _DHCPTAB_H
  28 #define _DHCPTAB_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 /*
  33  * Implementation-specific data structures and constants for the binary
  34  * dhcptab container.  These structures are subject to change at any time.
  35  */
  36 
  37 #ifdef __cplusplus
  38 extern "C" {
  39 #endif
  40 
  41 #include <sys/types.h>
  42 #include <dhcp_svc_public.h>
  43 
  44 #define DT_NOREC        0               /* "no record" id value */
  45 #define DT_MAGIC        0x0d6c94ab      /* "dhcptab" in a hexadecimal world */
  46 
  47 /*
  48  * Constants for use with find_dt
  49  */
  50 #define FIND_PARTIAL    0x0001          /* allow partial success */
  51 #define FIND_POSITION   0x0002          /* return dt_recpos_t's */
  52 
  53 /*
  54  * Header atop the dhcptab container -- contains some basic information
  55  * about the container for sanity-checking purposes.
  56  */
  57 typedef struct dt_header {
  58         unsigned char   dth_version;    /* container version */
  59         unsigned char   dth_align[3];   /* ensure binary compatibility */
  60         uint32_t        dth_magic;      /* magic for sanity check */
  61         uint32_t        dth_pad[4];     /* for future use */
  62 } dt_header_t;
  63 
  64 /*
  65  * What each dt_rec_t looks like on-disk -- note that we cannot just write
  66  * dt_rec_t's because the `dt_value' field can be arbitrarily large.
  67  * Instead, write out the dt_rec_t structure followed by the variable-size
  68  * `rec_dtval' array which will contain the current value of `dt_value'.
  69  * Since `rec_dtval' is of variable size, we must explicitly keep track of
  70  * its length via `rec_dtvalsize'.
  71  */
  72 typedef struct dt_filerec {
  73         dt_rec_t        rec_dt;         /* actual dt_rec_t */
  74         uint32_t        rec_dtvalsize;  /* total size of rec_dtval */
  75         char            rec_dtval[1];   /* dt_value field from dt_rec_t */
  76 } dt_filerec_t;
  77 
  78 /*
  79  * Per-record state describing the underlying record, including its
  80  * position on-disk; these are returned instead of dt_rec_t's when find_dt
  81  * is called with FIND_POSITION set.  Note that for this to work, the
  82  * dt_rec_t must be the first member.
  83  */
  84 typedef struct dt_recpos {
  85         dt_rec_t        dtp_rec;        /* traditional dt_rec_t */
  86         size_t          dtp_size;       /* its size in the file */
  87         off_t           dtp_off;        /* its starting offset in the file */
  88 } dt_recpos_t;
  89 
  90 /*
  91  * Per-instance state for each handle returned from open_dt
  92  */
  93 typedef struct dt_handle {
  94         unsigned int    dh_oflags;               /* flags passed into open_dt */
  95         char            dh_location[MAXPATHLEN]; /* location of container */
  96 } dt_handle_t;
  97 
  98 #ifdef __cplusplus
  99 }
 100 #endif
 101 
 102 #endif /* _DHCPTAB_H */