|
1 /* |
|
2 * Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for parsing and generating 802.11 action frames in WMM category. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "core_frame_action_wmm.h" |
|
20 #include "core_frame_wmm_ie_tspec.h" |
|
21 #include "core_tools.h" |
|
22 #include "am_debug.h" |
|
23 |
|
24 // ======== MEMBER FUNCTIONS ======== |
|
25 |
|
26 const u16_t CORE_FRAME_ACTION_WMM_MIN_LENGTH = 28; |
|
27 const u16_t CORE_FRAME_ACTION_WMM_LENGTH = 200; |
|
28 const u16_t CORE_FRAME_ACTION_WMM_TYPE_INDEX = 25; |
|
29 const u16_t CORE_FRAME_ACTION_WMM_TOKEN_INDEX = 26; |
|
30 const u16_t CORE_FRAME_ACTION_WMM_STATUS_INDEX = 27; |
|
31 const u16_t CORE_FRAME_ACTION_WMM_IE_INDEX = 4; |
|
32 |
|
33 // --------------------------------------------------------------------------- |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 core_frame_action_wmm_c* core_frame_action_wmm_c::instance( |
|
37 const core_frame_action_c& frame ) |
|
38 { |
|
39 DEBUG( "core_frame_action_wmm_c::instance()" ); |
|
40 |
|
41 if ( frame.data_length() < CORE_FRAME_ACTION_WMM_MIN_LENGTH ) |
|
42 { |
|
43 DEBUG( "core_frame_action_wmm_c::instance() - not a valid 802.11 frame, frame is too short" ); |
|
44 |
|
45 return NULL; |
|
46 } |
|
47 |
|
48 core_frame_action_wmm_c* instance = new core_frame_action_wmm_c( |
|
49 frame.data_length(), |
|
50 frame.data(), |
|
51 0 ); |
|
52 if ( !instance ) |
|
53 { |
|
54 DEBUG( "core_frame_action_wmm_c::instance() - unable to create an instance" ); |
|
55 |
|
56 return NULL; |
|
57 } |
|
58 |
|
59 return instance; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 core_frame_action_wmm_c* core_frame_action_wmm_c::instance( |
|
66 u16_t duration, |
|
67 const core_mac_address_s& destination, |
|
68 const core_mac_address_s& source, |
|
69 const core_mac_address_s& bssid, |
|
70 u16_t sequence_control, |
|
71 u8_t action_type, |
|
72 u8_t dialog_token, |
|
73 u8_t status, |
|
74 const core_frame_wmm_ie_tspec_c* tspec ) |
|
75 { |
|
76 const u8_t max_data_length = CORE_FRAME_ACTION_WMM_LENGTH; |
|
77 |
|
78 u8_t* buffer = new u8_t[max_data_length]; |
|
79 if ( !buffer ) |
|
80 { |
|
81 DEBUG( "core_frame_action_wmm_c::instance() - unable create the internal buffer" ); |
|
82 return NULL; |
|
83 } |
|
84 |
|
85 core_frame_action_wmm_c* instance = |
|
86 new core_frame_action_wmm_c( 0, buffer, max_data_length ); |
|
87 if ( !instance ) |
|
88 { |
|
89 DEBUG( "core_frame_action_wmm_c::instance() - unable to create an instance" ); |
|
90 delete[] buffer; |
|
91 buffer = NULL; |
|
92 |
|
93 return NULL; |
|
94 } |
|
95 |
|
96 instance->generate( |
|
97 duration, |
|
98 destination, |
|
99 source, |
|
100 bssid, |
|
101 sequence_control, |
|
102 action_type, |
|
103 dialog_token, |
|
104 status, |
|
105 tspec ); |
|
106 |
|
107 return instance; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // --------------------------------------------------------------------------- |
|
112 // |
|
113 core_frame_action_wmm_c::~core_frame_action_wmm_c() |
|
114 { |
|
115 DEBUG( "core_frame_action_wmm_c::~core_frame_action_wmm_c()" ); |
|
116 } |
|
117 |
|
118 // --------------------------------------------------------------------------- |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 u8_t core_frame_action_wmm_c::action_type() const |
|
122 { |
|
123 return data_m[CORE_FRAME_ACTION_WMM_TYPE_INDEX]; |
|
124 } |
|
125 |
|
126 // --------------------------------------------------------------------------- |
|
127 // --------------------------------------------------------------------------- |
|
128 // |
|
129 u8_t core_frame_action_wmm_c::dialog_token() const |
|
130 { |
|
131 return data_m[CORE_FRAME_ACTION_WMM_TOKEN_INDEX]; |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 u8_t core_frame_action_wmm_c::status() const |
|
138 { |
|
139 return data_m[CORE_FRAME_ACTION_WMM_STATUS_INDEX]; |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // --------------------------------------------------------------------------- |
|
144 // |
|
145 u16_t core_frame_action_wmm_c::first_ie_offset() const |
|
146 { |
|
147 DEBUG( "core_frame_action_wmm_c::first_ie_offset()" ); |
|
148 |
|
149 return CORE_FRAME_ACTION_WMM_IE_INDEX; |
|
150 } |
|
151 |
|
152 |
|
153 // --------------------------------------------------------------------------- |
|
154 // --------------------------------------------------------------------------- |
|
155 // |
|
156 void core_frame_action_wmm_c::generate( |
|
157 u16_t duration, |
|
158 const core_mac_address_s& destination, |
|
159 const core_mac_address_s& source, |
|
160 const core_mac_address_s& bssid, |
|
161 u16_t sequence_control, |
|
162 u8_t action_type, |
|
163 u8_t dialog_token, |
|
164 u8_t status, |
|
165 const core_frame_wmm_ie_tspec_c* tspec ) |
|
166 { |
|
167 ASSERT( !data_length_m ); |
|
168 ASSERT( max_data_length_m ); |
|
169 |
|
170 core_frame_action_c::generate( |
|
171 duration, |
|
172 destination, |
|
173 source, |
|
174 bssid, |
|
175 sequence_control, |
|
176 core_frame_action_c::core_dot11_action_category_wmm_qos ); |
|
177 |
|
178 // Action Type |
|
179 data_m[data_length_m++] = action_type; |
|
180 |
|
181 // Dialog Token |
|
182 data_m[data_length_m++] = dialog_token; |
|
183 |
|
184 // Status |
|
185 data_m[data_length_m++] = status; |
|
186 |
|
187 // TSPEC |
|
188 core_tools_c::copy( |
|
189 &data_m[data_length_m], |
|
190 tspec->data(), |
|
191 tspec->data_length() ); |
|
192 data_length_m += tspec->data_length(); |
|
193 } |
|
194 |
|
195 // --------------------------------------------------------------------------- |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 core_frame_action_wmm_c::core_frame_action_wmm_c( |
|
199 u16_t data_length, |
|
200 const u8_t* data, |
|
201 u16_t max_data_length ) : |
|
202 core_frame_action_c( data_length, data, max_data_length ) |
|
203 { |
|
204 DEBUG( "core_frame_action_wmm_c::core_frame_action_wmm_c()" ); |
|
205 } |