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) 2010, 2012, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A/*
2N/A * This file contains hidden implementation structures and APIs of libnwam,
2N/A * and is not installed in the proto area. Implementation is MT safe.
2N/A */
2N/A
2N/A
2N/A#ifndef _LIBNWAM_IMPL_H
2N/A#define _LIBNWAM_IMPL_H
2N/A
2N/A#ifdef __cplusplus
2N/Aextern "C" {
2N/A#endif
2N/A
2N/A#include <libnetcfg.h>
2N/A#include <libnwam_priv.h>
2N/A#include <libnwam.h>
2N/A
2N/A/*
2N/A * We separate global flags (which are applicable to all object types) from
2N/A * local flags (which only apply to specific object types). These definitions
2N/A * mask off the global vs. local portions of the flags value, with the former
2N/A * being the low-order 32 bits and the latter the high-order 32 bits.
2N/A */
2N/A#define NWAM_FLAG_GLOBAL_MASK 0xFFFFFFFF
2N/A#define NWAM_FLAG_LOCAL_MASK 0xFFFFFFFFULL << 32
2N/A#define NWAM_WALK_FILTER_MASK NWAM_FLAG_LOCAL_MASK
2N/A
2N/A/* filenames to store nwam objects */
2N/A#define NWAM_CONF_DIR "/etc/nwam/"
2N/A#define NWAM_LOC_CONF_FILE NWAM_CONF_DIR "loc.conf"
2N/A#define NWAM_ENM_CONF_FILE NWAM_CONF_DIR "enm.conf"
2N/A#define NWAM_KNOWN_WLAN_CONF_FILE NWAM_CONF_DIR "known-wlan.conf"
2N/A
2N/A/* new filename for NCPs is ncp.conf, old was ncp-<profile>.conf */
2N/A#define NWAM_NCP_CONF_FILE NWAM_CONF_DIR "ncp.conf"
2N/A/* link NCUs are stored in /etc/dladm/datalink-<profile>.conf */
2N/A#define NWAM_DATALINK_CONF_FILE_PRE "/etc/dladm/datalink-"
2N/A/* interface NCUs are stored in /etc/ipadm/ipadm-<profile>.conf */
2N/A#define NWAM_IPADM_CONF_FILE_PRE "/etc/ipadm/ipadm-"
2N/A#define NWAM_CONF_FILE_SUF ".conf"
2N/A
2N/A#define NWAM_NCU_LINK_NAME_PRE "link:"
2N/A#define NWAM_NCU_INTERFACE_NAME_PRE "interface:"
2N/A
2N/Astruct nwam_handle {
2N/A nwam_object_type_t nwh_object_type;
2N/A char nwh_name[NWAM_MAX_NAME_LEN];
2N/A boolean_t nwh_committed;
2N/A nvlist_t *nwh_data;
2N/A};
2N/A
2N/Astruct nwam_value {
2N/A nwam_value_type_t nwv_value_type;
2N/A uint_t nwv_value_numvalues;
2N/A union {
2N/A boolean_t *nwv_boolean;
2N/A int64_t *nwv_int64;
2N/A uint64_t *nwv_uint64;
2N/A char **nwv_string;
2N/A } nwv_values;
2N/A};
2N/A
2N/A/* Used in property table retrieval of property attributes */
2N/A#define NWAM_TYPE_ANY 1
2N/A#define NWAM_CLASS_ANY 1
2N/A
2N/Atypedef nwam_error_t (*nwam_prop_validate_func_t)(nwam_value_t);
2N/A
2N/A/* Used to hold validation/description data for properties */
2N/Astruct nwam_prop_table_entry {
2N/A const char *prop_name;
2N/A nwam_value_type_t prop_type;
2N/A boolean_t prop_is_readonly;
2N/A uint_t prop_min_numvalues;
2N/A uint_t prop_max_numvalues;
2N/A nwam_prop_validate_func_t prop_validate;
2N/A const char *prop_description;
2N/A uint64_t prop_type_membership;
2N/A uint64_t prop_class_membership;
2N/A};
2N/A
2N/Astruct nwam_prop_table {
2N/A uint_t num_entries;
2N/A struct nwam_prop_table_entry *entries;
2N/A};
2N/A
2N/A/* Definitions that are used to map uint64 property values to strings */
2N/A
2N/A#define NWAM_MGMT_TYPE_REACTIVE_STRING "reactive"
2N/A#define NWAM_MGMT_TYPE_FIXED_STRING "fixed"
2N/A
2N/A#define NWAM_ACTIVATION_MODE_MANUAL_STRING "manual"
2N/A#define NWAM_ACTIVATION_MODE_SYSTEM_STRING "system"
2N/A#define NWAM_ACTIVATION_MODE_PRIORITIZED_STRING "prioritized"
2N/A#define NWAM_ACTIVATION_MODE_CONDITIONAL_ANY_STRING "conditional-any"
2N/A#define NWAM_ACTIVATION_MODE_CONDITIONAL_ALL_STRING "conditional-all"
2N/A
2N/A#define NWAM_CONDITION_IS_STRING "is"
2N/A#define NWAM_CONDITION_IS_NOT_STRING "is-not"
2N/A#define NWAM_CONDITION_IS_IN_RANGE_STRING "is-in-range"
2N/A#define NWAM_CONDITION_IS_NOT_IN_RANGE_STRING "is-not-in-range"
2N/A#define NWAM_CONDITION_CONTAINS_STRING "contains"
2N/A#define NWAM_CONDITION_DOES_NOT_CONTAIN_STRING "does-not-contain"
2N/A
2N/A#define NWAM_CONDITION_OBJECT_TYPE_NCP_STRING "ncp"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_NCU_STRING "ncu"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_ENM_STRING "enm"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_LOC_STRING "loc"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_IP_ADDRESS_STRING "ip-address"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_ADV_DOMAIN_STRING "advertised-domain"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_SYS_DOMAIN_STRING "system-domain"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_ESSID_STRING "essid"
2N/A#define NWAM_CONDITION_OBJECT_TYPE_BSSID_STRING "bssid"
2N/A
2N/A#define NWAM_CONDITION_ACTIVE_STRING "active"
2N/A
2N/A#define NWAM_NAMESERVICES_DNS_STRING "dns"
2N/A#define NWAM_NAMESERVICES_FILES_STRING "files"
2N/A#define NWAM_NAMESERVICES_NIS_STRING "nis"
2N/A#define NWAM_NAMESERVICES_LDAP_STRING "ldap"
2N/A
2N/A#define NWAM_CONFIGSRC_MANUAL_STRING "manual"
2N/A#define NWAM_CONFIGSRC_DHCP_STRING "dhcp"
2N/A
2N/A#define NWAM_NCU_TYPE_LINK_STRING "link"
2N/A#define NWAM_NCU_TYPE_INTERFACE_STRING "interface"
2N/A
2N/A#define NWAM_IP_VERSION_IPV4_STRING "ipv4"
2N/A#define NWAM_IP_VERSION_IPV6_STRING "ipv6"
2N/A
2N/A#define NWAM_ADDRSRC_DHCP_STRING "dhcp"
2N/A#define NWAM_ADDRSRC_AUTOCONF_STRING "autoconf"
2N/A#define NWAM_ADDRSRC_STATIC_STRING "static"
2N/A
2N/A#define NWAM_PRIORITY_MODE_EXCLUSIVE_STRING "exclusive"
2N/A#define NWAM_PRIORITY_MODE_SHARED_STRING "shared"
2N/A#define NWAM_PRIORITY_MODE_ALL_STRING "all"
2N/A
2N/A/*
2N/A * Functions that interact with nwamd's door server to request
2N/A * object actions, states or to register for receipt of events from nwamd.
2N/A * See libnwam_door.c.
2N/A */
2N/Aextern nwam_error_t nwam_request_register_unregister(nwam_request_type_t,
2N/A const char *);
2N/Aextern nwam_error_t nwam_request_action(nwam_object_type_t, const char *,
2N/A const char *, nwam_action_t);
2N/Aextern nwam_error_t nwam_request_state(nwam_object_type_t, const char *,
2N/A const char *, nwam_state_t *, nwam_aux_state_t *);
2N/Aextern nwam_error_t nwam_request_wlan(nwam_request_type_t, const char *,
2N/A const char *, const char *, uint32_t, uint_t, const char *, boolean_t);
2N/Aextern nwam_error_t nwam_request_wlan_scan_results(const char *name,
2N/A uint_t *, nwam_wlan_t **);
2N/Aextern nwam_error_t nwam_request_active_priority_group(int64_t *);
2N/A
2N/A/*
2N/A * Utility functions for nwam data (values and lists of values) associated
2N/A * with objects - see libnwam_values.c.
2N/A */
2N/Anwam_error_t nwam_alloc_object_list(void *);
2N/Avoid nwam_free_object_list(void *);
2N/Anwam_error_t nwam_dup_object_list(void *, void *);
2N/Anwam_error_t nwam_next_object_prop(void *, char *, char **, nwam_value_t *);
2N/A
2N/Aextern const char *nwam_value_type_to_string(nwam_value_type_t);
2N/Aextern nwam_value_type_t nwam_string_to_value_type(const char *);
2N/Aextern nwam_error_t nwam_delete_prop(void *, const char *);
2N/Aextern nwam_error_t nwam_set_prop_value(void *, const char *, nwam_value_t);
2N/Aextern nwam_error_t nwam_get_prop_value(void *, const char *, nwam_value_t *);
2N/A
2N/A/*
2N/A * Utility functions for nwam objects (NCUs, ENMs, locations and known WLANs).
2N/A * See libnwam_object.c.
2N/A */
2N/Anwam_error_t nwam_handle_create(nwam_object_type_t, const char *,
2N/A struct nwam_handle **);
2N/Anwam_error_t nwam_read(nwam_object_type_t, const char *, const char *,
2N/A uint64_t, struct nwam_handle **);
2N/Anwam_error_t nwam_create(nwam_object_type_t, const char *, const char *,
2N/A struct nwam_handle **);
2N/Anwam_error_t nwam_lists_to_handle(nvlist_t *, nvlist_t *, nwam_object_type_t,
2N/A struct nwam_handle **);
2N/Anwam_error_t nwam_get_name(struct nwam_handle *, char **);
2N/Anwam_error_t nwam_set_name(struct nwam_handle *, const char *);
2N/Anwam_error_t nwam_walk(const char *, netcfg_walkcb_t *, void *, uint64_t,
2N/A int *, netcfg_selectcb_t *);
2N/Avoid nwam_free(struct nwam_handle *, boolean_t);
2N/Anwam_error_t nwam_copy(const char *, struct nwam_handle *, const char *,
2N/A struct nwam_handle **);
2N/Anwam_error_t nwam_walk_props(struct nwam_handle *,
2N/A int(*)(const char *, nwam_value_t, void *), void *, uint64_t, int *);
2N/Anwam_error_t nwam_commit(const char *, struct nwam_handle *, uint64_t);
2N/Anwam_error_t nwam_destroy(const char *, struct nwam_handle *, uint64_t);
2N/Anwam_error_t nwam_enable(const char *, struct nwam_handle *);
2N/Anwam_error_t nwam_disable(const char *, struct nwam_handle *);
2N/Anwam_error_t nwam_offline(const char *, struct nwam_handle *);
2N/Anwam_error_t nwam_online(const char *, struct nwam_handle *);
2N/Astruct nwam_prop_table_entry *nwam_get_prop_table_entry(struct nwam_prop_table,
2N/A const char *);
2N/Anwam_error_t nwam_get_prop_description(struct nwam_prop_table, const char *,
2N/A const char **);
2N/Anwam_error_t nwam_get_prop_type(struct nwam_prop_table, const char *,
2N/A nwam_value_type_t *);
2N/Anwam_error_t nwam_prop_multivalued(struct nwam_prop_table, const char *,
2N/A boolean_t *);
2N/Anwam_error_t nwam_prop_read_only(struct nwam_prop_table, const char *,
2N/A boolean_t *);
2N/Anwam_error_t nwam_validate_prop(struct nwam_prop_table, struct nwam_handle *,
2N/A const char *, nwam_value_t);
2N/Anwam_error_t nwam_validate(struct nwam_prop_table, struct nwam_handle *,
2N/A const char **);
2N/Anwam_error_t nwam_get_default_proplist(struct nwam_prop_table, uint64_t,
2N/A uint64_t, const char ***, uint_t *);
2N/Anwam_error_t nwam_get_state(const char *, struct nwam_handle *, nwam_state_t *,
2N/A nwam_aux_state_t *);
2N/A
2N/A/*
2N/A * Generic validation functions - see libnwam_util.c.
2N/A */
2N/Aextern nwam_error_t nwam_valid_flags(uint64_t, uint64_t);
2N/Aextern nwam_error_t nwam_valid_condition(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_boolean(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_uint64(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_domain(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_host_any(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_host_v4(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_route_v4(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_host_v6(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_route_v6(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_host_or_domain(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_file(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_fmri(nwam_value_t);
2N/Aextern nwam_error_t nwam_valid_mac_addr(nwam_value_t);
2N/A
2N/A/* Misc. util functions */
2N/Aextern boolean_t nwam_override_readonly(uint64_t);
2N/Aextern nwam_error_t nwam_set_smf_string_property(const char *, const char *,
2N/A const char *, const char *);
2N/Aextern nwam_error_t nwam_get_smf_string_property(const char *, const char *,
2N/A const char *, char **);
2N/Aextern int nwam_make_door_call(const char *, int *, void *, size_t);
2N/Aextern nwam_error_t nwam_errno_to_nwam_error(int);
2N/Aextern nwam_error_t netcfg_error_to_nwam_error(netcfg_error_t);
2N/A
2N/Aextern char *nwam_ncp_name_from_dbname(const char *);
2N/Aextern nwam_ncu_type_t nwam_dbname_to_ncu_type(const char *);
2N/A
2N/A#ifdef __cplusplus
2N/A}
2N/A#endif
2N/A
2N/A#endif /* _LIBNWAM_IMPL_H */