|
|
@ -1506,7 +1506,12 @@ static int process_udp (n2n_sn_t * sss, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if(comm) { |
|
|
|
if(!comm) { |
|
|
|
traceEvent(TRACE_INFO, "Discarded registration: unallowed community '%s'", |
|
|
|
(char*)cmn.community); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
cmn2.ttl = N2N_DEFAULT_TTL; |
|
|
|
cmn2.pc = n2n_register_super_ack; |
|
|
|
cmn2.flags = N2N_FLAGS_SOCKET | N2N_FLAGS_FROM_SUPERNODE; |
|
|
@ -1577,7 +1582,6 @@ static int process_udp (n2n_sn_t * sss, |
|
|
|
cmn2.pc = n2n_register_super_nak; |
|
|
|
memcpy(&(nak.cookie), &(reg.cookie), sizeof(n2n_cookie_t)); |
|
|
|
memcpy(nak.srcMac, reg.edgeMac, sizeof(n2n_mac_t)); |
|
|
|
|
|
|
|
encode_REGISTER_SUPER_NAK(ackbuf, &encx, &cmn2, &nak); |
|
|
|
|
|
|
|
if(comm->header_encryption == HEADER_ENCRYPTION_ENABLED) { |
|
|
@ -1647,11 +1651,7 @@ static int process_udp (n2n_sn_t * sss, |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
traceEvent(TRACE_INFO, "Discarded registration: unallowed community '%s'", |
|
|
|
(char*)cmn.community); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
@ -1735,14 +1735,12 @@ static int process_udp (n2n_sn_t * sss, |
|
|
|
decode_REGISTER_SUPER_ACK(&ack, &cmn, udp_buf, &rem, &idx, dec_tmpbuf); |
|
|
|
orig_sender = &(ack.sock); |
|
|
|
|
|
|
|
if(comm) { |
|
|
|
if(comm->header_encryption == HEADER_ENCRYPTION_ENABLED) { |
|
|
|
if(!find_edge_time_stamp_and_verify(comm->edges, sn, ack.srcMac, stamp, TIME_STAMP_NO_JITTER)) { |
|
|
|
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER_ACK due to time stamp error."); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
traceEvent(TRACE_INFO, "Rx REGISTER_SUPER_ACK from MAC %s [%s] (external %s)", |
|
|
|
macaddr_str(mac_buf1, ack.srcMac), |
|
|
@ -1803,14 +1801,12 @@ static int process_udp (n2n_sn_t * sss, |
|
|
|
|
|
|
|
decode_REGISTER_SUPER_NAK(&nak, &cmn, udp_buf, &rem, &idx); |
|
|
|
|
|
|
|
if(comm) { |
|
|
|
if(comm->header_encryption == HEADER_ENCRYPTION_ENABLED) { |
|
|
|
if(!find_edge_time_stamp_and_verify(comm->edges, sn, nak.srcMac, stamp, TIME_STAMP_NO_JITTER)) { |
|
|
|
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER_NAK due to time stamp error."); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
traceEvent(TRACE_INFO, "Rx REGISTER_SUPER_NAK from %s [%s]", |
|
|
|
macaddr_str(mac_buf, nak.srcMac), |
|
|
@ -1883,7 +1879,9 @@ static int process_udp (n2n_sn_t * sss, |
|
|
|
|
|
|
|
decode_QUERY_PEER( &query, &cmn, udp_buf, &rem, &idx ); |
|
|
|
|
|
|
|
// already checked for valid comm
|
|
|
|
// to answer a PING, it is sufficient if the provided communtiy would be a valid one, there does not
|
|
|
|
// neccessarily need to be an entry present, e.g. because there locally are no edges of the community
|
|
|
|
// connected (several sueprnodes in a federation setup)
|
|
|
|
if(comm) { |
|
|
|
if(comm->header_encryption == HEADER_ENCRYPTION_ENABLED) { |
|
|
|
if(!find_edge_time_stamp_and_verify(comm->edges, sn, query.srcMac, stamp, TIME_STAMP_ALLOW_JITTER)) { |
|
|
@ -1931,6 +1929,13 @@ static int process_udp (n2n_sn_t * sss, |
|
|
|
macaddr_str(mac_buf2, query.targetMac)); |
|
|
|
|
|
|
|
struct peer_info *scan; |
|
|
|
|
|
|
|
// as opposed to the special case 'PING', proper QUERY_PEER processing requires a locally actually present community entry
|
|
|
|
if(!comm) { |
|
|
|
traceEvent(TRACE_DEBUG, "process_udp QUERY_PEER with unknown community %s", cmn.community); |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|
HASH_FIND_PEER(comm->edges, query.targetMac, scan); |
|
|
|
if(scan) { |
|
|
|
cmn2.ttl = N2N_DEFAULT_TTL; |
|
|
|