]> git.ipfire.org Git - thirdparty/mtr.git/commitdiff
mtr v0.46 v0.46
authorRoger Wolff <r.e.wolff@bitwizard.nl>
Sun, 10 Feb 2002 00:00:00 +0000 (00:00 +0000)
committerTravis Cross <tc@traviscross.com>
Sun, 3 Feb 2013 20:45:37 +0000 (20:45 +0000)
 - Included patch to be able to specify outgoing interface address.

source: ftp://ftp.bitwizard.nl/mtr/mtr-0.46.tar.gz

AUTHORS
ChangeLog
NEWS
configure.in
dns.c
mtr.8
mtr.c

diff --git a/AUTHORS b/AUTHORS
index f03cc5b74d960754640bbe25c1ccbfc76c6b632f..981965edecb4d57a62829e3ebd69b342586adc18 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -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.
index b19c0af16412c02012b5a0ab670147e9f6b797ec..0c91c59d5befdd6343f8ac7f5a829482d1ae5b6a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,6 @@
+2002-02-09  bodq  <bohdan@vstu.edu.ua>
+       * Added --address option to bind to given IP addess
+
 2001-04-15  root  <alane@geeksrus.net>
 
        * Added this file so that automake won't complain.
diff --git a/NEWS b/NEWS
index f18afb979311d6df3469aa96487c3a4089d35b47..43b825ff20bf8eab5faf2a55926a2d10d3f906f9 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -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
index 1682e996d334849a71898b02e3dad1c8b4eaa81e..06bfb447b21b0cbdb79afc5b8ab5c541a4333725 100644 (file)
@@ -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 --git a/dns.c b/dns.c
index b93fa0dd53125e1f916f5922f13d84e238313eac..fdcb0696395ad6640c3e3b6fbea101dc28375304 100644 (file)
--- a/dns.c
+++ b/dns.c
@@ -982,7 +982,7 @@ void parserespacket(byte *s,int l){
                   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 @@ void parserespacket(byte *s,int l){
                            }
                            break;
                         case T_PTR:
+                        case T_CNAME:
                            *namestring = '\0';
                            r = dn_expand(s,s + l,c,namestring,MAXDNAME);
                            if (r == -1){
@@ -1029,6 +1030,10 @@ void parserespacket(byte *s,int l){
                               failrp(rp);
                               return;
                            }
+                           if (datatype == T_CNAME){
+                              strcpy(stackstring,namestring);
+                              break;
+                           }
                            if (!rp->hostname){
                               rp->hostname = (char *)statmalloc(strlen(namestring) + 1);
                               if (!rp->hostname){
diff --git a/mtr.8 b/mtr.8
index d9f416c5a7de09d9a1c0c54c1f5d3200e54a57de..91d87df14eee0404cf52f1172213d8837f11c24b 100644 (file)
--- a/mtr.8
+++ b/mtr.8
@@ -38,6 +38,9 @@ mtr \- a network diagnostic tool
 .B \-\-gtk\c
 ]
 [\c
+.B \-\-address\ IP.ADD.RE.SS\c
+]
+[\c
 .B \-\-interval\ SECONDS\c
 ]
 [\c
@@ -182,6 +185,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
 .TP
diff --git a/mtr.c b/mtr.c
index 8ad4f0e6d84303863f9f38069376b2404eda5292..5f53549b583503c4231291b4ae35d7b7d011c777 100644 (file)
--- a/mtr.c
+++ b/mtr.c
@@ -44,6 +44,7 @@ int PrintHelp = 0;
 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 @@ void parse_arg(int argc, char **argv) {
     { "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 @@ void parse_arg(int argc, char **argv) {
     case 't':
       DisplayMode = DisplayCurses;
       break;
+    case 'a':
+      InterfaceAddress = optarg;
+      break;
     case 'g':
       DisplayMode = DisplayGTK;
       break;
@@ -184,7 +189,7 @@ int main(int argc, char **argv) {
   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 @@ int main(int argc, char **argv) {
   }
 
 
+  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