26RCSID(
"$Id: 565532041f121500b51df88fa3a3393fb1da5b34 $")
30#define LOG_PREFIX "tls"
32#include <freeradius-devel/internal/internal.h>
33#include <freeradius-devel/server/pair.h>
34#include <freeradius-devel/server/module_rlm.h>
35#include <freeradius-devel/unlang/function.h>
36#include <freeradius-devel/unlang/subrequest.h>
37#include <freeradius-devel/unlang/interpret.h>
38#include <freeradius-devel/util/debug.h>
47#include <openssl/ssl.h>
48#include <openssl/kdf.h>
56uint8_t *fr_tls_cache_id(TALLOC_CTX *ctx, SSL_SESSION *sess)
61 id = SSL_SESSION_get_id(sess, &len);
74static inline CC_HINT(always_inline,
nonnull)
80 id = SSL_SESSION_get_id(sess, &len);
93#define SESSION_ID(_box, _sess) \
95if (unlikely(fr_tls_cache_id_to_box_shallow(&_box, _sess) < 0)) fr_value_box_init_null(&_box)
110static inline CC_HINT(always_inline,
nonnull(2))
111void tls_cache_session_id_to_vp(
request_t *request,
uint8_t const *session_id)
118static inline CC_HINT(always_inline,
nonnull(2))
119void _tls_cache_load_state_reset(
request_t *request, fr_tls_cache_t *cache,
char const *func)
121 if (cache->load.sess) {
123 SESSION_ID(sess_id, cache->load.sess);
127 SSL_SESSION_free(cache->load.sess);
128 cache->load.sess = NULL;
130 cache->load.state = FR_TLS_CACHE_LOAD_INIT;
132#define tls_cache_load_state_reset(_request, _cache) _tls_cache_load_state_reset(_request, _cache, __FUNCTION__)
134static inline CC_HINT(always_inline,
nonnull(2))
135void _tls_cache_store_state_reset(
request_t *request, fr_tls_cache_t *cache,
char const *func)
137 if (cache->store.sess) {
139 SESSION_ID(sess_id, cache->store.sess);
142 SSL_SESSION_free(cache->store.sess);
143 cache->store.sess = NULL;
145 cache->store.state = FR_TLS_CACHE_STORE_INIT;
147#define tls_cache_store_state_reset(_request, _cache) _tls_cache_store_state_reset(_request, _cache, __FUNCTION__)
149static inline CC_HINT(always_inline)
150void _tls_cache_clear_state_reset(
request_t *request, fr_tls_cache_t *cache,
char const *func)
152 if (cache->clear.id) {
156 TALLOC_FREE(cache->clear.id);
159 cache->clear.state = FR_TLS_CACHE_CLEAR_INIT;
161#define tls_cache_clear_state_reset(_request, _cache) _tls_cache_clear_state_reset(_request, _cache, __FUNCTION__)
166static int tls_cache_app_data_set(
request_t *request, SSL_SESSION *sess,
uint32_t resumption_type)
169 fr_dbuff_uctx_talloc_t tctx;
179 type_vp->vp_uint32 = resumption_type;
182 SESSION_ID(sess_id, sess);
184 RDEBUG2(
"Session ID %pV - Adding session-state[*] to data", &sess_id);
206 SESSION_ID(sess_id, sess);
208 RPERROR(
"Session ID %pV - Failed serialising session-state list", &sess_id);
225 SESSION_ID(sess_id, sess);
227 fr_tls_log(request,
"Session ID %pV - Failed setting application data", &sess_id);
234static int tls_cache_app_data_get(
request_t *request, SSL_SESSION *sess)
244 if (SSL_SESSION_get0_ticket_appdata(sess, (
void **)&
data, &data_len) != 1) {
245 SESSION_ID(sess_id, sess);
247 fr_tls_log(request,
"Session ID %pV - Failed retrieving application data", &sess_id);
265 SESSION_ID(sess_id, sess);
268 RPEDEBUG(
"Session-ID %pV - Failed decoding session-state", &sess_id);
274 SESSION_ID(sess_id, sess);
276 RDEBUG2(
"Session-ID %pV - Restoring session-state[*]", &sess_id);
291static void tls_cache_delete_request(SSL_SESSION *sess)
293 fr_tls_session_t *tls_session;
294 fr_tls_cache_t *tls_cache;
297 tls_session = talloc_get_type_abort(SSL_SESSION_get_ex_data(sess, FR_TLS_EX_INDEX_TLS_SESSION), fr_tls_session_t);
299 if (!tls_session->cache)
return;
301 request = fr_tls_session_request(tls_session->ssl);
302 tls_cache = tls_session->cache;
309 fr_assert(tls_cache->clear.state == FR_TLS_CACHE_CLEAR_INIT);
314 tls_cache->clear.id = fr_tls_cache_id(tls_cache, sess);
315 if (!tls_cache->clear.id) {
316 RWDEBUG(
"Error retrieving Session ID");
322 tls_cache->clear.state = FR_TLS_CACHE_CLEAR_REQUESTED;
331 if (tls_session->session == sess) tls_session->session = NULL;
346 if (tls_session->can_pause) ASYNC_pause_job();
354 fr_tls_session_t *tls_session = talloc_get_type_abort(uctx, fr_tls_session_t);
355 fr_tls_cache_t *tls_cache = tls_session->cache;
362 RWDEBUG(
"Failed acquiring session data");
364 tls_cache->load.state = FR_TLS_CACHE_LOAD_FAILED;
370 RWDEBUG(
"No cached session found");
375 p = (
unsigned char const **)&q;
377 sess = d2i_SSL_SESSION(NULL, p,
vp->vp_length);
379 fr_tls_log(request,
"Failed loading persisted session");
384 SESSION_ID(sess_id, sess);
386 RDEBUG3(
"Session ID %pV - Read %zu bytes of data. "
387 "Session de-serialized successfully", &sess_id,
vp->vp_length);
388 SSL_SESSION_print(fr_tls_request_log_bio(request,
L_DBG,
L_DBG_LVL_3), sess);
400 SSL_SESSION_set_ex_data(sess, FR_TLS_EX_INDEX_TLS_SESSION, fr_tls_session(tls_session->ssl));
402 tls_cache->load.state = FR_TLS_CACHE_LOAD_RETRIEVED;
403 tls_cache->load.sess = sess;
419 fr_tls_cache_t *tls_cache = tls_session->cache;
420 fr_tls_conf_t *
conf = fr_tls_session_conf(tls_session->ssl);
443 tls_cache_session_id_to_vp(child, tls_cache->load.id);
449 ua = fr_tls_call_push(child, tls_cache_load_result,
conf, tls_session);
452 tls_cache_load_state_reset(request, tls_cache);
464 fr_tls_session_t *tls_session = talloc_get_type_abort(uctx, fr_tls_session_t);
465 fr_tls_cache_t *tls_cache = tls_session->cache;
468 tls_cache_store_state_reset(request, tls_cache);
472 tls_cache->store.state = FR_TLS_CACHE_STORE_PERSISTED;
474 RWDEBUG(
"Failed storing session data");
475 tls_cache->store.state = FR_TLS_CACHE_STORE_INIT;
491static inline CC_HINT(always_inline)
494 fr_tls_cache_t *tls_cache = tls_session->cache;
501 SSL_SESSION *sess = tls_session->cache->store.sess;
503#if OPENSSL_VERSION_NUMBER >= 0x30400000L
511 fr_assert(tls_cache->store.state == FR_TLS_CACHE_STORE_REQUESTED);
515 fr_tls_cache_id_to_box_shallow(&
id, sess);
517 RWDEBUG(
"Session ID %pV - Session has already expired, not storing", &
id);
553 len = i2d_SSL_SESSION(sess, NULL);
556 fr_tls_cache_id_to_box_shallow(&
id, sess);
559 fr_tls_strerror_printf(NULL);
560 RPWDEBUG(
"Session ID %pV - Serialisation failed, couldn't determine "
561 "required buffer length", &
id);
563 tls_cache_store_state_reset(request, tls_cache);
573 ret = i2d_SSL_SESSION(sess, &p);
576 fr_tls_cache_id_to_box_shallow(&
id, sess);
578 fr_tls_strerror_printf(NULL);
579 RPWDEBUG(
"Session ID %pV - Serialisation failed", &
id);
589 ua = fr_tls_call_push(child, tls_cache_store_result,
conf, tls_session);
590 if (ua < 0)
goto error;
600 fr_tls_session_t *tls_session = talloc_get_type_abort(uctx, fr_tls_session_t);
601 fr_tls_cache_t *tls_cache = tls_session->cache;
604 tls_cache_clear_state_reset(request, tls_cache);
613 RWDEBUG(
"Failed deleting session data - security may be compromised");
627static inline CC_HINT(always_inline)
632 fr_tls_cache_t *tls_cache = tls_session->cache;
635 fr_assert(tls_cache->clear.state == FR_TLS_CACHE_CLEAR_REQUESTED);
652 tls_cache_session_id_to_vp(child, tls_cache->clear.id);
658 ua = fr_tls_call_push(child, tls_cache_clear_result,
conf, tls_session);
661 tls_cache_clear_state_reset(request, tls_cache);
678 fr_tls_cache_t *tls_cache = tls_session->cache;
679 fr_tls_conf_t *
conf = fr_tls_session_conf(tls_session->ssl);
686 if (tls_cache->load.state == FR_TLS_CACHE_LOAD_REQUESTED) {
687 return tls_cache_load_push(request, tls_session);
694 if (tls_cache->clear.state == FR_TLS_CACHE_CLEAR_REQUESTED) {
700 if (tls_cache->store.state == FR_TLS_CACHE_STORE_REQUESTED) {
704 id = SSL_SESSION_get_id(tls_cache->store.sess, &len);
705 if ((len == talloc_array_length(tls_cache->clear.id)) &&
706 (memcmp(tls_cache->clear.id,
id, len) == 0)) {
707 tls_cache_store_state_reset(request, tls_cache);
711 return tls_cache_clear_push(request,
conf, tls_session);
714 if (tls_cache->store.state == FR_TLS_CACHE_STORE_REQUESTED) {
715 return tls_cache_store_push(request,
conf, tls_session);
734static int tls_cache_store_cb(SSL *ssl, SSL_SESSION *sess)
737 fr_tls_session_t *tls_session;
738 fr_tls_cache_t *tls_cache;
747 tls_session = fr_tls_session(ssl);
748 request = fr_tls_session_request(tls_session->ssl);
749 tls_cache = tls_session->cache;
757 id = SSL_SESSION_get_id(sess, &id_len);
763 tls_cache->store.sess = sess;
764 tls_cache->store.state = FR_TLS_CACHE_STORE_REQUESTED;
781static SSL_SESSION *tls_cache_load_cb(SSL *ssl,
782 unsigned char const *key,
783 int key_len,
int *copy)
785 fr_tls_session_t *tls_session;
786 fr_tls_cache_t *tls_cache;
789 tls_session = fr_tls_session(ssl);
790 request = fr_tls_session_request(tls_session->ssl);
791 tls_cache = tls_session->cache;
803 if (!tls_cache || !tls_session->allow_session_resumption)
return NULL;
818 switch (tls_cache->load.state) {
819 case FR_TLS_CACHE_LOAD_INIT:
822 tls_cache->load.state = FR_TLS_CACHE_LOAD_REQUESTED;
833 if (
unlikely(!tls_session->can_pause)) {
836 "tls_session_async_handshake_cont must be in call stack", __FUNCTION__);
855 tls_cache_load_state_reset(request, tls_cache);
861 case FR_TLS_CACHE_LOAD_REQUESTED:
863 tls_cache->load.state = FR_TLS_CACHE_LOAD_FAILED;
866 case FR_TLS_CACHE_LOAD_RETRIEVED:
870 TALLOC_FREE(tls_cache->load.id);
872 RDEBUG3(
"Setting session data");
884 if (tls_cache_app_data_get(request, tls_cache->load.sess) < 0) {
885 REDEBUG(
"Denying session resumption via session-id");
891 tls_cache_delete_request(tls_cache->load.sess);
892 tls_cache_load_state_reset(request, tls_session->cache);
904 fr_tls_verify_cert_request(tls_session,
true);
906 if (
unlikely(!tls_session->can_pause))
goto cant_pause;
923 tls_cache_load_state_reset(request, tls_cache);
924 fr_tls_verify_cert_reset(tls_session);
933 if (!fr_tls_verify_cert_result(tls_session)) {
934 RDEBUG2(
"Certificate re-validation failed, denying session resumption via session-id");
937 sess = tls_cache->load.sess;
946 SESSION_ID(sess_id, tls_cache->load.sess);
948 RDEBUG3(
"Session ID %pV - Session ownership transferred to libssl", &sess_id);
950 tls_cache->load.sess = NULL;
956 case FR_TLS_CACHE_LOAD_FAILED:
957 RDEBUG3(
"Session data load failed");
961 TALLOC_FREE(tls_cache->load.id);
972static void tls_cache_delete_cb(
UNUSED SSL_CTX *ctx, SSL_SESSION *sess)
980 if (!SSL_SESSION_get_ex_data(sess, FR_TLS_EX_INDEX_TLS_SESSION))
return;
981 tls_cache_delete_request(sess);
995int fr_tls_cache_disable_cb(SSL *ssl,
int is_forward_secure)
999 fr_tls_session_t *tls_session;
1002 tls_session = fr_tls_session(ssl);
1003 request = fr_tls_session_request(tls_session->ssl);
1012 fr_tls_conf_t *
conf;
1014 conf = talloc_get_type_abort(SSL_get_ex_data(ssl, FR_TLS_EX_INDEX_CONF), fr_tls_conf_t);
1015 if (
conf->cache.require_extms && (SSL_get_extms_support(tls_session->ssl) == 0)) {
1016 RDEBUG2(
"Client does not support the Extended Master Secret extension, "
1017 "denying session resumption");
1021 if (
conf->cache.require_pfs && !is_forward_secure) {
1022 RDEBUG2(
"Cipher suite is not forward secure, denying session resumption");
1036 if (!tls_session->allow_session_resumption) {
1037 RDEBUG2(
"Session resumption not enabled for this TLS session, denying session resumption");
1042 if (
vp && (
vp->vp_uint32 == 0)) {
1043 RDEBUG2(
"control.Allow-Session-Resumption == no, denying session resumption");
1045 SSL_CTX_remove_session(tls_session->ctx, tls_session->session);
1046 tls_session->allow_session_resumption =
false;
1050 RDEBUG2(
"Allowing future session-resumption");
1073void fr_tls_cache_deny(
request_t *request, fr_tls_session_t *tls_session)
1075 fr_tls_cache_t *tls_cache = tls_session->cache;
1076 bool tmp_bind = !fr_tls_session_request_bound(tls_session->ssl);
1084 fr_tls_session_request_bind(tls_session->ssl, request);
1090 fr_assert(fr_tls_session_request(tls_session->ssl) == request);
1110 if (tls_session->session) SSL_CTX_remove_session(tls_session->ctx, tls_session->session);
1111 tls_session->allow_session_resumption =
false;
1116 tls_cache_store_state_reset(fr_tls_session_request(tls_session->ssl), tls_cache);
1121 if (tmp_bind) fr_tls_session_request_unbind(tls_session->ssl);
1126static int _tls_cache_free(fr_tls_cache_t *tls_cache)
1128 tls_cache_load_state_reset(NULL, tls_cache);
1129 tls_cache_store_state_reset(NULL, tls_cache);
1140void fr_tls_cache_session_alloc(fr_tls_session_t *tls_session)
1144 MEM(tls_session->cache = talloc_zero(tls_session, fr_tls_cache_t));
1145 talloc_set_destructor(tls_session->cache, _tls_cache_free);
1152static inline CC_HINT(always_inline)
1153void tls_cache_disable_stateless_resumption(SSL_CTX *ctx)
1155 long ctx_options = SSL_CTX_get_options(ctx);
1160 ctx_options |= SSL_OP_NO_TICKET;
1161 SSL_CTX_set_options(ctx, ctx_options);
1169 SSL_CTX_set_num_tickets(ctx, 0);
1176static inline CC_HINT(always_inline)
1177void tls_cache_disable_statefull_resumption(SSL_CTX *ctx)
1190 SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_OFF);
1199static int tls_cache_session_ticket_app_data_set(SSL *ssl,
void *arg)
1201 fr_tls_session_t *tls_session = fr_tls_session(ssl);
1202 fr_tls_cache_conf_t *tls_cache_conf = arg;
1212 if (!fr_tls_session_request_bound(ssl))
return 1;
1220 request = fr_tls_session_request(ssl);
1232 if (!tls_session->allow_session_resumption ||
1233 (!(tls_cache_conf->mode & FR_TLS_CACHE_STATELESS))) {
1234 REDEBUG(
"Generating session-tickets is not allowed");
1238 sess = SSL_get_session(ssl);
1240 REDEBUG(
"Failed retrieving session in session generation callback");
1253static SSL_TICKET_RETURN tls_cache_session_ticket_app_data_get(SSL *ssl, SSL_SESSION *sess,
1254 UNUSED unsigned char const *keyname,
1255 UNUSED size_t keyname_len,
1256 SSL_TICKET_STATUS status,
1259 fr_tls_session_t *tls_session = fr_tls_session(ssl);
1260 fr_tls_conf_t *
conf = fr_tls_session_conf(tls_session->ssl);
1261 fr_tls_cache_conf_t *tls_cache_conf = arg;
1264 if (fr_tls_session_request_bound(ssl)) {
1265 request = fr_tls_session_request(ssl);
1269 if (!tls_session->allow_session_resumption ||
1270 (!(tls_cache_conf->mode & FR_TLS_CACHE_STATELESS))) {
1272 "denying session resumption via session-ticket");
1273 return SSL_TICKET_RETURN_IGNORE;
1277 case SSL_TICKET_EMPTY:
1278 case SSL_TICKET_NO_DECRYPT:
1279 case SSL_TICKET_FATAL_ERR_MALLOC:
1280 case SSL_TICKET_FATAL_ERR_OTHER:
1281 case SSL_TICKET_NONE:
1282#ifdef STATIC_ANALYZER
1285 return SSL_TICKET_RETURN_IGNORE_RENEW;
1287 case SSL_TICKET_SUCCESS:
1288 if (!request)
return SSL_TICKET_RETURN_USE;
1291 case SSL_TICKET_SUCCESS_RENEW:
1292 if (!request)
return SSL_TICKET_RETURN_USE_RENEW;
1306 if (tls_cache_app_data_get(request, sess) < 0) {
1307 REDEBUG(
"Denying session resumption via session-ticket");
1308 return SSL_TICKET_RETURN_IGNORE_RENEW;
1311 if (
conf->virtual_server && tls_session->verify_client_cert) {
1312 RDEBUG2(
"Requesting certificate re-validation for session-ticket");
1321 fr_tls_verify_cert_request(tls_session,
true);
1329 if (
unlikely(!tls_session->can_pause)) {
1331 "tls_session_async_handshake_cont must be in call stack", __FUNCTION__);
1332 return SSL_TICKET_RETURN_IGNORE_RENEW;
1349 fr_tls_verify_cert_reset(tls_session);
1350 return SSL_TICKET_RETURN_ABORT;
1358 if (!fr_tls_verify_cert_result(tls_session)) {
1359 RDEBUG2(
"Certificate re-validation failed, denying session resumption via session-ticket");
1360 return SSL_TICKET_RETURN_IGNORE_RENEW;
1364 return (status == SSL_TICKET_SUCCESS_RENEW) ? SSL_TICKET_RETURN_USE_RENEW : SSL_TICKET_RETURN_USE;
1375int fr_tls_cache_ctx_init(SSL_CTX *ctx, fr_tls_cache_conf_t
const *cache_conf)
1377 switch (cache_conf->mode) {
1378 case FR_TLS_CACHE_DISABLED:
1379 tls_cache_disable_stateless_resumption(ctx);
1380 tls_cache_disable_statefull_resumption(ctx);
1383 case FR_TLS_CACHE_AUTO:
1384 case FR_TLS_CACHE_STATEFUL:
1389 SSL_CTX_sess_set_new_cb(ctx, tls_cache_store_cb);
1390 SSL_CTX_sess_set_get_cb(ctx, tls_cache_load_cb);
1391 SSL_CTX_sess_set_remove_cb(ctx, tls_cache_delete_cb);
1399 SSL_CTX_set_session_cache_mode(ctx, SSL_SESS_CACHE_SERVER | SSL_SESS_CACHE_NO_INTERNAL);
1409 if (!(cache_conf->mode & FR_TLS_CACHE_STATELESS)) {
1410 tls_cache_disable_stateless_resumption(ctx);
1415 case FR_TLS_CACHE_STATELESS:
1419 EVP_PKEY_CTX *pkey_ctx = NULL;
1421 if (!(cache_conf->mode & FR_TLS_CACHE_STATEFUL)) tls_cache_disable_statefull_resumption(ctx);
1432 key_len = SSL_CTX_set_tlsext_ticket_keys(ctx, NULL, 0);
1434 if (
unlikely((pkey_ctx = EVP_PKEY_CTX_new_id(EVP_PKEY_HKDF, NULL)) == NULL)) {
1435 fr_tls_strerror_printf(NULL);
1436 PERROR(
"Failed initialising KDF");
1438 if (pkey_ctx) EVP_PKEY_CTX_free(pkey_ctx);
1441 if (
unlikely(EVP_PKEY_derive_init(pkey_ctx) != 1)) {
1442 fr_tls_strerror_printf(NULL);
1443 PERROR(
"Failed initialising KDF derivation ctx");
1446 if (
unlikely(EVP_PKEY_CTX_set_hkdf_md(pkey_ctx,
UNCONST(
struct evp_md_st *, EVP_sha256())) != 1)) {
1447 fr_tls_strerror_printf(NULL);
1448 PERROR(
"Failed setting KDF MD");
1451 if (
unlikely(EVP_PKEY_CTX_set1_hkdf_key(pkey_ctx,
1452 UNCONST(
unsigned char *, cache_conf->session_ticket_key),
1453 talloc_array_length(cache_conf->session_ticket_key)) != 1)) {
1454 fr_tls_strerror_printf(NULL);
1455 PERROR(
"Failed setting KDF key");
1458 if (
unlikely(EVP_PKEY_CTX_add1_hkdf_info(pkey_ctx,
1459 UNCONST(
unsigned char *,
"freeradius-session-ticket"),
1460 sizeof(
"freeradius-session-ticket") - 1) != 1)) {
1461 fr_tls_strerror_printf(NULL);
1462 PERROR(
"Failed setting KDF label");
1470 MEM(key_buff = talloc_array(NULL,
uint8_t, key_len));
1471 if (EVP_PKEY_derive(pkey_ctx, key_buff, &key_len) != 1) {
1472 fr_tls_strerror_printf(NULL);
1473 PERROR(
"Failed deriving session ticket key");
1478 EVP_PKEY_CTX_free(pkey_ctx);
1480 fr_assert(talloc_array_length(key_buff) == key_len);
1484 if (SSL_CTX_set_tlsext_ticket_keys(ctx,
1485 key_buff, key_len) != 1) {
1486 fr_tls_strerror_printf(NULL);
1487 PERROR(
"Failed setting session ticket keys");
1491 DEBUG3(
"Derived session-ticket-key:");
1499 if (
unlikely(SSL_CTX_set_session_ticket_cb(ctx,
1500 tls_cache_session_ticket_app_data_set,
1501 tls_cache_session_ticket_app_data_get,
1502 UNCONST(fr_tls_cache_conf_t *, cache_conf)) != 1)) {
1503 fr_tls_strerror_printf(NULL);
1504 PERROR(
"Failed setting session ticket callbacks");
1514 SSL_CTX_set_num_tickets(ctx, 1);
1519 SSL_CTX_set_not_resumable_session_callback(ctx, fr_tls_cache_disable_cb);
1520 SSL_CTX_set_quiet_shutdown(ctx, 1);
unlang_action_t
Returned by unlang_op_t calls, determine the next action of the interpreter.
@ UNLANG_ACTION_FAIL
Encountered an unexpected error.
@ UNLANG_ACTION_CALCULATE_RESULT
Calculate a new section rlm_rcode_t value.
#define UNCONST(_type, _ptr)
Remove const qualification from a pointer.
#define USES_APPLE_DEPRECATED_API
#define FALL_THROUGH
clang 10 doesn't recognised the FALL-THROUGH comment anymore
#define fr_dbuff_used(_dbuff_or_marker)
Return the number of bytes remaining between the start of the dbuff or marker and the current positio...
static void fr_dbuff_free_talloc(fr_dbuff_t *dbuff)
Free the talloc buffer associated with a dbuff.
#define fr_dbuff_len(_dbuff_or_marker)
The length of the underlying buffer.
#define fr_dbuff_init(_out, _start, _len_or_end)
Initialise an dbuff for encoding or decoding.
#define fr_dbuff_start(_dbuff_or_marker)
Return the 'start' position of a dbuff or marker.
#define fr_dbuff_remaining(_dbuff_or_marker)
Return the number of bytes remaining between the dbuff or marker and the end of the buffer.
static fr_dbuff_t * fr_dbuff_init_talloc(TALLOC_CTX *ctx, fr_dbuff_t *dbuff, fr_dbuff_uctx_talloc_t *tctx, size_t init, size_t max)
Initialise a special dbuff which automatically extends as additional data is written.
static void * fr_dcursor_current(fr_dcursor_t *cursor)
Return the item the cursor current points to.
#define fr_assert_msg(_x, _msg,...)
Calls panic_action ifndef NDEBUG, else logs error and causes the server to exit immediately with code...
fr_dict_attr_t const * fr_dict_root(fr_dict_t const *dict)
Return the root attribute of a dictionary.
bool unlang_request_is_cancelled(request_t const *request)
Return whether a request has been cancelled.
fr_dict_t const * dict_tls
void log_request_pair_list(fr_log_lvl_t lvl, request_t *request, fr_pair_t const *parent, fr_pair_list_t const *vps, char const *prefix)
Print a fr_pair_list_t.
#define REXDENT()
Exdent (unindent) R* messages by one level.
#define ROPTIONAL(_l_request, _l_global, _fmt,...)
Use different logging functions depending on whether request is NULL or not.
#define RDEBUG_ENABLED3
True if request debug level 1-3 messages are enabled.
#define RHEXDUMP4(_data, _len, _fmt,...)
#define ROPTIONAL_ENABLED(_e_request, _e_global)
Check if a debug level is set by the request (if !NULL) or by the global log.
#define RPEDEBUG(fmt,...)
#define HEXDUMP3(_data, _len, _fmt,...)
#define RPWDEBUG(fmt,...)
#define DEBUG_ENABLED3
True if global debug level 1-3 messages are enabled.
#define RINDENT()
Indent R* messages by one level.
fr_value_box_t const * enum_tls_packet_type_store_session
HIDDEN fr_dict_attr_t const * attr_tls_packet_type
fr_value_box_t const * enum_tls_packet_type_success
HIDDEN fr_dict_attr_t const * attr_tls_session_ttl
fr_value_box_t const * enum_tls_session_resumed_stateful
HIDDEN fr_dict_attr_t const * attr_tls_session_data
fr_value_box_t const * enum_tls_packet_type_load_session
HIDDEN fr_dict_attr_t const * attr_tls_session_id
fr_value_box_t const * enum_tls_packet_type_clear_session
fr_value_box_t const * enum_tls_session_resumed_stateless
fr_value_box_t const * enum_tls_packet_type_notfound
HIDDEN fr_dict_attr_t const * attr_tls_session_resume_type
HIDDEN fr_dict_attr_t const * attr_allow_session_resumption
@ L_DBG_LVL_3
3rd highest priority debug messages (-xxx | -Xx).
@ L_DBG_LVL_2
2nd highest priority debug messages (-xx | -X).
@ L_DBG
Only displayed when debugging is enabled.
int fr_pair_value_memdup_buffer(fr_pair_t *vp, uint8_t const *src, bool tainted)
Copy data from a talloced buffer into an "octets" data type.
fr_pair_t * fr_pair_find_by_da(fr_pair_list_t const *list, fr_pair_t const *prev, fr_dict_attr_t const *da)
Find the first pair with a matching da.
void fr_pair_list_init(fr_pair_list_t *list)
Initialise a pair list header.
int fr_pair_value_memdup_buffer_shallow(fr_pair_t *vp, uint8_t const *src, bool tainted)
Assign a talloced buffer to a "octets" type value pair.
ssize_t fr_internal_decode_pair_dbuff(TALLOC_CTX *ctx, fr_pair_list_t *out, fr_dict_attr_t const *parent, fr_dbuff_t *dbuff, void *decode_ctx)
ssize_t fr_internal_encode_pair(fr_dbuff_t *dbuff, fr_dcursor_t *cursor, void *encode_ctx)
Encode a data structure into an internal attribute.
#define pair_update_request(_attr, _da)
#define RDEBUG_ENABLED2()
rlm_rcode_t
Return codes indicating the result of the module call.
#define pair_append_session_state(_attr, _da)
Allocate and append a fr_pair_t to session-state list.
#define pair_prepend_request(_attr, _da)
Allocate and prepend a fr_pair_t to the request list.
#define fr_time()
Allow us to arbitrarily manipulate time.
Stores an attribute, a value and various bits of other data.
request_t * unlang_subrequest_alloc(request_t *parent, fr_dict_t const *namespace)
Allocate a subrequest to run through a virtual server at some point in the future.
uint8_t * talloc_typed_memdup(TALLOC_CTX *ctx, uint8_t const *in, size_t inlen)
Call talloc_memdup, setting the type on the new chunk correctly.
#define fr_time_lteq(_a, _b)
static int64_t fr_time_delta_to_sec(fr_time_delta_t delta)
static fr_time_t fr_time_from_sec(time_t when)
Convert a time_t (wallclock time) to a fr_time_t (internal time)
#define fr_time_sub(_a, _b)
Subtract one time from another.
fr_pair_t * fr_pair_remove(fr_pair_list_t *list, fr_pair_t *vp)
Remove fr_pair_t from a list without freeing.
void fr_pair_list_free(fr_pair_list_t *list)
Free memory used by a valuepair list.
void fr_pair_list_append(fr_pair_list_t *dst, fr_pair_list_t *src)
Appends a list of fr_pair_t from a temporary list to a destination list.
#define fr_pair_dcursor_init(_cursor, _list)
Initialises a special dcursor with callbacks that will maintain the attr sublists correctly.
void fr_value_box_memdup_shallow(fr_value_box_t *dst, fr_dict_attr_t const *enumv, uint8_t const *src, size_t len, bool tainted)
Assign a buffer to a box, but don't copy it.
#define fr_box_octets_buffer(_val)
static size_t char ** out
#define fr_box_octets(_val, _len)