aboutsummaryrefslogtreecommitdiff
path: root/networking
diff options
context:
space:
mode:
authorandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-11-10 11:22:46 +0000
committerandersen <andersen@69ca8d6d-28ef-0310-b511-8ec308f3f277>2001-11-10 11:22:46 +0000
commit6513e85b61ee36cc5e699122f0edfbe60d0be104 (patch)
tree94163bfef63fec4c2638d5f56be310b7176464d7 /networking
parent5bf1e9412b3bc8281e5c8cb2a02c5e5b5736c422 (diff)
downloadbusybox-w32-6513e85b61ee36cc5e699122f0edfbe60d0be104.tar.gz
busybox-w32-6513e85b61ee36cc5e699122f0edfbe60d0be104.tar.bz2
busybox-w32-6513e85b61ee36cc5e699122f0edfbe60d0be104.zip
Latest patch from vodz:
-- 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 git-svn-id: svn://busybox.net/trunk/busybox@3645 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'networking')
-rw-r--r--networking/ifconfig.c12
-rw-r--r--networking/netstat.c33
-rw-r--r--networking/nslookup.c10
-rw-r--r--networking/route.c69
-rw-r--r--networking/telnet.c38
-rw-r--r--networking/traceroute.c15
6 files changed, 71 insertions, 106 deletions
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 @@
15 * Foundation; either version 2 of the License, or (at 15 * Foundation; either version 2 of the License, or (at
16 * your option) any later version. 16 * your option) any later version.
17 * 17 *
18 * $Id: ifconfig.c,v 1.15 2001/10/28 09:36:48 andersen Exp $ 18 * $Id: ifconfig.c,v 1.16 2001/11/10 11:22:43 andersen Exp $
19 * 19 *
20 */ 20 */
21 21
@@ -34,14 +34,12 @@
34#include <string.h> // strcmp and friends 34#include <string.h> // strcmp and friends
35#include <ctype.h> // isdigit and friends 35#include <ctype.h> // isdigit and friends
36#include <stddef.h> /* offsetof */ 36#include <stddef.h> /* offsetof */
37#include <sys/types.h>
38#include <sys/socket.h>
39#include <sys/ioctl.h> 37#include <sys/ioctl.h>
40#include <netinet/in.h>
41#include <arpa/inet.h>
42#include <net/if.h>
43#include <net/if_arp.h> 38#include <net/if_arp.h>
39#include <netinet/in.h>
44#include <linux/if_ether.h> 40#include <linux/if_ether.h>
41#include <net/if.h>
42#include "inet_common.h"
45#include "busybox.h" 43#include "busybox.h"
46 44
47#ifdef CONFIG_FEATURE_IFCONFIG_SLIP 45#ifdef CONFIG_FEATURE_IFCONFIG_SLIP
@@ -339,7 +337,7 @@ int ifconfig_main(int argc, char **argv)
339 safe_strncpy(host, *argv, (sizeof host)); 337 safe_strncpy(host, *argv, (sizeof host));
340 sai.sin_family = AF_INET; 338 sai.sin_family = AF_INET;
341 sai.sin_port = 0; 339 sai.sin_port = 0;
342 if (!strcmp(host, "default")) { 340 if (!strcmp(host, bb_INET_default)) {
343 /* Default is special, meaning 0.0.0.0. */ 341 /* Default is special, meaning 0.0.0.0. */
344 sai.sin_addr.s_addr = INADDR_ANY; 342 sai.sin_addr.s_addr = INADDR_ANY;
345 } else if (inet_aton(host, &sai.sin_addr) == 0) { 343 } 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 @@
30#include <dirent.h> 30#include <dirent.h>
31#include <unistd.h> 31#include <unistd.h>
32#include <pwd.h> 32#include <pwd.h>
33#include <sys/socket.h> 33#include "inet_common.h"
34#include <netinet/in.h>
35#include <arpa/inet.h>
36
37#include "busybox.h" 34#include "busybox.h"
38 35
39#define NETSTAT_CONNECTED 0x01 36#define NETSTAT_CONNECTED 0x01
@@ -95,7 +92,7 @@ typedef enum {
95#define SO_WAITDATA (1<<17) /* wait data to read */ 92#define SO_WAITDATA (1<<17) /* wait data to read */
96#define SO_NOSPACE (1<<18) /* no space to write */ 93#define SO_NOSPACE (1<<18) /* no space to write */
97 94
98char *itoa(unsigned int i) 95static char *itoa(unsigned int i)
99{ 96{
100 /* 21 digits plus null terminator, good for 64-bit or smaller ints */ 97 /* 21 digits plus null terminator, good for 64-bit or smaller ints */
101 static char local[22]; 98 static char local[22];
@@ -108,24 +105,7 @@ char *itoa(unsigned int i)
108 return p + 1; 105 return p + 1;
109} 106}
110 107
111char *inet_sprint(struct sockaddr* addr, int num) 108static char *get_sname(int port, const char *proto, int num)
112{
113 char *str;
114 str=inet_ntoa(((struct sockaddr_in*)addr)->sin_addr);
115 if (!strcmp(str,"0.0.0.0")) {
116 str="*";
117 }
118 if (num)
119 {
120 } else {
121 struct hostent *he=gethostbyaddr(&((struct sockaddr_in*)addr)->sin_addr,4,AF_INET);
122 if (he)
123 str=he->h_name;
124 }
125 return str;
126}
127
128char *get_sname(int port, const char *proto, int num)
129{ 109{
130 char *str=itoa(ntohs(port)); 110 char *str=itoa(ntohs(port));
131 if (num) { 111 if (num) {
@@ -140,10 +120,13 @@ char *get_sname(int port, const char *proto, int num)
140 return str; 120 return str;
141} 121}
142 122
143void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int port, char *proto, int numeric) 123static void snprint_ip_port(char *ip_port, int size, struct sockaddr *addr, int port, char *proto, int numeric)
144{ 124{
145 char *port_name; 125 char *port_name;
146 safe_strncpy(ip_port, inet_sprint(addr, numeric), size); 126
127 INET_rresolve(ip_port, size, (struct sockaddr_in *)addr,
128 0x4000 | ((numeric&NETSTAT_NUMERIC) ? 0x0fff : 0),
129 0xffffffff);
147 port_name=get_sname(htons(port), proto, numeric); 130 port_name=get_sname(htons(port), proto, numeric);
148 if ((strlen(ip_port) + strlen(port_name)) > 22) 131 if ((strlen(ip_port) + strlen(port_name)) > 22)
149 ip_port[22 - strlen(port_name)] = '\0'; 132 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)
90} 90}
91 91
92/* print the results as nslookup would */ 92/* print the results as nslookup would */
93static struct hostent *hostent_fprint(struct hostent *host) 93static struct hostent *hostent_fprint(struct hostent *host, const char *server_host)
94{ 94{
95 if (host) { 95 if (host) {
96 printf("Name: %s\n", host->h_name); 96 printf("%s %s\n", server_host, host->h_name);
97 addr_list_fprint(host->h_addr_list); 97 addr_list_fprint(host->h_addr_list);
98 } else { 98 } else {
99 printf("*** Unknown host\n"); 99 printf("*** Unknown host\n");
@@ -142,7 +142,7 @@ static inline void server_print(void)
142 struct sockaddr_in def = _res.nsaddr_list[0]; 142 struct sockaddr_in def = _res.nsaddr_list[0];
143 char *ip = inet_ntoa(def.sin_addr); 143 char *ip = inet_ntoa(def.sin_addr);
144 144
145 hostent_fprint(gethostbyaddr_wrapper(ip)); 145 hostent_fprint(gethostbyaddr_wrapper(ip), "Server:");
146 printf("\n"); 146 printf("\n");
147} 147}
148#endif 148#endif
@@ -176,8 +176,8 @@ int nslookup_main(int argc, char **argv)
176 } else { 176 } else {
177 host = xgethostbyname(argv[1]); 177 host = xgethostbyname(argv[1]);
178 } 178 }
179 hostent_fprint(host); 179 hostent_fprint(host, "Name: ");
180 return EXIT_SUCCESS; 180 return EXIT_SUCCESS;
181} 181}
182 182
183/* $Id: nslookup.c,v 1.26 2001/10/24 04:59:56 andersen Exp $ */ 183/* $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 @@
15 * Foundation; either version 2 of the License, or (at 15 * Foundation; either version 2 of the License, or (at
16 * your option) any later version. 16 * your option) any later version.
17 * 17 *
18 * $Id: route.c,v 1.13 2001/09/05 19:32:00 andersen Exp $ 18 * $Id: route.c,v 1.14 2001/11/10 11:22:43 andersen Exp $
19 * 19 *
20 * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru> 20 * displayroute() code added by Vladimir N. Oleynik <dzo@simtreas.ru>
21 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov> 21 * adjustments by Larry Doolittle <LRDoolittle@lbl.gov>
@@ -23,11 +23,9 @@
23 23
24#include <sys/types.h> 24#include <sys/types.h>
25#include <sys/ioctl.h> 25#include <sys/ioctl.h>
26#include <sys/socket.h> 26#include "inet_common.h"
27#include <net/route.h> 27#include <net/route.h>
28#include <linux/param.h> // HZ 28#include <linux/param.h> // HZ
29#include <netinet/in.h>
30#include <arpa/inet.h>
31#include <stdio.h> 29#include <stdio.h>
32#include <errno.h> 30#include <errno.h>
33#include <fcntl.h> 31#include <fcntl.h>
@@ -55,29 +53,6 @@
55#define E_INTERN 2 53#define E_INTERN 2
56#define E_NOSUPP 1 54#define E_NOSUPP 1
57 55
58/* resolve XXX.YYY.ZZZ.QQQ -> binary */
59
60static int
61INET_resolve(char *name, struct sockaddr *sa)
62{
63 struct sockaddr_in *s_in = (struct sockaddr_in *)sa;
64
65 s_in->sin_family = AF_INET;
66 s_in->sin_port = 0;
67
68 /* Default is special, meaning 0.0.0.0. */
69 if (strcmp(name, "default")==0) {
70 s_in->sin_addr.s_addr = INADDR_ANY;
71 return 1;
72 }
73 /* Look to see if it's a dotted quad. */
74 if (inet_aton(name, &s_in->sin_addr)) {
75 return 0;
76 }
77 /* guess not.. */
78 return -1;
79}
80
81#if defined (SIOCADDRTOLD) || defined (RTF_IRTT) /* route */ 56#if defined (SIOCADDRTOLD) || defined (RTF_IRTT) /* route */
82#define HAVE_NEW_ADDRT 1 57#define HAVE_NEW_ADDRT 1
83#endif 58#endif
@@ -96,13 +71,16 @@ INET_resolve(char *name, struct sockaddr *sa)
96#define full_mask(x) (((struct sockaddr_in *)&(x))->sin_addr.s_addr) 71#define full_mask(x) (((struct sockaddr_in *)&(x))->sin_addr.s_addr)
97#endif 72#endif
98 73
74
75
99/* add or delete a route depending on action */ 76/* add or delete a route depending on action */
100 77
101static int 78static int
102INET_setroute(int action, int options, char **args) 79INET_setroute(int action, int options, char **args)
103{ 80{
104 struct rtentry rt; 81 struct rtentry rt;
105 char target[128], gateway[128] = "NONE", netmask[128] = "default"; 82 char target[128], gateway[128] = "NONE";
83 const char *netmask = bb_INET_default;
106 int xflag, isnet; 84 int xflag, isnet;
107 int skfd; 85 int skfd;
108 86
@@ -117,13 +95,15 @@ INET_setroute(int action, int options, char **args)
117 xflag = 2; 95 xflag = 2;
118 args++; 96 args++;
119 } 97 }
98 if (*args == NULL)
99 show_usage();
120 safe_strncpy(target, *args++, (sizeof target)); 100 safe_strncpy(target, *args++, (sizeof target));
121 101
122 /* Clean out the RTREQ structure. */ 102 /* Clean out the RTREQ structure. */
123 memset((char *) &rt, 0, sizeof(struct rtentry)); 103 memset((char *) &rt, 0, sizeof(struct rtentry));
124 104
125 105
126 if ((isnet = INET_resolve(target, &rt.rt_dst)) < 0) { 106 if ((isnet = INET_resolve(target, (struct sockaddr_in *)&rt.rt_dst, xflag!=1)) < 0) {
127 error_msg(_("can't resolve %s"), target); 107 error_msg(_("can't resolve %s"), target);
128 return EXIT_FAILURE; /* XXX change to E_something */ 108 return EXIT_FAILURE; /* XXX change to E_something */
129 } 109 }
@@ -169,8 +149,8 @@ INET_setroute(int action, int options, char **args)
169 args++; 149 args++;
170 if (!*args || mask_in_addr(rt)) 150 if (!*args || mask_in_addr(rt))
171 show_usage(); 151 show_usage();
172 safe_strncpy(netmask, *args, (sizeof netmask)); 152 netmask = *args;
173 if ((isnet = INET_resolve(netmask, &mask)) < 0) { 153 if ((isnet = INET_resolve(netmask, (struct sockaddr_in *)&mask, 0)) < 0) {
174 error_msg(_("can't resolve netmask %s"), netmask); 154 error_msg(_("can't resolve netmask %s"), netmask);
175 return E_LOOKUP; 155 return E_LOOKUP;
176 } 156 }
@@ -186,7 +166,7 @@ INET_setroute(int action, int options, char **args)
186 if (rt.rt_flags & RTF_GATEWAY) 166 if (rt.rt_flags & RTF_GATEWAY)
187 show_usage(); 167 show_usage();
188 safe_strncpy(gateway, *args, (sizeof gateway)); 168 safe_strncpy(gateway, *args, (sizeof gateway));
189 if ((isnet = INET_resolve(gateway, &rt.rt_gateway)) < 0) { 169 if ((isnet = INET_resolve(gateway, (struct sockaddr_in *)&rt.rt_gateway, 1)) < 0) {
190 error_msg(_("can't resolve gw %s"), gateway); 170 error_msg(_("can't resolve gw %s"), gateway);
191 return E_LOOKUP; 171 return E_LOOKUP;
192 } 172 }
@@ -362,7 +342,7 @@ INET_setroute(int action, int options, char **args)
362#define RTF_REJECT 0x0200 /* Reject route */ 342#define RTF_REJECT 0x0200 /* Reject route */
363#endif 343#endif
364 344
365static void displayroutes(void) 345static void displayroutes(int noresolve)
366{ 346{
367 char buff[256]; 347 char buff[256];
368 int nl = 0 ; 348 int nl = 0 ;
@@ -375,12 +355,17 @@ static void displayroutes(void)
375 355
376 char sdest[16], sgw[16]; 356 char sdest[16], sgw[16];
377 357
378
379 FILE *fp = xfopen("/proc/net/route", "r"); 358 FILE *fp = xfopen("/proc/net/route", "r");
380 359
360 if(noresolve)
361 noresolve = 0x0fff;
362
381 while( fgets(buff, sizeof(buff), fp) != NULL ) { 363 while( fgets(buff, sizeof(buff), fp) != NULL ) {
382 if(nl) { 364 if(nl) {
383 int ifl = 0; 365 int ifl = 0;
366 int numeric;
367 struct sockaddr_in s_addr;
368
384 while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0') 369 while(buff[ifl]!=' ' && buff[ifl]!='\t' && buff[ifl]!='\0')
385 ifl++; 370 ifl++;
386 buff[ifl]=0; /* interface */ 371 buff[ifl]=0; /* interface */
@@ -412,10 +397,14 @@ static void displayroutes(void)
412 dest.s_addr = d; 397 dest.s_addr = d;
413 gw.s_addr = g; 398 gw.s_addr = g;
414 mask.s_addr = m; 399 mask.s_addr = m;
415 strcpy(sdest, (dest.s_addr==0 ? "default" : 400 memset(&s_addr, 0, sizeof(struct sockaddr_in));
416 inet_ntoa(dest))); 401 s_addr.sin_family = AF_INET;
417 strcpy(sgw, (gw.s_addr==0 ? "*" : 402 s_addr.sin_addr = dest;
418 inet_ntoa(gw))); 403 numeric = noresolve | 0x8000; /* default instead of * */
404 INET_rresolve(sdest, sizeof(sdest), &s_addr, numeric, m);
405 numeric = noresolve | 0x4000; /* host instead of net */
406 s_addr.sin_addr = gw;
407 INET_rresolve(sgw, sizeof(sgw), &s_addr, numeric, m);
419 printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n", 408 printf("%-16s%-16s%-16s%-6s%-6d %-2d %7d %s\n",
420 sdest, sgw, 409 sdest, sgw,
421 inet_ntoa(mask), 410 inet_ntoa(mask),
@@ -433,8 +422,8 @@ int route_main(int argc, char **argv)
433 argc--; 422 argc--;
434 argv++; 423 argv++;
435 424
436 if (*argv == NULL) { 425 if (*argv == NULL || (*(argv+1)==NULL && strcmp(*argv, "-n")==0)) {
437 displayroutes(); 426 displayroutes(*argv != NULL);
438 return EXIT_SUCCESS; 427 return EXIT_SUCCESS;
439 } else { 428 } else {
440 /* check verb */ 429 /* 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;
112static struct Globalvars G; 112static struct Globalvars G;
113#endif 113#endif
114 114
115static inline void iacflush() 115static inline void iacflush(void)
116{ 116{
117 write(G.netfd, G.iacbuf, G.iaclen); 117 write(G.netfd, G.iacbuf, G.iaclen);
118 G.iaclen = 0; 118 G.iaclen = 0;
@@ -121,13 +121,12 @@ static inline void iacflush()
121/* Function prototypes */ 121/* Function prototypes */
122static int getport(char * p); 122static int getport(char * p);
123static struct in_addr getserver(char * p); 123static struct in_addr getserver(char * p);
124static int create_socket();
125static void setup_sockaddr_in(struct sockaddr_in * addr, int port); 124static void setup_sockaddr_in(struct sockaddr_in * addr, int port);
126static int remote_connect(struct in_addr addr, int port); 125static int remote_connect(struct in_addr addr, int port);
127static void rawmode(); 126static void rawmode(void);
128static void cookmode(); 127static void cookmode(void);
129static void do_linemode(); 128static void do_linemode(void);
130static void will_charmode(); 129static void will_charmode(void);
131static void telopt(byte c); 130static void telopt(byte c);
132static int subneg(byte c); 131static int subneg(byte c);
133#if 0 132#if 0
@@ -147,7 +146,7 @@ static void doexit(int ev)
147 exit(ev); 146 exit(ev);
148} 147}
149 148
150static void conescape() 149static void conescape(void)
151{ 150{
152 char b; 151 char b;
153 152
@@ -353,7 +352,7 @@ static void putiac_subopt(byte c, char *str)
353 352
354static char const escapecharis[] = "\r\nEscape character is "; 353static char const escapecharis[] = "\r\nEscape character is ";
355 354
356static void setConMode() 355static void setConMode(void)
357{ 356{
358 if (G.telflags & UF_ECHO) 357 if (G.telflags & UF_ECHO)
359 { 358 {
@@ -375,7 +374,7 @@ static void setConMode()
375 374
376/* ******************************* */ 375/* ******************************* */
377 376
378static void will_charmode() 377static void will_charmode(void)
379{ 378{
380 G.charmode = CHM_TRY; 379 G.charmode = CHM_TRY;
381 G.telflags |= (UF_ECHO | UF_SGA); 380 G.telflags |= (UF_ECHO | UF_SGA);
@@ -386,7 +385,7 @@ static void will_charmode()
386 iacflush(); 385 iacflush();
387} 386}
388 387
389static void do_linemode() 388static void do_linemode(void)
390{ 389{
391 G.charmode = CHM_TRY; 390 G.charmode = CHM_TRY;
392 G.telflags &= ~(UF_ECHO | UF_SGA); 391 G.telflags &= ~(UF_ECHO | UF_SGA);
@@ -405,7 +404,7 @@ static inline void to_notsup(char c)
405 else if (G.telwish == DO) putiac2(WONT, c); 404 else if (G.telwish == DO) putiac2(WONT, c);
406} 405}
407 406
408static inline void to_echo() 407static inline void to_echo(void)
409{ 408{
410 /* if server requests ECHO, don't agree */ 409 /* if server requests ECHO, don't agree */
411 if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; } 410 if (G.telwish == DO) { putiac2(WONT, TELOPT_ECHO); return; }
@@ -432,7 +431,7 @@ static inline void to_echo()
432 WriteCS(1, "\r\n"); /* sudden modec */ 431 WriteCS(1, "\r\n"); /* sudden modec */
433} 432}
434 433
435static inline void to_sga() 434static inline void to_sga(void)
436{ 435{
437 /* daemon always sends will/wont, client do/dont */ 436 /* daemon always sends will/wont, client do/dont */
438 437
@@ -454,7 +453,7 @@ static inline void to_sga()
454} 453}
455 454
456#ifdef CONFIG_FEATURE_TELNET_TTYPE 455#ifdef CONFIG_FEATURE_TELNET_TTYPE
457static inline void to_ttype() 456static inline void to_ttype(void)
458{ 457{
459 /* Tell server we will (or won't) do TTYPE */ 458 /* Tell server we will (or won't) do TTYPE */
460 459
@@ -471,10 +470,10 @@ static void telopt(byte c)
471{ 470{
472 switch (c) 471 switch (c)
473 { 472 {
474 case TELOPT_ECHO: to_echo(c); break; 473 case TELOPT_ECHO: to_echo(); break;
475 case TELOPT_SGA: to_sga(c); break; 474 case TELOPT_SGA: to_sga(); break;
476#ifdef CONFIG_FEATURE_TELNET_TTYPE 475#ifdef CONFIG_FEATURE_TELNET_TTYPE
477 case TELOPT_TTYPE: to_ttype(c); break; 476 case TELOPT_TTYPE: to_ttype(); break;
478#endif 477#endif
479 default: to_notsup(c); break; 478 default: to_notsup(c); break;
480 } 479 }
@@ -515,12 +514,12 @@ static void fgotsig(int sig)
515} 514}
516 515
517 516
518static void rawmode() 517static void rawmode(void)
519{ 518{
520 tcsetattr(0, TCSADRAIN, &G.termios_raw); 519 tcsetattr(0, TCSADRAIN, &G.termios_raw);
521} 520}
522 521
523static void cookmode() 522static void cookmode(void)
524{ 523{
525 tcsetattr(0, TCSADRAIN, &G.termios_def); 524 tcsetattr(0, TCSADRAIN, &G.termios_def);
526} 525}
@@ -650,7 +649,7 @@ static struct in_addr getserver(char * host)
650 return addr; 649 return addr;
651} 650}
652 651
653static int create_socket() 652static int create_socket(void)
654{ 653{
655 return socket(AF_INET, SOCK_STREAM, 0); 654 return socket(AF_INET, SOCK_STREAM, 0);
656} 655}
@@ -708,4 +707,3 @@ c-basic-offset: 4
708tab-width: 4 707tab-width: 4
709End: 708End:
710*/ 709*/
711
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 @@
72#include <string.h> 72#include <string.h>
73#include <unistd.h> 73#include <unistd.h>
74#include <sys/time.h> 74#include <sys/time.h>
75#include <sys/types.h> 75#include "inet_common.h"
76#include <sys/socket.h>
77#include <netdb.h> 76#include <netdb.h>
78#include <endian.h> 77#include <endian.h>
79#include <arpa/inet.h>
80#include <netinet/udp.h> 78#include <netinet/udp.h>
81#include <netinet/ip.h> 79#include <netinet/ip.h>
82#include <netinet/ip_icmp.h> 80#include <netinet/ip_icmp.h>
@@ -228,8 +226,8 @@ static inline void
228inetname(struct sockaddr_in *from) 226inetname(struct sockaddr_in *from)
229{ 227{
230 char *cp; 228 char *cp;
231 struct hostent *hp;
232 static char domain[MAXHOSTNAMELEN + 1]; 229 static char domain[MAXHOSTNAMELEN + 1];
230 char name[MAXHOSTNAMELEN + 1];
233 static int first = 1; 231 static int first = 1;
234 const char *ina; 232 const char *ina;
235 233
@@ -243,12 +241,11 @@ inetname(struct sockaddr_in *from)
243 } 241 }
244 cp = 0; 242 cp = 0;
245 if (!nflag && from->sin_addr.s_addr != INADDR_ANY) { 243 if (!nflag && from->sin_addr.s_addr != INADDR_ANY) {
246 hp = gethostbyaddr((char *)&(from->sin_addr), sizeof (from->sin_addr), AF_INET); 244 if(INET_rresolve(name, sizeof(name), from, 0, 0xffffffff) >= 0) {
247 if (hp) { 245 if ((cp = strchr(name, '.')) &&
248 if ((cp = strchr(hp->h_name, '.')) &&
249 !strcmp(cp + 1, domain)) 246 !strcmp(cp + 1, domain))
250 *cp = 0; 247 *cp = 0;
251 cp = (char *)hp->h_name; 248 cp = (char *)name;
252 } 249 }
253 } 250 }
254 ina = inet_ntoa(from->sin_addr); 251 ina = inet_ntoa(from->sin_addr);
@@ -645,7 +642,7 @@ traceroute_main(argc, argv)
645 } 642 }
646 putchar('\n'); 643 putchar('\n');
647 if (got_there || unreachable >= nprobes-1) 644 if (got_there || unreachable >= nprobes-1)
648 exit(0); 645 return 0;
649 } 646 }
650 647
651 return 0; 648 return 0;