wlantest.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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 radius_msg;
  20. #define MAX_RADIUS_SECRET_LEN 128
  21. struct wlantest_radius_secret {
  22. struct dl_list list;
  23. char secret[MAX_RADIUS_SECRET_LEN];
  24. };
  25. struct wlantest_passphrase {
  26. struct dl_list list;
  27. char passphrase[64];
  28. u8 ssid[32];
  29. size_t ssid_len;
  30. u8 bssid[ETH_ALEN];
  31. };
  32. struct wlantest_pmk {
  33. struct dl_list list;
  34. u8 pmk[32];
  35. };
  36. struct wlantest_sta {
  37. struct dl_list list;
  38. u8 addr[ETH_ALEN];
  39. enum {
  40. STATE1 /* not authenticated */,
  41. STATE2 /* authenticated */,
  42. STATE3 /* associated */
  43. } state;
  44. u16 aid;
  45. u8 rsnie[257]; /* WPA/RSN IE */
  46. u8 anonce[32]; /* ANonce from the previous EAPOL-Key msg 1/4 or 3/4 */
  47. u8 snonce[32]; /* SNonce from the previous EAPOL-Key msg 2/4 */
  48. struct wpa_ptk ptk; /* Derived PTK */
  49. int ptk_set;
  50. };
  51. struct wlantest_bss {
  52. struct dl_list list;
  53. u8 bssid[ETH_ALEN];
  54. u16 capab_info;
  55. u8 ssid[32];
  56. size_t ssid_len;
  57. int proberesp_seen;
  58. int parse_error_reported;
  59. u8 wpaie[257];
  60. u8 rsnie[257];
  61. struct dl_list sta; /* struct wlantest_sta */
  62. struct dl_list pmk; /* struct wlantest_pmk */
  63. u8 gtk[4][32];
  64. size_t gtk_len[4];
  65. u8 igtk[6][16];
  66. int igtk_set[6];
  67. };
  68. struct wlantest_radius {
  69. struct dl_list list;
  70. u32 srv;
  71. u32 cli;
  72. struct radius_msg *last_req;
  73. };
  74. struct wlantest {
  75. int monitor_sock;
  76. int monitor_wired;
  77. struct dl_list passphrase; /* struct wlantest_passphrase */
  78. struct dl_list bss; /* struct wlantest_bss */
  79. struct dl_list secret; /* struct wlantest_radius_secret */
  80. struct dl_list radius; /* struct wlantest_radius */
  81. struct dl_list pmk; /* struct wlantest_pmk */
  82. unsigned int rx_mgmt;
  83. unsigned int rx_ctrl;
  84. unsigned int rx_data;
  85. unsigned int fcs_error;
  86. };
  87. int read_cap_file(struct wlantest *wt, const char *fname);
  88. int read_wired_cap_file(struct wlantest *wt, const char *fname);
  89. void wlantest_process(struct wlantest *wt, const u8 *data, size_t len);
  90. void wlantest_process_wired(struct wlantest *wt, const u8 *data, size_t len);
  91. u32 crc32(const u8 *frame, size_t frame_len);
  92. int monitor_init(struct wlantest *wt, const char *ifname);
  93. int monitor_init_wired(struct wlantest *wt, const char *ifname);
  94. void monitor_deinit(struct wlantest *wt);
  95. void rx_mgmt(struct wlantest *wt, const u8 *data, size_t len);
  96. void rx_data(struct wlantest *wt, const u8 *data, size_t len);
  97. struct wlantest_bss * bss_get(struct wlantest *wt, const u8 *bssid);
  98. void bss_deinit(struct wlantest_bss *bss);
  99. void bss_update(struct wlantest *wt, struct wlantest_bss *bss,
  100. struct ieee802_11_elems *elems);
  101. void pmk_deinit(struct wlantest_pmk *pmk);
  102. struct wlantest_sta * sta_get(struct wlantest_bss *bss, const u8 *addr);
  103. void sta_deinit(struct wlantest_sta *sta);
  104. void sta_update_assoc(struct wlantest_sta *sta,
  105. struct ieee802_11_elems *elems);
  106. #endif /* WLANTEST_H */