#include "mtr.h"
#include "asn.h"
#include "utils.h"
-//#define IIDEBUG
+/* #define IIDEBUG */
#ifdef IIDEBUG
#include <syslog.h>
#define DEB_syslog syslog
static int iihash = 0;
static char fmtinfo[32];
-// items width: ASN, Route, Country, Registry, Allocated
-static const int iiwidth[] = { 7, 19, 4, 8, 11 }; // item len + space
+/* items width: ASN, Route, Country, Registry, Allocated */
+static const int iiwidth[] = { 7, 19, 4, 8, 11 }; /* item len + space */
typedef char* items_t[ITEMSMAX + 1];
-static items_t items_a; // without hash: items
-static char txtrec[NAMELEN + 1]; // without hash: txtrec
+static items_t items_a; /* without hash: items */
+static char txtrec[NAMELEN + 1]; /* without hash: txtrec */
static items_t* items = &items_a;
return txt;
}
-// originX.asn.cymru.com txtrec: ASN | Route | Country | Registry | Allocated
+/* originX.asn.cymru.com txtrec: ASN | Route | Country | Registry | Allocated */
static char* split_txtrec(struct mtr_ctl *ctl, char *txt_rec) {
char* prev;
char* next;
}
#ifdef ENABLE_IPV6
-// from dns.c:addr2ip6arpa()
+/* from dns.c:addr2ip6arpa() */
static void reverse_host6(struct in6_addr *addr, char *buff) {
int i;
char *b = buff;
- for (i=(sizeof(*addr)/2-1); i>=0; i--, b+=4) // 64b portion
+ for (i=(sizeof(*addr)/2-1); i>=0; i--, b+=4) /* 64b portion */
sprintf(b, "%x.%x.", addr->s6_addr[i] & 0xf, addr->s6_addr[i] >> 4);
buff[strlen(buff) - 1] = '\0';
}
*dst++ = ' ';
format_number (n, 5, dst);
} else if (strchr( format, 'f' ) ) {
- // this is for fields where we measure integer microseconds but
- // display floating point miliseconds. Convert to float here.
+ /* this is for fields where we measure integer microseconds but
+ display floating point miliseconds. Convert to float here. */
sprintf(dst, format, n / 1000.0 );
- // this was marked as a temporary hack over 10 years ago. -- REW
+ /* this was marked as a temporary hack over 10 years ago. -- REW */
} else {
sprintf(dst, format, n);
}
static int block_col[NUM_FACTORS+1] =
-{ // 1:black 2:red 3:green 4:brown/yellow 5:blue 6:magenta 7:cyan 8:white
+{ /* 1:black 2:red 3:green 4:brown/yellow 5:blue 6:magenta 7:cyan 8:white */
COLOR_PAIR(2)|A_BOLD,
A_NORMAL,
COLOR_PAIR(3),
int i;
FILE *infp;
- // Automatically reap children.
+ /* Automatically reap children. */
if (signal(SIGCHLD, SIG_IGN) == SIG_ERR) {
error(EXIT_FAILURE, errno, "signal");
}
- // Close all unneccessary FDs.
- // for debugging and error reporting, keep std-in/out/err.
+ /* Close all unneccessary FDs.
+ for debugging and error reporting, keep std-in/out/err. */
for (i=3;i<fromdns[1];i++) {
if (i == todns[0]) continue;
if (i == fromdns[1]) continue;
if (!fork ()) {
int rv;
- buf[strlen(buf)-1] = 0; // chomp newline.
+ buf[strlen(buf)-1] = 0; /* chomp newline. */
longipstr (buf, &host, ctl->af);
set_sockaddr_ip (ctl, &sa, &host);
} else {
int flags;
- // the parent.
- close (todns[0]); // close the pipe ends we don't need.
+ /* the parent. */
+ close (todns[0]); /* close the pipe ends we don't need. */
close (fromdns[1]);
fromdnsfp = fdopen (fromdns[0],"r");
flags = fcntl(fromdns[0], F_GETFL, 0);
r = findip (ctl, ip);
if (r) {
- // we've got a result.
+ /* we've got a result. */
if (r->name)
return r->name;
else
return t;
}
-// XXX check if necessary/exported.
+/* XXX check if necessary/exported. */
/* Resolve an IP address to a hostname. */
extern struct hostent *addr2host( const char *addr, int family ) {
N_COLS
};
-// Trick to cast a pointer to integer.....
-// We are mis-using a pointer as a single integer. On 64-bit
-// architectures, the pointer is 64 bits and the integer only 32.
-// The compiler warns us of loss of precision. However we know we
-// casted a normal 32-bit integer into this pointer a few microseconds
-// earlier, so it is ok. Nothing to worry about....
+/* Trick to cast a pointer to integer. We are mis-using a pointer as a
+ single integer. On 64-bit architectures, the pointer is 64 bits and the
+ integer only 32. The compiler warns us of loss of precision. However we
+ know we casted a normal 32-bit integer into this pointer a few
+ microseconds earlier, so it is ok. Nothing to worry about. */
#define POINTER_TO_INT(p) ((int)(long)(p))
static void float_formatter(GtkTreeViewColumn *tree_column ATTRIBUTE_UNUSED,
gtk_tree_view_set_cursor(GTK_TREE_VIEW(ReportTreeView), path, NULL, FALSE);
- // Single right click: prepare and show the popup menu
+ /* Single right click: prepare and show the popup menu */
popup_menu = gtk_menu_new ();
copy_item = gtk_menu_item_new_with_label ("Copy to clipboard");
error(EXIT_FAILURE, 0, "Couldn't determine raw socket type");
}
- if (!names) append_to_names ("localhost"); // default: localhost.
+ if (!names) append_to_names ("localhost"); /* default: localhost. */
head = names;
while (names != NULL) {
uint32_t seq;
};
-// This ifdef is unnecessary. But it should trigger errors if I forget
-// an ifdef HAS_SCTP further down. (Success! I forgot one and the compiler
-// told me the line number!)
+/* This ifdef is unnecessary. But it should trigger errors if I forget an
+ ifdef HAS_SCTP further down. (Success! I forgot one and the compiler
+ told me the line number!) */
#ifdef HAS_SCTP
/* Structure of an SCTP header */
struct SCTPHeader {
gettimeofday(&sequence[udp->dstport].time, NULL);
udp->dstport = htons(udp->dstport);
} else {
- // keep dstport constant, stuff sequence into the checksum
+ /* keep dstport constant, stuff sequence into the checksum */
udp->dstport = htons(ctl->remoteport);
udp->checksum = new_sequence(ctl, index);
gettimeofday(&sequence[udp->checksum].time, NULL);
#include "dns.h"
-// Log an echo request, or a "ping"
+/* Log an echo request, or a "ping" */
extern void raw_rawxmit (int host, int seq)
{
printf ("x %d %d\n", host, seq);
fflush (stdout);
}
-// Log an echo reply, or a "pong"
+/* Log an echo reply, or a "pong" */
extern void raw_rawping (struct mtr_ctl *ctl, int host, int msec, int seq)
{
static int havename[MaxHost];
if (ctl->reportwide)
{
- // get the longest hostname
+ /* get the longest hostname */
len_hosts = strlen(ctl->LocalHostname);
max = net_max(ctl);
at = net_min(ctl);
if (ctl->ipinfo_no >= 0 && iiwidth_len) {
ctl->ipinfo_no %= iiwidth_len;
if (ctl->reportwide) {
- len_hosts++; // space
+ len_hosts++; /* space */
len_tmp += get_iiwidth(ctl->ipinfo_no);
if (!ctl->ipinfo_no)
- len_tmp += 2; // align header: AS
+ len_tmp += 2; /* align header: AS */
}
}
snprintf( fmt, sizeof(fmt), "HOST: %%-%ds", len_tmp);
printf(",\n");
}
- if (j <= 0) continue; // Field nr 0, " " shouldn't be printed in this method.
+ if (j <= 0) continue; /* Field nr 0, " " shouldn't be printed in this method. */
/* Format value */
format = data_fields[j].format;
const char *title;
j = ctl->fld_index[ctl->fld_active[i]];
- if (j <= 0) continue; // Field nr 0, " " shouldn't be printed in this method.
+ if (j <= 0) continue; /* Field nr 0, " " shouldn't be printed in this method. */
snprintf(name, sizeof(name), "%s%s%s", " <%s>", data_fields[j].format, "</%s>\n");