|
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 |
|
22 #if !defined(_EAP_GENERAL_HEADER_BASE_H_) |
|
23 #define _EAP_GENERAL_HEADER_BASE_H_ |
|
24 |
|
25 |
|
26 #include "eap_am_assert.h" |
|
27 #include "eap_am_tools.h" |
|
28 #include "eap_tools.h" |
|
29 |
|
30 /** @file */ |
|
31 |
|
32 /** This is general base class defining the view to packet header. |
|
33 */ |
|
34 class EAP_EXPORT eap_general_header_base_c |
|
35 { |
|
36 private: |
|
37 //-------------------------------------------------- |
|
38 |
|
39 /// This is pointer to the tools class. |
|
40 abs_eap_am_tools_c * const m_am_tools; |
|
41 |
|
42 /// This is pointer to the header buffer. |
|
43 u8_t * m_header_buffer; |
|
44 |
|
45 /// This is length of the header buffer. |
|
46 u32_t m_header_buffer_length; |
|
47 |
|
48 #if defined(USE_EAP_ERROR_TESTS) |
|
49 /// This flag tells whether protocol detected error on packet. |
|
50 /// This is used in error testing. |
|
51 /// Value of this attribute is initialized to true. |
|
52 /// Protocol should change attribute value to false |
|
53 /// after it accepts this packet. |
|
54 bool m_error_detected; |
|
55 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
56 |
|
57 //-------------------------------------------------- |
|
58 protected: |
|
59 //-------------------------------------------------- |
|
60 |
|
61 //-------------------------------------------------- |
|
62 public: |
|
63 //-------------------------------------------------- |
|
64 |
|
65 /// Destructor does nothing special. |
|
66 /// NOTE the header buffer is not deleted here. |
|
67 EAP_FUNC_IMPORT virtual ~eap_general_header_base_c(); |
|
68 |
|
69 /// Constructor does nothing special. |
|
70 /// The tools parameter is pointer to tools object. |
|
71 /// The header_buffer parameter is pointer to buffer of the packet including header and data. |
|
72 /// The header_buffer_length parameter is length of the header_buffer. |
|
73 EAP_FUNC_IMPORT eap_general_header_base_c( |
|
74 abs_eap_am_tools_c * const tools, |
|
75 void * const header_buffer, |
|
76 const u32_t header_buffer_length); |
|
77 |
|
78 /// This function returns the pointer to the offset of the data of the packet. |
|
79 EAP_FUNC_IMPORT u8_t * get_header_offset(const u32_t offset, const u32_t data_length) const; |
|
80 |
|
81 /// This function returns the pointer to the data of the packet. |
|
82 EAP_FUNC_IMPORT u8_t * get_header_buffer(const u32_t data_length) const; |
|
83 |
|
84 /// This function sets the buffer of the packet. |
|
85 /// The header_buffer parameter is pointer to buffer of the packet including header and data. |
|
86 /// The header_buffer_length parameter is length of the header_buffer. |
|
87 EAP_FUNC_IMPORT void set_header_buffer(u8_t * const header_buffer, const u32_t header_buffer_length); |
|
88 |
|
89 /// This function returns the length of the header buffer. |
|
90 EAP_FUNC_IMPORT u32_t get_header_buffer_length() const; |
|
91 |
|
92 /// This function returns validity of the object. |
|
93 EAP_FUNC_IMPORT bool get_is_valid() const; |
|
94 |
|
95 /// This function returns pointer to the tools object. |
|
96 EAP_FUNC_IMPORT abs_eap_am_tools_c * get_am_tools() const; |
|
97 |
|
98 /// This function checks the validity of derived header. |
|
99 virtual eap_status_e check_header() const = 0; |
|
100 |
|
101 |
|
102 #if defined(USE_EAP_ERROR_TESTS) |
|
103 |
|
104 EAP_FUNC_IMPORT void set_error_detected(const bool error_detected); |
|
105 |
|
106 EAP_FUNC_IMPORT bool get_error_detected(); |
|
107 |
|
108 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
109 |
|
110 // |
|
111 //-------------------------------------------------- |
|
112 }; // class eap_general_header_base_c |
|
113 |
|
114 |
|
115 #if defined(USE_EAP_ERROR_TESTS) |
|
116 |
|
117 #define EAP_GENERAL_HEADER_COPY_ERROR_PARAMETERS(destination, source) \ |
|
118 { \ |
|
119 (destination)->set_error_detected((source)->get_error_detected()); \ |
|
120 } |
|
121 |
|
122 #define EAP_GENERAL_HEADER_SET_ERROR_DETECTED(packet, true_or_false) \ |
|
123 { \ |
|
124 (packet)->set_error_detected((true_or_false)); \ |
|
125 } |
|
126 |
|
127 #else |
|
128 |
|
129 #define EAP_GENERAL_HEADER_COPY_ERROR_PARAMETERS(destination, source) |
|
130 |
|
131 #define EAP_GENERAL_HEADER_SET_ERROR_DETECTED(packet, true_or_false) |
|
132 |
|
133 #endif //#if defined(USE_EAP_ERROR_TESTS) |
|
134 |
|
135 |
|
136 #endif //#if !defined(_EAP_GENERAL_HEADER_BASE_H_) |
|
137 |
|
138 //-------------------------------------------------- |
|
139 |
|
140 |
|
141 |
|
142 // End. |