Gleb Klochkov / Mbed OS Climatcontroll_Main

Dependencies:   esp8266-driver

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers pana_eap_header.h Source File

pana_eap_header.h

00001 /*
00002  * Copyright (c) 2017, Arm Limited and affiliates.
00003  * SPDX-License-Identifier: Apache-2.0
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 #ifndef PANA_EAP_HEADER_H_
00019 #define PANA_EAP_HEADER_H_
00020 
00021 // Codes
00022 #define EAP_REQ                         0x01
00023 #define EAP_RESPONSE                    0x02
00024 #define EAP_SUCCESS                     0x03
00025 #define EAP_FAILURE                     0x04
00026 
00027 // Request/Response Types
00028 #define EAP_IDENTITY                    1
00029 #define EAP_TLS                         13
00030 #define EAP_TTLS                        21
00031 
00032 #define EAP_TLS_START                   0x20
00033 #define EAP_TLS_MORE_FRAGMENTS          0x40
00034 #define EAP_TLS_FRAGMENT_LENGTH         0x80
00035 
00036 #define EAP_MTU_SIZE                    520
00037 #define EAP_MTU_FRAG_SIZE               296
00038 
00039 /****************************************
00040  * EAP BASE For EAP_REQ & EAP_RESPONSE
00041  *
00042  * Code     Identifier  Length  Type
00043  * 8-bit    8-bit       16-bit  8-bit
00044  *
00045  */
00046 
00047 /****************************************
00048  * EAP BASE For EAP_SUCCESS & EAP_FAILURE
00049  *
00050  * Code     Identifier  Length
00051  * 8-bit    8-bit       16-bit
00052  *
00053  */
00054 
00055 typedef struct {
00056     uint16_t length;
00057     uint8_t eap_code;
00058     uint8_t id_seq;
00059     uint8_t type;
00060     uint8_t *data_ptr;
00061 } eap_header_t;
00062 
00063 typedef struct {
00064     uint8_t *data_ptr;
00065     uint8_t eap_tls_flags;
00066     uint16_t tls_frame_length;
00067     uint16_t tls_length;
00068 } eap_tls_header_t;
00069 
00070 bool eap_header_parse(uint8_t *data_ptr, uint16_t length, eap_header_t *header);
00071 uint8_t eap_header_size(uint8_t eap_code);
00072 uint8_t *eap_header_build(uint8_t *ptr, uint16_t data_length, uint8_t eap_code, uint8_t id_seq, uint8_t type);
00073 bool eap_tls_header_parse(uint8_t *eap_data_ptr, uint16_t eap_datalength, eap_tls_header_t *header);
00074 uint8_t eap_tls_header_size(uint16_t eap_tls_flags);
00075 uint8_t *eap_tls_header_build(uint8_t *ptr, uint16_t eap_tls_flags, uint16_t frame_length);
00076 
00077 
00078 #endif /* PANA_EAP_HEADER_H_ */