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 2007 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 #pragma ident "%Z%%M% %I% %E% SMI" 30 31 /* 32 * This file includes structures, macros and routines used by WLAN link 33 * administration. 34 */ 35 36 #include <sys/types.h> 37 #include <libdladm.h> 38 39 /* 40 * General libdlwlan definitions and functions. 41 * 42 * These interfaces are ON consolidation-private. 43 * For documentation, refer to PSARC/2006/623. 44 */ 45 46 #ifdef __cplusplus 47 extern "C" { 48 #endif 49 50 #define DLADM_WLAN_MAX_ESSID_LEN 32 /* per 802.11 spec */ 51 #define DLADM_WLAN_BSSID_LEN 6 /* per 802.11 spec */ 52 53 #define DLADM_WLAN_CONNECT_TIMEOUT_DEFAULT 10 54 #define DLADM_WLAN_CONNECT_CREATEIBSS 0x00000001 55 #define DLADM_WLAN_CONNECT_NOSCAN 0x00000002 56 57 typedef struct dladm_wlan_essid { 58 char we_bytes[DLADM_WLAN_MAX_ESSID_LEN]; 59 } dladm_wlan_essid_t; 60 61 typedef struct dladm_wlan_bssid { 62 uint8_t wb_bytes[DLADM_WLAN_BSSID_LEN]; 63 } dladm_wlan_bssid_t; 64 65 typedef enum { 66 DLADM_WLAN_SECMODE_NONE = 1, 67 DLADM_WLAN_SECMODE_WEP 68 } dladm_wlan_secmode_t; 69 70 typedef enum { 71 DLADM_WLAN_STRENGTH_VERY_WEAK = 1, 72 DLADM_WLAN_STRENGTH_WEAK, 73 DLADM_WLAN_STRENGTH_GOOD, 74 DLADM_WLAN_STRENGTH_VERY_GOOD, 75 DLADM_WLAN_STRENGTH_EXCELLENT 76 } dladm_wlan_strength_t; 77 78 typedef enum { 79 DLADM_WLAN_MODE_NONE = 0, 80 DLADM_WLAN_MODE_80211A, 81 DLADM_WLAN_MODE_80211B, 82 DLADM_WLAN_MODE_80211G 83 } dladm_wlan_mode_t; 84 85 typedef enum { 86 DLADM_WLAN_AUTH_OPEN = 1, 87 DLADM_WLAN_AUTH_SHARED 88 } dladm_wlan_auth_t; 89 90 typedef enum { 91 DLADM_WLAN_BSSTYPE_BSS = 1, 92 DLADM_WLAN_BSSTYPE_IBSS, 93 DLADM_WLAN_BSSTYPE_ANY 94 } dladm_wlan_bsstype_t; 95 96 typedef enum { 97 DLADM_WLAN_LINKSTATUS_DISCONNECTED = 1, 98 DLADM_WLAN_LINKSTATUS_CONNECTED 99 } dladm_wlan_linkstatus_t; 100 101 typedef uint32_t dladm_wlan_speed_t; 102 typedef uint32_t dladm_wlan_channel_t; 103 104 enum { 105 DLADM_WLAN_ATTR_ESSID = 0x00000001, 106 DLADM_WLAN_ATTR_BSSID = 0x00000002, 107 DLADM_WLAN_ATTR_SECMODE = 0x00000004, 108 DLADM_WLAN_ATTR_STRENGTH = 0x00000008, 109 DLADM_WLAN_ATTR_MODE = 0x00000010, 110 DLADM_WLAN_ATTR_SPEED = 0x00000020, 111 DLADM_WLAN_ATTR_AUTH = 0x00000040, 112 DLADM_WLAN_ATTR_BSSTYPE = 0x00000080, 113 DLADM_WLAN_ATTR_CHANNEL = 0x00000100 114 }; 115 typedef struct dladm_wlan_attr { 116 uint_t wa_valid; 117 dladm_wlan_essid_t wa_essid; 118 dladm_wlan_bssid_t wa_bssid; 119 dladm_wlan_secmode_t wa_secmode; 120 dladm_wlan_strength_t wa_strength; 121 dladm_wlan_mode_t wa_mode; 122 dladm_wlan_speed_t wa_speed; 123 dladm_wlan_auth_t wa_auth; 124 dladm_wlan_bsstype_t wa_bsstype; 125 dladm_wlan_channel_t wa_channel; 126 } dladm_wlan_attr_t; 127 128 enum { 129 DLADM_WLAN_LINKATTR_STATUS = 0x00000001, 130 DLADM_WLAN_LINKATTR_WLAN = 0x00000002 131 }; 132 typedef struct dladm_wlan_linkattr { 133 uint_t la_valid; 134 dladm_wlan_linkstatus_t la_status; 135 dladm_wlan_attr_t la_wlan_attr; 136 } dladm_wlan_linkattr_t; 137 138 #define DLADM_WLAN_WEPKEY64_LEN 5 /* per WEP spec */ 139 #define DLADM_WLAN_WEPKEY128_LEN 13 /* per WEP spec */ 140 #define DLADM_WLAN_MAX_WEPKEY_LEN 13 /* per WEP spec */ 141 #define DLADM_WLAN_MAX_WEPKEYS 4 /* MAX_NWEPKEYS */ 142 #define DLADM_WLAN_MAX_WEPKEYNAME_LEN 64 143 typedef struct dladm_wlan_wepkey { 144 uint_t wk_idx; 145 uint_t wk_len; 146 uint8_t wk_val[DLADM_WLAN_MAX_WEPKEY_LEN]; 147 char wk_name[DLADM_WLAN_MAX_WEPKEYNAME_LEN]; 148 } dladm_wlan_wepkey_t; 149 150 extern dladm_status_t dladm_wlan_scan(const char *, void *, 151 boolean_t (*)(void *, dladm_wlan_attr_t *)); 152 extern dladm_status_t dladm_wlan_connect(const char *, dladm_wlan_attr_t *, 153 int, void *, uint_t, uint_t); 154 extern dladm_status_t dladm_wlan_disconnect(const char *); 155 extern dladm_status_t dladm_wlan_get_linkattr(const char *, 156 dladm_wlan_linkattr_t *); 157 extern dladm_status_t dladm_wlan_walk(void *, 158 boolean_t (*)(void *, const char *)); 159 extern boolean_t dladm_wlan_is_valid(const char *); 160 extern dladm_status_t dladm_wlan_set_prop(const char *, const char *, 161 char **, uint_t, char **); 162 extern dladm_status_t dladm_wlan_walk_prop(const char *, void *, 163 boolean_t (*)(void *, const char *)); 164 extern dladm_status_t dladm_wlan_get_prop(const char *, dladm_prop_type_t, 165 const char *, char **, uint_t *); 166 167 extern const char *dladm_wlan_essid2str(dladm_wlan_essid_t *, char *); 168 extern const char *dladm_wlan_bssid2str(dladm_wlan_bssid_t *, char *); 169 extern const char *dladm_wlan_secmode2str(dladm_wlan_secmode_t *, char *); 170 extern const char *dladm_wlan_strength2str(dladm_wlan_strength_t *, 171 char *); 172 extern const char *dladm_wlan_mode2str(dladm_wlan_mode_t *, char *); 173 extern const char *dladm_wlan_speed2str(dladm_wlan_speed_t *, char *); 174 extern const char *dladm_wlan_auth2str(dladm_wlan_auth_t *, char *); 175 extern const char *dladm_wlan_bsstype2str(dladm_wlan_bsstype_t *, char *); 176 extern const char *dladm_wlan_linkstatus2str(dladm_wlan_linkstatus_t *, 177 char *); 178 179 extern dladm_status_t dladm_wlan_str2essid(const char *, 180 dladm_wlan_essid_t *); 181 extern dladm_status_t dladm_wlan_str2bssid(const char *, 182 dladm_wlan_bssid_t *); 183 extern dladm_status_t dladm_wlan_str2secmode(const char *, 184 dladm_wlan_secmode_t *); 185 extern dladm_status_t dladm_wlan_str2strength(const char *, 186 dladm_wlan_strength_t *); 187 extern dladm_status_t dladm_wlan_str2mode(const char *, 188 dladm_wlan_mode_t *); 189 extern dladm_status_t dladm_wlan_str2speed(const char *, 190 dladm_wlan_speed_t *); 191 extern dladm_status_t dladm_wlan_str2auth(const char *, 192 dladm_wlan_auth_t *); 193 extern dladm_status_t dladm_wlan_str2bsstype(const char *, 194 dladm_wlan_bsstype_t *); 195 extern dladm_status_t dladm_wlan_str2linkstatus(const char *, 196 dladm_wlan_linkstatus_t *); 197 198 #ifdef __cplusplus 199 } 200 #endif 201 202 #endif /* _LIBDLWLAN_H */ 203