Detail adjustment. (#488)

* Fix compilation warning.

* Detail adjustment.

Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com>
This commit is contained in:
fengdaolong 2020-11-09 23:11:09 +08:00 committed by GitHub
parent eff68f1241
commit 4bad6a7625
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 22 deletions

View File

@ -1383,7 +1383,7 @@ static void readFromMgmtSocket(n2n_edge_t *eee, int *keep_running) {
}
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 | ",
@ -1761,11 +1761,11 @@ void readFromIPSocket(n2n_edge_t * eee, int in_sock) {
time_t now=0;
uint64_t stamp = 0;
size_t i;
size_t length;
i = sizeof(sender_sock);
length = sizeof(sender_sock);
recvlen = recvfrom(in_sock, udp_buf, N2N_PKT_BUF_SIZE, 0/*flags*/,
(struct sockaddr *)&sender_sock, (socklen_t*)&i);
(struct sockaddr *)&sender_sock, (socklen_t*)&length);
if(recvlen < 0) {
#ifdef WIN32

View File

@ -72,7 +72,7 @@ static int process_udp(n2n_sn_t *sss,
size_t udp_size,
time_t now);
static const n2n_mac_t null_mac = {0, 0, 0, 0, 0, 0};
static const n2n_mac_t null_mac = {0, 0, 0, 0, 0, 0}; /* 00:00:00:00:00:00 */
/* ************************************** */
@ -669,6 +669,7 @@ static int process_mgmt(n2n_sn_t *sss,
" id tun_tap MAC edge hint last_seen\n");
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
"-------------------------------------------------------------------------------------------------\n");
HASH_ITER(hh, sss->communities, community, tmp) {
num_edges += HASH_COUNT(community->edges);
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
@ -691,7 +692,7 @@ static int process_mgmt(n2n_sn_t *sss,
}
}
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
"---------------------------------------------------------------------------------\n");
"--------------------------------------------------------------------------------------------------\n");
ressize += snprintf(resbuf + ressize, N2N_SN_PKTBUF_SIZE - ressize,
"uptime %lu | ", (now - sss->start_time));
@ -773,7 +774,6 @@ static int process_udp(n2n_sn_t * sss,
char buf[32];
struct sn_community *comm, *tmp;
uint64_t stamp;
const n2n_mac_t null_mac = {0, 0, 0, 0, 0, 0}; /* 00:00:00:00:00:00 */
traceEvent(TRACE_DEBUG, "Processing incoming UDP packet [len: %lu][sender: %s:%u]",
udp_size, intoa(ntohl(sender_sock->sin_addr.s_addr), buf, sizeof(buf)),
@ -1194,19 +1194,20 @@ static int process_udp(n2n_sn_t * sss,
n2n_REGISTER_SUPER_ACK_t ack;
size_t encx=0;
struct sn_community *fed;
struct peer_info *scan, *tmp;
n2n_sock_str_t sockbuf1;
n2n_sock_str_t sockbuf2;
macstr_t mac_buf1;
n2n_sock_t sender;
n2n_sock_t *orig_sender;
n2n_sock_t *tmp_sock;
n2n_mac_t *tmp_mac;
int i;
uint8_t dec_tmpbuf[MAX_AVAILABLE_SPACE_FOR_ENTRIES];
int skip_add;
struct peer_info *scan, *tmp_peer;
n2n_sock_str_t sockbuf1;
n2n_sock_str_t sockbuf2;
macstr_t mac_buf1;
n2n_sock_t sender;
n2n_sock_t *orig_sender;
n2n_sock_t *tmp_sock;
n2n_mac_t *tmp_mac;
int i;
uint8_t dec_tmpbuf[MAX_AVAILABLE_SPACE_FOR_ENTRIES];
int skip_add;
memset(&sender, 0, sizeof(n2n_sock_t));
memset(&sender, 0, sizeof(n2n_sock_t));
sender.family = AF_INET;
sender.port = ntohs(sender_sock->sin_port);
memcpy(&(sender.addr.v4), &(sender_sock->sin_addr.s_addr), IPV4_SIZE);
@ -1256,11 +1257,11 @@ static int process_udp(n2n_sn_t * sss,
tmp_mac = (void*)dec_tmpbuf + sizeof(n2n_sock_t);
for(i=0; i<ack.num_sn; i++) {
skip_add = NO_SKIP;
tmp = add_sn_to_list_by_mac_or_sock(&(sss->federation->edges), tmp_sock, tmp_mac, &skip_add);
skip_add = NO_SKIP;
tmp_peer = add_sn_to_list_by_mac_or_sock(&(sss->federation->edges), tmp_sock, tmp_mac, &skip_add);
if(skip_add == ADDED) {
tmp->last_seen = now - TEST_TIME;
tmp_peer->last_seen = now - TEST_TIME;
}
/* REVISIT: find a more elegant expression to increase following pointers. */