Browse Source

Merge pull request #301 from Logan007/macMgmt

added MAC to management port output
pull/306/head
Luca Deri 4 years ago
committed by GitHub
parent
commit
1125d7f368
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/sn.c
  2. 17
      src/sn_utils.c

8
src/sn.c

@ -296,6 +296,8 @@ static int process_mgmt(n2n_sn_t * sss,
uint32_t num_edges=0;
ssize_t r;
struct sn_community *community, *tmp;
struct peer_info * peer, *tmpPeer;
macstr_t mac_buf;
traceEvent(TRACE_DEBUG, "process_mgmt");
@ -347,11 +349,15 @@ static int process_mgmt(n2n_sn_t * sss,
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
" [%s]",
community->community);
HASH_ITER(hh, community->edges, peer, tmpPeer) {
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
" {%s}",
macaddr_str(mac_buf, peer->mac_addr));
}
}
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
"\n");
r = sendto(sss->mgmt_sock, resbuf, ressize, 0/*flags*/,
(struct sockaddr *)sender_sock, sizeof(struct sockaddr_in));

17
src/sn_utils.c

@ -299,6 +299,8 @@ static int process_mgmt(n2n_sn_t *sss,
uint32_t num_edges = 0;
ssize_t r;
struct sn_community *community, *tmp;
struct peer_info * peer, *tmpPeer;
macstr_t mac_buf;
traceEvent(TRACE_DEBUG, "process_mgmt");
@ -345,6 +347,21 @@ static int process_mgmt(n2n_sn_t *sss,
"last reg %lu sec ago\n",
(long unsigned int)(now - sss->stats.last_reg_super));
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
"cur_cmnts");
HASH_ITER(hh, sss->communities, community, tmp) {
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
" [%s]",
community->community);
HASH_ITER(hh, community->edges, peer, tmpPeer) {
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
" {%s}",
macaddr_str(mac_buf, peer->mac_addr));
}
}
ressize += snprintf(resbuf+ressize, N2N_SN_PKTBUF_SIZE-ressize,
"\n");
r = sendto(sss->mgmt_sock, resbuf, ressize, 0 /*flags*/,
(struct sockaddr *)sender_sock, sizeof(struct sockaddr_in));

Loading…
Cancel
Save