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
40
int
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
45
if
(frame->
frame_control
.
type
!=
TYPE_MANAGEMENT
|| frame->
frame_control
.
subtype
!=
SUBTYPE_DISASSOC
) {
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
,
53
sizeof
(
struct
libwifi_mgmt_ordered_frame_header
));
54
tags_len = (frame->
len
-
sizeof
(
struct
libwifi_mgmt_ordered_frame_header
) -
55
sizeof(struct
libwifi_disassoc_fixed_parameters
));
56
}
else
{
57
memcpy(&disassoc->
frame_header
.
unordered
, &frame->
header
.
mgmt_unordered
,
58
sizeof
(
struct
libwifi_mgmt_unordered_frame_header
));
59
tags_len = (frame->
len
-
sizeof
(
struct
libwifi_mgmt_unordered_frame_header
) -
60
sizeof(struct
libwifi_disassoc_fixed_parameters
));
61
}
62
63
unsigned
char
*
body
= (
unsigned
char
*) frame->
body
;
64
65
memcpy(&disassoc->
fixed_parameters
,
body
,
sizeof
(
struct
libwifi_disassoc_fixed_parameters
));
66
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
@ SUBTYPE_DISASSOC
Definition:
frame.h:47
TYPE_MANAGEMENT
@ TYPE_MANAGEMENT
Definition:
frame.h:31
common.h
libwifi_parse_disassoc
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...
Definition:
disassociation.c:40
disassociation.h
libwifi_disassoc_fixed_parameters
Definition:
disassociation.h:38
libwifi_frame_ctrl_flags::ordered
unsigned int ordered
Definition:
frame.h:115
libwifi_frame_ctrl::type
unsigned int type
Definition:
frame.h:123
libwifi_frame_ctrl::flags
struct libwifi_frame_ctrl_flags flags
Definition:
frame.h:125
libwifi_frame_ctrl::subtype
unsigned int subtype
Definition:
frame.h:124
libwifi_frame
Definition:
frame.h:308
libwifi_frame::header
union libwifi_frame_header header
Definition:
frame.h:312
libwifi_frame::body
unsigned char * body
Definition:
frame.h:314
libwifi_frame::len
size_t len
Definition:
frame.h:311
libwifi_frame::frame_control
struct libwifi_frame_ctrl frame_control
Definition:
frame.h:310
libwifi_mgmt_ordered_frame_header
Definition:
frame.h:180
libwifi_mgmt_unordered_frame_header
Definition:
frame.h:207
libwifi_parsed_disassoc
Definition:
disassociation.h:48
libwifi_parsed_disassoc::fixed_parameters
struct libwifi_disassoc_fixed_parameters fixed_parameters
Definition:
disassociation.h:51
libwifi_parsed_disassoc::tags
struct libwifi_tagged_parameters tags
Definition:
disassociation.h:52
libwifi_parsed_disassoc::frame_header
union libwifi_mgmt_frame_header frame_header
Definition:
disassociation.h:50
libwifi_parsed_disassoc::ordered
int ordered
Definition:
disassociation.h:49
body
unsigned char * body
Definition:
tag.h:1
libwifi_frame_header::mgmt_unordered
struct libwifi_mgmt_unordered_frame_header mgmt_unordered
Definition:
frame.h:290
libwifi_frame_header::mgmt_ordered
struct libwifi_mgmt_ordered_frame_header mgmt_ordered
Definition:
frame.h:289
libwifi_mgmt_frame_header::ordered
struct libwifi_mgmt_ordered_frame_header ordered
Definition:
frame.h:300
libwifi_mgmt_frame_header::unordered
struct libwifi_mgmt_unordered_frame_header unordered
Definition:
frame.h:301
libwifi
parse
management
disassociation.c
Generated by
1.9.3