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, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A#ifndef _DHCP_SVC_PUBLIC_H
2N/A#define _DHCP_SVC_PUBLIC_H
2N/A
2N/A/*
2N/A * Contains published interfaces to the DHCP data service.
2N/A */
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <sys/types.h>
2N/A#include <netinet/in.h> /* struct in_addr */
2N/A#include <netinet/dhcp.h>
2N/A
2N/A#define DSVC_PUBLIC_VERSION 1 /* version of public layer interface */
2N/A
2N/A/*
2N/A * Errors which can be returned from the defined API
2N/A * Note: must be kept in sync with errmsgs[] in private/errmsgs.c.
2N/A */
2N/A#define DSVC_SUCCESS 0 /* success */
2N/A#define DSVC_EXISTS 1 /* object already exists */
2N/A#define DSVC_ACCESS 2 /* access denied */
2N/A#define DSVC_NO_CRED 3 /* no underlying credential */
2N/A#define DSVC_NOENT 4 /* object doesn't exist */
2N/A#define DSVC_BUSY 5 /* object temporarily busy (again) */
2N/A#define DSVC_INVAL 6 /* invalid argument(s) */
2N/A#define DSVC_INTERNAL 7 /* internal data store error */
2N/A#define DSVC_UNAVAILABLE 8 /* underlying service required by */
2N/A /* public module unavailable */
2N/A#define DSVC_COLLISION 9 /* update collision */
2N/A#define DSVC_UNSUPPORTED 10 /* operation not supported */
2N/A#define DSVC_NO_MEMORY 11 /* operation ran out of memory */
2N/A#define DSVC_NO_RESOURCES 12 /* non-memory resources unavailable */
2N/A#define DSVC_BAD_RESOURCE 13 /* malformed/missing RESOURCE setting */
2N/A#define DSVC_BAD_PATH 14 /* malformed/missing PATH setting */
2N/A#define DSVC_MODULE_VERSION 15 /* public layer version mismatch */
2N/A#define DSVC_MODULE_ERR 16 /* internal public module error */
2N/A#define DSVC_MODULE_LOAD_ERR 17 /* error loading public module */
2N/A#define DSVC_MODULE_UNLOAD_ERR 18 /* error unloading public module */
2N/A#define DSVC_MODULE_CFG_ERR 19 /* Module configuration failure */
2N/A#define DSVC_SYNCH_ERR 20 /* error in synchronization protocol */
2N/A#define DSVC_NO_LOCKMGR 21 /* cannot contact lock manager */
2N/A#define DSVC_NO_LOCATION 22 /* location nonexistent */
2N/A#define DSVC_BAD_CONVER 23 /* malformed/missing CONVER setting */
2N/A#define DSVC_NO_TABLE 24 /* container does not exist */
2N/A#define DSVC_TABLE_EXISTS 25 /* container already exists */
2N/A
2N/A#define DSVC_NERR (DSVC_TABLE_EXISTS + 1)
2N/A
2N/A/*
2N/A * Flags that can be passed to open_*
2N/A */
2N/A#define DSVC_CREATE 0x01 /* create container; must not exist */
2N/A#define DSVC_READ 0x02 /* open container for reading */
2N/A#define DSVC_WRITE 0x04 /* open container for writing */
2N/A#define DSVC_NONBLOCK 0x08 /* open container in nonblocking mode */
2N/A
2N/A/*
2N/A * Query macros - used for initializing query flags to lookup_*
2N/A */
2N/A#define DSVC_QINIT(q) ((q) = 0)
2N/A#define DSVC_QEQ(q, v) ((q) = ((q) | (v) | ((v) << 16)))
2N/A#define DSVC_QNEQ(q, v) ((q) = ((~((v) << 16)) & (q)) | (v))
2N/A#define DSVC_QISEQ(q, v) (((q) & (v)) && ((q) & ((v) << 16)))
2N/A#define DSVC_QISNEQ(q, v) (((q) & (v)) && (!((q) & ((v) << 16))))
2N/A
2N/A#define DSVC_MAX_MACSYM_LEN 128 /* max length of a macro or symbol */
2N/A
2N/A/*
2N/A * DHCP Configuration Container (dhcptab(4))
2N/A */
2N/A#define DT_DHCPTAB "dhcptab" /* Default name of container */
2N/A#define DT_SYMBOL 's'
2N/A#define DT_MACRO 'm'
2N/A
2N/A/* Query flags for lookup_dt */
2N/A#define DT_QKEY 0x01
2N/A#define DT_QTYPE 0x02
2N/A#define DT_QALL (DT_QKEY|DT_QTYPE)
2N/A
2N/A/*
2N/A * Consumer's dhcptab record form. Dynamically allocated by underlying data
2N/A * store. dt_sig is set by underlying data store -- it's opaque to the
2N/A * DHCP service, and is used by the data store to detect update collisions.
2N/A * All fields must be fixed-width types and in host byte order. Note that
2N/A * SUNWbinfiles writes these records directly to disk, thus changing its
2N/A * definition may introduce binary compatibility problems. Note also that
2N/A * fields have been carefully ordered to avoid internal padding and the
2N/A * structure's size is 64-bit aligned to avoid capricious trailing padding.
2N/A */
2N/Atypedef struct {
2N/A uint64_t dt_sig; /* Opaque atomic cookie */
2N/A char *dt_value; /* Value of type dt_type */
2N/A char dt_key[DSVC_MAX_MACSYM_LEN + 1]; /* Macro/symbol name */
2N/A char dt_type; /* Type of data */
2N/A char dt_pad[2]; /* Pad to 64-bit boundary */
2N/A} dt_rec_t;
2N/A
2N/Atypedef struct dt_rec_list {
2N/A dt_rec_t *dtl_rec;
2N/A struct dt_rec_list *dtl_next; /* Next record in the list */
2N/A} dt_rec_list_t;
2N/A
2N/A/*
2N/A * DHCP Network Container (dhcp_network(4))
2N/A */
2N/A#define DN_MAX_CID_LEN (DSVC_MAX_MACSYM_LEN / 2)
2N/A#define DN_MAX_COMMENT_LEN 48
2N/A
2N/A/* Query flags for lookup_dn */
2N/A#define DN_QCID 0x0001
2N/A#define DN_QCIP 0x0002
2N/A#define DN_QSIP 0x0004
2N/A#define DN_QLEASE 0x0008
2N/A#define DN_QMACRO 0x0010
2N/A#define DN_QFDYNAMIC 0x0020
2N/A#define DN_QFAUTOMATIC 0x0040
2N/A#define DN_QFMANUAL 0x0080
2N/A#define DN_QFUNUSABLE 0x0100
2N/A#define DN_QFBOOTP_ONLY 0x0200
2N/A#define DN_QALL (DN_QCID | DN_QCIP | DN_QSIP | DN_QLEASE |\
2N/A DN_QMACRO | DN_QFDYNAMIC | DN_QFAUTOMATIC |\
2N/A DN_QFMANUAL | DN_QFUNUSABLE |\
2N/A DN_QFBOOTP_ONLY)
2N/A
2N/A/* dn_flags values */
2N/A#define DN_FDYNAMIC 0x00 /* Non-permanent */
2N/A#define DN_FAUTOMATIC 0x01 /* Lease is permanent */
2N/A#define DN_FMANUAL 0x02 /* Manually allocated (sacred) */
2N/A#define DN_FUNUSABLE 0x04 /* Address is unusable */
2N/A#define DN_FBOOTP_ONLY 0x08 /* Address is reserved for BOOTP */
2N/A#define DN_FALL (DN_FDYNAMIC | DN_FAUTOMATIC | DN_FMANUAL |\
2N/A DN_FUNUSABLE | DN_FBOOTP_ONLY)
2N/A
2N/A/*
2N/A * Consumer's DHCP network container record form. Dynamically allocated by
2N/A * underlying data store. dn_sig is set by underlying data store -- it's
2N/A * opaque to the DHCP service, and is used by the data store to detect
2N/A * update collisions. All fields must be fixed-width types and in host
2N/A * byte order. Note that SUNWbinfiles writes these records directly to
2N/A * disk, thus changing its definition may introduce binary compatibility
2N/A * problems. Note also that fields have been carefully ordered to avoid
2N/A * internal padding and the structure's size is 64-bit aligned to avoid
2N/A * capricious trailing padding.
2N/A */
2N/Atypedef struct {
2N/A uint64_t dn_sig; /* Opaque atomic cookie */
2N/A struct in_addr dn_cip; /* Client IP address */
2N/A struct in_addr dn_sip; /* Server IP address */
2N/A lease_t dn_lease; /* Abs lease expiration */
2N/A char dn_macro[DSVC_MAX_MACSYM_LEN + 1];
2N/A char dn_comment[DN_MAX_COMMENT_LEN + 1];
2N/A uchar_t dn_cid[DN_MAX_CID_LEN]; /* Opaque client id */
2N/A uchar_t dn_cid_len; /* Length of client id */
2N/A uchar_t dn_flags; /* Flags */
2N/A} dn_rec_t;
2N/A
2N/Atypedef struct dn_rec_list {
2N/A dn_rec_t *dnl_rec; /* The record itself */
2N/A struct dn_rec_list *dnl_next; /* Next entry in the list */
2N/A} dn_rec_list_t;
2N/A
2N/A/*
2N/A * Synchronization Service Type and values.
2N/A */
2N/Atypedef uint32_t dsvc_synchtype_t;
2N/A
2N/A#define DSVC_SYNCH_NONE 0 /* no synch type */
2N/A#define DSVC_SYNCH_DSVCD 1 /* dsvclockd(1M) synch type */
2N/A
2N/A/*
2N/A * Generic API provided by SMI
2N/A */
2N/Aextern dt_rec_t *alloc_dtrec(const char *, char, const char *);
2N/Aextern dn_rec_t *alloc_dnrec(const uchar_t *, uchar_t, uchar_t, struct in_addr,
2N/A struct in_addr, lease_t, const char *, const char *);
2N/Aextern dt_rec_list_t *add_dtrec_to_list(dt_rec_t *, dt_rec_list_t *);
2N/Aextern dn_rec_list_t *add_dnrec_to_list(dn_rec_t *, dn_rec_list_t *);
2N/Aextern void free_dtrec(dt_rec_t *);
2N/Aextern void free_dnrec(dn_rec_t *);
2N/Aextern void free_dtrec_list(dt_rec_list_t *);
2N/Aextern void free_dnrec_list(dn_rec_list_t *);
2N/Aextern const char *dhcpsvc_errmsg(uint_t);
2N/A
2N/A/*
2N/A * The remaining functions are not directly callable by the libdhcpsvc
2N/A * implementation; don't expose them to it.
2N/A */
2N/A#ifndef _DHCPSVC_IMPL
2N/A
2N/A/*
2N/A * Generic Service Provider Layer API provided by data store implementor
2N/A */
2N/Aextern int status(const char *);
2N/Aextern int version(int *);
2N/Aextern int configure(const char *);
2N/Aextern int mklocation(const char *);
2N/A
2N/A/*
2N/A * dhcptab Service Provider Layer API
2N/A */
2N/Aextern int list_dt(const char *, char ***, uint_t *);
2N/Aextern int open_dt(void **, const char *, uint_t);
2N/Aextern int close_dt(void **);
2N/Aextern int add_dt(void *, dt_rec_t *);
2N/Aextern int remove_dt(const char *);
2N/Aextern int modify_dt(void *, const dt_rec_t *, dt_rec_t *);
2N/Aextern int delete_dt(void *, const dt_rec_t *);
2N/Aextern int lookup_dt(void *, boolean_t, uint_t, int,
2N/A const dt_rec_t *, dt_rec_list_t **, uint_t *);
2N/A/*
2N/A * DHCP Network Service Provider Layer API
2N/A * IP address arguments are host order.
2N/A */
2N/Aextern int list_dn(const char *, char ***, uint_t *);
2N/Aextern int open_dn(void **, const char *, uint_t, const struct in_addr *,
2N/A const struct in_addr *);
2N/Aextern int close_dn(void **);
2N/Aextern int add_dn(void *, dn_rec_t *);
2N/Aextern int remove_dn(const char *, const struct in_addr *);
2N/Aextern int modify_dn(void *, const dn_rec_t *, dn_rec_t *);
2N/Aextern int delete_dn(void *, const dn_rec_t *);
2N/Aextern int lookup_dn(void *, boolean_t, uint_t, int,
2N/A const dn_rec_t *, dn_rec_list_t **, uint_t *);
2N/A#endif
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* !_DHCP_SVC_PUBLIC_H */