coap_session.[hc]: Added function to retrieve PSK identity from session

The new function coap_session_get_psk_identity() returns the given
session's psk_identity as provided during the handhake (for CoAP server)
or a session setup (for CoAP client).
This commit is contained in:
Olaf Bergmann committed 2021-10-21 09:59:56 +02:00
1 parent c821148b98
commit df9071c93e
4 files changed
+23

No files matched your search

+9
View File
@@ -287,6 +287,15 @@ coap_session_t *coap_new_client_session_psk2(
const coap_bin_const_t * coap_session_get_psk_hint(
const coap_session_t *session);
/**
* Get the server session's current PSK identity (PSK).
*
* @param session The current coap_session_t object.
*
* @return PSK identity if successful, else @c NULL.
*/
const coap_bin_const_t *coap_session_get_psk_identity(
const coap_session_t *session);
/**
* Get the session's current pre-shared key (PSK).
*
+1
View File
@@ -188,6 +188,7 @@ global:
coap_session_get_max_retransmit;
coap_session_get_proto;
coap_session_get_psk_hint;
coap_session_get_psk_identity;
coap_session_get_psk_key;
coap_session_get_state;
coap_session_get_tls;
+1
View File
@@ -186,6 +186,7 @@ coap_session_get_ifindex
coap_session_get_max_retransmit
coap_session_get_proto
coap_session_get_psk_hint
coap_session_get_psk_identity
coap_session_get_psk_key
coap_session_get_state
coap_session_get_tls
+12
View File
@@ -1131,6 +1131,18 @@ coap_session_get_psk_hint(const coap_session_t *session) {
}
#endif /* COAP_SERVER_SUPPORT */
const coap_bin_const_t *
coap_session_get_psk_identity(const coap_session_t *session) {
const coap_bin_const_t *psk_identity = NULL;
if (session) {
psk_identity = session->psk_identity;
if (psk_identity == NULL) {
psk_identity = &session->cpsk_setup_data.psk_info.identity;
}
}
return psk_identity;
}
const coap_bin_const_t *
coap_session_get_psk_key(const coap_session_t *session) {
if (session)