1303 files changed, 32187 insertions, 57138 deletions
diff --git a/networking/netstat.c b/networking/netstat.c index f80b845..90da6cd 100644 --- a/networking/netstat.c +++ b/networking/netstat.c @@ -13,6 +13,32 @@ * * Licensed under GPLv2 or later, see file LICENSE in this source tree. */ +//config:config NETSTAT +//config: bool "netstat" +//config: default y +//config: select PLATFORM_LINUX +//config: help +//config: netstat prints information about the Linux networking subsystem. +//config: +//config:config FEATURE_NETSTAT_WIDE +//config: bool "Enable wide netstat output" +//config: default y +//config: depends on NETSTAT +//config: help +//config: Add support for wide columns. Useful when displaying IPv6 addresses +//config: (-W option). +//config: +//config:config FEATURE_NETSTAT_PRG +//config: bool "Enable PID/Program name output" +//config: default y +//config: depends on NETSTAT +//config: help +//config: Add support for -p flag to print out PID and program name. +//config: +700 bytes of code. + +//applet:IF_NETSTAT(APPLET(netstat, BB_DIR_BIN, BB_SUID_DROP)) + +//kbuild:lib-$(CONFIG_NETSTAT) += netstat.o #include "libbb.h" #include "inet_common.h" @@ -119,7 +145,7 @@ typedef enum { #define ADDR_NORMAL_WIDTH 23 /* When there are IPv6 connections the IPv6 addresses will be * truncated to none-recognition. The '-W' option makes the - * address columns wide enough to accomodate for longest possible + * address columns wide enough to accommodate for longest possible * IPv6 addresses, i.e. addresses of the form * xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:ddd.ddd.ddd.ddd */ @@ -228,12 +254,12 @@ static long extract_socket_inode(const char *lname) { long inode = -1; - if (strncmp(lname, "socket:[", sizeof("socket:[")-1) == 0) { + if (is_prefixed_with(lname, "socket:[")) { /* "socket:[12345]", extract the "12345" as inode */ inode = bb_strtoul(lname + sizeof("socket:[")-1, (char**)&lname, 0); if (*lname != ']') inode = -1; - } else if (strncmp(lname, "[0000]:", sizeof("[0000]:")-1) == 0) { + } else if (is_prefixed_with(lname, "[0000]:")) { /* "[0000]:12345", extract the "12345" as inode */ inode = bb_strtoul(lname + sizeof("[0000]:")-1, NULL, 0); if (errno) /* not NUL terminated? */ @@ -622,7 +648,7 @@ static int FAST_FUNC unix_do_one(char *line) /* TODO: currently we stop at first NUL byte. Is it a problem? */ line += path_ofs; - *strchrnul(line, '\n') = '\0'; + chomp(line); while (*line) fputc_printable(*line++, stdout); bb_putchar('\n'); |