Content-Type: text/plain Content-Disposition: inline Content-Transfer-Encoding: binary MIME-Version: 1.0 X-Mailer: MIME-tools 5.411 (Entity 5.404) X-RT-Original-Encoding: iso-8859-1 Content-Length: 6357 From jhawk@bbnplanet.com Tue Oct 15 20:20:31 1996 Received: from MIT.EDU (PACIFIC-CARRIER-ANNEX.MIT.EDU [18.69.0.28]) by rt-11.MIT.EDU (8.7.5/8.7.3) with SMTP id UAA01844 for ; Tue, 15 Oct 1996 20:20:30 -0400 Received: from all-purpose-gunk.near.net by MIT.EDU with SMTP id AA01788; Tue, 15 Oct 96 20:20:30 EDT Received: (from jhawk@localhost) by all-purpose-gunk.near.net (8.8.0/8.8.0) id UAA26458; Tue, 15 Oct 1996 20:20:23 -0400 (EDT) Message-Id: <199610160020.UAA26458@all-purpose-gunk.near.net> Date: Tue, 15 Oct 1996 20:20:23 -0400 (EDT) From: John Hawkinson To: krb5-bugs@MIT.EDU Subject: telnet should provide the IP address connected to >Number: 113 >Category: telnet >Synopsis: telnet should provide the IP address connected to >Confidential: no >Severity: non-critical >Priority: low >Responsible: hartmans >State: closed >Class: change-request >Submitter-Id: unknown >Arrival-Date: Tue Oct e 20:21:01 EDT 1996 >Last-Modified: Sun Nov 10 21:14:12 EST 1996 >Originator: >Organization: BBN Planet >Release: beta-7 >Environment: System: SunOS all-purpo 4.1.4 4 sun4m Architecture: sun4 >Description: When telnetting to multiple-interfaced hosts (i.e. round robin A records), it's sometimes useful to know which one you've landed on. The current interface can give you this information at connect time, but generally you're more interested in getting it much later. This patch adds support to telnet for keeping track of the current IP address outside of the scope of the tn() function (just like it currently does with "hostname"), and displaying it respone to the "status" command. >How-To-Repeat: umm, scratch your head wondering what IP address you've managed to connect to and decide that running "netstat" is too much trouble or not deterministic enough. >Fix: *** commands.c 1996/10/06 23:21:52 1.2 --- commands.c 1996/10/16 00:01:59 1.3 *************** *** 96,101 **** --- 96,102 ---- char *hostname; static char _hostname[MAXDNAME]; + struct in_addr hostaddr; extern char *getenv(); *************** *** 103,108 **** --- 104,111 ---- extern char **genget(); extern int Ambiguous(); + extern char *inet_ntoa(); + static call(); typedef struct { *************** *** 2156,2162 **** char *argv[]; { if (connected) { ! printf("Connected to %s.\r\n", hostname); if ((argc < 2) || strcmp(argv[1], "notmuch")) { int mode = getconnmode(); --- 2159,2165 ---- char *argv[]; { if (connected) { ! printf("Connected to %s (%s).\r\n", hostname, inet_ntoa(hostaddr)); if ((argc < 2) || strcmp(argv[1], "notmuch")) { int mode = getconnmode(); *************** *** 2240,2246 **** struct sockaddr_in sin; struct servent *sp = 0; unsigned long temp; - extern char *inet_ntoa(); #if defined(IP_OPTIONS) && defined(IPPROTO_IP) char *srp = 0; unsigned long sourceroute(), srlen; --- 2243,2248 ---- *************** *** 2348,2353 **** --- 2350,2356 ---- #if defined(IP_OPTIONS) && defined(IPPROTO_IP) } #endif + hostaddr.s_addr = sin.sin_addr.s_addr; if (portp) { if (*portp == '-') { portp++; >Audit-Trail: From: John Hawkinson To: hartmans@MIT.EDU Cc: krb5-bugs@MIT.EDU Subject: Re: telnet/113: telnet should provide the IP address connected to Date: Sat, 19 Oct 1996 11:00:35 -0400 (EDT) Incidently, Sam asked why this was interesting. Here is an example (please ignore the idiocy that results in this A name binding to multiple ifaces rather than a loopback, though): ---cut [all-purpose-gunk!jhawk] ~> telnet denver-cr1 Trying 4.0.208.249... telnet: connect to address 4.0.208.249: Host is unreachable telnet: connect to address 4.0.208.245: Host is unreachable telnet: connect to address 4.0.208.97: Host is unreachable telnet: connect to address 4.0.208.101: Host is unreachable telnet: connect to address 4.0.208.105: Host is unreachable telnet: connect to address 4.0.208.109: Host is unreachable telnet: connect to address 4.0.208.113: Host is unreachable telnet: connect to address 4.0.208.117: Host is unreachable telnet: connect to address 4.0.208.121: Host is unreachable telnet: connect to address 4.0.208.125: Host is unreachable Encryption is verbose Connected to denver-cr1.bbnplanet.net (4.0.208.249). Escape character is '^]'. ---cut Please note this is with my patch applied. The original telnet code tells you the first IP address it tries, and each failure thereafter, but does not tell you where you have connected to originally (my patch has the side effect of repeating the IP address at you after connection, as the same code is used there as in the "status" command). Arguably the interface should be changed so it prints a Trying a.b.c.d... line prior to each attempt. At this point, I think that would be slightly suboptimal since it would double the lines of output. Perhaps Trying should not print a newline and then the connect() error could be shortened to something not including the ipaddr... I'd still like my patch applied, however, since my desire is to find out the other side's address sometime *after* the initial connection and thus the "Trying..." lines have scrolled off. --jhawk From: John Hawkinson To: krb5-bugs@MIT.EDU Cc: krb5-prs@RT-11.MIT.EDU Subject: Re: telnet/113: telnet should provide the IP address connected to Date: Tue, 29 Oct 1996 23:14:41 -0500 My earlier patch missed the case where connect() fails and telnet moves on to a new IP address -- in that case hostaddr does not get (re-)set so it indicates the IP address first attempted. Here's an addition to my previous patch. *** commands.c 1996/10/16 00:01:59 1.3 --- commands.c 1996/10/30 04:12:43 1.4 *************** *** 2427,2432 **** --- 2427,2434 ---- host->h_addr_list++; memcpy((caddr_t)&sin.sin_addr, host->h_addr_list[0], host->h_length); + memcpy((caddr_t)&hostaddr, + host->h_addr_list[0], host->h_length); (void) NetClose(net); continue; } --jhawk State-Changed-From-To: open-closed State-Changed-By: hartmans State-Changed-When: Sun Nov 10 21:13:44 EST 1996 State-Changed-Why: Applied patch >Unformatted: