Commit Graph
17 Commits
Author SHA1 Message Date
Jon Shallow 3552b53be4 Copyright: Update copyright date to end 2023 as appropriate 2023-01-02 11:45:10 +00:00
Jon Shallow 3897d2334c Logging: Make logging consistent across (D)TLS libraries
Set up coap_log_t as an enum, using syslog variable names prefixed by
COAP_.

Add function coap_dtls_log() for logging information from (D)TLS libraries.

Update the log output to have use Lower-case variants for the logging levels to
indicate that output is from the (D)TLS library instead of the CoAP library.

(D)TLS libraries updated to be consistent in the usage of
coap_dtls_set_log_level()/coap_dtls_get_log_level().

Add in coap_log_emerg(), coap_log_alert() etc. as wrappers to reduce the line
length required for log entries.  Updating all the coap_log() functions to
no longer use syslog variants will be a part of a separate PR.

Added in the "-V" option to the examples, with an initial default of
COAP_LOG_ERR, separating out the CoAP and (D)TLS logging levels.

Note: TinyDTLS log output will be consistent when built against a TinyDTLS
version that contains support for an external logging handler.
2022-11-03 16:02:36 +00:00
Jon Shallow 5a10ce4890 Congestion Control: add in RFC7252 configuration flexibility
Create where appropriate default values for the Congestion control base
values and update the derived CC values accordingly.

Move derived value #define to coap_session_internal.h.

Update coap_session_t to hold the new CC values.

Update documentation for the new CC functions that update / get the
appropriate values.

NOTE: PROBING_WAIT is not currently checked in the code.
2022-06-17 12:15:19 +02: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
Olaf Bergmann 3f7ba0afc8 Bump API version to 3, release candidate 2 2021-04-21 14:38:54 +02:00
Jon Shallow 3809d0d3b1 man: Extra checks on function definitions
Correct man pages as appropriate to line up with the header files.
If there were no EXAMPLES, previously this was not caught.
2021-04-16 14:40:44 +01:00
Jon Shallow f8d9af4b93 coap_context_t: Obfuscate coap_context_t for applications
Move coap_context_t and coap_queue_t to coap_net_internal.h.

Move internal context and queue based function definitions to
coap_net_internal.h.

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

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

Update examples to use these new access functions where appropriate.

For the man documentation, move the server session setup functions to (new)
coap_endpoint_server(3) and update coap_context(3) with all the context access
functions as these are common to both the client and server.
2021-04-15 17:27:02 +01: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
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
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
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 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 c8ab318e48 Ubuntu 20.4: Fix builds as Ubuntu 20.4 will be used by github workflows
.github/workflows/main.yml:

Build all the cmake TLS variants.

CMakeLists.txt:

Add in missing file.

examples/tiny.c:
include/coap2/encode.h:

Move COAP_PSEUDOFP_ENCODE_8_4 functions from encode.h to tiny.c.
Fix COAP_PSEUDOFP_ENCODE_8_4_DOWN 'ls' ordering complaint.

man/examples-code-check.c:

Fix compile warning, allow 'Unused but set variables' in examples and set
-Werror when compling the examples.

examples/lwip/Makefile:

Remove  compilation option -fpack-struct
2021-03-01 15:47:55 +00:00
Jon Shallow b2233810c2 examples-code-check.c: Add in function checking as well
Build dummy functions based on the SYNOPSIS definitions for further checking.
Note: COAP_STATIC_INLINE functions have to be excepted.
2021-02-26 08:59:42 +00:00
Jon Shallow cb8c7bffc9 Cygwin: Add in compiler support
See https://sourceforge.net/p/libcoap/mailman/message/37039434/

Works for

Computer: Windows 10 64 bit & CYGWIN_NT-10.0 x86_64
Cygwin: 3.1.5-1
OpenSSL: 1.1.1g
gcc:9.3.0

and gcc-10.2.0 + openssl1.1.1f

configure.ac:

Support cygwin build environment.  If so, set -D_CYGWIN_ENV in CFLAGS.

libtool: warning: undefined symbols not allowed in x86_64-pc-cygwin shared libraries; building static only
still to be fixed.

.gitignore:

Ignore *.exe filenames

src/coap_io.c:

define ipi_spec_dst as ipi_addr if _CYGWIN_ENV

examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:
examples/etsi_iot_01.c
man/examples-code-check.c:
src/coap_io.c:
src/coap_tcp.c:

Fix compiler warnings.

sizeof(socklen_t) != sizeof(size_t) [-Wsign-compare]
isdigit() etc. complain about byte size array subscripts [-Wchar-subscripts]
snprintf size checks [-Wformat-truncation=]

Update
2020-11-13 16:12:24 +00:00
Olaf Bergmann da38169b42 examples-code-check.c: add NULL pointer check before closing file
This fixes CID 1495717.
2020-06-19 16:07:37 +02:00
Jon Shallow 7812efb1eb Man examples: Add in support to check that the man example's code compiles
There needs to be an easy way to validate that the examples provided in the
man pages compile without errors.

This PR provides a new executable examples-code-check that can be run against
the .txt.in files that are in the man directory.  It abstracts the code for
each example and then runs the compiler against that stub code reporting errors
and warnings as appropriate for subsequent fixing in the man page.

.gitignore:

Ignore the new executable and the files it generates.

Makefile.am:
configure.ac:

Remove MAN_DIR and hard code in the man directory so that examples-code-check
is always built.

autogen.sh:

Make sure that all the temporary stub code files are cleaned up.

man/Makefile.am:

Support building and clean-up of the new examples-code-check.

man/examples-code-check.c: (new)

The code that parses the man pages, looking for examples and the gets
the examples compiled, testing for errors.
The function definitions in the SYNOPSIS section are also included in the
compilation of the examples.

scripts/build.sh:

If WITH_TESTS is set, check that the man page examples compile.

man/coap_encryption.txt.in:
man/coap_io.txt.in:
man/coap_observe.txt.in:
man/coap_pdu_setup.txt.in:
man/coap_resource.txt.in:
man/coap_session.txt.in:

Correct the SYNOPSIS function definitions.
2020-05-04 14:47:36 +01:00