|
1 /* |
|
2 * Copyright (c) 2001-2006 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: EAP and WLAN authentication protocols. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // This is enumeration of EAPOL source code. |
|
20 #if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
21 #undef EAP_FILE_NUMBER_ENUM |
|
22 #define EAP_FILE_NUMBER_ENUM 32 |
|
23 #undef EAP_FILE_NUMBER_DATE |
|
24 #define EAP_FILE_NUMBER_DATE 1127594498 |
|
25 #endif //#if defined(USE_EAP_MINIMUM_RELEASE_TRACES) |
|
26 |
|
27 |
|
28 |
|
29 #include "eapol_ethernet_header.h" |
|
30 |
|
31 |
|
32 //-------------------------------------------------- |
|
33 |
|
34 // |
|
35 EAP_FUNC_EXPORT eapol_ethernet_header_base_c::~eapol_ethernet_header_base_c() |
|
36 { |
|
37 } |
|
38 |
|
39 // |
|
40 EAP_FUNC_EXPORT eapol_ethernet_header_base_c::eapol_ethernet_header_base_c( |
|
41 abs_eap_am_tools_c * const tools, |
|
42 void * const header_buffer, |
|
43 const u32_t header_buffer_length) |
|
44 : eap_general_header_base_c(tools, header_buffer, header_buffer_length) |
|
45 , m_am_tools(tools) |
|
46 { |
|
47 } |
|
48 |
|
49 EAP_FUNC_EXPORT u8_t * eapol_ethernet_header_base_c::get_destination() const |
|
50 { |
|
51 return (get_header_offset(m_destination_offset, EAPOL_ETHERNET_ADDRESS_LENGTH)); |
|
52 } |
|
53 |
|
54 EAP_FUNC_EXPORT u8_t * eapol_ethernet_header_base_c::get_source() const |
|
55 { |
|
56 return (get_header_offset(m_source_offset, EAPOL_ETHERNET_ADDRESS_LENGTH)); |
|
57 } |
|
58 |
|
59 EAP_FUNC_EXPORT u32_t eapol_ethernet_header_base_c::get_destination_length() const |
|
60 { |
|
61 return EAPOL_ETHERNET_ADDRESS_LENGTH; |
|
62 } |
|
63 |
|
64 EAP_FUNC_EXPORT u32_t eapol_ethernet_header_base_c::get_source_length() const |
|
65 { |
|
66 return EAPOL_ETHERNET_ADDRESS_LENGTH; |
|
67 } |
|
68 |
|
69 EAP_FUNC_EXPORT u16_t eapol_ethernet_header_base_c::get_type() const |
|
70 { |
|
71 const u8_t * const type_data = get_header_offset(m_type_offset, sizeof(u16_t)); |
|
72 if (type_data != 0) |
|
73 { |
|
74 return eap_read_u16_t_network_order(type_data, sizeof(u16_t)); |
|
75 } |
|
76 else |
|
77 { |
|
78 return 0; |
|
79 } |
|
80 } |
|
81 |
|
82 EAP_FUNC_EXPORT u8_t * eapol_ethernet_header_base_c::get_data(const u32_t data_length) const |
|
83 { |
|
84 return get_header_offset(m_data_offset, data_length); |
|
85 } |
|
86 |
|
87 EAP_FUNC_EXPORT u32_t eapol_ethernet_header_base_c::get_data_length() const |
|
88 { |
|
89 return get_header_buffer_length()-get_header_length(); |
|
90 } |
|
91 |
|
92 EAP_FUNC_EXPORT u16_t eapol_ethernet_header_base_c::get_header_length() |
|
93 { |
|
94 return m_data_offset; |
|
95 } |
|
96 |
|
97 EAP_FUNC_EXPORT void eapol_ethernet_header_base_c::set_type(const eapol_ethernet_type_e type) |
|
98 { |
|
99 u8_t * const type_data = get_header_offset(m_type_offset, sizeof(u16_t)); |
|
100 EAP_ASSERT(type_data != 0); |
|
101 type_data[0] = static_cast<u8_t>((type & 0xff00) >> 8); |
|
102 type_data[1] = static_cast<u8_t>(type & 0x00ff); |
|
103 } |
|
104 |
|
105 EAP_FUNC_EXPORT eap_status_e eapol_ethernet_header_base_c::check_header() const |
|
106 { |
|
107 if (get_type() != eapol_ethernet_type_pae |
|
108 && get_type() != eapol_ethernet_type_preauthentication) |
|
109 { |
|
110 return EAP_STATUS_RETURN(m_am_tools, eap_status_header_corrupted); |
|
111 } |
|
112 return EAP_STATUS_RETURN(m_am_tools, eap_status_ok); |
|
113 } |
|
114 |
|
115 //-------------------------------------------------- |
|
116 //-------------------------------------------------- |
|
117 //-------------------------------------------------- |
|
118 |
|
119 // |
|
120 EAP_FUNC_EXPORT eapol_ethernet_header_rd_c::~eapol_ethernet_header_rd_c() |
|
121 { |
|
122 } |
|
123 |
|
124 // |
|
125 EAP_FUNC_EXPORT eapol_ethernet_header_rd_c::eapol_ethernet_header_rd_c( |
|
126 abs_eap_am_tools_c * const tools, |
|
127 const u8_t * const header_buffer, |
|
128 const u32_t header_buffer_length) |
|
129 : eapol_ethernet_header_base_c(tools, const_cast<u8_t *>(header_buffer), header_buffer_length) |
|
130 , m_am_tools(tools) |
|
131 { |
|
132 } |
|
133 |
|
134 EAP_FUNC_EXPORT u8_t * eapol_ethernet_header_rd_c::get_eapol_header() const |
|
135 { |
|
136 return eapol_ethernet_header_base_c::get_data(eapol_header_base_c::get_header_length()); |
|
137 } |
|
138 |
|
139 //-------------------------------------------------- |
|
140 //-------------------------------------------------- |
|
141 //-------------------------------------------------- |
|
142 |
|
143 // |
|
144 EAP_FUNC_EXPORT eapol_ethernet_header_wr_c::~eapol_ethernet_header_wr_c() |
|
145 { |
|
146 } |
|
147 |
|
148 // |
|
149 EAP_FUNC_EXPORT eapol_ethernet_header_wr_c::eapol_ethernet_header_wr_c( |
|
150 abs_eap_am_tools_c * const tools, |
|
151 const u8_t * const header_buffer, |
|
152 const u32_t header_buffer_length) |
|
153 : eapol_ethernet_header_base_c(tools, const_cast<u8_t *>(header_buffer), header_buffer_length) |
|
154 , m_am_tools(tools) |
|
155 { |
|
156 } |
|
157 |
|
158 EAP_FUNC_EXPORT u8_t * eapol_ethernet_header_wr_c::get_eapol_header() const |
|
159 { |
|
160 return eapol_ethernet_header_base_c::get_data(eapol_header_base_c::get_header_length()); |
|
161 } |
|
162 |
|
163 EAP_FUNC_EXPORT u8_t * eapol_ethernet_header_wr_c::get_destination() |
|
164 { |
|
165 return eapol_ethernet_header_base_c::get_destination(); |
|
166 } |
|
167 |
|
168 EAP_FUNC_EXPORT u8_t * eapol_ethernet_header_wr_c::get_source() |
|
169 { |
|
170 return eapol_ethernet_header_base_c::get_source(); |
|
171 } |
|
172 |
|
173 EAP_FUNC_EXPORT void eapol_ethernet_header_wr_c::reset_header(const eapol_ethernet_type_e type, const u16_t buffer_length) |
|
174 { |
|
175 EAP_UNREFERENCED_PARAMETER(buffer_length); // <-- in release version |
|
176 m_am_tools->memset(get_destination(), 0, EAPOL_ETHERNET_ADDRESS_LENGTH); |
|
177 m_am_tools->memset(get_source(), 0, EAPOL_ETHERNET_ADDRESS_LENGTH); |
|
178 |
|
179 set_type(type); |
|
180 |
|
181 EAP_ASSERT(buffer_length >= get_header_length()+eapol_header_wr_c::get_header_length()); |
|
182 } |
|
183 |
|
184 //-------------------------------------------------- |
|
185 |
|
186 |
|
187 |
|
188 // End. |