Subject: Re: telnet 0: No address associated with hostname
To: None <hubert.feyrer@informatik.fh-regensburg.de>
From: None <itojun@iijlab.net>
List: tech-net
Date: 07/30/2000 12:42:21
>> 	this is because we switched name resolution code in telnet(1) from
>> 	inet_aton(3) to getaddrinfo(3).  getaddrinfo(3) is specified to take
>> 	full dot-quad only.  do we need to provide backward compatibility
>> 	for this?  if so, we need to perform:
>> 		inet_aton -> inet_ntop -> getaddrinfo
>I sure wouldn't mind backward compatibility. (And compatibility with
>existing systems that allow this syntax, e.g. Solaris)
>IMHO it's better than giving back an error.

	just for reference, the following patch provides backward compatibility.
	i don't think this is needed.

itojun


Index: commands.c
===================================================================
RCS file: /cvsroot/basesrc/usr.bin/telnet/commands.c,v
retrieving revision 1.43
diff -c -r1.43 commands.c
*** commands.c	2000/06/22 06:47:48	1.43
--- commands.c	2000/07/30 03:40:29
***************
*** 2380,2385 ****
--- 2380,2387 ----
  #endif
      char *cmd, *hostp = 0, *portp = 0;
      const char *user = 0;
+     char inet4name[sizeof("255.255.255.255") + 1];
+     struct in_addr in4;
  #ifdef __GNUC__	/* Avoid vfork clobbering */
      (void) &user;
  #endif
***************
*** 2454,2459 ****
--- 2456,2467 ----
  	/* use telnet negotiation if port number/name preceded by minus sign */
  	telnetport = 1;
  	portp++;
+     }
+ 
+     /* backward compatibility against classful notation */
+     if (inet_aton(hostname, &in4) == 1 &&
+ 	inet_ntop(AF_INET, &in4, inet4name, sizeof(inet4name)) != NULL) {
+ 	hostname = inet4name;
      }
  
      memset(&hints, 0, sizeof(hints));