diff --git a/overlay_mdp.c b/overlay_mdp.c index e367590d..c653279e 100644 --- a/overlay_mdp.c +++ b/overlay_mdp.c @@ -1126,6 +1126,7 @@ static void send_route( static int routing_table(void **record, void *context) { struct subscriber *subscriber = *record; + DEBUGF(mdprequests, " subscriber sid=%s reachable=%s", alloca_tohex_sid_t(subscriber->sid), alloca_reachable_flags(subscriber->reachable)); if (subscriber->reachable != REACHABLE_NONE){ struct routing_state *state = (struct routing_state *)context; if ((subscriber->reachable & REACHABLE_SELF) == 0 || subscriber != get_my_subscriber(0)){ @@ -1597,7 +1598,7 @@ static void mdp_process_packet(struct socket_address *client, struct mdp_header mdp_interface_packet(client, header, payload); break; case MDP_ROUTE_TABLE: - DEBUGF(mdprequests, "Processing MDP_ROUTING_TABLE from %s", alloca_socket_address(client)); + DEBUGF(mdprequests, "Processing MDP_ROUTE_TABLE from %s", alloca_socket_address(client)); { struct routing_state state={ .client = client, diff --git a/strbuf_helpers.c b/strbuf_helpers.c index 513ea088..ea2b995f 100644 --- a/strbuf_helpers.c +++ b/strbuf_helpers.c @@ -66,6 +66,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include #include #include "lang.h" // for FALLTHROUGH +#include "overlay_address.h" // for REACHABLE_ flags #include "http_server.h" #include "strbuf_helpers.h" #include "str.h" @@ -623,6 +624,40 @@ strbuf strbuf_append_file_meta(strbuf sb, const struct file_meta *metap) return sb; } +strbuf strbuf_append_reachable_flags(strbuf sb, int flags) { + if (flags == REACHABLE_NONE) + strbuf_puts(sb, "NONE"); + else { + const char *sep = ""; + if (flags & REACHABLE_SELF) { + strbuf_puts(sb, sep); + strbuf_puts(sb, "SELF"); + sep = "|"; + } + if (flags & REACHABLE_BROADCAST) { + strbuf_puts(sb, sep); + strbuf_puts(sb, "BROADCAST"); + sep = "|"; + } + if (flags & REACHABLE_UNICAST) { + strbuf_puts(sb, sep); + strbuf_puts(sb, "UNICAST"); + sep = "|"; + } + if (flags & REACHABLE_INDIRECT) { + strbuf_puts(sb, sep); + strbuf_puts(sb, "INDIRECT"); + sep = "|"; + } + if (flags & REACHABLE_ASSUMED) { + strbuf_puts(sb, sep); + strbuf_puts(sb, "ASSUMED"); + sep = "|"; + } + } + return sb; +} + strbuf strbuf_append_quoted_string(strbuf sb, const char *str) { strbuf_putc(sb, '"'); diff --git a/strbuf_helpers.h b/strbuf_helpers.h index 5352fa09..3e00109a 100644 --- a/strbuf_helpers.h +++ b/strbuf_helpers.h @@ -205,6 +205,12 @@ struct file_meta; strbuf strbuf_append_file_meta(strbuf sb, const struct file_meta *metap); #define alloca_file_meta(metap) strbuf_str(strbuf_append_file_meta(strbuf_alloca(80), (metap))) +/* Append a representation of routing reachable flags. + * @author Andrew Bettison + */ +strbuf strbuf_append_reachable_flags(strbuf sb, int flags); +#define alloca_reachable_flags(flags) strbuf_str(strbuf_append_reachable_flags(strbuf_alloca(80), (flags))) + /* Append a string using HTTP quoted-string format: delimited by double quotes (") and * internal double quotes and backslash escaped by leading backslash. * @author Andrew Bettison diff --git a/tests/routing b/tests/routing index 50653aa5..99a3c7df 100755 --- a/tests/routing +++ b/tests/routing @@ -44,7 +44,7 @@ link_matches() { done sid="$1" tfw_log "Looking for link ${sid}, ${link_type}, ${interface_ex}, ${via}" - if ! $GREP "^${sid}:${link_type}:${interface_ex}:${via}:" $_tfw_tmp/stdout; then + if ! $GREP "^${sid}:${link_type}:${interface_ex}:${via}:" "$TFWSTDOUT"; then tfw_log "Link not found" return 1 fi @@ -90,6 +90,7 @@ configure_servald_server() { executeOk_servald config \ set debug.mdprequests yes \ set debug.linkstate yes \ + set debug.subscriber yes \ set debug.verbose yes \ set debug.overlayrouting yes \ set log.console.level debug \