libwifi 0.0.3
An 802.11 Frame Parsing and Generation library in C
disassociation.c
Go to the documentation of this file.
1/* Copyright 2021 The libwifi Authors
2 *
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16#include "disassociation.h"
17#include "common.h"
18
19#include <errno.h>
20#include <string.h>
21
40int libwifi_parse_disassoc(struct libwifi_parsed_disassoc *disassoc, struct libwifi_frame *frame) {
41 memset(disassoc, 0, sizeof(struct libwifi_parsed_disassoc));
42
43 int tags_len = 0;
44
46 return -EINVAL;
47 }
48
49 disassoc->ordered = frame->frame_control.flags.ordered;
50
51 if (disassoc->ordered) {
52 memcpy(&disassoc->frame_header.ordered, &frame->header.mgmt_ordered,
54 tags_len = (frame->len - sizeof(struct libwifi_mgmt_ordered_frame_header) -
56 } else {
57 memcpy(&disassoc->frame_header.unordered, &frame->header.mgmt_unordered,
59 tags_len = (frame->len - sizeof(struct libwifi_mgmt_unordered_frame_header) -
61 }
62
63 unsigned char *body = (unsigned char *) frame->body;
64
65 memcpy(&disassoc->fixed_parameters, body, sizeof(struct libwifi_disassoc_fixed_parameters));
67
68 memcpy(&disassoc->tags, body, tags_len);
69 body += tags_len;
70
71 return 0;
72}
@ SUBTYPE_DISASSOC
Definition: frame.h:47
@ TYPE_MANAGEMENT
Definition: frame.h:31
int libwifi_parse_disassoc(struct libwifi_parsed_disassoc *disassoc, struct libwifi_frame *frame)
TODO: potentally write a parsed_to_gen function that converts a parsed disassoc back into something t...
unsigned int ordered
Definition: frame.h:115
unsigned int type
Definition: frame.h:123
struct libwifi_frame_ctrl_flags flags
Definition: frame.h:125
unsigned int subtype
Definition: frame.h:124
union libwifi_frame_header header
Definition: frame.h:312
unsigned char * body
Definition: frame.h:314
size_t len
Definition: frame.h:311
struct libwifi_frame_ctrl frame_control
Definition: frame.h:310
struct libwifi_disassoc_fixed_parameters fixed_parameters
struct libwifi_tagged_parameters tags
union libwifi_mgmt_frame_header frame_header
unsigned char * body
Definition: tag.h:1
struct libwifi_mgmt_unordered_frame_header mgmt_unordered
Definition: frame.h:290
struct libwifi_mgmt_ordered_frame_header mgmt_ordered
Definition: frame.h:289
struct libwifi_mgmt_ordered_frame_header ordered
Definition: frame.h:300
struct libwifi_mgmt_unordered_frame_header unordered
Definition: frame.h:301