summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdhcpsvc/modules/binfiles/dhcptab.h
blob: 887de8d4400f0eaf0a80dae37ee00e445ceb524e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright (c) 2000 by Sun Microsystems, Inc.
 * All rights reserved.
 */

#ifndef _DHCPTAB_H
#define	_DHCPTAB_H

#pragma ident	"%Z%%M%	%I%	%E% SMI"

/*
 * Implementation-specific data structures and constants for the binary
 * dhcptab container.  These structures are subject to change at any time.
 */

#ifdef __cplusplus
extern "C" {
#endif

#include <sys/types.h>
#include <dhcp_svc_public.h>

#define	DT_NOREC	0		/* "no record" id value */
#define	DT_MAGIC	0x0d6c94ab	/* "dhcptab" in a hexadecimal world */

/*
 * Constants for use with find_dt
 */
#define	FIND_PARTIAL	0x0001		/* allow partial success */
#define	FIND_POSITION	0x0002 		/* return dt_recpos_t's */

/*
 * Header atop the dhcptab container -- contains some basic information
 * about the container for sanity-checking purposes.
 */
typedef struct dt_header {
	unsigned char	dth_version;	/* container version */
	unsigned char	dth_align[3]; 	/* ensure binary compatibility */
	uint32_t	dth_magic;	/* magic for sanity check */
	uint32_t	dth_pad[4];	/* for future use */
} dt_header_t;

/*
 * What each dt_rec_t looks like on-disk -- note that we cannot just write
 * dt_rec_t's because the `dt_value' field can be arbitrarily large.
 * Instead, write out the dt_rec_t structure followed by the variable-size
 * `rec_dtval' array which will contain the current value of `dt_value'.
 * Since `rec_dtval' is of variable size, we must explicitly keep track of
 * its length via `rec_dtvalsize'.
 */
typedef struct dt_filerec {
	dt_rec_t	rec_dt;		/* actual dt_rec_t */
	uint32_t	rec_dtvalsize;	/* total size of rec_dtval */
	char		rec_dtval[1];	/* dt_value field from dt_rec_t */
} dt_filerec_t;

/*
 * Per-record state describing the underlying record, including its
 * position on-disk; these are returned instead of dt_rec_t's when find_dt
 * is called with FIND_POSITION set.  Note that for this to work, the
 * dt_rec_t must be the first member.
 */
typedef struct dt_recpos {
	dt_rec_t	dtp_rec;	/* traditional dt_rec_t */
	size_t		dtp_size;	/* its size in the file */
	off_t		dtp_off;	/* its starting offset in the file */
} dt_recpos_t;

/*
 * Per-instance state for each handle returned from open_dt
 */
typedef struct dt_handle {
	unsigned int	dh_oflags;		 /* flags passed into open_dt */
	char		dh_location[MAXPATHLEN]; /* location of container */
} dt_handle_t;

#ifdef __cplusplus
}
#endif

#endif /* _DHCPTAB_H */