mirror of
https://github.com/obgm/libcoap.git
synced 2026-11-09 10:32:53 +03:00
coap_context_set_pki_root_cas(): New coap_dtls_context_set_psk(): remove unused parameters, add in server parameter coap_dtls_context_set_pki(): add in server parameter coap_dtls_pki_t: Additional configuration parameters coap_dtls_security_setup_t: Updated coap_dtls_cn_callback_t: New coap_dtls_sni_callback_t: New coap_pki_key_t: New coap_pki_key_pem_t: New coap_pki_key_asn1_t: New coap_dtls_sni_t: New Comments tidy up. Better Doxygen comments for coap_dtls.h and net.h Doxygen fix for debug.h (introduced by #219 merge) Doxygen update coap_endpoint_new_dtls_session() for in coap_session.h
101 lines
2.7 KiB
C
101 lines
2.7 KiB
C
/*
|
|
* debug.h -- debug utilities
|
|
*
|
|
* Copyright (C) 2010-2011,2014 Olaf Bergmann <bergmann@tzi.org>
|
|
*
|
|
* This file is part of the CoAP library libcoap. Please see README for terms
|
|
* of use.
|
|
*/
|
|
|
|
#ifndef _COAP_DEBUG_H_
|
|
#define _COAP_DEBUG_H_
|
|
|
|
#ifndef COAP_DEBUG_FD
|
|
#define COAP_DEBUG_FD stdout
|
|
#endif
|
|
|
|
#ifndef COAP_ERR_FD
|
|
#define COAP_ERR_FD stderr
|
|
#endif
|
|
|
|
#ifdef HAVE_SYSLOG_H
|
|
#include <syslog.h>
|
|
typedef short coap_log_t;
|
|
#else
|
|
/** Pre-defined log levels akin to what is used in \b syslog. */
|
|
typedef enum {
|
|
LOG_EMERG=0,
|
|
LOG_ALERT,
|
|
LOG_CRIT,
|
|
LOG_ERR,
|
|
LOG_WARNING,
|
|
LOG_NOTICE,
|
|
LOG_INFO,
|
|
LOG_DEBUG
|
|
} coap_log_t;
|
|
#endif
|
|
|
|
/** Returns the current log level. */
|
|
coap_log_t coap_get_log_level(void);
|
|
|
|
/** Sets the log level to the specified value. */
|
|
void coap_set_log_level(coap_log_t level);
|
|
|
|
typedef void (*coap_log_handler_t) (coap_log_t level, const char *message);
|
|
|
|
/** Add a custom log callback, use NULL to reset default handler */
|
|
void coap_set_log_handler(coap_log_handler_t handler);
|
|
|
|
/** Returns a zero-terminated string with the name of this library. */
|
|
const char *coap_package_name(void);
|
|
|
|
/** Returns a zero-terminated string with the library version. */
|
|
const char *coap_package_version(void);
|
|
|
|
/**
|
|
* Writes the given text to @c COAP_ERR_FD (for @p level <= @c LOG_CRIT) or @c
|
|
* COAP_DEBUG_FD (for @p level >= @c LOG_WARNING). The text is output only when
|
|
* @p level is below or equal to the log level that set by coap_set_log_level().
|
|
*/
|
|
#if (defined(__GNUC__))
|
|
void coap_log_impl(coap_log_t level,
|
|
const char *format, ...) __attribute__ ((format(printf, 2, 3)));
|
|
#else
|
|
void coap_log_impl(coap_log_t level, const char *format, ...);
|
|
#endif
|
|
|
|
#ifndef coap_log
|
|
#define coap_log(level, ...) do { if ((level)<=(int)coap_get_log_level()) coap_log_impl((level), __VA_ARGS__); } while(0)
|
|
#endif
|
|
|
|
/* A set of convenience macros for common log levels. */
|
|
#define info(...) coap_log(LOG_INFO, __VA_ARGS__)
|
|
#define warn(...) coap_log(LOG_WARNING, __VA_ARGS__)
|
|
#define debug(...) coap_log(LOG_DEBUG, __VA_ARGS__)
|
|
|
|
#include "pdu.h"
|
|
|
|
/**
|
|
* Defines the output mode for the coap_show_pdu() function.
|
|
*
|
|
* @param use_fprintf 1 if the output is to use fprintf() (the default)
|
|
* 0 if the output is to use coap_log()
|
|
*/
|
|
void coap_set_show_pdu_output(int use_fprintf);
|
|
|
|
/**
|
|
* Display the contents of the specified @p pdu.
|
|
*
|
|
* @param level The required minimum logging level
|
|
* @param pdu The PDU to decode
|
|
*/
|
|
void coap_show_pdu(coap_log_t level, const coap_pdu_t *pdu);
|
|
|
|
struct coap_address_t;
|
|
size_t coap_print_addr(const struct coap_address_t *, unsigned char *, size_t);
|
|
|
|
int coap_debug_set_packet_loss(const char *loss_level);
|
|
int coap_debug_send_packet(void);
|
|
|
|
#endif /* _COAP_DEBUG_H_ */
|