libnwam.h revision ab32bdf2f746488f918233b2d8cabd5835efe9f3
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson/*
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * CDDL HEADER START
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson *
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * The contents of this file are subject to the terms of the
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * Common Development and Distribution License (the "License").
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * You may not use this file except in compliance with the License.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson *
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * or http://www.opensolaris.org/os/licensing.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * See the License for the specific language governing permissions
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * and limitations under the License.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson *
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * When distributing Covered Code, include this CDDL HEADER in each
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * If applicable, add the following below this CDDL HEADER, with the
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * fields enclosed by brackets "[]" replaced with your own identifying
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * information: Portions Copyright [yyyy] [name of copyright owner]
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson *
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * CDDL HEADER END
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson/*
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * Use is subject to license terms.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#ifndef _LIBNWAM_H
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#define _LIBNWAM_H
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#include <netinet/in.h>
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson/*
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * This file defines the programming interface for libnwam. It is a private
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * (undocumented, subject to change) interface shared between the NWAM GUI and
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * nwamd.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#ifdef __cplusplus
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern "C" {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#endif
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef struct libnwam_wlan_attr_s {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_essid;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_bssid;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_secmode;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_strength;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_mode;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_speed;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_auth;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wla_bsstype;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson int wla_channel;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_wlan_attr_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson/* Number of strings above; used for internal allocation purposes */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#define WLA_NUM_STRS 8
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson/*
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * The descriptive event types shared with nwamd and with the GUI client. With
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * all events other than deInitial, led_interface is always valid. The other
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson * fields are present when indicated, and otherwise must be left unused.
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef enum libnwam_descr_evtype_e {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deInitial, /* no other fields; new active client */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deInterfaceUp, /* led_v4address led_prefixlen */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deInterfaceDown, /* led_cause */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deInterfaceAdded,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deInterfaceRemoved,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deWlanConnectFail,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deWlanDisconnect, /* led_wlan */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deWlanConnected, /* led_wlan */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deLLPSelected,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deLLPUnselected, /* led_cause */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deULPActivated,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deULPDeactivated,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deScanChange,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deScanSame,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deWlanKeyNeeded, /* led_wlan */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson deWlanSelectionNeeded
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_descr_evtype_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef enum libnwam_diag_cause_e {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcNone = 0, /* no cause */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcDHCP, /* DHCP left interface down or with zero addr */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcTimer, /* gave up on DHCP; switching to next best */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcUnplugged, /* interface lost RUNNING flag */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcUser, /* user changed priority */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcBetter, /* higher-priority interface became RUNNING */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcNewAP, /* scan completed on higher-priority i/f */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcGone, /* periodic wireless scan showed disconnect */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcFaded, /* periodic scan showed "very weak" signal */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcAllDown, /* all-but-one taken down (initial LLP) */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcUnwanted, /* another higher-priority interface is up */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcShutdown, /* daemon is being shut down */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcSelect, /* different AP selected (forced down/up) */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcRemoved, /* interface removed from system */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson dcFailed /* interface bring-up failed */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_diag_cause_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef struct libnwam_event_data_s {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson libnwam_descr_evtype_t led_type;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson libnwam_diag_cause_t led_cause;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson struct in_addr led_v4address; /* deInterfaceUp only */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson int led_prefixlen; /* deInterfaceUp only */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson libnwam_wlan_attr_t led_wlan;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson char *led_interface;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_event_data_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef enum libnwam_ipv4src_e {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson IPV4SRC_STATIC,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson IPV4SRC_DHCP
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_ipv4src_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef enum libnwam_interface_type_e {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson IF_UNKNOWN,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson IF_WIRED,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson IF_WIRELESS,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson IF_TUN
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_interface_type_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef struct libnwam_llp_s {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *llp_interface;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson int llp_pri; /* lower number => higher priority */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson libnwam_interface_type_t llp_type;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson libnwam_ipv4src_t llp_ipv4src;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t llp_primary; /* selected primary interface */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t llp_locked; /* selected is locked */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t llp_link_failed; /* unusable due to link failure */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t llp_dhcp_failed; /* unusable due to DHCP failure */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t llp_link_up; /* datalink layer is up */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t llp_need_wlan; /* wlan/AP not yet selected */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t llp_need_key; /* wlan key not set */
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_llp_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef struct libnwam_wlan_s {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson libnwam_wlan_attr_t wlan_attrs;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *wlan_interface;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t wlan_known;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t wlan_haskey;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t wlan_connected;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_wlan_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsontypedef struct libnwam_known_ap_s {
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *ka_essid;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *ka_bssid;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson boolean_t ka_haskey;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson} libnwam_known_ap_t;
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern libnwam_event_data_t *libnwam_wait_event(void);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern void libnwam_free_event(libnwam_event_data_t *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern libnwam_llp_t *libnwam_get_llp_list(uint_t *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern void libnwam_free_llp_list(libnwam_llp_t *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_set_llp_priority(const char *, int);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_lock_llp(const char *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern libnwam_wlan_t *libnwam_get_wlan_list(uint_t *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern void libnwam_free_wlan_list(libnwam_wlan_t *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern libnwam_known_ap_t *libnwam_get_known_ap_list(uint_t *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern void libnwam_free_known_ap_list(libnwam_known_ap_t *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_add_known_ap(const char *, const char *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_delete_known_ap(const char *, const char *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_select_wlan(const char *, const char *, const char *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_wlan_key(const char *, const char *, const char *,
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson const char *);
ab32bdf2f746488f918233b2d8cabd5835efe9f3James Carlson#pragma weak libnwam_wlan_key_secmode
ab32bdf2f746488f918233b2d8cabd5835efe9f3James Carlsonextern int libnwam_wlan_key_secmode(const char *, const char *, const char *,
ab32bdf2f746488f918233b2d8cabd5835efe9f3James Carlson const char *, const char *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_start_rescan(const char *);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_fini(void);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlsonextern int libnwam_init(int);
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#ifdef __cplusplus
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson}
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#endif
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson
b00044a2eb43864b8718585d21949611a2ee59efJames Carlson#endif /* _LIBNWAM_H */