The API functions described in this section are used to manipulate the DHCP network containers and the IP address records within them.
To return a list of network containers.
int list_dn(const char *location, char ***listppp, uint_t *count);
Produces 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.
DSVC_SUCCESS, DSVC_ACCESS, DSVC_NO_LOCATION.
To open a network container or create a new one.
int open_dn(void **handpp, const char *location, uint_t flags, const struct in_addr *netp, const struct in_addr *maskp);
Opens 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.
DSVC_SUCCESS, DSVC_EXISTS, DSVC_ACCESS, DSVC_NOENT, DSVC_NO_LOCATION, DSVC_BUSY, DSVC_INTERNAL, DSVC_UNSUPPORTED.
To perform a lookup query for records in a DHCP network container.
int 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);
Searches 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.
DSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_INTERNAL.
To add a record to the DHCP network container.
int add_dn(void *handp, dn_rec_t *newp);
Adds 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.
DSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_INTERNAL, DSVC_EXISTS.
To modify a record in a DHCP network container.
int modify_dn(void *handp, const dn_rec_t *origp, dn_rec_t *newp);
Atomically 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.
DSVC_SUCCESS, DSVC_ACCESS, DSVC_BUSY, DSVC_COLLISION, DSVC_INTERNAL, DSVC_NOENT.
To delete a record from a DHCP network container.
int delete_dn(void *handp, const dn_rec_t *pnp);
Deletes 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.
DSVC_SUCCESS, DSVC_ACCESS, DSVC_NOENT, DSVC_BUSY, DSVC_INTERNAL, DSVC_COLLISION.
To close the network container.
int close_dn(void **handpp);
Frees the instance handle and cleans up per-instance state.
DSVC_SUCCESS, DSVC_ACCESS, DSVC_INTERNAL.
To delete the DHCP network container from the data store location.
int remove_dn(const char *location, const struct in_addr *netp);
Removes DHCP network container netp (host order) in location.
DSVC_SUCCESS, DSVC_ACCESS, DSVC_NOENT, DSVC_NO_LOCATION, DSVC_BUSY, DSVC_INTERNAL.