eapol/eapol_framework/eapol_common/type/radius/include/eap_radius_header.h
changeset 0 c8830336c852
child 2 1c7bc153c08e
equal deleted inserted replaced
-1:000000000000 0:c8830336c852
       
     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_RADIUS_HEADER_H_)
       
    23 #define _EAP_RADIUS_HEADER_H_
       
    24 
       
    25 
       
    26 #include "eap_general_header_base.h"
       
    27 #include "eap_am_types.h"
       
    28 
       
    29 
       
    30 /** @file */
       
    31 
       
    32 //-----------------------------------------------------------------------------------------
       
    33 
       
    34 /// Enumeration of the RADIUS-Code values.
       
    35 enum eap_radius_code_value_e
       
    36 {
       
    37 	eap_radius_code_none                = 0, ///< This is internal value for no type case.
       
    38 	eap_radius_code_access_request      = 1, ///< 
       
    39 	eap_radius_code_access_accept       = 2, ///< 
       
    40 	eap_radius_code_access_reject       = 3, ///< 
       
    41 	eap_radius_code_accounting_request  = 4, ///< 
       
    42 	eap_radius_code_accounting_response = 5, ///< 
       
    43 	eap_radius_code_access_challenge    = 11, ///< 
       
    44 	eap_radius_code_maximum_supported = eap_radius_code_access_challenge, ///< Keep this the last one.
       
    45 };
       
    46 
       
    47 const u32_t EAP_RADIUS_AUTHENTICATOR_LENGTH = 16ul;
       
    48 
       
    49 //-----------------------------------------------------------------------------------------
       
    50 
       
    51 /** This is base class defining the RADIUS-packet header.
       
    52  * @code
       
    53  *   0                   1                   2                   3
       
    54  *   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
       
    55  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    56  *  |     Code      |  Identifier   |            Length             |
       
    57  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    58  *  |                                                               |
       
    59  *  |                         Authenticator                         |
       
    60  *  |                                                               |
       
    61  *  |                                                               |
       
    62  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    63  *  |  Attributes ...
       
    64  *  +-+-+-+-+-+-+-+-+-+-+-+-+-
       
    65  * @endcode
       
    66  */
       
    67 class EAP_EXPORT eap_radius_header_base_c
       
    68 : public eap_general_header_base_c
       
    69 {
       
    70 private:
       
    71 	//--------------------------------------------------
       
    72 
       
    73 	/// This is pointer to the tools class.
       
    74 	abs_eap_am_tools_c * const m_am_tools;
       
    75 
       
    76 	//--------------------------------------------------
       
    77 public:
       
    78 	//--------------------------------------------------
       
    79 
       
    80 	/**
       
    81 	 * This enumeration defines the offsets of the RADIUS-header fields.
       
    82 	 */
       
    83 	enum offsets
       
    84 	{
       
    85 		m_code_offset = 0ul,                                ///< This is offset to code field.
       
    86 		m_identifier_offset = m_code_offset+sizeof(u8_t),   ///< This is offset to identifier field.
       
    87 		m_length_offset = m_identifier_offset+sizeof(u8_t), ///< This is offset to length field.
       
    88 		
       
    89 		m_authenticator_offset = m_length_offset+sizeof(u16_t),
       
    90 		///< This is offset to authenticator field.
       
    91 
       
    92 		m_attributes_offset = m_authenticator_offset+EAP_RADIUS_AUTHENTICATOR_LENGTH*sizeof(u8_t),
       
    93 		///< This is offset to optional attributes fields.
       
    94 	};
       
    95 
       
    96 	/// Destructor does nothing special.
       
    97 	EAP_FUNC_IMPORT virtual ~eap_radius_header_base_c();
       
    98 
       
    99 	/// Constructor does nothing special.
       
   100 	/// The tools parameter is pointer to tools object.
       
   101 	/// The header_buffer parameter is pointer to buffer of RADIUS-packet including header and data.
       
   102 	/// The header_buffer_length parameter is length of the header_buffer.
       
   103 	EAP_FUNC_IMPORT eap_radius_header_base_c(
       
   104 		abs_eap_am_tools_c * const tools,
       
   105 		void * const header_buffer,
       
   106 		const u32_t header_buffer_length);
       
   107 
       
   108 	/// This function returns the header length of the RADIUS-packet.
       
   109 	EAP_FUNC_IMPORT static u32_t get_header_length();
       
   110 
       
   111 	/// This function returns the code field of RADIUS-header.
       
   112 	EAP_FUNC_IMPORT eap_radius_code_value_e get_code() const;
       
   113 
       
   114 	/// This function returns the authenticator field of RADIUS-header.
       
   115 	EAP_FUNC_IMPORT u8_t * get_authenticator() const;
       
   116 
       
   117 	/// This function returns the length of the authenticator field of RADIUS-header.
       
   118 	EAP_FUNC_IMPORT u32_t get_authenticator_length() const;
       
   119 
       
   120 	/// This function returns the identifier field of RADIUS-header.
       
   121 	EAP_FUNC_IMPORT u8_t get_identifier() const;
       
   122 
       
   123 	/// This function returns the length field of RADIUS-header.
       
   124 	EAP_FUNC_IMPORT u16_t get_length() const;
       
   125 
       
   126 	/// This function returns the length of the attribute data of RADIUS-header.
       
   127 	EAP_FUNC_IMPORT u16_t get_data_length() const;
       
   128 
       
   129 	/// This function returns the pointer to the offset of the attribute field of RADIUS-packet.
       
   130 	/// Data field includes type field.
       
   131 	EAP_FUNC_IMPORT u8_t * get_data_offset(
       
   132 		const u32_t p_offset, const u32_t p_continuous_bytes) const;
       
   133 
       
   134 
       
   135 	/// This function sets the code field of the RADIUS-header.
       
   136 	EAP_FUNC_IMPORT void set_code(const eap_radius_code_value_e p_code);
       
   137 
       
   138 	/// This function sets the identifier field of the RADIUS-header.
       
   139 	EAP_FUNC_IMPORT void set_identifier(const u8_t p_identifier);
       
   140 
       
   141 	/// This function sets the length field of the RADIUS-header.
       
   142 	EAP_FUNC_IMPORT void set_length(const u16_t p_length);
       
   143 
       
   144 	/// This function sets the length field of the RADIUS-header
       
   145 	/// based on attribute data length.
       
   146 	EAP_FUNC_IMPORT void set_data_length(const u16_t p_length);
       
   147 
       
   148 
       
   149 	/// This function returns debug string of the code of the RADIUS-packet.
       
   150 	EAP_FUNC_IMPORT eap_const_string get_code_string() const;
       
   151 
       
   152 	/// This function checks the validity of RADIUS-header.
       
   153 	EAP_FUNC_IMPORT eap_status_e check_header() const;
       
   154 
       
   155 
       
   156 	/// This function resets the RADIUS-header.
       
   157 	/// The buffer_length parameter is the length of the RADISU-header and the following attribute data buffer.
       
   158 	EAP_FUNC_IMPORT void reset_header(u16_t buffer_length);
       
   159 
       
   160 	// 
       
   161 	//--------------------------------------------------
       
   162 }; // class eap_header_c
       
   163 
       
   164 
       
   165 #endif //#if !defined(_EAP_RADIUS_HEADER_H_)
       
   166 
       
   167 //--------------------------------------------------
       
   168 
       
   169 
       
   170 
       
   171 // End.