diff options
41 files changed, 457 insertions, 225 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index cb0ee76..aa87f3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -5,7 +5,7 @@ project(wifi DESCRIPTION "802.11 Parsing / Generation library" VERSION 0.1) | |||
5 | execute_process(COMMAND git rev-parse --abbrev-ref HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GITBRANCH) | 5 | execute_process(COMMAND git rev-parse --abbrev-ref HEAD OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GITBRANCH) |
6 | execute_process(COMMAND git log -1 --pretty=format:%h OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GITHASH) | 6 | execute_process(COMMAND git log -1 --pretty=format:%h OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE GITHASH) |
7 | execute_process(COMMAND date OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE BUILDTIME) | 7 | execute_process(COMMAND date OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_VARIABLE BUILDTIME) |
8 | set(LIBWIFI_VERSION "0.0.2") | 8 | set(LIBWIFI_VERSION "0.0.3") |
9 | 9 | ||
10 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu17") | 10 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu17") |
11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") | 11 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra") |
@@ -24,6 +24,16 @@ message("-----------------------------------") | |||
24 | message("802.11 Parsing / Generation Library") | 24 | message("802.11 Parsing / Generation Library") |
25 | message("Version: ${LIBWIFI_VERSION}, Git: ${GITBRANCH} (${GITHASH}), Time: ${BUILDTIME}") | 25 | message("Version: ${LIBWIFI_VERSION}, Git: ${GITBRANCH} (${GITHASH}), Time: ${BUILDTIME}") |
26 | message("Compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") | 26 | message("Compiler: ${CMAKE_C_COMPILER_ID} ${CMAKE_C_COMPILER_VERSION}") |
27 | |||
28 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
29 | message("Building for Debug") | ||
30 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -O0") | ||
31 | add_compile_definitions(LIBWIFI_VERSION="dev-${GITBRANCH}-${GITHASH}") | ||
32 | else() | ||
33 | message("Building for Release") | ||
34 | add_compile_definitions(LIBWIFI_VERSION="${LIBWIFI_VERSION}") | ||
35 | endif(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
36 | |||
27 | message(" ") | 37 | message(" ") |
28 | 38 | ||
29 | file(GLOB_RECURSE libwifi_src | 39 | file(GLOB_RECURSE libwifi_src |
@@ -31,11 +41,6 @@ file(GLOB_RECURSE libwifi_src | |||
31 | "src/libwifi/*.c" | 41 | "src/libwifi/*.c" |
32 | ) | 42 | ) |
33 | 43 | ||
34 | if (CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
35 | message("Building as Debug") | ||
36 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ggdb -O0") | ||
37 | endif(CMAKE_BUILD_TYPE STREQUAL "Debug") | ||
38 | |||
39 | add_library(wifi SHARED ${libwifi_src}) | 44 | add_library(wifi SHARED ${libwifi_src}) |
40 | 45 | ||
41 | set_target_properties(wifi PROPERTIES LINKER_LANGUAGE C) | 46 | set_target_properties(wifi PROPERTIES LINKER_LANGUAGE C) |
diff --git a/README.md b/README.md index 846ec94..46e4b00 100644 --- a/README.md +++ b/README.md | |||
@@ -13,7 +13,7 @@ It is written with a simple-to-use approach while also exposing features that al | |||
13 | The library is fully documented with code comments in both the headers files and the code files. | 13 | The library is fully documented with code comments in both the headers files and the code files. |
14 | 14 | ||
15 | ## Building and Installing | 15 | ## Building and Installing |
16 | ### Linux | 16 | ### Building as Release |
17 | ``` | 17 | ``` |
18 | $ mkdir build | 18 | $ mkdir build |
19 | $ cd build | 19 | $ cd build |
@@ -21,6 +21,19 @@ $ cmake .. | |||
21 | $ make | 21 | $ make |
22 | $ sudo make install | 22 | $ sudo make install |
23 | ``` | 23 | ``` |
24 | ### Building as Debug | ||
25 | You can also specify `-DCMAKE_BUILD_TYPE=Debug` to CMake, to generate a library with debug symbols present. This also sets the library version number to `dev-BRANCHNAME-COMMITHASH`. | ||
26 | ``` | ||
27 | $ mkdir build | ||
28 | $ cd build | ||
29 | $ cmake .. -DCMAKE_BUILD_TYPE=Debug | ||
30 | $ make | ||
31 | $ sudo make install | ||
32 | ``` | ||
33 | ``` | ||
34 | $ ./test_misc | ||
35 | libwifi version: dev-fixup-7909700 | ||
36 | ``` | ||
24 | 37 | ||
25 | ## Examples | 38 | ## Examples |
26 | Some examples are available in the `examples/` directory, which show the general flow of how libwifi is used to generate and parse different types of 802.11 frame. | 39 | Some examples are available in the `examples/` directory, which show the general flow of how libwifi is used to generate and parse different types of 802.11 frame. |
diff --git a/examples/generate_beacon/generate_beacon.c b/examples/generate_beacon/generate_beacon.c index b994161..dcd1913 100644 --- a/examples/generate_beacon/generate_beacon.c +++ b/examples/generate_beacon/generate_beacon.c | |||
@@ -19,7 +19,7 @@ void create_write_beacon() { | |||
19 | libwifi_random_mac(transmitter, NULL); | 19 | libwifi_random_mac(transmitter, NULL); |
20 | unsigned char receiver[6] = "\xFF\xFF\xFF\xFF\xFF\xFF"; | 20 | unsigned char receiver[6] = "\xFF\xFF\xFF\xFF\xFF\xFF"; |
21 | 21 | ||
22 | libwifi_create_beacon(&beacon, receiver, transmitter, "libwifi-beacon", 6); | 22 | libwifi_create_beacon(&beacon, receiver, transmitter, transmitter, "libwifi-beacon", 6); |
23 | libwifi_quick_add_tag(&beacon.tags, TAG_VENDOR_SPECIFIC, | 23 | libwifi_quick_add_tag(&beacon.tags, TAG_VENDOR_SPECIFIC, |
24 | (unsigned char *) "libwifi-tag", strlen("libwifi-tag")); | 24 | (unsigned char *) "libwifi-tag", strlen("libwifi-tag")); |
25 | 25 | ||
diff --git a/src/libwifi/core/core.h b/src/libwifi/core/core.h index 02e6d45..75043a6 100644 --- a/src/libwifi/core/core.h +++ b/src/libwifi/core/core.h | |||
@@ -16,7 +16,9 @@ | |||
16 | #ifndef LIBWIFI_CORE_H | 16 | #ifndef LIBWIFI_CORE_H |
17 | #define LIBWIFI_CORE_H | 17 | #define LIBWIFI_CORE_H |
18 | 18 | ||
19 | #define LIBWIFI_VERSION "0.0.1" | 19 | #ifndef LIBWIFI_VERSION |
20 | #define LIBWIFI_VERSION "UNSET_VERSION" | ||
21 | #endif | ||
20 | 22 | ||
21 | /** | 23 | /** |
22 | * Commonly used fixed fields | 24 | * Commonly used fixed fields |
diff --git a/src/libwifi/gen/management/action.c b/src/libwifi/gen/management/action.c index 04d7a5f..dc37987 100644 --- a/src/libwifi/gen/management/action.c +++ b/src/libwifi/gen/management/action.c | |||
@@ -46,15 +46,18 @@ void libwifi_free_action_detail(struct libwifi_action_detail *detail) { | |||
46 | } | 46 | } |
47 | } | 47 | } |
48 | 48 | ||
49 | int libwifi_create_action(struct libwifi_action *action, const unsigned char receiver[6], | 49 | int libwifi_create_action(struct libwifi_action *action, |
50 | const unsigned char transmitter[6], uint8_t category) { | 50 | const unsigned char receiver[6], |
51 | const unsigned char transmitter[6], | ||
52 | const unsigned char address3[6], | ||
53 | uint8_t category) { | ||
51 | memset(action, 0, sizeof(struct libwifi_action)); | 54 | memset(action, 0, sizeof(struct libwifi_action)); |
52 | 55 | ||
53 | action->frame_header.frame_control.type = TYPE_MANAGEMENT; | 56 | action->frame_header.frame_control.type = TYPE_MANAGEMENT; |
54 | action->frame_header.frame_control.subtype = SUBTYPE_ACTION; | 57 | action->frame_header.frame_control.subtype = SUBTYPE_ACTION; |
55 | memcpy(&action->frame_header.addr1, receiver, 6); | 58 | memcpy(&action->frame_header.addr1, receiver, 6); |
56 | memcpy(&action->frame_header.addr2, transmitter, 6); | 59 | memcpy(&action->frame_header.addr2, transmitter, 6); |
57 | memcpy(&action->frame_header.addr3, transmitter, 6); | 60 | memcpy(&action->frame_header.addr3, address3, 6); |
58 | 61 | ||
59 | action->frame_header.seq_control.sequence_number = (rand() % 4096); | 62 | action->frame_header.seq_control.sequence_number = (rand() % 4096); |
60 | 63 | ||
@@ -63,15 +66,18 @@ int libwifi_create_action(struct libwifi_action *action, const unsigned char rec | |||
63 | return 0; | 66 | return 0; |
64 | } | 67 | } |
65 | 68 | ||
66 | int libwifi_create_action_no_ack(struct libwifi_action *action, const unsigned char receiver[6], | 69 | int libwifi_create_action_no_ack(struct libwifi_action *action, |
67 | const unsigned char transmitter[6], uint8_t category) { | 70 | const unsigned char receiver[6], |
71 | const unsigned char transmitter[6], | ||
72 | const unsigned char address3[6], | ||
73 | uint8_t category) { | ||
68 | memset(action, 0, sizeof(struct libwifi_action)); | 74 | memset(action, 0, sizeof(struct libwifi_action)); |
69 | 75 | ||
70 | action->frame_header.frame_control.type = TYPE_MANAGEMENT; | 76 | action->frame_header.frame_control.type = TYPE_MANAGEMENT; |
71 | action->frame_header.frame_control.subtype = SUBTYPE_ACTION_NOACK; | 77 | action->frame_header.frame_control.subtype = SUBTYPE_ACTION_NOACK; |
72 | memcpy(&action->frame_header.addr1, receiver, 6); | 78 | memcpy(&action->frame_header.addr1, receiver, 6); |
73 | memcpy(&action->frame_header.addr2, transmitter, 6); | 79 | memcpy(&action->frame_header.addr2, transmitter, 6); |
74 | memcpy(&action->frame_header.addr3, transmitter, 6); | 80 | memcpy(&action->frame_header.addr3, address3, 6); |
75 | 81 | ||
76 | action->frame_header.seq_control.sequence_number = (rand() % 4096); | 82 | action->frame_header.seq_control.sequence_number = (rand() % 4096); |
77 | 83 | ||
diff --git a/src/libwifi/gen/management/action.h b/src/libwifi/gen/management/action.h index ae1b5cc..2073f7d 100644 --- a/src/libwifi/gen/management/action.h +++ b/src/libwifi/gen/management/action.h | |||
@@ -23,12 +23,13 @@ | |||
23 | * Create a detail for an action frame by supplying raw data and it's length. | 23 | * Create a detail for an action frame by supplying raw data and it's length. |
24 | * New data can be added to an existing libwifi_action_detail. | 24 | * New data can be added to an existing libwifi_action_detail. |
25 | * | 25 | * |
26 | * @param detail A libwifi_action_detail struct | 26 | * @param detail A libwifi_action_detail struct |
27 | * @param data Raw data to be added to the libwifi_action_detail | 27 | * @param data Raw data to be added to the libwifi_action_detail |
28 | * @param data_len Length of the raw data | 28 | * @param data_len Length of the raw data |
29 | * @return Length of the action | 29 | * @return Length of the action, or negative error |
30 | */ | 30 | */ |
31 | size_t libwifi_add_action_detail(struct libwifi_action_detail *detail, const unsigned char *data, | 31 | size_t libwifi_add_action_detail(struct libwifi_action_detail *detail, |
32 | const unsigned char *data, | ||
32 | size_t data_len); | 33 | size_t data_len); |
33 | 34 | ||
34 | /** | 35 | /** |
@@ -44,13 +45,20 @@ void libwifi_free_action_detail(struct libwifi_action_detail *detail); | |||
44 | * @param action A new libwifi_action struct | 45 | * @param action A new libwifi_action struct |
45 | * @param receiver The receiver MAC address | 46 | * @param receiver The receiver MAC address |
46 | * @param transmitter The transmitter MAC address | 47 | * @param transmitter The transmitter MAC address |
48 | * @param address3 The address 3 frame field value, typically the BSSID | ||
47 | * @param category The action frame category | 49 | * @param category The action frame category |
48 | * @return zero on success | 50 | * @return Zero on success, or negative error |
49 | */ | 51 | */ |
50 | int libwifi_create_action(struct libwifi_action *action, const unsigned char receiver[6], | 52 | int libwifi_create_action(struct libwifi_action *action, |
51 | const unsigned char transmitter[6], uint8_t category); | 53 | const unsigned char receiver[6], |
52 | int libwifi_create_action_no_ack(struct libwifi_action *action, const unsigned char receiver[6], | 54 | const unsigned char transmitter[6], |
53 | const unsigned char transmitter[6], uint8_t category); | 55 | const unsigned char address3[6], |
56 | uint8_t category); | ||
57 | int libwifi_create_action_no_ack(struct libwifi_action *action, | ||
58 | const unsigned char receiver[6], | ||
59 | const unsigned char transmitter[6], | ||
60 | const unsigned char address3[6], | ||
61 | uint8_t category); | ||
54 | 62 | ||
55 | /** | 63 | /** |
56 | * Get the length of a given libwifi_action | 64 | * Get the length of a given libwifi_action |
@@ -63,10 +71,10 @@ size_t libwifi_get_action_length(struct libwifi_action *action); | |||
63 | /** | 71 | /** |
64 | * Dump a given libwifi_action to a raw buffer | 72 | * Dump a given libwifi_action to a raw buffer |
65 | * | 73 | * |
66 | * @param action A used libwifi_action struct | 74 | * @param action A used libwifi_action struct |
67 | * @param buf A buffer receiver | 75 | * @param buf A buffer receiver |
68 | * @param buf_len The length of the given buf | 76 | * @param buf_len The length of the given buf |
69 | * @return Bytes written to the buf | 77 | * @return Bytes written to the buf, or negative error |
70 | */ | 78 | */ |
71 | size_t libwifi_dump_action(struct libwifi_action *action, unsigned char *buf, size_t buf_len); | 79 | size_t libwifi_dump_action(struct libwifi_action *action, unsigned char *buf, size_t buf_len); |
72 | 80 | ||
diff --git a/src/libwifi/gen/management/assoc_request.c b/src/libwifi/gen/management/assoc_request.c index 268b167..e9d720e 100644 --- a/src/libwifi/gen/management/assoc_request.c +++ b/src/libwifi/gen/management/assoc_request.c | |||
@@ -33,15 +33,19 @@ size_t libwifi_get_assoc_req_length(struct libwifi_assoc_req *assoc_req) { | |||
33 | * The generated association request frame is made with sane defaults defined in common.h. | 33 | * The generated association request frame is made with sane defaults defined in common.h. |
34 | * Two tagged parameters are also added to the association request: SSID and Channel. | 34 | * Two tagged parameters are also added to the association request: SSID and Channel. |
35 | */ | 35 | */ |
36 | int libwifi_create_assoc_req(struct libwifi_assoc_req *assoc_req, const unsigned char receiver[6], | 36 | int libwifi_create_assoc_req(struct libwifi_assoc_req *assoc_req, |
37 | const unsigned char transmitter[6], const char *ssid, uint8_t channel) { | 37 | const unsigned char receiver[6], |
38 | const unsigned char transmitter[6], | ||
39 | const unsigned char address3[6], | ||
40 | const char *ssid, | ||
41 | uint8_t channel) { | ||
38 | memset(assoc_req, 0, sizeof(struct libwifi_assoc_req)); | 42 | memset(assoc_req, 0, sizeof(struct libwifi_assoc_req)); |
39 | 43 | ||
40 | assoc_req->frame_header.frame_control.type = TYPE_MANAGEMENT; | 44 | assoc_req->frame_header.frame_control.type = TYPE_MANAGEMENT; |
41 | assoc_req->frame_header.frame_control.subtype = SUBTYPE_ASSOC_REQ; | 45 | assoc_req->frame_header.frame_control.subtype = SUBTYPE_ASSOC_REQ; |
42 | memcpy(&assoc_req->frame_header.addr1, receiver, 6); | 46 | memcpy(&assoc_req->frame_header.addr1, receiver, 6); |
43 | memcpy(&assoc_req->frame_header.addr2, transmitter, 6); | 47 | memcpy(&assoc_req->frame_header.addr2, transmitter, 6); |
44 | memcpy(&assoc_req->frame_header.addr3, receiver, 6); | 48 | memcpy(&assoc_req->frame_header.addr3, address3, 6); |
45 | assoc_req->frame_header.seq_control.sequence_number = (rand() % 4096); | 49 | assoc_req->frame_header.seq_control.sequence_number = (rand() % 4096); |
46 | 50 | ||
47 | assoc_req->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); | 51 | assoc_req->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); |
diff --git a/src/libwifi/gen/management/assoc_request.h b/src/libwifi/gen/management/assoc_request.h index 85cbd3b..fc43d03 100644 --- a/src/libwifi/gen/management/assoc_request.h +++ b/src/libwifi/gen/management/assoc_request.h | |||
@@ -24,16 +24,44 @@ | |||
24 | * Create a new association request | 24 | * Create a new association request |
25 | * | 25 | * |
26 | * @param assoc_req A new libwifi_assoc_req struct | 26 | * @param assoc_req A new libwifi_assoc_req struct |
27 | * @param receiver The receiver MAC address | 27 | * @param receiver The receiver MAC address |
28 | * @param transmitter The transmitter MAC address | 28 | * @param transmitter The transmitter MAC address |
29 | * @param address3 The address 3 frame field value, typically the BSSID | ||
29 | * @param ssid The desired BSS SSID | 30 | * @param ssid The desired BSS SSID |
30 | * @param channel The desired channel | 31 | * @param channel The desired channel |
31 | * @param zero on success | 32 | * @param Zero on success, or negative error |
33 | */ | ||
34 | int libwifi_create_assoc_req(struct libwifi_assoc_req *assoc_req, | ||
35 | const unsigned char receiver[6], | ||
36 | const unsigned char transmitter[6], | ||
37 | const unsigned char address3[6], | ||
38 | const char *ssid, | ||
39 | uint8_t channel); | ||
40 | |||
41 | /** | ||
42 | * Get the length of a given libwifi_assoc_req | ||
43 | * | ||
44 | * @param assoc_req A libwifi_assoc_req struct | ||
45 | * @return Length of the given libwifi_assoc_req | ||
32 | */ | 46 | */ |
33 | int libwifi_create_assoc_req(struct libwifi_assoc_req *assoc_req, const unsigned char receiver[6], | ||
34 | const unsigned char transmitter[6], const char *ssid, uint8_t channel); | ||
35 | size_t libwifi_get_assoc_req_length(struct libwifi_assoc_req *assoc_req); | 47 | size_t libwifi_get_assoc_req_length(struct libwifi_assoc_req *assoc_req); |
48 | |||
49 | /** | ||
50 | * Dump a libwifi_assoc_req into a raw format for packet injection. | ||
51 | * | ||
52 | * @param assoc_req A libwifi_assoc_req struct | ||
53 | * @param buf The buffer to dump into | ||
54 | * @param buf_len The length of the supplied buffer | ||
55 | * @param The amount of bytes dumped, or negative error | ||
56 | */ | ||
36 | size_t libwifi_dump_assoc_req(struct libwifi_assoc_req *assoc_req, unsigned char *buf, size_t buf_len); | 57 | size_t libwifi_dump_assoc_req(struct libwifi_assoc_req *assoc_req, unsigned char *buf, size_t buf_len); |
58 | |||
59 | |||
60 | /** | ||
61 | * Free any memory claimed by a libwifi_assoc_req back to the system. | ||
62 | * | ||
63 | * @param assoc_req A libwifi_assoc_req | ||
64 | */ | ||
37 | void libwifi_free_assoc_req(struct libwifi_assoc_req *assoc_req); | 65 | void libwifi_free_assoc_req(struct libwifi_assoc_req *assoc_req); |
38 | 66 | ||
39 | #endif /* LIBWIFI_GEN_ASSOCREQUEST_H */ | 67 | #endif /* LIBWIFI_GEN_ASSOCREQUEST_H */ |
diff --git a/src/libwifi/gen/management/assoc_response.c b/src/libwifi/gen/management/assoc_response.c index 70f53d6..0fd145c 100644 --- a/src/libwifi/gen/management/assoc_response.c +++ b/src/libwifi/gen/management/assoc_response.c | |||
@@ -33,7 +33,8 @@ | |||
33 | */ | 33 | */ |
34 | size_t libwifi_get_assoc_resp_length(struct libwifi_assoc_resp *assoc_resp) { | 34 | size_t libwifi_get_assoc_resp_length(struct libwifi_assoc_resp *assoc_resp) { |
35 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + | 35 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + |
36 | sizeof(struct libwifi_assoc_resp_fixed_parameters) + assoc_resp->tags.length; | 36 | sizeof(struct libwifi_assoc_resp_fixed_parameters) + |
37 | assoc_resp->tags.length; | ||
37 | } | 38 | } |
38 | 39 | ||
39 | /** | 40 | /** |
@@ -61,14 +62,18 @@ int libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_ | |||
61 | * The generated association response frame is made with sane defaults defined in common.h and core/types.h. | 62 | * The generated association response frame is made with sane defaults defined in common.h and core/types.h. |
62 | * Two tagged parameters are also added to the association response: Channel and Supported Rates. | 63 | * Two tagged parameters are also added to the association response: Channel and Supported Rates. |
63 | */ | 64 | */ |
64 | int libwifi_create_assoc_resp(struct libwifi_assoc_resp *assoc_resp, const unsigned char receiver[6], | 65 | int libwifi_create_assoc_resp(struct libwifi_assoc_resp *assoc_resp, |
65 | const unsigned char transmitter[6], uint8_t channel) { | 66 | const unsigned char receiver[6], |
67 | const unsigned char transmitter[6], | ||
68 | const unsigned char address3[6], | ||
69 | uint8_t channel) { | ||
66 | memset(assoc_resp, 0, sizeof(struct libwifi_assoc_resp)); | 70 | memset(assoc_resp, 0, sizeof(struct libwifi_assoc_resp)); |
67 | 71 | ||
68 | assoc_resp->frame_header.frame_control.type = TYPE_MANAGEMENT; | 72 | assoc_resp->frame_header.frame_control.type = TYPE_MANAGEMENT; |
69 | assoc_resp->frame_header.frame_control.subtype = SUBTYPE_ASSOC_RESP; | 73 | assoc_resp->frame_header.frame_control.subtype = SUBTYPE_ASSOC_RESP; |
70 | memcpy(&assoc_resp->frame_header.addr1, receiver, 6); | 74 | memcpy(&assoc_resp->frame_header.addr1, receiver, 6); |
71 | memcpy(&assoc_resp->frame_header.addr2, transmitter, 6); | 75 | memcpy(&assoc_resp->frame_header.addr2, transmitter, 6); |
76 | memcpy(&assoc_resp->frame_header.addr3, address3, 6); | ||
72 | 77 | ||
73 | assoc_resp->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); | 78 | assoc_resp->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); |
74 | assoc_resp->fixed_parameters.status_code = STATUS_SUCCESS; | 79 | assoc_resp->fixed_parameters.status_code = STATUS_SUCCESS; |
diff --git a/src/libwifi/gen/management/assoc_response.h b/src/libwifi/gen/management/assoc_response.h index 07ad4b4..cac0171 100644 --- a/src/libwifi/gen/management/assoc_response.h +++ b/src/libwifi/gen/management/assoc_response.h | |||
@@ -22,7 +22,8 @@ | |||
22 | * Set the channel of a libwifi_assoc_resp. | 22 | * Set the channel of a libwifi_assoc_resp. |
23 | * | 23 | * |
24 | * @param assoc_resp A libwifi_assoc_resp | 24 | * @param assoc_resp A libwifi_assoc_resp |
25 | * @param channel The new channel | 25 | * @param channel The new channel |
26 | * @return Zero on success, or negative error | ||
26 | */ | 27 | */ |
27 | int libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_t channel); | 28 | int libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_t channel); |
28 | 29 | ||
@@ -30,7 +31,7 @@ int libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_ | |||
30 | * Calculate the length of a given libwifi_assoc_resp | 31 | * Calculate the length of a given libwifi_assoc_resp |
31 | * | 32 | * |
32 | * @param assoc_resp A libwifi_assoc_resp | 33 | * @param assoc_resp A libwifi_assoc_resp |
33 | * @return The length of the given assoc_resp | 34 | * @return The length of the given assoc_resp, or negative error |
34 | */ | 35 | */ |
35 | size_t libwifi_get_assoc_resp_length(struct libwifi_assoc_resp *assoc_resp); | 36 | size_t libwifi_get_assoc_resp_length(struct libwifi_assoc_resp *assoc_resp); |
36 | 37 | ||
@@ -40,22 +41,26 @@ size_t libwifi_get_assoc_resp_length(struct libwifi_assoc_resp *assoc_resp); | |||
40 | * A generated libwifi assoc_resp can be "dumped" into a buffer for packet injection | 41 | * A generated libwifi assoc_resp can be "dumped" into a buffer for packet injection |
41 | * via the libwifi_dump_assoc_resp. | 42 | * via the libwifi_dump_assoc_resp. |
42 | * | 43 | * |
43 | * @param assoc_resp A libwifi_assoc_resp | 44 | * @param assoc_resp A libwifi_assoc_resp |
44 | * @param receiver The receiver MAC address, aka address 1 | 45 | * @param receiver The receiver MAC address, aka address 1 |
45 | * @param transmitter The source MAC address, aka address 2 | 46 | * @param transmitter The source MAC address, aka address 2 |
46 | * @param channel The desired channel of the assoc_resp | 47 | * @param address3 The address 3 frame field value, typically the BSSID |
47 | * | 48 | * @param channel The desired channel of the assoc_resp |
49 | * @return Zero on success, or negative error | ||
48 | */ | 50 | */ |
49 | int libwifi_create_assoc_resp(struct libwifi_assoc_resp *assoc_resp, const unsigned char receiver[6], | 51 | int libwifi_create_assoc_resp(struct libwifi_assoc_resp *assoc_resp, |
50 | const unsigned char transmitter[6], uint8_t channel); | 52 | const unsigned char receiver[6], |
53 | const unsigned char transmitter[6], | ||
54 | const unsigned char address3[6], | ||
55 | uint8_t channel); | ||
51 | 56 | ||
52 | /** | 57 | /** |
53 | * Dump a libwifi_assoc_resp into a raw format for packet injection. | 58 | * Dump a libwifi_assoc_resp into a raw format for packet injection. |
54 | * | 59 | * |
55 | * @param assoc_resp A libwifi_assoc_resp | 60 | * @param assoc_resp A libwifi_assoc_resp |
56 | * @param buf The output buffer for the frame data | 61 | * @param buf The output buffer for the frame data |
57 | * @param buf_len The length of the output buffer | 62 | * @param buf_len The length of the output buffer |
58 | * @return The length of the dumped assoc_resp | 63 | * @return The length of the dumped assoc_resp, or negative error |
59 | */ | 64 | */ |
60 | size_t libwifi_dump_assoc_resp(struct libwifi_assoc_resp *assoc_resp, unsigned char *buf, size_t buf_len); | 65 | size_t libwifi_dump_assoc_resp(struct libwifi_assoc_resp *assoc_resp, unsigned char *buf, size_t buf_len); |
61 | 66 | ||
diff --git a/src/libwifi/gen/management/atim.c b/src/libwifi/gen/management/atim.c index 960a2de..60b5203 100644 --- a/src/libwifi/gen/management/atim.c +++ b/src/libwifi/gen/management/atim.c | |||
@@ -18,15 +18,17 @@ | |||
18 | #include <stdlib.h> | 18 | #include <stdlib.h> |
19 | #include <string.h> | 19 | #include <string.h> |
20 | 20 | ||
21 | int libwifi_create_atim(struct libwifi_atim *atim, const unsigned char transmitter[6], | 21 | int libwifi_create_atim(struct libwifi_atim *atim, |
22 | const unsigned char receiver[6], const unsigned char bssid[6]) { | 22 | const unsigned char transmitter[6], |
23 | const unsigned char receiver[6], | ||
24 | const unsigned char address3[6]) { | ||
23 | memset(atim, 0, sizeof(struct libwifi_atim)); | 25 | memset(atim, 0, sizeof(struct libwifi_atim)); |
24 | 26 | ||
25 | atim->frame_header.frame_control.type = TYPE_MANAGEMENT; | 27 | atim->frame_header.frame_control.type = TYPE_MANAGEMENT; |
26 | atim->frame_header.frame_control.subtype = SUBTYPE_ATIM; | 28 | atim->frame_header.frame_control.subtype = SUBTYPE_ATIM; |
27 | memcpy(&atim->frame_header.addr1, transmitter, 6); | 29 | memcpy(&atim->frame_header.addr1, transmitter, 6); |
28 | memcpy(&atim->frame_header.addr2, receiver, 6); | 30 | memcpy(&atim->frame_header.addr2, receiver, 6); |
29 | memcpy(&atim->frame_header.addr3, bssid, 6); | 31 | memcpy(&atim->frame_header.addr3, address3, 6); |
30 | atim->frame_header.frame_control.flags.power_mgmt = 1; | 32 | atim->frame_header.frame_control.flags.power_mgmt = 1; |
31 | atim->frame_header.duration = (rand() % 4096); | 33 | atim->frame_header.duration = (rand() % 4096); |
32 | atim->frame_header.seq_control.sequence_number = (rand() % 4096); | 34 | atim->frame_header.seq_control.sequence_number = (rand() % 4096); |
diff --git a/src/libwifi/gen/management/atim.h b/src/libwifi/gen/management/atim.h index d9a306a..ca3b8a4 100644 --- a/src/libwifi/gen/management/atim.h +++ b/src/libwifi/gen/management/atim.h | |||
@@ -18,7 +18,18 @@ | |||
18 | 18 | ||
19 | #include "../../core/frame/management/atim.h" | 19 | #include "../../core/frame/management/atim.h" |
20 | 20 | ||
21 | int libwifi_create_atim(struct libwifi_atim *atim, const unsigned char transmitter[6], | 21 | /** |
22 | const unsigned char receiver[6], const unsigned char bssid[6]); | 22 | * Generate a populated ATIM frame. |
23 | * | ||
24 | * @param atim A new libwifi_atim struct | ||
25 | * @param transmitter The transmitter address, aka address 1 | ||
26 | * @param receiver The receiver address, aka address 2 | ||
27 | * @param address3 The address 3 frame value, typically the BSSID | ||
28 | * @return Zero on success, or negative error | ||
29 | */ | ||
30 | int libwifi_create_atim(struct libwifi_atim *atim, | ||
31 | const unsigned char transmitter[6], | ||
32 | const unsigned char receiver[6], | ||
33 | const unsigned char address3[6]); | ||
23 | 34 | ||
24 | #endif /* LIBWIFI_GEN_ATIM_H */ | 35 | #endif /* LIBWIFI_GEN_ATIM_H */ |
diff --git a/src/libwifi/gen/management/authentication.c b/src/libwifi/gen/management/authentication.c index e8ffea2..fa1d769 100644 --- a/src/libwifi/gen/management/authentication.c +++ b/src/libwifi/gen/management/authentication.c | |||
@@ -32,16 +32,20 @@ size_t libwifi_get_auth_length(struct libwifi_auth *auth) { | |||
32 | /** | 32 | /** |
33 | * The generated authentication frame is made with sane defaults defined in common.h. | 33 | * The generated authentication frame is made with sane defaults defined in common.h. |
34 | */ | 34 | */ |
35 | int libwifi_create_auth(struct libwifi_auth *auth, const unsigned char receiver[6], | 35 | int libwifi_create_auth(struct libwifi_auth *auth, |
36 | const unsigned char transmitter[6], uint16_t algorithm_number, | 36 | const unsigned char receiver[6], |
37 | uint16_t transaction_sequence, uint16_t status_code) { | 37 | const unsigned char transmitter[6], |
38 | const unsigned char address3[6], | ||
39 | uint16_t algorithm_number, | ||
40 | uint16_t transaction_sequence, | ||
41 | uint16_t status_code) { | ||
38 | memset(auth, 0, sizeof(struct libwifi_auth)); | 42 | memset(auth, 0, sizeof(struct libwifi_auth)); |
39 | 43 | ||
40 | auth->frame_header.frame_control.type = TYPE_MANAGEMENT; | 44 | auth->frame_header.frame_control.type = TYPE_MANAGEMENT; |
41 | auth->frame_header.frame_control.subtype = SUBTYPE_AUTH; | 45 | auth->frame_header.frame_control.subtype = SUBTYPE_AUTH; |
42 | memcpy(&auth->frame_header.addr1, receiver, 6); | 46 | memcpy(&auth->frame_header.addr1, receiver, 6); |
43 | memcpy(&auth->frame_header.addr2, transmitter, 6); | 47 | memcpy(&auth->frame_header.addr2, transmitter, 6); |
44 | memcpy(&auth->frame_header.addr3, transmitter, 6); | 48 | memcpy(&auth->frame_header.addr3, address3, 6); |
45 | auth->frame_header.seq_control.sequence_number = (rand() % 4096); | 49 | auth->frame_header.seq_control.sequence_number = (rand() % 4096); |
46 | 50 | ||
47 | auth->fixed_parameters.algorithm_number = algorithm_number; | 51 | auth->fixed_parameters.algorithm_number = algorithm_number; |
diff --git a/src/libwifi/gen/management/authentication.h b/src/libwifi/gen/management/authentication.h index 75e8dcf..5468c5f 100644 --- a/src/libwifi/gen/management/authentication.h +++ b/src/libwifi/gen/management/authentication.h | |||
@@ -24,7 +24,7 @@ | |||
24 | * Calculate the length of a given libwifi_auth | 24 | * Calculate the length of a given libwifi_auth |
25 | * | 25 | * |
26 | * @param auth A libwifi_auth | 26 | * @param auth A libwifi_auth |
27 | * @return The length of the given auth | 27 | * @return The length of the given auth |
28 | */ | 28 | */ |
29 | size_t libwifi_get_auth_length(struct libwifi_auth *auth); | 29 | size_t libwifi_get_auth_length(struct libwifi_auth *auth); |
30 | 30 | ||
@@ -34,23 +34,30 @@ size_t libwifi_get_auth_length(struct libwifi_auth *auth); | |||
34 | * A generated libwifi auth can be "dumped" into a buffer for packet injection | 34 | * A generated libwifi auth can be "dumped" into a buffer for packet injection |
35 | * via the libwifi_dump_auth. | 35 | * via the libwifi_dump_auth. |
36 | * | 36 | * |
37 | * @param auth A libwifi_auth | 37 | * @param auth A libwifi_auth |
38 | * @param receiver The receiver MAC address, aka address 1 | 38 | * @param receiver The receiver MAC address, aka address 1 |
39 | * @param transmitter The source MAC address, aka address 2 | 39 | * @param transmitter The source MAC address, aka address 2 |
40 | * @param algorithm_number Algorithm type to use | 40 | * @param address3 The address 3 frame field value, typically the BSSID |
41 | * | 41 | * @param algorithm_number Algorithm type to use, as defined in the IEEE802.11 spec |
42 | * @param transaction_sequence Transaction sequence value to use | ||
43 | * @param status_code Status code to use, as defined in the IEEE802.11 spec | ||
44 | * @return Zero on success, or negative error | ||
42 | */ | 45 | */ |
43 | int libwifi_create_auth(struct libwifi_auth *auth, const unsigned char receiver[6], | 46 | int libwifi_create_auth(struct libwifi_auth *auth, |
44 | const unsigned char transmitter[6], uint16_t algorithm_number, | 47 | const unsigned char receiver[6], |
45 | uint16_t transaction_sequence, uint16_t status_code); | 48 | const unsigned char transmitter[6], |
49 | const unsigned char address3[6], | ||
50 | uint16_t algorithm_number, | ||
51 | uint16_t transaction_sequence, | ||
52 | uint16_t status_code); | ||
46 | 53 | ||
47 | /** | 54 | /** |
48 | * Dump a libwifi_auth into a raw format for packet injection. | 55 | * Dump a libwifi_auth into a raw format for packet injection. |
49 | * | 56 | * |
50 | * @param auth A libwifi_auth | 57 | * @param auth A libwifi_auth |
51 | * @param buf The output buffer for the frame data | 58 | * @param buf The output buffer for the frame data |
52 | * @param buf_len The length of the output buffer | 59 | * @param buf_len The length of the output buffer |
53 | * @return The length of the dumped auth | 60 | * @return The length of the dumped auth, or negative error |
54 | */ | 61 | */ |
55 | size_t libwifi_dump_auth(struct libwifi_auth *auth, unsigned char *buf, size_t buf_len); | 62 | size_t libwifi_dump_auth(struct libwifi_auth *auth, unsigned char *buf, size_t buf_len); |
56 | 63 | ||
diff --git a/src/libwifi/gen/management/beacon.c b/src/libwifi/gen/management/beacon.c index f884c6e..ab99254 100644 --- a/src/libwifi/gen/management/beacon.c +++ b/src/libwifi/gen/management/beacon.c | |||
@@ -32,7 +32,8 @@ | |||
32 | */ | 32 | */ |
33 | size_t libwifi_get_beacon_length(struct libwifi_beacon *beacon) { | 33 | size_t libwifi_get_beacon_length(struct libwifi_beacon *beacon) { |
34 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + | 34 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + |
35 | sizeof(struct libwifi_beacon_fixed_parameters) + beacon->tags.length; | 35 | sizeof(struct libwifi_beacon_fixed_parameters) + |
36 | beacon->tags.length; | ||
36 | } | 37 | } |
37 | 38 | ||
38 | /** | 39 | /** |
@@ -75,12 +76,12 @@ int libwifi_set_beacon_channel(struct libwifi_beacon *beacon, uint8_t channel) { | |||
75 | 76 | ||
76 | /** | 77 | /** |
77 | * The generated beacon frame is made with sane defaults defined in common.h. | 78 | * The generated beacon frame is made with sane defaults defined in common.h. |
78 | * Three tagged parameters are also added to the beacon: SSID, Channel and Supported Rates. | 79 | * Two tagged parameters are also added to the beacon: SSID and Channel. |
79 | */ | 80 | */ |
80 | int libwifi_create_beacon(struct libwifi_beacon *beacon, | 81 | int libwifi_create_beacon(struct libwifi_beacon *beacon, |
81 | const unsigned char receiver[6], | 82 | const unsigned char receiver[6], |
82 | const unsigned char transmitter[6], | 83 | const unsigned char transmitter[6], |
83 | const unsigned char bssid[6], | 84 | const unsigned char address3[6], |
84 | const char *ssid, | 85 | const char *ssid, |
85 | uint8_t channel) { | 86 | uint8_t channel) { |
86 | memset(beacon, 0, sizeof(struct libwifi_beacon)); | 87 | memset(beacon, 0, sizeof(struct libwifi_beacon)); |
@@ -89,18 +90,19 @@ int libwifi_create_beacon(struct libwifi_beacon *beacon, | |||
89 | beacon->frame_header.frame_control.subtype = SUBTYPE_BEACON; | 90 | beacon->frame_header.frame_control.subtype = SUBTYPE_BEACON; |
90 | memcpy(&beacon->frame_header.addr1, receiver, 6); | 91 | memcpy(&beacon->frame_header.addr1, receiver, 6); |
91 | memcpy(&beacon->frame_header.addr2, transmitter, 6); | 92 | memcpy(&beacon->frame_header.addr2, transmitter, 6); |
92 | memcpy(&beacon->frame_header.addr3, bssid, 6); | 93 | memcpy(&beacon->frame_header.addr3, address3, 6); |
93 | beacon->frame_header.seq_control.sequence_number = (rand() % 4096); | 94 | beacon->frame_header.seq_control.sequence_number = (rand() % 4096); |
94 | 95 | ||
95 | beacon->fixed_parameters.timestamp = BYTESWAP64(libwifi_get_epoch()); | 96 | beacon->fixed_parameters.timestamp = BYTESWAP64(libwifi_get_epoch()); |
96 | beacon->fixed_parameters.beacon_interval = BYTESWAP16(LIBWIFI_DEFAULT_BEACON_INTERVAL); | 97 | beacon->fixed_parameters.beacon_interval = BYTESWAP16(LIBWIFI_DEFAULT_BEACON_INTERVAL); |
97 | beacon->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); | 98 | beacon->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); |
98 | 99 | ||
99 | libwifi_set_beacon_ssid(beacon, ssid); | 100 | int ret = libwifi_set_beacon_ssid(beacon, ssid); |
100 | libwifi_set_beacon_channel(beacon, channel); | 101 | if (ret != 0) { |
102 | return ret; | ||
103 | } | ||
101 | 104 | ||
102 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; | 105 | ret = libwifi_set_beacon_channel(beacon, channel); |
103 | int ret = libwifi_quick_add_tag(&beacon->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); | ||
104 | 106 | ||
105 | return ret; | 107 | return ret; |
106 | } | 108 | } |
diff --git a/src/libwifi/gen/management/beacon.h b/src/libwifi/gen/management/beacon.h index 943be55..631a475 100644 --- a/src/libwifi/gen/management/beacon.h +++ b/src/libwifi/gen/management/beacon.h | |||
@@ -22,23 +22,25 @@ | |||
22 | * Set the SSID of a struct libwifi_beacon. | 22 | * Set the SSID of a struct libwifi_beacon. |
23 | * | 23 | * |
24 | * @param beacon A struct libwifi_beacon | 24 | * @param beacon A struct libwifi_beacon |
25 | * @param ssid The new SSID | 25 | * @param ssid The new SSID |
26 | * @return Zero on success, or negative error | ||
26 | */ | 27 | */ |
27 | int libwifi_set_beacon_ssid(struct libwifi_beacon *beacon, const char *ssid); | 28 | int libwifi_set_beacon_ssid(struct libwifi_beacon *beacon, const char *ssid); |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * Set the channel of a struct libwifi_beacon. | 31 | * Set the channel of a struct libwifi_beacon. |
31 | * | 32 | * |
32 | * @param beacon A struct libwifi_beacon | 33 | * @param beacon A struct libwifi_beacon |
33 | * @param channel The new channel | 34 | * @param channel The new channel |
35 | * @return Zero on success, or negative error | ||
34 | */ | 36 | */ |
35 | int libwifi_set_beacon_channel(struct libwifi_beacon *beacon, uint8_t channel); | 37 | int libwifi_set_beacon_channel(struct libwifi_beacon *beacon, uint8_t channel); |
36 | 38 | ||
37 | /** | 39 | /** |
38 | * Calculate the length of a given struct libwifi_beacon | 40 | * Calculate the length of a given struct libwifi_beacon |
39 | * | 41 | * |
40 | * @param beacon A struct libwifi_beacon | 42 | * @param beacon A libwifi_beacon struct |
41 | * @return The length of the given beacon | 43 | * @return The length of the given beacon, or negative error |
42 | */ | 44 | */ |
43 | size_t libwifi_get_beacon_length(struct libwifi_beacon *beacon); | 45 | size_t libwifi_get_beacon_length(struct libwifi_beacon *beacon); |
44 | 46 | ||
@@ -48,28 +50,28 @@ size_t libwifi_get_beacon_length(struct libwifi_beacon *beacon); | |||
48 | * A generated libwifi beacon can be "dumped" into a buffer for packet injection | 50 | * A generated libwifi beacon can be "dumped" into a buffer for packet injection |
49 | * via the libwifi_dump_beacon. | 51 | * via the libwifi_dump_beacon. |
50 | * | 52 | * |
51 | * @param beacon A struct libwifi_beacon | 53 | * @param beacon A struct libwifi_beacon |
52 | * @param receiver The receiver MAC address, aka address 1 | 54 | * @param receiver The receiver MAC address, aka address 1 |
53 | * @param transmitter The source MAC address, aka address 2 | 55 | * @param transmitter The source MAC address, aka address 2 |
54 | * @param bssid The BSSID MAC address, aka address 3 | 56 | * @param address3 The address 3 frame field value, typically the BSSID |
55 | * @param ssid The SSID of the beacon. Maximum length is 32 characters | 57 | * @param ssid The SSID of the beacon. Maximum length is 32 characters |
56 | * @param channel The desired channel of the beacon | 58 | * @param channel The desired channel of the beacon |
57 | * | 59 | * @return Zero on success, or negative error |
58 | */ | 60 | */ |
59 | int libwifi_create_beacon(struct libwifi_beacon *beacon, | 61 | int libwifi_create_beacon(struct libwifi_beacon *beacon, |
60 | const unsigned char receiver[6], | 62 | const unsigned char receiver[6], |
61 | const unsigned char transmitter[6], | 63 | const unsigned char transmitter[6], |
62 | const unsigned char bssid[6], | 64 | const unsigned char address3[6], |
63 | const char *ssid, | 65 | const char *ssid, |
64 | uint8_t channel); | 66 | uint8_t channel); |
65 | 67 | ||
66 | /** | 68 | /** |
67 | * Dump a struct libwifi_beacon into a raw format for packet injection. | 69 | * Dump a struct libwifi_beacon into a raw format for packet injection. |
68 | * | 70 | * |
69 | * @param beacon A struct libwifi_beacon | 71 | * @param beacon A struct libwifi_beacon |
70 | * @param buf The output buffer for the frame data | 72 | * @param buf The output buffer for the frame data |
71 | * @param buf_len The length of the output buffer | 73 | * @param buf_len The length of the output buffer |
72 | * @return The length of the dumped beacon | 74 | * @return The length of the dumped beacon, or negative error |
73 | */ | 75 | */ |
74 | size_t libwifi_dump_beacon(struct libwifi_beacon *beacon, unsigned char *buf, size_t buf_len); | 76 | size_t libwifi_dump_beacon(struct libwifi_beacon *beacon, unsigned char *buf, size_t buf_len); |
75 | 77 | ||
diff --git a/src/libwifi/gen/management/deauthentication.c b/src/libwifi/gen/management/deauthentication.c index 14f2c26..a388a6e 100644 --- a/src/libwifi/gen/management/deauthentication.c +++ b/src/libwifi/gen/management/deauthentication.c | |||
@@ -33,15 +33,18 @@ size_t libwifi_get_deauth_length(struct libwifi_deauth *deauth) { | |||
33 | * The generated deauthentication frame contains only the supplied receiver, transmitter and reason_code by | 33 | * The generated deauthentication frame contains only the supplied receiver, transmitter and reason_code by |
34 | * default. | 34 | * default. |
35 | */ | 35 | */ |
36 | int libwifi_create_deauth(struct libwifi_deauth *deauth, const unsigned char receiver[6], | 36 | int libwifi_create_deauth(struct libwifi_deauth *deauth, |
37 | const unsigned char transmitter[6], uint16_t reason_code) { | 37 | const unsigned char receiver[6], |
38 | const unsigned char transmitter[6], | ||
39 | const unsigned char address3[6], | ||
40 | uint16_t reason_code) { | ||
38 | memset(deauth, 0, sizeof(struct libwifi_deauth)); | 41 | memset(deauth, 0, sizeof(struct libwifi_deauth)); |
39 | 42 | ||
40 | deauth->frame_header.frame_control.type = TYPE_MANAGEMENT; | 43 | deauth->frame_header.frame_control.type = TYPE_MANAGEMENT; |
41 | deauth->frame_header.frame_control.subtype = SUBTYPE_DEAUTH; | 44 | deauth->frame_header.frame_control.subtype = SUBTYPE_DEAUTH; |
42 | memcpy(&deauth->frame_header.addr1, receiver, 6); | 45 | memcpy(&deauth->frame_header.addr1, receiver, 6); |
43 | memcpy(&deauth->frame_header.addr2, transmitter, 6); | 46 | memcpy(&deauth->frame_header.addr2, transmitter, 6); |
44 | memcpy(&deauth->frame_header.addr3, transmitter, 6); | 47 | memcpy(&deauth->frame_header.addr3, address3, 6); |
45 | 48 | ||
46 | deauth->frame_header.seq_control.sequence_number = (rand() % 4096); | 49 | deauth->frame_header.seq_control.sequence_number = (rand() % 4096); |
47 | 50 | ||
diff --git a/src/libwifi/gen/management/deauthentication.h b/src/libwifi/gen/management/deauthentication.h index 902241d..f118ade 100644 --- a/src/libwifi/gen/management/deauthentication.h +++ b/src/libwifi/gen/management/deauthentication.h | |||
@@ -24,7 +24,7 @@ | |||
24 | * Calculate the length of a given libwifi_deauth | 24 | * Calculate the length of a given libwifi_deauth |
25 | * | 25 | * |
26 | * @param deauth A libwifi_deauth | 26 | * @param deauth A libwifi_deauth |
27 | * @return The length of the given deauth | 27 | * @return The length of the given deauth |
28 | */ | 28 | */ |
29 | size_t libwifi_get_deauth_length(struct libwifi_deauth *deauth); | 29 | size_t libwifi_get_deauth_length(struct libwifi_deauth *deauth); |
30 | 30 | ||
@@ -34,22 +34,26 @@ size_t libwifi_get_deauth_length(struct libwifi_deauth *deauth); | |||
34 | * A generated libwifi deauth can be "dumped" into a buffer for packet injection | 34 | * A generated libwifi deauth can be "dumped" into a buffer for packet injection |
35 | * via the libwifi_dump_deauth. | 35 | * via the libwifi_dump_deauth. |
36 | * | 36 | * |
37 | * @param deauth A libwifi_deauth | 37 | * @param deauth A libwifi_deauth |
38 | * @param receiver The receiver MAC address, aka address 1 | 38 | * @param receiver The receiver MAC address, aka address 1 |
39 | * @param transmitter The source MAC address, aka address 2 | 39 | * @param transmitter The source MAC address, aka address 2 |
40 | * @param address3 The address 3 frame field value, typically the BSSID | ||
40 | * @param reason_code The deauth reason code | 41 | * @param reason_code The deauth reason code |
41 | * | 42 | * @return Zero on success, or negative error |
42 | */ | 43 | */ |
43 | int libwifi_create_deauth(struct libwifi_deauth *deauth, const unsigned char receiver[6], | 44 | int libwifi_create_deauth(struct libwifi_deauth *deauth, |
44 | const unsigned char transmitter[6], uint16_t reason_code); | 45 | const unsigned char receiver[6], |
46 | const unsigned char transmitter[6], | ||
47 | const unsigned char address3[6], | ||
48 | uint16_t reason_code); | ||
45 | 49 | ||
46 | /** | 50 | /** |
47 | * Dump a libwifi_deauth into a raw format for packet injection. | 51 | * Dump a libwifi_deauth into a raw format for packet injection. |
48 | * | 52 | * |
49 | * @param deauth A libwifi_deauth | 53 | * @param deauth A libwifi_deauth |
50 | * @param buf The output buffer for the frame data | 54 | * @param buf The output buffer for the frame data |
51 | * @param buf_len The length of the output buffer | 55 | * @param buf_len The length of the output buffer |
52 | * @return The length of the dumped deauth | 56 | * @return The length of the dumped deauth, or negative error |
53 | */ | 57 | */ |
54 | size_t libwifi_dump_deauth(struct libwifi_deauth *deauth, unsigned char *buf, size_t buf_len); | 58 | size_t libwifi_dump_deauth(struct libwifi_deauth *deauth, unsigned char *buf, size_t buf_len); |
55 | 59 | ||
diff --git a/src/libwifi/gen/management/disassociation.c b/src/libwifi/gen/management/disassociation.c index d6cf237..dde1f1e 100644 --- a/src/libwifi/gen/management/disassociation.c +++ b/src/libwifi/gen/management/disassociation.c | |||
@@ -33,15 +33,18 @@ size_t libwifi_get_disassoc_length(struct libwifi_disassoc *disassoc) { | |||
33 | * The generated disassociation frame contains only the supplied receiver, transmitter and reason_code by | 33 | * The generated disassociation frame contains only the supplied receiver, transmitter and reason_code by |
34 | * default. | 34 | * default. |
35 | */ | 35 | */ |
36 | int libwifi_create_disassoc(struct libwifi_disassoc *disassoc, const unsigned char receiver[6], | 36 | int libwifi_create_disassoc(struct libwifi_disassoc *disassoc, |
37 | const unsigned char transmitter[6], uint16_t reason_code) { | 37 | const unsigned char receiver[6], |
38 | const unsigned char transmitter[6], | ||
39 | const unsigned char address3[6], | ||
40 | uint16_t reason_code) { | ||
38 | memset(disassoc, 0, sizeof(struct libwifi_disassoc)); | 41 | memset(disassoc, 0, sizeof(struct libwifi_disassoc)); |
39 | 42 | ||
40 | disassoc->frame_header.frame_control.type = TYPE_MANAGEMENT; | 43 | disassoc->frame_header.frame_control.type = TYPE_MANAGEMENT; |
41 | disassoc->frame_header.frame_control.subtype = SUBTYPE_DISASSOC; | 44 | disassoc->frame_header.frame_control.subtype = SUBTYPE_DISASSOC; |
42 | memcpy(&disassoc->frame_header.addr1, receiver, 6); | 45 | memcpy(&disassoc->frame_header.addr1, receiver, 6); |
43 | memcpy(&disassoc->frame_header.addr2, transmitter, 6); | 46 | memcpy(&disassoc->frame_header.addr2, transmitter, 6); |
44 | memcpy(&disassoc->frame_header.addr3, transmitter, 6); | 47 | memcpy(&disassoc->frame_header.addr3, address3, 6); |
45 | 48 | ||
46 | disassoc->frame_header.seq_control.sequence_number = (rand() % 4096); | 49 | disassoc->frame_header.seq_control.sequence_number = (rand() % 4096); |
47 | 50 | ||
diff --git a/src/libwifi/gen/management/disassociation.h b/src/libwifi/gen/management/disassociation.h index 10f1db9..d4cfc29 100644 --- a/src/libwifi/gen/management/disassociation.h +++ b/src/libwifi/gen/management/disassociation.h | |||
@@ -24,7 +24,7 @@ | |||
24 | * Calculate the length of a given libwifi_disassoc | 24 | * Calculate the length of a given libwifi_disassoc |
25 | * | 25 | * |
26 | * @param disassoc A libwifi_disassoc | 26 | * @param disassoc A libwifi_disassoc |
27 | * @return The length of the given disassoc | 27 | * @return The length of the given disassoc, or negative error |
28 | */ | 28 | */ |
29 | size_t libwifi_get_disassoc_length(struct libwifi_disassoc *disassoc); | 29 | size_t libwifi_get_disassoc_length(struct libwifi_disassoc *disassoc); |
30 | 30 | ||
@@ -34,22 +34,26 @@ size_t libwifi_get_disassoc_length(struct libwifi_disassoc *disassoc); | |||
34 | * A generated libwifi disassoc can be "dumped" into a buffer for packet injection | 34 | * A generated libwifi disassoc can be "dumped" into a buffer for packet injection |
35 | * via the libwifi_dump_disassoc. | 35 | * via the libwifi_dump_disassoc. |
36 | * | 36 | * |
37 | * @param disassoc A libwifi_disassoc | 37 | * @param disassoc A libwifi_disassoc |
38 | * @param receiver The receiver MAC address, aka address 1 | 38 | * @param receiver The receiver MAC address, aka address 1 |
39 | * @param transmitter The source MAC address, aka address 2 | 39 | * @param transmitter The source MAC address, aka address 2 |
40 | * @param address3 The address 3 frame field value, typically the BSSID | ||
40 | * @param reason_code The disassoc reason code | 41 | * @param reason_code The disassoc reason code |
41 | * | 42 | * @return Zero on success, or negative error |
42 | */ | 43 | */ |
43 | int libwifi_create_disassoc(struct libwifi_disassoc *disassoc, const unsigned char receiver[6], | 44 | int libwifi_create_disassoc(struct libwifi_disassoc *disassoc, |
44 | const unsigned char transmitter[6], uint16_t reason_code); | 45 | const unsigned char receiver[6], |
46 | const unsigned char transmitter[6], | ||
47 | const unsigned char address3[6], | ||
48 | uint16_t reason_code); | ||
45 | 49 | ||
46 | /** | 50 | /** |
47 | * Dump a libwifi_disassoc into a raw format for packet injection. | 51 | * Dump a libwifi_disassoc into a raw format for packet injection. |
48 | * | 52 | * |
49 | * @param disassoc A libwifi_disassoc | 53 | * @param disassoc A libwifi_disassoc |
50 | * @param buf The output buffer for the frame data | 54 | * @param buf The output buffer for the frame data |
51 | * @param buf_len The length of the output buffer | 55 | * @param buf_len The length of the output buffer |
52 | * @return The length of the dumped disassoc | 56 | * @return The length of the dumped disassoc, or negative error |
53 | */ | 57 | */ |
54 | size_t libwifi_dump_disassoc(struct libwifi_disassoc *disassoc, unsigned char *buf, size_t buf_len); | 58 | size_t libwifi_dump_disassoc(struct libwifi_disassoc *disassoc, unsigned char *buf, size_t buf_len); |
55 | 59 | ||
diff --git a/src/libwifi/gen/management/probe_request.c b/src/libwifi/gen/management/probe_request.c index 95cdcdb..8e4ce60 100644 --- a/src/libwifi/gen/management/probe_request.c +++ b/src/libwifi/gen/management/probe_request.c | |||
@@ -31,16 +31,19 @@ size_t libwifi_get_probe_req_length(struct libwifi_probe_req *probe_req) { | |||
31 | * The generated probe request frame is made with sane defaults defined in common.h. | 31 | * The generated probe request frame is made with sane defaults defined in common.h. |
32 | * Two tagged parameters are also added to the beacon: SSID and Channel. | 32 | * Two tagged parameters are also added to the beacon: SSID and Channel. |
33 | */ | 33 | */ |
34 | int libwifi_create_probe_req(struct libwifi_probe_req *probe_req, const unsigned char receiver[6], | 34 | int libwifi_create_probe_req(struct libwifi_probe_req *probe_req, |
35 | const unsigned char transmitter[6], const unsigned char bssid[6], | 35 | const unsigned char receiver[6], |
36 | const char *ssid, uint8_t channel) { | 36 | const unsigned char transmitter[6], |
37 | const unsigned char address3[6], | ||
38 | const char *ssid, | ||
39 | uint8_t channel) { | ||
37 | memset(probe_req, 0, sizeof(struct libwifi_probe_req)); | 40 | memset(probe_req, 0, sizeof(struct libwifi_probe_req)); |
38 | 41 | ||
39 | probe_req->frame_header.frame_control.type = TYPE_MANAGEMENT; | 42 | probe_req->frame_header.frame_control.type = TYPE_MANAGEMENT; |
40 | probe_req->frame_header.frame_control.subtype = SUBTYPE_PROBE_REQ; | 43 | probe_req->frame_header.frame_control.subtype = SUBTYPE_PROBE_REQ; |
41 | memcpy(&probe_req->frame_header.addr1, receiver, 6); | 44 | memcpy(&probe_req->frame_header.addr1, receiver, 6); |
42 | memcpy(&probe_req->frame_header.addr2, transmitter, 6); | 45 | memcpy(&probe_req->frame_header.addr2, transmitter, 6); |
43 | memcpy(&probe_req->frame_header.addr3, bssid, 6); | 46 | memcpy(&probe_req->frame_header.addr3, address3, 6); |
44 | probe_req->frame_header.seq_control.sequence_number = (rand() % 4096); | 47 | probe_req->frame_header.seq_control.sequence_number = (rand() % 4096); |
45 | 48 | ||
46 | int ret = libwifi_quick_add_tag(&probe_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); | 49 | int ret = libwifi_quick_add_tag(&probe_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); |
diff --git a/src/libwifi/gen/management/probe_request.h b/src/libwifi/gen/management/probe_request.h index c71897b..47dc23a 100644 --- a/src/libwifi/gen/management/probe_request.h +++ b/src/libwifi/gen/management/probe_request.h | |||
@@ -24,7 +24,7 @@ | |||
24 | * Calculate the length of a given libwifi_probe_req | 24 | * Calculate the length of a given libwifi_probe_req |
25 | * | 25 | * |
26 | * @param probe_req A libwifi_probe_req | 26 | * @param probe_req A libwifi_probe_req |
27 | * @return The length of the given probe_req | 27 | * @return The length of the given probe_req, or negative error |
28 | */ | 28 | */ |
29 | size_t libwifi_get_probe_req_length(struct libwifi_probe_req *probe_req); | 29 | size_t libwifi_get_probe_req_length(struct libwifi_probe_req *probe_req); |
30 | 30 | ||
@@ -34,23 +34,28 @@ size_t libwifi_get_probe_req_length(struct libwifi_probe_req *probe_req); | |||
34 | * A generated libwifi probe_req can be "dumped" into a buffer for packet injection | 34 | * A generated libwifi probe_req can be "dumped" into a buffer for packet injection |
35 | * via the libwifi_dump_probe_req. | 35 | * via the libwifi_dump_probe_req. |
36 | * | 36 | * |
37 | * @param probe_req A libwifi_probe_req | 37 | * @param probe_req A libwifi_probe_req |
38 | * @param receiver The receiver MAC address, aka address 1 | 38 | * @param receiver The receiver MAC address, aka address 1 |
39 | * @param transmitter The source MAC address, aka address 2 | 39 | * @param transmitter The source MAC address, aka address 2 |
40 | * @param reason_code The probe_req reason code | 40 | * @param address3 The address 3 frame field value, typically the BSSID |
41 | * | 41 | * @param ssid The probe request SSID |
42 | * @param channel The probe request channel | ||
43 | * @return Zero on success, or negative error | ||
42 | */ | 44 | */ |
43 | int libwifi_create_probe_req(struct libwifi_probe_req *probe_req, const unsigned char receiver[6], | 45 | int libwifi_create_probe_req(struct libwifi_probe_req *probe_req, |
44 | const unsigned char transmitter[6], const unsigned char bssid[6], | 46 | const unsigned char receiver[6], |
45 | const char *ssid, uint8_t channel); | 47 | const unsigned char transmitter[6], |
48 | const unsigned char address3[6], | ||
49 | const char *ssid, | ||
50 | uint8_t channel); | ||
46 | 51 | ||
47 | /** | 52 | /** |
48 | * Dump a libwifi_probe_req into a raw format for packet injection. | 53 | * Dump a libwifi_probe_req into a raw format for packet injection. |
49 | * | 54 | * |
50 | * @param probe_req A libwifi_probe_req | 55 | * @param probe_req A libwifi_probe_req |
51 | * @param buf The output buffer for the frame data | 56 | * @param buf The output buffer for the frame data |
52 | * @param buf_len The length of the output buffer | 57 | * @param buf_len The length of the output buffer |
53 | * @return The length of the dumped probe_req | 58 | * @return The length of the dumped probe_req, or negative error |
54 | */ | 59 | */ |
55 | size_t libwifi_dump_probe_req(struct libwifi_probe_req *probe_req, unsigned char *buf, size_t buf_len); | 60 | size_t libwifi_dump_probe_req(struct libwifi_probe_req *probe_req, unsigned char *buf, size_t buf_len); |
56 | 61 | ||
diff --git a/src/libwifi/gen/management/probe_response.c b/src/libwifi/gen/management/probe_response.c index 6c1e990..603d0c4 100644 --- a/src/libwifi/gen/management/probe_response.c +++ b/src/libwifi/gen/management/probe_response.c | |||
@@ -32,7 +32,8 @@ | |||
32 | */ | 32 | */ |
33 | size_t libwifi_get_probe_resp_length(struct libwifi_probe_resp *probe_resp) { | 33 | size_t libwifi_get_probe_resp_length(struct libwifi_probe_resp *probe_resp) { |
34 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + | 34 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + |
35 | sizeof(struct libwifi_probe_resp_fixed_parameters) + probe_resp->tags.length; | 35 | sizeof(struct libwifi_probe_resp_fixed_parameters) + |
36 | probe_resp->tags.length; | ||
36 | } | 37 | } |
37 | 38 | ||
38 | /** | 39 | /** |
@@ -48,7 +49,7 @@ int libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const cha | |||
48 | } | 49 | } |
49 | } | 50 | } |
50 | 51 | ||
51 | ret = libwifi_quick_add_tag(&probe_resp->tags, TAG_SSID, (void *) ssid, strlen(ssid)); | 52 | ret = libwifi_quick_add_tag(&probe_resp->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); |
52 | 53 | ||
53 | return ret; | 54 | return ret; |
54 | } | 55 | } |
@@ -75,16 +76,21 @@ int libwifi_set_probe_resp_channel(struct libwifi_probe_resp *probe_resp, uint8_ | |||
75 | 76 | ||
76 | /** | 77 | /** |
77 | * The generated probe response frame is made with sane defaults defined in common.h. | 78 | * The generated probe response frame is made with sane defaults defined in common.h. |
78 | * Three tagged parameters are also added to the probe response: SSID, Channel and Supported Rates. | 79 | * Two tagged parameters are also added to the probe response: SSID and Channel. |
79 | */ | 80 | */ |
80 | int libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, const unsigned char receiver[6], | 81 | int libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, |
81 | const unsigned char transmitter[6], const char *ssid, uint8_t channel) { | 82 | const unsigned char receiver[6], |
83 | const unsigned char transmitter[6], | ||
84 | const unsigned char address3[6], | ||
85 | const char *ssid, | ||
86 | uint8_t channel) { | ||
82 | memset(probe_resp, 0, sizeof(struct libwifi_probe_resp)); | 87 | memset(probe_resp, 0, sizeof(struct libwifi_probe_resp)); |
83 | 88 | ||
84 | probe_resp->frame_header.frame_control.type = TYPE_MANAGEMENT; | 89 | probe_resp->frame_header.frame_control.type = TYPE_MANAGEMENT; |
85 | probe_resp->frame_header.frame_control.subtype = SUBTYPE_PROBE_RESP; | 90 | probe_resp->frame_header.frame_control.subtype = SUBTYPE_PROBE_RESP; |
86 | memcpy(&probe_resp->frame_header.addr1, receiver, 6); | 91 | memcpy(&probe_resp->frame_header.addr1, receiver, 6); |
87 | memcpy(&probe_resp->frame_header.addr2, transmitter, 6); | 92 | memcpy(&probe_resp->frame_header.addr2, transmitter, 6); |
93 | memcpy(&probe_resp->frame_header.addr3, address3, 6); | ||
88 | 94 | ||
89 | probe_resp->frame_header.seq_control.sequence_number = (rand() % 4096); | 95 | probe_resp->frame_header.seq_control.sequence_number = (rand() % 4096); |
90 | probe_resp->fixed_parameters.timestamp = BYTESWAP64(libwifi_get_epoch()); | 96 | probe_resp->fixed_parameters.timestamp = BYTESWAP64(libwifi_get_epoch()); |
@@ -98,12 +104,6 @@ int libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, const unsig | |||
98 | } | 104 | } |
99 | 105 | ||
100 | ret = libwifi_set_probe_resp_channel(probe_resp, channel); | 106 | ret = libwifi_set_probe_resp_channel(probe_resp, channel); |
101 | if (ret != 0) { | ||
102 | return ret; | ||
103 | } | ||
104 | |||
105 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; | ||
106 | ret = libwifi_quick_add_tag(&probe_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); | ||
107 | 107 | ||
108 | return ret; | 108 | return ret; |
109 | } | 109 | } |
diff --git a/src/libwifi/gen/management/probe_response.h b/src/libwifi/gen/management/probe_response.h index 80f5451..4e49a6e 100644 --- a/src/libwifi/gen/management/probe_response.h +++ b/src/libwifi/gen/management/probe_response.h | |||
@@ -21,24 +21,26 @@ | |||
21 | /** | 21 | /** |
22 | * Set the SSID of a libwifi_probe_resp. | 22 | * Set the SSID of a libwifi_probe_resp. |
23 | * | 23 | * |
24 | * @param probe_resp A libwifi_probe_resp | 24 | * @param probe_resp A libwifi_probe_resp struct |
25 | * @param ssid The new SSID | 25 | * @param ssid The new SSID |
26 | * @return Zero on success, or negative error | ||
26 | */ | 27 | */ |
27 | int libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const char *ssid); | 28 | int libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const char *ssid); |
28 | 29 | ||
29 | /** | 30 | /** |
30 | * Set the channel of a libwifi_probe_resp. | 31 | * Set the channel of a libwifi_probe_resp. |
31 | * | 32 | * |
32 | * @param probe_resp A libwifi_probe_resp | 33 | * @param probe_resp A libwifi_probe_resp struct |
33 | * @param channel The new channel | 34 | * @param channel The new channel |
35 | * @return Zero on success, or negative error | ||
34 | */ | 36 | */ |
35 | int libwifi_set_probe_resp_channel(struct libwifi_probe_resp *probe_resp, uint8_t channel); | 37 | int libwifi_set_probe_resp_channel(struct libwifi_probe_resp *probe_resp, uint8_t channel); |
36 | 38 | ||
37 | /** | 39 | /** |
38 | * Calculate the length of a given libwifi_probe_resp | 40 | * Calculate the length of a given libwifi_probe_resp |
39 | * | 41 | * |
40 | * @param probe_resp A libwifi_probe_resp | 42 | * @param probe_resp A libwifi_probe_resp struct |
41 | * @return The length of the given probe_resp | 43 | * @return The length of the given probe_resp, or negative error |
42 | */ | 44 | */ |
43 | size_t libwifi_get_probe_resp_length(struct libwifi_probe_resp *probe_resp); | 45 | size_t libwifi_get_probe_resp_length(struct libwifi_probe_resp *probe_resp); |
44 | 46 | ||
@@ -48,23 +50,28 @@ size_t libwifi_get_probe_resp_length(struct libwifi_probe_resp *probe_resp); | |||
48 | * A generated libwifi probe_resp can be "dumped" into a buffer for packet injection | 50 | * A generated libwifi probe_resp can be "dumped" into a buffer for packet injection |
49 | * via the libwifi_dump_probe_resp. | 51 | * via the libwifi_dump_probe_resp. |
50 | * | 52 | * |
51 | * @param probe_resp A libwifi_probe_resp | 53 | * @param probe_resp A libwifi_probe_resp |
52 | * @param receiver The receiver MAC address, aka address 1 | 54 | * @param receiver The receiver MAC address, aka address 1 |
53 | * @param transmitter The source MAC address, aka address 2 | 55 | * @param transmitter The source MAC address, aka address 2 |
54 | * @param ssid The SSID of the probe_resp. Maximum length is 32 characters | 56 | * @param address3 The address 3 frame field value, typically the BSSID |
55 | * @param channel The desired channel of the probe_resp | 57 | * @param ssid The SSID of the probe_resp. Maximum length is 32 characters |
56 | * | 58 | * @param channel The desired channel of the probe_resp |
59 | * @return Zero on success, or negative error | ||
57 | */ | 60 | */ |
58 | int libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, const unsigned char receiver[6], | 61 | int libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, |
59 | const unsigned char transmitter[6], const char *ssid, uint8_t channel); | 62 | const unsigned char receiver[6], |
63 | const unsigned char transmitter[6], | ||
64 | const unsigned char address3[6], | ||
65 | const char *ssid, | ||
66 | uint8_t channel); | ||
60 | 67 | ||
61 | /** | 68 | /** |
62 | * Dump a libwifi_probe_resp into a raw format for packet injection. | 69 | * Dump a libwifi_probe_resp into a raw format for packet injection. |
63 | * | 70 | * |
64 | * @param probe_resp A libwifi_probe_resp | 71 | * @param probe_resp A libwifi_probe_resp |
65 | * @param buf The output buffer for the frame data | 72 | * @param buf The output buffer for the frame data |
66 | * @param buf_len The length of the output buffer | 73 | * @param buf_len The length of the output buffer |
67 | * @return The length of the dumped probe_resp | 74 | * @return The length of the dumped probe_resp, or negative error |
68 | */ | 75 | */ |
69 | size_t libwifi_dump_probe_resp(struct libwifi_probe_resp *probe_resp, unsigned char *buf, size_t buf_len); | 76 | size_t libwifi_dump_probe_resp(struct libwifi_probe_resp *probe_resp, unsigned char *buf, size_t buf_len); |
70 | 77 | ||
diff --git a/src/libwifi/gen/management/reassoc_request.c b/src/libwifi/gen/management/reassoc_request.c index 9e9bcd8..ed61a50 100644 --- a/src/libwifi/gen/management/reassoc_request.c +++ b/src/libwifi/gen/management/reassoc_request.c | |||
@@ -26,23 +26,28 @@ | |||
26 | */ | 26 | */ |
27 | size_t libwifi_get_reassoc_req_length(struct libwifi_reassoc_req *reassoc_req) { | 27 | size_t libwifi_get_reassoc_req_length(struct libwifi_reassoc_req *reassoc_req) { |
28 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + | 28 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + |
29 | sizeof(struct libwifi_reassoc_req_fixed_parameters) + reassoc_req->tags.length; | 29 | sizeof(struct libwifi_reassoc_req_fixed_parameters) + |
30 | reassoc_req->tags.length; | ||
30 | } | 31 | } |
31 | 32 | ||
32 | /** | 33 | /** |
33 | * The generated reassociation request frame is made with sane defaults defined in common.h. | 34 | * The generated reassociation request frame is made with sane defaults defined in common.h. |
34 | * Two tagged parameters are also added to the reassociation frame: SSID and Channel | 35 | * Two tagged parameters are also added to the reassociation frame: SSID and Channel |
35 | */ | 36 | */ |
36 | int libwifi_create_reassoc_req(struct libwifi_reassoc_req *reassoc_req, const unsigned char receiver[6], | 37 | int libwifi_create_reassoc_req(struct libwifi_reassoc_req *reassoc_req, |
37 | const unsigned char transmitter[6], const unsigned char current_ap[6], | 38 | const unsigned char receiver[6], |
38 | const char *ssid, uint8_t channel) { | 39 | const unsigned char transmitter[6], |
40 | const unsigned char address3[6], | ||
41 | const unsigned char current_ap[6], | ||
42 | const char *ssid, | ||
43 | uint8_t channel) { | ||
39 | memset(reassoc_req, 0, sizeof(struct libwifi_reassoc_req)); | 44 | memset(reassoc_req, 0, sizeof(struct libwifi_reassoc_req)); |
40 | 45 | ||
41 | reassoc_req->frame_header.frame_control.type = TYPE_MANAGEMENT; | 46 | reassoc_req->frame_header.frame_control.type = TYPE_MANAGEMENT; |
42 | reassoc_req->frame_header.frame_control.subtype = SUBTYPE_REASSOC_REQ; | 47 | reassoc_req->frame_header.frame_control.subtype = SUBTYPE_REASSOC_REQ; |
43 | memcpy(&reassoc_req->frame_header.addr1, receiver, 6); | 48 | memcpy(&reassoc_req->frame_header.addr1, receiver, 6); |
44 | memcpy(&reassoc_req->frame_header.addr2, transmitter, 6); | 49 | memcpy(&reassoc_req->frame_header.addr2, transmitter, 6); |
45 | memcpy(&reassoc_req->frame_header.addr3, receiver, 6); | 50 | memcpy(&reassoc_req->frame_header.addr3, address3, 6); |
46 | reassoc_req->frame_header.seq_control.sequence_number = (rand() % 4096); | 51 | reassoc_req->frame_header.seq_control.sequence_number = (rand() % 4096); |
47 | 52 | ||
48 | reassoc_req->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); | 53 | reassoc_req->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); |
diff --git a/src/libwifi/gen/management/reassoc_request.h b/src/libwifi/gen/management/reassoc_request.h index 3db971f..04dbb14 100644 --- a/src/libwifi/gen/management/reassoc_request.h +++ b/src/libwifi/gen/management/reassoc_request.h | |||
@@ -20,11 +20,48 @@ | |||
20 | #include "../../core/frame/management/common.h" | 20 | #include "../../core/frame/management/common.h" |
21 | #include "../../core/frame/management/reassoc_request.h" | 21 | #include "../../core/frame/management/reassoc_request.h" |
22 | 22 | ||
23 | int libwifi_create_reassoc_req(struct libwifi_reassoc_req *reassoc_req, const unsigned char receiver[6], | 23 | /** |
24 | const unsigned char transmitter[6], const unsigned char current_ap[6], | 24 | * Create a new libwifi reassociation request |
25 | * | ||
26 | * @param reassoc_req A new libwifi_reassoc_req struct | ||
27 | * @param receiver The receiver MAC address | ||
28 | * @param transmitter The transmitter MAC address | ||
29 | * @param address3 The address 3 frame field value, typically the BSSID | ||
30 | * @param current_ap The current AP BSSID | ||
31 | * @param ssid The desired BSS SSID | ||
32 | * @param channel The desired channel | ||
33 | * @return Zero on success, or negative error | ||
34 | */ | ||
35 | int libwifi_create_reassoc_req(struct libwifi_reassoc_req *reassoc_req, | ||
36 | const unsigned char receiver[6], | ||
37 | const unsigned char transmitter[6], | ||
38 | const unsigned char address3[6], | ||
39 | const unsigned char current_ap[6], | ||
25 | const char *ssid, uint8_t channel); | 40 | const char *ssid, uint8_t channel); |
41 | |||
42 | /** | ||
43 | * Get the length of a given libwifi_reassoc_req | ||
44 | * | ||
45 | * @param reassoc_req A libwifi_reassoc_req struct | ||
46 | * @return The length of the given libwifi_reassoc_req, or negative error | ||
47 | */ | ||
26 | size_t libwifi_get_reassoc_req_length(struct libwifi_reassoc_req *reassoc_req); | 48 | size_t libwifi_get_reassoc_req_length(struct libwifi_reassoc_req *reassoc_req); |
49 | |||
50 | /** | ||
51 | * Dump a libwifi_reassoc_req into a raw format for packet injection. | ||
52 | * | ||
53 | * @param reassoc_req A libwifi_reassoc_req struct | ||
54 | * @param buf The buffer to dump into | ||
55 | * @param buf_len The length of the supplied buffer | ||
56 | * @return The amount of bytes dumped, or negative error | ||
57 | */ | ||
27 | size_t libwifi_dump_reassoc_req(struct libwifi_reassoc_req *reassoc_req, unsigned char *buf, size_t buf_len); | 58 | size_t libwifi_dump_reassoc_req(struct libwifi_reassoc_req *reassoc_req, unsigned char *buf, size_t buf_len); |
59 | |||
60 | /** | ||
61 | * Free any memory claimed by a libwifi_reassoc_req back to the system. | ||
62 | * | ||
63 | * @param reassoc_req A libwifi_reassoc_req | ||
64 | */ | ||
28 | void libwifi_free_reassoc_req(struct libwifi_reassoc_req *reassoc_req); | 65 | void libwifi_free_reassoc_req(struct libwifi_reassoc_req *reassoc_req); |
29 | 66 | ||
30 | #endif /* LIBWIFI_GEN_REASSOCREQUEST_H */ | 67 | #endif /* LIBWIFI_GEN_REASSOCREQUEST_H */ |
diff --git a/src/libwifi/gen/management/reassoc_response.c b/src/libwifi/gen/management/reassoc_response.c index 30a2389..5d85a86 100644 --- a/src/libwifi/gen/management/reassoc_response.c +++ b/src/libwifi/gen/management/reassoc_response.c | |||
@@ -33,7 +33,8 @@ | |||
33 | */ | 33 | */ |
34 | size_t libwifi_get_reassoc_resp_length(struct libwifi_reassoc_resp *reassoc_resp) { | 34 | size_t libwifi_get_reassoc_resp_length(struct libwifi_reassoc_resp *reassoc_resp) { |
35 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + | 35 | return sizeof(struct libwifi_mgmt_unordered_frame_header) + |
36 | sizeof(struct libwifi_reassoc_resp_fixed_parameters) + reassoc_resp->tags.length; | 36 | sizeof(struct libwifi_reassoc_resp_fixed_parameters) + |
37 | reassoc_resp->tags.length; | ||
37 | } | 38 | } |
38 | 39 | ||
39 | /** | 40 | /** |
@@ -58,28 +59,26 @@ int libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, | |||
58 | 59 | ||
59 | /** | 60 | /** |
60 | * The generated reassoc_resp frame is made with sane defaults defined in common.h. | 61 | * The generated reassoc_resp frame is made with sane defaults defined in common.h. |
61 | * Three tagged parameters are also added to the reassoc_resp: SSID, Channel and Supported Rates. | 62 | * One tagged parameters is also added to the reassoc_resp: Channel. |
62 | */ | 63 | */ |
63 | int libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, const unsigned char receiver[6], | 64 | int libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, |
64 | const unsigned char transmitter[6], uint8_t channel) { | 65 | const unsigned char receiver[6], |
66 | const unsigned char transmitter[6], | ||
67 | const unsigned char address3[6], | ||
68 | uint8_t channel) { | ||
65 | memset(reassoc_resp, 0, sizeof(struct libwifi_reassoc_resp)); | 69 | memset(reassoc_resp, 0, sizeof(struct libwifi_reassoc_resp)); |
66 | 70 | ||
67 | reassoc_resp->frame_header.frame_control.type = TYPE_MANAGEMENT; | 71 | reassoc_resp->frame_header.frame_control.type = TYPE_MANAGEMENT; |
68 | reassoc_resp->frame_header.frame_control.subtype = SUBTYPE_REASSOC_RESP; | 72 | reassoc_resp->frame_header.frame_control.subtype = SUBTYPE_REASSOC_RESP; |
69 | memcpy(&reassoc_resp->frame_header.addr1, receiver, 6); | 73 | memcpy(&reassoc_resp->frame_header.addr1, receiver, 6); |
70 | memcpy(&reassoc_resp->frame_header.addr2, transmitter, 6); | 74 | memcpy(&reassoc_resp->frame_header.addr2, transmitter, 6); |
75 | memcpy(&reassoc_resp->frame_header.addr3, address3, 6); | ||
71 | 76 | ||
72 | reassoc_resp->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); | 77 | reassoc_resp->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); |
73 | reassoc_resp->fixed_parameters.status_code = STATUS_SUCCESS; | 78 | reassoc_resp->fixed_parameters.status_code = STATUS_SUCCESS; |
74 | reassoc_resp->fixed_parameters.association_id = rand() % 4096; | 79 | reassoc_resp->fixed_parameters.association_id = rand() % 4096; |
75 | 80 | ||
76 | int ret = libwifi_set_reassoc_resp_channel(reassoc_resp, channel); | 81 | int ret = libwifi_set_reassoc_resp_channel(reassoc_resp, channel); |
77 | if (ret != 0) { | ||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; | ||
82 | ret = libwifi_quick_add_tag(&reassoc_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); | ||
83 | 82 | ||
84 | return ret; | 83 | return ret; |
85 | } | 84 | } |
diff --git a/src/libwifi/gen/management/reassoc_response.h b/src/libwifi/gen/management/reassoc_response.h index 420ed66..9db4696 100644 --- a/src/libwifi/gen/management/reassoc_response.h +++ b/src/libwifi/gen/management/reassoc_response.h | |||
@@ -22,7 +22,8 @@ | |||
22 | * Set the channel of a libwifi_reassoc_resp. | 22 | * Set the channel of a libwifi_reassoc_resp. |
23 | * | 23 | * |
24 | * @param reassoc_resp A libwifi_reassoc_resp | 24 | * @param reassoc_resp A libwifi_reassoc_resp |
25 | * @param channel The new channel | 25 | * @param channel The desired channel |
26 | * @return Zero on success, or negative error | ||
26 | */ | 27 | */ |
27 | int libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, uint8_t channel); | 28 | int libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, uint8_t channel); |
28 | 29 | ||
@@ -30,7 +31,7 @@ int libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, | |||
30 | * Calculate the length of a given libwifi_reassoc_resp | 31 | * Calculate the length of a given libwifi_reassoc_resp |
31 | * | 32 | * |
32 | * @param reassoc_resp A libwifi_reassoc_resp | 33 | * @param reassoc_resp A libwifi_reassoc_resp |
33 | * @return The length of the given reassoc_resp | 34 | * @return The length of the given reassoc_resp, or negative error |
34 | */ | 35 | */ |
35 | size_t libwifi_get_reassoc_resp_length(struct libwifi_reassoc_resp *reassoc_resp); | 36 | size_t libwifi_get_reassoc_resp_length(struct libwifi_reassoc_resp *reassoc_resp); |
36 | 37 | ||
@@ -41,13 +42,17 @@ size_t libwifi_get_reassoc_resp_length(struct libwifi_reassoc_resp *reassoc_resp | |||
41 | * via the libwifi_dump_reassoc_resp. | 42 | * via the libwifi_dump_reassoc_resp. |
42 | * | 43 | * |
43 | * @param reassoc_resp A libwifi_reassoc_resp | 44 | * @param reassoc_resp A libwifi_reassoc_resp |
44 | * @param receiver The receiver MAC address, aka address 1 | 45 | * @param receiver The receiver MAC address, aka address 1 |
45 | * @param transmitter The source MAC address, aka address 2 | 46 | * @param transmitter The source MAC address, aka address 2 |
46 | * @param channel The desired channel of the reassoc_resp | 47 | * @param address3 The address 3 frame field value, typically the BSSID |
47 | * | 48 | * @param channel The desired channel of the reassoc_resp |
49 | * @return Zero on success, or negative error | ||
48 | */ | 50 | */ |
49 | int libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, const unsigned char receiver[6], | 51 | int libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, |
50 | const unsigned char transmitter[6], uint8_t channel); | 52 | const unsigned char receiver[6], |
53 | const unsigned char transmitter[6], | ||
54 | const unsigned char address3[6], | ||
55 | uint8_t channel); | ||
51 | 56 | ||
52 | /** | 57 | /** |
53 | * Dump a libwifi_reassoc_resp into a raw format for packet injection. | 58 | * Dump a libwifi_reassoc_resp into a raw format for packet injection. |
@@ -55,7 +60,7 @@ int libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, const | |||
55 | * @param reassoc_resp A libwifi_reassoc_resp | 60 | * @param reassoc_resp A libwifi_reassoc_resp |
56 | * @param buf The output buffer for the frame data | 61 | * @param buf The output buffer for the frame data |
57 | * @param buf_len The length of the output buffer | 62 | * @param buf_len The length of the output buffer |
58 | * @return The length of the dumped reassoc_resp | 63 | * @return The length of the dumped reassoc_resp, or negative error |
59 | */ | 64 | */ |
60 | size_t libwifi_dump_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, unsigned char *buf, | 65 | size_t libwifi_dump_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, unsigned char *buf, |
61 | size_t buf_len); | 66 | size_t buf_len); |
@@ -63,7 +68,7 @@ size_t libwifi_dump_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, unsi | |||
63 | /** | 68 | /** |
64 | * Free any memory claimed by a libwifi_reassoc_resp back to the system. | 69 | * Free any memory claimed by a libwifi_reassoc_resp back to the system. |
65 | * | 70 | * |
66 | * @param reassoc_resp A libwifi_reassoc_resp | 71 | * @param reassoc_resp A libwifi_reassoc_resp struct |
67 | */ | 72 | */ |
68 | void libwifi_free_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp); | 73 | void libwifi_free_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp); |
69 | 74 | ||
diff --git a/src/libwifi/gen/management/timing_ad.c b/src/libwifi/gen/management/timing_ad.c index 61b9003..73a1188 100644 --- a/src/libwifi/gen/management/timing_ad.c +++ b/src/libwifi/gen/management/timing_ad.c | |||
@@ -23,16 +23,23 @@ | |||
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <string.h> | 24 | #include <string.h> |
25 | 25 | ||
26 | int libwifi_create_timing_advert(struct libwifi_timing_advert *adv, const unsigned char destination[6], | 26 | int libwifi_create_timing_advert(struct libwifi_timing_advert *adv, |
27 | const unsigned char transmitter[6], struct libwifi_timing_advert_fields *adv_fields, | 27 | const unsigned char destination[6], |
28 | const char country[3], uint16_t max_reg_power, uint8_t max_tx_power, uint8_t tx_power_used, | 28 | const unsigned char transmitter[6], |
29 | uint8_t noise_floor) { | 29 | const unsigned char address3[6], |
30 | struct libwifi_timing_advert_fields *adv_fields, | ||
31 | const char country[3], | ||
32 | uint16_t max_reg_power, | ||
33 | uint8_t max_tx_power, | ||
34 | uint8_t tx_power_used, | ||
35 | uint8_t noise_floor) { | ||
30 | memset(adv, 0, sizeof(struct libwifi_timing_advert)); | 36 | memset(adv, 0, sizeof(struct libwifi_timing_advert)); |
31 | 37 | ||
32 | adv->frame_header.frame_control.type = TYPE_MANAGEMENT; | 38 | adv->frame_header.frame_control.type = TYPE_MANAGEMENT; |
33 | adv->frame_header.frame_control.subtype = SUBTYPE_TIME_ADV; | 39 | adv->frame_header.frame_control.subtype = SUBTYPE_TIME_ADV; |
34 | memcpy(&adv->frame_header.addr1, destination, 6); | 40 | memcpy(&adv->frame_header.addr1, destination, 6); |
35 | memcpy(&adv->frame_header.addr2, transmitter, 6); | 41 | memcpy(&adv->frame_header.addr2, transmitter, 6); |
42 | memcpy(&adv->frame_header.addr3, address3, 6); | ||
36 | adv->frame_header.seq_control.sequence_number = (rand() % 4096); | 43 | adv->frame_header.seq_control.sequence_number = (rand() % 4096); |
37 | 44 | ||
38 | adv->fixed_parameters.timestamp = BYTESWAP64(libwifi_get_epoch()); | 45 | adv->fixed_parameters.timestamp = BYTESWAP64(libwifi_get_epoch()); |
diff --git a/src/libwifi/gen/management/timing_ad.h b/src/libwifi/gen/management/timing_ad.h index 51c7729..7f0de18 100644 --- a/src/libwifi/gen/management/timing_ad.h +++ b/src/libwifi/gen/management/timing_ad.h | |||
@@ -18,15 +18,57 @@ | |||
18 | 18 | ||
19 | #include "../../core/frame/management/timing_ad.h" | 19 | #include "../../core/frame/management/timing_ad.h" |
20 | 20 | ||
21 | int libwifi_create_timing_advert(struct libwifi_timing_advert *adv, const unsigned char destination[6], | 21 | /** |
22 | const unsigned char transmitter[6], struct libwifi_timing_advert_fields *adv_fields, | 22 | * Create a populated libwifi_timing_advert struct |
23 | const char country[3], uint16_t max_reg_power, uint8_t max_tx_power, uint8_t tx_power_used, | 23 | * |
24 | uint8_t noise_floor); | 24 | * A generated libwifi timing advert can be "dumped" into a buffer for packet injection |
25 | * via the libwifi_dump_timing_advert function. | ||
26 | * | ||
27 | * @param adv A new libwifi_timing_advert struct | ||
28 | * @param receiver The receiver MAC address, aka address 1 | ||
29 | * @param transmitter The source MAC address, aka address 2 | ||
30 | * @param address3 The address 3 frame field value, typically the BSSID | ||
31 | * @param adv_fields A libwifi_timing_advert_fields struct | ||
32 | * @param country The ISO 3166-1 country code field value | ||
33 | * @param max_reg_power Maximum Regulatory Power value | ||
34 | * @param max_tx_power Maximum Transmit Power value | ||
35 | * @param tx_power_used Transmit Power Used value | ||
36 | * @param noise_floor Noise Floor value | ||
37 | * @return Zero on success, or negative errno | ||
38 | */ | ||
39 | int libwifi_create_timing_advert(struct libwifi_timing_advert *adv, | ||
40 | const unsigned char receiver[6], | ||
41 | const unsigned char transmitter[6], | ||
42 | const unsigned char address3[6], | ||
43 | struct libwifi_timing_advert_fields *adv_fields, | ||
44 | const char country[3], | ||
45 | uint16_t max_reg_power, | ||
46 | uint8_t max_tx_power, | ||
47 | uint8_t tx_power_used, | ||
48 | uint8_t noise_floor); | ||
25 | 49 | ||
50 | /** | ||
51 | * Get the length of the specified libwifi_timing_advert struct | ||
52 | * | ||
53 | * @return Length of the specified timing advert, or negative error | ||
54 | */ | ||
26 | size_t libwifi_get_timing_advert_length(struct libwifi_timing_advert *adv); | 55 | size_t libwifi_get_timing_advert_length(struct libwifi_timing_advert *adv); |
27 | 56 | ||
57 | /** | ||
58 | * Dump a libwifi_timing_advert into a raw format for packet injection. | ||
59 | * | ||
60 | * @param adv A libwifi_timing_advert | ||
61 | * @param buf The output buffer for the frame data | ||
62 | * @param buf_len The length of the output buffer | ||
63 | * @return The length of the dumped timing advert, or negative error | ||
64 | */ | ||
28 | size_t libwifi_dump_timing_advert(struct libwifi_timing_advert *adv, unsigned char *buf, size_t buf_len); | 65 | size_t libwifi_dump_timing_advert(struct libwifi_timing_advert *adv, unsigned char *buf, size_t buf_len); |
29 | 66 | ||
67 | /** | ||
68 | * Free any memory claimed by a libwifi_timing_advert back to the system. | ||
69 | * | ||
70 | * @param adv A libwifi_timing_advert struct | ||
71 | */ | ||
30 | void libwifi_free_timing_advert(struct libwifi_timing_advert *adv); | 72 | void libwifi_free_timing_advert(struct libwifi_timing_advert *adv); |
31 | 73 | ||
32 | #endif /* LIBWIFI_GEN_TIMINGAD_H */ | 74 | #endif /* LIBWIFI_GEN_TIMINGAD_H */ |
diff --git a/test/src/action_tests.c b/test/src/action_tests.c index 997095d..c8377b5 100644 --- a/test/src/action_tests.c +++ b/test/src/action_tests.c | |||
@@ -12,7 +12,7 @@ const unsigned char bcast[] = BCAST_MAC; | |||
12 | int test_action_gen_full() { | 12 | int test_action_gen_full() { |
13 | struct libwifi_action action = {0}; | 13 | struct libwifi_action action = {0}; |
14 | 14 | ||
15 | int ret = libwifi_create_action(&action, bcast, to, ACTION_HT); | 15 | int ret = libwifi_create_action(&action, bcast, to, to, ACTION_HT); |
16 | if (ret != 0) { | 16 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create action: %s\n", strerror(ret)); | 17 | fprintf(stderr, "Failed to create action: %s\n", strerror(ret)); |
18 | return ret; | 18 | return ret; |
@@ -42,7 +42,7 @@ int test_action_gen_full() { | |||
42 | int test_action_add_detail() { | 42 | int test_action_add_detail() { |
43 | struct libwifi_action action = {0}; | 43 | struct libwifi_action action = {0}; |
44 | 44 | ||
45 | int ret = libwifi_create_action(&action, bcast, to, ACTION_HT); | 45 | int ret = libwifi_create_action(&action, bcast, to, to, ACTION_HT); |
46 | if (ret != 0) { | 46 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create action: %s\n", strerror(ret)); | 47 | fprintf(stderr, "Failed to create action: %s\n", strerror(ret)); |
48 | return ret; | 48 | return ret; |
diff --git a/test/src/assoc_req_tests.c b/test/src/assoc_req_tests.c index fc6379f..32d199e 100644 --- a/test/src/assoc_req_tests.c +++ b/test/src/assoc_req_tests.c | |||
@@ -12,7 +12,7 @@ const unsigned char bcast[] = BCAST_MAC; | |||
12 | int test_assoc_req_gen_full() { | 12 | int test_assoc_req_gen_full() { |
13 | struct libwifi_assoc_req assoc_req = {0}; | 13 | struct libwifi_assoc_req assoc_req = {0}; |
14 | 14 | ||
15 | int ret = libwifi_create_assoc_req(&assoc_req, bcast, to, "Some SSID", 11); | 15 | int ret = libwifi_create_assoc_req(&assoc_req, bcast, to, to, "Some SSID", 11); |
16 | if (ret != 0) { | 16 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create assoc_req: %s\n", strerror(ret)); | 17 | fprintf(stderr, "Failed to create assoc_req: %s\n", strerror(ret)); |
18 | return ret; | 18 | return ret; |
@@ -42,7 +42,7 @@ int test_assoc_req_gen_full() { | |||
42 | int test_assoc_req_add_tag() { | 42 | int test_assoc_req_add_tag() { |
43 | struct libwifi_assoc_req assoc_req = {0}; | 43 | struct libwifi_assoc_req assoc_req = {0}; |
44 | 44 | ||
45 | int ret = libwifi_create_assoc_req(&assoc_req, bcast, to, "Some SSID", 11); | 45 | int ret = libwifi_create_assoc_req(&assoc_req, bcast, to, to, "Some SSID", 11); |
46 | if (ret != 0) { | 46 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create assoc_req: %s\n", strerror(ret)); | 47 | fprintf(stderr, "Failed to create assoc_req: %s\n", strerror(ret)); |
48 | return ret; | 48 | return ret; |
diff --git a/test/src/assoc_resp_tests.c b/test/src/assoc_resp_tests.c index 3a261ed..717a3cd 100644 --- a/test/src/assoc_resp_tests.c +++ b/test/src/assoc_resp_tests.c | |||
@@ -12,7 +12,7 @@ const unsigned char bcast[] = BCAST_MAC; | |||
12 | int test_assoc_resp_gen_full() { | 12 | int test_assoc_resp_gen_full() { |
13 | struct libwifi_assoc_resp assoc_resp = {0}; | 13 | struct libwifi_assoc_resp assoc_resp = {0}; |
14 | 14 | ||
15 | int ret = libwifi_create_assoc_resp(&assoc_resp, bcast, to, 11); | 15 | int ret = libwifi_create_assoc_resp(&assoc_resp, bcast, to, to, 11); |
16 | if (ret != 0) { | 16 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create assoc_resp: %s\n", strerror(ret)); | 17 | fprintf(stderr, "Failed to create assoc_resp: %s\n", strerror(ret)); |
18 | return ret; | 18 | return ret; |
@@ -42,7 +42,7 @@ int test_assoc_resp_gen_full() { | |||
42 | int test_assoc_resp_add_tag() { | 42 | int test_assoc_resp_add_tag() { |
43 | struct libwifi_assoc_resp assoc_resp = {0}; | 43 | struct libwifi_assoc_resp assoc_resp = {0}; |
44 | 44 | ||
45 | int ret = libwifi_create_assoc_resp(&assoc_resp, bcast, to, 11); | 45 | int ret = libwifi_create_assoc_resp(&assoc_resp, bcast, to, to, 11); |
46 | if (ret != 0) { | 46 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create assoc_resp: %s\n", strerror(ret)); | 47 | fprintf(stderr, "Failed to create assoc_resp: %s\n", strerror(ret)); |
48 | return ret; | 48 | return ret; |
diff --git a/test/src/auth_tests.c b/test/src/auth_tests.c index f78aeed..41dcefe 100644 --- a/test/src/auth_tests.c +++ b/test/src/auth_tests.c | |||
@@ -12,7 +12,7 @@ const unsigned char bcast[] = BCAST_MAC; | |||
12 | int test_auth_gen_full() { | 12 | int test_auth_gen_full() { |
13 | struct libwifi_auth auth = {0}; | 13 | struct libwifi_auth auth = {0}; |
14 | 14 | ||
15 | int ret = libwifi_create_auth(&auth, bcast, to, 0, 100, STATUS_SUCCESS); | 15 | int ret = libwifi_create_auth(&auth, bcast, to, to, 0, 100, STATUS_SUCCESS); |
16 | if (ret != 0) { | 16 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create auth: %s\n", strerror(ret)); | 17 | fprintf(stderr, "Failed to create auth: %s\n", strerror(ret)); |
18 | return ret; | 18 | return ret; |
@@ -42,7 +42,7 @@ int test_auth_gen_full() { | |||
42 | int test_auth_add_tag() { | 42 | int test_auth_add_tag() { |
43 | struct libwifi_auth auth = {0}; | 43 | struct libwifi_auth auth = {0}; |
44 | 44 | ||
45 | int ret = libwifi_create_auth(&auth, bcast, to, 0, 100, STATUS_SUCCESS); | 45 | int ret = libwifi_create_auth(&auth, bcast, to, to, 0, 100, STATUS_SUCCESS); |
46 | if (ret != 0) { | 46 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create auth: %s\n", strerror(ret)); | 47 | fprintf(stderr, "Failed to create auth: %s\n", strerror(ret)); |
48 | return ret; | 48 | return ret; |
diff --git a/test/src/deauth_tests.c b/test/src/deauth_tests.c index 9033574..99df9f6 100644 --- a/test/src/deauth_tests.c +++ b/test/src/deauth_tests.c | |||
@@ -12,7 +12,7 @@ const unsigned char bcast[] = BCAST_MAC; | |||
12 | int test_deauth_gen_full() { | 12 | int test_deauth_gen_full() { |
13 | struct libwifi_deauth deauth = {0}; | 13 | struct libwifi_deauth deauth = {0}; |
14 | 14 | ||
15 | int ret = libwifi_create_deauth(&deauth, bcast, to, REASON_STA_LEAVING); | 15 | int ret = libwifi_create_deauth(&deauth, bcast, to, to, REASON_STA_LEAVING); |
16 | if (ret != 0) { | 16 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create deauth: %s\n", strerror(ret)); | 17 | fprintf(stderr, "Failed to create deauth: %s\n", strerror(ret)); |
18 | return ret; | 18 | return ret; |
@@ -42,7 +42,7 @@ int test_deauth_gen_full() { | |||
42 | int test_deauth_add_tag() { | 42 | int test_deauth_add_tag() { |
43 | struct libwifi_deauth deauth = {0}; | 43 | struct libwifi_deauth deauth = {0}; |
44 | 44 | ||
45 | int ret = libwifi_create_deauth(&deauth, bcast, to, REASON_STA_LEAVING); | 45 | int ret = libwifi_create_deauth(&deauth, bcast, to, to, REASON_STA_LEAVING); |
46 | if (ret != 0) { | 46 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create deauth: %s\n", strerror(ret)); | 47 | fprintf(stderr, "Failed to create deauth: %s\n", strerror(ret)); |
48 | return ret; | 48 | return ret; |
diff --git a/test/src/disassoc_tests.c b/test/src/disassoc_tests.c index c5e27de..2e3da77 100644 --- a/test/src/disassoc_tests.c +++ b/test/src/disassoc_tests.c | |||
@@ -12,7 +12,7 @@ const unsigned char bcast[] = BCAST_MAC; | |||
12 | int test_disassoc_gen_full() { | 12 | int test_disassoc_gen_full() { |
13 | struct libwifi_disassoc disassoc = {0}; | 13 | struct libwifi_disassoc disassoc = {0}; |
14 | 14 | ||
15 | int ret = libwifi_create_disassoc(&disassoc, bcast, to, REASON_STA_LEAVING); | 15 | int ret = libwifi_create_disassoc(&disassoc, bcast, to, to, REASON_STA_LEAVING); |
16 | if (ret != 0) { | 16 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create disassoc: %s\n", strerror(ret)); | 17 | fprintf(stderr, "Failed to create disassoc: %s\n", strerror(ret)); |
18 | return ret; | 18 | return ret; |
@@ -42,7 +42,7 @@ int test_disassoc_gen_full() { | |||
42 | int test_disassoc_add_tag() { | 42 | int test_disassoc_add_tag() { |
43 | struct libwifi_disassoc disassoc = {0}; | 43 | struct libwifi_disassoc disassoc = {0}; |
44 | 44 | ||
45 | int ret = libwifi_create_disassoc(&disassoc, bcast, to, REASON_STA_LEAVING); | 45 | int ret = libwifi_create_disassoc(&disassoc, bcast, to, to, REASON_STA_LEAVING); |
46 | if (ret != 0) { | 46 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create disassoc: %s\n", strerror(ret)); | 47 | fprintf(stderr, "Failed to create disassoc: %s\n", strerror(ret)); |
48 | return ret; | 48 | return ret; |
diff --git a/test/src/probe_resp_tests.c b/test/src/probe_resp_tests.c index 463a90a..4f4f650 100644 --- a/test/src/probe_resp_tests.c +++ b/test/src/probe_resp_tests.c | |||
@@ -12,7 +12,7 @@ const unsigned char bcast[] = BCAST_MAC; | |||
12 | int test_probe_resp_gen_full() { | 12 | int test_probe_resp_gen_full() { |
13 | struct libwifi_probe_resp probe_resp = {0}; | 13 | struct libwifi_probe_resp probe_resp = {0}; |
14 | 14 | ||
15 | int ret = libwifi_create_probe_resp(&probe_resp, bcast, to, "Some SSID", 11); | 15 | int ret = libwifi_create_probe_resp(&probe_resp, bcast, to, to, "Some SSID", 11); |
16 | if (ret != 0) { | 16 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create probe_resp: %s\n", strerror(ret)); | 17 | fprintf(stderr, "Failed to create probe_resp: %s\n", strerror(ret)); |
18 | return ret; | 18 | return ret; |
@@ -42,7 +42,7 @@ int test_probe_resp_gen_full() { | |||
42 | int test_probe_resp_add_tag() { | 42 | int test_probe_resp_add_tag() { |
43 | struct libwifi_probe_resp probe_resp = {0}; | 43 | struct libwifi_probe_resp probe_resp = {0}; |
44 | 44 | ||
45 | int ret = libwifi_create_probe_resp(&probe_resp, bcast, to, "Some SSID", 11); | 45 | int ret = libwifi_create_probe_resp(&probe_resp, bcast, to, to, "Some SSID", 11); |
46 | if (ret != 0) { | 46 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create probe_resp: %s\n", strerror(ret)); | 47 | fprintf(stderr, "Failed to create probe_resp: %s\n", strerror(ret)); |
48 | return ret; | 48 | return ret; |
diff --git a/test/src/reassoc_req_tests.c b/test/src/reassoc_req_tests.c index 00e2b53..53cf6b9 100644 --- a/test/src/reassoc_req_tests.c +++ b/test/src/reassoc_req_tests.c | |||
@@ -4,15 +4,17 @@ | |||
4 | #include <stdio.h> | 4 | #include <stdio.h> |
5 | #include <string.h> | 5 | #include <string.h> |
6 | 6 | ||
7 | #define BCAST_MAC "\xff\xff\xff\xff\xff\xff" | 7 | #define BCAST_MAC "\xff\xff\xff\xff\xff\xff" |
8 | #define TO_MAC "\x00\x20\x91\xAA\xBB\xCC" | 8 | #define TO_MAC "\x00\x20\x91\xAA\xBB\xCC" |
9 | #define CURRENT_AP "\x00\x20\x91\x00\x11\x22" | ||
9 | const unsigned char to[] = TO_MAC; | 10 | const unsigned char to[] = TO_MAC; |
10 | const unsigned char bcast[] = BCAST_MAC; | 11 | const unsigned char bcast[] = BCAST_MAC; |
12 | const unsigned char current_ap[] = CURRENT_AP; | ||
11 | 13 | ||
12 | int test_reassoc_req_gen_full() { | 14 | int test_reassoc_req_gen_full() { |
13 | struct libwifi_reassoc_req reassoc_req = {0}; | 15 | struct libwifi_reassoc_req reassoc_req = {0}; |
14 | 16 | ||
15 | int ret = libwifi_create_reassoc_req(&reassoc_req, bcast, to, to, "Some SSID", 11); | 17 | int ret = libwifi_create_reassoc_req(&reassoc_req, bcast, to, to, current_ap, "Some SSID", 11); |
16 | if (ret != 0) { | 18 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create reassoc_req: %s\n", strerror(ret)); | 19 | fprintf(stderr, "Failed to create reassoc_req: %s\n", strerror(ret)); |
18 | return ret; | 20 | return ret; |
@@ -42,7 +44,7 @@ int test_reassoc_req_gen_full() { | |||
42 | int test_reassoc_req_add_tag() { | 44 | int test_reassoc_req_add_tag() { |
43 | struct libwifi_reassoc_req reassoc_req = {0}; | 45 | struct libwifi_reassoc_req reassoc_req = {0}; |
44 | 46 | ||
45 | int ret = libwifi_create_reassoc_req(&reassoc_req, bcast, to, to, "Some SSID", 11); | 47 | int ret = libwifi_create_reassoc_req(&reassoc_req, bcast, to, to, current_ap, "Some SSID", 11); |
46 | if (ret != 0) { | 48 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create reassoc_req: %s\n", strerror(ret)); | 49 | fprintf(stderr, "Failed to create reassoc_req: %s\n", strerror(ret)); |
48 | return ret; | 50 | return ret; |
diff --git a/test/src/reassoc_resp_tests.c b/test/src/reassoc_resp_tests.c index 8167916..fbfd448 100644 --- a/test/src/reassoc_resp_tests.c +++ b/test/src/reassoc_resp_tests.c | |||
@@ -6,13 +6,15 @@ | |||
6 | 6 | ||
7 | #define BCAST_MAC "\xff\xff\xff\xff\xff\xff" | 7 | #define BCAST_MAC "\xff\xff\xff\xff\xff\xff" |
8 | #define TO_MAC "\x00\x20\x91\xAA\xBB\xCC" | 8 | #define TO_MAC "\x00\x20\x91\xAA\xBB\xCC" |
9 | #define CURRENT_AP "\x00\x20\x91\x00\x11\x22" | ||
9 | const unsigned char to[] = TO_MAC; | 10 | const unsigned char to[] = TO_MAC; |
10 | const unsigned char bcast[] = BCAST_MAC; | 11 | const unsigned char bcast[] = BCAST_MAC; |
12 | const unsigned char current_ap[] = CURRENT_AP; | ||
11 | 13 | ||
12 | int test_reassoc_resp_gen_full() { | 14 | int test_reassoc_resp_gen_full() { |
13 | struct libwifi_reassoc_resp reassoc_resp = {0}; | 15 | struct libwifi_reassoc_resp reassoc_resp = {0}; |
14 | 16 | ||
15 | int ret = libwifi_create_reassoc_resp(&reassoc_resp, bcast, to, 11); | 17 | int ret = libwifi_create_reassoc_resp(&reassoc_resp, bcast, to, current_ap, 11); |
16 | if (ret != 0) { | 18 | if (ret != 0) { |
17 | fprintf(stderr, "Failed to create reassoc_resp: %s\n", strerror(ret)); | 19 | fprintf(stderr, "Failed to create reassoc_resp: %s\n", strerror(ret)); |
18 | return ret; | 20 | return ret; |
@@ -42,7 +44,7 @@ int test_reassoc_resp_gen_full() { | |||
42 | int test_reassoc_resp_add_tag() { | 44 | int test_reassoc_resp_add_tag() { |
43 | struct libwifi_reassoc_resp reassoc_resp = {0}; | 45 | struct libwifi_reassoc_resp reassoc_resp = {0}; |
44 | 46 | ||
45 | int ret = libwifi_create_reassoc_resp(&reassoc_resp, bcast, to, 11); | 47 | int ret = libwifi_create_reassoc_resp(&reassoc_resp, bcast, to, current_ap, 11); |
46 | if (ret != 0) { | 48 | if (ret != 0) { |
47 | fprintf(stderr, "Failed to create reassoc_resp: %s\n", strerror(ret)); | 49 | fprintf(stderr, "Failed to create reassoc_resp: %s\n", strerror(ret)); |
48 | return ret; | 50 | return ret; |
diff --git a/test/src/timing_ad_tests.c b/test/src/timing_ad_tests.c index 59d20eb..2e2e5ba 100644 --- a/test/src/timing_ad_tests.c +++ b/test/src/timing_ad_tests.c | |||
@@ -19,7 +19,7 @@ int test_timing_ad_gen_full() { | |||
19 | memcpy(ad_fields.time_value, | 19 | memcpy(ad_fields.time_value, |
20 | "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", 10); | 20 | "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", 10); |
21 | 21 | ||
22 | int ret = libwifi_create_timing_advert(&time_ad, to, to, &ad_fields, "GB", -56, -56, -30, -20); | 22 | int ret = libwifi_create_timing_advert(&time_ad, bcast, to, to, &ad_fields, "GB", -56, -56, -30, -20); |
23 | if (ret != 0) { | 23 | if (ret != 0) { |
24 | fprintf(stderr, "Failed to create timing advert\n"); | 24 | fprintf(stderr, "Failed to create timing advert\n"); |
25 | return ret; | 25 | return ret; |
diff --git a/utils/src/test_generation.c b/utils/src/test_generation.c index f269fe4..b77a2fc 100644 --- a/utils/src/test_generation.c +++ b/utils/src/test_generation.c | |||
@@ -186,7 +186,7 @@ void inject_probe_responses() { | |||
186 | struct libwifi_probe_resp probe_resp; | 186 | struct libwifi_probe_resp probe_resp; |
187 | memset(&probe_resp, 0, sizeof(struct libwifi_probe_resp)); | 187 | memset(&probe_resp, 0, sizeof(struct libwifi_probe_resp)); |
188 | 188 | ||
189 | libwifi_create_probe_resp(&probe_resp, to, from, PROBE_RESP_SSID, CHANNEL); | 189 | libwifi_create_probe_resp(&probe_resp, to, from, from, PROBE_RESP_SSID, CHANNEL); |
190 | libwifi_quick_add_tag(&probe_resp.tags, TAG_VENDOR_SPECIFIC, tag_data1, sizeof(tag_data1)); | 190 | libwifi_quick_add_tag(&probe_resp.tags, TAG_VENDOR_SPECIFIC, tag_data1, sizeof(tag_data1)); |
191 | 191 | ||
192 | unsigned char *buf = NULL; | 192 | unsigned char *buf = NULL; |
@@ -258,7 +258,7 @@ void inject_deauths() { | |||
258 | struct libwifi_deauth deauth; | 258 | struct libwifi_deauth deauth; |
259 | memset(&deauth, 0, sizeof(struct libwifi_deauth)); | 259 | memset(&deauth, 0, sizeof(struct libwifi_deauth)); |
260 | 260 | ||
261 | libwifi_create_deauth(&deauth, to, from, REASON_STA_LEAVING); | 261 | libwifi_create_deauth(&deauth, to, from, from, REASON_STA_LEAVING); |
262 | 262 | ||
263 | unsigned char *buf = NULL; | 263 | unsigned char *buf = NULL; |
264 | size_t buf_sz = libwifi_get_deauth_length(&deauth); | 264 | size_t buf_sz = libwifi_get_deauth_length(&deauth); |
@@ -293,7 +293,7 @@ void inject_disassocs() { | |||
293 | struct libwifi_disassoc disassoc; | 293 | struct libwifi_disassoc disassoc; |
294 | memset(&disassoc, 0, sizeof(struct libwifi_disassoc)); | 294 | memset(&disassoc, 0, sizeof(struct libwifi_disassoc)); |
295 | 295 | ||
296 | libwifi_create_disassoc(&disassoc, to, from, REASON_STA_LEAVING); | 296 | libwifi_create_disassoc(&disassoc, to, from, from, REASON_STA_LEAVING); |
297 | 297 | ||
298 | unsigned char *buf = NULL; | 298 | unsigned char *buf = NULL; |
299 | size_t buf_sz = libwifi_get_disassoc_length(&disassoc); | 299 | size_t buf_sz = libwifi_get_disassoc_length(&disassoc); |
@@ -328,7 +328,7 @@ void inject_assoc_requests() { | |||
328 | struct libwifi_assoc_req assoc_req; | 328 | struct libwifi_assoc_req assoc_req; |
329 | memset(&assoc_req, 0, sizeof(struct libwifi_assoc_req)); | 329 | memset(&assoc_req, 0, sizeof(struct libwifi_assoc_req)); |
330 | 330 | ||
331 | libwifi_create_assoc_req(&assoc_req, to, from, ASSOC_REQ_SSID, CHANNEL); | 331 | libwifi_create_assoc_req(&assoc_req, to, from, from, ASSOC_REQ_SSID, CHANNEL); |
332 | 332 | ||
333 | unsigned char *buf = NULL; | 333 | unsigned char *buf = NULL; |
334 | size_t buf_sz = libwifi_get_assoc_req_length(&assoc_req); | 334 | size_t buf_sz = libwifi_get_assoc_req_length(&assoc_req); |
@@ -363,7 +363,7 @@ void inject_assoc_responses() { | |||
363 | struct libwifi_assoc_resp assoc_resp; | 363 | struct libwifi_assoc_resp assoc_resp; |
364 | memset(&assoc_resp, 0, sizeof(struct libwifi_assoc_req)); | 364 | memset(&assoc_resp, 0, sizeof(struct libwifi_assoc_req)); |
365 | 365 | ||
366 | libwifi_create_assoc_resp(&assoc_resp, to, from, CHANNEL); | 366 | libwifi_create_assoc_resp(&assoc_resp, to, from, from, CHANNEL); |
367 | 367 | ||
368 | unsigned char *buf = NULL; | 368 | unsigned char *buf = NULL; |
369 | size_t buf_sz = libwifi_get_assoc_resp_length(&assoc_resp); | 369 | size_t buf_sz = libwifi_get_assoc_resp_length(&assoc_resp); |
@@ -398,7 +398,7 @@ void inject_reassoc_requests() { | |||
398 | struct libwifi_reassoc_req reassoc_req; | 398 | struct libwifi_reassoc_req reassoc_req; |
399 | memset(&reassoc_req, 0, sizeof(struct libwifi_assoc_req)); | 399 | memset(&reassoc_req, 0, sizeof(struct libwifi_assoc_req)); |
400 | 400 | ||
401 | libwifi_create_reassoc_req(&reassoc_req, to, from, reassoc_mac, REASSOC_REQ_SSID, CHANNEL); | 401 | libwifi_create_reassoc_req(&reassoc_req, to, from, from, reassoc_mac, REASSOC_REQ_SSID, CHANNEL); |
402 | 402 | ||
403 | unsigned char *buf = NULL; | 403 | unsigned char *buf = NULL; |
404 | size_t buf_sz = libwifi_get_reassoc_req_length(&reassoc_req); | 404 | size_t buf_sz = libwifi_get_reassoc_req_length(&reassoc_req); |
@@ -434,7 +434,7 @@ void inject_reassoc_responses() { | |||
434 | struct libwifi_reassoc_resp reassoc_resp; | 434 | struct libwifi_reassoc_resp reassoc_resp; |
435 | memset(&reassoc_resp, 0, sizeof(struct libwifi_assoc_req)); | 435 | memset(&reassoc_resp, 0, sizeof(struct libwifi_assoc_req)); |
436 | 436 | ||
437 | libwifi_create_reassoc_resp(&reassoc_resp, to, from, CHANNEL); | 437 | libwifi_create_reassoc_resp(&reassoc_resp, to, from, from, CHANNEL); |
438 | 438 | ||
439 | unsigned char *buf = NULL; | 439 | unsigned char *buf = NULL; |
440 | size_t buf_sz = libwifi_get_reassoc_resp_length(&reassoc_resp); | 440 | size_t buf_sz = libwifi_get_reassoc_resp_length(&reassoc_resp); |
@@ -469,7 +469,7 @@ void inject_auths() { | |||
469 | struct libwifi_auth auth; | 469 | struct libwifi_auth auth; |
470 | memset(&auth, 0, sizeof(struct libwifi_deauth)); | 470 | memset(&auth, 0, sizeof(struct libwifi_deauth)); |
471 | 471 | ||
472 | libwifi_create_auth(&auth, to, from, AUTH_OPEN, 0, STATUS_SUCCESS); | 472 | libwifi_create_auth(&auth, to, from, from, AUTH_OPEN, 0, STATUS_SUCCESS); |
473 | 473 | ||
474 | unsigned char *buf = NULL; | 474 | unsigned char *buf = NULL; |
475 | size_t buf_sz = libwifi_get_auth_length(&auth); | 475 | size_t buf_sz = libwifi_get_auth_length(&auth); |
@@ -487,7 +487,7 @@ void inject_auths() { | |||
487 | 487 | ||
488 | memset(&auth, 0, sizeof(struct libwifi_deauth)); | 488 | memset(&auth, 0, sizeof(struct libwifi_deauth)); |
489 | 489 | ||
490 | libwifi_create_auth(&auth, from, to, AUTH_OPEN, 1, STATUS_SUCCESS); | 490 | libwifi_create_auth(&auth, from, to, to, AUTH_OPEN, 1, STATUS_SUCCESS); |
491 | 491 | ||
492 | buf = NULL; | 492 | buf = NULL; |
493 | buf_sz = libwifi_get_auth_length(&auth); | 493 | buf_sz = libwifi_get_auth_length(&auth); |
@@ -527,7 +527,7 @@ void inject_timing_ads() { | |||
527 | memcpy(ad_fields.time_value, | 527 | memcpy(ad_fields.time_value, |
528 | "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", 10); | 528 | "\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA\xAA", 10); |
529 | 529 | ||
530 | libwifi_create_timing_advert(&time_ad, to, from, &ad_fields, "GB", -56, -56, -30, -20); | 530 | libwifi_create_timing_advert(&time_ad, to, from, from, &ad_fields, "GB", -56, -56, -30, -20); |
531 | 531 | ||
532 | unsigned char *buf = NULL; | 532 | unsigned char *buf = NULL; |
533 | size_t buf_len = libwifi_get_timing_advert_length(&time_ad); | 533 | size_t buf_len = libwifi_get_timing_advert_length(&time_ad); |
@@ -562,7 +562,7 @@ void inject_action_noacks() { | |||
562 | struct libwifi_action action; | 562 | struct libwifi_action action; |
563 | memset(&action, 0, sizeof(struct libwifi_action)); | 563 | memset(&action, 0, sizeof(struct libwifi_action)); |
564 | 564 | ||
565 | libwifi_create_action_no_ack(&action, to, from, ACTION_FAST_BSS_TRANSITION); | 565 | libwifi_create_action_no_ack(&action, to, from, from, ACTION_FAST_BSS_TRANSITION); |
566 | 566 | ||
567 | unsigned char *action_buf = malloc(256); | 567 | unsigned char *action_buf = malloc(256); |
568 | memset(action_buf, 0, 256); | 568 | memset(action_buf, 0, 256); |
@@ -637,7 +637,7 @@ void inject_actions() { | |||
637 | struct libwifi_action action; | 637 | struct libwifi_action action; |
638 | memset(&action, 0, sizeof(struct libwifi_action)); | 638 | memset(&action, 0, sizeof(struct libwifi_action)); |
639 | 639 | ||
640 | libwifi_create_action(&action, to, from, ACTION_FAST_BSS_TRANSITION); | 640 | libwifi_create_action(&action, to, from, from, ACTION_FAST_BSS_TRANSITION); |
641 | 641 | ||
642 | unsigned char *action_buf = malloc(256); | 642 | unsigned char *action_buf = malloc(256); |
643 | memset(action_buf, 0, 256); | 643 | memset(action_buf, 0, 256); |