提交 de1fd2bf 编写于 作者: L liuxianliang

[add] lwIP 2.1.2 transplantation on RT-Thread.

Signed-off-by: Nliuxianliang <liuxianliang@rt-thread.com>
上级 a9796b90
......@@ -120,9 +120,13 @@ config RT_USING_LWIP
config RT_USING_LWIP210
bool "lwIP v2.1.0"
config RT_USING_LWIP212
bool "lwIP v2.1.2"
endchoice
if (RT_USING_LWIP210 || RT_USING_LWIP202)
if (RT_USING_LWIP210 || RT_USING_LWIP202 || RT_USING_LWIP212)
config RT_USING_LWIP_IPV6
bool "IPV6 protocol"
default n
......
......@@ -8,7 +8,7 @@ cwd = GetCurrentDir()
list = os.listdir(cwd)
# the default version of LWIP is 2.0.2
if not GetDepend('RT_USING_LWIP141') and not GetDepend('RT_USING_LWIP202') and not GetDepend('RT_USING_LWIP210'):
if not GetDepend('RT_USING_LWIP141') and not GetDepend('RT_USING_LWIP202') and not GetDepend('RT_USING_LWIP210') and not GetDepend('RT_USING_LWIP212'):
AddDepend('RT_USING_LWIP202')
for d in list:
......
# lwip 移植说明
为了适配 RT-Thread 网卡设备,RT-Thread 团队基于原 [lwip](http://savannah.nongnu.org/projects/lwip/) 进行了一些修改,本文档记录了相关修改内容。
> 本 lwip-2.1.2 版本基于 [lwip STABLE-2_1_2_RELEASE](https://git.savannah.gnu.org/git/lwip.git) 版本移植而来。
| Date | Author | Notes |
| :---- | :---- | :---- |
| 2019-09-02 | MurphyZhao | 增加 lwip 2.1.2 移植说明 |
| 2020-06-18 | xiangxistu | 增加部分 lwIP 2.1.2 移植说明 |
## 修改内容
### src/api
- `src/api/sockets.c` 增加 `lwip_tryget_socket` 函数,作为 `tryget_socket` 函数的全局实现
- `src/api/sockets.c``alloc_socket` 函数中,增加 SAL 移植函数 `rt_wqueue_init`
```
#ifdef SAL_USING_POSIX
rt_wqueue_init(&sockets[i].wait_head);
#endif
```
### src/app
- 增加 `ping/ping.c`,便于在 finsh/msh 中使用 ping 功能
- 增加 `tftp/tftp_port.c`,便于在 finsh/msh 中使用 tftp_server 功能
### src/arch
增加 `src/arch` 目录,存储对接 RT-Thread 设备框架的移植文件,从 lwip-2.0.2 版本中的移植文件修改而来。
以及相对于 lwIP2.0.2 的增加修改内容:
*`src/arch/sys_arch.c` 中增加 MTU 与 etharp_output 的初始化
*`src/arch/sys_arch.c` 中增加新添加的邮箱函数
对邮箱机制的新增加的 sys_mbox_trypost_fromisr 函数予以实现
*`src/arch/sys_arch.c` 中增加新添加的内存堆函数
对内存堆的新增加的 mem_overflow_check_raw 与 mem_overflow_init_raw 函数予以实现
*`src/arch/cc.h` 中增加对 lwIP 使用的标准错误代码宏的处理,不再使用 lwIP 内置的错误宏
### src/core
-`src/core/dns.c``dns_setserver` 函数中增加 RT-Thread netdev 相关的移植
-`src/core/netif.c` 中增加 RT-Thread netdev 相关的移植
### src/include
-`src/include/lwip/priv/sockets_priv.h` 中增加 SAL 相关的移植
在 `lwip_sock` 结构体中增加 ` rt_wqueue_t wait_head;` 成员
-`src/include/lwip/prot/ieee.h` 中增加 EAPOL, EAP over LAN 标识
-`src/include/lwip/init.h` 中的版本号后增加 `U` 标识
-`src/include/lwip/sockets.h` 中增加 `LWIP_SOCKET_SELECT`,解决开启 RT_USING_POSIX 时的冲突
-`src/include/lwip/arch.h` 中修改 `<unistd.h> ``"sys/types.h" `,解决编译冲突
并添加 typedef int ssize_t 定义,补足因 libc 与 dfs 未开启时 ssize_t 的定义不足问题
-`src/include/netif/` 中增加 `ethernetif.h`,用于对接 RT-Thread 网卡设备
### src/netif
-`src/netif/` 中增加 `ethernetif.c`,用于对接 RT-Thread 网卡设备
-`src/netif/lowpan6.c` 中增加 `LWIP_6LOWPAN` 宏定义,以防止编译错误
### src
- 在 src 目录下,增加 `src/lwipopts.h`,用于 lwip 功能裁剪以及配置设置
- 在 src 目录下,增加 `src/lwippools.h`,用于定义 `LWIP_MALLOC_MEMPOOL`
### 其它
- 增加 SConscript 文件,用于 scons 构建
- 增加 README_RT-THREAD.md 文件,用于记录相对原 lwip 源码的改动
from building import *
# get current directory
cwd = GetCurrentDir()
# 1. The minimum set of files needed for lwIP.
lwipcore_SRCS = Split("""
src/core/init.c
src/core/def.c
src/core/dns.c
src/core/inet_chksum.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
""")
# 1.1
lwipcore_altcp_SRCS = Split("""
src/core/altcp.c
src/core/altcp_alloc.c
src/core/altcp_tcp.c
""")
# 1.2
lwipcore4_SRCS = 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_frag.c
src/core/ipv4/ip4.c
src/core/ipv4/ip4_addr.c
""")
# 1.3
lwipcore6_SRCS = 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
""")
# 2. APIFILES: The files which implement the sequential and socket APIs.
lwipapi_SRCS = Split("""
src/api/api_lib.c
src/api/api_msg.c
src/api/err.c
src/api/if_api.c
src/api/netbuf.c
src/api/netdb.c
src/api/netifapi.c
src/api/sockets.c
src/api/tcpip.c
""")
# 3. Files implementing various generic network interface functions
lwipnetif_SRCS = Split("""
src/netif/ethernet.c
src/netif/ethernetif.c
""")
# 3.1 Files implementing an IEEE 802.1D bridge by using a multilayer netif approach
lwipnetif_bridgeif_SRCS = Split("""
src/netif/bridgeif.c
src/netif/bridgeif_fdb.c
""")
# 3.2 A generic implementation of the SLIP (Serial Line IP) protocol.
lwipnetif_slipif_SRCS = Split("""
src/netif/slipif.c
""")
# 4. 6LoWPAN
lwipsixlowpan_SRCS = Split("""
src/netif/lowpan6.c
""")
# 4.1 A 6LoWPAN over Bluetooth Low Energy (BLE) implementation as netif,
# according to RFC-7668.
lwipsixlowpan_ble_SRCS = Split("""
src/netif/lowpan6_ble.c
""")
# 4.2 Common 6LowPAN routines for IPv6.
lwipsixlowpan_ipv6_SRCS = Split("""
src/netif/lowpan6_common.c
""")
# 4.3 A netif implementing the ZigBee Encapsulation Protocol (ZEP).
lwipsixlowpan_zep_SRCS = Split("""
src/netif/zepif.c
""")
# 5. PPP
lwipppp_SRCS = Split("""
src/netif/ppp/auth.c
src/netif/ppp/ccp.c
src/netif/ppp/chap-md5.c
src/netif/ppp/chap_ms.c
src/netif/ppp/chap-new.c
src/netif/ppp/demand.c
src/netif/ppp/eap.c
src/netif/ppp/ecp.c
src/netif/ppp/eui64.c
src/netif/ppp/fsm.c
src/netif/ppp/ipcp.c
src/netif/ppp/ipv6cp.c
src/netif/ppp/lcp.c
src/netif/ppp/magic.c
src/netif/ppp/mppe.c
src/netif/ppp/multilink.c
src/netif/ppp/ppp.c
src/netif/ppp/pppapi.c
src/netif/ppp/pppcrypt.c
src/netif/ppp/pppoe.c
src/netif/ppp/pppol2tp.c
src/netif/ppp/pppos.c
src/netif/ppp/upap.c
src/netif/ppp/utils.c
src/netif/ppp/vj.c
src/netif/ppp/polarssl/arc4.c
src/netif/ppp/polarssl/des.c
src/netif/ppp/polarssl/md4.c
src/netif/ppp/polarssl/md5.c
src/netif/ppp/polarssl/sha1.c
""")
# 6. SNMPv3 agent
lwipsnmp_SRCS = Split("""
src/apps/snmp/snmp_asn1.c
src/apps/snmp/snmp_core.c
src/apps/snmp/snmp_mib2.c
src/apps/snmp/snmp_mib2_icmp.c
src/apps/snmp/snmp_mib2_interfaces.c
src/apps/snmp/snmp_mib2_ip.c
src/apps/snmp/snmp_mib2_snmp.c
src/apps/snmp/snmp_mib2_system.c
src/apps/snmp/snmp_mib2_tcp.c
src/apps/snmp/snmp_mib2_udp.c
src/apps/snmp/snmp_snmpv2_framework.c
src/apps/snmp/snmp_snmpv2_usm.c
src/apps/snmp/snmp_msg.c
src/apps/snmp/snmpv3.c
src/apps/snmp/snmp_netconn.c
src/apps/snmp/snmp_pbuf_stream.c
src/apps/snmp/snmp_raw.c
src/apps/snmp/snmp_scalar.c
src/apps/snmp/snmp_table.c
src/apps/snmp/snmp_threadsync.c
src/apps/snmp/snmp_traps.c
""")
# 7. HTTP server + client
lwiphttp_SRCS = Split("""
src/apps/http/altcp_proxyconnect.c
src/apps/http/fs.c
src/apps/http/http_client.c
src/apps/http/httpd.c
""")
# 8. MAKEFSDATA HTTP server host utility
lwipmakefsdata_SRCS = Split("""
src/apps/http/makefsdata/makefsdata.c
""")
# 9. IPERF server
lwipiperf_SRCS = Split("""
src/apps/lwiperf/lwiperf.c
""")
# 10. SMTP client
lwipsmtp_SRCS = Split("""
src/apps/smtp/smtp.c
""")
# 11. SNTP client
lwipsntp_SRCS = Split("""
src/apps/sntp/sntp.c
""")
# 12. MDNS responder
lwipmdns_SRCS = Split("""
src/apps/mdns/mdns.c
""")
# 13. NetBIOS name server
lwipnetbios_SRCS = Split("""
src/apps/netbiosns/netbiosns.c
""")
# 14. TFTP server files
lwiptftp_SRCS = Split("""
src/apps/tftp/tftp_server.c
src/apps/tftp/tftp_port.c
""")
# 15. MQTT client files
lwipmqtt_SRCS = Split("""
src/apps/mqtt/mqtt.c
""")
# 16. ARM MBEDTLS related files of lwIP rep
lwipmbedtls_SRCS = Split("""
src/apps/altcp_tls/altcp_tls_mbedtls.c
src/apps/altcp_tls/altcp_tls_mbedtls_mem.c
src/apps/snmp/snmpv3_mbedtls.c
""")
# 17. ping
lwipping_SRCS = Split("""
src/apps/ping/ping.c
""")
src = Split("""
src/arch/sys_arch.c
""")
src += lwipcore_SRCS # rm mem.c
src += lwipcore_altcp_SRCS
src += lwipapi_SRCS
src += lwipnetif_SRCS
src += lwipsixlowpan_SRCS
src += lwipcore4_SRCS
path = [cwd + '/src',
cwd + '/src/include',
cwd + '/src/arch/include',
cwd + '/src/include/netif']
if not GetDepend('RT_USING_SAL'):
path += [cwd + '/src/include/compat/posix']
if GetDepend(['RT_LWIP_SNMP']):
src += lwipsnmp_SRCS
path += [cwd + '/src/apps/snmp']
if GetDepend(['RT_LWIP_PPP']):
src += lwipppp_SRCS
path += [cwd + '/src/netif/ppp']
if GetDepend(['RT_USING_LWIP_IPV6']):
src += lwipcore6_SRCS
if GetDepend(['RT_LWIP_USING_PING']):
src += lwipping_SRCS
group = DefineGroup('lwIP', src, depend = ['RT_USING_LWIP', 'RT_USING_LWIP212'], CPPPATH = path)
Return('group')
/*
* netutils: ping implementation
*/
#include <rtthread.h>
#ifdef RT_LWIP_ICMP /* don't build if not configured for use in rtconfig.h */
#include <lwip/opt.h>
#include <lwip/init.h>
#include <lwip/mem.h>
#include <lwip/icmp.h>
#include <lwip/netif.h>
#include <lwip/sys.h>
#include <lwip/inet.h>
#include <lwip/inet_chksum.h>
#include <lwip/ip.h>
#include <lwip/netdb.h>
#include <lwip/sockets.h>
/**
* PING_DEBUG: Enable debugging for PING.
*/
#ifndef PING_DEBUG
#define PING_DEBUG LWIP_DBG_ON
#endif
/** ping receive timeout - in milliseconds */
#define PING_RCV_TIMEO (2 * RT_TICK_PER_SECOND)
/** ping delay - in milliseconds */
#define PING_DELAY (1 * RT_TICK_PER_SECOND)
/** ping identifier - must fit on a u16_t */
#ifndef PING_ID
#define PING_ID 0xAFAF
#endif
/** ping additional data size to include in the packet */
#ifndef PING_DATA_SIZE
#define PING_DATA_SIZE 32
#endif
/* ping variables */
static u16_t ping_seq_num;
struct _ip_addr
{
rt_uint8_t addr0, addr1, addr2, addr3;
};
/** Prepare a echo ICMP request */
static void ping_prepare_echo( struct icmp_echo_hdr *iecho, u16_t len)
{
size_t i;
size_t data_len = len - sizeof(struct icmp_echo_hdr);
ICMPH_TYPE_SET(iecho, ICMP_ECHO);
ICMPH_CODE_SET(iecho, 0);
iecho->chksum = 0;
iecho->id = PING_ID;
iecho->seqno = htons(++ping_seq_num);
/* fill the additional data buffer with some data */
for (i = 0; i < data_len; i++)
{
((char*) iecho)[sizeof(struct icmp_echo_hdr) + i] = (char) i;
}
#ifdef RT_LWIP_USING_HW_CHECKSUM
iecho->chksum = 0;
#else
iecho->chksum = inet_chksum(iecho, len);
#endif
}
/* Ping using the socket ip */
err_t lwip_ping_send(int s, ip_addr_t *addr, int size)
{
int err;
struct icmp_echo_hdr *iecho;
struct sockaddr_in to;
int ping_size = sizeof(struct icmp_echo_hdr) + size;
LWIP_ASSERT("ping_size is too big", ping_size <= 0xffff);
iecho = rt_malloc(ping_size);
if (iecho == RT_NULL)
{
return ERR_MEM;
}
ping_prepare_echo(iecho, (u16_t) ping_size);
to.sin_len = sizeof(to);
to.sin_family = AF_INET;
#if LWIP_IPV4 && LWIP_IPV6
to.sin_addr.s_addr = addr->u_addr.ip4.addr;
#elif LWIP_IPV4
to.sin_addr.s_addr = addr->addr;
#elif LWIP_IPV6
#error Not supported IPv6.
#endif
err = lwip_sendto(s, iecho, ping_size, 0, (struct sockaddr*) &to, sizeof(to));
rt_free(iecho);
return (err == ping_size ? ERR_OK : ERR_VAL);
}
int lwip_ping_recv(int s, int *ttl)
{
char buf[64];
int fromlen = sizeof(struct sockaddr_in), len;
struct sockaddr_in from;
struct ip_hdr *iphdr;
struct icmp_echo_hdr *iecho;
while ((len = lwip_recvfrom(s, buf, sizeof(buf), 0, (struct sockaddr*) &from, (socklen_t*) &fromlen)) > 0)
{
if (len >= (int)(sizeof(struct ip_hdr) + sizeof(struct icmp_echo_hdr)))
{
iphdr = (struct ip_hdr *) buf;
iecho = (struct icmp_echo_hdr *) (buf + (IPH_HL(iphdr) * 4));
if ((iecho->id == PING_ID) && (iecho->seqno == htons(ping_seq_num)))
{
*ttl = iphdr->_ttl;
return len;
}
}
}
return len;
}
#ifndef RT_USING_NETDEV
/* using the lwIP custom ping */
rt_err_t ping(char* target_name, rt_uint32_t times, rt_size_t size)
{
#if LWIP_VERSION_MAJOR >= 2U
struct timeval timeout = { PING_RCV_TIMEO / RT_TICK_PER_SECOND, PING_RCV_TIMEO % RT_TICK_PER_SECOND };
#else
int timeout = PING_RCV_TIMEO * 1000UL / RT_TICK_PER_SECOND;
#endif
int s, ttl, recv_len;
ip_addr_t target_addr;
rt_uint32_t send_times;
rt_tick_t recv_start_tick;
struct addrinfo hint, *res = NULL;
struct sockaddr_in *h = NULL;
struct in_addr ina;
send_times = 0;
ping_seq_num = 0;
if (size == 0)
{
size = PING_DATA_SIZE;
}
memset(&hint, 0, sizeof(hint));
/* convert URL to IP */
if (lwip_getaddrinfo(target_name, NULL, &hint, &res) != 0)
{
rt_kprintf("ping: unknown host %s\n", target_name);
return -RT_ERROR;
}
memcpy(&h, &res->ai_addr, sizeof(struct sockaddr_in *));
memcpy(&ina, &h->sin_addr, sizeof(ina));
lwip_freeaddrinfo(res);
if (inet_aton(inet_ntoa(ina), &target_addr) == 0)
{
rt_kprintf("ping: unknown host %s\n", target_name);
return -RT_ERROR;
}
/* new a socket */
if ((s = lwip_socket(AF_INET, SOCK_RAW, IP_PROTO_ICMP)) < 0)
{
rt_kprintf("ping: create socket failed\n");
return -RT_ERROR;
}
lwip_setsockopt(s, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout));
while (1)
{
int elapsed_time;
if (lwip_ping_send(s, &target_addr, size) == ERR_OK)
{
recv_start_tick = rt_tick_get();
if ((recv_len = lwip_ping_recv(s, &ttl)) >= 0)
{
elapsed_time = (rt_tick_get() - recv_start_tick) * 1000UL / RT_TICK_PER_SECOND;
rt_kprintf("%d bytes from %s icmp_seq=%d ttl=%d time=%d ms\n", recv_len, inet_ntoa(ina), send_times,
ttl, elapsed_time);
}
else
{
rt_kprintf("From %s icmp_seq=%d timeout\n", inet_ntoa(ina), send_times);
}
}
else
{
rt_kprintf("Send %s - error\n", inet_ntoa(ina));
}
send_times++;
if (send_times >= times)
{
/* send ping times reached, stop */
break;
}
rt_thread_delay(PING_DELAY); /* take a delay */
}
lwip_close(s);
return RT_EOK;
}
#ifdef RT_USING_FINSH
#include <finsh.h>
FINSH_FUNCTION_EXPORT(ping, ping network host);
int cmd_ping(int argc, char **argv)
{
if (argc == 1)
{
rt_kprintf("Please input: ping <host address>\n");
}
else
{
ping(argv[1], 4, 0);
}
return 0;
}
FINSH_FUNCTION_EXPORT_ALIAS(cmd_ping, __cmd_ping, ping network host);
#endif /* RT_USING_FINSH */
#endif /* RT_USING_NETDEV */
#endif /* RT_LWIP_ICMP */
/*
* File : tftp_port.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006 - 2017, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2017-08-17 armink first version.
*/
#include <rtthread.h>
#include <dfs_posix.h>
#include <lwip/apps/tftp_server.h>
static struct tftp_context ctx;
static void* tftp_open(const char* fname, const char* mode, u8_t write)
{
int fd = -1;
if (!rt_strcmp(mode, "octet"))
{
if (write)
{
fd = open(fname, O_WRONLY | O_CREAT, 0);
}
else
{
fd = open(fname, O_RDONLY, 0);
}
}
else
{
rt_kprintf("tftp: No support this mode(%s).", mode);
}
return (void *) fd;
}
static int tftp_write(void* handle, struct pbuf* p)
{
int fd = (int) handle;
return write(fd, p->payload, p->len);
}
#if defined(RT_USING_FINSH)
#include <finsh.h>
static void tftp_server(uint8_t argc, char **argv)
{
ctx.open = tftp_open;
ctx.close = (void (*)(void *)) close;
ctx.read = (int (*)(void *, void *, int)) read;
ctx.write = tftp_write;
if (tftp_init(&ctx) == ERR_OK)
{
rt_kprintf("TFTP server start successfully.\n");
}
else
{
rt_kprintf("TFTP server start failed.\n");
}
}
FINSH_FUNCTION_EXPORT(tftp_server, start tftp server.);
#if defined(FINSH_USING_MSH)
MSH_CMD_EXPORT(tftp_server, start tftp server.);
#endif /* defined(FINSH_USING_MSH) */
#endif /* defined(RT_USING_FINSH) */
/*
* 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(__ICCARM__)
#pragma pack(1)
#endif
/*
* Copyright (c) 2001, 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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>
*
* $Id: cc.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $
*/
#ifndef __ARCH_CC_H__
#define __ARCH_CC_H__
#include <rthw.h>
#include <rtthread.h>
#define U16_F "hu"
#define S16_F "hd"
#define X16_F "hx"
#define U32_F "lu"
#define S32_F "ld"
#define X32_F "lx"
#ifdef RT_USING_LIBC
#if defined(__CC_ARM) || defined(__CLANG_ARM) || defined(__IAR_SYSTEMS_ICC__)
#include <sys/errno.h>
#else
#include <errno.h>
/* some errno not defined in newlib */
#define ENSRNOTFOUND 163 /* Domain name not found */
/* WARNING: ESHUTDOWN also not defined in newlib. We chose
180 here because the number "108" which is used
in arch.h has been assigned to another error code. */
#define ESHUTDOWN 180
#endif /* __CC_ARM/__IAR_SYSTEMS_ICC__ */
#endif /* RT_USING_LIBC */
#if defined(RT_USING_LIBC) || defined(RT_USING_MINILIBC) || defined(RT_LIBC_USING_TIME)
#include <sys/time.h>
#define LWIP_TIMEVAL_PRIVATE 0
#else
#define LWIP_TIMEVAL_PRIVATE 1
#endif
#if defined(__CC_ARM) /* ARMCC compiler */
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT __attribute__ ((__packed__))
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END
#elif defined(__IAR_SYSTEMS_ICC__) /* IAR Compiler */
#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(__GNUC__) /* GNU GCC Compiler */
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT __attribute__((packed))
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END
#elif defined(_MSC_VER)
#define PACK_STRUCT_FIELD(x) x
#define PACK_STRUCT_STRUCT
#define PACK_STRUCT_BEGIN
#define PACK_STRUCT_END
#endif
void sys_arch_assert(const char* file, int line);
#define LWIP_PLATFORM_DIAG(x) do {rt_kprintf x;} while(0)
#define LWIP_PLATFORM_ASSERT(x) do {rt_kprintf(x); sys_arch_assert(__FILE__, __LINE__);}while(0)
#include "string.h"
#define SYS_ARCH_DECL_PROTECT(level)
#define SYS_ARCH_PROTECT(level) rt_enter_critical()
#define SYS_ARCH_UNPROTECT(level) rt_exit_critical()
#endif /* __ARCH_CC_H__ */
/*
* 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(__ICCARM__)
#pragma pack()
#endif
/*
* Copyright (c) 2001, 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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>
*
* $Id: perf.h,v 1.1.1.1 2004/12/16 14:17:13 bear Exp $
*/
#ifndef __ARCH_PERF_H__
#define __ARCH_PERF_H__
//#include <sys/times.h>
#define PERF_START /* null definition */
#define PERF_STOP(x) /* null definition */
/*
void perf_print(unsigned long c1l, unsigned long c1h,
unsigned long c2l, unsigned long c2h,
char *key);
void perf_print_times(struct tms *start, struct tms *end, char *key);
void perf_init(char *fname);
*/
#endif /* __ARCH_PERF_H__ */
/*
* Copyright (c) 2001, 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. Neither the name of the Institute nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``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 INSTITUTE OR CONTRIBUTORS 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>
*
* $Id: sys_arch.h,v 1.3 2005/03/13 16:03:23 bear Exp $
*/
#ifndef __ARCH_SYS_ARCH_H__
#define __ARCH_SYS_ARCH_H__
#include "arch/cc.h"
#include <rtthread.h>
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
#define SYS_MBOX_NULL RT_NULL
#define SYS_SEM_NULL RT_NULL
typedef u32_t sys_prot_t;
#define SYS_MBOX_SIZE 10
#define SYS_LWIP_TIMER_NAME "timer"
#define SYS_LWIP_MBOX_NAME "mbox"
#define SYS_LWIP_SEM_NAME "sem"
#define SYS_LWIP_MUTEX_NAME "mu"
typedef rt_sem_t sys_sem_t;
typedef rt_mutex_t sys_mutex_t;
typedef rt_mailbox_t sys_mbox_t;
typedef rt_thread_t sys_thread_t;
// err_t sys_mbox_trypost_fromisr(sys_mbox_t *q, void *msg);
#endif /* __ARCH_SYS_ARCH_H__ */
此差异已折叠。
#ifndef __NETIF_ETHERNETIF_H__
#define __NETIF_ETHERNETIF_H__
#include "lwip/netif.h"
#include <rtthread.h>
#define NIOCTL_GADDR 0x01
#ifndef RT_LWIP_ETH_MTU
#define ETHERNET_MTU 1500
#else
#define ETHERNET_MTU RT_LWIP_ETH_MTU
#endif
/* eth flag with auto_linkup or phy_linkup */
#define ETHIF_LINK_AUTOUP 0x0000
#define ETHIF_LINK_PHYUP 0x0100
struct eth_device
{
/* inherit from rt_device */
struct rt_device parent;
/* network interface for lwip */
struct netif *netif;
struct rt_semaphore tx_ack;
rt_uint16_t flags;
rt_uint8_t link_changed;
rt_uint8_t link_status;
/* eth device interface */
struct pbuf* (*eth_rx)(rt_device_t dev);
rt_err_t (*eth_tx)(rt_device_t dev, struct pbuf* p);
};
#ifdef __cplusplus
extern "C" {
#endif
rt_err_t eth_device_ready(struct eth_device* dev);
rt_err_t eth_device_init(struct eth_device * dev, const char *name);
rt_err_t eth_device_init_with_flag(struct eth_device *dev, const char *name, rt_uint16_t flag);
rt_err_t eth_device_linkchange(struct eth_device* dev, rt_bool_t up);
void eth_device_deinit(struct eth_device *dev);
int eth_system_device_init(void);
#ifdef __cplusplus
}
#endif
#endif /* __NETIF_ETHERNETIF_H__ */
#ifndef __LWIPOPTS_H__
#define __LWIPOPTS_H__
#include <rtconfig.h>
#define ERRNO 1
#define LWIP_SOCKET_SELECT 1
#define LWIP_SOCKET_POLL 1
#define LWIP_IPV4 1
#ifdef RT_USING_LWIP_IPV6
#define LWIP_IPV6 1
#else
#define LWIP_IPV6 0
#endif /* RT_USING_LWIP_IPV6 */
#define NO_SYS 0
#define LWIP_SOCKET 1
#define LWIP_NETCONN 1
#ifdef RT_LWIP_IGMP
#define LWIP_IGMP 1
#else
#define LWIP_IGMP 0
#endif
#ifdef RT_LWIP_ICMP
#define LWIP_ICMP 1
#else
#define LWIP_ICMP 0
#endif
#ifdef RT_LWIP_SNMP
#define LWIP_SNMP 1
#else
#define LWIP_SNMP 0
#endif
#ifdef RT_LWIP_DNS
#define LWIP_DNS 1
#else
#define LWIP_DNS 0
#endif
#define LWIP_HAVE_LOOPIF 0
#define LWIP_PLATFORM_BYTESWAP 0
#ifndef BYTE_ORDER
#define BYTE_ORDER LITTLE_ENDIAN
#endif
/* #define RT_LWIP_DEBUG */
#ifdef RT_LWIP_DEBUG
#define LWIP_DEBUG
#endif
/* ---------- Debug options ---------- */
#ifdef LWIP_DEBUG
#ifdef RT_LWIP_SYS_DEBUG
#define SYS_DEBUG LWIP_DBG_ON
#else
#define SYS_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_ETHARP_DEBUG
#define ETHARP_DEBUG LWIP_DBG_ON
#else
#define ETHARP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_PPP_DEBUG
#define PPP_DEBUG LWIP_DBG_ON
#else
#define PPP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_MEM_DEBUG
#define MEM_DEBUG LWIP_DBG_ON
#else
#define MEM_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_MEMP_DEBUG
#define MEMP_DEBUG LWIP_DBG_ON
#else
#define MEMP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_PBUF_DEBUG
#define PBUF_DEBUG LWIP_DBG_ON
#else
#define PBUF_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_API_LIB_DEBUG
#define API_LIB_DEBUG LWIP_DBG_ON
#else
#define API_LIB_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_API_MSG_DEBUG
#define API_MSG_DEBUG LWIP_DBG_ON
#else
#define API_MSG_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCPIP_DEBUG
#define TCPIP_DEBUG LWIP_DBG_ON
#else
#define TCPIP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_NETIF_DEBUG
#define NETIF_DEBUG LWIP_DBG_ON
#else
#define NETIF_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_SOCKETS_DEBUG
#define SOCKETS_DEBUG LWIP_DBG_ON
#else
#define SOCKETS_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_DNS_DEBUG
#define DNS_DEBUG LWIP_DBG_ON
#else
#define DNS_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_AUTOIP_DEBUG
#define AUTOIP_DEBUG LWIP_DBG_ON
#else
#define AUTOIP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_DHCP_DEBUG
#define DHCP_DEBUG LWIP_DBG_ON
#else
#define DHCP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_IP_DEBUG
#define IP_DEBUG LWIP_DBG_ON
#else
#define IP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_IP_REASS_DEBUG
#define IP_REASS_DEBUG LWIP_DBG_ON
#else
#define IP_REASS_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_ICMP_DEBUG
#define ICMP_DEBUG LWIP_DBG_ON
#else
#define ICMP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_IGMP_DEBUG
#define IGMP_DEBUG LWIP_DBG_ON
#else
#define IGMP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_UDP_DEBUG
#define UDP_DEBUG LWIP_DBG_ON
#else
#define UDP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_DEBUG
#define TCP_DEBUG LWIP_DBG_ON
#else
#define TCP_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_INPUT_DEBUG
#define TCP_INPUT_DEBUG LWIP_DBG_ON
#else
#define TCP_INPUT_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_OUTPUT_DEBUG
#define TCP_OUTPUT_DEBUG LWIP_DBG_ON
#else
#define TCP_OUTPUT_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_RTO_DEBUG
#define TCP_RTO_DEBUG LWIP_DBG_ON
#else
#define TCP_RTO_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_CWND_DEBUG
#define TCP_CWND_DEBUG LWIP_DBG_ON
#else
#define TCP_CWND_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_WND_DEBUG
#define TCP_WND_DEBUG LWIP_DBG_ON
#else
#define TCP_WND_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_FR_DEBUG
#define TCP_FR_DEBUG LWIP_DBG_ON
#else
#define TCP_FR_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_QLEN_DEBUG
#define TCP_QLEN_DEBUG LWIP_DBG_ON
#else
#define TCP_QLEN_DEBUG LWIP_DBG_OFF
#endif
#ifdef RT_LWIP_TCP_RST_DEBUG
#define TCP_RST_DEBUG LWIP_DBG_ON
#else
#define TCP_RST_DEBUG LWIP_DBG_OFF
#endif
#endif /* LWIP_DEBUG */
#define LWIP_DBG_TYPES_ON (LWIP_DBG_ON|LWIP_DBG_TRACE|LWIP_DBG_STATE|LWIP_DBG_FRESH|LWIP_DBG_HALT)
# ifndef __STRICT_ANSI__
# define SSIZE_MAX LONG_MAX
# endif
#ifdef RT_USING_LIBC
#define LWIP_NO_UNISTD_H 0
#else
#define LWIP_NO_UNISTD_H 1
#endif
/* ---------- Memory options ---------- */
#define MEM_ALIGNMENT 4
#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 MEMP_MEM_MALLOC 0
/* 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 32 //16
/* the number of struct netconns */
#ifdef RT_MEMP_NUM_NETCONN
#define MEMP_NUM_NETCONN RT_MEMP_NUM_NETCONN
#endif
/* the number of UDP protocol control blocks. One per active RAW "connection". */
#ifdef RT_LWIP_RAW_PCB_NUM
#define MEMP_NUM_RAW_PCB RT_LWIP_RAW_PCB_NUM
#endif
/* the number of UDP protocol control blocks. One per active UDP "connection". */
#ifdef RT_LWIP_UDP_PCB_NUM
#define MEMP_NUM_UDP_PCB RT_LWIP_UDP_PCB_NUM
#endif
/* the number of simulatenously active TCP connections. */
#ifdef RT_LWIP_TCP_PCB_NUM
#define MEMP_NUM_TCP_PCB RT_LWIP_TCP_PCB_NUM
#endif
/* the number of simultaneously queued TCP */
#ifdef RT_LWIP_TCP_SEG_NUM
#define MEMP_NUM_TCP_SEG RT_LWIP_TCP_SEG_NUM
#else
#define MEMP_NUM_TCP_SEG TCP_SND_QUEUELEN
#endif
/*
* You can re-define following setting in rtcofnig.h to overwrite the default
* setting in the lwip opts.h
*/
/* MEMP_NUM_NETBUF: the number of struct netbufs. */
// #define MEMP_NUM_NETBUF 2
/* MEMP_NUM_NETCONN: the number of struct netconns. */
// #define MEMP_NUM_NETCONN 4
/* MEMP_NUM_TCPIP_MSG_*: the number of struct tcpip_msg, which is used
for sequential API communication and incoming packets. Used in
src/api/tcpip.c. */
// #define MEMP_NUM_TCPIP_MSG_API 16
// #define MEMP_NUM_TCPIP_MSG_INPKT 16
/* ---------- Pbuf options ---------- */
/* PBUF_POOL_SIZE: the number of buffers in the pbuf pool. */
#ifdef RT_LWIP_PBUF_NUM
#define PBUF_POOL_SIZE RT_LWIP_PBUF_NUM
#endif
/* PBUF_POOL_BUFSIZE: the size of each pbuf in the pbuf pool. */
#ifdef RT_LWIP_PBUF_POOL_BUFSIZE
#define PBUF_POOL_BUFSIZE RT_LWIP_PBUF_POOL_BUFSIZE
#endif
/* PBUF_LINK_HLEN: the number of bytes that should be allocated for a
link level header. */
#define PBUF_LINK_HLEN 16
#ifdef RT_LWIP_ETH_PAD_SIZE
#define ETH_PAD_SIZE RT_LWIP_ETH_PAD_SIZE
#endif
/** SYS_LIGHTWEIGHT_PROT
* define SYS_LIGHTWEIGHT_PROT in lwipopts.h if you want inter-task protection
* for certain critical regions during buffer allocation, deallocation and memory
* allocation and deallocation.
*/
#define SYS_LIGHTWEIGHT_PROT (NO_SYS==0)
#ifdef LWIP_USING_NAT
#define IP_NAT 1
#else
#define IP_NAT 0
#endif
/* ---------- TCP options ---------- */
#ifdef RT_LWIP_TCP
#define LWIP_TCP 1
#else
#define LWIP_TCP 0
#endif
#define TCP_TTL 255
/* Controls if TCP should queue segments that arrive out of
order. Define to 0 if your device is low on memory. */
#define TCP_QUEUE_OOSEQ 1
/* TCP Maximum segment size. */
#define TCP_MSS 1460
/* TCP sender buffer space (bytes). */
#ifdef RT_LWIP_TCP_SND_BUF
#define TCP_SND_BUF RT_LWIP_TCP_SND_BUF
#else
#define TCP_SND_BUF (TCP_MSS * 2)
#endif
/* TCP sender buffer space (pbufs). This must be at least = 2 *
TCP_SND_BUF/TCP_MSS for things to work. */
#define TCP_SND_QUEUELEN (4 * TCP_SND_BUF/TCP_MSS)
/* TCP writable space (bytes). This must be less than or equal
to TCP_SND_BUF. It is the amount of space which must be
available in the tcp snd_buf for select to return writable */
#define TCP_SNDLOWAT (TCP_SND_BUF/2)
#define TCP_SNDQUEUELOWAT TCP_SND_QUEUELEN/2
/* TCP receive window. */
#ifdef RT_LWIP_TCP_WND
#define TCP_WND RT_LWIP_TCP_WND
#else
#define TCP_WND (TCP_MSS * 2)
#endif
/* Maximum number of retransmissions of data segments. */
#define TCP_MAXRTX 12
/* Maximum number of retransmissions of SYN segments. */
#define TCP_SYNMAXRTX 4
/* tcpip thread options */
#ifdef RT_LWIP_TCPTHREAD_PRIORITY
#define TCPIP_MBOX_SIZE RT_LWIP_TCPTHREAD_MBOX_SIZE
#define TCPIP_THREAD_PRIO RT_LWIP_TCPTHREAD_PRIORITY
#define TCPIP_THREAD_STACKSIZE RT_LWIP_TCPTHREAD_STACKSIZE
#else
#define TCPIP_MBOX_SIZE 8
#define TCPIP_THREAD_PRIO 128
#define TCPIP_THREAD_STACKSIZE 4096
#endif
#define TCPIP_THREAD_NAME "tcpip"
#define DEFAULT_TCP_RECVMBOX_SIZE 10
/* ---------- ARP options ---------- */
#define LWIP_ARP 1
#define ARP_TABLE_SIZE 10
#define ARP_QUEUEING 1
/* ---------- Checksum options ---------- */
#ifdef RT_LWIP_USING_HW_CHECKSUM
#define CHECKSUM_GEN_IP 0
#define CHECKSUM_GEN_UDP 0
#define CHECKSUM_GEN_TCP 0
#define CHECKSUM_GEN_ICMP 0
#define CHECKSUM_CHECK_IP 0
#define CHECKSUM_CHECK_UDP 0
#define CHECKSUM_CHECK_TCP 0
#define CHECKSUM_CHECK_ICMP 0
#endif
/* ---------- IP options ---------- */
/* Define IP_FORWARD to 1 if you wish to have the ability to forward
IP packets across network interfaces. If you are going to run lwIP
on a device with only one network interface, define this to 0. */
#define IP_FORWARD 0
/* IP reassembly and segmentation.These are orthogonal even
* if they both deal with IP fragments */
#ifdef RT_LWIP_REASSEMBLY_FRAG
#define IP_REASSEMBLY 1
#define IP_FRAG 1
#define IP_REASS_MAX_PBUFS 10
#define MEMP_NUM_REASSDATA 10
#else
#define IP_REASSEMBLY 0
#define IP_FRAG 0
#endif
/* ---------- ICMP options ---------- */
#define ICMP_TTL 255
/* ---------- DHCP options ---------- */
/* Define LWIP_DHCP to 1 if you want DHCP configuration of
interfaces. */
#ifdef RT_LWIP_DHCP
#define LWIP_DHCP 1
#else
#define LWIP_DHCP 0
#endif
/* 1 if you want to do an ARP check on the offered address
(recommended). */
#define DHCP_DOES_ARP_CHECK (LWIP_DHCP)
/* ---------- AUTOIP options ------- */
#define LWIP_AUTOIP 0
#define LWIP_DHCP_AUTOIP_COOP (LWIP_DHCP && LWIP_AUTOIP)
/* ---------- UDP options ---------- */
#ifdef RT_LWIP_UDP
#define LWIP_UDP 1
#else
#define LWIP_UDP 0
#endif
#define LWIP_UDPLITE 0
#define UDP_TTL 255
#define DEFAULT_UDP_RECVMBOX_SIZE 1
/* ---------- RAW options ---------- */
#ifdef RT_LWIP_RAW
#define LWIP_RAW 1
#else
#define LWIP_RAW 0
#endif
#define DEFAULT_RAW_RECVMBOX_SIZE 1
#define DEFAULT_ACCEPTMBOX_SIZE 10
/* ---------- Statistics options ---------- */
#ifdef RT_LWIP_STATS
#define LWIP_STATS 1
#define LWIP_STATS_DISPLAY 1
#else
#define LWIP_STATS 0
#endif
#if LWIP_STATS
#define LINK_STATS 1
#define IP_STATS 1
#define ICMP_STATS 1
#define IGMP_STATS 1
#define IPFRAG_STATS 1
#define UDP_STATS 1
#define TCP_STATS 1
#define MEM_STATS 1
#define MEMP_STATS 1
#define PBUF_STATS 1
#define SYS_STATS 1
#define MIB2_STATS 1
#endif /* LWIP_STATS */
/* ---------- PPP options ---------- */
#ifdef RT_LWIP_PPP
#define PPP_SUPPORT 1 /* Set > 0 for PPP */
#else
#define PPP_SUPPORT 0 /* Set > 0 for PPP */
#endif
#if PPP_SUPPORT
#define NUM_PPP 1 /* Max PPP sessions. */
/* Select modules to enable. Ideally these would be set in the makefile but
* we're limited by the command line length so you need to modify the settings
* in this file.
*/
#ifdef RT_LWIP_PPPOE
#define PPPOE_SUPPORT 1
#else
#define PPPOE_SUPPORT 0
#endif
#ifdef RT_LWIP_PPPOS
#define PPPOS_SUPPORT 1
#else
#define PPPOS_SUPPORT 0
#endif
#define PAP_SUPPORT 1 /* Set > 0 for PAP. */
#define CHAP_SUPPORT 1 /* Set > 0 for CHAP. */
#define MSCHAP_SUPPORT 0 /* Set > 0 for MSCHAP (NOT FUNCTIONAL!) */
#define CBCP_SUPPORT 0 /* Set > 0 for CBCP (NOT FUNCTIONAL!) */
#define CCP_SUPPORT 0 /* Set > 0 for CCP (NOT FUNCTIONAL!) */
#define VJ_SUPPORT 1 /* Set > 0 for VJ header compression. */
#define MD5_SUPPORT 1 /* Set > 0 for MD5 (see also CHAP) */
#endif /* PPP_SUPPORT */
/**
* LWIP_POSIX_SOCKETS_IO_NAMES==1: Enable POSIX-style sockets functions names.
* Disable this option if you use a POSIX operating system that uses the same
* names (read, write & close). (only used if you use sockets.c)
*/
#ifndef LWIP_POSIX_SOCKETS_IO_NAMES
#define LWIP_POSIX_SOCKETS_IO_NAMES 0
#endif
/**
* LWIP_TCP_KEEPALIVE==1: Enable TCP_KEEPIDLE, TCP_KEEPINTVL and TCP_KEEPCNT
* options processing. Note that TCP_KEEPIDLE and TCP_KEEPINTVL have to be set
* in seconds. (does not require sockets.c, and will affect tcp.c)
*/
#ifndef LWIP_TCP_KEEPALIVE
#define LWIP_TCP_KEEPALIVE 1
#endif
/**
* LWIP_NETIF_HOSTNAME==1: Support netif hostname
*/
#ifndef LWIP_NETIF_HOSTNAME
#define LWIP_NETIF_HOSTNAME 1
#endif
/**
* LWIP_NETIF_API==1: Support netif api (in netifapi.c)
*/
#ifndef LWIP_NETIF_API
#define LWIP_NETIF_API 1
#endif
#ifdef LWIP_IGMP
#include <stdlib.h>
#define LWIP_RAND rand
#endif
/*
------------------------------------
---------- Socket options ----------
------------------------------------
*/
/*
* LWIP_SOCKET==1: Enable Socket API (require to use sockets.c)
*/
#ifndef LWIP_SOCKET
#define LWIP_SOCKET 1
#endif
/*
* LWIP_COMPAT_SOCKETS==1: Enable BSD-style sockets functions names.
* (only used if you use sockets.c)
*/
#ifdef SAL_USING_POSIX
#define LWIP_COMPAT_SOCKETS 0
#else
#ifndef LWIP_COMPAT_SOCKETS
#define LWIP_COMPAT_SOCKETS 1
#endif
#endif
/**
* LWIP_SO_SNDTIMEO==1: Enable send timeout for sockets/netconns and
* SO_SNDTIMEO processing.
*/
#ifndef LWIP_SO_SNDTIMEO
#define LWIP_SO_SNDTIMEO 1
#endif
/**
* LWIP_SO_RCVTIMEO==1: Enable receive timeout for sockets/netconns and
* SO_RCVTIMEO processing.
*/
#ifndef LWIP_SO_RCVTIMEO
#define LWIP_SO_RCVTIMEO 1
#endif
/**
* LWIP_SO_RCVBUF==1: Enable SO_RCVBUF processing.
*/
#ifndef LWIP_SO_RCVBUF
#define LWIP_SO_RCVBUF 1
#endif
/**
* If LWIP_SO_RCVBUF is used, this is the default value for recv_bufsize.
*/
#ifndef RECV_BUFSIZE_DEFAULT
#define RECV_BUFSIZE_DEFAULT 8192
#endif
/**
* SO_REUSE==1: Enable SO_REUSEADDR option.
*/
#ifndef SO_REUSE
#define SO_REUSE 0
#endif
/*
------------------------------------
------- Applications options -------
------------------------------------
*/
/**
* Max. length of TFTP filename
*/
#ifdef RT_LWIP_TFTP_MAX_FILENAME_LEN
#define TFTP_MAX_FILENAME_LEN RT_LWIP_TFTP_MAX_FILENAME_LEN
#elif defined(RT_DFS_ELM_MAX_LFN)
#define TFTP_MAX_FILENAME_LEN RT_DFS_ELM_MAX_LFN
#else
#define TFTP_MAX_FILENAME_LEN 64
#endif
#endif /* __LWIPOPTS_H__ */
#if 1
LWIP_MALLOC_MEMPOOL_START
LWIP_MALLOC_MEMPOOL((unsigned char)128, 256)
LWIP_MALLOC_MEMPOOL((unsigned char)128, 512)
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_END
#endif
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册