Commit Graph
7 Commits
Author SHA1 Message Date
Jon Shallow 23b3e6e17e Add in coap_new_client_session_psk2 and coap_context_set_psk2 functions
This fix is in preparation for the full coap_new_client_session_psk2()
and coap_context_set_psk2() functions.  Structures are updated with the
necessary information, as well as provide the high level support.

As new sessions are now created for every genuine incoming session (#333),
coap_context_t will only hold the initial information provided by
coap_context_set_psk2() (server mode), but if there is any updated
(triggered by SNI or Indentity), this will be kept in coap_session_t.

Likewise, the client initial information will be kept in the
coap_session_t, and if modified (triggered by Hint) will be kept separately
in coap_session_t.

This change does not include the support required in the DTLS interface modules
other than changes required to make the code compilable and still run the
existing examples - so it is a standalone change.

Makefile.am:

Make coap_dtls_context_set_cpsk, coap_dtls_context_set_spsk,
coap_session_refresh_psk_key and coap_session_refresh_psk_hint hidden
Remove coap_dtls_context_set_psk

include/coap2/*.h:

Replace call-back with callback for consistency

include/coap2/coap_dtls.h:

Include coap_dtls_cpsk_key_t and coap_dtls_spsk_key_t definitions
Define coap_dtls_spsk_key_t for the new coap_*_psk2 functions.
Include all the new call back function definitions

include/coap2/coap_session.h:

Update coap_session_t with the new PSK information
Define coap_new_client_session_psk2(), coap_session_refresh_psk_key() and
coap_session_refresh_psk_hint() functions

include/coap2/net.h:

Update coap_context_t with the new PSK information
Define the coap_context_set_psk2() function

include/coap2/str.h:

Add in a new struct coap_bin_const_t
Define new functions coap_new_bin_const(), coap_delete_bin_const()
and coap_binary_equal().

libcoap-2.{map|sym}

Expose the new coap_context_set_psk2, coap_new_client_session_psk2,
coap_new_bin_const and coap_delete_bin_const functions

src/coap_gnutls.c:
src/coap_notls.c:
src/coap_tinydtls.c:

Replace coap_dtls_context_set_psk() with coap_dtls_context_set_spsk()
and coap_dtls_context_set_cpsk()

src/coap_openssl.c:

Replace coap_dtls_context_set_psk() with coap_dtls_context_set_spsk()
and coap_dtls_context_set_cpsk()
Update the SSL_CTX_use* and SSL_set_* functions with the new variable
locations

src/coap_session.c:

Free off new information on coap_session_t in coap_session_mfree()

Build parameters for coap_new_client_session_psk2() in
coap_new_client_session_psk() and call coap_new_client_session_psk2() instead
of coap_session_create_client().
Create new coap_new_client_session_psk2().
Create new coap_session_refresh_psk_key() (will be used when DTLS interface
code is updated

src/net.c:

Update coap_get_session_client_psk() to use the new PSK locations.
Update coap_get_session_server_psk() to use the new PSK locations.
Update coap_get_session_server_hint() to use the new PSK locations.
Build parameters for coap_context_set_psk2() in
coap_context_set_psk() and call coap_context_set_psk2().
Create new coap_context_set_psk2().
Cleanup usage of old PSK information in coap_free_context()

src/str.c:

Code for coap_new_bin_const() and coap_delete_bin_const() functions
2019-12-03 14:46:26 +00:00
Jon Shallow 5d32ffe920 str.h: Fix coap_make_str_const() for C++
As pointed out in issue #368 [1], C++ officially forbids aggregate
initialization for non-aggegrates. This change therefore introduces
an alternative version (which works for both C and C++) to provide
the required functionality.

str.c:
str.h:

Make coap_make_str_const() a function.

examples/coap-server.c:

Fix parameter type in coap_add_attr() call.

src/resource.c:

Static variables can no longer make use of coap_make_str_const().

libcoap-2.map:
libcoap-2.sym:

Make coap_make_str_const() appication visible.

Fixes #368.

[1] https://github.com/obgm/libcoap/issues/368

Update
2019-08-30 10:29:17 +01:00
Olaf Bergmann 3531087bb3 Revert "str.h: Fix coap_make_str_const() for C++"
This reverts commit 2309691770.

As the temporary object is cleaned up, the contents pointed to
by the coap_str_const_t object are destroyed.
2019-08-02 15:47:56 +02:00
Olaf Bergmann 2309691770 str.h: Fix coap_make_str_const() for C++
As pointed out in issue #368 [1], C++ officially forbids aggregate
initialization for non-aggegrates. This change therefore introduces
a template function coap_make_str_const() that creates and initializes
an automatic variable that is moved to the caller on exit.

Note that at least -std=c++14 is required.

Fixes #368.

[1] https://github.com/obgm/libcoap/issues/368
2019-08-02 13:29:42 +02:00
Jon Shallow 55d579449c Reserved Identifier fixes
include/coap2/libcoap.h
_LIBCOAP_H_ to COAP_LIBCOAP_H_
src/coap_session.c
_COAP_SESSION_H_ to COAP_SESSION_C_
include/coap2/coap_session.h
_SESSION_H_ to COAP_SESSION_H_

otherwise, all #define _COAP_xxxxx wrappers are now COAP_xxxxx

Fixes #291
2019-01-29 15:30:42 +00:00
Jon Shallow 371c295fce Remove deprecated str typedef to remove namespace pollution
As str structure has been replaced by coap_string_t, remove it from the code
as it is no longer required, has been deprecated for some time and can cause
clashes with other str definitions.

Tidy up comment referring to str.
2018-12-27 11:51:42 +00:00
Carsten Schoenert f584abc19e include: move header files to include/coap2
Automake is using the variable 'libcoap_include_HEADERS' as the list to
install the header files and is this list installing to $(prefix)
basically.
This commit is changing the primary installation folder for the header
files in addition to the previous commit.
2018-10-04 12:21:12 +02:00