Skip to content

Commit d0fbd85

Browse files
authored
Merge pull request #39 from caleb2h/br_node_uuid_64
Implement 64-bit node uuid
2 parents 1612639 + cab087d commit d0fbd85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+693
-531
lines changed

src/cli/gnb.c

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,26 @@ extern gnb_arg_list_t *gnb_es_arg_list;
5656

5757
extern int is_self_test;
5858

59+
void signal_alrm_handler(int signum){
60+
return;
61+
}
62+
5963
void signal_handler(int signum){
6064

65+
6166
if ( SIGTERM == signum ) {
62-
unlink(gnb_core->conf->pid_file);
63-
exit(0);
67+
goto finish;
6468
}
6569

70+
if ( SIGINT == signum ) {
71+
goto finish;
72+
}
73+
74+
finish:
75+
gnb_core_stop(gnb_core);
76+
unlink(gnb_core->conf->pid_file);
77+
exit(0);
78+
6679
}
6780

6881
static void self_test(){
@@ -84,7 +97,7 @@ static void self_test(){
8497
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST systemd_daemon='%d'\n", gnb_core->conf->systemd_daemon );
8598

8699
if ( 1 == gnb_core->conf->activate_tun && 0 == gnb_core->conf->public_index_service ) {
87-
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST local node=%lu\n", gnb_core->local_node->uuid32);
100+
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST local node=%lu\n", gnb_core->local_node->uuid64);
88101
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST tun ipv4[%s]\n", GNB_ADDR4STR_PLAINTEXT1(&gnb_core->local_node->tun_addr4));
89102
}
90103

@@ -228,10 +241,10 @@ static void self_test(){
228241

229242
node = &ctl_block->node_zone->node[i];
230243

231-
if ( node->uuid32 != ctl_block->core_zone->local_uuid ) {
232-
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST ----- remote node %u -----\n", node->uuid32);
244+
if ( node->uuid64 != ctl_block->core_zone->local_uuid ) {
245+
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST ----- remote node %u -----\n", node->uuid64);
233246
} else {
234-
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST local node %u\n", node->uuid32);
247+
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST local node %u\n", node->uuid64);
235248
}
236249

237250
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST tun_ipv6 %s\n", GNB_ADDR6STR_PLAINTEXT1(&node->tun_ipv6_addr));
@@ -262,7 +275,7 @@ static void self_test(){
262275
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE,"SELF-TEST num of fwd node=%d\n", gnb_core->fwd_node_ring.num);
263276

264277
for ( i=0; i<gnb_core->fwd_node_ring.num; i++ ) {
265-
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST fwd node=%d\n", gnb_core->fwd_node_ring.nodes[i]->uuid32);
278+
GNB_LOG1(gnb_core->log, GNB_LOG_ID_CORE, "SELF-TEST fwd node=%llu\n", gnb_core->fwd_node_ring.nodes[i]->uuid64);
266279
}
267280

268281
for ( i=0; i<gnb_es_arg_list->argc; i++ ) {
@@ -381,8 +394,10 @@ int main (int argc,char *argv[]){
381394

382395
#ifdef __UNIX_LIKE_OS__
383396
signal(SIGPIPE, SIG_IGN);
384-
signal(SIGALRM, signal_handler);
397+
signal(SIGALRM, signal_alrm_handler);
398+
385399
signal(SIGTERM, signal_handler);
400+
signal(SIGINT, signal_handler);
386401

387402
if ( gnb_core->conf->daemon ) {
388403
gnb_daemon();

src/cli/gnb_crypto.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static void show_useage(int argc,char *argv[]){
5151

5252
}
5353

54-
static void create_keypair(uint32_t uuid32, const char *private_key_file, const char *public_key_file){
54+
static void create_keypair(gnb_uuid_t uuid64, const char *private_key_file, const char *public_key_file){
5555

5656
int private_file_fd;
5757
int public_file_fd;
@@ -119,7 +119,7 @@ int main (int argc,char *argv[]){
119119

120120
int opt;
121121

122-
uint32_t uuid32 = 0;
122+
gnb_uuid_t uuid64 = 0;
123123

124124
char *public_key_file = NULL;
125125
char *private_key_file = NULL;
@@ -164,7 +164,7 @@ int main (int argc,char *argv[]){
164164
exit(0);
165165
}
166166

167-
create_keypair(uuid32, private_key_file, public_key_file);
167+
create_keypair(uuid64, private_key_file, public_key_file);
168168

169169
return 0;
170170

src/cli/gnb_ctl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@
3939
#endif
4040

4141

42-
void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t online_opt);
43-
void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid);
42+
void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, gnb_uuid_t in_nodeid, uint8_t online_opt);
43+
void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, gnb_uuid_t in_nodeid, uint8_t online_opt);
4444

4545
static void show_useage(int argc,char *argv[]){
4646

47-
printf("GNB Ctl version 1.4.5.c protocol version 1.4.5\n");
47+
printf("GNB Ctl version 1.5.0.a protocol version 1.5.0\n");
4848

4949
printf("%s\n", GNB_BUILD_STRING);
5050

@@ -76,7 +76,7 @@ int main (int argc,char *argv[]){
7676
uint8_t core_opt = 0;
7777
uint8_t node_status_opt = 0;
7878
uint8_t online_opt = 0;
79-
uint32_t nodeid = 0;
79+
gnb_uuid_t nodeid = 0;
8080

8181
static struct option long_options[] = {
8282

@@ -112,7 +112,7 @@ int main (int argc,char *argv[]){
112112
break;
113113

114114
case 'n':
115-
nodeid = (uint32_t)strtoul(optarg, NULL, 10);
115+
nodeid = (gnb_uuid_t)strtoull(optarg, NULL, 10);
116116
break;
117117

118118
case 'c':
@@ -167,7 +167,7 @@ int main (int argc,char *argv[]){
167167
}
168168

169169
if ( address_opt ) {
170-
gnb_ctl_dump_address_list(ctl_block, nodeid);
170+
gnb_ctl_dump_address_list(ctl_block, nodeid, online_opt);
171171
}
172172

173173

src/cli/gnb_es.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void gnb_start_environment_service(gnb_es_ctx *es_ctx);
7575

7676
static void show_useage(int argc,char *argv[]){
7777

78-
printf("GNB Environment Service version 1.4.5.c protocol version 1.4.5\n");
78+
printf("GNB Environment Service version 1.5.0.a protocol version 1.5.0\n");
7979

8080
printf("%s\n", GNB_BUILD_STRING);
8181

src/ctl/gnb_ctl_dump.c

Lines changed: 30 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
#endif
3838

3939

40-
void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t online_opt){
40+
void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, gnb_uuid_t in_nodeid, uint8_t online_opt){
4141

4242
#define LINE_SIZE 1024
4343
char line_string[LINE_SIZE];
@@ -89,7 +89,7 @@ void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t
8989
goto dump_all_node;
9090
}
9191

92-
if ( 0 != in_nodeid && in_nodeid != node->uuid32 ) {
92+
if ( 0 != in_nodeid && in_nodeid != node->uuid64 ) {
9393
continue;
9494
}
9595

@@ -110,7 +110,7 @@ void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t
110110

111111
printf("\n====================\n");
112112

113-
printf("node %u\n",node->uuid32);
113+
printf("node %llu\n",node->uuid64);
114114
printf("addr4_ping_latency_usec %"PRIu64"\n",node->addr4_ping_latency_usec);
115115
printf("tun_ipv4 %s\n",GNB_ADDR4STR1(&node->tun_addr4));
116116
printf("tun_ipv6 %s\n",GNB_ADDR6STR1(&node->tun_ipv6_addr));
@@ -144,7 +144,7 @@ void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t
144144
printf("crypto_key %s\n",GNB_HEX1_BYTE128(node->crypto_key));
145145
printf("key512 %s\n",GNB_HEX1_BYTE64(node->key512));
146146

147-
if ( node->uuid32 != ctl_block->core_zone->local_uuid ) {
147+
if ( node->uuid64 != ctl_block->core_zone->local_uuid ) {
148148

149149
if ( (node->udp_addr_status & GNB_NODE_STATUS_IPV6_PONG) ) {
150150
printf("ipv6 Direct Point to Point\n");
@@ -171,7 +171,7 @@ void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t
171171
printf("addr6_ping_latency_usec:%"PRIu64"\n", node->addr6_ping_latency_usec);
172172
printf("addr4_ping_latency_usec:%"PRIu64"\n", node->addr4_ping_latency_usec);
173173

174-
printf("detect_count %d\n", node->detect_count);
174+
printf("detect_count %u\n", node->detect_count);
175175

176176
printf("wan_ipv4 %s\n", GNB_SOCKADDR4STR1(&node->udp_sockaddr4));
177177
printf("wan_ipv6 %s\n", GNB_SOCKADDR6STR1(&node->udp_sockaddr6));
@@ -243,7 +243,7 @@ void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t
243243

244244
for ( j=0; j<GNB_UNIFIED_FORWARDING_NODE_ARRAY_SIZE; j++ ) {
245245

246-
wlen = snprintf(p, line_string_len-wlen, "%u,", node->unified_forwarding_node_array[j].uuid32);
246+
wlen = snprintf(p, line_string_len-wlen, "%llu,", node->unified_forwarding_node_array[j].uuid64);
247247

248248
line_string_len -= wlen;
249249

@@ -280,7 +280,7 @@ void gnb_ctl_dump_status(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t
280280
}
281281

282282

283-
void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, uint8_t online_opt) {
283+
void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, gnb_uuid_t in_nodeid, uint8_t online_opt) {
284284

285285
gnb_address_t *gnb_address;
286286

@@ -307,34 +307,32 @@ void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, u
307307
goto dump_all_node_address;
308308
}
309309

310-
if ( 0 != in_nodeid && in_nodeid != node->uuid32 ) {
310+
if ( 0 != in_nodeid && in_nodeid != node->uuid64 ) {
311311
continue;
312312
}
313313

314314
dump_all_node_address:
315315

316-
if ( node->uuid32 == ctl_block->core_zone->local_uuid ) {
317-
printf( "l|%u|%s\n", node->uuid32, GNB_SOCKADDR6STR1(&node->udp_sockaddr6) );
318-
printf( "l|%u|%s\n", node->uuid32, GNB_SOCKADDR4STR1(&node->udp_sockaddr4) );
316+
if ( node->uuid64 == ctl_block->core_zone->local_uuid ) {
317+
printf( "l|%llu|%s\n", node->uuid64, GNB_SOCKADDR6STR1(&node->udp_sockaddr6) );
318+
printf( "l|%llu|%s\n", node->uuid64, GNB_SOCKADDR4STR1(&node->udp_sockaddr4) );
319319
continue;
320320
}
321321

322322
if ( 0 != online_opt && !((GNB_NODE_STATUS_IPV6_PONG | GNB_NODE_STATUS_IPV4_PONG) & node->udp_addr_status) ) {
323323
continue;
324324
}
325325

326-
if ( 0 != online_opt ) {
327-
328-
if ( GNB_NODE_STATUS_IPV6_PONG & node->udp_addr_status ) {
329-
printf( "w|%u|%s\n", node->uuid32, GNB_SOCKADDR6STR1(&node->udp_sockaddr6) );
330-
}
326+
if ( GNB_NODE_STATUS_IPV6_PONG & node->udp_addr_status ) {
327+
printf( "w|%llu|%s\n", node->uuid64, GNB_SOCKADDR6STR1(&node->udp_sockaddr6) );
328+
}
331329

332-
if ( GNB_NODE_STATUS_IPV4_PONG & node->udp_addr_status ) {
333-
printf( "w|%u|%s\n", node->uuid32, GNB_SOCKADDR4STR1(&node->udp_sockaddr4) );
334-
}
330+
if ( GNB_NODE_STATUS_IPV4_PONG & node->udp_addr_status ) {
331+
printf( "w|%llu|%s\n", node->uuid64, GNB_SOCKADDR4STR1(&node->udp_sockaddr4) );
332+
}
335333

334+
if ( 0 != online_opt ) {
336335
continue;
337-
338336
}
339337

340338
available_address6_list = (gnb_address_list_t *)&node->available_address6_list3_block;
@@ -353,9 +351,9 @@ void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, u
353351
}
354352

355353
if ( AF_INET6 == gnb_address->type ) {
356-
printf( "a|%u|%s|%d\n", node->uuid32, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
354+
printf( "a|%llu|%s|%d\n", node->uuid64, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
357355
} else if ( AF_INET == gnb_address->type ) {
358-
printf( "p|%u|%s|%d\n", node->uuid32, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
356+
printf( "p|%llu|%s|%d\n", node->uuid64, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
359357
} else {
360358
continue;
361359
}
@@ -371,9 +369,9 @@ void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, u
371369
}
372370

373371
if ( AF_INET6 == gnb_address->type ) {
374-
printf( "a|%u|%s|%d\n", node->uuid32, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
372+
printf( "a|%llu|%s|%d\n", node->uuid64, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
375373
} else if ( AF_INET == gnb_address->type ) {
376-
printf( "p|%u|%s|%d\n", node->uuid32, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
374+
printf( "p|%llu|%s|%d\n", node->uuid64, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
377375
} else {
378376
continue;
379377
}
@@ -389,9 +387,9 @@ void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, u
389387
}
390388

391389
if ( AF_INET6 == gnb_address->type ) {
392-
printf( "s|%u|%s|%d\n", node->uuid32, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
390+
printf( "s|%llu|%s|%d\n", node->uuid64, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
393391
} else if ( AF_INET == gnb_address->type ) {
394-
printf( "s|%u|%s|%d\n", node->uuid32, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
392+
printf( "s|%llu|%s|%d\n", node->uuid64, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
395393
} else {
396394
continue;
397395
}
@@ -407,9 +405,9 @@ void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, u
407405
}
408406

409407
if ( AF_INET6 == gnb_address->type ) {
410-
printf( "d|%u|%s|%d\n", node->uuid32, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
408+
printf( "d|%llu|%s|%d\n", node->uuid64, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
411409
} else if ( AF_INET == gnb_address->type ) {
412-
printf( "d|%u|%s|%d\n", node->uuid32, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
410+
printf( "d|%llu|%s|%d\n", node->uuid64, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
413411
} else {
414412
continue;
415413
}
@@ -425,9 +423,9 @@ void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, u
425423
}
426424

427425
if ( AF_INET6 == gnb_address->type ) {
428-
printf( "r|%u|%s|%d\n", node->uuid32, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
426+
printf( "r|%llu|%s|%d\n", node->uuid64, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
429427
} else if ( AF_INET == gnb_address->type ) {
430-
printf( "r|%u|%s|%d\n", node->uuid32, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
428+
printf( "r|%llu|%s|%d\n", node->uuid64, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
431429
} else {
432430
continue;
433431
}
@@ -443,9 +441,9 @@ void gnb_ctl_dump_address_list(gnb_ctl_block_t *ctl_block, uint32_t in_nodeid, u
443441
}
444442

445443
if ( AF_INET6 == gnb_address->type ) {
446-
printf( "p|%u|%s|%d\n", node->uuid32, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
444+
printf( "p|%llu|%s|%d\n", node->uuid64, GNB_ADDR6STR1(&gnb_address->address.addr6), ntohs(gnb_address->port) );
447445
} else if ( AF_INET == gnb_address->type ) {
448-
printf( "p|%u|%s|%d\n", node->uuid32, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
446+
printf( "p|%llu|%s|%d\n", node->uuid64, GNB_ADDR4STR1(&gnb_address->address.addr4), ntohs(gnb_address->port) );
449447
} else {
450448
continue;
451449
}

0 commit comments

Comments
 (0)