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