Commit Graph
2363 Commits
Author SHA1 Message Date
Olaf Bergmann a2e0046c80 [OSS-Fuzz] pdu_parse_target.c: Fix compiler warning
Declare prototype for internal function coap_pdu_encode_header().
2022-02-09 16:32:00 +01:00
obgm afb4f2b7a1 Merge pull request #812 from mrdeep1/multiple_sessions
sessions: Prevent multiple client session confusion
2022-02-09 12:38:35 +01:00
Jon Shallow b3d503cbff sessions: Prevent multiple client session confusion
Prevent multiple coap_new_client_session*() calls that are connecting to
the same server/port being bound to the same local ip/port.

Update logging for session creation / removal to easily differentiate between
sessions that have the same 4-tuple.

Document that coap_new_endpoint() is not required in client based code.

If coap-client '-p port' but not '-a addr' is provided, fix code so that
the port is bound to.

Only remove outstanding CON requests with token matches if there is an
ACK response.

Update the logging to differentiate between the 6 occurrences where the mid
is removed.
2022-02-08 16:52:15 +00:00
obgm 6aa967cee1 Merge pull request #809 from mrdeep1/cmake_tinydtls
cmake_coap_config.h.in: Fix definitions for when building with tinydtls
2022-02-08 15:43:36 +01:00
obgm dc4994f1d1 Merge pull request #821 from mrdeep1/block_docs
coap_block.txt.in: Clarify / more make readable the block handling information
2022-02-08 15:42:36 +01:00
obgm 838b2d9e39 Merge pull request #813 from mrdeep1/pdu_ordering
pdu building: Enforce the application order of building a PDU
2022-02-08 15:42:01 +01:00
Jon Shallow 726b9630e5 coap_block.txt.in: Clarify / more make readable the block handling information 2022-02-08 14:16:27 +00:00
Jon Shallow 756bb04239 pdu building: Enforce the application order of building a PDU
Make coap_add_option() invalid after calling a coap_add_data*() function.
Add in internal support for adding options to PDUs that contain data with
a replacement coap_add_option_internal() function.  Call this new function
in the appropriate places in the libcoap src.

Add coap_log warnings when the application tries to build a PDU in the wrong
order and then return failure.

Update documentation re-inforcing the PDU building order.
2022-02-08 14:14:51 +00:00
obgm 0d6c7d686b Merge pull request #819 from mrdeep1/coap_access_pdu
coap_pdu_access.txt.in: Add in documentation for coap_get_uri_path()
2022-02-07 17:33:00 +01:00
obgm 6504b667d3 Merge pull request #818 from mrdeep1/proxy_uri
proxy_uri: Fix handling the resource for uri path in Proxy-Uri
2022-02-07 17:32:31 +01:00
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
Jon Shallow aaf6115594 proxy_uri: Fix handling the resource for uri path in Proxy-Uri
If the server recieving a Proxy request determines that it is the final
endpoint of the request, the resource that the request was sent to
was wrong. The update to coap_get_uri_path() fixes this issue.

There is now also parameter support for the proxy definition for the
coap-server where any defined host is treated as being the final endpoint
is in:

  coap-server -P ,

This allows any actual server to be the final endpoint of any proxy request
without have to define all the names or IP addresses that the coap-server is
known by.  Note that if there is nothing following the , (comma), anything
before the , (comma) will never be used.

Documentation updated.
2022-02-07 14:46:46 +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
Jon Shallow 0a16d790ce cmake_coap_config.h.in: Fix definitions for when building with tinydtls
Build the coap_config.h file in the same way that the make system does
without wrapping the definitions with ""
2022-01-01 13:26:08 +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