Commit Graph

5982 Commits

Author SHA1 Message Date
Dirk Ziegelmeier
79cd89f99d Fix possible NULL pointer dereference in autoip_start()
autoip variable is dereferenced (autoip->state) before it is checked for NULL pointer
2019-08-28 07:24:31 +02:00
Joan Lledó
7fd158a109 Make socket functions depend on LWIP_SOCKETS
* Socket functions definitions moved out of the
  #define LWIP_SOCKET_EXTERNAL_HEADERS as all users who
  set LWIP_SOCKETS to 1 will need them regardless they use
  lwip's or external socket headers.
2019-08-16 10:59:31 +02:00
Joan Lledó
785b7aba3c Sockets: Unit tests and apps corrections
* Include lwip/inet.h in some unit tests and apps
  * Since they use htons() and pals.
* test/unit/api/test_sockets.c:
  * write() could be declared by external socket headers
    * Call lwip_write() instead.
  * Code expects fcntl() to return 6
    * But O_RDWR could have another value if external
      socket headers are present
    * Replace 6 by O_RDWR.
* apps/tftp/tftp.c:
  * recv() could be declared by external socket headers
    * Rename it to tftp_recv()
2019-08-11 20:12:47 +02:00
Joan Lledó
f92d6702bc Sockets: declare msghdr->msg_iovlen as msg_iovlen_t
* Lwip declares msghdr->msg_iovlen as int, but when
  using external socket headers, some systems declare
  msg_iovlen as size_t or others.
* This patch creates a new type msg_iovlen_t and
  expects users to typedef it to the type they need
  for their system.
2019-08-11 20:12:02 +02:00
Simon Goldschmidt
602a66fe58 sockets: convert _HAVE_SA_LEN to lwip style 2019-08-01 21:04:06 +02:00
Joan Lledó
f126750ccd Add support for struct sockaddr with no sa_len field.
Lwip's struct sockaddr includes sa_len, but some systems
like Linux doesn't have this filed, which produces many
compilation problems when using external headers.

A set of macros has benn added to detect the absence of
sa_len and adapt sockets.c
2019-08-01 20:49:54 +02:00
Simon Goldschmidt
c53a8444e8 dhcp: don't use LWIP_ERROR in dhcp_parse_reply()
See bug #56643

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-26 20:43:08 +02:00
Simon Goldschmidt
6b3ed88d9c ALTCP_TLS_MBEDTLS: include mbedtls/net_sockets.h instead of deprecated mbedtls/net.h
See patch #9815

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-26 20:29:27 +02:00
Joan Lledó
fa6f8054eb Move LWIP_MARK_TCPIP_THREAD to include/lwip/sys.h
* LWIP_MARK_TCPIP_THREAD moved to include/lwip/sys.h
* Unix port macro definitions moved to sys_arch.h
  * LWIP_MARK_TCPIP_THREAD
  * LOCK_TCPIP_CORE
  * UNLOCK_TCPIP_CORE

(goldsimon@gmx.de: fixed unix Makefile build and win32 build)
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-26 20:09:40 +02:00
Freddie Chopin
8291ff3dc0 Fix definition of LWIP_NUM_SYS_TIMEOUT_INTERNAL
In timeouts.c commit 7d1c26cc0c replaced
timeout for AUTOIP with a timeout for ACD, however the value of
LWIP_NUM_SYS_TIMEOUT_INTERNAL was not updated and still counts
LWIP_AUTOIP instead of LWIP_ACD. If user has AUTOIP disabled (or not
explicitly enabled) and DHCP enabled, then ACD gets automatically
enabled too. In this case there will be one timeout too little for lwIP
and first TCP packet received causes an assertion.

Also add LWIP_IPV6_DHCP6 to the value of LWIP_NUM_SYS_TIMEOUT_INTERNAL,
as it was also not accounted for.
2019-07-26 19:44:35 +02:00
Joan Lledó
9dca4a0211 New function tcpip_callback_wait() * Call a function inside the tcpip thread and block the calling thread until the callback finishes.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-07-13 20:52:48 +02:00
Joan Lledó
3546a0a4a0 IF_NAMESIZE: define it only if it's not defined before by system headers 2019-07-13 20:49:48 +02:00
Simon Goldschmidt
5465fdfd69 netconn: add callback arg storage
This reuses the member 'int socket' by making it a union containing
both int and void pointer.

See bug #56593.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
Suggested-by: Wilfred <wilfrednilsen@hotmail.com>
2019-07-13 20:46:36 +02:00
Simon Goldschmidt
f37925dad2 api_lib: fix duplicate NULL check with sys_sem_valid() 2019-07-10 21:55:28 +02:00
Simon Goldschmidt
aa545fbbc6 LWIP_NETCONN_FULLDUPLEX is not alpha any more 2019-07-10 21:14:35 +02:00
Giuseppe Modugno
832490eec8 Added the configuration option ALTCP_MBEDTLS_AUTHMODE to set the certificate verification mode.
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-06-11 21:15:45 +02:00
Giuseppe Modugno
edeeef0d20 mqtt: fix ping request coming too late
See bug #56022 and patch #9813

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-06-11 21:13:05 +02:00
Axel Lin
b3a939417e sockets: Get rid of sock_set_errno
The err field is removed from struct lwip_sock since commit e0a2472706
("netconn/sockets: remove fatal error handling, fix asynchronous error handling, ensure data before RST can be received")
sock_set_errno() simply calls set_errno() now, so use set_errno() instead.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Dirk Ziegelmeier <dziegelmeier@de.pepperl-fuchs.com>
2019-05-06 19:47:56 +08:00
Dirk Ziegelmeier
0255106d55 Fix bug #56136: The netif->mtu6 was updated by Router Advertisement abnomally
Using patch from Gao Quingahui plus improvement
2019-05-06 12:37:19 +02:00
Our Air Quality
ff17530997 mdns mdns_search_service mdns_search_stop: define the request id as unsigned. 2019-04-30 14:53:58 +02:00
Dirk Ziegelmeier
3d7ff53070 Apply patch for bug #56098: Support for MQTT over TLS port 443 instead of 8883 2019-04-30 13:22:09 +02:00
Dirk Ziegelmeier
295996f912 Apply patch for bug #56239: compile fail when disable TCP 2019-04-30 13:16:30 +02:00
Dirk Ziegelmeier
534d3a794c Minor compile fix for last commit 2019-04-30 13:05:50 +02:00
David Girault
fc8f6e8fd9 mqtt: fix first packet checking which fail if MQTT_VAR_HEADER_BUFFER_LEN > 1516
If client reception buffer is bigger than the first frame we receive, the first packet test
will always fail for the second one if it is shorter the the diffence between reception
buffer size and first frame length.

For example, if we receive a PUBLISH message with length = 1517 (payload len = 1514 +
header len = 3), this result in total message length of 1517.

altcp_tls will send MQTT client frame up to 1516 bytes max. This result to PUBLISH
message splitted in two frame: first is 1516 bytes, the second of 1 bytes.

If MQTT_VAR_HEADER_BUFFER_LEN is 1520 (1516 + 4 bytes for stored fixed header), the
second frame of 1 bytes is considered as first publish frame because
client->msg_idx (1517) < MQTT_VAR_HEADER_BUFFER_LEN (1520).

This result in disconnection AND application callback never called for the end of the
payload.

The fix will check `(client->msg_idx - (fixed_hdr_len + length)) == 0` which can be
only true for the first frame of a message.

Below logs showing the bug:
```
April 3rd 2019, 23:14:05.459    lwip_dbg    mqtt_parse_incoming: Remaining length after fixed header: 1514
April 3rd 2019, 23:14:05.460    lwip_dbg    mqtt_parse_incoming: msg_idx: 1516, cpy_len: 1513, remaining 1
April 3rd 2019, 23:14:05.460    lwip_dbg    mqtt_incomming_publish: Received message with QoS 1 at topic: v2/inte...
April 3rd 2019, 23:14:05.461    lwip_dbg    mqtt_parse_incoming: Remaining length after fixed header: 1514
April 3rd 2019, 23:14:05.461    lwip_dbg    mqtt_parse_incoming: msg_idx: 1517, cpy_len: 1, remaining 0
April 3rd 2019, 23:14:05.461    lwip_dbg    mqtt_message_received: Received short PUBLISH packet
```
2019-04-30 12:57:48 +02:00
David Girault
df0699c143 mqtt: support mostly zero-copy message analysis
also ensure no parts of message are lost because cpy_len != buffer_space!
2019-04-30 12:57:40 +02:00
Our Air Quality
156bb74d17 mdns_resp_add_service: simplify the max services guard. 2019-04-30 12:41:19 +02:00
Our Air Quality
224b884c1e mDNS: output search queries to the IP v4 and v6 groups.
These had been broadcasting to the *_ANY addresses.
2019-04-30 12:38:07 +02:00
Our Air Quality
c156cd2a33 ND6: add an explicit queue size check.
When using the MEMP_MEM_MALLOC option, memp_malloc() can not be relied on to
limit the number of allocations allowed for each MEMP queue, as the ND6 code
had been. This caused the ND6 queue to keep growing until the heap allocation
failed when using the MEMP_MEM_MALLOC option. So add an explicit queue size
check in ND6.
2019-04-30 12:34:43 +02:00
Our Air Quality
46bbfe4ee2 mdns: defined the service slot id as unsigned rather than signed. 2019-04-30 12:33:22 +02:00
Our Air Quality
2229c51704 mdns_search_service: simply the search for a free slot. 2019-04-30 12:29:43 +02:00
Our Air Quality
af5906370f mDNS: change some debug line terminations to just newlines.
Some of there were using carriage-return and newline, yet the
rest of the code base consistently uses only newline.
2019-04-30 12:29:08 +02:00
Freddie Chopin
ec11b289cb Fix and simplify newlines in doxygen documentation
Replace '\n' with '<br>', as this allows doxygen to understand reference
names followed by newline. For some cases just drop the newline if it's
not required.

Doxygen 1.8.15 doesn't like if the name of reference is followed by
anything else than (selected?) punctuation or whitespace.

bug #56004
2019-03-28 08:18:20 +01:00
Freddie Chopin
c594599350 Fix doxygen @ref in altcp.c
Doxygen 1.8.15 doesn't like if the name of reference is followed by
anything else than (selected?) punctuation or whitespace.

bug #56004
2019-03-28 08:18:19 +01:00
Dirk Ziegelmeier
53818ad3e4 Add #define for minimum IPv6 MTU length 2019-03-28 08:16:47 +01:00
Dirk Ziegelmeier
ecd8c5b936 Fix bug #55702: SSI bug
Apply patch from Stanislav
2019-03-24 21:47:56 +01:00
Dirk Ziegelmeier
d0d86b5ba1 Fix compile of last patch 2019-03-24 21:46:43 +01:00
Dirk Ziegelmeier
aa7009b2fc Fix bug #55972: The Neighbour Solicitation used to do IPv6 address resolution was wrong
Apply patch from Gao Qingshui
2019-03-24 21:34:08 +01:00
Dirk Ziegelmeier
4f6fd6c845 Fix bug #55973: The parsing of max response time in MLD Query message was wrong
Apply patch from Gao Qingshui
2019-03-24 21:32:26 +01:00
Dirk Ziegelmeier
4b10b4dab3 Add note about MEMP_NUM_SYS_TIMEOUT in four apps 2019-03-20 20:50:17 +01:00
Simon Goldschmidt
3b5eb7ca90 udp_bind: fix missing parenthesis warning
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-02-27 10:29:55 +01:00
Simon Goldschmidt
752cdb1a53 udp: fix udp_bind for IPADDR_TYPE_ANY
See bug #55171

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2019-02-26 14:48:44 +01:00
Dirk Ziegelmeier
e479bd56df Fix LWIP_ERROR macro - it should never be fatal (LWIP_ASSERT)
The only difference should be:
- LWIP_DEBUG enabled  -> print a diag message
- LWIP_DEBUG disabled -> NO diag message is printed
2019-02-08 12:29:05 +01:00
Dirk Ziegelmeier
27c226b5d6 Fix a few documentation errors in MDNS 2019-02-02 22:44:57 +01:00
Solganik Alexander
b1d3dcb8d7 tcp: don't reset dupack count upon non-empty packet receive
According to rfc5681:

https://tools.ietf.org/html/rfc5681

Paragraph 3.2.  Fast Retransmit/Fast Recovery
The TCP sender SHOULD use the "fast retransmit" algorithm to detect
and repair loss, based on incoming duplicate ACKs.  The fast
retransmit algorithm uses the arrival of 3 duplicate ACKs (as defined
in section 2, without any intervening ACKs which move SND.UNA) as an
indication that a segment has been lost.  After receiving 3 duplicate
ACKs, TCP performs a retransmission of what appears to be the missing
segment, without waiting for the retransmission timer to expire.

Now consider the following scenario:
Server sends packets to client P0, P1, P2 .. PK.
Client sends packets to server P`0 P`1 ... P`k.

I.e. it is a pipelined conversation. Now lets assume that P1 is lost, Client will
send an empty "duplicate" ack upon receive of P2, P3... In addition client will
also send a new packet with "Client Data", P`0 P`1 .. e.t.c. according to sever receive
window and client congestion window.

Current implementation resets "duplicate" ack count upon receive of packets from client
that holds new data. This in turn prevents server from fast recovery upon 3-duplicate acks
receive.
This is not required as in this case "sender unacknowledged window" is not moving.

Signed-off-by: Solganik Alexander <sashas@lightbitslabs.com>
2019-01-30 21:13:22 +01:00
Simon Goldschmidt
5666f305ce sntp: obey KoD when using multiple servers
See bug #55253 (SNTP retry next server instantly result as a flood of NTP request).
Added 'sntp_getkodreceived()' to check the status.
2019-01-30 20:42:56 +01:00
Simon Goldschmidt
8e86555f93 mdns: fix compiler errors and coding style 2019-01-30 20:15:26 +01:00
David Girault
b4be0d8808 mdns: added support for searching services
Two new API:
err_t mdns_search_service(const char *name, const char *service, enum mdns_sd_proto proto,
                          struct netif *netif, search_result_fn_t result_fn, void *arg,
                          s8_t *request_id);
void mdns_search_stop(s8_t request_id);

One compilation flags:
LWIP_MDNS_SEARCH

One options flags:
MDNS_MAX_REQUESTS

Some structure declarations moved to allow use by callback result function.

Result domain names are early uncompress before calling application callback
because it cannot be made by application itself.

Allow search services with multiples labels included, like '_services._dns-sd'.

Search for `_services._dns-sd._udp.local.` is handled in a special way.
Only `PTR` answers are send back to the application.

The `mdns_search_service()` function won't assert if no more space in `mdns_request`
table, just return an error if too many simultanous requests.
2019-01-30 20:05:51 +01:00
Ivan Warren
9263d44847 Small documentation fix for TFTP
Apparently the TFTP server now also invokes the error() function in the
tftp_context struct.

Some tftp clients (for example Windows 10 TFTP client) will open the
remote file before checking the local file can be opened - and will then
send an error indication to the server to indicate there was an error
opening the local file. When the happens, the LWIP tftp server will
invoke the error() member of the tftp_context.
2019-01-30 19:56:49 +01:00
David J. Fiddes
8f2f43f093 Implement RFC4075 Receive SNTP servers via DHCPv6
This adds support for RFC4075 SNTP server configuration via DHCPv6.
The DHCPv6 options transmitted are now conditional on how LwIP is
configured.

A new SNTP application option SNTP_GET_SERVERS_FROM_DHCPV6 is used
to enable. For simplicity this is configured to use the global
LWIP_DHCP6_GET_NTP_SRV configuration setting.

Tests:
 - Check the global options now control the DHCPv6 request sent
   in Wireshark
 - Check against 0, 1 and 3 SNTP servers configured on an odhcpd
   server configured to support RFC 4075 SNTP server lists.
   Verify that the SNTP server list is updated on connection
   establishment on an ESP8266 WeMOS D1.
 - Verify that SNTP packets are sent and recieved from a
   configured server and that system time is updated.

Signed-off-by: David J. Fiddes <D.J@fiddes.net>
2019-01-30 17:49:18 +01:00
David Girault
3cb6ae7770 altcp_tls: assert in altcp_mbedtls_bio_recv if bad state 2019-01-30 17:42:52 +01:00
David Girault
b04d8a6a6c altcp: support for setting keepalive parameters 2019-01-30 17:42:46 +01:00
David Girault
b298afabdc altcp_tls_mbedtls: remove entropy/ctr_drbg from altcp_tls_config struct
Use only one entropy/ctr_drbg context for all altcp_tls_config structure allocated.

(Small adjustments before committing: fix coding style, adapt to changes in master)
2019-01-30 17:42:39 +01:00
David Girault
2cc420e434 mqtt: remove bad assert in mqtt_message_received()
- client->msg_idx can be > MQTT_VAR_HEADER_BUFFER_LEN in long message splitted in multiple pbufs
- renamed fixed_hdr_idx to fixed_hdr_len because it is length of fixed header in rx_buffer, not an index to it
- removed the cpy_start as data always copied right after the fixed header
2019-01-30 14:29:21 +01:00
Simon Goldschmidt
ed561a578b tcp: improve debug message a little 2019-01-30 14:27:16 +01:00
Dirk Ziegelmeier
4c19a909c2 Fix bug #55537: Crash in SYN_SENT state when TCP_INPUT_DEBUG logs are ON 2019-01-28 14:21:34 +01:00
Dirk Ziegelmeier
941300c21c Apply patch #9737: Fix DHCPv6 DNS server assignment 2019-01-28 14:19:15 +01:00
Dirk Ziegelmeier
3efc43531b Fix bug #55536: lwIP 2.1.2: netconn_delete() called twice from lwip_accept()
netconn is deleted in free_socket() call
2019-01-28 14:13:52 +01:00
Dirk Ziegelmeier
8bf2e21b4d TCP/UDP documentation: Add reference to PCB mempool #defines 2019-01-28 13:47:03 +01:00
Dirk Ziegelmeier
926e399355 Fix bug #55513: Uninitialized variable in struct netconn
using patch from Karol Domagalski
2019-01-18 20:51:58 +01:00
Dirk Ziegelmeier
ea14b774c8 Replace several occurences of stdint types by lwIPs portability typedefs
Fixes bug #55405: Usage of uint8_t instead of ui8_t in TCP code
2019-01-06 21:19:04 +01:00
Dirk Ziegelmeier
d504e27142 dhcp.c: Fix typo in debug message 2019-01-04 11:08:46 +01:00
Jacob Kroon
c02fea0961 PPP, PPPoE: use service name and concentrator name
Make pppoe_create() actually store the passed service name and
concentrator name, so that they are passed in the PADI/PADR/PADS
packets.

Assume that the user application won't be freeing the strings and just
copy the string pointers, therefore remove the mem_free() in
pppoe_destroy().

Since only the pointers are copied now, make them 'const' in
pppoe_softc.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-20 13:24:04 +01:00
Sylvain Rochet
48615984c7 PPP, PPPoE: remove leftover from PPPOE_SCNAME_SUPPORT support
Stupid me managed to push a pending patch, remove it.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:19:37 +01:00
Jacob Kroon
7eab5947af PPP, PPPoE: fix build when PPPOE_SCNAME_SUPPORT is defined
lwip/src/netif/ppp/pppoe.c:768:24: error: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Werror=poin$
     l1 = (int)strlen(sc->sc_service_name);
lwip/src/netif/ppp/pppoe.c:772:24: error: pointer targets in passing argument 1 of ‘strlen’ differ in signedness [-Werror=poin$
     l2 = (int)strlen(sc->sc_concentrator_name);

sc->sc_service_name and sc->sc_concentrator_name are best defined as
char* because there are passed to libc strings functions which expect
a char*.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:13:46 +01:00
Sylvain Rochet
96548ede2b PPP, PPPoE: rename PPPOE_TODO to PPPOE_SCNAME_SUPPORT, prepare service name and concentrator support
Rename PPPOE_TODO to PPPOE_SCNAME_SUPPORT because this is the only
feature enclosed by them. Prepare for proper service name and
concentrator name support by moving PPPOE_SCNAME_SUPPORT define to
ppp_opts.h.

Signed-off-by: Sylvain Rochet <gradator@gradator.net>
2018-12-18 22:09:48 +01:00
Dirk Ziegelmeier
2ff0db9a9b Fix bug #55171: Binding UDP PCB with different IP type PCBs does not work
by additionally checking IP address type
2018-12-06 14:40:57 +01:00
Jasper Verschueren
75f33081c2 DEF: added lwip_strnistr() for case insensitive matching 2018-12-05 19:59:45 +01:00
Simon Goldschmidt
dcb29c591f nd6: fix copying more than one DNS server
See bug #55163
2018-12-05 19:56:48 +01:00
Simon Goldschmidt
282389a332 altcp_tls_mbedtls: listen: free members of the ssl context
The ssl context is not used on listening pcbs. This includes freeing
input/output buffers, so saves ~32KByte by default.
2018-12-03 07:14:02 +01:00
Dirk Ziegelmeier
781a4ccb62 mdns_domain.c: Fix doxygen comments 2018-11-25 14:39:31 +01:00
Dirk Ziegelmeier
92a18bf638 Fix bug #55078: Add custom data to pbuf struct
Add a #define that users can use to store custom data on a pbuf
2018-11-25 14:01:23 +01:00
Simon Goldschmidt
3f583a1757 altcp_tls: add functions to create servers with multiple certificates 2018-11-24 13:41:34 +01:00
Simon Goldschmidt
6f232b7c3f altcp_tls_mbedtls: add session tickes, improve configuration for session cache 2018-11-23 22:39:58 +01:00
Simon Goldschmidt
54448559bb altcp_tls_mbedtls: add debug output of mbedtls library 2018-11-23 22:25:21 +01:00
Simon Goldschmidt
7859c6832b makefsdata: fix compiling for win32 2018-11-23 12:59:07 +01:00
Axel Lin
d116d235a5 apps/smtp: Remove redundant LWIP_ASSERT checking in smtp_send_mail_bodycback
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-11-23 19:28:24 +08:00
Dirk Ziegelmeier
b1fbb5ad45 Fix warnings about ignored return values in makefsdata.c
These only show up when compiling with -O3
2018-11-22 21:53:12 +01:00
Dirk Ziegelmeier
e31f1b918c mdns.c: Fix accessing potentially uninitialized variable
myprobe_inpkt.pbuf may not be set to NULL in mdns_handle_probe_tiebreaking()
2018-11-22 13:36:20 +01:00
Dirk Ziegelmeier
45a055840d snmp_traps.c: Portability fix: Don't use non-constant initializers 2018-11-22 13:25:43 +01:00
Craig McQueen
ef76bbe3f0 DNS: Allow a DNS look-up with a trailing dot in the name
Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-11-22 13:14:41 +01:00
Simon Goldschmidt
9071db11af snmp: don't allocat outbound msg for GET RESP (inform cb) 2018-11-22 12:54:50 +01:00
Simon Goldschmidt
ed59260b92 snmp: fix coding style
no need to initialize global static variables to NULL
2018-11-22 12:51:46 +01:00
Dirk Ziegelmeier
c23aa713f9 Try to fix compile warning in mdns.c
src/apps/mdns/mdns.c: In function 'mdns_debug_print_answer':
src/apps/mdns/mdns.c:796:24: warning: ', rdata = ' directive output may be truncated writing 10 bytes into a region of size between 8 and 15 [-Wformat-truncation=]
   snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
src/apps/mdns/mdns.c:796:3: note: 'snprintf' output between 31 and 38 bytes into a destination of size 35
   snprintf(string, 35, "Type = %2d, class = %1d, rdata = ", a->info.type, a->info.klass);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-11-22 11:37:24 +01:00
Dirk Ziegelmeier
10e0130a4a netbiosns_name_decode: Take CONST char* as first argument 2018-11-21 21:03:36 +01:00
Jens Nielsen
b0c753da96 Fix netbiosns expecting too large packet 2018-11-21 20:50:35 +01:00
Dirk Ziegelmeier
30b2d07362 Fix compile error with GCC 8 in makefsdata
lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:56: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=]
   snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);

/home/dziegel/lwip/lwip/src/apps/http/makefsdata/makefsdata.c:929:3: note: ‘snprintf’ output 2 or more bytes (assuming 257) into a destination of size 256
   snprintf(qualifiedName, sizeof(qualifiedName), "%s/%s", curSubdir, filename);

Reduce subdir string length by 3 bytes to make the warning go away. The whole file path including directory AND filename is limited to MAX_PATH_LEN - so it is reasonable to reserve 3 bytes less for directory - the filename won't fit anyway in the remaining 3 bytes.
2018-11-20 20:34:29 +01:00
Jasper Verschueren
ee1bab3411 mDNS: conflict resolution added
If the host observes a response (after probing) containing RR's
that he thought were unique to him, there is a conflict. If a host
observes such conflict, it resets back to probing and the probing
procedures will resolve the conflict. (RFC6762 section 9)
2018-11-20 12:49:58 +01:00
Simon Goldschmidt
3bd84aba4b snmp_v3: use strlen, not strnlen
strnlen is not portable.
In this case, it does not matter as we zero-terminate the string before.

Signed-off-by: Simon Goldschmidt <goldsimon@gmx.de>
2018-11-19 20:13:30 +01:00
Dirk Ziegelmeier
aa83bdf490 Fix bug #55034: apps/smtp.c fails to compile with strict C compatibility because of strnlen
by replacing strnlen with strlen. It's a user-supplied string, so we can assume it is correctly \0 terminated (as done several times elsewhere in the code)
2018-11-19 14:43:26 +01:00
Dirk Ziegelmeier
4adcd68ce4 Fix compile of mdns.c
Add missing stdio.h for snprintf()
Fix variable declaration in code
2018-11-19 14:32:05 +01:00
Jasper Verschueren
19cbf2a652 mDNS: probe rate limiting if more then 15 conflicts occur in 10s
According to RFC6762 section 8.1:
If fifteen conflicts occur within any ten-second period, then the
host MUST wait at least five seconds before each successive
additional probe attempt.
If the host restarts mDNS, instead of a probe wait timeout randomly
chosen between 0 and 250ms, we wait 5s if more then 15 conflicts
occured in 10seconds. This flag is reset from the moment probing
succeeded.
2018-11-19 14:26:25 +01:00
Jasper Verschueren
593c02aed4 mDNS: probe tiebreaking added
mDNS: first version probe tiebreaking added

This first version works for our MCU boards but does only compare
the first question and answer. It does not sort the list of answers
and it does not search for answers or questions.

mDNS: improved probe question handling

For every probe question in our packet, we check the presence
in the incomming packet until we find a match. then we perform
the tiebreaking. At the moment we still only look at the first
answer.

mDNS: evaluate all answers in the authoritative section

The authoritative sections of both messages are evaluated.
The records that answer the probe question are sorted in to lists.
Then the lists are compared pairwise. A winner and a loser are
chosen and the host reacts on the outcome (ignore or stop probing).

mDNS: add support for name decompression in rdata when comparing.

For probe tiebreaking we need to compare RR's. It is possible that
the rdata of an RR contains compessed names (SRV record). We need
to decompress it first before we do the comparison.
2018-11-19 14:25:31 +01:00
Jasper Verschueren
a09646c507 mDNS: split probe packet definition and split outpkt creation
Probe packet creation -> by splitting the definition and the sending
we can use the definition function for probe tiebreaking.
outpkt creation -> by splitting the creation and sending we can use
the creation function for probe tiebreaking.
2018-11-16 14:52:40 +01:00
Jasper Verschueren
861ce296b9 mDNS: respond to probe via multicast added
The host only responded to a probe query via unicast because
according to the RFC, a probe should have the QU bit on.
This is a should and not a must so we need to be careful.
We added multicast probe answering support with the needed timouts.
Avahi for example probes with the QM queries. With this commit the
conflict is resolved.
2018-11-14 16:52:17 +01:00
Dirk Ziegelmeier
d386388fb5 Move netif_mdns_data() and get_mdns_pcb() to mdns_priv.h 2018-11-13 12:22:24 +01:00
Dirk Ziegelmeier
2adc6d2687 MDNS: Minor compile fix, declare variables before code 2018-11-13 12:20:57 +01:00
Jasper Verschueren
405fc4d802 Revert "mDNS: authority section of probe message needs to contain all records"
This reverts commit e959e6efaf8a1cb57e9a5d4d8e0056c7ea52179f.
2018-11-13 12:18:19 +01:00
Jasper Verschueren
ee7ed8c87d mDNS: cleanup probing and announcing sequence
The implementation was not fully to the standard. This commit adds
a nicer state machine implementation and multiple announce messages
with a minimum of 2.
2018-11-13 12:18:04 +01:00
Jasper Verschueren
65eb36b10d mDNS: ignore responses with src port != 5353 (rfc6762 section 6) 2018-11-13 12:17:38 +01:00
Jasper Verschueren
16da67bb21 mDNS: source address check added
RFC6762 section 5.5 and 11 define that we should check that all
packets originated on the local link.
2018-11-13 12:17:38 +01:00