wlantest.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /*
  2. * wlantest - IEEE 802.11 protocol monitoring and testing tool
  3. * Copyright (c) 2010, Jouni Malinen <j@w1.fi>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2 as
  7. * published by the Free Software Foundation.
  8. *
  9. * Alternatively, this software may be distributed under the terms of BSD
  10. * license.
  11. *
  12. * See README and COPYING for more details.
  13. */
  14. #ifndef WLANTEST_H
  15. #define WLANTEST_H
  16. #include "utils/list.h"
  17. #include "common/wpa_common.h"
  18. struct ieee802_11_elems;
  19. struct wlantest_passphrase {
  20. struct dl_list list;
  21. char passphrase[64];
  22. u8 ssid[32];
  23. size_t ssid_len;
  24. u8 bssid[ETH_ALEN];
  25. };
  26. struct wlantest_pmk {
  27. struct dl_list list;
  28. u8 pmk[32];
  29. };
  30. struct wlantest_sta {
  31. struct dl_list list;
  32. u8 addr[ETH_ALEN];
  33. enum {
  34. STATE1 /* not authenticated */,
  35. STATE2 /* authenticated */,
  36. STATE3 /* associated */
  37. } state;
  38. u16 aid;
  39. u8 rsnie[257]; /* WPA/RSN IE */
  40. u8 anonce[32]; /* ANonce from the previous EAPOL-Key msg 1/4 or 3/4 */
  41. u8 snonce[32]; /* SNonce from the previous EAPOL-Key msg 2/4 */
  42. struct wpa_ptk ptk; /* Derived PTK */
  43. int ptk_set;
  44. };
  45. struct wlantest_bss {
  46. struct dl_list list;
  47. u8 bssid[ETH_ALEN];
  48. u16 capab_info;
  49. u8 ssid[32];
  50. size_t ssid_len;
  51. int proberesp_seen;
  52. int parse_error_reported;
  53. u8 wpaie[257];
  54. u8 rsnie[257];
  55. struct dl_list sta; /* struct wlantest_sta */
  56. struct dl_list pmk; /* struct wlantest_pmk */
  57. };
  58. struct wlantest {
  59. int monitor_sock;
  60. struct dl_list passphrase; /* struct wlantest_passphrase */
  61. struct dl_list bss; /* struct wlantest_bss */
  62. unsigned int rx_mgmt;
  63. unsigned int rx_ctrl;
  64. unsigned int rx_data;
  65. unsigned int fcs_error;
  66. };
  67. int read_cap_file(struct wlantest *wt, const char *fname);
  68. void wlantest_process(struct wlantest *wt, const u8 *data, size_t len);
  69. u32 crc32(const u8 *frame, size_t frame_len);
  70. int monitor_init(struct wlantest *wt, const char *ifname);
  71. void monitor_deinit(struct wlantest *wt);
  72. void rx_mgmt(struct wlantest *wt, const u8 *data, size_t len);
  73. void rx_data(struct wlantest *wt, const u8 *data, size_t len);
  74. struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid);
  75. void bss_deinit(struct wlantest_bss *bss);
  76. void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
  77. struct ieee802_11_elems *elems);
  78. struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
  79. void sta_deinit(struct wlantest_sta *sta);
  80. void sta_update_assoc(struct wlantest_sta *sta,
  81. struct ieee802_11_elems *elems);
  82. #endif /* WLANTEST_H */