Browse Source

Detail adjustment. (#488)

* Fix compilation warning.

* Detail adjustment.

Co-authored-by: Luca Deri <lucaderi@users.noreply.github.com>
pull/491/head
fengdaolong 4 years ago
committed by GitHub
parent
commit
4bad6a7625
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      src/edge_utils.c
  2. 39
      src/sn_utils.c

8
src/edge_utils.c

@ -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), 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), msg_len += snprintf((char *) (udp_buf + msg_len), (N2N_PKT_BUF_SIZE - msg_len),
"uptime %lu | ", "uptime %lu | ",
@ -1761,11 +1761,11 @@ void readFromIPSocket(n2n_edge_t * eee, int in_sock) {
time_t now=0; time_t now=0;
uint64_t stamp = 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*/, 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) { if(recvlen < 0) {
#ifdef WIN32 #ifdef WIN32

39
src/sn_utils.c

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

Loading…
Cancel
Save