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 _DHCP_NETWORK_H
  28 #define _DHCP_NETWORK_H
  29 
  30 #pragma ident   "%Z%%M% %I%     %E% SMI"
  31 
  32 #include <sys/types.h>
  33 #include <sys/param.h>
  34 #include <netinet/in.h>
  35 #include <dhcp_svc_public.h>
  36 
  37 /*
  38  * Implementation-specific data structures for the files dhcp_network
  39  * container.  These structures are subject to change at any time.
  40  */
  41 
  42 #ifdef  __cplusplus
  43 extern "C" {
  44 #endif
  45 
  46 /*
  47  * Per-record state describing the underlying record, including its
  48  * position on-disk.
  49  */
  50 typedef struct dn_recpos {
  51         dn_rec_t        dnp_rec;        /* traditional record */
  52         size_t          dnp_size;       /* its size in the file */
  53         off_t           dnp_off;        /* its starting offset in the file */
  54 } dn_recpos_t;
  55 
  56 /*
  57  * Per-record state for the underlying on-disk record representation.  Note
  58  * that `dnf_cid' is twice its usual maximum length (plus room for a NUL
  59  * byte) since it doubles in size when converted to ASCII; `dnf_macro' and
  60  * `dnf_comment' are twice their usual maximum length in case we need to
  61  * escape every character in them.
  62  */
  63 typedef struct dn_filerec {
  64         char            dnf_cip[INET_ADDRSTRLEN];
  65         char            dnf_cid[DN_MAX_CID_LEN * 2 + 1];
  66         uint16_t        dnf_flags;
  67         char            dnf_sip[INET_ADDRSTRLEN];
  68         uint32_t        dnf_lease;
  69         uint64_t        dnf_sig;
  70         char            dnf_macro[DSVC_MAX_MACSYM_LEN * 2 + 1];
  71         char            dnf_comment[DN_MAX_COMMENT_LEN * 2 + 1];
  72 } dn_filerec_t;
  73 
  74 /*
  75  * Per-instance state for each instance of an open_dn()
  76  */
  77 typedef struct dn_handle {
  78         unsigned int    dh_oflags;      /* flags passed into open_dn() */
  79         char            dh_location[MAXPATHLEN];
  80         ipaddr_t        dh_net;
  81 } dn_handle_t;
  82 
  83 /*
  84  * Order of the fields in the on-disk record.
  85  */
  86 enum { DNF_CIP, DNF_CID, DNF_FLAGS, DNF_SIP, DNF_LEASE, DNF_SIG, DNF_MACRO,
  87         DNF_COMMENT };
  88 
  89 #define DNF_FIELDS              8       /* number of fields per record */
  90 #define DNF_COMMENT_CHAR        '#'
  91 
  92 /*
  93  * Constants for use with find_dn()
  94  */
  95 #define FIND_PARTIAL    0x0001          /* allow partial success */
  96 #define FIND_POSITION   0x0002          /* return dn_recpos_t's */
  97 
  98 #ifdef  __cplusplus
  99 }
 100 #endif
 101 
 102 #endif  /* _DHCP_NETWORK_H */