Commit Graph
2351 Commits
Author SHA1 Message Date
Jon Shallow c02ca5f097 coap_pdu_access.txt.in: Add in documentation for coap_get_uri_path()
Also document the return values of the various functions.
2022-02-07 14:50:03 +00:00
obgm 1fceff7cc3 Merge pull request #814 from mrdeep1/build_version
versioning: Make current git describe available
2022-02-07 14:38:34 +01:00
obgm 5e793d4852 Merge pull request #816 from mrdeep1/coap_encode
coap_pdu_setup.txt.in: Better document coap_encode_var_safe8()
2022-02-07 13:24:47 +01:00
Jon Shallow a8c00f2af9 coap_pdu_setup.txt.in: Better document coap_encode_var_safe8()
Document return value can be 0 for both being valid and returning on error.
Same is true for coap_encode_var_safe().

[Error should assert() by default]
2022-02-02 21:37:54 +00:00
Jon Shallow 64e5641017 versioning: Make current git describe available
Add new function coap_package_build() which returns "git describe --tags"
if available at library build time, else standard package version.

The value of "git describe --tags" is created at run time and passed in as
a compiler -D definition.

Update copyright end dates for updated files.
2022-02-02 11:24:52 +00:00
obgm 2a329e1c76 Merge pull request #771 from mrdeep1/server_post
coap-server: Add in POST support for unknown request handler
2021-12-22 15:31:37 +01:00
obgm fce44ba52a Merge pull request #779 from mrdeep1/mid_testing
coap_session.c: Do not check for duplicate mids if reliable protocol
2021-12-22 15:05:02 +01:00
obgm 17f7fe8c52 Merge pull request #780 from mrdeep1/multicast_get
coap-client.c: Allow time for all server responses to mcast
2021-12-22 14:16:36 +01:00
obgm 0da7c50c54 Merge pull request #790 from mrdeep1/mbedtls_lib
configure.ac: Fix have mbedtls lib, but no mbedtls-dev issue
2021-12-22 14:15:03 +01:00
obgm ffc1f4f938 Merge pull request #791 from mrdeep1/resource_delete
resource.c: Support deleting resources that have not yet been added
2021-12-22 14:04:05 +01:00
Jon Shallow 74582eddde resource.c: Support deleting resources that have not yet been added
Support deleting a resource both before and after calling
coap_delete_resource().

Make the coap_delete_resource() usage in examples less complex.
2021-12-22 12:59:32 +00:00
obgm efe18d2845 Merge pull request #781 from mrdeep1/large_tcp_writes
coap_write_session: Account correctly for partial TCP writes
2021-12-22 13:55:28 +01:00
obgm dc0db3a238 Merge pull request #796 from mrdeep1/block_boundaries
block: Check block size space correctly
2021-12-22 12:04:27 +01:00
obgm cbe387614c Merge pull request #799 from mrdeep1/cmake_bin_install
cmake: Install example programs if examples enabled
2021-12-22 12:02:49 +01:00
obgm 470f36b45e Merge pull request #801 from mrdeep1/request_overlap
block.c: Do not match large response if no Block2 option in request
2021-12-22 12:02:27 +01:00
obgm 571807bcc5 Merge pull request #803 from mrdeep1/request_handler_log
request_handler: Report only when app's request handler is actually called
2021-12-22 12:00:13 +01:00
Jon Shallow 32d2d0e1c6 request_handler: Report only when app's request handler is actually called
Aids tracking issues with the libcoap block handling logic to easily
differentiate when libcoap sends a response and when app handler is called
to send a response.
2021-12-22 10:23:34 +00:00
Jon Shallow 5dc2dfca86 block.c: Do not match large response if no Block2 option in request
Allows a following request not to match cached multi-payload large response.
2021-12-20 20:31:37 +00:00
Jon Shallow 18888cd0dd cmake: Install example programs if examples enabled 2021-12-20 12:24:00 +00:00
Jon Shallow c0e032ffad block: Check block size space correctly
Account correctly for larger stateless tokens.
2021-12-18 15:16:45 +00:00
obgm 997c31fa62 Merge pull request #792 from kkrentz/return-pr
Corrects return value in net.c#coap_send_internal
2021-12-16 08:58:29 +01:00
kkrentz 693a4e2313 net.c: correct return value in coap_send_internal()
The interface description of coap_send_internal says that COAP_INVALID_MID
is returned  in the case of errors. Presently, it, however, returns
"(coap_mid_t)bytes_written" in a special case. Accidentally,
bytes_written == -1 == COAP_INVALID_MID in this specific case, which is why
no problems occur in practice due to this. As a cosmetic fix, this commit
changes the return value to COAP_INVALID_MID.
2021-12-14 15:37:34 +01:00
Jon Shallow 38bffb7f99 configure.ac: Fix have mbedtls lib, but no mbedtls-dev issue
Do not make it a hard error if mbedtls library exists, but the mbedtls
development environment is missing.

Just remove mbedtls support if this is the case.
2021-12-13 10:04:49 +00:00
obgm cca9c858b9 Merge pull request #737 from mrdeep1/proxy_fix
coap-server.c: Fix proxy response type and code
2021-12-08 15:59:33 +01:00
Jon Shallow 694a205f28 coap-server.c: Fix proxy response type and code
Handle "separate" response types correctly.

Make proxy based traffic handling mode COAP_BLOCK_SINGLE_BODY to remove
complexities.

Rename proxy_message_handler() to proxy_response_handler() as it is a
response handler.

Build a dummy 'received' PDU for use with coap_add_data_large_response() in
proxy_response_handler() to be consistant across all uses of
coap_add_data_large_response().

Add appropriate resource_flags (so that NON can be used in observe) for
resources "async" and "example_data".
2021-12-08 11:09:15 +00:00
Jon Shallow e8e33f0424 coap-server: Add in POST support for unknown request handler 2021-12-07 21:30:35 +00:00
obgm 7d6903d857 Merge pull request #784 from mrdeep1/cache_fix
coap_cache.c: Correctly build cache key
2021-12-07 13:20:24 +01:00
obgm c83c7703ed Merge pull request #769 from mrdeep1/handler_doc
handlers: Clarify which handlers are client only, server only or both
2021-12-07 13:04:22 +01:00
obgm 8acd058865 Merge pull request #740 from mrdeep1/block_fix
RFC7959: Handle both client and server initiating requests
2021-12-06 19:11:53 +01:00
Jon Shallow 3f5ec5467a coap_cache.c: Correctly build cache key
Include actual session address in the hash, not first 8 bytes of session.

Include actual option number in the hash, not the delta which may vary
if there are different non-cachable option across the payloads of a body.
2021-12-04 17:14:22 +00:00
Jon Shallow e43cf9369a RFC7959: Handle both client and server initiating requests
Simplify token handling by having a state token for Block1 requests where the
top 16 bits are an incrementing request counter and the bottom 48 bits are the
base token.

Re-order struct coap_lg_crcv_t to reduce data space usage.

Track request method for Block2 requests.

Make coap_add_data_large_internal() a static function.

Make sure that lg_srcv is freed off when all PUT/POST data is in to
prevent next PUT/POST to same resource not getting correctly updated.
2021-11-30 15:53:57 +00:00
Jon Shallow bdf7686613 coap_write_session: Account correctly for partial TCP writes
Fix the buffer start offset when writing the next part of the PDU.

Also correctly report the number of bytes actually written,
2021-11-29 15:59:17 +00:00
Jon Shallow 76194be8cd coap-client.c: Allow time for all server responses to mcast
Instead of exiting after first response to a mcast request, wait for
DEFAULT_LEISURE for all potential server responses.
2021-11-29 11:59:27 +00:00
Jon Shallow d395df1a81 coap_session.c: Do not check for duplicate mids if reliable protocol 2021-11-29 10:39:10 +00:00
Jon Shallow 73389b8192 handlers: Clarify which handlers are client only, server only or both
Add in additional handler coap_register_request_handler() in addition to
coap_register_handler() but now only refer to and use
coap_register_request_handler() to aid readability.
2021-11-05 15:39:22 +00:00
Olaf Bergmann df9071c93e coap_session.[hc]: Added function to retrieve PSK identity from session
The new function coap_session_get_psk_identity() returns the given
session's psk_identity as provided during the handhake (for CoAP server)
or a session setup (for CoAP client).
2021-10-21 09:59:56 +02:00
obgm c821148b98 Merge pull request #746 from mrdeep1/doc_summary
doxygen: Fix summary output for manual pages
2021-10-18 09:50:22 +02:00
Olaf Bergmann 7791897e8f api-version-bump.sh: Added missing changes for win32
This change adds replacements for additional files in the win32
subdirectory tree according to commit 166ef51e (see [1]).

[1] https://github.com/obgm/libcoap/pull/763
2021-10-18 09:48:56 +02:00
obgm ca3d68e567 Merge pull request #763 from mrdeep1/windows-3
Windows: Update libcoap-2 objects to libcoap-3
2021-10-18 09:46:11 +02:00
Helmut Grohne 4834b86067 pkg-config: Don't use hard coded binary
libcoap3 fails to cross build from source, because configure.ac hard
codes the build architecture pkg-config.
2021-10-18 09:06:58 +02:00
Jon Shallow 166ef51ed1 Windows: Update libcoap-2 objects to libcoap-3 2021-10-10 20:28:54 +01:00
obgm c190c4960f Merge pull request #732 from mrdeep1/doc_modules
doxygen: Tidy up Modules and Files tab information
2021-10-04 17:17:39 +02:00
obgm 26f6ddfd12 Merge pull request #742 from mrdeep1/psk_checks
PSK: Make PSK hint / key / identity retrieval simpler
2021-10-04 08:21:50 +02:00
Jon Shallow 31722c208a PSK: Make PSK hint / key / identity retrieval simpler
Make the retrieval of  PSK hint / key / identity items simpler, remove
duplicate coding, remove a set of memcpy() and handle all these internally
as coap_bin_const_t.

This removes the need for libcoap internally to allocate (potentially
limited) holding space for these items on the stack.

The respective (D)TLS interface modules then convert these items into
the format required for the underlying (D)TLS libraries.

If the underlying (D)TLS library indicates that there is insufficient
space for an item (defined by a max_len type parameter), then the item
is truncated to that size and a warning issued about the provided item
being too large for the underlying (D)TLS library.

The item access functions are now standalone, not indexed through
coap_context_t.
2021-10-01 17:46:56 +01:00
obgm 5d9b29ce65 Merge pull request #756 from mrdeep1/coap_pdu_parse
coap_pdu_parse: Add to public API
2021-10-01 09:33:55 +02:00
Jon Shallow d746fc24e5 coap_pdu_parse: Add to public API 2021-09-30 21:41:53 +01:00
Jon Shallow 0aeb0d6247 doxygen: Tidy up Modules and Files tab information
doc/module_api_wrap.h: New

Used to split modules into Application and Internal only.

include/coap/*.h:

Module (@defgroup) description put into group application_api or internal_api
as appropriate.

Add in @file information if missing.

src/*.c

Add in @file information.
2021-09-30 16:59:04 +01:00
obgm 2952468cc5 Merge pull request #728 from mrdeep1/client_server
client+server: Reduce code size by building libcoap for client or server only
2021-09-30 17:29:15 +02:00
Jon Shallow f026f5701e client+server: Reduce code size by building libcoap for client or server only
Add in new ./configure options --enable-client-mode or
--enable-server-mode which by default are enabled.

If --disable-client-mode is set, then disable all the client specific code.
[ COAP_CLIENT_SUPPORT is not defined ]

If --disable-server-mode is set, then disable all the server specific code.
[ COAP_SERVER_SUPPORT is not defined ]

Functions and variables are only #ifdef'd out in the include/coap3/*_internal.h
files.  They cannot be #ifdef'd out in the other include files as
COAP_CLIENT_SUPPORT and COAP_SERVER_SUPPORT are not available for application
compilations. The result of this is if, say, client only API functons are used
in a server application and COAP_CLIENT_SUPPORT is not defined, there will be
linking issues (missing functions).  Providing stub functions unecessarily
increases the code size.

For coap-server, if it is able to provide proxy support, requires both
COAP_SERVER_SUPPORT and COAP_CLIENT_SUPPORT to set up the ongoing sessions.
So, the build environment deliberatly sets SERVER_CAN_PROXY=0 if
COAP_CLIENT_SUPPORT is not available to allow linking.

Some of the tests have to be disabled if COAP_SERVER_SUPPORT or
COAP_CLIENT_SUPPORT is not set.

Code size change indications

   text    data     bss     sum   filename
 155912    1728   12080  169720   libcoap-3-notls.a
 138300    1728   12080  152108   libcoap-3-notls.a --disable-client-mode
 106734    1632   10304  118670   libcoap-3-notls.a --disable-server-mode

 180485    1733   12080  194298   libcoap-3-openssl.a
 160306    1733   12080  174119   libcoap-3-openssl.a --disable-client-mode
 125543    1637   10304  137484   libcoap-3-openssl.a --disable-server-mode

 181755    1728   12080  195563   libcoap-3-gnutls.a
 160972    1728   12080  174780   libcoap-3-gnutls.a --disable-client-mode
 127178    1632   10304  139114   libcoap-3-gnutls.a --disable-server-mode

 165879    1855   12128  179862   libcoap-3-tinydtls.a
 147022    1855   12128  161005   libcoap-3-tinydtls.a --disable-client-mode
 115618    1759   10352  127729   libcoap-3-tinydtls.a --disable-server-mode

 171690    1728   13744  187162   libcoap-3-mbedtls.a
 152099    1728   13712  167539   libcoap-3-mbedtls.a --disable-client-mode
 118786    1632   11984  132402   libcoap-3-mbedtls.a --disable-server-mode
2021-09-30 16:10:52 +01:00
obgm 1091e59ff4 Merge pull request #747 from mrdeep1/session_release
net.c: Protect against session release in coap_io_do_io()
2021-09-30 16:28:52 +02:00