|
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 IEs. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "genscaninfo.h" |
|
20 #include "core_frame_rm_ie_beacon_report_ie.h" |
|
21 #include "core_frame_rm_ie_beacon_report_frame_body_ie.h" |
|
22 #include "core_tools.h" |
|
23 #include "core_tools_parser.h" |
|
24 #include "am_debug.h" |
|
25 |
|
26 // ======== MEMBER FUNCTIONS ======== |
|
27 |
|
28 const u8_t CORE_FRAME_RM_IE_BEACON_REPORT_IE_MIN_LENGTH = 26; |
|
29 |
|
30 // --------------------------------------------------------------------------- |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 u8_t core_frame_rm_ie_beacon_report_ie_c::length() const |
|
34 { |
|
35 return CORE_FRAME_RM_IE_BEACON_REPORT_IE_MIN_LENGTH; |
|
36 } |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 core_frame_rm_ie_beacon_report_ie_c* core_frame_rm_ie_beacon_report_ie_c::instance( |
|
42 u8_t regulatory_class, |
|
43 u16_t measurement_duration, |
|
44 u8_t reported_frame_information, |
|
45 u8_t antenna_id, |
|
46 core_ap_data_c& ap_data ) |
|
47 { |
|
48 DEBUG( "core_frame_rm_ie_beacon_report_ie_c::instance()" ); |
|
49 |
|
50 core_tsf_value_s dummy_tsf = {0}; |
|
51 u8_t dummy_rsni = 0xFF; |
|
52 |
|
53 u8_t* buffer = new u8_t[CORE_FRAME_RM_IE_BEACON_REPORT_IE_MIN_LENGTH]; |
|
54 if ( !buffer ) |
|
55 { |
|
56 DEBUG( "core_frame_rm_ie_beacon_report_ie_c::instance() - unable create the internal buffer" ); |
|
57 return NULL; |
|
58 } |
|
59 |
|
60 core_frame_rm_ie_beacon_report_ie_c* instance = |
|
61 new core_frame_rm_ie_beacon_report_ie_c( 0, buffer, CORE_FRAME_RM_IE_BEACON_REPORT_IE_MIN_LENGTH ); |
|
62 if ( !instance ) |
|
63 { |
|
64 DEBUG( "core_frame_rm_ie_beacon_report_ie_c::instance() - unable to create an instance" ); |
|
65 delete[] buffer; |
|
66 |
|
67 return NULL; |
|
68 } |
|
69 |
|
70 instance->generate( |
|
71 regulatory_class, |
|
72 dummy_tsf, |
|
73 measurement_duration, |
|
74 reported_frame_information, |
|
75 dummy_rsni, |
|
76 antenna_id, |
|
77 dummy_tsf, |
|
78 ap_data ); |
|
79 |
|
80 return instance; |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void core_frame_rm_ie_beacon_report_ie_c::generate( |
|
87 u8_t regulatory_class, |
|
88 core_tsf_value_s& actual_measurement_start_time, |
|
89 u16_t measurement_duration, |
|
90 u8_t reported_frame_information, |
|
91 u8_t rsni, |
|
92 u8_t antenna_id, |
|
93 core_tsf_value_s& parent_tsf, |
|
94 core_ap_data_c& ap_data ) |
|
95 { |
|
96 DEBUG( "core_frame_rm_ie_beacon_report_ie_c::generate()" ); |
|
97 |
|
98 // Regulatory Class |
|
99 data_m[data_length_m++] = regulatory_class; |
|
100 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - Regulatory Class: 0x%02X", data_m[data_length_m - 1] ); |
|
101 |
|
102 // Channel Number |
|
103 data_m[data_length_m++] = ap_data.channel(); |
|
104 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - Channel Number: 0x%02X", data_m[data_length_m - 1] ); |
|
105 |
|
106 // Actual Measurement Start Time |
|
107 core_tools_c::copy( |
|
108 &data_m[data_length_m], |
|
109 reinterpret_cast<const u8_t*>( &actual_measurement_start_time.tsf[0] ), |
|
110 TSF_VALUE_LEN ); |
|
111 data_length_m += TSF_VALUE_LEN; |
|
112 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - Actual Measurement Start Time: 0x%016X", data_m[data_length_m - 1] ); |
|
113 |
|
114 // Measurement Duration |
|
115 core_tools_c::copy( |
|
116 &data_m[data_length_m], |
|
117 reinterpret_cast<const u8_t*>( &measurement_duration ), |
|
118 sizeof( measurement_duration ) ); |
|
119 data_length_m += sizeof( measurement_duration ); |
|
120 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - Measurement Duration: 0x%04X", data_m[data_length_m - 1] ); |
|
121 |
|
122 // Reported Frame Information |
|
123 data_m[data_length_m++] = reported_frame_information; |
|
124 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - Reported Frame Information: 0x%02X", data_m[data_length_m - 1] ); |
|
125 |
|
126 // RCPI |
|
127 data_m[data_length_m++] = ap_data.rcpi(); |
|
128 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - RCPI: 0x%02X", data_m[data_length_m - 1] ); |
|
129 |
|
130 // RSNI |
|
131 data_m[data_length_m++] = rsni; |
|
132 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - RSNI: 0x%02X", data_m[data_length_m - 1] ); |
|
133 |
|
134 // BSSID |
|
135 const core_mac_address_s bssid = ap_data.bssid(); |
|
136 DEBUG6( "core_frame_rm_ie_beacon_report_ie_c::generate() - BSSID: %02X:%02X:%02X:%02X:%02X:%02X", |
|
137 bssid.addr[0], bssid.addr[1], bssid.addr[2], |
|
138 bssid.addr[3], bssid.addr[4], bssid.addr[5] ); |
|
139 core_tools_c::copy( |
|
140 &data_m[data_length_m], |
|
141 reinterpret_cast<const u8_t*>( &bssid.addr[0] ), |
|
142 MAC_ADDR_LEN ); |
|
143 data_length_m += MAC_ADDR_LEN; |
|
144 |
|
145 // Antenna ID |
|
146 data_m[data_length_m++] = antenna_id; |
|
147 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - Antenna ID: 0x%02X", data_m[data_length_m - 1] ); |
|
148 |
|
149 // Parent TSF |
|
150 core_tools_c::copy( |
|
151 &data_m[data_length_m], |
|
152 reinterpret_cast<const u8_t*>( &parent_tsf.tsf[0] ), |
|
153 TSF_VALUE_LEN / 2 ); |
|
154 |
|
155 data_length_m += TSF_VALUE_LEN / 2; |
|
156 DEBUG1( "core_frame_rm_ie_beacon_report_ie_c::generate() - Parent TSF: 0x%08X", data_m[data_length_m - 1] ); |
|
157 |
|
158 // check generated data length doesn't exceed allocated buffer |
|
159 ASSERT( data_length_m <= max_data_length_m ); |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------------------------- |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 core_frame_rm_ie_beacon_report_ie_c::~core_frame_rm_ie_beacon_report_ie_c() |
|
166 { |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // --------------------------------------------------------------------------- |
|
171 // |
|
172 core_frame_rm_ie_beacon_report_ie_c::core_frame_rm_ie_beacon_report_ie_c( |
|
173 u16_t data_length, |
|
174 const u8_t* data, |
|
175 u16_t max_data_length ) : |
|
176 core_frame_dot11_ie_c( data_length, data, max_data_length ), |
|
177 current_ie_m( NULL ), |
|
178 current_ie_max_length_m( 0 ) |
|
179 { |
|
180 } |