|
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 |
|
20 |
|
21 #if !defined(_EAP_TLV_HEADER_H_) |
|
22 #define _EAP_TLV_HEADER_H_ |
|
23 |
|
24 #include "eap_am_types.h" |
|
25 #include "eap_tools.h" |
|
26 #include "eap_general_header_base.h" |
|
27 |
|
28 /** @file */ |
|
29 |
|
30 |
|
31 typedef u32_t eap_tlv_type_t; |
|
32 |
|
33 const eap_tlv_type_t eap_tlv_type_none = 0ul; |
|
34 |
|
35 //---------------------------------------------------------------------------- |
|
36 |
|
37 |
|
38 /// This class defines header of Attribute-Value Pairs. |
|
39 /** |
|
40 * Here is a figure of header of Attribute-Value Pairs. |
|
41 * Value data follows eap_tlv_header_c. |
|
42 * @code |
|
43 * EAP-TLV-header: |
|
44 * 0 1 2 3 |
|
45 * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 |
|
46 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
47 * | Type | |
|
48 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
49 * | Length | |
|
50 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
51 * | Value... |
|
52 * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |
|
53 * @endcode |
|
54 * |
|
55 * @code |
|
56 * The fields of this header are: |
|
57 * 32-bits Type; This is a type of value. |
|
58 * 32-bits value length (Length); This is a length field, the length (in bytes) of the following value. |
|
59 * @endcode |
|
60 * |
|
61 */ |
|
62 class EAP_EXPORT eap_tlv_header_c |
|
63 : public eap_general_header_base_c |
|
64 { |
|
65 private: |
|
66 //-------------------------------------------------- |
|
67 |
|
68 abs_eap_am_tools_c * const m_am_tools; |
|
69 |
|
70 //-------------------------------------------------- |
|
71 protected: |
|
72 //-------------------------------------------------- |
|
73 |
|
74 /// This is enumeration of offsets to data fields. |
|
75 enum offsets |
|
76 { |
|
77 m_type_offset = 0ul, ///< This is offset to fags and tlv type 32-bit field. |
|
78 m_length_offset = m_type_offset+sizeof(u32_t), ///< This is offset to length 32-bit field. |
|
79 m_data_offset = m_length_offset+sizeof(u32_t), ///< This is offset to data field. |
|
80 }; |
|
81 |
|
82 //-------------------------------------------------- |
|
83 public: |
|
84 //-------------------------------------------------- |
|
85 |
|
86 /** |
|
87 * The destructor of the eap_tlv_header_c class does nothing. |
|
88 */ |
|
89 EAP_FUNC_IMPORT virtual ~eap_tlv_header_c(); |
|
90 |
|
91 /** |
|
92 * The constructor of the eap_tlv_header_c class simply initializes the attributes. |
|
93 */ |
|
94 EAP_FUNC_IMPORT eap_tlv_header_c( |
|
95 abs_eap_am_tools_c * const tools, |
|
96 void * const header_begin, |
|
97 const u32_t header_buffer_length); |
|
98 |
|
99 /** |
|
100 * This function returns the type. |
|
101 */ |
|
102 EAP_FUNC_IMPORT eap_tlv_type_t get_type() const; |
|
103 |
|
104 /** |
|
105 * This function returns the data length of value. |
|
106 */ |
|
107 EAP_FUNC_IMPORT u32_t get_value_length() const; |
|
108 |
|
109 /** |
|
110 * This function returns the header length of TLV. |
|
111 */ |
|
112 EAP_FUNC_IMPORT static u32_t get_header_length(); |
|
113 |
|
114 /** |
|
115 * This function returns pointer to the offset of value. |
|
116 * @param offset is the offset of queried data in bytes. |
|
117 * @param contignuous_bytes is the length of queried data in bytes. |
|
118 */ |
|
119 EAP_FUNC_IMPORT u8_t * get_value_offset(const u32_t offset, const u32_t contignuous_bytes) const; |
|
120 |
|
121 |
|
122 /** |
|
123 * This function returns pointer to begin of value. |
|
124 * @param contignuous_bytes is the length of queried data in bytes. |
|
125 */ |
|
126 EAP_FUNC_IMPORT u8_t * get_value(const u32_t contignuous_bytes) const; |
|
127 |
|
128 |
|
129 /** |
|
130 * This function checks the header is valid. |
|
131 */ |
|
132 EAP_FUNC_IMPORT eap_status_e check_header() const; |
|
133 |
|
134 /** |
|
135 * This function returns the type. |
|
136 */ |
|
137 EAP_FUNC_IMPORT eap_status_e set_type(const eap_tlv_type_t type); |
|
138 |
|
139 /** |
|
140 * This function sets the value length. |
|
141 */ |
|
142 EAP_FUNC_IMPORT eap_status_e set_value_length(const u32_t value_length); |
|
143 |
|
144 /** |
|
145 * This function resets the TLV header. |
|
146 */ |
|
147 EAP_FUNC_IMPORT eap_status_e reset_header( |
|
148 const eap_tlv_type_t type, |
|
149 const u32_t value_length); |
|
150 |
|
151 // |
|
152 //-------------------------------------------------- |
|
153 }; // class eap_tlv_header_c |
|
154 |
|
155 |
|
156 //-------------------------------------------------- |
|
157 |
|
158 #endif //#if !defined(_EAP_TLV_HEADER_H_) |
|
159 |
|
160 |
|
161 |
|
162 // End. |