未验证 提交 91c32b51 编写于 作者: X xiangxistu 提交者: GitHub

Merge pull request #1 from xiangxistu/lwIP-2.1.2

lwIP 2.1.2

要显示的变更太多。

To preserve performance only 1000 of 1000+ files are displayed.
......@@ -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:
......
此差异已折叠。
cmake_minimum_required(VERSION 3.7)
project(lwIP)
set(LWIP_DIR ${CMAKE_CURRENT_SOURCE_DIR})
include(src/Filelists.cmake)
# Package generation
set(CPACK_SOURCE_GENERATOR "ZIP")
set(CPACK_SOURCE_PACKAGE_DESCRIPTION_SUMMARY "lwIP lightweight IP stack")
set(CPACK_PACKAGE_VERSION_MAJOR "${LWIP_VERSION_MAJOR}")
set(CPACK_PACKAGE_VERSION_MINOR "${LWIP_VERSION_MINOR}")
set(CPACK_PACKAGE_VERSION_PATCH "${LWIP_VERSION_REVISION}")
set(CPACK_SOURCE_IGNORE_FILES "/build/;${CPACK_SOURCE_IGNORE_FILES};.git")
set(CPACK_SOURCE_PACKAGE_FILE_NAME "lwip-${LWIP_VERSION_MAJOR}.${LWIP_VERSION_MINOR}.${LWIP_VERSION_REVISION}")
include(CPack)
# Target for package generation
add_custom_target(dist COMMAND ${CMAKE_MAKE_PROGRAM} package_source)
add_dependencies(dist lwipdocs)
/*
* Copyright (c) 2001, 2002 Swedish Institute of Computer Science.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
* SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
* OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
* OF SUCH DAMAGE.
*
* This file is part of the lwIP TCP/IP stack.
*
* Author: Adam Dunkels <adam@sics.se>
*
*/
lwIP is a small independent implementation of the TCP/IP protocol suite targeted at embedded systems.
The focus of the lwIP TCP/IP implementation is to reduce resource usage while still having a full scale TCP. This makes lwIP suitable for use in embedded systems with tens of kilobytes of free RAM and room for around 40 kilobytes of code ROM.
Main features include:
- Protocols: IP, IPv6, ICMP, ND, MLD, UDP, TCP, IGMP, ARP, PPPoS, PPPoE, 6LowPAN (via IEEE 802.15.4, BLE or ZEP; since v2.1.0)
- DHCP client, stateless DHCPv6 (since v2.1.0), DNS client (incl. mDNS hostname resolver), AutoIP/APIPA (Zeroconf), SNMP agent (v1, v2c, v3 (since v2.1.0), private MIB support & MIB compiler)
- APIs: specialized APIs for enhanced performance & zero copy, optional Berkeley-alike socket API
- Extended features: IP forwarding over multiple network interfaces
- Extended TCP features: congestion control, RTT estimation and fast recovery/fast retransmit, sending SACKs (since v2.1.0), "altcp": nearly transparent TLS for any tcp pcb (since v2.1.0)
- Addon applications: HTTP server (HTTPS via altcp), HTTP(S) client (since v2.1.0), SNTP client, SMTP client (SMTPS via altcp), ping, NetBIOS nameserver, mDNS responder, MQTT client (TLS support since v2.1.0), TFTP server, iPerf2 counterpart
src/ - The source code for the lwIP TCP/IP stack.
doc/ - The documentation for lwIP.
test/ - Some code to test whether the sources do what they should.
See also the FILES file in each subdirectory.
INTRODUCTION
lwIP is a small independent implementation of the TCP/IP protocol suite.
The focus of the lwIP TCP/IP implementation is to reduce the RAM usage
while still having a full scale TCP. This making lwIP suitable for use
in embedded systems with tens of kilobytes of free RAM and room for
around 40 kilobytes of code ROM.
lwIP was originally developed by Adam Dunkels at the Computer and Networks
Architectures (CNA) lab at the Swedish Institute of Computer Science (SICS)
and is now developed and maintained by a worldwide network of developers.
FEATURES
* IP (Internet Protocol, IPv4 and IPv6) including packet forwarding over
multiple network interfaces
* ICMP (Internet Control Message Protocol) for network maintenance and debugging
* IGMP (Internet Group Management Protocol) for multicast traffic management
* MLD (Multicast listener discovery for IPv6). Aims to be compliant with
RFC 2710. No support for MLDv2
* ND (Neighbor discovery and stateless address autoconfiguration for IPv6).
Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862
(Address autoconfiguration)
* DHCP, AutoIP/APIPA (Zeroconf) and (stateless) DHCPv6
* UDP (User Datagram Protocol) including experimental UDP-lite extensions
* TCP (Transmission Control Protocol) with congestion control, RTT estimation
fast recovery/fast retransmit and sending SACKs
* raw/native API for enhanced performance
* Optional Berkeley-like socket API
* TLS: optional layered TCP ("altcp") for nearly transparent TLS for any
TCP-based protocol (ported to mbedTLS) (see changelog for more info)
* PPPoS and PPPoE (Point-to-point protocol over Serial/Ethernet)
* DNS (Domain name resolver incl. mDNS)
* 6LoWPAN (via IEEE 802.15.4, BLE or ZEP)
APPLICATIONS
* HTTP server with SSI and CGI (HTTPS via altcp)
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol), v3 via altcp
* SNTP (Simple network time protocol)
* NetBIOS name service responder
* MDNS (Multicast DNS) responder
* iPerf server implementation
* MQTT client (TLS support via altcp)
LICENSE
lwIP is freely available under a BSD license.
DEVELOPMENT
lwIP has grown into an excellent TCP/IP stack for embedded devices,
and developers using the stack often submit bug fixes, improvements,
and additions to the stack to further increase its usefulness.
Development of lwIP is hosted on Savannah, a central point for
software development, maintenance and distribution. Everyone can
help improve lwIP by use of Savannah's interface, Git and the
mailing list. A core team of developers will commit changes to the
Git source tree.
The lwIP TCP/IP stack is maintained in the 'lwip' Git module and
contributions (such as platform ports) are in the 'contrib' Git module.
See doc/savannah.txt for details on Git server access for users and
developers.
The current Git trees are web-browsable:
http://git.savannah.gnu.org/cgit/lwip.git
http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git
Submit patches and bugs via the lwIP project page:
http://savannah.nongnu.org/projects/lwip/
Continuous integration builds (GCC, clang):
https://travis-ci.org/yarrick/lwip-merged
DOCUMENTATION
Self documentation of the source code is regularly extracted from the current
Git sources and is available from this web page:
http://www.nongnu.org/lwip/
There is now a constantly growing wiki about lwIP at
http://lwip.wikia.com/wiki/LwIP_Wiki
Also, there are mailing lists you can subscribe at
http://savannah.nongnu.org/mail/?group=lwip
plus searchable archives:
http://lists.nongnu.org/archive/html/lwip-users/
http://lists.nongnu.org/archive/html/lwip-devel/
lwIP was originally written by Adam Dunkels:
http://dunkels.com/adam/
Reading Adam's papers, the files in docs/, browsing the source code
documentation and browsing the mailing list archives is a good way to
become familiar with the design of lwIP.
Adam Dunkels <adam@sics.se>
Leon Woestenberg <leon.woestenberg@gmx.net>
# 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 源码的改动
此差异已折叠。
此差异已折叠。
doxygen/ - Configuration files and scripts to create the lwIP doxygen source
documentation (found at http://www.nongnu.org/lwip/)
savannah.txt - How to obtain the current development source code.
contrib.txt - How to contribute to lwIP as a developer.
rawapi.txt - The documentation for the core API of lwIP.
Also provides an overview about the other APIs and multithreading.
sys_arch.txt - The documentation for a system abstraction layer of lwIP.
ppp.txt - Documentation of the PPP interface for lwIP.
void
eth_mac_irq()
{
/* Service MAC IRQ here */
/* Allocate pbuf from pool (avoid using heap in interrupts) */
struct pbuf* p = pbuf_alloc(PBUF_RAW, eth_data_count, PBUF_POOL);
if(p != NULL) {
/* Copy ethernet frame into pbuf */
pbuf_take(p, eth_data, eth_data_count);
/* Put in a queue which is processed in main loop */
if(!queue_try_put(&queue, p)) {
/* queue is full -> packet loss */
pbuf_free(p);
}
}
}
static err_t
netif_output(struct netif *netif, struct pbuf *p)
{
LINK_STATS_INC(link.xmit);
/* Update SNMP stats (only if you use SNMP) */
MIB2_STATS_NETIF_ADD(netif, ifoutoctets, p->tot_len);
int unicast = ((p->payload[0] & 0x01) == 0);
if (unicast) {
MIB2_STATS_NETIF_INC(netif, ifoutucastpkts);
} else {
MIB2_STATS_NETIF_INC(netif, ifoutnucastpkts);
}
lock_interrupts();
pbuf_copy_partial(p, mac_send_buffer, p->tot_len, 0);
/* Start MAC transmit here */
unlock_interrupts();
return ERR_OK;
}
static void
netif_status_callback(struct netif *netif)
{
printf("netif status changed %s\n", ip4addr_ntoa(netif_ip4_addr(netif)));
}
static err_t
netif_init(struct netif *netif)
{
netif->linkoutput = netif_output;
netif->output = etharp_output;
netif->output_ip6 = ethip6_output;
netif->mtu = ETHERNET_MTU;
netif->flags = NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP | NETIF_FLAG_ETHERNET | NETIF_FLAG_IGMP | NETIF_FLAG_MLD6;
MIB2_INIT_NETIF(netif, snmp_ifType_ethernet_csmacd, 100000000);
SMEMCPY(netif->hwaddr, your_mac_address_goes_here, ETH_HWADDR_LEN);
netif->hwaddr_len = ETH_HWADDR_LEN;
return ERR_OK;
}
void
main(void)
{
struct netif netif;
lwip_init();
netif_add(&netif, IP4_ADDR_ANY, IP4_ADDR_ANY, IP4_ADDR_ANY, NULL, netif_init, netif_input);
netif.name[0] = 'e';
netif.name[1] = '0';
netif_create_ip6_linklocal_address(&netif, 1);
netif.ip6_autoconfig_enabled = 1;
netif_set_status_callback(&netif, netif_status_callback);
netif_set_default(&netif);
netif_set_up(&netif);
/* Start DHCP and HTTPD */
dhcp_start(&netif );
httpd_init();
while(1) {
/* Check link state, e.g. via MDIO communication with PHY */
if(link_state_changed()) {
if(link_is_up()) {
netif_set_link_up(&netif);
} else {
netif_set_link_down(&netif);
}
}
/* Check for received frames, feed them to lwIP */
lock_interrupts();
struct pbuf* p = queue_try_get(&queue);
unlock_interrupts();
if(p != NULL) {
LINK_STATS_INC(link.recv);
/* Update SNMP stats (only if you use SNMP) */
MIB2_STATS_NETIF_ADD(netif, ifinoctets, p->tot_len);
int unicast = ((p->payload[0] & 0x01) == 0);
if (unicast) {
MIB2_STATS_NETIF_INC(netif, ifinucastpkts);
} else {
MIB2_STATS_NETIF_INC(netif, ifinnucastpkts);
}
if(netif.input(p, &netif) != ERR_OK) {
pbuf_free(p);
}
}
/* Cyclic lwIP timers check */
sys_check_timeouts();
/* your application goes here */
}
}
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
var altcp_8c =
[
[ "altcp_abort", "group__altcp.html#ga7f6fab99fed448385a76b4a5100796ab", null ],
[ "altcp_accept", "group__altcp.html#ga7c4cd0b1179a53b1a223936ba2270bf9", null ],
[ "altcp_alloc", "altcp_8c.html#a6a99f8757c18fbc9b9f30925afbcf4c2", null ],
[ "altcp_arg", "group__altcp.html#ga197a33af038556a04d8f27c7033d771f", null ],
[ "altcp_bind", "group__altcp.html#ga485b248680f73b9876d8674029c5157c", null ],
[ "altcp_close", "group__altcp.html#ga4329798afdf3709c789a2ee060ee3993", null ],
[ "altcp_connect", "group__altcp.html#gafaf1d533e4e89dc249a3f931afa93492", null ],
[ "altcp_err", "group__altcp.html#gadc76a1f3b2448559dc87da1b33291644", null ],
[ "altcp_free", "altcp_8c.html#afd7f6b6602e89cff51f8a8ea0315321d", null ],
[ "altcp_listen_with_backlog_and_err", "group__altcp.html#gac69722b86b1198916f2527fb9f132c2b", null ],
[ "altcp_mss", "group__altcp.html#gae7cfc8bd8e45c517a706afd5857fda08", null ],
[ "altcp_new", "group__altcp.html#ga86843287b0ad0099c067817cfb7aa336", null ],
[ "altcp_new_ip6", "group__altcp.html#gaa51a47bcb334b188c82a1b99db49f1f1", null ],
[ "altcp_new_ip_type", "group__altcp.html#gab631f6f92d7f6c58d9db27b7b415bc21", null ],
[ "altcp_output", "group__altcp.html#ga5d2370d3b671377d7e2c98ce2dc3cfc6", null ],
[ "altcp_poll", "group__altcp.html#ga269beeaf7d8264b6ff02333bcc7c7ab0", null ],
[ "altcp_recv", "group__altcp.html#ga7f89221f9d65036d890b1e5bd9192a71", null ],
[ "altcp_recved", "group__altcp.html#gac086951cbfedaed0c36c5fb26b44ef83", null ],
[ "altcp_sent", "group__altcp.html#gab2b228c77c827fb14bfc513171c79f47", null ],
[ "altcp_setprio", "group__altcp.html#ga5040b0a4646bca718d3611ba7fa558c5", null ],
[ "altcp_shutdown", "group__altcp.html#ga0c3172d0bfe452599e242ea2e4692319", null ],
[ "altcp_sndbuf", "group__altcp.html#gab295cba0c1ded90fe044a8c37387a12c", null ],
[ "altcp_sndqueuelen", "group__altcp.html#ga516a1bfbf38fc47cfd47852715c505c5", null ],
[ "altcp_write", "group__altcp.html#gaad9a38396b127cfd778e253f20a97b8d", null ]
];
\ No newline at end of file
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册