diff --git a/src/edge_utils.c b/src/edge_utils.c index 43c2dfe..6fe2171 100644 --- a/src/edge_utils.c +++ b/src/edge_utils.c @@ -1822,6 +1822,7 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { struct peer_info *peer, *tmpPeer; macstr_t mac_buf; char time_buf[10]; /* 9 digits + 1 terminating zero */ + char uptime_buf[11]; /* 10 digits + 1 terminating zero */ /* dec_ip_bit_str_t ip_bit_str = {'\0'}; */ /* dec_ip_str_t ip_str = {'\0'}; */ in_addr_t net; @@ -1905,9 +1906,9 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { "COMMUNITY '%s'\n\n", eee->conf.community_name); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - " ### | TAP | MAC | EDGE | HINT | LAST SEEN | VERSION | UPTIME \n\n"); + " ### | TAP | MAC | EDGE | HINT | LAST SEEN | UPTIME \n\n"); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - "===================================================================================================================================\n"); + "=============================================================================================================\n"); // dump nodes with forwarding through supernodes msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), @@ -1918,7 +1919,7 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { net = htonl(peer->dev_addr.net_addr); snprintf (time_buf, sizeof(time_buf), "%9u", (unsigned int)(now - peer->last_seen)); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - "%4u | %-15s | %-17s | %-21s | %-15s | %9s | |\n", + "%4u | %-15s | %-17s | %-21s | %-15s | %9s |\n", ++num, (peer->dev_addr.net_addr == 0) ? "" : inet_ntoa(*(struct in_addr *) &net), (is_null_mac(peer->mac_addr)) ? "" : macaddr_str(mac_buf, peer->mac_addr), @@ -1933,7 +1934,7 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { // dump peer-to-peer nodes msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - "-----------------------------------------------------------------------------------------------------------------------------------\n"); + "-------------------------------------------------------------------------------------------------------------\n"); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), "PEER TO PEER\n"); num = 0; @@ -1942,7 +1943,7 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { net = htonl(peer->dev_addr.net_addr); snprintf (time_buf, sizeof(time_buf), "%9u", (unsigned int)(now - peer->last_seen)); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - "%4u | %-15s | %-17s | %-21s | %-15s | %9s | |\n", + "%4u | %-15s | %-17s | %-21s | %-15s | %9s |\n", ++num, (peer->dev_addr.net_addr == 0) ? "" : inet_ntoa(*(struct in_addr *) &net), (is_null_mac(peer->mac_addr)) ? "" : macaddr_str(mac_buf, peer->mac_addr), @@ -1957,24 +1958,24 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { // dump supernodes msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - "-----------------------------------------------------------------------------------------------------------------------------------\n"); + "-------------------------------------------------------------------------------------------------------------\n"); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), "SUPERNODES\n"); HASH_ITER(hh, eee->conf.supernodes, peer, tmpPeer) { net = htonl(peer->dev_addr.net_addr); snprintf (time_buf, sizeof(time_buf), "%9u", (unsigned int)(now - peer->last_seen)); + snprintf (uptime_buf, sizeof(uptime_buf), "%10u", (unsigned int)(peer->uptime)); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - "%4u | %-3s %-11s | %-17s | %-21s | %-15s | %9s | %-19s | %10lu\n", - ++num, - (peer->purgeable == SN_UNPURGEABLE) ? "-l" : "", - (peer == eee->curr_sn) ? (eee->sn_wait ? ">>..." : ">>>>>" ) : "", + "%-19s %1s%1s | %-17s | %-21s | %-15s | %9s | %10s\n", + peer->version, + (peer->purgeable == SN_UNPURGEABLE) ? "l" : "", + (peer == eee->curr_sn) ? (eee->sn_wait ? "." : "*" ) : "", is_null_mac(peer->mac_addr) ? "" : macaddr_str(mac_buf, peer->mac_addr), sock_to_cstr(sockbuf, &(peer->sock)), sn_selection_criterion_str(sel_buf, peer), (peer->last_seen) ? time_buf : "", - peer->version, - peer->uptime); + (peer->uptime) ? uptime_buf : ""); sendto(eee->udp_mgmt_sock, udp_buf, msg_len, 0, (struct sockaddr *) &sender_sock, sizeof(struct sockaddr_in)); @@ -1983,7 +1984,7 @@ static void readFromMgmtSocket (n2n_edge_t *eee, int *keep_running) { // further stats msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), - "===================================================================================================================================\n"); + "=============================================================================================================\n"); msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len), "uptime %lu | ",