Commit Graph
2119 Commits
Author SHA1 Message Date
Olaf Bergmann 6d8aaa9b90 scripts/api-version-bump.sh: fix missing file
Fix API version in files generated from man/examples-code-check.c.

Call autoreconf after updating configure.ac to ensure configure is
re-run the next time make is executed.
2021-04-15 12:04:56 +02:00
obgm c2e7b42e30 Merge pull request #637 from mrdeep1/siocgifindex
siocgifindex: use if_nametoindex() if available
2021-04-15 10:41:47 +02:00
Olaf Bergmann 8efab74066 scripts/api-version-bump.sh: require explicit version parameter
To avoid accidentally changing the API version, the script now aborts
if no new version other than the current API version has been
specified.
2021-04-14 13:06:15 +02:00
Jon Shallow 6d414205c1 siocgifindex: use if_nametoindex() if available
Fixes MacOS builds
2021-04-13 17:10:25 +01:00
obgm d9ecb04a99 Merge pull request #627 from mrdeep1/obf_session_t
coap_session_t: Obfuscate coap_session_t for applications
2021-04-09 15:05:00 +02:00
Jon Shallow 0c3928f536 coap_session_t: Obfuscate coap_session_t for applications
Move coap_session_t and coap_addr_hash_t to coap_session_internal.h.

Move internal session based function definitions to coap_session_internal.h.

Replace most references to "struct coap_session_t" with "coap_session_t".

Provide new functions to allow applications to access parts of coap_session_t
as appropriate and document these functions.

Update examples to use these new access functions where appropriate.

For the man documentation, move the client session setup functions to (new)
coap_endpoint_client(3) and update coap_session(3) with all the session access
functions as these are common to both the client and server.
[coap_endpoint_server(3) will be created when coap_context_t is obfuscated.]
2021-04-09 13:13:46 +01:00
obgm 3b8a77d744 Merge pull request #633 from mrdeep1/libraries
libraries: Rename libcoap-x to libcoap-x-notls and make libcoap-x default linker
2021-04-08 18:24:16 +02:00
Jon Shallow 9612b50c5f libraries: Rename libcoap-x to libcoap-x-notls and make libcoap-x default linker
Make the old installed libcoap-2.{so,la,a,pc} libcoap-2-notls.{so,la,a,pc}, and
make the installed libcoap-2.{so,la,a,pc} be a set of soft links to installed
libcoap-2.{tlstype}.{so,la,a,pc}.

Thus installed libcoap-2.{so,la,a,pc} will be based on the latest (D)TLS
library build.

Update the linking documentation.
2021-04-08 16:40:17 +01:00
Olaf Bergmann 145d86f96d scripts/api-version-bump.sh: Adjust hard-coded API version
This script is called from the package's top directory to adjust
all places where the current API version is hard-coded. The
current version is detected from the LIBCOAP_API_VERSION in
configure.ac. The target version is LIBCOAP_API_VERSION + 1 if no
parameter is provided on the command line. Otherwise, the given
value is used as target version.

Note that calling this script also results in 'git mv' operations.
git commit must be called manually after running this script.
2021-04-08 14:32:52 +02:00
Olaf Bergmann 60dd7aa32a [LWIP] Makefile: Fix include path for lwippools.h
Create path for pre-processor includes from LIBCOAP_API_VERSION in
configure.ac. This avoids breaking the example after API version
change.
2021-04-08 14:32:20 +02:00
obgm 4426fa2a69 Merge pull request #624 from mrdeep1/versioning
versioning: Include api version in non-posix coap_config.h/coap.h .in…
2021-04-08 14:29:14 +02:00
obgm 707822005e Merge pull request #622 from mrdeep1/esp_idf_1
esp-idf: Fix for esp-idf builds
2021-04-08 10:39:30 +02:00
obgm 3b9ec3b691 Merge pull request #625 from mrdeep1/duplicate_ack
net.c: Handle duplicate empty ACK
2021-04-07 17:13:56 +02:00
obgm 98ccc9f35a Merge pull request #631 from mrdeep1/invalid_tid
COAP_INVALID_TID: Inform this is deprecated and to use COAP_INVALID_MID
2021-04-07 17:09:47 +02:00
obgm e4b92da827 Merge pull request #629 from mrdeep1/lib_ver
Examples: Output runtime libcoap version in usage()
2021-04-07 17:04:58 +02:00
Jon Shallow 91737ccb46 versioning: Include api version in non-posix coap_config.h/coap.h .in files
Add in some new .in files, but still keep original files in distribution
files.

Essentially, use coap@LIBCOAP_API_VERSION@ (or equivalent) instead of
coap2. so resultant files have the correct value.

coap_config.h.lwip.in: (new)
coap_config.h.riot.in: (new)
include/coap2/coap.h.windows.in: (new)

As per https://gcc.gnu.org/onlinedocs/cpp/Search-Path.html, many of the
coap2/ prefixes are not required for #include, so these have been removed.

Make sure that the test suite accesses the latest source version of
coap@LIBCOAP_API_VERSION@/coap.h by creating a tests/test_common.h.in that
makes the correct tests/test_common.h which is included in all of the test
suite files.
2021-04-07 13:01:42 +01:00
obgm e20ae3c298 Merge pull request #623 from mrdeep1/nits
nits: Fix runtime warnings
2021-04-07 13:11:01 +02:00
Jon Shallow 640ede340e COAP_INVALID_TID: Inform this is deprecated and to use COAP_INVALID_MID
Doxygen comment only, but allow COAP_INVALID_TID to still be used.
2021-04-07 11:48:03 +01:00
Jon Shallow e7bcd53375 esp-idf: Fix for esp-idf builds
src/coap_mbedtls.c:

Add in fix for memory leak found by esp-idf.

src/coap_io.c:
src/net.c:

Update multicast setup logic to support esp-idf.
2021-04-07 11:40:06 +01:00
Jon Shallow db075ce659 Examples: Output runtime libcoap version in usage()
Helps to diagnose issues.
2021-04-06 14:07:09 +01:00
Jon Shallow bdeeae9c04 net.c: Handle duplicate empty ACK
An empty response ACK is ignored if there was a request on the Send-Q.

However if there was a subsequent duplicate ACK this would then fall through
to the general handling logic in coap_dispatch(), and would trigger the ping
handler (if set) and send a RST (if not mcast) which is not correct.

Correct a change added in by #554 so that all empty response ACKs are ignored.
2021-03-31 12:56:03 +01:00
Jon Shallow 7b9f7db224 nits: Fix runtime warnings
src/coap_debug.c:

Increase available buffer space.

src/coap_gnutls.c

Do not access NULL pointer offset.
2021-03-27 12:41:07 +00:00
Olaf Bergmann 4cab59dbbf configure.ac: bounce version number to v4.3.0rc1
Set library version to

LT_LIBCOAP_CURRENT=3
LT_LIBCOAP_REVISION=0
LT_LIBCOAP_AGE=0
v4.3.0-rc1
2021-03-18 15:05:02 +01:00
obgm f8048b4ad2 Merge pull request #621 from mrdeep1/win32
win32/libcoap.sln: Fix Debug DLL build issue
2021-03-18 14:38:00 +01:00
Jon Shallow b32ef3f31b win32/libcoap.sln: Fix Debug DLL build issue
Fix Debug DLL issue and re-order NoTLS entries as updated by VS
configuration manager.
2021-03-18 13:16:25 +00:00
obgm 7906bcf2a3 Merge pull request #613 from mrdeep1/message_id
message id: clean up documentation usage of transaction which is message id
2021-03-18 13:52:10 +01:00
obgm 9410aa5070 Merge pull request #619 from mrdeep1/large_mcast
mcast block2: Support mcast request with block2 responses
2021-03-18 13:51:53 +01:00
obgm 59fdcd4b44 Merge pull request #620 from mrdeep1/ms_build
build: Add in Visual Studio build
2021-03-17 19:00:13 +01:00
Olaf Bergmann 877e8d01d7 Updated Doxyfile.in to version 1.9.1 2021-03-17 18:57:40 +01:00
obgm d717ee2a08 Merge pull request #617 from mrdeep1/mcast_if
multicast: Add in IPv4 and update IPv6 multicast support
2021-03-17 18:47:55 +01:00
Jon Shallow a34228c80f multicast: Add in IPv4 and update IPv6 multicast support
include/coap2/net.h:
src/net.c:

Update code using #587 as a base to fix potential issues.

Fixes CID 1502429

CMakeLists.txt:
cmake_coap_config.h.in:

Test for <net/if.h>

examples/coap-rd.c:
examples/coap-server.c:
man/coap-rd.txt.in:
man/coap-server.txt.in:

Add in -G option to support specifying interface to use for multicasting.
Otherwise, the interface allocated by the O/S is used depending on the
address (if any) bound to.

man/Makefile.am:
man/coap_context.txt.in:

Document the coap_join_mcast_group_intf() function.

src/coap_debug.c:

Make sure that coap_print_addr() returns a NULL terminated buffer.
2021-03-17 17:43:14 +00:00
Szabolcs Szekelyi 42b2f03470 Allow network interface name to be specified when joining multicast group
This change renames `coap_join_mcast_group` to `coap_join_mcast_group_intf`
and adds an extra `const char *ifname` parameter to specify the interface
name.

A `coap_join_mcast_group` macro is defined to maintain backwards API
compatibility.

`coap_is_mcast` has been modified to recognize IPv6-mapped IPv4 multicast
addresses. Without this `coap_network_send` treats these addresses as
unicast which makes `semdmsg` fail with EINVAL.

Examples have been updated to use the new call.
2021-03-17 17:25:31 +00:00
Jon Shallow a524b2341c build: Add in Visual Studio build
Update Windows build files to include a build that does not use OpenSSL
(called NoTLS).

Include this build in the github workflow.
2021-03-17 16:55:07 +00:00
obgm 1d300a6275 Merge pull request #615 from mrdeep1/block2_fix
Block2: Fix ordering issue when calling coap_add_data_large_response()
2021-03-17 17:48:41 +01:00
obgm d3cb5f4990 Merge pull request #618 from mrdeep1/nit_fixes
General: Fix minor issues
2021-03-17 17:41:13 +01:00
obgm a713c4029b Merge pull request #614 from mrdeep1/coverity_2
Coverity: Fix scan issues
2021-03-17 17:39:52 +01:00
Jon Shallow 74342abe4d Coverity: Fix scan issues
Fixes

CID 1502435:
CID 1502432:
CID 1502423:

False Positives

CID 1502434:  Cant see why code is not reached
CID 1502433:  Could make blk_size uint8_t:3 I guess.
CID 1502430:  Dont know why it is complaining
CID 1502427:
CID 1502426:  Code looks fine to me - context->session could be set.
CID 1502424:

Fixed by other PRs

CID 1502422: #610
CID 1502431: #610
CID 1502428: #610
CID 1502429: #587 with my additional fixes
2021-03-17 11:17:18 +00:00
Jon Shallow 50095d343a mcast block2: Support mcast request with block2 responses
The first block response is unicast, and the client requests the further blocks
using unicast.  https://tools.ietf.org/html/rfc7959#section-2.8

However, the hash for the server lookup of incoming data is based on
coap_addr_tuple_t which includes the local address - which changes between
receipt of mcast and unicast requests.  This causes 2 sessions to be set up,
and the subsequent request/responses are treated as individual block random
access causing mismatch of information by the client.

Fix is to hash only on the remote address (IP + port) and local port for
servers.
2021-03-16 11:32:59 +00:00
Jon Shallow 7b8bd139d0 General: Fix minor issues
src/coap_tinydtls.c:

Replace UNUSED with COAP_UNUSED that got missed from a merge.

man/examples-code-check.c:
src/pdu.c:
tests/oss-fuzz/pdu_parse_target.c:

Fix trailing white space.

win32/libcoap.vcxproj:
win32/testdriver/testdriver.vcxproj:

Correct include/coap2 paths.
2021-03-15 16:01:21 +00:00
Jon Shallow 48a680359d Block2: Fix ordering issue when calling coap_add_data_large_response()
If the response code was set after calling coap_add_data_large_response(),
the continuing blocks were sent with code 0.00.

Now check following call to response handler that the correct code is held
within the lg_xmit information.
2021-03-10 13:12:45 +00:00
Jon Shallow 48ae6b0fdc message id: clean up documentation usage of transaction which is message id
CoAP transaction id was formerly defined as a hash of the remote address and
message id of the CoAP PDU.  It now only refers to, and is used as, the
message id.

Replace occurences of 'transaction id' with 'message id' to reflect naming in
RFC7252.

Correct the definition of coap_tid_t to what it actually represents.

Replace occurrences of coap_tid_t with coap_mid_t.

Replace uses of tid with mid

Remove unused function coap_find_transaction().
2021-03-08 18:49:30 +00:00
obgm ae752e9e7a Merge pull request #612 from mrdeep1/coap_unused
COAP_UNUSED: Remove UNUSED and UNUSED_PARAM and use COAP_UNUSED instead
2021-03-08 18:43:45 +01:00
obgm 301f6e10c0 Merge pull request #606 from mrdeep1/refactor_headers
include: Move header files into libcoap namespace
2021-03-08 18:39:01 +01:00
obgm 6965d404e2 Merge pull request #610 from mrdeep1/large_block_fix
RFC7959: Handle both Block1 and Block2 for same request/response
2021-03-08 18:34:17 +01:00
Jon Shallow 0c031d7904 include: Move header files into libcoap namespace
I.E. '#include "mem.h"' becomes '#include "coap2/mem.h"'

This prevents header name clashes.

Replacement for #487
2021-03-08 16:45:02 +00:00
Jon Shallow 4a264b2b4c COAP_UNUSED: Remove UNUSED and UNUSED_PARAM and use COAP_UNUSED instead
Remove the UNUSED and UNUSED_PARAM definitions and use a single definition
of COAP_UNUSED as defined in libcoap.h

Replace all UNUSED / UNUSED_PARAM usages with COAP_UNUSED.
2021-03-05 11:49:34 +00:00
Jon Shallow e2c8df147b RFC7959: Handle both Block1 and Block2 for same request/response
Correctly track the tokens so that the token that application sees in the
response is the same token as used in the initial request.

Update coap-server so that response data can be sent back to echo the data
that was in the request.

Fixes
CID 1502431
CID 1502428
CID 1502422
2021-03-04 15:31:20 +00:00
obgm 4efb04d4d4 Merge pull request #609 from mrdeep1/vs_sizing
variables: Remove size changing warnings when using Visual Studio
2021-03-04 09:01:52 +01:00
Jon Shallow 640bb4e667 variables: Remove size changing warnings when using Visual Studio
Change some of the types of variables, and cast change sizes where known to
be safe.

There still are some C4116 warning and a couple of C4090 warning which are OK,
so disabled by a #pragma.
2021-03-03 12:23:25 +00:00
obgm 0044c61fab Merge pull request #601 from mrdeep1/verify_depth
cert_chain_verify_depth: Handle value of 0
2021-03-03 10:26:23 +01:00