Compare commits
27 Commits
STABLE-2_1
...
v2.1.3-amb
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6297b80812 | ||
|
|
5d6edaaaf0 | ||
|
|
26fed6b1a7 | ||
|
|
be44894e32 | ||
|
|
57abad9790 | ||
|
|
3bf1dde1df | ||
|
|
6ca936f6b5 | ||
|
|
e7b74570d9 | ||
|
|
018c64ab94 | ||
|
|
7e92fb3d7f | ||
|
|
051fbea5e6 | ||
|
|
214e2d90f3 | ||
|
|
4022a19cbc | ||
|
|
a32ea1e793 | ||
|
|
f67f2692d4 | ||
|
|
3b745f7154 | ||
|
|
d876d3c4df | ||
|
|
e8b0c52806 | ||
|
|
5bd7518343 | ||
|
|
51265f3f7d | ||
|
|
2e4932f23b | ||
|
|
dbd0bc8a2c | ||
|
|
e5627ec649 | ||
|
|
5c8fd3158d | ||
|
|
d5843944cc | ||
|
|
f62be85576 | ||
|
|
f1bd63046e |
6
.gitattributes
vendored
6
.gitattributes
vendored
@@ -2,3 +2,9 @@
|
||||
*.txt text
|
||||
*.c text
|
||||
*.h text
|
||||
|
||||
# For git archive
|
||||
.gitignore export-ignore
|
||||
.gitattributes export-ignore
|
||||
.travis.yml export-ignore
|
||||
.vscode export-ignore
|
||||
|
||||
@@ -38,7 +38,7 @@ PROJECT_NAME = "lwIP"
|
||||
# could be handy for archiving the generated documentation or if some version
|
||||
# control system is used.
|
||||
|
||||
PROJECT_NUMBER = "2.1.3.rc1"
|
||||
PROJECT_NUMBER = "2.1.3"
|
||||
|
||||
# Using the PROJECT_BRIEF tag one can provide an optional one line description
|
||||
# for a project that appears at the top of each page and should give viewer a
|
||||
|
||||
5
package.json
Normal file
5
package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "library-lwip",
|
||||
"version": "2.1.3-amb1",
|
||||
"description": "lwIP - A Lightweight TCPIP stack"
|
||||
}
|
||||
36
port/realtek/arch/bpstruct.h
Normal file
36
port/realtek/arch/bpstruct.h
Normal file
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)|| defined (__GNUC__)
|
||||
#pragma pack(1)
|
||||
#endif
|
||||
|
||||
95
port/realtek/arch/cc.h
Normal file
95
port/realtek/arch/cc.h
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
#ifndef __CC_H__
|
||||
#define __CC_H__
|
||||
|
||||
#include "cpu.h"
|
||||
|
||||
typedef int sys_prot_t;
|
||||
|
||||
#define U16_F "d"
|
||||
#define S16_F "d"
|
||||
#define X16_F "x"
|
||||
#define U32_F "d"
|
||||
#define S32_F "d"
|
||||
#define X32_F "x"
|
||||
#define SZT_F "uz"
|
||||
|
||||
/* define compiler specific symbols */
|
||||
#if defined (__ICCARM__)
|
||||
#if !defined (__IARSTDLIB__)
|
||||
#define _STRING
|
||||
#ifndef memcmp
|
||||
#define memcmp(dst, src, sz) _memcmp(dst, src, sz)
|
||||
#endif
|
||||
#ifndef memset
|
||||
#define memset(dst, val, sz) _memset(dst, val, sz)
|
||||
#endif
|
||||
#ifndef memcpy
|
||||
#define memcpy(dst, src, sz) _memcpy(dst, src, sz)
|
||||
#endif
|
||||
#endif // __IARSTDLIB__
|
||||
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_END
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_USE_INCLUDES
|
||||
|
||||
#elif defined (__CC_ARM)
|
||||
|
||||
#define PACK_STRUCT_BEGIN __packed
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_END
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
|
||||
#elif defined (__GNUC__)
|
||||
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
|
||||
#define PACK_STRUCT_END
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_USE_INCLUDES
|
||||
|
||||
#elif defined (__TASKING__)
|
||||
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_STRUCT
|
||||
#define PACK_STRUCT_END
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
|
||||
#endif
|
||||
|
||||
#define LWIP_PLATFORM_ASSERT(x) //do { if(!(x)) while(1); } while(0)
|
||||
#define LWIP_PLATFORM_DIAG printf
|
||||
|
||||
#endif /* __CC_H__ */
|
||||
37
port/realtek/arch/cpu.h
Normal file
37
port/realtek/arch/cpu.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
#ifndef __CPU_H__
|
||||
#define __CPU_H__
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
#endif /* __CPU_H__ */
|
||||
38
port/realtek/arch/epstruct.h
Normal file
38
port/realtek/arch/epstruct.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
|
||||
#if defined(__IAR_SYSTEMS_ICC__)
|
||||
#pragma pack()
|
||||
#elif defined (__GNUC__)
|
||||
#pragma pack()
|
||||
#endif
|
||||
|
||||
44
port/realtek/arch/init.h
Normal file
44
port/realtek/arch/init.h
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
#ifndef __ARCH_INIT_H__
|
||||
#define __ARCH_INIT_H__
|
||||
|
||||
#define TCPIP_INIT_DONE(arg) tcpip_init_done(arg)
|
||||
|
||||
void tcpip_init_done(void *);
|
||||
int wait_for_tcpip_init(void);
|
||||
|
||||
#endif /* __ARCH_INIT_H__ */
|
||||
|
||||
|
||||
|
||||
|
||||
38
port/realtek/arch/lib.h
Normal file
38
port/realtek/arch/lib.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
#ifndef __LIB_H__
|
||||
#define __LIB_H__
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#endif /* __LIB_H__ */
|
||||
38
port/realtek/arch/perf.h
Normal file
38
port/realtek/arch/perf.h
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
#ifndef __PERF_H__
|
||||
#define __PERF_H__
|
||||
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
|
||||
#endif /* __PERF_H__ */
|
||||
67
port/realtek/arch/sys_arch.h
Normal file
67
port/realtek/arch/sys_arch.h
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
#ifndef __SYS_RTXC_H__
|
||||
#define __SYS_RTXC_H__
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#define SYS_MBOX_NULL (xQueueHandle)0
|
||||
#define SYS_SEM_NULL (xSemaphoreHandle)0
|
||||
#define SYS_DEFAULT_THREAD_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||
|
||||
typedef xSemaphoreHandle sys_sem_t;
|
||||
typedef xSemaphoreHandle sys_mutex_t;
|
||||
typedef xQueueHandle sys_mbox_t;
|
||||
typedef xTaskHandle sys_thread_t;
|
||||
|
||||
typedef struct _sys_arch_state_t
|
||||
{
|
||||
// Task creation data.
|
||||
char cTaskName[configMAX_TASK_NAME_LEN];
|
||||
unsigned short nStackDepth;
|
||||
unsigned short nTaskCount;
|
||||
} sys_arch_state_t;
|
||||
|
||||
|
||||
|
||||
//extern sys_arch_state_t s_sys_arch_state;
|
||||
|
||||
//void sys_set_default_state();
|
||||
//void sys_set_state(signed char *pTaskName, unsigned short nStackSize);
|
||||
|
||||
/* Message queue constants. */
|
||||
#define archMESG_QUEUE_LENGTH ( 6 )
|
||||
#endif /* __SYS_RTXC_H__ */
|
||||
|
||||
377
port/realtek/freertos/ethernetif.c
Normal file
377
port/realtek/freertos/ethernetif.c
Normal file
@@ -0,0 +1,377 @@
|
||||
/**
|
||||
* @file
|
||||
* Ethernet Interface Skeleton
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (c) 2001-2004 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>
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file is a skeleton for developing Ethernet network interface
|
||||
* drivers for lwIP. Add code to the low_level functions and do a
|
||||
* search-and-replace for the word "ethernetif" to replace it with
|
||||
* something that better describes your network interface.
|
||||
*/
|
||||
|
||||
#include "lwip/opt.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/tcpip.h"
|
||||
#include "lwip/icmp.h"
|
||||
#include "lwip/lwip_timers.h"
|
||||
#include "netif/etharp.h"
|
||||
#include "err.h"
|
||||
#include "ethernetif.h"
|
||||
#include "queue.h"
|
||||
#include "lwip_netconf.h"
|
||||
|
||||
//#include "lwip/ethip6.h" //Add for ipv6
|
||||
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include "platform_opts.h"
|
||||
|
||||
#if CONFIG_WLAN
|
||||
#include <lwip_intf.h>
|
||||
#endif
|
||||
|
||||
#if CONFIG_INIC_HOST
|
||||
#include "freertos/inic_intf.h"
|
||||
#endif
|
||||
|
||||
#define netifMTU (1500)
|
||||
#define netifINTERFACE_TASK_STACK_SIZE ( 350 )
|
||||
#define netifINTERFACE_TASK_PRIORITY ( configMAX_PRIORITIES - 1 )
|
||||
#define netifGUARD_BLOCK_TIME ( 250 )
|
||||
/* The time to block waiting for input. */
|
||||
#define emacBLOCK_TIME_WAITING_FOR_INPUT ( ( portTickType ) 100 )
|
||||
|
||||
|
||||
#ifdef CONFIG_CONCURRENT_MODE
|
||||
#define IF2NAME0 'r'
|
||||
#define IF2NAME1 '2'
|
||||
#endif
|
||||
|
||||
static void arp_timer(void *arg);
|
||||
|
||||
|
||||
/**
|
||||
* In this function, the hardware should be initialized.
|
||||
* Called from ethernetif_init().
|
||||
*
|
||||
* @param netif the already initialized lwip network interface structure
|
||||
* for this ethernetif
|
||||
*/
|
||||
|
||||
static void low_level_init(struct netif *netif)
|
||||
{
|
||||
|
||||
/* set netif MAC hardware address length */
|
||||
netif->hwaddr_len = ETHARP_HWADDR_LEN;
|
||||
|
||||
/* set netif maximum transfer unit */
|
||||
netif->mtu = 1500;
|
||||
|
||||
/* Accept broadcast address and ARP traffic */
|
||||
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
|
||||
|
||||
#if LWIP_IGMP
|
||||
/* make LwIP_Init do igmp_start to add group 224.0.0.1 */
|
||||
netif->flags |= NETIF_FLAG_IGMP;
|
||||
#endif
|
||||
|
||||
/* Wlan interface is initialized later */
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* This function should do the actual transmission of the packet. The packet is
|
||||
* contained in the pbuf that is passed to the function. This pbuf
|
||||
* might be chained.
|
||||
*
|
||||
* @param netif the lwip network interface structure for this ethernetif
|
||||
* @param p the MAC packet to send (e.g. IP packet including MAC addresses and type)
|
||||
* @return ERR_OK if the packet could be sent
|
||||
* an err_t value if the packet couldn't be sent
|
||||
*
|
||||
* @note Returning ERR_MEM here if a DMA queue of your MAC is full can lead to
|
||||
* strange results. You might consider waiting for space in the DMA queue
|
||||
* to become availale since the stack doesn't retry to send a packet
|
||||
* dropped because of memory failure (except for the TCP timers).
|
||||
*/
|
||||
|
||||
static err_t low_level_output(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
|
||||
|
||||
/* Refer to eCos lwip eth_drv_send() */
|
||||
struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
|
||||
int sg_len = 0;
|
||||
struct pbuf *q;
|
||||
#if CONFIG_WLAN
|
||||
if(!rltk_wlan_running(netif_get_idx(netif)))
|
||||
return ERR_IF;
|
||||
#endif
|
||||
for (q = p; q != NULL && sg_len < MAX_ETH_DRV_SG; q = q->next) {
|
||||
sg_list[sg_len].buf = (unsigned int) q->payload;
|
||||
sg_list[sg_len++].len = q->len;
|
||||
}
|
||||
|
||||
if (sg_len) {
|
||||
#if CONFIG_WLAN
|
||||
if (rltk_wlan_send(netif_get_idx(netif), sg_list, sg_len, p->tot_len) == 0)
|
||||
#elif CONFIG_INIC_HOST
|
||||
if(rltk_inic_send( sg_list, sg_len, p->tot_len) == 0)
|
||||
#else
|
||||
if(1)
|
||||
#endif
|
||||
return ERR_OK;
|
||||
else
|
||||
return ERR_BUF; // return a non-fatal error
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*for ethernet mii interface*/
|
||||
static err_t low_level_output_mii(struct netif *netif, struct pbuf *p)
|
||||
{
|
||||
struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
|
||||
int sg_len = 0;
|
||||
struct pbuf *q;
|
||||
for (q = p; q != NULL && sg_len < MAX_ETH_DRV_SG; q = q->next) {
|
||||
sg_list[sg_len].buf = (unsigned int) q->payload;
|
||||
sg_list[sg_len++].len = q->len;
|
||||
}
|
||||
if (sg_len) {
|
||||
if(rltk_mii_send(sg_list, sg_len, p->tot_len) == 0)
|
||||
return ERR_OK;
|
||||
else
|
||||
return ERR_BUF; // return a non-fatal error
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Should allocate a pbuf and transfer the bytes of the incoming
|
||||
* packet from the interface into the pbuf.
|
||||
*
|
||||
* @param netif the lwip network interface structure for this ethernetif
|
||||
* @return a pbuf filled with the received packet (including MAC header)
|
||||
* NULL on memory error
|
||||
*/
|
||||
//static struct pbuf * low_level_input(struct netif *netif){}
|
||||
|
||||
|
||||
/**
|
||||
* This function is the ethernetif_input task, it is processed when a packet
|
||||
* is ready to be read from the interface. It uses the function low_level_input()
|
||||
* that should handle the actual reception of bytes from the network
|
||||
* interface. Then the type of the received packet is determined and
|
||||
* the appropriate input function is called.
|
||||
*
|
||||
* @param netif the lwip network interface structure for this ethernetif
|
||||
*/
|
||||
//void ethernetif_input( void * pvParameters )
|
||||
|
||||
|
||||
/* Refer to eCos eth_drv_recv to do similarly in ethernetif_input */
|
||||
void ethernetif_recv(struct netif *netif, int total_len)
|
||||
{
|
||||
struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
|
||||
struct pbuf *p, *q;
|
||||
int sg_len = 0;
|
||||
#if CONFIG_WLAN
|
||||
if(!rltk_wlan_running(netif_get_idx(netif)))
|
||||
return;
|
||||
#endif
|
||||
if ((total_len > MAX_ETH_MSG) || (total_len < 0))
|
||||
total_len = MAX_ETH_MSG;
|
||||
|
||||
// Allocate buffer to store received packet
|
||||
p = pbuf_alloc(PBUF_RAW, total_len, PBUF_POOL);
|
||||
if (p == NULL) {
|
||||
printf("\n\rCannot allocate pbuf to receive packet");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create scatter list
|
||||
for (q = p; q != NULL && sg_len < MAX_ETH_DRV_SG; q = q->next) {
|
||||
sg_list[sg_len].buf = (unsigned int) q->payload;
|
||||
sg_list[sg_len++].len = q->len;
|
||||
}
|
||||
|
||||
// Copy received packet to scatter list from wrapper rx skb
|
||||
//printf("\n\rwlan:%c: Recv sg_len: %d, tot_len:%d", netif->name[1],sg_len, total_len);
|
||||
#if CONFIG_WLAN
|
||||
rltk_wlan_recv(netif_get_idx(netif), sg_list, sg_len);
|
||||
#elif CONFIG_INIC_HOST
|
||||
rltk_inic_recv(sg_list, sg_len);
|
||||
#endif
|
||||
// Pass received packet to the interface
|
||||
if (ERR_OK != netif->input(p, netif))
|
||||
pbuf_free(p);
|
||||
|
||||
}
|
||||
|
||||
void ethernetif_mii_recv(struct netif *netif, int total_len)
|
||||
{
|
||||
struct eth_drv_sg sg_list[MAX_ETH_DRV_SG];
|
||||
struct pbuf *p, *q;
|
||||
int sg_len = 0;
|
||||
|
||||
if ((total_len > MAX_ETH_MSG) || (total_len < 0))
|
||||
total_len = MAX_ETH_MSG;
|
||||
|
||||
// Allocate buffer to store received packet
|
||||
p = pbuf_alloc(PBUF_RAW, total_len, PBUF_POOL);
|
||||
if (p == NULL) {
|
||||
printf("\n\rCannot allocate pbuf to receive packet");
|
||||
return;
|
||||
}
|
||||
|
||||
// Create scatter list
|
||||
for (q = p; q != NULL && sg_len < MAX_ETH_DRV_SG; q = q->next) {
|
||||
sg_list[sg_len].buf = (unsigned int) q->payload;
|
||||
sg_list[sg_len++].len = q->len;
|
||||
}
|
||||
rltk_mii_recv(sg_list, sg_len);
|
||||
|
||||
// Pass received packet to the interface
|
||||
if (ERR_OK != netif->input(p, netif))
|
||||
pbuf_free(p);
|
||||
|
||||
}
|
||||
/**
|
||||
* Should be called at the beginning of the program to set up the
|
||||
* network interface. It calls the function low_level_init() to do the
|
||||
* actual setup of the hardware.
|
||||
*
|
||||
* This function should be passed as a parameter to netif_add().
|
||||
*
|
||||
* @param netif the lwip network interface structure for this ethernetif
|
||||
* @return ERR_OK if the loopif is initialized
|
||||
* ERR_MEM if private data couldn't be allocated
|
||||
* any other err_t on error
|
||||
*/
|
||||
err_t ethernetif_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
/* Initialize interface hostname */
|
||||
if(netif->name[1] == '0')
|
||||
netif->hostname = "lwip0";
|
||||
else if(netif->name[1] == '1')
|
||||
netif->hostname = "lwip1";
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
netif->output = etharp_output;
|
||||
//#if LWIP_IPV6
|
||||
// netif->output_ip6 = ethip6_output;
|
||||
//#endif
|
||||
netif->linkoutput = low_level_output;
|
||||
|
||||
/* initialize the hardware */
|
||||
low_level_init(netif);
|
||||
|
||||
etharp_init();
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
err_t ethernetif_mii_init(struct netif *netif)
|
||||
{
|
||||
LWIP_ASSERT("netif != NULL", (netif != NULL));
|
||||
|
||||
#if LWIP_NETIF_HOSTNAME
|
||||
netif->hostname = "lwip2";
|
||||
#endif /* LWIP_NETIF_HOSTNAME */
|
||||
|
||||
netif->output = etharp_output;
|
||||
//#if LWIP_IPV6
|
||||
// netif->output_ip6 = ethip6_output;
|
||||
//#endif
|
||||
netif->linkoutput = low_level_output_mii;
|
||||
|
||||
/* initialize the hardware */
|
||||
low_level_init(netif);
|
||||
|
||||
etharp_init();
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
static void arp_timer(void *arg)
|
||||
{
|
||||
etharp_tmr();
|
||||
sys_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
|
||||
}
|
||||
|
||||
/*
|
||||
* For FreeRTOS tickless
|
||||
*/
|
||||
int lwip_tickless_used = 0;
|
||||
|
||||
int arp_timeout_exist(void)
|
||||
{
|
||||
struct sys_timeouts *timeouts;
|
||||
struct sys_timeo *t;
|
||||
|
||||
timeouts = sys_arch_timeouts();
|
||||
|
||||
for(t = timeouts->next; t != NULL;t = t->next)
|
||||
if(t->h == arp_timer)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Called by rltk_wlan_PRE_SLEEP_PROCESSING()
|
||||
void lwip_PRE_SLEEP_PROCESSING(void)
|
||||
{
|
||||
if(arp_timeout_exist()) {
|
||||
tcpip_untimeout(arp_timer, NULL);
|
||||
}
|
||||
lwip_tickless_used = 1;
|
||||
}
|
||||
|
||||
//Called in ips_leave() path, support tickless when wifi power wakeup due to ioctl or deinit
|
||||
void lwip_POST_SLEEP_PROCESSING(void)
|
||||
{
|
||||
if(lwip_tickless_used) {
|
||||
tcpip_timeout(ARP_TMR_INTERVAL, arp_timer, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
25
port/realtek/freertos/ethernetif.h
Normal file
25
port/realtek/freertos/ethernetif.h
Normal file
@@ -0,0 +1,25 @@
|
||||
#ifndef __ETHERNETIF_H__
|
||||
#define __ETHERNETIF_H__
|
||||
|
||||
|
||||
#include "lwip/err.h"
|
||||
#include "lwip/netif.h"
|
||||
|
||||
//----- ------------------------------------------------------------------
|
||||
// Ethernet Buffer
|
||||
//----- ------------------------------------------------------------------
|
||||
struct eth_drv_sg {
|
||||
unsigned int buf;
|
||||
unsigned int len;
|
||||
};
|
||||
|
||||
#define MAX_ETH_DRV_SG 32
|
||||
#define MAX_ETH_MSG 1540
|
||||
|
||||
void ethernetif_recv(struct netif *netif, int total_len);
|
||||
err_t ethernetif_init(struct netif *netif);
|
||||
err_t ethernetif_mii_init(struct netif *netif);
|
||||
void lwip_PRE_SLEEP_PROCESSING(void);
|
||||
void lwip_POST_SLEEP_PROCESSING(void);
|
||||
|
||||
#endif
|
||||
633
port/realtek/freertos/sys_arch.c
Normal file
633
port/realtek/freertos/sys_arch.c
Normal file
@@ -0,0 +1,633 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
|
||||
/* lwIP includes. */
|
||||
#include "lwip/debug.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
#include "lwip/lwip_timers.h"
|
||||
#include "autoconf.h"
|
||||
#include "tcm_heap.h"
|
||||
|
||||
xTaskHandle xTaskGetCurrentTaskHandle( void ) PRIVILEGED_FUNCTION;
|
||||
extern void * vTaskGetCurrentTCB( void );
|
||||
struct timeoutlist
|
||||
{
|
||||
struct sys_timeouts timeouts;
|
||||
xTaskHandle pid;
|
||||
};
|
||||
|
||||
/* This is the number of threads that can be started with sys_thread_new() */
|
||||
#define SYS_THREAD_MAX 6
|
||||
|
||||
static struct timeoutlist s_timeoutlist[SYS_THREAD_MAX];
|
||||
static u16_t s_nextthread = 0;
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// Creates an empty mailbox.
|
||||
err_t sys_mbox_new(sys_mbox_t *mbox, int size)
|
||||
{
|
||||
(void ) size;
|
||||
|
||||
*mbox = xQueueCreate( size, sizeof( void * ) );
|
||||
|
||||
#if SYS_STATS
|
||||
++lwip_stats.sys.mbox.used;
|
||||
if (lwip_stats.sys.mbox.max < lwip_stats.sys.mbox.used) {
|
||||
lwip_stats.sys.mbox.max = lwip_stats.sys.mbox.used;
|
||||
}
|
||||
#endif /* SYS_STATS */
|
||||
if (*mbox == NULL)
|
||||
return ERR_MEM;
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
Deallocates a mailbox. If there are messages still present in the
|
||||
mailbox when the mailbox is deallocated, it is an indication of a
|
||||
programming error in lwIP and the developer should be notified.
|
||||
*/
|
||||
void sys_mbox_free(sys_mbox_t *mbox)
|
||||
{
|
||||
if( uxQueueMessagesWaiting( *mbox ) )
|
||||
{
|
||||
/* Line for breakpoint. Should never break here! */
|
||||
portNOP();
|
||||
#if SYS_STATS
|
||||
lwip_stats.sys.mbox.err++;
|
||||
#endif /* SYS_STATS */
|
||||
|
||||
// TODO notify the user of failure.
|
||||
}
|
||||
|
||||
vQueueDelete( *mbox );
|
||||
|
||||
#if SYS_STATS
|
||||
--lwip_stats.sys.mbox.used;
|
||||
#endif /* SYS_STATS */
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// Posts the "msg" to the mailbox.
|
||||
void sys_mbox_post(sys_mbox_t *mbox, void *data)
|
||||
{
|
||||
while ( xQueueSendToBack(*mbox, &data, portMAX_DELAY ) != pdTRUE ){}
|
||||
}
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// Try to post the "msg" to the mailbox.
|
||||
err_t sys_mbox_trypost(sys_mbox_t *mbox, void *msg)
|
||||
{
|
||||
err_t result;
|
||||
|
||||
if ( xQueueSend( *mbox, &msg, 0 ) == pdPASS )
|
||||
{
|
||||
result = ERR_OK;
|
||||
}
|
||||
else {
|
||||
// could not post, queue must be full
|
||||
result = ERR_MEM;
|
||||
|
||||
#if SYS_STATS
|
||||
lwip_stats.sys.mbox.err++;
|
||||
#endif /* SYS_STATS */
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
Blocks the thread until a message arrives in the mailbox, but does
|
||||
not block the thread longer than "timeout" milliseconds (similar to
|
||||
the sys_arch_sem_wait() function). The "msg" argument is a result
|
||||
parameter that is set by the function (i.e., by doing "*msg =
|
||||
ptr"). The "msg" parameter maybe NULL to indicate that the message
|
||||
should be dropped.
|
||||
|
||||
The return values are the same as for the sys_arch_sem_wait() function:
|
||||
Number of milliseconds spent waiting or SYS_ARCH_TIMEOUT if there was a
|
||||
timeout.
|
||||
|
||||
Note that a function with a similar name, sys_mbox_fetch(), is
|
||||
implemented by lwIP.
|
||||
*/
|
||||
u32_t sys_arch_mbox_fetch(sys_mbox_t *mbox, void **msg, u32_t timeout)
|
||||
{
|
||||
void *dummyptr;
|
||||
portTickType StartTime, EndTime, Elapsed;
|
||||
|
||||
StartTime = xTaskGetTickCount();
|
||||
|
||||
if ( msg == NULL )
|
||||
{
|
||||
msg = &dummyptr;
|
||||
}
|
||||
|
||||
if ( timeout != 0 )
|
||||
{
|
||||
if ( pdTRUE == xQueueReceive( *mbox, &(*msg), timeout / portTICK_RATE_MS ) )
|
||||
{
|
||||
EndTime = xTaskGetTickCount();
|
||||
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;
|
||||
|
||||
return ( Elapsed );
|
||||
}
|
||||
else // timed out blocking for message
|
||||
{
|
||||
*msg = NULL;
|
||||
|
||||
return SYS_ARCH_TIMEOUT;
|
||||
}
|
||||
}
|
||||
else // block forever for a message.
|
||||
{
|
||||
while( pdTRUE != xQueueReceive( *mbox, &(*msg), portMAX_DELAY ) ){} // time is arbitrary
|
||||
EndTime = xTaskGetTickCount();
|
||||
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;
|
||||
|
||||
return ( Elapsed ); // return time blocked TODO test
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
Similar to sys_arch_mbox_fetch, but if message is not ready immediately, we'll
|
||||
return with SYS_MBOX_EMPTY. On success, 0 is returned.
|
||||
*/
|
||||
u32_t sys_arch_mbox_tryfetch(sys_mbox_t *mbox, void **msg)
|
||||
{
|
||||
void *dummyptr;
|
||||
|
||||
if ( msg == NULL )
|
||||
{
|
||||
msg = &dummyptr;
|
||||
}
|
||||
|
||||
if ( pdTRUE == xQueueReceive( *mbox, &(*msg), 0 ) )
|
||||
{
|
||||
return ERR_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
return SYS_MBOX_EMPTY;
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------------------------------*/
|
||||
int sys_mbox_valid(sys_mbox_t *mbox)
|
||||
{
|
||||
if (*mbox == SYS_MBOX_NULL)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void sys_mbox_set_invalid(sys_mbox_t *mbox)
|
||||
{
|
||||
*mbox = SYS_MBOX_NULL;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// Creates a new semaphore. The "count" argument specifies
|
||||
// the initial state of the semaphore.
|
||||
err_t sys_sem_new(sys_sem_t *sem, u8_t count)
|
||||
{
|
||||
vSemaphoreCreateBinary(*sem );
|
||||
if(*sem == NULL)
|
||||
{
|
||||
|
||||
#if SYS_STATS
|
||||
++lwip_stats.sys.sem.err;
|
||||
#endif /* SYS_STATS */
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
if(count == 0) // Means it can't be taken
|
||||
{
|
||||
xSemaphoreTake(*sem,1);
|
||||
}
|
||||
|
||||
#if SYS_STATS
|
||||
++lwip_stats.sys.sem.used;
|
||||
if (lwip_stats.sys.sem.max < lwip_stats.sys.sem.used) {
|
||||
lwip_stats.sys.sem.max = lwip_stats.sys.sem.used;
|
||||
}
|
||||
#endif /* SYS_STATS */
|
||||
|
||||
return ERR_OK;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
Blocks the thread while waiting for the semaphore to be
|
||||
signaled. If the "timeout" argument is non-zero, the thread should
|
||||
only be blocked for the specified time (measured in
|
||||
milliseconds).
|
||||
|
||||
If the timeout argument is non-zero, the return value is the number of
|
||||
milliseconds spent waiting for the semaphore to be signaled. If the
|
||||
semaphore wasn't signaled within the specified time, the return value is
|
||||
SYS_ARCH_TIMEOUT. If the thread didn't have to wait for the semaphore
|
||||
(i.e., it was already signaled), the function may return zero.
|
||||
|
||||
Notice that lwIP implements a function with a similar name,
|
||||
sys_sem_wait(), that uses the sys_arch_sem_wait() function.
|
||||
*/
|
||||
u32_t sys_arch_sem_wait(sys_sem_t *sem, u32_t timeout)
|
||||
{
|
||||
portTickType StartTime, EndTime, Elapsed;
|
||||
|
||||
StartTime = xTaskGetTickCount();
|
||||
|
||||
if( timeout != 0)
|
||||
{
|
||||
if( xSemaphoreTake( *sem, timeout / portTICK_RATE_MS ) == pdTRUE )
|
||||
{
|
||||
EndTime = xTaskGetTickCount();
|
||||
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;
|
||||
|
||||
return (Elapsed); // return time blocked TODO test
|
||||
}
|
||||
else
|
||||
{
|
||||
return SYS_ARCH_TIMEOUT;
|
||||
}
|
||||
}
|
||||
else // must block without a timeout
|
||||
{
|
||||
while( xSemaphoreTake(*sem, portMAX_DELAY) != pdTRUE){}
|
||||
EndTime = xTaskGetTickCount();
|
||||
Elapsed = (EndTime - StartTime) * portTICK_RATE_MS;
|
||||
|
||||
return ( Elapsed ); // return time blocked
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// Signals a semaphore
|
||||
void sys_sem_signal(sys_sem_t *sem)
|
||||
{
|
||||
xSemaphoreGive(*sem);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// Deallocates a semaphore
|
||||
void sys_sem_free(sys_sem_t *sem)
|
||||
{
|
||||
#if SYS_STATS
|
||||
--lwip_stats.sys.sem.used;
|
||||
#endif /* SYS_STATS */
|
||||
|
||||
vQueueDelete(*sem);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
int sys_sem_valid(sys_sem_t *sem)
|
||||
{
|
||||
if (*sem == SYS_SEM_NULL)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
void sys_sem_set_invalid(sys_sem_t *sem)
|
||||
{
|
||||
*sem = SYS_SEM_NULL;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// Initialize sys arch
|
||||
void sys_init(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
// Initialize the the per-thread sys_timeouts structures
|
||||
// make sure there are no valid pids in the list
|
||||
for(i = 0; i < SYS_THREAD_MAX; i++)
|
||||
{
|
||||
s_timeoutlist[i].pid = 0;
|
||||
s_timeoutlist[i].timeouts.next = NULL;
|
||||
}
|
||||
|
||||
// keep track of how many threads have been created
|
||||
s_nextthread = 0;
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
Returns a pointer to the per-thread sys_timeouts structure. In lwIP,
|
||||
each thread has a list of timeouts which is represented as a linked
|
||||
list of sys_timeout structures. The sys_timeouts structure holds a
|
||||
pointer to a linked list of timeouts. This function is called by
|
||||
the lwIP timeout scheduler and must not return a NULL value.
|
||||
|
||||
In a single threaded sys_arch implementation, this function will
|
||||
simply return a pointer to a global sys_timeouts variable stored in
|
||||
the sys_arch module.
|
||||
*/
|
||||
struct sys_timeouts *sys_arch_timeouts(void)
|
||||
{
|
||||
int i;
|
||||
xTaskHandle pid;
|
||||
struct timeoutlist *tl;
|
||||
|
||||
pid = xTaskGetCurrentTaskHandle();
|
||||
|
||||
for(i = 0; i < s_nextthread; i++)
|
||||
{
|
||||
tl = &(s_timeoutlist[i]);
|
||||
if(tl->pid == pid)
|
||||
{
|
||||
return &(tl->timeouts);
|
||||
}
|
||||
}
|
||||
// Error
|
||||
return NULL;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Mutexes*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
#if LWIP_COMPAT_MUTEX == 0
|
||||
/* Create a new mutex*/
|
||||
err_t sys_mutex_new(sys_mutex_t *mutex) {
|
||||
|
||||
*mutex = xSemaphoreCreateMutex();
|
||||
if(*mutex == NULL)
|
||||
{
|
||||
#if SYS_STATS
|
||||
++lwip_stats.sys.mutex.err;
|
||||
#endif /* SYS_STATS */
|
||||
return ERR_MEM;
|
||||
}
|
||||
|
||||
#if SYS_STATS
|
||||
++lwip_stats.sys.mutex.used;
|
||||
if (lwip_stats.sys.mutex.max < lwip_stats.sys.mutex.used) {
|
||||
lwip_stats.sys.mutex.max = lwip_stats.sys.mutex.used;
|
||||
}
|
||||
#endif /* SYS_STATS */
|
||||
return ERR_OK;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Deallocate a mutex*/
|
||||
void sys_mutex_free(sys_mutex_t *mutex)
|
||||
{
|
||||
#if SYS_STATS
|
||||
--lwip_stats.sys.mutex.used;
|
||||
#endif /* SYS_STATS */
|
||||
|
||||
vQueueDelete(*mutex);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Lock a mutex*/
|
||||
void sys_mutex_lock(sys_mutex_t *mutex)
|
||||
{
|
||||
sys_arch_sem_wait(*mutex, 0);
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/* Unlock a mutex*/
|
||||
void sys_mutex_unlock(sys_mutex_t *mutex)
|
||||
{
|
||||
xSemaphoreGive(*mutex);
|
||||
}
|
||||
#endif /*LWIP_COMPAT_MUTEX*/
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// TODO
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
Starts a new thread with priority "prio" that will begin its execution in the
|
||||
function "thread()". The "arg" argument will be passed as an argument to the
|
||||
thread() function. The id of the new thread is returned. Both the id and
|
||||
the priority are system dependent.
|
||||
*/
|
||||
sys_thread_t sys_thread_new_tcm(const char *name, lwip_thread_fn thread , void *arg, int stacksize, int prio)
|
||||
{
|
||||
xTaskHandle CreatedTask;
|
||||
int result;
|
||||
|
||||
if ( s_nextthread < SYS_THREAD_MAX )
|
||||
{
|
||||
vPortEnterCritical();
|
||||
#if CONFIG_USE_TCM_HEAP
|
||||
{
|
||||
void *stack_addr = tcm_heap_malloc(stacksize * sizeof(int));
|
||||
|
||||
if(stack_addr == NULL){
|
||||
}
|
||||
|
||||
result = xTaskGenericCreate(
|
||||
thread,
|
||||
( signed portCHAR * ) name,
|
||||
stacksize,
|
||||
arg,
|
||||
prio,
|
||||
&CreatedTask,
|
||||
stack_addr,
|
||||
NULL);
|
||||
}
|
||||
#else
|
||||
result = xTaskCreate( thread, ( signed portCHAR * ) name, stacksize, arg, prio, &CreatedTask );
|
||||
#endif
|
||||
|
||||
// For each task created, store the task handle (pid) in the timers array.
|
||||
// This scheme doesn't allow for threads to be deleted
|
||||
s_timeoutlist[s_nextthread++].pid = CreatedTask;
|
||||
vPortExitCritical();
|
||||
|
||||
if(result == pdPASS)
|
||||
{
|
||||
return CreatedTask;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
// TODO
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
/*
|
||||
Starts a new thread with priority "prio" that will begin its execution in the
|
||||
function "thread()". The "arg" argument will be passed as an argument to the
|
||||
thread() function. The id of the new thread is returned. Both the id and
|
||||
the priority are system dependent.
|
||||
*/
|
||||
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread , void *arg, int stacksize, int prio)
|
||||
{
|
||||
xTaskHandle CreatedTask;
|
||||
int result;
|
||||
|
||||
if ( s_nextthread < SYS_THREAD_MAX )
|
||||
{
|
||||
vPortEnterCritical();
|
||||
result = xTaskCreate( thread, ( signed portCHAR * ) name, stacksize, arg, prio, &CreatedTask );
|
||||
|
||||
// For each task created, store the task handle (pid) in the timers array.
|
||||
// This scheme doesn't allow for threads to be deleted
|
||||
s_timeoutlist[s_nextthread++].pid = CreatedTask;
|
||||
vPortExitCritical();
|
||||
|
||||
if(result == pdPASS)
|
||||
{
|
||||
return CreatedTask;
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int sys_thread_delete(xTaskHandle pid)
|
||||
{
|
||||
int i, isFind = 0;
|
||||
struct timeoutlist *tl, *tend = NULL;
|
||||
|
||||
pid = (( pid == NULL)?(xTaskHandle) vTaskGetCurrentTCB() : pid);
|
||||
|
||||
if (s_nextthread)
|
||||
{
|
||||
vPortEnterCritical();
|
||||
|
||||
tend = &(s_timeoutlist[s_nextthread-1]);//the last one
|
||||
for(i = 0; i < s_nextthread; i++)
|
||||
{
|
||||
tl = &(s_timeoutlist[i]);
|
||||
if(tl->pid == pid)
|
||||
{//find the task, exchange with the last one
|
||||
memcpy(tl, tend, sizeof(struct timeoutlist));
|
||||
memset(tend, 0, sizeof(struct timeoutlist));
|
||||
s_nextthread --;
|
||||
isFind = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isFind) {
|
||||
vTaskDelete( pid);
|
||||
}
|
||||
|
||||
vPortExitCritical();
|
||||
|
||||
if (isFind)
|
||||
{
|
||||
return pdPASS;
|
||||
}
|
||||
else
|
||||
{
|
||||
return pdFAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return pdFAIL;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
This optional function does a "fast" critical region protection and returns
|
||||
the previous protection level. This function is only called during very short
|
||||
critical regions. An embedded system which supports ISR-based drivers might
|
||||
want to implement this function by disabling interrupts. Task-based systems
|
||||
might want to implement this by using a mutex or disabling tasking. This
|
||||
function should support recursive calls from the same task or interrupt. In
|
||||
other words, sys_arch_protect() could be called while already protected. In
|
||||
that case the return value indicates that it is already protected.
|
||||
|
||||
sys_arch_protect() is only required if your port is supporting an operating
|
||||
system.
|
||||
*/
|
||||
sys_prot_t sys_arch_protect(void)
|
||||
{
|
||||
vPortEnterCritical();
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
This optional function does a "fast" set of critical region protection to the
|
||||
value specified by pval. See the documentation for sys_arch_protect() for
|
||||
more information. This function is only required if your port is supporting
|
||||
an operating system.
|
||||
*/
|
||||
void sys_arch_unprotect(sys_prot_t pval)
|
||||
{
|
||||
( void ) pval;
|
||||
vPortExitCritical();
|
||||
}
|
||||
|
||||
/*
|
||||
* Prints an assertion messages and aborts execution.
|
||||
*/
|
||||
void sys_assert( const char *msg )
|
||||
{
|
||||
( void ) msg;
|
||||
/*FSL:only needed for debugging
|
||||
printf(msg);
|
||||
printf("\n\r");
|
||||
*/
|
||||
vPortEnterCritical( );
|
||||
for(;;)
|
||||
;
|
||||
}
|
||||
|
||||
u32_t sys_now(void)
|
||||
{
|
||||
return xTaskGetTickCount();
|
||||
}
|
||||
|
||||
u32_t sys_jiffies(void)
|
||||
{
|
||||
return xTaskGetTickCount();
|
||||
}
|
||||
66
port/realtek/freertos/sys_arch.h
Normal file
66
port/realtek/freertos/sys_arch.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (c) 2001-2003 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>
|
||||
*
|
||||
*/
|
||||
#ifndef __SYS_RTXC_H__
|
||||
#define __SYS_RTXC_H__
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#define SYS_MBOX_NULL (xQueueHandle)0
|
||||
#define SYS_SEM_NULL (xSemaphoreHandle)0
|
||||
#define SYS_DEFAULT_THREAD_STACK_DEPTH configMINIMAL_STACK_SIZE
|
||||
|
||||
typedef xSemaphoreHandle sys_sem_t;
|
||||
typedef xQueueHandle sys_mbox_t;
|
||||
typedef xTaskHandle sys_thread_t;
|
||||
|
||||
typedef struct _sys_arch_state_t
|
||||
{
|
||||
// Task creation data.
|
||||
char cTaskName[configMAX_TASK_NAME_LEN];
|
||||
unsigned short nStackDepth;
|
||||
unsigned short nTaskCount;
|
||||
} sys_arch_state_t;
|
||||
|
||||
|
||||
|
||||
//extern sys_arch_state_t s_sys_arch_state;
|
||||
|
||||
//void sys_set_default_state();
|
||||
//void sys_set_state(signed char *pTaskName, unsigned short nStackSize);
|
||||
|
||||
/* Message queue constants. */
|
||||
#define archMESG_QUEUE_LENGTH ( 6 )
|
||||
#endif /* __SYS_RTXC_H__ */
|
||||
|
||||
@@ -14,7 +14,7 @@ set(LWIP_VERSION_REVISION "3")
|
||||
# LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases
|
||||
# LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for Git versions
|
||||
# Numbers 1..31 are reserved for release candidates
|
||||
set(LWIP_VERSION_RC "1")
|
||||
set(LWIP_VERSION_RC "LWIP_RC_RELEASE")
|
||||
|
||||
if ("${LWIP_VERSION_RC}" STREQUAL "LWIP_RC_RELEASE")
|
||||
set(LWIP_VERSION_STRING
|
||||
|
||||
@@ -1341,12 +1341,24 @@ netconn_gethostbyname(const char *name, ip_addr_t *addr)
|
||||
}
|
||||
#endif /* LWIP_DNS*/
|
||||
|
||||
//Realtek add
|
||||
err_t netconn_abort(struct netconn *conn)
|
||||
{
|
||||
if (conn->acceptmbox != SYS_MBOX_NULL) {
|
||||
/* Register event with callback */
|
||||
API_EVENT(conn, NETCONN_EVT_RCVPLUS, 0);
|
||||
sys_mbox_post(&conn->acceptmbox, NULL);
|
||||
}
|
||||
return ERR_OK;
|
||||
}
|
||||
//Realtek add end
|
||||
|
||||
#if LWIP_NETCONN_SEM_PER_THREAD
|
||||
void
|
||||
netconn_thread_init(void)
|
||||
{
|
||||
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
|
||||
if ((sem == NULL) || !sys_sem_valid(sem)) {
|
||||
if (!sys_sem_valid(sem)) {
|
||||
/* call alloc only once */
|
||||
LWIP_NETCONN_THREAD_SEM_ALLOC();
|
||||
LWIP_ASSERT("LWIP_NETCONN_THREAD_SEM_ALLOC() failed", sys_sem_valid(LWIP_NETCONN_THREAD_SEM_GET()));
|
||||
@@ -1357,7 +1369,7 @@ void
|
||||
netconn_thread_cleanup(void)
|
||||
{
|
||||
sys_sem_t *sem = LWIP_NETCONN_THREAD_SEM_GET();
|
||||
if ((sem != NULL) && sys_sem_valid(sem)) {
|
||||
if (sys_sem_valid(sem)) {
|
||||
/* call free only once */
|
||||
LWIP_NETCONN_THREAD_SEM_FREE();
|
||||
}
|
||||
|
||||
@@ -128,8 +128,7 @@ lwip_gethostbyname(const char *name)
|
||||
if (s_hostent.h_addr_list != NULL) {
|
||||
u8_t idx;
|
||||
for (idx = 0; s_hostent.h_addr_list[idx]; idx++) {
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i] == %p\n", idx, s_hostent.h_addr_list[idx]));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ipaddr_ntoa((ip_addr_t *)s_hostent.h_addr_list[idx])));
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("hostent.h_addr_list[%i]-> == %s\n", idx, ipaddr_ntoa(s_phostent_addr[idx])));
|
||||
}
|
||||
}
|
||||
#endif /* DNS_DEBUG */
|
||||
@@ -306,7 +305,11 @@ lwip_getaddrinfo(const char *nodename, const char *servname,
|
||||
/* service name specified: convert to port number
|
||||
* @todo?: currently, only ASCII integers (port numbers) are supported (AI_NUMERICSERV)! */
|
||||
port_nr = atoi(servname);
|
||||
if ((port_nr <= 0) || (port_nr > 0xffff)) {
|
||||
if (port_nr == 0 && (servname[0] != '0')) {
|
||||
/* atoi failed - service was not numeric */
|
||||
return EAI_SERVICE;
|
||||
}
|
||||
if ((port_nr < 0) || (port_nr > 0xffff)) {
|
||||
return EAI_SERVICE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3984,6 +3984,77 @@ lwip_inet_pton(int af, const char *src, void *dst)
|
||||
return err;
|
||||
}
|
||||
|
||||
/**************************************************************
|
||||
* Added by Realtek Begin *
|
||||
**************************************************************/
|
||||
int lwip_allocsocketsd()
|
||||
{
|
||||
struct netconn *conn;
|
||||
int i;
|
||||
|
||||
/*new a netconn due to avoid some socket->conn check*/
|
||||
conn = netconn_new_with_proto_and_callback(NETCONN_RAW, 0, NULL);
|
||||
if (!conn) {
|
||||
printf("\r\n could not create netconn");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*alloc a socket*/
|
||||
i = alloc_socket(conn, 1);
|
||||
if (i == -1) {
|
||||
netconn_delete(conn);
|
||||
printf("\r\n alloc socket fail!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
conn->socket = i;
|
||||
return i;
|
||||
}
|
||||
void lwip_setsockrcvevent(int fd, int rcvevent)
|
||||
{
|
||||
struct lwip_sock *sock = get_socket(fd);
|
||||
|
||||
if(sock){
|
||||
if(rcvevent)
|
||||
sock->rcvevent = 1;
|
||||
else
|
||||
sock->rcvevent = 0;
|
||||
}
|
||||
}
|
||||
void lwip_selectevindicate(int fd)
|
||||
{
|
||||
struct lwip_select_cb *scb;
|
||||
struct lwip_sock *sock;
|
||||
|
||||
sock = get_socket(fd);
|
||||
SYS_ARCH_DECL_PROTECT(lev);
|
||||
while (1) {
|
||||
SYS_ARCH_PROTECT(lev);
|
||||
for (scb = select_cb_list; scb; scb = scb->next) {
|
||||
if (scb->sem_signalled == 0) {
|
||||
/* Test this select call for our socket */
|
||||
if (scb->readset && FD_ISSET(fd, scb->readset))
|
||||
if (sock->rcvevent > 0)
|
||||
break;
|
||||
if (scb->writeset && FD_ISSET(fd, scb->writeset))
|
||||
if (sock->sendevent)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (scb) {
|
||||
scb->sem_signalled = 1;
|
||||
sys_sem_signal(&scb->sem);
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
} else {
|
||||
SYS_ARCH_UNPROTECT(lev);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
/**************************************************************
|
||||
* Added by Realtek end *
|
||||
**************************************************************/
|
||||
|
||||
#if LWIP_IGMP
|
||||
/** Register a new IGMP membership. On socket close, the membership is dropped automatically.
|
||||
*
|
||||
|
||||
@@ -50,6 +50,8 @@
|
||||
#include "lwip/etharp.h"
|
||||
#include "netif/ethernet.h"
|
||||
|
||||
#include "osdep_service.h"
|
||||
|
||||
#define TCPIP_MSG_VAR_REF(name) API_VAR_REF(name)
|
||||
#define TCPIP_MSG_VAR_DECLARE(name) API_VAR_DECLARE(struct tcpip_msg, name)
|
||||
#define TCPIP_MSG_VAR_ALLOC(name) API_VAR_ALLOC(struct tcpip_msg, MEMP_TCPIP_MSG_API, name, ERR_MEM)
|
||||
@@ -448,12 +450,17 @@ tcpip_send_msg_wait_sem(tcpip_callback_fn fn, void *apimsg, sys_sem_t *sem)
|
||||
LWIP_ASSERT("semaphore not initialized", sys_sem_valid(sem));
|
||||
LWIP_ASSERT("Invalid mbox", sys_mbox_valid_val(tcpip_mbox));
|
||||
|
||||
UBaseType_t prio = uxTaskPriorityGet(NULL); // add to prevent switch to tcpip thread between mbox post and sem wait
|
||||
if((TCPIP_THREAD_PRIO + 1) > prio)
|
||||
vTaskPrioritySet(NULL, TCPIP_THREAD_PRIO + 1); // set priority higher than tcpip thread
|
||||
|
||||
TCPIP_MSG_VAR_ALLOC(msg);
|
||||
TCPIP_MSG_VAR_REF(msg).type = TCPIP_MSG_API;
|
||||
TCPIP_MSG_VAR_REF(msg).msg.api_msg.function = fn;
|
||||
TCPIP_MSG_VAR_REF(msg).msg.api_msg.msg = apimsg;
|
||||
sys_mbox_post(&tcpip_mbox, &TCPIP_MSG_VAR_REF(msg));
|
||||
sys_arch_sem_wait(sem, 0);
|
||||
vTaskPrioritySet(NULL, prio); // restore to original priority
|
||||
TCPIP_MSG_VAR_FREE(msg);
|
||||
return ERR_OK;
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
@@ -613,8 +620,11 @@ tcpip_init(tcpip_init_done_fn initfunc, void *arg)
|
||||
LWIP_ASSERT("failed to create lock_tcpip_core", 0);
|
||||
}
|
||||
#endif /* LWIP_TCPIP_CORE_LOCKING */
|
||||
|
||||
sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
|
||||
#if CONFIG_USE_TCM_HEAP
|
||||
sys_thread_new_tcm(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
|
||||
#else
|
||||
sys_thread_new(TCPIP_THREAD_NAME, tcpip_thread, NULL, TCPIP_THREAD_STACKSIZE, TCPIP_THREAD_PRIO);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -772,7 +772,9 @@ mqtt_message_received(mqtt_client_t *client, u8_t fixed_hdr_len, u16_t length, u
|
||||
LWIP_DEBUGF(MQTT_DEBUG_WARN,( "mqtt_message_received: Received short packet (payload)\n"));
|
||||
goto out_disconnect;
|
||||
}
|
||||
client->data_cb(client->inpub_arg, var_hdr_payload + payload_offset, payload_length, remaining_length == 0 ? MQTT_DATA_FLAG_LAST : 0);
|
||||
if (client->data_cb != NULL) {
|
||||
client->data_cb(client->inpub_arg, var_hdr_payload + payload_offset, payload_length, remaining_length == 0 ? MQTT_DATA_FLAG_LAST : 0);
|
||||
}
|
||||
/* Reply if QoS > 0 */
|
||||
if (remaining_length == 0 && qos > 0) {
|
||||
/* Send PUBACK for QoS 1 or PUBREC for QoS 2 */
|
||||
|
||||
@@ -161,21 +161,25 @@ static void
|
||||
altcp_tcp_remove_callbacks(struct tcp_pcb *tpcb)
|
||||
{
|
||||
tcp_arg(tpcb, NULL);
|
||||
tcp_recv(tpcb, NULL);
|
||||
tcp_sent(tpcb, NULL);
|
||||
tcp_err(tpcb, NULL);
|
||||
tcp_poll(tpcb, NULL, tpcb->pollinterval);
|
||||
if (tpcb->state != LISTEN) {
|
||||
tcp_recv(tpcb, NULL);
|
||||
tcp_sent(tpcb, NULL);
|
||||
tcp_err(tpcb, NULL);
|
||||
tcp_poll(tpcb, NULL, tpcb->pollinterval);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
altcp_tcp_setup_callbacks(struct altcp_pcb *conn, struct tcp_pcb *tpcb)
|
||||
{
|
||||
tcp_arg(tpcb, conn);
|
||||
tcp_recv(tpcb, altcp_tcp_recv);
|
||||
tcp_sent(tpcb, altcp_tcp_sent);
|
||||
tcp_err(tpcb, altcp_tcp_err);
|
||||
/* tcp_poll is set when interval is set by application */
|
||||
/* listen is set totally different :-) */
|
||||
/* this might be called for LISTN when close fails... */
|
||||
if (tpcb->state != LISTEN) {
|
||||
tcp_recv(tpcb, altcp_tcp_recv);
|
||||
tcp_sent(tpcb, altcp_tcp_sent);
|
||||
tcp_err(tpcb, altcp_tcp_err);
|
||||
/* tcp_poll is set when interval is set by application */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
||||
@@ -1130,6 +1130,27 @@ dns_check_entries(void)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call dns_answer_ip_validate to check the IP in DNS answer is valid or not
|
||||
*/
|
||||
static u8_t
|
||||
dns_answer_ip_validate(char *ptr)
|
||||
{
|
||||
ip_addr_t ipaddr;
|
||||
u32_t ntohl_addr;
|
||||
|
||||
/* read the IP address after answer resource record's header */
|
||||
SMEMCPY(&ipaddr, (ptr + SIZEOF_DNS_ANSWER), sizeof(ip_addr_t));
|
||||
ntohl_addr = PP_NTOHL(ipaddr.addr);
|
||||
|
||||
LWIP_DEBUGF(DNS_DEBUG, ("dns_validate_ip: "));
|
||||
ip_addr_debug_print(DNS_DEBUG, (&ipaddr));
|
||||
LWIP_DEBUGF(DNS_DEBUG, (", n:%x, h:%x\n", ipaddr.addr, ntohl_addr));
|
||||
|
||||
return ((ntohl_addr == IPADDR_ANY) || (ntohl_addr == IPADDR_LOOPBACK) || (ntohl_addr == IPADDR_BROADCAST) ||
|
||||
IP_MULTICAST(ntohl_addr) || IP_BADCLASS(ntohl_addr)) ? 0 : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save TTL and call dns_call_found for correct response.
|
||||
*/
|
||||
@@ -1281,7 +1302,7 @@ dns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
|
||||
}
|
||||
res_idx = (u16_t)(res_idx + SIZEOF_DNS_ANSWER);
|
||||
|
||||
if (ans.cls == PP_HTONS(DNS_RRCLASS_IN)) {
|
||||
if (ans.cls == PP_HTONS(DNS_RRCLASS_IN) && dns_answer_ip_validate(p)) {
|
||||
#if LWIP_IPV4
|
||||
if ((ans.type == PP_HTONS(DNS_RRTYPE_A)) && (ans.len == PP_HTONS(sizeof(ip4_addr_t)))) {
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
|
||||
@@ -73,6 +73,7 @@
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "lwip/netif.h"
|
||||
#include "lwip/def.h"
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/dhcp.h"
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/dns.h"
|
||||
@@ -445,7 +446,9 @@ dhcp_coarse_tmr(void)
|
||||
if (dhcp->t0_timeout && (++dhcp->lease_used == dhcp->t0_timeout)) {
|
||||
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_coarse_tmr(): t0 timeout\n"));
|
||||
/* this clients' lease time has expired */
|
||||
igmp_report_groups_leave(netif); // not remove group to make able to report group when dhcp bind
|
||||
dhcp_release_and_stop(netif);
|
||||
dhcp->seconds_elapsed = sys_now();
|
||||
dhcp_start(netif);
|
||||
/* timer is active (non zero), and triggers (zeroes) now? */
|
||||
} else if (dhcp->t2_rebind_time && (dhcp->t2_rebind_time-- == 1)) {
|
||||
@@ -561,6 +564,7 @@ dhcp_t1_timeout(struct netif *netif)
|
||||
("dhcp_t1_timeout(): must renew\n"));
|
||||
/* This slightly different to RFC2131: DHCPREQUEST will be sent from state
|
||||
DHCP_STATE_RENEWING, not DHCP_STATE_BOUND */
|
||||
dhcp->seconds_elapsed = sys_now();
|
||||
dhcp_renew(netif);
|
||||
/* Calculate next timeout */
|
||||
if (((dhcp->t2_timeout - dhcp->lease_used) / 2) >= ((60 + DHCP_COARSE_TIMER_SECS / 2) / DHCP_COARSE_TIMER_SECS)) {
|
||||
@@ -778,6 +782,11 @@ dhcp_start(struct netif *netif)
|
||||
/* dhcp is cleared below, no need to reset flag*/
|
||||
}
|
||||
|
||||
#if DHCP_CREATE_RAND_XID && defined(LWIP_SRAND)
|
||||
/* For each system startup, fill in a random seed with different system ticks. */
|
||||
LWIP_SRAND();
|
||||
#endif /* DHCP_CREATE_RAND_XID && defined(LWIP_SRAND) */
|
||||
|
||||
/* clear data structure */
|
||||
memset(dhcp, 0, sizeof(struct dhcp));
|
||||
/* dhcp_set_state(&dhcp, DHCP_STATE_OFF); */
|
||||
@@ -796,6 +805,7 @@ dhcp_start(struct netif *netif)
|
||||
}
|
||||
|
||||
/* (re)start the DHCP negotiation */
|
||||
dhcp->seconds_elapsed = sys_now();
|
||||
result = dhcp_discover(netif);
|
||||
if (result != ERR_OK) {
|
||||
/* free resources allocated above */
|
||||
@@ -954,6 +964,9 @@ dhcp_decline(struct netif *netif)
|
||||
options_out_len = dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_REQUESTED_IP, 4);
|
||||
options_out_len = dhcp_option_long(options_out_len, msg_out->options, lwip_ntohl(ip4_addr_get_u32(&dhcp->offered_ip_addr)));
|
||||
|
||||
dhcp_option(options_out_len, msg_out->options, DHCP_OPTION_SERVER_ID, 4);
|
||||
dhcp_option_long(options_out_len, msg_out->options, lwip_ntohl(ip4_addr_get_u32(&dhcp->server_ip_addr)));
|
||||
|
||||
LWIP_HOOK_DHCP_APPEND_OPTIONS(netif, dhcp, DHCP_STATE_BACKING_OFF, msg_out, DHCP_DECLINE, &options_out_len);
|
||||
dhcp_option_trailer(options_out_len, msg_out->options, p_out);
|
||||
|
||||
@@ -1099,11 +1112,6 @@ dhcp_bind(struct netif *netif)
|
||||
dhcp->t2_rebind_time = dhcp->t2_timeout;
|
||||
}
|
||||
|
||||
/* If we have sub 1 minute lease, t2 and t1 will kick in at the same time. */
|
||||
if ((dhcp->t1_timeout >= dhcp->t2_timeout) && (dhcp->t2_timeout > 0)) {
|
||||
dhcp->t1_timeout = 0;
|
||||
}
|
||||
|
||||
if (dhcp->subnet_mask_given) {
|
||||
/* copy offered network mask */
|
||||
ip4_addr_copy(sn_mask, dhcp->offered_sn_mask);
|
||||
@@ -1120,13 +1128,6 @@ dhcp_bind(struct netif *netif)
|
||||
}
|
||||
|
||||
ip4_addr_copy(gw_addr, dhcp->offered_gw_addr);
|
||||
/* gateway address not given? */
|
||||
if (ip4_addr_isany_val(gw_addr)) {
|
||||
/* copy network address */
|
||||
ip4_addr_get_network(&gw_addr, &dhcp->offered_ip_addr, &sn_mask);
|
||||
/* use first host address on network as gateway */
|
||||
ip4_addr_set_u32(&gw_addr, ip4_addr_get_u32(&gw_addr) | PP_HTONL(0x00000001UL));
|
||||
}
|
||||
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
if (dhcp->autoip_coop_state == DHCP_AUTOIP_COOP_STATE_ON) {
|
||||
@@ -1323,6 +1324,8 @@ void
|
||||
dhcp_release_and_stop(struct netif *netif)
|
||||
{
|
||||
struct dhcp *dhcp = netif_dhcp_data(netif);
|
||||
err_t result;
|
||||
u16_t msecs;
|
||||
ip_addr_t server_ip_addr;
|
||||
|
||||
LWIP_ASSERT_CORE_LOCKED();
|
||||
@@ -1354,6 +1357,7 @@ dhcp_release_and_stop(struct netif *netif)
|
||||
/* create and initialize the DHCP message header */
|
||||
struct pbuf *p_out;
|
||||
u16_t options_out_len;
|
||||
dhcp_set_state(dhcp, DHCP_STATE_OFF);
|
||||
p_out = dhcp_create_msg(netif, dhcp, DHCP_RELEASE, &options_out_len);
|
||||
if (p_out != NULL) {
|
||||
struct dhcp_msg *msg_out = (struct dhcp_msg *)p_out->payload;
|
||||
@@ -1373,6 +1377,8 @@ dhcp_release_and_stop(struct netif *netif)
|
||||
|
||||
/* remove IP address from interface (prevents routing from selecting this interface) */
|
||||
netif_set_addr(netif, IP4_ADDR_ANY4, IP4_ADDR_ANY4, IP4_ADDR_ANY4);
|
||||
} else {
|
||||
dhcp_set_state(dhcp, DHCP_STATE_OFF);
|
||||
}
|
||||
|
||||
#if LWIP_DHCP_AUTOIP_COOP
|
||||
@@ -1382,8 +1388,6 @@ dhcp_release_and_stop(struct netif *netif)
|
||||
}
|
||||
#endif /* LWIP_DHCP_AUTOIP_COOP */
|
||||
|
||||
dhcp_set_state(dhcp, DHCP_STATE_OFF);
|
||||
|
||||
if (dhcp->pcb_allocated != 0) {
|
||||
dhcp_dec_pcb_refcount(); /* free DHCP PCB if not needed any more */
|
||||
dhcp->pcb_allocated = 0;
|
||||
@@ -1514,6 +1518,7 @@ dhcp_parse_reply(struct pbuf *p, struct dhcp *dhcp)
|
||||
u8_t *options;
|
||||
u16_t offset;
|
||||
u16_t offset_max;
|
||||
u16_t options_offset;
|
||||
u16_t options_idx;
|
||||
u16_t options_idx_max;
|
||||
struct pbuf *q;
|
||||
@@ -1546,6 +1551,7 @@ dhcp_parse_reply(struct pbuf *p, struct dhcp *dhcp)
|
||||
options_idx_max = p->tot_len;
|
||||
again:
|
||||
q = p;
|
||||
options_offset = options_idx;
|
||||
while ((q != NULL) && (options_idx >= q->len)) {
|
||||
options_idx = (u16_t)(options_idx - q->len);
|
||||
options_idx_max = (u16_t)(options_idx_max - q->len);
|
||||
@@ -1619,7 +1625,7 @@ again:
|
||||
case (DHCP_OPTION_OVERLOAD):
|
||||
LWIP_DHCP_INPUT_ERROR("len == 1", len == 1, return ERR_VAL;);
|
||||
/* decode overload only in options, not in file/sname: invalid packet */
|
||||
LWIP_DHCP_INPUT_ERROR("overload in file/sname", options_idx == DHCP_OPTIONS_OFS, return ERR_VAL;);
|
||||
LWIP_DHCP_INPUT_ERROR("overload in file/sname", options_offset == DHCP_OPTIONS_OFS, return ERR_VAL;);
|
||||
decode_idx = DHCP_OPTION_IDX_OVERLOAD;
|
||||
break;
|
||||
case (DHCP_OPTION_MESSAGE_TYPE):
|
||||
@@ -1933,6 +1939,11 @@ dhcp_create_msg(struct netif *netif, struct dhcp *dhcp, u8_t message_type, u16_t
|
||||
msg_out->htype = LWIP_IANA_HWTYPE_ETHERNET;
|
||||
msg_out->hlen = netif->hwaddr_len;
|
||||
msg_out->xid = lwip_htonl(dhcp->xid);
|
||||
if ((message_type == DHCP_DISCOVER) || (message_type == DHCP_REQUEST)) {
|
||||
msg_out->secs = (uint16_t)((sys_now() - dhcp->seconds_elapsed) / configTICK_RATE_HZ);
|
||||
} else {
|
||||
msg_out->secs = 0;
|
||||
}
|
||||
/* we don't need the broadcast flag since we can receive unicast traffic
|
||||
before being fully configured! */
|
||||
/* set ciaddr to netif->ip_addr based on message_type and state */
|
||||
|
||||
@@ -983,6 +983,14 @@ etharp_query(struct netif *netif, const ip4_addr_t *ipaddr, struct pbuf *q)
|
||||
/* We don't re-send arp request in etharp_tmr, but we still queue packets,
|
||||
since this failure could be temporary, and the next packet calling
|
||||
etharp_query again could lead to sending the queued packets. */
|
||||
} else {
|
||||
/* ARP request successfully sent */
|
||||
if ((arp_table[i].state == ETHARP_STATE_PENDING) && !is_new_entry) {
|
||||
/* A new ARP request has been sent for a pending entry. Reset the ctime to
|
||||
not let it expire too fast. */
|
||||
LWIP_DEBUGF(ETHARP_DEBUG | LWIP_DBG_TRACE, ("etharp_query: reset ctime for entry %"S16_F"\n", (s16_t)i));
|
||||
arp_table[i].ctime = 0;
|
||||
}
|
||||
}
|
||||
if (q == NULL) {
|
||||
return result;
|
||||
|
||||
@@ -206,6 +206,20 @@ igmp_report_groups(struct netif *netif)
|
||||
}
|
||||
}
|
||||
|
||||
/* Realtek added to only send igmp leave, but not remove group */
|
||||
void
|
||||
igmp_report_groups_leave(struct netif *netif)
|
||||
{
|
||||
struct igmp_group *group = netif_igmp_data(netif);
|
||||
|
||||
while (group != NULL) {
|
||||
if ((!ip_addr_cmp(&group->group_address, &allsystems)) && (group->last_reporter_flag)) {
|
||||
igmp_send(netif, group, IGMP_LEAVE_GROUP);
|
||||
}
|
||||
group = group->next;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a group in the netif's igmp group list
|
||||
*
|
||||
|
||||
@@ -56,6 +56,8 @@
|
||||
#include "lwip/autoip.h"
|
||||
#include "lwip/stats.h"
|
||||
#include "lwip/prot/iana.h"
|
||||
#include "lwip/prot/dhcp.h"
|
||||
#include "platform_opts.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@@ -153,6 +155,7 @@ ip4_route(const ip4_addr_t *dest)
|
||||
{
|
||||
#if !LWIP_SINGLE_NETIF
|
||||
struct netif *netif;
|
||||
struct netif *last_netif = NULL;
|
||||
|
||||
LWIP_ASSERT_CORE_LOCKED();
|
||||
|
||||
@@ -306,15 +309,21 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
/* @todo: send ICMP_DUR_NET? */
|
||||
goto return_noroute;
|
||||
}
|
||||
#if !IP_FORWARD_ALLOW_TX_ON_RX_NETIF
|
||||
#ifdef CONFIG_DONT_CARE_TP
|
||||
/* Do not forward packets onto the same network interface on which
|
||||
* they arrived. */
|
||||
if (netif == inp) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip4_forward: not bouncing packets back on incoming interface.\n"));
|
||||
goto return_noroute;
|
||||
}
|
||||
if((netif->flags & NETIF_FLAG_IPSWITCH) == 0)
|
||||
{
|
||||
#endif
|
||||
#if !IP_FORWARD_ALLOW_TX_ON_RX_NETIF
|
||||
if (netif == inp) {
|
||||
LWIP_DEBUGF(IP_DEBUG, ("ip_forward: not bouncing packets back on incoming interface.\n"));
|
||||
goto return_noroute;
|
||||
}
|
||||
#endif /* IP_FORWARD_ALLOW_TX_ON_RX_NETIF */
|
||||
|
||||
#ifdef CONFIG_DONT_CARE_TP
|
||||
}
|
||||
#endif
|
||||
/* decrement TTL */
|
||||
IPH_TTL_SET(iphdr, IPH_TTL(iphdr) - 1);
|
||||
/* send ICMP if TTL == 0 */
|
||||
@@ -346,7 +355,11 @@ ip4_forward(struct pbuf *p, struct ip_hdr *iphdr, struct netif *inp)
|
||||
|
||||
PERF_STOP("ip4_forward");
|
||||
/* don't fragment if interface has mtu set to 0 [loopif] */
|
||||
#ifdef CONFIG_DONT_CARE_TP
|
||||
if ((netif->flags & NETIF_FLAG_IPSWITCH) &&(netif->mtu && (p->tot_len > netif->mtu)) ){
|
||||
#else
|
||||
if (netif->mtu && (p->tot_len > netif->mtu)) {
|
||||
#endif
|
||||
if ((IPH_OFFSET(iphdr) & PP_NTOHS(IP_DF)) == 0) {
|
||||
#if IP_FRAG
|
||||
ip4_frag(p, netif, ip4_current_dest_addr());
|
||||
@@ -620,7 +633,12 @@ ip4_input(struct pbuf *p, struct netif *inp)
|
||||
LWIP_DEBUGF(IP_DEBUG | LWIP_DBG_TRACE, ("ip4_input: packet not for us.\n"));
|
||||
#if IP_FORWARD
|
||||
/* non-broadcast packet? */
|
||||
if (!ip4_addr_isbroadcast(ip4_current_dest_addr(), inp)) {
|
||||
#ifdef CONFIG_DONT_CARE_TP
|
||||
if(inp->flags & NETIF_FLAG_IPSWITCH)
|
||||
#else
|
||||
if (!ip_addr_isbroadcast(ip4_current_dest_addr(), inp))
|
||||
#endif
|
||||
{
|
||||
/* try to forward IP packet on (other) interfaces */
|
||||
ip4_forward(p, (struct ip_hdr *)p->payload, inp);
|
||||
} else
|
||||
|
||||
@@ -173,6 +173,8 @@ ip4addr_aton(const char *cp, ip4_addr_t *addr)
|
||||
}
|
||||
for (;;) {
|
||||
if (lwip_isdigit(c)) {
|
||||
if((base == 8) && ((u32_t)(c - '0') >= 8))
|
||||
break;
|
||||
val = (val * base) + (u32_t)(c - '0');
|
||||
c = *++cp;
|
||||
} else if (base == 16 && lwip_isxdigit(c)) {
|
||||
|
||||
@@ -1305,6 +1305,7 @@ ip6_output(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||
ip6_addr_copy_from_packed(src_addr, ip6hdr->src);
|
||||
ip6_addr_copy_from_packed(dest_addr, ip6hdr->dest);
|
||||
netif = ip6_route(&src_addr, &dest_addr);
|
||||
dest = &dest_addr;
|
||||
}
|
||||
|
||||
if (netif == NULL) {
|
||||
@@ -1364,6 +1365,7 @@ ip6_output_hinted(struct pbuf *p, const ip6_addr_t *src, const ip6_addr_t *dest,
|
||||
ip6_addr_copy_from_packed(src_addr, ip6hdr->src);
|
||||
ip6_addr_copy_from_packed(dest_addr, ip6hdr->dest);
|
||||
netif = ip6_route(&src_addr, &dest_addr);
|
||||
dest = &dest_addr;
|
||||
}
|
||||
|
||||
if (netif == NULL) {
|
||||
|
||||
@@ -781,7 +781,7 @@ ip6_frag(struct pbuf *p, struct netif *netif, const ip6_addr_t *dest)
|
||||
return ERR_MEM;
|
||||
}
|
||||
LWIP_ASSERT("this needs a pbuf in one piece!",
|
||||
(p->len >= (IP6_HLEN)));
|
||||
(rambuf->len >= (IP6_HLEN)));
|
||||
SMEMCPY(rambuf->payload, original_ip6hdr, IP6_HLEN);
|
||||
ip6hdr = (struct ip6_hdr *)rambuf->payload;
|
||||
frag_hdr = (struct ip6_frag_hdr *)((u8_t*)rambuf->payload + IP6_HLEN);
|
||||
|
||||
@@ -890,7 +890,7 @@ tcp_listen_with_backlog_and_err(struct tcp_pcb *pcb, u8_t backlog, err_t *err)
|
||||
lpcb->state = LISTEN;
|
||||
lpcb->prio = pcb->prio;
|
||||
lpcb->so_options = pcb->so_options;
|
||||
lpcb->netif_idx = NETIF_NO_INDEX;
|
||||
lpcb->netif_idx = pcb->netif_idx;
|
||||
lpcb->ttl = pcb->ttl;
|
||||
lpcb->tos = pcb->tos;
|
||||
#if LWIP_IPV4 && LWIP_IPV6
|
||||
@@ -1329,6 +1329,7 @@ tcp_slowtmr_start:
|
||||
/* Check if KEEPALIVE should be sent */
|
||||
if (ip_get_option(pcb, SOF_KEEPALIVE) &&
|
||||
((pcb->state == ESTABLISHED) ||
|
||||
(pcb->state == FIN_WAIT_1) || //modified by realtek
|
||||
(pcb->state == CLOSE_WAIT))) {
|
||||
if ((u32_t)(tcp_ticks - pcb->tmr) >
|
||||
(pcb->keep_idle + TCP_KEEP_DUR(pcb)) / TCP_SLOW_INTERVAL) {
|
||||
|
||||
@@ -53,6 +53,9 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define port_netconn_recv(conn , buf, ret) do{ret = netconn_recv(conn, &buf);}while(0);
|
||||
#define port_netconn_accept(conn , newconn, ret) do{ret = netconn_accept(conn, &newconn);}while(0);
|
||||
|
||||
/* Throughout this file, IP addresses and port numbers are expected to be in
|
||||
* the same byte order as in the corresponding pcb.
|
||||
*/
|
||||
@@ -350,6 +353,8 @@ err_t netconn_write_vectors_partly(struct netconn *conn, struct netvector *vec
|
||||
err_t netconn_close(struct netconn *conn);
|
||||
err_t netconn_shutdown(struct netconn *conn, u8_t shut_rx, u8_t shut_tx);
|
||||
|
||||
err_t netconn_abort(struct netconn *conn);//Realtek add
|
||||
|
||||
#if LWIP_IGMP || (LWIP_IPV6 && LWIP_IPV6_MLD)
|
||||
err_t netconn_join_leave_group(struct netconn *conn, const ip_addr_t *multiaddr,
|
||||
const ip_addr_t *netif_addr, enum netconn_igmp join_or_leave);
|
||||
|
||||
@@ -39,6 +39,7 @@
|
||||
|
||||
#include "lwip/arch.h"
|
||||
#include "lwip/opt.h"
|
||||
#include <stdio.h> //Realtek add
|
||||
|
||||
/**
|
||||
* @defgroup debugging_levels LWIP_DBG_MIN_LEVEL and LWIP_DBG_TYPES_ON values
|
||||
@@ -145,7 +146,7 @@
|
||||
((debug) & LWIP_DBG_ON) && \
|
||||
((debug) & LWIP_DBG_TYPES_ON) && \
|
||||
((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \
|
||||
LWIP_PLATFORM_DIAG(message); \
|
||||
LWIP_PLATFORM_DIAG message; \
|
||||
if ((debug) & LWIP_DBG_HALT) { \
|
||||
while(1); \
|
||||
} \
|
||||
|
||||
@@ -90,6 +90,7 @@ struct dhcp
|
||||
ip4_addr_t offered_ip_addr;
|
||||
ip4_addr_t offered_sn_mask;
|
||||
ip4_addr_t offered_gw_addr;
|
||||
ip4_addr_t offered_bc_addr;
|
||||
|
||||
u32_t offered_t0_lease; /* lease period (in seconds) */
|
||||
u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
|
||||
@@ -98,6 +99,7 @@ struct dhcp
|
||||
ip4_addr_t offered_si_addr;
|
||||
char boot_file_name[DHCP_BOOT_FILE_LEN];
|
||||
#endif /* LWIP_DHCP_BOOTPFILE */
|
||||
u32_t seconds_elapsed;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -111,6 +111,7 @@ err_t dns_gethostbyname(const char *hostname, ip_addr_t *addr,
|
||||
err_t dns_gethostbyname_addrtype(const char *hostname, ip_addr_t *addr,
|
||||
dns_found_callback found, void *callback_arg,
|
||||
u8_t dns_addrtype);
|
||||
void dns_reset_ttl();
|
||||
|
||||
|
||||
#if DNS_LOCAL_HOSTLIST
|
||||
|
||||
@@ -58,7 +58,7 @@ extern "C" {
|
||||
/** For release candidates, this is set to 1..254
|
||||
* For official releases, this is set to 255 (LWIP_RC_RELEASE)
|
||||
* For development versions (Git), this is set to 0 (LWIP_RC_DEVELOPMENT) */
|
||||
#define LWIP_VERSION_RC 1
|
||||
#define LWIP_VERSION_RC LWIP_RC_RELEASE
|
||||
|
||||
/** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */
|
||||
#define LWIP_RC_RELEASE 255
|
||||
|
||||
@@ -160,6 +160,9 @@ enum netif_mac_filter_action {
|
||||
NETIF_ADD_MAC_FILTER = 1
|
||||
};
|
||||
|
||||
#ifdef CONFIG_DONT_CARE_TP
|
||||
#define NETIF_FLAG_IPSWITCH 0x100U
|
||||
#endif
|
||||
/** Function prototype for netif init functions. Set up flags and output/linkoutput
|
||||
* callback functions in this function.
|
||||
*
|
||||
|
||||
@@ -529,7 +529,7 @@
|
||||
* (only needed if you use the sequential API, like api_lib.c)
|
||||
*/
|
||||
#if !defined MEMP_NUM_NETCONN || defined __DOXYGEN__
|
||||
#define MEMP_NUM_NETCONN 4
|
||||
#define MEMP_NUM_NETCONN 8
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -979,7 +979,7 @@
|
||||
* LWIP_AUTOIP==1: Enable AUTOIP module.
|
||||
*/
|
||||
#if !defined LWIP_AUTOIP || defined __DOXYGEN__
|
||||
#define LWIP_AUTOIP 0
|
||||
#define LWIP_AUTOIP 1 //Realtek modified (0->1)
|
||||
#endif
|
||||
#if !LWIP_IPV4
|
||||
/* disable AUTOIP when IPv4 is disabled */
|
||||
@@ -1753,7 +1753,7 @@
|
||||
* TCPIP_THREAD_NAME: The name assigned to the main tcpip thread.
|
||||
*/
|
||||
#if !defined TCPIP_THREAD_NAME || defined __DOXYGEN__
|
||||
#define TCPIP_THREAD_NAME "tcpip_thread"
|
||||
#define TCPIP_THREAD_NAME "TCP_IP" //Realtek modified ("tcpip_thread"->"TCP_IP")
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -1999,7 +1999,7 @@
|
||||
* SO_RCVTIMEO processing.
|
||||
*/
|
||||
#if !defined LWIP_SO_RCVTIMEO || defined __DOXYGEN__
|
||||
#define LWIP_SO_RCVTIMEO 0
|
||||
#define LWIP_SO_RCVTIMEO 1 //Realtek modified(0->1)
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -2042,7 +2042,7 @@
|
||||
* SO_REUSE==1: Enable SO_REUSEADDR option.
|
||||
*/
|
||||
#if !defined SO_REUSE || defined __DOXYGEN__
|
||||
#define SO_REUSE 0
|
||||
#define SO_REUSE 1
|
||||
#endif
|
||||
|
||||
/**
|
||||
@@ -2255,6 +2255,7 @@
|
||||
#define MLD6_STATS 0
|
||||
#define ND6_STATS 0
|
||||
#define MIB2_STATS 0
|
||||
#define ETHARP_STATS 0 //Realtek add
|
||||
|
||||
#endif /* LWIP_STATS */
|
||||
/**
|
||||
|
||||
@@ -418,6 +418,7 @@ void sys_mbox_set_invalid(sys_mbox_t *mbox);
|
||||
* @param stacksize stack size in bytes for the new thread (may be ignored by ports)
|
||||
* @param prio priority of the new thread (may be ignored by ports) */
|
||||
sys_thread_t sys_thread_new(const char *name, lwip_thread_fn thread, void *arg, int stacksize, int prio);
|
||||
sys_thread_t sys_thread_new_tcm(const char *name, lwip_thread_fn thread , void *arg, int stacksize, int prio);
|
||||
|
||||
#endif /* NO_SYS */
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@
|
||||
|
||||
#if LWIP_TCP /* don't build if not configured for use in lwipopts.h */
|
||||
|
||||
#include "lwip/sys.h"
|
||||
#include "lwip/tcpbase.h"
|
||||
#include "lwip/mem.h"
|
||||
#include "lwip/pbuf.h"
|
||||
@@ -58,6 +59,8 @@ extern "C" {
|
||||
struct tcp_pcb;
|
||||
struct tcp_pcb_listen;
|
||||
|
||||
extern struct tcp_pcb *tcp_tw_pcbs; /* List of all TCP PCBs in TIME-WAIT. */
|
||||
|
||||
/** Function prototype for tcp accept callback functions. Called when a new
|
||||
* connection can be accepted on a listening pcb.
|
||||
*
|
||||
|
||||
@@ -102,6 +102,14 @@ struct sys_timeo {
|
||||
|
||||
void sys_timeouts_init(void);
|
||||
|
||||
//Realtek add
|
||||
struct sys_timeouts {
|
||||
struct sys_timeo *next;
|
||||
};
|
||||
|
||||
struct sys_timeouts *sys_arch_timeouts(void);
|
||||
//Realtek add end
|
||||
|
||||
#if LWIP_DEBUG_TIMERNAMES
|
||||
void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name);
|
||||
#define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler)
|
||||
|
||||
0
src/include/netif/loopif.h
Normal file
0
src/include/netif/loopif.h
Normal file
@@ -216,7 +216,8 @@ static err_t ppp_netif_output(struct netif *netif, struct pbuf *pb, u16_t protoc
|
||||
/***********************************/
|
||||
#if PPP_AUTH_SUPPORT
|
||||
void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *passwd) {
|
||||
LWIP_ASSERT_CORE_LOCKED();
|
||||
LWIP_ASSERT("pcb->phase == PPP_PHASE_DEAD", pcb->phase == PPP_PHASE_DEAD);
|
||||
|
||||
#if PAP_SUPPORT
|
||||
pcb->settings.refuse_pap = !(authtype & PPPAUTHTYPE_PAP);
|
||||
#endif /* PAP_SUPPORT */
|
||||
@@ -238,6 +239,8 @@ void ppp_set_auth(ppp_pcb *pcb, u8_t authtype, const char *user, const char *pas
|
||||
#if MPPE_SUPPORT
|
||||
/* Set MPPE configuration */
|
||||
void ppp_set_mppe(ppp_pcb *pcb, u8_t flags) {
|
||||
LWIP_ASSERT("pcb->phase == PPP_PHASE_DEAD", pcb->phase == PPP_PHASE_DEAD);
|
||||
|
||||
if (flags == PPP_MPPE_DISABLE) {
|
||||
pcb->settings.require_mppe = 0;
|
||||
return;
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#error "This tests needs LWIP_NETIF_EXT_STATUS_CALLBACK enabled"
|
||||
#endif
|
||||
|
||||
struct netif net_test;
|
||||
static struct netif net_test;
|
||||
|
||||
|
||||
/* Setups/teardown functions */
|
||||
@@ -215,13 +215,67 @@ START_TEST(test_netif_extcallbacks)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_netif_flag_set)
|
||||
{
|
||||
ip4_addr_t addr;
|
||||
ip4_addr_t netmask;
|
||||
ip4_addr_t gw;
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
IP4_ADDR(&addr, 0, 0, 0, 0);
|
||||
IP4_ADDR(&netmask, 0, 0, 0, 0);
|
||||
IP4_ADDR(&gw, 0, 0, 0, 0);
|
||||
|
||||
netif_add(&net_test, &addr, &netmask, &gw, &net_test, testif_init, ethernet_input);
|
||||
|
||||
fail_if(netif_is_flag_set(&net_test, NETIF_FLAG_UP));
|
||||
fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_BROADCAST));
|
||||
fail_if(netif_is_flag_set(&net_test, NETIF_FLAG_LINK_UP));
|
||||
fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_ETHARP));
|
||||
fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_ETHERNET));
|
||||
fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_IGMP));
|
||||
fail_unless(netif_is_flag_set(&net_test, NETIF_FLAG_MLD6));
|
||||
|
||||
netif_remove(&net_test);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
START_TEST(test_netif_find)
|
||||
{
|
||||
struct netif net0;
|
||||
struct netif net1;
|
||||
LWIP_UNUSED_ARG(_i);
|
||||
|
||||
/* No netifs available */
|
||||
fail_unless(netif_find("ch0") == NULL);
|
||||
|
||||
/* Add netifs with known names */
|
||||
fail_unless(netif_add_noaddr(&net0, NULL, testif_init, ethernet_input) == &net0);
|
||||
net0.num = 0;
|
||||
fail_unless(netif_add_noaddr(&net1, NULL, testif_init, ethernet_input) == &net1);
|
||||
net1.num = 1;
|
||||
|
||||
fail_unless(netif_find("ch0") == &net0);
|
||||
fail_unless(netif_find("CH0") == NULL);
|
||||
fail_unless(netif_find("ch1") == &net1);
|
||||
fail_unless(netif_find("ch3") == NULL);
|
||||
/* atoi failure is not treated as zero */
|
||||
fail_unless(netif_find("chX") == NULL);
|
||||
fail_unless(netif_find("ab0") == NULL);
|
||||
|
||||
netif_remove(&net0);
|
||||
netif_remove(&net1);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/** Create the suite including all tests for this module */
|
||||
Suite *
|
||||
netif_suite(void)
|
||||
{
|
||||
testfunc tests[] = {
|
||||
TESTFUNC(test_netif_extcallbacks)
|
||||
TESTFUNC(test_netif_extcallbacks),
|
||||
TESTFUNC(test_netif_flag_set),
|
||||
TESTFUNC(test_netif_find)
|
||||
};
|
||||
return create_suite("NETIF", tests, sizeof(tests)/sizeof(testfunc), netif_setup, netif_teardown);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "lwip/etharp.h"
|
||||
#include "netif/ethernet.h"
|
||||
|
||||
struct netif net_test;
|
||||
static struct netif net_test;
|
||||
|
||||
static const u8_t broadcast[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
|
||||
|
||||
|
||||
@@ -287,6 +287,43 @@ START_TEST(test_ip6_lladdr)
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/* Reproduces bug #57374 */
|
||||
START_TEST(test_ip6_frag_pbuf_len_assert)
|
||||
{
|
||||
ip_addr_t my_addr = IPADDR6_INIT_HOST(0x20010db8, 0x0, 0x0, 0x1);
|
||||
ip_addr_t peer_addr = IPADDR6_INIT_HOST(0x20010db8, 0x0, 0x0, 0x4);
|
||||
struct pbuf *payload, *hdr;
|
||||
err_t err;
|
||||
int i;
|
||||
|
||||
/* Configure and enable local address */
|
||||
test_netif6.mtu = 1500;
|
||||
netif_set_up(&test_netif6);
|
||||
netif_ip6_addr_set(&test_netif6, 0, ip_2_ip6(&my_addr));
|
||||
netif_ip6_addr_set_state(&test_netif6, 0, IP6_ADDR_VALID);
|
||||
|
||||
/* Create packet with lots of small pbufs around mtu limit */
|
||||
payload = pbuf_alloc(PBUF_RAW, 1400, PBUF_POOL);
|
||||
fail_unless(payload != NULL);
|
||||
for (i = 0; i < 16; i++) {
|
||||
struct pbuf *p = pbuf_alloc(PBUF_RAW, 32, PBUF_RAM);
|
||||
fail_unless(p != NULL);
|
||||
pbuf_cat(payload, p);
|
||||
}
|
||||
/* Prefix with header like UDP would */
|
||||
hdr = pbuf_alloc(PBUF_IP, 8, PBUF_RAM);
|
||||
fail_unless(hdr != NULL);
|
||||
pbuf_chain(hdr, payload);
|
||||
|
||||
/* Send it and don't crash while fragmenting */
|
||||
err = ip6_output_if_src(hdr, ip_2_ip6(&my_addr), ip_2_ip6(&peer_addr), 15, 0, IP_PROTO_UDP, &test_netif6);
|
||||
fail_unless(err == ERR_OK);
|
||||
|
||||
pbuf_free(hdr);
|
||||
pbuf_free(payload);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
/** Create the suite including all tests for this module */
|
||||
Suite *
|
||||
ip6_suite(void)
|
||||
@@ -296,7 +333,8 @@ ip6_suite(void)
|
||||
TESTFUNC(test_ip6_aton_ipv4mapped),
|
||||
TESTFUNC(test_ip6_ntoa_ipv4mapped),
|
||||
TESTFUNC(test_ip6_ntoa),
|
||||
TESTFUNC(test_ip6_lladdr)
|
||||
TESTFUNC(test_ip6_lladdr),
|
||||
TESTFUNC(test_ip6_frag_pbuf_len_assert)
|
||||
};
|
||||
return create_suite("IPv6", tests, sizeof(tests)/sizeof(testfunc), ip6_setup, ip6_teardown);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#define EXPECT_RETX(x, y) do { fail_unless(x); if(!(x)) { return y; }} while(0)
|
||||
#define EXPECT_RETNULL(x) EXPECT_RETX(x, NULL)
|
||||
|
||||
#if (CHECK_MAJOR_VERSION == 0 && CHECK_MINOR_VERSION < 13)
|
||||
typedef struct {
|
||||
TFun func;
|
||||
const char *name;
|
||||
@@ -24,6 +25,15 @@ typedef struct {
|
||||
#define tcase_add_named_test(tc,tf) \
|
||||
_tcase_add_test((tc),(tf).func,(tf).name,0, 0, 0, 1)
|
||||
|
||||
#else
|
||||
/* From 0.13.0 check keeps track of the method name internally */
|
||||
typedef const TTest * testfunc;
|
||||
|
||||
#define TESTFUNC(x) x
|
||||
|
||||
#define tcase_add_named_test(tc,tf) tcase_add_test(tc,tf)
|
||||
#endif
|
||||
|
||||
/** typedef for a function returning a test suite */
|
||||
typedef Suite* (suite_getter_fn)(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user