diff options
| author | Marc <foxtrot@malloc.me> | 2022-01-09 15:21:47 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-09 15:21:47 +0000 |
| commit | 0bd924735125b34b74c893936b89cfae02e3379d (patch) | |
| tree | c8140bf65c24791874fa9b0e194773178a34da83 /src/libwifi/gen/management/assoc_response.c | |
| parent | 8e09d29df19312583747a3de00fe4269c17e6586 (diff) | |
| parent | 11c7393bebe4df6e2061f69787f4a7dd5c31f077 (diff) | |
| download | libwifi-0bd924735125b34b74c893936b89cfae02e3379d.tar.gz libwifi-0bd924735125b34b74c893936b89cfae02e3379d.tar.bz2 libwifi-0bd924735125b34b74c893936b89cfae02e3379d.zip | |
Merge pull request #3 from libwifi/test
test: Add ctests for parse and generate functions.
Diffstat (limited to 'src/libwifi/gen/management/assoc_response.c')
| -rw-r--r-- | src/libwifi/gen/management/assoc_response.c | 19 |
1 files changed, 14 insertions, 5 deletions
| 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 | /** |
