|
1 /* |
|
2 * Copyright (c) 2005-2009 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 parsing 802.11k Beacon Report Frame Body IEs. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "genscaninfo.h" |
|
20 #include "core_frame_rm_ie_beacon_report_frame_body_ie.h" |
|
21 #include "core_tools.h" |
|
22 #include "core_tools_parser.h" |
|
23 #include "am_debug.h" |
|
24 |
|
25 // ======== MEMBER FUNCTIONS ======== |
|
26 |
|
27 const u8_t CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_MAX_LENGTH = 224; |
|
28 const u8_t CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_HEADER_LENGTH = 2; |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 core_frame_rm_ie_beacon_report_frame_body_ie_c* core_frame_rm_ie_beacon_report_frame_body_ie_c::instance( |
|
34 core_ap_data_c& ap_data ) |
|
35 { |
|
36 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::instance()" ); |
|
37 |
|
38 u8_t reported_frame_body[CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_MAX_LENGTH] = { 0 }; |
|
39 u16_t reported_frame_body_length = ( 0 ); |
|
40 ap_data.get_reported_frame_body( &reported_frame_body_length, reported_frame_body ); |
|
41 |
|
42 u8_t* buffer = new u8_t[reported_frame_body_length + CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_HEADER_LENGTH]; |
|
43 if ( !buffer ) |
|
44 { |
|
45 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::instance() - unable create the internal buffer" ); |
|
46 return NULL; |
|
47 } |
|
48 |
|
49 core_frame_rm_ie_beacon_report_frame_body_ie_c* instance = |
|
50 new core_frame_rm_ie_beacon_report_frame_body_ie_c( 0, buffer, reported_frame_body_length + CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_HEADER_LENGTH ); |
|
51 if ( !instance ) |
|
52 { |
|
53 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::instance() - unable to create an instance" ); |
|
54 delete[] buffer; |
|
55 |
|
56 return NULL; |
|
57 } |
|
58 |
|
59 instance->generate( |
|
60 ap_data ); |
|
61 |
|
62 return instance; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 core_frame_rm_ie_beacon_report_frame_body_ie_c* core_frame_rm_ie_beacon_report_frame_body_ie_c::instance( |
|
69 core_ap_data_c& ap_data, |
|
70 u8_t* ie_id_list, |
|
71 u8_t ie_id_list_length ) |
|
72 { |
|
73 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::instance()" ); |
|
74 |
|
75 u8_t reported_frame_body[CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_MAX_LENGTH] = { 0 }; |
|
76 u16_t reported_frame_body_length = ( 0 ); |
|
77 |
|
78 ap_data.request_ie( &reported_frame_body_length, reported_frame_body, ie_id_list, ie_id_list_length ); |
|
79 |
|
80 u8_t* buffer = new u8_t[reported_frame_body_length + CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_HEADER_LENGTH]; |
|
81 if ( !buffer ) |
|
82 { |
|
83 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::instance() - unable create the internal buffer" ); |
|
84 return NULL; |
|
85 } |
|
86 |
|
87 core_frame_rm_ie_beacon_report_frame_body_ie_c* instance = |
|
88 new core_frame_rm_ie_beacon_report_frame_body_ie_c( 0, buffer, reported_frame_body_length + CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_HEADER_LENGTH ); |
|
89 if ( !instance ) |
|
90 { |
|
91 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::instance() - unable to create an instance" ); |
|
92 delete[] buffer; |
|
93 |
|
94 return NULL; |
|
95 } |
|
96 |
|
97 instance->generate( |
|
98 ap_data, |
|
99 ie_id_list, |
|
100 ie_id_list_length ); |
|
101 |
|
102 return instance; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------------------------- |
|
106 // --------------------------------------------------------------------------- |
|
107 // |
|
108 void core_frame_rm_ie_beacon_report_frame_body_ie_c::generate( |
|
109 core_ap_data_c& ap_data ) |
|
110 { |
|
111 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::generate()" ); |
|
112 |
|
113 ASSERT( !data_length_m ); |
|
114 ASSERT( max_data_length_m ); |
|
115 |
|
116 core_frame_dot11_ie_c::generate( core_frame_dot11_ie_c::core_frame_dot11_ie_element_id_supported_rates ); |
|
117 |
|
118 // Reported Frame Body |
|
119 u8_t reported_frame_body[CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_MAX_LENGTH] = { 0 }; |
|
120 u16_t reported_frame_body_length = ( 0 ); |
|
121 ap_data.get_reported_frame_body( &reported_frame_body_length, reported_frame_body ); |
|
122 DEBUG1( "core_frame_rm_ie_beacon_report_frame_body_ie_c::generate() - Reported Frame Body Length: 0x%04X", reported_frame_body_length ); |
|
123 core_tools_c::copy( |
|
124 &data_m[data_length_m], |
|
125 reinterpret_cast<const u8_t*>( &reported_frame_body[0] ), |
|
126 reported_frame_body_length ); |
|
127 data_length_m += reported_frame_body_length; |
|
128 |
|
129 set_length( data_length_m ); |
|
130 |
|
131 // check generated data length doesn't exceed allocated buffer |
|
132 ASSERT( data_length_m <= max_data_length_m ); |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 void core_frame_rm_ie_beacon_report_frame_body_ie_c::generate( |
|
139 core_ap_data_c& ap_data, |
|
140 u8_t* ie_id_list, |
|
141 u8_t ie_id_list_length ) |
|
142 { |
|
143 DEBUG( "core_frame_rm_ie_beacon_report_frame_body_ie_c::generate()" ); |
|
144 |
|
145 ASSERT( !data_length_m ); |
|
146 ASSERT( max_data_length_m ); |
|
147 |
|
148 core_frame_dot11_ie_c::generate( core_frame_dot11_ie_c::core_frame_dot11_ie_element_id_supported_rates ); |
|
149 |
|
150 // Reported Frame Body |
|
151 u8_t reported_frame_body[CORE_FRAME_RM_IE_BEACON_REPORT_FRAME_BODY_IE_MAX_LENGTH] = { 0 }; |
|
152 u16_t reported_frame_body_length = ( 0 ); |
|
153 ap_data.request_ie( &reported_frame_body_length, reported_frame_body, ie_id_list, ie_id_list_length ); |
|
154 DEBUG1( "core_frame_rm_ie_beacon_report_frame_body_ie_c::generate() - Reported Frame Body Length: 0x%04X", reported_frame_body_length ); |
|
155 core_tools_c::copy( |
|
156 &data_m[data_length_m], |
|
157 reinterpret_cast<const u8_t*>( &reported_frame_body[0] ), |
|
158 reported_frame_body_length ); |
|
159 data_length_m += reported_frame_body_length; |
|
160 |
|
161 set_length( data_length_m ); |
|
162 |
|
163 // check generated data length doesn't exceed allocated buffer |
|
164 ASSERT( data_length_m <= max_data_length_m ); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------------------------- |
|
168 // --------------------------------------------------------------------------- |
|
169 // |
|
170 core_frame_rm_ie_beacon_report_frame_body_ie_c::~core_frame_rm_ie_beacon_report_frame_body_ie_c() |
|
171 { |
|
172 } |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 core_frame_rm_ie_beacon_report_frame_body_ie_c::core_frame_rm_ie_beacon_report_frame_body_ie_c( |
|
178 u16_t data_length, |
|
179 const u8_t* data, |
|
180 u16_t max_data_length ) : |
|
181 core_frame_dot11_ie_c( data_length, data, max_data_length ), |
|
182 current_ie_m( NULL ), |
|
183 current_ie_max_length_m( 0 ) |
|
184 { |
|
185 } |