diff -ur mtr-0.45/AUTHORS mtr-0.46/AUTHORS --- mtr-0.45/AUTHORS Thu Jan 24 09:30:47 2002 +++ mtr-0.46/AUTHORS Sun Feb 3 20:45:06 2002 @@ -36,7 +36,7 @@ Robert Sparks (rjsparks@nostrum.com) David Stone (stone@AsIf.com) Greg Stark (gsstark@mit.edu) - Andrew Brown (codewarrior@daemon.org ?) + Andrew Brown (atatat@atatdot.net) Marc Bejarano (marc.bejarano@openwave.com) and anyone who has slipped through the cracks of my mail file. diff -ur mtr-0.45/ChangeLog mtr-0.46/ChangeLog --- mtr-0.45/ChangeLog Sat Apr 28 01:32:50 2001 +++ mtr-0.46/ChangeLog Sun Feb 10 00:01:38 2002 @@ -1,3 +1,6 @@ +2002-02-09 bodq + * Added --address option to bind to given IP addess + 2001-04-15 root * Added this file so that automake won't complain. diff -ur mtr-0.45/NEWS mtr-0.46/NEWS --- mtr-0.45/NEWS Wed Jan 23 21:49:57 2002 +++ mtr-0.46/NEWS Sun Feb 10 00:08:56 2002 @@ -1,5 +1,8 @@ WHAT'S NEW? + v0.45 Included patch to be able to specify outgoing interface + address. + v0.45 People are pressuring me to release new versions with their changes. That's fine. Now this version just adds dynamic switching between numeric / dns names, and some minor diff -ur mtr-0.45/configure mtr-0.46/configure --- mtr-0.45/configure Sat Apr 28 01:32:52 2001 +++ mtr-0.46/configure Thu Jan 24 09:33:31 2002 @@ -699,7 +699,7 @@ PACKAGE=mtr -VERSION=0.45 +VERSION=0.46 if test "`cd $srcdir && pwd`" != "`pwd`" && test -f $srcdir/config.status; then { echo "configure: error: source directory already configured; run "make distclean" there first" 1>&2; exit 1; } diff -ur mtr-0.45/configure.in mtr-0.46/configure.in --- mtr-0.45/configure.in Sat Apr 28 01:32:50 2001 +++ mtr-0.46/configure.in Thu Jan 24 09:33:29 2002 @@ -1,5 +1,5 @@ AC_INIT(mtr.c) -AM_INIT_AUTOMAKE(mtr, 0.45) +AM_INIT_AUTOMAKE(mtr, 0.46) AC_SUBST(GTK_OBJ) AC_SUBST(CURSES_OBJ) diff -ur mtr-0.45/dns.c mtr-0.46/dns.c --- mtr-0.45/dns.c Tue Jan 22 00:01:18 2002 +++ mtr-0.46/dns.c Sun Feb 3 20:44:24 2002 @@ -982,7 +982,7 @@ restell("Resolver error: Specified rdata length exceeds packet size."); return; } - if (datatype == qdatatype){ + if (datatype == qdatatype || datatype == T_CNAME){ if (debug){ sprintf(tempstring,"Resolver: TTL: %s",strtdiff(sendstring,ttl)); restell(tempstring); @@ -1014,6 +1014,7 @@ } break; case T_PTR: + case T_CNAME: *namestring = '\0'; r = dn_expand(s,s + l,c,namestring,MAXDNAME); if (r == -1){ @@ -1028,6 +1029,10 @@ restell("Resolver error: Domain name too long."); failrp(rp); return; + } + if (datatype == T_CNAME){ + strcpy(stackstring,namestring); + break; } if (!rp->hostname){ rp->hostname = (char *)statmalloc(strlen(namestring) + 1); diff -ur mtr-0.45/mtr.8 mtr-0.46/mtr.8 --- mtr-0.45/mtr.8 Sat Apr 28 01:32:50 2001 +++ mtr-0.46/mtr.8 Sun Feb 10 00:01:38 2002 @@ -38,6 +38,9 @@ .B \-\-gtk\c ] [\c +.B \-\-address\ IP.ADD.RE.SS\c +] +[\c .B \-\-interval\ SECONDS\c ] [\c @@ -181,6 +184,16 @@ to use the raw output format. This format is better suited for archival of the measurement results. It could be parsed to be presented into any of the other display methods. + +.TP +.B \-a\ IP.ADD.RE.SS +.TP +.B \-\-address\ IP.ADD.RE.SS +.br +Use this option to bind outgoing packets' socket to specific interface, +so that any packet will be sent through this interface. NOTE that this +option doesn't apply to DNS requests (which could be and could not be +what you want). .TP .B \-i\ SECONDS diff -ur mtr-0.45/mtr.c mtr-0.46/mtr.c --- mtr-0.45/mtr.c Sat Apr 28 01:32:50 2001 +++ mtr-0.46/mtr.c Sun Feb 10 00:04:36 2002 @@ -44,6 +44,7 @@ int MaxPing = 16; float WaitTime = 1.0; char *Hostname = NULL; +char *InterfaceAddress = NULL; char LocalHostname[128]; int dns = 1; int packetsize = MINPACKET; @@ -61,13 +62,14 @@ { "psize", 1, 0, 'p' }, { "no-dns", 0, 0, 'n' }, { "split", 0, 0, 's' }, /* BL */ + { "address", 1, 0, 'a' }, { "raw", 0, 0, 'l' }, { 0, 0, 0, 0 } }; opt = 0; while(1) { - opt = getopt_long(argc, argv, "hvrc:tgklnsi:p:", long_options, NULL); + opt = getopt_long(argc, argv, "a:hvrc:tgklnsi:p:", long_options, NULL); if(opt == -1) break; @@ -90,6 +92,9 @@ case 't': DisplayMode = DisplayCurses; break; + case 'a': + InterfaceAddress = optarg; + break; case 'g': DisplayMode = DisplayGTK; break; @@ -184,7 +189,7 @@ if(PrintHelp) { printf("usage: %s [-hvrctglsni] [--help] [--version] [--report]\n" "\t\t[--report-cycles=COUNT] [--curses] [--gtk]\n" - "\t\t[--raw] [--split] [--no-dns]\n" /* BL */ + "\t\t[--raw] [--split] [--no-dns] [--address interface]\n" /* BL */ "\t\t[--psize=bytes/-p=bytes]\n" /* ok */ "\t\t[--interval=SECONDS] HOSTNAME [PACKETSIZE]\n", argv[0]); exit(0); @@ -201,6 +206,33 @@ } + 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 */ + + source.sin_family = AF_INET; + source.sin_port = 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[0] = i1; + ptr[1] = i2; + ptr[2] = i3; + ptr[3] = i4; + } + + if(bind(sendsock, (struct sockaddr*)&source, sizeof(source)) == -1) { + perror("mtr: failed to bind to interface"); + exit(1); + } + } + host = gethostbyname(Hostname); if(host == NULL) { #ifndef NO_HERROR .