提交 685c189d 编写于 作者: B bernard

[lwIP] remove lwip-head and add lwip-2.0.0

上级 bbcac311
src/ - The source code for the lwIP TCP/IP stack. src/ - The source code for the lwIP TCP/IP stack.
doc/ - The documentation for lwIP. 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. See also the FILES file in each subdirectory.
...@@ -10,28 +10,41 @@ while still having a full scale TCP. This making lwIP suitable for use ...@@ -10,28 +10,41 @@ 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 in embedded systems with tens of kilobytes of free RAM and room for
around 40 kilobytes of code ROM. around 40 kilobytes of code ROM.
FEATURES FEATURES
* IP (Internet Protocol) including packet forwarding over multiple network * IP (Internet Protocol, IPv4 and IPv6) including packet forwarding over
interfaces multiple network interfaces
* ICMP (Internet Control Message Protocol) for network maintenance and debugging * ICMP (Internet Control Message Protocol) for network maintenance and debugging
* IGMP (Internet Group Management Protocol) for multicast traffic management * IGMP (Internet Group Management Protocol) for multicast traffic management
* MLD (Multicast listener discovery for IPv6). Aims to be compliant with
RFC 2710. No support for MLDv2
* ND (Neighbor discovery and stateless address autoconfiguration for IPv6).
Aims to be compliant with RFC 4861 (Neighbor discovery) and RFC 4862
(Address autoconfiguration)
* UDP (User Datagram Protocol) including experimental UDP-lite extensions * UDP (User Datagram Protocol) including experimental UDP-lite extensions
* TCP (Transmission Control Protocol) with congestion control, RTT estimation * TCP (Transmission Control Protocol) with congestion control, RTT estimation
and fast recovery/fast retransmit and fast recovery/fast retransmit
* Specialized raw/native API for enhanced performance * raw/native API for enhanced performance
* Optional Berkeley-like socket API * Optional Berkeley-like socket API
* DNS (Domain names resolver) * DNS (Domain names resolver)
* SNMP (Simple Network Management Protocol)
* DHCP (Dynamic Host Configuration Protocol)
* AUTOIP (for IPv4, conform with RFC 3927) APPLICATIONS
* PPP (Point-to-Point Protocol)
* ARP (Address Resolution Protocol) for Ethernet * HTTP server with SSI and CGI
* SNMPv2c agent with MIB compiler (Simple Network Management Protocol)
* SNTP (Simple network time protocol)
* NetBIOS name service responder
* MDNS (Multicast DNS) responder
* iPerf server implementation
LICENSE LICENSE
lwIP is freely available under a BSD license. lwIP is freely available under a BSD license.
DEVELOPMENT DEVELOPMENT
lwIP has grown into an excellent TCP/IP stack for embedded devices, lwIP has grown into an excellent TCP/IP stack for embedded devices,
...@@ -40,38 +53,34 @@ and additions to the stack to further increase its usefulness. ...@@ -40,38 +53,34 @@ and additions to the stack to further increase its usefulness.
Development of lwIP is hosted on Savannah, a central point for Development of lwIP is hosted on Savannah, a central point for
software development, maintenance and distribution. Everyone can software development, maintenance and distribution. Everyone can
help improve lwIP by use of Savannah's interface, CVS and the help improve lwIP by use of Savannah's interface, Git and the
mailing list. A core team of developers will commit changes to the mailing list. A core team of developers will commit changes to the
CVS source tree. Git source tree.
The lwIP TCP/IP stack is maintained in the 'lwip' CVS module and The lwIP TCP/IP stack is maintained in the 'lwip' Git module and
contributions (such as platform ports) are in the 'contrib' module. contributions (such as platform ports) are in the 'contrib' Git module.
See doc/savannah.txt for details on CVS server access for users and See doc/savannah.txt for details on Git server access for users and
developers. developers.
Last night's CVS tar ball can be downloaded from: The current Git trees are web-browsable:
http://savannah.gnu.org/cvs.backups/lwip.tar.gz [CHANGED - NEEDS FIXING] http://git.savannah.gnu.org/cgit/lwip.git
http://git.savannah.gnu.org/cgit/lwip/lwip-contrib.git
The current CVS trees are web-browsable:
http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/lwip/
http://savannah.nongnu.org/cgi-bin/viewcvs/lwip/contrib/
Submit patches and bugs via the lwIP project page: Submit patches and bugs via the lwIP project page:
http://savannah.nongnu.org/projects/lwip/ http://savannah.nongnu.org/projects/lwip/
Continuous integration builds (GCC, clang):
https://travis-ci.org/yarrick/lwip-merged
DOCUMENTATION
The original out-dated homepage of lwIP and Adam Dunkels' papers on DOCUMENTATION
lwIP are at the official lwIP home page:
http://www.sics.se/~adam/lwip/
Self documentation of the source code is regularly extracted from the Self documentation of the source code is regularly extracted from the current
current CVS sources and is available from this web page: Git sources and is available from this web page:
http://www.nongnu.org/lwip/ http://www.nongnu.org/lwip/
There is now a constantly growin wiki about lwIP at There is now a constantly growing wiki about lwIP at
http://lwip.wikia.com/wiki/LwIP_Wiki http://lwip.wikia.com/wiki/LwIP_Wiki
Also, there are mailing lists you can subscribe at Also, there are mailing lists you can subscribe at
...@@ -80,10 +89,12 @@ plus searchable archives: ...@@ -80,10 +89,12 @@ plus searchable archives:
http://lists.nongnu.org/archive/html/lwip-users/ http://lists.nongnu.org/archive/html/lwip-users/
http://lists.nongnu.org/archive/html/lwip-devel/ 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 Reading Adam's papers, the files in docs/, browsing the source code
documentation and browsing the mailing list archives is a good way to documentation and browsing the mailing list archives is a good way to
become familiar with the design of lwIP. become familiar with the design of lwIP.
Adam Dunkels <adam@sics.se> Adam Dunkels <adam@sics.se>
Leon Woestenberg <leon.woestenberg@gmx.net> Leon Woestenberg <leon.woestenberg@gmx.net>
Import('RTT_ROOT')
from building import * from building import *
src = Split(""" src = Split("""
src/arch/sys_arch.c
src/api/api_lib.c src/api/api_lib.c
src/api/api_msg.c src/api/api_msg.c
src/api/err.c src/api/err.c
...@@ -10,13 +10,11 @@ src/api/netdb.c ...@@ -10,13 +10,11 @@ src/api/netdb.c
src/api/netifapi.c src/api/netifapi.c
src/api/sockets.c src/api/sockets.c
src/api/tcpip.c src/api/tcpip.c
src/api/pppapi.c
src/arch/sys_arch.c
src/core/def.c src/core/def.c
src/core/dhcp.c
src/core/dns.c src/core/dns.c
src/core/inet_chksum.c
src/core/init.c src/core/init.c
src/core/mem.c src/core/ip.c
src/core/memp.c src/core/memp.c
src/core/netif.c src/core/netif.c
src/core/pbuf.c src/core/pbuf.c
...@@ -26,18 +24,23 @@ src/core/sys.c ...@@ -26,18 +24,23 @@ src/core/sys.c
src/core/tcp.c src/core/tcp.c
src/core/tcp_in.c src/core/tcp_in.c
src/core/tcp_out.c src/core/tcp_out.c
src/core/timers.c src/core/timeouts.c
src/core/udp.c src/core/udp.c
src/core/inet_chksum.c src/netif/ethernet.c
src/netif/etharp.c
src/netif/ethernetif.c src/netif/ethernetif.c
src/netif/lowpan6.c
src/netif/slipif.c src/netif/slipif.c
""")
ipv4_src = Split("""
src/core/ipv4/autoip.c src/core/ipv4/autoip.c
src/core/ipv4/dhcp.c
src/core/ipv4/etharp.c
src/core/ipv4/icmp.c src/core/ipv4/icmp.c
src/core/ipv4/igmp.c src/core/ipv4/igmp.c
src/core/ipv4/ip4.c src/core/ipv4/ip4.c
src/core/ipv4/ip4_addr.c src/core/ipv4/ip4_addr.c
src/core/ipv4/ip_frag.c src/core/ipv4/ip4_frag.c
""") """)
ipv6_src = Split(""" ipv6_src = Split("""
...@@ -45,73 +48,34 @@ src/core/ipv6/dhcp6.c ...@@ -45,73 +48,34 @@ src/core/ipv6/dhcp6.c
src/core/ipv6/ethip6.c src/core/ipv6/ethip6.c
src/core/ipv6/icmp6.c src/core/ipv6/icmp6.c
src/core/ipv6/inet6.c src/core/ipv6/inet6.c
src/core/ipv6/ip6_addr.c
src/core/ipv6/ip6.c src/core/ipv6/ip6.c
src/core/ipv6/ip6_addr.c
src/core/ipv6/ip6_frag.c src/core/ipv6/ip6_frag.c
src/core/ipv6/mld6.c src/core/ipv6/mld6.c
src/core/ipv6/nd6.c src/core/ipv6/nd6.c
""") """)
snmp_src = Split(""" snmp_src = Glob("src/apps/snmp/*.c")
src/core/snmp/asn1_dec.c
src/core/snmp/asn1_enc.c
src/core/snmp/mib2.c
src/core/snmp/mib_structs.c
src/core/snmp/msg_in.c
src/core/snmp/msg_out.c
""")
ppp_src = Split(""" ppp_src = Glob("src/netif/ppp/*.c") + Glob("src/netif/ppp/polarssl/*c")
src/netif/ppp/auth.c
src/netif/ppp/ccp.c src = src + ipv4_src
src/netif/ppp/chap_ms.c
src/netif/ppp/chap_md5.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/multilink.c
src/netif/ppp/ppp.c
src/netif/ppp/pppcrypt.c
src/netif/ppp/pppoe.c
src/netif/ppp/pppol2tp.c
src/netif/ppp/upap.c
src/netif/ppp/utils.c
src/netif/ppp/vj.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
""")
# The set of source files associated with this SConscript file. # The set of source files associated with this SConscript file.
path = [GetCurrentDir() + '/src', path = [GetCurrentDir() + '/src',
GetCurrentDir() + '/src/include', GetCurrentDir() + '/src/include',
GetCurrentDir() + '/src/include/ipv4', GetCurrentDir() + '/src/include/ipv4',
GetCurrentDir() + '/src/include/ipv6',
GetCurrentDir() + '/src/arch/include', GetCurrentDir() + '/src/arch/include',
GetCurrentDir() + '/src/include/netif'] GetCurrentDir() + '/src/include/netif']
if GetDepend(['RT_LWIP_IPV6']):
src += ipv6_src
if GetDepend(['RT_LWIP_SNMP']): if GetDepend(['RT_LWIP_SNMP']):
src += snmp_src src += snmp_src
path += [GetCurrentDir() + '/src/apps/snmp']
if GetDepend(['RT_LWIP_PPP']): if GetDepend(['RT_LWIP_PPP']):
src += ppp_src src += ppp_src
path += [GetCurrentDir() + '/src/netif/ppp'] path += [GetCurrentDir() + '/src/netif/ppp']
# For testing apps group = DefineGroup('lwIP', src, depend = ['RT_USING_LWIP', 'RT_USING_LWIP200'], CPPPATH = path)
if GetDepend(['RT_USING_NETUTILS']):
src += Glob('./apps/*.c')
group = DefineGroup('LwIP', src, depend = ['RT_USING_LWIP', 'RT_USING_LWIP_HEAD'], CPPPATH = path)
Return('group') Return('group')
...@@ -4,10 +4,94 @@ application written for an older version of lwIP to correctly work ...@@ -4,10 +4,94 @@ application written for an older version of lwIP to correctly work
with newer versions. with newer versions.
(CVS HEAD) (git master)
* [Enter new changes just after this line - do not remove this line] * [Enter new changes just after this line - do not remove this line]
* TODO
(2.0.0)
++ Application changes:
* Changed netif "up" flag handling to be an administrative flag (as opposed to the previous meaning of
"ip4-address-valid", a netif will now not be used for transmission if not up) -> even a DHCP netif
has to be set "up" before starting the DHCP client
* Added IPv6 support (dual-stack or IPv4/IPv6 only)
* Changed ip_addr_t to be a union in dual-stack mode (use ip4_addr_t where referring to IPv4 only).
* Major rewrite of SNMP (added MIB parser that creates code stubs for custom MIBs);
supports SNMPv2c (experimental v3 support)
* Moved some core applications from contrib repository to src/apps (and include/lwip/apps)
+++ Raw API:
* Changed TCP listen backlog: removed tcp_accepted(), added the function pair tcp_backlog_delayed()/
tcp_backlog_accepted() to explicitly delay backlog handling on a connection pcb
+++ Socket API:
* Added an implementation for posix sendmsg()
* Added LWIP_FIONREAD_LINUXMODE that makes ioctl/FIONREAD return the size of the next pending datagram
++ Port changes
+++ new files:
* MANY new and moved files!
* Added src/Filelists.mk for use in Makefile projects
* Continued moving stack-internal parts from abc.h to abc_priv.h in sub-folder "priv"
to let abc.h only contain the actual application programmer's API
+++ sys layer:
* Made LWIP_TCPIP_CORE_LOCKING==1 the default as it usually performs better than
the traditional message passing (although with LWIP_COMPAT_MUTEX you are still
open to priority inversion, so this is not recommended any more)
* Added LWIP_NETCONN_SEM_PER_THREAD to use one "op_completed" semaphore per thread
instead of using one per netconn (these semaphores are used even with core locking
enabled as some longer lasting functions like big writes still need to delay)
* Added generalized abstraction for itoa(), strnicmp(), stricmp() and strnstr()
in def.h (to be overridden in cc.h) instead of config
options for netbiosns, httpd, dns, etc. ...
* New abstraction for hton* and ntoh* functions in def.h.
To override them, use the following in cc.h:
#define lwip_htons(x) <your_htons>
#define lwip_htonl(x) <your_htonl>
+++ new options:
* TODO
+++ new pools:
* Added LWIP_MEMPOOL_* (declare/init/alloc/free) to declare private memp pools
that share memp.c code but do not have to be made global via lwippools.h
* Added pools for IPv6, MPU_COMPATIBLE, dns-api, netif-api, etc.
* added hook LWIP_HOOK_MEMP_AVAILABLE() to get informed when a memp pool was empty and an item
is now available
* Signature of LWIP_HOOK_VLAN_SET macro was changed
* LWIP_DECLARE_MEMORY_ALIGNED() may be used to declare aligned memory buffers (mem/memp)
or to move buffers to dedicated memory using compiler attributes
* Standard C headers are used to define sized types and printf formatters
(disable by setting LWIP_NO_STDINT_H=1 or LWIP_NO_INTTYPES_H=1 if your compiler
does not support these)
++ Major bugfixes/improvements
* Added IPv6 support (dual-stack or IPv4/IPv6 only)
* Major rewrite of PPP (incl. keep-up with apache pppd)
see doc/ppp.txt for an upgrading how-to
* Major rewrite of SNMP (incl. MIB parser)
* Fixed timing issues that might have lead to losing a DHCP lease
* Made rx processing path more robust against crafted errors
* TCP window scaling support
* modification of api modules to support FreeRTOS-MPU (don't pass stack-pointers to other threads)
* made DNS client more robust
* support PBUF_REF for RX packets
* LWIP_NETCONN_FULLDUPLEX allows netconn/sockets to be used for reading/writing from separate
threads each (needs LWIP_NETCONN_SEM_PER_THREAD)
* Moved and reordered stats (mainly memp/mib2)
(1.4.0)
++ Application changes: ++ Application changes:
* Replaced struct ip_addr by typedef ip_addr_t (struct ip_addr is kept for * Replaced struct ip_addr by typedef ip_addr_t (struct ip_addr is kept for
......
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. savannah.txt - How to obtain the current development source code.
contrib.txt - How to contribute to lwIP as a developer. contrib.txt - How to contribute to lwIP as a developer.
rawapi.txt - The documentation for the core API of lwIP. rawapi.txt - The documentation for the core API of lwIP.
Also provides an overview about the other APIs and multithreading. Also provides an overview about the other APIs and multithreading.
snmp_agent.txt - The documentation for the lwIP SNMP agent.
sys_arch.txt - The documentation for a system abstraction layer of lwIP. 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, sizeof(netif->hwaddr));
netif->hwaddr_len = sizeof(netif->hwaddr);
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_init();
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 */
}
}
...@@ -34,26 +34,25 @@ features of Savannah help us not lose users' input. ...@@ -34,26 +34,25 @@ features of Savannah help us not lose users' input.
2.3 Bug reports and patches: 2.3 Bug reports and patches:
1. Make sure you are reporting bugs or send patches against the latest 1. Make sure you are reporting bugs or send patches against the latest
sources. (From the latest release and/or the current CVS sources.) sources. (From the latest release and/or the current Git sources.)
2. If you think you found a bug make sure it's not already filed in the 2. If you think you found a bug make sure it's not already filed in the
bugtracker at Savannah. bugtracker at Savannah.
3. If you have a fix put the patch on Savannah. If it is a patch that affects 3. If you have a fix put the patch on Savannah. If it is a patch that affects
both core and arch specific stuff please separate them so that the core can both core and arch specific stuff please separate them so that the core can
be applied separately while leaving the other patch 'open'. The prefered way be applied separately while leaving the other patch 'open'. The preferred way
is to NOT touch archs you can't test and let maintainers take care of them. is to NOT touch archs you can't test and let maintainers take care of them.
This is a good way to see if they are used at all - the same goes for unix This is a good way to see if they are used at all - the same goes for unix
netifs except tapif. netifs except tapif.
4. Do not file a bug and post a fix to it to the patch area. Either a bug report 4. Do not file a bug and post a fix to it to the patch area. Either a bug report
or a patch will be enough. or a patch will be enough.
If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area. If you correct an existing bug then attach the patch to the bug rather than creating a new entry in the patch area.
5. Patches should be specific to a single change or to related changes.Do not mix bugfixes with spelling and other 5. Patches should be specific to a single change or to related changes. Do not mix bugfixes with spelling and other
trivial fixes unless the bugfix is trivial too.Do not reorganize code and rename identifiers in the same patch you trivial fixes unless the bugfix is trivial too. Do not reorganize code and rename identifiers in the same patch you
change behaviour if not necessary.A patch is easier to read and understand if it's to the point and short than change behaviour if not necessary. A patch is easier to read and understand if it's to the point and short than
if it's not to the point and long :) so the chances for it to be applied are greater. if it's not to the point and long :) so the chances for it to be applied are greater.
2.4 Platform porters: 2.4 Platform porters:
1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and 1. If you have ported lwIP to a platform (an OS, a uC/processor or a combination of these) and
you think it could benefit others[1] you might want discuss this on the mailing list. You you think it could benefit others[1] you might want discuss this on the mailing list. You
can also ask for CVS access to submit and maintain your port in the contrib CVS module. can also ask for Git access to submit and maintain your port in the contrib Git module.
\ No newline at end of file
此差异已折叠。
/**
* @defgroup lwip lwIP
*
* @defgroup infrastructure Infrastructure
*
* @defgroup callbackstyle_api Callback-style APIs
* Non thread-safe APIs, callback style for maximum performance and minimum
* memory footprint.
*
* @defgroup sequential_api Sequential-style APIs
* Sequential-style APIs, blocking functions. More overhead, but can be called
* from any thread except TCPIP thread.
*
* @defgroup addons Addons
*
* @defgroup apps Applications
*/
/**
* @mainpage Overview
* @verbinclude "README"
*/
/**
* @page upgrading Upgrading
* @verbinclude "UPGRADING"
*/
/**
* @page contrib How to contribute to lwIP
* @verbinclude "contrib.txt"
*/
/**
* @page pitfalls Common pitfalls
*
* Multiple Execution Contexts in lwIP code
* ========================================
*
* The most common source of lwIP problems is to have multiple execution contexts
* inside the lwIP code.
*
* lwIP can be used in two basic modes: @ref lwip_nosys (no OS/RTOS
* running on target system) or @ref lwip_os (there is an OS running
* on the target system).
*
* Mainloop Mode
* -------------
* In mainloop mode, only @ref callbackstyle_api can be used.
* The user has two possibilities to ensure there is only one
* exection context at a time in lwIP:
*
* 1) Deliver RX ethernet packets directly in interrupt context to lwIP
* by calling netif->input directly in interrupt. This implies all lwIP
* callback functions are called in IRQ context, which may cause further
* problems in application code: IRQ is blocked for a long time, multiple
* execution contexts in application code etc. When the application wants
* to call lwIP, it only needs to disable interrupts during the call.
* If timers are involved, even more locking code is needed to lock out
* timer IRQ and ethernet IRQ from each other, assuming these may be nested.
*
* 2) Run lwIP in a mainloop. There is example code here: @ref lwip_nosys.
* lwIP is _ONLY_ called from mainloop callstacks here. The ethernet IRQ
* has to put received telegrams into a queue which is polled in the
* mainloop. Ensure lwIP is _NEVER_ called from an interrupt, e.g.
* some SPI IRQ wants to forward data to udp_send() or tcp_write()!
*
* OS Mode
* -------
* In OS mode, @ref callbackstyle_api AND @ref sequential_api can be used.
* @ref sequential_api are designed to be called from threads other than
* the TCPIP thread, so there is nothing to consider here.
* But @ref callbackstyle_api functions must _ONLY_ be called from
* TCPIP thread. It is a common error to call these from other threads
* or from IRQ contexts. ​Ethernet RX needs to deliver incoming packets
* in the correct way by sending a message to TCPIP thread, this is
* implemented in tcpip_input().​​
* Again, ensure lwIP is _NEVER_ called from an interrupt, e.g.
* some SPI IRQ wants to forward data to udp_send() or tcp_write()!
*
* 1) tcpip_callback() can be used get called back from TCPIP thread,
* it is safe to call any @ref callbackstyle_api from there.
*
* 2) Use @ref LWIP_TCPIP_CORE_LOCKING. All @ref callbackstyle_api
* functions can be called when lwIP core lock is aquired, see
* @ref LOCK_TCPIP_CORE() and @ref UNLOCK_TCPIP_CORE().
* These macros cannot be used in an interrupt context!
* Note the OS must correctly handle priority inversion for this.
*/
/**
* @page bugs Reporting bugs
* Please report bugs in the lwIP bug tracker at savannah.\n
* BEFORE submitting, please check if the bug has already been reported!\n
* https://savannah.nongnu.org/bugs/?group=lwip
*/
/**
* @defgroup lwip_nosys Mainloop mode ("NO_SYS")
* @ingroup lwip
* Use this mode if you do not run an OS on your system. \#define NO_SYS to 1.
* Feed incoming packets to netif->input(pbuf, netif) function from mainloop,
* *not* *from* *interrupt* *context*. You can allocate a @ref pbuf in interrupt
* context and put them into a queue which is processed from mainloop.\n
* Call sys_check_timeouts() periodically in the mainloop.\n
* Porting: implement all functions in @ref sys_time and @ref sys_prot.\n
* You can only use @ref callbackstyle_api in this mode.\n
* Sample code:\n
* @include NO_SYS_SampleCode.c
*/
/**
* @defgroup lwip_os OS mode (TCPIP thread)
* @ingroup lwip
* Use this mode if you run an OS on your system. It is recommended to
* use an RTOS that correctly handles priority inversion and
* to use @ref LWIP_TCPIP_CORE_LOCKING.\n
* Porting: implement all functions in @ref sys_layer.\n
* You can use @ref callbackstyle_api together with @ref tcpip_callback,
* and all @ref sequential_api.
*/
/**
* @page raw_api lwIP API
* @verbinclude "rawapi.txt"
*/
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Redirection</title>
<meta http-equiv="refresh" content="0; url=html/index.html" />
</head>
<body>
<a href="html/index.html">index.html</a>
</body>
</html>
Multicast DNS for lwIP
Author: Erik Ekman
Note! The MDNS responder does not have all features required by the standards.
See notes in src/apps/mdns/mdns.c for what is left. It is however usable in normal
cases - but watch out if many devices on the same network try to use the same
host/service instance names.
How to enable:
==============
MDNS support does not depend on DNS.
MDNS supports using IPv4 only, v6 only, or v4+v6.
To enable MDNS responder, set
LWIP_MDNS_RESPONDER = 1
in lwipopts.h and add src/apps/mdns/mdns.c to your list of files to build.
The max number of services supported per netif is defined by MDNS_MAX_SERVICES,
default is 1.
Increase MEMP_NUM_UDP_PCB by 1. MDNS needs one PCB.
Increase LWIP_NUM_NETIF_CLIENT_DATA by 1 (MDNS needs one entry on netif).
MDNS with IPv4 requires LWIP_IGMP = 1, and preferably LWIP_AUTOIP = 1.
MDNS with IPv6 requires LWIP_IPV6_MLD = 1, and that a link-local address is
generated.
The MDNS code puts its structs on the stack where suitable to reduce dynamic
memory allocation. It may use up to 1kB of stack.
MDNS needs a strncasecmp() implementation. If you have one, define
LWIP_MDNS_STRNCASECMP to it. Otherwise the code will provide an implementation
for you.
How to use:
===========
Call mdns_resp_init() during system initialization.
This opens UDP sockets on port 5353 for IPv4 and IPv6.
To start responding on a netif, run
mdns_resp_add_netif(struct netif *netif, char *hostname, u32_t dns_ttl)
The hostname will be copied. If this returns successfully, the netif will join
the multicast groups and any MDNS/legacy DNS requests sent unicast or multicast
to port 5353 will be handled:
- <hostname>.local type A, AAAA or ANY returns relevant IP addresses
- Reverse lookups (PTR in-addr.arpa, ip6.arpa) of netif addresses
returns <hostname>.local
Answers will use the supplied TTL (in seconds)
MDNS allows UTF-8 names, but it is recommended to stay within ASCII,
since the default case-insensitive comparison assumes this.
It is recommended to call this function after an IPv4 address has been set,
since there is currently no check if the v4 address is valid.
Call mdns_resp_netif_settings_changed() every time the IP address
on the netif has changed.
To stop responding on a netif, run
mdns_resp_remove_netif(struct netif *netif)
Adding services:
================
The netif first needs to be registered. Then run
mdns_resp_add_service(struct netif *netif, char *name, char *service,
u16_t proto, u16_t port, u32_t dns_ttl,
service_get_txt_fn_t txt_fn, void *txt_userdata);
The name and service pointers will be copied. Name refers to the name of the
service instance, and service is the type of service, like _http
proto can be DNSSD_PROTO_UDP or DNSSD_PROTO_TCP which represent _udp and _tcp.
If this call returns successfully, the following queries will be answered:
- _services._dns-sd._udp.local type PTR returns <service>.<proto>.local
- <service>.<proto>.local type PTR returns <name>.<service>.<proto>.local
- <name>.<service>.<proto>.local type SRV returns hostname and port of service
- <name>.<service>.<proto>.local type TXT builds text strings by calling txt_fn
with the supplied userdata. The callback adds strings to the reply by calling
mdns_resp_add_service_txtitem(struct mdns_service *service, char *txt,
int txt_len). Example callback method:
static void srv_txt(struct mdns_service *service, void *txt_userdata)
{
res = mdns_resp_add_service_txtitem(service, "path=/", 6);
LWIP_ERROR("mdns add service txt failed\n", (res == ERR_OK), return);
}
Since a hostname struct is used for TXT storage each single item can be max
63 bytes long, and the total max length (including length bytes for each
item) is 255 bytes.
If your device runs a webserver on port 80, an example call might be:
mdns_resp_add_service(netif, "myweb", "_http"
DNSSD_PROTO_TCP, 80, 3600, srv_txt, NULL);
which will publish myweb._http._tcp.local for any hosts looking for web servers,
and point them to <hostname>.local:80
Relevant information will be sent as additional records to reduce number of
requests required from a client.
Removing services is currently not supported. Services are removed when the
netif is removed.
此差异已折叠。
...@@ -2,37 +2,34 @@ Daily Use Guide for using Savannah for lwIP ...@@ -2,37 +2,34 @@ Daily Use Guide for using Savannah for lwIP
Table of Contents: Table of Contents:
1 - Obtaining lwIP from the CVS repository 1 - Obtaining lwIP from the Git repository
2 - Committers/developers CVS access using SSH (to be written) 2 - Committers/developers Git access using SSH
3 - Merging from DEVEL branch to main trunk (stable branch) 3 - Merging a development branch to master branch
4 - How to release lwIP 4 - How to release lwIP
1 Obtaining lwIP from the CVS repository 1 Obtaining lwIP from the Git repository
---------------------------------------- ----------------------------------------
To perform an anonymous CVS checkout of the main trunk (this is where To perform an anonymous Git clone of the master branch (this is where
bug fixes and incremental enhancements occur), do this: bug fixes and incremental enhancements occur), do this:
git clone git://git.savannah.nongnu.org/lwip.git
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout lwip
Or, obtain a stable branch (updated with bug fixes only) as follows: Or, obtain a stable branch (updated with bug fixes only) as follows:
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ git clone --branch DEVEL-1_4_1 git://git.savannah.nongnu.org/lwip.git
-r STABLE-0_7 -d lwip-0.7 lwip
Or, obtain a specific (fixed) release as follows: Or, obtain a specific (fixed) release as follows:
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ git clone --branch STABLE-1_4_1 git://git.savannah.nongnu.org/lwip.git
-r STABLE-0_7_0 -d lwip-0.7.0 lwip
3 Committers/developers CVS access using SSH
2 Committers/developers Git access using SSH
-------------------------------------------- --------------------------------------------
The Savannah server uses SSH (Secure Shell) protocol 2 authentication and encryption. The Savannah server uses SSH (Secure Shell) protocol 2 authentication and encryption.
As such, CVS commits to the server occur through a SSH tunnel for project members. As such, Git commits to the server occur through a SSH tunnel for project members.
To create a SSH2 key pair in UNIX-like environments, do this: To create a SSH2 key pair in UNIX-like environments, do this:
ssh-keygen -t dsa
ssh-keygen -t dsa
Under Windows, a recommended SSH client is "PuTTY", freely available with good Under Windows, a recommended SSH client is "PuTTY", freely available with good
documentation and a graphic user interface. Use its key generator. documentation and a graphic user interface. Use its key generator.
...@@ -41,95 +38,83 @@ Now paste the id_dsa.pub contents into your Savannah account public key list. Wa ...@@ -41,95 +38,83 @@ Now paste the id_dsa.pub contents into your Savannah account public key list. Wa
a while so that Savannah can update its configuration (This can take minutes). a while so that Savannah can update its configuration (This can take minutes).
Try to login using SSH: Try to login using SSH:
ssh -v your_login@git.sv.gnu.org
ssh -v your_login@cvs.sv.gnu.org
If it tells you: If it tells you:
Linux vcs.savannah.gnu.org 2.6.32-5-xen-686 #1 SMP Wed Jun 17 17:10:03 UTC 2015 i686
Authenticating with public key "your_key_name"... Interactive shell login is not possible for security reasons.
Server refused to allocate pty VCS commands are allowed.
Last login: Tue May 15 23:10:12 2012 from 82.245.102.129
You tried to execute:
Sorry, you are not allowed to execute that command.
Shared connection to git.sv.gnu.org closed.
then you could login; Savannah refuses to give you a shell - which is OK, as we then you could login; Savannah refuses to give you a shell - which is OK, as we
are allowed to use SSH for CVS only. Now, you should be able to do this: are allowed to use SSH for Git only. Now, you should be able to do this:
git clone your_login@git.sv.gnu.org:/srv/git/lwip.git
export CVS_RSH=ssh After which you can edit your local files with bug fixes or new features and
cvs -z3 -d:ext:your_login@cvs.sv.gnu.org:/sources/lwip co lwip commit them. Make sure you know what you are doing when using Git to make
after which you can edit your local files with bug fixes or new features and
commit them. Make sure you know what you are doing when using CVS to make
changes on the repository. If in doubt, ask on the lwip-members mailing list. changes on the repository. If in doubt, ask on the lwip-members mailing list.
(If SSH asks about authenticity of the host, you can check the key (If SSH asks about authenticity of the host, you can check the key
fingerprint against http://savannah.nongnu.org/cvs/?group=lwip) fingerprint against https://savannah.nongnu.org/git/?group=lwip
3 Merging from DEVEL branch to main trunk (stable)
--------------------------------------------------
Merging is a delicate process in CVS and requires the 3 - Merging a development branch to master branch
following disciplined steps in order to prevent conflicts -------------------------------------------------
in the future. Conflicts can be hard to solve!
Merging from branch A to branch B requires that the A branch Merging is a straightforward process in Git. How to merge all changes in a
has a tag indicating the previous merger. This tag is called development branch since our last merge from main:
'merged_from_A_to_B'. After merging, the tag is moved in the
A branch to remember this merger for future merge actions.
IMPORTANT: AFTER COMMITTING A SUCCESFUL MERGE IN THE Checkout the master branch:
REPOSITORY, THE TAG MUST BE SET ON THE SOURCE BRANCH OF THE git checkout master
MERGE ACTION (REPLACING EXISTING TAGS WITH THE SAME NAME).
Merge all changes in DEVEL since our last merge to main: Merge the development branch to master:
git merge your-development-branch
In the working copy of the main trunk: Resolve any conflict.
cvs update -P -jmerged_from_DEVEL_to_main -jDEVEL
(This will apply the changes between 'merged_from_DEVEL_to_main' Commit the merge result.
and 'DEVEL' to your work set of files) git commit -a
We can now commit the merge result. Push your commits:
cvs commit -R -m "Merged from DEVEL to main." git push
If this worked out OK, we now move the tag in the DEVEL branch
to this merge point, so we can use this point for future merges:
cvs rtag -F -r DEVEL merged_from_DEVEL_to_main lwip
4 How to release lwIP 4 How to release lwIP
--------------------- ---------------------
First, checkout a clean copy of the branch to be released. Tag this set with First, tag the release using Git: (I use release number 1.4.1 throughout
tag name "STABLE-0_6_3". (I use release number 0.6.3 throughout this example). this example).
git tag -a STABLE-1_4_1
Login CVS using pserver authentication, then export a clean copy of the
tagged tree. Export is similar to a checkout, except that the CVS metadata
is not created locally.
export CVS_RSH=ssh Share the tag reference by pushing it to remote:
cvs -z3 -d:pserver:anonymous@cvs.sv.gnu.org:/sources/lwip checkout \ git push origin STABLE-1_4_1
-r STABLE-0_6_3 -d lwip-0.6.3 lwip
Archive this directory using tar, gzip'd, bzip2'd and zip'd. Prepare the release:
cp -r lwip lwip-1.4.1
rm -rf lwip-1.4.1/.git lwip-1.4.1/.gitattributes
tar czvf lwip-0.6.3.tar.gz lwip-0.6.3 Archive the current directory using tar, gzip'd, bzip2'd and zip'd.
tar cjvf lwip-0.6.3.tar.bz2 lwip-0.6.3 tar czvf lwip-1.4.1.tar.gz lwip-1.4.1
zip -r lwip-0.6.3.zip lwip-0.6.3 tar cjvf lwip-1.4.1.tar.bz2 lwip-1.4.1
zip -r lwip-1.4.1.zip lwip-1.4.1
Now, sign the archives with a detached GPG binary signature as follows: Now, sign the archives with a detached GPG binary signature as follows:
gpg -b lwip-1.4.1.tar.gz
gpg -b lwip-0.6.3.tar.gz gpg -b lwip-1.4.1.tar.bz2
gpg -b lwip-0.6.3.tar.bz2 gpg -b lwip-1.4.1.zip
gpg -b lwip-0.6.3.zip
Upload these files using anonymous FTP: Upload these files using anonymous FTP:
ncftp ftp://savannah.gnu.org/incoming/savannah/lwip ncftp ftp://savannah.gnu.org/incoming/savannah/lwip
ncftp> mput *1.4.1.*
ncftp>mput *0.6.3.*
Additionally, you may post a news item on Savannah, like this: Additionally, you may post a news item on Savannah, like this:
A new 0.6.3 release is now available here: A new 1.4.1 release is now available here:
http://savannah.nongnu.org/files/?group=lwip&highlight=0.6.3 http://savannah.nongnu.org/files/?group=lwip&highlight=1.4.1
You will have to submit this via the user News interface, then approve You will have to submit this via the user News interface, then approve
this via the Administrator News interface. this via the Administrator News interface.
\ No newline at end of file
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
...@@ -59,5 +59,4 @@ typedef rt_mutex_t sys_mutex_t; ...@@ -59,5 +59,4 @@ typedef rt_mutex_t sys_mutex_t;
typedef rt_mailbox_t sys_mbox_t; typedef rt_mailbox_t sys_mbox_t;
typedef rt_thread_t sys_thread_t; typedef rt_thread_t sys_thread_t;
#endif /* __ARCH_SYS_ARCH_H__ */ #endif /* __ARCH_SYS_ARCH_H__ */
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册