Index: Makefile
===================================================================
--- Makefile (nonexistent)
+++ Makefile (revision 5)
@@ -0,0 +1,56 @@
+
+COMPONENT_TARGETS = $(HARDWARE_NOARCH)
+
+
+include ../../../../build-system/constants.mk
+
+
+url = $(DOWNLOAD_SERVER)/sources/packages/n/net-tools
+
+versions = 1.60-20210110
+pkgname = net-tools
+suffix = tar.bz2
+
+tarballs = $(addsuffix .$(suffix), $(addprefix $(pkgname)-, $(versions)))
+sha1s = $(addsuffix .sha1sum, $(tarballs))
+
+patches = $(CURDIR)/patches/net-tools-1.60-20210110.patch
+
+.NOTPARALLEL: $(patches)
+
+
+BUILD_TARGETS = $(tarballs) $(sha1s) $(patches)
+
+
+include ../../../../build-system/core.mk
+
+
+.PHONY: download_clean
+
+
+$(tarballs):
+ @echo -e "\n======= Downloading source tarballs =======" ; \
+ for tarball in $(tarballs) ; do \
+ echo "$(url)/$$tarball" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & \
+ done ; wait
+
+$(sha1s): $(tarballs)
+ @for sha in $@ ; do \
+ echo -e "\n======= Downloading '$$sha' signature =======\n" ; \
+ echo "$(url)/$$sha" | xargs -n 1 -P 100 wget $(WGET_OPTIONS) - & wait %1 ; \
+ touch $$sha ; \
+ echo -e "\n======= Check the '$$sha' sha1sum =======\n" ; \
+ sha1sum --check $$sha ; ret="$$?" ; \
+ if [ "$$ret" == "1" ]; then \
+ echo -e "\n======= ERROR: Bad '$$sha' sha1sum =======\n" ; \
+ exit 1 ; \
+ fi ; \
+ done
+
+$(patches): $(sha1s)
+ @echo -e "\n======= Create Patches =======\n" ; \
+ ( cd create-1.60-20210110-patch ; ./create.patch.sh ) ; \
+ echo -e "\n"
+
+download_clean:
+ @rm -f $(tarballs) $(sha1s) $(patches)
Index: create-1.60-20210110-patch/create.patch.sh
===================================================================
--- create-1.60-20210110-patch/create.patch.sh (nonexistent)
+++ create-1.60-20210110-patch/create.patch.sh (revision 5)
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+VERSION=1.60-20210110
+
+tar --files-from=file.list -xjvf ../net-tools-$VERSION.tar.bz2
+mv net-tools-$VERSION net-tools-$VERSION-orig
+
+cp -rf ./net-tools-$VERSION-new ./net-tools-$VERSION
+
+diff --unified -Nr net-tools-$VERSION-orig net-tools-$VERSION > net-tools-$VERSION.patch
+
+mv net-tools-$VERSION.patch ../patches
+
+rm -rf ./net-tools-$VERSION
+rm -rf ./net-tools-$VERSION-orig
Property changes on: create-1.60-20210110-patch/create.patch.sh
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: create-1.60-20210110-patch/file.list
===================================================================
--- create-1.60-20210110-patch/file.list (nonexistent)
+++ create-1.60-20210110-patch/file.list (revision 5)
@@ -0,0 +1,5 @@
+net-tools-1.60-20210110/lib/inet_gr.c
+net-tools-1.60-20210110/lib/tr.c
+net-tools-1.60-20210110/ifconfig.c
+net-tools-1.60-20210110/iptunnel.c
+net-tools-1.60-20210110/netstat.c
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/config.h
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/config.h (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/config.h (revision 5)
@@ -0,0 +1,83 @@
+/*
+ * 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 0
+#define HAVE_AFX25 1
+#define HAVE_AFECONET 0
+#define HAVE_AFDECnet 0
+#define HAVE_AFASH 0
+#define HAVE_AFBLUETOOTH 1
+
+/*
+ *
+ * Device Hardware types.
+ *
+ */
+#define HAVE_HWETHER 1
+#define HAVE_HWARC 1
+#define HAVE_HWSLIP 1
+#define HAVE_HWPPP 1
+#define HAVE_HWTUNNEL 1
+#define HAVE_HWSTRIP 1
+#define HAVE_HWTR 1
+#define HAVE_HWAX25 1
+#define HAVE_HWROSE 0
+#define HAVE_HWNETROM 1
+#define HAVE_HWX25 1
+#define HAVE_HWFR 1
+#define HAVE_HWSIT 0
+#define HAVE_HWFDDI 1
+#define HAVE_HWHIPPI 1
+#define HAVE_HWASH 0
+#define HAVE_HWHDLCLAPB 0
+#define HAVE_HWIRDA 1
+#define HAVE_HWEC 0
+#define HAVE_HWEUI64 1
+#define HAVE_HWIB 1
+
+/*
+ *
+ * Other Features.
+ *
+ */
+#define HAVE_FW_MASQUERADE 1
+#define HAVE_ARP_TOOLS 1
+#define HAVE_HOSTNAME_TOOLS 1
+#define HAVE_HOSTNAME_SYMLINKS 1
+#define HAVE_IP_TOOLS 1
+#define HAVE_MII 1
+#define HAVE_PLIP_TOOLS 1
+#define HAVE_SERIAL_TOOLS 1
+#define HAVE_SELINUX 0
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/ifconfig.c
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/ifconfig.c (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/ifconfig.c (revision 5)
@@ -0,0 +1,1191 @@
+/*
+ * ifconfig This file contains an implementation of the command
+ * that either displays or sets the characteristics of
+ * one or more of the system's networking interfaces.
+ *
+ * Version: $Id: ifconfig.c,v 1.59 2011-01-01 03:22:31 ecki Exp $
+ *
+ * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
+ * and others. Copyright 1993 MicroWalt Corporation
+ *
+ * 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; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * Patched to support 'add' and 'del' keywords for INET(4) addresses
+ * by Mrs. Brisby <mrs.brisby@nimh.org>
+ *
+ * {1.34} - 19980630 - Arnaldo Carvalho de Melo <acme@conectiva.com.br>
+ * - gettext instead of catgets for i18n
+ * 10/1998 - Andi Kleen. Use interface list primitives.
+ * 20001008 - Bernd Eckenfels, Patch from RH for setting mtu
+ * (default AF was wrong)
+ * 20010404 - Arnaldo Carvalho de Melo, use setlocale
+ */
+
+#define DFLT_AF "inet"
+
+#include "config.h"
+
+#include <features.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <netinet/in.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <netdb.h>
+
+/* Ugh. But libc5 doesn't provide POSIX types. */
+#include <asm/types.h>
+
+
+#if HAVE_HWSLIP
+#include <linux/if_slip.h>
+#endif
+
+#if HAVE_AFINET6
+
+#ifndef _LINUX_IN6_H
+/*
+ * This is in linux/include/net/ipv6.h.
+ */
+
+struct in6_ifreq {
+ struct in6_addr ifr6_addr;
+ __u32 ifr6_prefixlen;
+ unsigned int ifr6_ifindex;
+};
+
+#endif
+
+#endif /* HAVE_AFINET6 */
+
+#if HAVE_AFIPX
+#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
+#include <netipx/ipx.h>
+#else
+#include "ipx.h"
+#endif
+#endif
+#include "net-support.h"
+#include "pathnames.h"
+#include "version.h"
+#include "../intl.h"
+#include "interface.h"
+#include "sockets.h"
+#include "util.h"
+
+static char *Release = RELEASE;
+
+int opt_a = 0; /* show all interfaces */
+int opt_v = 0; /* debugging output flag */
+
+int addr_family = 0; /* currently selected AF */
+
+/* for ipv4 add/del modes */
+static int get_nmbc_parent(char *parent, in_addr_t *nm, in_addr_t *bc);
+static int set_ifstate(char *parent, in_addr_t ip, in_addr_t nm, in_addr_t bc,
+ int flag);
+
+static int if_print(char *ifname)
+{
+ int res;
+
+ if (ife_short)
+ printf(_("Iface MTU RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg\n"));
+
+ if (!ifname) {
+ res = for_all_interfaces(do_if_print, &opt_a);
+ } else {
+ struct interface *ife;
+
+ ife = lookup_interface(ifname);
+ if (!ife) {
+ return -1;
+ }
+ res = do_if_fetch(ife);
+ if (res >= 0)
+ ife_print(ife);
+ }
+ return res;
+}
+
+/* Set a certain interface flag. */
+static int set_flag(char *ifname, short flag)
+{
+ struct ifreq ifr;
+
+ safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ if (ioctl(skfd, SIOCGIFFLAGS, &ifr) < 0) {
+ fprintf(stderr, _("%s: ERROR while getting interface flags: %s\n"),
+ ifname, strerror(errno));
+ return (-1);
+ }
+ safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ ifr.ifr_flags |= flag;
+ if (ioctl(skfd, SIOCSIFFLAGS, &ifr) < 0) {
+ perror("SIOCSIFFLAGS");
+ return -1;
+ }
+ return (0);
+}
+
+/* Clear a certain interface flag. */
+static int clr_flag(char *ifname, short flag)
+{
+ struct ifreq ifr;
+ int fd;
+
+ if (strchr(ifname, ':')) {
+ /* This is a v4 alias interface. Downing it via a socket for
+ another AF may have bad consequences. */
+ fd = get_socket_for_af(AF_INET);
+ if (fd < 0) {
+ fprintf(stderr, _("No support for INET on this system.\n"));
+ return -1;
+ }
+ } else
+ fd = skfd;
+
+ safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+ fprintf(stderr, _("%s: ERROR while getting interface flags: %s\n"),
+ ifname, strerror(errno));
+ return -1;
+ }
+ safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ ifr.ifr_flags &= ~flag;
+ if (ioctl(fd, SIOCSIFFLAGS, &ifr) < 0) {
+ perror("SIOCSIFFLAGS");
+ return -1;
+ }
+ return (0);
+}
+
+/** test is a specified flag is set */
+static int test_flag(char *ifname, short flags)
+{
+ struct ifreq ifr;
+ int fd;
+
+ if (strchr(ifname, ':')) {
+ /* This is a v4 alias interface. Downing it via a socket for
+ another AF may have bad consequences. */
+ fd = get_socket_for_af(AF_INET);
+ if (fd < 0) {
+ fprintf(stderr, _("No support for INET on this system.\n"));
+ return -1;
+ }
+ } else
+ fd = skfd;
+
+ safe_strncpy(ifr.ifr_name, ifname, IFNAMSIZ);
+ if (ioctl(fd, SIOCGIFFLAGS, &ifr) < 0) {
+ fprintf(stderr, _("%s: ERROR while testing interface flags: %s\n"),
+ ifname, strerror(errno));
+ return -1;
+ }
+ return (ifr.ifr_flags & flags);
+}
+
+static void usage(int rc)
+{
+ FILE *fp = rc ? stderr : stdout;
+ fprintf(fp, _("Usage:\n ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]\n"));
+#if HAVE_AFINET
+ fprintf(fp, _(" [add <address>[/<prefixlen>]]\n"));
+ fprintf(fp, _(" [del <address>[/<prefixlen>]]\n"));
+ fprintf(fp, _(" [[-]broadcast [<address>]] [[-]pointopoint [<address>]]\n"));
+ fprintf(fp, _(" [netmask <address>] [dstaddr <address>] [tunnel <address>]\n"));
+#endif
+#ifdef SIOCSKEEPALIVE
+ fprintf(fp, _(" [outfill <NN>] [keepalive <NN>]\n"));
+#endif
+ fprintf(fp, _(" [hw <HW> <address>] [mtu <NN>]\n"));
+ fprintf(fp, _(" [[-]trailers] [[-]arp] [[-]allmulti]\n"));
+ fprintf(fp, _(" [multicast] [[-]promisc]\n"));
+ fprintf(fp, _(" [mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]\n"));
+#ifdef HAVE_TXQUEUELEN
+ fprintf(fp, _(" [txqueuelen <NN>]\n"));
+#endif
+#ifdef SIOCSIFNAME
+ fprintf(fp, _(" [name <newname>]\n"));
+#endif
+#ifdef HAVE_DYNAMIC
+ fprintf(fp, _(" [[-]dynamic]\n"));
+#endif
+ fprintf(fp, _(" [up|down] ...\n\n"));
+
+ fprintf(fp, _(" <HW>=Hardware Type.\n"));
+ fprintf(fp, _(" List of possible hardware types:\n"));
+ print_hwlist(0); /* 1 = ARPable */
+ fprintf(fp, _(" <AF>=Address family. Default: %s\n"), DFLT_AF);
+ fprintf(fp, _(" List of possible address families:\n"));
+ print_aflist(0); /* 1 = routeable */
+ exit(rc);
+}
+
+static void version(void)
+{
+ printf("%s\n", Release);
+ exit(E_VERSION);
+}
+
+static int set_netmask(int skfd, struct ifreq *ifr, struct sockaddr *sa)
+{
+ int err = 0;
+
+ memcpy(&ifr->ifr_netmask, sa, sizeof(struct sockaddr));
+ if (ioctl(skfd, SIOCSIFNETMASK, ifr) < 0) {
+ fprintf(stderr, "SIOCSIFNETMASK: %s\n",
+ strerror(errno));
+ err = 1;
+ }
+ return err;
+}
+
+int main(int argc, char **argv)
+{
+ struct sockaddr_storage _sa, _samask;
+ struct sockaddr *sa = (struct sockaddr *)&_sa;
+ struct sockaddr *samask = (struct sockaddr *)&_samask;
+ struct sockaddr_in *sin = (struct sockaddr_in *)&_sa;
+ char host[128];
+ const struct aftype *ap;
+ const struct hwtype *hw;
+ struct ifreq ifr;
+ int goterr = 0, didnetmask = 0, neednetmask=0;
+ char **spp;
+ int fd;
+#if HAVE_AFINET6
+ extern struct aftype inet6_aftype;
+ struct sockaddr_in6 *sin6 = (struct sockaddr_in6 *)&_sa;
+ struct in6_ifreq ifr6;
+ unsigned long prefix_len;
+ char *cp;
+#endif
+#if HAVE_AFINET
+ extern struct aftype inet_aftype;
+#endif
+
+#if I18N
+ setlocale(LC_ALL, "");
+ bindtextdomain("net-tools", "/usr/share/locale");
+ textdomain("net-tools");
+#endif
+
+ /* Find any options. */
+ argc--;
+ argv++;
+ while (argc && *argv[0] == '-') {
+ if (!strcmp(*argv, "-a"))
+ opt_a = 1;
+
+ else if (!strcmp(*argv, "-s"))
+ ife_short = 1;
+
+ else if (!strcmp(*argv, "-v"))
+ opt_v = 1;
+
+ else if (!strcmp(*argv, "-V") || !strcmp(*argv, "-version") ||
+ !strcmp(*argv, "--version"))
+ version();
+
+ else if (!strcmp(*argv, "-?") || !strcmp(*argv, "-h") ||
+ !strcmp(*argv, "-help") || !strcmp(*argv, "--help"))
+ usage(E_USAGE);
+
+ else {
+ fprintf(stderr, _("ifconfig: option `%s' not recognised.\n"),
+ argv[0]);
+ fprintf(stderr, _("ifconfig: `--help' gives usage information.\n"));
+ exit(1);
+ }
+
+ argv++;
+ argc--;
+ }
+
+ /* Create a channel to the NET kernel. */
+ if ((skfd = sockets_open(0)) < 0) {
+ perror("socket");
+ exit(1);
+ }
+
+ /* Do we have to show the current setup? */
+ if (argc == 0) {
+ int err = if_print((char *) NULL);
+ (void) close(skfd);
+ exit(err < 0);
+ }
+ /* No. Fetch the interface name. */
+ spp = argv;
+ safe_strncpy(ifr.ifr_name, *spp++, IFNAMSIZ);
+ if (*spp == (char *) NULL) {
+ int err = if_print(ifr.ifr_name);
+ (void) close(skfd);
+ exit(err < 0);
+ }
+
+ /* The next argument is either an address family name, or an option. */
+ if ((ap = get_aftype(*spp)) != NULL)
+ spp++; /* it was a AF name */
+ else
+ ap = get_aftype(DFLT_AF);
+
+ if (ap) {
+ addr_family = ap->af;
+ skfd = ap->fd;
+ }
+
+ /* Process the remaining arguments. */
+ while (*spp != (char *) NULL) {
+ if (!strcmp(*spp, "arp")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_NOARP);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "-arp")) {
+ goterr |= set_flag(ifr.ifr_name, IFF_NOARP);
+ spp++;
+ continue;
+ }
+#ifdef IFF_PORTSEL
+ if (!strcmp(*spp, "media") || !strcmp(*spp, "port")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ if (!strcasecmp(*spp, "auto")) {
+ goterr |= set_flag(ifr.ifr_name, IFF_AUTOMEDIA);
+ } else {
+ int i, j, newport;
+ char *endp;
+ newport = strtol(*spp, &endp, 10);
+ if (*endp != 0) {
+ newport = -1;
+ for (i = 0; if_port_text[i][0] && newport == -1; i++) {
+ for (j = 0; if_port_text[i][j]; j++) {
+ if (!strcasecmp(*spp, if_port_text[i][j])) {
+ newport = i;
+ break;
+ }
+ }
+ }
+ }
+ spp++;
+ if (newport == -1) {
+ fprintf(stderr, _("Unknown media type.\n"));
+ goterr = 1;
+ } else {
+ if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) {
+ perror("port: SIOCGIFMAP");
+ goterr = 1;
+ continue;
+ }
+ ifr.ifr_map.port = newport;
+ if (ioctl(skfd, SIOCSIFMAP, &ifr) < 0) {
+ perror("port: SIOCSIFMAP");
+ goterr = 1;
+ }
+ }
+ }
+ continue;
+ }
+#endif
+
+ if (!strcmp(*spp, "trailers")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_NOTRAILERS);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "-trailers")) {
+ goterr |= set_flag(ifr.ifr_name, IFF_NOTRAILERS);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "promisc")) {
+ goterr |= set_flag(ifr.ifr_name, IFF_PROMISC);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "-promisc")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_PROMISC);
+ if (test_flag(ifr.ifr_name, IFF_PROMISC) > 0)
+ fprintf(stderr, _("Warning: Interface %s still in promisc mode... maybe other application is running?\n"), ifr.ifr_name);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "multicast")) {
+ goterr |= set_flag(ifr.ifr_name, IFF_MULTICAST);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "-multicast")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_MULTICAST);
+ if (test_flag(ifr.ifr_name, IFF_MULTICAST) > 0)
+ fprintf(stderr, _("Warning: Interface %s still in MULTICAST mode.\n"), ifr.ifr_name);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "allmulti")) {
+ goterr |= set_flag(ifr.ifr_name, IFF_ALLMULTI);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "-allmulti")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_ALLMULTI);
+ if (test_flag(ifr.ifr_name, IFF_ALLMULTI) > 0)
+ fprintf(stderr, _("Warning: Interface %s still in ALLMULTI mode.\n"), ifr.ifr_name);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "up")) {
+ goterr |= set_flag(ifr.ifr_name, (IFF_UP | IFF_RUNNING));
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "down")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_UP);
+ spp++;
+ continue;
+ }
+#ifdef HAVE_DYNAMIC
+ if (!strcmp(*spp, "dynamic")) {
+ goterr |= set_flag(ifr.ifr_name, IFF_DYNAMIC);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "-dynamic")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_DYNAMIC);
+ spp++;
+ if (test_flag(ifr.ifr_name, IFF_DYNAMIC) > 0)
+ fprintf(stderr, _("Warning: Interface %s still in DYNAMIC mode.\n"), ifr.ifr_name);
+ continue;
+ }
+#endif
+
+ if (!strcmp(*spp, "mtu")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ ifr.ifr_mtu = atoi(*spp);
+ if (ioctl(skfd, SIOCSIFMTU, &ifr) < 0) {
+ fprintf(stderr, "SIOCSIFMTU: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#ifdef SIOCSKEEPALIVE
+ if (!strcmp(*spp, "keepalive")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ ifr.ifr_data = (caddr_t) (uintptr_t) atoi(*spp);
+ if (ioctl(skfd, SIOCSKEEPALIVE, &ifr) < 0) {
+ fprintf(stderr, "SIOCSKEEPALIVE: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#endif
+
+#ifdef SIOCSOUTFILL
+ if (!strcmp(*spp, "outfill")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ ifr.ifr_data = (caddr_t) (uintptr_t) atoi(*spp);
+ if (ioctl(skfd, SIOCSOUTFILL, &ifr) < 0) {
+ fprintf(stderr, "SIOCSOUTFILL: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#endif
+
+ if (!strcmp(*spp, "-broadcast")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_BROADCAST);
+ if (test_flag(ifr.ifr_name, IFF_BROADCAST) > 0)
+ fprintf(stderr, _("Warning: Interface %s still in BROADCAST mode.\n"), ifr.ifr_name);
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "broadcast")) {
+ if (*++spp != NULL) {
+ safe_strncpy(host, *spp, (sizeof host));
+ if (ap->input(0, host, &_sa) < 0) {
+ if (ap->herror)
+ ap->herror(host);
+ else
+ fprintf(stderr, _("ifconfig: Error resolving '%s' for broadcast\n"), host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ memcpy(&ifr.ifr_broadaddr, sa, sizeof(struct sockaddr));
+ if (ioctl(ap->fd, SIOCSIFBRDADDR, &ifr) < 0) {
+ fprintf(stderr, "SIOCSIFBRDADDR: %s\n",
+ strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ }
+ goterr |= set_flag(ifr.ifr_name, IFF_BROADCAST);
+ continue;
+ }
+ if (!strcmp(*spp, "dstaddr")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ safe_strncpy(host, *spp, (sizeof host));
+ if (ap->input(0, host, &_sa) < 0) {
+ if (ap->herror)
+ ap->herror(host);
+ else
+ fprintf(stderr, _("ifconfig: Error resolving '%s' for dstaddr\n"), host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ memcpy(&ifr.ifr_dstaddr, sa, sizeof(struct sockaddr));
+ if (ioctl(ap->fd, SIOCSIFDSTADDR, &ifr) < 0) {
+ fprintf(stderr, "SIOCSIFDSTADDR: %s\n",
+ strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "netmask")) {
+ if (*++spp == NULL || didnetmask)
+ usage(E_OPTERR);
+ safe_strncpy(host, *spp, (sizeof host));
+ if (ap->input(0, host, &_sa) < 0) {
+ if (ap->herror)
+ ap->herror(host);
+ else
+ fprintf(stderr, _("ifconfig: Error resolving '%s' for netmask\n"), host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ didnetmask++;
+ goterr |= set_netmask(ap->fd, &ifr, sa);
+ spp++;
+ continue;
+ }
+#ifdef HAVE_TXQUEUELEN
+ if (!strcmp(*spp, "txqueuelen")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ ifr.ifr_qlen = strtoul(*spp, NULL, 0);
+ if (ioctl(skfd, SIOCSIFTXQLEN, &ifr) < 0) {
+ fprintf(stderr, "SIOCSIFTXQLEN: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#endif
+
+#ifdef SIOCSIFNAME
+ if (!strcmp(*spp, "name")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ safe_strncpy(ifr.ifr_newname, *spp, IFNAMSIZ);
+ if (ioctl(skfd, SIOCSIFNAME, &ifr) < 0) {
+ fprintf(stderr, "SIOCSIFNAME: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#endif
+
+ if (!strcmp(*spp, "mem_start")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) {
+ fprintf(stderr, "mem_start: SIOCGIFMAP: %s\n", strerror(errno));
+ spp++;
+ goterr = 1;
+ continue;
+ }
+ ifr.ifr_map.mem_start = strtoul(*spp, NULL, 0);
+ if (ioctl(skfd, SIOCSIFMAP, &ifr) < 0) {
+ fprintf(stderr, "mem_start: SIOCSIFMAP: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "io_addr")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) {
+ fprintf(stderr, "io_addr: SIOCGIFMAP: %s\n", strerror(errno));
+ spp++;
+ goterr = 1;
+ continue;
+ }
+ ifr.ifr_map.base_addr = strtol(*spp, NULL, 0);
+ if (ioctl(skfd, SIOCSIFMAP, &ifr) < 0) {
+ fprintf(stderr, "io_addr: SIOCSIFMAP: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "irq")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ if (ioctl(skfd, SIOCGIFMAP, &ifr) < 0) {
+ fprintf(stderr, "irq: SIOCGIFMAP: %s\n", strerror(errno));
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ ifr.ifr_map.irq = atoi(*spp);
+ if (ioctl(skfd, SIOCSIFMAP, &ifr) < 0) {
+ fprintf(stderr, "irq: SIOCSIFMAP: %s\n", strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+ if (!strcmp(*spp, "-pointopoint") || !strcmp(*spp, "-pointtopoint")) {
+ goterr |= clr_flag(ifr.ifr_name, IFF_POINTOPOINT);
+ spp++;
+ if (test_flag(ifr.ifr_name, IFF_POINTOPOINT) > 0)
+ fprintf(stderr, _("Warning: Interface %s still in POINTOPOINT mode.\n"), ifr.ifr_name);
+ continue;
+ }
+ if (!strcmp(*spp, "pointopoint") || !strcmp(*spp, "pointtopoint")) {
+ if (*(spp + 1) != NULL) {
+ spp++;
+ safe_strncpy(host, *spp, (sizeof host));
+ if (ap->input(0, host, &_sa)) {
+ if (ap->herror)
+ ap->herror(host);
+ else
+ fprintf(stderr, _("ifconfig: Error resolving '%s' for pointopoint\n"), host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ memcpy(&ifr.ifr_dstaddr, sa, sizeof(struct sockaddr));
+ if (ioctl(ap->fd, SIOCSIFDSTADDR, &ifr) < 0) {
+ fprintf(stderr, "SIOCSIFDSTADDR: %s\n",
+ strerror(errno));
+ goterr = 1;
+ }
+ }
+ goterr |= set_flag(ifr.ifr_name, IFF_POINTOPOINT);
+ spp++;
+ continue;
+ };
+
+ if (!strcmp(*spp, "hw")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ if ((hw = get_hwtype(*spp)) == NULL)
+ usage(E_OPTERR);
+ if (hw->input == NULL) {
+ fprintf(stderr, _("hw address type `%s' has no handler to set address. failed.\n"), *spp);
+ spp+=2;
+ goterr = 1;
+ continue;
+ }
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ safe_strncpy(host, *spp, (sizeof host));
+ if (hw->input(host, &_sa) < 0) {
+ fprintf(stderr, _("%s: invalid %s address.\n"), host, hw->name);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ memcpy(&ifr.ifr_hwaddr, sa, sizeof(struct sockaddr));
+ if (ioctl(skfd, SIOCSIFHWADDR, &ifr) < 0) {
+ if (errno == EBUSY)
+ fprintf(stderr, "SIOCSIFHWADDR: %s - you may need to down the interface\n",
+ strerror(errno));
+ else
+ fprintf(stderr, "SIOCSIFHWADDR: %s\n",
+ strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#if HAVE_AFINET || HAVE_AFINET6
+ if (!strcmp(*spp, "add")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+#if HAVE_AFINET6
+ if (strchr(*spp, ':')) {
+ /* INET6 */
+ if ((cp = strchr(*spp, '/'))) {
+ prefix_len = atol(cp + 1);
+ if ((prefix_len < 0) || (prefix_len > 128))
+ usage(E_OPTERR);
+ *cp = 0;
+ } else {
+ prefix_len = 128;
+ }
+ safe_strncpy(host, *spp, (sizeof host));
+ if (inet6_aftype.input(1, host, &_sa) < 0) {
+ if (inet6_aftype.herror)
+ inet6_aftype.herror(host);
+ else
+ fprintf(stderr, _("ifconfig: Error resolving '%s' for add\n"), host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ memcpy(&ifr6.ifr6_addr, &sin6->sin6_addr, sizeof(struct in6_addr));
+
+ fd = get_socket_for_af(AF_INET6);
+ if (fd < 0) {
+ fprintf(stderr,
+ _("No support for INET6 on this system.\n"));
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ if (ioctl(fd, SIOGIFINDEX, &ifr) < 0) {
+ perror("SIOGIFINDEX");
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ ifr6.ifr6_ifindex = ifr.ifr_ifindex;
+ ifr6.ifr6_prefixlen = prefix_len;
+ if (ioctl(fd, SIOCSIFADDR, &ifr6) < 0) {
+ perror("SIOCSIFADDR");
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#endif
+#if HAVE_AFINET
+ { /* ipv4 address a.b.c.d */
+ in_addr_t ip, nm = (in_addr_t)0, bc = (in_addr_t)0;
+ safe_strncpy(host, *spp, (sizeof host));
+ if (inet_aftype.input(0, host, &_sa) < 0) {
+ ap->herror(host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ fd = get_socket_for_af(AF_INET);
+ if (fd < 0) {
+ fprintf(stderr,
+ _("No support for INET on this system.\n"));
+ goterr = 1;
+ spp++;
+ continue;
+ }
+
+ memcpy(&ip, &sin->sin_addr.s_addr, sizeof(ip));
+
+ if (get_nmbc_parent(ifr.ifr_name, &nm, &bc) < 0) {
+ fprintf(stderr, _("Interface %s not initialized\n"),
+ ifr.ifr_name);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ set_ifstate(ifr.ifr_name, ip, nm, bc, 1);
+
+ }
+ spp++;
+ continue;
+#else
+ fprintf(stderr, _("Bad address.\n"));
+#endif
+ }
+#endif
+
+#if HAVE_AFINET || HAVE_AFINET6
+ if (!strcmp(*spp, "del")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+
+#ifdef SIOCDIFADDR
+#if HAVE_AFINET6
+ if (strchr(*spp, ':')) { /* INET6 */
+ if ((cp = strchr(*spp, '/'))) {
+ prefix_len = atol(cp + 1);
+ if ((prefix_len < 0) || (prefix_len > 128))
+ usage(E_OPTERR);
+ *cp = 0;
+ } else {
+ prefix_len = 128;
+ }
+ safe_strncpy(host, *spp, (sizeof host));
+ if (inet6_aftype.input(1, host, &_sa) < 0) {
+ inet6_aftype.herror(host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ memcpy(&ifr6.ifr6_addr, &sin6->sin6_addr,
+ sizeof(struct in6_addr));
+
+ fd = get_socket_for_af(AF_INET6);
+ if (fd < 0) {
+ fprintf(stderr,
+ _("No support for INET6 on this system.\n"));
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ if (ioctl(fd, SIOGIFINDEX, &ifr) < 0) {
+ perror("SIOGIFINDEX");
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ ifr6.ifr6_ifindex = ifr.ifr_ifindex;
+ ifr6.ifr6_prefixlen = prefix_len;
+ if (opt_v)
+ fprintf(stderr, "now deleting: ioctl(SIOCDIFADDR,{ifindex=%d,prefixlen=%ld})\n",ifr.ifr_ifindex,prefix_len);
+ if (ioctl(fd, SIOCDIFADDR, &ifr6) < 0) {
+ fprintf(stderr, "SIOCDIFADDR: %s\n",
+ strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#endif
+#if HAVE_AFINET
+ {
+ /* ipv4 address a.b.c.d */
+ in_addr_t ip, nm = (in_addr_t)0, bc = (in_addr_t)0;
+ safe_strncpy(host, *spp, (sizeof host));
+ if (inet_aftype.input(0, host, &_sa) < 0) {
+ ap->herror(host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ fd = get_socket_for_af(AF_INET);
+ if (fd < 0) {
+ fprintf(stderr, _("No support for INET on this system.\n"));
+ goterr = 1;
+ spp++;
+ continue;
+ }
+
+ /* Clear "ip" in case sizeof(unsigned long) > sizeof(sin.sin_addr.s_addr) */
+ ip = 0;
+ memcpy(&ip, &sin->sin_addr.s_addr, sizeof(ip));
+
+ if (get_nmbc_parent(ifr.ifr_name, &nm, &bc) < 0) {
+ fprintf(stderr, _("Interface %s not initialized\n"),
+ ifr.ifr_name);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ set_ifstate(ifr.ifr_name, ip, nm, bc, 0);
+ }
+ spp++;
+ continue;
+#else
+ fprintf(stderr, _("Bad address.\n"));
+#endif
+#else
+ fprintf(stderr, _("Address deletion not supported on this system.\n"));
+#endif
+ }
+#endif
+#if HAVE_AFINET6
+ if (!strcmp(*spp, "tunnel")) {
+ if (*++spp == NULL)
+ usage(E_OPTERR);
+ if ((cp = strchr(*spp, '/'))) {
+ prefix_len = atol(cp + 1);
+ if ((prefix_len < 0) || (prefix_len > 128))
+ usage(E_OPTERR);
+ *cp = 0;
+ } else {
+ prefix_len = 128;
+ }
+ safe_strncpy(host, *spp, (sizeof host));
+ if (inet6_aftype.input(1, host, &_sa) < 0) {
+ inet6_aftype.herror(host);
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ memcpy(&ifr6.ifr6_addr, &sin6->sin6_addr, sizeof(struct in6_addr));
+
+ fd = get_socket_for_af(AF_INET6);
+ if (fd < 0) {
+ fprintf(stderr, _("No support for INET6 on this system.\n"));
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ if (ioctl(fd, SIOGIFINDEX, &ifr) < 0) {
+ perror("SIOGIFINDEX");
+ goterr = 1;
+ spp++;
+ continue;
+ }
+ ifr6.ifr6_ifindex = ifr.ifr_ifindex;
+ ifr6.ifr6_prefixlen = prefix_len;
+
+ if (ioctl(fd, SIOCSIFDSTADDR, &ifr6) < 0) {
+ fprintf(stderr, "SIOCSIFDSTADDR: %s\n",
+ strerror(errno));
+ goterr = 1;
+ }
+ spp++;
+ continue;
+ }
+#endif
+
+ /* If the next argument is a valid hostname, assume OK. */
+ safe_strncpy(host, *spp, (sizeof host));
+
+ /* FIXME: sa is too small for INET6 addresses, inet6 should use that too,
+ broadcast is unexpected */
+ if (ap->getmask) {
+ switch (ap->getmask(host, &_samask, NULL)) {
+ case -1:
+ usage(E_OPTERR);
+ break;
+ case 1:
+ if (didnetmask)
+ usage(E_OPTERR);
+
+ // remeber to set the netmask from samask later
+ neednetmask = 1;
+ break;
+ }
+ }
+ if (ap->input == NULL) {
+ fprintf(stderr, _("ifconfig: Cannot set address for this protocol family.\n"));
+ exit(1);
+ }
+ if (ap->input(0, host, &_sa) < 0) {
+ if (ap->herror) {
+ ap->herror(host);
+ } else {
+ fprintf(stderr,_("ifconfig: error resolving '%s' to set address for af=%s\n"), host, ap->name);
+ fprintf(stderr, _("ifconfig: `--help' gives usage information.\n"));
+ exit(1);
+ }
+ }
+ memcpy(&ifr.ifr_addr, sa, sizeof(struct sockaddr));
+ {
+ int r = 0; /* to shut gcc up */
+ switch (ap->af) {
+#if HAVE_AFINET
+ case AF_INET:
+ fd = get_socket_for_af(AF_INET);
+ if (fd < 0) {
+ fprintf(stderr, _("No support for INET on this system.\n"));
+ exit(1);
+ }
+ r = ioctl(fd, SIOCSIFADDR, &ifr);
+ break;
+#endif
+#if HAVE_AFECONET
+ case AF_ECONET:
+ fd = get_socket_for_af(AF_ECONET);
+ if (fd < 0) {
+ fprintf(stderr, _("No support for ECONET on this system.\n"));
+ exit(1);
+ }
+ r = ioctl(fd, SIOCSIFADDR, &ifr);
+ break;
+#endif
+ default:
+ fprintf(stderr,
+ _("Don't know how to set addresses for family %d.\n"), ap->af);
+ exit(1);
+ }
+ if (r < 0) {
+ perror("SIOCSIFADDR");
+ goterr = 1;
+ }
+ }
+
+ /*
+ * Don't do the set_flag() if the address is an alias with a - at the
+ * end, since it's deleted already! - Roman
+ * Same goes if they used address 0.0.0.0 as the kernel uses this to
+ * destroy aliases.
+ *
+ * Should really use regex.h here, not sure though how well it'll go
+ * with the cross-platform support etc.
+ */
+ {
+ char *ptr;
+ short int found_colon = 0;
+ short int bring_up = 1;
+ for (ptr = ifr.ifr_name; *ptr; ptr++ )
+ if (*ptr == ':') found_colon++;
+
+ if (found_colon) {
+ if (ptr[-1] == '-')
+ bring_up = 0;
+ else if (ap->af == AF_INET && sin->sin_addr.s_addr == 0)
+ bring_up = 0;
+ }
+
+ if (bring_up)
+ goterr |= set_flag(ifr.ifr_name, (IFF_UP | IFF_RUNNING));
+ }
+
+ spp++;
+ }
+
+ if (neednetmask) {
+ goterr |= set_netmask(skfd, &ifr, samask);
+ didnetmask++;
+ }
+
+ if (opt_v && goterr)
+ fprintf(stderr, _("WARNING: at least one error occured. (%d)\n"), goterr);
+
+ return (goterr);
+}
+
+struct ifcmd {
+ int flag;
+ unsigned long addr;
+ char *base;
+ int baselen;
+};
+
+static unsigned char searcher[256];
+
+static int set_ip_using(const char *name, int c, unsigned long ip)
+{
+ struct ifreq ifr;
+ struct sockaddr_in sin;
+
+ safe_strncpy(ifr.ifr_name, name, IFNAMSIZ);
+ memset(&sin, 0, sizeof(struct sockaddr));
+ sin.sin_family = AF_INET;
+ sin.sin_addr.s_addr = ip;
+ memcpy(&ifr.ifr_addr, &sin, sizeof(struct sockaddr));
+ if (ioctl(skfd, c, &ifr) < 0)
+ return -1;
+ return 0;
+}
+
+static int do_ifcmd(struct interface *x, struct ifcmd *ptr)
+{
+ char *z, *e;
+ struct sockaddr_in *sin;
+ int i;
+
+ if (do_if_fetch(x) < 0)
+ return 0;
+ if (strncmp(x->name, ptr->base, ptr->baselen) != 0)
+ return 0; /* skip */
+ z = strchr(x->name, ':');
+ if (!z || !*z)
+ return 0;
+ z++;
+ for (e = z; *e; e++)
+ if (*e == '-') /* deleted */
+ return 0;
+ i = atoi(z);
+ if (i < 0 || i > 255)
+ abort();
+ searcher[i] = 1;
+
+ /* copy */
+ sin = (struct sockaddr_in *)&x->dstaddr_sas;
+ if (sin->sin_addr.s_addr != ptr->addr) {
+ return 0;
+ }
+
+ if (ptr->flag) {
+ /* turn UP */
+ if (set_flag(x->name, IFF_UP | IFF_RUNNING) == -1)
+ return -1;
+ } else {
+ /* turn DOWN */
+ if (clr_flag(x->name, IFF_UP) == -1)
+ return -1;
+ }
+
+ return 1; /* all done! */
+}
+
+
+static int get_nmbc_parent(char *parent,
+ in_addr_t *nm, in_addr_t *bc)
+{
+ struct interface *i;
+ struct sockaddr_in *sin;
+
+ i = lookup_interface(parent);
+ if (!i)
+ return -1;
+ if (do_if_fetch(i) < 0)
+ return 0;
+ sin = (struct sockaddr_in *)&i->netmask_sas;
+ memcpy(nm, &sin->sin_addr.s_addr, sizeof(*nm));
+ sin = (struct sockaddr_in *)&i->broadaddr_sas;
+ memcpy(bc, &sin->sin_addr.s_addr, sizeof(*bc));
+ return 0;
+}
+
+static int set_ifstate(char *parent, in_addr_t ip, in_addr_t nm, in_addr_t bc,
+ int flag)
+{
+ char buf[IFNAMSIZ];
+ struct ifcmd pt;
+ int i;
+
+ pt.base = parent;
+ pt.baselen = strlen(parent);
+ pt.addr = ip;
+ pt.flag = flag;
+ memset(searcher, 0, sizeof(searcher));
+ i = for_all_interfaces((int (*)(struct interface *,void *))do_ifcmd,
+ &pt);
+ if (i == -1)
+ return -1;
+ if (i == 1)
+ return 0;
+
+ /* add a new interface */
+ for (i = 0; i < 256; i++)
+ if (searcher[i] == 0)
+ break;
+
+ if (i == 256)
+ return -1; /* FAILURE!!! out of ip addresses */
+
+ if (snprintf(buf, IFNAMSIZ, "%s:%d", parent, i) > IFNAMSIZ)
+ return -1;
+ if (set_ip_using(buf, SIOCSIFADDR, ip) == -1)
+ return -1;
+ if (set_ip_using(buf, SIOCSIFNETMASK, nm) == -1)
+ return -1;
+ if (set_ip_using(buf, SIOCSIFBRDADDR, bc) == -1)
+ return -1;
+ if (set_flag(buf, IFF_BROADCAST) == -1)
+ return -1;
+ return 0;
+}
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/ipmask.8
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/ipmask.8 (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/ipmask.8 (revision 5)
@@ -0,0 +1,35 @@
+.\" -*- nroff -*-
+.ds g \" empty
+.ds G \" empty
+.\" Like TP, but if specified indent is more than half
+.\" the current line-length - indent, use the default indent.
+.de Tp
+.ie \\n(.$=0:((0\\$1)*2u>(\\n(.lu-\\n(.iu)) .TP
+.el .TP "\\$1"
+..
+.TH IPMASK 8 "29 April 2007" "Linux"
+.SH NAME
+ipmask \- determine network and broadcast addresses given a decimal netmask and IP address.
+.SH SYNOPSIS
+.B ipmask <decimal netmask> <decimal IP address>
+.BI packagename
+.SH DESCRIPTION
+.B ipmask
+is a simple program to calculate broadcast and network addresses from a decimal netmask and a decimal IP address. It is used in the Slackware networking script /etc/rc.d/rc.inet1, and in the netconfig script.
+.SH OPTIONS
+.TP
+.B \<decimal netmask>
+A decimal netmask, such as: 255.255.255.0
+.TP
+.B \<decimal IP address>
+A decimal IP address, such as: 192.168.168.168
+.SH EXAMPLE
+Using the above sample netmask and IP address, here's an example:
+.TP
+$ ipmask 255.255.255.0 192.168.168.168
+.TP
+192.168.168.255 192.168.168.0
+.TP
+The program returns first the corresponding broadcast address, and then the network address.
+.SH AUTHOR
+Copyright 1994 by David Niemi. Written in about 30 minutes on 13 Aug. The author places no restrictions on the use of this program, provided that this copyright is preserved in any derived source code.
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/ipmask.c
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/ipmask.c (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/ipmask.c (revision 5)
@@ -0,0 +1,88 @@
+/* ipmask.c
+ *
+ * Given argv[1] as a decimal netmask and argv[2] as a decimal IP address,
+ * print the resulting broadcast and network addresses to stdout. This is
+ * potentially useful in scripts which need the broadcast address and the
+ * network address but want to ask the user as few questions as possible.
+ *
+ * Copyright 1994 by David Niemi. Written in about 30 minutes on 13 Aug.
+ * The author places no restrictions on the use of this program, provided
+ * that this copyright is preserved in any derived source code.
+ *
+ * Typical compilation command for Linux:
+ * cc ipmask.c -Wall -O -m486 -N -o ipmask -s
+ */
+
+#define MYNAME "ipmask"
+
+#include <stdlib.h>
+#include <stdio.h>
+
+void Usage(void) {
+ fprintf (stderr,
+ "USAGE: %s <decimal netmask> <decimal IP address>\n",
+ MYNAME);
+}
+
+int main(int argc, char *argv[])
+{
+unsigned long netmask, ipaddr, netaddr, broadcast;
+int in[4], j;
+unsigned char bc[4],na[4];
+
+ if (3 != argc) {
+ Usage();
+ exit(1);
+ }
+
+ /* Check netmask */
+ if (4 != sscanf(argv[1],"%d.%d.%d.%d", &in[0],&in[1],&in[2],&in[3])) {
+ fprintf (stderr,"Invalid netmask \"%s\".\n", argv[1]);
+ Usage();
+ exit(1);
+ }
+ for (j=0; j<4; ++j) {
+ if (in[j]<0 || in[j]>255) {
+ fprintf (stderr,
+ "Invalid octet %d in netmask \"%s\".\n",
+ j+1, argv[1]);
+ Usage();
+ exit(1);
+ }
+ }
+ netmask = in[3] + 256 * (in[2] + 256 * (in[1] + 256 * in[0]));
+
+ /* Check IP address */
+ if (4 != sscanf(argv[2],"%d.%d.%d.%d", &in[0],&in[1],&in[2],&in[3])) {
+ fprintf (stderr,"Invalid IP address \"%s\".\n", argv[2]);
+ Usage();
+ exit(1);
+ }
+ for (j=0; j<4; ++j) {
+ if (in[j]<0 || in[j]>255) {
+ fprintf (stderr,
+ "Invalid octet %d in IP address \"%s\".\n",
+ j+1, argv[1]);
+ Usage();
+ exit(1);
+ }
+ }
+ ipaddr = in[3] + 256 * (in[2] + 256 * (in[1] + 256 * in[0]));
+
+ broadcast = ipaddr | (~ netmask);
+ bc[0] = broadcast / 256 / 256 / 256;
+ bc[1] = (broadcast / 256 / 256) % 256;
+ bc[2] = (broadcast / 256) % 256;
+ bc[3] = broadcast % 256;
+
+ netaddr = ipaddr & netmask;
+ na[0] = netaddr / 256 / 256 / 256;
+ na[1] = (netaddr / 256 / 256) % 256;
+ na[2] = (netaddr / 256) % 256;
+ na[3] = netaddr % 256;
+
+ printf ("%d.%d.%d.%d %d.%d.%d.%d\n",
+ bc[0], bc[1], bc[2], bc[3], na[0], na[1], na[2], na[3]);
+
+ exit(0);
+}
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/iptunnel.c
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/iptunnel.c (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/iptunnel.c (revision 5)
@@ -0,0 +1,637 @@
+/*
+ * iptunnel.c "ip tunnel"
+ *
+ * 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; either version
+ * 2 of the License, or (at your option) any later version.
+ *
+ * Authors: Alexey Kuznetsov, <kuznet@ms2.inr.ac.ru>
+ *
+ *
+ * Changes:
+ *
+ * Rani Assaf <rani@magic.metawire.com> 980929: resolve addresses
+ * Rani Assaf <rani@magic.metawire.com> 980930: do not allow key for ipip/sit
+ * Bernd Eckenfels 990715: add linux/types.h (not clean but solves missing __u16
+ * Arnaldo Carvalho de Melo 20010404: use setlocale
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <fcntl.h>
+#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4,9,0)
+#include <netinet/in.h>
+#endif
+#include <arpa/inet.h>
+#if defined(__GLIBC__) && (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1))
+#include <net/if.h>
+#include <net/if_arp.h>
+#else
+#include <linux/if.h>
+#include <linux/if_arp.h>
+#endif
+/* We only care about linux/if_tunnel.h. Unfortunately, older Linux headers
+ * (pre linux-4.8) did not include all the proper headers leading to missing
+ * structs and types.
+ */
+#include <linux/types.h>
+#include <linux/ip.h>
+#include <linux/if_tunnel.h>
+
+#include "config.h"
+#include "intl.h"
+#include "net-support.h"
+#include "version.h"
+#include "util.h"
+
+#undef GRE_CSUM
+#define GRE_CSUM htons(0x8000)
+#undef GRE_ROUTING
+#define GRE_ROUTING htons(0x4000)
+#undef GRE_KEY
+#define GRE_KEY htons(0x2000)
+#undef GRE_SEQ
+#define GRE_SEQ htons(0x1000)
+#undef GRE_STRICT
+#define GRE_STRICT htons(0x0800)
+#undef GRE_REC
+#define GRE_REC htons(0x0700)
+#undef GRE_FLAGS
+#define GRE_FLAGS htons(0x00F8)
+#undef GRE_VERSION
+#define GRE_VERSION htons(0x0007)
+
+/* Old versions of glibc do not define this */
+#if __GLIBC__ == 2 && __GLIBC_MINOR__ == 0
+#define IPPROTO_GRE 47
+#endif
+
+#include "util-ank.h"
+
+static char *Release = RELEASE, *Signature = "Alexey Kuznetsov";
+
+static void version(void)
+{
+ printf("%s\n%s\n", Release, Signature);
+ exit(E_VERSION);
+}
+
+__attribute__((noreturn))
+static void usage(int rc)
+{
+ FILE *fp = rc ? stderr : stdout;
+ fprintf(fp, _("Usage: iptunnel { add | change | del | show } [ NAME ]\n"));
+ fprintf(fp, _(" [ mode { ipip | gre | sit } ] [ remote ADDR ] [ local ADDR ]\n"));
+ fprintf(fp, _(" [ [i|o]seq ] [ [i|o]key KEY ] [ [i|o]csum ]\n"));
+ fprintf(fp, _(" [ ttl TTL ] [ tos TOS ] [ nopmtudisc ] [ dev PHYS_DEV ]\n"));
+ fprintf(fp, _(" iptunnel -V | --version\n\n"));
+ fprintf(fp, _("Where: NAME := STRING\n"));
+ fprintf(fp, _(" ADDR := { IP_ADDRESS | any }\n"));
+ fprintf(fp, _(" TOS := { NUMBER | inherit }\n"));
+ fprintf(fp, _(" TTL := { 1..255 | inherit }\n"));
+ fprintf(fp, _(" KEY := { DOTTED_QUAD | NUMBER }\n"));
+ exit(rc);
+}
+
+static int do_ioctl_get_ifindex(char *dev)
+{
+ struct ifreq ifr;
+ int fd;
+ int err;
+
+ safe_strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ err = ioctl(fd, SIOCGIFINDEX, &ifr);
+ if (err) {
+ perror("ioctl");
+ close(fd);
+ return 0;
+ }
+ close(fd);
+ return ifr.ifr_ifindex;
+}
+
+static int do_ioctl_get_iftype(char *dev)
+{
+ struct ifreq ifr;
+ int fd;
+ int err;
+
+ safe_strncpy(ifr.ifr_name, dev, IFNAMSIZ);
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ err = ioctl(fd, SIOCGIFHWADDR, &ifr);
+ if (err) {
+ perror("ioctl");
+ close(fd);
+ return -1;
+ }
+ close(fd);
+ return ifr.ifr_addr.sa_family;
+}
+
+
+static char * do_ioctl_get_ifname(int idx)
+{
+ static struct ifreq ifr;
+ int fd;
+ int err;
+
+ ifr.ifr_ifindex = idx;
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ err = ioctl(fd, SIOCGIFNAME, &ifr);
+ if (err) {
+ perror("ioctl");
+ close(fd);
+ return NULL;
+ }
+ close(fd);
+ return ifr.ifr_name;
+}
+
+
+
+static int do_get_ioctl(char *basedev, struct ip_tunnel_parm *p)
+{
+ struct ifreq ifr;
+ int fd;
+ int err;
+
+ safe_strncpy(ifr.ifr_name, basedev, IFNAMSIZ);
+ ifr.ifr_ifru.ifru_data = (void*)p;
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ err = ioctl(fd, SIOCGETTUNNEL, &ifr);
+ if (err)
+ perror("ioctl");
+ close(fd);
+ return err;
+}
+
+static int do_add_ioctl(int cmd, char *basedev, struct ip_tunnel_parm *p)
+{
+ struct ifreq ifr;
+ int fd;
+ int err;
+
+ safe_strncpy(ifr.ifr_name, basedev, IFNAMSIZ);
+ ifr.ifr_ifru.ifru_data = (void*)p;
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ err = ioctl(fd, cmd, &ifr);
+ if (err)
+ perror("ioctl");
+ close(fd);
+ return err;
+}
+
+static int do_del_ioctl(char *basedev, struct ip_tunnel_parm *p)
+{
+ struct ifreq ifr;
+ int fd;
+ int err;
+
+ safe_strncpy(ifr.ifr_name, basedev, IFNAMSIZ);
+ ifr.ifr_ifru.ifru_data = (void*)p;
+ fd = socket(AF_INET, SOCK_DGRAM, 0);
+ err = ioctl(fd, SIOCDELTUNNEL, &ifr);
+ if (err)
+ perror("ioctl");
+ close(fd);
+ return err;
+}
+
+static int parse_args(int argc, char **argv, struct ip_tunnel_parm *p)
+{
+ char medium[IFNAMSIZ];
+
+ memset(p, 0, sizeof(*p));
+ memset(&medium, 0, sizeof(medium));
+
+ p->iph.version = 4;
+ p->iph.ihl = 5;
+#ifndef IP_DF
+#define IP_DF 0x4000 /* Flag: "Don't Fragment" */
+#endif
+ p->iph.frag_off = htons(IP_DF);
+
+ while (argc > 0) {
+ if (strcmp(*argv, "mode") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "ipip") == 0) {
+ if (p->iph.protocol)
+ usage(E_OPTERR);
+ p->iph.protocol = IPPROTO_IPIP;
+ } else if (strcmp(*argv, "gre") == 0) {
+ if (p->iph.protocol)
+ usage(E_OPTERR);
+ p->iph.protocol = IPPROTO_GRE;
+ } else if (strcmp(*argv, "sit") == 0) {
+ if (p->iph.protocol)
+ usage(E_OPTERR);
+ p->iph.protocol = IPPROTO_IPV6;
+ } else
+ usage(E_OPTERR);
+ } else if (strcmp(*argv, "key") == 0) {
+ unsigned uval;
+ NEXT_ARG();
+ p->i_flags |= GRE_KEY;
+ p->o_flags |= GRE_KEY;
+ if (strchr(*argv, '.'))
+ p->i_key = p->o_key = get_addr32(*argv);
+ else {
+ if (scan_number(*argv, &uval)<0)
+ usage(E_OPTERR);
+ p->i_key = p->o_key = htonl(uval);
+ }
+ } else if (strcmp(*argv, "ikey") == 0) {
+ unsigned uval;
+ NEXT_ARG();
+ p->i_flags |= GRE_KEY;
+ if (strchr(*argv, '.'))
+ p->o_key = get_addr32(*argv);
+ else {
+ if (scan_number(*argv, &uval)<0)
+ usage(E_OPTERR);
+ p->i_key = htonl(uval);
+ }
+ } else if (strcmp(*argv, "okey") == 0) {
+ unsigned uval;
+ NEXT_ARG();
+ p->o_flags |= GRE_KEY;
+ if (strchr(*argv, '.'))
+ p->o_key = get_addr32(*argv);
+ else {
+ if (scan_number(*argv, &uval)<0)
+ usage(E_OPTERR);
+ p->o_key = htonl(uval);
+ }
+ } else if (strcmp(*argv, "seq") == 0) {
+ p->i_flags |= GRE_SEQ;
+ p->o_flags |= GRE_SEQ;
+ } else if (strcmp(*argv, "iseq") == 0) {
+ p->i_flags |= GRE_SEQ;
+ } else if (strcmp(*argv, "oseq") == 0) {
+ p->o_flags |= GRE_SEQ;
+ } else if (strcmp(*argv, "csum") == 0) {
+ p->i_flags |= GRE_CSUM;
+ p->o_flags |= GRE_CSUM;
+ } else if (strcmp(*argv, "icsum") == 0) {
+ p->i_flags |= GRE_CSUM;
+ } else if (strcmp(*argv, "ocsum") == 0) {
+ p->o_flags |= GRE_CSUM;
+ } else if (strcmp(*argv, "nopmtudisc") == 0) {
+ p->iph.frag_off = 0;
+ } else if (strcmp(*argv, "remote") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "any"))
+ p->iph.daddr = get_addr32(*argv);
+ } else if (strcmp(*argv, "local") == 0) {
+ NEXT_ARG();
+ if (strcmp(*argv, "any"))
+ p->iph.saddr = get_addr32(*argv);
+ } else if (strcmp(*argv, "dev") == 0) {
+ NEXT_ARG();
+ safe_strncpy(medium, *argv, IFNAMSIZ-1);
+ } else if (strcmp(*argv, "ttl") == 0) {
+ unsigned uval;
+ NEXT_ARG();
+ if (strcmp(*argv, "inherit") != 0) {
+ if (scan_number(*argv, &uval)<0)
+ usage(E_OPTERR);
+ if (uval > 255)
+ usage(E_OPTERR);
+ p->iph.ttl = uval;
+ }
+ } else if (strcmp(*argv, "tos") == 0) {
+ unsigned uval;
+ NEXT_ARG();
+ if (strcmp(*argv, "inherit") != 0) {
+ if (scan_number(*argv, &uval)<0)
+ usage(E_OPTERR);
+ if (uval > 255)
+ usage(E_OPTERR);
+ p->iph.tos = uval;
+ } else
+ p->iph.tos = 1;
+ } else {
+ if (p->name[0])
+ usage(E_OPTERR);
+ safe_strncpy(p->name, *argv, IFNAMSIZ);
+ }
+ argc--; argv++;
+ }
+
+ if (p->iph.protocol == 0) {
+ if (memcmp(p->name, "gre", 3) == 0)
+ p->iph.protocol = IPPROTO_GRE;
+ else if (memcmp(p->name, "ipip", 4) == 0)
+ p->iph.protocol = IPPROTO_IPIP;
+ else if (memcmp(p->name, "sit", 3) == 0)
+ p->iph.protocol = IPPROTO_IPV6;
+ }
+
+ if (p->iph.protocol == IPPROTO_IPIP || p->iph.protocol == IPPROTO_IPV6) {
+ if ((p->i_flags & GRE_KEY) || (p->o_flags & GRE_KEY)) {
+ fprintf(stderr, _("Keys are not allowed with ipip and sit.\n"));
+ return -1;
+ }
+ }
+
+ if (medium[0]) {
+ p->link = do_ioctl_get_ifindex(medium);
+ if (p->link == 0)
+ return -1;
+ }
+
+ if (p->i_key == 0 && IN_MULTICAST(ntohl(p->iph.daddr))) {
+ p->i_key = p->iph.daddr;
+ p->i_flags |= GRE_KEY;
+ }
+ if (p->o_key == 0 && IN_MULTICAST(ntohl(p->iph.daddr))) {
+ p->o_key = p->iph.daddr;
+ p->o_flags |= GRE_KEY;
+ }
+ if (IN_MULTICAST(ntohl(p->iph.daddr)) && !p->iph.saddr) {
+ fprintf(stderr, _("Broadcast tunnel requires a source address.\n"));
+ return -1;
+ }
+ return 0;
+}
+
+
+static int do_add(int cmd, int argc, char **argv)
+{
+ struct ip_tunnel_parm p;
+
+ if (parse_args(argc, argv, &p) < 0)
+ return -1;
+
+ if (p.iph.ttl && p.iph.frag_off == 0) {
+ fprintf(stderr, _("ttl != 0 and noptmudisc are incompatible\n"));
+ return -1;
+ }
+
+ switch (p.iph.protocol) {
+ case IPPROTO_IPIP:
+ return do_add_ioctl(cmd, "tunl0", &p);
+ case IPPROTO_GRE:
+ return do_add_ioctl(cmd, "gre0", &p);
+ case IPPROTO_IPV6:
+ return do_add_ioctl(cmd, "sit0", &p);
+ default:
+ fprintf(stderr, _("cannot determine tunnel mode (ipip, gre or sit)\n"));
+ return -1;
+ }
+ return -1;
+}
+
+int do_del(int argc, char **argv)
+{
+ struct ip_tunnel_parm p;
+
+ if (parse_args(argc, argv, &p) < 0)
+ return -1;
+
+ switch (p.iph.protocol) {
+ case IPPROTO_IPIP:
+ return do_del_ioctl(p.name[0] ? p.name : "tunl0", &p);
+ case IPPROTO_GRE:
+ return do_del_ioctl(p.name[0] ? p.name : "gre0", &p);
+ case IPPROTO_IPV6:
+ return do_del_ioctl(p.name[0] ? p.name : "sit0", &p);
+ default:
+ return do_del_ioctl(p.name, &p);
+ }
+ return -1;
+}
+
+void print_tunnel(struct ip_tunnel_parm *p)
+{
+ char s1[256];
+ char s2[256];
+ char s3[64];
+ char s4[64];
+
+ format_host(AF_INET, &p->iph.daddr, s1, sizeof(s1));
+ format_host(AF_INET, &p->iph.saddr, s2, sizeof(s2));
+ inet_ntop(AF_INET, &p->i_key, s3, sizeof(s3));
+ inet_ntop(AF_INET, &p->o_key, s4, sizeof(s4));
+
+ printf(_("%s: %s/ip remote %s local %s "),
+ p->name,
+ p->iph.protocol == IPPROTO_IPIP ? "ip" :
+ (p->iph.protocol == IPPROTO_GRE ? "gre" :
+ (p->iph.protocol == IPPROTO_IPV6 ? "ipv6" : _("unknown"))),
+ p->iph.daddr ? s1 : "any", p->iph.saddr ? s2 : "any");
+ if (p->link) {
+ char *n = do_ioctl_get_ifname(p->link);
+ if (n)
+ printf(" dev %s ", n);
+ }
+ if (p->iph.ttl)
+ printf(" ttl %d ", p->iph.ttl);
+ else
+ printf(" ttl inherit ");
+ if (p->iph.tos) {
+ printf(" tos");
+ if (p->iph.tos&1)
+ printf(" inherit");
+ if (p->iph.tos&~1)
+ printf("%c%02x ", p->iph.tos&1 ? '/' : ' ', p->iph.tos&~1);
+ }
+ if (!(p->iph.frag_off&htons(IP_DF)))
+ printf(" nopmtudisc");
+
+ if ((p->i_flags&GRE_KEY) && (p->o_flags&GRE_KEY) && p->o_key == p->i_key)
+ printf(" key %s", s3);
+ else if ((p->i_flags|p->o_flags)&GRE_KEY) {
+ if (p->i_flags&GRE_KEY)
+ printf(" ikey %s ", s3);
+ if (p->o_flags&GRE_KEY)
+ printf(" okey %s ", s4);
+ }
+ printf("\n");
+
+ if (p->i_flags&GRE_SEQ)
+ printf(_(" Drop packets out of sequence.\n"));
+ if (p->i_flags&GRE_CSUM)
+ printf(_(" Checksum in received packet is required.\n"));
+ if (p->o_flags&GRE_SEQ)
+ printf(_(" Sequence packets on output.\n"));
+ if (p->o_flags&GRE_CSUM)
+ printf(_(" Checksum output packets.\n"));
+}
+
+static int do_tunnels_list(struct ip_tunnel_parm *p)
+{
+ char name[IFNAMSIZ];
+ unsigned long rx_bytes, rx_packets, rx_errs, rx_drops,
+ rx_fifo, rx_frame,
+ tx_bytes, tx_packets, tx_errs, tx_drops,
+ tx_fifo, tx_colls, tx_carrier, rx_multi;
+ int type;
+ struct ip_tunnel_parm p1;
+
+ char buf[512];
+ FILE *fp = fopen("/proc/net/dev", "r");
+ if (fp == NULL) {
+ perror("fopen");
+ return -1;
+ }
+
+ if (fgets(buf, sizeof(buf), fp))
+ /* eat line */;
+ if (fgets(buf, sizeof(buf), fp))
+ /* eat line */;
+
+ while (fgets(buf, sizeof(buf), fp) != NULL) {
+ char *ptr;
+ buf[sizeof(buf) - 1] = 0;
+ if ((ptr = strchr(buf, ':')) == NULL ||
+ (*ptr++ = 0, sscanf(buf, "%s", name) != 1)) {
+ fprintf(stderr, _("Wrong format of /proc/net/dev. Sorry.\n"));
+ fclose(fp);
+ return -1;
+ }
+ if (sscanf(ptr, "%lu%lu%lu%lu%lu%lu%lu%*u%lu%lu%lu%lu%lu%lu%lu",
+ &rx_bytes, &rx_packets, &rx_errs, &rx_drops,
+ &rx_fifo, &rx_frame, &rx_multi,
+ &tx_bytes, &tx_packets, &tx_errs, &tx_drops,
+ &tx_fifo, &tx_colls, &tx_carrier) != 14)
+ continue;
+ if (p->name[0] && strcmp(p->name, name))
+ continue;
+ type = do_ioctl_get_iftype(name);
+ if (type == -1) {
+ fprintf(stderr, _("Failed to get type of [%s]\n"), name);
+ continue;
+ }
+ if (type != ARPHRD_TUNNEL && type != ARPHRD_IPGRE && type != ARPHRD_SIT)
+ continue;
+ memset(&p1, 0, sizeof(p1));
+ if (do_get_ioctl(name, &p1))
+ continue;
+ if ((p->link && p1.link != p->link) ||
+ (p->name[0] && strcmp(p1.name, p->name)) ||
+ (p->iph.daddr && p1.iph.daddr != p->iph.daddr) ||
+ (p->iph.saddr && p1.iph.saddr != p->iph.saddr) ||
+ (p->i_key && p1.i_key != p->i_key))
+ continue;
+ print_tunnel(&p1);
+ if (show_stats) {
+ printf(_("RX: Packets Bytes Errors CsumErrs OutOfSeq Mcasts\n"));
+ printf(" %-10ld %-12ld %-6ld %-8ld %-8ld %-8ld\n",
+ rx_packets, rx_bytes, rx_errs, rx_frame, rx_fifo, rx_multi);
+ printf(_("TX: Packets Bytes Errors DeadLoop NoRoute NoBufs\n"));
+ printf(" %-10ld %-12ld %-6ld %-8ld %-8ld %-6ld\n\n",
+ tx_packets, tx_bytes, tx_errs, tx_colls, tx_carrier, tx_drops);
+ }
+ }
+ fclose(fp);
+ return 0;
+}
+
+static int do_show(int argc, char **argv)
+{
+ int err;
+ struct ip_tunnel_parm p;
+
+ if (parse_args(argc, argv, &p) < 0)
+ return -1;
+
+ switch (p.iph.protocol) {
+ case IPPROTO_IPIP:
+ err = do_get_ioctl(p.name[0] ? p.name : "tunl0", &p);
+ break;
+ case IPPROTO_GRE:
+ err = do_get_ioctl(p.name[0] ? p.name : "gre0", &p);
+ break;
+ case IPPROTO_IPV6:
+ err = do_get_ioctl(p.name[0] ? p.name : "sit0", &p);
+ break;
+ default:
+ do_tunnels_list(&p);
+ return 0;
+ }
+ if (err)
+ return -1;
+
+ print_tunnel(&p);
+ return 0;
+}
+
+int do_iptunnel(int argc, char **argv)
+{
+ if (argc > 0) {
+ if (matches(*argv, "add") == 0)
+ return do_add(SIOCADDTUNNEL, argc-1, argv+1);
+ if (matches(*argv, "change") == 0)
+ return do_add(SIOCCHGTUNNEL, argc-1, argv+1);
+ if (matches(*argv, "del") == 0)
+ return do_del(argc-1, argv+1);
+ if (matches(*argv, "show") == 0 ||
+ matches(*argv, "lst") == 0 ||
+ matches(*argv, "list") == 0)
+ return do_show(argc-1, argv+1);
+ } else
+ return do_show(0, NULL);
+
+ usage(E_OPTERR);
+}
+
+
+int preferred_family = AF_UNSPEC;
+int show_stats = 0;
+int resolve_hosts = 0;
+
+int main(int argc, char **argv)
+{
+ char *basename;
+
+#if I18N
+ setlocale (LC_ALL, "");
+ bindtextdomain("net-tools", "/usr/share/locale");
+ textdomain("net-tools");
+#endif
+
+ basename = strrchr(argv[0], '/');
+ if (basename == NULL)
+ basename = argv[0];
+ else
+ basename++;
+
+ while (argc > 1) {
+ if (argv[1][0] != '-')
+ break;
+ if (matches(argv[1], "-family") == 0) {
+ argc--;
+ argv++;
+ if (argc <= 1)
+ usage(E_OPTERR);
+ if (strcmp(argv[1], "inet") == 0)
+ preferred_family = AF_INET;
+ else if (strcmp(argv[1], "inet6") == 0)
+ preferred_family = AF_INET6;
+ else
+ usage(E_OPTERR);
+ } else if (matches(argv[1], "-stats") == 0 ||
+ matches(argv[1], "-statistics") == 0) {
+ ++show_stats;
+ } else if (matches(argv[1], "-resolve") == 0) {
+ ++resolve_hosts;
+ } else if ((matches(argv[1], "-V") == 0) || (matches(argv[1], "--version") == 0)) {
+ version();
+ } else if ((matches(argv[1], "-h") == 0) || (matches(argv[1], "--help") == 0)) {
+ usage(E_USAGE);
+ } else
+ usage(E_OPTERR);
+ argc--; argv++;
+ }
+
+ return do_iptunnel(argc-1, argv+1);
+}
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib/inet_gr.c
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib/inet_gr.c (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib/inet_gr.c (revision 5)
@@ -0,0 +1,459 @@
+/*
+ $Id: inet_gr.c,v 1.14 2009/07/08 00:24:03 ecki Exp $
+
+ Modifications:
+ 1998-07-01 - Arnaldo Carvalho de Melo - GNU gettext instead of catgets
+ 1999-01-01 - Bernd Eckenfels - fixed the routing cache printouts
+ 1999-10-07 - Kurt Garloff <garloff@suse.de> - do host (instead of network) name
+ lookup for gws and hosts
+ */
+
+#include "config.h"
+
+#if HAVE_AFINET
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <arpa/nameser.h>
+/* #include <net/route.h> realy broken */
+#include <ctype.h>
+#include <errno.h>
+#include <netdb.h>
+#include <resolv.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdio.h>
+#include <unistd.h>
+#include "version.h"
+#include "net-support.h"
+#include "pathnames.h"
+#include "intl.h"
+#include "net-features.h"
+#include "proc.h"
+#include "util.h"
+extern struct aftype inet_aftype;
+
+extern char *INET_sprintmask(const struct sockaddr_storage *sap, int numeric,
+ unsigned int netmask);
+
+int rprint_fib(int ext, int numeric)
+{
+ char buff[1024], iface[17], flags[64];
+ char gate_addr[128], net_addr[128];
+ char mask_addr[128];
+ int num, iflags, metric, refcnt, use, mss, window, irtt;
+ FILE *fp = fopen(_PATH_PROCNET_ROUTE, "r");
+ char *fmt;
+
+ if (!fp) {
+ perror(_PATH_PROCNET_ROUTE);
+ printf(_("INET (IPv4) not configured in this system.\n"));
+ return 1;
+ }
+ printf(_("Kernel IP routing table\n"));
+
+ if (ext == 1)
+ printf(_("Destination Gateway Genmask "
+ "Flags Metric Ref Use Iface\n"));
+ if (ext == 2)
+ printf(_("Destination Gateway Genmask "
+ "Flags MSS Window irtt Iface\n"));
+ if (ext >= 3)
+ printf(_("Destination Gateway Genmask "
+ "Flags Metric Ref Use Iface "
+ "MSS Window irtt\n"));
+
+ irtt = 0;
+ window = 0;
+ mss = 0;
+
+ fmt = proc_gen_fmt(_PATH_PROCNET_ROUTE, 0, fp,
+ "Iface", "%15s",
+ "Destination", "%127s",
+ "Gateway", "%127s",
+ "Flags", "%X",
+ "RefCnt", "%d",
+ "Use", "%d",
+ "Metric", "%d",
+ "Mask", "%127s",
+ "MTU", "%d",
+ "Window", "%d",
+ "IRTT", "%d",
+ NULL);
+ /* "%15s %127s %127s %X %d %d %d %127s %d %d %d\n" */
+
+ if (!fmt)
+ return 1;
+
+ while (fgets(buff, 1023, fp)) {
+ struct sockaddr_storage snet_target, snet_gateway, snet_mask;
+ struct sockaddr_in *sin_netmask;
+
+ num = sscanf(buff, fmt,
+ iface, net_addr, gate_addr,
+ &iflags, &refcnt, &use, &metric, mask_addr,
+ &mss, &window, &irtt);
+ if (num < 10 || !(iflags & RTF_UP))
+ continue;
+
+ /* Fetch and resolve the target address. */
+ (void) inet_aftype.input(1, net_addr, &snet_target);
+
+ /* Fetch and resolve the gateway address. */
+ (void) inet_aftype.input(1, gate_addr, &snet_gateway);
+
+ /* Fetch and resolve the genmask. */
+ (void) inet_aftype.input(1, mask_addr, &snet_mask);
+
+ sin_netmask = (struct sockaddr_in *)&snet_mask;
+ safe_strncpy(net_addr, INET_sprintmask(&snet_target,
+ (numeric | 0x8000 | (iflags & RTF_HOST? 0x4000: 0)),
+ sin_netmask->sin_addr.s_addr), sizeof(net_addr));
+ net_addr[15] = '\0';
+
+ safe_strncpy(gate_addr, inet_aftype.sprint(&snet_gateway, numeric | 0x4000),
+ sizeof(gate_addr));
+ gate_addr[15] = '\0';
+
+ safe_strncpy(mask_addr, inet_aftype.sprint(&snet_mask, 1), sizeof(mask_addr));
+ mask_addr[15] = '\0';
+
+ /* Decode the flags. */
+ flags[0] = '\0';
+ if (iflags & RTF_UP)
+ strcat(flags, "U");
+ if (iflags & RTF_GATEWAY)
+ strcat(flags, "G");
+#if HAVE_RTF_REJECT
+ if (iflags & RTF_REJECT)
+ safe_strncpy(flags, "!", sizeof(flags));
+#endif
+ if (iflags & RTF_HOST)
+ strcat(flags, "H");
+ if (iflags & RTF_REINSTATE)
+ strcat(flags, "R");
+ if (iflags & RTF_DYNAMIC)
+ strcat(flags, "D");
+ if (iflags & RTF_MODIFIED)
+ strcat(flags, "M");
+ if (iflags & RTF_DEFAULT)
+ strcat(flags, "d");
+ if (iflags & RTF_ALLONLINK)
+ strcat(flags, "a");
+ if (iflags & RTF_ADDRCONF)
+ strcat(flags, "c");
+ if (iflags & RTF_NONEXTHOP)
+ strcat(flags, "o");
+ if (iflags & RTF_EXPIRES)
+ strcat(flags, "e");
+ if (iflags & RTF_CACHE)
+ strcat(flags, "c");
+ if (iflags & RTF_FLOW)
+ strcat(flags, "f");
+ if (iflags & RTF_POLICY)
+ strcat(flags, "p");
+ if (iflags & RTF_LOCAL)
+ strcat(flags, "l");
+ if (iflags & RTF_MTU)
+ strcat(flags, "u");
+ if (iflags & RTF_WINDOW)
+ strcat(flags, "w");
+ if (iflags & RTF_IRTT)
+ strcat(flags, "i");
+ if (iflags & RTF_NOTCACHED) /* 2.0.36 */
+ strcat(flags, "n");
+
+ /* Print the info. */
+ if (ext == 1) {
+#if HAVE_RTF_REJECT
+ if (iflags & RTF_REJECT)
+ printf("%-15s - %-15s %-5s %-6d - %7d -\n",
+ net_addr, mask_addr, flags, metric, use);
+ else
+#endif
+ printf("%-15s %-15s %-15s %-5s %-6d %-2d %7d %s\n",
+ net_addr, gate_addr, mask_addr, flags,
+ metric, refcnt, use, iface);
+ }
+ if (ext == 2) {
+#if HAVE_RTF_REJECT
+ if (iflags & RTF_REJECT)
+ printf("%-15s - %-15s %-5s - - - -\n",
+ net_addr, mask_addr, flags);
+ else
+#endif
+ printf("%-15s %-15s %-15s %-5s %5d %-5d %6d %s\n",
+ net_addr, gate_addr, mask_addr, flags,
+ mss, window, irtt, iface);
+ }
+ if (ext >= 3) {
+#if HAVE_RTF_REJECT
+ if (iflags & RTF_REJECT)
+ printf("%-15s - %-15s %-5s %-6d - %7d - - - -\n",
+ net_addr, mask_addr, flags, metric, use);
+ else
+#endif
+ printf("%-15s %-15s %-15s %-5s %-6d %-3d %6d %-6.6s %-5d %-6d %d\n",
+ net_addr, gate_addr, mask_addr, flags,
+ metric, refcnt, use, iface, mss, window, irtt);
+ }
+ }
+
+ free(fmt);
+ (void) fclose(fp);
+ return (0);
+}
+
+int rprint_cache(int ext, int numeric)
+{
+ char buff[1024], iface[17], flags[64];
+ char gate_addr[128], dest_addr[128], specdst[128];
+ char src_addr[128];
+ struct sockaddr_storage snet;
+ unsigned int iflags;
+ int num, format, metric, refcnt, use, mss, window, irtt, hh, hhref, hhuptod, arp, tos;
+ char *fmt = NULL;
+
+ FILE *fp = fopen(_PATH_PROCNET_RTCACHE, "r");
+
+ if (!fp) {
+ perror(_PATH_PROCNET_RTCACHE);
+ printf(_("INET (IPv4) not configured in this system.\n"));
+ return 1;
+ }
+
+ /* Okay, first thing we need to know is the format of the rt_cache.
+ * I am aware of two possible layouts:
+ * 2.2.0
+ * "Iface\tDestination\tGateway \tFlags\t\tRefCnt\tUse\tMetric\tSource\t\tMTU\tWindow\tIRTT\tTOS\tHHRef\tHHUptod\tSpecDst"
+ * "%s\t%08lX\t%08lX\t%8X\t%d\t%u\t%d\t%08lX\t%d\t%u\t%u\t%02X\t%d\t%1d\t%08X"
+ *
+ * 2.0.36
+ * "Iface\tDestination\tGateway \tFlags\tRefCnt\tUse\tMetric\tSource\t\tMTU\tWindow\tIRTT\tHH\tARP"
+ * "%s\t%08lX\t%08lX\t%02X\t%d\t%u\t%d\t%08lX\t%d\t%lu\t%u\t%d\t%1d"
+ */
+
+ format = proc_guess_fmt(_PATH_PROCNET_RTCACHE, fp, "IRTT",1,"TOS",2,"HHRef",4,"HHUptod",8,"SpecDst",16,"HH",32,"ARP",64,NULL);
+
+ printf(_("Kernel IP routing cache\n"));
+
+ switch(format) {
+ case -1: /* I/O Error */
+ perror(_PATH_PROCNET_RTCACHE);
+ exit(-1);
+ break;
+ case 63: /* 2.2.0 Format */
+ format = 2;
+ break;
+ case 97: /* 2.0.36 Format */
+ format = 1;
+ break;
+ default:
+ printf("ERROR: proc_guess_fmt(%s,... returned: %d\n",_PATH_PROCNET_RTCACHE, format);
+ break;
+ }
+
+ rewind(fp);
+
+ if (ext == 1)
+ printf(_("Source Destination Gateway "
+ "Flags Metric Ref Use Iface\n"));
+ if (ext == 2)
+ printf(_("Source Destination Gateway "
+ "Flags MSS Window irtt Iface\n"));
+
+ if (format == 1) {
+ if (ext >= 3)
+ printf(_("Source Destination Gateway "
+ "Flags Metric Ref Use Iface "
+ "MSS Window irtt HH Arp\n"));
+
+ fmt = proc_gen_fmt(_PATH_PROCNET_RTCACHE, 0, fp,
+ "Iface", "%15s",
+ "Destination", "%127s",
+ "Gateway", "%127s",
+ "Flags", "%X",
+ "RefCnt", "%d",
+ "Use", "%d",
+ "Metric", "%d",
+ "Source", "%127s",
+ "MTU", "%d",
+ "Window", "%d",
+ "IRTT", "%d",
+ "HH", "%d",
+ "ARP", "%d",
+ NULL);
+ /* "%15s %127s %127s %X %d %d %d %127s %d %d %d %d %d\n" */
+ }
+
+ if (format == 2) {
+ if (ext >= 3) {
+ printf(_("Source Destination Gateway "
+ "Flags Metric Ref Use Iface "
+ "MSS Window irtt TOS HHRef HHUptod SpecDst\n"));
+
+ fmt = proc_gen_fmt(_PATH_PROCNET_RTCACHE, 0, fp,
+ "Iface", "%15s",
+ "Destination", "%127s",
+ "Gateway", "%127s",
+ "Flags", "%X",
+ "RefCnt", "%d",
+ "Use", "%d",
+ "Metric", "%d",
+ "Source", "%127s",
+ "MTU", "%d",
+ "Window", "%d",
+ "IRTT", "%d",
+ "TOS", "%d",
+ "HHRef", "%d",
+ "HHUptod", "%d",
+ "SpecDst", "%127s",
+ NULL);
+ /* "%15s %127s %127s %X %d %d %d %127s %d %d %d %d %d %127s\n" */
+ }
+ }
+
+
+ irtt = 0;
+ window = 0;
+ mss = 0;
+ hh = 0; hhref = 0; hhuptod = 0;
+ arp = 0; tos = 0;
+ while (fgets(buff, 1023, fp)) {
+ if (format == 1) {
+ num = sscanf(buff, fmt,
+ iface, dest_addr, gate_addr,
+ &iflags, &refcnt, &use, &metric, src_addr,
+ &mss, &window, &irtt, &hh, &arp);
+ if (num < 12)
+ continue;
+ }
+ if (format == 2) {
+ num = sscanf(buff, fmt,
+ iface, dest_addr, gate_addr,
+ &iflags, &refcnt, &use, &metric, src_addr,
+ &mss, &window, &irtt, &tos, &hhref, &hhuptod, &specdst);
+ if (num < 12)
+ continue;
+ }
+
+
+ /* Fetch and resolve the target address. */
+ (void) inet_aftype.input(1, dest_addr, &snet);
+ safe_strncpy(dest_addr, inet_aftype.sprint(&snet, numeric), sizeof(dest_addr));
+
+ /* Fetch and resolve the gateway address. */
+ (void) inet_aftype.input(1, gate_addr, &snet);
+ safe_strncpy(gate_addr, inet_aftype.sprint(&snet, numeric), sizeof(gate_addr));
+
+ /* Fetch and resolve the source. */
+ (void) inet_aftype.input(1, src_addr, &snet);
+ safe_strncpy(src_addr, inet_aftype.sprint(&snet, numeric), sizeof(src_addr));
+
+ /* Fetch and resolve the SpecDst addrerss. */
+ (void) inet_aftype.input(1, specdst, &snet);
+ safe_strncpy(specdst, inet_aftype.sprint(&snet, numeric), sizeof(specdst));
+
+ /* Decode the flags. */
+ flags[0] = '\0';
+if (format == 1) {
+ if (iflags & RTF_UP)
+ strcat(flags, "U");
+ if (iflags & RTF_HOST)
+ strcat(flags, "H");
+}
+ if (iflags & RTF_GATEWAY)
+ strcat(flags, "G");
+#if HAVE_RTF_REJECT
+ if (iflags & RTF_REJECT)
+ safe_strncpy(flags, "!", sizeof(flags));
+#endif
+ if (iflags & RTF_REINSTATE)
+ strcat(flags, "R");
+ if (iflags & RTF_DYNAMIC)
+ strcat(flags, "D");
+ if (iflags & RTF_MODIFIED)
+ strcat(flags, "M");
+
+/* possible collision with 2.0 flags U and H */
+if (format == 2) {
+ if (iflags & RTCF_DEAD)
+ strcat(flags, "-");
+ if (iflags & RTCF_ONLINK)
+ strcat(flags, "o");
+}
+ if (iflags & RTCF_NOTIFY)
+ strcat(flags, "n");
+ if (iflags & RTCF_DIRECTDST)
+ strcat(flags, "d");
+ if (iflags & RTCF_TPROXY)
+ strcat(flags, "t");
+ if (iflags & RTCF_FAST)
+ strcat(flags, "f");
+ if (iflags & RTCF_MASQ)
+ strcat(flags, "q");
+ if (iflags & RTCF_SNAT)
+ strcat(flags, "Ns");
+ if (iflags & RTCF_DOREDIRECT)
+ strcat(flags, "r");
+ if (iflags & RTCF_DIRECTSRC)
+ strcat(flags, "i");
+ if (iflags & RTCF_DNAT)
+ strcat(flags, "Nd");
+ if (iflags & RTCF_BROADCAST)
+ strcat(flags, "b");
+ if (iflags & RTCF_MULTICAST)
+ strcat(flags, "m");
+ if (iflags & RTCF_REJECT)
+ strcat(flags, "#");
+ if (iflags & RTCF_LOCAL)
+ strcat(flags, "l");
+ /* Print the info. */
+ if (ext == 1) {
+ printf("%-15s %-15s %-15s %-5s %-6d %-2d %7d %s\n",
+ src_addr, dest_addr, gate_addr, flags,
+ metric, refcnt, use, iface);
+ }
+ if (ext == 2) {
+ printf("%-15s %-15s %-15s %-5s %5d %-5d %6d %s\n",
+ src_addr, dest_addr, gate_addr, flags,
+ mss, window, irtt, iface);
+ }
+ if (format == 1) {
+ if (ext >= 3) {
+ printf("%-15s %-15s %-15s %-5s %-6d %-3d %6d %-6.6s %-5d %-6d %-5d %-3d %d\n",
+ src_addr, dest_addr, gate_addr, flags,
+ metric, refcnt, use, iface, mss, window, irtt, hh, arp);
+ }
+ }
+ if (format == 2) {
+ if (ext >= 3) {
+ printf("%-15s %-15s %-15s %-5s %-6d %-3d %6d %-6.6s %-5d %-6d %-5d %-3d %-3d %-3d %15s\n",
+ src_addr, dest_addr, gate_addr, flags,
+ metric, refcnt, use, iface, mss, window, irtt, tos, hhref, hhuptod, specdst);
+ }
+ }
+ }
+
+ free(fmt);
+ (void) fclose(fp);
+ return (0);
+}
+
+int INET_rprint(int options)
+{
+ int ext = options & FLAG_EXT;
+ int numeric = options & (FLAG_NUM_HOST | FLAG_SYM);
+ int rc = E_INTERN;
+
+ if (options & FLAG_FIB)
+ if ((rc = rprint_fib(ext, numeric)))
+ return (rc);
+ if (options & FLAG_CACHE)
+ rc = rprint_cache(ext, numeric);
+
+ return (rc);
+}
+
+#endif /* HAVE_AFINET */
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib/tr.c
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib/tr.c (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib/tr.c (revision 5)
@@ -0,0 +1,149 @@
+/*
+ * lib/tr.c This file contains an implementation of the "Tokenring"
+ * support functions.
+ *
+ * Version: $Id: tr.c,v 1.9 2005/05/16 03:15:12 ecki Exp $
+ *
+ * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
+ * Copyright 1993 MicroWalt Corporation
+ *
+ * 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; either version 2 of the License, or (at
+ * your option) any later version.
+ */
+#include "config.h"
+
+#if HAVE_HWTR
+#include <asm/types.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if_arp.h>
+#include <netinet/if_tr.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <errno.h>
+#include <ctype.h>
+#include <string.h>
+#include <unistd.h>
+#include "net-support.h"
+#include "pathnames.h"
+#include "intl.h"
+#include "util.h"
+
+
+/* actual definition at the end of file */
+extern struct hwtype tr_hwtype;
+#ifdef ARPHRD_IEEE802_TR
+extern struct hwtype tr_hwtype1;
+#endif
+
+static const char *pr_tr(const char *ptr)
+{
+ static char buff[64];
+
+ snprintf(buff, sizeof(buff), "%02X:%02X:%02X:%02X:%02X:%02X",
+ (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
+ (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
+ );
+ return (buff);
+ }
+
+#ifdef DEBUG
+#define _DEBUG 1
+#else
+#define _DEBUG 0
+#endif
+
+static int in_tr(char *bufp, struct sockaddr_storage *sasp)
+{
+ struct sockaddr *sap = (struct sockaddr *)sasp;
+ char *ptr;
+ char c, *orig;
+ int i, val;
+
+#ifdef ARPHRD_IEEE802_TR
+ if (kernel_version() < KRELEASE(2,3,30)) {
+ sap->sa_family = tr_hwtype.type;
+ } else {
+ sap->sa_family = tr_hwtype1.type;
+ }
+#else
+ sap->sa_family = tr_hwtype.type;
+ #warning "Limited functionality, no support for ARPHRD_IEEE802_TR (old kernel headers?)"
+#endif
+
+ ptr = sap->sa_data;
+
+ i = 0;
+ orig = bufp;
+ while ((*bufp != '\0') && (i < TR_ALEN)) {
+ val = 0;
+ c = *bufp++;
+ if (isdigit(c))
+ val = c - '0';
+ else if (c >= 'a' && c <= 'f')
+ val = c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ val = c - 'A' + 10;
+ else {
+ if (_DEBUG)
+ fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
+ errno = EINVAL;
+ return (-1);
+ }
+ val <<= 4;
+ c = *bufp++;
+ if (isdigit(c))
+ val |= c - '0';
+ else if (c >= 'a' && c <= 'f')
+ val |= c - 'a' + 10;
+ else if (c >= 'A' && c <= 'F')
+ val |= c - 'A' + 10;
+ else {
+ if (_DEBUG)
+ fprintf(stderr, _("in_tr(%s): invalid token ring address!\n"), orig);
+ errno = EINVAL;
+ return (-1);
+ }
+ *ptr++ = (unsigned char) (val & 0377);
+ i++;
+
+ /* We might get a semicolon here - not required. */
+ if (*bufp == ':') {
+ if (_DEBUG && i == TR_ALEN)
+ fprintf(stderr, _("in_tr(%s): trailing : ignored!\n"),
+ orig);
+ bufp++;
+ }
+ }
+
+ /* That's it. Any trailing junk? */
+ if (_DEBUG && (i == TR_ALEN) && (*bufp != '\0')) {
+ fprintf(stderr, _("in_tr(%s): trailing junk!\n"), orig);
+ errno = EINVAL;
+ return (-1);
+ }
+ if (_DEBUG)
+ fprintf(stderr, "in_tr(%s): %s\n", orig, pr_tr(sap->sa_data));
+
+ return (0);
+}
+
+
+struct hwtype tr_hwtype =
+{
+ "tr", NULL /* "16/4 Mbps Token Ring" */, ARPHRD_IEEE802, TR_ALEN,
+ pr_tr, in_tr, NULL
+};
+#ifdef ARPHRD_IEEE802_TR
+struct hwtype tr_hwtype1 =
+{
+ "tr", NULL /* "16/4 Mbps Token Ring" */, ARPHRD_IEEE802_TR, TR_ALEN,
+ pr_tr, in_tr, NULL
+};
+#endif
+
+
+#endif /* HAVE_HWTR */
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib (revision 5)
Property changes on: create-1.60-20210110-patch/net-tools-1.60-20210110-new/lib
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new/netstat.c
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new/netstat.c (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new/netstat.c (revision 5)
@@ -0,0 +1,2513 @@
+/*
+ * netstat This file contains an implementation of the command
+ * that helps in debugging the networking modules.
+ *
+ * NET-TOOLS A collection of programs that form the base set of the
+ * NET-3 Networking Distribution for the LINUX operating
+ * system.
+ *
+ * Version: $Id: netstat.c,v 1.73 2011-04-20 01:35:22 ecki Exp $
+ *
+ * Authors: Fred Baumgarten, <dc6iq@insu1.etec.uni-karlsruhe.de>
+ * Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
+ * Phil Packer, <pep@wicked.demon.co.uk>
+ * Johannes Stille, <johannes@titan.os.open.de>
+ * Bernd Eckenfels, <net-tools@lina.inka.de>
+ * Phil Blundell <philb@gnu.org>
+ * Tuan Hoang <tqhoang@bigfoot.com>
+ *
+ * Tuned for NET3 by:
+ * Alan Cox, <A.Cox@swansea.ac.uk>
+ * Copyright (c) 1993 Fred Baumgarten
+ *
+ * Modified:
+ *
+ *960116 {1.01} Bernd Eckenfels: verbose, cleanups
+ *960204 {1.10} Bernd Eckenfels: aftrans, usage, new route_info,
+ * DLFT_AF
+ *960204 {1.11} Bernd Eckenfels: netlink support
+ *960204 {1.12} Bernd Eckenfels: route_init()
+ *960215 {1.13} Bernd Eckenfels: netlink_print honors HAVE_
+ *960217 {1.14} Bernd Eckenfels: masq_info from Jos Vos and
+ * ax25_info from Jonathan Naylor.
+ *960218 {1.15} Bernd Eckenfels: ipx_info rewritten, -e for tcp/ipx
+ *960220 {1.16} Bernd Eckenfels: minor output reformats, -a for -x
+ *960221 {1.17} Bernd Eckenfels: route_init->getroute_init
+ *960426 {1.18} Bernd Eckenfels: new RTACTION, SYM/NUM, FIB/CACHE
+ *960517 {1.19} Bernd Eckenfels: usage() spelling fix and --unix inode,
+ * ':' is part of sock_addr for --inet
+ *960822 {x.xx} Frank Strauss: INET6 support
+ *
+ *970406 {1.33} Philip Copeland Added snmp reporting support module -s
+ * code provided by Andi Kleen
+ * (relly needs to be kernel hooked but
+ * this will do in the meantime)
+ * minor header file misplacement tidy up.
+ *980815 {1.xx} Stephane Fillod: X.25 support
+ *980411 {1.34} Arnaldo Carvalho i18n: catgets -> gnu gettext, substitution
+ * of sprintf for snprintf
+ *10/1998 Andi Kleen Use new interface primitives.
+ *990101 {1.36} Bernd Eckenfels usage updated to include -s and -C -F,
+ * fixed netstat -rC output (lib/inet_gr.c)
+ * removed broken NETLINK Support
+ * fixed format for /proc/net/udp|tcp|raw
+ * added -w,-t,-u TcpExt support to -s
+ *990131 {1.37} Jan Kratochvil added -p for prg_cache() & friends
+ * Flames to <short@ucw.cz>.
+ * Tuan Hoang added IGMP support for IPv4 and IPv6
+ *
+ *990420 {1.38} Tuan Hoang removed a useless assignment from igmp_do_one()
+ *20010404 {1.39} Arnaldo Carvalho de Melo - use setlocale
+ *20081201 {1.42} Brian Micek added -L|--udplite options for RFC 3828
+ *20020722 {1.51} Thomas Preusser added SCTP over IPv4 support
+ *
+ * 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; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ */
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
+#include <unistd.h>
+#include <ctype.h>
+#include <fcntl.h>
+#include <netdb.h>
+#include <paths.h>
+#include <pwd.h>
+#include <getopt.h>
+#include <sys/param.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <sys/stat.h>
+#include <net/if.h>
+#include <dirent.h>
+
+#include "net-support.h"
+#include "pathnames.h"
+#include "version.h"
+#include "config.h"
+#include "intl.h"
+#include "sockets.h"
+#include "interface.h"
+#include "util.h"
+#include "proc.h"
+
+#if HAVE_SELINUX
+#include <selinux/selinux.h>
+#endif
+
+#if HAVE_AFBLUETOOTH
+/*
+ Only following stuff is needed from
+ kernel: net/bluetooth/bluetooth.h
+ or bluez: bluetooth/bluetooth.h
+ */
+#define BT_SECURITY_SDP 0
+#define BT_SECURITY_LOW 1
+#define BT_SECURITY_MEDIUM 2
+#define BT_SECURITY_HIGH 3
+#define BT_SECURITY_FIPS 4
+
+/* Connection and socket states */
+enum {
+ BT_CONNECTED = 1, /* Equal to TCP_ESTABLISHED to make net code happy */
+ BT_OPEN,
+ BT_BOUND,
+ BT_LISTEN,
+ BT_CONNECT,
+ BT_CONNECT2,
+ BT_CONFIG,
+ BT_DISCONN,
+ BT_CLOSED
+};
+#endif
+
+#define PROGNAME_WIDTH 20
+#define SELINUX_WIDTH 50
+
+#if !defined(s6_addr32) && defined(in6a_words)
+#define s6_addr32 in6a_words /* libinet6 */
+#endif
+
+/* prototypes for statistics.c */
+void parsesnmp(int, int, int, int);
+void parsesnmp6(int, int, int);
+
+typedef enum {
+ SS_FREE = 0, /* not allocated */
+ SS_UNCONNECTED, /* unconnected to any socket */
+ SS_CONNECTING, /* in process of connecting */
+ SS_CONNECTED, /* connected to socket */
+ SS_DISCONNECTING /* in process of disconnecting */
+} socket_state;
+
+#define SO_ACCEPTCON (1<<16) /* performed a listen */
+#define SO_WAITDATA (1<<17) /* wait data to read */
+#define SO_NOSPACE (1<<18) /* no space to write */
+
+#define DFLT_AF "inet"
+
+#define FEATURE_NETSTAT
+#include "lib/net-features.h"
+
+static char *Release = RELEASE, *Signature = "Fred Baumgarten, Alan Cox, Bernd Eckenfels, Phil Blundell, Tuan Hoang, Brian Micek and others";
+
+
+#define E_READ -1
+#define E_IOCTL -3
+
+int flag_int = 0;
+int flag_rou = 0;
+int flag_mas = 0;
+int flag_sta = 0;
+
+int flag_all = 0;
+int flag_lst = 0;
+int flag_cnt = 0;
+int flag_deb = 0;
+int flag_not = 0;
+int flag_cf = 0;
+int flag_opt = 0;
+int flag_raw = 0;
+int flag_tcp = 0;
+int flag_sctp= 0;
+int flag_udp = 0;
+int flag_udplite = 0;
+int flag_igmp= 0;
+int flag_rom = 0;
+int flag_exp = 1;
+int flag_wide= 0;
+int flag_prg = 0;
+int flag_arg = 0;
+int flag_noprot = 0;
+int flag_ver = 0;
+int flag_l2cap = 0;
+int flag_rfcomm = 0;
+int flag_selinux = 0;
+
+FILE *procinfo;
+
+#define INFO_GUTS1(file,name,proc,prot) \
+ procinfo = proc_fopen((file)); \
+ if (procinfo == NULL) { \
+ if (errno != ENOENT && errno != EACCES) { \
+ perror((file)); \
+ return -1; \
+ } \
+ if (!flag_noprot && (flag_arg || flag_ver)) \
+ ESYSNOT("netstat", (name)); \
+ if (!flag_noprot && flag_arg) \
+ rc = 1; \
+ } else { \
+ do { \
+ if (fgets(buffer, sizeof(buffer), procinfo)) \
+ (proc)(lnr++, buffer,prot); \
+ } while (!feof(procinfo)); \
+ fclose(procinfo); \
+ }
+
+#if HAVE_AFINET6
+#define INFO_GUTS2(file,proc,prot) \
+ lnr = 0; \
+ procinfo = proc_fopen((file)); \
+ if (procinfo != NULL) { \
+ do { \
+ if (fgets(buffer, sizeof(buffer), procinfo)) \
+ (proc)(lnr++, buffer,prot); \
+ } while (!feof(procinfo)); \
+ fclose(procinfo); \
+ }
+#else
+#define INFO_GUTS2(file,proc,prot)
+#endif
+
+#define INFO_GUTS3 \
+ return rc;
+
+#define INFO_GUTS6(file,file6,name,proc,prot4,prot6) \
+ char buffer[8192]; \
+ int rc = 0; \
+ int lnr = 0; \
+ if (!flag_arg || flag_inet) { \
+ INFO_GUTS1(file,name,proc,prot4) \
+ } \
+ if (!flag_arg || flag_inet6) { \
+ INFO_GUTS2(file6,proc,prot6) \
+ } \
+ INFO_GUTS3
+
+#define INFO_GUTS(file,name,proc,prot) \
+ char buffer[8192]; \
+ int rc = 0; \
+ int lnr = 0; \
+ INFO_GUTS1(file,name,proc,prot) \
+ INFO_GUTS3
+
+#define PROGNAME_WIDTHs PROGNAME_WIDTH1(PROGNAME_WIDTH)
+#define PROGNAME_WIDTH1(s) PROGNAME_WIDTH2(s)
+#define PROGNAME_WIDTH2(s) #s
+
+#define SELINUX_WIDTHs SELINUX_WIDTH1(SELINUX_WIDTH)
+#define SELINUX_WIDTH1(s) SELINUX_WIDTH2(s)
+#define SELINUX_WIDTH2(s) #s
+
+#define PRG_HASH_SIZE 211
+
+static struct prg_node {
+ struct prg_node *next;
+ unsigned long inode;
+ char name[PROGNAME_WIDTH];
+ char scon[SELINUX_WIDTH];
+} *prg_hash[PRG_HASH_SIZE];
+
+static char prg_cache_loaded = 0;
+
+#define PRG_HASHIT(x) ((x) % PRG_HASH_SIZE)
+
+#define PROGNAME_BANNER "PID/Program name"
+#define SELINUX_BANNER "Security Context"
+
+#define print_progname_banner() do { if (flag_prg) printf(" %-" PROGNAME_WIDTHs "s",PROGNAME_BANNER); } while (0)
+
+#define print_selinux_banner() do { if (flag_selinux) printf("%-" SELINUX_WIDTHs "s"," " SELINUX_BANNER); } while (0)
+
+#define PRG_LOCAL_ADDRESS "local_address"
+#define PRG_INODE "inode"
+#define PRG_SOCKET_PFX "socket:["
+#define PRG_SOCKET_PFXl (strlen(PRG_SOCKET_PFX))
+#define PRG_SOCKET_PFX2 "[0000]:"
+#define PRG_SOCKET_PFX2l (strlen(PRG_SOCKET_PFX2))
+
+
+#ifndef LINE_MAX
+#define LINE_MAX 4096
+#endif
+
+#define PATH_PROC "/proc"
+#define PATH_FD_SUFF "fd"
+#define PATH_FD_SUFFl strlen(PATH_FD_SUFF)
+#define PATH_PROC_X_FD PATH_PROC "/%s/" PATH_FD_SUFF
+#define PATH_CMDLINE "cmdline"
+#define PATH_CMDLINEl strlen(PATH_CMDLINE)
+
+static void prg_cache_add(unsigned long inode, char *name, const char *scon)
+{
+ unsigned hi = PRG_HASHIT(inode);
+ struct prg_node **pnp,*pn;
+
+ prg_cache_loaded = 2;
+ for (pnp = prg_hash + hi; (pn = *pnp); pnp = &pn->next) {
+ if (pn->inode == inode) {
+ /* Some warning should be appropriate here
+ as we got multiple processes for one i-node */
+ return;
+ }
+ }
+ if (!(*pnp = malloc(sizeof(**pnp))))
+ return;
+ pn = *pnp;
+ pn->next = NULL;
+ pn->inode = inode;
+ safe_strncpy(pn->name, name, sizeof(pn->name));
+
+ {
+ int len = (strlen(scon) - sizeof(pn->scon)) + 1;
+ if (len > 0)
+ safe_strncpy(pn->scon, &scon[len + 1], sizeof(pn->scon));
+ else
+ safe_strncpy(pn->scon, scon, sizeof(pn->scon));
+ }
+
+}
+
+static const char *prg_cache_get(unsigned long inode)
+{
+ unsigned hi = PRG_HASHIT(inode);
+ struct prg_node *pn;
+
+ for (pn = prg_hash[hi]; pn; pn = pn->next)
+ if (pn->inode == inode)
+ return (pn->name);
+ return ("-");
+}
+
+static const char *prg_cache_get_con(unsigned long inode)
+{
+ unsigned hi = PRG_HASHIT(inode);
+ struct prg_node *pn;
+
+ for (pn = prg_hash[hi]; pn; pn = pn->next)
+ if (pn->inode == inode)
+ return (pn->scon);
+ return ("-");
+}
+
+static void prg_cache_clear(void)
+{
+ struct prg_node **pnp,*pn;
+
+ if (prg_cache_loaded == 2)
+ for (pnp = prg_hash; pnp < prg_hash + PRG_HASH_SIZE; pnp++)
+ while ((pn = *pnp)) {
+ *pnp = pn->next;
+ free(pn);
+ }
+ prg_cache_loaded = 0;
+}
+
+static void wait_continous(void)
+{
+ fflush(stdout);
+ sleep(1);
+}
+
+static int extract_type_1_socket_inode(const char lname[], unsigned long * inode_p) {
+
+ /* If lname is of the form "socket:[12345]", extract the "12345"
+ as *inode_p. Otherwise, return -1 as *inode_p.
+ */
+
+ if (strlen(lname) < PRG_SOCKET_PFXl+3) return(-1);
+
+ if (memcmp(lname, PRG_SOCKET_PFX, PRG_SOCKET_PFXl)) return(-1);
+ if (lname[strlen(lname)-1] != ']') return(-1);
+
+ {
+ char inode_str[strlen(lname + 1)]; /* e.g. "12345" */
+ const int inode_str_len = strlen(lname) - PRG_SOCKET_PFXl - 1;
+ char *serr;
+
+ strncpy(inode_str, lname+PRG_SOCKET_PFXl, inode_str_len);
+ inode_str[inode_str_len] = '\0';
+ *inode_p = strtoul(inode_str, &serr, 0);
+ if (!serr || *serr || *inode_p == ~0)
+ return(-1);
+ }
+ return(0);
+}
+
+
+
+static int extract_type_2_socket_inode(const char lname[], unsigned long * inode_p) {
+
+ /* If lname is of the form "[0000]:12345", extract the "12345"
+ as *inode_p. Otherwise, return -1 as *inode_p.
+ */
+
+ if (strlen(lname) < PRG_SOCKET_PFX2l+1) return(-1);
+ if (memcmp(lname, PRG_SOCKET_PFX2, PRG_SOCKET_PFX2l)) return(-1);
+
+ {
+ char *serr;
+
+ *inode_p = strtoul(lname + PRG_SOCKET_PFX2l, &serr, 0);
+ if (!serr || *serr || *inode_p == ~0)
+ return(-1);
+ }
+ return(0);
+}
+
+
+
+
+static void prg_cache_load(void)
+{
+ char line[LINE_MAX], eacces=0;
+ int procfdlen, fd, cmdllen, lnamelen;
+ char lname[30], cmdlbuf[512], finbuf[PROGNAME_WIDTH];
+ unsigned long inode;
+ const char *cs, *cmdlp;
+ DIR *dirproc = NULL, *dirfd = NULL;
+ struct dirent *direproc, *direfd;
+#if HAVE_SELINUX
+ security_context_t scon = NULL;
+#endif
+
+ if (prg_cache_loaded || !flag_prg) return;
+ prg_cache_loaded = 1;
+ cmdlbuf[sizeof(cmdlbuf) - 1] = '\0';
+ if (!(dirproc=opendir(PATH_PROC))) goto fail;
+ while (errno = 0, direproc = readdir(dirproc)) {
+ for (cs = direproc->d_name; *cs; cs++)
+ if (!isdigit(*cs))
+ break;
+ if (*cs)
+ continue;
+ procfdlen = snprintf(line,sizeof(line),PATH_PROC_X_FD,direproc->d_name);
+ if (procfdlen <= 0 || procfdlen >= sizeof(line) - 5)
+ continue;
+ errno = 0;
+ dirfd = opendir(line);
+ if (! dirfd) {
+ if (errno == EACCES)
+ eacces = 1;
+ continue;
+ }
+ line[procfdlen] = '/';
+ cmdlp = NULL;
+ while ((direfd = readdir(dirfd))) {
+ /* Skip . and .. */
+ if (!isdigit(direfd->d_name[0]))
+ continue;
+ if (procfdlen + 1 + strlen(direfd->d_name) + 1 > sizeof(line))
+ continue;
+ memcpy(line + procfdlen - PATH_FD_SUFFl, PATH_FD_SUFF "/",
+ PATH_FD_SUFFl + 1);
+ safe_strncpy(line + procfdlen + 1, direfd->d_name,
+ sizeof(line) - procfdlen - 1);
+ lnamelen = readlink(line, lname, sizeof(lname) - 1);
+ if (lnamelen == -1)
+ continue;
+ lname[lnamelen] = '\0'; /*make it a null-terminated string*/
+
+ if (extract_type_1_socket_inode(lname, &inode) < 0)
+ if (extract_type_2_socket_inode(lname, &inode) < 0)
+ continue;
+
+ if (!cmdlp) {
+ if (procfdlen - PATH_FD_SUFFl + PATH_CMDLINEl >=
+ sizeof(line) - 5)
+ continue;
+ safe_strncpy(line + procfdlen - PATH_FD_SUFFl, PATH_CMDLINE,
+ sizeof(line) - procfdlen + PATH_FD_SUFFl);
+ fd = open(line, O_RDONLY);
+ if (fd < 0)
+ continue;
+ cmdllen = read(fd, cmdlbuf, sizeof(cmdlbuf) - 1);
+ if (close(fd))
+ continue;
+ if (cmdllen == -1)
+ continue;
+ if (cmdllen < sizeof(cmdlbuf) - 1)
+ cmdlbuf[cmdllen]='\0';
+ if (cmdlbuf[0] == '/' && (cmdlp = strrchr(cmdlbuf, '/')))
+ cmdlp++;
+ else
+ cmdlp = cmdlbuf;
+ }
+
+ snprintf(finbuf, sizeof(finbuf), "%s/%s", direproc->d_name, cmdlp);
+#if HAVE_SELINUX
+ if (getpidcon(atoi(direproc->d_name), &scon) == -1) {
+ scon=xstrdup("-");
+ }
+ prg_cache_add(inode, finbuf, scon);
+ freecon(scon);
+#else
+ prg_cache_add(inode, finbuf, "-");
+#endif
+ }
+ closedir(dirfd);
+ dirfd = NULL;
+ }
+ if (dirproc)
+ closedir(dirproc);
+ if (dirfd)
+ closedir(dirfd);
+ if (!eacces)
+ return;
+ if (prg_cache_loaded == 1) {
+ fail:
+ fprintf(stderr,_("(No info could be read for \"-p\": geteuid()=%d but you should be root.)\n"),
+ geteuid());
+ }
+ else
+ fprintf(stderr, _("(Not all processes could be identified, non-owned process info\n"
+ " will not be shown, you would have to be root to see it all.)\n"));
+}
+
+#if HAVE_AFNETROM
+static const char *netrom_state[] =
+{
+ N_("LISTENING"),
+ N_("CONN SENT"),
+ N_("DISC SENT"),
+ N_("ESTABLISHED")
+};
+
+static int netrom_info(void)
+{
+ FILE *f;
+ char buffer[256], dev[16];
+ int st, vs, vr, sendq, recvq, ret;
+
+ f = proc_fopen(_PATH_PROCNET_NR);
+ if (f == NULL) {
+ if (errno != ENOENT) {
+ perror(_PATH_PROCNET_NR);
+ return (-1);
+ }
+ if (flag_arg || flag_ver)
+ ESYSNOT("netstat", "AF NETROM");
+ if (flag_arg)
+ return (1);
+ else
+ return (0);
+ }
+ printf(_("Active NET/ROM sockets\n"));
+ printf(_("User Dest Source Device State Vr/Vs Send-Q Recv-Q\n"));
+ if (fgets(buffer, 256, f))
+ /* eat line */;
+
+ while (fgets(buffer, 256, f)) {
+ buffer[9] = 0;
+ buffer[19] = 0;
+ buffer[29] = 0;
+ ret = sscanf(buffer + 30, "%s %*x/%*x %*x/%*x %d %d %d %*d %*d/%*d %*d/%*d %*d/%*d %*d/%*d %*d/%*d %*d %d %d %*d",
+ dev, &st, &vs, &vr, &sendq, &recvq);
+ if (ret != 6) {
+ printf(_("Problem reading data from %s\n"), _PATH_PROCNET_NR);
+ continue;
+ }
+ printf("%-9s %-9s %-9s %-6s %-11s %03d/%03d %-6d %-6d\n",
+ buffer, buffer + 10, buffer + 20,
+ dev,
+ _(netrom_state[st]),
+ vr, vs, sendq, recvq);
+ }
+ fclose(f);
+ return 0;
+}
+#endif
+
+#if HAVE_AFROSE
+static const char * const rose_state[] =
+{
+ N_("LISTENING"),
+ N_("CONN SENT"),
+ N_("DISC SENT"),
+ N_("ESTABLISHED"),
+};
+
+static int rose_info(void)
+{
+ FILE *f;
+ char buffer[256], dev[6];
+ int ret, st, lci, neigh;
+ char src_addr[10], src_call[9], dest_addr[10], dest_call[9];
+
+ f = fopen(_PATH_PROCNET_ROSE, "r");
+ if (f == NULL) {
+ if (errno != ENOENT) {
+ perror(_PATH_PROCNET_ROSE);
+ return (-1);
+ }
+ if (flag_arg || flag_ver)
+ ESYSNOT("netstat", "AF ROSE");
+ if (flag_arg)
+ return (1);
+ else
+ return (0);
+ }
+ printf(_("Active ROSE sockets\n"));
+ printf(_("dest_addr dest_call src_addr src_call dev lci neigh state\n"));
+ if (fgets(buffer, 256, f))
+ /* eat line */;
+
+ while (fgets(buffer, 256, f)) {
+ ret = sscanf(buffer, "%s %s %s %s %s %d %d %d",
+ dest_addr, dest_call, src_addr, src_call, dev, &lci, &neigh, &st);
+ if (ret != 8) {
+ printf(_("Problem reading data from %s\n"), _PATH_PROCNET_ROSE);
+ continue;
+ }
+ printf("%-10s %-9s %-10s %-9s %-5s %3d %5d %s\n",
+ dest_addr, dest_call, src_addr, src_call, dev, lci, neigh, _(rose_state[st]));
+ }
+ fclose(f);
+ return 0;
+}
+#endif
+
+/* These enums are used by IPX too. :-( */
+enum {
+ TCP_ESTABLISHED = 1,
+ TCP_SYN_SENT,
+ TCP_SYN_RECV,
+ TCP_FIN_WAIT1,
+ TCP_FIN_WAIT2,
+ TCP_TIME_WAIT,
+ TCP_CLOSE,
+ TCP_CLOSE_WAIT,
+ TCP_LAST_ACK,
+ TCP_LISTEN,
+ TCP_CLOSING /* now a valid state */
+};
+
+#if HAVE_AFINET || HAVE_AFINET6
+
+static const char *tcp_state[] =
+{
+ "",
+ N_("ESTABLISHED"),
+ N_("SYN_SENT"),
+ N_("SYN_RECV"),
+ N_("FIN_WAIT1"),
+ N_("FIN_WAIT2"),
+ N_("TIME_WAIT"),
+ N_("CLOSE"),
+ N_("CLOSE_WAIT"),
+ N_("LAST_ACK"),
+ N_("LISTEN"),
+ N_("CLOSING")
+};
+
+static void finish_this_one(int uid, unsigned long inode, const char *timers)
+{
+ struct passwd *pw;
+
+ if (flag_exp > 1) {
+ if (!(flag_not & FLAG_NUM_USER) && ((pw = getpwuid(uid)) != NULL))
+ printf(" %-10s ", pw->pw_name);
+ else
+ printf(" %-10d ", uid);
+ printf("%-10lu",inode);
+ }
+ if (flag_prg)
+ printf(" %-" PROGNAME_WIDTHs "s",prg_cache_get(inode));
+ if (flag_selinux)
+ printf(" %-" SELINUX_WIDTHs "s",prg_cache_get_con(inode));
+
+ if (flag_opt)
+ printf(" %s", timers);
+ putchar('\n');
+}
+
+static void igmp_do_one(int lnr, const char *line,const char *prot)
+{
+ char mcast_addr[128];
+ struct sockaddr_storage sas;
+ struct sockaddr_in *sin = (struct sockaddr_in *)&sas;
+#if HAVE_AFINET6
+ char addr6[INET6_ADDRSTRLEN];
+ struct in6_addr in6;
+ extern struct aftype inet6_aftype;
+#endif
+ const struct aftype *ap;
+ static int idx_flag = 0;
+ static int igmp6_flag = 0;
+ static char device[16];
+ int num, idx, refcnt;
+ char* offset;
+
+ if (lnr == 0) {
+ /* IPV6 ONLY */
+ /* igmp6 file does not have any comments on first line */
+ if ( strstr( line, "Device" ) == NULL ) {
+ igmp6_flag = 1;
+ } else {
+ /* IPV4 ONLY */
+ /* 2.1.x kernels and up have Idx field */
+ /* 2.0.x and below do not have Idx field */
+ if ( strncmp( line, "Idx", strlen("Idx") ) == 0 )
+ idx_flag = 1;
+ else
+ idx_flag = 0;
+ return;
+ }
+ }
+
+ if (igmp6_flag) { /* IPV6 */
+#if HAVE_AFINET6
+ num = sscanf( line, "%d %15s %64[0-9A-Fa-f] %d", &idx, device, mcast_addr, &refcnt );
+ if (num == 4) {
+ /* Demangle what the kernel gives us */
+ sscanf(mcast_addr, "%08X%08X%08X%08X",
+ &in6.s6_addr32[0], &in6.s6_addr32[1],
+ &in6.s6_addr32[2], &in6.s6_addr32[3]);
+ in6.s6_addr32[0] = htonl(in6.s6_addr32[0]);
+ in6.s6_addr32[1] = htonl(in6.s6_addr32[1]);
+ in6.s6_addr32[2] = htonl(in6.s6_addr32[2]);
+ in6.s6_addr32[3] = htonl(in6.s6_addr32[3]);
+ inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
+ inet6_aftype.input(1, addr6, &sas);
+ sas.ss_family = AF_INET6;
+ } else {
+ fprintf(stderr, _("warning, got bogus igmp6 line %d.\n"), lnr);
+ return;
+ }
+
+ if ((ap = get_afntype(sas.ss_family)) == NULL) {
+ fprintf(stderr, _("netstat: unsupported address family %d !\n"),
+ sas.ss_family);
+ return;
+ }
+ safe_strncpy(mcast_addr, ap->sprint(&sas, flag_not & FLAG_NUM_HOST),
+ sizeof(mcast_addr));
+ printf("%-15s %-6d %s\n", device, refcnt, mcast_addr);
+#endif
+ } else { /* IPV4 */
+#if HAVE_AFINET
+ if (line[0] != '\t') {
+ if (idx_flag) {
+ if ((num = sscanf(line, "%d\t%15c", &idx, device)) < 2) {
+ fprintf(stderr, _("warning, got bogus igmp line %d.\n"), lnr);
+ return;
+ }
+ } else {
+ if ((num = sscanf(line, "%15c", device)) < 1 ) {
+ fprintf(stderr, _("warning, got bogus igmp line %d.\n"), lnr);
+ return;
+ }
+ }
+
+ offset = strrchr(device, ':');
+ if (offset)
+ *offset = 0;
+
+ return;
+ } else if ( line[0] == '\t' ) {
+ if ( (num = sscanf(line, "\t%8[0-9A-Fa-f] %d", mcast_addr, &refcnt)) < 2 ) {
+ fprintf(stderr, _("warning, got bogus igmp line %d.\n"), lnr);
+ return;
+ }
+ sscanf(mcast_addr, "%X", &sin->sin_addr.s_addr);
+ sas.ss_family = AF_INET;
+ } else {
+ fprintf(stderr, _("warning, got bogus igmp line %d.\n"), lnr);
+ return;
+ }
+
+ if ((ap = get_afntype(sas.ss_family)) == NULL) {
+ fprintf(stderr, _("netstat: unsupported address family %d !\n"),
+ sas.ss_family);
+ return;
+ }
+ safe_strncpy(mcast_addr, ap->sprint(&sas, flag_not & FLAG_NUM_HOST),
+ sizeof(mcast_addr));
+ printf("%-15s %-6d %s\n", device, refcnt, mcast_addr );
+#endif
+ } /* IPV4 */
+}
+
+#if HAVE_AFX25
+static int x25_info(void)
+{
+ FILE *f=proc_fopen(_PATH_PROCNET_X25);
+ char buffer[256],dev[16];
+ int st,vs,vr,sendq,recvq,lci;
+ static char *x25_state[5]=
+ {
+ "LISTENING",
+ "SABM_SENT",
+ "DISC_SENT",
+ "ESTABLISHED",
+ "RECOVERY"
+ };
+ if(!f)
+ {
+ if (errno != ENOENT) {
+ perror(_PATH_PROCNET_X25);
+ return(-1);
+ }
+ if (flag_arg || flag_ver)
+ ESYSNOT("netstat","AF X25");
+ if (flag_arg)
+ return(1);
+ else
+ return(0);
+ }
+ printf( _("Active X.25 sockets\n"));
+ /* IMHO, Vr/Vs is not very usefull --SF */
+ printf( _("Dest Source Device LCI State Vr/Vs Send-Q Recv-Q\n"));
+ if (fgets(buffer,256,f))
+ /* eat line */;
+ while(fgets(buffer,256,f))
+ {
+ buffer[10]=0;
+ buffer[20]=0;
+ sscanf(buffer+22,"%s %d %d %d %d %*d %*d %*d %*d %*d %*d %d %d %*d",
+ dev,&lci,&st,&vs,&vr,&sendq,&recvq);
+ if (!(flag_all || lci))
+ continue;
+ printf("%-15s %-15s %-7s %-3d %-11s %02d/%02d %-6d %-6d\n",
+ buffer,buffer+11,
+ dev,
+ lci,
+ x25_state[st],
+ vr,vs,sendq,recvq);
+ }
+ fclose(f);
+ return 0;
+}
+#endif
+
+static int igmp_info(void)
+{
+ INFO_GUTS6(_PATH_PROCNET_IGMP, _PATH_PROCNET_IGMP6, "AF INET (igmp)",
+ igmp_do_one, "igmp", "igmp6");
+}
+
+static const char *sctp_socket_state_str(int state)
+{
+ if (state >= 0 && state < ARRAY_SIZE(tcp_state))
+ return tcp_state[state];
+ else {
+ static char state_str_buf[64];
+ sprintf(state_str_buf, "UNKNOWN(%d)", state);
+ return state_str_buf;
+ }
+}
+
+static const struct aftype *process_sctp_addr_str(const char *addr_str, struct sockaddr_storage *sas)
+{
+ 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, sas);
+ sas->ss_family = AF_INET6;
+#endif
+ } else {
+ struct sockaddr_in *sin = (struct sockaddr_in *)sas;
+ sin->sin_addr.s_addr = inet_addr(addr_str);
+ sas->ss_family = AF_INET;
+ }
+ return get_afntype(sas->ss_family);
+}
+
+static void sctp_eps_do_one(int lnr, char *line, const char *proto)
+{
+ char buffer[1024];
+ int state, port;
+ int uid;
+ unsigned long inode;
+ const struct aftype *ap;
+ struct sockaddr_storage localsas;
+ 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"); /* skip 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, &localsas);
+ if (ap)
+ safe_strncpy(local_addr, ap->sprint(&localsas, flag_not), sizeof(local_addr));
+ else
+ sprintf(local_addr, _("unsupported address family %d"), localsas.ss_family);
+
+ if (first)
+ printf("sctp ");
+ else
+ printf("\n ");
+ 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;
+
+ const struct aftype *ap;
+ struct sockaddr_storage localsas, remotesas;
+ 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"); /* skip 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, &localsas);
+ if (ap)
+ safe_strncpy(local_addr,
+ ap->sprint(&localsas, flag_not), sizeof(local_addr));
+ else
+ sprintf(local_addr, _("unsupported address family %d"), localsas.ss_family);
+ }
+ if (this_remote_addr) {
+ if (this_remote_addr[0] == '*') {
+ /* skip * */
+ this_remote_addr++;
+ }
+ ap = process_sctp_addr_str(this_remote_addr, &remotesas);
+ if (ap)
+ safe_strncpy(remote_addr,
+ ap->sprint(&remotesas, flag_not), sizeof(remote_addr));
+ else
+ sprintf(remote_addr, _("unsupported address family %d"), remotesas.ss_family);
+ }
+
+ if (first)
+ printf("sctp %6u %6u ", rxqueue, txqueue);
+ else
+ printf("\n ");
+ 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_eps(void)
+{
+ INFO_GUTS6(_PATH_PROCNET_SCTPEPTS, _PATH_PROCNET_SCTP6EPTS, "AF INET (sctp)",
+ sctp_eps_do_one, "sctp", "sctp6");
+}
+
+static int sctp_info_assocs(void)
+{
+ INFO_GUTS6(_PATH_PROCNET_SCTPASSOCS, _PATH_PROCNET_SCTP6ASSOCS, "AF INET (sctp)",
+ sctp_assoc_do_one, "sctp", "sctp6");
+}
+
+static int sctp_info(void)
+{
+ int res;
+
+ if (flag_all || flag_lst) {
+ res = sctp_info_eps();
+ if (res)
+ return res;
+ }
+
+ if (flag_all || !flag_lst) {
+ res = sctp_info_assocs();
+ }
+
+ return res;
+}
+
+static void addr_do_one(char *buf, size_t buf_len, size_t short_len, const struct aftype *ap,
+ const struct sockaddr_storage *addr,
+ int port, const char *proto
+)
+{
+ const char *sport, *saddr;
+ size_t port_len, addr_len;
+
+ saddr = ap->sprint(addr, flag_not & FLAG_NUM_HOST);
+ sport = get_sname(htons(port), proto, flag_not & FLAG_NUM_PORT);
+ addr_len = strlen(saddr);
+ port_len = strlen(sport);
+ if (!flag_wide && (addr_len + port_len > short_len)) {
+ /* Assume port name is short */
+ port_len = netmin(port_len, short_len - 4);
+ addr_len = short_len - port_len;
+ strncpy(buf, saddr, addr_len);
+ buf[addr_len] = '\0';
+ strcat(buf, ":");
+ strncat(buf, sport, port_len);
+ } else
+ snprintf(buf, buf_len, "%s:%s", saddr, sport);
+}
+
+static void tcp_do_one(int lnr, const char *line, const char *prot)
+{
+ unsigned long rxq, txq, time_len, retr, inode;
+ int num, local_port, rem_port, d, state, uid, timer_run, timeout;
+ char rem_addr[128], local_addr[128], timers[64];
+ const struct aftype *ap;
+ struct sockaddr_storage localsas, remsas;
+ struct sockaddr_in *localaddr = (struct sockaddr_in *)&localsas;
+ struct sockaddr_in *remaddr = (struct sockaddr_in *)&remsas;
+#if HAVE_AFINET6
+ char addr6[INET6_ADDRSTRLEN];
+ struct in6_addr in6;
+ extern struct aftype inet6_aftype;
+#endif
+ long clk_tck = ticks_per_second();
+
+ if (lnr == 0)
+ return;
+
+ num = sscanf(line,
+ "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %*s\n",
+ &d, local_addr, &local_port, rem_addr, &rem_port, &state,
+ &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode);
+
+ if (num < 11) {
+ fprintf(stderr, _("warning, got bogus tcp line.\n"));
+ return;
+ }
+
+ if (!flag_all && ((flag_lst && rem_port) || (!flag_lst && !rem_port)))
+ return;
+
+ if (strlen(local_addr) > 8) {
+#if HAVE_AFINET6
+ /* Demangle what the kernel gives us */
+ sscanf(local_addr, "%08X%08X%08X%08X",
+ &in6.s6_addr32[0], &in6.s6_addr32[1],
+ &in6.s6_addr32[2], &in6.s6_addr32[3]);
+ inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
+ inet6_aftype.input(1, addr6, &localsas);
+ sscanf(rem_addr, "%08X%08X%08X%08X",
+ &in6.s6_addr32[0], &in6.s6_addr32[1],
+ &in6.s6_addr32[2], &in6.s6_addr32[3]);
+ inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
+ inet6_aftype.input(1, addr6, &remsas);
+ localsas.ss_family = AF_INET6;
+ remsas.ss_family = AF_INET6;
+#endif
+ } else {
+ sscanf(local_addr, "%X", &localaddr->sin_addr.s_addr);
+ sscanf(rem_addr, "%X", &remaddr->sin_addr.s_addr);
+ localsas.ss_family = AF_INET;
+ remsas.ss_family = AF_INET;
+ }
+
+ if ((ap = get_afntype(localsas.ss_family)) == NULL) {
+ fprintf(stderr, _("netstat: unsupported address family %d !\n"),
+ localsas.ss_family);
+ return;
+ }
+
+ addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localsas, local_port, "tcp");
+ addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remsas, rem_port, "tcp");
+
+ timers[0] = '\0';
+ if (flag_opt)
+ switch (timer_run) {
+ case 0:
+ snprintf(timers, sizeof(timers), _("off (0.00/%ld/%d)"), retr, timeout);
+ break;
+
+ case 1:
+ snprintf(timers, sizeof(timers), _("on (%2.2f/%ld/%d)"),
+ (double) time_len / clk_tck, retr, timeout);
+ break;
+
+ case 2:
+ snprintf(timers, sizeof(timers), _("keepalive (%2.2f/%ld/%d)"),
+ (double) time_len / clk_tck, retr, timeout);
+ break;
+
+ case 3:
+ snprintf(timers, sizeof(timers), _("timewait (%2.2f/%ld/%d)"),
+ (double) time_len / clk_tck, retr, timeout);
+ break;
+
+ case 4:
+ snprintf(timers, sizeof(timers), _("probe (%2.2f/%ld/%d)"),
+ (double) time_len / clk_tck, retr, timeout);
+ break;
+
+ default:
+ snprintf(timers, sizeof(timers), _("unkn-%d (%2.2f/%ld/%d)"),
+ timer_run, (double) time_len / clk_tck, retr, timeout);
+ break;
+ }
+
+ printf("%-4s %6ld %6ld %-*s %-*s %-11s",
+ prot, rxq, txq, (int)netmax(23,strlen(local_addr)), local_addr, (int)netmax(23,strlen(rem_addr)), rem_addr, _(tcp_state[state]));
+
+ finish_this_one(uid,inode,timers);
+}
+
+static int tcp_info(void)
+{
+ INFO_GUTS6(_PATH_PROCNET_TCP, _PATH_PROCNET_TCP6, "AF INET (tcp)",
+ tcp_do_one, "tcp", "tcp6");
+}
+
+static int notnull(const struct sockaddr_storage *sas)
+{
+ const struct sockaddr_in *sin = (const struct sockaddr_in *)sas;
+
+#if HAVE_AFINET6
+ const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sas;
+
+ if (sin6->sin6_family == AF_INET6) {
+ return sin6->sin6_addr.s6_addr32[0] ||
+ sin6->sin6_addr.s6_addr32[1] ||
+ sin6->sin6_addr.s6_addr32[2] ||
+ sin6->sin6_addr.s6_addr32[3];
+ }
+#endif
+
+ return sin->sin_addr.s_addr;
+}
+
+static void udp_do_one(int lnr, const char *line,const char *prot)
+{
+ char local_addr[128], rem_addr[128];
+ char *udp_state, timers[64];
+ int num, local_port, rem_port, d, state, timer_run, uid, timeout;
+ struct sockaddr_storage localsas, remsas;
+ struct sockaddr_in *localaddr = (struct sockaddr_in *)&localsas;
+ struct sockaddr_in *remaddr = (struct sockaddr_in *)&remsas;
+#if HAVE_AFINET6
+ char addr6[INET6_ADDRSTRLEN];
+ struct in6_addr in6;
+ extern struct aftype inet6_aftype;
+#endif
+ const struct aftype *ap;
+ unsigned long rxq, txq, time_len, retr, inode;
+
+ if (lnr == 0)
+ return;
+
+ num = sscanf(line,
+ "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %*s\n",
+ &d, local_addr, &local_port,
+ rem_addr, &rem_port, &state,
+ &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode);
+
+ if (num < 10) {
+ fprintf(stderr, _("warning, got bogus udp line.\n"));
+ return;
+ }
+
+ if (strlen(local_addr) > 8) {
+#if HAVE_AFINET6
+ sscanf(local_addr, "%08X%08X%08X%08X",
+ &in6.s6_addr32[0], &in6.s6_addr32[1],
+ &in6.s6_addr32[2], &in6.s6_addr32[3]);
+ inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
+ inet6_aftype.input(1, addr6, &localsas);
+ sscanf(rem_addr, "%08X%08X%08X%08X",
+ &in6.s6_addr32[0], &in6.s6_addr32[1],
+ &in6.s6_addr32[2], &in6.s6_addr32[3]);
+ inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
+ inet6_aftype.input(1, addr6, &remsas);
+ localsas.ss_family = AF_INET6;
+ remsas.ss_family = AF_INET6;
+#endif
+ } else {
+ sscanf(local_addr, "%X", &localaddr->sin_addr.s_addr);
+ sscanf(rem_addr, "%X", &remaddr->sin_addr.s_addr);
+ localsas.ss_family = AF_INET;
+ remsas.ss_family = AF_INET;
+ }
+
+ retr = 0L;
+
+ if ((ap = get_afntype(localsas.ss_family)) == NULL) {
+ fprintf(stderr, _("netstat: unsupported address family %d !\n"),
+ localsas.ss_family);
+ return;
+ }
+ switch (state) {
+ case TCP_ESTABLISHED:
+ udp_state = _("ESTABLISHED");
+ break;
+
+ case TCP_CLOSE:
+ udp_state = "";
+ break;
+
+ default:
+ udp_state = _("UNKNOWN");
+ break;
+ }
+
+ if (flag_all || (notnull(&remsas) && !flag_lst) || (!notnull(&remsas) && flag_lst))
+ {
+ addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localsas, local_port, "udp");
+ addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remsas, rem_port, "udp");
+
+ timers[0] = '\0';
+ if (flag_opt)
+ switch (timer_run) {
+ case 0:
+ snprintf(timers, sizeof(timers), _("off (0.00/%ld/%d)"), retr, timeout);
+ break;
+
+ case 1:
+ case 2:
+ snprintf(timers, sizeof(timers), _("on%d (%2.2f/%ld/%d)"), timer_run, (double) time_len / 100, retr, timeout);
+ break;
+
+ default:
+ snprintf(timers, sizeof(timers), _("unkn-%d (%2.2f/%ld/%d)"), timer_run, (double) time_len / 100,
+ retr, timeout);
+ break;
+ }
+ printf("%-5s %6ld %6ld %-23s %-23s %-11s",
+ prot, rxq, txq, local_addr, rem_addr, udp_state);
+
+ finish_this_one(uid,inode,timers);
+ }
+}
+
+static int udp_info(void)
+{
+ INFO_GUTS6(_PATH_PROCNET_UDP, _PATH_PROCNET_UDP6, "AF INET (udp)",
+ udp_do_one, "udp", "udp6");
+}
+
+static int udplite_info(void)
+{
+ INFO_GUTS6(_PATH_PROCNET_UDPLITE, _PATH_PROCNET_UDPLITE6,
+ "AF INET (udplite)", udp_do_one, "udpl", "udpl6" );
+}
+
+static void raw_do_one(int lnr, const char *line,const char *prot)
+{
+ char local_addr[128], rem_addr[128];
+ char timers[64];
+ int num, local_port, rem_port, d, state, timer_run, uid, timeout;
+ struct sockaddr_storage localsas, remsas;
+ struct sockaddr_in *localaddr = (struct sockaddr_in *)&localsas;
+ struct sockaddr_in *remaddr = (struct sockaddr_in *)&remsas;
+#if HAVE_AFINET6
+ char addr6[INET6_ADDRSTRLEN];
+ struct in6_addr in6;
+ extern struct aftype inet6_aftype;
+#endif
+ const struct aftype *ap;
+ unsigned long rxq, txq, time_len, retr, inode;
+
+ if (lnr == 0)
+ return;
+
+ num = sscanf(line,
+ "%d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %lX:%lX %X:%lX %lX %d %d %lu %*s\n",
+ &d, local_addr, &local_port, rem_addr, &rem_port, &state,
+ &txq, &rxq, &timer_run, &time_len, &retr, &uid, &timeout, &inode);
+
+ if (num < 10) {
+ fprintf(stderr, _("warning, got bogus raw line.\n"));
+ return;
+ }
+
+ if (strlen(local_addr) > 8) {
+#if HAVE_AFINET6
+ sscanf(local_addr, "%08X%08X%08X%08X",
+ &in6.s6_addr32[0], &in6.s6_addr32[1],
+ &in6.s6_addr32[2], &in6.s6_addr32[3]);
+ inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
+ inet6_aftype.input(1, addr6, &localsas);
+ sscanf(rem_addr, "%08X%08X%08X%08X",
+ &in6.s6_addr32[0], &in6.s6_addr32[1],
+ &in6.s6_addr32[2], &in6.s6_addr32[3]);
+ inet_ntop(AF_INET6, &in6, addr6, sizeof(addr6));
+ inet6_aftype.input(1, addr6, &remsas);
+ localsas.ss_family = AF_INET6;
+ remsas.ss_family = AF_INET6;
+#endif
+ } else {
+ sscanf(local_addr, "%X", &localaddr->sin_addr.s_addr);
+ sscanf(rem_addr, "%X", &remaddr->sin_addr.s_addr);
+ localsas.ss_family = AF_INET;
+ remsas.ss_family = AF_INET;
+ }
+
+ if ((ap = get_afntype(localsas.ss_family)) == NULL) {
+ fprintf(stderr, _("netstat: unsupported address family %d !\n"), localsas.ss_family);
+ return;
+ }
+
+ if (flag_all || (notnull(&remsas) && !flag_lst) || (!notnull(&remsas) && flag_lst))
+ {
+ addr_do_one(local_addr, sizeof(local_addr), 22, ap, &localsas, local_port, "raw");
+ addr_do_one(rem_addr, sizeof(rem_addr), 22, ap, &remsas, rem_port, "raw");
+
+ timers[0] = '\0';
+ if (flag_opt)
+ switch (timer_run) {
+ case 0:
+ snprintf(timers, sizeof(timers), _("off (0.00/%ld/%d)"), retr, timeout);
+ break;
+
+ case 1:
+ case 2:
+ snprintf(timers, sizeof(timers), _("on%d (%2.2f/%ld/%d)"), timer_run, (double) time_len / 100,
+ retr, timeout);
+ break;
+
+ default:
+ snprintf(timers, sizeof(timers), _("unkn-%d (%2.2f/%ld/%d)"),
+ timer_run, (double) time_len / 100,
+ retr, timeout);
+ break;
+ }
+ printf("%-4s %6ld %6ld %-23s %-23s %-11d",
+ prot, rxq, txq, local_addr, rem_addr, state);
+
+ finish_this_one(uid,inode,timers);
+ }
+}
+
+static int raw_info(void)
+{
+ INFO_GUTS6(_PATH_PROCNET_RAW, _PATH_PROCNET_RAW6, "AF INET (raw)",
+ raw_do_one, "raw", "raw6");
+}
+
+#endif
+
+
+#if HAVE_AFUNIX
+
+#define HAS_INODE 1
+
+static void unix_do_one(int nr, const char *line, const char *prot)
+{
+ static int has = 0;
+ char path[MAXPATHLEN], ss_flags[32];
+ char *ss_proto, *ss_state, *ss_type;
+ int num, state, type;
+ void *d;
+ unsigned long refcnt, proto, flags, inode;
+
+ if (nr == 0) {
+ if (strstr(line, "Inode"))
+ has |= HAS_INODE;
+ return;
+ }
+ path[0] = '\0';
+ num = sscanf(line, "%p: %lX %lX %lX %X %X %lu %s",
+ &d, &refcnt, &proto, &flags, &type, &state, &inode, path);
+ if (num < 6) {
+ fprintf(stderr, _("warning, got bogus unix line.\n"));
+ return;
+ }
+ if (!(has & HAS_INODE))
+ snprintf(path,sizeof(path),"%lu",inode);
+
+ if (!flag_all) {
+ if ((state == SS_UNCONNECTED) && (flags & SO_ACCEPTCON)) {
+ if (!flag_lst)
+ return;
+ } else {
+ if (flag_lst)
+ return;
+ }
+ }
+
+ switch (proto) {
+ case 0:
+ ss_proto = "unix";
+ break;
+
+ default:
+ ss_proto = "??";
+ }
+
+ switch (type) {
+ case SOCK_STREAM:
+ ss_type = _("STREAM");
+ break;
+
+ case SOCK_DGRAM:
+ ss_type = _("DGRAM");
+ break;
+
+ case SOCK_RAW:
+ ss_type = _("RAW");
+ break;
+
+ case SOCK_RDM:
+ ss_type = _("RDM");
+ break;
+
+ case SOCK_SEQPACKET:
+ ss_type = _("SEQPACKET");
+ break;
+
+ default:
+ ss_type = _("UNKNOWN");
+ }
+
+ switch (state) {
+ case SS_FREE:
+ ss_state = _("FREE");
+ break;
+
+ case SS_UNCONNECTED:
+ /*
+ * Unconnected sockets may be listening
+ * for something.
+ */
+ if (flags & SO_ACCEPTCON) {
+ ss_state = _("LISTENING");
+ } else {
+ ss_state = "";
+ }
+ break;
+
+ case SS_CONNECTING:
+ ss_state = _("CONNECTING");
+ break;
+
+ case SS_CONNECTED:
+ ss_state = _("CONNECTED");
+ break;
+
+ case SS_DISCONNECTING:
+ ss_state = _("DISCONNECTING");
+ break;
+
+ default:
+ ss_state = _("UNKNOWN");
+ }
+
+ safe_strncpy(ss_flags, "[ ", sizeof(ss_flags));
+ if (flags & SO_ACCEPTCON)
+ strcat(ss_flags, "ACC ");
+ if (flags & SO_WAITDATA)
+ strcat(ss_flags, "W ");
+ if (flags & SO_NOSPACE)
+ strcat(ss_flags, "N ");
+
+ strcat(ss_flags, "]");
+
+ printf("%-5s %-6ld %-11s %-10s %-13s ",
+ ss_proto, refcnt, ss_flags, ss_type, ss_state);
+ if (has & HAS_INODE)
+ printf("%-8lu",inode);
+ else
+ printf("- ");
+ if (flag_prg)
+ printf(" %-" PROGNAME_WIDTHs "s",(has & HAS_INODE?prg_cache_get(inode):"-"));
+ if (flag_selinux)
+ printf(" %-" SELINUX_WIDTHs "s",(has & HAS_INODE?prg_cache_get_con(inode):"-"));
+
+ printf(" %s\n", path);
+}
+
+static int unix_info(void)
+{
+
+ printf(_("Active UNIX domain sockets "));
+ if (flag_all)
+ printf(_("(servers and established)"));
+ else {
+ if (flag_lst)
+ printf(_("(only servers)"));
+ else
+ printf(_("(w/o servers)"));
+ }
+
+ printf(_("\nProto RefCnt Flags Type State I-Node "));
+ print_progname_banner();
+ print_selinux_banner();
+ printf(_(" Path\n")); /* xxx */
+
+ {
+ INFO_GUTS(_PATH_PROCNET_UNIX, "AF UNIX", unix_do_one, "unix");
+ }
+}
+#endif
+
+
+#if HAVE_AFAX25
+static int ax25_info(void)
+{
+ FILE *f;
+ char buffer[256], buf[16];
+ char *src, *dst, *dev, *p;
+ int st, vs, vr, sendq, recvq, ret;
+ int new = -1; /* flag for new (2.1.x) kernels */
+ static char *ax25_state[5] =
+ {
+ N_("LISTENING"),
+ N_("SABM SENT"),
+ N_("DISC SENT"),
+ N_("ESTABLISHED"),
+ N_("RECOVERY")
+ };
+ if (!(f = proc_fopen(_PATH_PROCNET_AX25))) {
+ if (errno != ENOENT) {
+ perror(_PATH_PROCNET_AX25);
+ return (-1);
+ }
+ if (flag_arg || flag_ver)
+ ESYSNOT("netstat", "AF AX25");
+ if (flag_arg)
+ return (1);
+ else
+ return (0);
+ }
+ printf(_("Active AX.25 sockets\n"));
+ printf(_("Dest Source Device State Vr/Vs Send-Q Recv-Q\n"));
+ while (fgets(buffer, 256, f)) {
+ if (new == -1) {
+ if (!strncmp(buffer, "dest_addr", 9)) {
+ new = 0;
+ continue; /* old kernels have a header line */
+ } else
+ new = 1;
+ }
+ /*
+ * In a network connection with no user socket the Snd-Q, Rcv-Q
+ * and Inode fields are empty in 2.0.x and '*' in 2.1.x
+ */
+ sendq = 0;
+ recvq = 0;
+ if (new == 0) {
+ dst = buffer;
+ src = buffer + 10;
+ dst[9] = 0;
+ src[9] = 0;
+ ret = sscanf(buffer + 20, "%s %d %d %d %*d %*d/%*d %*d/%*d %*d/%*d %*d/%*d %*d/%*d %*d %*d %*d %d %d %*d",
+ buf, &st, &vs, &vr, &sendq, &recvq);
+ if (ret != 4 && ret != 6) {
+ printf(_("Problem reading data from %s\n"), _PATH_PROCNET_AX25);
+ continue;
+ }
+ dev = buf;
+ } else {
+ p = buffer;
+ while (*p != ' ') p++;
+ p++;
+ dev = p;
+ while (*p != ' ') p++;
+ *p++ = 0;
+ src = p;
+ while (*p != ' ') p++;
+ *p++ = 0;
+ dst = p;
+ while (*p != ' ') p++;
+ *p++ = 0;
+ ret = sscanf(p, "%d %d %d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %*d %d %d %*d",
+ &st, &vs, &vr, &sendq, &recvq);
+ if (ret != 3 && ret != 5) {
+ printf(_("problem reading data from %s\n"), _PATH_PROCNET_AX25);
+ continue;
+ }
+ /*
+ * FIXME: digipeaters should be handled somehow.
+ * For now we just strip them.
+ */
+ p = dst;
+ while (*p && *p != ',') p++;
+ *p = 0;
+ }
+ printf("%-9s %-9s %-6s %-11s %03d/%03d %-6d %-6d\n",
+ dst, src,
+ dev,
+ _(ax25_state[st]),
+ vr, vs, sendq, recvq);
+ }
+ fclose(f);
+ return 0;
+}
+#endif
+
+
+#if HAVE_AFIPX
+static int ipx_info(void)
+{
+ FILE *f;
+ char buf[256];
+ unsigned long txq, rxq;
+ unsigned int state;
+ unsigned int uid;
+ char *st;
+ int nc;
+ const struct aftype *ap;
+ struct passwd *pw;
+ char sad[50], dad[50];
+ struct sockaddr_storage sa;
+ unsigned sport = 0, dport = 0;
+ struct stat s;
+
+ f = proc_fopen(_PATH_PROCNET_IPX_SOCKET1);
+ if (!f) {
+ if (errno != ENOENT) {
+ perror(_PATH_PROCNET_IPX_SOCKET1);
+ return (-1);
+ }
+ f = proc_fopen(_PATH_PROCNET_IPX_SOCKET2);
+
+ /* We need to check for directory */
+ if (f) {
+ if (fstat (fileno(f), &s) == -1 ||
+ !S_ISREG(s.st_mode)) {
+ fclose(f);
+ f=NULL;
+ }
+ }
+
+ if (!f) {
+ if (errno != ENOENT) {
+ perror(_PATH_PROCNET_IPX_SOCKET2);
+ return (-1);
+ }
+ if (flag_arg || flag_ver)
+ ESYSNOT("netstat", "AF IPX");
+ if (flag_arg)
+ return (1);
+ else
+ return (0);
+ }
+ }
+ printf(_("Active IPX sockets\nProto Recv-Q Send-Q Local Address Foreign Address State")); /* xxx */
+ if (flag_exp > 1)
+ printf(_(" User")); /* xxx */
+ printf("\n");
+ if ((ap = get_afntype(AF_IPX)) == NULL) {
+ EINTERN("netstat.c", "AF_IPX missing");
+ fclose(f);
+ return (-1);
+ }
+ if (fgets(buf, 255, f))
+ /* eat line */;
+
+ while (fgets(buf, 255, f) != NULL) {
+ sscanf(buf, "%s %s %lX %lX %u %u",
+ sad, dad, &txq, &rxq, &state, &uid);
+ if ((st = rindex(sad, ':'))) {
+ *st++ = '\0';
+ sscanf(st, "%X", &sport); /* net byt order */
+ sport = ntohs(sport);
+ } else {
+ EINTERN("netstat.c", "ipx socket format error in source port");
+ fclose(f);
+ return (-1);
+ }
+ nc = 0;
+ if (strcmp(dad, "Not_Connected") != 0) {
+ if ((st = rindex(dad, ':'))) {
+ *st++ = '\0';
+ sscanf(st, "%X", &dport); /* net byt order */
+ dport = ntohs(dport);
+ } else {
+ EINTERN("netstat.c", "ipx socket format error in destination port");
+ fclose(f);
+ return (-1);
+ }
+ } else
+ nc = 1;
+
+ switch (state) {
+ case TCP_ESTABLISHED:
+ st = _("ESTAB");
+ break;
+
+ case TCP_CLOSE:
+ st = "";
+ break;
+
+ default:
+ st = _("UNK.");
+ break;
+ }
+
+ /* Fetch and resolve the Source */
+ (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(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
+ safe_strncpy(dad, "-", sizeof(dad));
+
+ printf("IPX %6ld %6ld %-26s %-26s %-5s", txq, rxq, sad, dad, st);
+ if (flag_exp > 1) {
+ if (!(flag_not & FLAG_NUM_USER) && ((pw = getpwuid(uid)) != NULL))
+ printf(" %-10s", pw->pw_name);
+ else
+ printf(" %-10d", uid);
+ }
+ printf("\n");
+ }
+ fclose(f);
+ return 0;
+}
+#endif
+
+#if HAVE_AFBLUETOOTH
+const char *bluetooth_state(int state)
+{
+ switch (state) {
+ case BT_CONNECTED:
+ return _("CONNECTED");
+ case BT_OPEN:
+ return _("OPEN");
+ case BT_BOUND:
+ return _("BOUND");
+ case BT_LISTEN:
+ return _("LISTEN");
+ case BT_CONNECT:
+ return _("CONNECT");
+ case BT_CONNECT2:
+ return _("CONNECT2");
+ case BT_CONFIG:
+ return _("CONFIG");
+ case BT_DISCONN:
+ return _("DISCONN");
+ case BT_CLOSED:
+ return _("CLOSED");
+ default:
+ return _("UNKNOWN");
+ }
+}
+
+static void l2cap_do_one(int nr, const char *line, const char *prot)
+{
+ char daddr[18], saddr[18];
+ unsigned dtype, stype, state, psm, dcid, scid, imtu, omtu, sec_level;
+ int num;
+ const char *bt_state, *bt_sec_level;
+
+ num = sscanf(line, "%17s (%u) %17s (%u) %d %d 0x%04x 0x%04x %d %d %d",
+ daddr, &dtype, saddr, &stype, &state, &psm, &dcid, &scid, &imtu, &omtu, &sec_level);
+
+ if (num != 11) {
+ num = sscanf(line, "%17s %17s %d %d 0x%04x 0x%04x %d %d %d",
+ daddr, saddr, &state, &psm, &dcid, &scid, &imtu, &omtu, &sec_level);
+
+ if (num != 9) {
+ fprintf(stderr, _("warning, got bogus l2cap line.\n"));
+ return;
+ }
+ }
+
+ if (flag_lst && !(state == BT_LISTEN || state == BT_BOUND))
+ return;
+ if (!(flag_all || flag_lst) && (state == BT_LISTEN || state == BT_BOUND))
+ return;
+
+ bt_state = bluetooth_state(state);
+ switch (sec_level) {
+ case BT_SECURITY_SDP:
+ bt_sec_level = _("SDP");
+ break;
+ case BT_SECURITY_LOW:
+ bt_sec_level = _("LOW");
+ break;
+ case BT_SECURITY_MEDIUM:
+ bt_sec_level = _("MEDIUM");
+ break;
+ case BT_SECURITY_HIGH:
+ bt_sec_level = _("HIGH");
+ break;
+ default:
+ bt_sec_level = _("UNKNOWN");
+ }
+
+ printf("l2cap %-17s %-17s %-9s %7d 0x%04x 0x%04x %7d %7d %-7s\n",
+ (strcmp (daddr, "00:00:00:00:00:00") == 0 ? "*" : daddr),
+ (strcmp (saddr, "00:00:00:00:00:00") == 0 ? "*" : saddr),
+ bt_state, psm, dcid, scid, imtu, omtu, bt_sec_level);
+}
+
+static int l2cap_info(void)
+{
+ printf("%-6s %-17s %-17s %-9s %7s %-6s %-6s %7s %7s %-7s\n",
+ "Proto", "Destination", "Source", "State", "PSM", "DCID", "SCID", "IMTU", "OMTU", "Security");
+ INFO_GUTS(_PATH_SYS_BLUETOOTH_L2CAP, "BTPROTO L2CAP", l2cap_do_one, "l2cap");
+}
+
+static void rfcomm_do_one(int nr, const char *line, const char *prot)
+{
+ char daddr[18], saddr[18];
+ unsigned state, channel;
+ int num;
+ const char *bt_state;
+
+ num = sscanf(line, "%17s %17s %d %d", daddr, saddr, &state, &channel);
+ if (num < 4) {
+ fprintf(stderr, _("warning, got bogus rfcomm line.\n"));
+ return;
+ }
+
+ if (flag_lst && !(state == BT_LISTEN || state == BT_BOUND))
+ return;
+ if (!(flag_all || flag_lst) && (state == BT_LISTEN || state == BT_BOUND))
+ return;
+
+ bt_state = bluetooth_state(state);
+ printf("rfcomm %-17s %-17s %-9s %7d\n",
+ (strcmp (daddr, "00:00:00:00:00:00") == 0 ? "*" : daddr),
+ (strcmp (saddr, "00:00:00:00:00:00") == 0 ? "*" : saddr),
+ bt_state, channel);
+}
+
+static int rfcomm_info(void)
+{
+ printf("%-6s %-17s %-17s %-9s %7s\n", "Proto", "Destination", "Source", "State", "Channel");
+ INFO_GUTS(_PATH_SYS_BLUETOOTH_RFCOMM, "BTPROTO RFCOMM", rfcomm_do_one, "rfcomm");
+}
+#endif
+
+static int iface_info(void)
+{
+ if (skfd < 0) {
+ if ((skfd = sockets_open(0)) < 0) {
+ perror("socket");
+ exit(1);
+ }
+ printf(_("Kernel Interface table\n"));
+ }
+ 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 (for_all_interfaces(do_if_print, &flag_all) < 0) {
+ perror(_("missing interface information"));
+ exit(1);
+ }
+ if (flag_cnt)
+ if_cache_free();
+ else {
+ close(skfd);
+ skfd = -1;
+ }
+
+ return 0;
+}
+
+
+static void version(void)
+{
+ printf("%s\n%s\n%s\n", Release, Signature, Features);
+ exit(E_VERSION);
+}
+
+
+static void usage(int rc)
+{
+ FILE *fp = rc ? stderr : stdout;
+ fprintf(fp, _("usage: netstat [-vWeenNcCF] [<Af>] -r netstat {-V|--version|-h|--help}\n"));
+ fprintf(fp, _(" netstat [-vWnNcaeol] [<Socket> ...]\n"));
+ fprintf(fp, _(" netstat { [-vWeenNac] -i | [-cnNe] -M | -s [-6tuw] }\n\n"));
+
+ fprintf(fp, _(" -r, --route display routing table\n"));
+ fprintf(fp, _(" -i, --interfaces display interface table\n"));
+ fprintf(fp, _(" -g, --groups display multicast group memberships\n"));
+ fprintf(fp, _(" -s, --statistics display networking statistics (like SNMP)\n"));
+#if HAVE_FW_MASQUERADE
+ fprintf(fp, _(" -M, --masquerade display masqueraded connections\n\n"));
+#endif
+
+ fprintf(fp, _(" -v, --verbose be verbose\n"));
+ fprintf(fp, _(" -W, --wide don't truncate IP addresses\n"));
+ fprintf(fp, _(" -n, --numeric don't resolve names\n"));
+ fprintf(fp, _(" --numeric-hosts don't resolve host names\n"));
+ fprintf(fp, _(" --numeric-ports don't resolve port names\n"));
+ fprintf(fp, _(" --numeric-users don't resolve user names\n"));
+ fprintf(fp, _(" -N, --symbolic resolve hardware names\n"));
+ fprintf(fp, _(" -e, --extend display other/more information\n"));
+ fprintf(fp, _(" -p, --programs display PID/Program name for sockets\n"));
+ fprintf(fp, _(" -o, --timers display timers\n"));
+ fprintf(fp, _(" -c, --continuous continuous listing\n\n"));
+ fprintf(fp, _(" -l, --listening display listening server sockets\n"));
+ fprintf(fp, _(" -a, --all display all sockets (default: connected)\n"));
+ fprintf(fp, _(" -F, --fib display Forwarding Information Base (default)\n"));
+ fprintf(fp, _(" -C, --cache display routing cache instead of FIB\n"));
+#if HAVE_SELINUX
+ fprintf(fp, _(" -Z, --context display SELinux security context for sockets\n"));
+#endif
+
+ fprintf(fp, _("\n <Socket>={-t|--tcp} {-u|--udp} {-U|--udplite} {-S|--sctp} {-w|--raw}\n"));
+ fprintf(fp, _(" {-x|--unix} --ax25 --ipx --netrom\n"));
+ fprintf(fp, _(" <AF>=Use '-6|-4' or '-A <af>' or '--<af>'; default: %s\n"), DFLT_AF);
+ fprintf(fp, _(" List of possible address families (which support routing):\n"));
+ print_aflist(1); /* 1 = routeable */
+ exit(rc);
+}
+
+
+int main
+ (int argc, char *argv[]) {
+ int i;
+ int lop;
+ static struct option longopts[] =
+ {
+ AFTRANS_OPTS,
+ {"version", 0, 0, 'V'},
+ {"interfaces", 0, 0, 'i'},
+ {"help", 0, 0, 'h'},
+ {"route", 0, 0, 'r'},
+#if HAVE_FW_MASQUERADE
+ {"masquerade", 0, 0, 'M'},
+#endif
+ {"protocol", 1, 0, 'A'},
+ {"tcp", 0, 0, 't'},
+ {"sctp", 0, 0, 'S'},
+ {"udp", 0, 0, 'u'},
+ {"udplite", 0, 0, 'U'},
+ {"raw", 0, 0, 'w'},
+ {"unix", 0, 0, 'x'},
+ {"l2cap", 0, 0, '2'},
+ {"rfcomm", 0, 0, 'f'},
+ {"listening", 0, 0, 'l'},
+ {"all", 0, 0, 'a'},
+ {"timers", 0, 0, 'o'},
+ {"continuous", 0, 0, 'c'},
+ {"extend", 0, 0, 'e'},
+ {"programs", 0, 0, 'p'},
+ {"verbose", 0, 0, 'v'},
+ {"statistics", 0, 0, 's'},
+ {"wide", 0, 0, 'W'},
+ {"numeric", 0, 0, 'n'},
+ {"numeric-hosts", 0, 0, '!'},
+ {"numeric-ports", 0, 0, '@'},
+ {"numeric-users", 0, 0, '#'},
+ {"symbolic", 0, 0, 'N'},
+ {"cache", 0, 0, 'C'},
+ {"fib", 0, 0, 'F'},
+ {"groups", 0, 0, 'g'},
+ {"context", 0, 0, 'Z'},
+ {NULL, 0, 0, 0}
+ };
+
+#if I18N
+ setlocale (LC_ALL, "");
+ bindtextdomain("net-tools", "/usr/share/locale");
+ textdomain("net-tools");
+#endif
+ getroute_init(); /* Set up AF routing support */
+
+ afname[0] = '\0';
+ while ((i = getopt_long(argc, argv, "A:CFMacdeghilnNoprsStuUvVWw2fx64?Z", longopts, &lop)) != EOF)
+ switch (i) {
+ case -1:
+ break;
+ case 1:
+ if (lop < 0 || lop >= AFTRANS_CNT) {
+ EINTERN("netstat.c", "longopts 1 range");
+ break;
+ }
+ if (aftrans_opt(longopts[lop].name))
+ exit(1);
+ break;
+ case 'A':
+ if (aftrans_opt(optarg))
+ exit(1);
+ break;
+ case 'M':
+ flag_mas++;
+ break;
+ case 'a':
+ flag_all++;
+ break;
+ case 'l':
+ flag_lst++;
+ break;
+ case 'c':
+ flag_cnt++;
+ break;
+
+ case 'd':
+ flag_deb++;
+ break;
+ case 'g':
+ flag_igmp++;
+ break;
+ case 'e':
+ flag_exp++;
+ break;
+ case 'p':
+ flag_prg++;
+ break;
+ case 'i':
+ flag_int++;
+ break;
+ case 'W':
+ flag_wide++;
+ break;
+ case 'n':
+ flag_not |= FLAG_NUM;
+ break;
+ case '!':
+ flag_not |= FLAG_NUM_HOST;
+ break;
+ case '@':
+ flag_not |= FLAG_NUM_PORT;
+ break;
+ case '#':
+ flag_not |= FLAG_NUM_USER;
+ break;
+ case 'N':
+ flag_not |= FLAG_SYM;
+ break;
+ case 'C':
+ flag_cf |= FLAG_CACHE;
+ break;
+ case 'F':
+ flag_cf |= FLAG_FIB;
+ break;
+ case 'o':
+ flag_opt++;
+ break;
+ case '6':
+ if (aftrans_opt("inet6"))
+ exit(1);
+ break;
+ case '4':
+ if (aftrans_opt("inet"))
+ exit(1);
+ break;
+ case 'V':
+ version();
+ /*NOTREACHED */
+ case 'v':
+ flag_ver |= FLAG_VERBOSE;
+ break;
+ case 'r':
+ flag_rou++;
+ break;
+ case 't':
+ flag_tcp++;
+ break;
+ case 'S':
+ flag_sctp++;
+ break;
+ case 'u':
+ flag_udp++;
+ break;
+ case 'U':
+ flag_udplite++;
+ break;
+ case 'w':
+ flag_raw++;
+ break;
+ case '2':
+ flag_l2cap++;
+ break;
+ case 'f':
+ flag_rfcomm++;
+ break;
+ case 'x':
+ if (aftrans_opt("unix"))
+ exit(1);
+ break;
+ case 'Z':
+#if HAVE_SELINUX
+ if (is_selinux_enabled() <= 0) {
+ fprintf(stderr, _("SELinux is not enabled on this machine.\n"));
+ exit(1);
+ }
+ flag_prg++;
+ flag_selinux++;
+#else
+ fprintf(stderr, _("SELinux is not enabled for this application.\n"));
+ exit(1);
+#endif
+
+ break;
+ case '?':
+ usage(E_OPTERR);
+ case 'h':
+ usage(E_USAGE);
+ case 's':
+ flag_sta++;
+ }
+
+ if (flag_int + flag_rou + flag_mas + flag_sta > 1)
+ usage(E_OPTERR);
+
+ if ((flag_inet || flag_inet6 || flag_sta) &&
+ !(flag_tcp || flag_sctp || flag_udp || flag_udplite || flag_raw))
+ flag_noprot = flag_tcp = flag_sctp = flag_udp = flag_udplite = flag_raw = 1;
+
+ if ((flag_tcp || flag_sctp || flag_udp || flag_udplite || flag_raw || flag_igmp) &&
+ !(flag_inet || flag_inet6))
+ flag_inet = flag_inet6 = 1;
+
+ if (flag_bluetooth && !(flag_l2cap || flag_rfcomm))
+ flag_l2cap = flag_rfcomm = 1;
+
+ flag_arg = flag_tcp + flag_sctp + flag_udplite + flag_udp + flag_raw + flag_unx
+ + flag_ipx + flag_ax25 + flag_netrom + flag_igmp + flag_x25 + flag_rose
+ + flag_l2cap + flag_rfcomm;
+
+ if (flag_mas) {
+#if HAVE_FW_MASQUERADE && HAVE_AFINET
+#if MORE_THAN_ONE_MASQ_AF
+ if (!afname[0])
+ safe_strncpy(afname, DFLT_AF, sizeof(afname));
+#endif
+ for (;;) {
+ i = ip_masq_info(flag_not & FLAG_NUM_HOST,
+ flag_not & FLAG_NUM_PORT, flag_exp);
+ if (i || !flag_cnt)
+ break;
+ wait_continous();
+ }
+#else
+ ENOSUPP("netstat", "FW_MASQUERADE");
+ i = -1;
+#endif
+ return (i);
+ }
+
+ if (flag_sta) {
+ if (!afname[0])
+ safe_strncpy(afname, DFLT_AF, sizeof(afname));
+
+ if (!strcmp(afname, "inet")) {
+#if HAVE_AFINET
+ parsesnmp(flag_raw, flag_tcp, flag_udp, flag_sctp);
+#else
+ ENOSUPP("netstat", "AF INET");
+ exit(1);
+#endif
+ } else if(!strcmp(afname, "inet6")) {
+#if HAVE_AFINET6
+ parsesnmp6(flag_raw, flag_tcp, flag_udp);
+#else
+ ENOSUPP("netstat", "AF INET6");
+ exit(1);
+#endif
+ } else {
+ printf(_("netstat: No statistics support for specified address family: %s\n"), afname);
+ exit(1);
+ }
+ exit(0);
+ }
+
+ if (flag_rou) {
+ int options = 0;
+
+ if (!afname[0])
+ safe_strncpy(afname, DFLT_AF, sizeof(afname));
+
+ if (flag_exp == 2)
+ flag_exp = 1;
+ else if (flag_exp == 1)
+ flag_exp = 2;
+
+ options = (flag_exp & FLAG_EXT) | flag_not | flag_cf | flag_ver;
+ if (!flag_cf)
+ options |= FLAG_FIB;
+
+ for (;;) {
+ i = route_info(afname, options);
+ if (i || !flag_cnt)
+ break;
+ wait_continous();
+ }
+ return (i);
+ }
+ if (flag_int) {
+ for (;;) {
+ i = iface_info();
+ if (!flag_cnt || i)
+ break;
+ wait_continous();
+ }
+ return (i);
+ }
+ for (;;) {
+ if (!flag_arg || flag_tcp || flag_sctp || flag_udp || flag_udplite || flag_raw) {
+#if HAVE_AFINET
+ prg_cache_load();
+ printf(_("Active Internet connections ")); /* xxx */
+
+ if (flag_all)
+ printf(_("(servers and established)"));
+ else {
+ if (flag_lst)
+ printf(_("(only servers)"));
+ else
+ printf(_("(w/o servers)"));
+ }
+ printf(_("\nProto Recv-Q Send-Q Local Address Foreign Address State ")); /* xxx */
+ if (flag_exp > 1)
+ printf(_(" User Inode "));
+ print_progname_banner();
+ print_selinux_banner();
+ if (flag_opt)
+ printf(_(" Timer")); /* xxx */
+ printf("\n");
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF INET");
+ }
+#endif
+ }
+#if HAVE_AFINET
+ if (!flag_arg || flag_tcp) {
+ i = tcp_info();
+ if (i)
+ return (i);
+ }
+
+ if (!flag_arg || flag_sctp) {
+ i = sctp_info();
+ if (i)
+ return (i);
+ }
+
+ if (!flag_arg || flag_udp) {
+ i = udp_info();
+ if (i)
+ return (i);
+ }
+
+ if (!flag_arg || flag_udplite) {
+ i = udplite_info();
+ if (i)
+ return (i);
+ }
+
+ if (!flag_arg || flag_raw) {
+ i = raw_info();
+ if (i)
+ return (i);
+ }
+
+ if (flag_igmp) {
+#if HAVE_AFINET6
+ printf( "IPv6/");
+#endif
+ printf( _("IPv4 Group Memberships\n") );
+ printf( _("Interface RefCnt Group\n") );
+ printf( "--------------- ------ ---------------------\n" );
+ i = igmp_info();
+ if (i)
+ return (i);
+ }
+#endif
+
+ if (!flag_arg || flag_unx) {
+#if HAVE_AFUNIX
+ prg_cache_load();
+ i = unix_info();
+ if (i)
+ return (i);
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF UNIX");
+ }
+#endif
+ }
+ if (!flag_arg || flag_ipx) {
+#if HAVE_AFIPX
+ i = ipx_info();
+ if (i)
+ return (i);
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF IPX");
+ }
+#endif
+ }
+ if (!flag_arg || flag_ax25) {
+#if HAVE_AFAX25
+ i = ax25_info();
+ if (i)
+ return (i);
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF AX25");
+ }
+#endif
+ }
+ if(!flag_arg || flag_x25) {
+#if HAVE_AFX25
+ /* FIXME */
+ i = x25_info();
+ if (i)
+ return(i);
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF X25");
+ }
+#endif
+ }
+ if (!flag_arg || flag_netrom) {
+#if HAVE_AFNETROM
+ i = netrom_info();
+ if (i)
+ return (i);
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF NETROM");
+ }
+#endif
+ }
+ if (!flag_arg || flag_rose) {
+#if HAVE_AFROSE
+ i = rose_info();
+ if (i)
+ return (i);
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF ROSE");
+ }
+#endif
+ }
+
+ if (!flag_arg || flag_l2cap || flag_rfcomm) {
+#if HAVE_AFBLUETOOTH
+ printf(_("Active Bluetooth connections ")); /* xxx */
+
+ if (flag_all)
+ printf(_("(servers and established)"));
+ else {
+ if (flag_lst)
+ printf(_("(only servers)"));
+ else
+ printf(_("(w/o servers)"));
+ }
+ printf("\n");
+#else
+ if (flag_arg) {
+ i = 1;
+ ENOSUPP("netstat", "AF BLUETOOTH");
+ }
+#endif
+ }
+#if HAVE_AFBLUETOOTH
+ if (!flag_arg || flag_l2cap) {
+ i = l2cap_info();
+ if (i)
+ return (i);
+ }
+ if (!flag_arg || flag_rfcomm) {
+ i = rfcomm_info();
+ if (i)
+ return (i);
+ }
+#endif
+
+ if (!flag_cnt || i)
+ break;
+ wait_continous();
+ prg_cache_clear();
+ }
+ return (i);
+}
Index: create-1.60-20210110-patch/net-tools-1.60-20210110-new
===================================================================
--- create-1.60-20210110-patch/net-tools-1.60-20210110-new (nonexistent)
+++ create-1.60-20210110-patch/net-tools-1.60-20210110-new (revision 5)
Property changes on: create-1.60-20210110-patch/net-tools-1.60-20210110-new
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: create-1.60-20210110-patch
===================================================================
--- create-1.60-20210110-patch (nonexistent)
+++ create-1.60-20210110-patch (revision 5)
Property changes on: create-1.60-20210110-patch
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: patches/README
===================================================================
--- patches/README (nonexistent)
+++ patches/README (revision 5)
@@ -0,0 +1,6 @@
+
+/* begin *
+
+ TODO: Leave some comment here.
+
+ * end */
Index: patches
===================================================================
--- patches (nonexistent)
+++ patches (revision 5)
Property changes on: patches
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~
Index: .
===================================================================
--- . (nonexistent)
+++ . (revision 5)
Property changes on: .
___________________________________________________________________
Added: svn:ignore
## -0,0 +1,73 ##
+
+# install dir
+dist
+
+# Target build dirs
+.a1x-newlib
+.a2x-newlib
+.at91sam7s-newlib
+
+.build-machine
+
+.a1x-glibc
+.a2x-glibc
+.h3-glibc
+.h5-glibc
+.i586-glibc
+.i686-glibc
+.imx6-glibc
+.jz47xx-glibc
+.makefile
+.am335x-glibc
+.omap543x-glibc
+.p5600-glibc
+.power8-glibc
+.power8le-glibc
+.power9-glibc
+.power9le-glibc
+.m1000-glibc
+.riscv64-glibc
+.rk328x-glibc
+.rk33xx-glibc
+.rk339x-glibc
+.s8xx-glibc
+.s9xx-glibc
+.x86_64-glibc
+
+# Hidden files (each file)
+.makefile
+.dist
+.rootfs
+
+# src & hw requires
+.src_requires
+.src_requires_depend
+.requires
+.requires_depend
+
+# Tarballs
+*.gz
+*.bz2
+*.lz
+*.xz
+*.tgz
+*.txz
+
+# Signatures
+*.asc
+*.sig
+*.sign
+*.sha1sum
+
+# Patches
+*.patch
+
+# Descriptions
+*.dsc
+*.txt
+
+# Default linux config files
+*.defconfig
+
+# backup copies
+*~