1 /* 2 * Copyright (c) 2006-2023, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 * 2018-08-03 tyx the first version 9 * 2024-12-25 Evlers add get_info api for more new sta information 10 * 2025-01-04 Evlers add ap_get_info api for more ap information 11 */ 12 13 #ifndef __DEV_WLAN_DEVICE_H__ 14 #define __DEV_WLAN_DEVICE_H__ 15 16 #ifdef __cplusplus 17 extern "C" { 18 #endif 19 20 #define RT_WLAN_DEV_VERSION 0x10001 /* 1.0.1 */ 21 22 typedef enum 23 { 24 RT_WLAN_NONE, 25 RT_WLAN_STATION, 26 RT_WLAN_AP, 27 RT_WLAN_MODE_MAX 28 } rt_wlan_mode_t; 29 30 typedef enum 31 { 32 RT_WLAN_CMD_MODE = 0x10, 33 RT_WLAN_CMD_SCAN, /* trigger scanning (list cells) */ 34 RT_WLAN_CMD_JOIN, 35 RT_WLAN_CMD_SOFTAP, /* start soft-AP */ 36 RT_WLAN_CMD_DISCONNECT, 37 RT_WLAN_CMD_AP_STOP, /* stop soft-AP */ 38 RT_WLAN_CMD_AP_DEAUTH, 39 RT_WLAN_CMD_SCAN_STOP, 40 RT_WLAN_CMD_GET_RSSI, /* get sensitivity (dBm) */ 41 RT_WLAN_CMD_GET_INFO, /* get information (rssi, channel, datarate.) */ 42 RT_WLAN_CMD_AP_GET_INFO, /* get ap information (bssid, security, channel.) */ 43 RT_WLAN_CMD_SET_POWERSAVE, 44 RT_WLAN_CMD_GET_POWERSAVE, 45 RT_WLAN_CMD_CFG_PROMISC, /* start/stop minitor */ 46 RT_WLAN_CMD_CFG_FILTER, /* start/stop frame filter */ 47 RT_WLAN_CMD_CFG_MGNT_FILTER, /* start/stop management frame filter */ 48 RT_WLAN_CMD_SET_CHANNEL, 49 RT_WLAN_CMD_GET_CHANNEL, 50 RT_WLAN_CMD_SET_COUNTRY, 51 RT_WLAN_CMD_GET_COUNTRY, 52 RT_WLAN_CMD_SET_MAC, 53 RT_WLAN_CMD_GET_MAC, 54 RT_WLAN_CMD_GET_FAST_CONNECT_INFO, 55 RT_WLAN_CMD_FAST_CONNECT, 56 } rt_wlan_cmd_t; 57 58 typedef enum 59 { 60 RT_WLAN_DEV_EVT_INIT_DONE = 0, 61 RT_WLAN_DEV_EVT_CONNECT, 62 RT_WLAN_DEV_EVT_CONNECT_FAIL, 63 RT_WLAN_DEV_EVT_DISCONNECT, 64 RT_WLAN_DEV_EVT_AP_START, 65 RT_WLAN_DEV_EVT_AP_STOP, 66 RT_WLAN_DEV_EVT_AP_ASSOCIATED, 67 RT_WLAN_DEV_EVT_AP_DISASSOCIATED, 68 RT_WLAN_DEV_EVT_AP_ASSOCIATE_FAILED, 69 RT_WLAN_DEV_EVT_SCAN_REPORT, 70 RT_WLAN_DEV_EVT_SCAN_DONE, 71 RT_WLAN_DEV_EVT_MAX, 72 } rt_wlan_dev_event_t; 73 74 #define SHARED_ENABLED 0x00008000 75 #define WPA_SECURITY 0x00200000 76 #define WPA2_SECURITY 0x00400000 77 #define WPS_ENABLED 0x10000000 78 #define WEP_ENABLED 0x0001 79 #define TKIP_ENABLED 0x0002 80 #define AES_ENABLED 0x0004 81 #define WSEC_SWFLAG 0x0008 82 83 #define RT_WLAN_FLAG_STA_ONLY (0x1 << 0) 84 #define RT_WLAN_FLAG_AP_ONLY (0x1 << 1) 85 86 #ifndef RT_WLAN_SSID_MAX_LENGTH 87 #define RT_WLAN_SSID_MAX_LENGTH (32) /* SSID MAX LEN */ 88 #endif 89 90 #ifndef RT_WLAN_BSSID_MAX_LENGTH 91 #define RT_WLAN_BSSID_MAX_LENGTH (6) /* BSSID MAX LEN (default is 6) */ 92 #endif 93 94 #ifndef RT_WLAN_PASSWORD_MAX_LENGTH 95 #define RT_WLAN_PASSWORD_MAX_LENGTH (32) /* PASSWORD MAX LEN*/ 96 #endif 97 98 #ifndef RT_WLAN_DEV_EVENT_NUM 99 #define RT_WLAN_DEV_EVENT_NUM (2) /* EVENT GROUP MAX NUM */ 100 #endif 101 102 /** 103 * Enumeration of Wi-Fi security modes 104 */ 105 typedef enum 106 { 107 SECURITY_OPEN = 0, /* Open security */ 108 SECURITY_WEP_PSK = WEP_ENABLED, /* WEP Security with open authentication */ 109 SECURITY_WEP_SHARED = (WEP_ENABLED | SHARED_ENABLED), /* WEP Security with shared authentication */ 110 SECURITY_WPA_TKIP_PSK = (WPA_SECURITY | TKIP_ENABLED), /* WPA Security with TKIP */ 111 SECURITY_WPA_AES_PSK = (WPA_SECURITY | AES_ENABLED), /* WPA Security with AES */ 112 SECURITY_WPA2_AES_PSK = (WPA2_SECURITY | AES_ENABLED), /* WPA2 Security with AES */ 113 SECURITY_WPA2_TKIP_PSK = (WPA2_SECURITY | TKIP_ENABLED), /* WPA2 Security with TKIP */ 114 SECURITY_WPA2_MIXED_PSK = (WPA2_SECURITY | AES_ENABLED | TKIP_ENABLED), /* WPA2 Security with AES & TKIP */ 115 SECURITY_WPS_OPEN = WPS_ENABLED, /* WPS with open security */ 116 SECURITY_WPS_SECURE = (WPS_ENABLED | AES_ENABLED), /* WPS with AES security */ 117 SECURITY_UNKNOWN = -1, /* May be returned by scan function if security is unknown. 118 Do not pass this to the join function! */ 119 } rt_wlan_security_t; 120 121 typedef enum 122 { 123 RT_802_11_BAND_5GHZ = 0, /* Denotes 5GHz radio band */ 124 RT_802_11_BAND_2_4GHZ = 1, /* Denotes 2.4GHz radio band */ 125 RT_802_11_BAND_UNKNOWN = 0x7fffffff, /* unknown */ 126 } rt_802_11_band_t; 127 128 typedef enum 129 { 130 RT_COUNTRY_AFGHANISTAN, 131 RT_COUNTRY_ALBANIA, 132 RT_COUNTRY_ALGERIA, 133 RT_COUNTRY_AMERICAN_SAMOA, 134 RT_COUNTRY_ANGOLA, 135 RT_COUNTRY_ANGUILLA, 136 RT_COUNTRY_ANTIGUA_AND_BARBUDA, 137 RT_COUNTRY_ARGENTINA, 138 RT_COUNTRY_ARMENIA, 139 RT_COUNTRY_ARUBA, 140 RT_COUNTRY_AUSTRALIA, 141 RT_COUNTRY_AUSTRIA, 142 RT_COUNTRY_AZERBAIJAN, 143 RT_COUNTRY_BAHAMAS, 144 RT_COUNTRY_BAHRAIN, 145 RT_COUNTRY_BAKER_ISLAND, 146 RT_COUNTRY_BANGLADESH, 147 RT_COUNTRY_BARBADOS, 148 RT_COUNTRY_BELARUS, 149 RT_COUNTRY_BELGIUM, 150 RT_COUNTRY_BELIZE, 151 RT_COUNTRY_BENIN, 152 RT_COUNTRY_BERMUDA, 153 RT_COUNTRY_BHUTAN, 154 RT_COUNTRY_BOLIVIA, 155 RT_COUNTRY_BOSNIA_AND_HERZEGOVINA, 156 RT_COUNTRY_BOTSWANA, 157 RT_COUNTRY_BRAZIL, 158 RT_COUNTRY_BRITISH_INDIAN_OCEAN_TERRITORY, 159 RT_COUNTRY_BRUNEI_DARUSSALAM, 160 RT_COUNTRY_BULGARIA, 161 RT_COUNTRY_BURKINA_FASO, 162 RT_COUNTRY_BURUNDI, 163 RT_COUNTRY_CAMBODIA, 164 RT_COUNTRY_CAMEROON, 165 RT_COUNTRY_CANADA, 166 RT_COUNTRY_CAPE_VERDE, 167 RT_COUNTRY_CAYMAN_ISLANDS, 168 RT_COUNTRY_CENTRAL_AFRICAN_REPUBLIC, 169 RT_COUNTRY_CHAD, 170 RT_COUNTRY_CHILE, 171 RT_COUNTRY_CHINA, 172 RT_COUNTRY_CHRISTMAS_ISLAND, 173 RT_COUNTRY_COLOMBIA, 174 RT_COUNTRY_COMOROS, 175 RT_COUNTRY_CONGO, 176 RT_COUNTRY_CONGO_THE_DEMOCRATIC_REPUBLIC_OF_THE, 177 RT_COUNTRY_COSTA_RICA, 178 RT_COUNTRY_COTE_DIVOIRE, 179 RT_COUNTRY_CROATIA, 180 RT_COUNTRY_CUBA, 181 RT_COUNTRY_CYPRUS, 182 RT_COUNTRY_CZECH_REPUBLIC, 183 RT_COUNTRY_DENMARK, 184 RT_COUNTRY_DJIBOUTI, 185 RT_COUNTRY_DOMINICA, 186 RT_COUNTRY_DOMINICAN_REPUBLIC, 187 RT_COUNTRY_DOWN_UNDER, 188 RT_COUNTRY_ECUADOR, 189 RT_COUNTRY_EGYPT, 190 RT_COUNTRY_EL_SALVADOR, 191 RT_COUNTRY_EQUATORIAL_GUINEA, 192 RT_COUNTRY_ERITREA, 193 RT_COUNTRY_ESTONIA, 194 RT_COUNTRY_ETHIOPIA, 195 RT_COUNTRY_FALKLAND_ISLANDS_MALVINAS, 196 RT_COUNTRY_FAROE_ISLANDS, 197 RT_COUNTRY_FIJI, 198 RT_COUNTRY_FINLAND, 199 RT_COUNTRY_FRANCE, 200 RT_COUNTRY_FRENCH_GUINA, 201 RT_COUNTRY_FRENCH_POLYNESIA, 202 RT_COUNTRY_FRENCH_SOUTHERN_TERRITORIES, 203 RT_COUNTRY_GABON, 204 RT_COUNTRY_GAMBIA, 205 RT_COUNTRY_GEORGIA, 206 RT_COUNTRY_GERMANY, 207 RT_COUNTRY_GHANA, 208 RT_COUNTRY_GIBRALTAR, 209 RT_COUNTRY_GREECE, 210 RT_COUNTRY_GRENADA, 211 RT_COUNTRY_GUADELOUPE, 212 RT_COUNTRY_GUAM, 213 RT_COUNTRY_GUATEMALA, 214 RT_COUNTRY_GUERNSEY, 215 RT_COUNTRY_GUINEA, 216 RT_COUNTRY_GUINEA_BISSAU, 217 RT_COUNTRY_GUYANA, 218 RT_COUNTRY_HAITI, 219 RT_COUNTRY_HOLY_SEE_VATICAN_CITY_STATE, 220 RT_COUNTRY_HONDURAS, 221 RT_COUNTRY_HONG_KONG, 222 RT_COUNTRY_HUNGARY, 223 RT_COUNTRY_ICELAND, 224 RT_COUNTRY_INDIA, 225 RT_COUNTRY_INDONESIA, 226 RT_COUNTRY_IRAN_ISLAMIC_REPUBLIC_OF, 227 RT_COUNTRY_IRAQ, 228 RT_COUNTRY_IRELAND, 229 RT_COUNTRY_ISRAEL, 230 RT_COUNTRY_ITALY, 231 RT_COUNTRY_JAMAICA, 232 RT_COUNTRY_JAPAN, 233 RT_COUNTRY_JERSEY, 234 RT_COUNTRY_JORDAN, 235 RT_COUNTRY_KAZAKHSTAN, 236 RT_COUNTRY_KENYA, 237 RT_COUNTRY_KIRIBATI, 238 RT_COUNTRY_KOREA_REPUBLIC_OF, 239 RT_COUNTRY_KOSOVO, 240 RT_COUNTRY_KUWAIT, 241 RT_COUNTRY_KYRGYZSTAN, 242 RT_COUNTRY_LAO_PEOPLES_DEMOCRATIC_REPUBIC, 243 RT_COUNTRY_LATVIA, 244 RT_COUNTRY_LEBANON, 245 RT_COUNTRY_LESOTHO, 246 RT_COUNTRY_LIBERIA, 247 RT_COUNTRY_LIBYAN_ARAB_JAMAHIRIYA, 248 RT_COUNTRY_LIECHTENSTEIN, 249 RT_COUNTRY_LITHUANIA, 250 RT_COUNTRY_LUXEMBOURG, 251 RT_COUNTRY_MACAO, 252 RT_COUNTRY_MACEDONIA_FORMER_YUGOSLAV_REPUBLIC_OF, 253 RT_COUNTRY_MADAGASCAR, 254 RT_COUNTRY_MALAWI, 255 RT_COUNTRY_MALAYSIA, 256 RT_COUNTRY_MALDIVES, 257 RT_COUNTRY_MALI, 258 RT_COUNTRY_MALTA, 259 RT_COUNTRY_MAN_ISLE_OF, 260 RT_COUNTRY_MARTINIQUE, 261 RT_COUNTRY_MAURITANIA, 262 RT_COUNTRY_MAURITIUS, 263 RT_COUNTRY_MAYOTTE, 264 RT_COUNTRY_MEXICO, 265 RT_COUNTRY_MICRONESIA_FEDERATED_STATES_OF, 266 RT_COUNTRY_MOLDOVA_REPUBLIC_OF, 267 RT_COUNTRY_MONACO, 268 RT_COUNTRY_MONGOLIA, 269 RT_COUNTRY_MONTENEGRO, 270 RT_COUNTRY_MONTSERRAT, 271 RT_COUNTRY_MOROCCO, 272 RT_COUNTRY_MOZAMBIQUE, 273 RT_COUNTRY_MYANMAR, 274 RT_COUNTRY_NAMIBIA, 275 RT_COUNTRY_NAURU, 276 RT_COUNTRY_NEPAL, 277 RT_COUNTRY_NETHERLANDS, 278 RT_COUNTRY_NETHERLANDS_ANTILLES, 279 RT_COUNTRY_NEW_CALEDONIA, 280 RT_COUNTRY_NEW_ZEALAND, 281 RT_COUNTRY_NICARAGUA, 282 RT_COUNTRY_NIGER, 283 RT_COUNTRY_NIGERIA, 284 RT_COUNTRY_NORFOLK_ISLAND, 285 RT_COUNTRY_NORTHERN_MARIANA_ISLANDS, 286 RT_COUNTRY_NORWAY, 287 RT_COUNTRY_OMAN, 288 RT_COUNTRY_PAKISTAN, 289 RT_COUNTRY_PALAU, 290 RT_COUNTRY_PANAMA, 291 RT_COUNTRY_PAPUA_NEW_GUINEA, 292 RT_COUNTRY_PARAGUAY, 293 RT_COUNTRY_PERU, 294 RT_COUNTRY_PHILIPPINES, 295 RT_COUNTRY_POLAND, 296 RT_COUNTRY_PORTUGAL, 297 RT_COUNTRY_PUETO_RICO, 298 RT_COUNTRY_QATAR, 299 RT_COUNTRY_REUNION, 300 RT_COUNTRY_ROMANIA, 301 RT_COUNTRY_RUSSIAN_FEDERATION, 302 RT_COUNTRY_RWANDA, 303 RT_COUNTRY_SAINT_KITTS_AND_NEVIS, 304 RT_COUNTRY_SAINT_LUCIA, 305 RT_COUNTRY_SAINT_PIERRE_AND_MIQUELON, 306 RT_COUNTRY_SAINT_VINCENT_AND_THE_GRENADINES, 307 RT_COUNTRY_SAMOA, 308 RT_COUNTRY_SANIT_MARTIN_SINT_MARTEEN, 309 RT_COUNTRY_SAO_TOME_AND_PRINCIPE, 310 RT_COUNTRY_SAUDI_ARABIA, 311 RT_COUNTRY_SENEGAL, 312 RT_COUNTRY_SERBIA, 313 RT_COUNTRY_SEYCHELLES, 314 RT_COUNTRY_SIERRA_LEONE, 315 RT_COUNTRY_SINGAPORE, 316 RT_COUNTRY_SLOVAKIA, 317 RT_COUNTRY_SLOVENIA, 318 RT_COUNTRY_SOLOMON_ISLANDS, 319 RT_COUNTRY_SOMALIA, 320 RT_COUNTRY_SOUTH_AFRICA, 321 RT_COUNTRY_SPAIN, 322 RT_COUNTRY_SRI_LANKA, 323 RT_COUNTRY_SURINAME, 324 RT_COUNTRY_SWAZILAND, 325 RT_COUNTRY_SWEDEN, 326 RT_COUNTRY_SWITZERLAND, 327 RT_COUNTRY_SYRIAN_ARAB_REPUBLIC, 328 RT_COUNTRY_TAIWAN_PROVINCE_OF_CHINA, 329 RT_COUNTRY_TAJIKISTAN, 330 RT_COUNTRY_TANZANIA_UNITED_REPUBLIC_OF, 331 RT_COUNTRY_THAILAND, 332 RT_COUNTRY_TOGO, 333 RT_COUNTRY_TONGA, 334 RT_COUNTRY_TRINIDAD_AND_TOBAGO, 335 RT_COUNTRY_TUNISIA, 336 RT_COUNTRY_TURKEY, 337 RT_COUNTRY_TURKMENISTAN, 338 RT_COUNTRY_TURKS_AND_CAICOS_ISLANDS, 339 RT_COUNTRY_TUVALU, 340 RT_COUNTRY_UGANDA, 341 RT_COUNTRY_UKRAINE, 342 RT_COUNTRY_UNITED_ARAB_EMIRATES, 343 RT_COUNTRY_UNITED_KINGDOM, 344 RT_COUNTRY_UNITED_STATES, 345 RT_COUNTRY_UNITED_STATES_REV4, 346 RT_COUNTRY_UNITED_STATES_NO_DFS, 347 RT_COUNTRY_UNITED_STATES_MINOR_OUTLYING_ISLANDS, 348 RT_COUNTRY_URUGUAY, 349 RT_COUNTRY_UZBEKISTAN, 350 RT_COUNTRY_VANUATU, 351 RT_COUNTRY_VENEZUELA, 352 RT_COUNTRY_VIET_NAM, 353 RT_COUNTRY_VIRGIN_ISLANDS_BRITISH, 354 RT_COUNTRY_VIRGIN_ISLANDS_US, 355 RT_COUNTRY_WALLIS_AND_FUTUNA, 356 RT_COUNTRY_WEST_BANK, 357 RT_COUNTRY_WESTERN_SAHARA, 358 RT_COUNTRY_WORLD_WIDE_XX, 359 RT_COUNTRY_YEMEN, 360 RT_COUNTRY_ZAMBIA, 361 RT_COUNTRY_ZIMBABWE, 362 RT_COUNTRY_UNKNOWN 363 } rt_country_code_t; 364 365 struct rt_wlan_device; 366 struct rt_wlan_buff; 367 368 typedef void (*rt_wlan_dev_event_handler)(struct rt_wlan_device *device, rt_wlan_dev_event_t event, struct rt_wlan_buff *buff, void *parameter); 369 370 typedef void (*rt_wlan_pormisc_callback_t)(struct rt_wlan_device *device, void *data, int len); 371 372 typedef void (*rt_wlan_mgnt_filter_callback_t)(struct rt_wlan_device *device, void *data, int len); 373 374 struct rt_wlan_ssid 375 { 376 rt_uint8_t len; 377 rt_uint8_t val[RT_WLAN_SSID_MAX_LENGTH + 1]; 378 }; 379 typedef struct rt_wlan_ssid rt_wlan_ssid_t; 380 381 struct rt_wlan_key 382 { 383 rt_uint8_t len; 384 rt_uint8_t val[RT_WLAN_PASSWORD_MAX_LENGTH + 1]; 385 }; 386 typedef struct rt_wlan_key rt_wlan_key_t; 387 388 #define INVALID_INFO(_info) do { \ 389 rt_memset((_info), 0, sizeof(struct rt_wlan_info)); \ 390 (_info)->band = RT_802_11_BAND_UNKNOWN; \ 391 (_info)->security = SECURITY_UNKNOWN; \ 392 (_info)->channel = -1; \ 393 } while(0) 394 395 #define SSID_SET(_info, _ssid) do { \ 396 rt_strncpy((char *)(_info)->ssid.val, (_ssid), RT_WLAN_SSID_MAX_LENGTH); \ 397 (_info)->ssid.len = rt_strlen((char *)(_info)->ssid.val); \ 398 } while(0) 399 400 struct rt_wlan_info 401 { 402 /* security type */ 403 rt_wlan_security_t security; 404 /* 2.4G/5G */ 405 rt_802_11_band_t band; 406 /* maximal data rate */ 407 rt_uint32_t datarate; 408 /* radio channel */ 409 rt_int16_t channel; 410 /* signal strength */ 411 rt_int16_t rssi; 412 /* ssid */ 413 rt_wlan_ssid_t ssid; 414 /* hwaddr */ 415 rt_uint8_t bssid[RT_WLAN_BSSID_MAX_LENGTH]; 416 rt_uint8_t hidden; 417 }; 418 419 struct rt_wlan_buff 420 { 421 void *data; 422 rt_int32_t len; 423 }; 424 425 struct rt_filter_pattern 426 { 427 rt_uint16_t offset; /* Offset in bytes to start filtering (referenced to the start of the ethernet packet) */ 428 rt_uint16_t mask_size; /* Size of the mask in bytes */ 429 rt_uint8_t *mask; /* Pattern mask bytes to be ANDed with the pattern eg. "\xff00" (must be in network byte order) */ 430 rt_uint8_t *pattern; /* Pattern bytes used to filter eg. "\x0800" (must be in network byte order) */ 431 }; 432 433 typedef enum 434 { 435 RT_POSITIVE_MATCHING = 0, /* Receive the data matching with this pattern and discard the other data */ 436 RT_NEGATIVE_MATCHING = 1 /* Discard the data matching with this pattern and receive the other data */ 437 } rt_filter_rule_t; 438 439 struct rt_wlan_filter 440 { 441 struct rt_filter_pattern patt; 442 rt_filter_rule_t rule; 443 rt_uint8_t enable; 444 }; 445 446 struct rt_wlan_dev_event_desc 447 { 448 rt_wlan_dev_event_handler handler; 449 void *parameter; 450 }; 451 452 struct rt_wlan_device 453 { 454 struct rt_device device; 455 rt_wlan_mode_t mode; 456 struct rt_mutex lock; 457 struct rt_wlan_dev_event_desc handler_table[RT_WLAN_DEV_EVT_MAX][RT_WLAN_DEV_EVENT_NUM]; 458 rt_wlan_pormisc_callback_t pormisc_callback; 459 rt_wlan_mgnt_filter_callback_t mgnt_filter_callback; 460 const struct rt_wlan_dev_ops *ops; 461 rt_uint32_t flags; 462 struct netdev *netdev; 463 void *prot; 464 void *user_data; 465 }; 466 467 struct rt_sta_info 468 { 469 rt_wlan_ssid_t ssid; 470 rt_wlan_key_t key; 471 rt_uint8_t bssid[6]; 472 rt_uint16_t channel; 473 rt_wlan_security_t security; 474 }; 475 476 struct rt_ap_info 477 { 478 rt_wlan_ssid_t ssid; 479 rt_wlan_key_t key; 480 rt_bool_t hidden; 481 rt_uint16_t channel; 482 rt_wlan_security_t security; 483 }; 484 485 struct rt_scan_info 486 { 487 rt_wlan_ssid_t ssid; 488 rt_uint8_t bssid[6]; 489 rt_int16_t channel_min; 490 rt_int16_t channel_max; 491 rt_bool_t passive; 492 }; 493 494 struct rt_wlan_dev_ops 495 { 496 rt_err_t (*wlan_init)(struct rt_wlan_device *wlan); 497 rt_err_t (*wlan_mode)(struct rt_wlan_device *wlan, rt_wlan_mode_t mode); 498 rt_err_t (*wlan_scan)(struct rt_wlan_device *wlan, struct rt_scan_info *scan_info); 499 rt_err_t (*wlan_join)(struct rt_wlan_device *wlan, struct rt_sta_info *sta_info); 500 rt_err_t (*wlan_softap)(struct rt_wlan_device *wlan, struct rt_ap_info *ap_info); 501 rt_err_t (*wlan_disconnect)(struct rt_wlan_device *wlan); 502 rt_err_t (*wlan_ap_stop)(struct rt_wlan_device *wlan); 503 rt_err_t (*wlan_ap_deauth)(struct rt_wlan_device *wlan, rt_uint8_t mac[]); 504 rt_err_t (*wlan_scan_stop)(struct rt_wlan_device *wlan); 505 int (*wlan_get_rssi)(struct rt_wlan_device *wlan); 506 int (*wlan_get_info)(struct rt_wlan_device *wlan, struct rt_wlan_info *info); 507 int (*wlan_ap_get_info)(struct rt_wlan_device *wlan, struct rt_wlan_info *info); 508 rt_err_t (*wlan_set_powersave)(struct rt_wlan_device *wlan, int level); 509 int (*wlan_get_powersave)(struct rt_wlan_device *wlan); 510 rt_err_t (*wlan_cfg_promisc)(struct rt_wlan_device *wlan, rt_bool_t start); 511 rt_err_t (*wlan_cfg_filter)(struct rt_wlan_device *wlan, struct rt_wlan_filter *filter); 512 rt_err_t (*wlan_cfg_mgnt_filter)(struct rt_wlan_device *wlan, rt_bool_t start); 513 rt_err_t (*wlan_set_channel)(struct rt_wlan_device *wlan, int channel); 514 int (*wlan_get_channel)(struct rt_wlan_device *wlan); 515 rt_err_t (*wlan_set_country)(struct rt_wlan_device *wlan, rt_country_code_t country_code); 516 rt_country_code_t (*wlan_get_country)(struct rt_wlan_device *wlan); 517 rt_err_t (*wlan_set_mac)(struct rt_wlan_device *wlan, rt_uint8_t mac[]); 518 rt_err_t (*wlan_get_mac)(struct rt_wlan_device *wlan, rt_uint8_t mac[]); 519 int (*wlan_recv)(struct rt_wlan_device *wlan, void *buff, int len); 520 int (*wlan_send)(struct rt_wlan_device *wlan, void *buff, int len); 521 int (*wlan_send_raw_frame)(struct rt_wlan_device *wlan, void *buff, int len); 522 int (*wlan_get_fast_info)(void *data); 523 rt_err_t (*wlan_fast_connect)(void *data,rt_int32_t len); 524 }; 525 526 /* 527 * wlan device init 528 */ 529 rt_err_t rt_wlan_dev_init(struct rt_wlan_device *device, rt_wlan_mode_t mode); 530 531 /* 532 * wlan device station interface 533 */ 534 rt_err_t rt_wlan_dev_connect(struct rt_wlan_device *device, struct rt_wlan_info *info, const char *password, int password_len); 535 rt_err_t rt_wlan_dev_fast_connect(struct rt_wlan_device *device, struct rt_wlan_info *info, const char *password, int password_len); 536 rt_err_t rt_wlan_dev_disconnect(struct rt_wlan_device *device); 537 int rt_wlan_dev_get_rssi(struct rt_wlan_device *device); 538 rt_err_t rt_wlan_dev_get_info(struct rt_wlan_device *device, struct rt_wlan_info *info); 539 540 /* 541 * wlan device ap interface 542 */ 543 rt_err_t rt_wlan_dev_ap_start(struct rt_wlan_device *device, struct rt_wlan_info *info, const char *password, int password_len); 544 rt_err_t rt_wlan_dev_ap_stop(struct rt_wlan_device *device); 545 rt_err_t rt_wlan_dev_ap_deauth(struct rt_wlan_device *device, rt_uint8_t mac[6]); 546 rt_err_t rt_wlan_dev_ap_get_info(struct rt_wlan_device *device, struct rt_wlan_info *info); 547 548 /* 549 * wlan device scan interface 550 */ 551 rt_err_t rt_wlan_dev_scan(struct rt_wlan_device *device, struct rt_wlan_info *info); 552 rt_err_t rt_wlan_dev_scan_stop(struct rt_wlan_device *device); 553 554 /* 555 * wlan device mac interface 556 */ 557 rt_err_t rt_wlan_dev_get_mac(struct rt_wlan_device *device, rt_uint8_t mac[6]); 558 rt_err_t rt_wlan_dev_set_mac(struct rt_wlan_device *device, rt_uint8_t mac[6]); 559 560 /* 561 * wlan device powersave interface 562 */ 563 rt_err_t rt_wlan_dev_set_powersave(struct rt_wlan_device *device, int level); 564 int rt_wlan_dev_get_powersave(struct rt_wlan_device *device); 565 566 /* 567 * wlan device event interface 568 */ 569 rt_err_t rt_wlan_dev_register_event_handler(struct rt_wlan_device *device, rt_wlan_dev_event_t event, rt_wlan_dev_event_handler handler, void *parameter); 570 rt_err_t rt_wlan_dev_unregister_event_handler(struct rt_wlan_device *device, rt_wlan_dev_event_t event, rt_wlan_dev_event_handler handler); 571 void rt_wlan_dev_indicate_event_handle(struct rt_wlan_device *device, rt_wlan_dev_event_t event, struct rt_wlan_buff *buff); 572 573 /* 574 * wlan device promisc interface 575 */ 576 rt_err_t rt_wlan_dev_enter_promisc(struct rt_wlan_device *device); 577 rt_err_t rt_wlan_dev_exit_promisc(struct rt_wlan_device *device); 578 rt_err_t rt_wlan_dev_set_promisc_callback(struct rt_wlan_device *device, rt_wlan_pormisc_callback_t callback); 579 void rt_wlan_dev_promisc_handler(struct rt_wlan_device *device, void *data, int len); 580 581 /* 582 * wlan device filter interface 583 */ 584 rt_err_t rt_wlan_dev_cfg_filter(struct rt_wlan_device *device, struct rt_wlan_filter *filter); 585 586 /* 587 * wlan device channel interface 588 */ 589 rt_err_t rt_wlan_dev_set_channel(struct rt_wlan_device *device, int channel); 590 int rt_wlan_dev_get_channel(struct rt_wlan_device *device); 591 592 /* 593 * wlan device country interface 594 */ 595 rt_err_t rt_wlan_dev_set_country(struct rt_wlan_device *device, rt_country_code_t country_code); 596 rt_country_code_t rt_wlan_dev_get_country(struct rt_wlan_device *device); 597 598 /* 599 * wlan device datat transfer interface 600 */ 601 rt_err_t rt_wlan_dev_report_data(struct rt_wlan_device *device, void *buff, int len); 602 // void rt_wlan_dev_data_ready(struct rt_wlan_device *device, int len); 603 604 /* 605 * wlan device register interface 606 */ 607 rt_err_t rt_wlan_dev_register(struct rt_wlan_device *wlan, const char *name, 608 const struct rt_wlan_dev_ops *ops, rt_uint32_t flag, void *user_data); 609 610 #ifdef __cplusplus 611 } 612 #endif 613 614 #endif 615