diff options
-rw-r--r-- | Changelog | 6 | ||||
-rw-r--r-- | INSTALL | 15 | ||||
-rw-r--r-- | libbb/Makefile | 4 | ||||
-rw-r--r-- | libbb/interface.c | 197 | ||||
-rw-r--r-- | networking/ifconfig.c | 12 | ||||
-rw-r--r-- | networking/netstat.c | 33 | ||||
-rw-r--r-- | networking/nslookup.c | 10 | ||||
-rw-r--r-- | networking/route.c | 69 | ||||
-rw-r--r-- | networking/telnet.c | 38 | ||||
-rw-r--r-- | networking/traceroute.c | 15 |
10 files changed, 94 insertions, 305 deletions
@@ -26,7 +26,11 @@ * Magick -- made init run inittab command's in the order they show up in the inittab file (FIFO instead of LIFO). - + * Vladimir Oleynik + -- reverse resolve network name and cache in route and ifconfig + applets, fix print nslookup server name if compile without + uClibc, fix route crashe 'route add', fix warnings compile + networking and pwd_grp applets -Erik Andersen, --not yet released-- @@ -1,8 +1,13 @@ -1) Check Config.h and adjust if you need a different functionality than - defined by default. +1) Run 'make config' or 'make menuconfig' and select the + functionality that you wish to enable. -2) Check the Makefile +2) make dep -3) make +3) Check the Makefile for any Makefile setting you wish + to adjust for your system (things like like setting + your cross compiler, adjusting optimizations, etc) -4) make install +4) make + +5) Run 'make install' or 'make PREFIX=/target install' to + install busybox and all the needed links. diff --git a/libbb/Makefile b/libbb/Makefile index f4f2d857f..ef8fef4b7 100644 --- a/libbb/Makefile +++ b/libbb/Makefile @@ -45,7 +45,7 @@ obj-y += ask_confirmation.o chomp.o concat_path_file.o copy_file.o \ xgetcwd.o xreadlink.o xregcomp.o interface.o remove_file.o last_char_is.o \ copyfd.o vherror_msg.o herror_msg.o herror_msg_and_die.o xgethostbyname.o \ dirname.o make_directory.o create_icmp_socket.o u_signal_names.o arith.o \ - simplify_path.o $(LIBBB_MOBJS) $(LIBBB_AROBJS) + simplify_path.o inet_common.o $(LIBBB_MOBJS) $(LIBBB_AROBJS) # Hand off to toplevel Rules.mak @@ -65,5 +65,3 @@ loop.h: mk_loop_h.sh clean: rm -f $(L_TARGET) *.o core - - diff --git a/libbb/interface.c b/libbb/interface.c index 680216a57..9ecb81b9f 100644 --- a/libbb/interface.c +++ b/libbb/interface.c @@ -15,7 +15,7 @@ * that either displays or sets the characteristics of * one or more of the system's networking interfaces. * - * Version: $Id: interface.c,v 1.6 2001/10/27 03:28:19 andersen Exp $ + * Version: $Id: interface.c,v 1.7 2001/11/10 11:22:46 andersen Exp $ * * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org> * and others. Copyright 1993 MicroWalt Corporation @@ -62,26 +62,17 @@ #undef HAVE_HWSLIP -#include <features.h> -#include <sys/types.h> -#include <sys/socket.h> -#include <sys/ioctl.h> -#include <netinet/in.h> -#include <net/if.h> -#include <net/if_arp.h> +#include "inet_common.h" #include <stdio.h> #include <errno.h> -#include <fcntl.h> -#include <ctype.h> #include <stdlib.h> #include <string.h> #include <unistd.h> -#include <netdb.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#if 0 -#include <arpa/nameser.h> -#endif +#include <fcntl.h> +#include <ctype.h> +#include <sys/ioctl.h> +#include <net/if.h> +#include <net/if_arp.h> #include "libbb.h" #define _(x) x @@ -91,7 +82,6 @@ static int procnetdev_vsn = 1; - /* Ugh. But libc5 doesn't provide POSIX types. */ #include <asm/types.h> @@ -124,15 +114,6 @@ struct in6_ifreq { #include "ipx.h" #endif #endif -#if 0 -#include "net-support.h" -#include "pathnames.h" -#include "version.h" -#include "../intl.h" -#include "interface.h" -#include "sockets.h" -#include "util.h" -#endif /* Defines for glibc2.0 users. */ #ifndef SIOCSIFTXQLEN @@ -313,170 +294,6 @@ static struct aftype unix_aftype = #if HAVE_AFINET -#if 0 -extern int h_errno; /* some netdb.h versions don't export this */ -#endif - -/* cache */ -struct addr { - struct sockaddr_in addr; - char *name; - int host; - struct addr *next; -}; - -static struct addr *INET_nn = NULL; /* addr-to-name cache */ - -#ifdef KEEP_UNUSED -static int INET_resolve(char *name, struct sockaddr_in *sin, int hostfirst) -{ - struct hostent *hp; - struct netent *np; - - /* Grmpf. -FvK */ - sin->sin_family = AF_INET; - sin->sin_port = 0; - - /* Default is special, meaning 0.0.0.0. */ - if (!strcmp(name, "default")) { - sin->sin_addr.s_addr = INADDR_ANY; - return (1); - } - /* Look to see if it's a dotted quad. */ - if (inet_aton(name, &sin->sin_addr)) { - return 0; - } - /* If we expect this to be a hostname, try hostname database first */ -#ifdef DEBUG - if (hostfirst) fprintf (stderr, "gethostbyname (%s)\n", name); -#endif - if (hostfirst && - (hp = gethostbyname(name)) != (struct hostent *) NULL) { - memcpy((char *) &sin->sin_addr, (char *) hp->h_addr_list[0], - sizeof(struct in_addr)); - return 0; - } - /* Try the NETWORKS database to see if this is a known network. */ -#ifdef DEBUG - fprintf (stderr, "getnetbyname (%s)\n", name); -#endif - if ((np = getnetbyname(name)) != (struct netent *) NULL) { - sin->sin_addr.s_addr = htonl(np->n_net); - return 1; - } - if (hostfirst) { - /* Don't try again */ - errno = h_errno; - return -1; - } -#ifdef DEBUG - res_init(); - _res.options |= RES_DEBUG; -#endif - -#ifdef DEBUG - fprintf (stderr, "gethostbyname (%s)\n", name); -#endif - if ((hp = gethostbyname(name)) == (struct hostent *) NULL) { - errno = h_errno; - return -1; - } - memcpy((char *) &sin->sin_addr, (char *) hp->h_addr_list[0], - sizeof(struct in_addr)); - - return 0; -} -#endif /* KEEP_UNUSED */ - -/* numeric: & 0x8000: default instead of *, - * & 0x4000: host instead of net, - * & 0x0fff: don't resolve - */ -static int INET_rresolve(char *name, size_t len, struct sockaddr_in *s_in, - int numeric, unsigned int netmask) -{ - struct hostent *ent; - struct netent *np; - struct addr *pn; - unsigned long ad, host_ad; - int host = 0; - - /* Grmpf. -FvK */ - if (s_in->sin_family != AF_INET) { -#ifdef DEBUG - fprintf(stderr, _("rresolve: unsupport address family %d !\n"), s_in->sin_family); -#endif - errno = EAFNOSUPPORT; - return (-1); - } - ad = (unsigned long) s_in->sin_addr.s_addr; -#ifdef DEBUG - fprintf (stderr, "rresolve: %08lx, mask %08x, num %08x \n", ad, netmask, numeric); -#endif - if (ad == INADDR_ANY) { - if ((numeric & 0x0FFF) == 0) { - if (numeric & 0x8000) - safe_strncpy(name, "default", len); - else - safe_strncpy(name, "*", len); - return (0); - } - } - if (numeric & 0x0FFF) { - safe_strncpy(name, inet_ntoa(s_in->sin_addr), len); - return (0); - } - - if ((ad & (~netmask)) != 0 || (numeric & 0x4000)) - host = 1; -#if 0 - INET_nn = NULL; -#endif - pn = INET_nn; - while (pn != NULL) { - if (pn->addr.sin_addr.s_addr == ad && pn->host == host) { - safe_strncpy(name, pn->name, len); -#ifdef DEBUG - fprintf (stderr, "rresolve: found %s %08lx in cache\n", (host? "host": "net"), ad); -#endif - return (0); - } - pn = pn->next; - } - - host_ad = ntohl(ad); - np = NULL; - ent = NULL; - if (host) { -#ifdef DEBUG - fprintf (stderr, "gethostbyaddr (%08lx)\n", ad); -#endif - ent = gethostbyaddr((char *) &ad, 4, AF_INET); - if (ent != NULL) - safe_strncpy(name, ent->h_name, len); - } else { -#ifdef DEBUG - fprintf (stderr, "getnetbyaddr (%08lx)\n", host_ad); -#endif -#if 0 - np = getnetbyaddr(host_ad, AF_INET); - if (np != NULL) - safe_strncpy(name, np->n_name, len); -#endif - } - if ((ent == NULL) && (np == NULL)) - safe_strncpy(name, inet_ntoa(s_in->sin_addr), len); - pn = (struct addr *) xmalloc(sizeof(struct addr)); - pn->addr = *s_in; - pn->next = INET_nn; - pn->host = host; - pn->name = (char *) xmalloc(strlen(name) + 1); - strcpy(pn->name, name); - INET_nn = pn; - - return (0); -} - #ifdef KEEP_UNUSED static void INET_reserror(char *text) { diff --git a/networking/ifconfig.c b/networking/ifconfig.c index fe154cf13..0b834e7c7 100644 --- a/networking/ifconfig.c +++ b/networking/ifconfig.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: ifconfig.c,v 1.15 2001/10/28 09:36:48 andersen Exp $ + * $Id: ifconfig.c,v 1.16 2001/11/10 11:22:43 andersen Exp $ * */ @@ -34,14 +34,12 @@ #include <string.h> // strcmp and friends #include <ctype.h> // isdigit and friends #include <stddef.h> /* offsetof */ -#include <sys/types.h> -#include <sys/socket.h> #include <sys/ioctl.h> -#include <netinet/in.h> -#include <arpa/inet.h> -#include <net/if.h> #include <net/if_arp.h> +#include <netinet/in.h> #include <linux/if_ether.h> +#include <net/if.h> +#include "inet_common.h" #include "busybox.h" #ifdef CONFIG_FEATURE_IFCONFIG_SLIP @@ -339,7 +337,7 @@ int ifconfig_main(int argc, char **argv) safe_strncpy(host, *argv, (sizeof host)); sai.sin_family = AF_INET; sai.sin_port = 0; - if (!strcmp(host, "default")) { + if (!strcmp(host, bb_INET_default)) { /* Default is special, meaning 0.0.0.0. */ sai.sin_addr.s_addr = INADDR_ANY; } else if (inet_aton(host, &sai.sin_addr) == 0) { diff --git a/networking/netstat.c b/networking/netstat.c index e33a89a64..28ae9bc32 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -30,10 +30,7 @@ #include <dirent.h> #include <unistd.h> #include <pwd.h> -#include <sys/socket.h> -#include <netinet/in.h> -#include <arpa/inet.h> - +#include "inet_common.h" #include "busybox.h" #define NETSTAT_CONNECTED 0x01 @@ -95,7 +92,7 @@ typedef enum { #define SO_WAITDATA (1<<17) /* wait data to read */ #define SO_NOSPACE (1<<18) /* no space to write */ -char *itoa(unsigned int i) +static char *itoa(unsigned int i) { /* 21 digits plus null terminator, good for 64-bit or smaller ints */ static char local[22]; @@ -108,24 +105,7 @@ char *itoa(unsigned int i) return p + 1; } -char *inet_sprint(struct sockaddr* addr, int num) -{ - char *str; - str=inet_ntoa(((struct sockaddr_in*)addr)->sin_addr); - if (!strcmp(str,"0.0.0.0")) { - str="*"; - } - if (num) - { - } else { - struct hostent *he=gethostbyaddr(&((struct sockaddr_in*)addr)->sin_addr,4,AF_INET); - if (he) - str=he->h_name; - } - return str; -} - -char *get_sname(int port, const char *proto, int num) +static char *get_sname(int port, const char *proto, int num) { char *str=itoa(ntohs(port)); if (num) { @@ -140,10 +120,13 @@ char *get_sname(int port, const char *proto, int num) return str; } -void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int port, char *proto, int numeric) +static void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int port, char *proto, int numeric) { char *port_name; - safe_strncpy(ip_port, inet_sprint(addr, numeric), size); + + INET_rresolve(ip_port, size, (struct sockaddr_in *)addr, + 0x4000 | ((numeric&NETSTAT_NUMERIC) ? 0x0fff : 0), + 0xffffffff); port_name=get_sname(htons(port), proto, numeric); if ((strlen(ip_port) + strlen(port_name)) > 22) ip_port[22 - strlen(port_name)] = '\0'; diff --git a/networking/nslookup.c b/networking/nslookup.c index a1a12d992..81b57cccf 100644 --- a/networking/nslookup.c +++ b/networking/nslookup.c @@ -90,10 +90,10 @@ static int addr_list_fprint(char **h_addr_list) } /* print the results as nslookup would */ -static struct hostent *hostent_fprint(struct hostent *host) +static struct hostent *hostent_fprint(struct hostent *host, const char *server_host) { if (host) { - printf("Name: %s\n", host->h_name); + printf("%s %s\n", server_host, host->h_name); addr_list_fprint(host->h_addr_list); } else { printf("*** Unknown host\n"); @@ -142,7 +142,7 @@ static inline void server_print(void) struct sockaddr_in def = _res.nsaddr_list[0]; char *ip = inet_ntoa(def.sin_addr); - hostent_fprint(gethostbyaddr_wrapper(ip)); + hostent_fprint(gethostbyaddr_wrapper(ip), "Server:"); printf("\n"); } #endif @@ -176,8 +176,8 @@ int nslookup_main(int argc, char **argv) } else { host = xgethostbyname(argv[1]); } - hostent_fprint(host); + hostent_fprint(host, "Name: "); return EXIT_SUCCESS; } -/* $Id: nslookup.c,v 1.26 2001/10/24 04:59:56 andersen Exp $ */ +/* $Id: nslookup.c,v 1.27 2001/11/10 11:22:43 andersen Exp $ */ diff --git a/networking/route.c b/networking/route.c index ee3533100..43180296d 100644 --- a/networking/route.c +++ b/networking/route.c @@ -15,7 +15,7 @@ * Foundation; either version 2 of the License, or (at * your option) any later version. * - * $Id: route.c,v 1.13 2001/09/05 19:32:00 andersen Exp $ + * $Id: route.c,v 1.14 2001/11/10 11:22:43 andersen Exp $ * * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> @@ -23,11 +23,9 @@ #include <sys/types.h> #include <sys/ioctl.h> -#include <sys/socket.h> +#include "inet_common.h" #include <net/route.h> #include <linux/param.h> // HZ -#include <netinet/in.h> -#include <arpa/inet.h> #include <stdio.h> #include <errno.h> #include <fcntl.h> @@ -55,29 +53,6 @@ #define E_INTERN 2 #define E_NOSUPP 1 -/* resolve XXX.YYY.ZZZ.QQQ -> binary */ - -static int -INET_resolve(char *name, struct sockaddr *sa) -{ - struct sockaddr_in *s_in = (struct sockaddr_in *)sa; - - s_in->sin_family = AF_INET; - s_in->sin_port = 0; - - /* Default is special, meaning 0.0.0.0. */ - if (strcmp(name, "default")==0) { - s_in->sin_addr.s_addr = INADDR_ANY; - return 1; - } - /* Look to see if it's a dotted quad. */ - if (inet_aton(name, &s_in->sin_addr)) { - return 0; - } - /* guess not.. */ - return -1; -} - #if defined (SIOCADDRTOLD) || defined (RTF_IRTT) /* route */ #define HAVE_NEW_ADDRT 1 #endif @@ -96,13 +71,16 @@ INET_resolve(char *name, struct sockaddr *sa) #define full_mask(x) (((struct sockaddr_in *)&(x))->sin_addr.s_addr) #endif + + /* add or delete a route depending on action */ static int INET_setroute(int action, int options, char **args) { struct rtentry rt; - char target[128], gateway[128] = "NONE", netmask[128] = "default"; + char target[128], gateway[128] = "NONE"; + const char *netmask = bb_INET_default; int xflag, isnet; int skfd; @@ -117,13 +95,15 @@ INET_setroute(int action, int options, char **args) xflag = 2; args++; } + if (*args == NULL) + show_usage(); safe_strncpy(target, *args++, (sizeof target)); /* Clean out the RTREQ structure. */ memset((char *) &rt, 0, sizeof(struct rtentry)); - if ((isnet = INET_resolve(target, &rt.rt_dst)) < 0) { + if ((isnet = INET_resolve(target, (struct sockaddr_in *)&rt.rt_dst, xflag!=1)) < 0) { error_msg(_("can't resolve %s"), target); return EXIT_FAILURE; /* XXX change to E_something */ } @@ -169,8 +149,8 @@ INET_setroute(int action, int options, char **args) args++; if (!*args || mask_in_addr(rt)) show_usage(); - safe_strncpy(netmask, *args, (sizeof netmask)); - if ((isnet = INET_resolve(netmask, &mask)) < 0) { + netmask = *args; + if ((isnet = INET_resolve(netmask, (struct sockaddr_in *)&mask, 0)) < 0) { error_msg(_("can't resolve netmask %s"), netmask); return E_LOOKUP; } @@ -186,7 +166,7 @@ INET_setroute(int action, int options, char **args) if (rt.rt_flags & RTF_GATEWAY) show_usage(); safe_strncpy(gateway, *args, (sizeof gateway)); - if ((isnet = INET_resolve(gateway, &rt.rt_gateway)) < 0) { + if ((isnet = INET_resolve(gateway, (struct sockaddr_in *)&rt.rt_gateway, 1)) < 0) { error_msg(_("can't resolve gw %s"), gateway); return E_LOOKUP; } @@ -362,7 +342,7 @@ INET_setroute(int action, int options, char **args) #define RTF_REJECT 0x0200 /* Reject route */ #endif -static void displayroutes(void) +static void displayroutes(int noresolve) { char buff[256]; int nl = 0 ; @@ -375,12 +355,17 @@ static void displayroutes(void) char sdest[16], sgw[16]; - FILE *fp = xfopen("/proc/net/route", "r"); + if(noresolve) + noresolve = 0x0fff; + while( fgets(buff, sizeof(buff), fp) != NULL ) { if(nl) { int ifl = 0; + int numeric; + struct sockaddr_in s_addr; + while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0') ifl++; buff[ifl]=0; /* interface */ @@ -412,10 +397,14 @@ static void displayroutes(void) dest.s_addr = d; gw.s_addr = g; mask.s_addr = m; - strcpy(sdest, (dest.s_addr==0 ? "default" : - inet_ntoa(dest))); - strcpy(sgw, (gw.s_addr==0 ? "*" : - inet_ntoa(gw))); + memset(&s_addr, 0, sizeof(struct sockaddr_in)); + s_addr.sin_family = AF_INET; + s_addr.sin_addr = dest; + numeric = noresolve | 0x8000; /* default instead of * */ + INET_rresolve(sdest, sizeof(sdest), &s_addr, numeric, m); + numeric = noresolve | 0x4000; /* host instead of net */ + s_addr.sin_addr = gw; + INET_rresolve(sgw, sizeof(sgw), &s_addr, numeric, m); printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n", sdest, sgw, inet_ntoa(mask), @@ -433,8 +422,8 @@ int route_main(int argc, char **argv) argc--; argv++; - if (*argv == NULL) { - displayroutes(); + if (*argv == NULL || (*(argv+1)==NULL && strcmp(*argv, "-n")==0)) { + displayroutes(*argv != NULL); return EXIT_SUCCESS; } else { /* check verb */ diff --git a/networking/telnet.c b/networking/telnet.c index 57494089d..71479fce4 100644 --- a/networking/telnet.c +++ b/networking/telnet.c @@ -112,7 +112,7 @@ struct Globalvars * Gptr; static struct Globalvars G; #endif -static inline void iacflush() +static inline void iacflush(void) { write(G.netfd, G.iacbuf, G.iaclen); G.iaclen = 0; @@ -121,13 +121,12 @@ static inline void iacflush() /* Function prototypes */ static int getport(char * p); static struct in_addr getserver(char * p); -static int create_socket(); static void setup_sockaddr_in(struct sockaddr_in * addr, int port); static int remote_connect(struct in_addr addr, int port); -static void rawmode(); -static void cookmode(); -static void do_linemode(); -static void will_charmode(); +static void rawmode(void); +static void cookmode(void); +static void do_linemode(void); +static void will_charmode(void); static void telopt(byte c); static int subneg(byte c); #if 0 @@ -147,7 +146,7 @@ static void doexit(int ev) exit(ev); } -static void conescape() +static void conescape(void) { char b; @@ -353,7 +352,7 @@ static void putiac_subopt(byte c, char *str) static char const escapecharis[] = "\r\nEscape character is "; -static void setConMode() +static void setConMode(void) { if (G.telflags & UF_ECHO) { @@ -375,7 +374,7 @@ static void setConMode() /* ******************************* */ -static void will_charmode() +static void will_charmode(void) { G.charmode = CHM_TRY; G.telflags |= (UF_ECHO | UF_SGA); @@ -386,7 +385,7 @@ static void will_charmode() iacflush(); } -static void do_linemode() +static void do_linemode(void) { G.charmode = CHM_TRY; G.telflags &= ~(UF_ECHO | UF_SGA); @@ -405,7 +404,7 @@ static inline void to_notsup(char c) else if (G.telwish == DO) putiac2(WONT, c); } -static inline void to_echo() +static inline void to_echo(void) { /* if server requests ECHO, don't agree */ if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; } @@ -432,7 +431,7 @@ static inline void to_echo() WriteCS(1, "\r\n"); /* sudden modec */ } -static inline void to_sga() +static inline void to_sga(void) { /* daemon always sends will/wont, client do/dont */ @@ -454,7 +453,7 @@ static inline void to_sga() } #ifdef CONFIG_FEATURE_TELNET_TTYPE -static inline void to_ttype() +static inline void to_ttype(void) { /* Tell server we will (or won't) do TTYPE */ @@ -471,10 +470,10 @@ static void telopt(byte c) { switch (c) { - case TELOPT_ECHO: to_echo(c); break; - case TELOPT_SGA: to_sga(c); break; + case TELOPT_ECHO: to_echo(); break; + case TELOPT_SGA: to_sga(); break; #ifdef CONFIG_FEATURE_TELNET_TTYPE - case TELOPT_TTYPE: to_ttype(c); break; + case TELOPT_TTYPE: to_ttype(); break; #endif default: to_notsup(c); break; } @@ -515,12 +514,12 @@ static void fgotsig(int sig) } -static void rawmode() +static void rawmode(void) { tcsetattr(0, TCSADRAIN, &G.termios_raw); } -static void cookmode() +static void cookmode(void) { tcsetattr(0, TCSADRAIN, &G.termios_def); } @@ -650,7 +649,7 @@ static struct in_addr getserver(char * host) return addr; } -static int create_socket() +static int create_socket(void) { return socket(AF_INET, SOCK_STREAM, 0); } @@ -708,4 +707,3 @@ c-basic-offset: 4 tab-width: 4 End: */ - diff --git a/networking/traceroute.c b/networking/traceroute.c index e7d9725af..5bd3ddb0e 100644 --- a/networking/traceroute.c +++ b/networking/traceroute.c @@ -72,11 +72,9 @@ #include <string.h> #include <unistd.h> #include <sys/time.h> -#include <sys/types.h> -#include <sys/socket.h> +#include "inet_common.h" #include <netdb.h> #include <endian.h> -#include <arpa/inet.h> #include <netinet/udp.h> #include <netinet/ip.h> #include <netinet/ip_icmp.h> @@ -228,8 +226,8 @@ static inline void inetname(struct sockaddr_in *from) { char *cp; - struct hostent *hp; static char domain[MAXHOSTNAMELEN + 1]; + char name[MAXHOSTNAMELEN + 1]; static int first = 1; const char *ina; @@ -243,12 +241,11 @@ inetname(struct sockaddr_in *from) } cp = 0; if (!nflag && from->sin_addr.s_addr != INADDR_ANY) { - hp = gethostbyaddr((char *)&(from->sin_addr), sizeof (from->sin_addr), AF_INET); - if (hp) { - if ((cp = strchr(hp->h_name, '.')) && + if(INET_rresolve(name, sizeof(name), from, 0, 0xffffffff) >= 0) { + if ((cp = strchr(name, '.')) && !strcmp(cp + 1, domain)) *cp = 0; - cp = (char *)hp->h_name; + cp = (char *)name; } } ina = inet_ntoa(from->sin_addr); @@ -645,7 +642,7 @@ traceroute_main(argc, argv) } putchar('\n'); if (got_there || unreachable >= nprobes-1) - exit(0); + return 0; } return 0; |