tinydtls  0.8.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
Macros | Functions | Variables
debug.c File Reference
#include "tinydtls.h"
#include "dtls_config.h"
#include <assert.h>
#include <stdarg.h>
#include <stdio.h>
#include <arpa/inet.h>
#include <time.h>
#include "global.h"
#include "debug.h"

Go to the source code of this file.

Macros

#define min(a, b)   ((a) < (b) ? (a) : (b))
 

Functions

const char * dtls_package_name ()
 
const char * dtls_package_version ()
 
log_t dtls_get_log_level ()
 
void dtls_set_log_level (log_t level)
 
static size_t print_timestamp (char *s, size_t len, time_t t)
 
static size_t dtls_strnlen (const char *s, size_t maxlen)
 
static size_t dsrv_print_addr (const session_t *addr, char *buf, size_t len)
 
void dsrv_log (log_t level, char *format,...)
 
void hexdump (const unsigned char *packet, int length)
 
void dump (unsigned char *buf, size_t len)
 
void dtls_dsrv_log_addr (log_t level, const char *name, const session_t *addr)
 
void dtls_dsrv_hexdump_log (log_t level, const char *name, const unsigned char *buf, size_t length, int extend)
 

Variables

static int maxlog = DTLS_LOG_WARN
 
static char * loglevels []
 

Macro Definition Documentation

#define min (   a,
 
)    ((a) < (b) ? (a) : (b))

Definition at line 114 of file debug.c.

Function Documentation

void dsrv_log ( log_t  level,
char *  format,
  ... 
)

Writes the given text to stdout. The text is output only when level is below or equal to the log level that set by set_log_level().

Definition at line 208 of file debug.c.

static size_t dsrv_print_addr ( const session_t addr,
char *  buf,
size_t  len 
)
static

Definition at line 118 of file debug.c.

void dtls_dsrv_hexdump_log ( log_t  level,
const char *  name,
const unsigned char *  buf,
size_t  length,
int  extend 
)

Definition at line 290 of file debug.c.

void dtls_dsrv_log_addr ( log_t  level,
const char *  name,
const session_t addr 
)

Definition at line 277 of file debug.c.

log_t dtls_get_log_level ( )

Returns the current log level.

Definition at line 58 of file debug.c.

const char* dtls_package_name ( )

Returns a zero-terminated string with the name of this library.

Definition at line 49 of file debug.c.

const char* dtls_package_version ( )

Returns a zero-terminated string with the library version.

Definition at line 53 of file debug.c.

void dtls_set_log_level ( log_t  level)

Sets the log level to the specified value.

Definition at line 63 of file debug.c.

static size_t dtls_strnlen ( const char *  s,
size_t  maxlen 
)
inlinestatic

A length-safe strlen() fake.

Parameters
sThe string to count characters != 0.
maxlenThe maximum length of s.
Returns
The length of s.

Definition at line 106 of file debug.c.

void dump ( unsigned char *  buf,
size_t  len 
)

dump as narrow string of hex digits

Definition at line 272 of file debug.c.

void hexdump ( const unsigned char *  packet,
int  length 
)

dumps packets in usual hexdump format

Definition at line 252 of file debug.c.

static size_t print_timestamp ( char *  s,
size_t  len,
time_t  t 
)
inlinestatic

Definition at line 75 of file debug.c.

Variable Documentation

char* loglevels[]
static
Initial value:
= {
"EMRG", "ALRT", "CRIT", "WARN", "NOTE", "INFO", "DEBG"
}

Definition at line 68 of file debug.c.

int maxlog = DTLS_LOG_WARN
static

Definition at line 47 of file debug.c.