The FreeRADIUS server  $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
log.h
Go to the documentation of this file.
1 #pragma once
2 /*
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU General Public License as published by
5  * the Free Software Foundation; either version 2 of the License, or
6  * (at your option) any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program; if not, write to the Free Software
15  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
16  */
17 #ifdef WITH_TLS
18 /**
19  * $Id: 282b4e7742e1e563bbe98f3196ef46b23bfc0e97 $
20  *
21  * @file lib/tls/log.h
22  * @brief Prototypes for TLS logging functions
23  *
24  * @copyright 2017 The FreeRADIUS project
25  * @copyright 2021 Arran Cudbard-Bell (a.cudbardb@freeradius.org)
26  */
27 RCSIDH(tls_log_h, "$Id: 282b4e7742e1e563bbe98f3196ef46b23bfc0e97 $")
28 
29 #include "openssl_user_macros.h"
30 
31 #include <stdbool.h>
32 #include <stdint.h>
33 
34 #include <freeradius-devel/server/request.h>
35 #include <openssl/bio.h>
36 
37 #include "base.h"
38 
39 /** Write out a certificate chain to the request or global log
40  *
41  * @param[in] _request The current request or NULL if you want to write to the global log.
42  * @param[in] _log_type Type of log message to create.
43  * @param[in] _chain A stack of X509 certificates representing the chain.
44  * @param[in] _leaf The leaf certificate. May be NULL.
45  */
46 #define fr_tls_chain_log(_request, _log_type, _chain, _leaf) \
47  _fr_tls_chain_log( __FILE__, __LINE__, _request, _log_type, _chain, _leaf)
48 void _fr_tls_chain_log(char const *file, int line,
49  request_t *request, fr_log_type_t log_type, STACK_OF(X509) *chain, X509 *leaf);
50 
51 /** Write out a certificate chain with a marker to the request or global log
52  *
53  * @param[in] _request The current request or NULL if you want to write to the global log.
54  * @param[in] _log_type Type of log message to create.
55  * @param[in] _chain A stack of X509 certificates representing the chain.
56  * @param[in] _leaf The leaf certificate. May be NULL.
57  * @param[in] _marker Emit a marker for this certificate.
58  */
59 #define fr_tls_chain_marker_log(_request, _log_type, _chain, _leaf, _marker) \
60  _fr_tls_chain_marker_log( __FILE__, __LINE__, _request, _log_type, _chain, _leaf, _marker)
61 void _fr_tls_chain_marker_log(char const *file, int line,
62  request_t *request, fr_log_type_t log_type, STACK_OF(X509) *chain, X509 *leaf,
63  X509 *marker);
64 
65 /** Write out a collection of X509 objects to the request or global log
66  *
67  * @param[in] _request The current request or NULL if you want to write to the global log.
68  * @param[in] _log_type Type of log message to create.
69  * @param[in] _objects to print to the log
70  */
71 #define fr_tls_x509_objects_log(_request, _log_type, _objects) \
72  _fr_tls_x509_objects_log( __FILE__, __LINE__, _request, _log_type, _objects)
73 void _fr_tls_x509_objects_log(char const *file, int line,
74  request_t *request, fr_log_type_t log_type,
75  STACK_OF(X509_OBJECT) *objects);
76 
77 int fr_tls_log_io_error(request_t *request, int err, char const *msg, ...)
78  CC_HINT(format (printf, 3, 4));
79 
80 int fr_tls_log(request_t *request, char const *msg, ...) CC_HINT(format (printf, 2, 3));
81 
82 void fr_tls_log_clear(void);
83 
84 /** Return a BIO that writes to the log of the specified request
85  *
86  * @note BIO should be considered invalid if the request yields
87  *
88  * @param[in] _request to associate with the logging BIO.
89  * @param[in] _type of log messages.
90  * @param[in] _lvl to print log messages at.
91  * @return A BIO.
92  */
93 #define fr_tls_request_log_bio(_request, _type, _lvl) \
94  _fr_tls_request_log_bio(__FILE__, __LINE__, _request, _type, _lvl)
95 BIO *_fr_tls_request_log_bio(char const *file, int line, request_t *request,
96  fr_log_type_t type, fr_log_lvl_t lvl) CC_HINT(nonnull);
97 
98 /** Return a BIO that writes to the global log
99  *
100  * @note BIO should be considered invalid if the request yields
101  *
102  * @param[in] _type of log messages.
103  * @param[in] _lvl to print log messages at.
104  * @return A BIO.
105  */
106 #define fr_tls_global_log_bio(_type, _lvl) \
107  _fr_tls_global_log_bio(__FILE__, __LINE__, _type, _lvl)
108 BIO *_fr_tls_global_log_bio(char const *file, int line, fr_log_type_t type, fr_log_lvl_t lvl);
109 
110 int fr_tls_log_init(void); /* Called from fr_openssl_init() */
111 
112 void fr_tls_log_free(void); /* Called from fr_openssl_init() */
113 #endif
int const char * file
Definition: acutest.h:702
log_entry msg
Definition: acutest.h:794
int const char int line
Definition: acutest.h:702
#define RCSIDH(h, id)
Definition: build.h:445
static fr_slen_t err
Definition: dict.h:645
fr_log_lvl_t
Definition: log.h:67
fr_log_type_t
Definition: log.h:54
fr_aka_sim_id_type_t type
int nonnull(2, 5))
int format(printf, 5, 0))