1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 */ 21 /* 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 26 #ifndef _LIBDLWLAN_H 27 #define _LIBDLWLAN_H 28 29 /* 30 * This file includes structures, macros and routines used by WLAN link 31 * administration. 32 */ 33 34 #include <sys/types.h> 35 #include <libdladm.h> 36 37 /* 38 * General libdlwlan definitions and functions. 39 * 40 * These interfaces are ON consolidation-private. 41 * For documentation, refer to PSARC/2006/623. 42 */ 43 44 #ifdef __cplusplus 45 extern "C" { 46 #endif 47 48 #define DLADM_WLAN_MAX_ESSID_LEN (32 + 1) /* per 802.11 spec */ 49 /* max essid length is 32 */ 50 /* one more for '\0' */ 51 #define DLADM_WLAN_BSSID_LEN 6 /* per 802.11 spec */ 52 #define DLADM_WLAN_WPA_KEY_LEN 32 /* per 802.11i spec */ 53 #define DLADM_WLAN_MAX_WPA_IE_LEN 40 /* per 802.11i spec */ 54 55 #define DLADM_WLAN_CONNECT_TIMEOUT_DEFAULT 10 56 #define DLADM_WLAN_CONNECT_CREATEIBSS 0x00000001 57 #define DLADM_WLAN_CONNECT_NOSCAN 0x00000002 58 59 typedef struct dladm_wlan_essid { 60 char we_bytes[DLADM_WLAN_MAX_ESSID_LEN]; 61 } dladm_wlan_essid_t; 62 63 typedef struct dladm_wlan_bssid { 64 uint8_t wb_bytes[DLADM_WLAN_BSSID_LEN]; 65 } dladm_wlan_bssid_t; 66 67 typedef struct dladm_wlan_ess { 68 dladm_wlan_bssid_t we_bssid; 69 dladm_wlan_essid_t we_ssid; 70 uint_t we_ssid_len; 71 uint8_t we_wpa_ie[DLADM_WLAN_MAX_WPA_IE_LEN]; 72 uint_t we_wpa_ie_len; 73 int we_freq; 74 } dladm_wlan_ess_t; 75 76 typedef enum { 77 DLADM_WLAN_CIPHER_WEP = 0, 78 DLADM_WLAN_CIPHER_TKIP, 79 DLADM_WLAN_CIPHER_AES_OCB, 80 DLADM_WLAN_CIPHER_AES_CCM, 81 DLADM_WLAN_CIPHER_CKIP, 82 DLADM_WLAN_CIPHER_NONE 83 } dladm_wlan_cipher_t; 84 85 typedef enum { 86 DLADM_WLAN_MLME_ASSOC = 1, /* associate station */ 87 DLADM_WLAN_MLME_DISASSOC = 2 /* disassociate station */ 88 } dladm_wlan_mlme_op_t; 89 90 typedef enum { 91 DLADM_WLAN_REASON_UNSPECIFIED = 1, 92 DLADM_WLAN_REASON_DISASSOC_LEAVING = 5 93 } dladm_wlan_reason_t; 94 95 typedef enum { 96 DLADM_WLAN_SECMODE_NONE = 1, 97 DLADM_WLAN_SECMODE_WEP, 98 DLADM_WLAN_SECMODE_WPA 99 } dladm_wlan_secmode_t; 100 101 typedef enum { 102 DLADM_WLAN_STRENGTH_VERY_WEAK = 1, 103 DLADM_WLAN_STRENGTH_WEAK, 104 DLADM_WLAN_STRENGTH_GOOD, 105 DLADM_WLAN_STRENGTH_VERY_GOOD, 106 DLADM_WLAN_STRENGTH_EXCELLENT 107 } dladm_wlan_strength_t; 108 109 typedef enum { 110 DLADM_WLAN_MODE_NONE = 0, 111 DLADM_WLAN_MODE_80211A, 112 DLADM_WLAN_MODE_80211B, 113 DLADM_WLAN_MODE_80211G, 114 DLADM_WLAN_MODE_80211GN, 115 DLADM_WLAN_MODE_80211AN 116 } dladm_wlan_mode_t; 117 118 typedef enum { 119 DLADM_WLAN_AUTH_OPEN = 1, 120 DLADM_WLAN_AUTH_SHARED 121 } dladm_wlan_auth_t; 122 123 typedef enum { 124 DLADM_WLAN_BSSTYPE_BSS = 1, 125 DLADM_WLAN_BSSTYPE_IBSS, 126 DLADM_WLAN_BSSTYPE_ANY 127 } dladm_wlan_bsstype_t; 128 129 typedef enum { 130 DLADM_WLAN_LINK_DISCONNECTED = 1, 131 DLADM_WLAN_LINK_CONNECTED 132 } dladm_wlan_linkstatus_t; 133 134 typedef uint32_t dladm_wlan_speed_t; 135 typedef uint32_t dladm_wlan_channel_t; 136 137 enum { 138 DLADM_WLAN_ATTR_ESSID = 0x00000001, 139 DLADM_WLAN_ATTR_BSSID = 0x00000002, 140 DLADM_WLAN_ATTR_SECMODE = 0x00000004, 141 DLADM_WLAN_ATTR_STRENGTH = 0x00000008, 142 DLADM_WLAN_ATTR_MODE = 0x00000010, 143 DLADM_WLAN_ATTR_SPEED = 0x00000020, 144 DLADM_WLAN_ATTR_AUTH = 0x00000040, 145 DLADM_WLAN_ATTR_BSSTYPE = 0x00000080, 146 DLADM_WLAN_ATTR_CHANNEL = 0x00000100 147 }; 148 typedef struct dladm_wlan_attr { 149 uint_t wa_valid; 150 dladm_wlan_essid_t wa_essid; 151 dladm_wlan_bssid_t wa_bssid; 152 dladm_wlan_secmode_t wa_secmode; 153 dladm_wlan_strength_t wa_strength; 154 dladm_wlan_mode_t wa_mode; 155 dladm_wlan_speed_t wa_speed; 156 dladm_wlan_auth_t wa_auth; 157 dladm_wlan_bsstype_t wa_bsstype; 158 dladm_wlan_channel_t wa_channel; 159 } dladm_wlan_attr_t; 160 161 enum { 162 DLADM_WLAN_LINKATTR_STATUS = 0x00000001, 163 DLADM_WLAN_LINKATTR_WLAN = 0x00000002 164 }; 165 typedef struct dladm_wlan_linkattr { 166 uint_t la_valid; 167 dladm_wlan_linkstatus_t la_status; 168 dladm_wlan_attr_t la_wlan_attr; 169 } dladm_wlan_linkattr_t; 170 171 #define DLADM_WLAN_WEPKEY64_LEN 5 /* per WEP spec */ 172 #define DLADM_WLAN_WEPKEY128_LEN 13 /* per WEP spec */ 173 #define DLADM_WLAN_MAX_KEY_LEN 64 /* per WEP/WPA spec */ 174 #define DLADM_WLAN_MAX_WEPKEYS 4 /* MAX_NWEPKEYS */ 175 #define DLADM_WLAN_MAX_KEYNAME_LEN 64 176 typedef struct dladm_wlan_key { 177 uint_t wk_idx; 178 uint_t wk_len; 179 uint8_t wk_val[DLADM_WLAN_MAX_KEY_LEN]; 180 char wk_name[DLADM_WLAN_MAX_KEYNAME_LEN]; 181 uint_t wk_class; 182 } dladm_wlan_key_t; 183 184 extern dladm_status_t dladm_wlan_scan(dladm_handle_t, datalink_id_t, void *, 185 boolean_t (*)(void *, dladm_wlan_attr_t *)); 186 extern dladm_status_t dladm_wlan_connect(dladm_handle_t, datalink_id_t, 187 dladm_wlan_attr_t *, int, void *, uint_t, uint_t); 188 extern dladm_status_t dladm_wlan_disconnect(dladm_handle_t, datalink_id_t); 189 extern dladm_status_t dladm_wlan_get_linkattr(dladm_handle_t, datalink_id_t, 190 dladm_wlan_linkattr_t *); 191 /* WPA support routines */ 192 extern dladm_status_t dladm_wlan_wpa_get_sr(dladm_handle_t, datalink_id_t, 193 dladm_wlan_ess_t *, uint_t, uint_t *); 194 extern dladm_status_t dladm_wlan_wpa_set_ie(dladm_handle_t, datalink_id_t, 195 uint8_t *, uint_t); 196 extern dladm_status_t dladm_wlan_wpa_set_wpa(dladm_handle_t, datalink_id_t, 197 boolean_t); 198 extern dladm_status_t dladm_wlan_wpa_del_key(dladm_handle_t, datalink_id_t, 199 uint_t, const dladm_wlan_bssid_t *); 200 extern dladm_status_t dladm_wlan_wpa_set_key(dladm_handle_t, datalink_id_t, 201 dladm_wlan_cipher_t, const dladm_wlan_bssid_t *, 202 boolean_t, uint64_t, uint_t, uint8_t *, uint_t); 203 extern dladm_status_t dladm_wlan_wpa_set_mlme(dladm_handle_t, datalink_id_t, 204 dladm_wlan_mlme_op_t, 205 dladm_wlan_reason_t, dladm_wlan_bssid_t *); 206 207 extern const char *dladm_wlan_essid2str(dladm_wlan_essid_t *, char *); 208 extern const char *dladm_wlan_bssid2str(dladm_wlan_bssid_t *, char *); 209 extern const char *dladm_wlan_secmode2str(dladm_wlan_secmode_t *, char *); 210 extern const char *dladm_wlan_strength2str(dladm_wlan_strength_t *, 211 char *); 212 extern const char *dladm_wlan_mode2str(dladm_wlan_mode_t *, char *); 213 extern const char *dladm_wlan_speed2str(dladm_wlan_speed_t *, char *); 214 extern const char *dladm_wlan_auth2str(dladm_wlan_auth_t *, char *); 215 extern const char *dladm_wlan_bsstype2str(dladm_wlan_bsstype_t *, char *); 216 extern const char *dladm_wlan_linkstatus2str(dladm_wlan_linkstatus_t *, 217 char *); 218 219 extern dladm_status_t dladm_wlan_str2essid(const char *, 220 dladm_wlan_essid_t *); 221 extern dladm_status_t dladm_wlan_str2bssid(const char *, 222 dladm_wlan_bssid_t *); 223 extern dladm_status_t dladm_wlan_str2secmode(const char *, 224 dladm_wlan_secmode_t *); 225 extern dladm_status_t dladm_wlan_str2strength(const char *, 226 dladm_wlan_strength_t *); 227 extern dladm_status_t dladm_wlan_str2mode(const char *, 228 dladm_wlan_mode_t *); 229 extern dladm_status_t dladm_wlan_str2speed(const char *, 230 dladm_wlan_speed_t *); 231 extern dladm_status_t dladm_wlan_str2auth(const char *, 232 dladm_wlan_auth_t *); 233 extern dladm_status_t dladm_wlan_str2bsstype(const char *, 234 dladm_wlan_bsstype_t *); 235 extern dladm_status_t dladm_wlan_str2linkstatus(const char *, 236 dladm_wlan_linkstatus_t *); 237 238 #ifdef __cplusplus 239 } 240 #endif 241 242 #endif /* _LIBDLWLAN_H */ 243