From patchwork Mon Feb 20 17:49:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Stefan Schantl X-Patchwork-Id: 6566 Return-Path: Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by web04.haj.ipfire.org (Postfix) with ESMTPS id 4PL90y6YQmz3x1v for ; Mon, 20 Feb 2023 17:49:54 +0000 (UTC) Received: from mail02.haj.ipfire.org (mail02.haj.ipfire.org [172.28.1.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384 client-signature ECDSA (P-384) client-digest SHA384) (Client CN "mail02.haj.ipfire.org", Issuer "R3" (verified OK)) by mail01.ipfire.org (Postfix) with ESMTPS id 4PL90w1WGpz16Y; Mon, 20 Feb 2023 17:49:52 +0000 (UTC) Received: from mail02.haj.ipfire.org (localhost [127.0.0.1]) by mail02.haj.ipfire.org (Postfix) with ESMTP id 4PL90r4s0lz2xlX; Mon, 20 Feb 2023 17:49:48 +0000 (UTC) Received: from mail01.ipfire.org (mail01.haj.ipfire.org [172.28.1.202]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) client-signature ECDSA (P-384)) (Client CN "mail01.haj.ipfire.org", Issuer "R3" (verified OK)) by mail02.haj.ipfire.org (Postfix) with ESMTPS id 4PL90q3Vqjz2xSJ for ; Mon, 20 Feb 2023 17:49:47 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by mail01.ipfire.org (Postfix) with ESMTPSA id 4PL90p1RTbznv; Mon, 20 Feb 2023 17:49:46 +0000 (UTC) DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003ed25519; t=1676915386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZU8p5CuCaYO5OnPwjOWU+r1RMS+62zCF6WxU2RdWPOA=; b=tGcEmwx8aCDNe4lRDvwNYpwX8rXG/AzXfhdwhOqprjy8Tl12hPqTubvYDKOHl/2eeQQfzv BR2Kzn07sy+RytBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ipfire.org; s=202003rsa; t=1676915386; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ZU8p5CuCaYO5OnPwjOWU+r1RMS+62zCF6WxU2RdWPOA=; b=iwqkPQwc5pPOkgIa0f3j7Wr/FZ7a6dPYHwIIvJD/MFDeupAcMn7yqff9mXCxJIvUvB+pGJ 7p8syRD1H4r++9JkQDFYmWMM3WbArDVkT09ea1asQ8Pj0AsqxaSgwiDjAl3d/GrOJQ91kH iYiNGP6PWTQlIBN1PQvFHbhcjcDdWMlJWd+vxzVAdSgQe9bG9lVyZDVxYLu5Qj3UWxndg3 gBpSr/m80/p58fADaWo7YgomWJlOTEzIhEPzr36peGd4mu1xs5sxSA+HqOfOYI8VvMkPXb d2vddIbU/DPlCXXIIpbB3usGGSbMOmgeHZA5p2ZdEhZcz9Y+MBs7rQdL7zj0Ow== From: Stefan Schantl To: development@lists.ipfire.org Subject: [PATCH] net-tools: Drop package Date: Mon, 20 Feb 2023 18:49:39 +0100 Message-Id: <20230220174939.280410-1-stefan.schantl@ipfire.org> MIME-Version: 1.0 X-BeenThere: development@lists.ipfire.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: IPFire development talk List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: development-bounces@lists.ipfire.org Sender: "Development" The net-tools package is deprecated and was used by us to ship the "netstat" binary. The successor of "netstat" is the "ss" command from the iproute2. Signed-off-by: Stefan Schantl --- net-tools/config.h | 75 -- net-tools/config.make | 37 - net-tools/mii-diag.8 | 160 ----- net-tools/mii-diag.c | 653 ------------------ net-tools/net-tools.nm | 84 --- net-tools/patches/001-net-tools-cycle.patch | 375 ---------- net-tools/patches/002-net-tools-ipx.patch | 31 - net-tools/patches/003-net-tools-man.patch | 149 ---- .../patches/004-net-tools-interface.patch | 102 --- .../patches/005-net-tools-duplicate-tcp.patch | 146 ---- .../patches/006-net-tools-statalias.patch | 16 - .../007-net-tools-interface_stack.patch | 119 ---- .../008-net-tools-sctp-statistics.patch | 534 -------------- ...et-tools-ifconfig-long-iface-crasher.patch | 36 - 14 files changed, 2517 deletions(-) delete mode 100644 net-tools/config.h delete mode 100644 net-tools/config.make delete mode 100644 net-tools/mii-diag.8 delete mode 100644 net-tools/mii-diag.c delete mode 100644 net-tools/net-tools.nm delete mode 100644 net-tools/patches/001-net-tools-cycle.patch delete mode 100644 net-tools/patches/002-net-tools-ipx.patch delete mode 100644 net-tools/patches/003-net-tools-man.patch delete mode 100644 net-tools/patches/004-net-tools-interface.patch delete mode 100644 net-tools/patches/005-net-tools-duplicate-tcp.patch delete mode 100644 net-tools/patches/006-net-tools-statalias.patch delete mode 100644 net-tools/patches/007-net-tools-interface_stack.patch delete mode 100644 net-tools/patches/008-net-tools-sctp-statistics.patch delete mode 100644 net-tools/patches/009-net-tools-ifconfig-long-iface-crasher.patch diff --git a/net-tools/config.h b/net-tools/config.h deleted file mode 100644 index f63aecbfc..000000000 --- a/net-tools/config.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -* config.h Automatically generated configuration includefile -* -* NET-TOOLS A collection of programs that form the base set of the -* NET-3 Networking Distribution for the LINUX operating -* system. -* -* DO NOT EDIT DIRECTLY -* -*/ - -/* - * - * Internationalization - * - * The net-tools package has currently been translated to French, - * German and Brazilian Portugese. Other translations are, of - * course, welcome. Answer `n' here if you have no support for - * internationalization on your system. - * - */ -#define I18N 1 - -/* - * - * Protocol Families. - * - */ -#define HAVE_AFUNIX 1 -#define HAVE_AFINET 1 -#define HAVE_AFINET6 1 -#define HAVE_AFIPX 1 -#define HAVE_AFATALK 1 -#define HAVE_AFAX25 1 -#define HAVE_AFNETROM 1 -#define HAVE_AFROSE 1 -#define HAVE_AFX25 0 -#define HAVE_AFECONET 1 -#define HAVE_AFDECnet 0 -#define HAVE_AFASH 1 - -/* - * - * Device Hardware types. - * - */ -#define HAVE_HWETHER 1 -#define HAVE_HWARC 1 -#define HAVE_HWSLIP 0 -#define HAVE_HWPPP 1 -#define HAVE_HWTUNNEL 1 -#define HAVE_HWSTRIP 0 -#define HAVE_HWTR 0 -#define HAVE_HWAX25 1 -#define HAVE_HWROSE 1 -#define HAVE_HWNETROM 1 -#define HAVE_HWX25 0 -#define HAVE_HWFR 1 -#define HAVE_HWSIT 1 -#define HAVE_HWFDDI 1 -#define HAVE_HWHIPPI 1 -#define HAVE_HWASH 1 -#define HAVE_HWHDLCLAPB 1 -#define HAVE_HWIRDA 1 -#define HAVE_HWEC 1 -#define HAVE_HWIB 1 - -/* - * - * Other Features. - * - */ -#define HAVE_FW_MASQUERADE 1 -#define HAVE_IP_TOOLS 1 -#define HAVE_MII 1 diff --git a/net-tools/config.make b/net-tools/config.make deleted file mode 100644 index 18907a595..000000000 --- a/net-tools/config.make +++ /dev/null @@ -1,37 +0,0 @@ -I18N=1 -HAVE_AFUNIX=1 -HAVE_AFINET=1 -HAVE_AFINET6=1 -HAVE_AFIPX=1 -HAVE_AFATALK=1 -HAVE_AFAX25=1 -HAVE_AFNETROM=1 -HAVE_AFROSE=1 -HAVE_AFX25=1 -HAVE_AFECONET=1 -# HAVE_AFDECnet=0 -HAVE_AFASH=1 -HAVE_HWETHER=1 -HAVE_HWARC=1 -HAVE_HWSLIP=1 -HAVE_HWPPP=1 -HAVE_HWTUNNEL=1 -HAVE_HWSTRIP=0 -HAVE_HWTR=0 -HAVE_HWAX25=1 -HAVE_HWROSE=1 -HAVE_HWNETROM=1 -HAVE_HWX25=1 -HAVE_HWFR=1 -HAVE_HWSIT=1 -HAVE_HWFDDI=1 -HAVE_HWHIPPI=1 -HAVE_HWASH=1 -HAVE_HWHDLCLAPB=1 -HAVE_HWIRDA=1 -HAVE_HWEC=1 -HAVE_HWIB=1 -HAVE_FW_MASQUERADE=1 -HAVE_IP_TOOLS=1 -HAVE_MII=1 -HAVE_SELINUX=0 diff --git a/net-tools/mii-diag.8 b/net-tools/mii-diag.8 deleted file mode 100644 index aa0dc0be1..000000000 --- a/net-tools/mii-diag.8 +++ /dev/null @@ -1,160 +0,0 @@ -.\" Hey, EMACS: -*- nroff -*- -.\" $Revision: 1.1 $ $Date: 2003/09/06 17:20:17 $ -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH MII-DIAG 8 "September 9, 2003" "Scyld Beowulf\*(Tm" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -mii-diag \- Network adapter control and monitoring -.SH SYNOPSIS -.B mii-diag -.RI [ options ] -.SH DESCRIPTION -This manual page documents briefly the -.B mii-diag -network adapter control and monitoring command. -Addition documentation is available from http://scyld.com/diag/index.html. - -.\" TeX users may be more comfortable with the \fB\fP and -.\" \fI\fP escape sequences to invoke bold face and italics, -.\" respectively. -.PP -This \fBmii-diag\fP command configures, controls and monitors the -transceiver management registers for network interfaces, and configures -driver operational parameters. For transceiver control \fBmii-diag\fP -uses the Media Independent Interface (MII) standard (thus the command name). -It also has additional Linux-specific controls to communicate parameters -such as message enable settings and buffer sizes to the underlying device -driver. -.PP -The MII standard defines registers that control and report network -transceiver capabilities, link settings and errors. Examples are link -speed, duplex, capabilities advertised to the link partner, status LED -indications and link error counters. - -.SH OPTIONS -The \fBmii-diag\fP command supports both single character and long -option names. Short options use a single dash (´-´) in front of the option -character. For options without parameters, multiple options may be -concatenated after a single dash. Long options are prefixed by two -dashes (´--´), and may be abbreviated with a unique prefix. -A long option may take a parameter of the form --arg=param or --arg param. - -.PP -A summary of options is as follows. - -.TP -.B \-A, --advertise -.BR -.B \-F, --fixed-speed - -Speed is one of: 100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD, 10baseT, -10baseT-FD, 10baseT-HD. For more precise control an explict numeric -register setting is also allowed. - - -.TP -.B \-a, \--all-interfaces -Show the status of all interfaces. This option is not recommended with -any other option, especially ones that change settings. - -.TP -.B \-s,\--status -Return exit status 2 if there is no link beat. - -.TP -.B \-D -Increase the debugging level. This may be used to understand the -actions the command is taking. - -.TP -.B \-g, \--read-parameters -Show driver-specific parameters. - -.TP -.B \-G, \--set-parameters value[,value...] -Set driver-specific parameters. -Set a adapter-specific parameters. -Parameters are comma separated, with missing elements retaining the -existing value. - -.TP -.B \-v -Increase the verbosity level. Additional "-v" options increase the -level further. - -.TP -.B \-V -Show the program version information. - -.TP -.B \-w, \--watch -Continuously monitor the transceiver and report changes. - -.TP -.B \-? -Emit usage information. - -.SH DESCRIPTION - -.PP -Calling the command with just the interface name (which defaults to -'eth0' if missing) produces extensive output describing the transceiver -capabilities, configuration and current status. - -.PP -The '--monitor' option allows scripting link beat changes. -.PP -This option is similar to --watch, but with lower overhead and simplifed -output. It polls the interface only once a second and the output format -is a single line per link change with three fixed words - -.PP -Example output: mii-diag --monitor eth0 - down 0x7809 0x0000 - negotiating 0x7829 0x45e1 - up 0x782d 0x45e1 - down 0x7809 0x0000 - -.PP -This may be used as - mii-diag --monitor eth0 | - while read linkstatus bmsr linkpar; do - case $linkstatus in - up) ifup eth0 ;; - down) ifdown eth0 ;; - esac - done - -.PP -It may be useful to shorten the DHCP client daemon timeout if it does -not receive an address by adding the following setting to -/etc/sysconfig/network: -DHCPCDARGS="-t 3" - -.SH SEE ALSO -.BR ether-wake (8), net-diag (8), mii-tool (8). -.br -Addition documentation is available from http://scyld.com/diag/index.html. - -.SH KNOWN BUGS -The --all-interfaces option is quirky. There are very few settings that -are usefully applied to all interfaces. - -.SH AUTHOR -The manual pages, diagnostic commands, and many of the underlying Linux -network drivers were written by Donald Becker for the Scyld -Beowulf(\*(Tm) cluster system. - diff --git a/net-tools/mii-diag.c b/net-tools/mii-diag.c deleted file mode 100644 index 69ebd0bff..000000000 --- a/net-tools/mii-diag.c +++ /dev/null @@ -1,653 +0,0 @@ -/* Mode: C; - * mii-diag.c: Examine and set the MII registers of a network interfaces. - - Usage: mii-diag [-vw] interface. - - This program reads and writes the Media Independent Interface (MII) - management registers on network transceivers. The registers control - and report network link settings and errors. Examples are link speed, - duplex, capabilities advertised to the link partner, status LED - indications and link error counters. - - Notes: - The compile-command is at the end of this source file. - This program works with drivers that implement MII ioctl() calls. - - Written/copyright 1997-2003 by Donald Becker - - This program is free software; you can redistribute it - and/or modify it under the terms of the GNU General Public - License as published by the Free Software Foundation. - - The author may be reached as becker@scyld.com, or C/O - Scyld Computing Corporation - 914 Bay Ridge Road, Suite 220 - Annapolis MD 21403 - - References - http://scyld.com/expert/mii-status.html - http://scyld.com/expert/NWay.html - http://www.national.com/pf/DP/DP83840.html -*/ - -static char version[] = -"mii-diag.c:v2.11 3/21/2005 Donald Becker (becker@scyld.com)\n" -" http://www.scyld.com/diag/index.html\n"; - -static const char usage_msg[] = -"Usage: %s [--help] [-aDfrRvVw] [-AF ] [--watch] \n"; -static const char long_usage_msg[] = -"Usage: %s [-aDfrRvVw] [-AF ] [--watch] \n\ -\n\ - This program configures and monitors the transceiver management registers\n\ - for network interfaces. It uses the Media Independent Interface (MII)\n\ - standard with additional Linux-specific controls to communicate with the\n\ - underlying device driver. The MII registers control and report network\n\ - link settings and errors. Examples are link speed, duplex, capabilities\n\ - advertised to the link partner, status LED indications and link error\n\ - counters.\n\ -\n\ - The common usage is\n\ - mii-diag eth0\n\ -\n\ - Frequently used options are\n\ - -A --advertise \n\ - -F --fixed-speed \n\ - Speed is one of: 100baseT4, 100baseTx, 100baseTx-FD, 100baseTx-HD,\n\ - 10baseT, 10baseT-FD, 10baseT-HD\n\ - -s --status Return exit status 2 if there is no link beat.\n\ -\n\ - Less frequently used options are\n\ - -a --all-interfaces Show the status all interfaces\n\ - (Not recommended with options that change settings.)\n\ - -D --debug\n\ - -g --read-parameters Get driver-specific parameters.\n\ - -G --set-parameters PARMS Set driver-specific parameters.\n\ - Parameters are comma separated, missing parameters retain\n\ - their previous values.\n\ - -M --msg-level LEVEL Set the driver message bit map.\n\ - -p --phy ADDR Set the PHY (MII address) to report.\n\ - -r --restart Restart the link autonegotiation.\n\ - -R --reset Reset the transceiver.\n\ - -v --verbose Report each action taken.\n\ - -V --version Emit version information.\n\ - -w --watch Continuously monitor the transceiver and report changes.\n\ -\n\ - This command returns success (zero) if the interface information can be\n\ - read. If the --status option is passed, a zero return means that the\n\ - interface has link beat.\n\ -"; - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef use_linux_libc5 -#include -#include -#endif - -typedef u_int32_t u32; -typedef u_int16_t u16; -typedef u_int8_t u8; - -#if defined(SIOCGPARAMS) && SIOCGPARAMS != SIOCDEVPRIVATE+3 -#error Changed definition for SIOCGPARAMS -#else -#define SIOCGPARAMS (SIOCDEVPRIVATE+3) /* Read operational parameters. */ -#define SIOCSPARAMS (SIOCDEVPRIVATE+4) /* Set operational parameters. */ -#endif - -const char shortopts[] = "aA:C:DfF:gG:hmM:p:rRsvVw?"; -struct option longopts[] = { - /* { name has_arg *flag val } */ - {"all-interfaces", 0, 0, 'a'}, /* Show all interfaces. */ - {"advertise", 1, 0, 'A'}, /* Change the capabilities advertised. */ - {"BMCR", 1, 0, 'C'}, /* Set the control register. */ - {"debug", 0, 0, 'D'}, /* Increase the debug level. */ - {"force", 0, 0, 'f'}, /* Force the operation. */ - {"fixed-speed", 1, 0, 'F'}, /* Fixed speed name. */ - {"read-parameters", 0, 0, 'g'}, /* Show general settings values. */ - {"set-parameters", 1, 0, 'G'}, /* Write general settings values. */ - {"help", 0, 0, 'h'}, /* Print a long usage message. */ - {"monitor", 0, 0, 'm'}, /* Monitor status register. */ - {"msg-level", 1, 0, 'M'}, /* Set the driver message level. */ - {"phy", 1, 0, 'p'}, /* Set the PHY (MII address) to report. */ - {"restart", 0, 0, 'r'}, /* Restart the link negotiation */ - {"reset", 0, 0, 'R'}, /* Reset the transceiver. */ - {"status", 0, 0, 's'}, /* Non-zero exit status w/ no link beat. */ - {"verbose", 0, 0, 'v'}, /* Report each action taken. */ - {"version", 0, 0, 'V'}, /* Emit version information. */ - {"watch", 0, 0, 'w'}, /* Constantly monitor the port. */ - {"error", 0, 0, '?'}, /* Return the error message. */ - { 0, 0, 0, 0 } -}; - -/* Usually in libmii.c, but trivial substitions are below. */ -extern int show_mii_details(long ioaddr, int phy_id); -extern void monitor_mii(long ioaddr, int phy_id); -int show_mii_details(long ioaddr, int phy_id) __attribute__((weak)); -void monitor_mii(long ioaddr, int phy_id) __attribute__((weak)); - - -/* Command-line flags. */ -unsigned int opt_a = 0, /* Show-all-interfaces flag. */ - opt_f = 0, /* Force the operation. */ - opt_g = 0, - opt_G = 0, - verbose = 0, /* Verbose flag. */ - debug = 0, - opt_version = 0, - opt_restart = 0, - opt_reset = 0, - opt_status = 0, - opt_watch = 0; -static int msg_level = -1; -static int set_BMCR = -1; -static int nway_advertise = 0; -static int fixed_speed = -1; -static int override_phy = -1; -char *opt_G_string = NULL; - -/* Internal values. */ -int new_ioctl_nums; -int skfd = -1; /* AF_INET socket for ioctl() calls. */ -struct ifreq ifr; - -int do_one_xcvr(int skfd); -int show_basic_mii(long ioaddr, int phy_id); -int mdio_read(int skfd, int phy_id, int location); -void mdio_write(int skfd, int phy_id, int location, int value); -static int parse_advertise(const char *capabilities); -static void monitor_status(long ioaddr, int phy_id); - - -int -main(int argc, char **argv) -{ - int c, errflag = 0; - char **spp, *ifname; - char *progname = rindex(argv[0], '/') ? rindex(argv[0], '/')+1 : argv[0]; - - while ((c = getopt_long(argc, argv, shortopts, longopts, 0)) != EOF) - switch (c) { - case 'a': opt_a++; break; - case 'A': nway_advertise |= parse_advertise(optarg); - if (nway_advertise == -1) errflag++; - break; - case 'C': set_BMCR = strtoul(optarg, NULL, 16); break; - case 'D': debug++; break; - case 'f': opt_f++; break; - case 'F': fixed_speed = parse_advertise(optarg); - if (fixed_speed == -1) errflag++; - break; - case 'g': opt_g++; break; - case 'G': opt_G++; opt_G_string = strdup(optarg); break; - case 'm': opt_watch++; opt_status++; break; - case 'M': msg_level = strtoul(optarg, NULL, 0); break; - case 'h': fprintf(stderr, long_usage_msg, progname); return 0; - case 'p': override_phy = atoi(optarg); break; - case 'r': opt_restart++; break; - case 'R': opt_reset++; break; - case 's': opt_status++; break; - case 'v': verbose++; break; - case 'V': opt_version++; break; - case 'w': opt_watch++; break; - case '?': errflag++; break; - } - if (errflag) { - fprintf(stderr, usage_msg, progname); - return 2; - } - - if (verbose || opt_version) - printf("%s", version); - - /* Open a basic socket. */ - if ((skfd = socket(AF_INET, SOCK_DGRAM,0)) < 0) { - perror("socket"); - return 1; - } - - if (debug) - fprintf(stderr, "DEBUG: argc=%d, optind=%d and argv[optind] is %s.\n", - argc, optind, argv[optind]); - - /* No remaining args means interface wasn't specified. */ - if (optind == argc) { - fprintf(stderr, "No interface specified.\n"); - fprintf(stderr, usage_msg, progname); - (void) close(skfd); - return 2; - } else { - /* Copy the interface name. */ - spp = argv + optind; - ifname = *spp++; - } - - if (ifname == NULL) { - fprintf(stderr, "No ifname.\n"); - (void) close(skfd); - return -1; - } - - /* Verify that the interface supports the ioctl(), and if - it is using the new or old SIOCGMIIPHY value (grrr...). - */ - { - u16 *data = (u16 *)(&ifr.ifr_data); - - strncpy(ifr.ifr_name, ifname, IFNAMSIZ); - ifr.ifr_name[IFNAMSIZ-1] = '\0'; - data[0] = 0; - - if (ioctl(skfd, 0x8947, &ifr) >= 0) { - new_ioctl_nums = 1; - } else if (ioctl(skfd, SIOCDEVPRIVATE, &ifr) >= 0) { - new_ioctl_nums = 0; - } else { - fprintf(stderr, "SIOCGMIIPHY on %s failed: %s\n", ifname, - strerror(errno)); - (void) close(skfd); - return 1; - } - if (verbose) - printf(" Using the %s SIOCGMIIPHY value on PHY %d " - "(BMCR 0x%4.4x).\n", - new_ioctl_nums ? "new" : "old", data[0], data[3]); - } - - do_one_xcvr(skfd); - - (void) close(skfd); - return 0; -} - -int do_one_xcvr(int skfd) -{ - u16 *data = (u16 *)(&ifr.ifr_data); - u32 *data32 = (u32 *)(&ifr.ifr_data); - unsigned phy_id = data[0]; - - if (override_phy >= 0) { - printf("Using the specified MII PHY index %d.\n", override_phy); - phy_id = override_phy; - } - - if (opt_g || opt_G || msg_level >= 0) { - if (ioctl(skfd, SIOCGPARAMS, &ifr) < 0) { - fprintf(stderr, "SIOCGPARAMS on %s failed: %s\n", ifr.ifr_name, - strerror(errno)); - return -1; - } - } - if (opt_g) { - int i; - printf("Driver general parameter settings:"); - for (i = 0; i*sizeof(u32) < sizeof(ifr.ifr_ifru); i++) { - printf(" %d", data32[i]); - } - printf(".\n"); - } - if (opt_G) { - /* Set up to four arbitrary driver parameters from the -G parameter. - The format is comma separated integers, with a missing element - retaining the previous value. - */ - char *str = opt_G_string; - int i; - for (i = 0; str && i < 4; i++) { - char *endstr; - u32 newval = strtol(str, &endstr, 0); - if (debug) - printf(" parse string '%s' value %d end '%s'.\n", - str, newval, endstr); - if (str == endstr) { - if (endstr[0] == ',') /* No parameter */ - str = endstr+1; - else { - fprintf(stderr, "Invalid driver parameter '%s'.\n", str); - str = index(str, ','); - } - } else if (endstr[0] == ',') { - data32[i] = newval; - str = endstr + 1; - } else if (endstr[0] == 0) { - data32[i] = newval; - break; - } - } - printf("Setting new driver general parameters:"); - for (i = 0; i*sizeof(u32) < sizeof(ifr.ifr_ifru); i++) { - printf(" %d", data32[i]); - } - printf(".\n"); - if (ioctl(skfd, SIOCSPARAMS, &ifr) < 0) { - fprintf(stderr, "SIOCSPARAMS on %s failed: %s\n", ifr.ifr_name, - strerror(errno)); - return -1; - } - } - if (msg_level >= 0) { - data32[0] = msg_level; - if (ioctl(skfd, SIOCSPARAMS, &ifr) < 0) { - fprintf(stderr, "SIOCSPARAMS on %s failed: %s\n", ifr.ifr_name, - strerror(errno)); - return -1; - } - } - - if (opt_reset) { - printf("Resetting the transceiver...\n"); - mdio_write(skfd, phy_id, 0, 0x8000); - } - /* Note: PHY addresses > 32 are pseudo-MII devices, usually built-in. */ - if (phy_id < 64 && nway_advertise > 0) { - printf(" Setting the media capability advertisement register of " - "PHY #%d to 0x%4.4x.\n", phy_id, nway_advertise | 1); - mdio_write(skfd, phy_id, 4, nway_advertise | 1); - mdio_write(skfd, phy_id, 0, 0x1000); - } - - if (opt_restart) { - printf("Restarting negotiation...\n"); - mdio_write(skfd, phy_id, 0, 0x0000); - mdio_write(skfd, phy_id, 0, 0x1200); - } - /* To force 100baseTx-HD do mdio_write(skfd, phy_id, 0, 0x2000); */ - if (fixed_speed >= 0) { - int reg0_val = 0; - if (fixed_speed & 0x0180) /* 100mpbs */ - reg0_val |= 0x2000; - if ((fixed_speed & 0x0140) && /* A full duplex type and */ - ! (fixed_speed & 0x0820)) /* no half duplex types. */ - reg0_val |= 0x0100; - printf("Setting the speed to \"fixed\", Control register %4.4x.\n", - reg0_val); - mdio_write(skfd, phy_id, 0, reg0_val); - } - if (set_BMCR >= 0) { - printf("Setting the Basic Mode Control Register to 0x%4.4x.\n", - set_BMCR); - mdio_write(skfd, phy_id, 0, set_BMCR); - } - - if (opt_watch && opt_status) - monitor_status(skfd, phy_id); - - show_basic_mii(skfd, phy_id); -#ifdef LIBMII - if (verbose) - show_mii_details(skfd, phy_id); -#else - if (verbose || debug) { - int mii_reg, mii_val; - printf(" MII PHY #%d transceiver registers:", phy_id); - for (mii_reg = 0; mii_reg < 32; mii_reg++) { - mii_val = mdio_read(skfd, phy_id, mii_reg); - printf("%s %4.4x", (mii_reg % 8) == 0 ? "\n " : "", - mii_val); - } - printf("\n"); - } -#endif - - if (opt_watch) - monitor_mii(skfd, phy_id); - if (opt_status && - (mdio_read(skfd, phy_id, 1) & 0x0004) == 0) - exit(2); - return 0; -} - -int mdio_read(int skfd, int phy_id, int location) -{ - u16 *data = (u16 *)(&ifr.ifr_data); - - data[0] = phy_id; - data[1] = location; - - if (ioctl(skfd, new_ioctl_nums ? 0x8948 : SIOCDEVPRIVATE+1, &ifr) < 0) { - fprintf(stderr, "SIOCGMIIREG on %s failed: %s\n", ifr.ifr_name, - strerror(errno)); - return -1; - } - return data[3]; -} - -void mdio_write(int skfd, int phy_id, int location, int value) -{ - u16 *data = (u16 *)(&ifr.ifr_data); - - data[0] = phy_id; - data[1] = location; - data[2] = value; - - if (ioctl(skfd, new_ioctl_nums ? 0x8949 : SIOCDEVPRIVATE+2, &ifr) < 0) { - fprintf(stderr, "SIOCSMIIREG on %s failed: %s\n", ifr.ifr_name, - strerror(errno)); - } -} - -/* Parse the command line argument for advertised capabilities. */ -static int parse_advertise(const char *capabilities) -{ - const char *mtypes[] = { - "100baseT4", "100baseTx", "100baseTx-FD", "100baseTx-HD", - "10baseT", "10baseT-FD", "10baseT-HD", 0, - }; - char *endptr; - int cap_map[] = { 0x0200, 0x0180, 0x0100, 0x0080, 0x0060, 0x0040, 0x0020,}; - int i; - if ( ! capabilities) { - fprintf(stderr, "You passed -A 'NULL'. You must provide a media" - " list to advertise!\n"); - return -1; - } - if (debug) - fprintf(stderr, "Advertise string is '%s'.\n", capabilities); - for (i = 0; mtypes[i]; i++) - if (strcasecmp(mtypes[i], capabilities) == 0) - return cap_map[i]; - if ((i = strtol(capabilities, &endptr, 16)) <= 0xffff && endptr[0] == 0) - return i; - fprintf(stderr, "Invalid media advertisement value '%s'.\n" - " Either pass a numeric value or one of the following names:\n", - capabilities); - for (i = 0; mtypes[i]; i++) - fprintf(stderr, " %-14s %3.3x\n", mtypes[i], cap_map[i]); - return -1; -} - -/* Trivial versions if we don't link against libmii.c */ -static const char *media_names[] = { - "10baseT", "10baseT-FD", "100baseTx", "100baseTx-FD", "100baseT4", - "Flow-control", 0, -}; -/* Various non-good bits in the command register. */ -static const char *bmcr_bits[] = { - " Internal Collision-Test enabled!\n", "", /* 0x0080,0x0100 */ - " Restarted auto-negotiation in progress!\n", - " Transceiver isolated from the MII!\n", - " Transceiver powered down!\n", "", "", - " Transceiver in loopback mode!\n", - " Transceiver currently being reset!\n", -}; - -int show_basic_mii(long ioaddr, int phy_id) -{ - int mii_reg, i; - u16 mii_val[32]; - u16 bmcr, bmsr, new_bmsr, nway_advert, lkpar; - - for (mii_reg = 0; mii_reg < 8; mii_reg++) - mii_val[mii_reg] = mdio_read(ioaddr, phy_id, mii_reg); - if ( ! verbose) { - printf("Basic registers of MII PHY #%d: ", phy_id); - for (mii_reg = 0; mii_reg < 8; mii_reg++) - printf(" %4.4x", mii_val[mii_reg]); - printf(".\n"); - } - - if (mii_val[0] == 0xffff || mii_val[1] == 0x0000) { - printf(" No MII transceiver present!.\n"); - if (! opt_f) { - printf(" Use '--force' to view the information anyway.\n"); - return -1; - } - } - /* Descriptive rename. */ - bmcr = mii_val[0]; - bmsr = mii_val[1]; - nway_advert = mii_val[4]; - lkpar = mii_val[5]; - - if (lkpar & 0x4000) { - int negotiated = nway_advert & lkpar & 0x3e0; - int max_capability = 0; - /* Scan for the highest negotiated capability, highest priority - (100baseTx-FDX) to lowest (10baseT-HDX). */ - int media_priority[] = {8, 9, 7, 6, 5}; /* media_names[i-5] */ - printf(" The autonegotiated capability is %4.4x.\n", negotiated); - for (i = 0; media_priority[i]; i++) - if (negotiated & (1 << media_priority[i])) { - max_capability = media_priority[i]; - break; - } - if (max_capability) - printf("The autonegotiated media type is %s.\n", - media_names[max_capability - 5]); - else - printf("No common media type was autonegotiated!\n" - "This is extremely unusual and typically indicates a " - "configuration error.\n" "Perhaps the advertised " - "capability set was intentionally limited.\n"); - } - printf(" Basic mode control register 0x%4.4x:", bmcr); - if (bmcr & 0x1000) - printf(" Auto-negotiation enabled.\n"); - else - printf(" Auto-negotiation disabled, with\n" - " Speed fixed at 10%s mbps, %s-duplex.\n", - bmcr & 0x2000 ? "0" : "", - bmcr & 0x0100 ? "full":"half"); - for (i = 0; i < 9; i++) - if (bmcr & (0x0080<= 11; i--) - if (bmsr & (1<"); - printf(".\n"); - printf(" %s to perform Auto-negotiation, negotiation %scomplete.\n", - bmsr & 0x0008 ? "Able" : "Unable", - bmsr & 0x0020 ? "" : "not "); - } - - if (bmsr & 0x0010) - printf(" Remote fault detected!\n"); - if (bmsr & 0x0002) - printf(" *** Link Jabber! ***\n"); - - if (lkpar & 0x4000) { - printf(" Your link partner advertised %4.4x:", - lkpar); - for (i = 5; i >= 0; i--) - if (lkpar & (0x20< # -############################################################################### - -name = net-tools -version = 2.0 -git_rev = e5f1be13 -release = 2.%{git_rev} - -groups = System/Base -url = http://net-tools.berlios.de/ -license = GPL+ -summary = Basic networking tools. - -description - The net-tools package contains basic networking tools, - including ifconfig, netstat, route, and others. -end - -source_dl = -sources = %{thisapp}-%{git_rev}.tar.xz - -build - requires - gettext - end - - prepare_cmds - # Copy config files - cp %{DIR_SOURCE}/config.h %{DIR_APP} - cp %{DIR_SOURCE}/config.make %{DIR_APP} - - # Copy additional man pages - mkdir -pv %{DIR_APP}/man/en_US - cp %{DIR_SOURCE}/*.8 %{DIR_APP}/man/en_US - - # Copy source for mii-diag - cp %{DIR_SOURCE}/mii-diag.c %{DIR_APP} - end - - make_build_targets += \ - CC=gcc - - # Compiling in parallel mode is unsafe for this pkg. - PARALLELISMFLAGS = - - build_cmds - # Compile mii-diag - make mii-diag - end - - install - mv man/de_DE man/de - mv man/fr_FR man/fr - mv man/pt_BR man/pt - - make BASEDIR=%{BUILDROOT} BINDIR=%{bindir} \ - SBINDIR=%{sbindir} mandir=%{mandir} install - - # Install mii-diag - install -m 755 %{DIR_APP}/mii-diag %{BUILDROOT}%{sbindir} - - # Remove tools we do not want - rm -rvf \ - %{BUILDROOT}%{prefix}/{,*}/{arp,ifconfig,ip,nameif,plipconfig,rarp,route,slattach}* \ - %{BUILDROOT}%{mandir}/{,*}/man*/{arp,ifconfig,ip,nameif,plipconfig,rarp,route,slattach}* - - # Remove hostname (has its own package) - rm -rvf \ - %{BUILDROOT}%{bindir}/{dnsdomainname,domainname,hostname,nisdomainname,ypdomainname}* \ - %{BUILDROOT}%{mandir}/{,*}/man*/{dnsdomainname,domainname,hostname,nisdomainname,ypdomainname}* - end -end - -packages - package %{name} - groups += Base - end - - package %{name}-debuginfo - template DEBUGINFO - end -end diff --git a/net-tools/patches/001-net-tools-cycle.patch b/net-tools/patches/001-net-tools-cycle.patch deleted file mode 100644 index 7d58dbbd6..000000000 --- a/net-tools/patches/001-net-tools-cycle.patch +++ /dev/null @@ -1,375 +0,0 @@ -diff -up net-tools-2.0/lib/interface.c.cycle net-tools-2.0/lib/interface.c ---- net-tools-2.0/lib/interface.c.cycle 2014-11-11 14:38:03.000000000 +0100 -+++ net-tools-2.0/lib/interface.c 2014-11-24 14:45:46.128480980 +0100 -@@ -93,6 +93,7 @@ int if_list_all = 0; /* do we have reque - static struct interface *int_list, *int_last; - - static int if_readlist_proc(const char *); -+static int if_readlist_rep(const char *, struct interface *); - - static struct interface *if_cache_add(const char *name) - { -@@ -138,11 +139,14 @@ struct interface *lookup_interface(const - int for_all_interfaces(int (*doit) (struct interface *, void *), void *cookie) - { - struct interface *ife; -+ int err; - - if (!if_list_all && (if_readlist() < 0)) - return -1; - for (ife = int_list; ife; ife = ife->next) { -- int err = doit(ife, cookie); -+ if_readlist_rep(ife->name, ife); -+ err = doit(ife, cookie); -+ - if (err) - return err; - } -@@ -379,6 +383,41 @@ static int if_readlist_proc(const char * - fclose(fh); - return err; - } -+ -+static int if_readlist_rep(const char *target, struct interface *ife) -+{ -+ FILE *fh; -+ char buf[512]; -+ int err; -+ -+ fh = fopen(_PATH_PROCNET_DEV, "r"); -+ if (!fh) { -+ fprintf(stderr, _("Warning: cannot open %s (%s). Limited output.\n"), -+ _PATH_PROCNET_DEV, strerror(errno)); -+ return if_readconf(); -+ } -+ fgets(buf, sizeof buf, fh); /* eat line */ -+ fgets(buf, sizeof buf, fh); -+ -+ procnetdev_vsn = procnetdev_version(buf); -+ -+ err = 0; -+ while (fgets(buf, sizeof buf, fh)) { -+ char *s, name[IFNAMSIZ]; -+ s = get_name(name, buf); -+ get_dev_fields(s, ife); -+ ife->statistics_valid = 1; -+ if (target && !strcmp(target,name)) -+ break; -+ } -+ if (ferror(fh)) { -+ perror(_PATH_PROCNET_DEV); -+ err = -1; -+ } -+ -+ fclose(fh); -+ return err; -+} - - int if_readlist(void) - { -diff -up net-tools-2.0/man/en_US/netstat.8.cycle net-tools-2.0/man/en_US/netstat.8 ---- net-tools-2.0/man/en_US/netstat.8.cycle 2014-11-11 14:38:03.000000000 +0100 -+++ net-tools-2.0/man/en_US/netstat.8 2014-11-24 14:47:36.140944944 +0100 -@@ -36,6 +36,7 @@ netstat \- Print network connections, ro - .RB [ \-\-verbose | \-v ] - .RB [ \-\-continuous | \-c] - .RB [ \-\-wide | \-W ] -+.RB [delay] - .P - .B netstat - .RB { \-\-route | \-r } -@@ -45,6 +46,7 @@ netstat \- Print network connections, ro - .RB [ \-\-numeric | \-n ] - .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ] - .RB [ \-\-continuous | \-c ] -+.RB [delay] - .P - .B netstat - .RB { \-\-interfaces | \-i } -@@ -55,12 +57,14 @@ netstat \- Print network connections, ro - .RB [ \-\-numeric | \-n ] - .RB [ \-\-numeric-hosts "] [" \-\-numeric-ports "] [" \-\-numeric-users ] - .RB [ \-\-continuous | \-c ] -+.RB [delay] - .P - .B netstat - .RB { \-\-groups | \-g } - .RB [ \-\-numeric | \-n ] - .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ] - .RB [ \-\-continuous | \-c ] -+.RB [delay] - .P - .B netstat - .RB { \-\-masquerade | \-M } -@@ -68,6 +72,7 @@ netstat \- Print network connections, ro - .RB [ \-\-numeric | \-n ] - .RB [ \-\-numeric\-hosts "] [" \-\-numeric\-ports "] [" \-\-numeric\-users ] - .RB [ \-\-continuous | \-c ] -+.RB [delay] - .P - .B netstat - .RB { \-\-statistics | -s } -@@ -76,6 +81,7 @@ netstat \- Print network connections, ro - .RB [ \-\-udplite | \-U ] - .RB [ \-\-sctp | \-S ] - .RB [ \-\-raw | \-w ] -+.RB [delay] - .P - .B netstat - .RB { \-\-version | \-V } -@@ -208,6 +214,10 @@ option, show interfaces that are not up - Print routing information from the FIB. (This is the default.) - .SS "\-C" - Print routing information from the route cache. -+.SS delay -+Netstat will cycle printing through statistics every -+.B delay -+seconds. - .P - .SH OUTPUT - .P -diff -up net-tools-2.0/netstat.c.cycle net-tools-2.0/netstat.c ---- net-tools-2.0/netstat.c.cycle 2014-11-11 14:38:03.000000000 +0100 -+++ net-tools-2.0/netstat.c 2014-11-24 14:44:24.948614445 +0100 -@@ -115,9 +115,9 @@ - #endif - - /* prototypes for statistics.c */ --void parsesnmp(int, int, int); -+int parsesnmp(int, int, int); - void inittab(void); --void parsesnmp6(int, int, int); -+int parsesnmp6(int, int, int); - void inittab6(void); - - typedef enum { -@@ -342,10 +342,10 @@ static void prg_cache_clear(void) - prg_cache_loaded = 0; - } - --static void wait_continous(void) -+static void wait_continous(int reptimer) - { - fflush(stdout); -- sleep(1); -+ sleep(reptimer); - } - - static int extract_type_1_socket_inode(const char lname[], unsigned long * inode_p) { -@@ -1787,6 +1787,8 @@ static int rfcomm_info(void) - - static int iface_info(void) - { -+ static int count=0; -+ - if (skfd < 0) { - if ((skfd = sockets_open(0)) < 0) { - perror("socket"); -@@ -1796,20 +1798,21 @@ static int iface_info(void) - } - if (flag_exp < 2) { - ife_short = 1; -- printf(_("Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n")); -+ if(!(count % 8)) -+ printf(_("Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n")); - } - - if (for_all_interfaces(do_if_print, &flag_all) < 0) { - perror(_("missing interface information")); - exit(1); - } -- if (flag_cnt) -+ if (!flag_cnt) { - if_cache_free(); -- else { - close(skfd); - skfd = -1; - } - -+ count++; - return 0; - } - -@@ -1825,7 +1828,7 @@ static void usage(void) - { - fprintf(stderr, _("usage: netstat [-vWeenNcCF] [] -r netstat {-V|--version|-h|--help}\n")); - fprintf(stderr, _(" netstat [-vWnNcaeol] [ ...]\n")); -- fprintf(stderr, _(" netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }\n\n")); -+ fprintf(stderr, _(" netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay]\n\n")); - - fprintf(stderr, _(" -r, --route display routing table\n")); - fprintf(stderr, _(" -i, --interfaces display interface table\n")); -@@ -1867,6 +1870,7 @@ int main - (int argc, char *argv[]) { - int i; - int lop; -+ int reptimer = 1; - static struct option longopts[] = - { - AFTRANS_OPTS, -@@ -2049,6 +2053,12 @@ int main - flag_sta++; - } - -+ if(argc == optind + 1) { -+ if((reptimer = atoi(argv[optind])) <= 0) -+ usage(); -+ flag_cnt++; -+ } -+ - if (flag_int + flag_rou + flag_mas + flag_sta > 1) - usage(); - -@@ -2078,7 +2088,7 @@ int main - flag_not & FLAG_NUM_PORT, flag_exp); - if (i || !flag_cnt) - break; -- wait_continous(); -+ wait_continous(reptimer); - } - #else - ENOSUPP("netstat", "FW_MASQUERADE"); -@@ -2091,17 +2101,18 @@ int main - if (!afname[0]) - safe_strncpy(afname, DFLT_AF, sizeof(afname)); - -+ for (;;) { - if (!strcmp(afname, "inet")) { - #if HAVE_AFINET - inittab(); -- parsesnmp(flag_raw, flag_tcp, flag_udp); -+ i = parsesnmp(flag_raw, flag_tcp, flag_udp); - #else - ENOSUPP("netstat", "AF INET"); - #endif - } else if(!strcmp(afname, "inet6")) { - #if HAVE_AFINET6 - inittab6(); -- parsesnmp6(flag_raw, flag_tcp, flag_udp); -+ i = parsesnmp6(flag_raw, flag_tcp, flag_udp); - #else - ENOSUPP("netstat", "AF INET6"); - #endif -@@ -2109,7 +2120,11 @@ int main - printf(_("netstat: No statistics support for specified address family: %s\n"), afname); - exit(1); - } -- exit(0); -+ if(i || !flag_cnt) -+ break; -+ sleep(reptimer); -+ } -+ return (i); - } - - if (flag_rou) { -@@ -2131,7 +2146,7 @@ int main - i = route_info(afname, options); - if (i || !flag_cnt) - break; -- wait_continous(); -+ wait_continous(reptimer); - } - return (i); - } -@@ -2140,7 +2155,7 @@ int main - i = iface_info(); - if (!flag_cnt || i) - break; -- wait_continous(); -+ wait_continous(reptimer); - } - return (i); - } -@@ -2327,7 +2342,7 @@ int main - - if (!flag_cnt || i) - break; -- wait_continous(); -+ wait_continous(reptimer); - prg_cache_clear(); - } - return (i); -diff -up net-tools-2.0/statistics.c.cycle net-tools-2.0/statistics.c ---- net-tools-2.0/statistics.c.cycle 2014-11-11 14:38:03.000000000 +0100 -+++ net-tools-2.0/statistics.c 2014-11-24 14:44:24.949614431 +0100 -@@ -502,7 +502,7 @@ void process6_fd(FILE *f) - - } - --void parsesnmp(int flag_raw, int flag_tcp, int flag_udp) -+int parsesnmp(int flag_raw, int flag_tcp, int flag_udp) - { - FILE *f; - -@@ -511,14 +511,17 @@ void parsesnmp(int flag_raw, int flag_tc - f = proc_fopen("/proc/net/snmp"); - if (!f) { - perror(_("cannot open /proc/net/snmp")); -- return; -+ return(1); - } - - if (process_fd(f, 1, NULL) < 0) - fprintf(stderr, _("Problem while parsing /proc/net/snmp\n")); - -- if (ferror(f)) -+ if (ferror(f)) { - perror("/proc/net/snmp"); -+ fclose(f); -+ return(1); -+ } - - fclose(f); - -@@ -528,15 +531,18 @@ void parsesnmp(int flag_raw, int flag_tc - if (process_fd(f, 1, NULL) <0) - fprintf(stderr, _("Problem while parsing /proc/net/netstat\n")); - -- if (ferror(f)) -- perror("/proc/net/netstat"); -+ if (ferror(f)) { -+ perror("/proc/net/netstat"); -+ fclose(f); -+ return(1); -+ } - - fclose(f); - } -- return; -+ return(0); - } - --void parsesnmp6(int flag_raw, int flag_tcp, int flag_udp) -+int parsesnmp6(int flag_raw, int flag_tcp, int flag_udp) - { - FILE *f; - -@@ -545,7 +551,7 @@ void parsesnmp6(int flag_raw, int flag_t - f = fopen("/proc/net/snmp6", "r"); - if (!f) { - perror(_("cannot open /proc/net/snmp6")); -- return; -+ return(1); - } - process6_fd(f); - if (ferror(f)) -@@ -555,13 +561,16 @@ void parsesnmp6(int flag_raw, int flag_t - f = fopen("/proc/net/snmp", "r"); - if (!f) { - perror(_("cannot open /proc/net/snmp")); -- return; -+ return(1); - } - process_fd(f, 0, "Tcp"); -- if (ferror(f)) -+ if (ferror(f)) { - perror("/proc/net/snmp"); -+ return(1); -+ } - - fclose(f); -+ return(0); - } - - void inittab(void) diff --git a/net-tools/patches/002-net-tools-ipx.patch b/net-tools/patches/002-net-tools-ipx.patch deleted file mode 100644 index ec7814587..000000000 --- a/net-tools/patches/002-net-tools-ipx.patch +++ /dev/null @@ -1,31 +0,0 @@ -diff -up net-tools-2.0/lib/ipx_gr.c.ipx net-tools-2.0/lib/ipx_gr.c ---- net-tools-2.0/lib/ipx_gr.c.ipx 2013-09-10 12:33:52.494047907 +0200 -+++ net-tools-2.0/lib/ipx_gr.c 2013-09-10 12:34:28.531561603 +0200 -@@ -72,7 +72,7 @@ int IPX_rprint(int options) - continue; - - /* Fetch and resolve the Destination */ -- (void) ap->input(5, net, &sa); -+ (void) ap->input(1, net, &sa); - safe_strncpy(net, ap->sprint(&sa, numeric), sizeof(net)); - - /* Fetch and resolve the Router Net */ -diff -up net-tools-2.0/netstat.c.ipx net-tools-2.0/netstat.c ---- net-tools-2.0/netstat.c.ipx 2013-09-10 12:33:52.491047948 +0200 -+++ net-tools-2.0/netstat.c 2013-09-10 12:33:52.495047894 +0200 -@@ -1643,13 +1643,13 @@ static int ipx_info(void) - } - - /* Fetch and resolve the Source */ -- (void) ap->input(4, sad, &sa); -+ (void) ap->input(0, sad, &sa); - safe_strncpy(buf, ap->sprint(&sa, flag_not & FLAG_NUM_HOST), sizeof(buf)); - snprintf(sad, sizeof(sad), "%s:%04X", buf, sport); - - if (!nc) { - /* Fetch and resolve the Destination */ -- (void) ap->input(4, dad, &sa); -+ (void) ap->input(0, dad, &sa); - safe_strncpy(buf, ap->sprint(&sa, flag_not & FLAG_NUM_HOST), sizeof(buf)); - snprintf(dad, sizeof(dad), "%s:%04X", buf, dport); - } else diff --git a/net-tools/patches/003-net-tools-man.patch b/net-tools/patches/003-net-tools-man.patch deleted file mode 100644 index 1a33a1e3a..000000000 --- a/net-tools/patches/003-net-tools-man.patch +++ /dev/null @@ -1,149 +0,0 @@ -diff -up net-tools-2.0/man/en_US/arp.8.man net-tools-2.0/man/en_US/arp.8 ---- net-tools-2.0/man/en_US/arp.8.man 2014-04-26 02:45:16.000000000 +0200 -+++ net-tools-2.0/man/en_US/arp.8 2014-07-07 14:51:31.378459439 +0200 -@@ -63,6 +63,10 @@ arp \- manipulate the system ARP cache - .B \-f - .RI [ filename ] - -+.SH NOTE -+.P -+This program is obsolete. For replacement check \fBip neigh\fR. -+ - .SH DESCRIPTION - .B Arp - manipulates or displays the kernel's IPv4 network neighbour cache. It can add -@@ -219,6 +223,6 @@ published proxy ARP entries and permanen - .br - .I /etc/ethers - .SH SEE ALSO --rarp(8), route(8), ifconfig(8), netstat(8) -+.BR ip(8) - .SH AUTHORS - Fred N. van Kempen , Bernd Eckenfels . -diff -up net-tools-2.0/man/en_US/ethers.5.man net-tools-2.0/man/en_US/ethers.5 ---- net-tools-2.0/man/en_US/ethers.5.man 2014-04-26 02:45:16.000000000 +0200 -+++ net-tools-2.0/man/en_US/ethers.5 2014-07-07 14:51:31.378459439 +0200 -@@ -26,6 +26,3 @@ can be resolved by DNS or a dot separate - .SH FILES \"{{{ - /etc/ethers - .\"}}} --.SH "SEE ALSO" \"{{{ --rarp(8) --.\"}}} -diff -up net-tools-2.0/man/en_US/ifconfig.8.man net-tools-2.0/man/en_US/ifconfig.8 ---- net-tools-2.0/man/en_US/ifconfig.8.man 2014-04-26 02:45:16.000000000 +0200 -+++ net-tools-2.0/man/en_US/ifconfig.8 2014-07-07 14:51:31.379459422 +0200 -@@ -5,6 +5,13 @@ ifconfig \- configure a network interfac - .B "ifconfig [-v] [-a] [-s] [interface]" - .br - .B "ifconfig [-v] interface [aftype] options | address ..." -+ -+.SH NOTE -+.P -+This program is obsolete! -+For replacement check \fBip addr\fR and \fBip link\fR. -+For statistics use \fBip -s link\fR. -+ - .SH DESCRIPTION - .B Ifconfig - is used to configure the kernel-resident network interfaces. It is -@@ -222,7 +229,8 @@ package to display link layer informatio - While appletalk DDP and IPX addresses will be displayed they cannot be - altered by this command. - .SH SEE ALSO --route(8), netstat(8), arp(8), rarp(8), iptables(8), ifup(8), interfaces(5). -+.BR ip(8), -+.BR iptables(8) - .br - http://physics.nist.gov/cuu/Units/binary.html - Prefixes for binary multiples - .SH AUTHORS -diff -up net-tools-2.0/man/en_US/mii-tool.8.man net-tools-2.0/man/en_US/mii-tool.8 ---- net-tools-2.0/man/en_US/mii-tool.8.man 2014-04-26 02:45:16.000000000 +0200 -+++ net-tools-2.0/man/en_US/mii-tool.8 2014-07-07 14:51:31.379459422 +0200 -@@ -18,6 +18,10 @@ mii\-tool \- view, manipulate media-inde - [\fB\-p\fR, \fB\-\-phy=\fIaddr\fR] - .RI "interface\ ..." - -+.SH NOTE -+.P -+This program is obsolete. For replacement check \fBethtool\fB. -+ - .SH DESCRIPTION - This utility checks or sets the status of a network interface's Media - Independent Interface (MII) unit. Most fast ethernet adapters use an -@@ -93,6 +97,9 @@ SIOCGMIIPHY on 'eth?' failed: Operation - The interface in question does not support MII queries. Most likely, it does not have - MII transceivers, at all. - -+.SH SEE ALSO -+ethtool(8) -+ - .SH AUTHORS - David Hinds \- dhinds@pcmcia.sourceforge.org - .br -diff -up net-tools-2.0/man/en_US/nameif.8.man net-tools-2.0/man/en_US/nameif.8 ---- net-tools-2.0/man/en_US/nameif.8.man 2014-04-26 02:45:16.000000000 +0200 -+++ net-tools-2.0/man/en_US/nameif.8 2014-07-07 14:51:31.379459422 +0200 -@@ -5,6 +5,12 @@ nameif \- name network interfaces based - .B "nameif [\-c configfile] [\-s]" - .br - .B "nameif [\-c configfile] [\-s] {interface macaddress}" -+ -+.SH NOTE -+.P -+This program is obsolete. For replacement check \fBip link\fR. -+This functionality is also much better provided by udev methods. -+ - .SH DESCRIPTION - .B nameif - renames network interfaces based on mac addresses. When no arguments are -@@ -31,5 +37,10 @@ should be run before the interface is up - - .SH FILES - /etc/mactab -+ -+.SH SEE ALSO -+.BR ip(8), -+.BR udev(7) -+ - .SH BUGS - Only works for Ethernet currently. -diff -up net-tools-2.0/man/en_US/netstat.8.man net-tools-2.0/man/en_US/netstat.8 ---- net-tools-2.0/man/en_US/netstat.8.man 2014-07-07 14:51:31.370459575 +0200 -+++ net-tools-2.0/man/en_US/netstat.8 2014-07-07 14:51:31.380459405 +0200 -@@ -198,7 +198,8 @@ Show the PID and name of the program to - .SS "\-l, \-\-listening" - Show only listening sockets. (These are omitted by default.) - .SS "\-a, \-\-all" --Show both listening and non-listening sockets. With the -+Show both listening and non-listening (for TCP this means established -+connections) sockets. With the - .B \-\-interfaces - option, show interfaces that are not up - .SS "\-F" -diff -up net-tools-2.0/man/en_US/route.8.man net-tools-2.0/man/en_US/route.8 ---- net-tools-2.0/man/en_US/route.8.man 2014-04-26 02:45:16.000000000 +0200 -+++ net-tools-2.0/man/en_US/route.8 2014-07-07 14:52:58.766977905 +0200 -@@ -57,6 +57,11 @@ family - .RB [ \-\-version ] - .RB [ \-h ] - .RB [ \-\-help ] -+ -+.SH NOTE -+.P -+This program is obsolete. For replacement check \fBip route\fR. -+ - .SH DESCRIPTION - .B Route - manipulates the kernel's IP routing tables. Its primary use is to set -@@ -330,10 +335,6 @@ Whether or not the hardware address for - .I /proc/net/rt_cache - .LP - .SH "SEE ALSO" --.IR ifconfig (8), --.IR netstat (8), --.IR arp (8), --.IR rarp (8), - .IR ip (8) - .LP - .SH HISTORY diff --git a/net-tools/patches/004-net-tools-interface.patch b/net-tools/patches/004-net-tools-interface.patch deleted file mode 100644 index abbc0ba3c..000000000 --- a/net-tools/patches/004-net-tools-interface.patch +++ /dev/null @@ -1,102 +0,0 @@ -diff -up net-tools-2.0/man/en_US/netstat.8.interface net-tools-2.0/man/en_US/netstat.8 ---- net-tools-2.0/man/en_US/netstat.8.interface 2014-11-24 14:52:45.648623478 +0100 -+++ net-tools-2.0/man/en_US/netstat.8 2014-11-24 14:53:32.294972184 +0100 -@@ -49,9 +49,9 @@ netstat \- Print network connections, ro - .RB [delay] - .P - .B netstat --.RB { \-\-interfaces | \-i } -+.RB { \-\-interfaces | \-I | \-i } - .RB [ \-\-all | \-a ] --.RB [ \-\-extend | \-e [ \-\-extend | \-e] ] -+.RB [ \-\-extend | \-e ] - .RB [ \-\-verbose | \-v ] - .RB [ \-\-program | \-p ] - .RB [ \-\-numeric | \-n ] -@@ -134,8 +134,8 @@ and - produce the same output. - .SS "\-\-groups, \-g" - Display multicast group membership information for IPv4 and IPv6. --.SS "\-\-interfaces, \-i" --Display a table of all network interfaces. -+.SS "\-\-interfaces=\fIiface \fR, \fB\-I=\fIiface \fR, \fB\-i" -+Display a table of all network interfaces, or the specified \fIiface\fR. - .SS "\-\-masquerade, \-M" - Display a list of masqueraded connections. - .SS "\-\-statistics, \-s" -diff -up net-tools-2.0/netstat.c.interface net-tools-2.0/netstat.c ---- net-tools-2.0/netstat.c.interface 2014-11-24 14:52:45.644623534 +0100 -+++ net-tools-2.0/netstat.c 2014-11-24 14:52:45.652623422 +0100 -@@ -144,6 +144,7 @@ static char *Release = RELEASE, *Signatu - #define E_IOCTL -3 - - int flag_int = 0; -+char *flag_int_name = NULL; - int flag_rou = 0; - int flag_mas = 0; - int flag_sta = 0; -@@ -1788,6 +1789,7 @@ static int rfcomm_info(void) - static int iface_info(void) - { - static int count=0; -+ struct interface *ife = NULL; - - if (skfd < 0) { - if ((skfd = sockets_open(0)) < 0) { -@@ -1802,7 +1804,11 @@ static int iface_info(void) - printf(_("Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n")); - } - -- if (for_all_interfaces(do_if_print, &flag_all) < 0) { -+ if (flag_int_name) { -+ ife = lookup_interface(flag_int_name); -+ do_if_print(ife, &flag_all); -+ } -+ else if (for_all_interfaces(do_if_print, &flag_all) < 0) { - perror(_("missing interface information")); - exit(1); - } -@@ -1828,9 +1834,10 @@ static void usage(void) - { - fprintf(stderr, _("usage: netstat [-vWeenNcCF] [] -r netstat {-V|--version|-h|--help}\n")); - fprintf(stderr, _(" netstat [-vWnNcaeol] [ ...]\n")); -- fprintf(stderr, _(" netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay]\n\n")); -+ fprintf(stderr, _(" netstat { [-vWeenNac] -I[] | [-veenNac] -i | [-cnNe] -M | -s [-6tuw] } [delay]\n\n")); - - fprintf(stderr, _(" -r, --route display routing table\n")); -+ fprintf(stderr, _(" -I, --interfaces= display interface table for \n")); - fprintf(stderr, _(" -i, --interfaces display interface table\n")); - fprintf(stderr, _(" -g, --groups display multicast group memberships\n")); - fprintf(stderr, _(" -s, --statistics display networking statistics (like SNMP)\n")); -@@ -1875,7 +1882,7 @@ int main - { - AFTRANS_OPTS, - {"version", 0, 0, 'V'}, -- {"interfaces", 0, 0, 'i'}, -+ {"interfaces", 2, 0, 'I'}, - {"help", 0, 0, 'h'}, - {"route", 0, 0, 'r'}, - #if HAVE_FW_MASQUERADE -@@ -1919,7 +1926,7 @@ int main - getroute_init(); /* Set up AF routing support */ - - afname[0] = '\0'; -- while ((i = getopt_long(argc, argv, "A:CFMacdeghilnNoprsStuUvVWw2fx64?Z", longopts, &lop)) != EOF) -+ while ((i = getopt_long(argc, argv, "A:CFMacdeghiI::lnNoprsStuUvVWw2fx64?Z", longopts, &lop)) != EOF) - switch (i) { - case -1: - break; -@@ -1960,6 +1967,13 @@ int main - case 'p': - flag_prg++; - break; -+ case 'I': -+ if (optarg && strcmp(optarg, "(null)")) -+ if (optarg[0] == '=') optarg++; -+ if (optarg && strcmp(optarg, "(null)")) -+ flag_int_name = strdup(optarg); -+ flag_int++; -+ break; - case 'i': - flag_int++; - break; diff --git a/net-tools/patches/005-net-tools-duplicate-tcp.patch b/net-tools/patches/005-net-tools-duplicate-tcp.patch deleted file mode 100644 index 393d27235..000000000 --- a/net-tools/patches/005-net-tools-duplicate-tcp.patch +++ /dev/null @@ -1,146 +0,0 @@ -diff -up net-tools-2.0/netstat.c.dup-tcp net-tools-2.0/netstat.c ---- net-tools-2.0/netstat.c.dup-tcp 2012-10-04 11:32:01.437729086 +0200 -+++ net-tools-2.0/netstat.c 2012-10-04 11:32:01.441729032 +0200 -@@ -502,6 +502,121 @@ static void prg_cache_load(void) - " will not be shown, you would have to be root to see it all.)\n")); - } - -+#define TCP_HASH_SIZE 1009 -+ -+static struct tcp_node { -+ struct tcp_node *next; -+ char *socket_pair; -+} *tcp_node_hash[TCP_HASH_SIZE]; -+ -+static unsigned int tcp_node_compute_string_hash(const char *p) -+{ -+ unsigned int h = *p; -+ -+ if (h) -+ for (p += 1; *p != '\0'; p++) -+ h = (h << 5) - h + *p; -+ -+ return h; -+} -+ -+#define TCP_NODE_HASH_STRING(x) \ -+ (tcp_node_compute_string_hash(x) % TCP_HASH_SIZE) -+ -+static void tcp_node_hash_clear(void) -+{ -+ int i; -+ struct tcp_node *next_node; -+ struct tcp_node *tmp_node; -+ for (i=0; i < TCP_HASH_SIZE; i++) { -+ if (tcp_node_hash[i]) { -+ /* free the children of this hash bucket */ -+ next_node = tcp_node_hash[i]->next; -+ while (next_node) { -+ tmp_node = next_node; -+ next_node = next_node->next; -+ free(tmp_node->socket_pair); -+ free(tmp_node); -+ } -+ -+ /* free the bucket itself */ -+ free(tcp_node_hash[i]->socket_pair); -+ free(tcp_node_hash[i]); -+ tcp_node_hash[i] = NULL; -+ } -+ } -+} -+ -+/* This function takes a socket pair string. If it already exists in -+ the hash it returns -1, otherwise it returns 0. */ -+ -+static int tcp_node_hash_check_and_append(const char *local_addr, -+ int local_port, -+ const char *rem_addr, -+ int rem_port) -+{ -+ unsigned int hash_val; -+ struct tcp_node *tmp_node; -+ int tmp_string_len; -+ char *tmp_string;; -+ -+ /* Size of the string is the size of the two lengths of the address -+ strings plus enough sizes for the colons and the ports. */ -+ tmp_string_len = strlen(local_addr) + strlen(rem_addr) + 32; -+ tmp_string = malloc(tmp_string_len); -+ if (!tmp_string) -+ return 0; -+ -+ if (snprintf(tmp_string, tmp_string_len - 1, "%s:%d:%s:%d", -+ local_addr, local_port, rem_addr, rem_port) < 0) { -+ free(tmp_string); -+ return 0; -+ } -+ -+ hash_val = TCP_NODE_HASH_STRING(tmp_string); -+ -+ /* See if we have to allocate this node */ -+ if (!tcp_node_hash[hash_val]) { -+ tcp_node_hash[hash_val] = malloc(sizeof(struct tcp_node)); -+ if (!tcp_node_hash[hash_val]) { -+ free(tmp_string); -+ return 0; -+ } -+ -+ memset(tcp_node_hash[hash_val], 0, sizeof(struct tcp_node)); -+ -+ /* Stuff this new value into the hash bucket and return early */ -+ tcp_node_hash[hash_val]->socket_pair = tmp_string; -+ return 0; -+ } -+ -+ /* Try to find the value in the hash bucket. */ -+ tmp_node = tcp_node_hash[hash_val]; -+ while (tmp_node) { -+ if (!strcmp(tmp_node->socket_pair, tmp_string)) { -+ free(tmp_string); -+ return -1; -+ } -+ tmp_node = tmp_node->next; -+ } -+ -+ /* If we got this far it means that it isn't in the hash bucket. -+ Add it to the front since it's faster that way. */ -+ tmp_node = tcp_node_hash[hash_val]; -+ -+ tcp_node_hash[hash_val] = malloc(sizeof(struct tcp_node)); -+ if (!tcp_node_hash[hash_val]) { -+ free(tmp_string); -+ tcp_node_hash[hash_val] = tmp_node; -+ return 0; -+ } -+ -+ tcp_node_hash[hash_val]->socket_pair = tmp_string; -+ tcp_node_hash[hash_val]->next = tmp_node; -+ -+ return 0; -+} -+ - #if HAVE_AFNETROM - static const char *netrom_state[] = - { -@@ -1018,6 +1133,12 @@ static void tcp_do_one(int lnr, const ch - return; - } - -+ /* make sure that we haven't seen this socket pair before */ -+ if (tcp_node_hash_check_and_append(local_addr, local_port, rem_addr, rem_port) < 0) { -+ /* fprintf(stderr, _("warning, got duplicate tcp line.\n")); */ -+ return; -+ } -+ - addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localaddr, local_port, "tcp"); - addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remaddr, rem_port, "tcp"); - -@@ -2355,6 +2476,7 @@ int main - break; - wait_continous(reptimer); - prg_cache_clear(); -+ tcp_node_hash_clear(); - } - return (i); - } diff --git a/net-tools/patches/006-net-tools-statalias.patch b/net-tools/patches/006-net-tools-statalias.patch deleted file mode 100644 index b544ff409..000000000 --- a/net-tools/patches/006-net-tools-statalias.patch +++ /dev/null @@ -1,16 +0,0 @@ -diff -up net-tools-2.0/lib/interface.c.statalias net-tools-2.0/lib/interface.c ---- net-tools-2.0/lib/interface.c.statalias 2012-10-04 11:33:05.490889090 +0200 -+++ net-tools-2.0/lib/interface.c 2012-10-04 11:33:05.513888785 +0200 -@@ -405,9 +405,11 @@ static int if_readlist_rep(char *target, - char *s, name[IFNAMSIZ]; - s = get_name(name, buf); - get_dev_fields(s, ife); -- ife->statistics_valid = 1; - if (target && !strcmp(target,name)) -+ { -+ ife->statistics_valid = 1; - break; -+ } - } - if (ferror(fh)) { - perror(_PATH_PROCNET_DEV); diff --git a/net-tools/patches/007-net-tools-interface_stack.patch b/net-tools/patches/007-net-tools-interface_stack.patch deleted file mode 100644 index 6a93e6741..000000000 --- a/net-tools/patches/007-net-tools-interface_stack.patch +++ /dev/null @@ -1,119 +0,0 @@ -diff -up net-tools-2.0/include/interface.h.stack net-tools-2.0/include/interface.h -diff -up net-tools-2.0/lib/interface.c.stack net-tools-2.0/lib/interface.c ---- net-tools-2.0/lib/interface.c.stack 2014-11-24 14:54:32.293134466 +0100 -+++ net-tools-2.0/lib/interface.c 2014-11-24 15:07:58.434764441 +0100 -@@ -214,10 +214,11 @@ out: - return err; - } - --static const char *get_name(char *name, const char *p) -+static const char *get_name(char **namep, const char *p) - { - while (isspace(*p)) - p++; -+ char *name = *namep = p; - while (*p) { - if (isspace(*p)) - break; -@@ -320,9 +321,10 @@ static int get_dev_fields(const char *bp - static int if_readlist_proc(const char *target) - { - FILE *fh; -- char buf[512]; - struct interface *ife; - int err; -+ char *line = NULL; -+ size_t linelen = 0; - - fh = fopen(_PATH_PROCNET_DEV, "r"); - if (!fh) { -@@ -330,10 +332,11 @@ static int if_readlist_proc(const char * - _PATH_PROCNET_DEV, strerror(errno)); - return -2; - } -- if (fgets(buf, sizeof buf, fh)) -- /* eat line */; -- if (fgets(buf, sizeof buf, fh)) -- /* eat line */; -+ if (getline(&line, &linelen, fh) == -1 /* eat line */ -+ || getline(&line, &linelen, fh) == -1) { /* eat line */ -+ err = -1; -+ goto out; -+ } - - #if 0 /* pretty, but can't cope with missing fields */ - fmt = proc_gen_fmt(_PATH_PROCNET_DEV, 1, fh, -@@ -358,14 +361,14 @@ static int if_readlist_proc(const char * - if (!fmt) - return -1; - #else -- procnetdev_vsn = procnetdev_version(buf); -+ procnetdev_vsn = procnetdev_version(line); - #endif - - err = 0; -- while (fgets(buf, sizeof buf, fh)) { -+ while (getline(&line, &linelen, fh) != -1) { - const char *s; -- char name[IFNAMSIZ]; -- s = get_name(name, buf); -+ char *name; -+ s = get_name(&name, line); - ife = if_cache_add(name); - get_dev_fields(s, ife); - ife->statistics_valid = 1; -@@ -380,6 +383,8 @@ static int if_readlist_proc(const char * - #if 0 - free(fmt); - #endif -+ out: -+ free(line); - fclose(fh); - return err; - } -@@ -387,24 +392,28 @@ static int if_readlist_proc(const char * - static int if_readlist_rep(const char *target, struct interface *ife) - { - FILE *fh; -- char buf[512]; - int err; -+ char *line = NULL; -+ size_t linelen = 0; - - fh = fopen(_PATH_PROCNET_DEV, "r"); - if (!fh) { - fprintf(stderr, _("Warning: cannot open %s (%s). Limited output.\n"), - _PATH_PROCNET_DEV, strerror(errno)); - return if_readconf(); -- } -- fgets(buf, sizeof buf, fh); /* eat line */ -- fgets(buf, sizeof buf, fh); -+ } -+ if (getline(&line, &linelen, fh) == -1 /* eat line */ -+ || getline(&line, &linelen, fh) == -1) { /* eat line */ -+ err = -1; -+ goto out; -+ } - -- procnetdev_vsn = procnetdev_version(buf); -+ procnetdev_vsn = procnetdev_version(line); - - err = 0; -- while (fgets(buf, sizeof buf, fh)) { -- char *s, name[IFNAMSIZ]; -- s = get_name(name, buf); -+ while (getline(&line, &linelen, fh) != -1) { -+ char *s, *name; -+ s = get_name(&name, line); - get_dev_fields(s, ife); - if (target && !strcmp(target,name)) - { -@@ -417,6 +426,8 @@ static int if_readlist_rep(const char *t - err = -1; - } - -+ out: -+ free(line); - fclose(fh); - return err; - } diff --git a/net-tools/patches/008-net-tools-sctp-statistics.patch b/net-tools/patches/008-net-tools-sctp-statistics.patch deleted file mode 100644 index b84b8aa18..000000000 --- a/net-tools/patches/008-net-tools-sctp-statistics.patch +++ /dev/null @@ -1,534 +0,0 @@ -diff -up net-tools-2.0/netstat.c.sctp net-tools-2.0/netstat.c ---- net-tools-2.0/netstat.c.sctp 2013-09-23 15:14:59.524866201 +0200 -+++ net-tools-2.0/netstat.c 2013-09-23 15:24:20.259143969 +0200 -@@ -115,7 +115,7 @@ - #endif - - /* prototypes for statistics.c */ --int parsesnmp(int, int, int); -+int parsesnmp(int, int, int, int); - void inittab(void); - int parsesnmp6(int, int, int); - void inittab6(void); -@@ -888,159 +888,269 @@ static int igmp_info(void) - igmp_do_one, "igmp", "igmp6"); - } - --static int ip_parse_dots(uint32_t *addr, char const *src) { -- unsigned a, b, c, d; -- unsigned ret = 4-sscanf(src, "%u.%u.%u.%u", &a, &b, &c, &d); -- *addr = htonl((a << 24)|(b << 16)|(c << 8)|d); -- return ret; --} -- --static void print_ip_service(struct sockaddr_in *addr, char const *protname, -- char *buf, unsigned size) { -- struct aftype *ap; -- -- if(size == 0) return; -- -- /* print host */ -- if((ap = get_afntype(addr->sin_family)) == NULL) { -- fprintf(stderr, _("netstat: unsupported address family %d !\n"), -- addr->sin_family); -- return; -- } -- safe_strncpy(buf, ap->sprint((struct sockaddr*)addr, flag_not), size); -- -- /* print service */ -- if(flag_all || (flag_lst && !addr->sin_port) || (!flag_lst && addr->sin_port)) { -- char bfs[32]; -- -- snprintf(bfs, sizeof(bfs), "%s", -- get_sname(addr->sin_port, (char*)protname, flag_not & FLAG_NUM_PORT)); -- -- /* check if we must cut on host and/or service name */ -- { -- unsigned const bufl = strlen(buf); -- unsigned const bfsl = strlen(bfs); -- -- if(bufl+bfsl+2 > size) { -- unsigned const half = (size-2)>>1; -- if(bufl > half) { -- if(bfsl > half) { -- buf[size-2-half] = '\0'; -- bfs[half+1] = '\0'; -- } -- else buf[size-2-bfsl] = '\0'; -- } -- else bfs[size-2-bufl] = '\0'; -- } -+static const char *sctp_socket_state_str(int state) -+{ -+ if(state>=0 && state<=10) -+ return tcp_state[state]; -+ else { -+ static char state_str_buf[64]; -+ sprintf(state_str_buf,"UNKNOWN(%d)",state); -+ return state_str_buf; - } -- strcat(buf, ":"); -- strcat(buf, bfs); -- } - } - --/* process single SCTP endpoint */ --static void sctp_do_ept(int lnr, char const *line, const char *prot) -+static struct aftype *process_sctp_addr_str(const char *addr_str, struct sockaddr *sa) - { -- struct sockaddr_in laddr, raddr; -- unsigned uid, inode; -- -- char l_addr[23], r_addr[23]; -- -- /* fill sockaddr_in structures */ -- { -- unsigned lport; -- unsigned ate; -- -- if(lnr == 0) return; -- if(sscanf(line, "%*X %*X %*u %*u %*u %u %u %u %n", -- &lport, &uid, &inode, &ate) < 3) goto err; -- -- /* decode IP address */ -- if(ip_parse_dots(&laddr.sin_addr.s_addr, line+ate)) goto err; -- raddr.sin_addr.s_addr = htonl(0); -- laddr.sin_family = raddr.sin_family = AF_INET; -- laddr.sin_port = htons(lport); -- raddr.sin_port = htons(0); -- } -+ if (strchr(addr_str,':')) { -+#if HAVE_AFINET6 -+ extern struct aftype inet6_aftype; -+ /* Demangle what the kernel gives us */ -+ struct in6_addr in6; -+ char addr6_str[INET6_ADDRSTRLEN]; -+ unsigned u0,u1,u2,u3,u4,u5,u6,u7; -+ sscanf(addr_str, "%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X", -+ &u0, &u1, &u2, &u3, &u4, &u5, &u6, &u7); -+ in6.s6_addr16[0] = htons(u0); -+ in6.s6_addr16[1] = htons(u1); -+ in6.s6_addr16[2] = htons(u2); -+ in6.s6_addr16[3] = htons(u3); -+ in6.s6_addr16[4] = htons(u4); -+ in6.s6_addr16[5] = htons(u5); -+ in6.s6_addr16[6] = htons(u6); -+ in6.s6_addr16[7] = htons(u7); -+ -+ inet_ntop(AF_INET6, &in6, addr6_str, sizeof(addr6_str)); -+ inet6_aftype.input(1, addr6_str, sa); -+ sa->sa_family = AF_INET6; -+#endif -+ } else { -+ ((struct sockaddr_in*)sa)->sin_addr.s_addr = inet_addr(addr_str); -+ sa->sa_family = AF_INET; -+ } -+ return get_afntype(sa->sa_family); -+} - -- /* print IP:service to l_addr and r_addr */ -- print_ip_service(&laddr, prot, l_addr, sizeof(l_addr)); -- print_ip_service(&raddr, prot, r_addr, sizeof(r_addr)); -- -- /* Print line */ -- printf("%-4s %6d %6d %-*s %-*s %-11s", -- prot, 0, 0, -- (int)netmax(23,strlen(l_addr)), l_addr, -- (int)netmax(23,strlen(r_addr)), r_addr, -- _(tcp_state[TCP_LISTEN])); -- finish_this_one(uid, inode, ""); -- return; -- err: -- fprintf(stderr, "SCTP error in line: %d\n", lnr); --} -- --/* process single SCTP association */ --static void sctp_do_assoc(int lnr, char const *line, const char *prot) --{ -- struct sockaddr_in laddr, raddr; -- unsigned long rxq, txq; -- unsigned uid, inode; -- -- char l_addr[23], r_addr[23]; -- -- /* fill sockaddr_in structures */ -- { -- unsigned lport, rport; -- unsigned ate; -- char const *addr; -- -- if(lnr == 0) return; -- if(sscanf(line, "%*X %*X %*u %*u %*u %*u %*u %lu %lu %u %u %u %u %n", -- &txq, &rxq, &uid, &inode, &lport, &rport, &ate) < 6) goto err; -- -- /* decode IP addresses */ -- addr = strchr(line+ate, '*'); -- if(addr == 0) goto err; -- if(ip_parse_dots(&laddr.sin_addr.s_addr, ++addr)) goto err; -- addr = strchr(addr, '*'); -- if(addr == 0) goto err; -- if(ip_parse_dots(&raddr.sin_addr.s_addr, ++addr)) goto err; -- -- /* complete sockaddr_in structures */ -- laddr.sin_family = raddr.sin_family = AF_INET; -- laddr.sin_port = htons(lport); -- raddr.sin_port = htons(rport); -- } -+static void sctp_eps_do_one(int lnr, char *line, const char *proto) -+{ -+ char buffer[1024]; -+ int state, port; -+ int uid; -+ unsigned long inode; -+ struct aftype *ap; -+#if HAVE_AFINET6 -+ struct sockaddr_in6 localaddr; -+#else -+ struct sockaddr_in localaddr; -+#endif -+ const char *sst_str; -+ const char *lport_str; -+ const char *uid_str; -+ const char *inode_str; -+ char *laddrs_str; -+ -+ if(lnr == 0) { -+ /* ENDPT SOCK STY SST HBKT LPORT UID INODE LADDRS */ -+ return; -+ } -+ strtok(line," \t\n"); /*skip endpt*/ -+ strtok(0," \t\n"); /*skip sock*/ -+ strtok(0," \t\n"); /*skp sty*/ -+ sst_str = strtok(0," \t\n"); -+ strtok(0," \t\n"); /*skip hash bucket*/ -+ lport_str=strtok(0," \t\n"); -+ uid_str = strtok(0," \t\n"); -+ inode_str = strtok(0," \t\n"); -+ laddrs_str=strtok(0,"\t\n"); -+ -+ if (!sst_str || !lport_str || !uid_str || !inode_str) { -+ fprintf(stderr, _("warning, got bogus sctp eps line.\n")); -+ return; -+ } -+ state = atoi(sst_str); -+ port = atoi(lport_str); -+ uid = atoi(uid_str); -+ inode = strtoul(inode_str,0,0); -+ -+ const char *this_local_addr; -+ int first=1; -+ char local_port[16]; -+ snprintf(local_port, sizeof(local_port), "%s", -+ get_sname(htons(port), proto, flag_not & FLAG_NUM_PORT)); -+ for(this_local_addr=strtok(laddrs_str," \t\n"); -+ this_local_addr; -+ this_local_addr=strtok(0," \t\n")) -+ { -+ char local_addr[64]; -+ ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); -+ if(ap) -+ safe_strncpy(local_addr, -+ ap->sprint((struct sockaddr *) &localaddr, flag_not), -+ sizeof(local_addr)); -+ else -+ sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); -+ -+ if(!first) printf("\n"); -+ if(first) -+ printf("sctp "); -+ else -+ printf(" "); -+ sprintf(buffer,"%s:%s", local_addr, local_port); -+ printf("%-47s", buffer); -+ printf(" %-11s", first?sctp_socket_state_str(state):""); -+ first = 0; -+ } -+ finish_this_one(uid,inode,""); -+} -+ -+static void sctp_assoc_do_one(int lnr, char *line, const char *proto) -+{ -+ char buffer[1024]; -+ int state, lport,rport; -+ int uid; -+ unsigned rxqueue,txqueue; -+ unsigned long inode; -+ -+ struct aftype *ap; -+#if HAVE_AFINET6 -+ struct sockaddr_in6 localaddr,remoteaddr; -+#else -+ struct sockaddr_in localaddr,remoteaddr; -+#endif -+ const char *sst_str; -+ const char *txqueue_str; -+ const char *rxqueue_str; -+ const char *lport_str,*rport_str; -+ const char *uid_str; -+ const char *inode_str; -+ char *laddrs_str; -+ char *raddrs_str; -+ -+ if(lnr == 0) { -+ /* ASSOC SOCK STY SST ST HBKT ASSOC-ID TX_QUEUE RX_QUEUE UID INODE LPORT RPORT LADDRS <-> RADDRS */ -+ return; -+ } -+ -+ strtok(line," \t\n"); /*skip assoc*/ -+ strtok(0," \t\n"); /*skip sock*/ -+ strtok(0," \t\n"); /*skp sty*/ -+ sst_str = strtok(0," \t\n"); -+ strtok(0," \t\n"); -+ strtok(0," \t\n"); /*skip hash bucket*/ -+ strtok(0," \t\n"); /*skip hash assoc-id*/ -+ txqueue_str = strtok(0," \t\n"); -+ rxqueue_str = strtok(0," \t\n"); -+ uid_str = strtok(0," \t\n"); -+ inode_str = strtok(0," \t\n"); -+ lport_str=strtok(0," \t\n"); -+ rport_str=strtok(0," \t\n"); -+ laddrs_str = strtok(0,"<->\t\n"); -+ raddrs_str = strtok(0,"<->\t\n"); -+ -+ if (!sst_str || !txqueue_str || !rxqueue_str || !uid_str || -+ !inode_str || !lport_str || !rport_str) { -+ fprintf(stderr, _("warning, got bogus sctp assoc line.\n")); -+ return; -+ } -+ -+ state = atoi(sst_str); -+ txqueue = atoi(txqueue_str); -+ rxqueue = atoi(rxqueue_str); -+ uid = atoi(uid_str); -+ inode = strtoul(inode_str,0,0); -+ lport = atoi(lport_str); -+ rport = atoi(rport_str); -+ -+ /*print all addresses*/ -+ const char *this_local_addr; -+ const char *this_remote_addr; -+ char *ss1,*ss2; -+ int first=1; -+ char local_port[16]; -+ char remote_port[16]; -+ snprintf(local_port, sizeof(local_port), "%s", -+ get_sname(htons(lport), proto, -+ flag_not & FLAG_NUM_PORT)); -+ snprintf(remote_port, sizeof(remote_port), "%s", -+ get_sname(htons(rport), proto, -+ flag_not & FLAG_NUM_PORT)); -+ -+ this_local_addr=strtok_r(laddrs_str," \t\n",&ss1); -+ this_remote_addr=strtok_r(raddrs_str," \t\n",&ss2); -+ while(this_local_addr || this_remote_addr) { -+ char local_addr[64]; -+ char remote_addr[64]; -+ -+ if(this_local_addr) { -+ if (this_local_addr[0] == '*') { -+ /* skip * */ -+ this_local_addr++; -+ } -+ ap = process_sctp_addr_str(this_local_addr, (struct sockaddr*)&localaddr); -+ if(ap) -+ safe_strncpy(local_addr, -+ ap->sprint((struct sockaddr *) &localaddr, flag_not), sizeof(local_addr)); -+ else -+ sprintf(local_addr,_("unsupported address family %d"), ((struct sockaddr*)&localaddr)->sa_family); -+ } -+ if(this_remote_addr) { -+ if (this_remote_addr[0] == '*') { -+ /* skip * */ -+ this_remote_addr++; -+ } -+ ap = process_sctp_addr_str(this_remote_addr, (struct sockaddr*)&remoteaddr); -+ if(ap) -+ safe_strncpy(remote_addr, -+ ap->sprint((struct sockaddr *) &remoteaddr, flag_not), sizeof(remote_addr)); -+ else -+ sprintf(remote_addr,_("unsupported address family %d"), ((struct sockaddr*)&remoteaddr)->sa_family); -+ } - -- /* print IP:service to l_addr and r_addr */ -- print_ip_service(&laddr, prot, l_addr, sizeof(l_addr)); -- print_ip_service(&raddr, prot, r_addr, sizeof(r_addr)); -- -- /* Print line */ -- printf("%-4s %6ld %6ld %-*s %-*s %-11s", -- prot, rxq, txq, -- (int)netmax(23,strlen(l_addr)), l_addr, -- (int)netmax(23,strlen(r_addr)), r_addr, -- _(tcp_state[TCP_ESTABLISHED])); -- finish_this_one(uid, inode, ""); -- return; -- err: -- fprintf(stderr, "SCTP error in line: %d\n", lnr); -+ if(!first) printf("\n"); -+ if(first) -+ printf("sctp %6u %6u ", rxqueue, txqueue); -+ else -+ printf(" "); -+ if(this_local_addr) { -+ if(first) -+ sprintf(buffer,"%s:%s", local_addr, local_port); -+ else -+ sprintf(buffer,"%s", local_addr); -+ printf("%-23s", buffer); -+ } else -+ printf("%-23s", ""); -+ printf(" "); -+ if(this_remote_addr) { -+ if(first) -+ sprintf(buffer,"%s:%s", remote_addr, remote_port); -+ else -+ sprintf(buffer,"%s", remote_addr); -+ printf("%-23s", buffer); -+ } else -+ printf("%-23s", ""); -+ -+ printf(" %-11s", first?sctp_socket_state_str(state):""); -+ -+ first = 0; -+ this_local_addr=strtok_r(0," \t\n",&ss1); -+ this_remote_addr=strtok_r(0," \t\n",&ss2); -+ } -+ finish_this_one(uid,inode,""); - } - --static int sctp_info_epts(void) { -+static int sctp_info_eps(void) -+{ - INFO_GUTS6(_PATH_PROCNET_SCTPEPTS, _PATH_PROCNET_SCTP6EPTS, "AF INET (sctp)", -- sctp_do_ept, "sctp", "sctp6"); -+ sctp_eps_do_one, "sctp", "sctp6"); - } - - static int sctp_info_assocs(void) { - INFO_GUTS6(_PATH_PROCNET_SCTPASSOCS, _PATH_PROCNET_SCTP6ASSOCS, "AF INET (sctp)", -- sctp_do_assoc, "sctp", "sctp6"); -+ sctp_assoc_do_one, "sctp", "sctp6"); - } - - static int sctp_info(void) { - int res; -- res = sctp_info_epts(); -+ res = sctp_info_eps(); - if(res) return res; - return sctp_info_assocs(); - } -@@ -2234,7 +2344,7 @@ int main - if (!strcmp(afname, "inet")) { - #if HAVE_AFINET - inittab(); -- i = parsesnmp(flag_raw, flag_tcp, flag_udp); -+ i = parsesnmp(flag_raw, flag_tcp, flag_udp, flag_sctp); - #else - ENOSUPP("netstat", "AF INET"); - #endif -diff -up net-tools-2.0/statistics.c.sctp net-tools-2.0/statistics.c ---- net-tools-2.0/statistics.c.sctp 2013-09-23 15:14:59.501866518 +0200 -+++ net-tools-2.0/statistics.c 2013-09-23 15:14:59.534866063 +0200 -@@ -21,7 +21,7 @@ - #define UFWARN(x) - #endif - --int print_static,f_raw,f_tcp,f_udp,f_unknown = 1; -+int print_static,f_raw,f_tcp,f_udp,f_sctp,f_unknown = 1; - - enum State { - number = 0, opt_number, i_forward, i_inp_icmp, i_outp_icmp, i_rto_alg, -@@ -299,6 +299,27 @@ struct entry Tcpexttab[] = - { "TCPRenoRecoveryFail", N_("%llu classic Reno fast retransmits failed"), opt_number }, - }; - -+struct entry Sctptab[] = -+{ -+ {"SctpCurrEstab", N_("%llu Current Associations"), number}, -+ {"SctpActiveEstabs", N_("%llu Active Associations"), number}, -+ {"SctpPassiveEstabs", N_("%llu Passive Associations"), number}, -+ {"SctpAborteds", N_("%llu Number of Aborteds "), number}, -+ {"SctpShutdowns", N_("%llu Number of Graceful Terminations"), number}, -+ {"SctpOutOfBlues", N_("%llu Number of Out of Blue packets"), number}, -+ {"SctpChecksumErrors", N_("%llu Number of Packets with invalid Checksum"), number}, -+ {"SctpOutCtrlChunks", N_("%llu Number of control chunks sent"), number}, -+ {"SctpOutOrderChunks", N_("%llu Number of ordered chunks sent"), number}, -+ {"SctpOutUnorderChunks", N_("%llu Number of Unordered chunks sent"), number}, -+ {"SctpInCtrlChunks", N_("%llu Number of control chunks received"), number}, -+ {"SctpInOrderChunks", N_("%llu Number of ordered chunks received"), number}, -+ {"SctpInUnorderChunks", N_("%llu Number of Unordered chunks received"), number}, -+ {"SctpFragUsrMsgs", N_("%llu Number of messages fragmented"), number}, -+ {"SctpReasmUsrMsgs", N_("%llu Number of messages reassembled "), number}, -+ {"SctpOutSCTPPacks", N_("%llu Number of SCTP packets sent"), number}, -+ {"SctpInSCTPPacks", N_("%llu Number of SCTP packets received"), number}, -+}; -+ - struct tabtab { - char *title; - struct entry *tab; -@@ -312,6 +333,7 @@ struct tabtab snmptabs[] = - {"Icmp", Icmptab, sizeof(Icmptab), &f_raw}, - {"Tcp", Tcptab, sizeof(Tcptab), &f_tcp}, - {"Udp", Udptab, sizeof(Udptab), &f_udp}, -+ {"Sctp", Sctptab, sizeof(Sctptab), &f_sctp}, - {"TcpExt", Tcpexttab, sizeof(Tcpexttab), &f_tcp}, - {NULL} - }; -@@ -502,11 +524,38 @@ void process6_fd(FILE *f) - - } - --int parsesnmp(int flag_raw, int flag_tcp, int flag_udp) -+/* Process a file with name-value lines (like /proc/net/sctp/snmp) */ -+void process_fd2(FILE *f, const char *filename) -+{ -+ char buf1[1024]; -+ char *sp; -+ struct tabtab *tab; -+ -+ tab = newtable(snmptabs, "Sctp"); -+ -+ while (fgets(buf1, sizeof buf1, f)) { -+ sp = buf1 + strcspn(buf1, " \t\n"); -+ if (!sp) { -+ fprintf(stderr,_("error parsing %s\n"), filename); -+ return; -+ } -+ *sp = '\0'; -+ sp++; -+ -+ sp += strspn(sp, " \t\n"); -+ -+ if (*sp != '\0' && *(tab->flag)) -+ printval(tab, buf1, strtoul(sp, 0, 10)); -+ } -+ return; -+} -+ -+int parsesnmp(int flag_raw, int flag_tcp, int flag_udp, int flag_sctp) -+ - { - FILE *f; - -- f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp; -+ f_raw = flag_raw; f_tcp = flag_tcp; f_udp = flag_udp; f_sctp = flag_sctp; - - f = proc_fopen("/proc/net/snmp"); - if (!f) { -@@ -539,6 +588,17 @@ int parsesnmp(int flag_raw, int flag_tcp - - fclose(f); - } -+ -+ f = proc_fopen("/proc/net/sctp/snmp"); -+ if (f) { -+ process_fd2(f,"/proc/net/sctp/snmp"); -+ if (ferror(f)) { -+ perror("/proc/net/sctp/snmp"); -+ fclose(f); -+ return(1); -+ } -+ } -+ - return(0); - } - diff --git a/net-tools/patches/009-net-tools-ifconfig-long-iface-crasher.patch b/net-tools/patches/009-net-tools-ifconfig-long-iface-crasher.patch deleted file mode 100644 index d1ba07720..000000000 --- a/net-tools/patches/009-net-tools-ifconfig-long-iface-crasher.patch +++ /dev/null @@ -1,36 +0,0 @@ -diff -up net-tools-2.0/lib/interface.c.long_iface net-tools-2.0/lib/interface.c ---- net-tools-2.0/lib/interface.c.long_iface 2014-11-24 15:09:45.130254503 +0100 -+++ net-tools-2.0/lib/interface.c 2014-11-24 15:10:54.662270496 +0100 -@@ -216,6 +216,7 @@ out: - - static const char *get_name(char **namep, const char *p) - { -+ int count = 0; - while (isspace(*p)) - p++; - char *name = *namep = p; -@@ -224,7 +225,13 @@ static const char *get_name(char **namep - break; - if (*p == ':') { /* could be an alias */ - const char *dot = p++; -- while (*p && isdigit(*p)) p++; -+ count++; -+ while (*p && isdigit(*p)) { -+ p++; -+ count++; -+ if (count == (IFNAMSIZ-1)) -+ break; -+ } - if (*p == ':') { - /* Yes it is, backup and copy it. */ - p = dot; -@@ -240,6 +247,9 @@ static const char *get_name(char **namep - break; - } - *name++ = *p++; -+ count++; -+ if (count == (IFNAMSIZ-1)) -+ break; - } - *name++ = '\0'; - return p;