diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/libwifi/gen/management/assoc_request.c | 11 | ||||
-rw-r--r-- | src/libwifi/gen/management/assoc_response.c | 19 | ||||
-rw-r--r-- | src/libwifi/gen/management/assoc_response.h | 4 | ||||
-rw-r--r-- | src/libwifi/gen/management/authentication.c | 4 | ||||
-rw-r--r-- | src/libwifi/gen/management/authentication.h | 2 | ||||
-rw-r--r-- | src/libwifi/gen/management/beacon.c | 32 | ||||
-rw-r--r-- | src/libwifi/gen/management/beacon.h | 6 | ||||
-rw-r--r-- | src/libwifi/gen/management/disassociation.c | 4 | ||||
-rw-r--r-- | src/libwifi/gen/management/disassociation.h | 2 | ||||
-rw-r--r-- | src/libwifi/gen/management/probe_request.c | 11 | ||||
-rw-r--r-- | src/libwifi/gen/management/probe_request.h | 2 | ||||
-rw-r--r-- | src/libwifi/gen/management/probe_response.c | 43 | ||||
-rw-r--r-- | src/libwifi/gen/management/probe_response.h | 6 | ||||
-rw-r--r-- | src/libwifi/gen/management/reassoc_request.c | 10 | ||||
-rw-r--r-- | src/libwifi/gen/management/reassoc_response.c | 23 | ||||
-rw-r--r-- | src/libwifi/gen/management/reassoc_response.h | 4 | ||||
-rw-r--r-- | src/libwifi/gen/management/timing_ad.c | 9 | ||||
-rw-r--r-- | src/libwifi/gen/management/timing_ad.h | 2 |
18 files changed, 138 insertions, 56 deletions
diff --git a/src/libwifi/gen/management/assoc_request.c b/src/libwifi/gen/management/assoc_request.c index 8ba3585..268b167 100644 --- a/src/libwifi/gen/management/assoc_request.c +++ b/src/libwifi/gen/management/assoc_request.c | |||
@@ -47,8 +47,15 @@ int libwifi_create_assoc_req(struct libwifi_assoc_req *assoc_req, const unsigned | |||
47 | assoc_req->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); | 47 | assoc_req->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); |
48 | assoc_req->fixed_parameters.listen_interval = BYTESWAP16(LIBWIFI_DEFAULT_LISTEN_INTERVAL); | 48 | assoc_req->fixed_parameters.listen_interval = BYTESWAP16(LIBWIFI_DEFAULT_LISTEN_INTERVAL); |
49 | 49 | ||
50 | libwifi_quick_add_tag(&assoc_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); | 50 | int ret = libwifi_quick_add_tag(&assoc_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); |
51 | libwifi_quick_add_tag(&assoc_req->tags, TAG_DS_PARAMETER, (const unsigned char *) &channel, 1); | 51 | if (ret != 0) { |
52 | return ret; | ||
53 | } | ||
54 | |||
55 | ret = libwifi_quick_add_tag(&assoc_req->tags, TAG_DS_PARAMETER, (const unsigned char *) &channel, 1); | ||
56 | if (ret != 0) { | ||
57 | return ret; | ||
58 | } | ||
52 | 59 | ||
53 | return 0; | 60 | return 0; |
54 | } | 61 | } |
diff --git a/src/libwifi/gen/management/assoc_response.c b/src/libwifi/gen/management/assoc_response.c index be00511..b3077de 100644 --- a/src/libwifi/gen/management/assoc_response.c +++ b/src/libwifi/gen/management/assoc_response.c | |||
@@ -41,21 +41,28 @@ size_t libwifi_get_assoc_resp_length(struct libwifi_assoc_resp *assoc_resp) { | |||
41 | * Simple helper function to set the channel of an association response by removing and re-adding the | 41 | * Simple helper function to set the channel of an association response by removing and re-adding the |
42 | * DS tagged parameter. | 42 | * DS tagged parameter. |
43 | */ | 43 | */ |
44 | void libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_t channel) { | 44 | int libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_t channel) { |
45 | int ret = 0; | ||
46 | |||
45 | if (assoc_resp->tags.length != 0) { | 47 | if (assoc_resp->tags.length != 0) { |
46 | libwifi_remove_tag(&assoc_resp->tags, TAG_DS_PARAMETER); | 48 | ret = libwifi_remove_tag(&assoc_resp->tags, TAG_DS_PARAMETER); |
49 | if (ret != 0) { | ||
50 | return ret; | ||
51 | } | ||
47 | } | 52 | } |
48 | 53 | ||
49 | const unsigned char *chan = (const unsigned char *) &channel; | 54 | const unsigned char *chan = (const unsigned char *) &channel; |
50 | 55 | ||
51 | libwifi_quick_add_tag(&assoc_resp->tags, TAG_DS_PARAMETER, chan, 1); | 56 | ret = libwifi_quick_add_tag(&assoc_resp->tags, TAG_DS_PARAMETER, chan, 1); |
57 | |||
58 | return ret; | ||
52 | } | 59 | } |
53 | 60 | ||
54 | /** | 61 | /** |
55 | * 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. |
56 | * 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. |
57 | */ | 64 | */ |
58 | void 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, const unsigned char receiver[6], |
59 | const unsigned char transmitter[6], uint8_t channel) { | 66 | const unsigned char transmitter[6], uint8_t channel) { |
60 | memset(assoc_resp, 0, sizeof(struct libwifi_assoc_resp)); | 67 | memset(assoc_resp, 0, sizeof(struct libwifi_assoc_resp)); |
61 | 68 | ||
@@ -71,7 +78,9 @@ void libwifi_create_assoc_resp(struct libwifi_assoc_resp *assoc_resp, const unsi | |||
71 | libwifi_set_assoc_resp_channel(assoc_resp, channel); | 78 | libwifi_set_assoc_resp_channel(assoc_resp, channel); |
72 | 79 | ||
73 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; | 80 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; |
74 | libwifi_quick_add_tag(&assoc_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); | 81 | int ret = libwifi_quick_add_tag(&assoc_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); |
82 | |||
83 | return ret; | ||
75 | } | 84 | } |
76 | 85 | ||
77 | /** | 86 | /** |
diff --git a/src/libwifi/gen/management/assoc_response.h b/src/libwifi/gen/management/assoc_response.h index 9162d1c..07ad4b4 100644 --- a/src/libwifi/gen/management/assoc_response.h +++ b/src/libwifi/gen/management/assoc_response.h | |||
@@ -24,7 +24,7 @@ | |||
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 | */ | 26 | */ |
27 | void libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_t channel); | 27 | int libwifi_set_assoc_resp_channel(struct libwifi_assoc_resp *assoc_resp, uint8_t channel); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Calculate the length of a given libwifi_assoc_resp | 30 | * Calculate the length of a given libwifi_assoc_resp |
@@ -46,7 +46,7 @@ size_t libwifi_get_assoc_resp_length(struct libwifi_assoc_resp *assoc_resp); | |||
46 | * @param channel The desired channel of the assoc_resp | 46 | * @param channel The desired channel of the assoc_resp |
47 | * | 47 | * |
48 | */ | 48 | */ |
49 | void libwifi_create_assoc_resp(struct libwifi_assoc_resp *assoc_resp, const unsigned char receiver[6], | 49 | int libwifi_create_assoc_resp(struct libwifi_assoc_resp *assoc_resp, const unsigned char receiver[6], |
50 | const unsigned char transmitter[6], uint8_t channel); | 50 | const unsigned char transmitter[6], uint8_t channel); |
51 | 51 | ||
52 | /** | 52 | /** |
diff --git a/src/libwifi/gen/management/authentication.c b/src/libwifi/gen/management/authentication.c index 7fcaa22..e8ffea2 100644 --- a/src/libwifi/gen/management/authentication.c +++ b/src/libwifi/gen/management/authentication.c | |||
@@ -32,7 +32,7 @@ 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 | void libwifi_create_auth(struct libwifi_auth *auth, const unsigned char receiver[6], | 35 | int libwifi_create_auth(struct libwifi_auth *auth, const unsigned char receiver[6], |
36 | const unsigned char transmitter[6], uint16_t algorithm_number, | 36 | const unsigned char transmitter[6], uint16_t algorithm_number, |
37 | uint16_t transaction_sequence, uint16_t status_code) { | 37 | uint16_t transaction_sequence, uint16_t status_code) { |
38 | memset(auth, 0, sizeof(struct libwifi_auth)); | 38 | memset(auth, 0, sizeof(struct libwifi_auth)); |
@@ -47,6 +47,8 @@ void libwifi_create_auth(struct libwifi_auth *auth, const unsigned char receiver | |||
47 | auth->fixed_parameters.algorithm_number = algorithm_number; | 47 | auth->fixed_parameters.algorithm_number = algorithm_number; |
48 | auth->fixed_parameters.transaction_sequence = transaction_sequence; | 48 | auth->fixed_parameters.transaction_sequence = transaction_sequence; |
49 | auth->fixed_parameters.status_code = status_code; | 49 | auth->fixed_parameters.status_code = status_code; |
50 | |||
51 | return 0; | ||
50 | } | 52 | } |
51 | 53 | ||
52 | /** | 54 | /** |
diff --git a/src/libwifi/gen/management/authentication.h b/src/libwifi/gen/management/authentication.h index 4328f95..75e8dcf 100644 --- a/src/libwifi/gen/management/authentication.h +++ b/src/libwifi/gen/management/authentication.h | |||
@@ -40,7 +40,7 @@ size_t libwifi_get_auth_length(struct libwifi_auth *auth); | |||
40 | * @param algorithm_number Algorithm type to use | 40 | * @param algorithm_number Algorithm type to use |
41 | * | 41 | * |
42 | */ | 42 | */ |
43 | void libwifi_create_auth(struct libwifi_auth *auth, const unsigned char receiver[6], | 43 | int libwifi_create_auth(struct libwifi_auth *auth, const unsigned char receiver[6], |
44 | const unsigned char transmitter[6], uint16_t algorithm_number, | 44 | const unsigned char transmitter[6], uint16_t algorithm_number, |
45 | uint16_t transaction_sequence, uint16_t status_code); | 45 | uint16_t transaction_sequence, uint16_t status_code); |
46 | 46 | ||
diff --git a/src/libwifi/gen/management/beacon.c b/src/libwifi/gen/management/beacon.c index 4eb394a..e678fd7 100644 --- a/src/libwifi/gen/management/beacon.c +++ b/src/libwifi/gen/management/beacon.c | |||
@@ -39,32 +39,46 @@ size_t libwifi_get_beacon_length(struct libwifi_beacon *beacon) { | |||
39 | /** | 39 | /** |
40 | * Simple helper to set the beacon SSID tag by removing it and then adding it back with the new value. | 40 | * Simple helper to set the beacon SSID tag by removing it and then adding it back with the new value. |
41 | */ | 41 | */ |
42 | void libwifi_set_beacon_ssid(struct libwifi_beacon *beacon, const char *ssid) { | 42 | int libwifi_set_beacon_ssid(struct libwifi_beacon *beacon, const char *ssid) { |
43 | int ret = 0; | ||
44 | |||
43 | if (beacon->tags.length != 0) { | 45 | if (beacon->tags.length != 0) { |
44 | libwifi_remove_tag(&beacon->tags, TAG_SSID); | 46 | ret = libwifi_remove_tag(&beacon->tags, TAG_SSID); |
47 | if (ret != 0) { | ||
48 | return ret; | ||
49 | } | ||
45 | } | 50 | } |
46 | 51 | ||
47 | libwifi_quick_add_tag(&beacon->tags, TAG_SSID, (void *) ssid, strlen(ssid)); | 52 | ret = libwifi_quick_add_tag(&beacon->tags, TAG_SSID, (void *) ssid, strlen(ssid)); |
53 | |||
54 | return ret; | ||
48 | } | 55 | } |
49 | 56 | ||
50 | /** | 57 | /** |
51 | * Simple helper to set the beacon DS tag by removing it and then adding it back with the new value. | 58 | * Simple helper to set the beacon DS tag by removing it and then adding it back with the new value. |
52 | */ | 59 | */ |
53 | void libwifi_set_beacon_channel(struct libwifi_beacon *beacon, uint8_t channel) { | 60 | int libwifi_set_beacon_channel(struct libwifi_beacon *beacon, uint8_t channel) { |
61 | int ret = 0; | ||
62 | |||
54 | if (beacon->tags.length != 0) { | 63 | if (beacon->tags.length != 0) { |
55 | libwifi_remove_tag(&beacon->tags, TAG_DS_PARAMETER); | 64 | ret = libwifi_remove_tag(&beacon->tags, TAG_DS_PARAMETER); |
65 | if (ret != 0) { | ||
66 | return ret; | ||
67 | } | ||
56 | } | 68 | } |
57 | 69 | ||
58 | const unsigned char *chan = (const unsigned char *) &channel; | 70 | const unsigned char *chan = (const unsigned char *) &channel; |
59 | 71 | ||
60 | libwifi_quick_add_tag(&beacon->tags, TAG_DS_PARAMETER, chan, 1); | 72 | ret = libwifi_quick_add_tag(&beacon->tags, TAG_DS_PARAMETER, chan, 1); |
73 | |||
74 | return ret; | ||
61 | } | 75 | } |
62 | 76 | ||
63 | /** | 77 | /** |
64 | * 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. |
65 | * Three tagged parameters are also added to the beacon: SSID, Channel and Supported Rates. | 79 | * Three tagged parameters are also added to the beacon: SSID, Channel and Supported Rates. |
66 | */ | 80 | */ |
67 | void libwifi_create_beacon(struct libwifi_beacon *beacon, const unsigned char receiver[6], | 81 | int libwifi_create_beacon(struct libwifi_beacon *beacon, const unsigned char receiver[6], |
68 | const unsigned char transmitter[6], const char *ssid, uint8_t channel) { | 82 | const unsigned char transmitter[6], const char *ssid, uint8_t channel) { |
69 | memset(beacon, 0, sizeof(struct libwifi_beacon)); | 83 | memset(beacon, 0, sizeof(struct libwifi_beacon)); |
70 | 84 | ||
@@ -82,7 +96,9 @@ void libwifi_create_beacon(struct libwifi_beacon *beacon, const unsigned char re | |||
82 | libwifi_set_beacon_channel(beacon, channel); | 96 | libwifi_set_beacon_channel(beacon, channel); |
83 | 97 | ||
84 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; | 98 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; |
85 | libwifi_quick_add_tag(&beacon->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); | 99 | int ret = libwifi_quick_add_tag(&beacon->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); |
100 | |||
101 | return ret; | ||
86 | } | 102 | } |
87 | 103 | ||
88 | /** | 104 | /** |
diff --git a/src/libwifi/gen/management/beacon.h b/src/libwifi/gen/management/beacon.h index 3da342b..971df88 100644 --- a/src/libwifi/gen/management/beacon.h +++ b/src/libwifi/gen/management/beacon.h | |||
@@ -24,7 +24,7 @@ | |||
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 | */ | 26 | */ |
27 | void libwifi_set_beacon_ssid(struct libwifi_beacon *beacon, const char *ssid); | 27 | int libwifi_set_beacon_ssid(struct libwifi_beacon *beacon, const char *ssid); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Set the channel of a struct libwifi_beacon. | 30 | * Set the channel of a struct libwifi_beacon. |
@@ -32,7 +32,7 @@ void libwifi_set_beacon_ssid(struct libwifi_beacon *beacon, const char *ssid); | |||
32 | * @param beacon A struct libwifi_beacon | 32 | * @param beacon A struct libwifi_beacon |
33 | * @param channel The new channel | 33 | * @param channel The new channel |
34 | */ | 34 | */ |
35 | void libwifi_set_beacon_channel(struct libwifi_beacon *beacon, uint8_t channel); | 35 | int libwifi_set_beacon_channel(struct libwifi_beacon *beacon, uint8_t channel); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Calculate the length of a given struct libwifi_beacon | 38 | * Calculate the length of a given struct libwifi_beacon |
@@ -55,7 +55,7 @@ size_t libwifi_get_beacon_length(struct libwifi_beacon *beacon); | |||
55 | * @param channel The desired channel of the beacon | 55 | * @param channel The desired channel of the beacon |
56 | * | 56 | * |
57 | */ | 57 | */ |
58 | void libwifi_create_beacon(struct libwifi_beacon *beacon, const unsigned char receiver[6], | 58 | int libwifi_create_beacon(struct libwifi_beacon *beacon, const unsigned char receiver[6], |
59 | const unsigned char transmitter[6], const char *ssid, uint8_t channel); | 59 | const unsigned char transmitter[6], const char *ssid, uint8_t channel); |
60 | 60 | ||
61 | /** | 61 | /** |
diff --git a/src/libwifi/gen/management/disassociation.c b/src/libwifi/gen/management/disassociation.c index a885efd..d6cf237 100644 --- a/src/libwifi/gen/management/disassociation.c +++ b/src/libwifi/gen/management/disassociation.c | |||
@@ -33,7 +33,7 @@ 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 | void libwifi_create_disassoc(struct libwifi_disassoc *disassoc, const unsigned char receiver[6], | 36 | int libwifi_create_disassoc(struct libwifi_disassoc *disassoc, const unsigned char receiver[6], |
37 | const unsigned char transmitter[6], uint16_t reason_code) { | 37 | const unsigned char transmitter[6], uint16_t reason_code) { |
38 | memset(disassoc, 0, sizeof(struct libwifi_disassoc)); | 38 | memset(disassoc, 0, sizeof(struct libwifi_disassoc)); |
39 | 39 | ||
@@ -46,6 +46,8 @@ void libwifi_create_disassoc(struct libwifi_disassoc *disassoc, const unsigned c | |||
46 | disassoc->frame_header.seq_control.sequence_number = (rand() % 4096); | 46 | disassoc->frame_header.seq_control.sequence_number = (rand() % 4096); |
47 | 47 | ||
48 | memcpy(&disassoc->fixed_parameters.reason_code, &reason_code, sizeof(reason_code)); | 48 | memcpy(&disassoc->fixed_parameters.reason_code, &reason_code, sizeof(reason_code)); |
49 | |||
50 | return 0; | ||
49 | } | 51 | } |
50 | 52 | ||
51 | /** | 53 | /** |
diff --git a/src/libwifi/gen/management/disassociation.h b/src/libwifi/gen/management/disassociation.h index fada9f0..10f1db9 100644 --- a/src/libwifi/gen/management/disassociation.h +++ b/src/libwifi/gen/management/disassociation.h | |||
@@ -40,7 +40,7 @@ size_t libwifi_get_disassoc_length(struct libwifi_disassoc *disassoc); | |||
40 | * @param reason_code The disassoc reason code | 40 | * @param reason_code The disassoc reason code |
41 | * | 41 | * |
42 | */ | 42 | */ |
43 | void libwifi_create_disassoc(struct libwifi_disassoc *disassoc, const unsigned char receiver[6], | 43 | int libwifi_create_disassoc(struct libwifi_disassoc *disassoc, const unsigned char receiver[6], |
44 | const unsigned char transmitter[6], uint16_t reason_code); | 44 | const unsigned char transmitter[6], uint16_t reason_code); |
45 | 45 | ||
46 | /** | 46 | /** |
diff --git a/src/libwifi/gen/management/probe_request.c b/src/libwifi/gen/management/probe_request.c index 7c5b99e..95cdcdb 100644 --- a/src/libwifi/gen/management/probe_request.c +++ b/src/libwifi/gen/management/probe_request.c | |||
@@ -31,7 +31,7 @@ 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 | void 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, const unsigned char receiver[6], |
35 | const unsigned char transmitter[6], const unsigned char bssid[6], | 35 | const unsigned char transmitter[6], const unsigned char bssid[6], |
36 | const char *ssid, uint8_t channel) { | 36 | const char *ssid, uint8_t channel) { |
37 | memset(probe_req, 0, sizeof(struct libwifi_probe_req)); | 37 | memset(probe_req, 0, sizeof(struct libwifi_probe_req)); |
@@ -43,8 +43,13 @@ void libwifi_create_probe_req(struct libwifi_probe_req *probe_req, const unsigne | |||
43 | memcpy(&probe_req->frame_header.addr3, bssid, 6); | 43 | memcpy(&probe_req->frame_header.addr3, bssid, 6); |
44 | probe_req->frame_header.seq_control.sequence_number = (rand() % 4096); | 44 | probe_req->frame_header.seq_control.sequence_number = (rand() % 4096); |
45 | 45 | ||
46 | libwifi_quick_add_tag(&probe_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); | 46 | int ret = libwifi_quick_add_tag(&probe_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); |
47 | libwifi_quick_add_tag(&probe_req->tags, TAG_DS_PARAMETER, (const unsigned char *) &channel, 1); | 47 | if (ret != 0) { |
48 | return ret; | ||
49 | } | ||
50 | |||
51 | ret = libwifi_quick_add_tag(&probe_req->tags, TAG_DS_PARAMETER, (const unsigned char *) &channel, 1); | ||
52 | return ret; | ||
48 | } | 53 | } |
49 | 54 | ||
50 | /** | 55 | /** |
diff --git a/src/libwifi/gen/management/probe_request.h b/src/libwifi/gen/management/probe_request.h index f98b70a..c71897b 100644 --- a/src/libwifi/gen/management/probe_request.h +++ b/src/libwifi/gen/management/probe_request.h | |||
@@ -40,7 +40,7 @@ size_t libwifi_get_probe_req_length(struct libwifi_probe_req *probe_req); | |||
40 | * @param reason_code The probe_req reason code | 40 | * @param reason_code The probe_req reason code |
41 | * | 41 | * |
42 | */ | 42 | */ |
43 | void libwifi_create_probe_req(struct libwifi_probe_req *probe_req, const unsigned char receiver[6], | 43 | int libwifi_create_probe_req(struct libwifi_probe_req *probe_req, const unsigned char receiver[6], |
44 | const unsigned char transmitter[6], const unsigned char bssid[6], | 44 | const unsigned char transmitter[6], const unsigned char bssid[6], |
45 | const char *ssid, uint8_t channel); | 45 | const char *ssid, uint8_t channel); |
46 | 46 | ||
diff --git a/src/libwifi/gen/management/probe_response.c b/src/libwifi/gen/management/probe_response.c index 403a8bc..1528313 100644 --- a/src/libwifi/gen/management/probe_response.c +++ b/src/libwifi/gen/management/probe_response.c | |||
@@ -39,32 +39,46 @@ size_t libwifi_get_probe_resp_length(struct libwifi_probe_resp *probe_resp) { | |||
39 | /** | 39 | /** |
40 | * Simple helper to set the probe response SSID tag by removing it and then adding it back with the new value. | 40 | * Simple helper to set the probe response SSID tag by removing it and then adding it back with the new value. |
41 | */ | 41 | */ |
42 | void libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const char *ssid) { | 42 | int libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const char *ssid) { |
43 | int ret = 0; | ||
44 | |||
43 | if (probe_resp->tags.length != 0) { | 45 | if (probe_resp->tags.length != 0) { |
44 | libwifi_remove_tag(&probe_resp->tags, TAG_SSID); | 46 | ret = libwifi_remove_tag(&probe_resp->tags, TAG_SSID); |
47 | if (ret != 0) { | ||
48 | return ret; | ||
49 | } | ||
45 | } | 50 | } |
46 | 51 | ||
47 | libwifi_quick_add_tag(&probe_resp->tags, TAG_SSID, (void *) ssid, strlen(ssid)); | 52 | ret = libwifi_quick_add_tag(&probe_resp->tags, TAG_SSID, (void *) ssid, strlen(ssid)); |
53 | |||
54 | return ret; | ||
48 | } | 55 | } |
49 | 56 | ||
50 | /** | 57 | /** |
51 | * Simple helper to set the probe response DS tag by removing it and then adding it back with the new value. | 58 | * Simple helper to set the probe response DS tag by removing it and then adding it back with the new value. |
52 | */ | 59 | */ |
53 | void libwifi_set_probe_resp_channel(struct libwifi_probe_resp *probe_resp, uint8_t channel) { | 60 | int libwifi_set_probe_resp_channel(struct libwifi_probe_resp *probe_resp, uint8_t channel) { |
61 | int ret = 0; | ||
62 | |||
54 | if (probe_resp->tags.length != 0) { | 63 | if (probe_resp->tags.length != 0) { |
55 | libwifi_remove_tag(&probe_resp->tags, TAG_DS_PARAMETER); | 64 | ret = libwifi_remove_tag(&probe_resp->tags, TAG_DS_PARAMETER); |
65 | if (ret != 0) { | ||
66 | return ret; | ||
67 | } | ||
56 | } | 68 | } |
57 | 69 | ||
58 | const unsigned char *chan = (const unsigned char *) &channel; | 70 | const unsigned char *chan = (const unsigned char *) &channel; |
59 | 71 | ||
60 | libwifi_quick_add_tag(&probe_resp->tags, TAG_DS_PARAMETER, chan, 1); | 72 | ret = libwifi_quick_add_tag(&probe_resp->tags, TAG_DS_PARAMETER, chan, 1); |
73 | |||
74 | return ret; | ||
61 | } | 75 | } |
62 | 76 | ||
63 | /** | 77 | /** |
64 | * 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. |
65 | * Three tagged parameters are also added to the probe response: SSID, Channel and Supported Rates. | 79 | * Three tagged parameters are also added to the probe response: SSID, Channel and Supported Rates. |
66 | */ | 80 | */ |
67 | void 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, const unsigned char receiver[6], |
68 | const unsigned char transmitter[6], const char *ssid, uint8_t channel) { | 82 | const unsigned char transmitter[6], const char *ssid, uint8_t channel) { |
69 | memset(probe_resp, 0, sizeof(struct libwifi_probe_resp)); | 83 | memset(probe_resp, 0, sizeof(struct libwifi_probe_resp)); |
70 | 84 | ||
@@ -79,11 +93,20 @@ void libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, const unsi | |||
79 | probe_resp->fixed_parameters.probe_resp_interval = BYTESWAP16(probe_resp_interval); | 93 | probe_resp->fixed_parameters.probe_resp_interval = BYTESWAP16(probe_resp_interval); |
80 | probe_resp->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); | 94 | probe_resp->fixed_parameters.capabilities_information = BYTESWAP16(LIBWIFI_DEFAULT_AP_CAPABS); |
81 | 95 | ||
82 | libwifi_set_probe_resp_ssid(probe_resp, ssid); | 96 | int ret = libwifi_set_probe_resp_ssid(probe_resp, ssid); |
83 | libwifi_set_probe_resp_channel(probe_resp, channel); | 97 | if (ret != 0) { |
98 | return ret; | ||
99 | } | ||
100 | |||
101 | ret = libwifi_set_probe_resp_channel(probe_resp, channel); | ||
102 | if (ret != 0) { | ||
103 | return ret; | ||
104 | } | ||
84 | 105 | ||
85 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; | 106 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; |
86 | libwifi_quick_add_tag(&probe_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); | 107 | ret = libwifi_quick_add_tag(&probe_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); |
108 | |||
109 | return ret; | ||
87 | } | 110 | } |
88 | 111 | ||
89 | /** | 112 | /** |
diff --git a/src/libwifi/gen/management/probe_response.h b/src/libwifi/gen/management/probe_response.h index 56243ee..80f5451 100644 --- a/src/libwifi/gen/management/probe_response.h +++ b/src/libwifi/gen/management/probe_response.h | |||
@@ -24,7 +24,7 @@ | |||
24 | * @param probe_resp A libwifi_probe_resp | 24 | * @param probe_resp A libwifi_probe_resp |
25 | * @param ssid The new SSID | 25 | * @param ssid The new SSID |
26 | */ | 26 | */ |
27 | void libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const char *ssid); | 27 | int libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const char *ssid); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Set the channel of a libwifi_probe_resp. | 30 | * Set the channel of a libwifi_probe_resp. |
@@ -32,7 +32,7 @@ void libwifi_set_probe_resp_ssid(struct libwifi_probe_resp *probe_resp, const ch | |||
32 | * @param probe_resp A libwifi_probe_resp | 32 | * @param probe_resp A libwifi_probe_resp |
33 | * @param channel The new channel | 33 | * @param channel The new channel |
34 | */ | 34 | */ |
35 | void libwifi_set_probe_resp_channel(struct libwifi_probe_resp *probe_resp, uint8_t channel); | 35 | int libwifi_set_probe_resp_channel(struct libwifi_probe_resp *probe_resp, uint8_t channel); |
36 | 36 | ||
37 | /** | 37 | /** |
38 | * Calculate the length of a given libwifi_probe_resp | 38 | * Calculate the length of a given libwifi_probe_resp |
@@ -55,7 +55,7 @@ size_t libwifi_get_probe_resp_length(struct libwifi_probe_resp *probe_resp); | |||
55 | * @param channel The desired channel of the probe_resp | 55 | * @param channel The desired channel of the probe_resp |
56 | * | 56 | * |
57 | */ | 57 | */ |
58 | void libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, const unsigned char receiver[6], | 58 | int libwifi_create_probe_resp(struct libwifi_probe_resp *probe_resp, const unsigned char receiver[6], |
59 | const unsigned char transmitter[6], const char *ssid, uint8_t channel); | 59 | const unsigned char transmitter[6], const char *ssid, uint8_t channel); |
60 | 60 | ||
61 | /** | 61 | /** |
diff --git a/src/libwifi/gen/management/reassoc_request.c b/src/libwifi/gen/management/reassoc_request.c index f678caf..9e9bcd8 100644 --- a/src/libwifi/gen/management/reassoc_request.c +++ b/src/libwifi/gen/management/reassoc_request.c | |||
@@ -49,10 +49,14 @@ int libwifi_create_reassoc_req(struct libwifi_reassoc_req *reassoc_req, const un | |||
49 | reassoc_req->fixed_parameters.listen_interval = BYTESWAP16(LIBWIFI_DEFAULT_LISTEN_INTERVAL); | 49 | reassoc_req->fixed_parameters.listen_interval = BYTESWAP16(LIBWIFI_DEFAULT_LISTEN_INTERVAL); |
50 | memcpy(&reassoc_req->fixed_parameters.current_ap_address, current_ap, 6); | 50 | memcpy(&reassoc_req->fixed_parameters.current_ap_address, current_ap, 6); |
51 | 51 | ||
52 | libwifi_quick_add_tag(&reassoc_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); | 52 | int ret = libwifi_quick_add_tag(&reassoc_req->tags, TAG_SSID, (const unsigned char *) ssid, strlen(ssid)); |
53 | libwifi_quick_add_tag(&reassoc_req->tags, TAG_DS_PARAMETER, (const unsigned char *) &channel, 1); | 53 | if (ret != 0) { |
54 | return ret; | ||
55 | } | ||
56 | |||
57 | ret = libwifi_quick_add_tag(&reassoc_req->tags, TAG_DS_PARAMETER, (const unsigned char *) &channel, 1); | ||
54 | 58 | ||
55 | return 0; | 59 | return ret; |
56 | } | 60 | } |
57 | 61 | ||
58 | /** | 62 | /** |
diff --git a/src/libwifi/gen/management/reassoc_response.c b/src/libwifi/gen/management/reassoc_response.c index b9acbb6..3279f52 100644 --- a/src/libwifi/gen/management/reassoc_response.c +++ b/src/libwifi/gen/management/reassoc_response.c | |||
@@ -41,21 +41,27 @@ size_t libwifi_get_reassoc_resp_length(struct libwifi_reassoc_resp *reassoc_resp | |||
41 | * Simple helper to set the reassociation response DS tag by removing it and then adding it back with the new | 41 | * Simple helper to set the reassociation response DS tag by removing it and then adding it back with the new |
42 | * value. | 42 | * value. |
43 | */ | 43 | */ |
44 | void libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, uint8_t channel) { | 44 | int libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, uint8_t channel) { |
45 | int ret = 0; | ||
46 | |||
45 | if (reassoc_resp->tags.length != 0) { | 47 | if (reassoc_resp->tags.length != 0) { |
46 | libwifi_remove_tag(&reassoc_resp->tags, TAG_DS_PARAMETER); | 48 | ret = libwifi_remove_tag(&reassoc_resp->tags, TAG_DS_PARAMETER); |
49 | if (ret != 0) { | ||
50 | return ret; | ||
51 | } | ||
47 | } | 52 | } |
48 | 53 | ||
49 | const unsigned char *chan = (const unsigned char *) &channel; | 54 | const unsigned char *chan = (const unsigned char *) &channel; |
55 | ret = libwifi_quick_add_tag(&reassoc_resp->tags, TAG_DS_PARAMETER, chan, 1); | ||
50 | 56 | ||
51 | libwifi_quick_add_tag(&reassoc_resp->tags, TAG_DS_PARAMETER, chan, 1); | 57 | return ret; |
52 | } | 58 | } |
53 | 59 | ||
54 | /** | 60 | /** |
55 | * 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. |
56 | * Three tagged parameters are also added to the reassoc_resp: SSID, Channel and Supported Rates. | 62 | * Three tagged parameters are also added to the reassoc_resp: SSID, Channel and Supported Rates. |
57 | */ | 63 | */ |
58 | void 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, const unsigned char receiver[6], |
59 | const unsigned char transmitter[6], uint8_t channel) { | 65 | const unsigned char transmitter[6], uint8_t channel) { |
60 | memset(reassoc_resp, 0, sizeof(struct libwifi_reassoc_resp)); | 66 | memset(reassoc_resp, 0, sizeof(struct libwifi_reassoc_resp)); |
61 | 67 | ||
@@ -68,10 +74,15 @@ void libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, cons | |||
68 | reassoc_resp->fixed_parameters.status_code = STATUS_SUCCESS; | 74 | reassoc_resp->fixed_parameters.status_code = STATUS_SUCCESS; |
69 | reassoc_resp->fixed_parameters.association_id = rand() % 4096; | 75 | reassoc_resp->fixed_parameters.association_id = rand() % 4096; |
70 | 76 | ||
71 | libwifi_set_reassoc_resp_channel(reassoc_resp, channel); | 77 | int ret = libwifi_set_reassoc_resp_channel(reassoc_resp, channel); |
78 | if (ret != 0) { | ||
79 | return ret; | ||
80 | } | ||
72 | 81 | ||
73 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; | 82 | const unsigned char supported_rates[] = LIBWIFI_DEFAULT_SUPP_RATES; |
74 | libwifi_quick_add_tag(&reassoc_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); | 83 | ret = libwifi_quick_add_tag(&reassoc_resp->tags, TAG_SUPP_RATES, supported_rates, sizeof(supported_rates) - 1); |
84 | |||
85 | return ret; | ||
75 | } | 86 | } |
76 | 87 | ||
77 | /** | 88 | /** |
diff --git a/src/libwifi/gen/management/reassoc_response.h b/src/libwifi/gen/management/reassoc_response.h index f0a2da2..420ed66 100644 --- a/src/libwifi/gen/management/reassoc_response.h +++ b/src/libwifi/gen/management/reassoc_response.h | |||
@@ -24,7 +24,7 @@ | |||
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 new channel |
26 | */ | 26 | */ |
27 | void libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, uint8_t channel); | 27 | int libwifi_set_reassoc_resp_channel(struct libwifi_reassoc_resp *reassoc_resp, uint8_t channel); |
28 | 28 | ||
29 | /** | 29 | /** |
30 | * Calculate the length of a given libwifi_reassoc_resp | 30 | * Calculate the length of a given libwifi_reassoc_resp |
@@ -46,7 +46,7 @@ size_t libwifi_get_reassoc_resp_length(struct libwifi_reassoc_resp *reassoc_resp | |||
46 | * @param channel The desired channel of the reassoc_resp | 46 | * @param channel The desired channel of the reassoc_resp |
47 | * | 47 | * |
48 | */ | 48 | */ |
49 | void libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, const unsigned char receiver[6], | 49 | int libwifi_create_reassoc_resp(struct libwifi_reassoc_resp *reassoc_resp, const unsigned char receiver[6], |
50 | const unsigned char transmitter[6], uint8_t channel); | 50 | const unsigned char transmitter[6], uint8_t channel); |
51 | 51 | ||
52 | /** | 52 | /** |
diff --git a/src/libwifi/gen/management/timing_ad.c b/src/libwifi/gen/management/timing_ad.c index 6e67a6b..61b9003 100644 --- a/src/libwifi/gen/management/timing_ad.c +++ b/src/libwifi/gen/management/timing_ad.c | |||
@@ -19,10 +19,11 @@ | |||
19 | #include "../../core/misc/epoch.h" | 19 | #include "../../core/misc/epoch.h" |
20 | #include "../../core/frame/tag.h" | 20 | #include "../../core/frame/tag.h" |
21 | 21 | ||
22 | #include <errno.h> | ||
22 | #include <stdlib.h> | 23 | #include <stdlib.h> |
23 | #include <string.h> | 24 | #include <string.h> |
24 | 25 | ||
25 | void 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, const unsigned char destination[6], |
26 | const unsigned char transmitter[6], struct libwifi_timing_advert_fields *adv_fields, | 27 | const unsigned char transmitter[6], struct libwifi_timing_advert_fields *adv_fields, |
27 | const char country[3], uint16_t max_reg_power, uint8_t max_tx_power, uint8_t tx_power_used, | 28 | const char country[3], uint16_t max_reg_power, uint8_t max_tx_power, uint8_t tx_power_used, |
28 | uint8_t noise_floor) { | 29 | uint8_t noise_floor) { |
@@ -45,7 +46,7 @@ void libwifi_create_timing_advert(struct libwifi_timing_advert *adv, const unsig | |||
45 | adv->fixed_parameters.noise_floor = noise_floor; | 46 | adv->fixed_parameters.noise_floor = noise_floor; |
46 | 47 | ||
47 | if (adv_fields == NULL) { | 48 | if (adv_fields == NULL) { |
48 | return; | 49 | return -EINVAL; |
49 | } | 50 | } |
50 | 51 | ||
51 | // Maximum element size is 17 | 52 | // Maximum element size is 17 |
@@ -78,7 +79,9 @@ void libwifi_create_timing_advert(struct libwifi_timing_advert *adv, const unsig | |||
78 | 79 | ||
79 | element_data_len = offset; | 80 | element_data_len = offset; |
80 | 81 | ||
81 | libwifi_quick_add_tag(&adv->tags, TAG_TIME_ADVERTISEMENT, element_data, element_data_len); | 82 | int ret = libwifi_quick_add_tag(&adv->tags, TAG_TIME_ADVERTISEMENT, element_data, element_data_len); |
83 | |||
84 | return ret; | ||
82 | } | 85 | } |
83 | 86 | ||
84 | size_t libwifi_get_timing_advert_length(struct libwifi_timing_advert *adv) { | 87 | size_t libwifi_get_timing_advert_length(struct libwifi_timing_advert *adv) { |
diff --git a/src/libwifi/gen/management/timing_ad.h b/src/libwifi/gen/management/timing_ad.h index cdcb827..51c7729 100644 --- a/src/libwifi/gen/management/timing_ad.h +++ b/src/libwifi/gen/management/timing_ad.h | |||
@@ -18,7 +18,7 @@ | |||
18 | 18 | ||
19 | #include "../../core/frame/management/timing_ad.h" | 19 | #include "../../core/frame/management/timing_ad.h" |
20 | 20 | ||
21 | void libwifi_create_timing_advert(struct libwifi_timing_advert *adv, const unsigned char destination[6], | 21 | int libwifi_create_timing_advert(struct libwifi_timing_advert *adv, const unsigned char destination[6], |
22 | const unsigned char transmitter[6], struct libwifi_timing_advert_fields *adv_fields, | 22 | const unsigned char transmitter[6], struct libwifi_timing_advert_fields *adv_fields, |
23 | const char country[3], uint16_t max_reg_power, uint8_t max_tx_power, uint8_t tx_power_used, | 23 | const char country[3], uint16_t max_reg_power, uint8_t max_tx_power, uint8_t tx_power_used, |
24 | uint8_t noise_floor); | 24 | uint8_t noise_floor); |