Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers altcp_tls_mbedtls_structs.h Source File

altcp_tls_mbedtls_structs.h

Go to the documentation of this file.
00001 /**
00002  * @file
00003  * Application layered TCP/TLS connection API (to be used from TCPIP thread)
00004  *
00005  * This file contains structure definitions for a TLS layer using mbedTLS.
00006  */
00007 
00008 /*
00009  * Copyright (c) 2017 Simon Goldschmidt
00010  * All rights reserved.
00011  *
00012  * Redistribution and use in source and binary forms, with or without modification,
00013  * are permitted provided that the following conditions are met:
00014  *
00015  * 1. Redistributions of source code must retain the above copyright notice,
00016  *    this list of conditions and the following disclaimer.
00017  * 2. Redistributions in binary form must reproduce the above copyright notice,
00018  *    this list of conditions and the following disclaimer in the documentation
00019  *    and/or other materials provided with the distribution.
00020  * 3. The name of the author may not be used to endorse or promote products
00021  *    derived from this software without specific prior written permission.
00022  *
00023  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
00024  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
00025  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
00026  * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00027  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00028  * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00029  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00030  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
00031  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
00032  * OF SUCH DAMAGE.
00033  *
00034  * This file is part of the lwIP TCP/IP stack.
00035  *
00036  * Author: Simon Goldschmidt <goldsimon@gmx.de>
00037  *
00038  */
00039 #ifndef LWIP_HDR_ALTCP_MBEDTLS_STRUCTS_H
00040 #define LWIP_HDR_ALTCP_MBEDTLS_STRUCTS_H
00041 
00042 #include "lwip/opt.h"
00043 
00044 #if LWIP_ALTCP /* don't build if not configured for use in lwipopts.h */
00045 
00046 #include "lwip/apps/altcp_tls_mbedtls_opts.h"
00047 
00048 #if LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS
00049 
00050 #include "lwip/altcp.h"
00051 #include "lwip/pbuf.h"
00052 
00053 #include "mbedtls/ssl.h"
00054 
00055 #ifdef __cplusplus
00056 extern "C" {
00057 #endif
00058 
00059 #define ALTCP_MBEDTLS_FLAGS_HANDSHAKE_DONE    0x01
00060 #define ALTCP_MBEDTLS_FLAGS_UPPER_CALLED      0x02
00061 #define ALTCP_MBEDTLS_FLAGS_RX_CLOSE_QUEUED   0x04
00062 #define ALTCP_MBEDTLS_FLAGS_RX_CLOSED         0x08
00063 #define ALTCP_MBEDTLS_FLAGS_APPLDATA_SENT     0x10
00064 
00065 typedef struct altcp_mbedtls_state_s {
00066   void *conf;
00067   mbedtls_ssl_context ssl_context;
00068   /* chain of rx pbufs (before decryption) */
00069   struct pbuf *rx;
00070   struct pbuf *rx_app;
00071   u8_t flags;
00072   int rx_passed_unrecved;
00073   int bio_bytes_read;
00074   int bio_bytes_appl;
00075 } altcp_mbedtls_state_t;
00076 
00077 #ifdef __cplusplus
00078 }
00079 #endif
00080 
00081 #endif /* LWIP_ALTCP_TLS && LWIP_ALTCP_TLS_MBEDTLS */
00082 #endif /* LWIP_ALTCP */
00083 #endif /* LWIP_HDR_ALTCP_MBEDTLS_STRUCTS_H */