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