diff --git a/mesh/util.c b/mesh/util.c
index 2cdcdf3..b3ce1ce 100644
--- a/mesh/util.c
+++ b/mesh/util.c
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- *
*/
#ifdef HAVE_CONFIG_H
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
+#include <unistd.h>
+#include <termios.h>
#include <time.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+
+#include <ell/ell.h>
#include "mesh/util.h"
+void print_packet(const char *label, const void *data, uint16_t size)
+{
+ struct timeval pkt_time;
+
+ gettimeofday(&pkt_time, NULL);
+
+ if (size > 0) {
+ char *str;
+
+ str = l_util_hexstring(data, size);
+ l_debug("%05d.%03d %s: %s",
+ (uint32_t) pkt_time.tv_sec % 100000,
+ (uint32_t) pkt_time.tv_usec/1000, label, str);
+ l_free(str);
+ } else
+ l_debug("%05d.%03d %s: empty",
+ (uint32_t) pkt_time.tv_sec % 100000,
+ (uint32_t) pkt_time.tv_usec/1000, label);
+}
+
uint32_t get_timestamp_secs(void)
{
struct timespec ts;
diff --git a/mesh/util.h b/mesh/util.h
index 6111010..007ea36 100644
--- a/mesh/util.h
+++ b/mesh/util.h
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
- *
*/
uint32_t get_timestamp_secs(void);
bool str2hex(const char *str, uint16_t in_len, uint8_t *out,
uint16_t out_len);
size_t hex2str(uint8_t *in, size_t in_len, char *out, size_t out_len);
+void print_packet(const char *label, const void *data, uint16_t size);