1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright (c) 2001 by Sun Microsystems, Inc. 24*0Sstevel@tonic-gate * All rights reserved. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _DHCP_SVC_PRIVATE_H 28*0Sstevel@tonic-gate #define _DHCP_SVC_PRIVATE_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate /* 33*0Sstevel@tonic-gate * Contains SMI-private interfaces to DHCP data service. DO NOT SHIP! 34*0Sstevel@tonic-gate */ 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate #ifdef __cplusplus 37*0Sstevel@tonic-gate extern "C" { 38*0Sstevel@tonic-gate #endif 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate #include <sys/types.h> 41*0Sstevel@tonic-gate #include <stddef.h> 42*0Sstevel@tonic-gate #include <dhcp_svc_confopt.h> 43*0Sstevel@tonic-gate #include <dhcp_svc_public.h> 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate #define DSVC_PRIVATE_VERSION 1 /* Version of private layer API */ 46*0Sstevel@tonic-gate #define DSVC_MODULE_DIR "/usr/lib/inet/dhcp/svc" 47*0Sstevel@tonic-gate #define DSVC_PUBLIC_PREFIX "ds" 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate /* 50*0Sstevel@tonic-gate * Public (service provider) layer definitions at boundary with private layer. 51*0Sstevel@tonic-gate */ 52*0Sstevel@tonic-gate typedef int (*dsvc_splfuncp_t)(); 53*0Sstevel@tonic-gate 54*0Sstevel@tonic-gate typedef struct { 55*0Sstevel@tonic-gate dsvc_splfuncp_t status; 56*0Sstevel@tonic-gate dsvc_splfuncp_t version; 57*0Sstevel@tonic-gate dsvc_splfuncp_t mklocation; 58*0Sstevel@tonic-gate dsvc_splfuncp_t list_dt; 59*0Sstevel@tonic-gate dsvc_splfuncp_t open_dt; 60*0Sstevel@tonic-gate dsvc_splfuncp_t close_dt; 61*0Sstevel@tonic-gate dsvc_splfuncp_t remove_dt; 62*0Sstevel@tonic-gate dsvc_splfuncp_t lookup_dt; 63*0Sstevel@tonic-gate dsvc_splfuncp_t add_dt; 64*0Sstevel@tonic-gate dsvc_splfuncp_t modify_dt; 65*0Sstevel@tonic-gate dsvc_splfuncp_t delete_dt; 66*0Sstevel@tonic-gate dsvc_splfuncp_t list_dn; 67*0Sstevel@tonic-gate dsvc_splfuncp_t open_dn; 68*0Sstevel@tonic-gate dsvc_splfuncp_t close_dn; 69*0Sstevel@tonic-gate dsvc_splfuncp_t remove_dn; 70*0Sstevel@tonic-gate dsvc_splfuncp_t lookup_dn; 71*0Sstevel@tonic-gate dsvc_splfuncp_t add_dn; 72*0Sstevel@tonic-gate dsvc_splfuncp_t modify_dn; 73*0Sstevel@tonic-gate dsvc_splfuncp_t delete_dn; 74*0Sstevel@tonic-gate } dsvc_splapi_t; 75*0Sstevel@tonic-gate 76*0Sstevel@tonic-gate #define DSVC_NSPLFUNCS (sizeof (dsvc_splapi_t) / sizeof (dsvc_splfuncp_t)) 77*0Sstevel@tonic-gate #define DSVC_CUR_CONVER (-1) /* magic "get the current version" token */ 78*0Sstevel@tonic-gate 79*0Sstevel@tonic-gate typedef struct { 80*0Sstevel@tonic-gate char *d_resource; /* datastore name; e.g. "SUNWfiles" */ 81*0Sstevel@tonic-gate char *d_location; /* location of datastore containers */ 82*0Sstevel@tonic-gate char *d_config; /* datastore-specific config data */ 83*0Sstevel@tonic-gate int d_conver; /* container version */ 84*0Sstevel@tonic-gate } dsvc_datastore_t; 85*0Sstevel@tonic-gate 86*0Sstevel@tonic-gate /* 87*0Sstevel@tonic-gate * Container types. 88*0Sstevel@tonic-gate */ 89*0Sstevel@tonic-gate typedef enum { 90*0Sstevel@tonic-gate DSVC_DHCPTAB, 91*0Sstevel@tonic-gate DSVC_DHCPNETWORK 92*0Sstevel@tonic-gate } dsvc_contype_t; 93*0Sstevel@tonic-gate 94*0Sstevel@tonic-gate /* 95*0Sstevel@tonic-gate * Container ID: so far just the network and netmask for DSVC_DHCPNETWORK 96*0Sstevel@tonic-gate * containers, but may include more information in the future. 97*0Sstevel@tonic-gate */ 98*0Sstevel@tonic-gate typedef struct { 99*0Sstevel@tonic-gate struct in_addr c_net; /* network number */ 100*0Sstevel@tonic-gate struct in_addr c_mask; /* netmask */ 101*0Sstevel@tonic-gate } dsvc_conid_t; 102*0Sstevel@tonic-gate 103*0Sstevel@tonic-gate struct dsvc_synch_ops; /* forward declaration */ 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate /* 106*0Sstevel@tonic-gate * Per-handle synchronization information, used when modules require 107*0Sstevel@tonic-gate * private-layer synchronization. 108*0Sstevel@tonic-gate */ 109*0Sstevel@tonic-gate typedef struct { 110*0Sstevel@tonic-gate dsvc_datastore_t *s_datastore; /* datastore backpointer */ 111*0Sstevel@tonic-gate char s_loctoken[MAXPATHLEN]; 112*0Sstevel@tonic-gate char *s_conname; /* container name */ 113*0Sstevel@tonic-gate boolean_t s_nonblock; /* container opened NONBLOCK */ 114*0Sstevel@tonic-gate struct dsvc_synch_ops *s_ops; /* pointer to ops vector */ 115*0Sstevel@tonic-gate void *s_data; /* synch-layer private data */ 116*0Sstevel@tonic-gate } dsvc_synch_t; 117*0Sstevel@tonic-gate 118*0Sstevel@tonic-gate /* 119*0Sstevel@tonic-gate * Synchronization operations; each synchronization strategy must implement 120*0Sstevel@tonic-gate * these operations. Right now, we only have one synchronization strategy, 121*0Sstevel@tonic-gate * but this may change someday. 122*0Sstevel@tonic-gate */ 123*0Sstevel@tonic-gate typedef struct dsvc_synch_ops { 124*0Sstevel@tonic-gate int (*synch_init)(dsvc_synch_t *, unsigned int); 125*0Sstevel@tonic-gate void (*synch_fini)(dsvc_synch_t *); 126*0Sstevel@tonic-gate int (*synch_rdlock)(dsvc_synch_t *, void **); 127*0Sstevel@tonic-gate int (*synch_wrlock)(dsvc_synch_t *, void **); 128*0Sstevel@tonic-gate int (*synch_unlock)(dsvc_synch_t *, void *); 129*0Sstevel@tonic-gate } dsvc_synch_ops_t; 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate #define DSVC_SYNCH_INIT(sp, flags) ((sp)->s_ops->synch_init((sp), (flags))) 132*0Sstevel@tonic-gate #define DSVC_SYNCH_FINI(sp) ((sp)->s_ops->synch_fini((sp))) 133*0Sstevel@tonic-gate #define DSVC_SYNCH_RDLOCK(sp, cp) ((sp)->s_ops->synch_rdlock((sp), (cp))) 134*0Sstevel@tonic-gate #define DSVC_SYNCH_WRLOCK(sp, cp) ((sp)->s_ops->synch_wrlock((sp), (cp))) 135*0Sstevel@tonic-gate #define DSVC_SYNCH_UNLOCK(sp, c) ((sp)->s_ops->synch_unlock((sp), (c))) 136*0Sstevel@tonic-gate 137*0Sstevel@tonic-gate /* 138*0Sstevel@tonic-gate * We divide the dsvc_synchtype_t up into two parts: a strategy part and a 139*0Sstevel@tonic-gate * flags part. Right now, the only flag tells private layer to request 140*0Sstevel@tonic-gate * cross-host synchronization. This is here instead of <dhcp_svc_public.h> 141*0Sstevel@tonic-gate * since it's not a public interface and there's nowhere better to put it. 142*0Sstevel@tonic-gate */ 143*0Sstevel@tonic-gate #define DSVC_SYNCH_FLAGMASK 0xffff0000 144*0Sstevel@tonic-gate #define DSVC_SYNCH_STRATMASK 0x0000ffff 145*0Sstevel@tonic-gate #define DSVC_SYNCH_CROSSHOST 0x00010000 146*0Sstevel@tonic-gate 147*0Sstevel@tonic-gate /* 148*0Sstevel@tonic-gate * Private layer handle, one per open instance of a container. 149*0Sstevel@tonic-gate * Allocated by open_dd(), destroyed by close_dd(). 150*0Sstevel@tonic-gate */ 151*0Sstevel@tonic-gate typedef struct dsvc_handle { 152*0Sstevel@tonic-gate dsvc_datastore_t d_desc; /* datastore descriptor */ 153*0Sstevel@tonic-gate void *d_instance; /* dlopen() instance */ 154*0Sstevel@tonic-gate dsvc_contype_t d_type; /* container type */ 155*0Sstevel@tonic-gate dsvc_conid_t d_conid; /* container id */ 156*0Sstevel@tonic-gate void *d_hand; /* public module handle */ 157*0Sstevel@tonic-gate dsvc_synch_t *d_synch; /* synchronization state */ 158*0Sstevel@tonic-gate dsvc_splapi_t d_api; /* service provider layer API */ 159*0Sstevel@tonic-gate } *dsvc_handle_t; 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate /* 162*0Sstevel@tonic-gate * Quick-n-dirty check for an invalid dsvc_handle_t. 163*0Sstevel@tonic-gate */ 164*0Sstevel@tonic-gate #define DSVC_HANDLE_INVAL(h) ((h) == NULL || (h)->d_instance == NULL || \ 165*0Sstevel@tonic-gate (h)->d_hand == NULL) 166*0Sstevel@tonic-gate 167*0Sstevel@tonic-gate extern int enumerate_dd(char ***, int *); 168*0Sstevel@tonic-gate extern int list_dd(dsvc_datastore_t *, dsvc_contype_t, char ***, uint_t *); 169*0Sstevel@tonic-gate extern int status_dd(dsvc_datastore_t *); 170*0Sstevel@tonic-gate extern int mklocation_dd(dsvc_datastore_t *); 171*0Sstevel@tonic-gate extern int add_dd_entry(dsvc_handle_t, void *); 172*0Sstevel@tonic-gate extern int modify_dd_entry(dsvc_handle_t, const void *, void *); 173*0Sstevel@tonic-gate extern int delete_dd_entry(dsvc_handle_t, void *); 174*0Sstevel@tonic-gate extern int close_dd(dsvc_handle_t *); 175*0Sstevel@tonic-gate extern int remove_dd(dsvc_datastore_t *, dsvc_contype_t, const char *); 176*0Sstevel@tonic-gate extern int open_dd(dsvc_handle_t *, dsvc_datastore_t *, dsvc_contype_t, 177*0Sstevel@tonic-gate const char *, uint_t); 178*0Sstevel@tonic-gate extern int lookup_dd(dsvc_handle_t, boolean_t, uint_t, int, const void *, 179*0Sstevel@tonic-gate void **, uint_t *); 180*0Sstevel@tonic-gate extern void free_dd(dsvc_handle_t, void *); 181*0Sstevel@tonic-gate extern void free_dd_list(dsvc_handle_t, void *); 182*0Sstevel@tonic-gate extern int confopt_to_datastore(dhcp_confopt_t *, dsvc_datastore_t *); 183*0Sstevel@tonic-gate extern int module_synchtype(dsvc_datastore_t *, dsvc_synchtype_t *); 184*0Sstevel@tonic-gate 185*0Sstevel@tonic-gate /* 186*0Sstevel@tonic-gate * Under DEBUG, the DHCP_CONFOPT_ROOT environment variable can be set to 187*0Sstevel@tonic-gate * the path of a directory for the DHCP server to use an alternate root 188*0Sstevel@tonic-gate * for its configuration information and datastores. 189*0Sstevel@tonic-gate */ 190*0Sstevel@tonic-gate #ifdef DEBUG 191*0Sstevel@tonic-gate #define DHCP_CONFOPT_ROOT ((getenv("DHCP_CONFOPT_ROOT") != NULL) ? \ 192*0Sstevel@tonic-gate getenv("DHCP_CONFOPT_ROOT") : "") 193*0Sstevel@tonic-gate #else 194*0Sstevel@tonic-gate #define DHCP_CONFOPT_ROOT "" 195*0Sstevel@tonic-gate #endif 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate #ifdef __cplusplus 198*0Sstevel@tonic-gate } 199*0Sstevel@tonic-gate #endif 200*0Sstevel@tonic-gate 201*0Sstevel@tonic-gate #endif /* !_DHCP_SVC_PRIVATE_H */ 202