]> git.ipfire.org Git - people/amarx/ipfire-3.x.git/blob - net-tools/patches/net-tools-1.60-hfi.patch
Move all packages to root.
[people/amarx/ipfire-3.x.git] / net-tools / patches / net-tools-1.60-hfi.patch
1 diff -up net-tools-1.60/config.in.hfi net-tools-1.60/config.in
2 --- net-tools-1.60/config.in.hfi 2010-09-16 17:20:04.000000000 +0200
3 +++ net-tools-1.60/config.in 2010-09-16 19:17:35.000000000 +0200
4 @@ -83,6 +83,7 @@ bool '(Cisco)-HDLC/LAPB support' HAVE_HW
5 bool 'IrDA support' HAVE_HWIRDA y
6 bool 'Econet hardware support' HAVE_HWEC n
7 bool 'InfiniBand hardware support' HAVE_HWIB y
8 +bool 'HFI support' HAVE_HWHFI y
9 *
10 *
11 * Other Features.
12 diff -up net-tools-1.60/lib/hfi.c.hfi net-tools-1.60/lib/hfi.c
13 --- net-tools-1.60/lib/hfi.c.hfi 2010-09-16 19:17:58.000000000 +0200
14 +++ net-tools-1.60/lib/hfi.c 2010-09-16 19:19:49.000000000 +0200
15 @@ -0,0 +1,125 @@
16 +#include "config.h"
17 +
18 +#if HAVE_HWHFI
19 +#include <sys/types.h>
20 +#include <sys/socket.h>
21 +#include <net/if_arp.h>
22 +#include <stdlib.h>
23 +#include <stdio.h>
24 +#include <errno.h>
25 +#include <ctype.h>
26 +#include <string.h>
27 +#include <unistd.h>
28 +#include "net-support.h"
29 +#include "pathnames.h"
30 +#include "intl.h"
31 +#include "util.h"
32 +
33 +extern struct hwtype hfi_hwtype;
34 +
35 +#define HF_ALEN 6 /* from hf_if.h */
36 +
37 +/* Display an HFI address in readable format. */
38 +static char *pr_hfi(unsigned char *ptr)
39 +{
40 + static char buff[64];
41 +
42 + snprintf(buff, sizeof(buff), "%02X:%02X:%02X:%02X:%02X:%02X",
43 + (ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
44 + (ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377)
45 + );
46 + return (buff);
47 +}
48 +
49 +
50 +/* Input an HFI address and convert to binary. */
51 +static int in_hfi(char *bufp, struct sockaddr *sap)
52 +{
53 + unsigned char *ptr;
54 + char c, *orig;
55 + int i;
56 + unsigned val;
57 +
58 + sap->sa_family = hfi_hwtype.type;
59 + ptr = sap->sa_data;
60 +
61 + i = 0;
62 + orig = bufp;
63 + while ((*bufp != '\0') && (i < HF_ALEN)) {
64 + val = 0;
65 + c = *bufp++;
66 + if (isdigit(c))
67 + val = c - '0';
68 + else if (c >= 'a' && c <= 'f')
69 + val = c - 'a' + 10;
70 + else if (c >= 'A' && c <= 'F')
71 + val = c - 'A' + 10;
72 + else {
73 +#ifdef DEBUG
74 + fprintf(stderr, _("in_hfi(%s): invalid hfi address!\n"), orig);
75 +#endif
76 + errno = EINVAL;
77 + return (-1);
78 + }
79 + val <<= 4;
80 + c = *bufp;
81 + if (isdigit(c))
82 + val |= c - '0';
83 + else if (c >= 'a' && c <= 'f')
84 + val |= c - 'a' + 10;
85 + else if (c >= 'A' && c <= 'F')
86 + val |= c - 'A' + 10;
87 + else if (c == ':' || c == 0)
88 + val >>= 4;
89 + else {
90 +#ifdef DEBUG
91 + fprintf(stderr, _("in_hfi(%s): invalid hfi address!\n"), orig);
92 +#endif
93 + errno = EINVAL;
94 + return (-1);
95 + }
96 + if (c != 0)
97 + bufp++;
98 + *ptr++ = (unsigned char) (val & 0377);
99 + i++;
100 +
101 + /* We might get a semicolon here - not required. */
102 + if (*bufp == ':') {
103 + if (i == HF_ALEN) {
104 +#ifdef DEBUG
105 + fprintf(stderr, _("in_hfi(%s): trailing : ignored!\n"),
106 + orig)
107 +#endif
108 + ; /* nothing */
109 + }
110 + bufp++;
111 + }
112 + }
113 +
114 + /* That's it. Any trailing junk? */
115 + if ((i == HF_ALEN) && (*bufp != '\0')) {
116 +#ifdef DEBUG
117 + fprintf(stderr, _("in_hfi(%s): trailing junk!\n"), orig);
118 + errno = EINVAL;
119 + return (-1);
120 +#endif
121 + }
122 +#ifdef DEBUG
123 + fprintf(stderr, "in_hfi(%s): %s\n", orig, pr_hfi(sap->sa_data));
124 +#endif
125 +
126 + return (0);
127 +}
128 +
129 +#if !defined(ARPHRD_HFI)
130 +#define ARPHRD_HFI 37 /* goes into if_arp.h */
131 +#endif
132 +
133 +struct hwtype hfi_hwtype =
134 +{
135 + "hfi", NULL, /*"HFI", */ ARPHRD_HFI, HF_ALEN,
136 + pr_hfi, in_hfi, NULL
137 +};
138 +
139 +
140 +#endif /* HAVE_HWHFI */
141 diff -up net-tools-1.60/lib/hw.c.hfi net-tools-1.60/lib/hw.c
142 --- net-tools-1.60/lib/hw.c.hfi 2010-09-16 17:20:04.000000000 +0200
143 +++ net-tools-1.60/lib/hw.c 2010-09-16 19:21:28.000000000 +0200
144 @@ -42,6 +42,7 @@ extern struct hwtype adaptive_hwtype;
145 extern struct hwtype strip_hwtype;
146
147 extern struct hwtype ether_hwtype;
148 +extern struct hwtype hfi_hwtype;
149 extern struct hwtype fddi_hwtype;
150 extern struct hwtype hippi_hwtype;
151 extern struct hwtype tr_hwtype;
152 @@ -146,6 +147,9 @@ static struct hwtype *hwtypes[] =
153 #if HAVE_HWX25
154 &x25_hwtype,
155 #endif
156 +#if HAVE_HWHFI
157 + &hfi_hwtype,
158 +#endif
159 #if HAVE_HWIB
160 &ib_hwtype,
161 #endif
162 @@ -222,6 +226,9 @@ void hwinit()
163 #if HAVE_HWEC
164 ec_hwtype.title = _("Econet");
165 #endif
166 +#if HAVE_HWHFI
167 + hfi_hwtype.title = _("HFI");
168 +#endif
169 #if HAVE_HWIB
170 ib_hwtype.title = _("InfiniBand");
171 #endif
172 diff -up net-tools-1.60/lib/Makefile.hfi net-tools-1.60/lib/Makefile
173 --- net-tools-1.60/lib/Makefile.hfi 2010-09-16 17:20:04.000000000 +0200
174 +++ net-tools-1.60/lib/Makefile 2010-09-16 19:22:34.000000000 +0200
175 @@ -16,7 +16,7 @@
176 #
177
178
179 -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
180 +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
181 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
182 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
183 AFSROBJS = inet_sr.o inet6_sr.o netrom_sr.o ipx_sr.o setroute.o x25_sr.o