- Note: Version 1.3.0 has been finalized and released.
Please refer to the CHANGELOG for a complete list of all changes made in version 1.3.0. The file netif/ethernetif.c provides a "good practice" example of an ethernet interface driver written for the 1.3.0 code base. The following are some particular notes and gotchas that you should be aware of if you are updating your code from 1.2.0 to 1.3.0. Bear in mind that these notes only cover the differences between 1.2.0 and 1.3.0.
- ARP
- New
LWIP_ARPoption in lwipopts.h. ARP can now be disabled completely. - New
NETIF_FLAG_ETHARPflag for Ethernet netifs. - New
ETHARP_TRUST_IP_MACoption in lwipopts.h. Enable this to allow any incoming IP packet to update the ARP table. - New
LWIP_NETIF_HWADDRHINToption in lwipopts.h. Enable this to allow each pcb (i.e. connection) to maintain a cache pointing into the ARP table, instead of having to scan the whole ARP table each time. ARP_QUEUEINGoption in lwipopts.h. Previous problems with this option have been fixed.- The
netif_set_upfunction now generates a "gratuitous ARP" when the netif is brought up. Your driver should (probably) no longer need to do this. etharp.cnow requires a MAC address to be 6 bytes since our ARP is currently only used with Ethernet.- You should no longer call
etharp_initin your port's initilization sequence if you usetcpip.c, because this call is done intcpip_initfunction.
- New
- IP Fragmentation
- New
IP_FRAG_USES_STATIC_BUFoption in lwipopts.h. In 1.2.0 and earlier, lwIP always used a static buffer to split packets into fragments, but now it is possible to disable this, and instead pbufs are allocated and referenced for each fragment in order to send the fragmented packet data.
- New
- UDP Lite
- New
LWIP_UDPLITEoption in lwipopts.h. Enable UDP Lite support for all API layers.
- New
- ICMP
- New
LWIP_ICMPoption in lwipopts.h. Enable/disable ICMP support. As with many options in lwIP, disabling this is not RFC compliant, but may not be useful depending on your application.
- New
- IGMP
- New
LWIP_IGMPoption in lwipopts.h. Enable IGMP support for all API layers (IP_ADD_MEMBERSHIP, IP_DROP_MEMBERSHIP, IP_MULTICAST_TTL, and IP_MULTICAST_IF). A newIGMP_STATSoption enables specific statistics. You have to set theNETIF_FLAG_IGMPflag for any netifs which should process IGMP messages. You also have to set MEMP_NUM_IGMP_GROUP large enough to support all needed IGMP groups.
- New
- SNMP
- The default SNMP ports are now configurable at build time (using the
SNMP_IN_PORTand/orSNMP_TRAP_PORTdefines in lwipopts.h). - New
NETIF_INIT_SNMP()macro to help SNMP initialization (seeethernetif.cfor a sample). - You can define a
SNMP_GET_SYSUPTIMEmacro in your lwipopts.h or your port to provide the system uptime information for MIB-II only when the module needs it. You can also usesnmp_add_sysuptimeto increase the uptime in large amounts, avoiding the need for a timer to increase the "sysuptime" every 10ms.
- The default SNMP ports are now configurable at build time (using the
- DHCP
- New
LWIP_NETIF_HOSTNAMEoption in lwipopts.h. Enable this to initialize ahostnamefield in the netif, which DHCP can then use and pass to the DHCP server to register a client hostname. You can also choose to use it forsnmp_set_sysname.
- New
- AUTOIP
- New
LWIP_AUTOIPoption in lwipopts.h. Enable AUTOIP support with or without DHCP cooperation mode (LWIP_DHCP_AUTOIP_COOP). - The random part for AUTOIP is done by the
LWIP_AUTOIP_RANDmacro. But you can redefine it in your lwipopts.h if you want to use therand()function from the C runtime.
- New
- Memory Management
- New
MEM_USE_POOLSoption in lwipopts.h. Enable to use memp module to avoid fragmentation problems. Need to defineMEM_POOL_NUM_1/4pool size, andMEM_POOL_SIZE_1/4bytes size, in lwipopts.h). (FIXME: This isn't right. what option is meant here? -Jifl) - New
MEM_LIBC_MALLOCoption in lwipopts.h. Enable to use C runtime malloc in the place ofmem.c. - New
MEMP_OVERFLOW_CHECKoption in lwipopts.h. Enable to add runtime checks for memory overflow (this is recommended during development). - New
MEMCPY/SMEMCPYoption in lwipopts.h. Enable to use different memory copy functions for normal (MEMCPY) and small (SMEMCPY) copies in place of the C runtimememcpyfunction. - New
MEMP_NUM_TCPIP_MSG_APIandMEMP_NUM_TCPIP_MSG_INPKTreplace olderMEMP_NUM_TCPIP_MSG.
- New
- System
- New
sys_mbox_tryfetchfunction should be implemented in yoursys_arch.c. This must not block on a fetch from an mbox (seesys_arch.txt). ReturnSYS_MBOX_EMPTYif no message in the mbox.sys_arch_mbox_tryfetchcan be implemented as a function-like macro by the port insys_arch.hif desired. - New parameters for
sys_thread_newfunction:name, andstacksize. For this last parameter, since it's system dependant, you can define xxx_THREAD_STACKSIZE macro in your lwipopts.h.
- New
- Network interfaces
- The order of the argument list for
etharp_outputhas been changed to match the order fornetif->output. Please verify that your driver uses the right order if your driver uses ARP. - Both ARP and IP incoming packets are now passed to the
tcpip_inputfunction. This means that the payload should point to theethhdr). - There are new callback features on netifs:
LWIP_NETIF_STATUS_CALLBACKsets a callback function to invoke when the netif status changes. For example, you can now get a callback when DHCP acquires a new IP address.LWIP_NETIF_LINK_CALLBACKenables a callback that drivers should now call when the physical link status changes.
- New
NETIF_FLAG_ETHARPflag for Ethernet netifs. - New
NETIF_FLAG_IGMPflag for IGMP netifs. - You should set
NETIF_FLAG_LINK_UPby default for your netifs to be compatible for future uses. - Thread-safe functions to add/remove netif in list, and to start/stop dhcp, provided via
LWIP_NETIF_APIin netifapi.c. - New
LWIP_LOOPIF_MULTITHREADINGshould be enabled if you usetcpip.cand the loopback interface (inloopif.c) together. - New
PPPOE_SUPPORToption, to enable PPP over Ethernet support.
- The order of the argument list for
- Raw API
- A new
tcp_output_naglemacro is available intcp.hto allow raw API users to easily use the Nagle algorithm. - New
pbuf_copy_partialfunction is now available for raw api users.
- A new
- Sockets/Netconn API
- Ports need to call
lwip_socket_init()now for socket layer initialization (integrated inlwip_init). - Implementation of
netconn_sendtofunction for netconn layer. - Implementation of
MSG_PEEKflag forlwip_recv/recvfromfunctions. - Implementation of
SO_NO_CHECKoption for UDP sockets to disable UDP checksum generation on transmit. - Implementation of UDP lite for sockets layer (use
IPPROTO_UDPLITEforprotocolinlwip_socketcall, and use optionsUDPLITE_SEND_CSCOV/UDPLITE_RECV_CSCOVto define checksum coverage). - New
LWIP_TCP_KEEPALIVEoption in lwipopts.h. If enabled, it allows use of new socket/netconn options forTCP_KEEPIDLE/TCP_KEEPINTVL/TCP_KEEPCNT - New
LWIP_SO_RCVTIMEOoption in lwipopts.h. If enabled, it allows socket/netconn receive with timeout operations usingSO_RCVTIMEO - New
LWIP_POSIX_SOCKETS_IO_NAMESoption in lwipopts.h to enable/disable POSIX-like defines names to avoid collision with some OS functions. - New
LWIP_SOCKET&LWIP_NETCONNoptions in lwipopts.h. Enable to reduce footprint in some cases when these APIs are not used. - Improvement of
lwip_recvto bypass internal netbuf boundaries in onelwip_recvcall. - VERY IMPORTANT: There is an API breakage for
netconn_addr(), since its parameters list has now changed. Your compiler should report an error if your application callsnetconn_addr()with the old form of arguments, so it should not fail silently.
- Ports need to call
- Other
- New files to add to your makefile/project (if necessary):
init.c, netbuf.c, igmp.c, autoip.c, ppp_oe.c - New
lwip_init()function to initialize all modules. This function in directly called bytcpip_init().lwip_init()includes some sanity checks of user-configurable values (at build time and runtime). - New
LWIP_STATS_LARGEoption, which can be enabled to get 32-bit statistics (instead of 16 bit) - New
LWIP_UNUSED_ARGmacro to avoid warnings at build time. You can override it in yourcc.hif the default version is insufficient. - Some macros have been renamed to avoid some name collisions with some OS macros:
MEM_ALIGNinLWIP_MEM_ALIGNandMEM_ALIGN_SIZEinLWIP_MEM_ALIGN_SIZE. Most of the debug macros have also been renamed:DBG_LEVEL_OFFtoLWIP_DBG_LEVEL_OFF,DBG_ONtoLWIP_DBG_ON, etc... - New
LWIP_ERRORmacro in debug.h. This macro can be overriden in yourcc.hfile to define what should be done when a fatal error is encountered. You can choose whether or not to enable this in your production release - it has lower overhead than other debug assertions and checks. - You should remove some obsolete definitions from your lwipopts.h file, including
MEMP_NUM_API_MSG, SYS_STATS, RAW_STATS, etc... (compare with currentopt.h). - Some limited sanity checking of user-configurable values is done in
init.c. It is good practice to only rebuildinit.cwhen you change your lwipopts.h file.
- New files to add to your makefile/project (if necessary):