Commit Graph

45 Commits

Author SHA1 Message Date
philip 78ee67fd2e Remove some uses of etc_*printf 2020-11-07 16:23:43 +01:00
vsky e28cf8d983 Fixes `net.ifinfo` failure 2020-09-04 21:54:40 +02:00
Lukáš Voborský 7a77d76438 net_info module - ping function (#2854)
* Net_info module exposing ping function initial commit
* Ping as a part of net module
* Sent callback implemented
* Add NET_PING_ENABLE macro

Authored-by: vsky <blue205@centrum.cz> with support from TerryE
2020-06-09 22:26:52 +02:00
Terry Ellison bbeb09b695 Squashed updates do get Lua51 and Lua53 working (#3075)
-  Lots of minor but nasty bugfixes to get all tests to run clean
-  core lua and test suite fixes to allow luac -F to run cleanly against test suite
-  next tranch to get LFS working
-  luac.cross -a options plus fixes from feedback
-  UART fixes and lua.c merge
-  commit of wip prior to rebaselining against current dev
-  more tweaks
2020-06-09 22:26:52 +02:00
Nathaniel Wesley Filardo c8c90fe4e1 app/modules: prune some unnecessary metamethods 2020-06-09 22:26:52 +02:00
Nathaniel Wesley Filardo efa786da4e net.dns: don't calloc a single int
Removes yet another unchecked allocation point in our C libraries.

While here, fix potential reference leaks on error paths

Also while here, remove some stale documentation.  There can be as many
DNS requests in flight as LwIP has room for in its table
(DNS_TABLE_SIZE, which defaults to 4).
2020-06-09 22:26:52 +02:00
Nathaniel Wesley Filardo fd68000c12 net: drop LUA_GCSTOP/GCRESTART dance 2020-06-09 22:26:52 +02:00
Nathaniel Wesley Filardo e1a81aa114 net: annotate deliberate case fallthrough 2020-06-09 22:26:52 +02:00
Nathaniel Wesley Filardo af426d0315 Networking rampage and accumulated fixes (#3060)
* espconn: remove unused espconn code, take 1

This is the easiest part of https://github.com/nodemcu/nodemcu-firmware/issues/3004 .
It removes a bunch of functions that were never called in our tree.

* espconn: De-orbit espconn_gethostbyname

Further work on https://github.com/nodemcu/nodemcu-firmware/issues/3004

While here, remove `mqtt`'s charming DNS-retry logic (which is neither
shared with nor duplicated in other modules) and update its :connect()
return value behavior and documentation.

* espconn: remove scary global pktinfo

A write-only global!  How about that.

* net: remove deprecated methods

All the TLS stuff moved over there a long time ago, and
net_createUDPSocket should just do what it says on the tin.

* espconn_secure: remove ESPCONN_SERVER support

We can barely function as a TLS client; being a TLS server seems like a
real stretch.  This code was never called from Lua anyway.

* espconn_secure: more code removal

* espconn_secure: simplify ssl options structure

There is nothing "ssl_packet" about this structure.  Get rid of the
terrifying "pbuffer" pointer.

Squash two structure types together and eliminate an unused field.

* espconn_secure: refactor mbedtls_msg_info_load

Split out espconn_mbedtls_parse, which we can use as part of our effort
towards addressing https://github.com/nodemcu/nodemcu-firmware/issues/3032

* espconn_secure: introduce TLS cert/key callbacks

The new feature part of https://github.com/nodemcu/nodemcu-firmware/issues/3032
Subsequent work will remove the old mechanism.

* tls: add deprecation warnings

* luacheck: net.ifinfo is a thing now

* tls: remove use of espconn->reverse

* mqtt: stop using espconn->reverse

Instead, just place the espconn structure itself at the top of the user
data.  This enlarges the structure somewhat but removes one more layer
of dynamic heap usage and NULL checks.

While here, simplify the code a bit.

* mqtt: remove redundant pointer to connect_info

Everywhere we have the mqtt_state_t we also have the lmqtt_userdata.

* mqtt: doc fixes

* mqtt: note bug

* tls: allow :on(...,nil) to unregister a callback
2020-06-09 22:26:52 +02:00
Nathaniel Wesley Filardo 446c058fa6 net: rename net.if.info to net.ifinfo (#3033)
Reserved words are always reserved in Lua, so let's not have people
typing net["if"]...
2020-06-09 22:26:52 +02:00
Nathaniel Wesley Filardo 948325a996 New `net.if.info` call to show LwIP information (#2862)
* Remove app/include/netif/wlan_lwip_if.h

This file appears to be unused in our tree.

* New `net.if.info` call to show LwIP information

This is a generalization of `wifi.sta`'s and `wifi.ap`'s `getip` and
`getmac` calls.  I don't propose to deprecate those, but perhaps we
should, in the documentation, point users at this function instead.

The direct motivation is to permit continued use of DHCP-provided NTP
servers in a future where
https://github.com/nodemcu/nodemcu-firmware/pull/2819 has landed, now
that https://github.com/nodemcu/nodemcu-firmware/pull/2709 is in the
tree.  But rather than exposing just that information, a more general
interface seems useful.
2020-06-09 22:26:06 +02:00
Terry Ellison e7c29fe38e Lua 5.1 to 5.3 realignement phase 1 2020-06-09 22:26:06 +02:00
Johny Mattsson f7a545b951
Evict c_types.h, tidy up a other c_prefixes. (#2841) 2019-07-23 14:22:38 +10:00
Johny Mattsson 526d21dab4 Major cleanup - c_whatever is finally history. (#2838)
The PR removed the bulk of non-newlib headers from the NodeMCU source base.  
app/libc has now been cut down to the bare minimum overrides to shadow the 
corresponding functions in the SDK's libc. The old c_xyz.h headerfiles have been 
nuked in favour of the standard <xyz.h> headers, with a few exceptions over in 
sdk-overrides. Again, shipping a libc.a without headers is a terrible thing to do. We're 
still living on a prayer that libc was configured the same was as a default-configured
xtensa gcc toolchain assumes it is. That part I cannot do anything about, unfortunately, 
but it's no worse than it has been before.

This enables our source files to compile successfully using the standard header files, 
and use the typical malloc()/calloc()/realloc()/free(), the strwhatever()s and 
memwhatever()s. These end up, through macro and linker magic, mapped to the 
appropriate SDK or ROM functions.
2019-07-22 00:58:21 +03:00
Terry Ellison 1990f95740
Updated ROTables 1st tranch (#2742)
Updated ROTables
2019-05-08 14:08:20 +03:00
sergio d77666c0e8 trailing spaces cleanup (#2659) 2019-02-17 18:26:29 +00:00
Johny Mattsson 3e60fa8f60 Fix data loss in TCP streams. (#2097)
* Fix data loss in TCP streams.

* Factored out the UDP extra args handling.
2017-09-28 22:41:22 +02:00
Yury Popov 2f00c1d8d9 TIME_WAIT sockets fixes (#1838)
* Enable SO_REUSEADDR for server TCP sockets

* Reduce TCP_MSL to 5 sec

* Add changes notice for future updates

* Move MSL change to lwipiots.h
2017-03-17 07:31:37 +01:00
Yury Popov 466c03d90f Deprecation messages for convenient net.create(Server/Connection) calls (#1844) 2017-03-07 20:50:32 +01:00
Yury Popov 2c8961d153 Add TTL support to net module (#1756) 2017-02-06 13:54:20 +01:00
Yury Popov 3adba91b15 Net functionality rewrite on top of LWIP (#1379)
* Rewrite net.dns.resolve on LWIP

* Move IGMP (net multicast) to LWIP

* Cleanup net module

* Move secure connection operations to tls module

* Net module on LWIP

* Server timeout parameter

* TCP hold

* Fixes in documentation

* Documentation fixes

* Note TLS module depends on net

* Add TLS module to user_modules.h

* Callback on connect event

* Fix depends net module on tls module

* Fix unhold exponential time issue
2016-12-31 13:14:03 +01:00
Yury Popov be263dacde Set espconn's secure buffer size once at initialization (#1466)
Fixes #1457
2016-09-04 22:45:46 +02:00
Yury Popov a499716cc1 Update modules to be Lua coroutine compatible (#1423) 2016-08-02 22:33:05 +02:00
philip 501bd1fb9a Adds support for verifying the certificate offered by an SSL server.
Squashed commit of the following:

commit 4439b8c45192f6dee1222df78bbb59f74509e0ee
Author: philip <philip@gladstonefamily.net>
Date:   Sun Mar 6 20:23:21 2016 -0500

    Fix the ignore

commit a07ee5acdf91286607c3e2dce128c9b8bfd7bd80
Author: philip <philip@gladstonefamily.net>
Date:   Sun Mar 6 20:20:41 2016 -0500

    Remove uneeded stuff

commit b3604ace92fc13b30161d385c354b0f1c5fe4046
Author: philip <philip@gladstonefamily.net>
Date:   Sun Mar 6 20:15:26 2016 -0500

    Remove client cert auth

commit 6e48c633569630736a986cd07a59a12de954391e
Author: philip <philip@gladstonefamily.net>
Date:   Sun Mar 6 20:11:42 2016 -0500

    More cleanup

commit d40eade405ef071d0d1b60d038566b5b8f2cafa3
Author: philip <philip@gladstonefamily.net>
Date:   Sat Mar 5 10:56:56 2016 -0500

    Move to almost working version

commit 1860a2d90afa94461c53bd41251d4870d6527f9d
Author: philip <philip@gladstonefamily.net>
Date:   Fri Mar 4 08:04:09 2016 -0500

    Changed the naem to server-ca.crt

commit e7a315660843273fe62943b7fe8ee6c0541dada2
Author: philip <philip@gladstonefamily.net>
Date:   Thu Mar 3 21:16:26 2016 -0500

    Update gitignores

commit 2b037d185c396209b64381399c40821c15e1840e
Author: philip <philip@gladstonefamily.net>
Date:   Thu Mar 3 08:56:17 2016 -0500

    Getting better

commit 763255cffba8e279158cd7f43391a3573efdeca8
Author: philip <philip@gladstonefamily.net>
Date:   Wed Mar 2 22:28:21 2016 -0500

    Works a bit better

commit a38325d1a47dbad255cb3e681da8415e8cf699ea
Author: philip <philip@gladstonefamily.net>
Date:   Wed Mar 2 09:11:04 2016 -0500

    First building version

commit 4aef13da33470ed954f2eaf5f7ac0ac3dcdf3774
Merge: 180e147 ebb0c33
Author: philip <philip@gladstonefamily.net>
Date:   Tue Mar 1 22:03:06 2016 -0500

    Merge remote-tracking branch 'upstream/dev' into ssl-client

commit 180e147c1abdcf4046ad9be9b3c1a48f4a875312
Author: philip <philip@gladstonefamily.net>
Date:   Sun Feb 28 21:34:21 2016 -0500

    Missing files from espressif

Try to imporve layout

Align the file names with the contents

Missing file

Review comments

More review coments
2016-03-09 21:51:23 -05:00
Uri Shaked ce498462f7 Fix secure TCP connections
Call `espconn_secure_set_size()` before calling `esp_secure_connect()`, should fix issues like #710 and #520
2016-02-06 17:12:46 +02:00
Johny Mattsson 182d45f928 Enable -std=gnu11 for modules dir.
Plus boat-load of fixes to actually make that build.
2016-01-20 19:40:47 +11:00
Johny Mattsson 4e8ef87d03 Reworked module registration, removed modules.h
Module creation & registration now made a lot simpler. In essence,
each module file is now self-contained and only needs a

  NODEMCU_MODULE(MYNAME, "myname", myname_map, luaopen_myname);

line to both be automatically recognised by the Lua initialization
as well as honor the LUA_USE_MODULES_MYNAME #define.
2015-12-16 16:09:16 +11:00
TerryE b773290b8c Major cleanup of module registration pass 2.
carrying on Johny's edits as per my comments on #810
2015-12-16 11:21:40 +11:00
Johny Mattsson 6b6456be47 Major cleanup of module registration.
As per #810 & #796, only LUA_OPTIMIZE_MEMORY=2 & MIN_OPT_LEVEL=2 are
supported when building. This commit effects that limitation.

With this change modules/auxmods.h no longer needs to be updated for
every new module, nor do module writers need to cater for a hypothetical
LUA_OPTIMIZE_MEMORY < 2 scenario.
2015-12-12 15:03:40 +11:00
Ivan Lopez 4ff9e6cc01 Make net.dns.resolve and net.dns work with an IP address host to resolve 2015-11-18 21:22:58 +01:00
Ivan Lopez a272491502 Make net.dns.resolve and net.dns work with an IP address host to resolve 2015-11-18 20:58:33 +01:00
Johny Mattsson 8fba0f47de Make UDP server work again after 1.4.0 API changes. 2015-10-15 12:14:27 +11:00
Johny Mattsson 3b9a42e254 Updated #includes to work on new SDK.
Both "c_types.h" and "lwip/ip_addr.h" don't get included indirectly anymore.
2015-10-12 13:26:04 +11:00
vowstar a32df17579 Fixed net.dns.getdnsserver() by @md5crypt. 2015-06-27 12:26:24 +08:00
MarsTechHAN 04c03b00ae @jorgempy We change the API of DNS callback format back
Make the net api universe  Callback Format -> function(conn,ip)
2015-06-20 19:10:01 +08:00
HuangRui 3cd5a6a1ed Merge branch 'master' of https://github.com/bruceme/nodemcu-firmware into dev
Conflicts:
	app/modules/net.c
2015-06-04 15:04:12 +08:00
Jorge Mesquita 70580dc4ae added net.dns.setdnsserver('ip',[index]), net.dns.getdnsserver([index]), net.dns.resolve('domain.com', function cb('ip' or nil if fail) )
modified:   app/modules/net.c
2015-05-16 20:53:31 -04:00
Kevin Uhlir f68d41608e Add multicastJoin and multicastLeave to net module
net.multicastJoin(if_ip, multicast_ip)
net.multicastLeave(if_ip, multicast_ip)

if_ip is a string containing the interface ip to join/leave the
multicast group.  multicast_ip is the multicast ip of the group to
join/leave. if_ip can be "" or "any" to affect all interfaces.
2015-04-15 03:41:13 -05:00
funshine d28a2c9eda add interger version release, fix #234, #252, #246 2015-03-11 13:21:19 +08:00
funshine 2c5c00a56a add net.socket:getpeer() api, returns peer ip,port 2015-02-14 02:38:15 +08:00
Santiago 929d4aed5c Added the hold and unhold methods to tcp socket 2015-02-09 03:00:18 -03:00
funshine dec47d5372 fix #185 2015-02-07 23:45:01 +08:00
funshine df3c82391f add spi, and some minor fix 2015-01-18 11:46:15 +08:00
HuangRui c04f2578ec Updated SDK to v0.9.5 and optimized memory. 2015-01-05 10:09:51 +08:00
funshine cdd13b1af3 source file first commit, folder structure refact 2014-12-22 19:35:05 +08:00