Commit Graph

1355 Commits

Author SHA1 Message Date
Alexander Alashkin
02499d672b Build c_mqtt/stm32 - part 1, with stubs
PUBLISHED_FROM=de4b9f3e9eeafa75bb8919abacd86fb23fdefc1b
2016-12-15 14:06:50 +00:00
Alexander Alashkin
8c2e641ed7 Simplest c_hello/stm32
PUBLISHED_FROM=3a22eb96ff011ef8327cd1b78b56a3af86ba2c84
2016-12-14 16:22:16 +00:00
Sergey Lyubka
a447ae5eab MQTT parsing fix
PUBLISHED_FROM=41f43cb0e707259740de3346308f746c2a3778fd
2016-12-13 10:37:06 +00:00
Dmitry Frank
5ebff5d15e Rename pic32_harmony -> pic32
PUBLISHED_FROM=00ca7b2adabde94a683ac4d33be1f2bdbb17772f
2016-12-09 22:06:14 +00:00
Dmitry Frank
731512a947 Define mg_file_upload_handler() only if needed
Namely, define it if only `MG_ENABLE_HTTP_STREAMING_MULTIPART` and
`MG_ENABLE_FILESYSTEM` are on

PUBLISHED_FROM=3094738a4b76ceb09a3c2374e8d9d914b71c3441
2016-12-09 16:06:17 +00:00
Alexander Alashkin
304dbca63d Fix miot-mbed errors and warning, part 3
PUBLISHED_FROM=2f6fb7ea5abdcd4ca9b06956172938ee3bc28459
2016-12-09 12:36:00 +00:00
Marko Mikulicic
9937e88985 Fix comparisons
PUBLISHED_FROM=4d86de7f73ef9d4c0f236e1fe1201e5de792f19f
2016-12-07 18:05:56 +00:00
Sergey Lyubka
57f964a139 Add mqtt last will
PUBLISHED_FROM=fb856714ead67390dfd7ce9d208ae5ae19ce7c6d
2016-12-07 17:21:56 +00:00
Alexander Alashkin
fba32acb73 Replace memcmp with strncmp in mongoose
PUBLISHED_FROM=3c5859f06ab838bba7c95c4878c4e7e883329810
2016-12-02 13:51:30 +00:00
Sergey Lyubka
2fdb1f78a2 Fix amalgamation conflicts: POC
PUBLISHED_FROM=5b63325ade34b9032476fc88ac407816990f1cfc
2016-12-01 22:21:14 +00:00
Alexander Alashkin
ea2069df51 Fix coredump in mg_reverse_proxy_handler
PUBLISHED_FROM=ca0ae588290f133ef7640ca538847a63c0cb544b
2016-12-01 09:21:11 +00:00
Alexander Alashkin
7267fc757d Fix mg_stat
PUBLISHED_FROM=e6fb19c5256b6d43359f21b325e16b415152f26f
2016-11-29 13:36:55 +00:00
Alexander Alashkin
ea7d69060d Replace fopen with mg_fopen
PUBLISHED_FROM=764ea806a5d31bd545a5d99de80e2ee0234ebcab
2016-11-29 13:36:54 +00:00
Alexander Alashkin
6e5e2eb694 Restore HTTP errors descriptions
PUBLISHED_FROM=26becdaf7dd61481b88b166ea87d44a7bc796660
2016-11-29 11:22:06 +00:00
Deomid Ryabkov
51466df7b9 Check for SEND_AND_CLOSE after HANDSHAKE_REQUEST
Assume handshake request was declined if either MG_F_CLOSE_IMMEDIATELY _or_ MG_F_SEND_AND_CLOSE is set.

PUBLISHED_FROM=60af32a3f8890e826205465b9add2f58b1d46e5f
2016-11-28 15:51:14 +00:00
Deomid Ryabkov
d6259332d4 Fix use-after-free
Free keys and cert before conf, not after

PUBLISHED_FROM=5628f56eb6973a779179d641fb425d0f14db39cf
2016-11-28 15:21:18 +00:00
Deomid Ryabkov
260229a4d1 Free certs and keys on client TLS connections
Renegotiation is disabled, so we don't need them.
Reduces per-connection usage when idle by 3K.

PUBLISHED_FROM=24b2ac9557107f7da412dae6a42257c9b7c812d5
2016-11-28 12:05:41 +00:00
Deomid Ryabkov
7776df241c Enable server name verification on mbedTLS
PUBLISHED_FROM=54774944d5402a5d6a351b4609428940c0ad20ea
2016-11-28 08:50:42 +00:00
Deomid Ryabkov
e17fdcb077 Minor memory shavings on ESP8266; ~2.5K less
- Only allow one TCP segment in flight. Each segment is 1.5K and it
   adds up. This may increase latency, but memory is precious on ESP.
   At teh same time, optimize use of tcp_output: do not send a new segment
   on every write, only call tcp_output at the end of connection
   processing during poll.

 - Build LWIP with DNS disabled. We have our won resolver, and LWIP's
   allocates large static buffers (1K).

 - mbedTLS: Deallocate peer's certificate at the end of SSL handshake,
   reduces idle SSL connection footprint by ~1.5K.

 Some tweaks to the heap log viewer (which made all the above possible).

PUBLISHED_FROM=6e84bba64eacb2d737561e09313918104921ea80
2016-11-27 17:21:29 +00:00
Deomid Ryabkov
d96629cdf4 Add support for PEM certs on SimpleLink
Also performs trnasparent SPIFFS -> SLFS cert copy.

If the file's extension is .pem, convert it to DER format and put on SLFS.

PUBLISHED_FROM=364caab21969ca28a05802c4dde93a11d1e0feda
2016-11-25 19:30:05 +00:00
Dmitry Frank
0c79fcfbd0 Add a flag to prevent a tunnel from reconnection
Also fixed a memory leak on reconnect: previously, each reconnect was
creating a `struct mg_connection` which was never reclaimed

PUBLISHED_FROM=eefdcf557e032ac81d5ed3aba55ac912e400148e
2016-11-25 11:36:14 +00:00
Alexander Alashkin
9125830de6 Fix stkovf in mg_resolve_async_opt
PUBLISHED_FROM=8e37c51c6b0bf7d0782f3a997360827471b95d2e
2016-11-25 08:21:38 +00:00
Deomid Ryabkov
44f7b91826 Fix use of SLFS from TI libc "device" interface
PUBLISHED_FROM=e1bb89268dfc4d51880b89b07fb2f69cb49e053b
2016-11-24 12:50:52 +00:00
Deomid Ryabkov
731ea5d50d Increase debug level of stat() and open() messages
Useful for debugging at level 3

PUBLISHED_FROM=b6a4565df0de0dccf37c182c71d2f4c852f2291a
2016-11-24 10:21:58 +00:00
Alexander Alashkin
9e517fde00 Implement SNTP client
PUBLISHED_FROM=ac54bcbc81a9ee688e8b90e261172be76a9fbacd
2016-11-24 09:51:58 +00:00
Dmitry Frank
1ff61837ac Fix mg_http_common_url_parse
The only client of `mg_http_common_url_parse` (namely,
`mg_connect_http_base`) expects `port_i` to be the index in the address
string at which the port was added.

PUBLISHED_FROM=b095926b5485e4674e3c59ff8481171831fb61ae
2016-11-23 18:06:50 +00:00
Deomid Ryabkov
3a8464e4b8 Reinstate fs_slfs_rename stub
Needed by TI libc for use with add_device

PUBLISHED_FROM=ff0713c5f4d04810894d8e1a82aaac25aa101365
2016-11-23 11:07:11 +00:00
Marko Mikulicic
39b0b8e2fd Fix clang formatting
PUBLISHED_FROM=ea64670e42ae58bbe26abee5d928f2afcd83bd46
2016-11-23 08:06:09 +00:00
Sergey Lyubka
3a61186491 Ubreak v7 build - add missing includes
PUBLISHED_FROM=01d691c9e06486cab0903b8db98e56fffc3fb234
2016-11-22 16:21:38 +00:00
Deomid Ryabkov
2180e1786c Allow use of absolute paths on SLFS
If the path starts with /, do not drop it.
There are no directories on SLFS, but use of /pretend/paths/to/files.txt
is common. What we do drop is the ./ prefix (added by mongoose when document_root=.)

PUBLISHED_FROM=5108bc078dfaf8f8afa4db554b4769d9d7b8a103
2016-11-22 15:52:04 +00:00
Deomid Ryabkov
8fb5e8ef19 mbedTLS support for LWIP net_if
PUBLISHED_FROM=a733ba6e06887a448f96f92679f6f8adbe9c61f7
2016-11-22 13:21:42 +00:00
Ilia Penev
a8f54d1851 Integrate PR170
PUBLISHED_FROM=f1a804466bea6d6d77103525d76ef7b819b63477
2016-11-22 08:05:55 +00:00
Marko Mikulicic
a23daa1547 Move mg_a*printf to common
PUBLISHED_FROM=cccd28ef43ec4e08fa52340ce78bda10db5ac27a
2016-11-18 15:36:00 +00:00
Sergey Lyubka
9dba6c806b Add endpoint to list tunnels
PUBLISHED_FROM=f45d9832a884374f6f9ea3f2e0a8c9465f214896
2016-11-18 12:21:11 +00:00
Marko Mikulicic
fc635a9340 Move mg_ncasecmp and sister to common string utils
PUBLISHED_FROM=182c43c3bd82190cb816c8ebaddccc13a94950d0
2016-11-17 11:21:17 +00:00
Alexander Alashkin
81f738af3f Fix mg_http_common_url_parse
PUBLISHED_FROM=51c44c445309aa0850b227949a0a0a6be433d08c
2016-11-17 11:05:57 +00:00
Alexander Alashkin
f6165d23e4 Fix stack overflow in mg_hexdump
PUBLISHED_FROM=5025692f3f4593b3ea38af51f8f49e1ac4df6b88
2016-11-16 17:36:14 +00:00
Alexander Alashkin
e4a4b6f260 Fix coredump in mg_tun_destroy_client
PUBLISHED_FROM=56ff5afe805e4680e02183a8c3887ea60ee5ebfe
2016-11-16 12:21:31 +00:00
Alexander Alashkin
8a6cf95fad Fix mg_match_prefix
PUBLISHED_FROM=4fdfa61e7b3b62083b0ac8fe74dd2dd3793f50fe
2016-11-15 13:36:31 +00:00
Dmitry Frank
37a7031f4e Minor formatting fix
PUBLISHED_FROM=c56b4ae00c454e6931ab29b095641bf0222f860c
2016-11-15 09:51:14 +00:00
Dmitry Frank
8874f3de9d Fix simplelink SSL context
It wasn't checked for `NULL`, and on CC3200 NULL dereferencing addresses
doesn't cause a crash, so it worked by pure luck: ctx->ssl_key was 0.
After `mg_` to `miot_` refactoring it's not the case anymore (presumably
because linker arranged objects in a different order), so this bug shown
up.

PUBLISHED_FROM=0f1cc73a078c18432c68ae0f9b14dd06b3bb4279
2016-11-15 09:06:03 +00:00
Marko Mikulicic
3c5d48ea13 Promote tun example to a unit test
PUBLISHED_FROM=0454cdeec5c7120eb4bf905fdd5b7abdcb4003c2
2016-11-14 18:06:04 +00:00
Marko Mikulicic
74b75899d3 Make cc3200 sprintf workaround smaller
in light of the root cause discovered by rojer
and addressed in cesanta/dev#5882 for the http connection code path.

PUBLISHED_FROM=aea563150a0411cbe3fdc6f7911529f3136cc76f
2016-11-14 17:06:31 +00:00
Deomid Ryabkov
240eca0b68 Avoid passing NULL to %.*s
CC3200 (TI's C library) doesn't like it

https://e2e.ti.com/support/development_tools/compiler/f/343/t/554883

PUBLISHED_FROM=d0e9fb7ebb7d189d1a76451d609f1f1861c7a837
2016-11-14 16:20:08 +00:00
Deomid Ryabkov
65e01dbabc Initial support for mbedTLS
PUBLISHED_FROM=edb1063d3fd64e3c732f16b8bf101c065cdacddd
2016-11-14 16:20:02 +00:00
Deomid Ryabkov
f67fe352cf Pull out common SSL interface
Currently only OpenSSL API impl, but the plan is to add more.

PUBLISHED_FROM=c85b26fa2312047768bdcf3eca583e60862aba90
2016-11-11 20:51:01 +00:00
Marko Mikulicic
4805797752 Fix hexdump memory overflow
PUBLISHED_FROM=a6f3f33432ce43b6d4462de623ba61a53e7f18df
2016-11-11 16:05:53 +00:00
Marko Mikulicic
4c038508f2 Extract tun proto name constant
PUBLISHED_FROM=574362ea7d90a17cd49963a430559824cfcff802
2016-11-11 10:06:02 +00:00
Marko Mikulicic
15db11c0e6 Fix tunnel teardown
PUBLISHED_FROM=2c23e4a4dfc7129da657c5935f06335fc022394a
2016-11-11 08:21:37 +00:00
Deomid Ryabkov
97fe505bb4 clang-format more stuff in common
PUBLISHED_FROM=8b5c6f70d5582402f327c4da7baee7cc15ee13aa
2016-11-10 23:50:42 +00:00
Deomid Ryabkov
fd45a6d31b CS_LOG_TS_DIFF -> CS_LOG_ENABLE_TS_DIFF; ifdef->if
PUBLISHED_FROM=48c8d4326ea8a24edd8d1ca011be9e7643219084
2016-11-10 16:21:28 +00:00
Marko Mikulicic
e1a9ad7f82 Overload mg_bind to bind to tunnel
PUBLISHED_FROM=f554cc63dfea12455fe5e428c6ce5f3152774f8e
2016-11-10 13:07:17 +00:00
Deomid Ryabkov
296affc6e4 Make Krypton define KR_VERSION; use it to detect
PUBLISHED_FROM=ea039cdc30aec44db074871ff6b2d2582f98b5c9
2016-11-10 11:50:56 +00:00
Marko Mikulicic
1889e12b54 Support username:pass authority in HTTP/WS urls
PUBLISHED_FROM=39a1c2a271c5cd961670e11c830105c17ba0b2e4
2016-11-10 11:21:43 +00:00
Sergey Lyubka
5e91d919e0 Make mg_register_http_endpoint work for websocket
PUBLISHED_FROM=5bf5a007929b3b6275121f3cf949526e881fb482
2016-11-09 17:21:38 +00:00
Marko Mikulicic
5934846852 Make mg_tun_bind take separate user+pass
PUBLISHED_FROM=3ee9478275c4b9253b1dd4f98a69cecc89290bce
2016-11-09 15:51:08 +00:00
Marko Mikulicic
5045dfab74 Mongoose TCP tunnel
PUBLISHED_FROM=f03b963aaec02574e47c28ee8033551440b94f2d
2016-11-09 15:05:46 +00:00
Alexander Alashkin
499a7d6a37 Fix mg_is_error
PUBLISHED_FROM=80481f8dbcb93d04eee51ecc6366949420a61f2f
2016-11-09 13:50:52 +00:00
Alexander Alashkin
f72c3fa9a7 Unbreak PIC32 compilation. Close cesanta/dev#5807
PUBLISHED_FROM=cfd7de45e4357a17719501b8ab004c2edbd3e87e
2016-11-09 11:21:02 +00:00
Alexander Alashkin
d0c50632cd Fixes in MQTT for AWS support
PUBLISHED_FROM=2b82f3793b3c6d0cf1266e4cc0e67930f43002c5
2016-11-09 10:05:40 +00:00
Marko Mikulicic
fffb54e2c6 Implementing MG interfaces
PUBLISHED_FROM=46496c2d5340a0bbe4fe1c6c9ff187bc65d2d35f
2016-11-08 22:36:13 +00:00
Dmitry Frank
76bb35d5db Adjust udp_recv callback type for nRF5x
PUBLISHED_FROM=66db56192ae710e3f865fef47593b49e0ed4f133
2016-11-04 17:35:37 +00:00
Deomid Ryabkov
fd763846e5 TI Tiva TM4C129 support and example project
PUBLISHED_FROM=c3d59657adff247f565bf0be59192e32d5d0bbf6
2016-11-02 18:55:04 +00:00
Alexander Alashkin
f4f310cf51 Add WinCE example, update Mongoose for WinCE6.0
PUBLISHED_FROM=2a76ccddb62b63caeaca3785a07d7d0b94125eaf
2016-11-02 10:11:20 +00:00
Deomid Ryabkov
39a17f8a72 Add text msgs for HTTP status codes 400 and 503
PUBLISHED_FROM=1bd3308933354e147c4e8aa375728a1ede6d8ab4
2016-11-01 18:10:46 +00:00
Deomid Ryabkov
78454da3b3 BREAKING: Set MG_F_SEND_AND_CLOSE on UDP conns
Long-lived UDP "connections" i.e. interactions that involve more
than one request and response are rare, most are transactional:
response is sent and the "connection" is closed. Or - should be.
But users (including ourselves) tend to forget about that part,
because UDP is connectionless and one does not think about
processing a UDP request as handling a connection that needs to be
closed. Thus, we begin with SEND_AND_CLOSE flag set, which should
be a reasonable default for most use cases, but it is possible to
turn it off the connection should be kept alive after processing.

PUBLISHED_FROM=1677d8024aa9afa7e18d8a04d829b699f7f2f103
2016-11-01 14:26:00 +00:00
Deomid Ryabkov
6a12bd7abc Wrap LOG and DBG in do { ... } while(0)
PUBLISHED_FROM=c4f3d44ed16dba60db3198b90478c1b2e6f2a5c1
2016-10-31 20:11:37 +00:00
Deomid Ryabkov
92b15395a4 Add CS_P_NXP_LPC - platform def for NXP LPC MCUs
PUBLISHED_FROM=d6ed793313a98545d5a89faafc8526b658ffff66
2016-10-28 18:12:08 +00:00
Marko Mikulicic
f2e7facbc3 Fix master build
amalgamation, ansi C and queue.h usage issue

PUBLISHED_FROM=96a2b8a90d590da0f2d9939c1d2bc7a64d1fe36a
2016-10-28 14:29:58 +00:00
Sergey Lyubka
f1b4f0c463 Fix SEGFAULT in MQTT server
PUBLISHED_FROM=6455082726781aab819a7f8645e81adaa7fc7669
2016-10-28 14:12:40 +00:00
Dmitry Frank
c04e3f80b9 Make mongoose compile for nRF51
PUBLISHED_FROM=6af3ed56802d2619f673c36059370440a0c06397
2016-10-28 11:08:09 +00:00
Deomid Ryabkov
5c9f463cab Add MG_EV_HTTP_MULTIPART_REQUEST_END
This event is sent at the end of the request

PUBLISHED_FROM=0b841a26320e3edbf73126e2ed8d286d4e5f3fa8
2016-10-27 18:09:57 +00:00
Sergey Lyubka
3a8f47befd Mqtt: parsing auth info in the connect message
PUBLISHED_FROM=017e707ea2bd7b1d1972fbb92e5d98c74e17e9d0
2016-10-27 17:53:17 +00:00
Marko Mikulicic
a3e2a41834 Improve error reporting of mg_connect_http
PUBLISHED_FROM=8149fc5ab3c6f7d6ec360473f0e6847040ca820b
2016-10-27 15:22:31 +00:00
Dmitry Frank
b667bd709d Specify void arguments explicitly
PUBLISHED_FROM=345ac55417a9b012e89244d36bfb9ebf8e908637
2016-10-27 12:37:38 +00:00
Marko Mikulicic
a4c668e37a Expose reverse proxy API for dynamic mounts
PUBLISHED_FROM=00772400bce7c15368d91741092ebc8ab0842e19
2016-10-27 12:08:05 +00:00
Marko Mikulicic
900bbe724a Mongoose forwarding
PUBLISHED_FROM=51652f0157bb951a43508f0fe948c62c351e96ba
2016-10-26 14:52:10 +00:00
Alexander Alashkin
06b430e57f PIC32 Harmony TCP/IP support basics
PUBLISHED_FROM=31f8f61de954fa3a36ebad162bdb730c0db95b58
2016-10-26 12:00:13 +00:00
Sergey Lyubka
99377bdd30 Fix user registration flow
PUBLISHED_FROM=bac8c10063215f7f7163f607213d15a3c5f81552
2016-10-26 11:02:09 +00:00
Marko Mikulicic
c151f9bc59 Denoisify mongoose poll logging
PUBLISHED_FROM=ec1cb82cc2404cfe2abdf3bd445ddec3d4ff3e57
2016-10-25 16:55:50 +00:00
Deomid Ryabkov
204bf9acec Krypton + LWIP fixes
* Make kr_{send,recv} report status via return code instaed of errno
 * Move mg_if_* recv and connect callback invocation out of LWIP
   callbacks: these can be nested and we don't want that to happen
   to our callbacks. Instead, we post events for the event manager to
   process during next poll.

PUBLISHED_FROM=9b3c1de796fae381dea1641807e51d7a897a398e
2016-10-25 15:30:04 +00:00
Dmitry Frank
e3bac87016 Make mongoose compile with ARMCC
(It compiles, but doesn't really work yet)

PUBLISHED_FROM=0382d355a343bdab9c9eeed87229efe90c30c40b
2016-10-25 09:56:40 +00:00
Sergey Lyubka
7f99013179 Make backend build under win32, MSVC98
PUBLISHED_FROM=961e25e133eff8ee168557f186713d5babbd0c5f
2016-10-24 21:49:11 +00:00
Alexander Alashkin
835af2cae1 Fix CoAP/CC3200 compilation
PUBLISHED_FROM=00e4c01cc2bccd63b0f18b797e2c0503a489ef6f
2016-10-21 15:57:55 +00:00
Ilia Penev
fcc75c6a3f Fix CoAP packet size calculation
PUBLISHED_FROM=43532ec3951779d17438b457fe6de6dea8f514fd
2016-10-21 12:13:10 +00:00
Marko Mikulicic
5bd3df7a0f Fix mg_time on mbed and make DNS work around epoch
PUBLISHED_FROM=c1aeef9dc25baba794b3269b44441c5bafbca5a8
2016-10-20 22:36:39 +00:00
Dmitry Frank
85d6292b8f Add nRF port for Mongoose
Example is not yet added

PUBLISHED_FROM=2732386091a0d4cd8d4c6e64dc16467780ec72a5
2016-10-19 19:22:15 +00:00
Deomid Ryabkov
7b05d70042 CS_P_ESP_LWIP -> CS_P_ESP8266;add CS_P_NXP_KINETIS
LWIP part has been finally fully split from the ESP part, and ESP
platform defs reduced to bare minimum. It is now possible to use LWIP
in either low-level or socket mode without any ESP dependencies,
and NXP Kinetis platform is the first to make use of it.

PUBLISHED_FROM=4a9055897609c812296bdab5b4943ffde641ced2
2016-10-18 12:38:06 +00:00
Deomid Ryabkov
492dcdca8d MG_DISABLE_(DNS|(_SYNC)?_RESOLVER) -> MG_ENABLE_$1
Disable sync resolver by default.

PUBLISHED_FROM=dbaed194e5fe211c07564fe6880649a1aee7f662
2016-10-17 19:21:46 +00:00
Deomid Ryabkov
4ef3a778c1 Introduce MG_NET_IF var, replaces MG_NET_IF_*
Possible values:
  MG_NET_IF_SOCKET (1) - traditional BSD socket API
  MG_NET_IF_SIMPLELINK (2) - TI's SimpleLink socket interface
  MG_NET_IF_LWIP_LOW_LEVEL - a net_if implementation that uses LWIP's
    low-level API, when LWIP_SOCKET is not available.

PUBLISHED_FROM=a5c0aebb7b6bdb1f1f4cb3210763d16f3ab5e133
2016-10-17 18:21:58 +00:00
Dmitry Frank
4656e7b0dd Don't access nc->ssl if SSL is disabled
PUBLISHED_FROM=bdbd9416f73f84a3d8afbffe886d0922c36769d4
2016-10-17 10:07:37 +00:00
Alexander Alashkin
4216cf2ac1 Enable FS for WinCE
PUBLISHED_FROM=ec3ed105e29251bdd9b8ad08e8e56c0873ced8ae
2016-10-17 09:22:32 +00:00
Deomid Ryabkov
37e4f51668 MG_DISABLE_SOCKETPAIR -> MG_ENABLE_BROADCAST
PUBLISHED_FROM=81b6289a4b54043df557142f0de8cc66bc5190d4
2016-10-17 04:07:06 +00:00
Deomid Ryabkov
1dae0373c8 MG_DISABLE_POPEN -> MG_ENABLE_HTTP_SSI_EXEC
PUBLISHED_FROM=55b2b70a688234f6ebcfba37eced20ee5d5387a1
2016-10-16 23:21:56 +00:00
Deomid Ryabkov
e928f36456 MG_DISABLE_HTTP(|_SSI|_WEBSOCKET) -> MG_ENABLE$1
Factor out SSI and WS code from http.c

HTTP + WS are enabled by default, but MQTT is built without HTTP
support as a compilation test.

PUBLISHED_FROM=925ed9a55abb193ed7deac1c9675a0e5b35dca50
2016-10-14 17:06:19 +00:00
Alexander Alashkin
fcb94a1742 Port Mongoose to WinCE, part I
PUBLISHED_FROM=292d73fa3e90377b1f929ae47ae1073dab5a4089
2016-10-14 13:37:07 +00:00
Deomid Ryabkov
8ff010ca0f MG_DISABLE_FILESYSTEM -> MG_ENABLE_FILESYSTEM
PUBLISHED_FROM=026810475d98df117ab1dadf40276759190aad19
2016-10-14 12:37:13 +00:00
Deomid Ryabkov
241090a82b CS_DISABLE_(STDIO|HEXDUMP) -> CS_ENABLE_$1
PUBLISHED_FROM=9fd0cebfa8df53b5d9574a8d013305ddda5e7a18
2016-10-14 10:22:30 +00:00
Deomid Ryabkov
3b69f5d500 MG_DISABLE_DAV -> MG_ENABLE_HTTP_WEBDAV
PUBLISHED_FROM=62267ea0a8e10d8ba7bad590d1a56b179bcffce9
2016-10-14 07:06:13 +00:00
Deomid Ryabkov
b298d46a40 MG_DISABLE_MQTT -> MG_ENABLE_MQTT
PUBLISHED_FROM=34e6028b68e286f81be7ba0f8ae73b760f144131
2016-10-13 21:08:22 +00:00
Deomid Ryabkov
75059d1bdc Rename MG_DISABLE_CGI -> MG_ENABLE_CGI
Also factor out CGI-related code from http.c, it's getting too big.

Build tests with -Wundef

PUBLISHED_FROM=a1e82fafba73812c249db0b49c59d1b48417b60d
2016-10-13 19:22:50 +00:00
Deomid Ryabkov
15e9a92798 Run V7 tests with -Wundef
PUBLISHED_FROM=e2375c5b10be12a75f6a5f9df56ebe9f5faa9331
2016-10-13 19:07:34 +00:00
Deomid Ryabkov
bafc30bec6 Change from using #ifdef to #if for features tests
"#if FOO" still works with simple -DFOO, but gives more flexibility.
Specifically, if user expressed no preference (FOO is not defined),
we can apply reasonable defaults (this is the legitimate use of ifdef).

In short, from now on, please use

 #if MG_ENABLE_FOO

instead of

 #ifdef MG_ENABLE_FOO

Since we are all used to #ifdef, this change also adds a precommit check
to police this. Specifically, in *.h and *.c files that are Copyright Cesanta,
"ifdef" and "if defined()" are not allowed to be used with macros that contain
ENABLE or DISABLE, unless the like also contains "ifdef-ok".

Hence, if you are sure you want to use ifdef, use this:

 #ifdef MG_ENABLE_FOO /* ifdef-ok */

PUBLISHED_FROM=9be829448f53cff575d6cae8b9945fb12531c15a
2016-10-13 18:07:25 +00:00
Deomid Ryabkov
ab48174bac esp_mg_net_if refactoring: split LWIP & ESP parts
esp_mg_net_if was a rat's nest of mongoose net_if and event manager
implementaions and the event loop task for the ESP8266 miot port.
From that, pieces that are related to LWIP support have been pulled out,
separated into net_if and event manager files, and event loop task
has been moved under the miot esp8266 dirrectory.

This is done to facilitate LWIP code reuse. This may not be the end of
it, but it's a start.

Note: custom retransmit logic has been removed for now. Can be
reintroduced later is necessary.

PUBLISHED_FROM=fd5bbf75714583ce95776d4c76b6c5b5dc535364
2016-10-11 18:38:10 +00:00
Deomid Ryabkov
f9a6403b11 Add MG_EV_SSI_CALL_CTX
This is the variant of MG_EV_SSI_CALL with context of the SSI call being
processed in addition to the tag argument. Specifically, call handler
now gets access to the HTTP request and the name of the file being processed.

MG_EV_SSI_CALL is preserved for backward compatibility.

PUBLISHED_FROM=eeea7487c062505abdb23b6f64994ff7a6b60ff8
2016-10-04 23:51:29 +00:00
Deomid Ryabkov
460d95afc5 Add mg_http_send_redirect and make examples use it
PUBLISHED_FROM=f45e06aeba1c00212078d539b6f74cb8bd054326
2016-09-30 11:22:00 +00:00
Alexander Alashkin
8f522048d8 Use gethostbyname for localhost
PUBLISHED_FROM=97c58e8624e0d4fa0f043acf6b20e2a1a5ca1b51
2016-09-30 06:50:52 +00:00
Marko Mikulicic
286fa90ee9 Simple mDNS + DNS-SD impl
Main TODOs:
1. the spec requires the impl to resend the reply once and
   to send gratuitous updates

2. advertise our clubby services as DNS-SD sub-services.

---

Tested with:

1. https://play.google.com/store/apps/details?id=com.grokkt.android.bonjour&hl=en
2. https://play.google.com/store/apps/details?id=com.druk.bonjour.browser&hl=en
3. osx `dns-sd`

Works well enough; it doesn't have some glitches due the fact that we
don't retransmit yet and we don't send gratuitous updates.

PUBLISHED_FROM=38d7a50beb274d4aeeda5b0b58e44dfa0789da84
2016-09-28 08:51:47 +00:00
Deomid Ryabkov
4d76a3be4c Amalgamation changes - clean up paths
Make paths embedded in amalgamated files nice and relative.
This facilitates subsequent clean un- and re-amalgamation.

PUBLISHED_FROM=d83e6000617c54ceaeb78b80c25814996043fe66
2016-09-27 05:06:32 +00:00
Alexander Alashkin
2e748fdbf1 Fix handles leak in CGI
PUBLISHED_FROM=6052b7bfec6af33328cbe369da60e9672ebac437
2016-09-23 15:06:46 +00:00
Deomid Ryabkov
6c99691d1c Add build target for leenoox (using docker)
PUBLISHED_FROM=46a7902a727e0ba34c3dbbe5ee04d5119afbaaff
2016-09-23 15:06:45 +00:00
Alexander Alashkin
fd067c8077 Fix handles leak in CGI
PUBLISHED_FROM=6052b7bfec6af33328cbe369da60e9672ebac437
2016-09-23 15:06:02 +00:00
Alexander Alashkin
0ec1a141f1 Fix mg_http_parse_headers
PUBLISHED_FROM=7e88f60283d499732e8df663814067849d9567bb
2016-09-23 10:21:36 +00:00
Deomid Ryabkov
7414a4fb06 Stop pretending that sl_* API is BSD-compatible
PUBLISHED_FROM=355fea9a5a75ac926d4c64d41828ebcd96c04080
2016-09-22 19:51:06 +00:00
Deomid Ryabkov
abbd44e276 Fix WS handshake nonce generation
PUBLISHED_FROM=ae8d436db9aee9aec7b5ac1cbee6bc4e32d8c6cf
2016-09-22 16:05:38 +00:00
Sergey Lyubka
13e80e6bd5 Add HTTP examples for MIOT
PUBLISHED_FROM=a7ca2e0b705390b32bf2bac44aaaf60c6fcc8522
2016-09-22 14:21:11 +00:00
Alexander Alashkin
238bf1a29e Fix MSVC2015 warnings in mongoose
PUBLISHED_FROM=9e2d5c45d112b9e9493d995b12fe989e93d66d5b
2016-09-13 08:51:20 +00:00
Alexander Alashkin
4cbf81da59 Use user timeout in multithreading polling
PUBLISHED_FROM=dbf75bfba087f1b0aa0531e5003ba3e69ed1a6ab
2016-09-12 14:21:05 +00:00
Alexander Alashkin
d9b7ec18e7 Add MG_F_ENABLE_BROADCAST option
PUBLISHED_FROM=293a54ab09e6879b6f0c36975a137eeaeff92098
2016-09-12 12:36:56 +00:00
Alexander Alashkin
ffed9c4d8c Copy flags for accepted connection
PUBLISHED_FROM=4787d59fdc9f4da525ddfae46e5203d06a596ef4
2016-09-12 10:51:11 +00:00
Dmitry Frank
2a541175b5 Use void arguments list consistently in C code
On my way, fixed a couple of cases where we had `()` in the header, and
non-empty argument list in the source file.

PUBLISHED_FROM=5519526cf84e2bbd425a726fcc112fea1a95cbf1
2016-09-05 15:51:19 +00:00
Alexander Alashkin
5f93f7162f Add STM32F4/CC3100 example & Co
PUBLISHED_FROM=7f805d89dcb795c9b3ee637ef1dbdcfcf3323469
2016-09-05 15:06:21 +00:00
Sergey Lyubka
12437fd7fe Refactor Mongoose documentation
PUBLISHED_FROM=e9a4e5c7b4a1d03b93a2a79e29de19e60e919929
2016-09-01 14:35:02 +00:00
Deomid Ryabkov
844c7787f9 Ignore SL_EAGAIN
It was observed that sl_Send can return SL_EAGAIN, despite the fact that
we only call write_to_socket if it was reported as writeable.

PUBLISHED_FROM=e4cbacb3f16bb7abb479222d7dcbfbe113a39161
2016-08-29 18:20:54 +00:00
Deomid Ryabkov
0fe9ec1499 C Clubby refactoring
Complete rewrite of the C Clubby implementation: it is now modeled after
the Go implementation, with a slight difference that codec and channel
are the same object (something we should probably do in Go as well, as
we only have a single type of channel so far, which is used with all
types of codecs).

This implementation also comes with a new external API,
which is hopefully cleaner and easier to use (see mg_clubby.h).

In this PR I am not adding any new types of channels, but a UART channel
as well as websocket listener channel will be added after this lands.

PUBLISHED_FROM=d545d4bb6434e2a02ad159f9e4b64e594a4797e7
2016-08-29 11:20:54 +00:00
Alexander Alashkin
2deaf084e4 Fix clang -std=c99 compilation
PUBLISHED_FROM=fc3f24d40f92f206e5de4a2fd15100430db87717
2016-08-24 12:50:59 +00:00
Artem Bulavin
fd839f1827 Pointer to int casting warning
PUBLISHED_FROM=6bf2a710edaae6133d68eaf900ede14bba75ad5a
2016-08-19 09:05:55 +00:00
Alexander Alashkin
f149f4aab1 Remove cs_dbg.h from amalgamated headers
PUBLISHED_FROM=993c4b1bec363e3f7975b83710e694792bedf5b3
2016-08-18 14:06:18 +00:00
Alexander Alashkin
8cdd19bcae Call MG_EV_ACCEPT on spawn
PUBLISHED_FROM=f1b4ce4334d24bf613db88ccb28cb3668390ce1d
2016-08-16 09:36:05 +00:00
Alexander Alashkin
2efc859829 Fix mt
PUBLISHED_FROM=6e33f546c4d096ef03103f6010124e5d568700b0
2016-08-15 16:21:14 +00:00
Deomid Ryabkov
5fa544fc78 Make mg_http_serve_file public
A way to serve a single, specific file as opposed to the hairy monster
that is mg_serve_http.

PUBLISHED_FROM=6ed1bc487b9d41d212a5907337182f23b040aecf
2016-08-09 10:51:02 +00:00
Deomid Ryabkov
1070dd2d87 Fix overrun in url rewrites, add tests
PUBLISHED_FROM=03dc62aa69dddcbe41d5bc5c014de248332da918
2016-08-09 10:06:12 +00:00
Deomid Ryabkov
447bf4adb0 Compile examples with -Werror
PUBLISHED_FROM=5a24bda9029db3fc7bf04dc871656d65d551f4ab
2016-08-08 10:36:19 +00:00
Marko Mikulicic
a6230bafe7 Make unamalgamated build work with bazel
PUBLISHED_FROM=c6756bc74e6c25e4c120024e3ee2e3406068ad92
2016-07-30 02:21:16 +00:00
Deomid Ryabkov
69f810febc Remove debug that slipped into prod code
PUBLISHED_FROM=7bacb1af60e85e4ed56a600fa3d1dbba1679db59
2016-07-26 18:39:48 +00:00
Deomid Ryabkov
15643f8e67 Use rand() instead of random(), it's more standard
Remove the random() stubs from the codebase

PUBLISHED_FROM=0f56ec7dffa0af1f5061a17d8801239d6f0e32a5
2016-07-22 11:06:16 +00:00
Deomid Ryabkov
1c80fc28ee Destroy net interface before invoking MG_EV_CLOSE
So that socket/connection/whatever is really closed by the time user code is run.

Speed up test_http_endpoints by using appropriate wait conditions.

PUBLISHED_FROM=5fc8a772cc2a9c3b8c9dbddde9f99b41ce4d334c
2016-07-20 14:52:12 +00:00
Deomid Ryabkov
256aa0296d Fix compilation for non-MGIOT projects
That don't have CONSOLE_UART defined

PUBLISHED_FROM=7930bb639baf81cff8ce53c6f81e9739668aae08
2016-07-15 13:34:59 +00:00
Deomid Ryabkov
2eb506c5e0 Make console output in SLFS adapter overrideable
PUBLISHED_FROM=455184fbe730cf62340046c73ffd8ae4b0e0a2c1
2016-07-15 13:19:51 +00:00
Deomid Ryabkov
9f78a2902b Fix SSL stuff
Do not use CA bundle on CC3200, it doesn't work.
Make ssl_ca_cert = "*" mean "no verification" and make sure
SSL is enabled on the connection when it's required, even w/o verification.

PUBLISHED_FROM=c8710a5d24ecfe174ef45b7f81c114d41faf5c12
2016-07-14 13:19:55 +00:00
Deomid Ryabkov
ab208b71c4 Do not define rename() when compiling with TI libc
PUBLISHED_FROM=e9878fc5d55b0b2da854573a7a84e8e14e2f301d
2016-07-13 19:49:47 +00:00
Alexander Alashkin
68dd8d277d Get rid of ubjson
PUBLISHED_FROM=e6f1dca95ec7ed3795adf493cca9cdcdc07381f5
2016-07-12 20:49:59 +00:00
Deomid Ryabkov
68437de416 Fix handling of socket write errors
PUBLISHED_FROM=7264edfb3b8e4e37f15f2993f479dfe0a9550b1d
2016-07-12 11:04:59 +00:00
Deomid Ryabkov
459cd1b095 Properly override rename on Newlib
Newlib implements rename as _link and _unlink, not _rename.
There is no _link on either SLFS or SPIFFS, so override rename directly.

PUBLISHED_FROM=ebb54664f8a3c8664ecab1fac021bef286a0e230
2016-07-11 16:49:56 +00:00
Deomid Ryabkov
fc0bf1953a Fix and improve sorting on Mongoose index pages
Remember sorting settings in url fragment, reverse order on repeated
header click.

PUBLISHED_FROM=faa033eddc86d0aafc12a86aea4145646ea2c89c
2016-07-07 15:49:59 +00:00
Deomid Ryabkov
c907e6c5fb Commonize mg_str
PUBLISHED_FROM=0e6a1c1a2356c1e12580e498c64ba7be367f601c
2016-07-06 23:49:57 +00:00
Deomid Ryabkov
29b3950ee7 Handle SimpleLink restarts in Mongoose
SimpleLink restart invalidates all sockets.
Listeners are restarted, outgoing connections are closed.

PUBLISHED_FROM=15567dfb822bffbd44d39ba0e69a7ac64fd7a1c8
2016-07-06 13:56:50 +00:00
Deomid Ryabkov
0e0c6b8357 Fix off-by one
cesanta/mongoose#677

PUBLISHED_FROM=4b62bdefac08fa3bedf511dc4d6f7463af3325fc
2016-07-06 13:56:48 +00:00
Sergey Lyubka
b7a0748312 Ditch JSON-RPC from mongoose
PUBLISHED_FROM=89b978c02be2f10eb930ff13673d45249fd67763
2016-07-01 11:35:18 +00:00
Alexander Alashkin
421b420a0c Fix mp+keepalive combination
PUBLISHED_FROM=dbfcfa91ad85d6447726d0d7e9fe15709f4c4646
2016-06-29 23:12:25 +03:00