1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-04-22 21:23:07 +03:00

453 Commits

Author SHA1 Message Date
david gauchard
6c5269a74b
fix UdpContext::(connect,listen) signature by using IPAddress (#5742)
* fix UdpContext::listen signature by using IPAddress
* fix UdpContext::connect signature by using IPAddress
  by courtesy of @AlfredLamoule
2019-02-11 13:46:40 +01:00
david gauchard
1959311180
UdpContext::setMulticastInterface(): fix for IPv6 (#5743)
Per 'udp_set_multicast_netif_addr()' signature and comments in lwIP sources:
An IPv4 address designating a specific interface must be used.
When an IPv6 address is given, the matching IPv4 in the same interface must be selected.

fix e3bc3c226b (r32235572)
2019-02-08 15:23:08 +01:00
Earle F. Philhower, III
d2a8e8acc2
Add debug messages on BSSL errors (#5723)
Add debugging output when DEBUG_ESP_SSL is defined.
Add dump of actual error when connect fails
2019-02-07 05:18:31 +00:00
Earle F. Philhower, III
56268b166d
Fix memory related issues w/BearSSL server/client (#5706)
Because the constructors of the BSSL client and server add a reference
count to the stack_thunk, if there is no copy constructor defined then
the stack thunk reference count can get out of sync causing the stack
thunk memory to be freed while still in use.  That could cause random
crashes or hangs.

Add a very basic copy constructor to the WiFiClientSecure and
WiFiServerSecure objects, using the default operator= to duplicate
simple types and shared_ptr classes.

The _cipher_list element (used only w/custom ciphers) could be freed
while still in use if copies of the WiFiClientSecure object were made.

Use a shared_ptr which will only free when the last reference is
deleted.

The axTLS compatibility mode calls allocate and store elements needed
for SSL connections (unlike normal BearSSL calls).  These elements could
be freed mistakenly while still in use if copies of the WiFiClientSecure
were made by the app.

Convert to a separately managed shared_ptr to ensure they live as long
as any referencing objects before deletion.

Same done for the axTLS compatability for WiFiServerSecure.
2019-02-02 18:09:19 +00:00
david gauchard
1cacf92ce1 stop lwIP dhcp client when WiFi goes off. (#5703)
* stop lwIP dhcp client with WiFi goes off.

* stop dhcp-client when really unused
2019-02-01 14:33:26 -03:00
Earle F. Philhower, III
3f8cd46dc2
Fix BearSSL Server WDT (#5702)
Fixes #5701 WDTs and other issues with BearSSL::WiFiServerSecure

The BSSL server was creating the client it returns on a connection in a
way that caused the counter for the stack_thunk to get out of sync and
cause it to be freed improperly by having the destructor be called one
more time than the constructor.  Looks like RVO.

Rewrite the ::available() function in order to avoid this issue with
help from @devyte.
2019-02-01 06:47:42 +00:00
david gauchard
f42bfdfc0d
adaptations for lwIP-v1.4 (#5682)
* adaptations for lwIP-v1.4
* add lwIP-v1.4 in CI
2019-01-28 22:31:59 +01:00
SmartBlug
5e4c2e9750 Add capability to have light static DHCP lease (#5594)
* Add capability to have light static DHCP lease

* added ESP8266WiFi StaticLease sample

* Update StaticLease to IPv4
2019-01-25 02:25:04 +00:00
david gauchard
7c5be91430 dynamic WiFi.hostname("newname") (#5652)
* dynamic WiFi.hostname("newname")

* WiFi.hostname() back to String return type

* no silent hostname fix but proceed with debug message and returning false
2019-01-24 17:13:20 -03:00
liebman
049a9eaa5b decorate as override virtual methods in WiFiUDP (#5637)
make WiFiUDP destructor virtual
add empty virtual destructor to Udp
2019-01-20 00:34:21 +01:00
david gauchard
b666435282 WiFiClient::remoteIP: fix nullptr crash (#5634) 2019-01-18 22:08:32 -03:00
david gauchard
cac22e3576
fix dhcp6 in upstream lwIP (#5560) 2018-12-27 19:29:04 +01:00
david gauchard
e3bc3c226b
Fixes for IPv6, added in CI (#5557) 2018-12-27 16:13:48 +01:00
david gauchard
da7ffdaa28
add 1 more IPAddress constructor for IPv6 (#5551) 2018-12-26 15:01:48 +01:00
dav1901
dd6333ee8b Add support for String args to softAP and begin (#5295) 2018-12-22 22:48:31 -03:00
acevest
34e90f3c56 fix bug. in sta mode, empty passphrase should not use secure auth mode (#5516)
* in sta mode, empty passphrase should not use secure auth mode

* use nullptr, camelCase and parenthesis
2018-12-18 10:47:25 -03:00
david gauchard
f8f4b81d60 better compatibility for IPAddress changes with external libraries (#5438) 2018-12-04 23:32:24 -03:00
david gauchard
216680bb57 weak hook preinit() #2111 #2133 #2136 (#5395)
* weak hook early_setup() #2111 #2133 #2136

* rename to early_init (more "c" vs early_setup which is more "c++arduino")

* example

* improve earlyWiFi example, slightly change AddrList interface, move WiFi sketches into WiFi examples

* fix CI

* fix local CI runner

* fix local CI runner

* rename early_init() to preinit()

* + static ESP8266WiFiClass::preinit_wifi_off()

* update early disable wifi example

* example update

* IPv6 example update

* Update ESP8266WiFiGeneric.h

camelCase for static method name

* Update ESP8266WiFiGeneric.cpp

camelCase for static method name

* Update EarlyDisableWiFi.ino

Expand comment, fix static method name

* Update core_esp8266_main.cpp

Expanded comment.

* Update core_esp8266_main.cpp

Expanded comment

* Update EarlyDisableWiFi.ino

Expanded comment
2018-12-03 20:54:27 -08:00
david gauchard
50cbdc0b92 update AddrList and examples (#5422) 2018-12-03 15:15:50 -03:00
Develo
4941711505 Implement for ssid a similar approach as for passphrase (#5411)
* Implement for ssid a similar approach as for passphrase

* Additional fixes for 32-char ssid
2018-12-02 21:25:13 -08:00
Earle F. Philhower, III
d8acfffdb0
Add cryptographically signed update support (#5213)
Using a pluggable architecture, allow updates delivered via the Update
class to be verified as signed by a certificate.  By using plugins, avoid
pulling either axTLS or BearSSL into normal builds.

A signature is appended to a binary image, followed by the size of the
signature as a 32-bit int.  The updater takes a verification function
and checks this signature using whatever method it chooses, and if it
fails the update is not applied.

A SHA256 hash class is presently implemented for the signing hash (since
MD5 is a busted algorithm).

A BearSSLPublicKey based verifier is implemented for RSA keys.  The
application only needs the Public Key, while to sign you can use
OpenSSL and your private key (which should never leave your control
or be deployed on any endpoints).

An example using automatic signing is included.

Update the docs to show the signing steps and how to use it in the
automatic and manual modes.

Also remove one debugging line from the signing tool.

Saves ~600 bytes when in debug mode by moving strings to PMEM

Windows can't run the signing script, nor does it normally have OpenSSL
installed.  When trying to build an automatically signed binary, warn
and don't run the python.
2018-12-02 19:57:47 -08:00
david gauchard
773f306ef9 more compatibility fixes to IPAddress, restore INADDR_ANY, INADDR_NONE (#5416) 2018-12-02 22:43:19 -03:00
david gauchard
92373a9837 Deprecate axTLS, update examples (#5366)
* update examples

* fix serial<->tcp example, use STASSID instead of SSID (name collision)

* fix HTTPSRequest.ino

* update AxTLS HTTPS examples, update AxTLS API to deprecated

* fixes

* fixes + fix astyle (no preproc directives) + restyling script

* fix HTTPClient library

* fixes

* common.sh: do not reload arduino when already present (for locally CI testing)

* common.sh: do not reload ArduinoJson when already present (for locally CI testing)

* fix

* fix

* fix deprecated example

* fix WiFiHTTPSServer.ino

* reduce footprint

* wipfix

* fix led builtin

* fix example

* finished updating APSSID on all examples

* style

* restyle examples

* helper to run CI test locally

* local CI runner more verbose

* +const

* deprecation deprecation

* deprecation

* Update NTPClient.ino

const char[] => const char *

* Update interactive.ino

const char[] => const char *
2018-11-29 20:49:27 -08:00
Earle F. Philhower, III
9ec03ed3f6
Move WiFi debug messages to PMEM (#5388)
Save ~1200 bytes in debug mode by making debug strings into PSTRs().
2018-11-29 12:55:40 -08:00
Earle F. Philhower, III
e7d3cf62b6
Don't clear authentication options on a ::stop (#5386)
Many objects now expect a WiFiClient* object to be passed to them and
potentially re-used multiple times (HTTPClient, others).  Clearing the
authentication options on a ::stop means they can never reconnect.

Remove the option clearing in ::stop

Fixes #5379
2018-11-28 16:12:01 -08:00
dav1901
5fcb8f1dac Check if AP exists before adding it (#5373) 2018-11-27 22:01:15 -03:00
david gauchard
5c4db3acf4
IPv6 on esp8266-nonos-sdk and arduino (#5136) 2018-11-27 23:07:47 +01:00
dav1901
cd05bae0e8 Pass string objects by reference (#5378) 2018-11-25 11:18:44 -03:00
Earle F. Philhower, III
19a0a0b6fd
Remove obsolete BSSL debug print routines (#5368)
Fixes #5356
2018-11-23 12:08:40 -08:00
dav1901
5d573652e4 Check for WEP when setting authmode (#5364)
* check if wep is enabled when setting authmode

* add requested changes
2018-11-22 18:19:37 -02:00
david gauchard
74ca42f829 Sketch emulation on host (#5342)
* WIP compile examples on host with 'make examples'

* WIP bufferize tcp input

* WIP Makefile

* WIP network to rework, tcp/udp to factorize, udp addresses broken

* minor changes to the core

* WIP basic udp working

* WIP mdns

* WIP mcast receiving, not sending

* WIP mdns OK

* beta version

* SSL + doc

* update travis host test command

* licenses

* typo

* doc: arduino builder is not around: declare functions before calling them

* fix with latest SSL PR, compile in 32 bits mode

* fix make clean

* make -m32 optional

* 32bits compiler ability tester

* WIP

* WIP (fix 1 vtable error, still another one to hunt with using spiffs)

* example astyle

* fix os_printf_plus

* load / save mock spiffs

* fix style

* fix using spiffs/mock

* don't mess ram

* update doc

* remove leftover

* optimization -Os except for CI, rename ARCH32 to FORCE32

* revert useless cast (not even compiled)

* remove unused function

* use proper type for pointer arithmetics

* makefile: sketch object and cpp file moved to bin/ directories
easier to clean, and IDE don't like them

* changes for review

* make use of %zd

* less verbose makefile by default (option)

* update readme
2018-11-20 18:51:45 -02:00
Earle F. Philhower, III
2f4380777e Move BearSSL from STACK_PROXY to a real, thunked 2nd stack (#5168)
* Update to BearSSL 0.6+ release, add AES_CCM modes

Pull in latest BearSSL head (0.6 + minor additions) release and add AES_CCM
modes to the encryption options.

* Enable the aes_ccm initialization in client/server

* Initial attempt

* Working code with second stack thunking

* Remove #ifdefs in .S file, not needed.

* Clean up thunks and remove separate stack flag

* Fix PIO assembler errors

* Remove #ifdef code changes, ensure same code as PC

Remove "#ifdef ESP8266;...;#else;...;#endif" brackets in BearSSL to
ensure the host-tested code is the same as the ESP8266-run code.

* Move to latest BearSSL w/EC progmem savings

* Merge with master

* Add br_thunk_* calls to do ref counting, painting

Add reference counting br_thunk_add/del_ref() to replace stack handling code
in the class.

Add in stack painting and max usage calculation.

* Add in postmortem stack dump hooks

When a crash occurs while in the second stack, dump the BSSL stack and
then also the stack that it was called from (either cont or sys).

* Update stack dump to match decoder expectations

* Move thunk to code core for linkiage

The thunk code needs to be visible to the core routines, so move it to the
cores/esp8266 directory.  Probably need to refactor the stack setup and the
bearssl portion to avoid dependency on bearssl libs in cores/esp8266

* Add 2nd stack dump utility routine

* Refactor once more, update stack size, add stress

Make stack_thunks generic, remove bearssl include inside of cores/esp8266.

Allocate the stack on a WiFiServerSecure object creation to avoid
fragmentation since we will need to allocate the stack to do any
connected work, anyway.

A stress test is now included which checks the total BearSSL second
stack usage for a variety of TLS handshake and certificate options
from badssl.org.

* Update to latest to-thunks branch

* Add BearSSL device test using stack stress

Run a series of SSL connection and transmission tests that stress
BearSSL and its stack usage to the device tests.

Modify device tests to include a possible SPIFFS generation and
upload when a make_spiffs.py file is present in a test directory.

* Use bearssl/master branch, not /to-thunks branch

Update to use the merged master branch of bearssl.  Should have no code
changes.
2018-11-14 23:29:24 -03:00
dav1901
79a6f36a02 Fix doc for ESP8266WiFi (#5325)
* Fix WiFiAP doc

* Fix softAP doc

* Fix doc
2018-11-08 07:06:54 -08:00
dav1901
56627338cc Set authmode if passphrase is provided (#5317) 2018-11-07 23:52:53 -03:00
Earle F. Philhower, III
233d3e3b5e
Move BearSSLHelpers into BearSSL namespace (#5315)
BearSSLX509List, BearSSLSession, BearSSLPublicKey, and BearSSLPrivateKey
were all in the global namespace and not in the BearSSL:: one, due to an
oversight when they were originally created.  Move them to the proper
namespace with the following mapping:
    BearSSLX509List => BearSSL::X509List
    BearSSLSession => BearSSL::Session
    BearSSLPublicKey => BearSSL::PublicKey
    BearSSLPrivateKey => BearSSL::PrivateKey
2018-11-06 19:27:40 -08:00
dsv19
ef95e05319 examples code cleanup (#5290)
* Update WiFiMulti.ino

* Update WiFiClientBasic.ino

* Update WiFiWebServer.ino

* Update WiFiClient.ino

* Update WiFiHTTPSServer.ino
2018-10-28 23:29:03 -03:00
Adrian Scillato
561426c0c7 Fix webserver unresponsiveness (#5259) 2018-10-18 18:36:47 -03:00
david gauchard
e549355221 Fix: WiFiClient::flush() yields but can be called from events (#5254)
Fix bug introduced by #5167 which replaced delay() by yield().
That should have been esp_yield() which is the one delay()
calls and is safe from either SYS or CONT contexts.

Fixes #5237.
2018-10-17 15:32:54 -07:00
Earle F. Philhower, III
1b1b0a28a8
Add stack repainting call to ESP class (#5221)
Allow the unused stack to be reset to the check value at any time in
the application, allowing for delta-stack calculations to be done.

Add ESP.resetFreeContStack() class method for general use.

Add in some dumping in the BearSSL_Validation example to show the
usage for those that care.
2018-10-11 08:55:30 -07:00
Junxiao Shi
d17ffc2874 WiFi: improve WiFiClient(Basic) examples (#5197)
WiFiClient no longer depends on now-defunct data.sparkfun.com
service, but uses a TCP "quote of the day" service instead.

fixes #4088
2018-10-11 02:08:13 -03:00
david gauchard
8ef21ca3ae Update to the last version of nonos-sdk V2, WiFi addons (#5210)
* fwupdate

* fw update to latest version:
WPA working, WEP+Open disabled by default. Need API change.

* helpers to follow sdk updates

* remove compare scripts - made a separate PR for them

* add wep api, restore original espressif comment (wep enabled does not prevent wpa)

* libmain was not up to date

* experimental: DTIM setting in WiFi.setSleepMode(WIFI_LIGHT/MODEM_SLEEP, DTIM-value)
with new getter: .getListenInterval() / .isSleepLevelMax()

* fixes

* fix debug message

* when not using listenInterval, set wifi sleep level to min

* update documentation

* update doc
2018-10-09 10:21:23 -03:00
Earle F. Philhower, III
14808c9ac4
Add warning when no authenticator, drop verify() (#5205)
Print a warning when in debug mode when a BearSSL connection tries to
connect without having any defined authentication methods, since it will
fail.

Completely remove the empty axTLS compatibilty method
"::verify(char *fp, char *name)" because it can't be done w/BearSSL w/o
user code changes, and always failed.  Better to have a compile failure
when we know at compile time the app won't do what is expected.

Completes the changes started by @d-a-v in PR #4833
2018-10-03 20:27:09 -07:00
Earle F. Philhower, III
18612c97d8
Add BearSSL::setFingerprint(char* fp) (#5204)
Add a method allowing a user to send in a character string for the
fingerprint, like axTLS supported.

Implements part of PR #4833 from @d-a-v with changes requested in
discussion.
2018-10-03 19:32:47 -07:00
aerlon
24a1d22730 Make softAP documentation state the correct min value (0) for the max_connection argument. (#5165) 2018-10-01 14:27:16 -03:00
Earle F. Philhower, III
270788bedb
Really free stack after last BearSSL obj destroyed (#5185)
The BearSSL second stack, once allocated, was never deallocated.  The
reference count of the stack pointer never hit 0 due to the initial
creation counting as one.  Now, check to see if there is only one use_count
and if so then delete the stack.
2018-09-29 18:12:03 -07:00
Earle F. Philhower, III
6314093fe5
Add SSL Session capability to speed reconnections (#5160)
SSL Sessions enable most of the SSL handshake to be skipped when both
client and server agree to use them.  Add a BearSSLSession class and
an optional setting to the SSL client to enable this.

Note that SSL sessions are unrelated to HTTP sessions.  They are
ephemeral and only relate to the SSL parameters, not anything at
the HTTP protocol level.
2018-09-28 12:03:20 -07:00
Earle F. Philhower, III
8e11836378
Move BearSSL _cipher* init to _clear() for consistency (#5178)
The cipher list count/pointer was cleared separately in the three
constructors available.  Move this reset to _clear() to reduce code
duplication and keep the semantics.
2018-09-28 09:18:07 -07:00
Earle F. Philhower, III
5137d4da11
Update to BearSSL 0.6+ release, add AES_CCM modes (#5164)
Pull in latest BearSSL head (0.6 + minor additions) release and add AES_CCM
modes to the encryption options. Enable the aes_ccm initialization in client/server

The EC mul20 and square20 code was identical in two different files,
but because these copies were static, we ended up with an extra 6k of
duplicated code. Updated BearSSL to make them shared, saving 6KB.
2018-09-27 20:30:19 -07:00
david gauchard
5a5af55d3a
ClientContext: restore TCP PuSH flasg when needed (#5176)
fix #5173
2018-09-27 17:22:21 +02:00
david gauchard
775eb9b343
fix: tcp_output() should always be called after tcp_write(), does not break nagle (+ doc) (#5172) 2018-09-26 23:56:01 +02:00