Browse Source

use payload struct for assembly (#503)

* use payload struct for assembly

* use payload struct for assembly
pull/507/head
Logan oos Even 4 years ago
committed by GitHub
parent
commit
bac807c472
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/sn_utils.c

16
src/sn_utils.c

@ -1075,8 +1075,8 @@ static int process_udp(n2n_sn_t * sss,
n2n_REGISTER_SUPER_ACK_t ack; n2n_REGISTER_SUPER_ACK_t ack;
n2n_common_t cmn2; n2n_common_t cmn2;
uint8_t ackbuf[N2N_SN_PKTBUF_SIZE]; uint8_t ackbuf[N2N_SN_PKTBUF_SIZE];
uint8_t tmpbuf[REG_SUPER_ACK_PAYLOAD_SPACE]; uint8_t payload_buf[REG_SUPER_ACK_PAYLOAD_SPACE];
uint8_t *tmp_dst; n2n_REGISTER_SUPER_ACK_payload_t *payload;
size_t encx=0; size_t encx=0;
struct sn_community *fed; struct sn_community *fed;
struct sn_community_regular_expression *re, *tmp_re; struct sn_community_regular_expression *re, *tmp_re;
@ -1194,7 +1194,7 @@ static int process_udp(n2n_sn_t * sss,
skip = (skip < 0) ? 0 : n2n_rand_sqr(skip); skip = (skip < 0) ? 0 : n2n_rand_sqr(skip);
/* Assembling supernode list for REGISTER_SUPER_ACK payload */ /* Assembling supernode list for REGISTER_SUPER_ACK payload */
tmp_dst = tmpbuf; payload = (n2n_REGISTER_SUPER_ACK_payload_t*)payload_buf;
HASH_ITER(hh, sss->federation->edges, peer, tmp_peer) { HASH_ITER(hh, sss->federation->edges, peer, tmp_peer) {
if(skip){ if(skip){
skip--; skip--;
@ -1207,10 +1207,10 @@ static int process_udp(n2n_sn_t * sss,
* their SN_ACTIVE time before they get re-registred to. */ * their SN_ACTIVE time before they get re-registred to. */
if(((++num)*REG_SUPER_ACK_PAYLOAD_ENTRY_SIZE) > REG_SUPER_ACK_PAYLOAD_SPACE) break; /* no more space available in REGISTER_SUPER_ACK payload */ if(((++num)*REG_SUPER_ACK_PAYLOAD_ENTRY_SIZE) > REG_SUPER_ACK_PAYLOAD_SPACE) break; /* no more space available in REGISTER_SUPER_ACK payload */
memcpy(tmp_dst, &(peer->sock), sizeof(n2n_sock_t)); memcpy(&(payload->sock), &(peer->sock), sizeof(n2n_sock_t));
tmp_dst += sizeof(n2n_sock_t); memcpy(&(payload->mac), &(peer->mac_addr), sizeof(n2n_mac_t));
memcpy(tmp_dst, &(peer->mac_addr), sizeof(n2n_mac_t)); // shift to next payload entry
tmp_dst += sizeof(n2n_mac_t); payload++;
} }
ack.num_sn = num; ack.num_sn = num;
@ -1223,7 +1223,7 @@ static int process_udp(n2n_sn_t * sss,
update_edge(sss, &reg, comm, &(ack.sock), now); update_edge(sss, &reg, comm, &(ack.sock), now);
} }
encode_REGISTER_SUPER_ACK(ackbuf, &encx, &cmn2, &ack, tmpbuf); encode_REGISTER_SUPER_ACK(ackbuf, &encx, &cmn2, &ack, payload_buf);
if (comm->header_encryption == HEADER_ENCRYPTION_ENABLED) if (comm->header_encryption == HEADER_ENCRYPTION_ENABLED)
packet_header_encrypt (ackbuf, encx, comm->header_encryption_ctx, packet_header_encrypt (ackbuf, encx, comm->header_encryption_ctx,

Loading…
Cancel
Save