Commit Graph
34 Commits
Author SHA1 Message Date
Jon Shallow 084c866c69 coap_startup: Make coap_startup() first function call in examples
This then makes sure that all things libcoap are properly initialized
before use, and coders realize they need to do this.

Note: coap_new_context() continues to make sure that coap_startup()
is invoked if not done previously, but this may be too late.
2023-07-25 13:50:18 +01:00
Jon Shallow a71b7930b9 pre-commit: Include re-styled examples files to checks 2023-07-13 09:01:41 +01:00
Jon Shallow 21bd1df95b examples: Remove references to sockaddr* structures
This means that apps need to have no knowledge of what IP support is available.

Updates coap_uri_into_options() and coap_resolve_address_info()
which have only been recently added to develop branch and are not in any
previous release.
2023-06-09 12:04:09 +01:00
Jon Shallow 4ca66d5b3b Examples: Format function headers and else statements.
Update function headers and "} else {" in libcoap coding style.
2022-10-18 10:27:02 +01:00
Jon Shallow a1d78d505d tiny.c: Fix message id generation 2021-08-02 10:09:21 +01: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
Olaf Bergmann 63f1369269 tiny.c: Update request method to COAP_REQUEST_CODE_POST 2021-04-21 13:45:56 +02:00
Jon Shallow e4e067e5fb coap_pdu_t: Obfuscate coap_pdu_t for applications
Move coap_pdu_t to coap_pdu_internal.h.

Move internal PDU based function definitions to coap_pdu_internal.h.

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

Create new enum coap_pdu_type_t, enum coap_pdu_code_t and coap_option_num_t,
using them where appropriate for clarity of documentation.

Provide new functions to allow applications to access/update parts of
coap_pdu_t as appropriate and document as appropriate.

Update examples to use these new access functions where appropriate.
2021-04-20 10:31:14 +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 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 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 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 dc6c5e6b00 workflow: Add in distribution and CMake checks
.github/workflows/main.yml:

Do a 'make check' for matrix builds.
Move documentation into separate job to reduce matrix build times
Add in CMake job.
Add in distribution job.
Add in tinydtls job.
Add in contiki/lwip job.

scripts/github_dist.sh:

Do the distribution checks using a script.

examples/etsi_iot_01.c:
examples/tiny.c:

Fix include coap.h directory in old examples.

README.md:

Update status badges to get only the branch actions and remove CMake
status badge.
2021-02-24 18:15:25 +00:00
Jon Shallow 003b64ab3f Fix SIGPIPE causing unexpected exit of example applications
examples/client.c:
examples/coap-rd.c:
examples/coap-server.c:
examples/etsi_iot_01.c:
examples/tiny.c:

Make the applications ignore SIGPIPE.

examples/coap-rd.c:

Support clean exit for SIGTERM / SIGQUIT for valgrind testing.
2019-08-29 12:58:15 +01:00
Jon Shallow 157985cb95 Update examples/tiny.c to use the new API
Update all the coap_ calls to use the new API, and the updated structures.
Introduce using session instead of context.
Correct all the compiler warnings.
2018-12-07 20:22:45 +00: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
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 8353417afb Added session management with simpler DTLS lib API.
Added DTLS support with OpenSSL.
2017-06-18 20:09:47 +02:00
Olaf Bergmann 28a6d45cde fixed bug #3524612 (Double free error when coap_send returns COAP_INVALID_TID)
From jsucaet's error description (Credits to Marc Haesen for revealing this bug):
The intent of the current code of coap_send is to release the allocated
memory upon success and not to release when an error has occured. However
this is broken (returning from coap_send with an error and a deallocated
pdu ptr is possible).
In the patch, I propose to let the calling function (of coap_send) be
responsible for free'ing the allocated pointer.
2012-05-29 19:41:22 +02:00
Olaf Bergmann 3358f2901d Fixed license info.
Options iterator.
Address abstraction to allow IPv4 addresses.
more changes for draft-ietf-core-coap-06.
2011-06-02 02:43:59 +02:00
Olaf Bergmann 38429f7541 API change: Pass local interface address to coap_new_context.
Changed library numbering to better reflect API changes.
2011-01-10 16:59:45 +01:00
Olaf Bergmann 758b7f775e Applied patches from Markus Becker (thanks!)
* 0001-Trailing-whitespace-cleanup.patch
* 0001-Went-back-to-2.65-of-autoconf.patch
* 0002-Fix-compiler-warning-for-str.patch
* added several files to Makefile target .gitignore
2010-11-22 13:01:00 +01:00
Olaf Bergmann 94cc2c4f42 added license information and general project information 2010-10-18 14:53:04 +02:00
Olaf Bergmann 9ff8221ffd fixed broken bit mask 2010-10-15 10:44:32 +02:00
Olaf Bergmann 58d37f4575 client 2010-07-11 19:59:58 +02:00
Olaf Bergmann 6b25bd6c1c set server port 2010-07-08 22:53:08 +02:00
Olaf Bergmann 4b8fe05413 explicitly set transaction id 2010-07-08 21:25:05 +02:00
Olaf Bergmann d82a7dca77 bugfix: wrong protocol level for hop count change 2010-07-06 13:58:27 +02:00
Olaf Bergmann feabb53c6c added string representation of encoded value to payload of sent pdu 2010-07-06 13:43:02 +02:00
Olaf Bergmann f98eeb45cb multicast example: main process joins group ff02:2001::1 2010-07-06 04:42:51 +02:00
Olaf Bergmann 0b755142fe added examples subdir with tiny fake sensor 2010-07-06 03:18:43 +02:00