From 3cad43fc05e6b7e3b1549df86315e3dee66eb0ba Mon Sep 17 00:00:00 2001 From: xools Date: Sat, 22 Apr 2017 22:39:09 -0700 Subject: [PATCH] add lwip-2.0.2 compile compatibility --- components/net/KConfig | 3 + components/net/SConscript | 2 +- components/net/lwip-2.0.2/SConscript | 81 +++++++++++++++++++ components/net/lwip-2.0.2/src/arch/sys_arch.c | 3 +- components/net/lwip-2.0.2/src/lwipopts.h | 16 ++-- components/net/lwip-2.0.2/src/lwippools.h | 2 +- .../net/lwip-2.0.2/src/netif/ethernetif.c | 6 +- 7 files changed, 98 insertions(+), 15 deletions(-) create mode 100644 components/net/lwip-2.0.2/SConscript diff --git a/components/net/KConfig b/components/net/KConfig index 5b9c46a4be..0f2b2d794d 100644 --- a/components/net/KConfig +++ b/components/net/KConfig @@ -17,6 +17,9 @@ config RT_USING_LWIP config RT_USING_LWIP200 bool "lwIP v2.0.0" + + config RT_USING_LWIP202 + bool "lwIP v2.0.2" endchoice config RT_LWIP_IGMP diff --git a/components/net/SConscript b/components/net/SConscript index 2674866178..6b70ba6249 100644 --- a/components/net/SConscript +++ b/components/net/SConscript @@ -8,7 +8,7 @@ cwd = GetCurrentDir() list = os.listdir(cwd) # the default version of LWIP is 1.4.1 -if not GetDepend('RT_USING_LWIP132') and not GetDepend('RT_USING_LWIP140') and not GetDepend('RT_USING_LWIP200'): +if not GetDepend('RT_USING_LWIP132') and not GetDepend('RT_USING_LWIP140') and not GetDepend('RT_USING_LWIP200') and not GetDepend('RT_USING_LWIP202'): AddDepend('RT_USING_LWIP141') for d in list: diff --git a/components/net/lwip-2.0.2/SConscript b/components/net/lwip-2.0.2/SConscript new file mode 100644 index 0000000000..631e4c1e6b --- /dev/null +++ b/components/net/lwip-2.0.2/SConscript @@ -0,0 +1,81 @@ +from building import * + +src = Split(""" +src/arch/sys_arch.c +src/api/api_lib.c +src/api/api_msg.c +src/api/err.c +src/api/netbuf.c +src/api/netdb.c +src/api/netifapi.c +src/api/sockets.c +src/api/tcpip.c +src/core/def.c +src/core/dns.c +src/core/inet_chksum.c +src/core/init.c +src/core/ip.c +src/core/memp.c +src/core/netif.c +src/core/pbuf.c +src/core/raw.c +src/core/stats.c +src/core/sys.c +src/core/tcp.c +src/core/tcp_in.c +src/core/tcp_out.c +src/core/timeouts.c +src/core/udp.c +src/netif/ethernet.c +src/netif/ethernetif.c +src/netif/lowpan6.c +src/netif/slipif.c +""") + +ipv4_src = Split(""" +src/core/ipv4/autoip.c +src/core/ipv4/dhcp.c +src/core/ipv4/etharp.c +src/core/ipv4/icmp.c +src/core/ipv4/igmp.c +src/core/ipv4/ip4.c +src/core/ipv4/ip4_addr.c +src/core/ipv4/ip4_frag.c +""") + +ipv6_src = Split(""" +src/core/ipv6/dhcp6.c +src/core/ipv6/ethip6.c +src/core/ipv6/icmp6.c +src/core/ipv6/inet6.c +src/core/ipv6/ip6.c +src/core/ipv6/ip6_addr.c +src/core/ipv6/ip6_frag.c +src/core/ipv6/mld6.c +src/core/ipv6/nd6.c +""") + +snmp_src = Glob("src/apps/snmp/*.c") + +ppp_src = Glob("src/netif/ppp/*.c") + Glob("src/netif/ppp/polarssl/*c") + +src = src + ipv4_src + +# The set of source files associated with this SConscript file. +path = [GetCurrentDir() + '/src', + GetCurrentDir() + '/src/include', + GetCurrentDir() + '/src/include/ipv4', + GetCurrentDir() + '/src/arch/include', + GetCurrentDir() + '/src/include/netif'] + +if GetDepend(['RT_LWIP_SNMP']): + src += snmp_src + path += [GetCurrentDir() + '/src/apps/snmp'] + +if GetDepend(['RT_LWIP_PPP']): + src += ppp_src + path += [GetCurrentDir() + '/src/netif/ppp'] + +group = DefineGroup('lwIP', src, depend = ['RT_USING_LWIP', 'RT_USING_LWIP202'], CPPPATH = path) + +Return('group') diff --git a/components/net/lwip-2.0.2/src/arch/sys_arch.c b/components/net/lwip-2.0.2/src/arch/sys_arch.c index d02e29bef5..4cddf86eb6 100644 --- a/components/net/lwip-2.0.2/src/arch/sys_arch.c +++ b/components/net/lwip-2.0.2/src/arch/sys_arch.c @@ -22,6 +22,7 @@ #include "arch/sys_arch.h" #include "lwip/debug.h" #include "lwip/netif.h" +#include "lwip/netifapi.h" #include "lwip/tcpip.h" #include "netif/ethernetif.h" #include "lwip/sio.h" @@ -601,7 +602,6 @@ u32_t sys_now(void) } -#if 0 WEAK void mem_init(void) { @@ -628,7 +628,6 @@ void mem_free(void *mem) { rt_free(mem); } -#endif #ifdef RT_LWIP_PPP u32_t sio_read(sio_fd_t fd, u8_t *buf, u32_t size) diff --git a/components/net/lwip-2.0.2/src/lwipopts.h b/components/net/lwip-2.0.2/src/lwipopts.h index 06366f92d6..873691c414 100644 --- a/components/net/lwip-2.0.2/src/lwipopts.h +++ b/components/net/lwip-2.0.2/src/lwipopts.h @@ -39,7 +39,7 @@ #define LWIP_HAVE_LOOPIF 0 #define LWIP_PLATFORM_BYTESWAP 0 -#define BYTE_ORDER LITTLE_ENDIAN +//#define BYTE_ORDER LITTLE_ENDIAN /* #define RT_LWIP_DEBUG */ @@ -52,9 +52,9 @@ #define SYS_DEBUG LWIP_DBG_OFF #define ETHARP_DEBUG LWIP_DBG_OFF #define PPP_DEBUG LWIP_DBG_OFF -#define MEM_DEBUG LWIP_DBG_ON -#define MEMP_DEBUG LWIP_DBG_ON -#define PBUF_DEBUG LWIP_DBG_ON +#define MEM_DEBUG LWIP_DBG_OFF +#define MEMP_DEBUG LWIP_DBG_OFF +#define PBUF_DEBUG LWIP_DBG_OFF #define API_LIB_DEBUG LWIP_DBG_OFF #define API_MSG_DEBUG LWIP_DBG_OFF #define TCPIP_DEBUG LWIP_DBG_OFF @@ -86,9 +86,9 @@ #define MEMP_OVERFLOW_CHECK 1 //// #define LWIP_ALLOW_MEM_FREE_FROM_OTHER_CONTEXT 1 //// //#define MEM_LIBC_MALLOC 1 -#define MEM_USE_POOLS 1 -#define MEMP_USE_CUSTOM_POOLS 1 -#define MEM_SIZE (1024*64) +//#define MEM_USE_POOLS 1 +//#define MEMP_USE_CUSTOM_POOLS 1 +//#define MEM_SIZE (1024*64) #ifdef RT_LWIP_USING_RT_MEM #define MEMP_MEM_MALLOC 1 @@ -99,7 +99,7 @@ /* MEMP_NUM_PBUF: the number of memp struct pbufs. If the application sends a lot of data out of ROM (or other static memory), this should be set high. */ -#define MEMP_NUM_PBUF 64 //16 +#define MEMP_NUM_PBUF 32 //16 /* the number of UDP protocol control blocks. One per active RAW "connection". */ #ifdef RT_LWIP_RAW_PCB_NUM diff --git a/components/net/lwip-2.0.2/src/lwippools.h b/components/net/lwip-2.0.2/src/lwippools.h index 9c8b2b483a..6583863de3 100644 --- a/components/net/lwip-2.0.2/src/lwippools.h +++ b/components/net/lwip-2.0.2/src/lwippools.h @@ -5,6 +5,6 @@ LWIP_MALLOC_MEMPOOL((unsigned char)128, 1024) LWIP_MALLOC_MEMPOOL((unsigned char)128, 1514) LWIP_MALLOC_MEMPOOL((unsigned char)128, 1536) - LWIP_MALLOC_MEMPOOL((unsigned char)128, 4096) + LWIP_MALLOC_MEMPOOL((unsigned char)128, 4096) LWIP_MALLOC_MEMPOOL_END #endif diff --git a/components/net/lwip-2.0.2/src/netif/ethernetif.c b/components/net/lwip-2.0.2/src/netif/ethernetif.c index 8c6f1657d7..4dca17b3e1 100644 --- a/components/net/lwip-2.0.2/src/netif/ethernetif.c +++ b/components/net/lwip-2.0.2/src/netif/ethernetif.c @@ -506,11 +506,11 @@ FINSH_FUNCTION_EXPORT(set_if, set network interface address); #include void set_dns(char* dns_server) { - ip_addr_t *addr; + ip_addr_t addr; - if ((dns_server != RT_NULL) && ipaddr_aton(dns_server, addr)) + if ((dns_server != RT_NULL) && ipaddr_aton(dns_server, &addr)) { - dns_setserver(0, addr); + dns_setserver(0, &addr); } } FINSH_FUNCTION_EXPORT(set_dns, set DNS server address);