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, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * 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) 2000 by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A#ifndef _DHCP_NETWORK_H
2N/A#define _DHCP_NETWORK_H
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A/*
2N/A * Implementation-specific data structures and constants for the binary
2N/A * files dhcp_network container. These structures are subject to change at
2N/A * any time.
2N/A */
2N/A
2N/A#include <sys/types.h>
2N/A#include <dhcp_svc_public.h>
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A/*
2N/A * The client id hash size is based on the idea that, given a perfect hash,
2N/A * the hash chain length shouldn't be more than the number of buckets.
2N/A * Given a worst case network with 2^24 addresses, that means we should
2N/A * have 4096 buckets; we shrink this by a bit to make the dn_header_t size
2N/A * be a power of two (32768 bytes). Note that we assert that a header is
2N/A * this size in open_dn().
2N/A */
2N/A#define DN_CIDHASHSZ 4056
2N/A#define DN_MAGIC 0x0d6c92e4 /* "dhcpnet" in hexadecimal world */
2N/A#define DN_NOIMAGE 0x80 /* image field not in use */
2N/A#define DN_NOREC 0x00000000 /* "no record" id value, must be zero */
2N/A#define DN_TEMPREC 0xffffffff /* "temp record" id value */
2N/A#define DN_HASHHEAD 0xfffffffe /* "hash chain head" id value */
2N/A
2N/Atypedef uint32_t dn_recid_t; /* record id type */
2N/A
2N/A/*
2N/A * Macros to compute the record id for a record with address `addr' in a
2N/A * container with netmask `mask', and to convert a record id `recid' to its
2N/A * starting file offset within its container. Note that we reserve the
2N/A * record id value of 0 for DN_NOREC for reasons explained in open_dn().
2N/A */
2N/A#define RECID(addr, mask) ((dn_recid_t)(((addr) & ~(mask)) + 1))
2N/A#define RECID2OFFSET(recid) \
2N/A (((recid) == DN_TEMPREC) ? offsetof(dn_header_t, dnh_temp) : \
2N/A (sizeof (dn_header_t) + ((off_t)sizeof (dn_filerec_t) * ((recid) - 1))))
2N/A
2N/A/*
2N/A * What each dn_rec_t looks like on-disk -- contains the dn_rec_t, pointers
2N/A * to the previous and next dn_rec_t's on its client id hash. See the big
2N/A * theory statement in dhcp_network.c for a discussion on the redundant
2N/A * dn_recid_t's.
2N/A */
2N/Atypedef struct dn_filerec {
2N/A dn_recid_t rec_next[2]; /* id of next record in cidhash */
2N/A dn_recid_t rec_prev[2]; /* id of prev record in cidhash */
2N/A dn_rec_t rec_dn; /* actual dn_rec_t */
2N/A} dn_filerec_t;
2N/A
2N/A/*
2N/A * Header atop each dhcp_network container -- contains some basic
2N/A * information about the container and an array of buckets to chain client
2N/A * id hashes from. See the big theory statement in dhcp_network.c for a
2N/A * discussion on the redundant dn_recid_t's and the concept of "images".
2N/A */
2N/Atypedef struct dn_header {
2N/A unsigned char dnh_version; /* container version */
2N/A unsigned char dnh_dirty; /* container might be dirty */
2N/A unsigned char dnh_image; /* container's active image */
2N/A unsigned char dnh_tempimage; /* temporary record's image */
2N/A uint32_t dnh_magic; /* container magic */
2N/A ipaddr_t dnh_network; /* network number of table */
2N/A ipaddr_t dnh_netmask; /* netmask of network number */
2N/A dn_filerec_t dnh_temp; /* temporary record used in modify_dn */
2N/A uint32_t dnh_checks; /* number of check_dn full runs */
2N/A uint32_t dnh_errors; /* number of errors caught */
2N/A uint32_t dnh_pad[4]; /* for future use */
2N/A
2N/A /*
2N/A * Note: read_header() assumes that dnh_cidhash is the last member.
2N/A */
2N/A dn_recid_t dnh_cidhash[DN_CIDHASHSZ][2]; /* cid hash buckets */
2N/A} dn_header_t;
2N/A
2N/A/*
2N/A * Per-instance state for each handle returned from open_dn.
2N/A */
2N/Atypedef struct dn_handle {
2N/A int dh_fd; /* fd for open file pointer */
2N/A unsigned int dh_oflags; /* flags passed into open_dn */
2N/A ipaddr_t dh_netmask; /* cached netmask of container */
2N/A} dn_handle_t;
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _DHCP_NETWORK_H */