Simon Kirby
Christophe Kalt
Steve Kann (stevek@spheara.horizonlive.com)
+ Brett Johnson (brett@jdacareers.com)
Damian Gryski (dgryski@uwaterloo.ca)
Mircea Damian
Cougar (cougar@random.ee)
sbin_PROGRAMS = mtr
man_MANS = mtr.8
install-exec-am:
- chmod u+s $(sbindir)/mtr
+ chmod u+s $(DESTDIR)$(sbindir)/mtr
mtr_SOURCES = mtr.c \
net.c net.h \
WHAT'S NEW?
+ v0.52 Mostly cleanups from Brett Johnson on MacOS X. It may
+ clean up some compilation problems on MacOS X as well.
+
v0.51 Fixed the bug introduced by the previous select loop fix...
Thanks Evgeniy
AC_INIT(mtr.c)
-AM_INIT_AUTOMAKE(mtr, 0.51)
+AM_INIT_AUTOMAKE(mtr, 0.52)
AC_SUBST(GTK_OBJ)
AC_SUBST(CURSES_OBJ)
#ifndef NO_CURSES
#include <ctype.h>
#include <stdlib.h>
+#include <string.h>
#if defined(HAVE_NCURSES_H)
# include <ncurses.h>
void mtr_fill_graph(int at, int cols) {
int* saved;
int i;
- int val;
saved = net_saved_pings(at);
for (i = SAVED_PINGS-cols; i < SAVED_PINGS; i++) {
*/
#include <config.h>
+#include <stdio.h>
#include "display.h"
#include "mtr-curses.h"
#include "mtr-gtk.h"
#include "report.h"
#include "select.h"
+#include "raw.h"
extern int DisplayMode;
#define mtr_curses_redraw()
#define mtr_curses_keyaction()
#define mtr_curses_clear()
+#else
+#include "mtr-curses.h"
#endif
#ifdef NO_GTK
#define gtk_open()
#define gtk_close()
#define gtk_redraw()
-#define gtk_keyaction()
-#define gtk_loop()
+#define gtk_keyaction() 0
+#define gtk_loop() {fprintf (stderr, "No GTK support. Sorry.\n"); exit (1); }
+#else
+#include "mtr-gtk.h"
#endif
#ifdef NO_SPLIT
#define split_close()
#define split_redraw()
#define split_keyaction() 0
+#else
+#include "split.h"
#endif
void display_detect(int *argc, char ***argv) {
mallocsize = size + TOT_SLACK * sizeof(dword);
p = malloc(mallocsize);
- if (!p){
- fprintf(stderr,"malloc() of %u bytes failed: %s\n",size,strerror(errno));
+ if (!p) {
+ fprintf(stderr,"malloc() of %u bytes failed: %s\n", (unsigned int)size, strerror(errno));
exit(-1);
}
*((dword *)p) = (dword)size;
void unlinkresolveid(struct resolve *rp){
dword bashnum;
bashnum = getidbash(rp->id);
- if (idbash[bashnum] == rp)
- if (rp->previousid)
- idbash[bashnum] = rp->previousid;
- else
- idbash[bashnum] = rp->nextid;
+ if (idbash[bashnum] == rp)
+ idbash[bashnum] = (rp->previousid)? rp->previousid : rp->nextid;
if (rp->nextid)
rp->nextid->previousid = rp->previousid;
if (rp->previousid)
dword bashnum;
bashnum = gethostbash(rp->hostname);
if (hostbash[bashnum] == rp)
- if (rp->previoushost)
- hostbash[bashnum] = rp->previoushost;
- else
- hostbash[bashnum] = rp->nexthost;
+ hostbash[bashnum] = (rp->previoushost)? rp->previoushost : rp->nexthost;
if (rp->nexthost)
rp->nexthost->previoushost = rp->previoushost;
if (rp->previoushost)
dword bashnum;
bashnum = getipbash(rp->ip);
if (ipbash[bashnum] == rp)
- if (rp->previousip)
- ipbash[bashnum] = rp->previousip;
- else
- ipbash[bashnum] = rp->nextip;
+ ipbash[bashnum] = (rp->previousip)? rp->previousip : rp->nextip;
if (rp->nextip)
rp->nextip->previousip = rp->previousip;
if (rp->previousip)
packetheader *hp;
int r,i;
int buf[(MaxPacketsize/sizeof (int))+1];
- r = res_mkquery(QUERY,s,C_IN,type,NULL,0,NULL,buf,MaxPacketsize);
+ r = res_mkquery(QUERY,s,C_IN,type,NULL,0,NULL,(unsigned char*)buf,MaxPacketsize);
if (r == -1){
restell("Resolver error: Query too large.");
return;
}
int istime(double x,double *sinterval){
- if (x)
- if (x > sweeptime){
+ if (x) {
+ if (x > sweeptime) {
if (*sinterval > x - sweeptime)
*sinterval = x - sweeptime;
} else
return 1;
- return 0;
+ }
+ return 0;
}
void dns_events(double *sinterval){
#endif
#include <stdio.h>
+#include <string.h>
/* Comment out all this code if we are using the GNU C Library, and are not
actually compiling the library itself. This code is part of the GNU C
const struct option *pfound = NULL;
int exact = 0;
int ambig = 0;
- int indfound;
+ int indfound = 0;
int option_index;
for (nameend = nextchar; *nameend && *nameend != '='; nameend++)
optarg = nameend + 1;
else
{
- if (opterr)
+ if (opterr) {
if (argv[optind - 1][1] == '-')
/* --option */
fprintf (stderr,
fprintf (stderr,
_("%s: option `%c%s' doesn't allow an argument\n"),
argv[0], argv[optind - 1][0], pfound->name);
-
+ }
nextchar += strlen (nextchar);
return '?';
}
if (net_up(row)) {
gdk_color_black(cmap, &color);
} else {
- color.red = 0xffffff;
+ color.red = 0xffff;
color.green = 0;
color.blue = 0;
}
.B mtr
runs on and
.BR HOSTNAME .
-After it determines the address of each network hop between the
-machines, it sends a sequence ICMP ECHO requests to each one to
-determine the quality of the link to each machine. As it does this,
-it prints running statistics about each machine.
-
+by sending packets with purposly low TTLs. It continues to send
+packets with low TTL, noting the response time of the intervening
+routers. This allows
+.B mtr
+to print the response percentage and response times of the internet
+route to
+.BR HOSTNAME .
+A sudden increase in packetloss or response time is often an indication
+of a bad (or simply overloaded) link.
.SH OPTIONS
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+#include <sys/types.h>
#include <config.h>
#include <netdb.h>
#include <stdio.h>
#include <string.h>
#include <netinet/in.h>
#include <sys/socket.h>
+#include <unistd.h>
#include "mtr-curses.h"
#include "getopt.h"
{
int argc;
char *argv[128], *p;
- int i;
if (!string) return;
if(InterfaceAddress) { /* Mostly borrowed from ping(1) code */
- struct sockaddr_in source;
int i1, i2, i3, i4;
char dummy;
- extern int sendsock; /* from net.c:115 */
+ extern int sendsock; /* from net.c:118 */
+ extern struct sockaddr_in sourceaddress; /* from net.c:120 */
- bzero(&source, sizeof(source)); /* -- Evgeniy Tretyak */
-
- source.sin_family = AF_INET;
- source.sin_port = 0;
+ sourceaddress.sin_family = AF_INET;
+ sourceaddress.sin_port = 0;
+ sourceaddress.sin_addr.s_addr = 0;
if(sscanf(InterfaceAddress, "%u.%u.%u.%u%c", &i1, &i2, &i3, &i4, &dummy) != 4) {
printf("mtr: bad interface address: %s\n", InterfaceAddress);
exit(1);
} else {
unsigned char*ptr;
- ptr = (unsigned char*)&source.sin_addr;
+ ptr = (unsigned char*)&sourceaddress.sin_addr;
ptr[0] = i1;
ptr[1] = i2;
ptr[2] = i3;
ptr[3] = i4;
}
- if(bind(sendsock, (struct sockaddr*)&source, sizeof(source)) == -1) {
+ if(bind(sendsock, (struct sockaddr*)&sourceaddress, sizeof(sourceaddress)) == -1) {
perror("mtr: failed to bind to interface");
exit(1);
}
#include <errno.h>
#include "net.h"
-
+#include "display.h"
#define MaxTransit 4
#define SOL_IP 0
#endif
-
+#define saddr_correction(addr) BSDfix ? addr : 0
struct nethost {
uint32 addr;
int timestamp;
int sendsock;
int recvsock;
+struct sockaddr_in sourceaddress;
struct sockaddr_in remoteaddress;
static int batch_at = 0;
ip->frag = 0;
ip->ttl = index + 1;
ip->protocol = IPPROTO_ICMP;
- ip->saddr = 0;
+ /* BSD needs the source address here, Linux & others do not... */
+ ip->saddr = saddr_correction(sourceaddress.sin_addr.s_addr);
ip->daddr = remoteaddress.sin_addr.s_addr;
icmp->type = ICMP_ECHO;
struct sockaddr_in fromaddr;
int fromaddrsize;
int num;
- int at;
struct ICMPHeader *header;
struct timeval now;
int net_percent(int at);
int net_best(int at);
int net_worst(int at);
+int net_last(int at);
int net_avg(int at);
int net_send_batch();
void net_end_transit();
#include <config.h>
#include <sys/types.h>
#include <sys/time.h>
+#include <stdlib.h>
+#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/select.h>
int NumPing;
int paused;
struct timeval lasttime, thistime, selecttime;
- float wt;
int dt;
int rv;
#include <ctype.h>
#include <stdlib.h>
#include <stdio.h>
+#include <string.h>
#include "display.h"
#include "dns.h"
-/*
+
#include "net.h"
#include "split.h"
-*/
+
#include <config.h>