Commit Graph
1240 Commits
Author SHA1 Message Date
Jon Shallow 2582d085f8 examples/client.c: Run at least once per sec to aid debugging 2018-04-13 14:08:08 +01:00
Jon Shallow 36de6d83a7 src/coap_openssl.c: Add in support for DTLS retry counting 2018-04-13 14:07:59 +01:00
Jon Shallow 60fccead90 include/coap/coap_session.h: Add in support for DTLS retry counting 2018-04-13 14:07:51 +01:00
obgm f889c29881 Merge pull request #139 from mrdeep1/man-pages
Add in man page support for the different exposed functions with examples
2018-04-09 14:01:55 +02:00
Jon Shallow d015c50091 coap-{client|rd|server}.txt.in: Move from examples to man directory 2018-04-07 11:34:44 +01:00
Jon Shallow 747205fb93 man/coap_observe.txt.in: New man page covering Observe usage 2018-04-07 11:34:44 +01:00
Jon Shallow 20cd610c03 examples/Makefile.am: Remove building man pages
Delete building man pages as they are now a part of the man directory
2018-04-07 11:34:44 +01:00
Jon Shallow 3f94f70fbd .gitignore: Add in man page temp files as well as src/ temp files to be ingored 2018-04-07 11:34:44 +01:00
Jon Shallow ebcf8ddb87 man/Makefile.am: New Makefile for building and installing man pages 2018-04-07 11:34:44 +01:00
Jon Shallow d21e0532bc configure.ac: Add in man page building with --enable-manpages
Create a new --enable-doxygen

Make --enable-documentation include both --enable-manpages and --enable-doxygen
and --disable-documentation include --disable-manpages and --disable-doxygen
2018-04-07 11:34:44 +01:00
Jon Shallow d766924954 autogen.sh: add in built man files to AUTOGEN_FILES=
Also add in examples/Makefile
2018-04-07 11:34:44 +01:00
Jon Shallow 050833ff50 Makefile.am: Add in man pages directory if man pages are being built 2018-04-07 11:34:44 +01:00
Jon Shallow c335c1e53e man/coap_tls_library.txt.in: New man page covering TLS library support 2018-04-07 11:34:44 +01:00
Jon Shallow 8b1fe26a7c man/coap_resource.txt.in: New man page covering resources 2018-04-07 11:34:44 +01:00
Jon Shallow 4a655b9840 man/coap_recovery.txt.in: New man page covering transmission recovery 2018-04-07 11:34:39 +01:00
Jon Shallow 3b9b5d2649 man/coap_handler.txt.in: New man page covering handlers 2018-04-06 10:49:56 +01:00
Jon Shallow e15f881af3 man/coap_context.txt.in: New man page convering contexts and session setup 2018-04-06 10:49:51 +01:00
Jon Shallow ee6ede84c2 man/coap_attribute.txt.in: New man page covering attributes 2018-04-06 10:49:46 +01:00
Jon Shallow ea30850d9d man/coap.txt.in: New overview man page 2018-04-06 10:49:35 +01:00
obgm 4cf5ff0c63 Merge pull request #152 from baw-serafin/resource_userdata
resource.h: Introduce new field user_data
2018-04-05 10:27:17 +02:00
obgm 4597c80983 Merge pull request #153 from mrdeep1/observe-fix
Observe additional functions to aid clarity
2018-04-05 10:21:28 +02:00
Jon Shallow b2df649822 libcoap-1.{map,sym}: Update 2018-04-04 18:39:12 +01:00
Jon Shallow ac97aeb9bc resource.c: Implement the coap_resource_notify_observers() function
Reuse coap_resource_set_dirty() and make coap_resource_set_dirty()
call coap_resource_notify_observers().
2018-04-04 18:39:12 +01:00
Jon Shallow 5ecc164caa coap_io.c: Include coap_check_notify() in the coap_write() logic
So that the application does not need to call in in the main i/o loop
2018-04-04 18:39:12 +01:00
Jon Shallow 864ae6df8c resource.h: Add in new Observe functions definitions
Add in

coap_resource_set_get_observable()
coap_resource_notify_observers()
coap_resource_get_uri_path()

Deprecate

coap_resource_set_dirty()
2018-04-04 18:38:14 +01:00
Jon Shallow 849deb2610 examples/contiki/coap-observer.c: Use COAP_OPTION_OBSERVE
As it is Observe that we are talking about here.
2018-04-04 16:46:04 +01:00
Jon Shallow 80cae52441 examples/coap-server.c: Update inline with new Observe functions
As we are talking about Observe here
2018-04-04 16:46:04 +01:00
Jon Shallow 97486e7112 examples/client.c: Change COAP_OPTION_SUBSCRIPTION to COAP_OPTION_OBSERVE
As we are talking about Observe here
2018-04-04 16:46:04 +01:00
Olaf Bergmann db48a839b6 test_uri.c: additional unit tests for URI creation
Added several unit tests for coap_get_uri_path():

* Check corner cases such as one or more zero-length Uri-Paths.
* Check percent-encoding of reserved characters.
* Check non-reserved characters that should not be percent-encoded.

This change also removes a couple of trailing LWS by accident.
2018-04-04 17:40:03 +02:00
obgm d28a8b5402 Merge pull request #133 from mrdeep1/issue-125
Issue 125 Fix - Support for unknown resource Uri when doing PUT/DELETE
2018-04-04 17:38:23 +02:00
Jon Shallow 373c132c27 resource.c: Add in support for unknown URI handler and update hashing
Include coap_resource_unknown_init() function for defining the unknown
resource.

Update hashing to use the resource's uri_path instead of key where appropriate
to avoid clashes when using the old hashed key.

coap_add_resource() now deletes previous resource with matching uri_path to
prevent duplication.

Remove now obsolete functions
coap_hash_request_uri()
coap_get_resource_from_key()

New function
coap_get_resource_from_uri_path()

*API Update coap_delete_resource() now deletes by resource, not by key.
2018-04-04 16:19:37 +01:00
Jon Shallow 9821b4b689 str.c: Replace str with coap_string_t
At some point, str will get replaced in all of the code with coap_string_t.
This is to prevent potential name clashes when compiling application code.

Use coap_malloc_type(COAP_STRING,... instead of coap_malloc(...
2018-04-04 16:19:37 +01:00
Jon Shallow 1c2d9416fe str.h: Add coap_string_equal() and create coap_string_t as replacement for str
Rename struct str as struct coap_string_t and 'typedef coap_string_t str' for
backwards compatabilty with the intent of removing str at some point to
prevent potential name clashes when compiling application code.

Add in new coap_string_equal() function for consistent comparing of strings.
2018-04-04 16:19:37 +01:00
Jon Shallow b7e1040fac hashkey.[ch]: Files removed as no longer used 2018-04-04 16:19:37 +01:00
Jon Shallow fbe1b8283d coap_config.h.lwip: Remove COAP_RESOURCES_NOHASH as no longer supported 2018-04-04 16:19:37 +01:00
Jon Shallow 8b5b9e083e coap_config.h.contiki: Remove COAP_RESOURCES_NOHASH as no longer supported 2018-04-04 16:19:37 +01:00
Jon Shallow 60e07c4eed Makefile.libcoap: Remove -DCOAP_RESOURCES_NOHASH as no longer supported 2018-04-04 16:19:37 +01:00
Jon Shallow 59d0d36b1d libcoap.vcxproj libcoap.vcxproj.filters: Stop building obsoleted hash libraries 2018-04-04 16:19:37 +01:00
Jon Shallow 1d61c32fee tests/test_uri.c: Update to use uri_path instead of key for resource hash. 2018-04-04 16:19:36 +01:00
Jon Shallow 14a2dc5b0b uri.c: Remove obsoleted functions, add in coap_get_uri_path()
With resource's hashed key being replaced by uri_path, old hash functions have
been removed and a new fuction coap_get_uri_path() added to abstract the
uri_path from the pdu.

Tidy up usage of is_unescaped_in_query() and slit it partially out to support
is_unescaped_in_path.

Update unsigned to uint16_t in appropriate places
2018-04-04 16:19:26 +01:00
obgm 0e672d048a Merge pull request #157 from mrdeep1/observers-memleak
resource.c: Fix memory leaks when deleting observers
2018-04-04 17:06:20 +02:00
Jon Shallow 11224dde47 resource.c: Fix memory leaks when deleting observers
When freeing off a subscriber entry, free off the saved query at
the same time.  Already done once, needs to be done in the three
other instances.
2018-03-15 20:33:25 +00:00
Jon Shallow 235a11ebe8 uri.h: remove coap_hash_path() and add coap_get_uri_path()
The old hashed key is no longer used, so coap_hash_path() is obsolete.

coap_get_uri_path() added to build the resource Uri Path from the pdu.
2018-03-14 09:32:58 +00:00
Jon Shallow ff6f8e041c pdu.h: remove COAP_DEFAULT_WKC_HASHKEY as no longer needed 2018-03-14 09:32:58 +00:00
Jon Shallow 6bbf993dbe examples/coap-rd.c: Update resource hashing from key to uri_path
Resources are now hashed by uri_path, not key.
2018-03-14 09:32:58 +00:00
Jon Shallow d88b0bb7fe Makefile.am: Drop building coap hash functions
As "coap_key_t key" is no longer used as the key for hashing resources onto
the hashlist which gave the potential for coap hashes clashing for the
resource Uri, "str uri" being used instead, so disable the building of the
coap_hash functions.

In addition, the .sym and .map file information now has duplicate
entries removed.
2018-03-14 09:32:58 +00:00
Jon Shallow be0c6616c6 libcoap-1.map & libcoap-1.sym: Add in coap_resource_unknown_init
Expose the new functions
coap_resource_unknown_init()
coap_get_uri_path()
coap_get_resource_from_uri_path()

Drop the functions as old hashed key is no longer supported
coap_get_resource_from_key()
coap_hash_*()
2018-03-14 09:32:58 +00:00
Jon Shallow e907596473 net.c: Update handle_request() to support unknown resource handler
Update handle_request() to call context->unknown_resource handler (if defined)
to support "RFC7252: 5.8.3.  PUT" requirements.

Allow only handlers defined for unknown_resource

Update handle_request() to return 2.02 for an unknown resource (and
context->unknown_resource is not defined) for a DELETE request
"RFC7252: 5.8.4.  DELETE"

Update code to use resource's uri_path not key as the item to hash for lookups

Make use of the new function coap_string_equal() when checking for
COAP_DEFAULT_URI_WELLKNOWN resource request.

Remove now obsolete hashed key code for is_wkc().
2018-03-14 09:32:45 +00:00
Jon Shallow 5aa31d010c resource.h: Add coap_add_resource_unknown() and hash resource on uri_path
Need to support
"RFC7252: 5.8.3.  PUT
 If no resource exists, then the server MAY create a new resource with that
 URI, resulting in a 2.01 (Created) Response Code."

Add in the function definition for the coap_add_resource_unknown().
Add in 'is_unknown' flag into coap_resource_t.

Make the resource uri_path be the hash lookup key, not the old hashed key, to
stop hash lookup clashes.

*API Change* Update coap_delete_resource() to not use the old hashed key.
Remove coap_get_resource_from_key() function and replace it with
coap_get_resource_from_uri_path().

Make the coap_resource_set_mode() more robust against bad parameters.

Remove #ifdef COAP_RESOURCES_NOHASH logic as no longer required
2018-03-13 14:49:22 +00:00
Serafin Leschke e394ca2953 resource.h: Introduce new field user_data
The library API lacks a way to store context for the handlers. A
LED-handler for example needs to now on which pin the specific LED
is connected in order to control it. Or a higher level API would like to save the
object pointer to the object responsible for the resource.

This change will introduce a void pointer for the user to save context.
He can then retrieve the context in the handler if needed.
2018-03-13 09:29:53 +01:00