diff options
author | Eric Andersen | 2001-11-10 11:22:46 +0000 |
---|---|---|
committer | Eric Andersen | 2001-11-10 11:22:46 +0000 |
commit | cd8c436d811a5a077a0b61a6616c900173e2dcfb (patch) | |
tree | 94163bfef63fec4c2638d5f56be310b7176464d7 /networking/netstat.c | |
parent | 94f19a838518293810a0fc0c4dca926ca8caff57 (diff) | |
download | busybox-cd8c436d811a5a077a0b61a6616c900173e2dcfb.zip busybox-cd8c436d811a5a077a0b61a6616c900173e2dcfb.tar.gz |
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
Diffstat (limited to 'networking/netstat.c')
-rw-r--r-- | networking/netstat.c | 33 |
1 files changed, 8 insertions, 25 deletions
diff --git a/networking/netstat.c b/networking/netstat.c index e33a89a..28ae9bc 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'; |