Commit Graph

226 Commits

Author SHA1 Message Date
Axel Lin
1d4cbe768d netif: Add proper lock protect for accessing netif->loop_first
All the reset part of the code accessing netif->loop_first has lock protection,
the only missing part is "while (netif->loop_first != NULL)".
Fix it by adding lock protect around the while loop.

Also convert the code to use while{} loop instead of do .. while{} loop,
then we can avoid NULL test for in pointer in each loop and reduce a level of indent.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2016-11-25 13:02:23 +01:00
David van Moolenbroek
1c9e603299 netif: fix reset of IPv6 addresses in netif_add()
Previously, only the state of the first IPv6 address would be reset,
thus possibly keeping other addresses valid (even though zeroed).
2016-11-04 20:18:25 +01:00
Dirk Ziegelmeier
13fb616bb2 Cleanup hton*/ntoh* function handling and platform abstraction
Let lwip use functions/macros prefixed by lwip_ internally to avoid naming clashes with external #includes.
Remove over-complicated #define handling in def.h
Make functions easier to override in cc.h. The following is sufficient now (no more LWIP_PLATFORM_BYTESWAP):
#define lwip_htons(x) <your_htons>
#define lwip_htonl(x) <your_htonl>
2016-10-06 12:55:57 +02:00
Dirk Ziegelmeier
df5a79966d Fix bug #48886: raw pcbs are not handled on netif address change 2016-10-01 17:13:33 +02:00
Dirk Ziegelmeier
149701b347 Fix bug #49218: pbuf_clen() overflow as a result of tcp_write concatenation
Let pbuf_clen() return u16_t
2016-09-30 09:04:36 +02:00
Dirk Ziegelmeier
65796cd827 "Fix" bug #49078: lwip cannot establish ipv6 connection, because of failed to fill ipv6 source address in Neighbor Solicitation Message by adding a note to netif_add not to forget to create a link-local IPv6 address 2016-09-29 12:02:50 +02:00
Dirk Ziegelmeier
633696c153 Implement consistent IPx_ADDR_ANYx macro naming between IPv4 and IPv6
- rename IP4_ADDR_ANY to IP4_ADDR_ANY4
- IP4_ADDR_ANY (= IP_ADDR_ANY) is now IPv4 any address in ip_addr_t format
2016-09-28 12:56:57 +02:00
Dirk Ziegelmeier
97b774ceb9 Minor: Documentation updates 2016-09-26 21:45:29 +02:00
Dirk Ziegelmeier
c7c6b7ce93 Rework IGMP and MLD6 code to store group info per-netif.
Reasoning:
- Makes code in single-netif case perform better and smaller
- IGMP / MLD6 code is a little bit easier to read and understand
- Easier to get multicast groups per netif when implementing drivers

Downside: In multi-netif mode, there are two more pointers on each netif, even if IGMP/MLD6 is not used on it. But these systems should not be so memory-constrained that this will matter.
2016-09-21 13:33:33 +02:00
Dirk Ziegelmeier
d66442ba91 Fix compile when TCP, UDP and RAW are disabled 2016-09-07 08:11:30 +02:00
Dirk Ziegelmeier
0d510dd66d Add API macros for netif client data handling and update documentation accordingly 2016-08-26 11:21:49 +02:00
Dirk Ziegelmeier
57468b8a30 Minor: Several documentation updates 2016-08-25 22:04:04 +02:00
sg
4c390ad39c update netif address change triggers to tpc & udp to work with IPv6, too 2016-08-24 20:51:05 +02:00
Erik Ekman
a1db05c11e Fix const argument warning in netif_ip6_addr_set
../../../../../lwip/src/netif/ppp/ppp.c:1276:37: error: passing
      'const ip6_addr_t *' (aka 'const struct ip6_addr *') to parameter of type
      'ip6_addr_t *' (aka 'struct ip6_addr *') discards qualifiers
      [-Werror,-Wincompatible-pointer-types-discards-qualifiers]
  netif_ip6_addr_set(pcb->netif, 0, IP6_ADDR_ANY6);
                                    ^~~~~~~~~~~~~
../../../../../lwip/src/include/lwip/ip_addr.h:340:24: note: expanded from macro
      'IP6_ADDR_ANY6'
                       ^~~~~~~~~~~~~~~~~~~~~~~~~
../../../../../lwip/src/include/lwip/netif.h:436:73: note: passing argument to
      parameter 'addr6' here
void netif_ip6_addr_set(struct netif *netif, s8_t addr_idx, ip6_addr_t *addr6);
2016-08-24 14:41:48 +02:00
goldsimon
298ec340e5 set netif IPv6 address & state via function to implement change triggers (task #13517) 2016-08-24 09:19:53 +02:00
Dirk Ziegelmeier
8eb9db18a2 Reduce usage of netif/ethernet.h header, mostly lwip/prot/ethernet.h is sufficient 2016-08-19 08:36:00 +02:00
Dirk Ziegelmeier
7f60cb3889 Improve netif client data API for lwIP internal clients - these can use a compile-time constant to access their data now 2016-08-18 12:37:21 +02:00
Dirk Ziegelmeier
ebf7959880 Coding style fixes in netif.c 2016-08-18 11:44:19 +02:00
Dirk Ziegelmeier
c62bfd8146 Port AUTOIP to new netif client data API 2016-08-17 21:26:08 +02:00
Dirk Ziegelmeier
1db9631e7d Port DHCP to new netif client data API 2016-08-17 21:04:44 +02:00
Dirk Ziegelmeier
c28fb298b7 Introduce an API to store arbitrary data pointers in struct netif
Let MDNS to use the new API
TODO: AutoIP, DHCP
2016-08-17 16:37:15 +02:00
Dirk Ziegelmeier
efb7b3d5f8 Rename LWIP_MDNS to LWIP_MDNS_RESPONDER 2016-08-17 12:07:38 +02:00
Erik Ekman
4919932c49 Apply patch #8755: Multicast DNS responder support from Erik Ekman 2016-08-14 15:07:45 +02:00
Axel Lin
0a7db8a9a5 PPP: remove double include for lwip/sys.h
Including it once is enough.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2016-08-07 12:35:50 +02:00
Dirk Ziegelmeier
8d07629b71 Some documentation cleanups and include more comments that have been already in code into doxygen docs 2016-08-07 10:05:34 +02:00
goldsimon
018294d287 remove doubled include (tcpip.h) 2016-08-01 09:44:18 +02:00
Dirk Ziegelmeier
2f7e6d0661 Remove hard reference from netif.c to tcpip.c - avoids pulling in unnecessary code 2016-08-01 09:32:54 +02:00
Dirk Ziegelmeier
2c2d11fa4d Update documentation of netif_input function 2016-07-30 10:40:36 +02:00
Dirk Ziegelmeier
4cb7e31d2d Add missing #include in netif.c 2016-07-30 10:36:11 +02:00
Dirk Ziegelmeier
0c7d015ec4 Further improvement to netif input function autoselection: Select between netif_input() and tcpip_input() depending on NO_SYS setting 2016-07-30 10:29:14 +02:00
Dirk Ziegelmeier
4b67c582f6 Create netif_input function that decides according to netif flags where to pass an incoming packet.
Allow to pass a NULL pointer to netif_add() input function - if so, use the function mentioned above as input function.
2016-07-30 10:19:16 +02:00
Dirk Ziegelmeier
8a9de94b1f Restructure documentation. Create two top-level sections for thread-safe and callback-style APIs. 2016-07-26 18:39:53 +02:00
Dirk Ziegelmeier
0fea2bc02e Document netconn API in doxygen module style 2016-07-26 17:40:55 +02:00
Dirk Ziegelmeier
8643782e5d Document netif and lwIP in doxygen module style 2016-07-26 16:53:27 +02:00
sg
97b8e88e69 netif_set_addr(): when removing an address (setting address to ANY), we have to remove it *before* changing netmask/gw to ensure that tcp RST segment can be sent correctly 2016-07-19 22:34:22 +02:00
Dirk Ziegelmeier
7037b340c1 Move etharp to core/ipv4, which is a more appropriate place for it 2016-07-19 09:29:51 +02:00
Jan Breuer
ac21a5f370 nd6: add cleanup function 2016-05-23 09:44:27 +02:00
Dirk Ziegelmeier
6203737093 Rename snmp_mib2.h to snmp.h so source compatibility for user netif implementations is preserved 2015-11-12 21:25:42 +01:00
sg
c12fa7b4c4 started to move "private" header files containing implementation details to "lwip/priv/" include directory to seperate the API from the implementation. 2015-10-09 21:58:58 +02:00
goldsimon
77f906376e minor: fixed coding style (lwip style) 2015-10-07 10:36:50 +02:00
goldsimon
b401f42520 minor: fixed coding style (lwip style) 2015-10-07 10:03:12 +02:00
sg
2b971400fa minor: coding style 2015-10-06 21:57:40 +02:00
sg
490581a0eb minor/coding style: removed spaces before line ending 2015-10-06 21:08:28 +02:00
Erik Ekman
f80d0dab08 Remove old comments about DHCP setting netif up 2015-10-03 21:31:48 +02:00
Dirk Zigelmeier
3f4d75c8d6 netif_get_ip6_addr_match/netif_add_ip6_address must take a const ip6addr to be usable 2015-09-30 20:55:08 +02:00
goldsimon
0fbdd5e56e fixed compiling LWIP_HAVE_LOOPIF after changing struct netif.ip6_addr to ip_addr_t 2015-09-24 07:58:29 +02:00
sg
db76671d4d task #13729: Convert netif addresses (IPv4 & IPv6) to ip_addr_t (so they can be used without conversion/temporary storage) 2015-09-23 22:09:37 +02:00
Dirk Ziegelmeier
e00e4a6c13 make netif_ip4_* get accessors return const pointers 2015-09-23 13:19:56 +02:00
sg
4f9bcc5ecc fixed compiler warnings reported by mingw-64 2015-09-17 22:00:16 +02:00
goldsimon
7702ed66a0 fixed compiler warning (stray 'a ' in code) - why is this a warning only??? 2015-09-08 09:52:22 +02:00
goldsimon
8a0fb03e21 Separate mib2 counter/table callbacks from snmp agent. This both cleans up the code and should allow integration of a 3rd party agent/mib2. 2015-09-08 09:47:30 +02:00
sg
aa0e41c389 task #12178: hardware checksum capabilities can be configured per netif (use NETIF_SET_CHECKSUM_CTRL() in your netif's init function) 2015-09-01 22:04:15 +02:00
sg
5eb1c411a5 LWIP_LOOPIF_MCAST -> LWIP_LOOPIF_MULTICAST 2015-08-26 20:55:51 +02:00
Joel Cunningham
0ab21da820 Add multicast support to loopif
This commit adds support to send and receive multicast on the loopback
netif by enabling IGMP via NETIF_FLAG_IGMP

This commit also introduces an LwIP configuration option,
LWIP_LOOPIF_MCAST, to control the behavior and it defaults to off
2015-08-26 20:28:03 +02:00
sg
94550682d7 more cleanup prework to fix bug #45029 2015-08-24 22:46:34 +02:00
sg
177c06b1f1 - prework for fixing bug #45029: access IPv4 configuration of struct netif via new API (netif_ip4_addr()/netif_ip4_netmask()/netif_ip4_gw()) instead of accessing the struct member directly. This way, we can change the struct member types from ip4_addr_t to ip_addr_t;
- fixed some bugs in calls to ip4_addr*() where the cast to u8_t* did not reveal the wrong address type
2015-08-20 22:39:48 +02:00
chrysn
877fcb35f4 fix return type of netif_add_ip6_address mismatch
the netif_add_ip6_address function was declared err_t in
src/include/lwip/netif.h, but defined as s8_t (the default value of
err_t) in its implementation in src/core/netif.c.

this causes "conflicting types for 'netif_add_ip6_address'" errors if
err_t is defined differently in cc.h (as for example recommended in
[1]).

as it only returns error constants, it is changed to use err_t
throughout.

[1] http://lwip.wikia.com/wiki/Porting_For_Bare_Metal
2015-08-18 20:55:30 +02:00
goldsimon
13801ebd74 netif_find(): name parameter can be const 2015-08-03 13:47:25 +02:00
goldsimon
4dc3c7a6a0 Fixed warnings about NULL check not required (ip_addr_isany) and implicit conversion (~) 2015-08-03 08:35:01 +02:00
Joel Cunningham
5b0d9338fd netif, loopif: set link up on loopback interface
When LWIP_HAVE_LOOPIF is enabled, a separate loopback interface is added
as a netif. A netif need to have its link state set to up to be able to be
selected as a route in ip4_route or ip6_route.

The regression appears to be when bug #43904 (ip_route() and ip6_route()
must detect linkup status) was fixed.

Furthermore, there is no point of having the loopif down by default.
2015-07-27 00:22:30 +02:00
sg
c1c65777b6 worked on task #13480: added LWIP_IPV4 define - IPv4 can be disabled, leaving an IPv6-only stack (SNMP is still missing) 2015-04-12 10:43:46 +02:00
sg
ce7e31cd04 task #12722 (improve IPv4/v6 address handling): renamed ip_addr_t to ip4_addr_t, renamed ipX_addr_t to ip_addr_t and added IP version;
ip_addr_t is used for all generic IP addresses for the API, ip(4/6)_addr_t are only used internally or when initializing netifs or when calling version-related functions
2015-04-09 22:21:15 +02:00
Ivan Delamer
12e3b52f4d fixed bug #39226: Validity of netif IPv6 address is not always checked 2015-03-18 11:56:48 -06:00
sg
12d374d4b7 Added function documentation, fixed coding style 2015-03-06 21:38:57 +01:00
sg
0ddd7de1ba patch #8359 (Provide utility function to add an IPv6 address to an interface) 2015-03-06 21:30:59 +01:00
sg
4e520cdd30 fixed bug #37068 (netif up/down handling is unclear): correclty separated administrative status of a netif (up/down) from 'valid address' status ATTENTION: netif_set_up() now always has to be called, even when dhcp/autoip is used! 2015-03-05 20:57:43 +01:00
sg
12514c09b2 Fixed bug #39956 (netif_create_ip6_linklocal_address out of bounds access of netif::hwaddr) 2015-03-04 20:58:37 +01:00
Sylvain Rochet
a310bc19a7 netif: fixed compiler warning
lwip/src/core/netif.c: In function ‘netif_set_ipaddr’:
lwip/src/core/netif.c:403:5: warning: implicit declaration of function ‘udp_netif_ipv4_addr_changed’ [-Wimplicit-function-declaration]
     udp_netif_ipv4_addr_changed(&netif->ip_addr, ipaddr);
     ^
2015-02-26 22:45:37 +01:00
sg
0647533f8c fixed bug #44378 (TCP connections are not aborted on netif remove) 2015-02-26 22:25:39 +01:00
sg
99dd78964a fixed bug #40753 (re-bind UDP pcbs on change of IP address) 2015-02-26 22:17:30 +01:00
sg
ec5cf8593e Continued chrysn's work: changed nearly all functions taking 'ip(X)_addr_t' pointer to take const pointers (changed user callbacks: raw_recv_fn, udp_recv_fn; changed port callbacks: netif_output_fn, netif_igmp_mac_filter_fn) 2015-02-22 21:46:35 +01:00
chrysn
9f065c0ea5 (api break) qualify ip_addr_t as const where feasible
this changes the callback signatures of the ip_output and the
{udp,raw}_recv functions.

changes were made by going through all header files, searching for
occurrences of ip_addr_t, qualifying them as const and if required
modifying the corresponding c files, looking for other uses of ip_addr_t
that would be required.

the following header files were not treated as i'm not using them and
wouldn't see them compiled: api.h api_msg.h dhcp.h dns.h igmp.h
netifapi.h pppapi.h snmp.h snmp_msg.h snmp_structs.h ppp.h pppol2tp.h
test/*

no modifications were done on ip6_addr_t.
2015-02-22 21:46:02 +01:00
Simon Goldschmidt
dceed2ea5c fixed bug #39225 udp.c uses netif_matches_ip6_addr() incorrectly; renamed function netif_matches_ip6_addr() to netif_get_ip6_addr_match() 2014-02-25 22:30:46 +01:00
Simon Goldschmidt
5070cc07be Fixed LWIP_IPV6==0 2014-01-17 21:57:40 +01:00
Simon Goldschmidt
1e65eb4936 Added IPv6 loopback address to loopback-netif, fixed last commit 2014-01-17 21:55:46 +01:00
Jay Logue
13e40f754c Enable support for IPv6 loopback
Packets are sent through the loopback path when they are addressed to any
of the valid local IPv6 addresses.
2014-01-17 21:32:24 +01:00
Stathis Voukelatos
039737ffc2 Fixed netif_poll() operation when LWIP_LOOPBACK_MAX_PBUFS > 0.
Using the pbuf_clen() function to calculate the number of pbufs
for the first packet in the queue is not correct here, as pbuf_clen()
will return the total number of pbufs in the loopback I/F queue.
2014-01-16 21:36:49 +01:00
Simon Goldschmidt
9809f1ff66 Fixed bug #38586 2013-04-24 21:38:01 +02:00
Ivan Delamer
c762c06b17 Fixed typo in previous commit.
Change-Id: I97f85f4593509911829cfbbb6e309eecedd5465b
2012-08-17 11:24:18 -06:00
Ivan Delamer
8bab543531 Add a "NULL" output function for ipv6 by default, to avoid NULL
dereferencing in case of non-IPv6-enabled netifs (e.g. PPP).

Change-Id: I45f08ca89bfa0b8d61962f7052b11cc81a5e3cd1
2012-08-17 10:56:14 -06:00
goldsimon
08b497faea fixed bug #34684: Clear the arp table cache when netif is brought down 2011-11-22 21:44:28 +01:00
Simon Goldschmidt
0a5755145c added netif remove callback (bug #32397) 2011-08-24 22:00:10 +02:00
Simon Goldschmidt
bf4ec9be22 fixed bug #34121 netif_add/netif_set_ipaddr fail on NULL ipaddr 2011-08-24 19:52:06 +02:00
goldsimon
732cac1c0e Moved static variable from inside the function to global scope 2011-06-07 19:10:55 +00:00
goldsimon
6865806b55 Combined IPv4 and IPv6 code where possible, added defines to access IPv4/IPv6 in non-IP code so that the code is more readable. 2011-05-25 17:16:35 +00:00
goldsimon
4bfbe7ebeb ... and finally, we got a first working version of a dual-stack lwIP runnin IPv4 and IPv6 in parallel - big thanks to Ivan Delamer! (this is work in progress, so please beware, test a lot and report problems!) 2011-05-17 19:35:14 +00:00
goldsimon
e25c9f7951 Fixed compiler warning when LWIP_SNMP==0 2010-03-15 09:47:43 +00:00
goldsimon
2a2be49d2c task #10241 (AutoIP: don't break existing connections when assiging routable address): when checking incoming packets and aborting existing connection on address change, filter out link-local addresses. 2010-03-08 18:17:52 +00:00
goldsimon
bcd4b76d31 Moved stack-internal parts of tcp.h to tcp_impl.h, tcp.h now only contains the actual application programmer's API 2010-02-21 11:35:21 +00:00
goldsimon
7c2054091d Link status does not depend on LWIP_NETIF_LINK_CALLBACK (fixes bug #28899) 2010-02-15 19:53:46 +00:00
goldsimon
e04e0cb98e Fixed bug #28877 (Duplicate ARP gratuitous packet with LWIP_NETIF_LINK_CALLBACK set on) by only sending if both link- and admin-status of a netif are up 2010-02-14 20:20:28 +00:00
goldsimon
29eb56a2f6 netif_set_link_up/down: only do something if the link state actually changes 2010-02-12 16:50:23 +00:00
goldsimon
a668a4e4d1 Fixed compilation for NO_SYS==1 2010-02-09 17:41:34 +00:00
goldsimon
b1250f003d For loopback packets, adjust the stats- and snmp-counters for the loopback netif. 2010-02-09 17:00:57 +00:00
goldsimon
077caac76d task #10153 (Integrate loopif into netif.c) - loopif does not have to be created by the port any more, just define LWIP_HAVE_LOOPIF to 1. 2010-02-09 16:01:24 +00:00
goldsimon
5d360a6711 Replaced struct ip_addr by typedef ip_addr_t to make changing the actual implementation behind the typedef easier. 2010-02-04 18:47:44 +00:00
goldsimon
a23b446ddf Use macros defined in ip_addr.h (some of them new) to work with IP addresses (preparation for bug #27352 - Change ip_addr from struct to typedef (u32_t) - and better code). 2010-02-04 17:21:32 +00:00
goldsimon
8712deb0b2 Don't call the link-callback from netif_set_up/down() since
this invalidly retriggers DHCP.
2010-01-31 13:30:47 +00:00
goldsimon
2d4e76874c Using typedefs for function prototypes and -pointers throughout the stack for clarity 2010-01-14 20:02:15 +00:00
goldsimon
c483c13dc4 Fixed bug #28248 (netif_remove doesn't call netif callback) by calling netif_set_down() from netif_remove() 2010-01-10 13:34:21 +00:00