Compare commits

...
196 Commits
Author SHA1 Message Date
Alexander Alashkin 0a8f839281 Mongoose 6.6
PUBLISHED_FROM=23d031720d8d6e170eab6bd615797f33e36a6701
2016-10-12 10:06:27 +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
Marko Mikulicic 4439251f17 Add MBED as platform
Currently this allows V7 to be built on MBED; more
work is likely required to port mongoose.

PUBLISHED_FROM=32cd0a38349c8e9019af46d4ce7e1429e660db25
2016-10-11 10:29:41 +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 786f46c655 Update TI compiler to 5.2.8
PUBLISHED_FROM=75a0ee6e842da6c8f9e8f1eb85165b64fada0d6a
2016-10-03 15:06:53 +00:00
Sergey Lyubka 5ebd9fe7a5 uart-to-websocket page content changes
PUBLISHED_FROM=e8db78b70a80ef63f1f6090b1ad5d16315e8f8c9
2016-10-03 15:06:52 +00:00
Deomid Ryabkov 2302ae5e88 Update TI compiler to 5.2.8
PUBLISHED_FROM=75a0ee6e842da6c8f9e8f1eb85165b64fada0d6a
2016-10-03 15:06:16 +00:00
Deomid Ryabkov 8b12263dbc Fix mg_http_send_redirect doc
PUBLISHED_FROM=77cd3df9959b0e3a2550d1581586e69878bbee0d
2016-09-30 13:06:39 +00:00
Alexander Alashkin 376d2666a5 Add PIC32MX/CC3100 mqtt_client example
PUBLISHED_FROM=cda885a9dc5d1203b7b59b13ea7fd7934b31260a
2016-09-30 12:39:35 +00:00
Deomid Ryabkov d90622630f Link MIOT for Linux statically
PUBLISHED_FROM=4f0adab828ebf06dbc3e0c4333bf0053f374b62f
2016-09-30 12:39:32 +00:00
Alexander Alashkin da447b1067 Add PIC32MX/CC3100 mqtt_client example
PUBLISHED_FROM=cda885a9dc5d1203b7b59b13ea7fd7934b31260a
2016-09-30 12:37:08 +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
Deomid Ryabkov 147c095105 Report errors in the netcat example
PUBLISHED_FROM=f43dc48512ff13028a57571b537c41d9658034b5
2016-09-29 12:05:53 +00:00
Alexander Alashkin fecb11f2fa Add CoAP server example doc. Closes cesanta/dev#4917
PUBLISHED_FROM=ee7728db61721c0628a00ed702a47f7382ad7cd7
2016-09-29 11:50:59 +00:00
Alexander Alashkin 56e50c2dbe Add CoAP client example doc
PUBLISHED_FROM=51fd5cd50ae8c9fce43d95d06fec2e7582018d00
2016-09-29 11:05:59 +00:00
Deomid Ryabkov c1b5e9b260 Rename MSP432 example project
So they are distinct from CC3200 projects during import

Also update compiler version (5.2.7 -> 5.2.8)

PUBLISHED_FROM=23834212eb51ad068579726a2870e8e6ae87ab9c
2016-09-28 12:51:35 +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 d63fb70c69 Publish the amalgamation tools
PUBLISHED_FROM=27ed0bd32e33252495b92361d2943a3450448f62
2016-09-27 15:36:56 +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
Dmitry Frank d9c612ef2b Fix miot serial communication on Windows
PUBLISHED_FROM=426ff040865ea9626ba62bcbca3aa84fb40fd3ea
2016-09-26 20:21:42 +00:00
Sergey Lyubka 3b3ca1c1b3 Update README.md 2016-09-26 15:46:44 +01: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
Marko Mikulicic 04012760d1 Add small multicast server demo for mongoose
PUBLISHED_FROM=c5f6b0c64bc1e43030743b6aae5d06ae231df5dc
2016-09-23 10:21:37 +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
Deomid Ryabkov ffa981d172 Update CC3200 sensor demo example
PUBLISHED_FROM=9e29cac6a7d4b632b7f4a3ab0fe5411368ad0f5a
2016-09-16 21:20:56 +00:00
Deomid Ryabkov 806f07db67 Fix MG_hello project build
PUBLISHED_FROM=450e5c045b6515fba0e0614c6d76a58712c72160
2016-09-15 13:36:09 +00:00
Alexander Alashkin 6746933a3d Fix Windows compilation
PUBLISHED_FROM=04bcd98025263f32d337730cf179bdfc35b683f1
2016-09-15 12:21:53 +00:00
Dmitry Frank 8cb2833fa7 Implement miot dev call
PUBLISHED_FROM=40d62ce03a4f739b458076395941e4ad7c932fb3
2016-09-15 12:21:52 +00:00
Alexander Alashkin 1730f3c0c9 Fix Windows compilation
PUBLISHED_FROM=04bcd98025263f32d337730cf179bdfc35b683f1
2016-09-15 12:21:21 +00:00
Sergey Lyubka d6dda04f4f Update mg_mgr docstring
PUBLISHED_FROM=da57dfe52e315dc1901d761289f0445be6e93cea
2016-09-13 11:37:47 +00:00
Artem Bulavin 1b0825ef4b Docs deployment via docs/make_doc
PUBLISHED_FROM=da5f7f80a9876ac4f1889a1176a3048f47980659
2016-09-13 11:37:46 +00:00
Sergey Lyubka 7249b2bd5f Update mg_mgr docstring
PUBLISHED_FROM=da57dfe52e315dc1901d761289f0445be6e93cea
2016-09-13 11:36:17 +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
Sergey Lyubka 0dc0c5a0e0 Add WebSocket support to the netcat example
PUBLISHED_FROM=c494ab910d0b1b98ea6ea4024450c60d0abff01d
2016-09-09 22:29:34 +00:00
Dmitry Frank 57f826ece1 Implement miot cloud group add, list, delete
PUBLISHED_FROM=4b6f7b6fb4559e085c93f5f8827b8fae1701de70
2016-09-09 22:29:33 +00:00
Sergey Lyubka 729bdebc50 Add WebSocket support to the netcat example
PUBLISHED_FROM=c494ab910d0b1b98ea6ea4024450c60d0abff01d
2016-09-09 22:20:58 +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 3640554503 Add DNS server example
PUBLISHED_FROM=0d71533fd475c152c29fe304ca95559512a6059d
2016-09-02 21:06:16 +00:00
Sergey Lyubka 12437fd7fe Refactor Mongoose documentation
PUBLISHED_FROM=e9a4e5c7b4a1d03b93a2a79e29de19e60e919929
2016-09-01 14:35:02 +00:00
Deomid Ryabkov 4120f953c7 Report bind error in simplest_web_server_ssl
PUBLISHED_FROM=73e7ed5dd69cbca00ad6f67125915fbfb296770b
2016-08-31 12:30:22 +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
Sergey Lyubka b3fb21dacc Add DLL building example
PUBLISHED_FROM=20d24793d766ee289c6bde95bd5ad01202cd614b
2016-08-26 09:21:09 +00:00
Alexander Alashkin 2deaf084e4 Fix clang -std=c99 compilation
PUBLISHED_FROM=fc3f24d40f92f206e5de4a2fd15100430db87717
2016-08-24 12:50:59 +00:00
Deomid Ryabkov 1b324510cc Add simplest_web_server_ssl example
PUBLISHED_FROM=8945dc72ce22d48c582e7cdd01348494677ac5bb
2016-08-22 22:20:45 +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
Marko Mikulicic af6fc64ab9 Add restart flag to ourci workers
PUBLISHED_FROM=f85aaf2215f8323866eab9fb5143407b44fa1959
2016-08-16 17:21:03 +00:00
Artem Bulavin ff159bf30a Simple mongoose http urls crawler
PUBLISHED_FROM=4eead54610606827963e7c244fcd8ab9a13d4c07
2016-08-16 14:36:11 +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
Alexander Alashkin d4a8351464 Remove port :5000 from docker.cesanta in Makefiles
PUBLISHED_FROM=b2454104b99100f23db0777f874ab8a33727acca
2016-08-12 15:36:30 +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 af98854ce4 Delete old cookie_auth example
PUBLISHED_FROM=c118b2796f697e8d5493bb3d534cee7406060c1a
2016-08-08 14:06:05 +00:00
Deomid Ryabkov 7cace648c0 Improve cookie auth example
Use templated index page and SSI calls instead of hard-coded html

PUBLISHED_FROM=eade9dfe283952ed5465cd0ff1924f61a14dea0c
2016-08-08 11:28:52 +00:00
Deomid Ryabkov 447bf4adb0 Compile examples with -Werror
PUBLISHED_FROM=5a24bda9029db3fc7bf04dc871656d65d551f4ab
2016-08-08 10:36:19 +00:00
Deomid Ryabkov 6572c1c692 Add a cookie auth and session management example
PUBLISHED_FROM=243437cf7d48b04aef3896bc4c5d4010975299a4
2016-08-08 10:36:19 +00:00
Dmitry Frank 7b48859f8d Fix mongoose comment a little
PUBLISHED_FROM=542e7c82fa494bef52222495301ab53dce43cd8f
2016-08-04 19:51:10 +00:00
Marko Mikulicic a6230bafe7 Make unamalgamated build work with bazel
PUBLISHED_FROM=c6756bc74e6c25e4c120024e3ee2e3406068ad92
2016-07-30 02:21:16 +00:00
Deomid Ryabkov cc8f1466c7 Turn on func. sections + dead section elimination
In CCS example projects

PUBLISHED_FROM=b3ab112f74ae475cb93bf06fdb7db811bbb99a59
2016-07-27 20:36:15 +00:00
Deomid Ryabkov 69f810febc Remove debug that slipped into prod code
PUBLISHED_FROM=7bacb1af60e85e4ed56a600fa3d1dbba1679db59
2016-07-26 18:39:48 +00:00
Dmitry Frank e5da7440d7 Bring back JS precompilation to CC3200
We haven't actually _fixed_ evaluation of precompiled bcode from
non-mmapped memory: we just never free it. For sane use case (do not
evaluate the same file more than once) it should be acceptable.

PUBLISHED_FROM=a9ca2d8fa72e9c40c93415d060ee8db697caa225
2016-07-26 15:36:00 +00:00
Dmitry Frank 849ec1684a Apply Mongoose docs edits by Ev
PUBLISHED_FROM=5cd78790a03580aa23dd3d2d8b825ad449083cc2
2016-07-26 15:06:04 +00:00
Alexander Alashkin 4f210cd8eb Fix error messages and more
PUBLISHED_FROM=11c57fc5ece01686e9cecab5e3bfce54a2825836
2016-07-25 17:21:23 +00:00
Evelyn 285f75764c Update mg_match_prefix.md 2016-07-25 17:37:20 +01:00
Evelyn 3586203753 Update mg_next_comma_list_entry.md 2016-07-25 17:36:46 +01:00
Alexander Alashkin e406de7e00 Remove extra error message
PUBLISHED_FROM=8b7fcfc1bc32ff9ff38e2904ddb730c83bf9fae4
2016-07-25 16:36:18 +00:00
Evelyn 53ed8502c9 Update mg_is_big_endian.md 2016-07-25 17:35:41 +01:00
Evelyn ac8c756879 Update mg_avprintf.md 2016-07-25 17:35:27 +01:00
Evelyn 07faacdaf9 Update mg_hexdump_connection.md 2016-07-25 17:34:35 +01:00
Evelyn 8464844518 Update mg_hexdump.md 2016-07-25 17:34:03 +01:00
Evelyn fe2d1ff027 Update mg_sock_addr_to_str.md 2016-07-25 17:33:17 +01:00
Evelyn 8d129e359e Update mg_conn_addr_to_str.md 2016-07-25 17:33:03 +01:00
Evelyn 39aa56457b Update mg_start_thread.md 2016-07-25 17:32:22 +01:00
Evelyn 8491d5da8b Update mg_open.md 2016-07-25 17:31:57 +01:00
Evelyn 681196e2c8 Update mg_fopen.md 2016-07-25 17:31:43 +01:00
Evelyn 836ad5ebab Update mg_stat.md 2016-07-25 17:31:28 +01:00
Evelyn a3ea1eddfb Update mg_base64_decode.md 2016-07-25 17:30:59 +01:00
Evelyn a2c06ac6ba Update mg_skip.md 2016-07-25 17:30:04 +01:00
Evelyn a5c697fa2d Update mg_coap_parse.md 2016-07-25 17:28:59 +01:00
Evelyn be199b4fe9 Update mg_coap_send_ack.md 2016-07-25 17:28:05 +01:00
Evelyn cc15320cfe Update mg_coap_send_message.md 2016-07-25 17:27:50 +01:00
Evelyn 70bae59ec6 Update mg_coap_free_options.md 2016-07-25 17:27:31 +01:00
Evelyn d4f3361805 Update mg_coap_add_option.md 2016-07-25 17:26:59 +01:00
Evelyn 332c855d40 Update mg_set_protocol_coap.md 2016-07-25 17:26:43 +01:00
Evelyn 01e3fa4d13 Update mg_mqtt_next.md 2016-07-25 17:26:26 +01:00
Evelyn 15a0f7a00a Update mg_mqtt_broker.md 2016-07-25 17:26:05 +01:00
Evelyn a751adba2a Update mg_mqtt_broker_init.md 2016-07-25 17:25:21 +01:00
Evelyn 10eed010df Update mg_mqtt_next_subscribe_topic.md 2016-07-25 17:25:00 +01:00
Evelyn 033ca26216 Update mg_mqtt_pong.md 2016-07-25 17:24:19 +01:00
Evelyn 40793cbdce Update mg_mqtt_ping.md 2016-07-25 17:24:10 +01:00
Evelyn 48a1b2ec75 Update mg_mqtt_unsuback.md 2016-07-25 17:24:03 +01:00
Evelyn 1a55556c66 Update mg_mqtt_suback.md 2016-07-25 17:23:53 +01:00
Evelyn 3edd3ccbe6 Update mg_mqtt_pubcomp.md 2016-07-25 17:23:39 +01:00
Evelyn 194933e037 Update mg_mqtt_pubrel.md 2016-07-25 17:23:30 +01:00
Evelyn 38deaedaef Update mg_mqtt_pubrec.md 2016-07-25 17:23:15 +01:00
Evelyn fc3dd5900c Update mg_mqtt_puback.md 2016-07-25 17:23:06 +01:00
Evelyn b1213425d0 Update mg_mqtt_connack.md 2016-07-25 17:22:53 +01:00
Evelyn 40f0b450a8 Update mg_mqtt_disconnect.md 2016-07-25 17:22:43 +01:00
Evelyn 0bab3977a8 Update mg_mqtt_unsubscribe.md 2016-07-25 17:22:35 +01:00
Evelyn 2c46760b77 Update mg_mqtt_subscribe.md 2016-07-25 17:22:22 +01:00
Evelyn 878c9ae5ae Update mg_mqtt_publish.md 2016-07-25 17:22:11 +01:00
Evelyn c8553de09e Update mg_send_mqtt_handshake_opt.md 2016-07-25 17:22:02 +01:00
Evelyn 6738858e11 Update mg_send_mqtt_handshake.md 2016-07-25 17:21:52 +01:00
Evelyn 61cd6ab86e Update mg_set_protocol_mqtt.md 2016-07-25 17:21:43 +01:00
Evelyn 77704b669a Update mg_dns_send_reply.md 2016-07-25 17:21:22 +01:00
Evelyn 770be613d7 Update mg_dns_reply_record.md 2016-07-25 17:20:33 +01:00
Evelyn 9790366449 Update mg_dns_create_reply.md 2016-07-25 17:19:44 +01:00
Evelyn 89f0a8c530 Update mg_set_protocol_dns.md 2016-07-25 17:18:19 +01:00
Evelyn f72a06e25a Update mg_dns_uncompress_name.md 2016-07-25 17:17:35 +01:00
Evelyn 8b975533e5 Update mg_dns_encode_record.md 2016-07-25 17:15:49 +01:00
Evelyn b32f7a9b57 Update mg_dns_copy_questions.md 2016-07-25 17:14:48 +01:00
Evelyn e1e0083897 Update mg_dns_insert_header.md 2016-07-25 17:14:27 +01:00
Evelyn ca08ac0e3c Update mg_send_dns_query.md 2016-07-25 17:14:13 +01:00
Evelyn a5b85b4462 Update mg_dns_parse_record_data.md 2016-07-25 17:14:03 +01:00
Deomid Ryabkov 3feab3a16d No-JS mode refactoring
Now JS is controlled with a make variable as opposed to a proproc define.

This allows skipping compiling a whole bunch of files when JS is
disabled, e.g. whole freezing step on ESP, or compiling v7.c on CC3200
which takes a while only to be discarded in its entirety later.

Var name is SJ_ENABLE_JS (note change from disable logic to enable to be in line with other stuff). Default is 1, meaning JS is enabled.

Also changed clubby knob in the same way: SJ_ENABLE_CLUBBY, default is 1 as well.

PUBLISHED_FROM=105277e9536e423d6363a51ff9acea9550a9c496
2016-07-25 15:06:00 +00:00
Evelyn 5d76e57b81 Update mg_set_protocol_http_websocket.md 2016-07-25 15:08:27 +01:00
Alexander Alashkin 9101cd0339 Use lld for ID
PUBLISHED_FROM=1246247fc29eb9a75b986ff7bb2d2350a52c03fc
2016-07-22 16:26:31 +00:00
Evelyn 4b2d3f5f5b Update mg_http_check_digest_auth.md 2016-07-22 16:23:52 +01:00
Evelyn 482a471abb Update mg_file_upload_handler.md 2016-07-22 16:23:16 +01:00
Evelyn 4d90bb0d02 Update mg_register_http_endpoint.md 2016-07-22 16:22:15 +01:00
Evelyn 202dfc18be Update mg_serve_http.md 2016-07-22 16:21:47 +01:00
Evelyn 13f4742699 Update mg_connect_http_opt.md 2016-07-22 16:21:30 +01:00
Evelyn 33e769bd75 Update mg_connect_http.md 2016-07-22 16:20:58 +01:00
Evelyn 992f3000ef Update mg_http_create_digest_auth_header.md 2016-07-22 16:20:04 +01:00
Evelyn 7ea4adae5e Update mg_url_decode.md 2016-07-22 16:19:38 +01:00
Evelyn 5ed9991135 Update mg_get_http_var.md 2016-07-22 16:18:42 +01:00
Evelyn dc2527c11f Update mg_parse_multipart.md 2016-07-22 16:17:58 +01:00
Evelyn bee95654f3 Update mg_http_parse_header.md 2016-07-22 16:17:08 +01:00
Evelyn 48296bb1cf Update mg_get_http_header.md 2016-07-22 16:16:21 +01:00
Evelyn 1ee9735354 Update mg_parse_http.md 2016-07-22 16:16:00 +01:00
Evelyn f8da303ca1 Update mg_printf_html_escape.md 2016-07-22 16:15:26 +01:00
Evelyn 6ae6ee9fd2 Update mg_send_head.md 2016-07-22 16:15:01 +01:00
Evelyn a11eafc5b3 Update mg_send_response_line.md 2016-07-22 16:13:59 +01:00
Evelyn efe53b57e4 Update mg_printf_http_chunk.md 2016-07-22 16:13:38 +01:00
Evelyn e2330944d4 Update mg_send_http_chunk.md 2016-07-22 16:13:20 +01:00
Evelyn 1c18906db7 Update mg_printf_websocket_frame.md 2016-07-22 16:12:07 +01:00
Evelyn 873ceb48bd Update mg_send_websocket_framev.md 2016-07-22 16:11:32 +01:00
Evelyn a48b955d89 Update mg_send_websocket_frame.md 2016-07-22 16:11:11 +01:00
Evelyn b92fae2bfb Update mg_connect_ws_opt.md 2016-07-22 16:10:30 +01:00
Evelyn 156be17191 Update mg_connect_ws_opt.md 2016-07-22 16:10:12 +01:00
Evelyn 92290cfe81 Update mg_connect_ws.md 2016-07-22 16:09:47 +01:00
Evelyn 29725c97f1 Update mg_send_websocket_handshake2.md 2016-07-22 16:08:59 +01:00
Evelyn 56b9cd14cb Update mg_send_websocket_handshake.md 2016-07-22 16:07:44 +01:00
Evelyn 3550cc8f48 Update mg_set_protocol_http_websocket.md 2016-07-22 16:03:38 +01:00
Deomid Ryabkov 6a3d01ee6b Depend on v7.c properly
PUBLISHED_FROM=cf49d0d345e4a7607c535f9578b8ed4160f2fccd
2016-07-22 14:31:13 +00:00
Evelyn 27986213aa Update mg_check_ip_acl.md 2016-07-22 15:23:11 +01:00
Evelyn a2d07ef983 Update mg_check_ip_acl.md 2016-07-22 15:13:59 +01:00
Evelyn 3cf4e32d9f Update mg_event_handler_t.md 2016-07-22 15:06:40 +01:00
Evelyn a54584b716 Update mg_set_timer.md 2016-07-22 15:06:00 +01:00
Evelyn 51907e2642 Update mg_enable_javascript.md 2016-07-22 15:04:58 +01:00
Evelyn 5dd9d37ef2 Update mg_enable_multithreading.md 2016-07-22 15:04:01 +01:00
Evelyn f900854e0d Update mg_socketpair.md 2016-07-22 14:54:30 +01:00
Evelyn d20e94f763 Update mg_printf.md 2016-07-22 14:53:54 +01:00
Evelyn 58de2ad2d7 Update mg_send.md 2016-07-22 14:53:28 +01:00
Evelyn f30c7b75d0 Update mg_set_ssl.md 2016-07-22 14:52:31 +01:00
Evelyn c5b8e55e12 Update mg_connect_opt.md 2016-07-22 14:48:10 +01:00
Evelyn 559874fce7 Update mg_connect.md 2016-07-22 14:41:40 +01:00
Evelyn 1875653b34 Update mg_bind_opt.md 2016-07-22 14:41:23 +01:00
Evelyn 6df770e72d Update mg_bind.md 2016-07-22 14:39:26 +01:00
Evelyn 51d415c8dd Update mg_add_sock_opt.md 2016-07-22 14:38:44 +01:00
Evelyn 63bf428c34 Update mg_add_sock.md 2016-07-22 14:37:21 +01:00
Evelyn a5d2772082 Update mg_next.md 2016-07-22 14:36:53 +01:00
Evelyn 43c317ef4c Update mg_broadcast.md 2016-07-22 14:36:13 +01:00
Evelyn 01ffdb69d0 Update mg_mgr_poll.md 2016-07-22 14:35:08 +01:00
Evelyn a78f346ac6 Update mg_mgr_free.md 2016-07-22 14:34:04 +01:00
Evelyn 4ae88c859e Update mg_mgr_init.md 2016-07-22 14:33:30 +01:00
Marko Mikulicic e8a97f12d7 Skip C build if not changed - step 1
Note: this is only the first step; the C sources won't be built until
the second step is done.

The actual build takes about 1.3s on cloud2 which still runs the docker
containers and image layers on the very slow spinning disk. cloud3 has
docker mounted on the SSD disk; measured speedups of 20-30%

PUBLISHED_FROM=c5acef1d64ebc8dca8ed31f51685c8b3090c5767
2016-07-22 12:51:18 +00:00
Evelyn 06aabdefbe Update mg_mgr_init.md 2016-07-22 13:48:35 +01: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 b987df1974 Refactor sys_config and ro_vars
Use the same config mechanism for ro_vars as for sys_config, get rid of a bunch of custom code.

PUBLISHED_FROM=d2be76cb97090669dd6a21e95d0ba821eaa1a313
2016-07-21 16:35:59 +00:00
Deomid Ryabkov cbe63d43df Prevent repeated invocation of Clubby handler
PUBLISHED_FROM=de348f944de60d116d9d1f5d18e920991c811fa8
2016-07-21 15:22:36 +00:00
Marko Mikulicic e91a7c9599 Reamalgam after .h edits
PUBLISHED_FROM=da1faa9b46cd0ff22dcba6d324b5847c4a0d42d8
2016-07-21 15:06:41 +00:00
Sergey Lyubka 3054952a5e Add %T to the API ref
PUBLISHED_FROM=f6679ea960b3aa0bc9142515548835ee0f78af67
2016-07-21 14:36:12 +00:00
Artem Bulavin 3244df9cd1 Added UI response on authentication, fixed non-clickable buttons
PUBLISHED_FROM=a4666982707fcc96cfe6e75903cab9ac225351e4
2016-07-21 14:07:13 +00:00
Dmitry Frank 1f75081f6e Add build option V7_NO_COMPILER
Which disables tokenizer, parser, AST, and compiler. On ESP8266, it
frees 21K of ROM.

PUBLISHED_FROM=ff4c53ace6b9056c595b9e12ef3453330d659775
2016-07-21 13:51:54 +00:00
Marko Mikulicic 2c83a50a8a Document %.*Q
PUBLISHED_FROM=5dc567f8978d5414835f7a2338a78ae9eb683f55
2016-07-21 13:38:48 +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
Sergey Lyubka 810eab9a58 Add SSI doc string
PUBLISHED_FROM=73540bf103672916eae35959d5e992a3616a6604
2016-07-20 11:07:37 +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 613ae4ee34 Fix led toggline in CC3200 sensor demo
PUBLISHED_FROM=10369c7903f3c9433e8c9f6f9725f014aed5768d
2016-07-13 20:04:48 +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
300 changed files with 15998 additions and 1621 deletions

No files matched your search

+4
View File
@@ -73,4 +73,8 @@ To submit contributions, sign
[Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml) [Cesanta CLA](https://docs.cesanta.com/contributors_la.shtml)
and send GitHub pull request. You retain the copyright on your contributions. and send GitHub pull request. You retain the copyright on your contributions.
## Working with the Source Code
See [tools](https://github.com/cesanta/mongoose/tree/master/tools) directory.
[![Analytics](https://ga-beacon.appspot.com/UA-42732794-5/project-page)](https://github.com/cesanta/mongoose) [![Analytics](https://ga-beacon.appspot.com/UA-42732794-5/project-page)](https://github.com/cesanta/mongoose)
+10 -10
View File
@@ -1,17 +1,17 @@
--- ---
title: "CoAP" title: "CoAP API reference"
symbol_kind: "intro" symbol_kind: "intro"
decl_name: "coap.h" decl_name: "coap.h"
items: items:
- { type: file, name: mg_set_protocol_coap.md } - { name: mg_set_protocol_coap.md }
- { type: file, name: mg_coap_add_option.md } - { name: mg_coap_add_option.md }
- { type: file, name: mg_coap_free_options.md } - { name: mg_coap_free_options.md }
- { type: file, name: mg_coap_send_message.md } - { name: mg_coap_send_message.md }
- { type: file, name: mg_coap_send_ack.md } - { name: mg_coap_send_ack.md }
- { type: file, name: mg_coap_parse.md } - { name: mg_coap_parse.md }
- { type: file, name: mg_coap_compose.md } - { name: mg_coap_compose.md }
- { type: file, name: struct_mg_coap_option.md } - { name: struct_mg_coap_option.md }
- { type: file, name: struct_mg_coap_message.md } - { name: struct_mg_coap_message.md }
--- ---
CoAP message format: CoAP message format:
+1 -1
View File
@@ -8,6 +8,6 @@ signature: |
size_t len); size_t len);
--- ---
Add new option to mg_coap_message structure. Adds a new option to mg_coap_message structure.
Returns pointer to the newly created option. Returns pointer to the newly created option.
+2 -2
View File
@@ -6,6 +6,6 @@ signature: |
void mg_coap_free_options(struct mg_coap_message *cm); void mg_coap_free_options(struct mg_coap_message *cm);
--- ---
Free the memory allocated for options, Frees the memory allocated for options.
if cm paramater doesn't contain any option does nothing. If the cm paramater doesn't contain any option it does nothing.
+4 -4
View File
@@ -6,13 +6,13 @@ signature: |
uint32_t mg_coap_parse(struct mbuf *io, struct mg_coap_message *cm); uint32_t mg_coap_parse(struct mbuf *io, struct mg_coap_message *cm);
--- ---
Parse COAP message and fills mg_coap_message and returns cm->flags. Parses CoAP message and fills mg_coap_message and returns cm->flags.
This is a helper function. This is a helper function.
NOTE: usually CoAP work over UDP, so lack of data means format error, NOTE: usually CoAP works over UDP, so lack of data means format error.
but in theory it is possible to use CoAP over TCP (according to RFC) But, in theory, it is possible to use CoAP over TCP (according to RFC)
The caller have to check results and treat COAP_NOT_ENOUGH_DATA according to The caller has to check results and treat COAP_NOT_ENOUGH_DATA according to
underlying protocol: underlying protocol:
- in case of UDP COAP_NOT_ENOUGH_DATA means COAP_FORMAT_ERROR, - in case of UDP COAP_NOT_ENOUGH_DATA means COAP_FORMAT_ERROR,
+2 -2
View File
@@ -6,7 +6,7 @@ signature: |
uint32_t mg_coap_send_ack(struct mg_connection *nc, uint16_t msg_id); uint32_t mg_coap_send_ack(struct mg_connection *nc, uint16_t msg_id);
--- ---
Compose CoAP acknowledgement from `mg_coap_message` Composes CoAP acknowledgement from `mg_coap_message`
and send it into `nc` connection. and sends it into `nc` connection.
Return value: see `mg_coap_send_message()` Return value: see `mg_coap_send_message()`
+3 -3
View File
@@ -7,9 +7,9 @@ signature: |
struct mg_coap_message *cm); struct mg_coap_message *cm);
--- ---
Compose CoAP message from `mg_coap_message` Composes a CoAP message from `mg_coap_message`
and send it into `nc` connection. and sends it into `nc` connection.
Return 0 on success. On error, it is a bitmask: Returns 0 on success. On error, it is a bitmask:
- `#define MG_COAP_ERROR 0x10000` - `#define MG_COAP_ERROR 0x10000`
- `#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)` - `#define MG_COAP_FORMAT_ERROR (MG_COAP_ERROR | 0x20000)`
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
int mg_set_protocol_coap(struct mg_connection *nc); int mg_set_protocol_coap(struct mg_connection *nc);
--- ---
Set CoAP protocol handler - trigger CoAP specific events Sets CoAP protocol handler - triggers CoAP specific events.
-12
View File
@@ -1,12 +0,0 @@
---
title: "DNS server"
symbol_kind: "intro"
decl_name: "dns-server.h"
items:
- { type: file, name: mg_dns_create_reply.md }
- { type: file, name: mg_dns_reply_record.md }
- { type: file, name: mg_dns_send_reply.md }
---
Disabled by default; enable with `-DMG_ENABLE_DNS_SERVER`.
+12 -11
View File
@@ -1,18 +1,19 @@
--- ---
title: "DNS" title: "DNS API reference"
symbol_kind: "intro" symbol_kind: "intro"
decl_name: "dns.h" decl_name: "dns.h"
items: items:
- { type: file, name: mg_dns_parse_record_data.md } - { name: mg_dns_parse_record_data.md }
- { type: file, name: mg_send_dns_query.md } - { name: mg_send_dns_query.md }
- { type: file, name: mg_dns_insert_header.md } - { name: mg_dns_insert_header.md }
- { type: file, name: mg_dns_copy_questions.md } - { name: mg_dns_copy_questions.md }
- { type: file, name: mg_dns_encode_record.md } - { name: mg_dns_encode_record.md }
- { type: file, name: mg_parse_dns.md } - { name: mg_dns_encode_name.md }
- { type: file, name: mg_dns_uncompress_name.md } - { name: mg_parse_dns.md }
- { type: file, name: mg_set_protocol_dns.md } - { name: mg_dns_uncompress_name.md }
- { type: file, name: struct_mg_dns_resource_record.md } - { name: mg_set_protocol_dns.md }
- { type: file, name: struct_mg_dns_message.md } - { name: struct_mg_dns_resource_record.md }
- { name: struct_mg_dns_message.md }
--- ---
+2 -2
View File
@@ -6,10 +6,10 @@ signature: |
int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg); int mg_dns_copy_questions(struct mbuf *io, struct mg_dns_message *msg);
--- ---
Append already encoded questions from an existing message. Appends already encoded questions from an existing message.
This is useful when generating a DNS reply message which includes This is useful when generating a DNS reply message which includes
all question records. all question records.
Return number of appened bytes. Returns the number of appended bytes.
+10
View File
@@ -0,0 +1,10 @@
---
title: "mg_dns_encode_name()"
decl_name: "mg_dns_encode_name"
symbol_kind: "func"
signature: |
int mg_dns_encode_name(struct mbuf *io, const char *name, size_t len);
---
Encodes a DNS name.
+6 -6
View File
@@ -8,18 +8,18 @@ signature: |
size_t rlen); size_t rlen);
--- ---
Encode and append a DNS resource record to an IO buffer. Encodes and appends a DNS resource record to an IO buffer.
The record metadata is taken from the `rr` parameter, while the name and data The record metadata is taken from the `rr` parameter, while the name and data
are taken from the parameters, encoded in the appropriate format depending on are taken from the parameters, encoded in the appropriate format depending on
record type, and stored in the IO buffer. The encoded values might contain record type and stored in the IO buffer. The encoded values might contain
offsets within the IO buffer. It's thus important that the IO buffer doesn't offsets within the IO buffer. It's thus important that the IO buffer doesn't
get trimmed while a sequence of records are encoded while preparing a DNS get trimmed while a sequence of records are encoded while preparing a DNS
*reply. reply.
This function doesn't update the `name` and `rdata` pointers in the `rr` This function doesn't update the `name` and `rdata` pointers in the `rr`
*struct struct because they might be invalidated as soon as the IO buffer grows
because they might be invalidated as soon as the IO buffer grows again. again.
Return the number of bytes appened or -1 in case of error. Returns the number of bytes appened or -1 in case of error.
+2 -2
View File
@@ -7,7 +7,7 @@ signature: |
struct mg_dns_message *msg); struct mg_dns_message *msg);
--- ---
Insert a DNS header to an IO buffer. Inserts a DNS header to an IO buffer.
Return number of bytes inserted. Returns the number of bytes inserted.
+1 -1
View File
@@ -8,7 +8,7 @@ signature: |
size_t data_len); size_t data_len);
--- ---
Parse the record data from a DNS resource record. Parses the record data from a DNS resource record.
- A: struct in_addr *ina - A: struct in_addr *ina
- AAAA: struct in6_addr *ina - AAAA: struct in6_addr *ina
+6 -6
View File
@@ -7,15 +7,15 @@ signature: |
char *dst, int dst_len); char *dst, int dst_len);
--- ---
Uncompress a DNS compressed name. Uncompresses a DNS compressed name.
The containing dns message is required because the compressed encoding The containing DNS message is required because of the compressed encoding
and reference suffixes present elsewhere in the packet. and reference suffixes present elsewhere in the packet.
If name is less than `dst_len` characters long, the remainder If the name is less than `dst_len` characters long, the remainder
of `dst` is terminated with `\0' characters. Otherwise, `dst` is not of `dst` is terminated with `\0` characters. Otherwise, `dst` is not
*terminated. terminated.
If `dst_len` is 0 `dst` can be NULL. If `dst_len` is 0 `dst` can be NULL.
Return the uncompressed name length. Returns the uncompressed name length.
+1 -1
View File
@@ -7,5 +7,5 @@ signature: |
int query_type); int query_type);
--- ---
Send a DNS query to the remote end. Sends a DNS query to the remote end.
+4 -4
View File
@@ -6,11 +6,11 @@ signature: |
void mg_set_protocol_dns(struct mg_connection *nc); void mg_set_protocol_dns(struct mg_connection *nc);
--- ---
Attach built-in DNS event handler to the given listening connection. Attaches a built-in DNS event handler to the given listening connection.
DNS event handler parses incoming UDP packets, treating them as DNS The DNS event handler parses the incoming UDP packets, treating them as DNS
requests. If incoming packet gets successfully parsed by the DNS event requests. If an incoming packet gets successfully parsed by the DNS event
handler, a user event handler will receive `MG_DNS_REQUEST` event, with handler, a user event handler will receive an `MG_DNS_REQUEST` event, with
`ev_data` pointing to the parsed `struct mg_dns_message`. `ev_data` pointing to the parsed `struct mg_dns_message`.
See See
+12
View File
@@ -0,0 +1,12 @@
---
title: "DNS server API reference"
symbol_kind: "intro"
decl_name: "dns_server.h"
items:
- { name: mg_dns_create_reply.md }
- { name: mg_dns_reply_record.md }
- { name: mg_dns_send_reply.md }
---
Disabled by default; enable with `-DMG_ENABLE_DNS_SERVER`.
@@ -7,18 +7,18 @@ signature: |
struct mg_dns_message *msg); struct mg_dns_message *msg);
--- ---
Create a DNS reply. Creates a DNS reply.
The reply will be based on an existing query message `msg`. The reply will be based on an existing query message `msg`.
The query body will be appended to the output buffer. The query body will be appended to the output buffer.
"reply + recursion allowed" will be added to the message flags and "reply + recursion allowed" will be added to the message flags and the
message's num_answers will be set to 0. message's num_answers will be set to 0.
Answer records can be appended with `mg_dns_send_reply` or by lower Answer records can be appended with `mg_dns_send_reply` or by lower
level function defined in the DNS API. level function defined in the DNS API.
In order to send the reply use `mg_dns_send_reply`. In order to send a reply use `mg_dns_send_reply`.
It's possible to use a connection's send buffer as reply buffers, It's possible to use a connection's send buffer as reply buffer,
and it will work for both UDP and TCP connections. and it will work for both UDP and TCP connections.
Example: Example:
@@ -9,10 +9,10 @@ signature: |
size_t rdata_len); size_t rdata_len);
--- ---
Append a DNS reply record to the IO buffer and to the DNS message. Appends a DNS reply record to the IO buffer and to the DNS message.
The message num_answers field will be incremented. It's caller's duty The message's num_answers field will be incremented. It's the caller's duty
to ensure num_answers is propertly initialized. to ensure num_answers is properly initialised.
Returns -1 on error. Returns -1 on error.
@@ -6,12 +6,12 @@ signature: |
void mg_dns_send_reply(struct mg_connection *nc, struct mg_dns_reply *r); void mg_dns_send_reply(struct mg_connection *nc, struct mg_dns_reply *r);
--- ---
Send a DNS reply through a connection. Sends a DNS reply through a connection.
The DNS data is stored in an IO buffer pointed by reply structure in `r`. The DNS data is stored in an IO buffer pointed by reply structure in `r`.
This function mutates the content of that buffer in order to ensure that This function mutates the content of that buffer in order to ensure that
the DNS header reflects size and flags of the mssage, that might have been the DNS header reflects the size and flags of the message, that might have
updated either with `mg_dns_reply_record` or by direct manipulation of been updated either with `mg_dns_reply_record` or by direct manipulation of
`r->message`. `r->message`.
Once sent, the IO buffer will be trimmed unless the reply IO buffer Once sent, the IO buffer will be trimmed unless the reply IO buffer
+14 -32
View File
@@ -1,39 +1,21 @@
--- ---
title: "HTTP + Websocket" title: "Common API reference"
symbol_kind: "intro" symbol_kind: "intro"
decl_name: "http.h" decl_name: "http.h"
items: items:
- { type: file, name: mg_set_protocol_http_websocket.md } - { name: mg_set_protocol_http_websocket.md }
- { type: file, name: mg_send_websocket_handshake.md } - { name: mg_send_websocket_handshake.md }
- { type: file, name: mg_send_websocket_handshake2.md } - { name: mg_send_websocket_handshake2.md }
- { type: file, name: mg_connect_ws.md } - { name: mg_connect_ws.md }
- { type: file, name: mg_connect_ws_opt.md } - { name: mg_connect_ws_opt.md }
- { type: file, name: mg_send_websocket_frame.md } - { name: mg_send_websocket_frame.md }
- { type: file, name: mg_send_websocket_framev.md } - { name: mg_send_websocket_framev.md }
- { type: file, name: mg_printf_websocket_frame.md } - { name: mg_printf_websocket_frame.md }
- { type: file, name: mg_send_http_chunk.md } - { name: mg_url_decode.md }
- { type: file, name: mg_printf_http_chunk.md } - { name: struct_http_message.md }
- { type: file, name: mg_send_response_line.md } - { name: struct_websocket_message.md }
- { type: file, name: mg_send_head.md } - { name: struct_mg_http_multipart_part.md }
- { type: file, name: mg_printf_html_escape.md } - { name: struct_mg_ssi_call_ctx.md }
- { type: file, name: mg_parse_http.md }
- { type: file, name: mg_get_http_header.md }
- { type: file, name: mg_http_parse_header.md }
- { type: file, name: mg_parse_multipart.md }
- { type: file, name: mg_get_http_var.md }
- { type: file, name: mg_url_decode.md }
- { type: file, name: mg_http_create_digest_auth_header.md }
- { type: file, name: mg_connect_http.md }
- { type: file, name: mg_connect_http_opt.md }
- { type: file, name: mg_serve_http.md }
- { type: file, name: mg_register_http_endpoint.md }
- { type: file, name: mg_file_upload_handler.md }
- { type: file, name: mg_http_check_digest_auth.md }
- { type: file, name: mg_fu_fname_fn.md }
- { type: file, name: struct_http_message.md }
- { type: file, name: struct_websocket_message.md }
- { type: file, name: struct_mg_http_multipart_part.md }
- { type: file, name: struct_mg_serve_http_opts.md }
--- ---
+1 -1
View File
@@ -13,7 +13,7 @@ Helper function that creates an outbound WebSocket connection.
`url` is a URL to connect to. It must be properly URL-encoded, e.g. have `url` is a URL to connect to. It must be properly URL-encoded, e.g. have
no spaces, etc. By default, `mg_connect_ws()` sends Connection and no spaces, etc. By default, `mg_connect_ws()` sends Connection and
Host headers. `extra_headers` is an extra HTTP headers to send, e.g. Host headers. `extra_headers` is an extra HTTP header to send, e.g.
`"User-Agent: my-app\r\n"`. `"User-Agent: my-app\r\n"`.
If `protocol` is not NULL, then a `Sec-WebSocket-Protocol` header is sent. If `protocol` is not NULL, then a `Sec-WebSocket-Protocol` header is sent.
+2 -2
View File
@@ -12,6 +12,6 @@ signature: |
Helper function that creates an outbound WebSocket connection Helper function that creates an outbound WebSocket connection
Mostly identical to mg_connect_ws, but allows to provide extra parameters Mostly identical to `mg_connect_ws`, but allows to provide extra parameters
(for example, SSL parameters (for example, SSL parameters)
-16
View File
@@ -1,16 +0,0 @@
---
title: "mg_get_http_var()"
decl_name: "mg_get_http_var"
symbol_kind: "func"
signature: |
int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
size_t dst_len);
---
Fetch an HTTP form variable.
Fetch a variable `name` from a `buf` into a buffer specified by
`dst`, `dst_len`. Destination is always zero-terminated. Return length
of a fetched variable. If not found, 0 is returned. `buf` must be
valid url-encoded buffer. If destination is too small, `-1` is returned.
-15
View File
@@ -1,15 +0,0 @@
---
title: "mg_parse_http()"
decl_name: "mg_parse_http"
symbol_kind: "func"
signature: |
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
---
Parse a HTTP message.
`is_req` should be set to 1 if parsing request, 0 if reply.
Return number of bytes parsed. If HTTP message is
incomplete, `0` is returned. On parse error, negative number is returned.
@@ -7,8 +7,8 @@ signature: |
const char *fmt, ...); const char *fmt, ...);
--- ---
Send websocket frame to the remote end. Sends WebSocket frame to the remote end.
Like `mg_send_websocket_frame()`, but allows to create formatted message Like `mg_send_websocket_frame()`, but allows to create formatted messages
with `printf()`-like semantics. with `printf()`-like semantics.
-25
View File
@@ -1,25 +0,0 @@
---
title: "mg_send_http_chunk()"
decl_name: "mg_send_http_chunk"
symbol_kind: "func"
signature: |
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
---
Send buffer `buf` of size `len` to the client using chunked HTTP encoding.
This function first sends buffer size as hex number + newline, then
buffer itself, then newline. For example,
`mg_send_http_chunk(nc, "foo", 3)` whill append `3\r\nfoo\r\n` string to
the `nc->send_mbuf` output IO buffer.
NOTE: HTTP header "Transfer-Encoding: chunked" should be sent prior to
using this function.
NOTE: do not forget to send empty chunk at the end of the response,
to tell the client that everything was sent. Example:
```
mg_printf_http_chunk(nc, "%s", "my response!");
mg_send_http_chunk(nc, "", 0); // Tell the client we're finished
```
+2 -2
View File
@@ -7,9 +7,9 @@ signature: |
const void *data, size_t data_len); const void *data, size_t data_len);
--- ---
Send websocket frame to the remote end. Send WebSocket frame to the remote end.
`op_and_flags` specifies frame's type, one of: `op_and_flags` specifies the frame's type. It's one of:
- WEBSOCKET_OP_CONTINUE - WEBSOCKET_OP_CONTINUE
- WEBSOCKET_OP_TEXT - WEBSOCKET_OP_TEXT
@@ -7,7 +7,7 @@ signature: |
const struct mg_str *strings, int num_strings); const struct mg_str *strings, int num_strings);
--- ---
Send multiple websocket frames. Sends multiple websocket frames.
Like `mg_send_websocket_frame()`, but composes a frame from multiple buffers. Like `mg_send_websocket_frame()`, but composes a frame from multiple buffers.
@@ -6,40 +6,41 @@ signature: |
void mg_set_protocol_http_websocket(struct mg_connection *nc); void mg_set_protocol_http_websocket(struct mg_connection *nc);
--- ---
Attach built-in HTTP event handler to the given connection. Attaches a built-in HTTP event handler to the given connection.
User-defined event handler will receive following extra events: The user-defined event handler will receive following extra events:
- MG_EV_HTTP_REQUEST: HTTP request has arrived. Parsed HTTP request - MG_EV_HTTP_REQUEST: HTTP request has arrived. Parsed HTTP request
is passed as is passed as
`struct http_message` through the handler's `void *ev_data` pointer. `struct http_message` through the handler's `void *ev_data` pointer.
- MG_EV_HTTP_MULTIPART_REQUEST: A multipart POST request has received. - MG_EV_HTTP_MULTIPART_REQUEST: A multipart POST request has received.
This event is sent before body is parsed. After this user This event is sent before body is parsed. After this, the user
should expect a sequence of MG_EV_HTTP_PART_BEGIN/DATA/END requests. should expect a sequence of MG_EV_HTTP_PART_BEGIN/DATA/END requests.
This is also the last time when headers and other request fields are This is also the last time when headers and other request fields are
accessible. accessible.
- MG_EV_HTTP_REPLY: HTTP reply has arrived. Parsed HTTP reply is passed as - MG_EV_HTTP_REPLY: The HTTP reply has arrived. The parsed HTTP reply is
`struct http_message` through the handler's `void *ev_data` pointer. passed as `struct http_message` through the handler's `void *ev_data`
- MG_EV_HTTP_CHUNK: HTTP chunked-encoding chunk has arrived. pointer.
Parsed HTTP reply is passed as `struct http_message` through the - MG_EV_HTTP_CHUNK: The HTTP chunked-encoding chunk has arrived.
The parsed HTTP reply is passed as `struct http_message` through the
handler's `void *ev_data` pointer. `http_message::body` would contain handler's `void *ev_data` pointer. `http_message::body` would contain
incomplete, reassembled HTTP body. incomplete, reassembled HTTP body.
It will grow with every new chunk arrived, and It will grow with every new chunk that arrives, and it can
potentially can consume a lot of memory. An event handler may process potentially consume a lot of memory. An event handler may process
the body as chunks are coming, and signal Mongoose to delete processed the body as chunks are coming, and signal Mongoose to delete processed
body by setting `MG_F_DELETE_CHUNK` in `mg_connection::flags`. When body by setting `MG_F_DELETE_CHUNK` in `mg_connection::flags`. When
the last zero chunk is received, the last zero chunk is received,
Mongoose sends `MG_EV_HTTP_REPLY` event with Mongoose sends `MG_EV_HTTP_REPLY` event with
full reassembled body (if handler did not signal to delete chunks) or full reassembled body (if handler did not signal to delete chunks) or
with empty body (if handler did signal to delete chunks). with empty body (if handler did signal to delete chunks).
- MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received websocket handshake - MG_EV_WEBSOCKET_HANDSHAKE_REQUEST: server has received the WebSocket
request. `ev_data` contains parsed HTTP request. handshake request. `ev_data` contains parsed HTTP request.
- MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed Websocket handshake. - MG_EV_WEBSOCKET_HANDSHAKE_DONE: server has completed the WebSocket
`ev_data` is `NULL`. handshake. `ev_data` is `NULL`.
- MG_EV_WEBSOCKET_FRAME: new websocket frame has arrived. `ev_data` is - MG_EV_WEBSOCKET_FRAME: new WebSocket frame has arrived. `ev_data` is
`struct websocket_message *` `struct websocket_message *`
- MG_EV_HTTP_PART_BEGIN: new part of multipart message is started, - MG_EV_HTTP_PART_BEGIN: new part of multipart message is started,
extra parameters are passed in mg_http_multipart_part extra parameters are passed in mg_http_multipart_part
- MG_EV_HTTP_PART_DATA: new portion of data from multiparted message - MG_EV_HTTP_PART_DATA: new portion of data from the multiparted message
no additional headers are available, only data and data size no additional headers are available, only data and data size
- MG_EV_HTTP_PART_END: final boundary received, analogue to maybe used to - MG_EV_HTTP_PART_END: final boundary received, analogue to maybe used to
find the end of packet find the end of packet
+4 -4
View File
@@ -7,12 +7,12 @@ signature: |
int is_form_url_encoded); int is_form_url_encoded);
--- ---
Decode URL-encoded string. Decodes a URL-encoded string.
Source string is specified by (`src`, `src_len`), and destination is Source string is specified by (`src`, `src_len`), and destination is
(`dst`, `dst_len`). If `is_form_url_encoded` is non-zero, then (`dst`, `dst_len`). If `is_form_url_encoded` is non-zero, then
`+` character is decoded as a blank space character. This function `+` character is decoded as a blank space character. This function
guarantees to `\0`-terminate the destination. If destination is too small, guarantees to NUL-terminate the destination. If destination is too small,
then source string is partially decoded and `-1` is returned. Otherwise, then the source string is partially decoded and `-1` is returned. Otherwise,
a length of decoded string is returned, not counting final `\0`. a length of the decoded string is returned, not counting final NUL.
@@ -0,0 +1,14 @@
---
title: "struct mg_ssi_call_ctx"
decl_name: "struct mg_ssi_call_ctx"
symbol_kind: "struct"
signature: |
struct mg_ssi_call_ctx {
struct http_message *req; /* The request being processed. */
struct mg_str file; /* Filesystem path of the file being processed. */
struct mg_str arg; /* The argument passed to the tag: <!-- call arg -->. */
};
---
SSI call context
+12
View File
@@ -0,0 +1,12 @@
---
title: "Client API reference"
symbol_kind: "intro"
decl_name: "http_client.h"
items:
- { name: mg_connect_http.md }
- { name: mg_connect_http_opt.md }
- { name: mg_http_create_digest_auth_header.md }
---
@@ -10,16 +10,16 @@ signature: |
const char *post_data); const char *post_data);
--- ---
Helper function that creates outbound HTTP connection. Helper function that creates an outbound HTTP connection.
`url` is a URL to fetch. It must be properly URL-encoded, e.g. have `url` is the URL to fetch. It must be properly URL-encoded, e.g. have
no spaces, etc. By default, `mg_connect_http()` sends Connection and no spaces, etc. By default, `mg_connect_http()` sends the Connection and
Host headers. `extra_headers` is an extra HTTP headers to send, e.g. Host headers. `extra_headers` is an extra HTTP header to send, e.g.
`"User-Agent: my-app\r\n"`. `"User-Agent: my-app\r\n"`.
If `post_data` is NULL, then GET request is created. Otherwise, POST request If `post_data` is NULL, then a GET request is created. Otherwise, a POST
is created with the specified POST data. Note that if the data being posted request is created with the specified POST data. Note that if the data being
is a form submission, the `Content-Type` header should be set accordingly posted is a form submission, the `Content-Type` header should be set
(see example below). accordingly (see example below).
Examples: Examples:
@@ -11,8 +11,9 @@ signature: |
const char *post_data); const char *post_data);
--- ---
Helper function that creates outbound HTTP connection. Helper function that creates an outbound HTTP connection.
Mostly identical to mg_connect_http, but allows to provide extra parameters Mostly identical to mg_connect_http, but allows you to provide extra
(for example, SSL parameters *parameters
(for example, SSL parameters)
@@ -9,5 +9,5 @@ signature: |
const char *passwd); const char *passwd);
--- ---
Create Digest authentication header for client request. Creates digest authentication header for a client request.
+27
View File
@@ -0,0 +1,27 @@
---
title: "Server API reference"
symbol_kind: "intro"
decl_name: "http_server.h"
items:
- { name: mg_parse_http.md }
- { name: mg_get_http_header.md }
- { name: mg_http_parse_header.md }
- { name: mg_parse_multipart.md }
- { name: mg_get_http_var.md }
- { name: mg_serve_http.md }
- { name: mg_http_serve_file.md }
- { name: mg_register_http_endpoint.md }
- { name: mg_file_upload_handler.md }
- { name: mg_http_check_digest_auth.md }
- { name: mg_send_http_chunk.md }
- { name: mg_printf_http_chunk.md }
- { name: mg_send_response_line.md }
- { name: mg_http_send_redirect.md }
- { name: mg_send_head.md }
- { name: mg_printf_html_escape.md }
- { name: mg_fu_fname_fn.md }
- { name: struct_mg_serve_http_opts.md }
---
@@ -12,9 +12,10 @@ This handler can be used to implement file uploads with minimum code.
This handler will process MG_EV_HTTP_PART_* events and store file data into This handler will process MG_EV_HTTP_PART_* events and store file data into
a local file. a local file.
`local_name_fn` will be invoked with whatever name was provided by the client `local_name_fn` will be invoked with whatever name was provided by the client
and will expect the name of the local file to open. Return value of NULL will and will expect the name of the local file to open. A return value of NULL
abort file upload (client will get a "403 Forbidden" response). If non-null, will abort file upload (client will get a "403 Forbidden" response). If
the returned string must be heap-allocated and will be freed by the caller. non-null, the returned string must be heap-allocated and will be freed by
the caller.
Exception: it is ok to return the same string verbatim. Exception: it is ok to return the same string verbatim.
Example: Example:
@@ -6,7 +6,7 @@ signature: |
struct mg_str *mg_get_http_header(struct http_message *hm, const char *name); struct mg_str *mg_get_http_header(struct http_message *hm, const char *name);
--- ---
Search and return header `name` in parsed HTTP message `hm`. Searches and returns the header `name` in parsed HTTP message `hm`.
If header is not found, NULL is returned. Example: If header is not found, NULL is returned. Example:
struct mg_str *host_hdr = mg_get_http_header(hm, "Host"); struct mg_str *host_hdr = mg_get_http_header(hm, "Host");
@@ -0,0 +1,16 @@
---
title: "mg_get_http_var()"
decl_name: "mg_get_http_var"
symbol_kind: "func"
signature: |
int mg_get_http_var(const struct mg_str *buf, const char *name, char *dst,
size_t dst_len);
---
Fetches a HTTP form variable.
Fetches a variable `name` from a `buf` into a buffer specified by `dst`,
`dst_len`. The destination is always zero-terminated. Returns the length of
a fetched variable. If not found, 0 is returned. `buf` must be valid
url-encoded buffer. If destination is too small, `-1` is returned.
@@ -7,6 +7,6 @@ signature: |
FILE *fp); FILE *fp);
--- ---
Authenticate HTTP request against opened passwords file. Authenticates a HTTP request against an opened password file.
Returns 1 if authenticated, 0 otherwise. Returns 1 if authenticated, 0 otherwise.
@@ -7,17 +7,17 @@ signature: |
size_t buf_size); size_t buf_size);
--- ---
Parse HTTP header `hdr`. Find variable `var_name` and store it's value Parses the HTTP header `hdr`. Finds variable `var_name` and stores its value
in the buffer `buf`, `buf_size`. Return 0 if variable not found, non-zero in the buffer `buf`, `buf_size`. Returns 0 if variable not found, non-zero
otherwise. otherwise.
This function is supposed to parse This function is supposed to parse cookies, authentication headers, etc.
cookies, authentication headers, etcetera. Example (error handling omitted): Example (error handling omitted):
char user[20]; char user[20];
struct mg_str *hdr = mg_get_http_header(hm, "Authorization"); struct mg_str *hdr = mg_get_http_header(hm, "Authorization");
mg_http_parse_header(hdr, "username", user, sizeof(user)); mg_http_parse_header(hdr, "username", user, sizeof(user));
Return length of the variable's value. If buffer is not large enough, Returns the length of the variable's value. If buffer is not large enough,
or variable not found, 0 is returned. or variable not found, 0 is returned.
@@ -0,0 +1,20 @@
---
title: "mg_http_send_redirect()"
decl_name: "mg_http_send_redirect"
symbol_kind: "func"
signature: |
void mg_http_send_redirect(struct mg_connection *nc, int status_code,
const struct mg_str location,
const struct mg_str extra_headers);
---
Sends a redirect response.
`status_code` should be either 301 or 302 and `location` point to the
new location.
If `extra_headers` is not empty, then `extra_headers` are also sent
after the reponse line. `extra_headers` must NOT end end with new line.
Example:
mg_http_send_redirect(nc, 302, mg_mk_str("/login"), mg_mk_str(NULL));
@@ -0,0 +1,28 @@
---
title: "mg_http_serve_file()"
decl_name: "mg_http_serve_file"
symbol_kind: "func"
signature: |
void mg_http_serve_file(struct mg_connection *nc, struct http_message *hm,
const char *path, const struct mg_str mime_type,
const struct mg_str extra_headers);
---
Serves a specific file with a given MIME type and optional extra headers.
Example code snippet:
```c
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
switch (ev) {
case MG_EV_HTTP_REQUEST: {
struct http_message *hm = (struct http_message *) ev_data;
mg_http_serve_file(nc, hm, "file.txt",
mg_mk_str("text/plain"), mg_mk_str(""));
break;
}
...
}
}
```
+15
View File
@@ -0,0 +1,15 @@
---
title: "mg_parse_http()"
decl_name: "mg_parse_http"
symbol_kind: "func"
signature: |
int mg_parse_http(const char *s, int n, struct http_message *hm, int is_req);
---
Parses a HTTP message.
`is_req` should be set to 1 if parsing a request, 0 if reply.
Returns the number of bytes parsed. If HTTP message is
incomplete `0` is returned. On parse error, a negative number is returned.
@@ -9,13 +9,13 @@ signature: |
size_t *chunk_len); size_t *chunk_len);
--- ---
Parse buffer `buf`, `buf_len` that contains multipart form data chunks. Parses the buffer `buf`, `buf_len` that contains multipart form data chunks.
Store chunk name in a `var_name`, `var_name_len` buffer. Stores the chunk name in a `var_name`, `var_name_len` buffer.
If a chunk is an uploaded file, then `file_name`, `file_name_len` is If a chunk is an uploaded file, then `file_name`, `file_name_len` is
filled with an uploaded file name. `chunk`, `chunk_len` filled with an uploaded file name. `chunk`, `chunk_len`
points to the chunk data. points to the chunk data.
Return: number of bytes to skip to the next chunk, or 0 if there are Return: number of bytes to skip to the next chunk or 0 if there are
no more chunks. no more chunks.
Usage example: Usage example:
@@ -6,5 +6,5 @@ signature: |
void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...); void mg_printf_html_escape(struct mg_connection *nc, const char *fmt, ...);
--- ---
Send printf-formatted HTTP chunk, escaping HTML tags. Sends a printf-formatted HTTP chunk, escaping HTML tags.
@@ -6,6 +6,6 @@ signature: |
void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...); void mg_printf_http_chunk(struct mg_connection *nc, const char *fmt, ...);
--- ---
Send printf-formatted HTTP chunk. Sends a printf-formatted HTTP chunk.
Functionality is similar to `mg_send_http_chunk()`. Functionality is similar to `mg_send_http_chunk()`.
@@ -7,8 +7,8 @@ signature: |
mg_event_handler_t handler); mg_event_handler_t handler);
--- ---
Register callback for specified http endpoint Registers a callback for a specified http endpoint
Note: if callback is registered it is called instead of Note: if callback is registered it is called instead of the
callback provided in mg_bind callback provided in mg_bind
Example code snippet: Example code snippet:
@@ -7,15 +7,16 @@ signature: |
int64_t content_length, const char *extra_headers); int64_t content_length, const char *extra_headers);
--- ---
Send response line and headers. Sends the response line and headers.
This function sends response line with the `status_code`, and automatically This function sends the response line with the `status_code`, and
sends one header: either "Content-Length", or "Transfer-Encoding". automatically
sends one header: either "Content-Length" or "Transfer-Encoding".
If `content_length` is negative, then "Transfer-Encoding: chunked" header If `content_length` is negative, then "Transfer-Encoding: chunked" header
is sent, otherwise, "Content-Length" header is sent. is sent, otherwise, "Content-Length" header is sent.
NOTE: If `Transfer-Encoding` is `chunked`, then message body must be sent NOTE: If `Transfer-Encoding` is `chunked`, then message body must be sent
using `mg_send_http_chunk()` or `mg_printf_http_chunk()` functions. using `mg_send_http_chunk()` or `mg_printf_http_chunk()` functions.
Otherwise, `mg_send()` or `mg_printf()` must be used. Otherwise, `mg_send()` or `mg_printf()` must be used.
Extra headers could be set through `extra_headers` - and note `extra_headers` Extra headers could be set through `extra_headers`. Note `extra_headers`
must NOT be terminated by a new line. must NOT be terminated by a new line.
@@ -0,0 +1,25 @@
---
title: "mg_send_http_chunk()"
decl_name: "mg_send_http_chunk"
symbol_kind: "func"
signature: |
void mg_send_http_chunk(struct mg_connection *nc, const char *buf, size_t len);
---
Sends buffer `buf` of size `len` to the client using chunked HTTP encoding.
This function sends the buffer size as hex number + newline first, then
the buffer itself, then the newline. For example,
`mg_send_http_chunk(nc, "foo", 3)` whill append the `3\r\nfoo\r\n` string
to the `nc->send_mbuf` output IO buffer.
NOTE: The HTTP header "Transfer-Encoding: chunked" should be sent prior to
using this function.
NOTE: do not forget to send an empty chunk at the end of the response,
to tell the client that everything was sent. Example:
```
mg_printf_http_chunk(nc, "%s", "my response!");
mg_send_http_chunk(nc, "", 0); // Tell the client we're finished
```
@@ -3,11 +3,11 @@ title: "mg_send_response_line()"
decl_name: "mg_send_response_line" decl_name: "mg_send_response_line"
symbol_kind: "func" symbol_kind: "func"
signature: | signature: |
void mg_send_response_line(struct mg_connection *c, int status_code, void mg_send_response_line(struct mg_connection *nc, int status_code,
const char *extra_headers); const char *extra_headers);
--- ---
Send response status line. Sends the response status line.
If `extra_headers` is not NULL, then `extra_headers` are also sent If `extra_headers` is not NULL, then `extra_headers` are also sent
after the reponse line. `extra_headers` must NOT end end with new line. after the reponse line. `extra_headers` must NOT end end with new line.
Example: Example:
@@ -7,7 +7,7 @@ signature: |
struct mg_serve_http_opts opts); struct mg_serve_http_opts opts);
--- ---
Serve given HTTP request according to the `options`. Serves given HTTP request according to the `options`.
Example code snippet: Example code snippet:
@@ -37,7 +37,64 @@ signature: |
/* Set to "no" to disable directory listing. Enabled by default. */ /* Set to "no" to disable directory listing. Enabled by default. */
const char *enable_directory_listing; const char *enable_directory_listing;
/* SSI files pattern. If not set, "**.shtml$|**.shtm$" is used. */ /*
* SSI files pattern. If not set, "**.shtml$|**.shtm$" is used.
*
* All files that match ssi_pattern are treated as SSI.
*
* Server Side Includes (SSI) is a simple interpreted server-side scripting
* language which is most commonly used to include the contents of a file
* into a web page. It can be useful when it is desirable to include a common
* piece of code throughout a website, for example, headers and footers.
*
* In order for a webpage to recognize an SSI-enabled HTML file, the
* filename should end with a special extension, by default the extension
* should be either .shtml or .shtm
*
* Unknown SSI directives are silently ignored by Mongoose. Currently,
* the following SSI directives are supported:
* &lt;!--#include FILE_TO_INCLUDE --&gt;
* &lt;!--#exec "COMMAND_TO_EXECUTE" --&gt;
* &lt;!--#call COMMAND --&gt;
*
* Note that &lt;!--#include ...> directive supports three path
*specifications:
*
* &lt;!--#include virtual="path" --&gt; Path is relative to web server root
* &lt;!--#include abspath="path" --&gt; Path is absolute or relative to the
* web server working dir
* &lt;!--#include file="path" --&gt;, Path is relative to current document
* &lt;!--#include "path" --&gt;
*
* The include directive may be used to include the contents of a file or
* the result of running a CGI script.
*
* The exec directive is used to execute
* a command on a server, and show command's output. Example:
*
* &lt;!--#exec "ls -l" --&gt;
*
* The call directive is a way to invoke a C handler from the HTML page.
* On each occurence of &lt;!--#call COMMAND OPTIONAL_PARAMS> directive,
* Mongoose calls a registered event handler with MG_EV_SSI_CALL event,
* and event parameter will point to the COMMAND OPTIONAL_PARAMS string.
* An event handler can output any text, for example by calling
* `mg_printf()`. This is a flexible way of generating a web page on
* server side by calling a C event handler. Example:
*
* &lt;!--#call foo --&gt; ... &lt;!--#call bar --&gt;
*
* In the event handler:
* case MG_EV_SSI_CALL: {
* const char *param = (const char *) ev_data;
* if (strcmp(param, "foo") == 0) {
* mg_printf(c, "hello from foo");
* } else if (strcmp(param, "bar") == 0) {
* mg_printf(c, "hello from bar");
* }
* break;
* }
*/
const char *ssi_pattern; const char *ssi_pattern;
/* IP ACL. By default, NULL, meaning all IPs are allowed to connect */ /* IP ACL. By default, NULL, meaning all IPs are allowed to connect */
+13 -9
View File
@@ -1,12 +1,16 @@
--- ---
items: items:
- { type: dir, name: mbuf.h } - { name: mbuf.h }
- { type: dir, name: net.h } - { name: net.h }
- { type: dir, name: http.h } - { name: http.h }
- { type: dir, name: dns.h } - { name: http_server.h }
- { type: dir, name: dns-server.h } - { name: http_client.h }
- { type: dir, name: mqtt.h } - { name: dns.h }
- { type: dir, name: mqtt-broker.h } - { name: dns_server.h }
- { type: dir, name: coap.h } - { name: resolv.h }
- { type: dir, name: util.h } - { name: mqtt.h }
- { name: mqtt_server.h }
- { name: coap.h }
- { name: util.h }
- { name: uri.h }
--- ---
+9 -9
View File
@@ -3,18 +3,18 @@ title: "Memory Buffers"
symbol_kind: "intro" symbol_kind: "intro"
decl_name: "mbuf.h" decl_name: "mbuf.h"
items: items:
- { type: file, name: mbuf_init.md } - { name: mbuf_init.md }
- { type: file, name: mbuf_free.md } - { name: mbuf_free.md }
- { type: file, name: mbuf_append.md } - { name: mbuf_append.md }
- { type: file, name: mbuf_insert.md } - { name: mbuf_insert.md }
- { type: file, name: mbuf_remove.md } - { name: mbuf_remove.md }
- { type: file, name: mbuf_resize.md } - { name: mbuf_resize.md }
- { type: file, name: mbuf_trim.md } - { name: mbuf_trim.md }
- { type: file, name: struct_mbuf.md } - { name: struct_mbuf.md }
--- ---
Mbufs are mutable/growing memory buffers, like C++ strings. Mbufs are mutable/growing memory buffers, like C++ strings.
Mbuf can append data to the end of a buffer, or insert data into arbitrary Mbuf can append data to the end of a buffer or insert data into arbitrary
position in the middle of a buffer. The buffer grows automatically when position in the middle of a buffer. The buffer grows automatically when
needed. needed.
+1 -1
View File
@@ -8,5 +8,5 @@ signature: |
Appends data to the Mbuf. Appends data to the Mbuf.
Return the number of bytes appended, or 0 if out of memory. Returns the number of bytes appended or 0 if out of memory.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mbuf_free(struct mbuf *); void mbuf_free(struct mbuf *);
--- ---
Free the space allocated for the mbuffer and resets the mbuf structure. Frees the space allocated for the mbuffer and resets the mbuf structure.
+1 -1
View File
@@ -6,6 +6,6 @@ signature: |
void mbuf_init(struct mbuf *, size_t initial_capacity); void mbuf_init(struct mbuf *, size_t initial_capacity);
--- ---
Initialize an Mbuf. Initialises an Mbuf.
`initial_capacity` specifies the initial capacity of the mbuf. `initial_capacity` specifies the initial capacity of the mbuf.
+2 -2
View File
@@ -6,9 +6,9 @@ signature: |
size_t mbuf_insert(struct mbuf *, size_t, const void *, size_t); size_t mbuf_insert(struct mbuf *, size_t, const void *, size_t);
--- ---
Insert data at a specified offset in the Mbuf. Inserts data at a specified offset in the Mbuf.
Existing data will be shifted forwards and the buffer will Existing data will be shifted forwards and the buffer will
be grown if necessary. be grown if necessary.
Return the number of bytes inserted. Returns the number of bytes inserted.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mbuf_remove(struct mbuf *, size_t data_size); void mbuf_remove(struct mbuf *, size_t data_size);
--- ---
Remove `data_size` bytes from the beginning of the buffer. Removes `data_size` bytes from the beginning of the buffer.
+1 -1
View File
@@ -6,7 +6,7 @@ signature: |
void mbuf_resize(struct mbuf *, size_t new_size); void mbuf_resize(struct mbuf *, size_t new_size);
--- ---
Resize an Mbuf. Resizes an Mbuf.
If `new_size` is smaller than buffer's `len`, the If `new_size` is smaller than buffer's `len`, the
resize is not performed. resize is not performed.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mbuf_trim(struct mbuf *); void mbuf_trim(struct mbuf *);
--- ---
Shrink an Mbuf by resizing its `size` to `len`. Shrinks an Mbuf by resizing its `size` to `len`.
-14
View File
@@ -1,14 +0,0 @@
---
title: "MQTT Broker"
symbol_kind: "intro"
decl_name: "mqtt-broker.h"
items:
- { type: file, name: mg_mqtt_broker_init.md }
- { type: file, name: mg_mqtt_broker.md }
- { type: file, name: mg_mqtt_next.md }
- { type: file, name: struct_mg_mqtt_session.md }
- { type: file, name: struct_mg_mqtt_broker.md }
---
+19 -19
View File
@@ -1,26 +1,26 @@
--- ---
title: "MQTT" title: "MQTT API reference"
symbol_kind: "intro" symbol_kind: "intro"
decl_name: "mqtt.h" decl_name: "mqtt.h"
items: items:
- { type: file, name: mg_set_protocol_mqtt.md } - { name: mg_set_protocol_mqtt.md }
- { type: file, name: mg_send_mqtt_handshake.md } - { name: mg_send_mqtt_handshake.md }
- { type: file, name: mg_send_mqtt_handshake_opt.md } - { name: mg_send_mqtt_handshake_opt.md }
- { type: file, name: mg_mqtt_publish.md } - { name: mg_mqtt_publish.md }
- { type: file, name: mg_mqtt_subscribe.md } - { name: mg_mqtt_subscribe.md }
- { type: file, name: mg_mqtt_unsubscribe.md } - { name: mg_mqtt_unsubscribe.md }
- { type: file, name: mg_mqtt_disconnect.md } - { name: mg_mqtt_disconnect.md }
- { type: file, name: mg_mqtt_connack.md } - { name: mg_mqtt_connack.md }
- { type: file, name: mg_mqtt_puback.md } - { name: mg_mqtt_puback.md }
- { type: file, name: mg_mqtt_pubrec.md } - { name: mg_mqtt_pubrec.md }
- { type: file, name: mg_mqtt_pubrel.md } - { name: mg_mqtt_pubrel.md }
- { type: file, name: mg_mqtt_pubcomp.md } - { name: mg_mqtt_pubcomp.md }
- { type: file, name: mg_mqtt_suback.md } - { name: mg_mqtt_suback.md }
- { type: file, name: mg_mqtt_unsuback.md } - { name: mg_mqtt_unsuback.md }
- { type: file, name: mg_mqtt_ping.md } - { name: mg_mqtt_ping.md }
- { type: file, name: mg_mqtt_pong.md } - { name: mg_mqtt_pong.md }
- { type: file, name: mg_mqtt_next_subscribe_topic.md } - { name: mg_mqtt_next_subscribe_topic.md }
- { type: file, name: struct_mg_mqtt_topic_expression.md } - { name: struct_mg_mqtt_topic_expression.md }
--- ---
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code); void mg_mqtt_connack(struct mg_connection *nc, uint8_t return_code);
--- ---
Send a CONNACK command with a given `return_code`. Sends a CONNACK command with a given `return_code`.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_disconnect(struct mg_connection *nc); void mg_mqtt_disconnect(struct mg_connection *nc);
--- ---
Send a DISCONNECT command. Sends a DISCONNECT command.
@@ -7,9 +7,9 @@ signature: |
struct mg_str *topic, uint8_t *qos, int pos); struct mg_str *topic, uint8_t *qos, int pos);
--- ---
Extract the next topic expression from a SUBSCRIBE command payload. Extracts the next topic expression from a SUBSCRIBE command payload.
Topic expression name will point to a string in the payload buffer. The topic expression name will point to a string in the payload buffer.
Return the pos of the next topic expression or -1 when the list Returns the pos of the next topic expression or -1 when the list
of topics is exhausted. of topics is exhausted.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_ping(struct mg_connection *nc); void mg_mqtt_ping(struct mg_connection *nc);
--- ---
Send a PINGREQ command. Sends a PINGREQ command.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pong(struct mg_connection *nc); void mg_mqtt_pong(struct mg_connection *nc);
--- ---
Send a PINGRESP command. Sends a PINGRESP command.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_puback(struct mg_connection *nc, uint16_t message_id); void mg_mqtt_puback(struct mg_connection *nc, uint16_t message_id);
--- ---
Send a PUBACK command with a given `message_id`. Sends a PUBACK command with a given `message_id`.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pubcomp(struct mg_connection *nc, uint16_t message_id); void mg_mqtt_pubcomp(struct mg_connection *nc, uint16_t message_id);
--- ---
Send a PUBCOMP command with a given `message_id`. Sends a PUBCOMP command with a given `message_id`.
+1 -1
View File
@@ -8,5 +8,5 @@ signature: |
size_t len); size_t len);
--- ---
Publish a message to a given topic. Publishes a message to a given topic.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pubrec(struct mg_connection *nc, uint16_t message_id); void mg_mqtt_pubrec(struct mg_connection *nc, uint16_t message_id);
--- ---
Send a PUBREC command with a given `message_id`. Sends a PUBREC command with a given `message_id`.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_pubrel(struct mg_connection *nc, uint16_t message_id); void mg_mqtt_pubrel(struct mg_connection *nc, uint16_t message_id);
--- ---
Send a PUBREL command with a given `message_id`. Sends a PUBREL command with a given `message_id`.
+1 -1
View File
@@ -7,6 +7,6 @@ signature: |
uint16_t message_id); uint16_t message_id);
--- ---
Send a SUBACK command with a given `message_id` Sends a SUBACK command with a given `message_id`
and a sequence of granted QoSs. and a sequence of granted QoSs.
+1 -1
View File
@@ -8,5 +8,5 @@ signature: |
size_t topics_len, uint16_t message_id); size_t topics_len, uint16_t message_id);
--- ---
Subscribe to a bunch of topics. Subscribes to a bunch of topics.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_unsuback(struct mg_connection *nc, uint16_t message_id); void mg_mqtt_unsuback(struct mg_connection *nc, uint16_t message_id);
--- ---
Send a UNSUBACK command with a given `message_id`. Sends a UNSUBACK command with a given `message_id`.
+1 -1
View File
@@ -7,5 +7,5 @@ signature: |
size_t topics_len, uint16_t message_id); size_t topics_len, uint16_t message_id);
--- ---
Unsubscribe from a bunch of topics. Unsubscribes from a bunch of topics.
+1 -1
View File
@@ -6,5 +6,5 @@ signature: |
void mg_send_mqtt_handshake(struct mg_connection *nc, const char *client_id); void mg_send_mqtt_handshake(struct mg_connection *nc, const char *client_id);
--- ---
Send MQTT handshake. Sends an MQTT handshake.
@@ -7,5 +7,5 @@ signature: |
struct mg_send_mqtt_handshake_opts); struct mg_send_mqtt_handshake_opts);
--- ---
Send MQTT handshake with optional parameters. Sends an MQTT handshake with optional parameters.
+1 -1
View File
@@ -6,7 +6,7 @@ signature: |
void mg_set_protocol_mqtt(struct mg_connection *nc); void mg_set_protocol_mqtt(struct mg_connection *nc);
--- ---
Attach built-in MQTT event handler to the given connection. Attaches a built-in MQTT event handler to the given connection.
The user-defined event handler will receive following extra events: The user-defined event handler will receive following extra events:
+14
View File
@@ -0,0 +1,14 @@
---
title: "MQTT Server API reference"
symbol_kind: "intro"
decl_name: "mqtt_server.h"
items:
- { name: mg_mqtt_broker_init.md }
- { name: mg_mqtt_broker.md }
- { name: mg_mqtt_next.md }
- { name: struct_mg_mqtt_session.md }
- { name: struct_mg_mqtt_broker.md }
---
@@ -6,10 +6,10 @@ signature: |
void mg_mqtt_broker(struct mg_connection *brk, int ev, void *data); void mg_mqtt_broker(struct mg_connection *brk, int ev, void *data);
--- ---
Process a MQTT broker message. Processes a MQTT broker message.
Listening connection expects a pointer to an initialized `mg_mqtt_broker` The listening connection expects a pointer to an initialised
structure in the `user_data` field. `mg_mqtt_broker` structure in the `user_data` field.
Basic usage: Basic usage:
@@ -6,5 +6,5 @@ signature: |
void mg_mqtt_broker_init(struct mg_mqtt_broker *brk, void *user_data); void mg_mqtt_broker_init(struct mg_mqtt_broker *brk, void *user_data);
--- ---
Initialize a MQTT broker. Initialises a MQTT broker.
@@ -7,7 +7,7 @@ signature: |
struct mg_mqtt_session *s); struct mg_mqtt_session *s);
--- ---
Iterate over all mqtt sessions connections. Example: Iterates over all MQTT session connections. Example:
```c ```c
struct mg_mqtt_session *s; struct mg_mqtt_session *s;
+31 -30
View File
@@ -1,40 +1,41 @@
--- ---
title: "Core: TCP/UDP/SSL" title: "Core API: TCP/UDP/SSL"
symbol_kind: "intro" symbol_kind: "intro"
decl_name: "net.h" decl_name: "net.h"
items: items:
- { type: file, name: mg_mgr_init.md } - { name: mg_mgr_init.md }
- { type: file, name: mg_mgr_free.md } - { name: mg_mgr_free.md }
- { type: file, name: mg_mgr_poll.md } - { name: mg_mgr_poll.md }
- { type: file, name: mg_broadcast.md } - { name: mg_broadcast.md }
- { type: file, name: mg_next.md } - { name: mg_next.md }
- { type: file, name: mg_add_sock.md } - { name: mg_add_sock.md }
- { type: file, name: mg_add_sock_opt.md } - { name: mg_add_sock_opt.md }
- { type: file, name: mg_bind.md } - { name: mg_bind.md }
- { type: file, name: mg_bind_opt.md } - { name: mg_bind_opt.md }
- { type: file, name: mg_connect.md } - { name: mg_connect.md }
- { type: file, name: mg_connect_opt.md } - { name: mg_connect_opt.md }
- { type: file, name: mg_set_ssl.md } - { name: mg_set_ssl.md }
- { type: file, name: mg_send.md } - { name: mg_send.md }
- { type: file, name: mg_printf.md } - { name: mg_printf.md }
- { type: file, name: mg_vprintf.md } - { name: mg_vprintf.md }
- { type: file, name: mg_socketpair.md } - { name: mg_socketpair.md }
- { type: file, name: mg_check_ip_acl.md } - { name: mg_check_ip_acl.md }
- { type: file, name: mg_enable_multithreading.md } - { name: mg_enable_multithreading.md }
- { type: file, name: mg_enable_javascript.md } - { name: mg_enable_javascript.md }
- { type: file, name: mg_set_timer.md } - { name: mg_set_timer.md }
- { type: file, name: mg_time.md } - { name: mg_time.md }
- { type: file, name: mg_event_handler_t.md } - { name: mg_event_handler_t.md }
- { type: file, name: struct_mg_mgr.md } - { name: struct_mg_mgr.md }
- { type: file, name: struct_mg_connection.md } - { name: struct_mg_connection.md }
- { type: file, name: struct_mg_add_sock_opts.md } - { name: struct_mg_add_sock_opts.md }
- { type: file, name: struct_mg_bind_opts.md } - { name: struct_mg_bind_opts.md }
- { type: file, name: struct_mg_connect_opts.md } - { name: struct_mg_connect_opts.md }
- { name: struct_mg_multithreading_opts.md }
--- ---
NOTE: Mongoose manager is single threaded. It does not protect NOTE: Mongoose manager is single threaded. It does not protect
its data structures by mutexes, therefore all functions that are dealing its data structures by mutexes, therefore all functions that are dealing
with particular event manager should be called from the same thread, with a particular event manager should be called from the same thread,
with exception of `mg_broadcast()` function. It is fine to have different with exception of the `mg_broadcast()` function. It is fine to have different
event managers handled by different threads. event managers handled by different threads.
+2 -2
View File
@@ -6,8 +6,8 @@ signature: |
struct mg_connection *mg_add_sock(struct mg_mgr *, sock_t, mg_event_handler_t); struct mg_connection *mg_add_sock(struct mg_mgr *, sock_t, mg_event_handler_t);
--- ---
Create a connection, associate it with the given socket and event handler, Creates a connection, associates it with the given socket and event handler
and add it to the manager. and adds it to the manager.
For more options see the `mg_add_sock_opt` variant. For more options see the `mg_add_sock_opt` variant.
+2 -2
View File
@@ -8,8 +8,8 @@ signature: |
struct mg_add_sock_opts); struct mg_add_sock_opts);
--- ---
Create a connection, associate it with the given socket and event handler, Creates a connection, associates it with the given socket and event handler
and add to the manager. and adds to the manager.
See the `mg_add_sock_opts` structure for a description of the options. See the `mg_add_sock_opts` structure for a description of the options.
+1 -1
View File
@@ -7,7 +7,7 @@ signature: |
mg_event_handler_t); mg_event_handler_t);
--- ---
Create listening connection. Creates a listening connection.
See `mg_bind_opt` for full documentation. See `mg_bind_opt` for full documentation.
+11 -10
View File
@@ -8,19 +8,20 @@ signature: |
struct mg_bind_opts opts); struct mg_bind_opts opts);
--- ---
Create listening connection. Creates a listening connection.
`address` parameter tells which address to bind to. It's format is the same The `address` parameter specifies which address to bind to. It's format is
as for the `mg_connect()` call, where `HOST` part is optional. `address` the same as for the `mg_connect()` call, where `HOST` part is optional.
can be just a port number, e.g. `:8000`. To bind to a specific interface, `address` can be just a port number, e.g. `:8000`. To bind to a specific
an IP address can be specified, e.g. `1.2.3.4:8000`. By default, a TCP interface, an IP address can be specified, e.g. `1.2.3.4:8000`. By default,
connection is created. To create UDP connection, prepend `udp://` prefix, a TCP connection is created. To create UDP connection, prepend `udp://`
e.g. `udp://:8000`. To summarize, `address` paramer has following format: prefix, e.g. `udp://:8000`. To summarize, `address` paramer has following
`[PROTO://][IP_ADDRESS]:PORT`, where `PROTO` could be `tcp` or `udp`. format: `[PROTO://][IP_ADDRESS]:PORT`, where `PROTO` could be `tcp` or
`udp`.
See the `mg_bind_opts` structure for a description of the optional See the `mg_bind_opts` structure for a description of the optional
parameters. parameters.
Return a new listening connection, or `NULL` on error. Returns a new listening connection or `NULL` on error.
NOTE: Connection remains owned by the manager, do not free(). NOTE: The connection remains owned by the manager, do not free().
+3 -3
View File
@@ -6,14 +6,14 @@ signature: |
void mg_broadcast(struct mg_mgr *, mg_event_handler_t func, void *, size_t); void mg_broadcast(struct mg_mgr *, mg_event_handler_t func, void *, size_t);
--- ---
Pass a message of a given length to all connections. Passes a message of a given length to all connections.
Must be called from a thread that does NOT call `mg_mgr_poll()`. Must be called from a thread that does NOT call `mg_mgr_poll()`.
Note that `mg_broadcast()` is the only function Note that `mg_broadcast()` is the only function
that can be, and must be, called from a different (non-IO) thread. that can be, and must be, called from a different (non-IO) thread.
`func` callback function will be called by the IO thread for each `func` callback function will be called by the IO thread for each
connection. When called, event would be `MG_EV_POLL`, and message will connection. When called, the event will be `MG_EV_POLL`, and a message will
be passed as `ev_data` pointer. Maximum message size is capped be passed as the `ev_data` pointer. Maximum message size is capped
by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes. by `MG_CTL_MSG_MESSAGE_SIZE` which is set to 8192 bytes.
+5 -5
View File
@@ -13,15 +13,15 @@ Verify given IP address against the ACL.
Each subnet is Each subnet is
prepended by either a - or a + sign. A plus sign means allow, where a prepended by either a - or a + sign. A plus sign means allow, where a
minus sign means deny. If a subnet mask is omitted, such as `-1.2.3.4`, minus sign means deny. If a subnet mask is omitted, such as `-1.2.3.4`,
this means to deny only that single IP address. it means that only that single IP address is denied.
Subnet masks may vary from 0 to 32, inclusive. The default setting Subnet masks may vary from 0 to 32, inclusive. The default setting
is to allow all accesses. On each request the full list is traversed, is to allow all access. On each request the full list is traversed,
and the last match wins. Example: and the last match wins. Example:
`-0.0.0.0/0,+192.168/16` - deny all acccesses, only allow 192.168/16 subnet `-0.0.0.0/0,+192.168/16` - deny all acccesses, only allow 192.168/16 subnet
To learn more about subnet masks, see the To learn more about subnet masks, see this
link:https://en.wikipedia.org/wiki/Subnetwork[Wikipedia page on Subnetwork] link:https://en.wikipedia.org/wiki/Subnetwork[Wikipedia page on Subnetwork].
Return -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed. Returns -1 if ACL is malformed, 0 if address is disallowed, 1 if allowed.
+1 -1
View File
@@ -7,7 +7,7 @@ signature: |
mg_event_handler_t handler); mg_event_handler_t handler);
--- ---
Connect to a remote host. Connects to a remote host.
See `mg_connect_opt()` for full documentation. See `mg_connect_opt()` for full documentation.
+12 -12
View File
@@ -8,11 +8,11 @@ signature: |
struct mg_connect_opts opts); struct mg_connect_opts opts);
--- ---
Connect to a remote host. Connects to a remote host.
`address` format is `[PROTO://]HOST:PORT`. `PROTO` could be `tcp` or `udp`. The `address` format is `[PROTO://]HOST:PORT`. `PROTO` could be `tcp` or
`HOST` could be an IP address, `udp`. `HOST` could be an IP address,
IPv6 address (if Mongoose is compiled with `-DMG_ENABLE_IPV6`), or a host IPv6 address (if Mongoose is compiled with `-DMG_ENABLE_IPV6`) or a host
name. If `HOST` is a name, Mongoose will resolve it asynchronously. Examples name. If `HOST` is a name, Mongoose will resolve it asynchronously. Examples
of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`, of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
`[::1]:80` `[::1]:80`
@@ -20,18 +20,18 @@ of valid addresses: `google.com:80`, `udp://1.2.3.4:53`, `10.0.0.1:443`,
See the `mg_connect_opts` structure for a description of the optional See the `mg_connect_opts` structure for a description of the optional
parameters. parameters.
Returns a new outbound connection, or `NULL` on error. Returns a new outbound connection or `NULL` on error.
NOTE: Connection remains owned by the manager, do not free(). NOTE: The connection remains owned by the manager, do not free().
NOTE: To enable IPv6 addresses, `-DMG_ENABLE_IPV6` should be specified NOTE: To enable IPv6 addresses `-DMG_ENABLE_IPV6` should be specified
in the compilation flags. in the compilation flags.
NOTE: New connection will receive `MG_EV_CONNECT` as it's first event NOTE: The new connection will receive `MG_EV_CONNECT` as its first event
which will report connect success status. which will report the connect success status.
If asynchronous resolution fail, or `connect()` syscall fail for whatever If the asynchronous resolution fails or the `connect()` syscall fails for
reason (e.g. with `ECONNREFUSED` or `ENETUNREACH`), then `MG_EV_CONNECT` whatever reason (e.g. with `ECONNREFUSED` or `ENETUNREACH`), then
event report failure. Code example below: `MG_EV_CONNECT` event will report failure. Code example below:
```c ```c
static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) { static void ev_handler(struct mg_connection *nc, int ev, void *ev_data) {
Loaded 100 of 300 files, more files were not shown because too many files have changed in this diff. Show more