mirror of
https://github.com/ntop/n2n.git
synced 2024-09-20 00:51:10 +02:00
Partial fixes for addressing compilation issues introduced by https://github.com/ntop/n2n/pull/460
This commit is contained in:
parent
c9eedd68f0
commit
f6e4047ce0
|
@ -82,6 +82,9 @@ enum federation{IS_NO_FEDERATION = 0,IS_FEDERATION = 1};
|
||||||
#define COMMUNITY_UNPURGEABLE 0
|
#define COMMUNITY_UNPURGEABLE 0
|
||||||
#define COMMUNITY_PURGEABLE 1
|
#define COMMUNITY_PURGEABLE 1
|
||||||
|
|
||||||
|
#define SN_UNPURGEABLE 0 /* FIX fcarli3 */
|
||||||
|
#define SN_PURGEABLE 1 /* FIX fcarli3 */
|
||||||
|
|
||||||
/* Header encryption indicators */
|
/* Header encryption indicators */
|
||||||
#define HEADER_ENCRYPTION_UNKNOWN 0
|
#define HEADER_ENCRYPTION_UNKNOWN 0
|
||||||
#define HEADER_ENCRYPTION_NONE 1
|
#define HEADER_ENCRYPTION_NONE 1
|
||||||
|
|
|
@ -11,4 +11,3 @@ dh_link
|
||||||
dh_gencontrol
|
dh_gencontrol
|
||||||
dh_md5sums
|
dh_md5sums
|
||||||
dh_builddeb
|
dh_builddeb
|
||||||
dh_builddeb
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# Automatically added by dh_installdebconf
|
# Automatically added by dh_installdebconf/11.1.6ubuntu2
|
||||||
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
|
if [ "$1" = purge ] && [ -e /usr/share/debconf/confmodule ]; then
|
||||||
. /usr/share/debconf/confmodule
|
. /usr/share/debconf/confmodule
|
||||||
db_purge
|
db_purge
|
||||||
|
|
|
@ -1 +1,2 @@
|
||||||
misc:Depends=debconf (>= 0.5) | debconf-2.0
|
misc:Depends=debconf (>= 0.5) | debconf-2.0
|
||||||
|
misc:Pre-Depends=
|
||||||
|
|
|
@ -1940,12 +1940,13 @@ void readFromIPSocket(n2n_edge_t * eee, int in_sock) {
|
||||||
|
|
||||||
if(0 == memcmp(ra.cookie, eee->last_cookie, N2N_COOKIE_SIZE))
|
if(0 == memcmp(ra.cookie, eee->last_cookie, N2N_COOKIE_SIZE))
|
||||||
{
|
{
|
||||||
if(ra.num_sn > 0)
|
#if 0
|
||||||
|
if(ra.num_sn > 0) /* FIX fcarli3 */
|
||||||
{
|
{
|
||||||
traceEvent(TRACE_NORMAL, "Rx REGISTER_SUPER_ACK backup supernode at %s",
|
traceEvent(TRACE_NORMAL, "Rx REGISTER_SUPER_ACK backup supernode at %s",
|
||||||
sock_to_cstr(sockbuf1, &(ra.sn_bak)));
|
sock_to_cstr(sockbuf1, &(ra.sn_bak)));
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
eee->last_sup = now;
|
eee->last_sup = now;
|
||||||
eee->sn_wait=0;
|
eee->sn_wait=0;
|
||||||
eee->sup_attempts = N2N_EDGE_SUP_ATTEMPTS; /* refresh because we got a response */
|
eee->sup_attempts = N2N_EDGE_SUP_ATTEMPTS; /* refresh because we got a response */
|
||||||
|
|
7
src/sn.c
7
src/sn.c
|
@ -251,7 +251,12 @@ static int setOption(int optkey, char *_optarg, n2n_sn_t *sss) {
|
||||||
anchor_sn->ip_addr = calloc(1,N2N_EDGE_SN_HOST_SIZE);
|
anchor_sn->ip_addr = calloc(1,N2N_EDGE_SN_HOST_SIZE);
|
||||||
if(anchor_sn->ip_addr){
|
if(anchor_sn->ip_addr){
|
||||||
strncpy(anchor_sn->ip_addr,_optarg,N2N_EDGE_SN_HOST_SIZE-1);
|
strncpy(anchor_sn->ip_addr,_optarg,N2N_EDGE_SN_HOST_SIZE-1);
|
||||||
rv = supernode2sock(socket,_optarg);
|
|
||||||
|
#if 1
|
||||||
|
rv = -1;
|
||||||
|
#else
|
||||||
|
rv = supernode2sock(socket,_optarg); /* FIX fcarli3 */
|
||||||
|
#endif
|
||||||
|
|
||||||
if(rv != 0){
|
if(rv != 0){
|
||||||
traceEvent(TRACE_WARNING, "Invalid socket");
|
traceEvent(TRACE_WARNING, "Invalid socket");
|
||||||
|
|
|
@ -205,7 +205,7 @@ static int try_broadcast(n2n_sn_t * sss,
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initialise some fields of the community structure **/
|
/** Initialise some fields of the community structure **/
|
||||||
int comm_init(struct sn_community *comm, char *cmn){
|
int comm_init(struct sn_community *comm, char *cmn) {
|
||||||
|
|
||||||
strncpy((char*)comm->community, cmn, N2N_COMMUNITY_SIZE-1);
|
strncpy((char*)comm->community, cmn, N2N_COMMUNITY_SIZE-1);
|
||||||
comm->community[N2N_COMMUNITY_SIZE-1] = '\0';
|
comm->community[N2N_COMMUNITY_SIZE-1] = '\0';
|
||||||
|
@ -241,7 +241,7 @@ int sn_init(n2n_sn_t *sss) {
|
||||||
sss->federation = (struct sn_community *)calloc(1,sizeof(struct sn_community));
|
sss->federation = (struct sn_community *)calloc(1,sizeof(struct sn_community));
|
||||||
|
|
||||||
/* Initialize the federation */
|
/* Initialize the federation */
|
||||||
if(sss->federation){
|
if(sss->federation) {
|
||||||
strncpy(sss->federation->community, (char*)FEDERATION_NAME, N2N_COMMUNITY_SIZE-1);
|
strncpy(sss->federation->community, (char*)FEDERATION_NAME, N2N_COMMUNITY_SIZE-1);
|
||||||
sss->federation->community[N2N_COMMUNITY_SIZE-1] = '\0';
|
sss->federation->community[N2N_COMMUNITY_SIZE-1] = '\0';
|
||||||
/* enable the flag for federation */
|
/* enable the flag for federation */
|
||||||
|
@ -256,7 +256,7 @@ int sn_init(n2n_sn_t *sss) {
|
||||||
n2n_srand (n2n_seed());
|
n2n_srand (n2n_seed());
|
||||||
|
|
||||||
/* Random MAC address */
|
/* Random MAC address */
|
||||||
for(i=0; i<6; i++){
|
for(i=0; i<6; i++) {
|
||||||
sss->mac_addr[i] = n2n_rand();
|
sss->mac_addr[i] = n2n_rand();
|
||||||
}
|
}
|
||||||
sss->mac_addr[0] &= ~0x01; /* Clear multicast bit */
|
sss->mac_addr[0] &= ~0x01; /* Clear multicast bit */
|
||||||
|
@ -510,16 +510,19 @@ static int find_edge_time_stamp_and_verify (struct peer_info * edges,
|
||||||
return ( time_stamp_verify_and_update (stamp, previous_stamp, allow_jitter) );
|
return ( time_stamp_verify_and_update (stamp, previous_stamp, allow_jitter) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int re_register_and_purge_supernodes(n2n_sn_t *sss, struct sn_community *comm, time_t now) {
|
||||||
static int re_register_and_purge_supernodes(n2n_sn_t *sss, struct sn_community *comm, time_t now){
|
|
||||||
time_t time;
|
time_t time;
|
||||||
struct peer_info *peer, *tmp;
|
struct peer_info *peer, *tmp;
|
||||||
|
|
||||||
if(comm != NULL){
|
if(comm != NULL) {
|
||||||
HASH_ITER(hh,comm->edges,peer,tmp){
|
HASH_ITER(hh,comm->edges,peer,tmp) {
|
||||||
time = now - peer->last_seen;
|
time = now - peer->last_seen;
|
||||||
if(time <= ALLOWED_TIME) continue;
|
if(time <= ALLOWED_TIME) continue;
|
||||||
if((time < PURGE_FEDERATION_NODE_INTERVAL) || (peer->purgeable == SN_UNPURGEABLE)){ /* re-regitser (send REGISTER_SUPER) */
|
|
||||||
|
if((time < PURGE_FEDERATION_NODE_INTERVAL)
|
||||||
|
|| (peer->purgeable == SN_UNPURGEABLE) /* FIX fcarli3 */
|
||||||
|
) {
|
||||||
|
/* re-regitser (send REGISTER_SUPER) */
|
||||||
uint8_t pktbuf[N2N_PKT_BUF_SIZE] = {0};
|
uint8_t pktbuf[N2N_PKT_BUF_SIZE] = {0};
|
||||||
size_t idx;
|
size_t idx;
|
||||||
/* ssize_t sent; */
|
/* ssize_t sent; */
|
||||||
|
@ -561,7 +564,7 @@ static int re_register_and_purge_supernodes(n2n_sn_t *sss, struct sn_community *
|
||||||
}
|
}
|
||||||
if(time >= PURGE_FEDERATION_NODE_INTERVAL) purge_expired_registrations(&(comm->edges),&time,PURGE_FEDERATION_NODE_INTERVAL);/* purge not-seen-long-time supernodes*/
|
if(time >= PURGE_FEDERATION_NODE_INTERVAL) purge_expired_registrations(&(comm->edges),&time,PURGE_FEDERATION_NODE_INTERVAL);/* purge not-seen-long-time supernodes*/
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0; /* OK */
|
return 0; /* OK */
|
||||||
}
|
}
|
||||||
|
@ -733,29 +736,29 @@ static int sendto_mgmt(n2n_sn_t *sss,
|
||||||
/** Search for a node in the federation list. If it has to add a new node, it creates a new peer_info and initializes it
|
/** Search for a node in the federation list. If it has to add a new node, it creates a new peer_info and initializes it
|
||||||
* Evaluate first the MAC parameter and if it's zero-MAC, then it can skip HASH_FIND_PEER by MAC and search by socket
|
* Evaluate first the MAC parameter and if it's zero-MAC, then it can skip HASH_FIND_PEER by MAC and search by socket
|
||||||
*/
|
*/
|
||||||
struct peer_info* add_sn_to_federation_by_mac_or_sock(n2n_sn_t *sss,n2n_sock_t *sock, n2n_mac_t *mac){
|
struct peer_info* add_sn_to_federation_by_mac_or_sock(n2n_sn_t *sss,n2n_sock_t *sock, n2n_mac_t *mac) {
|
||||||
struct peer_info *scan, *tmp, *peer;
|
struct peer_info *scan, *tmp, *peer;
|
||||||
int found = 0;
|
int found = 0;
|
||||||
|
|
||||||
if(sss->federation != NULL){
|
if(sss->federation != NULL) {
|
||||||
if(memcmp(mac,null_mac,sizeof(n2n_mac_t)) != 0){ /* not zero MAC */
|
if(memcmp(mac,null_mac,sizeof(n2n_mac_t)) != 0) { /* not zero MAC */
|
||||||
HASH_FIND_PEER(sss->federation->edges, mac, peer);
|
HASH_FIND_PEER(sss->federation->edges, mac, peer);
|
||||||
|
|
||||||
//REVISIT: make this dependent from last_seen and update socket
|
//REVISIT: make this dependent from last_seen and update socket
|
||||||
}
|
}
|
||||||
|
|
||||||
if(peer == NULL){ /* zero MAC, search by socket */
|
if(peer == NULL) { /* zero MAC, search by socket */
|
||||||
HASH_ITER(hh,sss->federation->edges,scan,tmp){
|
HASH_ITER(hh,sss->federation->edges,scan,tmp) {
|
||||||
if(memcmp(&(scan->sock), sock, sizeof(n2n_sock_t))){
|
if(memcmp(&(scan->sock), sock, sizeof(n2n_sock_t))) {
|
||||||
memcpy(&(scan->mac_addr), sock, sizeof(n2n_mac_t));
|
memcpy(&(scan->mac_addr), sock, sizeof(n2n_mac_t));
|
||||||
peer = scan;
|
peer = scan;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(peer == NULL){
|
if(peer == NULL) {
|
||||||
peer = (struct peer_info*)calloc(1,sizeof(struct peer_info));
|
peer = (struct peer_info*)calloc(1,sizeof(struct peer_info));
|
||||||
if(peer){
|
if(peer) {
|
||||||
memcpy(&(peer->sock),sock,sizeof(n2n_sock_t));
|
memcpy(&(peer->sock),sock,sizeof(n2n_sock_t));
|
||||||
memcpy(&(peer->mac_addr),mac, sizeof(n2n_mac_t));
|
memcpy(&(peer->mac_addr),mac, sizeof(n2n_mac_t));
|
||||||
HASH_ADD_PEER(sss->federation->edges,peer);
|
HASH_ADD_PEER(sss->federation->edges,peer);
|
||||||
|
@ -1065,7 +1068,7 @@ static int process_udp(n2n_sn_t * sss,
|
||||||
n2n_sock_t *tmp_sock;
|
n2n_sock_t *tmp_sock;
|
||||||
n2n_mac_t *tmp_mac;
|
n2n_mac_t *tmp_mac;
|
||||||
|
|
||||||
if(from_supernode != comm->is_federation){
|
if(from_supernode != comm->is_federation) {
|
||||||
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER: from_supernode value doesn't correspond to the internal federation marking");
|
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER: from_supernode value doesn't correspond to the internal federation marking");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1152,7 +1155,7 @@ static int process_udp(n2n_sn_t * sss,
|
||||||
memcpy(ack.sock.addr.v4, &(sender_sock->sin_addr.s_addr), IPV4_SIZE);
|
memcpy(ack.sock.addr.v4, &(sender_sock->sin_addr.s_addr), IPV4_SIZE);
|
||||||
|
|
||||||
/* Add sender's data to federation (or update it) */
|
/* Add sender's data to federation (or update it) */
|
||||||
if(comm->is_federation == IS_FEDERATION){
|
if(comm->is_federation == IS_FEDERATION) {
|
||||||
p = add_sn_to_federation_by_mac_or_sock(sss,&(ack.sock),&(reg.edgeMac));
|
p = add_sn_to_federation_by_mac_or_sock(sss,&(ack.sock),&(reg.edgeMac));
|
||||||
if(p) p->last_seen = now;
|
if(p) p->last_seen = now;
|
||||||
}
|
}
|
||||||
|
@ -1178,7 +1181,7 @@ static int process_udp(n2n_sn_t * sss,
|
||||||
macaddr_str(mac_buf, reg.edgeMac),
|
macaddr_str(mac_buf, reg.edgeMac),
|
||||||
sock_to_cstr(sockbuf, &(ack.sock)));
|
sock_to_cstr(sockbuf, &(ack.sock)));
|
||||||
|
|
||||||
if(memcmp(reg.edgeMac, &null_mac, N2N_MAC_SIZE) != 0){
|
if(memcmp(reg.edgeMac, &null_mac, N2N_MAC_SIZE) != 0) {
|
||||||
update_edge(sss, ®, comm, &(ack.sock), now);
|
update_edge(sss, ®, comm, &(ack.sock), now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1229,7 +1232,7 @@ static int process_udp(n2n_sn_t * sss,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(from_supernode != comm->is_federation){
|
if(from_supernode != comm->is_federation) {
|
||||||
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER_ACK: from_supernode value doesn't correspond to the internal federation marking.");
|
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER_ACK: from_supernode value doesn't correspond to the internal federation marking.");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1253,7 +1256,7 @@ static int process_udp(n2n_sn_t * sss,
|
||||||
|
|
||||||
if(comm->is_federation == IS_FEDERATION) {
|
if(comm->is_federation == IS_FEDERATION) {
|
||||||
HASH_FIND_PEER(sss->federation->edges, ack.edgeMac, scan);
|
HASH_FIND_PEER(sss->federation->edges, ack.edgeMac, scan);
|
||||||
if(scan != NULL){
|
if(scan != NULL) {
|
||||||
scan->last_seen = now;
|
scan->last_seen = now;
|
||||||
} else {
|
} else {
|
||||||
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER_ACK due to an unknown supernode.");
|
traceEvent(TRACE_DEBUG, "process_udp dropped REGISTER_SUPER_ACK due to an unknown supernode.");
|
||||||
|
@ -1264,10 +1267,10 @@ static int process_udp(n2n_sn_t * sss,
|
||||||
tmp_sock = (void*)&(ack.num_sn) + sizeof(ack.num_sn);
|
tmp_sock = (void*)&(ack.num_sn) + sizeof(ack.num_sn);
|
||||||
tmp_mac = (void*)tmp_sock + sizeof(n2n_sock_t);
|
tmp_mac = (void*)tmp_sock + sizeof(n2n_sock_t);
|
||||||
|
|
||||||
for(i=0; i<ack.num_sn; i++){
|
for(i=0; i<ack.num_sn; i++) {
|
||||||
tmp = add_sn_to_federation_by_mac_or_sock(sss,tmp_sock,tmp_mac);
|
tmp = add_sn_to_federation_by_mac_or_sock(sss,tmp_sock,tmp_mac);
|
||||||
|
|
||||||
if(tmp){
|
if(tmp) {
|
||||||
tmp->last_seen = now - TEST_TIME;
|
tmp->last_seen = now - TEST_TIME;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,7 +1279,7 @@ static int process_udp(n2n_sn_t * sss,
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MSG_TYPE_QUERY_PEER: {
|
case MSG_TYPE_QUERY_PEER: {
|
||||||
n2n_QUERY_PEER_t query;
|
n2n_QUERY_PEER_t query;
|
||||||
uint8_t encbuf[N2N_SN_PKTBUF_SIZE];
|
uint8_t encbuf[N2N_SN_PKTBUF_SIZE];
|
||||||
|
|
|
@ -405,11 +405,14 @@ int encode_REGISTER_SUPER_ACK(uint8_t *base,
|
||||||
retval += encode_uint16(base, idx, reg->lifetime);
|
retval += encode_uint16(base, idx, reg->lifetime);
|
||||||
retval += encode_sock(base, idx, &(reg->sock));
|
retval += encode_sock(base, idx, &(reg->sock));
|
||||||
retval += encode_uint8(base, idx, reg->num_sn);
|
retval += encode_uint8(base, idx, reg->num_sn);
|
||||||
|
|
||||||
|
#if 0 /* FIX fcarli3 */
|
||||||
if (reg->num_sn > 0) {
|
if (reg->num_sn > 0) {
|
||||||
/* We only support 0 or 1 at this stage */
|
/* We only support 0 or 1 at this stage */
|
||||||
retval += encode_sock(base, idx, &(reg->sn_bak));
|
retval += encode_sock(base, idx, &(reg->sn_bak));
|
||||||
retval += encode_mac(base, idx, reg->mac_addr);
|
retval += encode_mac(base, idx, reg->mac_addr);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
@ -434,11 +437,14 @@ int decode_REGISTER_SUPER_ACK(n2n_REGISTER_SUPER_ACK_t *reg,
|
||||||
|
|
||||||
/* Following the edge socket are an array of backup supernodes. */
|
/* Following the edge socket are an array of backup supernodes. */
|
||||||
retval += decode_uint8(&(reg->num_sn), base, rem, idx);
|
retval += decode_uint8(&(reg->num_sn), base, rem, idx);
|
||||||
|
|
||||||
|
#if 0 /* FIX fcarli3 */
|
||||||
if (reg->num_sn > 0) {
|
if (reg->num_sn > 0) {
|
||||||
/* We only support 0 or 1 at this stage */
|
/* We only support 0 or 1 at this stage */
|
||||||
retval += decode_sock(&(reg->sn_bak), base, rem, idx);
|
retval += decode_sock(&(reg->sn_bak), base, rem, idx);
|
||||||
retval += decode_mac(reg->mac_addr, base, rem, idx);
|
retval += decode_mac(reg->mac_addr, base, rem, idx);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user