Feersum
view release on metacpan or search on metacpan
picotls-git/include/picotls.h view on Meta::CPAN
PTLS_LOG_ELEMENT_HEXDUMP(name, value, value_len); \
PTLS_LOG__DO_ELEMENT_UNSIGNED(PTLS_TO_STR(name) "_len", value_len); \
} while (0)
/**
* retains a list of connections that are bound to the object
*/
struct st_ptls_log_state_t {
/**
* bit array of connections (1 is active)
*/
uint32_t active_conns;
/**
* generation counter used for staleness check; see `ptls_log._generation`
*/
uint64_t generation;
};
/**
* represents a log point identified by name (`module:type`)
*/
struct st_ptls_log_point_t {
const char *name;
struct st_ptls_log_state_t state;
};
/**
* represents a logging state of each connection
*/
typedef struct st_ptls_log_conn_state_t {
/**
* random value between 0 (inclusive) and 1 (non-inclusive) used to determine the ratio of sampling-based logging; see
* `ptls_add_fd'`. To disable logging entirely, use `ptls_log.dummy_conn_state`, or set the value exactly to 1.
*/
float random_;
/**
* represents the peer address using ipv6; ipv4 addresses are stored using the mapped form (::ffff:192.0.2.1)
*/
uint8_t address[16];
/**
* application-supplied identifier; emitted as `conn_id` if set to a non-zero value
*/
uint64_t conn_id;
struct st_ptls_log_state_t state;
} ptls_log_conn_state_t;
/**
* see `ptls_get_log_state`
*/
extern PTLS_THREADLOCAL ptls_log_conn_state_t *ptls_log_conn_state_override;
/**
* global variables exposed
*/
extern struct st_ptls_log_t {
/**
* if application-data (e.g., payload) should be emitted as well
*/
volatile unsigned may_include_appdata : 1;
/**
* endpoints that want to disable logging entirely can provide this value to the loggers
*/
ptls_log_conn_state_t dummy_conn_state;
/**
* generation counter that is incremented whenever the state of loggers change; see `st_ptls_log_state_t::generation`
*/
volatile uint64_t _generation;
} ptls_log;
/**
* initializes a ptls_log_conn_state_t. `conn_id` and `peeraddr` (of type struct sockaddr) are optional; pass 0 and NULL
* respectively when unavailable.
*/
void ptls_log_init_conn_state(ptls_log_conn_state_t *state, void (*random_bytes)(void *, size_t), uint64_t conn_id, void *peeraddr);
/**
* forces recalculation of the log state (should be called when SNI is determined)
*/
static void ptls_log_recalc_conn_state(ptls_log_conn_state_t *state);
/**
* returns a bitmap indicating the loggers active for given log point
*/
static uint32_t ptls_log_point_maybe_active(struct st_ptls_log_point_t *point);
/**
* returns a bitmap indicating the loggers active for given connection
*/
static uint32_t ptls_log_conn_maybe_active(ptls_log_conn_state_t *conn, ptls_log_getsni_t getsni);
/**
* Returns the number of log events that were unable to be emitted.
*/
size_t ptls_log_num_lost(void);
/**
* Registers an fd to the logger. A registered fd is automatically closed and removed when it is closed by the peer.
* @param sample_ratio sampling ratio between 0 and 1
* @param points list of points to log, in the form of p1\0p2\0\0 (i.e., concatenated list of C strings with an empty string
* marking the end). An empty list means attach to all.
* @param snis list of SNIs to log, using the same form as points
* @param addresses list of IPv4/v6 addresses to log, using the same form as points
*/
int ptls_log_add_fd(int fd, float sample_ratio, const char *points, const char *snis, const char *addresses, int appdata);
void ptls_log__recalc_point(int caller_locked, struct st_ptls_log_point_t *point);
void ptls_log__recalc_conn(int caller_locked, struct st_ptls_log_conn_state_t *conn, ptls_log_getsni_t getsni);
void ptls_log__do_push_element_safestr(const char *prefix, size_t prefix_len, const char *s, size_t l);
void ptls_log__do_push_element_unsafestr(const char *prefix, size_t prefix_len, const char *s, size_t l);
void ptls_log__do_push_element_hexdump(const char *prefix, size_t prefix_len, const void *s, size_t l);
void ptls_log__do_push_element_signed32(const char *prefix, size_t prefix_len, int32_t v);
void ptls_log__do_push_element_signed64(const char *prefix, size_t prefix_len, int64_t v);
void ptls_log__do_push_element_unsigned32(const char *prefix, size_t prefix_len, uint32_t v);
void ptls_log__do_push_element_unsigned64(const char *prefix, size_t prefix_len, uint64_t v);
void ptls_log__do_push_element_bool(const char *prefix, size_t prefix_len, int v);
void ptls_log__do_push_appdata_element_unsafestr(int includes_appdata, const char *prefix, size_t prefix_len, const char *s,
size_t l);
void ptls_log__do_push_appdata_element_hexdump(int includes_appdata, const char *prefix, size_t prefix_len, const void *s,
size_t l);
void ptls_log__do_write_start(struct st_ptls_log_point_t *point, int add_time);
int ptls_log__do_write_end(struct st_ptls_log_point_t *point, struct st_ptls_log_conn_state_t *conn, ptls_log_getsni_t getsni,
int includes_appdata);
/**
* create a client object to handle new TLS connection
( run in 0.478 second using v1.01-cache-2.11-cpan-16aabcbfbcb )