Hallo, dies ist ein Test.
PWD: /www/data-lst1/unixsoft/unixsoft/kaempfer/.public_html
Running in File Mode
Relative path: ./../../../../.././../usr/include/libnetcfg.h
Real path: /usr/include/libnetcfg.h
Zurück
/* * Copyright (c) 2012, 2017, Oracle and/or its affiliates. All rights reserved. */ #ifndef _LIBNETCFG_H #define _LIBNETCFG_H #ifdef __cplusplus extern "C" { #endif #include <libnvpair.h> #include <paths.h> #include <sys/param.h> #include <sys/types.h> #include <syslog.h> #include <ucred.h> /* * libnetcfg error codes */ typedef enum { NETCFG_SUCCESS, /* No error occurred */ NETCFG_EPERM, /* Permission denied */ NETCFG_INVALID_ARG, /* Invalid argument */ NETCFG_EXISTS, /* Object exists */ NETCFG_NOT_FOUND, /* Object not found */ NETCFG_WALK_HALTED, /* Callback halted walk */ NETCFG_NO_MEMORY, /* Insufficient memory */ NETCFG_FAILURE, /* Failure */ NETCFG_NOTSUP, /* Unsupported action */ NETCFG_NEEDS_RETRY /* Need retry */ } netcfg_error_t; #define NETCFG_OBJECT_ID_LIST "object-id-list" #define NETCFG_OBJECT_ID_STRING "object-id-string" #define NETCFG_OBJECT_DB_NAME "object-db-name" #define NETCFG_OBJECT_DB_ZONE "object-db-zone" #define NETCFG_OBJECT_RAWLINE "object-rawline" #define NETCFG_OBJECT_PGNAME "object-pgname" #define NETCFG_OBJECT_PGTYPE "object-pgtype" #define NETCFG_TMPL_PROP_TYPE "type" #define NETCFG_TMPL_PROP_DESCRIPTION "description" #define NETCFG_TMPL_VAL_DESCRIPTION "value-description" #define NETCFG_OBJECT_PGNAME_SEP "/" /* Flags used when reading db. */ #define NETCFG_DB_MATCH_EXACT_FLAG 0x00000001 #define NETCFG_DB_ALLPROPS_FLAG 0x00000002 /* Flags used when opening db. */ #define NETCFG_DB_CASE_SENSITIVE_FLAG 0x00000002 #define NETCFG_DB_TEMPORARY_FLAG 0x00000004 #define NETCFG_DB_FLAGS \ (NETCFG_DB_CASE_SENSITIVE_FLAG | NETCFG_DB_TEMPORARY_FLAG) #define NETCFG_IDLIST_NAME_IS_PGTYPE_REF(name) \ (strcmp(name, NETCFG_OBJECT_PGTYPE) == 0) /* Delimiter denotes nesting for object-pgname, e.g. a/b/c */ #define NETCFG_PG_DELIM_STR "/" #define NETCFG_PG_DELIM_CHAR '/' /* Wildcard can be used to match either any pg type or suffix. */ #define NETCFG_PG_WILDCARD_STR "*" /* Maximum number of retries for retry thread (see libnetcfg.c) */ #define NETCFG_MAX_NUM_RETRIES 100 /* opaque backend database command type */ struct netcfg_db_cmds; typedef struct netcfg_db_cmds *netcfg_db_cmds_t; /* Forward definition */ struct netcfg_db; typedef struct netcfg_db *netcfg_db_t; /* Export database functions for SMF, files, raw files and doors. */ extern netcfg_db_cmds_t netcfg_smf_db_cmds; extern netcfg_db_cmds_t netcfg_files_db_cmds; extern netcfg_db_cmds_t netcfg_rawfiles_db_cmds; extern netcfg_db_cmds_t netcfg_doors_db_cmds; /* Logging functions. */ extern void netcfg_log_open(const char *); extern void netcfg_log(int, const char *, ...); extern void netcfg_log_fmt(int, char *); extern void netcfg_log_close(void); #define NETCFG_LOG_ENVVAR "NETCFG_LOG" #define NETCFG_LOG_MSGLOG "msglog" #define NETCFG_LOG_SYSLOG "syslog" #define NETCFG_LOG_STDERR "stderr" /* * The following structures are used to support converting a proplist * containing enumerated values (stored as uint64s) to strings and vice * versa. The relevant functions netcfg_proplist_convert_to_persist() and * netcfg_proplist_convert_from_persist() are useful when converting properties * from a human-readable datastore to their native enumerated types and * vice-versa. Consumers pass in a proplist for modification with an array of * structures that contain a netcfg_propdesc_t as their first element, and also * pass in the size of that containing structure so we can traverse the array * picking out the netcfg_propdesc_t values. Each of the property descriptions * specifies an array of netcfg_valdesc_t. These values descriptions contain * string/value mappings. */ /* * An array of valdescs should be terminated with an empty valdesc, i.e. * { NULL, NULL, 0 }, defined below as "NETCFG_VALDESC_END". */ typedef struct netcfg_valdesc { char *nvd_name; char *nvd_description; uint64_t nvd_val; /* can be ptr or int depending */ /* on contect of property */ } netcfg_valdesc_t; /* * Some legacy numeric values signify "this value is not set". Rather than * persisting such values unnecessarily, we use the special nvd_name * NETCFG_VALUE_UNSET - if the associated numeric value is specified * prior to upgrade, post-upgrade we skip setting the value. One example * is the VNIC datalink attribute "vraf" - if set to 0, this implies vraf * is not specified. So we create a netcfg_valdesc_t which maps 0 to * NETCFG_VALUE_NAME_UNSET, and we skip persisting the value. */ #define NETCFG_VALUE_UNSET "?" #define NETCFG_VALDESC_END { NULL, NULL, 0 } #define NETCFG_VALDESC_NULL NETCFG_VALDESC_END #define NETCFG_VALDESC_EMPTY { "", "", 0 } /* Special nvd_val values denoting a value is to be reset/unset. */ #define NETCFG_RESET_VAL ((uint64_t)-1) #define NETCFG_UNSET_VAL ((uint64_t)-2) /* Flags for npd_flags */ /* * Values can be logically OR-ed together, e.g aggregation policies, and * uint64 representation will be expanded into multi-valued strings for each * value, e.g. AGGR_POLICY_L2 | AGGR_POLICY_L3 -> "L2", "L3" values. */ #define NETCFG_PROPDESC_BITFIELD_VALUE 0x1 /* * The value's representation is a string which is internally separated * with the delimiter provided in npd_delimiter. An example is the * ports field of a datalink aggregation - in libdladm the set of ports are * represented as a single string using ":" to delimit, e.g. "net1:net2:". * For persistence we wish to convert to a multiple-valued set of strings, * and vice-versa when converting back. */ #define NETCFG_PROPDESC_INTERNALLY_SEPARATED_VALUE 0x2 /* * Do not convert values - in this case we wish to express that the value * list comprise to possible set of string values, but we do not have * associated internal values other than the string representations. * Used in libipadm. */ #define NETCFG_PROPDESC_USE_STRING_VALUE 0x4 /* * An array of propdescs should be terimated with an empty propdesc, i.e. * { NULL, NULL, 0, 0, 0, 0, 0, 0, NULL NULL, NULL, NETCFG_VALDESC_END }, * defined below as "NETCFG_PROPDESC_END". */ typedef struct netcfg_propdesc { char *npd_name; char *npd_description; uint64_t npd_type; uint_t npd_min_vals; uint_t npd_max_vals; int64_t npd_min_range; int64_t npd_max_range; uint64_t npd_flags; char *npd_delimiters; netcfg_valdesc_t *npd_legacy_names; netcfg_valdesc_t *npd_vals; uint_t npd_version; netcfg_valdesc_t npd_stability; } netcfg_propdesc_t; #define NETCFG_PROPDESC_END \ { NULL, NULL, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, 0, \ NETCFG_VALDESC_NULL } /* * These definitions allow us to map from the old SMF values to the new * stability levels. See attributes(7). */ #define NETCFG_STABILITY_COMMITTED \ { "Standard", \ "Incompatibilites between Minor releases are exceptional", 0 } #define NETCFG_STABILITY_UNCOMMITTED \ { "Evolving", \ "No committments about stability between Minor releases", 1 } #define NETCFG_STABILITY_VOLATILE \ { "Unstable", \ "Changes can occur at any time and for any reason", 2 } extern netcfg_error_t netcfg_db_open(const char *, zoneid_t, netcfg_db_cmds_t, uint64_t, netcfg_db_t *); extern void netcfg_db_close(netcfg_db_t); netcfg_error_t netcfg_object_create(nvlist_t *, nvlist_t *, nvlist_t **); netcfg_error_t netcfg_object_get(nvlist_t *, nvlist_t **, nvlist_t **); int netcfg_valdescs_count(netcfg_valdesc_t *); /* * netcfg_proplist_convert_to_persist() prepares a property list for write to * the backend database. This involves: * * - Converting any uint64-stored values to associated strings using the * property description elements passed in as an array of structures of * specified size, (each containing a netcfg_propdesc_t as its first member). * - Converting any string values to the desired underlying types, again by * deriving the desired type from the property description elements. */ int netcfg_proplist_convert_to_persist(nvlist_t *proplist, size_t, void *); int netcfg_proplist_convert_from_persist(nvlist_t *proplist, size_t, void *); /* * netcfg_db_*() functions: * * Arguments: * - nvlist of object identifiers, including an optional * NETCFG_OBJECT_DB_NAME value. The additional db name is used in * cases where the dlmgmt_db_t is a door, and the request needs to * be sent to a specific database in the door handler. * - flags * - nvlist specifiying object properties (excluded for remove function) * * netcfg_db_read: sets proplist to point at an nvlist of properties * associated with the object specified in the idlist. * * netcfg_db_write: writes the object identified by idlist and specified * in proplist to the specified db. Replaces an existing entry, if present. * * netcfg_db_rename: in this case, the second nvlist is not a proplist; * instead, it is the new idlist. Finds the object identified by idlist, * and rewrites it to be identified with the new idlist. * * netcfg_db_remove: removes the object identified by idlist from the db. * * netcfg_db_get_object_props: reads the object identified by idlist and fetches * the value[s] of the property or properties included in the prop list, * updating the prop list with the values. If a particular property is * not present, it is removed from the object list. * * netcfg_db_backup: backs up the database specified by the db with named * backup. * * netcfg_db_restore: restores the database from named backup. * * netcfg_db_check_auth: check read or write auth for the db. */ extern netcfg_error_t netcfg_db_read(netcfg_db_t, nvlist_t *, uint64_t, nvlist_t **); extern netcfg_error_t netcfg_db_write(netcfg_db_t, nvlist_t *, uint64_t, nvlist_t *); extern netcfg_error_t netcfg_db_rename(netcfg_db_t, nvlist_t *, uint64_t, nvlist_t *); extern netcfg_error_t netcfg_db_remove(netcfg_db_t, nvlist_t *, uint64_t); extern netcfg_error_t netcfg_db_get_object_props(netcfg_db_t, nvlist_t *, uint64_t, nvlist_t **); extern netcfg_error_t netcfg_db_backup(netcfg_db_t, const char *); extern netcfg_error_t netcfg_db_restore(netcfg_db_t, const char *); extern netcfg_error_t netcfg_db_check_auth(netcfg_db_t, boolean_t); /* * netcfg_db_walk: walks all relevant objects in the database, optionally * sorting them prior to the walk via the qsort(3C)-based sortcb() callback * function. * * An optional idlist can be used to filter results - if the idlist contains a * name-value string pair, only those objects that have that same name-value * pair will be walked. Additionally, wildcard matching is supported by adding * empty string values to the idlist. The walk callback is passed the object's * idlist, property list, the flags passed to netcfg_db_walk() and the * void * argument passed to netcfg_db_walk(). * */ typedef int (netcfg_walkcb_t)(netcfg_db_t, nvlist_t *, nvlist_t *, uint64_t, void *); typedef int (netcfg_sortcb_t)(nvlist_t **, nvlist_t **); extern netcfg_error_t netcfg_db_walk(netcfg_db_t, nvlist_t *, uint64_t, netcfg_walkcb_t *, netcfg_sortcb_t *, void *, int *); /* * Functions to manipulate idlists: * * netcfg_idlist_init: allocates an nvlist, and adds the dbname is specified. * * netcfg_idlist_add: adds the name-value pair specified by the two string * arguments (name followed by value) to the given idlist. * * netcfg_idlist_add_zoneid: add zoneid to idlist. * * netcfg_idlist_get*: retrieve id/dbname/zone * * netcfg_idlist_remove: remove id specified * * netcfg_idlist2idstr: produces the string representation of the given idlist. * * netcfg_idlist_is_empty: returns B_TRUE if no string identifiers present. * */ extern netcfg_error_t netcfg_idlist_init(nvlist_t **, const char *); extern netcfg_error_t netcfg_idlist_add(nvlist_t *, const char *, const char *); extern netcfg_error_t netcfg_idlist_add_zoneid(nvlist_t *, zoneid_t); extern netcfg_error_t netcfg_idlist_get(nvlist_t *, const char *, char **); extern netcfg_error_t netcfg_idlist_get_db_name(nvlist_t *, char **); extern netcfg_error_t netcfg_idlist_get_zoneid(nvlist_t *, zoneid_t *); extern netcfg_error_t netcfg_idlist_remove(nvlist_t *, const char *); extern netcfg_error_t netcfg_idlist2idstr(nvlist_t *, char *); extern boolean_t netcfg_idlist_is_empty(nvlist_t *); /* * All properties are stored as arrays, regardless of the number of elements. * These functions allow callers to extract or add one value from/to an * nvpair in cases where there is known to be a single value in the array. */ extern int netcfg_nvl_get_one_boolean(nvlist_t *, const char *, boolean_t *); extern int netcfg_nvl_get_one_int32(nvlist_t *, const char *, int32_t *); extern int netcfg_nvl_get_one_int64(nvlist_t *, const char *, int64_t *); extern int netcfg_nvl_get_one_uint32(nvlist_t *, const char *, uint32_t *); extern int netcfg_nvl_get_one_uint64(nvlist_t *, const char *, uint64_t *); extern int netcfg_nvl_get_one_string(nvlist_t *, const char *, char **); extern int netcfg_nvp_get_one_boolean(nvpair_t *, boolean_t *); extern int netcfg_nvp_get_one_int32(nvpair_t *, int32_t *); extern int netcfg_nvp_get_one_int64(nvpair_t *, int64_t *); extern int netcfg_nvp_get_one_uint32(nvpair_t *, uint32_t *); extern int netcfg_nvp_get_one_uint64(nvpair_t *, uint64_t *); extern int netcfg_nvp_get_one_string(nvpair_t *, char **); extern int netcfg_nvl_add_one_boolean(nvlist_t *, const char *, boolean_t); extern int netcfg_nvl_add_one_int32(nvlist_t *, const char *, int32_t); extern int netcfg_nvl_add_one_int64(nvlist_t *, const char *, int64_t); extern int netcfg_nvl_add_one_uint32(nvlist_t *, const char *, uint32_t); extern int netcfg_nvl_add_one_uint64(nvlist_t *, const char *, uint64_t); extern int netcfg_nvl_add_one_string(nvlist_t *, const char *, char *); extern const char *netcfg_strerror(netcfg_error_t); extern int netcfg_error2errno(netcfg_error_t); extern char *netcfg_tokenize_by_unescaped_delim(char *, char, char **); extern netcfg_error_t netcfg_doorserver_create(const char *, const char *, const char *, netcfg_db_t, int *); extern void netcfg_doorserver_destroy(const char *, int); extern void netcfg_make_files_obsolete(const char *, const char *); #ifdef __cplusplus } #endif #endif /* _LIBNETCFG_H */