内に含ま
その他のドキュメントサポート リソース | PDF 文書ファイルをダウンロードする (476 KB)
Chapter 3 Service Provider Layer APIThis chapter lists and describes the API functions exported by public modules and consumed by the Framework Configuration Layer. The functions are grouped in sections according to their purpose. Within each section, functions are listed in an order in which you might use them. The following topics are included: All implementations that match a certain Service Provider Layer API version must follow this specification for the API functions they implement. Later versions of the API must be backward-compatible with earlier versions. This means that additional API calls may be added, but existing ones cannot be changed or deleted. See the include file /usr/include/dhcp_svc_public.h for more details about the functions. General Data Store FunctionsThis section lists functions related to general data store activities. configure()PurposeTo pass a configuration string to the data store. Synopsisint configure(const char *configp); DescriptionThe configure() function is optional. If it is provided together with the required public module management bean (see Data Service Configuration and DHCP Management Tools), the Framework Configuration Layer calls this function when the public module loads, and passes in the public-module-specific configuration string, which is cached by the Framework Configuration Layer on the DHCP server for the data store module. ReturnsDSVC_SUCCESS, DSVC_MODULE_CFG_ERR The configure() function returns DSVC_SUCCESS if the module wants the Framework Configuration Layer to continue to load the module, or DSVC_MODULE_CFG_ERR if the module wants the Framework Configuration Layer to fail the loading of the module. An example of such a situation is a configuration string so malformed that the required configuration of the module cannot take place. mklocation()PurposeTo create the directory where the data store containers are to reside. Synopsisint mklocation(const char *location); DescriptionCreates the directory pointed to by location (if the directory does not exist) for data store containers to reside. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_EXISTS, DSVC_BUSY, DSVC_INTERNAL, DSVC_UNSUPPORTED. status()PurposeTo obtain the general status of the data store. Synopsisint status(const char *location); DescriptionThe status() function instructs the data store to return its general status, and if location is non-NULL, further validates the location of the data store container by determining if the container does in fact exist, is accessible, and is formed correctly for the data store type. The data store must return the appropriate error codes if the facilities it needs are unavailable or it is otherwise not ready. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_NO_LOCATION, DSVC_BUSY, DSVC_INTERNAL. version()PurposeTo obtain the version number of the API implemented by the data store. Synopsisint version(int *versionp); DescriptionData stores that support the Service Provider Layer API described in this manual are version 1 (one). The version is returned in the int pointed to by versionp. ReturnsDSVC_SUCCESS, DSVC_INTERNAL, DSVC_MODULE_ERR. dhcptab FunctionsThe API functions described in this section are used with the dhcptab container. list_dt()PurposeTo list the name of the dhcptab container. Synopsisint list_dt(const char *location, char ***listppp, uint_t *count); DescriptionProduces a dynamically allocated list of dhcptab container objects (listppp) found at location and stores the number of list items in count. If no dhcptab container objects exist, then DSVC_SUCCESS is returned, listppp is set to NULL, and count is set to 0. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_NO_LOCATION. open_dt()PurposeTo open a dhcptab container or create a new one. Synopsisint open_dt(void **handpp, const char *location, uint_t flags); DescriptionOpens an existing dhcptab container or creates a new container at location and initializes handp to point to the instance handle. Performs any initialization needed by the data store. When creating a new dhcptab, the caller's identity is used for owner/permissions. Valid flags include DSVC_CREATE, DSVC_READ, DSVC_WRITE, DSVC_NONBLOCK. Note that the creation of a dhcptab container as read-only (DSVC_CREATE | DSVC_READ) is invalid. ReturnsDSVC_SUCCESS, DSVC_EXISTS, DSVC_ACCESS, DSVC_NOENT, DSVC_NO_LOCATION, DSVC_BUSY, DSVC_INTERNAL. lookup_dt()PurposeTo perform a lookup query for records in the dhcptab container. Synopsisint lookup_dt(void *handp, boolean_t partial, uint_t query, int count, const dt_rec_t *targetp, dt_rec_list_t **resultp, uint_t *records); DescriptionSearches the dhcptab container for instances that match the query described by the combination of query and targetp. If the partial argument is B_TRUE, then partial query results are acceptable to the caller. Thus, when partial is B_TRUE, any query that returns at least one matching record is considered successful. When partial is B_FALSE, the query returns DSVC_SUCCESS only if it has been applied to the entire container. The query argument consists of 2 fields, each 16 bits long. The lower 16 bits select which fields {key, type} of targetp are to be considered in the query. The upper 16 bits identify whether a particular field value selected in the lower 16 bits must match (bit set) or not match (bit clear). Bits 2 through 15 in both 16-bit fields are currently unused, and must be set to 0. Useful macros for constructing queries can be found in Example 3–1. The count field specifies the maximum number of matching records to return. A count value of -1 requests the return of all records that match, regardless of the number. A count value of 0 causes lookup_dt to return immediately with no data. resultp is set to point to the returned list of records. If resultp is NULL, then the caller is simply interested in knowing how many records match the query. Note that these records are dynamically allocated, and therefore the caller is responsible for freeing them. lookup_dt() returns the number of matching records in the records argument. A records value of 0 means that no records matched the query. The following example includes macros you might find useful for constructing and manipulating lookup queries for the DHCP network and dhcptab containers. Example 3–1 Useful Macros for Lookup Queries/* * Query macros - used for initializing query fields (lookup_d?) */ /* dhcp network container */ #define DN_QCID 0x0001 #define DN_QCIP 0x0002 #define DN_QSIP 0x0004 #define DN_QLEASE 0x0008 #define DN_QMACRO 0x0010 #define DN_QFDYNAMIC 0x0020 #define DN_QFAUTOMATIC 0x0040 #define DN_QFMANUAL 0x0080 #define DN_QFUNUSABLE 0x0100 #define DN_QFBOOTP_ONLY 0x0200 #define DN_QALL (DN_QCID | DN_QCIP | DN_QSIP | DN_QLEASE | \ DN_QMACRO | DN_QFDYNAMIC DN_QFAUTOMATIC |\ DN_QFMANUAL | DN_QFUNUSABLE | \ DN_QFBOOTP_ONLY) /* dhcptab */ #define DT_DHCPTAB "dhcptab" /* default name of container */ #define DT_QKEY 0x01 #define DT_QTYPE 0x02 #define DT_QALL (DT_QKEY | DT_QTYPE) /* general query macros */ #define DSVC_QINIT(q) ((q) = 0) #define DSVC_QEQ(q, v) ((q) = ((q) | (v) | ((v) << 16))) #define DSVC_QNEQ(q, v) ((q) = ((~(v << 16)) & (q)) | (v))) #define DSVC_QISEQ(q, v) (((q) & (v)) && ((q) & ((v) << 16))) #define DSVC_QISNEQ(q, v) (((q) & (v)) && (!((q) & ((v) << 16)))) /* Examples */ uint_t query; /* search for dhcptab record with key value, but not flags value */ DSVC_QINIT(query); DSVC_QEQ(query, DT_QKEY); DSVC_QNEQ(query, DT_QTYPE); /* search for dhcp network record that matches cid, client ip, server ip. */ DSVC_QINIT(query); DSVC_QEQ(query, (DN_QCID | DN_QCIP | DN_QSIP)); ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_INTERNAL. add_dt()PurposeTo add a record to the dhcptab container. Synopsisint add_dt(void *handp, dt_rec_t *newp); DescriptionAdds the record newp to the dhcptab container referred to by handp. The signature associated with newp is updated by the underlying public module. If an update collision occurs, the data store is not updated. The caller is responsible for freeing any dynamically allocated arguments. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_INTERNAL, DSVC_EXISTS. modify_dt()PurposeTo modify a record in the dhcptab container. Synopsisint modify_dt(void *handp, const dt_rec_t *origp, dt_rec_t *newp); DescriptionAtomically modifies the record origp with the record newp in the dhcptab container referred to by handp. The signature associated with newp is updated by the underlying public module. If an update collision occurs, the data store is not updated. The caller is responsible for freeing any dynamically allocated arguments. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_COLLISION, DSVC_INTERNAL, DSVC_NOENT. delete_dt()PurposeTo delete a record from the dhcptab container. Synopsisint delete_dt(void *handp, const dt_rec_t *dtp); DescriptionDeletes the record identified by the key, type and dt_sig fields of dtp from the dhcptab container referred to by the handle handp. If an update collision occurs, the matching record is not deleted from the data store, and DSVC_COLLISION is returned. The caller is responsible for freeing any dynamically allocated arguments. If the dtp signature (dt_sig) is 0, the matching record is simply deleted with no detection of update collisions. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_NOENT, DSVC_BUSY, DSVC_INTERNAL, DSVC_COLLISION. close_dt()PurposeTo close the dhcptab container. Synopsisint close_dt(void **handpp); DescriptionFrees the instance handle and cleans up per-instance state. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_INTERNAL. remove_dt()PurposeTo delete the dhcptab container from the data store location. Synopsisint remove_dt(const char *location); DescriptionRemoves the dhcptab container in location from the data store. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_NOENT, DSVC_NO_LOCATION, DSVC_BUSY, DSVC_INTERNAL. DHCP Network Container FunctionsThe API functions described in this section are used to manipulate the DHCP network containers and the IP address records within them. list_dn()PurposeTo return a list of network containers. Synopsisint list_dn(const char *location, char ***listppp, uint_t *count); DescriptionProduces a dynamically allocated list of network container objects (listppp) found at location and stores the number of list items in count. If no network container objects exist, then DSVC_SUCCESS is returned, listppp is set to NULL, and count is set to 0.
ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_NO_LOCATION. open_dn()PurposeTo open a network container or create a new one. Synopsisint open_dn(void **handpp, const char *location, uint_t flags, const struct in_addr *netp, const struct in_addr *maskp); DescriptionOpens an existing DHCP network container or creates a new container specified by netp and maskp (both host order) in location and initializes handpp to point to the instance handle. Performs any initialization needed by the data store. When creating a new DHCP network container, the caller's identity is used for owner/permissions. Valid flags include DSVC_CREATE, DSVC_READ, DSVC_WRITE, DSVC_NONBLOCK. Note that the creation of a DHCP network container as read-only (DSVC_CREATE | DSVC_READ) is invalid. ReturnsDSVC_SUCCESS, DSVC_EXISTS, DSVC_ACCESS, DSVC_NOENT, DSVC_NO_LOCATION, DSVC_BUSY, DSVC_INTERNAL, DSVC_UNSUPPORTED. lookup_dn()PurposeTo perform a lookup query for records in a DHCP network container. Synopsisint lookup_dn(void *handp, boolean_t partial, uint_t query, int count, const dn_rec_t *targetp, dn_rec_list_t **resultp, uint_t *records); DescriptionSearches a DHCP network container for instances that match the query described by the combination of query and targetp. If the partial argument is B_TRUE, then partial query results are acceptable to the caller. Thus, when partial is B_TRUE, any query that returns at least one matching record is considered successful. When partial is B_FALSE, the query returns DSVC_SUCCESS only if it has been applied to the entire container. The query argument consists of 2 fields, each 16 bits long. The lower 16 bits select which fields {client id, flags, client IP, server IP, expiration, macro, or comment} of targetp are to be considered in the query. The upper 16 bits identify whether a particular field value selected in the lower 16 bits must match (bit set) or not match (bit clear). Bits 7 through 15 in both 16-bit fields are currently unused, and must be set to 0. Useful macros for constructing queries can be found in Example 3–1. The count field specifies the maximum number of matching records to return. A count value of -1 requests the return of all records that match, regardless of the number. A count value of 0 causes lookup_dn to return immediately with no data. resultp is set to point to the returned list of records. If resultp is NULL, then the caller is simply interested in knowing how many records match the query. Note that these records are dynamically allocated, and therefore the caller is responsible for freeing them. lookup_dn() returns the number of matching records in the records argument. A records value of 0 means that no records matched the query. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_INTERNAL. add_dn()PurposeTo add a record to the DHCP network container. Synopsisint add_dn(void *handp, dn_rec_t *newp); DescriptionAdds the record newp to the DHCP network container referred to by the handle handp. The signature associated with newp is updated by the underlying public module. If an update collision occurs, the data store is not updated. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_INTERNAL, DSVC_EXISTS. modify_dn()PurposeTo modify a record in a DHCP network container. Synopsisint modify_dn(void *handp, const dn_rec_t *origp, dn_rec_t *newp); DescriptionAtomically modifies the record origp with the record newp in the DHCP network container referred to by the handle handp. The signature associated with newp is updated by the underlying public module. If an update collision occurs, the data store is not updated. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_COLLISION, DSVC_INTERNAL, DSVC_NOENT. delete_dn()PurposeTo delete a record from a DHCP network container. Synopsisint delete_dn(void *handp, const dn_rec_t *pnp); DescriptionDeletes the record identified by the dn_cip and dn_sig elements of pnp from the DHCP network container referred to by the handle handp. If an update collision occurs, the matching record is not deleted from the data store and DSVC_COLLISION is returned. If the dn_sig signature of pnp is 0, the matching record is simply deleted with no detection of update collisions. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_NOENT, DSVC_BUSY, DSVC_INTERNAL, DSVC_COLLISION. close_dn()PurposeTo close the network container. Synopsisint close_dn(void **handpp); DescriptionFrees the instance handle and cleans up per-instance state. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_INTERNAL. remove_dn()PurposeTo delete the DHCP network container from the data store location. Synopsisint remove_dn(const char *location, const struct in_addr *netp); DescriptionRemoves DHCP network container netp (host order) in location. ReturnsDSVC_SUCCESS, DSVC_ACCESS, DSVC_NOENT, DSVC_NO_LOCATION, DSVC_BUSY, DSVC_INTERNAL. Generic Error CodesThe Framework Configuration Layer and Service Provider Layer API functions will return the following integer error values. Note that the file /usr/include/dhcp_svc_public.h is the definitive source for these codes. * Standard interface errors
*/
#define DSVC_SUCCESS 0 /* success */
#define DSVC_EXISTS 1 /* object already exists */
#define DSVC_ACCESS 2 /* access denied */
#define DSVC_NO_CRED 3 /* No underlying credential */
#define DSVC_NOENT 4 /* object doesn't exist */
#define DSVC_BUSY 5 /* object temporarily busy (again) */
#define DSVC_INVAL 6 /* invalid argument(s) */
#define DSVC_INTERNAL 7 /* internal data store error */
#define DSVC_UNAVAILABLE 8 /* underlying service required by */
/* public module unavailable */
#define DSVC_COLLISION 9 /* update collision */
#define DSVC_UNSUPPORTED 10 /* operation not supported */
#define DSVC_NO_MEMORY 11 /* operation ran out of memory */
#define DSVC_NO_RESOURCES 12 /* non-memory resources unavailable */
#define DSVC_BAD_RESOURCE 13 /* malformed/missing RESOURCE setting */
#define DSVC_BAD_PATH 14 /* malformed/missing PATH setting */
#define DSVC_MODULE_VERSION 15 /* public module version mismatch */
#define DSVC_MODULE_ERR 16 /* internal public module error */
#define DSVC_MODULE_LOAD_ERR 17 /* error loading public module */
#define DSVC_MODULE_UNLOAD_ERR 18 /* error unloading public module */
#define DSVC_MODULE_CFG_ERR 19 /* module configuration failure */
#define DSVC_SYNCH_ERR 20 /* error in synchronization protocol */
#define DSVC_NO_LOCKMGR 21 /* cannot contact lock manager */
#define DSVC_NO_LOCATION 22 /* location nonexistent */
#define DSVC_BAD_CONVER 23 /* malformed/missing CONVER setting */
#define DSVC_NO_TABLE 24 /* table does not exist */
#define DSVC_TABLE_EXISTS 25 /* table already exists */
#define DSVC_NERR (DSVC_TABLE_EXISTS + 1)
|