mirror of https://github.com/ARMmbed/mbed-os.git
Merge branch 'master' into feature_wifi
Conflicts: features/net/FEATURE_IPV4/lwip-interface/lwip_stack.c hal/targets.jsonpull/3975/head
commit
f12676dfc7
|
@ -11,11 +11,7 @@
|
||||||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
||||||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
||||||
*/
|
*/
|
||||||
#if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
|
#if defined(TARGET_STM32F070RB) && defined(TOOLCHAIN_GCC)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
|
||||||
#elif (defined(TARGET_STM32F030R8) || defined(TARGET_STM32F070RB)) && defined(TOOLCHAIN_GCC)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
|
||||||
#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
|
|
|
@ -16,11 +16,7 @@
|
||||||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
||||||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
||||||
*/
|
*/
|
||||||
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
|
#if (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
|
||||||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE 768
|
#define STACK_SIZE 768
|
||||||
|
|
|
@ -22,13 +22,7 @@ typedef struct {
|
||||||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
||||||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
||||||
*/
|
*/
|
||||||
#if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
|
#if (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_GCC)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
|
||||||
#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
|
||||||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE 768
|
#define STACK_SIZE 768
|
||||||
|
|
|
@ -14,13 +14,7 @@
|
||||||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
||||||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
||||||
*/
|
*/
|
||||||
#if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
|
#if defined(TARGET_STM32F334R8) && defined(TOOLCHAIN_IAR)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_GCC)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif defined(TARGET_STM32F334R8) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
||||||
#elif defined(TARGET_STM32F070RB)
|
#elif defined(TARGET_STM32F070RB)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
|
@ -30,6 +24,8 @@
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
#elif defined(TARGET_STM32F303K8) && defined(TOOLCHAIN_IAR)
|
#elif defined(TARGET_STM32F303K8) && defined(TOOLCHAIN_IAR)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
|
#elif defined(TARGET_STM32L073RZ)
|
||||||
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
|
|
|
@ -22,13 +22,7 @@ typedef struct {
|
||||||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
||||||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
||||||
*/
|
*/
|
||||||
#if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
|
#if (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_GCC)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
|
||||||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE 768
|
#define STACK_SIZE 768
|
||||||
|
|
|
@ -15,22 +15,18 @@
|
||||||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
||||||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
||||||
*/
|
*/
|
||||||
#if (defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)) && defined(TOOLCHAIN_GCC)
|
#if defined(TARGET_STM32F334R8) && (defined(TOOLCHAIN_GCC) || defined(TOOLCHAIN_IAR))
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/16
|
|
||||||
#elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_GCC)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/8
|
|
||||||
#elif defined(TARGET_STM32F334R8) && (defined(TOOLCHAIN_GCC) || defined(TOOLCHAIN_IAR))
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
||||||
#elif defined(TARGET_STM32F103RB)
|
#elif defined(TARGET_STM32F103RB)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
#elif defined(TARGET_STM32F030R8) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif defined(TARGET_STM32F070RB)
|
#elif defined(TARGET_STM32F070RB)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
#elif defined(TARGET_STM32F072RB)
|
#elif defined(TARGET_STM32F072RB)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
#elif defined(TARGET_STM32F302R8) && defined(TOOLCHAIN_IAR)
|
#elif defined(TARGET_STM32F302R8) && defined(TOOLCHAIN_IAR)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
|
#elif defined(TARGET_STM32L073RZ)
|
||||||
|
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
||||||
#elif defined(TARGET_STM32F303K8) && defined(TOOLCHAIN_IAR)
|
#elif defined(TARGET_STM32F303K8) && defined(TOOLCHAIN_IAR)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
||||||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
|
|
|
@ -15,11 +15,7 @@ const int SIGNAL_HANDLE_DELEY = 25;
|
||||||
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
* the C standard library. For GCC, ARM_STD and IAR it is defined with a size of 2048 bytes
|
||||||
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
* and for ARM_MICRO 512. Because of reduce RAM size some targets need a reduced stacksize.
|
||||||
*/
|
*/
|
||||||
#if defined(TARGET_STM32L053R8) || defined(TARGET_STM32L053C8)
|
#if (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/4
|
|
||||||
#elif (defined(TARGET_STM32F030R8)) && defined(TOOLCHAIN_IAR)
|
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE/2
|
|
||||||
#elif (defined(TARGET_EFM32HG_STK3400)) && !defined(TOOLCHAIN_ARM_MICRO)
|
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
#elif (defined(TARGET_EFM32LG_STK3600) || defined(TARGET_EFM32WG_STK3800) || defined(TARGET_EFM32PG_STK3401)) && !defined(TOOLCHAIN_ARM_MICRO)
|
||||||
#define STACK_SIZE 768
|
#define STACK_SIZE 768
|
||||||
|
|
|
@ -17,7 +17,11 @@
|
||||||
*/
|
*/
|
||||||
#if defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
|
#if defined(TARGET_MCU_NRF51822) || defined(TARGET_MCU_NRF52832)
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
#elif (defined(TARGET_STM32F070RB) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F103RB))
|
#elif defined(TARGET_STM32F070RB) || defined(TARGET_STM32F072RB) || defined(TARGET_STM32F103RB) || defined(TARGET_STM32F091RC)
|
||||||
|
#define STACK_SIZE 512
|
||||||
|
#elif defined(TARGET_STM32F410RB)
|
||||||
|
#define STACK_SIZE 512
|
||||||
|
#elif defined(TARGET_STM32L073RZ)
|
||||||
#define STACK_SIZE 512
|
#define STACK_SIZE 512
|
||||||
#else
|
#else
|
||||||
#define STACK_SIZE DEFAULT_STACK_SIZE
|
#define STACK_SIZE DEFAULT_STACK_SIZE
|
||||||
|
|
|
@ -169,7 +169,7 @@ static void record_purge_disconnected()
|
||||||
m_bcs.valid_conn_handles,
|
m_bcs.valid_conn_handles,
|
||||||
(~m_bcs.flags.connected_flags) & (m_bcs.flags.valid_flags));
|
(~m_bcs.flags.connected_flags) & (m_bcs.flags.valid_flags));
|
||||||
|
|
||||||
for (int i = 0; i < disconnected_list.len; i++)
|
for (uint32_t i = 0; i < disconnected_list.len; i++)
|
||||||
{
|
{
|
||||||
record_invalidate(disconnected_list.flag_keys[i]);
|
record_invalidate(disconnected_list.flag_keys[i]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -172,7 +172,7 @@ static pdb_buffer_record_t * write_buffer_record_find_unused(void)
|
||||||
*/
|
*/
|
||||||
static void write_buffer_record_release(pdb_buffer_record_t * p_write_buffer_record)
|
static void write_buffer_record_release(pdb_buffer_record_t * p_write_buffer_record)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < p_write_buffer_record->n_bufs; i++)
|
for (uint32_t i = 0; i < p_write_buffer_record->n_bufs; i++)
|
||||||
{
|
{
|
||||||
pm_buffer_release(&m_pdb.write_buffer, p_write_buffer_record->buffer_block_id + i);
|
pm_buffer_release(&m_pdb.write_buffer, p_write_buffer_record->buffer_block_id + i);
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,7 +93,7 @@ uint8_t pm_buffer_block_acquire(pm_buffer_t * p_buffer, uint32_t n_blocks)
|
||||||
{
|
{
|
||||||
first_locked_mutex = i;
|
first_locked_mutex = i;
|
||||||
}
|
}
|
||||||
if ((i - first_locked_mutex + 1) == n_blocks)
|
if ((i - first_locked_mutex + 1) >= 0 && ((uint32_t)(i - first_locked_mutex + 1)) == n_blocks)
|
||||||
{
|
{
|
||||||
return first_locked_mutex;
|
return first_locked_mutex;
|
||||||
}
|
}
|
||||||
|
|
|
@ -191,8 +191,8 @@ __STATIC_INLINE void nrf_delay_us(uint32_t volatile number_of_us)
|
||||||
|
|
||||||
#elif defined ( __GNUC__ )
|
#elif defined ( __GNUC__ )
|
||||||
|
|
||||||
static void __INLINE nrf_delay_us(uint32_t volatile number_of_us) __attribute__((always_inline));
|
static __INLINE void nrf_delay_us(uint32_t volatile number_of_us) __attribute__((always_inline));
|
||||||
static void __INLINE nrf_delay_us(uint32_t volatile number_of_us)
|
static __INLINE void nrf_delay_us(uint32_t volatile number_of_us)
|
||||||
{
|
{
|
||||||
register uint32_t delay __ASM ("r0") = number_of_us;
|
register uint32_t delay __ASM ("r0") = number_of_us;
|
||||||
__ASM volatile (
|
__ASM volatile (
|
||||||
|
|
|
@ -40,6 +40,10 @@
|
||||||
#include "nrf_error.h"
|
#include "nrf_error.h"
|
||||||
#include "app_util.h"
|
#include "app_util.h"
|
||||||
|
|
||||||
|
static void fs_callback(uint8_t op_code,
|
||||||
|
uint32_t result,
|
||||||
|
uint32_t const * p_data,
|
||||||
|
fs_length_t length_words);
|
||||||
|
|
||||||
/** Our fstorage configuration.
|
/** Our fstorage configuration.
|
||||||
* The other fields will be assigned automatically during compilation. */
|
* The other fields will be assigned automatically during compilation. */
|
||||||
|
|
|
@ -68,7 +68,7 @@
|
||||||
#define FDS_CMD_QUEUE_SIZE_GC (1)
|
#define FDS_CMD_QUEUE_SIZE_GC (1)
|
||||||
|
|
||||||
|
|
||||||
static uint8_t m_nested_critical;
|
//static uint8_t m_nested_critical;
|
||||||
|
|
||||||
/** Macros to enable and disable application interrupts. */
|
/** Macros to enable and disable application interrupts. */
|
||||||
#define CRITICAL_SECTION_ENTER() //sd_nvic_critical_region_enter(&m_nested_critical)
|
#define CRITICAL_SECTION_ENTER() //sd_nvic_critical_region_enter(&m_nested_critical)
|
||||||
|
|
|
@ -559,7 +559,7 @@ void fs_debug_print()
|
||||||
printf("Num items: 0x%08lx\r\n", (unsigned long)FS_SECTION_VARS_COUNT);
|
printf("Num items: 0x%08lx\r\n", (unsigned long)FS_SECTION_VARS_COUNT);
|
||||||
printf("===== ITEMS %lu =====\r\n", (unsigned long)FS_SECTION_VARS_COUNT);
|
printf("===== ITEMS %lu =====\r\n", (unsigned long)FS_SECTION_VARS_COUNT);
|
||||||
|
|
||||||
for(int i = 0; i < FS_SECTION_VARS_COUNT; i++)
|
for(uint32_t i = 0; i < FS_SECTION_VARS_COUNT; i++)
|
||||||
{
|
{
|
||||||
fs_config_t* config = FS_SECTION_VARS_GET(i);
|
fs_config_t* config = FS_SECTION_VARS_GET(i);
|
||||||
printf( "Address: 0x%08lx, CB: 0x%08lx\r\n",
|
printf( "Address: 0x%08lx, CB: 0x%08lx\r\n",
|
||||||
|
|
|
@ -74,23 +74,6 @@ typedef void (*fs_cb_t)(uint8_t op_code,
|
||||||
fs_length_t length_words);
|
fs_length_t length_words);
|
||||||
|
|
||||||
|
|
||||||
/**@brief Function prototype for a callback handler.
|
|
||||||
*
|
|
||||||
* @details This function is expected to be implemented by the module that
|
|
||||||
* registers for fstorage usage. Its usage is described
|
|
||||||
* in the function pointer type fs_cb_t.
|
|
||||||
*
|
|
||||||
* @param[in] op_code Flash operation code.
|
|
||||||
* @param[in] result Result of the flash operation.
|
|
||||||
* @param[in] p_data Pointer to the resulting data (or NULL if not in use).
|
|
||||||
* @param[in] length_words Length of data in words.
|
|
||||||
*/
|
|
||||||
static void fs_callback(uint8_t op_code,
|
|
||||||
uint32_t result,
|
|
||||||
uint32_t const * p_data,
|
|
||||||
fs_length_t length_words);
|
|
||||||
|
|
||||||
|
|
||||||
/**@brief Flash storage config variable.
|
/**@brief Flash storage config variable.
|
||||||
*
|
*
|
||||||
* @details The fstorage module will update the start_addr and end_address according to
|
* @details The fstorage module will update the start_addr and end_address according to
|
||||||
|
|
|
@ -68,8 +68,6 @@ typedef enum
|
||||||
#define EXTERNAL_INT_VECTOR_OFFSET 16
|
#define EXTERNAL_INT_VECTOR_OFFSET 16
|
||||||
/**@endcond */
|
/**@endcond */
|
||||||
|
|
||||||
#define PACKED(TYPE) __packed TYPE
|
|
||||||
|
|
||||||
void critical_region_enter (void);
|
void critical_region_enter (void);
|
||||||
void critical_region_exit (void);
|
void critical_region_exit (void);
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ void sdk_mapped_flags_bulk_update_by_key(uint16_t * p_keys,
|
||||||
{
|
{
|
||||||
if (p_keys[i] == key)
|
if (p_keys[i] == key)
|
||||||
{
|
{
|
||||||
for (int j = 0; j < n_flag_collections; j++)
|
for (uint32_t j = 0; j < n_flag_collections; j++)
|
||||||
{
|
{
|
||||||
if (value)
|
if (value)
|
||||||
{
|
{
|
||||||
|
|
|
@ -42,11 +42,11 @@
|
||||||
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
|
#define SVCALL(number, return_type, signature) return_type __svc(number) signature
|
||||||
#elif defined (__GNUC__)
|
#elif defined (__GNUC__)
|
||||||
#define SVCALL(number, return_type, signature) \
|
#define SVCALL(number, return_type, signature) \
|
||||||
_Pragma("GCC diagnostic ignored \"-Wunused-function\"") \
|
|
||||||
_Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
|
|
||||||
_Pragma("GCC diagnostic push") \
|
_Pragma("GCC diagnostic push") \
|
||||||
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
|
_Pragma("GCC diagnostic ignored \"-Wreturn-type\"") \
|
||||||
__attribute__((naked)) static return_type signature \
|
__attribute__((naked)) \
|
||||||
|
__attribute__((unused)) \
|
||||||
|
static return_type signature \
|
||||||
{ \
|
{ \
|
||||||
__asm( \
|
__asm( \
|
||||||
"svc %0\n" \
|
"svc %0\n" \
|
||||||
|
|
|
@ -234,7 +234,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
|
||||||
/*! @brief Callback when an error occurs inside the SoftDevice */
|
/*! @brief Callback when an error occurs inside the SoftDevice */
|
||||||
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
|
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
|
||||||
{
|
{
|
||||||
ASSERT(false, (void) 0);
|
ASSERT_TRUE(false, (void) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -23,7 +23,6 @@
|
||||||
void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
|
void bleGattcEventHandler(const ble_evt_t *p_ble_evt)
|
||||||
{
|
{
|
||||||
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
nRF5xn &ble = nRF5xn::Instance(BLE::DEFAULT_INSTANCE);
|
||||||
nRF5xGap &gap = (nRF5xGap &) ble.getGap();
|
|
||||||
nRF5xGattClient &gattClient = (nRF5xGattClient &) ble.getGattClient();
|
nRF5xGattClient &gattClient = (nRF5xGattClient &) ble.getGattClient();
|
||||||
nRF5xServiceDiscovery &sdSingleton = gattClient.discovery();
|
nRF5xServiceDiscovery &sdSingleton = gattClient.discovery();
|
||||||
nRF5xCharacteristicDescriptorDiscoverer &characteristicDescriptorDiscoverer =
|
nRF5xCharacteristicDescriptorDiscoverer &characteristicDescriptorDiscoverer =
|
||||||
|
|
|
@ -135,7 +135,7 @@ ble_uuid_t custom_convert_to_nordic_uuid(const UUID &uuid)
|
||||||
#define CFG_CUSTOM_UUID_BASE "\x6E\x40\x00\x00\xB5\xA3\xF3\x93\xE0\xA9\xE5\x0E\x24\xDC\xCA\x9E"
|
#define CFG_CUSTOM_UUID_BASE "\x6E\x40\x00\x00\xB5\xA3\xF3\x93\xE0\xA9\xE5\x0E\x24\xDC\xCA\x9E"
|
||||||
|
|
||||||
uint8_t uuid_type = custom_add_uuid_base(CFG_CUSTOM_UUID_BASE);
|
uint8_t uuid_type = custom_add_uuid_base(CFG_CUSTOM_UUID_BASE);
|
||||||
ASSERT(uuid_type > 0, ERROR_NOT_FOUND);
|
ASSERT_TRUE(uuid_type > 0, ERROR_NOT_FOUND);
|
||||||
|
|
||||||
// We can now safely add the primary service and any characteristics
|
// We can now safely add the primary service and any characteristics
|
||||||
// for our custom service ...
|
// for our custom service ...
|
||||||
|
|
|
@ -125,7 +125,6 @@ static inline void debugger_breakpoint(void)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Logical Assert
|
// Logical Assert
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define ASSERT(...) ASSERT_TRUE(__VA_ARGS__)
|
|
||||||
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
|
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
|
||||||
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
|
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/* Send advertising data! */
|
/* Send advertising data! */
|
||||||
ASSERT(ERROR_NONE ==
|
ASSERT_TRUE(ERROR_NONE ==
|
||||||
sd_ble_gap_adv_data_set(advData.getPayload(),
|
sd_ble_gap_adv_data_set(advData.getPayload(),
|
||||||
advData.getPayloadLen(),
|
advData.getPayloadLen(),
|
||||||
scanResponse.getPayload(),
|
scanResponse.getPayload(),
|
||||||
|
@ -105,7 +105,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
|
||||||
|
|
||||||
/* Make sure the GAP Service appearance value is aligned with the
|
/* Make sure the GAP Service appearance value is aligned with the
|
||||||
*appearance from GapAdvertisingData */
|
*appearance from GapAdvertisingData */
|
||||||
ASSERT(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
|
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
|
||||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||||
|
|
||||||
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
|
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
|
||||||
|
@ -196,7 +196,7 @@ ble_error_t nRF5xGap::startAdvertising(const GapAdvertisingParams ¶ms)
|
||||||
adv_para.interval = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
|
adv_para.interval = params.getIntervalInADVUnits(); // advertising interval (in units of 0.625 ms)
|
||||||
adv_para.timeout = params.getTimeout();
|
adv_para.timeout = params.getTimeout();
|
||||||
|
|
||||||
ASSERT(ERROR_NONE == sd_ble_gap_adv_start(&adv_para), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_start(&adv_para), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||||
|
|
||||||
return BLE_ERROR_NONE;
|
return BLE_ERROR_NONE;
|
||||||
}
|
}
|
||||||
|
@ -267,7 +267,7 @@ ble_error_t nRF5xGap::stopScan(void) {
|
||||||
ble_error_t nRF5xGap::stopAdvertising(void)
|
ble_error_t nRF5xGap::stopAdvertising(void)
|
||||||
{
|
{
|
||||||
/* Stop Advertising */
|
/* Stop Advertising */
|
||||||
ASSERT(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||||
|
|
||||||
state.advertising = 0;
|
state.advertising = 0;
|
||||||
|
|
||||||
|
|
|
@ -220,7 +220,7 @@ private:
|
||||||
*/
|
*/
|
||||||
void processRadioNotificationEvent(bool param) {
|
void processRadioNotificationEvent(bool param) {
|
||||||
radioNotificationCallbackParam = param;
|
radioNotificationCallbackParam = param;
|
||||||
radioNotificationTimeout.attach_us(this, &nRF5xGap::postRadioNotificationCallback, 0);
|
radioNotificationTimeout.attach_us(mbed::callback(this, &nRF5xGap::postRadioNotificationCallback), 0);
|
||||||
}
|
}
|
||||||
friend void radioNotificationStaticCallback(bool param); /* allow invocations of processRadioNotificationEvent() */
|
friend void radioNotificationStaticCallback(bool param); /* allow invocations of processRadioNotificationEvent() */
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
|
||||||
nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
|
nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
|
||||||
|
|
||||||
uint16_t serviceHandle;
|
uint16_t serviceHandle;
|
||||||
ASSERT( ERROR_NONE ==
|
ASSERT_TRUE( ERROR_NONE ==
|
||||||
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
|
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
|
||||||
&nordicUUID,
|
&nordicUUID,
|
||||||
&serviceHandle),
|
&serviceHandle),
|
||||||
|
@ -88,7 +88,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT ( ERROR_NONE ==
|
ASSERT_TRUE ( ERROR_NONE ==
|
||||||
custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID,
|
custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID,
|
||||||
&nordicUUID,
|
&nordicUUID,
|
||||||
p_char->getProperties(),
|
p_char->getProperties(),
|
||||||
|
@ -123,7 +123,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
|
||||||
|
|
||||||
nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID());
|
nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID());
|
||||||
|
|
||||||
ASSERT(ERROR_NONE ==
|
ASSERT_TRUE(ERROR_NONE ==
|
||||||
custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID,
|
custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID,
|
||||||
&nordicUUID,
|
&nordicUUID,
|
||||||
p_desc->getValuePtr(),
|
p_desc->getValuePtr(),
|
||||||
|
@ -177,7 +177,7 @@ ble_error_t nRF5xGattServer::read(Gap::Handle_t connectionHandle, GattAttribute:
|
||||||
.p_value = buffer,
|
.p_value = buffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT( ERROR_NONE ==
|
ASSERT_TRUE( ERROR_NONE ==
|
||||||
sd_ble_gatts_value_get(connectionHandle, attributeHandle, &value),
|
sd_ble_gatts_value_get(connectionHandle, attributeHandle, &value),
|
||||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||||
*lengthP = value.len;
|
*lengthP = value.len;
|
||||||
|
|
|
@ -292,7 +292,7 @@ static void btle_handler(ble_evt_t *p_ble_evt)
|
||||||
/*! @brief Callback when an error occurs inside the SoftDevice */
|
/*! @brief Callback when an error occurs inside the SoftDevice */
|
||||||
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
|
void assert_nrf_callback(uint16_t line_num, const uint8_t *p_file_name)
|
||||||
{
|
{
|
||||||
ASSERT(false, (void) 0);
|
ASSERT_TRUE(false, (void) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -125,7 +125,6 @@ static inline void debugger_breakpoint(void)
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// Logical Assert
|
// Logical Assert
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define ASSERT(...) ASSERT_TRUE(__VA_ARGS__)
|
|
||||||
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
|
#define ASSERT_TRUE(condition , error) ASSERT_DEFINE( , (condition), error, "%s", "evaluated to false")
|
||||||
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
|
#define ASSERT_FALSE(condition , error) ASSERT_DEFINE( ,!(condition), error, "%s", "evaluated to true")
|
||||||
|
|
||||||
|
|
|
@ -96,7 +96,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
|
||||||
//}
|
//}
|
||||||
|
|
||||||
/* Send advertising data! */
|
/* Send advertising data! */
|
||||||
ASSERT(ERROR_NONE ==
|
ASSERT_TRUE(ERROR_NONE ==
|
||||||
sd_ble_gap_adv_data_set(advData.getPayload(),
|
sd_ble_gap_adv_data_set(advData.getPayload(),
|
||||||
advData.getPayloadLen(),
|
advData.getPayloadLen(),
|
||||||
scanResponse.getPayload(),
|
scanResponse.getPayload(),
|
||||||
|
@ -105,7 +105,7 @@ ble_error_t nRF5xGap::setAdvertisingData(const GapAdvertisingData &advData, cons
|
||||||
|
|
||||||
/* Make sure the GAP Service appearance value is aligned with the
|
/* Make sure the GAP Service appearance value is aligned with the
|
||||||
*appearance from GapAdvertisingData */
|
*appearance from GapAdvertisingData */
|
||||||
ASSERT(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
|
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_appearance_set(advData.getAppearance()),
|
||||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||||
|
|
||||||
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
|
/* ToDo: Perform some checks on the payload, for example the Scan Response can't */
|
||||||
|
@ -273,7 +273,7 @@ ble_error_t nRF5xGap::stopScan(void) {
|
||||||
ble_error_t nRF5xGap::stopAdvertising(void)
|
ble_error_t nRF5xGap::stopAdvertising(void)
|
||||||
{
|
{
|
||||||
/* Stop Advertising */
|
/* Stop Advertising */
|
||||||
ASSERT(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
ASSERT_TRUE(ERROR_NONE == sd_ble_gap_adv_stop(), BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||||
|
|
||||||
state.advertising = 0;
|
state.advertising = 0;
|
||||||
|
|
||||||
|
|
|
@ -221,7 +221,7 @@ private:
|
||||||
*/
|
*/
|
||||||
void processRadioNotificationEvent(bool param) {
|
void processRadioNotificationEvent(bool param) {
|
||||||
radioNotificationCallbackParam = param;
|
radioNotificationCallbackParam = param;
|
||||||
radioNotificationTimeout.attach_us(this, &nRF5xGap::postRadioNotificationCallback, 0);
|
radioNotificationTimeout.attach_us(mbed::callback(this, &nRF5xGap::postRadioNotificationCallback), 0);
|
||||||
}
|
}
|
||||||
friend void radioNotificationStaticCallback(bool param); /* allow invocations of processRadioNotificationEvent() */
|
friend void radioNotificationStaticCallback(bool param); /* allow invocations of processRadioNotificationEvent() */
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
|
||||||
nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
|
nordicUUID = custom_convert_to_nordic_uuid(service.getUUID());
|
||||||
|
|
||||||
uint16_t serviceHandle;
|
uint16_t serviceHandle;
|
||||||
ASSERT( ERROR_NONE ==
|
ASSERT_TRUE( ERROR_NONE ==
|
||||||
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
|
sd_ble_gatts_service_add(BLE_GATTS_SRVC_TYPE_PRIMARY,
|
||||||
&nordicUUID,
|
&nordicUUID,
|
||||||
&serviceHandle),
|
&serviceHandle),
|
||||||
|
@ -88,7 +88,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ASSERT ( ERROR_NONE ==
|
ASSERT_TRUE ( ERROR_NONE ==
|
||||||
custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID,
|
custom_add_in_characteristic(BLE_GATT_HANDLE_INVALID,
|
||||||
&nordicUUID,
|
&nordicUUID,
|
||||||
p_char->getProperties(),
|
p_char->getProperties(),
|
||||||
|
@ -123,7 +123,7 @@ ble_error_t nRF5xGattServer::addService(GattService &service)
|
||||||
|
|
||||||
nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID());
|
nordicUUID = custom_convert_to_nordic_uuid(p_desc->getUUID());
|
||||||
|
|
||||||
ASSERT(ERROR_NONE ==
|
ASSERT_TRUE(ERROR_NONE ==
|
||||||
custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID,
|
custom_add_in_descriptor(BLE_GATT_HANDLE_INVALID,
|
||||||
&nordicUUID,
|
&nordicUUID,
|
||||||
p_desc->getValuePtr(),
|
p_desc->getValuePtr(),
|
||||||
|
@ -177,7 +177,7 @@ ble_error_t nRF5xGattServer::read(Gap::Handle_t connectionHandle, GattAttribute:
|
||||||
.p_value = buffer,
|
.p_value = buffer,
|
||||||
};
|
};
|
||||||
|
|
||||||
ASSERT( ERROR_NONE ==
|
ASSERT_TRUE( ERROR_NONE ==
|
||||||
sd_ble_gatts_value_get(connectionHandle, attributeHandle, &value),
|
sd_ble_gatts_value_get(connectionHandle, attributeHandle, &value),
|
||||||
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
BLE_ERROR_PARAM_OUT_OF_RANGE);
|
||||||
*lengthP = value.len;
|
*lengthP = value.len;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
568 Milosch Meriac
|
569 Milosch Meriac
|
||||||
477 Alessandro Angelino
|
478 Alessandro Angelino
|
||||||
72 Jaeden Amero
|
73 Jaeden Amero
|
||||||
53 Niklas Hauser
|
54 Niklas Hauser
|
||||||
3 Hugo Vincent
|
3 Hugo Vincent
|
||||||
3 JaredCJR
|
3 JaredCJR
|
||||||
3 Jim Huang
|
3 Jim Huang
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
v0.25.0
|
v0.25.1
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -35,10 +35,13 @@ typedef struct {
|
||||||
|
|
||||||
// Mutex to protect "buf"
|
// Mutex to protect "buf"
|
||||||
SingletonPtr<Mutex> mutex;
|
SingletonPtr<Mutex> mutex;
|
||||||
|
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
||||||
static char buf[128];
|
static char buf[128];
|
||||||
static SingletonPtr<CircularBuffer<thread_info_t, THREAD_BUF_COUNT> > queue;
|
static SingletonPtr<CircularBuffer<thread_info_t, THREAD_BUF_COUNT> > queue;
|
||||||
|
#endif
|
||||||
|
|
||||||
static void send_heap_info(void);
|
static void send_heap_info(void);
|
||||||
|
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
||||||
static void send_stack_info(void);
|
static void send_stack_info(void);
|
||||||
static void on_thread_terminate(osThreadId id);
|
static void on_thread_terminate(osThreadId id);
|
||||||
static void enqeue_thread_info(osThreadId id);
|
static void enqeue_thread_info(osThreadId id);
|
||||||
|
@ -47,6 +50,7 @@ static void deque_and_print_thread_info(void);
|
||||||
// sprintf uses a lot of stack so use these instead
|
// sprintf uses a lot of stack so use these instead
|
||||||
static uint32_t print_hex(char *buf, uint32_t value);
|
static uint32_t print_hex(char *buf, uint32_t value);
|
||||||
static uint32_t print_dec(char *buf, uint32_t value);
|
static uint32_t print_dec(char *buf, uint32_t value);
|
||||||
|
#endif
|
||||||
|
|
||||||
void greentea_metrics_setup()
|
void greentea_metrics_setup()
|
||||||
{
|
{
|
||||||
|
@ -71,6 +75,7 @@ static void send_heap_info()
|
||||||
greentea_send_kv("max_heap_usage",heap_stats.max_size);
|
greentea_send_kv("max_heap_usage",heap_stats.max_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBED_STACK_STATS_ENABLED) && MBED_STACK_STATS_ENABLED
|
||||||
MBED_UNUSED static void send_stack_info()
|
MBED_UNUSED static void send_stack_info()
|
||||||
{
|
{
|
||||||
mutex->lock();
|
mutex->lock();
|
||||||
|
@ -205,3 +210,5 @@ static uint32_t print_dec(char *buf, uint32_t value)
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
|
@ -574,7 +574,6 @@ int greentea_parse_kv(char *out_key,
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -144,7 +144,6 @@ bool Harness::run(const Specification& specification)
|
||||||
if (handlers->test_teardown) handlers->test_teardown(0, 0, failure);
|
if (handlers->test_teardown) handlers->test_teardown(0, 0, failure);
|
||||||
test_cases = NULL;
|
test_cases = NULL;
|
||||||
exit(1);
|
exit(1);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
notify_testcases();
|
notify_testcases();
|
||||||
|
@ -159,7 +158,6 @@ bool Harness::run(const Specification& specification)
|
||||||
if (handlers->test_teardown) handlers->test_teardown(0, 0, failure);
|
if (handlers->test_teardown) handlers->test_teardown(0, 0, failure);
|
||||||
test_cases = NULL;
|
test_cases = NULL;
|
||||||
exit(1);
|
exit(1);
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -123,7 +123,6 @@ static int32_t utest_us_ticker_run()
|
||||||
callback();
|
callback();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -35,7 +35,7 @@ TARGET_SRC:=$(TARGET_PREFIX)src
|
||||||
TARGET_INC:=$(TARGET_PREFIX)inc
|
TARGET_INC:=$(TARGET_PREFIX)inc
|
||||||
|
|
||||||
# mbed TLS source directory - hidden from mbed via TARGET_IGNORE
|
# mbed TLS source directory - hidden from mbed via TARGET_IGNORE
|
||||||
MBED_TLS_URL:=https://github.com/ARMmbed/mbedtls-restricted.git
|
MBED_TLS_URL:=https://github.com/ARMmbed/mbedtls.git
|
||||||
MBED_TLS_DIR:=TARGET_IGNORE/mbedtls
|
MBED_TLS_DIR:=TARGET_IGNORE/mbedtls
|
||||||
MBED_TLS_API:=$(MBED_TLS_DIR)/include/mbedtls
|
MBED_TLS_API:=$(MBED_TLS_DIR)/include/mbedtls
|
||||||
MBED_TLS_GIT_CFG=$(MBED_TLS_DIR)/.git/config
|
MBED_TLS_GIT_CFG=$(MBED_TLS_DIR)/.git/config
|
||||||
|
@ -66,6 +66,9 @@ deploy: rsync
|
||||||
#
|
#
|
||||||
# Adjusting the default mbed TLS config file to mbed purposes
|
# Adjusting the default mbed TLS config file to mbed purposes
|
||||||
./adjust-config.sh $(MBED_TLS_DIR)/scripts/config.pl $(TARGET_INC)/mbedtls/config.h
|
./adjust-config.sh $(MBED_TLS_DIR)/scripts/config.pl $(TARGET_INC)/mbedtls/config.h
|
||||||
|
#
|
||||||
|
# Copy the trimmed config that does not require entropy source
|
||||||
|
cp $(MBED_TLS_DIR)/configs/config-no-entropy.h $(TARGET_INC)/mbedtls/.
|
||||||
|
|
||||||
update: $(MBED_TLS_GIT_CFG) $(MBED_TLS_HA_GIT_CFG)
|
update: $(MBED_TLS_GIT_CFG) $(MBED_TLS_HA_GIT_CFG)
|
||||||
#
|
#
|
||||||
|
|
|
@ -25,6 +25,36 @@ conf() {
|
||||||
$SCRIPT -f $FILE $@
|
$SCRIPT -f $FILE $@
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_code() {
|
||||||
|
MATCH_PATTERN="$1"
|
||||||
|
shift
|
||||||
|
CODE=$(IFS=""; printf "%s" "$*")
|
||||||
|
|
||||||
|
perl -i -pe \
|
||||||
|
"s/$MATCH_PATTERN/$MATCH_PATTERN$CODE/igs" \
|
||||||
|
"$FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
# add an #ifndef to include config-no-entropy.h when the target does not have
|
||||||
|
# an entropy source we can use.
|
||||||
|
add_code \
|
||||||
|
"#ifndef MBEDTLS_CONFIG_H\n" \
|
||||||
|
"\n" \
|
||||||
|
"#include \"platform\/inc\/platform_mbed.h\"\n" \
|
||||||
|
"\n" \
|
||||||
|
"\/*\n" \
|
||||||
|
" * Only use features that do not require an entropy source when\n" \
|
||||||
|
" * DEVICE_ENTROPY_SOURCE is not defined in mbed OS.\n" \
|
||||||
|
" *\/\n" \
|
||||||
|
"#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)\n" \
|
||||||
|
"#include \"mbedtls\/config-no-entropy.h\"\n" \
|
||||||
|
"#else\n"
|
||||||
|
|
||||||
|
add_code \
|
||||||
|
"#include \"check_config.h\"\n" \
|
||||||
|
"\n" \
|
||||||
|
"#endif \/* !MBEDTLS_ENTROPY_HARDWARE_ALT *\/"
|
||||||
|
|
||||||
# not supported on mbed OS, nor used by mbed Client
|
# not supported on mbed OS, nor used by mbed Client
|
||||||
conf unset MBEDTLS_NET_C
|
conf unset MBEDTLS_NET_C
|
||||||
conf unset MBEDTLS_TIMING_C
|
conf unset MBEDTLS_TIMING_C
|
||||||
|
|
|
@ -256,6 +256,36 @@
|
||||||
#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
|
#error "MBEDTLS_PLATFORM_EXIT_MACRO and MBEDTLS_PLATFORM_STD_EXIT/MBEDTLS_PLATFORM_EXIT_ALT cannot be defined simultaneously"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_ALT) &&\
|
||||||
|
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||||
|
!defined(MBEDTLS_HAVE_TIME) )
|
||||||
|
#error "MBEDTLS_PLATFORM_TIME_ALT defined, but not all prerequisites"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
|
||||||
|
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||||
|
!defined(MBEDTLS_HAVE_TIME) )
|
||||||
|
#error "MBEDTLS_PLATFORM_TIME_MACRO defined, but not all prerequisites"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
|
||||||
|
( !defined(MBEDTLS_PLATFORM_C) ||\
|
||||||
|
!defined(MBEDTLS_HAVE_TIME) )
|
||||||
|
#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO defined, but not all prerequisites"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_MACRO) &&\
|
||||||
|
( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
|
||||||
|
defined(MBEDTLS_PLATFORM_TIME_ALT) )
|
||||||
|
#error "MBEDTLS_PLATFORM_TIME_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO) &&\
|
||||||
|
( defined(MBEDTLS_PLATFORM_STD_TIME) ||\
|
||||||
|
defined(MBEDTLS_PLATFORM_TIME_ALT) )
|
||||||
|
#error "MBEDTLS_PLATFORM_TIME_TYPE_MACRO and MBEDTLS_PLATFORM_STD_TIME/MBEDTLS_PLATFORM_TIME_ALT cannot be defined simultaneously"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
|
#if defined(MBEDTLS_PLATFORM_FPRINTF_ALT) && !defined(MBEDTLS_PLATFORM_C)
|
||||||
#error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites"
|
#error "MBEDTLS_PLATFORM_FPRINTF_ALT defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
@ -352,6 +382,12 @@
|
||||||
#error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
|
#error "MBEDTLS_PLATFORM_STD_EXIT defined, but not all prerequisites"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_PLATFORM_STD_TIME) &&\
|
||||||
|
( !defined(MBEDTLS_PLATFORM_TIME_ALT) ||\
|
||||||
|
!defined(MBEDTLS_HAVE_TIME) )
|
||||||
|
#error "MBEDTLS_PLATFORM_STD_TIME defined, but not all prerequisites"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\
|
#if defined(MBEDTLS_PLATFORM_STD_FPRINTF) &&\
|
||||||
!defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
|
!defined(MBEDTLS_PLATFORM_FPRINTF_ALT)
|
||||||
#error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
|
#error "MBEDTLS_PLATFORM_STD_FPRINTF defined, but not all prerequisites"
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
/**
|
||||||
|
* Minimal configuration of features that do not require an entropy source
|
||||||
|
*
|
||||||
|
* Copyright (C) 2016, ARM Limited, All Rights Reserved
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Minimal configuration of features that do not require an entropy source
|
||||||
|
* Distinguishing reatures:
|
||||||
|
* - no entropy module
|
||||||
|
* - no TLS protocol implementation available due to absence of an entropy
|
||||||
|
* source
|
||||||
|
*
|
||||||
|
* See README.txt for usage instructions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MBEDTLS_CONFIG_H
|
||||||
|
#define MBEDTLS_CONFIG_H
|
||||||
|
|
||||||
|
/* System support */
|
||||||
|
#define MBEDTLS_HAVE_ASM
|
||||||
|
#define MBEDTLS_HAVE_TIME
|
||||||
|
|
||||||
|
/* mbed TLS feature support */
|
||||||
|
#define MBEDTLS_CIPHER_MODE_CBC
|
||||||
|
#define MBEDTLS_CIPHER_PADDING_PKCS7
|
||||||
|
#define MBEDTLS_REMOVE_ARC4_CIPHERSUITES
|
||||||
|
#define MBEDTLS_ECP_DP_SECP256R1_ENABLED
|
||||||
|
#define MBEDTLS_ECP_DP_SECP384R1_ENABLED
|
||||||
|
#define MBEDTLS_ECP_DP_CURVE25519_ENABLED
|
||||||
|
#define MBEDTLS_ECP_NIST_OPTIM
|
||||||
|
#define MBEDTLS_ECDSA_DETERMINISTIC
|
||||||
|
#define MBEDTLS_PK_RSA_ALT_SUPPORT
|
||||||
|
#define MBEDTLS_PKCS1_V15
|
||||||
|
#define MBEDTLS_PKCS1_V21
|
||||||
|
#define MBEDTLS_SELF_TEST
|
||||||
|
#define MBEDTLS_VERSION_FEATURES
|
||||||
|
#define MBEDTLS_X509_CHECK_KEY_USAGE
|
||||||
|
#define MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE
|
||||||
|
|
||||||
|
/* mbed TLS modules */
|
||||||
|
#define MBEDTLS_AES_C
|
||||||
|
#define MBEDTLS_ASN1_PARSE_C
|
||||||
|
#define MBEDTLS_ASN1_WRITE_C
|
||||||
|
#define MBEDTLS_BASE64_C
|
||||||
|
#define MBEDTLS_BIGNUM_C
|
||||||
|
#define MBEDTLS_CCM_C
|
||||||
|
#define MBEDTLS_CIPHER_C
|
||||||
|
#define MBEDTLS_ECDSA_C
|
||||||
|
#define MBEDTLS_ECP_C
|
||||||
|
#define MBEDTLS_ERROR_C
|
||||||
|
#define MBEDTLS_GCM_C
|
||||||
|
#define MBEDTLS_HMAC_DRBG_C
|
||||||
|
#define MBEDTLS_MD_C
|
||||||
|
#define MBEDTLS_OID_C
|
||||||
|
#define MBEDTLS_PEM_PARSE_C
|
||||||
|
#define MBEDTLS_PK_C
|
||||||
|
#define MBEDTLS_PK_PARSE_C
|
||||||
|
#define MBEDTLS_PK_WRITE_C
|
||||||
|
#define MBEDTLS_PLATFORM_C
|
||||||
|
#define MBEDTLS_RSA_C
|
||||||
|
#define MBEDTLS_SHA256_C
|
||||||
|
#define MBEDTLS_SHA512_C
|
||||||
|
#define MBEDTLS_VERSION_C
|
||||||
|
#define MBEDTLS_X509_USE_C
|
||||||
|
#define MBEDTLS_X509_CRT_PARSE_C
|
||||||
|
#define MBEDTLS_X509_CRL_PARSE_C
|
||||||
|
|
||||||
|
#include "check_config.h"
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_CONFIG_H */
|
|
@ -26,6 +26,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef MBEDTLS_CONFIG_H
|
#ifndef MBEDTLS_CONFIG_H
|
||||||
|
|
||||||
|
#include "platform/inc/platform_mbed.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only use features that do not require an entropy source when
|
||||||
|
* DEVICE_ENTROPY_SOURCE is not defined in mbed OS.
|
||||||
|
*/
|
||||||
|
#if !defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||||
|
#include "mbedtls/config-no-entropy.h"
|
||||||
|
#else
|
||||||
#define MBEDTLS_CONFIG_H
|
#define MBEDTLS_CONFIG_H
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE)
|
||||||
|
@ -71,6 +81,10 @@
|
||||||
* The time does not need to be correct, only time differences are used,
|
* The time does not need to be correct, only time differences are used,
|
||||||
* by contrast with MBEDTLS_HAVE_TIME_DATE
|
* by contrast with MBEDTLS_HAVE_TIME_DATE
|
||||||
*
|
*
|
||||||
|
* Defining MBEDTLS_HAVE_TIME allows you to specify MBEDTLS_PLATFORM_TIME_ALT,
|
||||||
|
* MBEDTLS_PLATFORM_TIME_MACRO, MBEDTLS_PLATFORM_TIME_TYPE_MACRO and
|
||||||
|
* MBEDTLS_PLATFORM_STD_TIME.
|
||||||
|
*
|
||||||
* Comment if your system does not support time functions
|
* Comment if your system does not support time functions
|
||||||
*/
|
*/
|
||||||
#define MBEDTLS_HAVE_TIME
|
#define MBEDTLS_HAVE_TIME
|
||||||
|
@ -148,6 +162,8 @@
|
||||||
* \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as
|
* \warning MBEDTLS_PLATFORM_XXX_ALT cannot be defined at the same time as
|
||||||
* MBEDTLS_PLATFORM_XXX_MACRO!
|
* MBEDTLS_PLATFORM_XXX_MACRO!
|
||||||
*
|
*
|
||||||
|
* Requires: MBEDTLS_PLATFORM_TIME_ALT requires MBEDTLS_HAVE_TIME
|
||||||
|
*
|
||||||
* Uncomment a macro to enable alternate implementation of specific base
|
* Uncomment a macro to enable alternate implementation of specific base
|
||||||
* platform function
|
* platform function
|
||||||
*/
|
*/
|
||||||
|
@ -1954,7 +1970,7 @@
|
||||||
* environment:
|
* environment:
|
||||||
* https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS
|
* https://tls.mbed.org/kb/how-to/how-do-i-port-mbed-tls-to-a-new-environment-OS
|
||||||
*
|
*
|
||||||
* Module: library/net.c
|
* Module: library/net_sockets.c
|
||||||
*
|
*
|
||||||
* This module provides networking routines.
|
* This module provides networking routines.
|
||||||
*/
|
*/
|
||||||
|
@ -2503,6 +2519,7 @@
|
||||||
/* Entropy options */
|
/* Entropy options */
|
||||||
//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */
|
//#define MBEDTLS_ENTROPY_MAX_SOURCES 20 /**< Maximum number of sources supported */
|
||||||
//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */
|
//#define MBEDTLS_ENTROPY_MAX_GATHER 128 /**< Maximum amount requested from entropy sources */
|
||||||
|
//#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Default minimum number of bytes required for the hardware entropy source mbedtls_hardware_poll() before entropy is released */
|
||||||
|
|
||||||
/* Memory buffer allocator options */
|
/* Memory buffer allocator options */
|
||||||
//#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */
|
//#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */
|
||||||
|
@ -2512,7 +2529,7 @@
|
||||||
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_STD_CALLOC calloc /**< Default allocator to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_STD_FREE free /**< Default free to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||||
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_STD_PRINTF printf /**< Default printf to use, can be undefined */
|
||||||
/* Note: your snprintf must correclty zero-terminate the buffer! */
|
/* Note: your snprintf must correclty zero-terminate the buffer! */
|
||||||
|
@ -2528,8 +2545,8 @@
|
||||||
//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_CALLOC_MACRO calloc /**< Default allocator macro to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_FREE_MACRO free /**< Default free macro to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_EXIT_MACRO exit /**< Default exit macro to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_TIME_MACRO time /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||||
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_TIME_TYPE_MACRO time_t /**< Default time macro to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||||
//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_FPRINTF_MACRO fprintf /**< Default fprintf macro to use, can be undefined */
|
||||||
//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */
|
//#define MBEDTLS_PLATFORM_PRINTF_MACRO printf /**< Default printf macro to use, can be undefined */
|
||||||
/* Note: your snprintf must correclty zero-terminate the buffer! */
|
/* Note: your snprintf must correclty zero-terminate the buffer! */
|
||||||
|
@ -2563,11 +2580,16 @@
|
||||||
|
|
||||||
/* X509 options */
|
/* X509 options */
|
||||||
//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */
|
//#define MBEDTLS_X509_MAX_INTERMEDIATE_CA 8 /**< Maximum number of intermediate CAs in a verification chain. */
|
||||||
|
//#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512 /**< Maximum length of a path/filename string in bytes including the null terminator character ('\0'). */
|
||||||
|
|
||||||
/* \} name SECTION: Customisation configuration options */
|
/* \} name SECTION: Customisation configuration options */
|
||||||
|
|
||||||
/* Target and application specific configurations */
|
/* Target and application specific configurations */
|
||||||
//#define YOTTA_CFG_MBEDTLS_USER_CONFIG_FILE "target_config.h"
|
//#define YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE "mbedtls/target_config.h"
|
||||||
|
|
||||||
|
#if defined(TARGET_LIKE_MBED) && defined(YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE)
|
||||||
|
#include YOTTA_CFG_MBEDTLS_TARGET_CONFIG_FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Allow user to override any previous default.
|
* Allow user to override any previous default.
|
||||||
|
@ -2584,4 +2606,5 @@
|
||||||
|
|
||||||
#include "check_config.h"
|
#include "check_config.h"
|
||||||
|
|
||||||
|
#endif /* !MBEDTLS_ENTROPY_HARDWARE_ALT */
|
||||||
#endif /* MBEDTLS_CONFIG_H */
|
#endif /* MBEDTLS_CONFIG_H */
|
||||||
|
|
|
@ -255,9 +255,29 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
|
||||||
/**
|
/**
|
||||||
* \brief Checkup routine
|
* \brief Checkup routine
|
||||||
*
|
*
|
||||||
|
* This module self-test also calls the entropy self-test,
|
||||||
|
* mbedtls_entropy_source_self_test();
|
||||||
|
*
|
||||||
* \return 0 if successful, or 1 if a test failed
|
* \return 0 if successful, or 1 if a test failed
|
||||||
*/
|
*/
|
||||||
int mbedtls_entropy_self_test( int verbose );
|
int mbedtls_entropy_self_test( int verbose );
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||||
|
/**
|
||||||
|
* \brief Checkup routine
|
||||||
|
*
|
||||||
|
* Verifies the integrity of the hardware entropy source
|
||||||
|
* provided by the function 'mbedtls_hardware_poll()'.
|
||||||
|
*
|
||||||
|
* Note this is the only hardware entropy source that is known
|
||||||
|
* at link time, and other entropy sources configured
|
||||||
|
* dynamically at runtime by the function
|
||||||
|
* mbedtls_entropy_add_source() will not be tested.
|
||||||
|
*
|
||||||
|
* \return 0 if successful, or 1 if a test failed
|
||||||
|
*/
|
||||||
|
int mbedtls_entropy_source_self_test( int verbose );
|
||||||
|
#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */
|
||||||
#endif /* MBEDTLS_SELF_TEST */
|
#endif /* MBEDTLS_SELF_TEST */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -41,7 +41,9 @@ extern "C" {
|
||||||
#define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
|
#define MBEDTLS_ENTROPY_MIN_PLATFORM 32 /**< Minimum for platform source */
|
||||||
#define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
|
#define MBEDTLS_ENTROPY_MIN_HAVEGE 32 /**< Minimum for HAVEGE */
|
||||||
#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
|
#define MBEDTLS_ENTROPY_MIN_HARDCLOCK 4 /**< Minimum for mbedtls_timing_hardclock() */
|
||||||
|
#if !defined(MBEDTLS_ENTROPY_MIN_HARDWARE)
|
||||||
#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
|
#define MBEDTLS_ENTROPY_MIN_HARDWARE 32 /**< Minimum for the hardware source */
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Entropy poll callback that provides 0 entropy.
|
* \brief Entropy poll callback that provides 0 entropy.
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
/**
|
/**
|
||||||
* \file net.h
|
* \file net.h
|
||||||
*
|
*
|
||||||
* \brief Network communication functions
|
* \brief Deprecated header file that includes mbedtls/net_sockets.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
@ -19,207 +19,13 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*
|
*
|
||||||
* This file is part of mbed TLS (https://tls.mbed.org)
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
|
*
|
||||||
|
* \deprecated Superseded by mbedtls/net_sockets.h
|
||||||
*/
|
*/
|
||||||
#ifndef MBEDTLS_NET_H
|
|
||||||
#define MBEDTLS_NET_H
|
|
||||||
|
|
||||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
#if !defined(MBEDTLS_DEPRECATED_REMOVED)
|
||||||
#include "config.h"
|
#include "mbedtls/net_sockets.h"
|
||||||
#else
|
#if defined(MBEDTLS_DEPRECATED_WARNING)
|
||||||
#include MBEDTLS_CONFIG_FILE
|
#warning "Deprecated header file: Superseded by mbedtls/net_sockets.h"
|
||||||
#endif
|
#endif /* MBEDTLS_DEPRECATED_WARNING */
|
||||||
|
#endif /* !MBEDTLS_DEPRECATED_REMOVED */
|
||||||
#include "ssl.h"
|
|
||||||
|
|
||||||
#include <stddef.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */
|
|
||||||
#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */
|
|
||||||
#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */
|
|
||||||
#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */
|
|
||||||
#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */
|
|
||||||
#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */
|
|
||||||
#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */
|
|
||||||
#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */
|
|
||||||
#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */
|
|
||||||
#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */
|
|
||||||
#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */
|
|
||||||
|
|
||||||
#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */
|
|
||||||
|
|
||||||
#define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */
|
|
||||||
#define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
extern "C" {
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Wrapper type for sockets.
|
|
||||||
*
|
|
||||||
* Currently backed by just a file descriptor, but might be more in the future
|
|
||||||
* (eg two file descriptors for combined IPv4 + IPv6 support, or additional
|
|
||||||
* structures for hand-made UDP demultiplexing).
|
|
||||||
*/
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int fd; /**< The underlying file descriptor */
|
|
||||||
}
|
|
||||||
mbedtls_net_context;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Initialize a context
|
|
||||||
* Just makes the context ready to be used or freed safely.
|
|
||||||
*
|
|
||||||
* \param ctx Context to initialize
|
|
||||||
*/
|
|
||||||
void mbedtls_net_init( mbedtls_net_context *ctx );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Initiate a connection with host:port in the given protocol
|
|
||||||
*
|
|
||||||
* \param ctx Socket to use
|
|
||||||
* \param host Host to connect to
|
|
||||||
* \param port Port to connect to
|
|
||||||
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
|
||||||
*
|
|
||||||
* \return 0 if successful, or one of:
|
|
||||||
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
|
||||||
* MBEDTLS_ERR_NET_UNKNOWN_HOST,
|
|
||||||
* MBEDTLS_ERR_NET_CONNECT_FAILED
|
|
||||||
*
|
|
||||||
* \note Sets the socket in connected mode even with UDP.
|
|
||||||
*/
|
|
||||||
int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Create a receiving socket on bind_ip:port in the chosen
|
|
||||||
* protocol. If bind_ip == NULL, all interfaces are bound.
|
|
||||||
*
|
|
||||||
* \param ctx Socket to use
|
|
||||||
* \param bind_ip IP to bind to, can be NULL
|
|
||||||
* \param port Port number to use
|
|
||||||
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
|
||||||
*
|
|
||||||
* \return 0 if successful, or one of:
|
|
||||||
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
|
||||||
* MBEDTLS_ERR_NET_BIND_FAILED,
|
|
||||||
* MBEDTLS_ERR_NET_LISTEN_FAILED
|
|
||||||
*
|
|
||||||
* \note Regardless of the protocol, opens the sockets and binds it.
|
|
||||||
* In addition, make the socket listening if protocol is TCP.
|
|
||||||
*/
|
|
||||||
int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Accept a connection from a remote client
|
|
||||||
*
|
|
||||||
* \param bind_ctx Relevant socket
|
|
||||||
* \param client_ctx Will contain the connected client socket
|
|
||||||
* \param client_ip Will contain the client IP address
|
|
||||||
* \param buf_size Size of the client_ip buffer
|
|
||||||
* \param ip_len Will receive the size of the client IP written
|
|
||||||
*
|
|
||||||
* \return 0 if successful, or
|
|
||||||
* MBEDTLS_ERR_NET_ACCEPT_FAILED, or
|
|
||||||
* MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small,
|
|
||||||
* MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to
|
|
||||||
* non-blocking and accept() would block.
|
|
||||||
*/
|
|
||||||
int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
|
|
||||||
mbedtls_net_context *client_ctx,
|
|
||||||
void *client_ip, size_t buf_size, size_t *ip_len );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the socket blocking
|
|
||||||
*
|
|
||||||
* \param ctx Socket to set
|
|
||||||
*
|
|
||||||
* \return 0 if successful, or a non-zero error code
|
|
||||||
*/
|
|
||||||
int mbedtls_net_set_block( mbedtls_net_context *ctx );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set the socket non-blocking
|
|
||||||
*
|
|
||||||
* \param ctx Socket to set
|
|
||||||
*
|
|
||||||
* \return 0 if successful, or a non-zero error code
|
|
||||||
*/
|
|
||||||
int mbedtls_net_set_nonblock( mbedtls_net_context *ctx );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Portable usleep helper
|
|
||||||
*
|
|
||||||
* \param usec Amount of microseconds to sleep
|
|
||||||
*
|
|
||||||
* \note Real amount of time slept will not be less than
|
|
||||||
* select()'s timeout granularity (typically, 10ms).
|
|
||||||
*/
|
|
||||||
void mbedtls_net_usleep( unsigned long usec );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Read at most 'len' characters. If no error occurs,
|
|
||||||
* the actual amount read is returned.
|
|
||||||
*
|
|
||||||
* \param ctx Socket
|
|
||||||
* \param buf The buffer to write to
|
|
||||||
* \param len Maximum length of the buffer
|
|
||||||
*
|
|
||||||
* \return the number of bytes received,
|
|
||||||
* or a non-zero error code; with a non-blocking socket,
|
|
||||||
* MBEDTLS_ERR_SSL_WANT_READ indicates read() would block.
|
|
||||||
*/
|
|
||||||
int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Write at most 'len' characters. If no error occurs,
|
|
||||||
* the actual amount read is returned.
|
|
||||||
*
|
|
||||||
* \param ctx Socket
|
|
||||||
* \param buf The buffer to read from
|
|
||||||
* \param len The length of the buffer
|
|
||||||
*
|
|
||||||
* \return the number of bytes sent,
|
|
||||||
* or a non-zero error code; with a non-blocking socket,
|
|
||||||
* MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block.
|
|
||||||
*/
|
|
||||||
int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Read at most 'len' characters, blocking for at most
|
|
||||||
* 'timeout' seconds. If no error occurs, the actual amount
|
|
||||||
* read is returned.
|
|
||||||
*
|
|
||||||
* \param ctx Socket
|
|
||||||
* \param buf The buffer to write to
|
|
||||||
* \param len Maximum length of the buffer
|
|
||||||
* \param timeout Maximum number of milliseconds to wait for data
|
|
||||||
* 0 means no timeout (wait forever)
|
|
||||||
*
|
|
||||||
* \return the number of bytes received,
|
|
||||||
* or a non-zero error code:
|
|
||||||
* MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out,
|
|
||||||
* MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal.
|
|
||||||
*
|
|
||||||
* \note This function will block (until data becomes available or
|
|
||||||
* timeout is reached) even if the socket is set to
|
|
||||||
* non-blocking. Handling timeouts with non-blocking reads
|
|
||||||
* requires a different strategy.
|
|
||||||
*/
|
|
||||||
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
|
|
||||||
uint32_t timeout );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Gracefully shutdown the connection and free associated data
|
|
||||||
*
|
|
||||||
* \param ctx The context to free
|
|
||||||
*/
|
|
||||||
void mbedtls_net_free( mbedtls_net_context *ctx );
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* net.h */
|
|
||||||
|
|
|
@ -0,0 +1,225 @@
|
||||||
|
/**
|
||||||
|
* \file net_sockets.h
|
||||||
|
*
|
||||||
|
* \brief Network communication functions
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
|
*/
|
||||||
|
#ifndef MBEDTLS_NET_SOCKETS_H
|
||||||
|
#define MBEDTLS_NET_SOCKETS_H
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||||
|
#include "config.h"
|
||||||
|
#else
|
||||||
|
#include MBEDTLS_CONFIG_FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "ssl.h"
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#define MBEDTLS_ERR_NET_SOCKET_FAILED -0x0042 /**< Failed to open a socket. */
|
||||||
|
#define MBEDTLS_ERR_NET_CONNECT_FAILED -0x0044 /**< The connection to the given server / port failed. */
|
||||||
|
#define MBEDTLS_ERR_NET_BIND_FAILED -0x0046 /**< Binding of the socket failed. */
|
||||||
|
#define MBEDTLS_ERR_NET_LISTEN_FAILED -0x0048 /**< Could not listen on the socket. */
|
||||||
|
#define MBEDTLS_ERR_NET_ACCEPT_FAILED -0x004A /**< Could not accept the incoming connection. */
|
||||||
|
#define MBEDTLS_ERR_NET_RECV_FAILED -0x004C /**< Reading information from the socket failed. */
|
||||||
|
#define MBEDTLS_ERR_NET_SEND_FAILED -0x004E /**< Sending information through the socket failed. */
|
||||||
|
#define MBEDTLS_ERR_NET_CONN_RESET -0x0050 /**< Connection was reset by peer. */
|
||||||
|
#define MBEDTLS_ERR_NET_UNKNOWN_HOST -0x0052 /**< Failed to get an IP address for the given hostname. */
|
||||||
|
#define MBEDTLS_ERR_NET_BUFFER_TOO_SMALL -0x0043 /**< Buffer is too small to hold the data. */
|
||||||
|
#define MBEDTLS_ERR_NET_INVALID_CONTEXT -0x0045 /**< The context is invalid, eg because it was free()ed. */
|
||||||
|
|
||||||
|
#define MBEDTLS_NET_LISTEN_BACKLOG 10 /**< The backlog that listen() should use. */
|
||||||
|
|
||||||
|
#define MBEDTLS_NET_PROTO_TCP 0 /**< The TCP transport protocol */
|
||||||
|
#define MBEDTLS_NET_PROTO_UDP 1 /**< The UDP transport protocol */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper type for sockets.
|
||||||
|
*
|
||||||
|
* Currently backed by just a file descriptor, but might be more in the future
|
||||||
|
* (eg two file descriptors for combined IPv4 + IPv6 support, or additional
|
||||||
|
* structures for hand-made UDP demultiplexing).
|
||||||
|
*/
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int fd; /**< The underlying file descriptor */
|
||||||
|
}
|
||||||
|
mbedtls_net_context;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Initialize a context
|
||||||
|
* Just makes the context ready to be used or freed safely.
|
||||||
|
*
|
||||||
|
* \param ctx Context to initialize
|
||||||
|
*/
|
||||||
|
void mbedtls_net_init( mbedtls_net_context *ctx );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Initiate a connection with host:port in the given protocol
|
||||||
|
*
|
||||||
|
* \param ctx Socket to use
|
||||||
|
* \param host Host to connect to
|
||||||
|
* \param port Port to connect to
|
||||||
|
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
||||||
|
*
|
||||||
|
* \return 0 if successful, or one of:
|
||||||
|
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
||||||
|
* MBEDTLS_ERR_NET_UNKNOWN_HOST,
|
||||||
|
* MBEDTLS_ERR_NET_CONNECT_FAILED
|
||||||
|
*
|
||||||
|
* \note Sets the socket in connected mode even with UDP.
|
||||||
|
*/
|
||||||
|
int mbedtls_net_connect( mbedtls_net_context *ctx, const char *host, const char *port, int proto );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Create a receiving socket on bind_ip:port in the chosen
|
||||||
|
* protocol. If bind_ip == NULL, all interfaces are bound.
|
||||||
|
*
|
||||||
|
* \param ctx Socket to use
|
||||||
|
* \param bind_ip IP to bind to, can be NULL
|
||||||
|
* \param port Port number to use
|
||||||
|
* \param proto Protocol: MBEDTLS_NET_PROTO_TCP or MBEDTLS_NET_PROTO_UDP
|
||||||
|
*
|
||||||
|
* \return 0 if successful, or one of:
|
||||||
|
* MBEDTLS_ERR_NET_SOCKET_FAILED,
|
||||||
|
* MBEDTLS_ERR_NET_BIND_FAILED,
|
||||||
|
* MBEDTLS_ERR_NET_LISTEN_FAILED
|
||||||
|
*
|
||||||
|
* \note Regardless of the protocol, opens the sockets and binds it.
|
||||||
|
* In addition, make the socket listening if protocol is TCP.
|
||||||
|
*/
|
||||||
|
int mbedtls_net_bind( mbedtls_net_context *ctx, const char *bind_ip, const char *port, int proto );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Accept a connection from a remote client
|
||||||
|
*
|
||||||
|
* \param bind_ctx Relevant socket
|
||||||
|
* \param client_ctx Will contain the connected client socket
|
||||||
|
* \param client_ip Will contain the client IP address
|
||||||
|
* \param buf_size Size of the client_ip buffer
|
||||||
|
* \param ip_len Will receive the size of the client IP written
|
||||||
|
*
|
||||||
|
* \return 0 if successful, or
|
||||||
|
* MBEDTLS_ERR_NET_ACCEPT_FAILED, or
|
||||||
|
* MBEDTLS_ERR_NET_BUFFER_TOO_SMALL if buf_size is too small,
|
||||||
|
* MBEDTLS_ERR_SSL_WANT_READ if bind_fd was set to
|
||||||
|
* non-blocking and accept() would block.
|
||||||
|
*/
|
||||||
|
int mbedtls_net_accept( mbedtls_net_context *bind_ctx,
|
||||||
|
mbedtls_net_context *client_ctx,
|
||||||
|
void *client_ip, size_t buf_size, size_t *ip_len );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the socket blocking
|
||||||
|
*
|
||||||
|
* \param ctx Socket to set
|
||||||
|
*
|
||||||
|
* \return 0 if successful, or a non-zero error code
|
||||||
|
*/
|
||||||
|
int mbedtls_net_set_block( mbedtls_net_context *ctx );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set the socket non-blocking
|
||||||
|
*
|
||||||
|
* \param ctx Socket to set
|
||||||
|
*
|
||||||
|
* \return 0 if successful, or a non-zero error code
|
||||||
|
*/
|
||||||
|
int mbedtls_net_set_nonblock( mbedtls_net_context *ctx );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Portable usleep helper
|
||||||
|
*
|
||||||
|
* \param usec Amount of microseconds to sleep
|
||||||
|
*
|
||||||
|
* \note Real amount of time slept will not be less than
|
||||||
|
* select()'s timeout granularity (typically, 10ms).
|
||||||
|
*/
|
||||||
|
void mbedtls_net_usleep( unsigned long usec );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Read at most 'len' characters. If no error occurs,
|
||||||
|
* the actual amount read is returned.
|
||||||
|
*
|
||||||
|
* \param ctx Socket
|
||||||
|
* \param buf The buffer to write to
|
||||||
|
* \param len Maximum length of the buffer
|
||||||
|
*
|
||||||
|
* \return the number of bytes received,
|
||||||
|
* or a non-zero error code; with a non-blocking socket,
|
||||||
|
* MBEDTLS_ERR_SSL_WANT_READ indicates read() would block.
|
||||||
|
*/
|
||||||
|
int mbedtls_net_recv( void *ctx, unsigned char *buf, size_t len );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Write at most 'len' characters. If no error occurs,
|
||||||
|
* the actual amount read is returned.
|
||||||
|
*
|
||||||
|
* \param ctx Socket
|
||||||
|
* \param buf The buffer to read from
|
||||||
|
* \param len The length of the buffer
|
||||||
|
*
|
||||||
|
* \return the number of bytes sent,
|
||||||
|
* or a non-zero error code; with a non-blocking socket,
|
||||||
|
* MBEDTLS_ERR_SSL_WANT_WRITE indicates write() would block.
|
||||||
|
*/
|
||||||
|
int mbedtls_net_send( void *ctx, const unsigned char *buf, size_t len );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Read at most 'len' characters, blocking for at most
|
||||||
|
* 'timeout' seconds. If no error occurs, the actual amount
|
||||||
|
* read is returned.
|
||||||
|
*
|
||||||
|
* \param ctx Socket
|
||||||
|
* \param buf The buffer to write to
|
||||||
|
* \param len Maximum length of the buffer
|
||||||
|
* \param timeout Maximum number of milliseconds to wait for data
|
||||||
|
* 0 means no timeout (wait forever)
|
||||||
|
*
|
||||||
|
* \return the number of bytes received,
|
||||||
|
* or a non-zero error code:
|
||||||
|
* MBEDTLS_ERR_SSL_TIMEOUT if the operation timed out,
|
||||||
|
* MBEDTLS_ERR_SSL_WANT_READ if interrupted by a signal.
|
||||||
|
*
|
||||||
|
* \note This function will block (until data becomes available or
|
||||||
|
* timeout is reached) even if the socket is set to
|
||||||
|
* non-blocking. Handling timeouts with non-blocking reads
|
||||||
|
* requires a different strategy.
|
||||||
|
*/
|
||||||
|
int mbedtls_net_recv_timeout( void *ctx, unsigned char *buf, size_t len,
|
||||||
|
uint32_t timeout );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Gracefully shutdown the connection and free associated data
|
||||||
|
*
|
||||||
|
* \param ctx The context to free
|
||||||
|
*/
|
||||||
|
void mbedtls_net_free( mbedtls_net_context *ctx );
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* net_sockets.h */
|
|
@ -29,6 +29,10 @@
|
||||||
#include MBEDTLS_CONFIG_FILE
|
#include MBEDTLS_CONFIG_FILE
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
|
#include "mbedtls/platform_time.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
@ -243,39 +247,6 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) );
|
||||||
#define MBEDTLS_EXIT_FAILURE 1
|
#define MBEDTLS_EXIT_FAILURE 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
|
||||||
* The time_t datatype
|
|
||||||
*/
|
|
||||||
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
|
|
||||||
typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
|
|
||||||
#else
|
|
||||||
/* For time_t */
|
|
||||||
#include <time.h>
|
|
||||||
typedef time_t mbedtls_time_t;
|
|
||||||
#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* The function pointers for time
|
|
||||||
*/
|
|
||||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
|
||||||
extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Set your own time function pointer
|
|
||||||
*
|
|
||||||
* \param time_func the time function implementation
|
|
||||||
*
|
|
||||||
* \return 0
|
|
||||||
*/
|
|
||||||
int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) );
|
|
||||||
#else
|
|
||||||
#if defined(MBEDTLS_PLATFORM_TIME_MACRO)
|
|
||||||
#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
|
|
||||||
#else
|
|
||||||
#define mbedtls_time time
|
|
||||||
#endif /* MBEDTLS_PLATFORM_TIME_MACRO */
|
|
||||||
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The function pointers for reading from and writing a seed file to
|
* The function pointers for reading from and writing a seed file to
|
||||||
* Non-Volatile storage (NV) in a platform-independent way
|
* Non-Volatile storage (NV) in a platform-independent way
|
||||||
|
|
|
@ -0,0 +1,81 @@
|
||||||
|
/**
|
||||||
|
* \file platform_time.h
|
||||||
|
*
|
||||||
|
* \brief mbed TLS Platform time abstraction
|
||||||
|
*
|
||||||
|
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
|
*/
|
||||||
|
#ifndef MBEDTLS_PLATFORM_TIME_H
|
||||||
|
#define MBEDTLS_PLATFORM_TIME_H
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||||
|
#include "config.h"
|
||||||
|
#else
|
||||||
|
#include MBEDTLS_CONFIG_FILE
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
extern "C" {
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \name SECTION: Module settings
|
||||||
|
*
|
||||||
|
* The configuration options you can set for this module are in this section.
|
||||||
|
* Either change them in config.h or define them on the compiler command line.
|
||||||
|
* \{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The time_t datatype
|
||||||
|
*/
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_TYPE_MACRO)
|
||||||
|
typedef MBEDTLS_PLATFORM_TIME_TYPE_MACRO mbedtls_time_t;
|
||||||
|
#else
|
||||||
|
/* For time_t */
|
||||||
|
#include <time.h>
|
||||||
|
typedef time_t mbedtls_time_t;
|
||||||
|
#endif /* MBEDTLS_PLATFORM_TIME_TYPE_MACRO */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The function pointers for time
|
||||||
|
*/
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||||
|
extern mbedtls_time_t (*mbedtls_time)( mbedtls_time_t* time );
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Set your own time function pointer
|
||||||
|
*
|
||||||
|
* \param time_func the time function implementation
|
||||||
|
*
|
||||||
|
* \return 0
|
||||||
|
*/
|
||||||
|
int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time ) );
|
||||||
|
#else
|
||||||
|
#if defined(MBEDTLS_PLATFORM_TIME_MACRO)
|
||||||
|
#define mbedtls_time MBEDTLS_PLATFORM_TIME_MACRO
|
||||||
|
#else
|
||||||
|
#define mbedtls_time time
|
||||||
|
#endif /* MBEDTLS_PLATFORM_TIME_MACRO */
|
||||||
|
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
||||||
|
|
||||||
|
#ifdef __cplusplus
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif /* platform_time.h */
|
|
@ -99,7 +99,7 @@ typedef struct
|
||||||
mbedtls_mpi Vf; /*!< cached un-blinding value */
|
mbedtls_mpi Vf; /*!< cached un-blinding value */
|
||||||
|
|
||||||
int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
|
int padding; /*!< MBEDTLS_RSA_PKCS_V15 for 1.5 padding and
|
||||||
RSA_PKCS_v21 for OAEP/PSS */
|
MBEDTLS_RSA_PKCS_v21 for OAEP/PSS */
|
||||||
int hash_id; /*!< Hash identifier of mbedtls_md_type_t as
|
int hash_id; /*!< Hash identifier of mbedtls_md_type_t as
|
||||||
specified in the mbedtls_md.h header file
|
specified in the mbedtls_md.h header file
|
||||||
for the EME-OAEP and EMSA-PSS
|
for the EME-OAEP and EMSA-PSS
|
||||||
|
|
|
@ -52,7 +52,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_HAVE_TIME)
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
#include <time.h>
|
#include "mbedtls/platform_time.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1105,9 +1105,10 @@ void mbedtls_ssl_conf_dbg( mbedtls_ssl_config *conf,
|
||||||
* \c mbedtls_ssl_recv_t and \c mbedtls_ssl_recv_timeout_t for
|
* \c mbedtls_ssl_recv_t and \c mbedtls_ssl_recv_timeout_t for
|
||||||
* the conventions those callbacks must follow.
|
* the conventions those callbacks must follow.
|
||||||
*
|
*
|
||||||
* \note On some platforms, net.c provides \c mbedtls_net_send(),
|
* \note On some platforms, net_sockets.c provides
|
||||||
* \c mbedtls_net_recv() and \c mbedtls_net_recv_timeout()
|
* \c mbedtls_net_send(), \c mbedtls_net_recv() and
|
||||||
* that are suitable to be used here.
|
* \c mbedtls_net_recv_timeout() that are suitable to be used
|
||||||
|
* here.
|
||||||
*/
|
*/
|
||||||
void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
|
void mbedtls_ssl_set_bio( mbedtls_ssl_context *ssl,
|
||||||
void *p_bio,
|
void *p_bio,
|
||||||
|
|
|
@ -120,6 +120,10 @@ mbedtls_x509_crt_profile;
|
||||||
#define MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN 32
|
#define MBEDTLS_X509_RFC5280_MAX_SERIAL_LEN 32
|
||||||
#define MBEDTLS_X509_RFC5280_UTC_TIME_LEN 15
|
#define MBEDTLS_X509_RFC5280_UTC_TIME_LEN 15
|
||||||
|
|
||||||
|
#if !defined( MBEDTLS_X509_MAX_FILE_PATH_LEN )
|
||||||
|
#define MBEDTLS_X509_MAX_FILE_PATH_LEN 512
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Container for writing a certificate (CRT)
|
* Container for writing a certificate (CRT)
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -0,0 +1,22 @@
|
||||||
|
/**
|
||||||
|
* Copyright (C) 2006-2016, ARM Limited, All Rights Reserved
|
||||||
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||||
|
* not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||||
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*
|
||||||
|
* This file is part of mbed TLS (https://tls.mbed.org)
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(DEVICE_TRNG)
|
||||||
|
#define MBEDTLS_ENTROPY_HARDWARE_ALT
|
||||||
|
#endif
|
|
@ -0,0 +1,29 @@
|
||||||
|
/* mbed Microcontroller Library
|
||||||
|
* Copyright (c) 2016 ARM Limited
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#if defined(DEVICE_TRNG)
|
||||||
|
|
||||||
|
#include "hal/trng_api.h"
|
||||||
|
|
||||||
|
int mbedtls_hardware_poll( void *data, unsigned char *output, size_t len, size_t *olen ) {
|
||||||
|
trng_t trng_obj;
|
||||||
|
trng_init(&trng_obj);
|
||||||
|
int ret = trng_get_bytes(&trng_obj, output, len, olen);
|
||||||
|
trng_free(&trng_obj);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
|
@ -68,9 +68,10 @@ OBJS_X509= certs.o pkcs11.o x509.o \
|
||||||
x509_create.o x509_crl.o x509_crt.o \
|
x509_create.o x509_crl.o x509_crt.o \
|
||||||
x509_csr.o x509write_crt.o x509write_csr.o
|
x509_csr.o x509write_crt.o x509write_csr.o
|
||||||
|
|
||||||
OBJS_TLS= debug.o net.o ssl_cache.o \
|
OBJS_TLS= debug.o net_sockets.o \
|
||||||
ssl_ciphersuites.o ssl_cli.o \
|
ssl_cache.o ssl_ciphersuites.o \
|
||||||
ssl_cookie.o ssl_srv.o ssl_ticket.o \
|
ssl_cli.o ssl_cookie.o \
|
||||||
|
ssl_srv.o ssl_ticket.o \
|
||||||
ssl_tls.o
|
ssl_tls.o
|
||||||
|
|
||||||
.SILENT:
|
.SILENT:
|
||||||
|
|
|
@ -60,16 +60,43 @@ int mbedtls_asn1_write_len( unsigned char **p, unsigned char *start, size_t len
|
||||||
return( 2 );
|
return( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( len <= 0xFFFF )
|
||||||
|
{
|
||||||
if( *p - start < 3 )
|
if( *p - start < 3 )
|
||||||
return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
||||||
|
|
||||||
// We assume we never have lengths larger than 65535 bytes
|
*--(*p) = ( len ) & 0xFF;
|
||||||
//
|
*--(*p) = ( len >> 8 ) & 0xFF;
|
||||||
*--(*p) = len % 256;
|
|
||||||
*--(*p) = ( len / 256 ) % 256;
|
|
||||||
*--(*p) = 0x82;
|
*--(*p) = 0x82;
|
||||||
|
|
||||||
return( 3 );
|
return( 3 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( len <= 0xFFFFFF )
|
||||||
|
{
|
||||||
|
if( *p - start < 4 )
|
||||||
|
return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
||||||
|
|
||||||
|
*--(*p) = ( len ) & 0xFF;
|
||||||
|
*--(*p) = ( len >> 8 ) & 0xFF;
|
||||||
|
*--(*p) = ( len >> 16 ) & 0xFF;
|
||||||
|
*--(*p) = 0x83;
|
||||||
|
return( 4 );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( len <= 0xFFFFFFFF )
|
||||||
|
{
|
||||||
|
if( *p - start < 5 )
|
||||||
|
return( MBEDTLS_ERR_ASN1_BUF_TOO_SMALL );
|
||||||
|
|
||||||
|
*--(*p) = ( len ) & 0xFF;
|
||||||
|
*--(*p) = ( len >> 8 ) & 0xFF;
|
||||||
|
*--(*p) = ( len >> 16 ) & 0xFF;
|
||||||
|
*--(*p) = ( len >> 24 ) & 0xFF;
|
||||||
|
*--(*p) = 0x84;
|
||||||
|
return( 5 );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( MBEDTLS_ERR_ASN1_INVALID_LENGTH );
|
||||||
}
|
}
|
||||||
|
|
||||||
int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag )
|
int mbedtls_asn1_write_tag( unsigned char **p, unsigned char *start, unsigned char tag )
|
||||||
|
|
|
@ -42,6 +42,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||||
|
#include "mbedtls/platform.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_SELF_TEST)
|
#if defined(MBEDTLS_SELF_TEST)
|
||||||
#if defined(MBEDTLS_PLATFORM_C)
|
#if defined(MBEDTLS_PLATFORM_C)
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
|
@ -452,6 +456,7 @@ int mbedtls_entropy_update_seed_file( mbedtls_entropy_context *ctx, const char *
|
||||||
#endif /* MBEDTLS_FS_IO */
|
#endif /* MBEDTLS_FS_IO */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SELF_TEST)
|
#if defined(MBEDTLS_SELF_TEST)
|
||||||
|
#if !defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||||
/*
|
/*
|
||||||
* Dummy source function
|
* Dummy source function
|
||||||
*/
|
*/
|
||||||
|
@ -465,6 +470,105 @@ static int entropy_dummy_source( void *data, unsigned char *output,
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
#endif /* !MBEDTLS_TEST_NULL_ENTROPY */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||||
|
|
||||||
|
static int mbedtls_entropy_source_self_test_gather( unsigned char *buf, size_t buf_len )
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
size_t entropy_len = 0;
|
||||||
|
size_t olen = 0;
|
||||||
|
size_t attempts = buf_len;
|
||||||
|
|
||||||
|
while( attempts > 0 && entropy_len < buf_len )
|
||||||
|
{
|
||||||
|
if( ( ret = mbedtls_hardware_poll( NULL, buf + entropy_len,
|
||||||
|
buf_len - entropy_len, &olen ) ) != 0 )
|
||||||
|
return( ret );
|
||||||
|
|
||||||
|
entropy_len += olen;
|
||||||
|
attempts--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if( entropy_len < buf_len )
|
||||||
|
{
|
||||||
|
ret = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return( ret );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int mbedtls_entropy_source_self_test_check_bits( const unsigned char *buf,
|
||||||
|
size_t buf_len )
|
||||||
|
{
|
||||||
|
unsigned char set= 0xFF;
|
||||||
|
unsigned char unset = 0x00;
|
||||||
|
size_t i;
|
||||||
|
|
||||||
|
for( i = 0; i < buf_len; i++ )
|
||||||
|
{
|
||||||
|
set &= buf[i];
|
||||||
|
unset |= buf[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return( set == 0xFF || unset == 0x00 );
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* A test to ensure hat the entropy sources are functioning correctly
|
||||||
|
* and there is no obvious failure. The test performs the following checks:
|
||||||
|
* - The entropy source is not providing only 0s (all bits unset) or 1s (all
|
||||||
|
* bits set).
|
||||||
|
* - The entropy source is not providing values in a pattern. Because the
|
||||||
|
* hardware could be providing data in an arbitrary length, this check polls
|
||||||
|
* the hardware entropy source twice and compares the result to ensure they
|
||||||
|
* are not equal.
|
||||||
|
* - The error code returned by the entropy source is not an error.
|
||||||
|
*/
|
||||||
|
int mbedtls_entropy_source_self_test( int verbose )
|
||||||
|
{
|
||||||
|
int ret = 0;
|
||||||
|
unsigned char buf0[2 * sizeof( unsigned long long int )];
|
||||||
|
unsigned char buf1[2 * sizeof( unsigned long long int )];
|
||||||
|
|
||||||
|
if( verbose != 0 )
|
||||||
|
mbedtls_printf( " ENTROPY_BIAS test: " );
|
||||||
|
|
||||||
|
memset( buf0, 0x00, sizeof( buf0 ) );
|
||||||
|
memset( buf1, 0x00, sizeof( buf1 ) );
|
||||||
|
|
||||||
|
if( ( ret = mbedtls_entropy_source_self_test_gather( buf0, sizeof( buf0 ) ) ) != 0 )
|
||||||
|
goto cleanup;
|
||||||
|
if( ( ret = mbedtls_entropy_source_self_test_gather( buf1, sizeof( buf1 ) ) ) != 0 )
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Make sure that the returned values are not all 0 or 1 */
|
||||||
|
if( ( ret = mbedtls_entropy_source_self_test_check_bits( buf0, sizeof( buf0 ) ) ) != 0 )
|
||||||
|
goto cleanup;
|
||||||
|
if( ( ret = mbedtls_entropy_source_self_test_check_bits( buf1, sizeof( buf1 ) ) ) != 0 )
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
/* Make sure that the entropy source is not returning values in a
|
||||||
|
* pattern */
|
||||||
|
ret = memcmp( buf0, buf1, sizeof( buf0 ) ) == 0;
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
if( verbose != 0 )
|
||||||
|
{
|
||||||
|
if( ret != 0 )
|
||||||
|
mbedtls_printf( "failed\n" );
|
||||||
|
else
|
||||||
|
mbedtls_printf( "passed\n" );
|
||||||
|
|
||||||
|
mbedtls_printf( "\n" );
|
||||||
|
}
|
||||||
|
|
||||||
|
return( ret != 0 );
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_ENTROPY_HARDWARE_ALT */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The actual entropy quality is hard to test, but we can at least
|
* The actual entropy quality is hard to test, but we can at least
|
||||||
|
@ -473,15 +577,18 @@ static int entropy_dummy_source( void *data, unsigned char *output,
|
||||||
*/
|
*/
|
||||||
int mbedtls_entropy_self_test( int verbose )
|
int mbedtls_entropy_self_test( int verbose )
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 1;
|
||||||
|
#if !defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||||
mbedtls_entropy_context ctx;
|
mbedtls_entropy_context ctx;
|
||||||
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
|
unsigned char buf[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
|
||||||
unsigned char acc[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
|
unsigned char acc[MBEDTLS_ENTROPY_BLOCK_SIZE] = { 0 };
|
||||||
size_t i, j;
|
size_t i, j;
|
||||||
|
#endif /* !MBEDTLS_TEST_NULL_ENTROPY */
|
||||||
|
|
||||||
if( verbose != 0 )
|
if( verbose != 0 )
|
||||||
mbedtls_printf( " ENTROPY test: " );
|
mbedtls_printf( " ENTROPY test: " );
|
||||||
|
|
||||||
|
#if !defined(MBEDTLS_TEST_NULL_ENTROPY)
|
||||||
mbedtls_entropy_init( &ctx );
|
mbedtls_entropy_init( &ctx );
|
||||||
|
|
||||||
/* First do a gather to make sure we have default sources */
|
/* First do a gather to make sure we have default sources */
|
||||||
|
@ -522,8 +629,14 @@ int mbedtls_entropy_self_test( int verbose )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_ENTROPY_HARDWARE_ALT)
|
||||||
|
if( ( ret = mbedtls_entropy_source_self_test( 0 ) ) != 0 )
|
||||||
|
goto cleanup;
|
||||||
|
#endif
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
mbedtls_entropy_free( &ctx );
|
mbedtls_entropy_free( &ctx );
|
||||||
|
#endif /* !MBEDTLS_TEST_NULL_ENTROPY */
|
||||||
|
|
||||||
if( verbose != 0 )
|
if( verbose != 0 )
|
||||||
{
|
{
|
||||||
|
|
|
@ -102,7 +102,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_NET_C)
|
#if defined(MBEDTLS_NET_C)
|
||||||
#include "mbedtls/net.h"
|
#include "mbedtls/net_sockets.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_OID_C)
|
#if defined(MBEDTLS_OID_C)
|
||||||
|
|
|
@ -36,10 +36,9 @@
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/net.h"
|
#include "mbedtls/net_sockets.h"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
|
@ -152,6 +152,7 @@ int FN_NAME( ATTR1_TYPE ATTR1, ATTR2_TYPE ATTR2, const char **oid , \
|
||||||
return( MBEDTLS_ERR_OID_NOT_FOUND ); \
|
return( MBEDTLS_ERR_OID_NOT_FOUND ); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
|
||||||
/*
|
/*
|
||||||
* For X520 attribute types
|
* For X520 attribute types
|
||||||
*/
|
*/
|
||||||
|
@ -247,7 +248,6 @@ static const oid_x520_attr_t oid_x520_attr_type[] =
|
||||||
FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type)
|
FN_OID_TYPED_FROM_ASN1(oid_x520_attr_t, x520_attr, oid_x520_attr_type)
|
||||||
FN_OID_GET_ATTR1(mbedtls_oid_get_attr_short_name, oid_x520_attr_t, x520_attr, const char *, short_name)
|
FN_OID_GET_ATTR1(mbedtls_oid_get_attr_short_name, oid_x520_attr_t, x520_attr, const char *, short_name)
|
||||||
|
|
||||||
#if defined(MBEDTLS_X509_USE_C) || defined(MBEDTLS_X509_CREATE_C)
|
|
||||||
/*
|
/*
|
||||||
* For X509 extensions
|
* For X509 extensions
|
||||||
*/
|
*/
|
||||||
|
@ -314,22 +314,32 @@ typedef struct {
|
||||||
|
|
||||||
static const oid_sig_alg_t oid_sig_alg[] =
|
static const oid_sig_alg_t oid_sig_alg[] =
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_RSA_C)
|
||||||
|
#if defined(MBEDTLS_MD2_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_MD2 ), "md2WithRSAEncryption", "RSA with MD2" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_MD2 ), "md2WithRSAEncryption", "RSA with MD2" },
|
||||||
MBEDTLS_MD_MD2, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_MD2, MBEDTLS_PK_RSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_MD2_C */
|
||||||
|
#if defined(MBEDTLS_MD4_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_MD4 ), "md4WithRSAEncryption", "RSA with MD4" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_MD4 ), "md4WithRSAEncryption", "RSA with MD4" },
|
||||||
MBEDTLS_MD_MD4, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_MD4, MBEDTLS_PK_RSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_MD4_C */
|
||||||
|
#if defined(MBEDTLS_MD5_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_MD5 ), "md5WithRSAEncryption", "RSA with MD5" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_MD5 ), "md5WithRSAEncryption", "RSA with MD5" },
|
||||||
MBEDTLS_MD_MD5, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_MD5, MBEDTLS_PK_RSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_MD5_C */
|
||||||
|
#if defined(MBEDTLS_SHA1_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA1 ), "sha-1WithRSAEncryption", "RSA with SHA1" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA1 ), "sha-1WithRSAEncryption", "RSA with SHA1" },
|
||||||
MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA1_C */
|
||||||
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA224 ), "sha224WithRSAEncryption", "RSA with SHA-224" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA224 ), "sha224WithRSAEncryption", "RSA with SHA-224" },
|
||||||
MBEDTLS_MD_SHA224, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_SHA224, MBEDTLS_PK_RSA,
|
||||||
|
@ -338,6 +348,8 @@ static const oid_sig_alg_t oid_sig_alg[] =
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA256 ), "sha256WithRSAEncryption", "RSA with SHA-256" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA256 ), "sha256WithRSAEncryption", "RSA with SHA-256" },
|
||||||
MBEDTLS_MD_SHA256, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_SHA256, MBEDTLS_PK_RSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA256_C */
|
||||||
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA384 ), "sha384WithRSAEncryption", "RSA with SHA-384" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA384 ), "sha384WithRSAEncryption", "RSA with SHA-384" },
|
||||||
MBEDTLS_MD_SHA384, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_SHA384, MBEDTLS_PK_RSA,
|
||||||
|
@ -346,14 +358,22 @@ static const oid_sig_alg_t oid_sig_alg[] =
|
||||||
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA512 ), "sha512WithRSAEncryption", "RSA with SHA-512" },
|
{ ADD_LEN( MBEDTLS_OID_PKCS1_SHA512 ), "sha512WithRSAEncryption", "RSA with SHA-512" },
|
||||||
MBEDTLS_MD_SHA512, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_SHA512, MBEDTLS_PK_RSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA512_C */
|
||||||
|
#if defined(MBEDTLS_SHA1_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_RSA_SHA_OBS ), "sha-1WithRSAEncryption", "RSA with SHA1" },
|
{ ADD_LEN( MBEDTLS_OID_RSA_SHA_OBS ), "sha-1WithRSAEncryption", "RSA with SHA1" },
|
||||||
MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA,
|
MBEDTLS_MD_SHA1, MBEDTLS_PK_RSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA1_C */
|
||||||
|
#endif /* MBEDTLS_RSA_C */
|
||||||
|
#if defined(MBEDTLS_ECDSA_C)
|
||||||
|
#if defined(MBEDTLS_SHA1_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA1 ), "ecdsa-with-SHA1", "ECDSA with SHA1" },
|
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA1 ), "ecdsa-with-SHA1", "ECDSA with SHA1" },
|
||||||
MBEDTLS_MD_SHA1, MBEDTLS_PK_ECDSA,
|
MBEDTLS_MD_SHA1, MBEDTLS_PK_ECDSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA1_C */
|
||||||
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA224 ), "ecdsa-with-SHA224", "ECDSA with SHA224" },
|
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA224 ), "ecdsa-with-SHA224", "ECDSA with SHA224" },
|
||||||
MBEDTLS_MD_SHA224, MBEDTLS_PK_ECDSA,
|
MBEDTLS_MD_SHA224, MBEDTLS_PK_ECDSA,
|
||||||
|
@ -362,6 +382,8 @@ static const oid_sig_alg_t oid_sig_alg[] =
|
||||||
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA256 ), "ecdsa-with-SHA256", "ECDSA with SHA256" },
|
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA256 ), "ecdsa-with-SHA256", "ECDSA with SHA256" },
|
||||||
MBEDTLS_MD_SHA256, MBEDTLS_PK_ECDSA,
|
MBEDTLS_MD_SHA256, MBEDTLS_PK_ECDSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA256_C */
|
||||||
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA384 ), "ecdsa-with-SHA384", "ECDSA with SHA384" },
|
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA384 ), "ecdsa-with-SHA384", "ECDSA with SHA384" },
|
||||||
MBEDTLS_MD_SHA384, MBEDTLS_PK_ECDSA,
|
MBEDTLS_MD_SHA384, MBEDTLS_PK_ECDSA,
|
||||||
|
@ -370,10 +392,14 @@ static const oid_sig_alg_t oid_sig_alg[] =
|
||||||
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA512 ), "ecdsa-with-SHA512", "ECDSA with SHA512" },
|
{ ADD_LEN( MBEDTLS_OID_ECDSA_SHA512 ), "ecdsa-with-SHA512", "ECDSA with SHA512" },
|
||||||
MBEDTLS_MD_SHA512, MBEDTLS_PK_ECDSA,
|
MBEDTLS_MD_SHA512, MBEDTLS_PK_ECDSA,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA512_C */
|
||||||
|
#endif /* MBEDTLS_ECDSA_C */
|
||||||
|
#if defined(MBEDTLS_RSA_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_RSASSA_PSS ), "RSASSA-PSS", "RSASSA-PSS" },
|
{ ADD_LEN( MBEDTLS_OID_RSASSA_PSS ), "RSASSA-PSS", "RSASSA-PSS" },
|
||||||
MBEDTLS_MD_NONE, MBEDTLS_PK_RSASSA_PSS,
|
MBEDTLS_MD_NONE, MBEDTLS_PK_RSASSA_PSS,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_RSA_C */
|
||||||
{
|
{
|
||||||
{ NULL, 0, NULL, NULL },
|
{ NULL, 0, NULL, NULL },
|
||||||
MBEDTLS_MD_NONE, MBEDTLS_PK_NONE,
|
MBEDTLS_MD_NONE, MBEDTLS_PK_NONE,
|
||||||
|
@ -429,50 +455,72 @@ typedef struct {
|
||||||
|
|
||||||
static const oid_ecp_grp_t oid_ecp_grp[] =
|
static const oid_ecp_grp_t oid_ecp_grp[] =
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP192R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192R1 ), "secp192r1", "secp192r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192R1 ), "secp192r1", "secp192r1" },
|
||||||
MBEDTLS_ECP_DP_SECP192R1,
|
MBEDTLS_ECP_DP_SECP192R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP192R1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP224R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224R1 ), "secp224r1", "secp224r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224R1 ), "secp224r1", "secp224r1" },
|
||||||
MBEDTLS_ECP_DP_SECP224R1,
|
MBEDTLS_ECP_DP_SECP224R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP224R1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP256R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256R1 ), "secp256r1", "secp256r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256R1 ), "secp256r1", "secp256r1" },
|
||||||
MBEDTLS_ECP_DP_SECP256R1,
|
MBEDTLS_ECP_DP_SECP256R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP256R1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP384R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP384R1 ), "secp384r1", "secp384r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP384R1 ), "secp384r1", "secp384r1" },
|
||||||
MBEDTLS_ECP_DP_SECP384R1,
|
MBEDTLS_ECP_DP_SECP384R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP384R1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP521R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP521R1 ), "secp521r1", "secp521r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP521R1 ), "secp521r1", "secp521r1" },
|
||||||
MBEDTLS_ECP_DP_SECP521R1,
|
MBEDTLS_ECP_DP_SECP521R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP521R1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP192K1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192K1 ), "secp192k1", "secp192k1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP192K1 ), "secp192k1", "secp192k1" },
|
||||||
MBEDTLS_ECP_DP_SECP192K1,
|
MBEDTLS_ECP_DP_SECP192K1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP192K1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP224K1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224K1 ), "secp224k1", "secp224k1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP224K1 ), "secp224k1", "secp224k1" },
|
||||||
MBEDTLS_ECP_DP_SECP224K1,
|
MBEDTLS_ECP_DP_SECP224K1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP224K1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_SECP256K1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256K1 ), "secp256k1", "secp256k1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_SECP256K1 ), "secp256k1", "secp256k1" },
|
||||||
MBEDTLS_ECP_DP_SECP256K1,
|
MBEDTLS_ECP_DP_SECP256K1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_SECP256K1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_BP256R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_BP256R1 ), "brainpoolP256r1","brainpool256r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_BP256R1 ), "brainpoolP256r1","brainpool256r1" },
|
||||||
MBEDTLS_ECP_DP_BP256R1,
|
MBEDTLS_ECP_DP_BP256R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_BP256R1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_BP384R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_BP384R1 ), "brainpoolP384r1","brainpool384r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_BP384R1 ), "brainpoolP384r1","brainpool384r1" },
|
||||||
MBEDTLS_ECP_DP_BP384R1,
|
MBEDTLS_ECP_DP_BP384R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_BP384R1_ENABLED */
|
||||||
|
#if defined(MBEDTLS_ECP_DP_BP512R1_ENABLED)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_EC_GRP_BP512R1 ), "brainpoolP512r1","brainpool512r1" },
|
{ ADD_LEN( MBEDTLS_OID_EC_GRP_BP512R1 ), "brainpoolP512r1","brainpool512r1" },
|
||||||
MBEDTLS_ECP_DP_BP512R1,
|
MBEDTLS_ECP_DP_BP512R1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_ECP_DP_BP512R1_ENABLED */
|
||||||
{
|
{
|
||||||
{ NULL, 0, NULL, NULL },
|
{ NULL, 0, NULL, NULL },
|
||||||
MBEDTLS_ECP_DP_NONE,
|
MBEDTLS_ECP_DP_NONE,
|
||||||
|
@ -524,22 +572,31 @@ typedef struct {
|
||||||
|
|
||||||
static const oid_md_alg_t oid_md_alg[] =
|
static const oid_md_alg_t oid_md_alg[] =
|
||||||
{
|
{
|
||||||
|
#if defined(MBEDTLS_MD2_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD2 ), "id-md2", "MD2" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD2 ), "id-md2", "MD2" },
|
||||||
MBEDTLS_MD_MD2,
|
MBEDTLS_MD_MD2,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_MD2_C */
|
||||||
|
#if defined(MBEDTLS_MD4_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD4 ), "id-md4", "MD4" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD4 ), "id-md4", "MD4" },
|
||||||
MBEDTLS_MD_MD4,
|
MBEDTLS_MD_MD4,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_MD4_C */
|
||||||
|
#if defined(MBEDTLS_MD5_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD5 ), "id-md5", "MD5" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_MD5 ), "id-md5", "MD5" },
|
||||||
MBEDTLS_MD_MD5,
|
MBEDTLS_MD_MD5,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_MD5_C */
|
||||||
|
#if defined(MBEDTLS_SHA1_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA1 ), "id-sha1", "SHA-1" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA1 ), "id-sha1", "SHA-1" },
|
||||||
MBEDTLS_MD_SHA1,
|
MBEDTLS_MD_SHA1,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA1_C */
|
||||||
|
#if defined(MBEDTLS_SHA256_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA224 ), "id-sha224", "SHA-224" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA224 ), "id-sha224", "SHA-224" },
|
||||||
MBEDTLS_MD_SHA224,
|
MBEDTLS_MD_SHA224,
|
||||||
|
@ -548,6 +605,8 @@ static const oid_md_alg_t oid_md_alg[] =
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA256 ), "id-sha256", "SHA-256" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA256 ), "id-sha256", "SHA-256" },
|
||||||
MBEDTLS_MD_SHA256,
|
MBEDTLS_MD_SHA256,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA256_C */
|
||||||
|
#if defined(MBEDTLS_SHA512_C)
|
||||||
{
|
{
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA384 ), "id-sha384", "SHA-384" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA384 ), "id-sha384", "SHA-384" },
|
||||||
MBEDTLS_MD_SHA384,
|
MBEDTLS_MD_SHA384,
|
||||||
|
@ -556,6 +615,7 @@ static const oid_md_alg_t oid_md_alg[] =
|
||||||
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA512 ), "id-sha512", "SHA-512" },
|
{ ADD_LEN( MBEDTLS_OID_DIGEST_ALG_SHA512 ), "id-sha512", "SHA-512" },
|
||||||
MBEDTLS_MD_SHA512,
|
MBEDTLS_MD_SHA512,
|
||||||
},
|
},
|
||||||
|
#endif /* MBEDTLS_SHA512_C */
|
||||||
{
|
{
|
||||||
{ NULL, 0, NULL, NULL },
|
{ NULL, 0, NULL, NULL },
|
||||||
MBEDTLS_MD_NONE,
|
MBEDTLS_MD_NONE,
|
||||||
|
|
|
@ -391,6 +391,7 @@ int mbedtls_pkcs5_self_test( int verbose )
|
||||||
mbedtls_printf( "passed\n" );
|
mbedtls_printf( "passed\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( verbose != 0 )
|
||||||
mbedtls_printf( "\n" );
|
mbedtls_printf( "\n" );
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
|
|
|
@ -190,6 +190,8 @@ int mbedtls_platform_set_exit( void (*exit_func)( int status ) )
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
|
#endif /* MBEDTLS_PLATFORM_EXIT_ALT */
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
|
|
||||||
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
#if defined(MBEDTLS_PLATFORM_TIME_ALT)
|
||||||
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
|
#if !defined(MBEDTLS_PLATFORM_STD_TIME)
|
||||||
/*
|
/*
|
||||||
|
@ -213,6 +215,8 @@ int mbedtls_platform_set_time( mbedtls_time_t (*time_func)( mbedtls_time_t* time
|
||||||
}
|
}
|
||||||
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
#endif /* MBEDTLS_PLATFORM_TIME_ALT */
|
||||||
|
|
||||||
|
#endif /* MBEDTLS_HAVE_TIME */
|
||||||
|
|
||||||
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
#if defined(MBEDTLS_ENTROPY_NV_SEED)
|
||||||
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
|
#if !defined(MBEDTLS_PLATFORM_NO_STD_FUNCTIONS) && defined(MBEDTLS_FS_IO)
|
||||||
/* Default implementations for the platform independent seed functions use
|
/* Default implementations for the platform independent seed functions use
|
||||||
|
|
|
@ -456,6 +456,9 @@ int mbedtls_ripemd160_self_test( int verbose )
|
||||||
mbedtls_printf( "passed\n" );
|
mbedtls_printf( "passed\n" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( verbose != 0 )
|
||||||
|
mbedtls_printf( "\n" );
|
||||||
|
|
||||||
return( 0 );
|
return( 0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,8 +37,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#define mbedtls_time time
|
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/ssl_cache.h"
|
#include "mbedtls/ssl_cache.h"
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "mbedtls/platform.h"
|
#include "mbedtls/platform.h"
|
||||||
#else
|
#else
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/ssl_ciphersuites.h"
|
#include "mbedtls/ssl_ciphersuites.h"
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#define mbedtls_time time
|
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/debug.h"
|
#include "mbedtls/debug.h"
|
||||||
|
@ -46,7 +44,7 @@
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#if defined(MBEDTLS_HAVE_TIME)
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
#include <time.h>
|
#include "mbedtls/platform_time.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
|
@ -2513,7 +2511,9 @@ exit:
|
||||||
|
|
||||||
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||||
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
|
static int ssl_parse_certificate_request( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
|
@ -2659,7 +2659,9 @@ exit:
|
||||||
}
|
}
|
||||||
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED &&
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
||||||
|
|
||||||
static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl )
|
static int ssl_parse_server_hello_done( mbedtls_ssl_context *ssl )
|
||||||
|
@ -2961,7 +2963,9 @@ static int ssl_write_client_key_exchange( mbedtls_ssl_context *ssl )
|
||||||
|
|
||||||
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||||
static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
|
static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
|
@ -3141,7 +3145,10 @@ static int ssl_write_certificate_verify( mbedtls_ssl_context *ssl )
|
||||||
}
|
}
|
||||||
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */
|
!MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl )
|
static int ssl_parse_new_session_ticket( mbedtls_ssl_context *ssl )
|
||||||
|
|
|
@ -36,8 +36,6 @@
|
||||||
#else
|
#else
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#define mbedtls_time time
|
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/ssl_cookie.h"
|
#include "mbedtls/ssl_cookie.h"
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#define mbedtls_time time
|
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/debug.h"
|
#include "mbedtls/debug.h"
|
||||||
|
@ -48,7 +46,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_HAVE_TIME)
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
#include <time.h>
|
#include "mbedtls/platform_time.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
|
@ -2450,7 +2448,9 @@ static int ssl_write_server_hello( mbedtls_ssl_context *ssl )
|
||||||
|
|
||||||
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||||
static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
|
static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
|
@ -2637,7 +2637,9 @@ static int ssl_write_certificate_request( mbedtls_ssl_context *ssl )
|
||||||
}
|
}
|
||||||
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED &&
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
||||||
|
|
||||||
#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
#if defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \
|
||||||
|
@ -3527,7 +3529,9 @@ static int ssl_parse_client_key_exchange( mbedtls_ssl_context *ssl )
|
||||||
|
|
||||||
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
#if !defined(MBEDTLS_KEY_EXCHANGE_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) && \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) && \
|
||||||
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED)&& \
|
||||||
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
!defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED)
|
||||||
static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl )
|
static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl )
|
||||||
{
|
{
|
||||||
|
@ -3706,7 +3710,10 @@ static int ssl_parse_certificate_verify( mbedtls_ssl_context *ssl )
|
||||||
}
|
}
|
||||||
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
#endif /* !MBEDTLS_KEY_EXCHANGE_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
!MBEDTLS_KEY_EXCHANGE_DHE_RSA_ENABLED &&
|
||||||
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED */
|
!MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED &&
|
||||||
|
!MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED */
|
||||||
|
|
||||||
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
#if defined(MBEDTLS_SSL_SESSION_TICKETS)
|
||||||
static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl )
|
static int ssl_write_new_session_ticket( mbedtls_ssl_context *ssl )
|
||||||
|
|
|
@ -33,8 +33,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#define mbedtls_time time
|
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/ssl_ticket.h"
|
#include "mbedtls/ssl_ticket.h"
|
||||||
|
|
|
@ -41,7 +41,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "mbedtls/debug.h"
|
#include "mbedtls/debug.h"
|
||||||
|
|
|
@ -55,12 +55,15 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#define mbedtls_free free
|
#define mbedtls_free free
|
||||||
#define mbedtls_calloc calloc
|
#define mbedtls_calloc calloc
|
||||||
#define mbedtls_time time
|
|
||||||
#define mbedtls_time_t time_t
|
|
||||||
#define mbedtls_printf printf
|
#define mbedtls_printf printf
|
||||||
#define mbedtls_snprintf snprintf
|
#define mbedtls_snprintf snprintf
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(MBEDTLS_HAVE_TIME)
|
||||||
|
#include "mbedtls/platform_time.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
#if defined(_WIN32) && !defined(EFIX64) && !defined(EFI32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
|
|
|
@ -1160,9 +1160,10 @@ int mbedtls_x509_crt_parse_path( mbedtls_x509_crt *chain, const char *path )
|
||||||
FindClose( hFind );
|
FindClose( hFind );
|
||||||
#else /* _WIN32 */
|
#else /* _WIN32 */
|
||||||
int t_ret;
|
int t_ret;
|
||||||
|
int snp_ret;
|
||||||
struct stat sb;
|
struct stat sb;
|
||||||
struct dirent *entry;
|
struct dirent *entry;
|
||||||
char entry_name[255];
|
char entry_name[MBEDTLS_X509_MAX_FILE_PATH_LEN];
|
||||||
DIR *dir = opendir( path );
|
DIR *dir = opendir( path );
|
||||||
|
|
||||||
if( dir == NULL )
|
if( dir == NULL )
|
||||||
|
@ -1178,11 +1179,16 @@ int mbedtls_x509_crt_parse_path( mbedtls_x509_crt *chain, const char *path )
|
||||||
|
|
||||||
while( ( entry = readdir( dir ) ) != NULL )
|
while( ( entry = readdir( dir ) ) != NULL )
|
||||||
{
|
{
|
||||||
mbedtls_snprintf( entry_name, sizeof entry_name, "%s/%s", path, entry->d_name );
|
snp_ret = mbedtls_snprintf( entry_name, sizeof entry_name,
|
||||||
|
"%s/%s", path, entry->d_name );
|
||||||
|
|
||||||
if( stat( entry_name, &sb ) == -1 )
|
if( snp_ret < 0 || (size_t)snp_ret >= sizeof entry_name )
|
||||||
|
{
|
||||||
|
ret = MBEDTLS_ERR_X509_BUFFER_TOO_SMALL;
|
||||||
|
goto cleanup;
|
||||||
|
}
|
||||||
|
else if( stat( entry_name, &sb ) == -1 )
|
||||||
{
|
{
|
||||||
closedir( dir );
|
|
||||||
ret = MBEDTLS_ERR_X509_FILE_IO_ERROR;
|
ret = MBEDTLS_ERR_X509_FILE_IO_ERROR;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
}
|
}
|
||||||
|
@ -1198,9 +1204,10 @@ int mbedtls_x509_crt_parse_path( mbedtls_x509_crt *chain, const char *path )
|
||||||
else
|
else
|
||||||
ret += t_ret;
|
ret += t_ret;
|
||||||
}
|
}
|
||||||
closedir( dir );
|
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
|
closedir( dir );
|
||||||
|
|
||||||
#if defined(MBEDTLS_THREADING_PTHREAD)
|
#if defined(MBEDTLS_THREADING_PTHREAD)
|
||||||
if( mbedtls_mutex_unlock( &mbedtls_threading_readdir_mutex ) != 0 )
|
if( mbedtls_mutex_unlock( &mbedtls_threading_readdir_mutex ) != 0 )
|
||||||
ret = MBEDTLS_ERR_THREADING_MUTEX_ERROR;
|
ret = MBEDTLS_ERR_THREADING_MUTEX_ERROR;
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
lwip/doc/*
|
||||||
|
lwip/test/*
|
||||||
|
lwip/src/apps/*
|
||||||
|
lwip/src/netif/ppp/*
|
||||||
|
lwip/src/netif/lwip_slipif.c
|
||||||
|
lwip/src/include/lwip/apps/*
|
||||||
|
lwip/src/include/posix/*
|
|
@ -59,17 +59,29 @@ const char *EthernetInterface::get_mac_address()
|
||||||
|
|
||||||
const char *EthernetInterface::get_ip_address()
|
const char *EthernetInterface::get_ip_address()
|
||||||
{
|
{
|
||||||
return lwip_get_ip_address();
|
if (lwip_get_ip_address(_ip_address, sizeof _ip_address)) {
|
||||||
|
return _ip_address;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *EthernetInterface::get_netmask()
|
const char *EthernetInterface::get_netmask()
|
||||||
{
|
{
|
||||||
return lwip_get_netmask();
|
if (lwip_get_netmask(_netmask, sizeof _netmask)) {
|
||||||
|
return _netmask;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *EthernetInterface::get_gateway()
|
const char *EthernetInterface::get_gateway()
|
||||||
{
|
{
|
||||||
return lwip_get_gateway();
|
if (lwip_get_gateway(_gateway, sizeof _gateway)) {
|
||||||
|
return _gateway;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkStack *EthernetInterface::get_stack()
|
NetworkStack *EthernetInterface::get_stack()
|
||||||
|
|
|
@ -92,7 +92,7 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual const char *get_netmask();
|
virtual const char *get_netmask();
|
||||||
|
|
||||||
/** Get the local gateway
|
/** Get the local gateways
|
||||||
*
|
*
|
||||||
* @return Null-terminated representation of the local gateway
|
* @return Null-terminated representation of the local gateway
|
||||||
* or null if no network mask has been recieved
|
* or null if no network mask has been recieved
|
||||||
|
@ -107,7 +107,7 @@ protected:
|
||||||
virtual NetworkStack *get_stack();
|
virtual NetworkStack *get_stack();
|
||||||
|
|
||||||
bool _dhcp;
|
bool _dhcp;
|
||||||
char _ip_address[NSAPI_IPv4_SIZE];
|
char _ip_address[IPADDR_STRLEN_MAX];
|
||||||
char _netmask[NSAPI_IPv4_SIZE];
|
char _netmask[NSAPI_IPv4_SIZE];
|
||||||
char _gateway[NSAPI_IPv4_SIZE];
|
char _gateway[NSAPI_IPv4_SIZE];
|
||||||
};
|
};
|
||||||
|
|
|
@ -6,8 +6,11 @@
|
||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
#include "lwip/snmp.h"
|
#include "lwip/snmp.h"
|
||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
|
#include "lwip/ethip6.h"
|
||||||
|
#include "lwip/igmp.h"
|
||||||
|
#include "lwip/mld6.h"
|
||||||
#include "netif/etharp.h"
|
#include "netif/etharp.h"
|
||||||
#include "netif/ppp_oe.h"
|
#include "netif/ppp/pppoe.h"
|
||||||
|
|
||||||
#include "eth_arch.h"
|
#include "eth_arch.h"
|
||||||
#include "sys_arch.h"
|
#include "sys_arch.h"
|
||||||
|
@ -236,7 +239,7 @@ static err_t low_level_init(struct netif *netif)
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is the ethernet packet send function. It calls
|
* This function is the ipv4 ethernet packet send function. It calls
|
||||||
* etharp_output after checking link status.
|
* etharp_output after checking link status.
|
||||||
*
|
*
|
||||||
* \param[in] netif the lwip network interface structure for this enetif
|
* \param[in] netif the lwip network interface structure for this enetif
|
||||||
|
@ -244,14 +247,106 @@ static err_t low_level_init(struct netif *netif)
|
||||||
* \param[in] ipaddr IP address
|
* \param[in] ipaddr IP address
|
||||||
* \return ERR_OK or error code
|
* \return ERR_OK or error code
|
||||||
*/
|
*/
|
||||||
err_t k64f_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr)
|
#if LWIP_IPV4
|
||||||
|
err_t k64f_etharp_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
|
||||||
{
|
{
|
||||||
/* Only send packet is link is up */
|
/* Only send packet is link is up */
|
||||||
if (netif->flags & NETIF_FLAG_LINK_UP)
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
return etharp_output(netif, q, ipaddr);
|
return etharp_output(netif, q, ipaddr);
|
||||||
|
}
|
||||||
|
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is the ipv6 ethernet packet send function. It calls
|
||||||
|
* ethip6_output after checking link status.
|
||||||
|
*
|
||||||
|
* \param[in] netif the lwip network interface structure for this enetif
|
||||||
|
* \param[in] q Pointer to pbug to send
|
||||||
|
* \param[in] ipaddr IP address
|
||||||
|
* \return ERR_OK or error code
|
||||||
|
*/
|
||||||
|
#if LWIP_IPV6
|
||||||
|
err_t k64f_etharp_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr)
|
||||||
|
{
|
||||||
|
/* Only send packet is link is up */
|
||||||
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
|
return ethip6_output(netif, q, ipaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_IGMP
|
||||||
|
/**
|
||||||
|
* IPv4 address filtering setup.
|
||||||
|
*
|
||||||
|
* \param[in] netif the lwip network interface structure for this enetif
|
||||||
|
* \param[in] group IPv4 group to modify
|
||||||
|
* \param[in] action
|
||||||
|
* \return ERR_OK or error code
|
||||||
|
*/
|
||||||
|
err_t igmp_mac_filter(struct netif *netif, const ip4_addr_t *group, u8_t action)
|
||||||
|
{
|
||||||
|
switch (action) {
|
||||||
|
case IGMP_ADD_MAC_FILTER:
|
||||||
|
{
|
||||||
|
uint32_t group23 = ntohl(group->addr) & 0x007FFFFF;
|
||||||
|
uint8_t addr[6];
|
||||||
|
addr[0] = LL_IP4_MULTICAST_ADDR_0;
|
||||||
|
addr[1] = LL_IP4_MULTICAST_ADDR_1;
|
||||||
|
addr[2] = LL_IP4_MULTICAST_ADDR_2;
|
||||||
|
addr[3] = group23 >> 16;
|
||||||
|
addr[4] = group23 >> 8;
|
||||||
|
addr[5] = group23;
|
||||||
|
ENET_AddMulticastGroup(ENET, addr);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
case IGMP_DEL_MAC_FILTER:
|
||||||
|
/* As we don't reference count, silently ignore delete requests */
|
||||||
|
return ERR_OK;
|
||||||
|
default:
|
||||||
|
return ERR_ARG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_IPV6_MLD
|
||||||
|
/**
|
||||||
|
* IPv6 address filtering setup.
|
||||||
|
*
|
||||||
|
* \param[in] netif the lwip network interface structure for this enetif
|
||||||
|
* \param[in] group IPv6 group to modify
|
||||||
|
* \param[in] action
|
||||||
|
* \return ERR_OK or error code
|
||||||
|
*/
|
||||||
|
err_t mld_mac_filter(struct netif *netif, const ip6_addr_t *group, u8_t action)
|
||||||
|
{
|
||||||
|
switch (action) {
|
||||||
|
case MLD6_ADD_MAC_FILTER:
|
||||||
|
{
|
||||||
|
uint32_t group32 = ntohl(group->addr[3]);
|
||||||
|
uint8_t addr[6];
|
||||||
|
addr[0] = LL_IP6_MULTICAST_ADDR_0;
|
||||||
|
addr[1] = LL_IP6_MULTICAST_ADDR_1;
|
||||||
|
addr[2] = group32 >> 24;
|
||||||
|
addr[3] = group32 >> 16;
|
||||||
|
addr[4] = group32 >> 8;
|
||||||
|
addr[5] = group32;
|
||||||
|
ENET_AddMulticastGroup(ENET, addr);
|
||||||
|
return ERR_OK;
|
||||||
|
}
|
||||||
|
case MLD6_DEL_MAC_FILTER:
|
||||||
|
/* As we don't reference count, silently ignore delete requests */
|
||||||
|
return ERR_OK;
|
||||||
|
default:
|
||||||
|
return ERR_ARG;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/** \brief Allocates a pbuf and returns the data from the incoming packet.
|
/** \brief Allocates a pbuf and returns the data from the incoming packet.
|
||||||
*
|
*
|
||||||
|
@ -322,7 +417,7 @@ static struct pbuf *k64f_low_level_input(struct netif *netif, int idx)
|
||||||
|
|
||||||
update_read_buffer(rx_buff[idx]->payload);
|
update_read_buffer(rx_buff[idx]->payload);
|
||||||
LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
|
LWIP_DEBUGF(UDP_LPC_EMAC | LWIP_DBG_TRACE,
|
||||||
("k64f_low_level_input: Packet received: %p, size %d (index=%d)\n",
|
("k64f_low_level_input: Packet received: %p, size %"PRIu32" (index=%d)\n",
|
||||||
p, length, idx));
|
p, length, idx));
|
||||||
|
|
||||||
/* Save size */
|
/* Save size */
|
||||||
|
@ -344,7 +439,6 @@ static struct pbuf *k64f_low_level_input(struct netif *netif, int idx)
|
||||||
*/
|
*/
|
||||||
void k64f_enetif_input(struct netif *netif, int idx)
|
void k64f_enetif_input(struct netif *netif, int idx)
|
||||||
{
|
{
|
||||||
struct eth_hdr *ethhdr;
|
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
|
|
||||||
/* move received packet into a new pbuf */
|
/* move received packet into a new pbuf */
|
||||||
|
@ -352,29 +446,12 @@ void k64f_enetif_input(struct netif *netif, int idx)
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* points to packet payload, which starts with an Ethernet header */
|
/* pass all packets to ethernet_input, which decides what packets it supports */
|
||||||
ethhdr = (struct eth_hdr*)p->payload;
|
|
||||||
|
|
||||||
switch (htons(ethhdr->type)) {
|
|
||||||
case ETHTYPE_IP:
|
|
||||||
case ETHTYPE_ARP:
|
|
||||||
#if PPPOE_SUPPORT
|
|
||||||
case ETHTYPE_PPPOEDISC:
|
|
||||||
case ETHTYPE_PPPOE:
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
/* full packet send to tcpip_thread to process */
|
|
||||||
if (netif->input(p, netif) != ERR_OK) {
|
if (netif->input(p, netif) != ERR_OK) {
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("k64f_enetif_input: IP input error\n"));
|
LWIP_DEBUGF(NETIF_DEBUG, ("k64f_enetif_input: input error\n"));
|
||||||
/* Free buffer */
|
/* Free buffer */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
/* Return buffer */
|
|
||||||
pbuf_free(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Packet reception task
|
/** \brief Packet reception task
|
||||||
|
@ -432,7 +509,6 @@ static err_t k64f_low_level_output(struct netif *netif, struct pbuf *p)
|
||||||
struct pbuf *temp_pbuf;
|
struct pbuf *temp_pbuf;
|
||||||
uint8_t *psend = NULL, *dst;
|
uint8_t *psend = NULL, *dst;
|
||||||
|
|
||||||
|
|
||||||
temp_pbuf = pbuf_alloc(PBUF_RAW, p->tot_len + ENET_BUFF_ALIGNMENT, PBUF_RAM);
|
temp_pbuf = pbuf_alloc(PBUF_RAW, p->tot_len + ENET_BUFF_ALIGNMENT, PBUF_RAM);
|
||||||
if (NULL == temp_pbuf)
|
if (NULL == temp_pbuf)
|
||||||
return ERR_MEM;
|
return ERR_MEM;
|
||||||
|
@ -569,14 +645,16 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
#else
|
#else
|
||||||
mbed_mac_address((char *)netif->hwaddr);
|
mbed_mac_address((char *)netif->hwaddr);
|
||||||
#endif
|
#endif
|
||||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
|
||||||
|
/* Ethernet address length */
|
||||||
|
netif->hwaddr_len = ETH_HWADDR_LEN;
|
||||||
|
|
||||||
/* maximum transfer unit */
|
/* maximum transfer unit */
|
||||||
netif->mtu = 1500;
|
netif->mtu = 1500;
|
||||||
|
|
||||||
/* device capabilities */
|
/* device capabilities */
|
||||||
// TODOETH: check if the flags are correct below
|
// TODOETH: check if the flags are correct below
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
||||||
|
|
||||||
/* Initialize the hardware */
|
/* Initialize the hardware */
|
||||||
netif->state = &k64f_enetdata;
|
netif->state = &k64f_enetdata;
|
||||||
|
@ -592,7 +670,23 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
netif->name[0] = 'e';
|
netif->name[0] = 'e';
|
||||||
netif->name[1] = 'n';
|
netif->name[1] = 'n';
|
||||||
|
|
||||||
netif->output = k64f_etharp_output;
|
#if LWIP_IPV4
|
||||||
|
netif->output = k64f_etharp_output_ipv4;
|
||||||
|
#if LWIP_IGMP
|
||||||
|
netif->igmp_mac_filter = igmp_mac_filter;
|
||||||
|
netif->flags |= NETIF_FLAG_IGMP;
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
netif->output_ip6 = k64f_etharp_output_ipv6;
|
||||||
|
#if LWIP_IPV6_MLD
|
||||||
|
netif->mld_mac_filter = mld_mac_filter;
|
||||||
|
netif->flags |= NETIF_FLAG_MLD6;
|
||||||
|
#else
|
||||||
|
// Would need to enable all multicasts here - no API in fsl_enet to do that
|
||||||
|
#error "IPv6 multicasts won't be received if LWIP_IPV6_MLD is disabled, breaking the system"
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
netif->linkoutput = k64f_low_level_output;
|
netif->linkoutput = k64f_low_level_output;
|
||||||
|
|
||||||
/* CMSIS-RTOS, start tasks */
|
/* CMSIS-RTOS, start tasks */
|
||||||
|
@ -610,7 +704,12 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
/* Packet receive task */
|
/* Packet receive task */
|
||||||
err = sys_sem_new(&k64f_enetdata.RxReadySem, 0);
|
err = sys_sem_new(&k64f_enetdata.RxReadySem, 0);
|
||||||
LWIP_ASSERT("RxReadySem creation error", (err == ERR_OK));
|
LWIP_ASSERT("RxReadySem creation error", (err == ERR_OK));
|
||||||
|
|
||||||
|
#ifdef LWIP_DEBUG
|
||||||
|
sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE*5, RX_PRIORITY);
|
||||||
|
#else
|
||||||
sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY);
|
sys_thread_new("receive_thread", packet_rx, netif->state, DEFAULT_THREAD_STACKSIZE, RX_PRIORITY);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Transmit cleanup task */
|
/* Transmit cleanup task */
|
||||||
err = sys_sem_new(&k64f_enetdata.TxCleanSem, 0);
|
err = sys_sem_new(&k64f_enetdata.TxCleanSem, 0);
|
||||||
|
|
|
@ -52,7 +52,8 @@
|
||||||
#include <lwip/stats.h>
|
#include <lwip/stats.h>
|
||||||
#include <lwip/snmp.h>
|
#include <lwip/snmp.h>
|
||||||
#include "netif/etharp.h"
|
#include "netif/etharp.h"
|
||||||
#include "netif/ppp_oe.h"
|
#include "lwip/ethip6.h"
|
||||||
|
#include "netif/ppp/pppoe.h"
|
||||||
#include "nuc472_eth.h"
|
#include "nuc472_eth.h"
|
||||||
#include "string.h"
|
#include "string.h"
|
||||||
|
|
||||||
|
@ -129,7 +130,6 @@ void mbed_mac_address(char *mac)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* In this function, the hardware should be initialized.
|
* In this function, the hardware should be initialized.
|
||||||
* Called from ethernetif_init().
|
* Called from ethernetif_init().
|
||||||
|
@ -142,7 +142,7 @@ low_level_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* set MAC hardware address length */
|
/* set MAC hardware address length */
|
||||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
netif->hwaddr_len = ETH_HWADDR_LEN;
|
||||||
|
|
||||||
/* set MAC hardware address */
|
/* set MAC hardware address */
|
||||||
#if 1 // set MAC HW address
|
#if 1 // set MAC HW address
|
||||||
|
@ -174,9 +174,20 @@ low_level_init(struct netif *netif)
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
||||||
#ifdef LWIP_IGMP
|
#ifdef LWIP_IGMP
|
||||||
netif->flags |= NETIF_FLAG_IGMP;
|
netif->flags |= NETIF_FLAG_IGMP;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6_MLD
|
||||||
|
netif->flags |= NETIF_FLAG_MLD6;
|
||||||
#endif
|
#endif
|
||||||
// TODO: enable clock & configure GPIO function
|
// TODO: enable clock & configure GPIO function
|
||||||
ETH_init(netif->hwaddr);
|
ETH_init(netif->hwaddr);
|
||||||
|
|
||||||
|
#if LWIP_IGMP
|
||||||
|
EMAC_ENABLE_RECV_BCASTPKT();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_IPV6_MLD
|
||||||
|
EMAC_ENABLE_RECV_MCASTPKT();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -335,32 +346,11 @@ ethernetif_input(u16_t len, u8_t *buf, u32_t s, u32_t ns)
|
||||||
void
|
void
|
||||||
ethernetif_loopback_input(struct pbuf *p) // TODO: make sure packet not drop in input()
|
ethernetif_loopback_input(struct pbuf *p) // TODO: make sure packet not drop in input()
|
||||||
{
|
{
|
||||||
struct eth_hdr *ethhdr;
|
/* pass all packets to ethernet_input, which decides what packets it supports */
|
||||||
|
if (netif->input(p, netif) != ERR_OK) {
|
||||||
/* points to packet payload, which starts with an Ethernet header */
|
LWIP_DEBUGF(NETIF_DEBUG, ("k64f_enetif_input: input error\n"));
|
||||||
ethhdr = p->payload;
|
/* Free buffer */
|
||||||
|
|
||||||
switch (htons(ethhdr->type)) {
|
|
||||||
/* IP or ARP packet? */
|
|
||||||
case ETHTYPE_IP:
|
|
||||||
case ETHTYPE_ARP:
|
|
||||||
#if PPPOE_SUPPORT
|
|
||||||
/* PPPoE packet? */
|
|
||||||
case ETHTYPE_PPPOEDISC:
|
|
||||||
case ETHTYPE_PPPOE:
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
/* full packet send to tcpip_thread to process */
|
|
||||||
if (_netif->input(p, _netif)!=ERR_OK) {
|
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("ethernetif_input: IP input error\n"));
|
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
p = NULL;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
pbuf_free(p);
|
|
||||||
p = NULL;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -415,7 +405,12 @@ err_t
|
||||||
* You can instead declare your own function an call etharp_output()
|
* You can instead declare your own function an call etharp_output()
|
||||||
* from it if you have to do some checks before sending (e.g. if link
|
* from it if you have to do some checks before sending (e.g. if link
|
||||||
* is available...) */
|
* is available...) */
|
||||||
|
#if LWIP_IPV4
|
||||||
netif->output = etharp_output;
|
netif->output = etharp_output;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
netif->output_ip6 = ethip6_output;
|
||||||
|
#endif
|
||||||
netif->linkoutput = low_level_output;
|
netif->linkoutput = low_level_output;
|
||||||
|
|
||||||
ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
ethernetif->ethaddr = (struct eth_addr *)&(netif->hwaddr[0]);
|
||||||
|
|
|
@ -31,7 +31,8 @@
|
||||||
#include "lwip/stats.h"
|
#include "lwip/stats.h"
|
||||||
#include "lwip/snmp.h"
|
#include "lwip/snmp.h"
|
||||||
#include "netif/etharp.h"
|
#include "netif/etharp.h"
|
||||||
#include "netif/ppp_oe.h"
|
#include "lwip/ethip6.h"
|
||||||
|
#include "netif/ppp/pppoe.h"
|
||||||
|
|
||||||
#include "lpc17xx_emac.h"
|
#include "lpc17xx_emac.h"
|
||||||
#include "eth_arch.h"
|
#include "eth_arch.h"
|
||||||
|
@ -409,29 +410,12 @@ void lpc_enetif_input(struct netif *netif)
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* points to packet payload, which starts with an Ethernet header */
|
|
||||||
ethhdr = p->payload;
|
|
||||||
|
|
||||||
switch (htons(ethhdr->type)) {
|
|
||||||
case ETHTYPE_IP:
|
|
||||||
case ETHTYPE_ARP:
|
|
||||||
#if PPPOE_SUPPORT
|
|
||||||
case ETHTYPE_PPPOEDISC:
|
|
||||||
case ETHTYPE_PPPOE:
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
/* full packet send to tcpip_thread to process */
|
/* full packet send to tcpip_thread to process */
|
||||||
if (netif->input(p, netif) != ERR_OK) {
|
if (netif->input(p, netif) != ERR_OK) {
|
||||||
LWIP_DEBUGF(NETIF_DEBUG, ("lpc_enetif_input: IP input error\n"));
|
LWIP_DEBUGF(NETIF_DEBUG, ("lpc_enetif_input: IP input error\n"));
|
||||||
/* Free buffer */
|
/* Free buffer */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
/* Return buffer */
|
|
||||||
pbuf_free(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Determine if the passed address is usable for the ethernet
|
/** \brief Determine if the passed address is usable for the ethernet
|
||||||
|
@ -920,7 +904,7 @@ void lpc_emac_set_speed(int mbs_100)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is the ethernet packet send function. It calls
|
* This function is the ethernet IPv4 packet send function. It calls
|
||||||
* etharp_output after checking link status.
|
* etharp_output after checking link status.
|
||||||
*
|
*
|
||||||
* \param[in] netif the lwip network interface structure for this lpc_enetif
|
* \param[in] netif the lwip network interface structure for this lpc_enetif
|
||||||
|
@ -928,8 +912,9 @@ void lpc_emac_set_speed(int mbs_100)
|
||||||
* \param[in] ipaddr IP address
|
* \param[in] ipaddr IP address
|
||||||
* \return ERR_OK or error code
|
* \return ERR_OK or error code
|
||||||
*/
|
*/
|
||||||
err_t lpc_etharp_output(struct netif *netif, struct pbuf *q,
|
#if LWIP_IPV4
|
||||||
ip_addr_t *ipaddr)
|
err_t lpc_etharp_output_ipv4(struct netif *netif, struct pbuf *q,
|
||||||
|
const ip4_addr_t *ipaddr)
|
||||||
{
|
{
|
||||||
/* Only send packet is link is up */
|
/* Only send packet is link is up */
|
||||||
if (netif->flags & NETIF_FLAG_LINK_UP)
|
if (netif->flags & NETIF_FLAG_LINK_UP)
|
||||||
|
@ -937,6 +922,28 @@ err_t lpc_etharp_output(struct netif *netif, struct pbuf *q,
|
||||||
|
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is the ethernet IPv6 packet send function. It calls
|
||||||
|
* etharp_output after checking link status.
|
||||||
|
*
|
||||||
|
* \param[in] netif the lwip network interface structure for this lpc_enetif
|
||||||
|
* \param[in] q Pointer to pbug to send
|
||||||
|
* \param[in] ipaddr IP address
|
||||||
|
* \return ERR_OK or error code
|
||||||
|
*/
|
||||||
|
#if LWIP_IPV6
|
||||||
|
err_t lpc_etharp_output_ipv6(struct netif *netif, struct pbuf *q,
|
||||||
|
const ip6_addr_t *ipaddr)
|
||||||
|
{
|
||||||
|
/* Only send packet is link is up */s
|
||||||
|
if (netif->flags & NETIF_FLAG_LINK_UP)
|
||||||
|
return ethip6_output(netif, q, ipaddr);
|
||||||
|
|
||||||
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#if NO_SYS == 0
|
#if NO_SYS == 0
|
||||||
/* periodic PHY status update */
|
/* periodic PHY status update */
|
||||||
|
@ -976,13 +983,19 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
#else
|
#else
|
||||||
mbed_mac_address((char *)netif->hwaddr);
|
mbed_mac_address((char *)netif->hwaddr);
|
||||||
#endif
|
#endif
|
||||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
netif->hwaddr_len = ETH_HWADDR_LEN;
|
||||||
|
|
||||||
/* maximum transfer unit */
|
/* maximum transfer unit */
|
||||||
netif->mtu = 1500;
|
netif->mtu = 1500;
|
||||||
|
|
||||||
/* device capabilities */
|
/* device capabilities */
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
||||||
|
#ifdef LWIP_IGMP
|
||||||
|
netif->flags |= NETIF_FLAG_IGMP;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6_MLD
|
||||||
|
netif->flags |= NETIF_FLAG_MLD6;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Initialize the hardware */
|
/* Initialize the hardware */
|
||||||
netif->state = &lpc_enetdata;
|
netif->state = &lpc_enetdata;
|
||||||
|
@ -998,7 +1011,13 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
netif->name[0] = 'e';
|
netif->name[0] = 'e';
|
||||||
netif->name[1] = 'n';
|
netif->name[1] = 'n';
|
||||||
|
|
||||||
netif->output = lpc_etharp_output;
|
#if LWIP_IPV4
|
||||||
|
netif->output = lpc_etharp_output_ipv4;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
netif->output_ip6 = lpc_etharp_output_ipv6;
|
||||||
|
#endif
|
||||||
|
|
||||||
netif->linkoutput = lpc_low_level_output;
|
netif->linkoutput = lpc_low_level_output;
|
||||||
|
|
||||||
/* CMSIS-RTOS, start tasks */
|
/* CMSIS-RTOS, start tasks */
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
#include "netif/etharp.h"
|
#include "netif/etharp.h"
|
||||||
|
#include "lwip/ethip6.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
#include "ethernet_api.h"
|
#include "ethernet_api.h"
|
||||||
#include "ethernetext_api.h"
|
#include "ethernetext_api.h"
|
||||||
|
@ -15,13 +16,17 @@ static sys_sem_t recv_ready_sem; /* receive ready semaphore */
|
||||||
/* function */
|
/* function */
|
||||||
static void rza1_recv_task(void *arg);
|
static void rza1_recv_task(void *arg);
|
||||||
static void rza1_phy_task(void *arg);
|
static void rza1_phy_task(void *arg);
|
||||||
static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
|
#if LWIP_IPV4
|
||||||
|
static err_t rza1_etharp_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
static err_t rza1_etharp_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr);
|
||||||
|
#endif
|
||||||
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p);
|
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p);
|
||||||
static void rza1_recv_callback(void);
|
static void rza1_recv_callback(void);
|
||||||
|
|
||||||
static void rza1_recv_task(void *arg) {
|
static void rza1_recv_task(void *arg) {
|
||||||
struct netif *netif = (struct netif*)arg;
|
struct netif *netif = (struct netif*)arg;
|
||||||
struct eth_hdr *ethhdr;
|
|
||||||
u16_t recv_size;
|
u16_t recv_size;
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
int cnt;
|
int cnt;
|
||||||
|
@ -34,25 +39,11 @@ static void rza1_recv_task(void *arg) {
|
||||||
p = pbuf_alloc(PBUF_RAW, recv_size, PBUF_RAM);
|
p = pbuf_alloc(PBUF_RAW, recv_size, PBUF_RAM);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
(void)ethernet_read((char *)p->payload, p->len);
|
(void)ethernet_read((char *)p->payload, p->len);
|
||||||
ethhdr = p->payload;
|
|
||||||
switch (htons(ethhdr->type)) {
|
|
||||||
case ETHTYPE_IP:
|
|
||||||
case ETHTYPE_ARP:
|
|
||||||
#if PPPOE_SUPPORT
|
|
||||||
case ETHTYPE_PPPOEDISC:
|
|
||||||
case ETHTYPE_PPPOE:
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
/* full packet send to tcpip_thread to process */
|
/* full packet send to tcpip_thread to process */
|
||||||
if (netif->input(p, netif) != ERR_OK) {
|
if (netif->input(p, netif) != ERR_OK) {
|
||||||
/* Free buffer */
|
/* Free buffer */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Return buffer */
|
|
||||||
pbuf_free(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -94,7 +85,8 @@ static void rza1_phy_task(void *arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr) {
|
#if LWIP_IPV4
|
||||||
|
static err_t rza1_etharp_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr) {
|
||||||
/* Only send packet is link is up */
|
/* Only send packet is link is up */
|
||||||
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
return etharp_output(netif, q, ipaddr);
|
return etharp_output(netif, q, ipaddr);
|
||||||
|
@ -102,6 +94,18 @@ static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *
|
||||||
|
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_IPV6
|
||||||
|
static err_t rza1_etharp_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr) {
|
||||||
|
/* Only send packet is link is up */
|
||||||
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
|
return ethip6_output(netif, q, ipaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p) {
|
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p) {
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
|
@ -150,13 +154,19 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
#else
|
#else
|
||||||
mbed_mac_address((char *)netif->hwaddr);
|
mbed_mac_address((char *)netif->hwaddr);
|
||||||
#endif
|
#endif
|
||||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
netif->hwaddr_len = ETH_HWADDR_LEN;
|
||||||
|
|
||||||
/* maximum transfer unit */
|
/* maximum transfer unit */
|
||||||
netif->mtu = 1500;
|
netif->mtu = 1500;
|
||||||
|
|
||||||
/* device capabilities */
|
/* device capabilities */
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
||||||
|
#ifdef LWIP_IGMP
|
||||||
|
netif->flags |= NETIF_FLAG_IGMP;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6_MLD
|
||||||
|
netif->flags |= NETIF_FLAG_MLD6;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
/* Initialize interface hostname */
|
/* Initialize interface hostname */
|
||||||
|
@ -166,7 +176,13 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
netif->name[0] = 'e';
|
netif->name[0] = 'e';
|
||||||
netif->name[1] = 'n';
|
netif->name[1] = 'n';
|
||||||
|
|
||||||
netif->output = rza1_etharp_output;
|
#if LWIP_IPV4
|
||||||
|
netif->output = rza1_etharp_output_ipv4;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
netif->output_ip6 = rza1_etharp_output_ipv6;
|
||||||
|
#endif
|
||||||
|
|
||||||
netif->linkoutput = rza1_low_level_output;
|
netif->linkoutput = rza1_low_level_output;
|
||||||
|
|
||||||
/* Initialize the hardware */
|
/* Initialize the hardware */
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
#include "lwip/timers.h"
|
|
||||||
#include "netif/etharp.h"
|
#include "netif/etharp.h"
|
||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
|
#include "lwip/ethip6.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
|
@ -40,7 +40,14 @@ static sys_mutex_t tx_lock_mutex;
|
||||||
/* function */
|
/* function */
|
||||||
static void _eth_arch_rx_task(void *arg);
|
static void _eth_arch_rx_task(void *arg);
|
||||||
static void _eth_arch_phy_task(void *arg);
|
static void _eth_arch_phy_task(void *arg);
|
||||||
static err_t _eth_arch_netif_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
|
|
||||||
|
#if LWIP_IPV4
|
||||||
|
static err_t _eth_arch_netif_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
static err_t _eth_arch_netif_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr);
|
||||||
|
#endif
|
||||||
|
|
||||||
static err_t _eth_arch_low_level_output(struct netif *netif, struct pbuf *p);
|
static err_t _eth_arch_low_level_output(struct netif *netif, struct pbuf *p);
|
||||||
static struct pbuf * _eth_arch_low_level_input(struct netif *netif);
|
static struct pbuf * _eth_arch_low_level_input(struct netif *netif);
|
||||||
|
|
||||||
|
@ -112,7 +119,7 @@ static void _eth_arch_low_level_init(struct netif *netif)
|
||||||
|
|
||||||
#if LWIP_ARP || LWIP_ETHERNET
|
#if LWIP_ARP || LWIP_ETHERNET
|
||||||
/* set MAC hardware address length */
|
/* set MAC hardware address length */
|
||||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
netif->hwaddr_len = ETH_HWADDR_LEN;
|
||||||
|
|
||||||
/* set MAC hardware address */
|
/* set MAC hardware address */
|
||||||
netif->hwaddr[0] = EthHandle.Init.MACAddr[0];
|
netif->hwaddr[0] = EthHandle.Init.MACAddr[0];
|
||||||
|
@ -356,7 +363,7 @@ static void _eth_arch_phy_task(void *arg)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function is the ethernet packet send function. It calls
|
* This function is the ethernet IPv4 packet send function. It calls
|
||||||
* etharp_output after checking link status.
|
* etharp_output after checking link status.
|
||||||
*
|
*
|
||||||
* \param[in] netif the lwip network interface structure for this lpc_enetif
|
* \param[in] netif the lwip network interface structure for this lpc_enetif
|
||||||
|
@ -364,7 +371,8 @@ static void _eth_arch_phy_task(void *arg)
|
||||||
* \param[in] ipaddr IP address
|
* \param[in] ipaddr IP address
|
||||||
* \return ERR_OK or error code
|
* \return ERR_OK or error code
|
||||||
*/
|
*/
|
||||||
static err_t _eth_arch_netif_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr)
|
#if LWIP_IPV4
|
||||||
|
static err_t _eth_arch_netif_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr)
|
||||||
{
|
{
|
||||||
/* Only send packet is link is up */
|
/* Only send packet is link is up */
|
||||||
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
|
@ -372,6 +380,27 @@ static err_t _eth_arch_netif_output(struct netif *netif, struct pbuf *q, ip_addr
|
||||||
}
|
}
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is the ethernet packet send function. It calls
|
||||||
|
* etharp_output after checking link status.
|
||||||
|
*
|
||||||
|
* \param[in] netif the lwip network IPv6 interface structure for this lpc_enetif
|
||||||
|
* \param[in] q Pointer to pbug to send
|
||||||
|
* \param[in] ipaddr IP address
|
||||||
|
* \return ERR_OK or error code
|
||||||
|
*/
|
||||||
|
#if LWIP_IPV6
|
||||||
|
static err_t _eth_arch_netif_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr)
|
||||||
|
{
|
||||||
|
/* Only send packet is link is up */
|
||||||
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
|
return ethip6_output(netif, q, ipaddr);
|
||||||
|
}
|
||||||
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should be called at the beginning of the program to set up the
|
* Should be called at the beginning of the program to set up the
|
||||||
|
@ -387,13 +416,13 @@ static err_t _eth_arch_netif_output(struct netif *netif, struct pbuf *q, ip_addr
|
||||||
err_t eth_arch_enetif_init(struct netif *netif)
|
err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
{
|
{
|
||||||
/* set MAC hardware address */
|
/* set MAC hardware address */
|
||||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
netif->hwaddr_len = ETH_HWADDR_LEN;
|
||||||
|
|
||||||
/* maximum transfer unit */
|
/* maximum transfer unit */
|
||||||
netif->mtu = 1500;
|
netif->mtu = 1500;
|
||||||
|
|
||||||
/* device capabilities */
|
/* device capabilities */
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
||||||
|
|
||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
/* Initialize interface hostname */
|
/* Initialize interface hostname */
|
||||||
|
@ -403,7 +432,15 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
netif->name[0] = 'e';
|
netif->name[0] = 'e';
|
||||||
netif->name[1] = 'n';
|
netif->name[1] = 'n';
|
||||||
|
|
||||||
netif->output = _eth_arch_netif_output;
|
#if LWIP_IPV4
|
||||||
|
netif->output = _eth_arch_netif_output_ipv4;
|
||||||
|
netif->flags |= NETIF_FLAG_IGMP;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
netif->output_ip6 = _eth_arch_netif_output_ipv6;
|
||||||
|
netif->flags |= NETIF_FLAG_MLD6;
|
||||||
|
#endif
|
||||||
|
|
||||||
netif->linkoutput = _eth_arch_low_level_output;
|
netif->linkoutput = _eth_arch_low_level_output;
|
||||||
|
|
||||||
/* semaphore */
|
/* semaphore */
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
#include "lwip/tcpip.h"
|
#include "lwip/tcpip.h"
|
||||||
#include "netif/etharp.h"
|
#include "netif/etharp.h"
|
||||||
|
#include "lwip/ethip6.h"
|
||||||
#include "mbed_interface.h"
|
#include "mbed_interface.h"
|
||||||
#include "ethernet_api.h"
|
#include "ethernet_api.h"
|
||||||
#include "ethernetext_api.h"
|
#include "ethernetext_api.h"
|
||||||
|
@ -15,13 +16,17 @@ static sys_sem_t recv_ready_sem; /* receive ready semaphore */
|
||||||
/* function */
|
/* function */
|
||||||
static void rza1_recv_task(void *arg);
|
static void rza1_recv_task(void *arg);
|
||||||
static void rza1_phy_task(void *arg);
|
static void rza1_phy_task(void *arg);
|
||||||
static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr);
|
#if LWIP_IPV4
|
||||||
|
static err_t rza1_etharp_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr);
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
static err_t rza1_etharp_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr);
|
||||||
|
#endif
|
||||||
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p);
|
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p);
|
||||||
static void rza1_recv_callback(void);
|
static void rza1_recv_callback(void);
|
||||||
|
|
||||||
static void rza1_recv_task(void *arg) {
|
static void rza1_recv_task(void *arg) {
|
||||||
struct netif *netif = (struct netif*)arg;
|
struct netif *netif = (struct netif*)arg;
|
||||||
struct eth_hdr *ethhdr;
|
|
||||||
u16_t recv_size;
|
u16_t recv_size;
|
||||||
struct pbuf *p;
|
struct pbuf *p;
|
||||||
int cnt;
|
int cnt;
|
||||||
|
@ -34,25 +39,11 @@ static void rza1_recv_task(void *arg) {
|
||||||
p = pbuf_alloc(PBUF_RAW, recv_size, PBUF_RAM);
|
p = pbuf_alloc(PBUF_RAW, recv_size, PBUF_RAM);
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
(void)ethernet_read((char *)p->payload, p->len);
|
(void)ethernet_read((char *)p->payload, p->len);
|
||||||
ethhdr = p->payload;
|
|
||||||
switch (htons(ethhdr->type)) {
|
|
||||||
case ETHTYPE_IP:
|
|
||||||
case ETHTYPE_ARP:
|
|
||||||
#if PPPOE_SUPPORT
|
|
||||||
case ETHTYPE_PPPOEDISC:
|
|
||||||
case ETHTYPE_PPPOE:
|
|
||||||
#endif /* PPPOE_SUPPORT */
|
|
||||||
/* full packet send to tcpip_thread to process */
|
/* full packet send to tcpip_thread to process */
|
||||||
if (netif->input(p, netif) != ERR_OK) {
|
if (netif->input(p, netif) != ERR_OK) {
|
||||||
/* Free buffer */
|
/* Free buffer */
|
||||||
pbuf_free(p);
|
pbuf_free(p);
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
default:
|
|
||||||
/* Return buffer */
|
|
||||||
pbuf_free(p);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
|
@ -94,7 +85,8 @@ static void rza1_phy_task(void *arg) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *ipaddr) {
|
#if LWIP_IPV4
|
||||||
|
static err_t rza1_etharp_output_ipv4(struct netif *netif, struct pbuf *q, const ip4_addr_t *ipaddr) {
|
||||||
/* Only send packet is link is up */
|
/* Only send packet is link is up */
|
||||||
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
return etharp_output(netif, q, ipaddr);
|
return etharp_output(netif, q, ipaddr);
|
||||||
|
@ -102,6 +94,18 @@ static err_t rza1_etharp_output(struct netif *netif, struct pbuf *q, ip_addr_t *
|
||||||
|
|
||||||
return ERR_CONN;
|
return ERR_CONN;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if LWIP_IPV6
|
||||||
|
static err_t rza1_etharp_output_ipv6(struct netif *netif, struct pbuf *q, const ip6_addr_t *ipaddr) {
|
||||||
|
/* Only send packet is link is up */
|
||||||
|
if (netif->flags & NETIF_FLAG_LINK_UP) {
|
||||||
|
return ethip6_output(netif, q, ipaddr);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ERR_CONN;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p) {
|
static err_t rza1_low_level_output(struct netif *netif, struct pbuf *p) {
|
||||||
struct pbuf *q;
|
struct pbuf *q;
|
||||||
|
@ -150,13 +154,19 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
#else
|
#else
|
||||||
mbed_mac_address((char *)netif->hwaddr);
|
mbed_mac_address((char *)netif->hwaddr);
|
||||||
#endif
|
#endif
|
||||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
netif->hwaddr_len = ETH_HWADDR_LEN;
|
||||||
|
|
||||||
/* maximum transfer unit */
|
/* maximum transfer unit */
|
||||||
netif->mtu = 1500;
|
netif->mtu = 1500;
|
||||||
|
|
||||||
/* device capabilities */
|
/* device capabilities */
|
||||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP;
|
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET;
|
||||||
|
#ifdef LWIP_IGMP
|
||||||
|
netif->flags |= NETIF_FLAG_IGMP;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6_MLD
|
||||||
|
netif->flags |= NETIF_FLAG_MLD6;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if LWIP_NETIF_HOSTNAME
|
#if LWIP_NETIF_HOSTNAME
|
||||||
/* Initialize interface hostname */
|
/* Initialize interface hostname */
|
||||||
|
@ -166,7 +176,13 @@ err_t eth_arch_enetif_init(struct netif *netif)
|
||||||
netif->name[0] = 'e';
|
netif->name[0] = 'e';
|
||||||
netif->name[1] = 'n';
|
netif->name[1] = 'n';
|
||||||
|
|
||||||
netif->output = rza1_etharp_output;
|
#if LWIP_IPV4
|
||||||
|
netif->output = rza1_etharp_output_ipv4;
|
||||||
|
#endif
|
||||||
|
#if LWIP_IPV6
|
||||||
|
netif->output_ip6 = rza1_etharp_output_ipv6;
|
||||||
|
#endif
|
||||||
|
|
||||||
netif->linkoutput = rza1_low_level_output;
|
netif->linkoutput = rza1_low_level_output;
|
||||||
|
|
||||||
/* Initialize the hardware */
|
/* Initialize the hardware */
|
||||||
|
|
|
@ -29,6 +29,49 @@
|
||||||
#include "lwip/sys.h"
|
#include "lwip/sys.h"
|
||||||
#include "lwip/mem.h"
|
#include "lwip/mem.h"
|
||||||
|
|
||||||
|
/* Define the heap ourselves to give us section placement control */
|
||||||
|
#ifndef ETHMEM_SECTION
|
||||||
|
#if defined(TARGET_LPC4088) || defined(TARGET_LPC4088_DM)
|
||||||
|
# if defined (__ICCARM__)
|
||||||
|
# define ETHMEM_SECTION
|
||||||
|
# elif defined(TOOLCHAIN_GCC_CR)
|
||||||
|
# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32")))
|
||||||
|
# else
|
||||||
|
# define ETHMEM_SECTION __attribute__((section("AHBSRAM1"),aligned))
|
||||||
|
# endif
|
||||||
|
#elif defined(TARGET_LPC1768)
|
||||||
|
# if defined (__ICCARM__)
|
||||||
|
# define ETHMEM_SECTION
|
||||||
|
# elif defined(TOOLCHAIN_GCC_CR)
|
||||||
|
# define ETHMEM_SECTION __attribute__((section(".data.$RamPeriph32")))
|
||||||
|
# else
|
||||||
|
# define ETHMEM_SECTION __attribute__((section("AHBSRAM0"),aligned))
|
||||||
|
# endif
|
||||||
|
#else
|
||||||
|
#define ETHMEM_SECTION
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* LWIP's mem.c doesn't give visibility of its overhead; memory area has to be big
|
||||||
|
* enough to hold "MEM_SIZE" (which we specify) plus mem.c's overhead. Have to work
|
||||||
|
* it all out here, copying code from mem.c */
|
||||||
|
struct mem {
|
||||||
|
/** index (-> ram[next]) of the next struct */
|
||||||
|
mem_size_t next;
|
||||||
|
/** index (-> ram[prev]) of the previous struct */
|
||||||
|
mem_size_t prev;
|
||||||
|
/** 1: this area is used; 0: this area is unused */
|
||||||
|
u8_t used;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define SIZEOF_STRUCT_MEM LWIP_MEM_ALIGN_SIZE(sizeof(struct mem))
|
||||||
|
#define MEM_SIZE_ALIGNED LWIP_MEM_ALIGN_SIZE(MEM_SIZE)
|
||||||
|
|
||||||
|
#if defined (__ICCARM__)
|
||||||
|
#pragma location = ".ethusbram"
|
||||||
|
#endif
|
||||||
|
LWIP_DECLARE_MEMORY_ALIGNED(lwip_ram_heap, MEM_SIZE_ALIGNED + (2U*SIZEOF_STRUCT_MEM)) ETHMEM_SECTION;
|
||||||
|
|
||||||
#if NO_SYS==1
|
#if NO_SYS==1
|
||||||
#include "cmsis.h"
|
#include "cmsis.h"
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
|
|
||||||
#include "lwip/opt.h"
|
#include "lwip/opt.h"
|
||||||
|
|
||||||
|
extern u8_t lwip_ram_heap[];
|
||||||
|
|
||||||
#if NO_SYS == 0
|
#if NO_SYS == 0
|
||||||
#include "cmsis_os.h"
|
#include "cmsis_os.h"
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
# These files are text and should be normalized
|
||||||
|
*.txt text
|
||||||
|
*.c text
|
||||||
|
*.h text
|
|
@ -0,0 +1,13 @@
|
||||||
|
/doc/doxygen/output
|
||||||
|
/src/apps/snmp/LwipMibCompiler/CCodeGeneration/bin/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/CCodeGeneration/obj/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/bin/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler/obj/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/MibViewer/bin/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/MibViewer/obj/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/bin/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/LwipSnmpCodeGeneration/obj/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/SharpSnmpLib/bin/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/SharpSnmpLib/obj/
|
||||||
|
/src/apps/snmp/LwipMibCompiler/LwipMibCompiler.userprefs
|
||||||
|
/src/apps/snmp/LwipMibCompiler/*.suo
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,33 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification,
|
||||||
|
* are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
* 3. The name of the author may not be used to endorse or promote products
|
||||||
|
* derived from this software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||||
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||||
|
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||||
|
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
||||||
|
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||||
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||||
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||||
|
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||||
|
* OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* This file is part of the lwIP TCP/IP stack.
|
||||||
|
*
|
||||||
|
* Author: Adam Dunkels <adam@sics.se>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
src/ - The source code for the lwIP TCP/IP stack.
|
||||||
|
doc/ - The documentation for lwIP.
|
||||||
|
|
||||||
|
See also the FILES file in each subdirectory.
|
|
@ -0,0 +1,97 @@
|
||||||
|
INTRODUCTION
|
||||||
|
|
||||||
|
lwIP is a small independent implementation of the TCP/IP protocol
|
||||||
|
suite that has been developed by Adam Dunkels at the Computer and
|
||||||
|
Networks Architectures (CNA) lab at the Swedish Institute of Computer
|
||||||
|
Science (SICS).
|
||||||
|
|
||||||
|
The focus of the lwIP TCP/IP implementation is to reduce the RAM usage
|
||||||
|
while still having a full scale TCP. This making lwIP suitable for use
|
||||||
|
in embedded systems with tens of kilobytes of free RAM and room for
|
||||||
|
around 40 kilobytes of code ROM.
|
||||||
|
|
||||||
|
|
||||||
|
FEATURES
|
||||||
|
|
||||||
|
* IP (Internet Protocol, IPv4 and IPv6) including packet forwarding over
|
||||||
|
multiple network interfaces
|
||||||
|
* ICMP (Internet Control Message Protocol) for network maintenance and debugging
|
||||||
|
* IGMP (Internet Group Management Protocol) for multicast traffic management
|
||||||
|
* MLD (Multicast listener discovery for IPv6). Aims to be compliant with
|
||||||
|
RFC 2710. No support for MLDv2
|
||||||
|
* ND (Neighbor discovery and stateless address autoconfiguration for IPv6).
|
||||||
|
Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862
|
||||||
|
(Address autoconfiguration)
|
||||||
|
* UDP (User Datagram Protocol) including experimental UDP-lite extensions
|
||||||
|
* TCP (Transmission Control Protocol) with congestion control, RTT estimation
|
||||||
|
and fast recovery/fast retransmit
|
||||||
|
* raw/native API for enhanced performance
|
||||||
|
* Optional Berkeley-like socket API
|
||||||
|
* DNS (Domain names resolver)
|
||||||
|
|
||||||
|
|
||||||
|
APPLICATIONS
|
||||||
|
|
||||||
|
* HTTP server with SSI and CGI
|
||||||
|
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol)
|
||||||
|
* SNTP (Simple network time protocol)
|
||||||
|
|
||||||
|
|
||||||
|
LICENSE
|
||||||
|
|
||||||
|
lwIP is freely available under a BSD license.
|
||||||
|
|
||||||
|
|
||||||
|
DEVELOPMENT
|
||||||
|
|
||||||
|
lwIP has grown into an excellent TCP/IP stack for embedded devices,
|
||||||
|
and developers using the stack often submit bug fixes, improvements,
|
||||||
|
and additions to the stack to further increase its usefulness.
|
||||||
|
|
||||||
|
Development of lwIP is hosted on Savannah, a central point for
|
||||||
|
software development, maintenance and distribution. Everyone can
|
||||||
|
help improve lwIP by use of Savannah's interface, Git and the
|
||||||
|
mailing list. A core team of developers will commit changes to the
|
||||||
|
Git source tree.
|
||||||
|
|
||||||
|
The lwIP TCP/IP stack is maintained in the 'lwip' Git module and
|
||||||
|
contributions (such as platform ports) are in the 'contrib' Git module.
|
||||||
|
|
||||||
|
See doc/savannah.txt for details on Git server access for users and
|
||||||
|
developers.
|
||||||
|
|
||||||
|
The current Git trees are web-browsable:
|
||||||
|
http://git.savannah.gnu.org/cgit/lwip.git
|
||||||
|
http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git
|
||||||
|
|
||||||
|
Submit patches and bugs via the lwIP project page:
|
||||||
|
http://savannah.nongnu.org/projects/lwip/
|
||||||
|
|
||||||
|
Continuous integration builds (GCC, clang):
|
||||||
|
https://travis-ci.org/yarrick/lwip-merged
|
||||||
|
|
||||||
|
|
||||||
|
DOCUMENTATION
|
||||||
|
|
||||||
|
Self documentation of the source code is regularly extracted from the current
|
||||||
|
Git sources and is available from this web page:
|
||||||
|
http://www.nongnu.org/lwip/
|
||||||
|
|
||||||
|
There is now a constantly growin wiki about lwIP at
|
||||||
|
http://lwip.wikia.com/wiki/LwIP_Wiki
|
||||||
|
|
||||||
|
Also, there are mailing lists you can subscribe at
|
||||||
|
http://savannah.nongnu.org/mail/?group=lwip
|
||||||
|
plus searchable archives:
|
||||||
|
http://lists.nongnu.org/archive/html/lwip-users/
|
||||||
|
http://lists.nongnu.org/archive/html/lwip-devel/
|
||||||
|
|
||||||
|
lwIP was originally written by Adam Dunkels:
|
||||||
|
http://dunkels.com/adam/
|
||||||
|
|
||||||
|
Reading Adam's papers, the files in docs/, browsing the source code
|
||||||
|
documentation and browsing the mailing list archives is a good way to
|
||||||
|
become familiar with the design of lwIP.
|
||||||
|
|
||||||
|
Adam Dunkels <adam@sics.se>
|
||||||
|
Leon Woestenberg <leon.woestenberg@gmx.net>
|
|
@ -0,0 +1,217 @@
|
||||||
|
This file lists major changes between release versions that require
|
||||||
|
ports or applications to be changed. Use it to update a port or an
|
||||||
|
application written for an older version of lwIP to correctly work
|
||||||
|
with newer versions.
|
||||||
|
|
||||||
|
|
||||||
|
(git master)
|
||||||
|
|
||||||
|
* [Enter new changes just after this line - do not remove this line]
|
||||||
|
|
||||||
|
* TODO
|
||||||
|
|
||||||
|
(2.0.0)
|
||||||
|
|
||||||
|
++ Application changes:
|
||||||
|
|
||||||
|
* Changed netif "up" flag handling to be an administrative flag (as opposed to the previous meaning of
|
||||||
|
"ip4-address-valid", a netif will now not be used for transmission if not up) -> even a DHCP netif
|
||||||
|
has to be set "up" before starting the DHCP client
|
||||||
|
* Added IPv6 support (dual-stack or IPv4/IPv6 only)
|
||||||
|
* Changed ip_addr_t to be a union in dual-stack mode (use ip4_addr_t where referring to IPv4 only).
|
||||||
|
* Major rewrite of SNMP (added MIB parser that creates code stubs for custom MIBs);
|
||||||
|
supports SNMP2vc (experimental v3 support)
|
||||||
|
* Moved some core applications from contrib repository to src/apps (and include/lwip/apps)
|
||||||
|
|
||||||
|
+++ Raw API:
|
||||||
|
* Changed TCP listen backlog: removed tcp_accepted(), added the function pair tcp_backlog_delayed()/
|
||||||
|
tcp_backlog_accepted() to explicitly delay backlog handling on a connection pcb
|
||||||
|
|
||||||
|
+++ Socket API:
|
||||||
|
* Added an implementation for posix sendmsg()
|
||||||
|
* Added LWIP_FIONREAD_LINUXMODE that makes ioctl/FIONREAD return the size of the next pending datagram
|
||||||
|
|
||||||
|
++ Port changes
|
||||||
|
|
||||||
|
+++ new files:
|
||||||
|
* MANY new and moved files!
|
||||||
|
* Continued moving stack-internal parts from abc.h to abc_priv.h in sub-folder "priv"
|
||||||
|
to let abc.h only contain the actual application programmer's API
|
||||||
|
|
||||||
|
+++ sys layer:
|
||||||
|
* Made LWIP_TCPIP_CORE_LOCKING==1 the default as it usually performs better than
|
||||||
|
the traditional message passing (although with LWIP_COMPAT_MUTEX you are still
|
||||||
|
open to priority inversion, so this is not recommended any more)
|
||||||
|
* Added LWIP_NETCONN_SEM_PER_THREAD to use one "op_completed" semaphore per thread
|
||||||
|
instead of using one per netconn (these semaphores are used even with core locking
|
||||||
|
enabled as some longer lasting functions like big writes still need to delay)
|
||||||
|
|
||||||
|
+++ new options:
|
||||||
|
* TODO
|
||||||
|
|
||||||
|
+++ new pools:
|
||||||
|
* Added LWIP_MEMPOOL_* (declare/init/alloc/free) to declare private memp pools
|
||||||
|
that share memp.c code but do not have to be made global via lwippools.h
|
||||||
|
* Added pools for IPv6, MPU_COMPATIBLE, dns-api, netif-api, etc.
|
||||||
|
* added hook LWIP_HOOK_MEMP_AVAILABLE() to get informed when a memp pool was empty and an item
|
||||||
|
is now available
|
||||||
|
|
||||||
|
* LWIP_DECLARE_MEMORY_ALIGNED() may be used to declare aligned memory buffers (mem/memp)
|
||||||
|
or to move buffers to dedicated memory using compiler attributes
|
||||||
|
|
||||||
|
* Standard C headers are used to define sized types and printf formatters
|
||||||
|
(disable by setting LWIP_NO_STDINT_H=1 or LWIP_NO_INTTYPES_H=1 if your compiler
|
||||||
|
does not support these)
|
||||||
|
|
||||||
|
|
||||||
|
++ Major bugfixes/improvements
|
||||||
|
|
||||||
|
* Added IPv6 support (dual-stack or IPv4/IPv6 only)
|
||||||
|
* Major rewrite of PPP (incl. keep-up with apache pppd)
|
||||||
|
* Major rewrite of SNMP (incl. MIB parser)
|
||||||
|
* Fixed timing issues that might have lead to losing a DHCP lease
|
||||||
|
* Made rx processing path more robust against crafted errors
|
||||||
|
* TCP window scaling support
|
||||||
|
* modification of api modules to support FreeRTOS-MPU (don't pass stack-pointers to other threads)
|
||||||
|
* made DNS client more robust
|
||||||
|
* support PBUF_REF for RX packets
|
||||||
|
* LWIP_NETCONN_FULLDUPLEX allows netconn/sockets to be used for reading/writing from separate
|
||||||
|
threads each (needs LWIP_NETCONN_SEM_PER_THREAD)
|
||||||
|
* Moved and reorderd stats (mainly memp/mib2)
|
||||||
|
|
||||||
|
(1.4.0)
|
||||||
|
|
||||||
|
++ Application changes:
|
||||||
|
|
||||||
|
* Replaced struct ip_addr by typedef ip_addr_t (struct ip_addr is kept for
|
||||||
|
compatibility to old applications, but will be removed in the future).
|
||||||
|
|
||||||
|
* Renamed mem_realloc() to mem_trim() to prevent confusion with realloc()
|
||||||
|
|
||||||
|
+++ Raw API:
|
||||||
|
* Changed the semantics of tcp_close() (since it was rather a
|
||||||
|
shutdown before): Now the application does *NOT* get any calls to the recv
|
||||||
|
callback (aside from NULL/closed) after calling tcp_close()
|
||||||
|
|
||||||
|
* When calling tcp_abort() from a raw API TCP callback function,
|
||||||
|
make sure you return ERR_ABRT to prevent accessing unallocated memory.
|
||||||
|
(ERR_ABRT now means the applicaiton has called tcp_abort!)
|
||||||
|
|
||||||
|
+++ Netconn API:
|
||||||
|
* Changed netconn_receive() and netconn_accept() to return
|
||||||
|
err_t, not a pointer to new data/netconn.
|
||||||
|
|
||||||
|
+++ Socket API:
|
||||||
|
* LWIP_SO_RCVTIMEO: when accept() or recv() time out, they
|
||||||
|
now set errno to EWOULDBLOCK/EAGAIN, not ETIMEDOUT.
|
||||||
|
|
||||||
|
* Added a minimal version of posix fctl() to have a
|
||||||
|
standardised way to set O_NONBLOCK for nonblocking sockets.
|
||||||
|
|
||||||
|
+++ all APIs:
|
||||||
|
* correctly implemented SO(F)_REUSEADDR
|
||||||
|
|
||||||
|
++ Port changes
|
||||||
|
|
||||||
|
+++ new files:
|
||||||
|
|
||||||
|
* Added 4 new files: def.c, timers.c, timers.h, tcp_impl.h:
|
||||||
|
|
||||||
|
* Moved stack-internal parts of tcp.h to tcp_impl.h, tcp.h now only contains
|
||||||
|
the actual application programmer's API
|
||||||
|
|
||||||
|
* Separated timer implementation from sys.h/.c, moved to timers.h/.c;
|
||||||
|
Added timer implementation for NO_SYS==1, set NO_SYS_NO_TIMERS==1 if you
|
||||||
|
still want to use your own timer implementation for NO_SYS==0 (as before).
|
||||||
|
|
||||||
|
+++ sys layer:
|
||||||
|
|
||||||
|
* Converted mbox- and semaphore-functions to take pointers to sys_mbox_t/
|
||||||
|
sys_sem_t;
|
||||||
|
|
||||||
|
* Converted sys_mbox_new/sys_sem_new to take pointers and return err_t;
|
||||||
|
|
||||||
|
* Added Mutex concept in sys_arch (define LWIP_COMPAT_MUTEX to let sys.h use
|
||||||
|
binary semaphores instead of mutexes - as before)
|
||||||
|
|
||||||
|
+++ new options:
|
||||||
|
|
||||||
|
* Don't waste memory when chaining segments, added option TCP_OVERSIZE to
|
||||||
|
prevent creating many small pbufs when calling tcp_write with many small
|
||||||
|
blocks of data. Instead, pbufs are allocated larger than needed and the
|
||||||
|
space is used for later calls to tcp_write.
|
||||||
|
|
||||||
|
* Added LWIP_NETIF_TX_SINGLE_PBUF to always copy to try to create single pbufs
|
||||||
|
in tcp_write/udp_send.
|
||||||
|
|
||||||
|
* Added an additional option LWIP_ETHERNET to support ethernet without ARP
|
||||||
|
(necessary for pure PPPoE)
|
||||||
|
|
||||||
|
* Add MEMP_SEPARATE_POOLS to place memory pools in separate arrays. This may
|
||||||
|
be used to place these pools into user-defined memory by using external
|
||||||
|
declaration.
|
||||||
|
|
||||||
|
* Added TCP_SNDQUEUELOWAT corresponding to TCP_SNDLOWAT
|
||||||
|
|
||||||
|
+++ new pools:
|
||||||
|
|
||||||
|
* Netdb uses a memp pool for allocating memory when getaddrinfo() is called,
|
||||||
|
so MEMP_NUM_NETDB has to be set accordingly.
|
||||||
|
|
||||||
|
* DNS_LOCAL_HOSTLIST_IS_DYNAMIC uses a memp pool instead of the heap, so
|
||||||
|
MEMP_NUM_LOCALHOSTLIST has to be set accordingly.
|
||||||
|
|
||||||
|
* Snmp-agent uses a memp pools instead of the heap, so MEMP_NUM_SNMP_* have
|
||||||
|
to be set accordingly.
|
||||||
|
|
||||||
|
* PPPoE uses a MEMP pool instead of the heap, so MEMP_NUM_PPPOE_INTERFACES
|
||||||
|
has to be set accordingly
|
||||||
|
|
||||||
|
* Integrated loopif into netif.c - loopif does not have to be created by the
|
||||||
|
port any more, just define LWIP_HAVE_LOOPIF to 1.
|
||||||
|
|
||||||
|
* Added define LWIP_RAND() for lwip-wide randomization (needs to be defined
|
||||||
|
in cc.h, e.g. used by igmp)
|
||||||
|
|
||||||
|
* Added printf-formatter X8_F to printf u8_t as hex
|
||||||
|
|
||||||
|
* The heap now may be moved to user-defined memory by defining
|
||||||
|
LWIP_RAM_HEAP_POINTER as a void pointer to that memory's address
|
||||||
|
|
||||||
|
* added autoip_set_struct() and dhcp_set_struct() to let autoip and dhcp work
|
||||||
|
with user-allocated structs instead of calling mem_malloc
|
||||||
|
|
||||||
|
* Added const char* name to mem- and memp-stats for easier debugging.
|
||||||
|
|
||||||
|
* Calculate the TCP/UDP checksum while copying to only fetch data once:
|
||||||
|
Define LWIP_CHKSUM_COPY to a memcpy-like function that returns the checksum
|
||||||
|
|
||||||
|
* Added SO_REUSE_RXTOALL to pass received UDP broadcast/multicast packets to
|
||||||
|
more than one pcb.
|
||||||
|
|
||||||
|
* Changed the semantics of ARP_QUEUEING==0: ARP_QUEUEING now cannot be turned
|
||||||
|
off any more, if this is set to 0, only one packet (the most recent one) is
|
||||||
|
queued (like demanded by RFC 1122).
|
||||||
|
|
||||||
|
|
||||||
|
++ Major bugfixes/improvements
|
||||||
|
|
||||||
|
* Implemented tcp_shutdown() to only shut down one end of a connection
|
||||||
|
* Implemented shutdown() at socket- and netconn-level
|
||||||
|
* Added errorset support to select() + improved select speed overhead
|
||||||
|
* Merged pppd to v2.3.11 (including some backported bugfixes from 2.4.x)
|
||||||
|
* Added timer implementation for NO_SYS==1 (may be disabled with NO_SYS_NO_TIMERS==1
|
||||||
|
* Use macros defined in ip_addr.h to work with IP addresses
|
||||||
|
* Implemented many nonblocking socket/netconn functions
|
||||||
|
* Fixed ARP input processing: only add a new entry if a request was directed as us
|
||||||
|
* mem_realloc() to mem_trim() to prevent confusion with realloc()
|
||||||
|
* Some improvements for AutoIP (don't route/forward link-local addresses, don't break
|
||||||
|
existing connections when assigning a routable address)
|
||||||
|
* Correctly handle remote side overrunning our rcv_wnd in ooseq case
|
||||||
|
* Removed packing from ip_addr_t, the packed version is now only used in protocol headers
|
||||||
|
* Corrected PBUF_POOL_BUFSIZE for ports where ETH_PAD_SIZE > 0
|
||||||
|
* Added support for static ARP table entries
|
||||||
|
|
||||||
|
(STABLE-1.3.2)
|
||||||
|
|
||||||
|
* initial version of this file
|
|
@ -1,160 +0,0 @@
|
||||||
/**
|
|
||||||
* @file
|
|
||||||
* Network Interface Sequential API module
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Redistribution and use in source and binary forms, with or without modification,
|
|
||||||
* are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
* 3. The name of the author may not be used to endorse or promote products
|
|
||||||
* derived from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
||||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
||||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
|
||||||
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
|
|
||||||
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
||||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
||||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
|
||||||
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
|
||||||
* OF SUCH DAMAGE.
|
|
||||||
*
|
|
||||||
* This file is part of the lwIP TCP/IP stack.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "lwip/opt.h"
|
|
||||||
|
|
||||||
#if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */
|
|
||||||
|
|
||||||
#include "lwip/netifapi.h"
|
|
||||||
#include "lwip/tcpip.h"
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call netif_add() inside the tcpip_thread context.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
do_netifapi_netif_add(struct netifapi_msg_msg *msg)
|
|
||||||
{
|
|
||||||
if (!netif_add( msg->netif,
|
|
||||||
msg->msg.add.ipaddr,
|
|
||||||
msg->msg.add.netmask,
|
|
||||||
msg->msg.add.gw,
|
|
||||||
msg->msg.add.state,
|
|
||||||
msg->msg.add.init,
|
|
||||||
msg->msg.add.input)) {
|
|
||||||
msg->err = ERR_IF;
|
|
||||||
} else {
|
|
||||||
msg->err = ERR_OK;
|
|
||||||
}
|
|
||||||
TCPIP_NETIFAPI_ACK(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call netif_set_addr() inside the tcpip_thread context.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
do_netifapi_netif_set_addr(struct netifapi_msg_msg *msg)
|
|
||||||
{
|
|
||||||
netif_set_addr( msg->netif,
|
|
||||||
msg->msg.add.ipaddr,
|
|
||||||
msg->msg.add.netmask,
|
|
||||||
msg->msg.add.gw);
|
|
||||||
msg->err = ERR_OK;
|
|
||||||
TCPIP_NETIFAPI_ACK(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) inside the
|
|
||||||
* tcpip_thread context.
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
do_netifapi_netif_common(struct netifapi_msg_msg *msg)
|
|
||||||
{
|
|
||||||
if (msg->msg.common.errtfunc != NULL) {
|
|
||||||
msg->err = msg->msg.common.errtfunc(msg->netif);
|
|
||||||
} else {
|
|
||||||
msg->err = ERR_OK;
|
|
||||||
msg->msg.common.voidfunc(msg->netif);
|
|
||||||
}
|
|
||||||
TCPIP_NETIFAPI_ACK(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call netif_add() in a thread-safe way by running that function inside the
|
|
||||||
* tcpip_thread context.
|
|
||||||
*
|
|
||||||
* @note for params @see netif_add()
|
|
||||||
*/
|
|
||||||
err_t
|
|
||||||
netifapi_netif_add(struct netif *netif,
|
|
||||||
ip_addr_t *ipaddr,
|
|
||||||
ip_addr_t *netmask,
|
|
||||||
ip_addr_t *gw,
|
|
||||||
void *state,
|
|
||||||
netif_init_fn init,
|
|
||||||
netif_input_fn input)
|
|
||||||
{
|
|
||||||
struct netifapi_msg msg;
|
|
||||||
msg.function = do_netifapi_netif_add;
|
|
||||||
msg.msg.netif = netif;
|
|
||||||
msg.msg.msg.add.ipaddr = ipaddr;
|
|
||||||
msg.msg.msg.add.netmask = netmask;
|
|
||||||
msg.msg.msg.add.gw = gw;
|
|
||||||
msg.msg.msg.add.state = state;
|
|
||||||
msg.msg.msg.add.init = init;
|
|
||||||
msg.msg.msg.add.input = input;
|
|
||||||
TCPIP_NETIFAPI(&msg);
|
|
||||||
return msg.msg.err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Call netif_set_addr() in a thread-safe way by running that function inside the
|
|
||||||
* tcpip_thread context.
|
|
||||||
*
|
|
||||||
* @note for params @see netif_set_addr()
|
|
||||||
*/
|
|
||||||
err_t
|
|
||||||
netifapi_netif_set_addr(struct netif *netif,
|
|
||||||
ip_addr_t *ipaddr,
|
|
||||||
ip_addr_t *netmask,
|
|
||||||
ip_addr_t *gw)
|
|
||||||
{
|
|
||||||
struct netifapi_msg msg;
|
|
||||||
msg.function = do_netifapi_netif_set_addr;
|
|
||||||
msg.msg.netif = netif;
|
|
||||||
msg.msg.msg.add.ipaddr = ipaddr;
|
|
||||||
msg.msg.msg.add.netmask = netmask;
|
|
||||||
msg.msg.msg.add.gw = gw;
|
|
||||||
TCPIP_NETIFAPI(&msg);
|
|
||||||
return msg.msg.err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* call the "errtfunc" (or the "voidfunc" if "errtfunc" is NULL) in a thread-safe
|
|
||||||
* way by running that function inside the tcpip_thread context.
|
|
||||||
*
|
|
||||||
* @note use only for functions where there is only "netif" parameter.
|
|
||||||
*/
|
|
||||||
err_t
|
|
||||||
netifapi_netif_common(struct netif *netif, netifapi_void_fn voidfunc,
|
|
||||||
netifapi_errt_fn errtfunc)
|
|
||||||
{
|
|
||||||
struct netifapi_msg msg;
|
|
||||||
msg.function = do_netifapi_netif_common;
|
|
||||||
msg.msg.netif = netif;
|
|
||||||
msg.msg.msg.common.voidfunc = voidfunc;
|
|
||||||
msg.msg.msg.common.errtfunc = errtfunc;
|
|
||||||
TCPIP_NETIFAPI(&msg);
|
|
||||||
return msg.msg.err;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif /* LWIP_NETIF_API */
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue