eapol/eapol_framework/eapol_common/type/radius/include/eap_radius_attribute_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 #if !defined(_EAP_RADIUS_PAYLOAD_HEADER_H_)
       
    22 #define _EAP_RADIUS_PAYLOAD_HEADER_H_
       
    23 
       
    24 #include "eap_tools.h"
       
    25 #include "eap_header.h"
       
    26 #include "eap_radius_types.h"
       
    27 #include "eap_diameter_avp_code.h"
       
    28 
       
    29 /** @file */
       
    30 
       
    31 const u32_t TRACE_FLAGS_RADIUS_ERROR = eap_am_tools_c::eap_trace_mask_error;
       
    32 
       
    33 
       
    34 const u32_t EAP_RADIUS_VENDOR_ID_LENGTH = 4ul*sizeof(u8_t);
       
    35 
       
    36 const u32_t EAP_RADIUS_VENDOR_ID_MS = 311ul;
       
    37 
       
    38 const u32_t EAP_RADIUS_MS_MPPE_KEY_LENGTH     = 32u;
       
    39 const u32_t EAP_RADIUS_MS_MPPE_KEY_DATA_LENGTH = 50ul;
       
    40 
       
    41 //----------------------------------------------------------------------------
       
    42 
       
    43 
       
    44 /// This class defines the attribute payload header of RADIUS EAP-type.
       
    45 /**
       
    46  * Here is a figure of attribute payload header of RADIUS EAP-type.
       
    47  * Attribute payload data is (m_length)-sizeof(eap_radius_attribute_header_c)
       
    48  * data octets that follows eap_radius_attribute_header_c.
       
    49  * @code
       
    50  *  0                   1                   2                   3
       
    51  *  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
       
    52  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    53  *  |  Type         |    Length     |    Value ...                   
       
    54  *  +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
       
    55  * @endcode
       
    56  *
       
    57  */
       
    58 class EAP_EXPORT eap_radius_attribute_header_c
       
    59 : public eap_general_header_base_c
       
    60 {
       
    61 private:
       
    62 	//--------------------------------------------------
       
    63 
       
    64 	/// This is pointer to the tools class.
       
    65 	abs_eap_am_tools_c * const m_am_tools;
       
    66 
       
    67 	//--------------------------------------------------
       
    68 protected:
       
    69 	//--------------------------------------------------
       
    70 
       
    71 	enum offsets
       
    72 	{
       
    73 		m_type_offset = 0ul,
       
    74 		m_length_offset = m_type_offset+sizeof(u8_t),
       
    75 		m_data_offset = m_length_offset+sizeof(u8_t),
       
    76 	};
       
    77 
       
    78 	//--------------------------------------------------
       
    79 public:
       
    80 	//--------------------------------------------------
       
    81 
       
    82 	// 
       
    83 	EAP_FUNC_IMPORT virtual ~eap_radius_attribute_header_c();
       
    84 
       
    85 	// 
       
    86 	EAP_FUNC_IMPORT eap_radius_attribute_header_c(
       
    87 		abs_eap_am_tools_c * const tools,
       
    88 		void * const header_buffer,
       
    89 		const u32_t header_buffer_length);
       
    90 
       
    91 	EAP_FUNC_IMPORT eap_diameter_avp_code_c get_current_payload() const;
       
    92 
       
    93 	EAP_FUNC_IMPORT u16_t get_length() const;
       
    94 
       
    95 	EAP_FUNC_IMPORT u32_t get_data_length() const;
       
    96 
       
    97 	EAP_FUNC_IMPORT static u16_t get_header_length();
       
    98 
       
    99 	EAP_FUNC_IMPORT static u16_t get_max_attribute_data_length();
       
   100 
       
   101 	EAP_FUNC_IMPORT u8_t * get_data_offset(const u32_t offset, const u32_t contignuous_bytes) const;
       
   102 
       
   103 	EAP_FUNC_IMPORT u8_t * get_next_header() const;
       
   104 
       
   105 
       
   106 	EAP_FUNC_IMPORT void set_current_payload(const eap_diameter_avp_code_c p_current_payload);
       
   107 
       
   108 	EAP_FUNC_IMPORT void set_data_length(const u16_t p_data_length);
       
   109 
       
   110 	EAP_FUNC_IMPORT void reset_header(const u16_t data_length);
       
   111 
       
   112 	EAP_FUNC_IMPORT eap_const_string get_payload_type_string() const;
       
   113 
       
   114 	EAP_FUNC_IMPORT eap_status_e check_header() const;
       
   115 
       
   116 	// 
       
   117 	//--------------------------------------------------
       
   118 }; // class eap_radius_attribute_header_c
       
   119 
       
   120 
       
   121 //--------------------------------------------------
       
   122 
       
   123 /// Macro traces payload type and data.
       
   124 #define EAP_RADIUS_TRACE_PAYLOAD(prefix, payload) \
       
   125 	{ \
       
   126 		EAP_TRACE_DEBUG( \
       
   127 			m_am_tools, TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS, \
       
   128 			(EAPL("%s (0x%08x): current payload 0x%08x=%s, data length 0x%04x.\n"), \
       
   129 			prefix, \
       
   130 			(payload)->get_header_buffer((payload)->get_length()), \
       
   131 			(payload)->get_current_payload().get_vendor_code(), \
       
   132 			(payload)->get_payload_type_string(), \
       
   133 			(payload)->get_data_length())); \
       
   134 		EAP_TRACE_DATA_DEBUG(m_am_tools, \
       
   135 			TRACE_FLAGS_DEFAULT|TRACE_TEST_VECTORS, \
       
   136 			(EAPL("payload"), \
       
   137 			(payload)->get_header_buffer((payload)->get_length()), \
       
   138 			(payload)->get_length())); \
       
   139 	}
       
   140 
       
   141 //--------------------------------------------------
       
   142 
       
   143 #endif //#if !defined(_EAP_RADIUS_PAYLOAD_HEADER_H_)
       
   144 
       
   145 
       
   146 
       
   147 // End.