mbed port of tinydtls

Committer:
ashleymills
Date:
Fri Oct 11 08:46:21 2013 +0000
Revision:
1:bc8a649bad13
Parent:
0:04990d454f45
Cleaned up all the debug stuff I added finding the hash table bug.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ashleymills 0:04990d454f45 1 /* debug.h -- debug utilities
ashleymills 0:04990d454f45 2 *
ashleymills 0:04990d454f45 3 * Copyright (C) 2011--2012 Olaf Bergmann <bergmann@tzi.org>
ashleymills 0:04990d454f45 4 *
ashleymills 0:04990d454f45 5 * Permission is hereby granted, free of charge, to any person
ashleymills 0:04990d454f45 6 * obtaining a copy of this software and associated documentation
ashleymills 0:04990d454f45 7 * files (the "Software"), to deal in the Software without
ashleymills 0:04990d454f45 8 * restriction, including without limitation the rights to use, copy,
ashleymills 0:04990d454f45 9 * modify, merge, publish, distribute, sublicense, and/or sell copies
ashleymills 0:04990d454f45 10 * of the Software, and to permit persons to whom the Software is
ashleymills 0:04990d454f45 11 * furnished to do so, subject to the following conditions:
ashleymills 0:04990d454f45 12 *
ashleymills 0:04990d454f45 13 * The above copyright notice and this permission notice shall be
ashleymills 0:04990d454f45 14 * included in all copies or substantial portions of the Software.
ashleymills 0:04990d454f45 15 *
ashleymills 0:04990d454f45 16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
ashleymills 0:04990d454f45 17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
ashleymills 0:04990d454f45 18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
ashleymills 0:04990d454f45 19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
ashleymills 0:04990d454f45 20 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
ashleymills 0:04990d454f45 21 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
ashleymills 0:04990d454f45 22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
ashleymills 0:04990d454f45 23 * SOFTWARE.
ashleymills 0:04990d454f45 24 */
ashleymills 0:04990d454f45 25
ashleymills 0:04990d454f45 26 #ifndef _DEBUG_H_
ashleymills 0:04990d454f45 27 #define _DEBUG_H_
ashleymills 0:04990d454f45 28
ashleymills 0:04990d454f45 29 #include "config.h"
ashleymills 0:04990d454f45 30 #include "global.h"
ashleymills 0:04990d454f45 31
ashleymills 0:04990d454f45 32 #ifdef __cplusplus
ashleymills 0:04990d454f45 33 extern "C" {
ashleymills 0:04990d454f45 34 #endif
ashleymills 0:04990d454f45 35
ashleymills 0:04990d454f45 36 /** Pre-defined log levels akin to what is used in \b syslog. */
ashleymills 0:04990d454f45 37 typedef enum { LOG_EMERG=0, LOG_ALERT, LOG_CRIT, LOG_WARN,
ashleymills 0:04990d454f45 38 LOG_NOTICE, LOG_INFO, LOG_DEBUG
ashleymills 0:04990d454f45 39 } log_t;
ashleymills 0:04990d454f45 40
ashleymills 0:04990d454f45 41 /** Returns the current log level. */
ashleymills 0:04990d454f45 42 log_t dtls_get_log_level();
ashleymills 0:04990d454f45 43
ashleymills 0:04990d454f45 44 /** Sets the log level to the specified value. */
ashleymills 0:04990d454f45 45 void dtls_set_log_level(log_t level);
ashleymills 0:04990d454f45 46
ashleymills 0:04990d454f45 47 /**
ashleymills 0:04990d454f45 48 * Writes the given text to \c stdout. The text is output only when \p
ashleymills 0:04990d454f45 49 * level is below or equal to the log level that set by
ashleymills 0:04990d454f45 50 * set_log_level(). */
ashleymills 0:04990d454f45 51 void dsrv_log(log_t level, char *format, ...);
ashleymills 0:04990d454f45 52
ashleymills 0:04990d454f45 53 size_t
ashleymills 0:04990d454f45 54 dsrv_print_addr(const session_t *addr, unsigned char *buf, size_t len);
ashleymills 0:04990d454f45 55
ashleymills 0:04990d454f45 56 void hexdump(const unsigned char *packet, int length);
ashleymills 0:04990d454f45 57 void dump(unsigned char *buf, size_t len);
ashleymills 0:04990d454f45 58
ashleymills 0:04990d454f45 59 /* A set of convenience macros for common log levels. */
ashleymills 0:04990d454f45 60 #define info2(...) dsrv_log(LOG_INFO, __VA_ARGS__)
ashleymills 0:04990d454f45 61 #define warn2(...) dsrv_log(LOG_WARN, __VA_ARGS__)
ashleymills 0:04990d454f45 62 #define debug2(...) dsrv_log(LOG_DEBUG, __VA_ARGS__)
ashleymills 0:04990d454f45 63
ashleymills 0:04990d454f45 64
ashleymills 0:04990d454f45 65 #ifdef __cplusplus
ashleymills 0:04990d454f45 66 }
ashleymills 0:04990d454f45 67 #endif
ashleymills 0:04990d454f45 68
ashleymills 0:04990d454f45 69 #endif /* _DEBUG_H_ */