--- embedaddon/mtr/report.c 2013/07/21 23:43:42 1.1.1.1 +++ embedaddon/mtr/report.c 2016/11/01 09:33:48 1.1.1.2 @@ -16,7 +16,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -#include +#include "config.h" + #include #include #include @@ -31,9 +32,7 @@ #include "report.h" #include "net.h" #include "dns.h" -#ifndef NO_IPINFO #include "asn.h" -#endif #define MAXLOADBAL 5 @@ -77,7 +76,7 @@ static size_t snprint_addr(char *dst, size_t dst_len, } -#ifndef NO_IPINFO +#ifdef IPINFO void print_mpls(struct mplslen *mpls) { int k; for (k=0; k < mpls->labels; k++) @@ -112,7 +111,7 @@ void report_close(void) } } -#ifndef NO_IPINFO +#ifdef IPINFO int len_tmp = len_hosts; if (ipinfo_no >= 0) { ipinfo_no %= iiwidth_len; @@ -146,7 +145,7 @@ void report_close(void) mpls = net_mpls(at); snprint_addr(name, sizeof(name), addr); -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) { snprintf(fmt, sizeof(fmt), " %%2d. %%s%%-%ds", len_hosts); snprintf(buf, sizeof(buf), fmt, at+1, fmt_ipinfo(addr), name); @@ -154,7 +153,7 @@ void report_close(void) #endif snprintf( fmt, sizeof(fmt), " %%2d.|-- %%-%ds", len_hosts); snprintf(buf, sizeof(buf), fmt, at+1, name); -#ifndef NO_IPINFO +#ifdef IPINFO } #endif len = reportwide ? strlen(buf) : len_hosts; @@ -192,7 +191,7 @@ void report_close(void) if (!found) { -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) { if (mpls->labels && z == 1 && enablempls) print_mpls(mpls); @@ -221,14 +220,14 @@ void report_close(void) } } #endif -#ifndef NO_IPINFO +#ifdef IPINFO } #endif } } /* No multipath */ -#ifndef NO_IPINFO +#ifdef IPINFO if (is_printii()) { if (mpls->labels && z == 1 && enablempls) print_mpls(mpls); @@ -241,7 +240,7 @@ void report_close(void) } } #endif -#ifndef NO_IPINFO +#ifdef IPINFO } #endif } @@ -271,19 +270,20 @@ void xml_close(void) ip_t *addr; char name[81]; - printf("\n"); + printf("= 0) { - printf(" PSIZE=%d", cpacketsize); + printf(" PSIZE=\"%d\"", cpacketsize); } else { - printf(" PSIZE=rand(%d-%d)",MINPACKET, -cpacketsize); + printf(" PSIZE=\"rand(%d-%d)\"",MINPACKET, -cpacketsize); } if( bitpattern>=0 ) { - printf(" BITPATTERN=0x%02X", (unsigned char)(bitpattern)); + printf(" BITPATTERN=\"0x%02X\"", (unsigned char)(bitpattern)); } else { - printf(" BITPATTERN=rand(0x00-FF)"); + printf(" BITPATTERN=\"rand(0x00-FF)\""); } - printf(" TESTS=%d>\n", MaxPing); + printf(" TESTS=\"%d\">\n", MaxPing); max = net_max(); at = net_min(); @@ -291,7 +291,7 @@ void xml_close(void) addr = net_addr(at); snprint_addr(name, sizeof(name), addr); - printf(" \n", at+1, name); + printf(" \n", at+1, name); for( i=0; i"); strcat(name, data_fields[j].format); strcat(name, "\n"); + + /* XML doesn't allow "%" in tag names, rename Loss% to just Loss */ + const char *title; + title = data_fields[j].title; + if( strcmp(data_fields[j].title, "Loss%") == 0 ) { + title = "Loss"; + } + /* 1000.0 is a temporay hack for stats usec to ms, impacted net_loss. */ if( index( data_fields[j].format, 'f' ) ) { printf( name, - data_fields[j].title, + title, data_fields[j].net_xxx(at) /1000.0, - data_fields[j].title ); + title ); } else { printf( name, - data_fields[j].title, + title, data_fields[j].net_xxx(at), - data_fields[j].title ); + title ); } } printf(" \n"); @@ -340,15 +348,16 @@ void csv_close(time_t now) snprint_addr(name, sizeof(name), addr); int last = net_last(at); +#ifdef IPINFO if(!ipinfo_no) { char* fmtinfo = fmt_ipinfo(addr); if (fmtinfo != NULL) fmtinfo = trim(fmtinfo); - printf("MTR.%s;%lu;%s;%s;%d;%s;%s;%d", MTR_VERSION, now, "OK", Hostname, + printf("MTR.%s;%lld;%s;%s;%d;%s;%s;%d", MTR_VERSION, (long long)now, "OK", Hostname, at+1, name, fmtinfo, last); - } else { - printf("MTR.%s;%lu;%s;%s;%d;%s;%d", MTR_VERSION, now, "OK", Hostname, + } else +#endif + printf("MTR.%s;%lld;%s;%s;%d;%s;%d", MTR_VERSION, (long long)now, "OK", Hostname, at+1, name, last); - } for( i=0; i