mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-11 19:30:40 +03:00
Add in new ./configure options --enable-client-mode or --enable-server-mode which by default are enabled. If --disable-client-mode is set, then disable all the client specific code. [ COAP_CLIENT_SUPPORT is not defined ] If --disable-server-mode is set, then disable all the server specific code. [ COAP_SERVER_SUPPORT is not defined ] Functions and variables are only #ifdef'd out in the include/coap3/*_internal.h files. They cannot be #ifdef'd out in the other include files as COAP_CLIENT_SUPPORT and COAP_SERVER_SUPPORT are not available for application compilations. The result of this is if, say, client only API functons are used in a server application and COAP_CLIENT_SUPPORT is not defined, there will be linking issues (missing functions). Providing stub functions unecessarily increases the code size. For coap-server, if it is able to provide proxy support, requires both COAP_SERVER_SUPPORT and COAP_CLIENT_SUPPORT to set up the ongoing sessions. So, the build environment deliberatly sets SERVER_CAN_PROXY=0 if COAP_CLIENT_SUPPORT is not available to allow linking. Some of the tests have to be disabled if COAP_SERVER_SUPPORT or COAP_CLIENT_SUPPORT is not set. Code size change indications text data bss sum filename 155912 1728 12080 169720 libcoap-3-notls.a 138300 1728 12080 152108 libcoap-3-notls.a --disable-client-mode 106734 1632 10304 118670 libcoap-3-notls.a --disable-server-mode 180485 1733 12080 194298 libcoap-3-openssl.a 160306 1733 12080 174119 libcoap-3-openssl.a --disable-client-mode 125543 1637 10304 137484 libcoap-3-openssl.a --disable-server-mode 181755 1728 12080 195563 libcoap-3-gnutls.a 160972 1728 12080 174780 libcoap-3-gnutls.a --disable-client-mode 127178 1632 10304 139114 libcoap-3-gnutls.a --disable-server-mode 165879 1855 12128 179862 libcoap-3-tinydtls.a 147022 1855 12128 161005 libcoap-3-tinydtls.a --disable-client-mode 115618 1759 10352 127729 libcoap-3-tinydtls.a --disable-server-mode 171690 1728 13744 187162 libcoap-3-mbedtls.a 152099 1728 13712 167539 libcoap-3-mbedtls.a --disable-client-mode 118786 1632 11984 132402 libcoap-3-mbedtls.a --disable-server-mode
116 lines
2.5 KiB
C
116 lines
2.5 KiB
C
/*
|
|
* coap_cache_internal.h -- Cache functions for libcoap
|
|
*
|
|
* Copyright (C) 2019--2020 Olaf Bergmann <bergmann@tzi.org> and others
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* This file is part of the CoAP library libcoap. Please see README for terms
|
|
* of use.
|
|
*/
|
|
|
|
/**
|
|
* @file coap_cache_internal.h
|
|
* @brief COAP cache internal information
|
|
*/
|
|
|
|
#ifndef COAP_CACHE_INTERNAL_H_
|
|
#define COAP_CACHE_INTERNAL_H_
|
|
|
|
#include "coap_internal.h"
|
|
#include "coap_io.h"
|
|
|
|
#if COAP_SERVER_SUPPORT
|
|
/**
|
|
* @defgroup cache_internal Cache Support (Internal)
|
|
* CoAP Cache Structures, Enums and Functions that are not exposed to
|
|
* applications
|
|
* @{
|
|
*/
|
|
|
|
/* Holds a digest in binary typically sha256 except for notls */
|
|
typedef struct coap_digest_t {
|
|
uint8_t key[32];
|
|
} coap_digest_t;
|
|
|
|
struct coap_cache_key_t {
|
|
uint8_t key[32];
|
|
};
|
|
|
|
struct coap_cache_entry_t {
|
|
UT_hash_handle hh;
|
|
coap_cache_key_t *cache_key;
|
|
coap_session_t *session;
|
|
coap_pdu_t *pdu;
|
|
void* app_data;
|
|
coap_tick_t expire_ticks;
|
|
unsigned int idle_timeout;
|
|
coap_cache_app_data_free_callback_t callback;
|
|
};
|
|
|
|
/**
|
|
* Expire coap_cache_entry_t entries
|
|
*
|
|
* Internal function.
|
|
*
|
|
* @param context The context holding the coap-entries to exire
|
|
*/
|
|
void coap_expire_cache_entries(coap_context_t *context);
|
|
|
|
typedef void coap_digest_ctx_t;
|
|
|
|
/**
|
|
* Initialize a coap_digest
|
|
*
|
|
* Internal function.
|
|
*
|
|
* @return The digest context or @c NULL if failure.
|
|
*/
|
|
coap_digest_ctx_t *coap_digest_setup(void);
|
|
|
|
/**
|
|
* Free off coap_digest_ctx_t. Always done by
|
|
* coap_digest_final()
|
|
*
|
|
* Internal function.
|
|
*
|
|
* @param digest_ctx The coap_digest context.
|
|
*/
|
|
void coap_digest_free(coap_digest_ctx_t *digest_ctx);
|
|
|
|
/**
|
|
* Update the coap_digest information with the next chunk of data
|
|
*
|
|
* Internal function.
|
|
*
|
|
* @param digest_ctx The coap_digest context.
|
|
* @param data Pointer to data.
|
|
* @param data_len Number of bytes.
|
|
*
|
|
* @return @c 1 success, @c 0 failure.
|
|
*/
|
|
int coap_digest_update(coap_digest_ctx_t *digest_ctx,
|
|
const uint8_t *data,
|
|
size_t data_len
|
|
);
|
|
|
|
/**
|
|
* Finalize the coap_digest information into the provided
|
|
* @p digest_buffer.
|
|
*
|
|
* Internal function.
|
|
*
|
|
* @param digest_ctx The coap_digest context.
|
|
* @param digest_buffer Pointer to digest buffer to update
|
|
*
|
|
* @return @c 1 success, @c 0 failure.
|
|
*/
|
|
int coap_digest_final(coap_digest_ctx_t *digest_ctx,
|
|
coap_digest_t *digest_buffer);
|
|
|
|
/** @} */
|
|
|
|
#endif /* COAP_SERVER_SUPPORT */
|
|
|
|
#endif /* COAP_CACHE_INTERNAL_H_ */
|