|
|
|
|
@ -4,6 +4,7 @@
|
|
|
|
|
*/ |
|
|
|
|
#include <stdlib.h> |
|
|
|
|
#include <string.h> |
|
|
|
|
#include <stdio.h> |
|
|
|
|
#include "../lib/platform_compat.h" |
|
|
|
|
#include "route_node.h" |
|
|
|
|
#include "route_lib.h" |
|
|
|
|
@ -42,6 +43,21 @@ static void route_bgp_send_table_request(struct ROUTE_BGP* bgp, struct ETCP_CONN
|
|
|
|
|
etcp_send(conn, e); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static char* nodeinfo_format(const uint8_t* data, size_t len) { |
|
|
|
|
if (!data || len < sizeof(struct BGP_NODEINFO_PACKET)) return NULL; |
|
|
|
|
struct BGP_NODEINFO_PACKET* pkt = (struct BGP_NODEINFO_PACKET*)data; |
|
|
|
|
struct NODEINFO* ni = &pkt->node; |
|
|
|
|
uint64_t node_id = be64toh(ni->node_id); |
|
|
|
|
char* buf = u_malloc(512); |
|
|
|
|
if (!buf) return NULL; |
|
|
|
|
const uint8_t* dyn = data + sizeof(struct BGP_NODEINFO_PACKET); |
|
|
|
|
size_t name_l = ni->node_name_len; |
|
|
|
|
const char* name_str = (name_l > 0 && len > sizeof(struct BGP_NODEINFO_PACKET) + name_l) ? (const char*)dyn : ""; |
|
|
|
|
snprintf(buf, 512, "NODEINFO: nid=%016llx ver=%u name_len=%u name=%.*s v4socks=%u v6socks=%u v4subs=%u v6subs=%u tranzit=%u hops=%u", |
|
|
|
|
(unsigned long long)node_id, (unsigned)ni->ver, (unsigned)name_l, (int)name_l, name_str, (unsigned)ni->local_v4_sockets, (unsigned)ni->local_v6_sockets, (unsigned)ni->local_v4_subnets, (unsigned)ni->local_v6_subnets, (unsigned)ni->tranzit_nodes, (unsigned)ni->hop_count); |
|
|
|
|
return buf; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Old full table sending removed - now using NODEINFO broadcast now */ |
|
|
|
|
|
|
|
|
|
// ============================================================================
|
|
|
|
|
@ -126,6 +142,7 @@ static void route_bgp_receive_cbk(struct ETCP_CONN* from_conn, struct ll_entry*
|
|
|
|
|
from_conn->log_name, subcmd, entry->len); |
|
|
|
|
|
|
|
|
|
if (subcmd == ROUTE_SUBCMD_NODEINFO) { |
|
|
|
|
char* s = nodeinfo_format(data, entry->len); if (s) { DEBUG_INFO(DEBUG_CATEGORY_BGP, "%s from %s", s, from_conn->log_name); u_free(s); } |
|
|
|
|
route_bgp_process_nodeinfo(bgp, from_conn, data, entry->len); |
|
|
|
|
} else if (subcmd == ROUTE_SUBCMD_WITHDRAW) { |
|
|
|
|
route_bgp_process_withdraw(bgp, from_conn, data, entry->len); |
|
|
|
|
|