eapol/eapol_framework/eapol_common/include/eap_buffer.h
changeset 49 43351a4f2da3
parent 26 9abfd4f00d37
equal deleted inserted replaced
47:712b4ffd76bb 49:43351a4f2da3
    22 #if !defined(_EAP_BUFFER_H_)
    22 #if !defined(_EAP_BUFFER_H_)
    23 #define _EAP_BUFFER_H_
    23 #define _EAP_BUFFER_H_
    24 
    24 
    25 #include "eap_am_assert.h"
    25 #include "eap_am_assert.h"
    26 #include "eap_variable_data.h"
    26 #include "eap_variable_data.h"
       
    27 #include "eap_am_export.h"
       
    28 // Start: added by script change_export_macros.sh.
       
    29 #if defined(EAP_NO_EXPORT_EAP_BUFFER_H)
       
    30 	#define EAP_CLASS_VISIBILITY_EAP_BUFFER_H EAP_NONSHARABLE 
       
    31 	#define EAP_FUNC_VISIBILITY_EAP_BUFFER_H 
       
    32 	#define EAP_C_FUNC_VISIBILITY_EAP_BUFFER_H 
       
    33 	#define EAP_FUNC_EXPORT_EAP_BUFFER_H 
       
    34 	#define EAP_C_FUNC_EXPORT_EAP_BUFFER_H 
       
    35 #elif defined(EAP_EXPORT_EAP_BUFFER_H)
       
    36 	#define EAP_CLASS_VISIBILITY_EAP_BUFFER_H EAP_EXPORT 
       
    37 	#define EAP_FUNC_VISIBILITY_EAP_BUFFER_H EAP_FUNC_EXPORT 
       
    38 	#define EAP_C_FUNC_VISIBILITY_EAP_BUFFER_H EAP_C_FUNC_EXPORT 
       
    39 	#define EAP_FUNC_EXPORT_EAP_BUFFER_H EAP_FUNC_EXPORT 
       
    40 	#define EAP_C_FUNC_EXPORT_EAP_BUFFER_H EAP_C_FUNC_EXPORT 
       
    41 #else
       
    42 	#define EAP_CLASS_VISIBILITY_EAP_BUFFER_H EAP_IMPORT 
       
    43 	#define EAP_FUNC_VISIBILITY_EAP_BUFFER_H EAP_FUNC_IMPORT 
       
    44 	#define EAP_C_FUNC_VISIBILITY_EAP_BUFFER_H EAP_C_FUNC_IMPORT 
       
    45 	#define EAP_FUNC_EXPORT_EAP_BUFFER_H 
       
    46 	#define EAP_C_FUNC_EXPORT_EAP_BUFFER_H 
       
    47 #endif
       
    48 // End: added by script change_export_macros.sh.
       
    49 
    27 
    50 
    28 //--------------------------------------------------
    51 //--------------------------------------------------
    29 
    52 
    30 const u32_t EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH = 1514;
    53 const u32_t EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH = 1514;
    31 
    54 
    73 class eapol_ethernet_header_wr_c;
    96 class eapol_ethernet_header_wr_c;
    74 class eapol_ethernet_header_rd_c;
    97 class eapol_ethernet_header_rd_c;
    75 
    98 
    76 
    99 
    77 /// Network packets are handled through eap_buf_chain_base_c class.
   100 /// Network packets are handled through eap_buf_chain_base_c class.
    78 class EAP_EXPORT eap_buf_chain_base_c
   101 class EAP_CLASS_VISIBILITY_EAP_BUFFER_H eap_buf_chain_base_c
    79 {
   102 {
    80 private:
   103 private:
    81 	//--------------------------------------------------
   104 	//--------------------------------------------------
    82 
   105 
    83 	/// This is pointer to the tools class.
   106 	/// This is pointer to the tools class.
   137 	//--------------------------------------------------
   160 	//--------------------------------------------------
   138 
   161 
   139 	/**
   162 	/**
   140 	 * This function initializes the eap_buf_chain_base_c object.
   163 	 * This function initializes the eap_buf_chain_base_c object.
   141 	 */
   164 	 */
   142 	EAP_FUNC_IMPORT eap_status_e initialize(
   165 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_status_e initialize(
   143 		const u32_t mem_guard_length);
   166 		const u32_t mem_guard_length);
   144 
   167 
   145 	/**
   168 	/**
   146 	 * Forses the inheritance.
   169 	 * Forses the inheritance.
   147 	 */
   170 	 */
   148 	EAP_FUNC_IMPORT virtual void force_inheritance() = 0;
   171 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H virtual void force_inheritance() = 0;
   149 
   172 
   150 	/**
   173 	/**
   151 	 * Function checks the memory guard bytes.
   174 	 * Function checks the memory guard bytes.
   152 	 */
   175 	 */
   153 	EAP_FUNC_IMPORT bool check_guard_bytes(const u8_t * const guard) const;
   176 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool check_guard_bytes(const u8_t * const guard) const;
   154 
   177 
   155 	/**
   178 	/**
   156 	 * Function sets the memory guard bytes.
   179 	 * Function sets the memory guard bytes.
   157 	 */
   180 	 */
   158 	EAP_FUNC_IMPORT void set_mem_guard_bytes();
   181 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_mem_guard_bytes();
   159 
   182 
   160 	/**
   183 	/**
   161 	 * Function zeroes the data buffer.
   184 	 * Function zeroes the data buffer.
   162 	 */
   185 	 */
   163 	EAP_FUNC_IMPORT void reset_data_buffer();
   186 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void reset_data_buffer();
   164 
   187 
   165 	//--------------------------------------------------
   188 	//--------------------------------------------------
   166 protected:
   189 protected:
   167 	//--------------------------------------------------
   190 	//--------------------------------------------------
   168 
   191 
   169 	/**
   192 	/**
   170 	 * @return Returns pointer to the tools object.
   193 	 * @return Returns pointer to the tools object.
   171 	 */
   194 	 */
   172 	EAP_FUNC_IMPORT abs_eap_am_tools_c * get_am_tools();
   195 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H abs_eap_am_tools_c * get_am_tools();
   173 
   196 
   174 	//--------------------------------------------------
   197 	//--------------------------------------------------
   175 public:
   198 public:
   176 	//--------------------------------------------------
   199 	//--------------------------------------------------
   177 
   200 
   178 	/**
   201 	/**
   179 	 * Function checks the all memory guard bytes.
   202 	 * Function checks the all memory guard bytes.
   180 	 */
   203 	 */
   181 	EAP_FUNC_IMPORT bool check_guards() const;
   204 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool check_guards() const;
   182 
   205 
   183 	/**
   206 	/**
   184 	 * The destructor of the eap_buf_chain_base_c class checks memory guards
   207 	 * The destructor of the eap_buf_chain_base_c class checks memory guards
   185 	 * and frees the allocated buffer.
   208 	 * and frees the allocated buffer.
   186 	 */
   209 	 */
   187 	EAP_FUNC_IMPORT virtual ~eap_buf_chain_base_c();
   210 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H virtual ~eap_buf_chain_base_c();
   188 
   211 
   189 	/**
   212 	/**
   190 	 * The constructor of the eap_buf_chain_wr class initializes attributes using
   213 	 * The constructor of the eap_buf_chain_wr class initializes attributes using
   191 	 * the parameters passes to it.
   214 	 * the parameters passes to it.
   192 	 * @param eap_write_buffer_e separates the write and read-only constructors.
   215 	 * @param eap_write_buffer_e separates the write and read-only constructors.
   213 	 *     response_packet.get_data_offset(eap_header_offset,
   236 	 *     response_packet.get_data_offset(eap_header_offset,
   214 	 *         (EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH
   237 	 *         (EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH
   215 	 *         -(eap_header_offset+ trailer_length)));
   238 	 *         -(eap_header_offset+ trailer_length)));
   216 	 * @endcode
   239 	 * @endcode
   217 	 */
   240 	 */
   218 	EAP_FUNC_IMPORT eap_buf_chain_base_c(
   241 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_base_c(
   219 		const eap_write_buffer_e, 
   242 		const eap_write_buffer_e, 
   220 		abs_eap_am_tools_c * const tools,
   243 		abs_eap_am_tools_c * const tools,
   221 		u8_t * const data, 
   244 		u8_t * const data, 
   222 		const u32_t data_length, 
   245 		const u32_t data_length, 
   223 		const bool reset_data,
   246 		const bool reset_data,
   247 	 *     response_packet.get_data_offset(eap_header_offset,
   270 	 *     response_packet.get_data_offset(eap_header_offset,
   248 	 *         (EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH
   271 	 *         (EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH
   249 	 *         -(eap_header_offset+ trailer_length)));
   272 	 *         -(eap_header_offset+ trailer_length)));
   250 	 * @endcode
   273 	 * @endcode
   251 	 */
   274 	 */
   252 	EAP_FUNC_IMPORT eap_buf_chain_base_c(
   275 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_base_c(
   253 		const eap_read_buffer_e,
   276 		const eap_read_buffer_e,
   254 		abs_eap_am_tools_c * const tools,
   277 		abs_eap_am_tools_c * const tools,
   255 		const u8_t * const data, 
   278 		const u8_t * const data, 
   256 		const u32_t data_length,
   279 		const u32_t data_length,
   257 		const bool free_buffer);
   280 		const bool free_buffer);
   277 	 *     response_packet.get_data_offset(eap_header_offset,
   300 	 *     response_packet.get_data_offset(eap_header_offset,
   278 	 *         (PACKET_BUFFER_LENGTH
   301 	 *         (PACKET_BUFFER_LENGTH
   279 	 *         -(eap_header_offset+ trailer_length)));
   302 	 *         -(eap_header_offset+ trailer_length)));
   280 	 * @endcode
   303 	 * @endcode
   281 	 */
   304 	 */
   282 	EAP_FUNC_IMPORT eap_buf_chain_base_c(
   305 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_base_c(
   283 		const eap_write_buffer_e,
   306 		const eap_write_buffer_e,
   284 		abs_eap_am_tools_c * const tools,
   307 		abs_eap_am_tools_c * const tools,
   285 		const u32_t data_length);
   308 		const u32_t data_length);
   286 
   309 
   287 	/**
   310 	/**
   305 	 *     response_packet.get_data_offset(eap_header_offset,
   328 	 *     response_packet.get_data_offset(eap_header_offset,
   306 	 *         (PACKET_BUFFER_LENGTH
   329 	 *         (PACKET_BUFFER_LENGTH
   307 	 *         -(eap_header_offset+ trailer_length)));
   330 	 *         -(eap_header_offset+ trailer_length)));
   308 	 * @endcode
   331 	 * @endcode
   309 	 */
   332 	 */
   310 	EAP_FUNC_IMPORT eap_buf_chain_base_c(
   333 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_base_c(
   311 		const eap_read_buffer_e,
   334 		const eap_read_buffer_e,
   312 		abs_eap_am_tools_c * const tools,
   335 		abs_eap_am_tools_c * const tools,
   313 		const u32_t data_length);
   336 		const u32_t data_length);
   314 
   337 
   315 	/**
   338 	/**
   316 	 * @return Returns count of memory guard bytes.
   339 	 * @return Returns count of memory guard bytes.
   317 	 */
   340 	 */
   318 	EAP_FUNC_IMPORT u32_t get_mem_guard_length();
   341 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H u32_t get_mem_guard_length();
   319 
   342 
   320 	/**
   343 	/**
   321 	 * The get_buffer_length() function returns the length of buffer in bytes.
   344 	 * The get_buffer_length() function returns the length of buffer in bytes.
   322 	 */
   345 	 */
   323 	EAP_FUNC_IMPORT u32_t get_buffer_length() const;
   346 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H u32_t get_buffer_length() const;
   324 
   347 
   325 	/**
   348 	/**
   326 	 * The get_data_length() function returns count of data bytes in the buffer.
   349 	 * The get_data_length() function returns count of data bytes in the buffer.
   327 	 */
   350 	 */
   328 	EAP_FUNC_IMPORT u32_t get_data_length() const;
   351 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H u32_t get_data_length() const;
   329 
   352 
   330 	/**
   353 	/**
   331 	 * The get_data_offset() function returns pointer to the data in offset (p_offset).
   354 	 * The get_data_offset() function returns pointer to the data in offset (p_offset).
   332 	 * @param p_offset indicates the required offset.
   355 	 * @param p_offset indicates the required offset.
   333 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   356 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   334 	 *
   357 	 *
   335 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   358 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   336 	 * this or the get_data() function. These functions can handle the memory guard.
   359 	 * this or the get_data() function. These functions can handle the memory guard.
   337 	 */
   360 	 */
   338 	EAP_FUNC_IMPORT u8_t * get_data_offset(const u32_t p_offset, const u32_t p_continuous_bytes) const;
   361 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H u8_t * get_data_offset(const u32_t p_offset, const u32_t p_continuous_bytes) const;
   339 
   362 
   340 	/**
   363 	/**
   341 	 * The get_data() function function returns pointer to the data.
   364 	 * The get_data() function function returns pointer to the data.
   342 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   365 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   343 	 *
   366 	 *
   344 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   367 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   345 	 * this or the get_data_offset() function. These functions can handle the memory guard.
   368 	 * this or the get_data_offset() function. These functions can handle the memory guard.
   346 	 */
   369 	 */
   347 	EAP_FUNC_IMPORT u8_t * get_data(const u32_t p_continuous_bytes) const;
   370 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H u8_t * get_data(const u32_t p_continuous_bytes) const;
   348 
   371 
   349 	/**
   372 	/**
   350 	 * The set_buffer_length() function allocates the buffer of length bytes.
   373 	 * The set_buffer_length() function allocates the buffer of length bytes.
   351 	 */
   374 	 */
   352 	EAP_FUNC_IMPORT eap_status_e set_buffer_length(const u32_t length);
   375 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_status_e set_buffer_length(const u32_t length);
   353 
   376 
   354 	/**
   377 	/**
   355 	 * The set_data_length() function set the data length in the buffer.
   378 	 * The set_data_length() function set the data length in the buffer.
   356 	 */
   379 	 */
   357 	EAP_FUNC_IMPORT eap_status_e set_data_length(const u32_t length);
   380 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_status_e set_data_length(const u32_t length);
   358 
   381 
   359 	/**
   382 	/**
   360 	 * The get_is_valid() function returns the status of the object.
   383 	 * The get_is_valid() function returns the status of the object.
   361 	 * @return True indicates the object is initialized.
   384 	 * @return True indicates the object is initialized.
   362 	 */
   385 	 */
   363 	EAP_FUNC_IMPORT bool get_is_valid() const;
   386 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool get_is_valid() const;
   364 
   387 
   365 	/**
   388 	/**
   366 	 * The get_is_valid() function returns the status of the
   389 	 * The get_is_valid() function returns the status of the
   367 	 * data included in object.
   390 	 * data included in object.
   368 	 * @return True indicates the object includes valid data.
   391 	 * @return True indicates the object includes valid data.
   369 	 */
   392 	 */
   370 	EAP_FUNC_IMPORT bool get_is_valid_data() const;
   393 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool get_is_valid_data() const;
   371 
   394 
   372 	/**
   395 	/**
   373 	 * The set_is_manipulated() function sets flag to indicate this packet is manipulated.
   396 	 * The set_is_manipulated() function sets flag to indicate this packet is manipulated.
   374 	 * This is used for testing purposes.
   397 	 * This is used for testing purposes.
   375 	 */
   398 	 */
   376 	EAP_FUNC_IMPORT void set_is_manipulated();
   399 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_is_manipulated();
   377 
   400 
   378 	/**
   401 	/**
   379 	 * The get_is_manipulated() function returns flag to indicate this packet is manipulated.
   402 	 * The get_is_manipulated() function returns flag to indicate this packet is manipulated.
   380 	 * This is used for testing purposes.
   403 	 * This is used for testing purposes.
   381 	 */
   404 	 */
   382 	EAP_FUNC_IMPORT bool get_is_manipulated();
   405 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool get_is_manipulated();
   383 
   406 
   384 	/**
   407 	/**
   385 	 * This function sets the index of sent packet.
   408 	 * This function sets the index of sent packet.
   386 	 * This is used for testing purposes.
   409 	 * This is used for testing purposes.
   387 	 */
   410 	 */
   388 	EAP_FUNC_IMPORT void set_send_packet_index(const u32_t send_packet_index);
   411 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_send_packet_index(const u32_t send_packet_index);
   389 
   412 
   390 	/**
   413 	/**
   391 	 * This function returns the index of sent packet.
   414 	 * This function returns the index of sent packet.
   392 	 * This is used for testing purposes.
   415 	 * This is used for testing purposes.
   393 	 */
   416 	 */
   394 	EAP_FUNC_IMPORT u32_t get_send_packet_index();
   417 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H u32_t get_send_packet_index();
   395 
   418 
   396 	/**
   419 	/**
   397 	 * The set_random_error_type() function sets the type of manipulation of the packet.
   420 	 * The set_random_error_type() function sets the type of manipulation of the packet.
   398 	 * This is used for testing purposes.
   421 	 * This is used for testing purposes.
   399 	 */
   422 	 */
   400 	EAP_FUNC_IMPORT void set_random_error_type(eap_random_error_type error_type);
   423 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_random_error_type(eap_random_error_type error_type);
   401 
   424 
   402 	/**
   425 	/**
   403 	 * The get_random_error_type() function returns the type of manipulation of the packet.
   426 	 * The get_random_error_type() function returns the type of manipulation of the packet.
   404 	 * This is used for testing purposes.
   427 	 * This is used for testing purposes.
   405 	 */
   428 	 */
   406 	EAP_FUNC_IMPORT eap_random_error_type get_random_error_type();
   429 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_random_error_type get_random_error_type();
   407 
   430 
   408 	/**
   431 	/**
   409 	 * The set_do_packet_retransmission() function sets the re-transmission flag of this packet.
   432 	 * The set_do_packet_retransmission() function sets the re-transmission flag of this packet.
   410 	 * Packet will be re-transmitted by lower layer when do_packet_retransmission_when_true is true.
   433 	 * Packet will be re-transmitted by lower layer when do_packet_retransmission_when_true is true.
   411 	 * Packet will not re-transmitted by lower layer when do_packet_retransmission_when_true is false.
   434 	 * Packet will not re-transmitted by lower layer when do_packet_retransmission_when_true is false.
   412 	 */
   435 	 */
   413 	EAP_FUNC_IMPORT void set_do_packet_retransmission(const bool do_packet_retransmission_when_true);
   436 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_do_packet_retransmission(const bool do_packet_retransmission_when_true);
   414 
   437 
   415 	/**
   438 	/**
   416 	 * The set_do_packet_retransmission() function gets the re-transmission flag of this packet.
   439 	 * The set_do_packet_retransmission() function gets the re-transmission flag of this packet.
   417 	 */
   440 	 */
   418 	EAP_FUNC_IMPORT bool get_do_packet_retransmission();
   441 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool get_do_packet_retransmission();
   419 
   442 
   420 	/**
   443 	/**
   421 	 * This sets whether the sender is client or server.
   444 	 * This sets whether the sender is client or server.
   422 	 * This is used in testing.
   445 	 * This is used in testing.
   423 	 */
   446 	 */
   424 	EAP_FUNC_IMPORT void set_is_client(const bool is_client_when_true);
   447 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_is_client(const bool is_client_when_true);
   425 
   448 
   426 	/**
   449 	/**
   427 	 * This gets whether the sender is client or server.
   450 	 * This gets whether the sender is client or server.
   428 	 * This is used in testing.
   451 	 * This is used in testing.
   429 	 */
   452 	 */
   430 	EAP_FUNC_IMPORT bool get_is_client() const;
   453 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool get_is_client() const;
   431 
   454 
   432 	/**
   455 	/**
   433 	 * This is used in testing.
   456 	 * This is used in testing.
   434 	 */
   457 	 */
   435 	EAP_FUNC_IMPORT void set_do_length_checks(const bool do_length_checks);
   458 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_do_length_checks(const bool do_length_checks);
   436 
   459 
   437 	/**
   460 	/**
   438 	 * This is used in testing.
   461 	 * This is used in testing.
   439 	 */
   462 	 */
   440 	EAP_FUNC_IMPORT bool get_do_length_checks() const;
   463 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool get_do_length_checks() const;
   441 
   464 
   442 
   465 
   443 	/**
   466 	/**
   444 	 * This sets whether this packet must be encrypted (true) or not (false).
   467 	 * This sets whether this packet must be encrypted (true) or not (false).
   445 	 * Encryption means the WLAN data encryption on the air (WEP, TKIP or CCMP).
   468 	 * Encryption means the WLAN data encryption on the air (WEP, TKIP or CCMP).
   446 	 * Using this flag to tell the encryption allows the configuration of the
   469 	 * Using this flag to tell the encryption allows the configuration of the
   447 	 * temporal key beforehand the key is used.
   470 	 * temporal key beforehand the key is used.
   448 	 * This is optimization to fasten the key configuration.
   471 	 * This is optimization to fasten the key configuration.
   449 	 */
   472 	 */
   450 	EAP_FUNC_IMPORT void set_encrypt(const bool encrypt_when_true);
   473 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_encrypt(const bool encrypt_when_true);
   451 
   474 
   452 	/**
   475 	/**
   453 	 * This gets whether this packet must be encrypted (true) or not (false).
   476 	 * This gets whether this packet must be encrypted (true) or not (false).
   454 	 * Encryption means the WLAN data encryption on the air (WEP, TKIP or CCMP).
   477 	 * Encryption means the WLAN data encryption on the air (WEP, TKIP or CCMP).
   455 	 * Using this flag to tell the encryption allows the configuration of the
   478 	 * Using this flag to tell the encryption allows the configuration of the
   456 	 * temporal key beforehand the key is used.
   479 	 * temporal key beforehand the key is used.
   457 	 * This is optimization to fasten the key configuration.
   480 	 * This is optimization to fasten the key configuration.
   458 	 */
   481 	 */
   459 	EAP_FUNC_IMPORT bool get_encrypt() const;
   482 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H bool get_encrypt() const;
   460 
   483 
   461 
   484 
   462 	/**
   485 	/**
   463 	 * This sets the pointer of sender stack.
   486 	 * This sets the pointer of sender stack.
   464 	 * This is used in testing.
   487 	 * This is used in testing.
   465 	 */
   488 	 */
   466 	EAP_FUNC_IMPORT void set_stack_address(const void * const stack_address);
   489 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void set_stack_address(const void * const stack_address);
   467 
   490 
   468 	/**
   491 	/**
   469 	 * This gets the pointer of sender stack.
   492 	 * This gets the pointer of sender stack.
   470 	 * This is used in testing.
   493 	 * This is used in testing.
   471 	 */
   494 	 */
   472 	EAP_FUNC_IMPORT const void * get_stack_address() const;
   495 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H const void * get_stack_address() const;
   473 
   496 
   474 	/**
   497 	/**
   475 	 * The add_data() function adds data to the end of the buffer.
   498 	 * The add_data() function adds data to the end of the buffer.
   476 	 * If the buffer is empty the data is added to begin of the buffer.
   499 	 * If the buffer is empty the data is added to begin of the buffer.
   477 	 * @param buffer points the data to be added.
   500 	 * @param buffer points the data to be added.
   478 	 * @param buffer_length is length of the buffer in bytes.
   501 	 * @param buffer_length is length of the buffer in bytes.
   479 	 */
   502 	 */
   480 	EAP_FUNC_IMPORT eap_status_e add_data(
   503 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_status_e add_data(
   481 		const void * const buffer,
   504 		const void * const buffer,
   482 		const u32_t buffer_length);
   505 		const u32_t buffer_length);
   483 
   506 
   484 	/**
   507 	/**
   485 	 * The add_data() function adds data to the end of the buffer.
   508 	 * The add_data() function adds data to the end of the buffer.
   486 	 * If the buffer is empty the data is added to begin of the buffer.
   509 	 * If the buffer is empty the data is added to begin of the buffer.
   487 	 * @param buffer points the data to be added.
   510 	 * @param buffer points the data to be added.
   488 	 */
   511 	 */
   489 	EAP_FUNC_IMPORT eap_status_e add_data(
   512 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_status_e add_data(
   490 		const eap_variable_data_c * const buffer);
   513 		const eap_variable_data_c * const buffer);
   491 
   514 
   492 	/**
   515 	/**
   493 	 * The add_data_to_offset() function adds data to the offset of the buffer.
   516 	 * The add_data_to_offset() function adds data to the offset of the buffer.
   494 	 * @param offset tells the place where data will begin.
   517 	 * @param offset tells the place where data will begin.
   495 	 * @param buffer points the data to be added.
   518 	 * @param buffer points the data to be added.
   496 	 * @param buffer_length is length of the buffer in bytes.
   519 	 * @param buffer_length is length of the buffer in bytes.
   497 	 */
   520 	 */
   498 	EAP_FUNC_IMPORT eap_status_e add_data_to_offset(
   521 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_status_e add_data_to_offset(
   499 		const u32_t offset,
   522 		const u32_t offset,
   500 		const void * const buffer,
   523 		const void * const buffer,
   501 		const u32_t buffer_length);
   524 		const u32_t buffer_length);
   502 
   525 
   503 	/**
   526 	/**
   504 	 * The add_data() function adds data to the offset of the buffer.
   527 	 * The add_data() function adds data to the offset of the buffer.
   505 	 * @param offset tells the place where data will begin.
   528 	 * @param offset tells the place where data will begin.
   506 	 * @param buffer points the data to be added.
   529 	 * @param buffer points the data to be added.
   507 	 */
   530 	 */
   508 	EAP_FUNC_IMPORT eap_status_e add_data_to_offset(
   531 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_status_e add_data_to_offset(
   509 		const u32_t offset,
   532 		const u32_t offset,
   510 		const eap_variable_data_c * const buffer);
   533 		const eap_variable_data_c * const buffer);
   511 
   534 
   512 	// 
   535 	// 
   513 	//--------------------------------------------------
   536 	//--------------------------------------------------
   516 
   539 
   517 
   540 
   518 /// Write only network packets are handled through eap_buf_chain_base_c class.
   541 /// Write only network packets are handled through eap_buf_chain_base_c class.
   519 /// Post-suffix _wr_c indicates the buffer has write attribute on.
   542 /// Post-suffix _wr_c indicates the buffer has write attribute on.
   520 /// The eap_buf_chain_wr_c class is derived from eap_buf_chain_base class.
   543 /// The eap_buf_chain_wr_c class is derived from eap_buf_chain_base class.
   521 class EAP_EXPORT eap_buf_chain_wr_c
   544 class EAP_CLASS_VISIBILITY_EAP_BUFFER_H eap_buf_chain_wr_c
   522 : public eap_buf_chain_base_c
   545 : public eap_buf_chain_base_c
   523 {
   546 {
   524 private:
   547 private:
   525 
   548 
   526 	/**
   549 	/**
   527 	 * Forses the inheritance.
   550 	 * Forses the inheritance.
   528 	 */
   551 	 */
   529 	EAP_FUNC_IMPORT void force_inheritance();
   552 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void force_inheritance();
   530 
   553 
   531 	//--------------------------------------------------
   554 	//--------------------------------------------------
   532 protected:
   555 protected:
   533 	//--------------------------------------------------
   556 	//--------------------------------------------------
   534 
   557 
   537 	//--------------------------------------------------
   560 	//--------------------------------------------------
   538 
   561 
   539 	/**
   562 	/**
   540 	 * The destructor does nothing special.
   563 	 * The destructor does nothing special.
   541 	 */
   564 	 */
   542 	EAP_FUNC_IMPORT virtual ~eap_buf_chain_wr_c();
   565 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H virtual ~eap_buf_chain_wr_c();
   543 
   566 
   544 	/**
   567 	/**
   545 	 * The costructor does nothing special. It just initializes all member attributes.
   568 	 * The costructor does nothing special. It just initializes all member attributes.
   546 	 * This version uses preallocated buffer.
   569 	 * This version uses preallocated buffer.
   547 	 */
   570 	 */
   548 	EAP_FUNC_IMPORT eap_buf_chain_wr_c(
   571 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_wr_c(
   549 		const eap_write_buffer_e,
   572 		const eap_write_buffer_e,
   550 		abs_eap_am_tools_c * const tools,
   573 		abs_eap_am_tools_c * const tools,
   551 		u8_t * const data,
   574 		u8_t * const data,
   552 		const u32_t data_length,
   575 		const u32_t data_length,
   553 		const bool reset_data,
   576 		const bool reset_data,
   556 
   579 
   557 	/**
   580 	/**
   558 	 * The costructor does nothing special. It just initializes all member attributes.
   581 	 * The costructor does nothing special. It just initializes all member attributes.
   559 	 * This version allocates buffer from heap.
   582 	 * This version allocates buffer from heap.
   560 	 */
   583 	 */
   561 	EAP_FUNC_IMPORT eap_buf_chain_wr_c(
   584 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_wr_c(
   562 		const eap_write_buffer_e,
   585 		const eap_write_buffer_e,
   563 		abs_eap_am_tools_c * const tools,
   586 		abs_eap_am_tools_c * const tools,
   564 		const u32_t data_length);
   587 		const u32_t data_length);
   565 
   588 
   566 	/**
   589 	/**
   567 	 * The costructor does nothing special. It just initializes all member attributes.
   590 	 * The costructor does nothing special. It just initializes all member attributes.
   568 	 * This version does not allocate buffer.
   591 	 * This version does not allocate buffer.
   569 	 * You must call set_buffer_length() member function to allocate buffer.
   592 	 * You must call set_buffer_length() member function to allocate buffer.
   570 	 */
   593 	 */
   571 	EAP_FUNC_IMPORT eap_buf_chain_wr_c(
   594 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_wr_c(
   572 		const eap_write_buffer_e,
   595 		const eap_write_buffer_e,
   573 		abs_eap_am_tools_c * const tools);
   596 		abs_eap_am_tools_c * const tools);
   574 
   597 
   575 	/**
   598 	/**
   576 	 * @return Returns the pointer to the ethernet header.
   599 	 * @return Returns the pointer to the ethernet header.
   577 	 */
   600 	 */
   578 	EAP_FUNC_IMPORT u8_t * get_ethernet_header();
   601 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H u8_t * get_ethernet_header();
   579 
   602 
   580 	/**
   603 	/**
   581 	 * The copy() function copies the eap_buf_chain_wr object.
   604 	 * The copy() function copies the eap_buf_chain_wr object.
   582 	 * Data is copied to new allocated buffer.
   605 	 * Data is copied to new allocated buffer.
   583 	 */
   606 	 */
   584 	EAP_FUNC_IMPORT eap_buf_chain_wr_c * copy();
   607 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_wr_c * copy();
   585 
   608 
   586 	// 
   609 	// 
   587 	//--------------------------------------------------
   610 	//--------------------------------------------------
   588 }; // class eap_buf_chain_wr_c
   611 }; // class eap_buf_chain_wr_c
   589 
   612 
   590 
   613 
   591 /// Read only network packets are handled through eap_buf_chain_rd_c class.
   614 /// Read only network packets are handled through eap_buf_chain_rd_c class.
   592 /// Post-suffix _rd_c indicates the buffer has read only attribute on.
   615 /// Post-suffix _rd_c indicates the buffer has read only attribute on.
   593 /// The eap_buf_chain_rd_c class is derived from eap_buf_chain_base class.
   616 /// The eap_buf_chain_rd_c class is derived from eap_buf_chain_base class.
   594 class EAP_EXPORT eap_buf_chain_rd_c
   617 class EAP_CLASS_VISIBILITY_EAP_BUFFER_H eap_buf_chain_rd_c
   595 : public eap_buf_chain_base_c
   618 : public eap_buf_chain_base_c
   596 {
   619 {
   597 private:
   620 private:
   598 
   621 
   599 	/**
   622 	/**
   600 	 * Forses the inheritance.
   623 	 * Forses the inheritance.
   601 	 */
   624 	 */
   602 	EAP_FUNC_IMPORT void force_inheritance();
   625 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H void force_inheritance();
   603 
   626 
   604 	//--------------------------------------------------
   627 	//--------------------------------------------------
   605 protected:
   628 protected:
   606 	//--------------------------------------------------
   629 	//--------------------------------------------------
   607 
   630 
   610 	//--------------------------------------------------
   633 	//--------------------------------------------------
   611 
   634 
   612 	/**
   635 	/**
   613 	 * The destructor of the eap_buf_chain_rd_c class checks memory guards.
   636 	 * The destructor of the eap_buf_chain_rd_c class checks memory guards.
   614 	 */
   637 	 */
   615 	EAP_FUNC_IMPORT virtual ~eap_buf_chain_rd_c();
   638 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H virtual ~eap_buf_chain_rd_c();
   616 
   639 
   617 	/**
   640 	/**
   618 	 * The constructor of the eap_buf_chain_wr class initializes attributes using
   641 	 * The constructor of the eap_buf_chain_wr class initializes attributes using
   619 	 * the parameters passes to it.
   642 	 * the parameters passes to it.
   620 	 * @param eap_read_buffer_e separates the write and read-only constructors.
   643 	 * @param eap_read_buffer_e separates the write and read-only constructors.
   637 	 *     response_packet.get_data_offset(eap_header_offset,
   660 	 *     response_packet.get_data_offset(eap_header_offset,
   638 	 *         (EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH
   661 	 *         (EAP_MAX_LOCAL_PACKET_BUFFER_LENGTH
   639 	 *         -(eap_header_offset+ trailer_length)));
   662 	 *         -(eap_header_offset+ trailer_length)));
   640 	 * @endcode
   663 	 * @endcode
   641 	 */
   664 	 */
   642 	EAP_FUNC_IMPORT eap_buf_chain_rd_c(
   665 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_rd_c(
   643 		const eap_read_buffer_e, 
   666 		const eap_read_buffer_e, 
   644 		abs_eap_am_tools_c * const tools,
   667 		abs_eap_am_tools_c * const tools,
   645 		const u8_t * const data, 
   668 		const u8_t * const data, 
   646 		const u32_t data_length,
   669 		const u32_t data_length,
   647 		const bool free_buffer);
   670 		const bool free_buffer);
   648 
   671 
   649 	/**
   672 	/**
   650 	 * The costructor does nothing special. It just initializes all member attributes.
   673 	 * The costructor does nothing special. It just initializes all member attributes.
   651 	 * This version allocates buffer from heap.
   674 	 * This version allocates buffer from heap.
   652 	 */
   675 	 */
   653 	EAP_FUNC_IMPORT eap_buf_chain_rd_c(
   676 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H eap_buf_chain_rd_c(
   654 		const eap_read_buffer_e,
   677 		const eap_read_buffer_e,
   655 		abs_eap_am_tools_c * const tools,
   678 		abs_eap_am_tools_c * const tools,
   656 		const u32_t data_length);
   679 		const u32_t data_length);
   657 
   680 
   658 	/**
   681 	/**
   660 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   683 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   661 	 *
   684 	 *
   662 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   685 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   663 	 * this or the get_data_offset() function. These functions can handle the memory guard.
   686 	 * this or the get_data_offset() function. These functions can handle the memory guard.
   664 	 */
   687 	 */
   665 	EAP_FUNC_IMPORT const u8_t * get_data(const u32_t p_continuous_bytes) const;
   688 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H const u8_t * get_data(const u32_t p_continuous_bytes) const;
   666 
   689 
   667 	/**
   690 	/**
   668 	 * The get_data_offset() function returns pointer to the data in offset (p_offset).
   691 	 * The get_data_offset() function returns pointer to the data in offset (p_offset).
   669 	 * @param p_offset indicates the required offset.
   692 	 * @param p_offset indicates the required offset.
   670 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   693 	 * @param p_continuous_bytes indicates how many bytes in continuous memory is needed.
   671 	 *
   694 	 *
   672 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   695 	 * NOTE user of the eap_buf_chain_wr class must obtain the pointer to the data using
   673 	 * this or the get_data() function. These functions can handle the memory guard.
   696 	 * this or the get_data() function. These functions can handle the memory guard.
   674 	 */
   697 	 */
   675 	EAP_FUNC_IMPORT const u8_t * get_data_offset(const u32_t p_offset, const u32_t p_continuous_bytes) const;
   698 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H const u8_t * get_data_offset(const u32_t p_offset, const u32_t p_continuous_bytes) const;
   676 
   699 
   677 	/**
   700 	/**
   678 	 * @return Returns the pointer to the ethernet header.
   701 	 * @return Returns the pointer to the ethernet header.
   679 	 */
   702 	 */
   680 	EAP_FUNC_IMPORT const u8_t * get_ethernet_header() const;
   703 	EAP_FUNC_VISIBILITY_EAP_BUFFER_H const u8_t * get_ethernet_header() const;
   681 
   704 
   682 	// 
   705 	// 
   683 	//--------------------------------------------------
   706 	//--------------------------------------------------
   684 }; // class eap_buf_chain_rd_c
   707 }; // class eap_buf_chain_rd_c
   685 
   708