X-Git-Url: https://tinc-vpn.org/git/browse?a=blobdiff_plain;f=src%2Finfo.c;h=25d51bff219a83f5a563264f1b9b3839f0361361;hb=d917c8cb6b69475d568ccbe82389b9f2b3eb5e80;hp=ee60a3fe4671c4f2aa9b5f0dd1287b22c9e18ed2;hpb=9ade39b7d5564fb6f5a41946c9a23cfa7851a19f;p=tinc diff --git a/src/info.c b/src/info.c index ee60a3fe..25d51bff 100644 --- a/src/info.c +++ b/src/info.c @@ -28,9 +28,9 @@ void logger(int level, int priority, const char *format, ...) { va_list ap; - va_start(ap, format); - vfprintf(stderr, format, ap); - va_end(ap); + va_start(ap, format); + vfprintf(stderr, format, ap); + va_end(ap); } char *strip_weight(char *netstr) { @@ -56,25 +56,20 @@ static int info_node(int fd, const char *item) { char via[4096]; char nexthop[4096]; int code, req, cipher, digest, maclength, compression, distance; - short int pmtu, minmtu, maxmtu; + short int pmtu, minmtu, maxmtu; unsigned int options; node_status_t status; long int last_state_change; while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s at %s port %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %hd (min %hd max %hd) %ld", &code, &req, node, host, port, &cipher, &digest, &maclength, &compression, &options, (unsigned *)&status, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change); + int n = sscanf(line, "%d %d %s %s port %s %d %d %d %d %x %x %s %s %d %hd %hd %hd %ld", &code, &req, node, host, port, &cipher, &digest, &maclength, &compression, &options, (unsigned *)&status, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change); if(n == 2) break; if(n != 18) { - *port = 0; - n = sscanf(line, "%d %d %s at %s cipher %d digest %d maclength %d compression %d options %x status %04x nexthop %s via %s distance %d pmtu %hd (min %hd max %hd) %ld", &code, &req, node, host, &cipher, &digest, &maclength, &compression, &options, (unsigned *)&status, nexthop, via, &distance, &pmtu, &minmtu, &maxmtu, &last_state_change); - - if(n != 17) { - fprintf(stderr, "Unable to parse node dump from tincd.\n"); - return 1; - } + fprintf(stderr, "Unable to parse node dump from tincd.\n"); + return 1; } if(!strcmp(node, item)) { @@ -92,10 +87,9 @@ static int info_node(int fd, const char *item) { if(sscanf(line, "%d %d %s", &code, &req, node) == 2) break; } - + printf("Node: %s\n", item); - if(*port) - printf("Address: %s port %s\n", host, port); + printf("Address: %s port %s\n", host, port); char timestr[32] = "never"; if(last_state_change) @@ -117,6 +111,8 @@ static int info_node(int fd, const char *item) { printf(" indirect"); if(status.sptps) printf(" sptps"); + if(status.udp_confirmed) + printf(" udp_confirmed"); printf("\n"); printf("Options: "); @@ -150,7 +146,7 @@ static int info_node(int fd, const char *item) { printf("Edges: "); sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_EDGES, item); while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s to %s", &code, &req, from, to); + int n = sscanf(line, "%d %d %s %s", &code, &req, from, to); if(n == 2) break; if(n != 4) { @@ -166,7 +162,7 @@ static int info_node(int fd, const char *item) { printf("Subnets: "); sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_SUBNETS, item); while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s owner %s", &code, &req, subnet, from); + int n = sscanf(line, "%d %d %s %s", &code, &req, subnet, from); if(n == 2) break; if(n != 4) { @@ -201,7 +197,7 @@ static int info_subnet(int fd, const char *item) { sendline(fd, "%d %d %s", CONTROL, REQ_DUMP_SUBNETS, item); while(recvline(fd, line, sizeof line)) { - int n = sscanf(line, "%d %d %s owner %s", &code, &req, netstr, owner); + int n = sscanf(line, "%d %d %s %s", &code, &req, netstr, owner); if(n == 2) break;