Commit Graph
29 Commits
Author SHA1 Message Date
Jon Shallow 13139e7be9 Options: Check Uri-Path and Location-Path options for . or ..
Check incoming Uri-Path and Location-Path options for just . or .. (or %2e
hex encoded variants) and treat as being invalid.

Stop insertion of Uri-Path and Location-Path options that contain just
. or .. (or %2e hex encoded variants).
2026-05-11 19:41:17 +01:00
Jon Shallow c9135b6b26 Copyright: Update to 2026 2026-01-05 10:37:26 +00:00
Jon Shallow 9d228feff0 testdriver.c: unit tests failures do not error on exit
Unfortunately tests/testdriver always exited with 0, even if there was a test
suite error.  This meant that CI tests were not picking up any issues.

tests/testdriver now exits with a value of 1 if there is a test suite issue.

Errors corrected in/for the test suite.
2025-05-15 19:22:01 +01:00
Jon Shallow 4289cb072d Copyright: Update to 2025 where appropriate 2025-02-17 09:37:55 +00:00
Jon Shallow 4a94cc7c80 scan-build: Fix warnings 2024-05-09 10:57:16 +01:00
Jon Shallow 8237c1d801 Copyright: Update to 2024 2024-01-02 08:45:59 +00:00
Jon Shallow e8005c5c27 pre-commit: Include re-styled tests files to checks 2023-07-08 16:37:59 +01:00
Jon Shallow a9b179ab32 Coding: Remove blank lines at ends of files 2023-06-29 09:34:52 +01:00
Jon Shallow 47a83549a8 RFC8974: Add in support for Extended Tokens
Add in new function coap_context_set_max_token_size() to define
the maximum supported token size.

Track changes to PDU to support extended tokens.

Update documentation.
2023-02-04 11:08:32 +00:00
Jon Shallow 3552b53be4 Copyright: Update copyright date to end 2023 as appropriate 2023-01-02 11:45:10 +00:00
Jon Shallow dfc678c33b Proxy: Support unknown Critical but Safe-To-Forward options
The CoAP Proxy may not know how to handle a Critical option, but if it
is safe to forward it should be able to handle this.

RFRC7252 5.4.1
   Critical/elective rules apply to non-proxying endpoints.  A proxy
   processes options based on Unsafe/Safe-to-Forward classes as defined
   in Section 5.7.

If this is an incoming proxy type request special case any
critical options that are safe to forward.

Track ongoing sessions from an enabled proxy server so unknown critical
response options can be passed back to the originating requestor.

Update coap-server to handle Proxy-Scheme for proxying.

Update tests to use critical option 25 instead of 9.
2022-02-18 12:51:35 +00:00
Olaf Bergmann 60421db0a5 Add SPDX-License-Identifier to source files
This change adds 'SPDX-License-Identifier: BSD-2-Clause' [1] to
the source code files that originate in the libcoap project.

Note that not all files are tagged because they are pulled in
from other sources and thus may fall under a different license.
More information about these is contained in the LICENSE file.

[1] https://spdx.org/licenses/BSD-2-Clause.html
2021-06-08 18:14:03 +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
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
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 e2e783033c coap_opt_filter_t: Make it a proper structure
Update coap_opt_filter_t to be a structure rather than a 16bit array that is
aliased with the real structure format.

Update code to use pointers where appropriate.
2021-02-26 09:24:34 +00:00
Jon Shallow 26cd2446a8 Deprecated: Replace deprecated functions in library
examples/contiki/coap-observer.c:
examples/etsi_iot_01.c:
include/coap2/coap_prng.h:
include/coap2/net.h:
src/coap_debug.c:
src/coap_openssl.c:
src/coap_session.c:
src/net.c:
src/option.c:
tests/test_error_response.c:
tests/test_options.c:

prng -> coap_prng
prng_init -> coap_prng_init
coap_option_setb -> coap_option_filter_set
coap_option_clrb -> coap_option_filter_unset
coap_option_getb -> coap_option_filter_get

include/coap2/coap.h.windows:
win32/libcoap.vcxproj:
win32/libcoap.vcxproj.filters:

prng.h -> coap_prng.h

include/coap2/option.h:

Add in COAP_DEPRECATED in deprecated functions.
2020-09-08 17:21:34 +01:00
Olaf Bergmann bbc6b24abd unit tests: Make global variables static
As of gcc 10, -fno-common is default to check for multiple
definitions of global variables at link time. This change makes
the global variables in the unit test files static to avoid
error messages caused by this.

Fixes #464
2020-02-26 12:49:38 +01:00
Jon Shallow f5367ef3de Delete trailing spaces from files, replace TAB with 8*SPACE
"git diff -w" shows no differences

TAB left alone in files that are not C based files or documentation
2018-09-28 17:34:07 +01:00
Jon Shallow 7dc16ed184 tests/*.c, examples/*.c: Remove cast-qual compiler warnings
Created new 'CU_ASSERT_PTR_EQUAL_C(actual, expected)' to handle const variable matching

Where appropriate

Replace 'unsigned char' with 'const uint8_t'
Replace 'str' with 'coap_str_c_t'
Replace 'str' with 'coap_string_t'
Prefix with 'const' some type casts
Update coap_add_attr() calls inline with updated API
Update coap_resource_init() calls inline with updated API
Make use of coap_make_str_const() for defining parameters

tests*/.c
Update code to stop memory leaks (as found by valgrind)

examples/coap-rd.c
Track the fact that uri_path in coap_resource_t is now a pointer
2018-05-25 14:11:04 +01:00
jcmichelou f81cb43fd3 session, pdu: Enforce maximum message size. 2017-10-21 16:11:12 +02:00
jcmichelou dfff930805 io, net: Add TCP accept/connect/read/write 2017-10-21 16:11:12 +02:00
jcmichelou bcfd7a0753 pdu: add support for TCP-style headers
Make coap_pdu-t independent of the header style.
Use C99 sized types when applicable.
Use transaction ids in host byte order in the library.
Make coap_pdu_t payload storage grow on demand.
Add parsing and encoding of PDUs with UDP or TCP style headers.
Adapt examples and unit tests to the new PDU format.
2017-10-21 16:11:11 +02:00
jcmichelou b2fe4a64de Make MTU configurable.
Use static or stack storage for coap_packet_t.
2017-06-26 17:34:01 +02:00
Olaf Bergmann df2a6d1f10 test_error_response.c: free storage from responses
Free the storage allocated by coap_new_error_response() in unit tests.
This change simplifies automated leak checks as it avoids cluttering
the output with almost false positives.
2016-12-02 13:18:38 +01:00
Carsten Schoenert 63924379e3 testdriver: switch linking to the shared library
The testdriver was linked against the statically generated library of
libcoap. By this the testdriver will *always* find any symbols, no
matter if it is a private or public symbol.
Due this the testing behavior isn't the same as a user would use the
shared library and can get a potentially pitfall even if the testdriver
was successful.

Due previous changes to the public header the testdriver source needs
now the local header coap_config.h to find all needed functions so there
are small changes needed to the source files.
2015-07-04 19:35:10 +02:00
Olaf Bergmann 04e1d8e7de Make test data unsigned to shut up compiler warnings. 2015-03-09 14:59:22 +01:00
Olaf Bergmann fa3f09cdb7 Fix warnings in unit tests 2015-03-04 15:10:09 +01:00
Olaf Bergmann ada296efaf added new test cases for error response generation
test t_error_response8 will fail when COAP_MAX_OPT < 2000
2013-09-03 14:07:16 +02:00