Commit Graph

578 Commits

Author SHA1 Message Date
Our Air Quality
373bf8c36d Quieten a toupper() compiler warning.
Gcc complains that an array index is a 'char' when passing a 'char' to
toupper(). Quieten this by coercing to an 'unsigned char'.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-04-25 20:39:25 +02:00
Jens Nielsen
c34120e855 TFTP server handle retransmit Data packets
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-04-25 20:29:31 +02:00
goldsimon
b1fe8cf4b8 netbiosns: check question type before generating an answer 2018-04-18 08:17:10 +02:00
goldsimon
f65911a84b netbios: fix response length of node status response 2018-04-18 07:28:41 +02:00
Dirk Ziegelmeier
66800925cf Fix indent in netbiosns.c 2018-04-17 14:08:59 +02:00
Dirk Ziegelmeier
533c97f0c3 Fix bug #53626: NetBIOS Responder generates malformed packet responding to "*" name
Implement corrected answer packet
2018-04-16 10:40:05 +02:00
goldsimon
4cc953d0e3 httpd: fixed compiling makefsdata.c 2018-04-04 21:45:47 +02:00
Ray Abram
b0ae967660 NetBIOS Responder should respond to "*" names
See bug #53325

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-04-03 22:19:18 +02:00
Tom Ferrin
82d8f08451 Add "server reachability" register to SNTP
Guarded with SNTP_MONITOR_SERVER_REACHABILITY (sntp_opts.h).
See patch 9581

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-04-03 21:56:33 +02:00
Tom Ferrin
e46b9ad4ac sntp: store server IP address after DNS lookup
See patch #9612

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-04-03 21:16:05 +02:00
Giuseppe Modugno
2d4da92eeb makefsdata: added options to skip and avoid compressing some extensions
See patch #9605

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-04-03 21:08:25 +02:00
goldsimon
c974fc9d43 http_client: fix compiling if mem_size_t is smaller than size_t 2018-03-21 09:33:00 +01:00
Axel Lin
600527dde7 apps/http: httpd: Fix unused parameter warning if !LWIP_HTTPD_SUPPORT_V09
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-03-21 15:05:33 +08:00
Axel Lin
e19d908f0e apps/http: Fix httpd_structs.h build error
Fixes: bug #53382: HTTPD_ADDITIONAL_CONTENT_TYPES doesn't compile
Reported-by: Giuseppe Modugno <giuseppe.modugno.loqed@gmail.com>
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-03-19 21:08:17 +08:00
goldsimon
253fcc8dcd http_client: call tcp_recved for header bytes
Without this, closing the connection after successful transfer resulted
in a RST being sent because the window was not fully marked as 'recved'.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-03-09 11:30:23 +01:00
goldsimon
61a1b98cc9 various IPv6-only compile fixes 2018-03-07 20:55:00 +01:00
goldsimon
b6d9bb6b2a http_client: check current state when receiving FIN 2018-03-06 21:51:13 +01:00
Axel Lin
53ddb9244b apps/sntp: Trivial build warning fix
Fix below build warning:
../../../../lwip/src/apps/sntp/sntp.c: In function ‘sntp_servermode_dhcp’:
../../../../lwip/src/apps/sntp/sntp.c:726:3: warning: ISO C90 forbids mixed declarations and code [-Wc90-c99-compat]
   u8_t new_mode = set_servers_from_dhcp ? 1 : 0;
   ^~~~

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-03-04 19:18:26 +08:00
goldsimon
0ee0393936 fix compiling http_client and altcp_proxyconnect with gcc 2018-02-22 09:12:51 +01:00
goldsimon
7b9e145fc5 http_client: change user-agent and make it overridable 2018-02-21 20:18:29 +01:00
goldsimon
2753eb1fb1 add an altcp layer for http proxy connect (e.g. to tunnel TLS through a http proxy)
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-21 20:18:05 +01:00
goldsimon
a0e900dd02 makefsdata: update usage output to code 2018-02-21 14:42:47 +01:00
goldsimon
325cdf3c0b altcp_tls_mbedtls: restructure upper callbacks to prevent double-free
This fixes bug #53192: use-after-free in altcp_mbedtls

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-21 14:20:34 +01:00
goldsimon
d66c0e3381 altcp: mbedtls: move freeing state->rx from close to dealloc (catch-all) 2018-02-20 22:12:11 +01:00
goldsimon
842b9f4429 altcp: simplify creating different types by adding an allocator concept
This is done with an example in the http_client

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-19 21:41:48 +01:00
Dirk Ziegelmeier
5b33d33e34 Add HTTP client to documentation 2018-02-19 09:01:44 +01:00
goldsimon
ef29f2d401 http_client: httpc_tcp_recv did not return inner_conn's recv return value
Signed-off-by: goldsimon <goldsimon@gmx.de>
Reported-by: Our Air Quality <info@ourairquality.org>
2018-02-18 09:02:00 +01:00
goldsimon
2648d30843 altcp_tls_mbedtls.c: tiny function rename 2018-02-16 13:57:38 +01:00
goldsimon
bd656efd64 http client: add https support, fix parsing header with chained pbufs 2018-02-16 12:29:40 +01:00
goldsimon
e87392cc85 http client: fix proxy support 2018-02-16 09:18:35 +01:00
goldsimon
3dafa72ec8 apps: add http client
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-15 22:10:29 +01:00
goldsimon
d4c4b0eec5 rename folder 'src/apps/httpd' to 'http'
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-15 20:13:25 +01:00
goldsimon
cd1516e2e4 mqtt: rewrote check for topc_len so that coverity is happy... 2018-02-15 09:15:40 +01:00
Axel Lin
5d5b8fbb46 Fix trivial copy & paste mistake for comment in header files
Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-02-14 22:49:12 +08:00
goldsimon
133bf70ab5 mqtt: slightly change some overflow checks 2018-02-14 12:37:35 +01:00
goldsimon
eea95459c9 mqtt: add more length validity checks in mqtt_message_received
This also (but not only) fixes bug #52345 ("MQTT buffer length check seems wrong")
2018-02-14 12:08:15 +01:00
goldsimon
731336223f mqtt: add comments in mqtt_parse_incoming 2018-02-14 06:54:56 +01:00
goldsimon
e20e9bc3d4 Try to fix issues reported by coverity 2018-02-13 12:09:18 +01:00
goldsimon
010b0210ba netif: ext_callback: make LWIP_NSC_ defines, not an enum; fix mdns accordingly
Re-applied after reverting d6e58d02a6
2018-02-08 12:36:26 +01:00
goldsimon
f201d261b2 Revert "MDNS send probes to verify domain before use"
This reverts commit d6e58d02a6.
Erik seems to have commit this by accident. Let's discuss this first
(see patch #9555)
2018-02-08 12:28:04 +01:00
goldsimon
3cf906e073 Revert "netif: ext_callback: make LWIP_NSC_ defines, not an enum; fix mdns accordingly"
This reverts commit 6934bb4428.
Need to revert commit d6e58d02a6 first, and that one produced merge conflicts.
2018-02-08 12:26:16 +01:00
goldsimon
f7be3d10ae httpd: create "connection" and "content-length" headers when file is ready
see patch #9500
2018-02-07 21:27:42 +01:00
goldsimon
e8d7e82c8c httpd: fix simple typo 2018-02-07 21:19:07 +01:00
goldsimon
6934bb4428 netif: ext_callback: make LWIP_NSC_ defines, not an enum; fix mdns accordingly 2018-02-07 20:35:49 +01:00
goldsimon
ea2e628ac3 httpd: get_http_headers: refactor decision for add_content_len 2018-02-03 21:58:45 +01:00
goldsimon
1a75112b47 httpd: ensure hs->keepalive is 0 if content length is not sent
Connections for custom files without the persistent flag were not
closed without this change.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-03 21:53:44 +01:00
goldsimon
053a5e6e13 httpd: get_http_headers: fix content length check for custom files
Headers are never included here or else get_http_headers would not
have been called.

As a result, custom files need to set FS_FILE_FLAGS_HEADER_PERSISTENT
in file->flags if file->len is the correct length of the file.

See also patch #9500

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-03 21:51:33 +01:00
goldsimon
d5d30d49f2 httpd: check that file data is present when dynamic read is disabled
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-02-02 21:31:36 +01:00
Jens Nielsen
d6e58d02a6 MDNS send probes to verify domain before use 2018-02-02 11:10:09 +01:00
goldsimon
6706b3778e httpd: add "struct file*" parameter to httpd_cgi_handler() callback 2018-02-02 09:29:52 +01:00
Giuseppe Modugno
ab281cb750 httpd: move httpd_cgi_handler() call
This patch moves in advance httpd_cgi_handler() call, before assigning
variables like hs->file and hs->left.

In this way, CGI handler could prepare the reply data and set the
"file properties", like file->data and file->len. At the exit, hs->file
and hs->left is correctly assigned.

The handler prototype says it can't access file pointer, however it is
simple to obtain it after setting LWIP_HTTPD_FILE_STATE that enables a
"file state" pointer. It is sufficient to assign file->state to file
itself in fs_open_custom().

For example, I have the request GET /login.cgi?user=admin&pwd=admin and
I have to reply with some JSON data. The answer depends on parameters
user and pwd passed in the query string.
2018-02-02 09:12:42 +01:00
Axel Lin
2c3c578475 apps/smtp: Fix wrong sizeof for memset s->bodydh
Use sizeof(struct smtp_bodydh_state) to zero all fields of s->bodydh.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2018-01-31 09:07:48 +08:00
Dirk Ziegelmeier
40997c4a08 Apply (modified) patch #9552: tftp_cleanup() for cleanup and filename buffer zeroing to prevent filename bugs
... without the memset to zero out the filename
2018-01-29 06:59:47 +01:00
goldsimon
05ba509e33 mdns: clarify usage of ip_addr_cmp_zoneless() 2018-01-26 06:32:35 +01:00
goldsimon
de68c5bed6 altcp_mbedtls_sndbuf: use mbedtls_ssl_get_record_expansion() 2018-01-25 13:15:49 +01:00
Mike Kleshov
84fcd6290e [patch #9548] Add .json to list of SSI file extensions
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-01-22 19:49:10 +01:00
goldsimon
9dbfa9ca0a lwiperf: enable TCP over IPv6 connections
tested against iperf 2.0.10
redefine LWIPERF_SERVER_IP_TYPE if you don't want both IP versions
2018-01-19 21:08:51 +01:00
goldsimon
a696b2b515 lwiperf: fix testing against iperf 2.0.10 (bug #52901) 2018-01-17 20:54:16 +01:00
goldsimon
8a27408eb2 altcp_tls_mbedtls: hide allocation strategy in altcp_tls_create_config() 2018-01-16 21:41:44 +01:00
David Girault
42f14a96fb altcp_tls: avoid use of static in altcp_tls_config
cert and pkey are allocated with the altcp_tls_config structure.

Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-01-16 21:03:43 +01:00
David Girault
c7106cc57f altcp_tls: fix pbuf leaked when handshake failed
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-01-16 20:56:15 +01:00
Dirk Ziegelmeier
51369854b5 Fix bug #52911: SNMPv3 time window check is not the same as RFC3414 2018-01-16 13:30:31 +01:00
goldsimon
2fd83c9d2e lwiperf: fix double-free of pbufs on recv error 2018-01-16 06:54:28 +01:00
goldsimon
28c8693683 mqtt: fix documentation error (remove ':' after param name) 2018-01-13 16:09:17 +01:00
goldsimon
eb51b683ed fix copy & paste error in comment 2018-01-12 20:29:12 +01:00
Dirk Ziegelmeier
46cb0a796b Forgot to add LWIP_ASSERT_CORE_LOCKED() to http_continue function 2018-01-12 13:35:20 +01:00
Dirk Ziegelmeier
653313cb37 Work on task #14780: Add debug helper asserts to ensure threading/locking requirements are met
Add LWIP_ASSERT_CORE_LOCKED() to several more places
2018-01-12 13:15:36 +01:00
David Girault
6ccd12b97c altcp_mbedtls: added altcp_mbedtls_sndbuf implementation
Signed-off-by: goldsimon <goldsimon@gmx.de>
2018-01-11 10:34:55 +01:00
goldsimon
6b2ef1a89b httpd: fix typo "kepalive" -> "keepalive" 2018-01-04 06:35:00 +01:00
Dirk Ziegelmeier
25f1c6ef2c Revert "Apply patch #9523: MDNS responder should reply after a random timeout"
This reverts commit fa345b0f22.
2018-01-03 07:48:23 +01:00
Dirk Ziegelmeier
3b79c60e41 Revert "Fix build warnings in mdns.c introduced in my last commit"
This reverts commit 744e69334d.
2018-01-03 07:48:12 +01:00
Dirk Ziegelmeier
744e69334d Fix build warnings in mdns.c introduced in my last commit 2018-01-03 06:31:59 +01:00
Dirk Ziegelmeier
fa345b0f22 Apply patch #9523: MDNS responder should reply after a random timeout
with a few cleanups and coding style fixes
2018-01-02 22:20:25 +01:00
Erik Ekman
d87740bb96 mdns: Fix multicast destination check for IPv6
This broke when IPv6 got scopes added. Scopes/zones are checked
even if none of the compared addresses are link local.

Result of the bug was that IPv6 replies were always sent unicast to
the source instead of to the multicast address.

Add ip-generic version that ignores IP zone info, since the v6 group
address is not tied to any netif.
2018-01-02 20:41:50 +01:00
Dirk Ziegelmeier
a8755b8530 Work on bug #52770: mdns: move the announcements to a timer callback
Don't automatically announce when adding netifs/services
2018-01-02 10:59:20 +01:00
Dirk Ziegelmeier
b536fd9767 Apply modified version of bug #52747: mdns resp: separate the announce function and add netifapi support for it
Changes made by me:
- Move all error handling code into mdns_resp_announce() so it can be safely used by external code
- Remove mdns_resp_netif_settings_changed() because it is the same as mdns_resp_announce() after my changes
- Declare #define for a "thread-safe" version of mdns_resp_announce in mdns.h instead of netifapi.h - I don't want to intermix netif API with APPs
2017-12-30 12:08:01 +01:00
Our Air Quality
1b57284bb4 mdns: guard against there being no ip4 address.
* Avoid announcing to an interface with no ip4addr.

* Avoid emitting A answers if there is no ip4 address.
2017-12-30 11:42:46 +01:00
goldsimon
7c1f844782 Fix compiling mdns.c after last change (mixed code and declarations) 2017-12-18 20:06:45 +01:00
goldsimon
2505c6019e httpd: fix the names of some global variables 2017-12-18 20:01:24 +01:00
Mike Kleshov
db68c6df6a httpd: make global variables static
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-12-18 19:57:07 +01:00
Our Air Quality
31c60775b6 mdns: silence some unused variable warnings. 2017-12-17 22:24:49 +01:00
Axel Lin
0527c1bdf5 apps/smtp: Avoid NULL pointer dereference in smtp_send_body_data_handler
Move the code to have NULL test before dereference.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-12-17 22:16:29 +01:00
goldsimon
82483073f0 sntp_send_request: assert that argument 'server_addr' != NULL 2017-12-17 22:13:09 +01:00
Axel Lin
ba270c2414 apps/sntp: Use ip_addr_copy to save server address
Use ip_addr_copy instead of ip_addr_set to avoid NULL test for
&sntp_last_server_address. This fixes build warning when
SNTP_CHECK_RESPONSE>=1 && LWIP_IPV4=1 && LWIP_IPV6=1.

In file included from ../../../../lwip/src/include/lwip/apps/sntp.h:41:0,
                 from ../../../../lwip/src/apps/sntp/sntp.c:52:
../../../../lwip/src/apps/sntp/sntp.c: In function ‘sntp_send_request’:
../../../../lwip/src/include/lwip/ip_addr.h:105:58: error: the comparison will always evaluate as ‘true’ for the address of ‘sntp_last_server_address’ will never be NULL [-Werror=address]
 #define IP_SET_TYPE(ipaddr, iptype)     do { if((ipaddr) != NULL) { IP_SET_TYPE_VAL(*(ipaddr), iptype); }}while(0)
                                                          ^
../../../../lwip/src/include/lwip/ip_addr.h:157:36: note: in expansion of macro ‘IP_SET_TYPE’
 #define ip_addr_set(dest, src) do{ IP_SET_TYPE(dest, IP_GET_TYPE(src)); if(IP_IS_V6(src)){ \
                                    ^~~~~~~~~~~
../../../../lwip/src/apps/sntp/sntp.c:549:5: note: in expansion of macro ‘ip_addr_set’
     ip_addr_set(&sntp_last_server_address, server_addr);
     ^~~~~~~~~~~

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-12-17 22:12:32 +01:00
Joel Cunningham
920ee2d07e sntp: use const for servername
This adds const to the sntp servername get/set API and internal storage

SNTP's usage of this name is read only and SNTP only passes it to dns_gethostbyname()

This was found by compiling with GCC -Wwrite-strings which makes the literal
SNTP_SERVER_ADDRESS a const string. This then produced warnings with sntp_init()'s
call to sntp_setservername()
2017-12-13 11:34:48 -06:00
Axel Lin
ec9f227eae apps/altcp_tls: Remove redundant check for altcp_mbedtls_malloc_clear_stats
No need to check altcp_mbedtls_malloc_clear_stats twice.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-12-05 06:35:44 +01:00
Dirk Ziegelmeier
2ceedfe097 Fix bug #52345: MQTT buffer length check seems wrong
Don't try to parse variable length part if it is not contained in message
2017-11-26 21:05:07 +01:00
Dirk Ziegelmeier
ad47a46815 Revert fix for bug #52345, that was not correct 2017-11-26 20:59:39 +01:00
Axel Lin
6cbee37a58 apps/httpd: Use LWIP_ARRAYSIZE at appropriate places
Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-11-22 16:54:03 +01:00
Axel Lin
5cd6c38893 apps/snmp: Fix buld error when LWIP_SNMP_CONFIGURE_VERSIONS=1
The version check is done in these functions, it should be ok to put
assert in the else clause.

Fix below build errors:

../../../../lwip/src/apps/snmp/snmp_msg.c: In function ‘snmp_version_enabled’:
../../../../lwip/src/apps/snmp/snmp_msg.c:87:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #if LWIP_SNMP_V3
 ^
../../../../lwip/src/apps/snmp/snmp_msg.c:89:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #endif
 ^
../../../../lwip/src/apps/snmp/snmp_msg.c: In function ‘snmp_version_enable’:
../../../../lwip/src/apps/snmp/snmp_msg.c:126:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #if LWIP_SNMP_V3
 ^
../../../../lwip/src/apps/snmp/snmp_msg.c:128:1: error: embedding a directive within macro arguments is not portable [-Werror]
 #endif
 ^
cc1: all warnings being treated as errors
/home/axel/git/lwip/lwip-contrib/ports/unix/../Common.allports.mk:94:
recipe for target 'snmp_msg.o' failed
make: *** [snmp_msg.o] Error 1

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-11-22 16:53:00 +01:00
goldsimon
b48106c662 Fixed build errors in makefsdata introduced with the last commit 2017-11-21 20:08:40 +01:00
goldsimon
5dc3072af8 makefsdata: added option "-ssi:<filename>" to control SSI tag checking/insertion through a list of filenames, not by checking the file extension at runtime
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-11-21 12:23:08 +01:00
goldsimon
26f55f1eb3 makefsdata: add information about SSI and about the version of the included header to files
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-11-21 12:23:08 +01:00
goldsimon
839e5ecec6 makefsdata: rework finding arguments, rework printing flags to file
Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-11-21 12:23:07 +01:00
Axel Lin
8b6bb1a503 apps/httpd: Fix build error when LWIP_HTTPD_TIMING=1
Include lwip/sys.h to fix below build error:

../../../../lwip/src/apps/httpd/httpd.c:470:23: error: implicit declaration of function ‘sys_now’ [-Werror=implicit-function-declaration]
     u32_t ms_needed = sys_now() - hs->time_started;
                       ^~~~~~~

Signed-off-by: Axel Lin <axel.lin@ingics.com>
2017-11-19 14:17:52 +01:00
goldsimon
0853d1e7d1 sntp: revert 2 -Wconversion changes (see bug #51538) 2017-11-17 21:39:23 +01:00
Dirk Ziegelmeier
1e0501c31a Improve HTTPD documentation 2017-11-17 10:08:35 +01:00
goldsimon
da01bc4d15 httpd: ssi: support selecting ssi files by file flags, not by extension (at runtime) only 2017-11-16 22:29:44 +01:00
goldsimon
8bd670430a httpd: ssi: move checking file extensions against g_pcSSIExtensions array into its own function guarded by LWIP_HTTPD_SSI_BY_FILE_EXTENSION 2017-11-16 22:24:17 +01:00
David Girault
5290eacf08 altcp_mbedtls: close and error related fixes
- call conn->err() instead of conn->recv() if handshake fail and free conn
- close inner_conn and free current conn in altcp_mbedtls_close()

Signed-off-by: goldsimon <goldsimon@gmx.de>
2017-11-15 21:58:12 +01:00