Commit Graph

3005 Commits

Author SHA1 Message Date
Sylvain Rochet
9778b1411c PPP, PPPoS, TCPIP: add packet input path for point to point interfaces (only PPPoS for now) through the TCPIP API
!NO_SYS users may now use as well the TCPIP API for PPPoS input data,
this way they can disable PPP_INPROC_MULTITHREADED and run pppos_input()
inside the lwIP thread, which fixes, at least for them, all the
threading issues related to PPP_INPROC_MULTITHREADED.
2015-03-11 00:58:09 +01:00
Sylvain Rochet
636ff411f1 PPP, PPPoS, improve the freeing of remaining RX pbuf if PPP_INPROC_MULTITHREADED is not enabled
If PPP_INPROC_MULTITHREADED is not enabled, we can free unfinished
RX pbuf from the pppos_disconnect() function because pppos_input()
is running in the same context. Thanks to the pppos->open flags we
now only need to free remaining pbuf in the disconnect function
if PPP_INPROC_MULTITHREADED is not enabled.
2015-03-10 23:58:16 +01:00
Sylvain Rochet
02598d1e91 PPP, PPPoS, moved pcomp and accomp only used by PPPoS to PPPoS 2015-03-10 23:51:32 +01:00
Sylvain Rochet
31aea3c996 PPP, PPPoS, moved vj_enabled flag from PPP CORE to PPPoS
Now that we have flags in PPPoS, moved vj_enabled only used for PPPoS to
PPPoS.
2015-03-10 23:42:14 +01:00
Sylvain Rochet
a60f2588d6 PPP, PPPoE and PPPoL2TP, removed ppp->pcomp usage
We refuse protocol compression in both PPPoE and PPPoL2TP, therefore
ppp->pcomp can't be true, removed.
2015-03-10 23:34:11 +01:00
Sylvain Rochet
d518f5f307 PPP, PPPoS, improve thread safety of pppos_input()
Don't process input data if PPPoS is closed, it helps using
pppos_input() from a different context to prevent pppos_input() to
modify PPPoS RX machine state on a closed PPPoS session. It also
prevents allocating pbuf (which are going to be tossed out by PPP core)
and parsing serial input on a closed session.

It only mitigates the fact that this function is actually NOT thread
safe in absolutely all cases, it does not fix it but it helps for a low
cost.

For example user application should never call pppos_input() while
pppos_connect() or pppos_listen() is currently running because both of
them are freeing any input pbuf left over from the last session before
resetting the PPPoS state, they really have to to prevent pbuf leaks.

We cannot fix that easily because we don't have spinlock with an
irqsave/irqrestore helper for IRQ contexts. Mutex cannot be used in
interrupt contexts (or again, with an IRQ mutex helper).

We are going to improve the documentation on this point.
2015-03-10 23:20:23 +01:00
Sylvain Rochet
d5cbacba50 PPP, PPPoS, don't protect pppos->in_accm if PPP_INPROC_MULTITHREADED is not enabled
If pppos_input() is used without PPP_INPROC_MULTITHREADED, then pppos_input()
is running in the lwIP context, we don't need to protect anything.
2015-03-10 22:35:04 +01:00
Sylvain Rochet
ab0f3da650 Revert "PPP, PPPoS, fixed thread safety of pppos_input()"
This reverts commit ea58a8103c.
2015-03-10 21:49:50 +01:00
Sylvain Rochet
52de24b95b Revert "PPP, PPPoS, added necessary comment about mutex"
This reverts commit b23a6172ed.
2015-03-10 21:49:50 +01:00
Sylvain Rochet
70b60bbe16 PPP, display correct pbuf size in ppp_input() debug messages 2015-03-10 21:49:50 +01:00
sg
aff890bce8 Fixed compiler error if LWIP_IPV6==0 but LWIP_IPV6_FRAG==1 2015-03-10 21:42:29 +01:00
sg
905f1609b3 fixed the IPv4 part of bug #43904 (ip_route() must detect linkup status) 2015-03-09 21:35:57 +01:00
goldsimon
c978b25f7f Enable LWIP_PPP_API by default if (PPP_SUPPORT && (NO_SYS == 0)) 2015-03-09 09:13:28 +01:00
Sylvain Rochet
2b526756f0 PPP, updated netif/FILES about PPP 2015-03-09 00:49:08 +01:00
Sylvain Rochet
8a436d5103 PPP, IPV6CP, code cleaning on VJ support 2015-03-08 23:36:28 +01:00
Sylvain Rochet
1dd050aaca PPP, IPV6CP, build out IPv6 VJ support using the existing IPV6CP_COMP define 2015-03-08 23:17:11 +01:00
Sylvain Rochet
99bcce7892 PPP, IPCP, removed proxy ARP support 2015-03-08 23:00:27 +01:00
Sylvain Rochet
0e2ea94f5e PPP, IPCP, removed WINS support 2015-03-08 22:53:12 +01:00
Sylvain Rochet
9cd7abdd6e PPP, IPCP, fully removed DNS support from IPCP if LWIP_DNS is disabled 2015-03-08 22:40:56 +01:00
Sylvain Rochet
dbacfe0a1d PPP, IPCP, fully removed VJ support from IPCP if VJ_SUPPORT is disabled 2015-03-08 22:40:53 +01:00
Sylvain Rochet
969306f0f1 API: netdb: replaced deprecated ip_ntoa() to ipaddr_ntoa() 2015-03-08 13:57:13 +01:00
Sylvain Rochet
af722a2978 PPP, IPv6, reduce size of llv6_ntoa() function
Reduced static buffer to the strict necessary (26 bytes), removed
call to eui64_ntoa(), merged eui64_ntoa() into llv6_ntoa().

272 bytes (code + static buffers) to 140 bytes on x86_64.

Improved eui64_ntoa() as well, we don't need it anymore but I'd
like to keep all eui64_* helpers functions.
2015-03-08 13:33:55 +01:00
Sylvain Rochet
7fce9346dc PPP, improved IPv6 address setting
Set IPv6 link local invalid before clearing it. Don't wait sif6up() to set
the link local valid, netif_ip6_addr_set_state() is only an accessor function
so it does not start any discovery whatsoever.
2015-03-08 12:47:09 +01:00
Sylvain Rochet
b23a6172ed PPP, PPPoS, added necessary comment about mutex 2015-03-08 12:05:13 +01:00
Sylvain Rochet
ea58a8103c PPP, PPPoS, fixed thread safety of pppos_input()
PPPoS was actually not thread safe, pppos_input() can be called from
lwIP user port at any time, whatever the PPP state is. It might even be
called during pppos_connect() and pppos_listen(), this is quite unlikely
the port do that but nothing prevent the user to since we document
pppos_input() as being thread safe.

Added a mutex if PPP_INPROC_MULTITHREADED is set and ensure pppos_input()
is safe in regard to other pppos_* functions.
2015-03-08 02:48:52 +01:00
Sylvain Rochet
b3c7e948be PPP, removed now useless struct ppp_addrs from ppp_pcb
Saved a few bytes of useless copy.
2015-03-08 00:44:47 +01:00
Sylvain Rochet
c966a538fb PPP, improved IPv6 address setting
Now setting IPv6 addresses in sif6addr() instead of sif6up(),
removed the useless copy of addresses.
2015-03-08 00:40:34 +01:00
Sylvain Rochet
3027a7d7e2 PPP, using DNS API for DNS servers
Now setting DNS addresses in sdns() using dns_setserver() instead
of keeping a local copy. This is probably the wanted PPP behavior,
we will see if users want this conditional.
2015-03-08 00:11:52 +01:00
Sylvain Rochet
dd22176935 PPP, improved IPv4 address setting
Now setting IPv4 addresses in sifaddr() instead of sifup(),
removed the useless copy of addresses.
2015-03-07 23:53:21 +01:00
Sylvain Rochet
dbf9d0f094 DNS, warning fix, dns_init() -> dns_init(void)
lwip/src/core/dns.c: In function ‘dns_init’:
lwip/src/core/dns.c:336:1: warning: old-style function definition [-Wold-style-definition]
 dns_init()
2015-03-07 23:28:18 +01:00
Sylvain Rochet
b3218d45f3 PPP, make DNS a little more optional if LWIP_DNS is unset 2015-03-07 23:28:14 +01:00
Sylvain Rochet
3ca5184998 PPP, CORE, separated administrative status from link status of PPP netif
This was confusing, recent lwIP changes fixed the meaning as well as
how it is used everywhere, making the administrative status a user-only
controlled flag. Now that it's clear, updated PPP to follow lwIP
core change.

Using netif_set_link_{up,down} instead of netif_set_{up,down} when PPP
reaches/leaves running state. PPP interface is now set to administratively
UP when created with link state down.
2015-03-07 22:24:27 +01:00
sg
007ab69777 Fixed default LWIP_SUPPORT_CUSTOM_PBUF setting for IPv6/frag 2015-03-06 22:09:33 +01: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
f385193a89 Patch #8207 (Don't Use ND6 Prefix Flags Field When LWIP_IPV6_AUTOCONFIG Is Deasserted) 2015-03-06 21:03:21 +01:00
Philip Gladstone
ff078920bc Patch #8360 (Speed up the acquisition of SLAAC addresses) - adapted to bug #43784 2015-03-06 20:58:30 +01:00
sg
b62f443be5 Fixed comment for NETIF_FLAG_UP after fixing bug #37068 2015-03-06 20:49:47 +01:00
sg
553c4203ab tcp/udp_netif_ipv4_addr_changed(): don't change specific-address of local tcp_listen/udp_pcb to ANY on address change 2015-03-06 20:25:51 +01:00
Sylvain Rochet
89434f6a2f PPP, CORE, call netif_set_up() after if4_up and if6_up flags are set, to prevent dropping packets
lwIP core might send packet when calling netif_set_up(), don't drop packets
anymore in ppp_netif_output_ip4() and ppp_netif_output_ip6() because flags
are cleared.
2015-03-05 22:00:11 +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
72dcdb7655 fixed bug #43784 (a host should send at least one Router Solicitation) 2015-03-04 21:21:49 +01:00
sg
db5510b866 init.c: raise an error if LWIP_PPP_API==1 but PPP_SUPPORT==0 2015-03-04 21:10:29 +01:00
sg
61e0efa0c7 fixed bug #41094 (Byte-order bug in IPv6 fragmentation header test) 2015-03-04 21:02:52 +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
sg
90a0590de1 patch by Zach Smith: fixed bug #38153 (nd6_input() byte order issues) 2015-03-04 20:49:02 +01:00
Sylvain Rochet
b09c891290 PPP, PPPoE, removed devname variable from pppoe_disc_input()
Only used for debug, reworked in a more clever way. It was actually broken
by design: setting an interface integer into a string without formatting
was quite a dumb idea.
2015-03-02 00:45:19 +01:00
Sylvain Rochet
d28bb04a9c PPP, PPPoE, improve reliability if we receive a PADT
Don't disconnect when we receive a PADT, we let the LCP Echo/Reply find
the fact that PPP session is down. Asking the PPP stack to end the
session require strict checking about the PPP phase to prevent endless
disconnection loops.

Luckily it previously does nothing because PADT frames are rarely sent
with a hunique tag and we only set the sc pointer if we receive a
hunique tag.
2015-03-02 00:16:25 +01:00
Sylvain Rochet
9de1c71ff7 PPP, PPPoE, removed global static buffer only used for debug
pppoe_error_tmp[] was only used in one function and only for debug purposes,
moved to stack.
2015-03-02 00:05:55 +01:00
Sylvain Rochet
3ce6dd166c PPP, L2TP, added link-level IPv6 support 2015-03-01 22:04:24 +01:00
Sylvain Rochet
684bef066f PPP, L2TP, merged common output code
New function: pppol2tp_udp_send(), common output code.
2015-03-01 21:22:21 +01:00
Sylvain Rochet
52f2221be9 PPP, L2TP, check source ip address and port
Improve L2TP defensiveness by checking source ip address and port
of input packets.
2015-03-01 21:15:15 +01:00
Sylvain Rochet
1bee131d52 PPP, L2TP, using LNS chosen destination port
L2TP LNS might chose its own local port, we actually stored
the port the LNS wanted to use but we never used it.
2015-03-01 21:14:52 +01:00
Sylvain Rochet
2731976a95 PPP, renamed ppp_open to ppp_connect
Makes it clear we are initiating the PPP session with ppp_connect
(i.e. acting as a PPP client) so there is no confusion possible
between ppp_connect and ppp_listen.
2015-03-01 10:53:08 +01:00
Sylvain Rochet
f7d5e81130 PPP, SERVER, MSCHAP: move output message from chap_server.message struct to stack
chap_server.message is only used in one function, moved to stack.
2015-03-01 00:34:00 +01:00
Sylvain Rochet
371bc91d73 PPP, SERVER: added PPPoS server support
New function: ppp_listen(), listen for an incoming PPP connection.
2015-02-28 22:41:18 +01:00
Sylvain Rochet
89771de6d0 PPP, remove VJ callback from link_callbacks if VJ support is not enabled 2015-02-28 21:39:32 +01:00
Sylvain Rochet
71b213df63 PPP, EAP: using MAXNAMELEN define instead of hardcoded 256 size for rhostname 2015-02-28 20:37:41 +01:00
Sylvain Rochet
7f3913ff58 PPP, EAP: removed malloc() and free()
Replaced pcb->eap.es_{client,server}.ea_peer pointer to a char table,
replaced strdup() with MEMCPY, etc.
2015-02-28 20:29:40 +01:00
Sylvain Rochet
d884034c9f PPP, replaced drand48() with magic_pow() 2015-02-28 19:50:25 +01:00
Sylvain Rochet
bec199c4a2 PPP, MAGIC: new function: magic_pow
magic_pow() returns a new random number between 0 and (2^pow)-1 included.
2015-02-28 19:36:03 +01:00
Sylvain Rochet
3686110ed2 PPP, SERVER: statically define our name for authentication purposes
We don't need that in RAM nor a pointer to a string, a static
define is fine for embedded devices, saved ~257 bytes of RAM.
2015-02-28 18:28:07 +01:00
Sylvain Rochet
708e421ec3 PPP, CORE: code cleaning 2015-02-28 18:08:37 +01:00
Sylvain Rochet
5ae7ee5276 PPP, SERVER: added CHAP authentication support 2015-02-28 17:40:07 +01:00
Sylvain Rochet
65493b421a PPP, SERVER, CHAP: fixed wrong pointer used on chap_timeout() 2015-02-28 15:36:35 +01:00
Sylvain Rochet
301511a840 PPP, SERVER: added PAP authentication support
New ppp auth function: auth_check_passwd() which check the user name and
passwd against configuration.

PAP: check remote user and password
2015-02-28 14:40:09 +01:00
Sylvain Rochet
e86a0a4325 PPP, CORE, SERVER, set auth configuration before auth
Set LCP wanted options accordingly to the user auth configuration
if peer is required to authenticate itself.
2015-02-28 13:08:20 +01:00
Sylvain Rochet
8d05279599 PPP, CORE, moved auth configuration from auth_reset() to lcp_resetci()
Prepare for PPP_SERVER support, we need to move auth configuration before
lcp_allowoptions is copied into lcp_gotoptions. Restore unused
auth_reset() function using pppd original source code.
2015-02-28 12:59:29 +01:00
Sylvain Rochet
587e0e3e0c PPP, CORE, beautified ppp_set_auth()
Beautified, added PPPAUTHTYPE_MSCHAP_V2 choice support.
2015-02-27 23:55:18 +01:00
Sylvain Rochet
2315f32ca0 PPP, CORE, cleaned struct ppp_settings coding style 2015-02-27 23:12:03 +01:00
Sylvain Rochet
5a71509353 PPP, CORE, IPCP: removed useless ask_for_local boolean
We don't need ask_for_local boolean, this is only useful for setup which
can determine the local IP address from the system hostname, which is
probably meaningless for embedded devices (and probably any devices).

It was actually only set by ip_check_options() which is commented out in
lwIP because we don't parse a config file nor check PPP configuration
(user is responsible about writing a configuration which is logical ;-).
Furthermore ask_for_local boolean never set actually had the wrong
default for PPP server setups.
2015-02-27 22:39:42 +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
0d1606ff23 Fixed last commit: can only check for bound sockets, not for unbound. There's some work to do for IPv6 in TCP... 2015-02-26 21:31:48 +01:00
sg
a6a92d42f9 Fixed bug #41700 (Call to tcp_listen_dual() should not accept IPv4 listen PCB args) 2015-02-26 21:23:40 +01:00
Sylvain Rochet
2aabe16163 PPP, PPPoS, removed ppp_accm_mask[], saved a few bytes of ROM
This was a pretty naive way of doing a bitshift, code is smaller if we let
the compiler decide.
2015-02-25 23:04:55 +01:00
sg
5984c996a8 fixed bug #40177 (System hangs when dealing with corrupted packets), implemented task #12357 (Ensure that malicious packets don't assert-fail): improved some pbuf_header calls to not assert-fail. 2015-02-25 22:58:27 +01:00
sg
c8d126f6ef work on task #12357 (Ensure that malicious packets don't assert-fail): don't let too short IP packets assert-fail; fix that IPv6 input did not obey VLAN header offset 2015-02-25 22:23:12 +01:00
Joel Cunningham
9004554da3 fixed bug #43028 (IP_MULTICAST_TTL affects unicast datagrams) 2015-02-25 21:59:21 +01:00
Greg Renda
4eb9efdd33 fixed bug #38210 (ip reassembly while remove oldest datagram) 2015-02-25 21:43:39 +01:00
sg
83740d81f2 fixed comment 2015-02-25 21:32:33 +01:00
sg
c8581e4cd9 fixed bug #38165 (socket with mulicast): ensure igmp membership are dropped when socket (not netconn!) is closed. 2015-02-25 21:30:22 +01:00
sg
612e33c499 fixed bug #38061 (wrong multicast routing in IPv4) by adding an optional default netif for multicast routing 2015-02-25 20:58:11 +01:00
sg
3e8ac30940 Fixed bug #44297 (CORE_LOCKING was broken some days ago); fixed that netconn_connect still used message passing for LWIP_TCPIP_CORE_LOCKING==1 2015-02-25 20:34:18 +01:00
Sylvain Rochet
4bcddd72e6 PPP, CORE, cleaned ppp_close() function
Calling new_phase() instead of assigning pcb->phase directly.
Removed redundant call to link status callback.
2015-02-24 22:13:04 +01:00
Sylvain Rochet
00bb70a62d PPP, CORE, functions ppp_set_netif_statuscallback() and ppp_set_netif_linkcallback() replaced with defines
PPP is now pointerful for a while, we don't need anymore accessor functions
for the unique PPP local and static control block. Replaced
ppp_set_netif_statuscallback() and ppp_set_netif_linkcallback() functions to
defines.

Removed pppapi_do_ppp_set_netif_statuscallback() and
pppapi_do_ppp_set_netif_linkcallback(), they were useless because
netif_set_status_callback() and netif_set_link_callback() can be
safely called while PPP status is in dead (= non open) state
and even before the PPP session is actually created at all.
2015-02-24 20:41:47 +01:00
Sylvain Rochet
b4990b5bb4 Fixed warnings on whole project introduced by const pointers on ip_addr_t 2015-02-22 22:50:06 +01:00
Sylvain Rochet
65095253a9 PPP, fixed warnings introduced by const pointers on ip_addr_t 2015-02-22 22:38:02 +01:00
sg
c87efb77bc patch by Jens Nielsen: fixed bug #38803 (Source address in broadcast ping reply) 2015-02-22 22:02:17 +01:00
sg
03159254ce added proper accessor functions for pcb->multicast_ip (previously used by get/setsockopt only) 2015-02-22 21:49:46 +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
Sylvain Rochet
df3f05e824 PPP, apply warnings found by MSVC fixes on other files needing the same fix 2015-02-22 21:39:04 +01:00
sg
9a10afbbc6 PPP: fixed 2 warnings found by MSVC 2015-02-22 21:30:17 +01:00
Sylvain Rochet
8d916b8573 PPP, PPPoS, removed unused next field in pppos_pcb
Linked list was removed, we don't need the next pointer anymore.
2015-02-22 16:57:57 +01:00
Sylvain Rochet
653657ae43 PPP, code cleaning 2015-02-22 16:45:38 +01:00
Sylvain Rochet
b0b7240022 PPP, PPPoS, moved advise about modem from pppos_create() to ppp_open()
pppos_create() can be called whether the modem is ready to process the
PPP session since pppos_create() does not start the PPP session anymore,
moved the advise from pppos_create() to ppp_open().
2015-02-22 16:20:03 +01:00
Sylvain Rochet
1e82003bf9 CORE, INIT, fail if none of PPP_IPV[46]_SUPPORT are enabled if PPP_SUPPORT is enabled
PPP_SUPPORT needs PPP_IPV4_SUPPORT and/or PPP_IPV6_SUPPORT turned on.
2015-02-22 14:30:24 +01:00
Sylvain Rochet
4be7fccad3 PPP, CORE, ppp_close() and ppp_sighup() ended up sharing almost everything, merged
Merged ppp_sighup() to ppp_close() using an optional argument  "nocarrier"
on ppp_close().
2015-02-22 14:25:36 +01:00