Removed HFI support + Improved num-ports.patch

This commit is contained in:
Jiri Popelka 2011-10-25 13:47:33 +02:00
parent 4b91bef840
commit 664ef26a7e
3 changed files with 57 additions and 205 deletions

View File

@ -1,183 +0,0 @@
diff -up net-tools-1.60/config.in.hfi net-tools-1.60/config.in
--- net-tools-1.60/config.in.hfi 2010-09-16 17:20:04.000000000 +0200
+++ net-tools-1.60/config.in 2010-09-16 19:17:35.000000000 +0200
@@ -83,6 +83,7 @@ bool '(Cisco)-HDLC/LAPB support' HAVE_HW
bool 'IrDA support' HAVE_HWIRDA y
bool 'Econet hardware support' HAVE_HWEC n
bool 'InfiniBand hardware support' HAVE_HWIB y
+bool 'HFI support' HAVE_HWHFI y
*
*
* Other Features.
diff -up net-tools-1.60/lib/hfi.c.hfi net-tools-1.60/lib/hfi.c
--- net-tools-1.60/lib/hfi.c.hfi 2010-09-16 19:17:58.000000000 +0200
+++ net-tools-1.60/lib/hfi.c 2010-09-16 19:19:49.000000000 +0200
@@ -0,0 +1,125 @@
+#include "config.h"
+
+#if HAVE_HWHFI
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if_arp.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"
+
+extern struct hwtype hfi_hwtype;
+
+#define HF_ALEN 6 /* from hf_if.h */
+
+/* Display an HFI address in readable format. */
+static char *pr_hfi(unsigned 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);
+}
+
+
+/* Input an HFI address and convert to binary. */
+static int in_hfi(char *bufp, struct sockaddr *sap)
+{
+ unsigned char *ptr;
+ char c, *orig;
+ int i;
+ unsigned val;
+
+ sap->sa_family = hfi_hwtype.type;
+ ptr = sap->sa_data;
+
+ i = 0;
+ orig = bufp;
+ while ((*bufp != '\0') && (i < HF_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 {
+#ifdef DEBUG
+ fprintf(stderr, _("in_hfi(%s): invalid hfi address!\n"), orig);
+#endif
+ 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 (c == ':' || c == 0)
+ val >>= 4;
+ else {
+#ifdef DEBUG
+ fprintf(stderr, _("in_hfi(%s): invalid hfi address!\n"), orig);
+#endif
+ errno = EINVAL;
+ return (-1);
+ }
+ if (c != 0)
+ bufp++;
+ *ptr++ = (unsigned char) (val & 0377);
+ i++;
+
+ /* We might get a semicolon here - not required. */
+ if (*bufp == ':') {
+ if (i == HF_ALEN) {
+#ifdef DEBUG
+ fprintf(stderr, _("in_hfi(%s): trailing : ignored!\n"),
+ orig)
+#endif
+ ; /* nothing */
+ }
+ bufp++;
+ }
+ }
+
+ /* That's it. Any trailing junk? */
+ if ((i == HF_ALEN) && (*bufp != '\0')) {
+#ifdef DEBUG
+ fprintf(stderr, _("in_hfi(%s): trailing junk!\n"), orig);
+ errno = EINVAL;
+ return (-1);
+#endif
+ }
+#ifdef DEBUG
+ fprintf(stderr, "in_hfi(%s): %s\n", orig, pr_hfi(sap->sa_data));
+#endif
+
+ return (0);
+}
+
+#if !defined(ARPHRD_HFI)
+#define ARPHRD_HFI 37 /* goes into if_arp.h */
+#endif
+
+struct hwtype hfi_hwtype =
+{
+ "hfi", NULL, /*"HFI", */ ARPHRD_HFI, HF_ALEN,
+ pr_hfi, in_hfi, NULL
+};
+
+
+#endif /* HAVE_HWHFI */
diff -up net-tools-1.60/lib/hw.c.hfi net-tools-1.60/lib/hw.c
--- net-tools-1.60/lib/hw.c.hfi 2010-09-16 17:20:04.000000000 +0200
+++ net-tools-1.60/lib/hw.c 2010-09-16 19:21:28.000000000 +0200
@@ -42,6 +42,7 @@ extern struct hwtype adaptive_hwtype;
extern struct hwtype strip_hwtype;
extern struct hwtype ether_hwtype;
+extern struct hwtype hfi_hwtype;
extern struct hwtype fddi_hwtype;
extern struct hwtype hippi_hwtype;
extern struct hwtype tr_hwtype;
@@ -146,6 +147,9 @@ static struct hwtype *hwtypes[] =
#if HAVE_HWX25
&x25_hwtype,
#endif
+#if HAVE_HWHFI
+ &hfi_hwtype,
+#endif
#if HAVE_HWIB
&ib_hwtype,
#endif
@@ -222,6 +226,9 @@ void hwinit()
#if HAVE_HWEC
ec_hwtype.title = _("Econet");
#endif
+#if HAVE_HWHFI
+ hfi_hwtype.title = _("HFI");
+#endif
#if HAVE_HWIB
ib_hwtype.title = _("InfiniBand");
#endif
diff -up net-tools-1.60/lib/Makefile.hfi net-tools-1.60/lib/Makefile
--- net-tools-1.60/lib/Makefile.hfi 2010-09-16 17:20:04.000000000 +0200
+++ net-tools-1.60/lib/Makefile 2010-09-16 19:22:34.000000000 +0200
@@ -16,7 +16,7 @@
#
-HWOBJS = hw.o loopback.o slip.o ether.o ax25.o ppp.o arcnet.o tr.o tunnel.o frame.o sit.o rose.o ash.o fddi.o hippi.o hdlclapb.o strip.o irda.o ec_hw.o x25.o ib.o
+HWOBJS = hw.o loopback.o slip.o ether.o ax25.o ppp.o arcnet.o tr.o tunnel.o frame.o sit.o rose.o ash.o fddi.o hippi.o hdlclapb.o strip.o irda.o ec_hw.o x25.o ib.o hfi.o
AFOBJS = unix.o inet.o inet6.o ax25.o ipx.o ddp.o ipx.o netrom.o af.o rose.o econet.o x25.o
AFGROBJS = inet_gr.o inet6_gr.o ipx_gr.o ddp_gr.o netrom_gr.o ax25_gr.o rose_gr.o getroute.o x25_gr.o
AFSROBJS = inet_sr.o inet6_sr.o netrom_sr.o ipx_sr.o setroute.o x25_sr.o

View File

@ -1,6 +1,25 @@
--- net-tools-1.60/netstat.c.num-ports 2004-11-24 12:19:24.000000000 +0100
+++ net-tools-1.60/netstat.c 2004-11-25 16:00:45.208367104 +0100
@@ -765,8 +765,8 @@
diff -up net-tools-1.60/netstat.c.num-ports net-tools-1.60/netstat.c
--- net-tools-1.60/netstat.c.num-ports 2011-10-21 17:40:53.632829074 +0200
+++ net-tools-1.60/netstat.c 2011-10-21 17:43:39.448756090 +0200
@@ -600,7 +600,7 @@ static void igmp_do_one(int lnr, const c
return;
}
safe_strncpy(mcast_addr, ap->sprint((struct sockaddr *) &mcastaddr,
- flag_not), sizeof(mcast_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(mcast_addr));
printf("%-15s %-6d %s\n", device, refcnt, mcast_addr);
#endif
} else { /* IPV4 */
@@ -638,7 +638,7 @@ static void igmp_do_one(int lnr, const c
return;
}
safe_strncpy(mcast_addr, ap->sprint((struct sockaddr *) &mcastaddr,
- flag_not), sizeof(mcast_addr));
+ flag_not & FLAG_NUM_HOST), sizeof(mcast_addr));
printf("%-15s %-6d %s\n", device, refcnt, mcast_addr );
#endif
} /* IPV4 */
@@ -765,8 +765,8 @@ static void tcp_do_one(int lnr, const ch
txq = 0L;
}
safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
@ -11,7 +30,7 @@
sizeof(rem_addr));
if (flag_all || (flag_lst && !rem_port) || (!flag_lst && rem_port)) {
snprintf(buffer, sizeof(buffer), "%s",
@@ -921,11 +921,11 @@
@@ -919,11 +919,11 @@ static void udp_do_one(int lnr, const ch
if (flag_all || (notnull(remaddr) && !flag_lst) || (!notnull(remaddr) && flag_lst))
{
safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
@ -25,7 +44,7 @@
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
@@ -934,8 +934,8 @@
@@ -931,8 +931,8 @@ static void udp_do_one(int lnr, const ch
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "udp", flag_not & FLAG_NUM_PORT));
safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
@ -36,7 +55,7 @@
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
@@ -958,7 +958,7 @@
@@ -954,7 +954,7 @@ static void udp_do_one(int lnr, const ch
retr, timeout);
break;
}
@ -45,7 +64,7 @@
rxq, txq, local_addr, rem_addr, udp_state);
finish_this_one(uid,inode,timers);
@@ -1045,8 +1045,8 @@
@@ -1041,8 +1041,8 @@ static void raw_do_one(int lnr, const ch
get_sname(htons(local_port), "raw",
flag_not & FLAG_NUM_PORT));
safe_strncpy(local_addr, ap->sprint((struct sockaddr *) &localaddr,
@ -56,7 +75,7 @@
local_addr[22 - strlen(buffer)] = '\0';
strcat(local_addr, ":");
strncat(local_addr, buffer, sizeof(local_addr)-strlen(local_addr)-1);
@@ -1055,8 +1055,8 @@
@@ -1050,8 +1050,8 @@ static void raw_do_one(int lnr, const ch
snprintf(buffer, sizeof(buffer), "%s",
get_sname(htons(rem_port), "raw", flag_not & FLAG_NUM_PORT));
safe_strncpy(rem_addr, ap->sprint((struct sockaddr *) &remaddr,
@ -67,7 +86,7 @@
rem_addr[22 - strlen(buffer)] = '\0';
strcat(rem_addr, ":");
strncat(rem_addr, buffer, sizeof(rem_addr)-strlen(rem_addr)-1);
@@ -1081,7 +1081,7 @@
@@ -1075,7 +1075,7 @@ static void raw_do_one(int lnr, const ch
retr, timeout);
break;
}
@ -76,3 +95,19 @@
rxq, txq, local_addr, rem_addr, state);
finish_this_one(uid,inode,timers);
@@ -1414,13 +1414,13 @@ static int ipx_info(void)
/* Fetch and resolve the Source */
(void) ap->input(0, sad, &sa);
- safe_strncpy(buf, ap->sprint(&sa, flag_not), sizeof(buf));
+ 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), sizeof(buf));
+ safe_strncpy(buf, ap->sprint(&sa, flag_not & FLAG_NUM_HOST), sizeof(buf));
snprintf(dad, sizeof(dad), "%s:%04X", buf, dport);
} else
strcpy(dad, "-");

View File

@ -1,7 +1,7 @@
Summary: Basic networking tools
Name: net-tools
Version: 1.60
Release: 127%{?dist}
Release: 128%{?dist}
License: GPL+
Group: System Environment/Base
URL: http://net-tools.sourceforge.net
@ -114,21 +114,18 @@ Patch78: net-tools-1.60-mii-gigabit.patch
# fix memory leak in netstat when run with -c option
Patch79: net-tools-1.60-netstat-leak.patch
# HFI support
Patch80: net-tools-1.60-hfi.patch
# Don't rely on eth0 being default network device name.
# Since Fedora 15 network devices can have arbitrary names (#682367)
Patch81: net-tools-1.60-arbitrary-device-names.patch
Patch80: net-tools-1.60-arbitrary-device-names.patch
# plipconfig man page and usage output fixes. (#694766)
Patch82: net-tools-1.60-plipconfig.patch
Patch81: net-tools-1.60-plipconfig.patch
# Possible problems found by static analysis of code.
Patch83: net-tools-1.60-coverity.patch
Patch82: net-tools-1.60-coverity.patch
# Update for 2 digit Linux version numbers
Patch84: net-tools-1.60-2digit.patch
Patch83: net-tools-1.60-2digit.patch
BuildRequires: gettext, libselinux
BuildRequires: libselinux-devel
@ -210,11 +207,10 @@ Most of them are obsolete. For replacement check iproute package.
%patch77 -p1 -b .doubleword
%patch78 -p1 -b .mii-gigabit
%patch79 -p1 -b .netstat-leak
%patch80 -p1 -b .hfi
%patch81 -p1 -b .arbitrary-device-names
%patch82 -p1 -b .plipconfig
%patch83 -p1 -b .coverity
%patch84 -p1 -b .2digit
%patch80 -p1 -b .arbitrary-device-names
%patch81 -p1 -b .plipconfig
%patch82 -p1 -b .coverity
%patch83 -p1 -b .2digit
cp %SOURCE1 ./config.h
@ -319,6 +315,10 @@ fi
%attr(0644,root,root) %{_unitdir}/arp-ethers.service
%changelog
* Tue Oct 25 2011 Jiri Popelka <jpopelka@redhat.com> - 1.60-128
- Removed HFI support.
- Improved num-ports.patch
* Thu Oct 20 2011 Jiri Popelka <jpopelka@redhat.com> - 1.60-127
- Merge all upstream fixes into net-tools-1.60-upstream.patch