mbed client on ethernet with LWIP

Dependencies:   mbed Socket lwip-eth lwip-sys lwip

Fork of mbed-client-classic-example-lwip by sandbox

Committer:
mbedAustin
Date:
Thu Jun 09 17:08:36 2016 +0000
Revision:
11:cada08fc8a70
Commit for public Consumption

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedAustin 11:cada08fc8a70 1 /**
mbedAustin 11:cada08fc8a70 2 * \file threading.h
mbedAustin 11:cada08fc8a70 3 *
mbedAustin 11:cada08fc8a70 4 * \brief Threading abstraction layer
mbedAustin 11:cada08fc8a70 5 *
mbedAustin 11:cada08fc8a70 6 * Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
mbedAustin 11:cada08fc8a70 7 * SPDX-License-Identifier: Apache-2.0
mbedAustin 11:cada08fc8a70 8 *
mbedAustin 11:cada08fc8a70 9 * Licensed under the Apache License, Version 2.0 (the "License"); you may
mbedAustin 11:cada08fc8a70 10 * not use this file except in compliance with the License.
mbedAustin 11:cada08fc8a70 11 * You may obtain a copy of the License at
mbedAustin 11:cada08fc8a70 12 *
mbedAustin 11:cada08fc8a70 13 * http://www.apache.org/licenses/LICENSE-2.0
mbedAustin 11:cada08fc8a70 14 *
mbedAustin 11:cada08fc8a70 15 * Unless required by applicable law or agreed to in writing, software
mbedAustin 11:cada08fc8a70 16 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
mbedAustin 11:cada08fc8a70 17 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbedAustin 11:cada08fc8a70 18 * See the License for the specific language governing permissions and
mbedAustin 11:cada08fc8a70 19 * limitations under the License.
mbedAustin 11:cada08fc8a70 20 *
mbedAustin 11:cada08fc8a70 21 * This file is part of mbed TLS (https://tls.mbed.org)
mbedAustin 11:cada08fc8a70 22 */
mbedAustin 11:cada08fc8a70 23 #ifndef MBEDTLS_THREADING_H
mbedAustin 11:cada08fc8a70 24 #define MBEDTLS_THREADING_H
mbedAustin 11:cada08fc8a70 25
mbedAustin 11:cada08fc8a70 26 #if !defined(MBEDTLS_CONFIG_FILE)
mbedAustin 11:cada08fc8a70 27 #include "config.h"
mbedAustin 11:cada08fc8a70 28 #else
mbedAustin 11:cada08fc8a70 29 #include MBEDTLS_CONFIG_FILE
mbedAustin 11:cada08fc8a70 30 #endif
mbedAustin 11:cada08fc8a70 31
mbedAustin 11:cada08fc8a70 32 #include <stdlib.h>
mbedAustin 11:cada08fc8a70 33
mbedAustin 11:cada08fc8a70 34 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 35 extern "C" {
mbedAustin 11:cada08fc8a70 36 #endif
mbedAustin 11:cada08fc8a70 37
mbedAustin 11:cada08fc8a70 38 #define MBEDTLS_ERR_THREADING_FEATURE_UNAVAILABLE -0x001A /**< The selected feature is not available. */
mbedAustin 11:cada08fc8a70 39 #define MBEDTLS_ERR_THREADING_BAD_INPUT_DATA -0x001C /**< Bad input parameters to function. */
mbedAustin 11:cada08fc8a70 40 #define MBEDTLS_ERR_THREADING_MUTEX_ERROR -0x001E /**< Locking / unlocking / free failed with error code. */
mbedAustin 11:cada08fc8a70 41
mbedAustin 11:cada08fc8a70 42 #if defined(MBEDTLS_THREADING_PTHREAD)
mbedAustin 11:cada08fc8a70 43 #include <pthread.h>
mbedAustin 11:cada08fc8a70 44 typedef struct
mbedAustin 11:cada08fc8a70 45 {
mbedAustin 11:cada08fc8a70 46 pthread_mutex_t mutex;
mbedAustin 11:cada08fc8a70 47 char is_valid;
mbedAustin 11:cada08fc8a70 48 } mbedtls_threading_mutex_t;
mbedAustin 11:cada08fc8a70 49 #endif
mbedAustin 11:cada08fc8a70 50
mbedAustin 11:cada08fc8a70 51 #if defined(MBEDTLS_THREADING_ALT)
mbedAustin 11:cada08fc8a70 52 /* You should define the mbedtls_threading_mutex_t type in your header */
mbedAustin 11:cada08fc8a70 53 #include "threading_alt.h"
mbedAustin 11:cada08fc8a70 54
mbedAustin 11:cada08fc8a70 55 /**
mbedAustin 11:cada08fc8a70 56 * \brief Set your alternate threading implementation function
mbedAustin 11:cada08fc8a70 57 * pointers and initialize global mutexes. If used, this
mbedAustin 11:cada08fc8a70 58 * function must be called once in the main thread before any
mbedAustin 11:cada08fc8a70 59 * other mbed TLS function is called, and
mbedAustin 11:cada08fc8a70 60 * mbedtls_threading_free_alt() must be called once in the main
mbedAustin 11:cada08fc8a70 61 * thread after all other mbed TLS functions.
mbedAustin 11:cada08fc8a70 62 *
mbedAustin 11:cada08fc8a70 63 * \note mutex_init() and mutex_free() don't return a status code.
mbedAustin 11:cada08fc8a70 64 * If mutex_init() fails, it should leave its argument (the
mbedAustin 11:cada08fc8a70 65 * mutex) in a state such that mutex_lock() will fail when
mbedAustin 11:cada08fc8a70 66 * called with this argument.
mbedAustin 11:cada08fc8a70 67 *
mbedAustin 11:cada08fc8a70 68 * \param mutex_init the init function implementation
mbedAustin 11:cada08fc8a70 69 * \param mutex_free the free function implementation
mbedAustin 11:cada08fc8a70 70 * \param mutex_lock the lock function implementation
mbedAustin 11:cada08fc8a70 71 * \param mutex_unlock the unlock function implementation
mbedAustin 11:cada08fc8a70 72 */
mbedAustin 11:cada08fc8a70 73 void mbedtls_threading_set_alt( void (*mutex_init)( mbedtls_threading_mutex_t * ),
mbedAustin 11:cada08fc8a70 74 void (*mutex_free)( mbedtls_threading_mutex_t * ),
mbedAustin 11:cada08fc8a70 75 int (*mutex_lock)( mbedtls_threading_mutex_t * ),
mbedAustin 11:cada08fc8a70 76 int (*mutex_unlock)( mbedtls_threading_mutex_t * ) );
mbedAustin 11:cada08fc8a70 77
mbedAustin 11:cada08fc8a70 78 /**
mbedAustin 11:cada08fc8a70 79 * \brief Free global mutexes.
mbedAustin 11:cada08fc8a70 80 */
mbedAustin 11:cada08fc8a70 81 void mbedtls_threading_free_alt( void );
mbedAustin 11:cada08fc8a70 82 #endif /* MBEDTLS_THREADING_ALT */
mbedAustin 11:cada08fc8a70 83
mbedAustin 11:cada08fc8a70 84 /*
mbedAustin 11:cada08fc8a70 85 * The function pointers for mutex_init, mutex_free, mutex_ and mutex_unlock
mbedAustin 11:cada08fc8a70 86 *
mbedAustin 11:cada08fc8a70 87 * All these functions are expected to work or the result will be undefined.
mbedAustin 11:cada08fc8a70 88 */
mbedAustin 11:cada08fc8a70 89 extern void (*mbedtls_mutex_init)( mbedtls_threading_mutex_t *mutex );
mbedAustin 11:cada08fc8a70 90 extern void (*mbedtls_mutex_free)( mbedtls_threading_mutex_t *mutex );
mbedAustin 11:cada08fc8a70 91 extern int (*mbedtls_mutex_lock)( mbedtls_threading_mutex_t *mutex );
mbedAustin 11:cada08fc8a70 92 extern int (*mbedtls_mutex_unlock)( mbedtls_threading_mutex_t *mutex );
mbedAustin 11:cada08fc8a70 93
mbedAustin 11:cada08fc8a70 94 /*
mbedAustin 11:cada08fc8a70 95 * Global mutexes
mbedAustin 11:cada08fc8a70 96 */
mbedAustin 11:cada08fc8a70 97 extern mbedtls_threading_mutex_t mbedtls_threading_readdir_mutex;
mbedAustin 11:cada08fc8a70 98 extern mbedtls_threading_mutex_t mbedtls_threading_gmtime_mutex;
mbedAustin 11:cada08fc8a70 99
mbedAustin 11:cada08fc8a70 100 #ifdef __cplusplus
mbedAustin 11:cada08fc8a70 101 }
mbedAustin 11:cada08fc8a70 102 #endif
mbedAustin 11:cada08fc8a70 103
mbedAustin 11:cada08fc8a70 104 #endif /* threading.h */