diff options
Diffstat (limited to 'mmss/gmrf.cpp')
-rw-r--r-- | mmss/gmrf.cpp | 30 |
1 files changed, 24 insertions, 6 deletions
diff --git a/mmss/gmrf.cpp b/mmss/gmrf.cpp index 1b05b7d..a2a60a8 100644 --- a/mmss/gmrf.cpp +++ b/mmss/gmrf.cpp @@ -29,6 +29,8 @@ #include "iface.hpp" #include "node.hpp" +#include <cstdlib> + using namespace MMSS; @@ -82,23 +84,39 @@ void gmrf_logf(gmrf_t *gmrf, int priority, const char *format, ...) { va_list ap; va_start(ap, format); - node->get_context()->vlogf_orig(node, priority, format, ap); + + char *message; + if (vasprintf(&message, format, ap) >= 0) { + node->get_context()->node_log(node, priority, std::string(message)); + std::free(message); + } + va_end(ap); } -void gmrf_debug_init(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) { +void gmrf_debug_init(gmrf_t *gmrf, const uint8_t *node_id, size_t len) { + node_t *node = static_cast<node_t*>(gmrf); + node->get_context()->node_init(node, node_id, len); } -void gmrf_debug_neigh(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, float rxcost UNUSED, float txcost UNUSED) { +void gmrf_debug_neigh(gmrf_t *gmrf, gmrf_iface_t *iface, const gmrf_addr_t *addr, float rxcost, float txcost) { + node_t *node = static_cast<node_t*>(gmrf); + node->get_context()->node_neigh(node, iface, addr, rxcost, txcost); } -void gmrf_debug_neigh_lost(gmrf_t *gmrf UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED) { +void gmrf_debug_neigh_lost(gmrf_t *gmrf, gmrf_iface_t *iface, const gmrf_addr_t *addr) { + node_t *node = static_cast<node_t*>(gmrf); + node->get_context()->node_neigh_lost(node, iface, addr); } -void gmrf_debug_route(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED, gmrf_iface_t *iface UNUSED, const gmrf_addr_t *addr UNUSED, int metric UNUSED) { +void gmrf_debug_route(gmrf_t *gmrf, const uint8_t *node_id, size_t len, gmrf_iface_t *iface, const gmrf_addr_t *addr, int metric) { + node_t *node = static_cast<node_t*>(gmrf); + node->get_context()->node_route(node, node_id, len, iface, addr, metric); } -void gmrf_debug_route_lost(gmrf_t *gmrf UNUSED, const uint8_t *node_id UNUSED, size_t len UNUSED) { +void gmrf_debug_route_lost(gmrf_t *gmrf, const uint8_t *node_id, size_t len) { + node_t *node = static_cast<node_t*>(gmrf); + node->get_context()->node_route_lost(node, node_id, len); } } |