aboutsummaryrefslogtreecommitdiff
path: root/gnu/packages/patches/inetutils-hurd.patch
blob: bd65c4feb191d4ff63149855b14bc595c86e16dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
Support compiling on the Hurd.

Taken from https://git.hadrons.org/cgit/debian/pkgs/inetutils.git/tree/debian/patches/0002-ifconfig-Improve-the-support-for-GNU-Hurd.patch

From 9a90d9b9119906df23cb2db1503cb0f099942dd9 Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson <gnu@gisladisker.se>
Date: Sat, 18 Jul 2015 01:12:41 +0200
Subject: [PATCH 02/35] ifconfig: Improve the support for GNU/Hurd.

Use system specific code instead of generic code.
This provides abilities similar to other systems.
---
 ChangeLog                   |  17 +++
 ifconfig/system.c           |  10 +-
 ifconfig/system.h           |   2 +
 ifconfig/system/Makefile.am |   4 +-
 ifconfig/system/generic.c   |  14 +-
 ifconfig/system/hurd.c      | 292 ++++++++++++++++++++++++++++++++++++
 ifconfig/system/hurd.h      |  50 ++++++
 7 files changed, 381 insertions(+), 8 deletions(-)
 create mode 100644 ifconfig/system/hurd.c
 create mode 100644 ifconfig/system/hurd.h

diff --git a/ifconfig/system.c b/ifconfig/system.c
index 30677e41..e108dc2e 100644
--- a/ifconfig/system.c
+++ b/ifconfig/system.c
@@ -25,10 +25,12 @@
 # include "system/solaris.c"
 #elif defined __QNX__
 # include "system/qnx.c"
-# elif defined __DragonFly__ || defined __FreeBSD__ || \
-       defined __FreeBSD_kernel__ || \
-       defined __NetBSD__ || defined __OpenBSD__
-#  include "system/bsd.c"
+#elif defined __DragonFly__ || defined __FreeBSD__ || \
+      defined __FreeBSD_kernel__ || \
+      defined __NetBSD__ || defined __OpenBSD__
+# include "system/bsd.c"
+#elif defined __GNU__
+# include "system/hurd.c"
 #else
 # include "system/generic.c"
 #endif
diff --git a/ifconfig/system.h b/ifconfig/system.h
index 8521ad95..66878d3a 100644
--- a/ifconfig/system.h
+++ b/ifconfig/system.h
@@ -97,6 +97,8 @@ extern struct if_nameindex* (*system_if_nameindex) (void);
        defined __FreeBSD_kernel__ || \
        defined __NetBSD__ || defined __OpenBSD__
 #  include "system/bsd.h"
+# elif defined __GNU__
+#  include "system/hurd.h"
 # else
 #  include "system/generic.h"
 # endif
diff --git a/ifconfig/system/Makefile.am b/ifconfig/system/Makefile.am
index 954c6774..62a9f1c4 100644
--- a/ifconfig/system/Makefile.am
+++ b/ifconfig/system/Makefile.am
@@ -26,8 +26,10 @@ noinst_HEADERS = \
 	linux.h \
 	solaris.h \
 	qnx.h \
+	hurd.h \
 	bsd.c \
 	generic.c \
 	linux.c \
 	solaris.c \
-	qnx.c
+	qnx.c \
+	hurd.c
diff --git a/ifconfig/system/generic.c b/ifconfig/system/generic.c
index 9a2bda55..20a78bde 100644
--- a/ifconfig/system/generic.c
+++ b/ifconfig/system/generic.c
@@ -22,6 +22,8 @@
 #include <config.h>
 
 #include "../ifconfig.h"
+
+#include <unused-parameter.h>
 
 
 /* Output format stuff.  */
@@ -36,19 +38,25 @@ const char *system_help;
 struct argp_child system_argp_child;
 
 int
-system_parse_opt (struct ifconfig **ifp, char option, char *optarg)
+system_parse_opt (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
+		  char option _GL_UNUSED_PARAMETER,
+		  char *optarg _GL_UNUSED_PARAMETER)
 {
   return 0;
 }
 
 int
-system_parse_opt_rest (struct ifconfig **ifp, int argc, char *argv[])
+system_parse_opt_rest (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
+		       int argc _GL_UNUSED_PARAMETER,
+		       char *argv[] _GL_UNUSED_PARAMETER)
 {
   return 0;
 }
 
 int
-system_configure (int sfd, struct ifreq *ifr, struct system_ifconfig *ifs)
+system_configure (int sfd _GL_UNUSED_PARAMETER,
+		  struct ifreq *ifr _GL_UNUSED_PARAMETER,
+		  struct system_ifconfig *ifs _GL_UNUSED_PARAMETER)
 {
   return 0;
 }
diff --git a/ifconfig/system/hurd.c b/ifconfig/system/hurd.c
new file mode 100644
index 00000000..3bd19775
--- /dev/null
+++ b/ifconfig/system/hurd.c
@@ -0,0 +1,292 @@
+/* hurd.c -- Code for ifconfig specific to GNU/Hurd.
+  Copyright (C) 2015 Free Software Foundation, Inc.
+
+  This file is part of GNU Inetutils.
+
+  GNU Inetutils 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 3 of the License, or (at
+  your option) any later version.
+
+  GNU Inetutils is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see `http://www.gnu.org/licenses/'. */
+
+/* Mostly written by Marcus Brinkmann.
+   Adaptions to GNU/Hurd by Mats Erik Andersson.  */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <sys/ioctl.h>
+#include <net/if_arp.h>
+#include "../ifconfig.h"
+
+#include <unused-parameter.h>
+
+
+/* Output format stuff.  */
+
+const char *system_default_format = "gnu";
+
+
+/* Argument parsing stuff.  */
+
+const char *system_help = "NAME [ADDR]\
+ [broadcast BRDADDR] [netmask MASK]\
+ [mtu N] [up|down] [FLAGS]";
+
+struct argp_child system_argp_child;
+
+int
+system_parse_opt (struct ifconfig **ifp _GL_UNUSED_PARAMETER,
+		  char option _GL_UNUSED_PARAMETER,
+		  char *optarg _GL_UNUSED_PARAMETER)
+{
+  return 0;
+}
+
+int
+system_parse_opt_rest (struct ifconfig **ifp, int argc, char *argv[])
+{
+  int i = 0, mask, rev;
+  enum {
+    EXPECT_NOTHING,
+    EXPECT_AF,
+    EXPECT_BROADCAST,
+    EXPECT_NETMASK,
+    EXPECT_METRIC,
+    EXPECT_MTU
+  } expect = EXPECT_AF;
+
+  *ifp = parse_opt_new_ifs (argv[0]);
+
+  while (++i < argc)
+    {
+      switch (expect)
+	{
+	case EXPECT_BROADCAST:
+	  parse_opt_set_brdaddr (*ifp, argv[i]);
+	  break;
+
+	case EXPECT_NETMASK:
+	  parse_opt_set_netmask (*ifp, argv[i]);
+	  break;
+
+	case EXPECT_MTU:
+	  parse_opt_set_mtu (*ifp, argv[i]);
+	  break;
+
+	/* XXX: 2015-07-18, GNU/Hurd does not yet support
+		ioctl(SIOCSIFMETRIC), but we let the code
+		handle this standard ability anyway!
+	 */
+	case EXPECT_METRIC:
+	  parse_opt_set_metric (*ifp, argv[i]);
+	  break;
+
+	case EXPECT_AF:
+	  expect = EXPECT_NOTHING;
+	  if (!strcmp (argv[i], "inet"))
+	    continue;
+	  else if (!strcmp (argv[i], "inet6"))
+	    {
+	      error (0, 0, "%s is not a supported address family", argv[i]);
+	      return 0;
+	    }
+	  break;
+
+	case EXPECT_NOTHING:
+	  break;
+	}
+
+      if (expect != EXPECT_NOTHING)
+	expect = EXPECT_NOTHING;
+      else if (!strcmp (argv[i], "broadcast"))
+	expect = EXPECT_BROADCAST;
+      else if (!strcmp (argv[i], "netmask"))
+	expect = EXPECT_NETMASK;
+      else if (!strcmp (argv[i], "metric"))
+	expect = EXPECT_METRIC;
+      else if (!strcmp (argv[i], "mtu"))
+	expect = EXPECT_MTU;
+      else if (!strcmp (argv[i], "up"))
+	parse_opt_set_flag (*ifp, IFF_UP | IFF_RUNNING, 0);
+      else if (!strcmp (argv[i], "down"))
+	parse_opt_set_flag (*ifp, IFF_UP, 1);
+      else if (((mask = if_nameztoflag (argv[i], &rev))
+		& ~IU_IFF_CANTCHANGE) != 0)
+	parse_opt_set_flag (*ifp, mask, rev);
+      else
+	{
+	  if (!((*ifp)->valid & IF_VALID_ADDR))
+	    parse_opt_set_address (*ifp, argv[i]);
+	  else if (!((*ifp)->valid & IF_VALID_DSTADDR))
+	    parse_opt_set_dstaddr (*ifp, argv[i]);
+	}
+    }
+
+  switch (expect)
+    {
+    case EXPECT_BROADCAST:
+      error (0, 0, "option `broadcast' requires an argument");
+      break;
+
+    case EXPECT_NETMASK:
+      error (0, 0, "option `netmask' requires an argument");
+      break;
+
+    case EXPECT_METRIC:
+      error (0, 0, "option `metric' requires an argument");
+      break;
+
+    case EXPECT_MTU:
+      error (0, 0, "option `mtu' requires an argument");
+      break;
+
+    case EXPECT_AF:
+    case EXPECT_NOTHING:
+      return 1;
+    }
+
+  return 0;
+}
+
+int
+system_configure (int sfd _GL_UNUSED_PARAMETER,
+		  struct ifreq *ifr _GL_UNUSED_PARAMETER,
+		  struct system_ifconfig *ifs _GL_UNUSED_PARAMETER)
+{
+  return 0;
+}
+
+struct if_nameindex* (*system_if_nameindex) (void) = if_nameindex;
+
+static void
+print_hwaddr_ether (format_data_t form _GL_UNUSED_PARAMETER,
+		    unsigned char *data)
+{
+  *column += printf ("%02X:%02X:%02X:%02X:%02X:%02X",
+		     data[0], data[1], data[2], data[3], data[4], data[5]);
+  had_output = 1;
+}
+
+struct arphrd_symbol
+{
+  const char *name;
+  const char *title;
+  int value;
+  void (*print_hwaddr) (format_data_t form, unsigned char *data);
+} arphrd_symbols[] =
+  {
+#ifdef ARPHRD_ETHER		/* Ethernet 10/100Mbps.  */
+    { "ETHER", "Ethernet", ARPHRD_ETHER, print_hwaddr_ether},
+#endif
+#ifdef ARPHRD_LOOPBACK		/* Loopback device.  */
+    { "LOOPBACK", "Local Loopback", ARPHRD_LOOPBACK, NULL},
+#endif
+    /* XXX: The image debian-hurd-20150424 returns the value 4
+	    instead of expected ARPHRD_LOOPBACK.  This has been
+	    discussed in the list debian-hurd, where I was asked
+	    to resist the temptation of a work around!
+     */
+    { NULL, NULL, 0, NULL}
+  };
+
+struct arphrd_symbol *
+arphrd_findvalue (int value)
+{
+  struct arphrd_symbol *arp = arphrd_symbols;
+  while (arp->name != NULL)
+    {
+      if (arp->value == value)
+	break;
+      arp++;
+    }
+  if (arp->name)
+    return arp;
+  else
+    return NULL;
+}
+
+void
+system_fh_hwaddr_query (format_data_t form, int argc, char *argv[])
+{
+#ifdef SIOCGIFHWADDR
+  struct arphrd_symbol *arp;
+
+  if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
+    select_arg (form, argc, argv, 1);
+
+  arp = arphrd_findvalue (form->ifr->ifr_hwaddr.sa_family);
+  select_arg (form, argc, argv, (arp && arp->print_hwaddr) ? 0 : 1);
+#else
+  select_arg (form, argc, argv, 1);
+#endif
+}
+
+void
+system_fh_hwaddr (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+		  char *argv[] _GL_UNUSED_PARAMETER)
+{
+#ifdef SIOCGIFHWADDR
+  if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
+    error (EXIT_FAILURE, errno,
+	   "SIOCGIFHWADDR failed for interface `%s'",
+	   form->ifr->ifr_name);
+  else
+    {
+      struct arphrd_symbol *arp;
+
+      arp = arphrd_findvalue (form->ifr->ifr_hwaddr.sa_family);
+      if (arp && arp->print_hwaddr)
+	arp->print_hwaddr (form,
+			   (unsigned char *) form->ifr->ifr_hwaddr.sa_data);
+      else
+	put_string (form, "(hwaddr unknown)");
+    }
+#else
+  *column += printf ("(not available)");
+  had_output = 1;
+#endif
+}
+
+void
+system_fh_hwtype_query (format_data_t form, int argc, char *argv[])
+{
+#ifdef SIOCGIFHWADDR
+  if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) >= 0)
+    select_arg (form, argc, argv, 0);
+  else
+#endif
+    select_arg (form, argc, argv, 1);
+}
+
+void
+system_fh_hwtype (format_data_t form, int argc _GL_UNUSED_PARAMETER,
+		  char *argv[] _GL_UNUSED_PARAMETER)
+{
+#ifdef SIOCGIFHWADDR
+  if (ioctl (form->sfd, SIOCGIFHWADDR, form->ifr) < 0)
+    error (EXIT_FAILURE, errno,
+	   "SIOCGIFHWADDR failed for interface `%s'",
+	   form->ifr->ifr_name);
+  else
+    {
+      struct arphrd_symbol *arp;
+
+      arp = arphrd_findvalue (form->ifr->ifr_hwaddr.sa_family);
+      if (arp)
+	put_string (form, arp->title);
+      else
+	put_string (form, "(hwtype unknown)");
+    }
+#else
+  *column += printf ("(not available)");
+  had_output = 1;
+#endif
+}
diff --git a/ifconfig/system/hurd.h b/ifconfig/system/hurd.h
new file mode 100644
index 00000000..bab14565
--- /dev/null
+++ b/ifconfig/system/hurd.h
@@ -0,0 +1,50 @@
+/*
+  Copyright (C) 2015 Free Software Foundation, Inc.
+
+  This file is part of GNU Inetutils.
+
+  GNU Inetutils 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 3 of the License, or (at
+  your option) any later version.
+
+  GNU Inetutils is distributed in the hope that it will be useful, but
+  WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  General Public License for more details.
+
+  You should have received a copy of the GNU General Public License
+  along with this program.  If not, see `http://www.gnu.org/licenses/'. */
+
+/* Written by Mats Erik Andersson.  */
+
+#ifndef IFCONFIG_SYSTEM_HURD_H
+# define IFCONFIG_SYSTEM_HURD_H
+
+# include "../printif.h"
+# include "../options.h"
+
+
+/* Option support.  */
+
+struct system_ifconfig
+{
+  int valid;
+};
+
+
+/* Output format support.  */
+
+# define SYSTEM_FORMAT_HANDLER \
+  { "hurd", fh_nothing}, \
+  { "hwaddr?", system_fh_hwaddr_query}, \
+  { "hwaddr", system_fh_hwaddr}, \
+  { "hwtype?", system_fh_hwtype_query}, \
+  { "hwtype", system_fh_hwtype},
+
+void system_fh_hwaddr_query (format_data_t form, int argc, char *argv[]);
+void system_fh_hwaddr (format_data_t form, int argc, char *argv[]);
+void system_fh_hwtype_query (format_data_t form, int argc, char *argv[]);
+void system_fh_hwtype (format_data_t form, int argc, char *argv[]);
+
+#endif /* !IFCONFIG_SYSTEM_HURD_H */
-- 
2.23.0.rc1.170.gbd704faa3e

From 589dab9c7d3119da82837dabae34c8a3d16cbe49 Mon Sep 17 00:00:00 2001
From: Mats Erik Andersson <gnu@gisladisker.se>
Date: Thu, 30 Jul 2015 01:06:42 +0200
Subject: [PATCH 07/35] ifconfig: Hardware detection in GNU/Hurd.

A work-around needed to distinguish hardware type.
---
 ChangeLog              | 10 ++++++++++
 ifconfig/system/hurd.c | 19 ++++++++++++-------
 2 files changed, 22 insertions(+), 7 deletions(-)

diff --git a/ifconfig/system/hurd.c b/ifconfig/system/hurd.c
index 3bd19775..b6261a00 100644
--- a/ifconfig/system/hurd.c
+++ b/ifconfig/system/hurd.c
@@ -175,6 +175,16 @@ print_hwaddr_ether (format_data_t form _GL_UNUSED_PARAMETER,
   had_output = 1;
 }
 
+/* GNU/Hurd and Mach are using a mixture of BSD definitions
+ * and GNU/Linux interface headers, which in this situation
+ * means that sa_family_t is an unsigned char, from BSD, while
+ * all ARPHRD_* come from GNU/Linux and are thus 16 bits wide.
+ * We must account for this.  The following bitmask will
+ * adapt to any future change!
+ */
+
+#define _ARP_MASK ((sizeof (sa_family_t) == 1) ? 0xff : 0xffff)
+
 struct arphrd_symbol
 {
   const char *name;
@@ -184,16 +194,11 @@ struct arphrd_symbol
 } arphrd_symbols[] =
   {
 #ifdef ARPHRD_ETHER		/* Ethernet 10/100Mbps.  */
-    { "ETHER", "Ethernet", ARPHRD_ETHER, print_hwaddr_ether},
+    { "ETHER", "Ethernet", ARPHRD_ETHER & _ARP_MASK, print_hwaddr_ether},
 #endif
 #ifdef ARPHRD_LOOPBACK		/* Loopback device.  */
-    { "LOOPBACK", "Local Loopback", ARPHRD_LOOPBACK, NULL},
+    { "LOOPBACK", "Local Loopback", ARPHRD_LOOPBACK & _ARP_MASK, NULL},
 #endif
-    /* XXX: The image debian-hurd-20150424 returns the value 4
-	    instead of expected ARPHRD_LOOPBACK.  This has been
-	    discussed in the list debian-hurd, where I was asked
-	    to resist the temptation of a work around!
-     */
     { NULL, NULL, 0, NULL}
   };
 
-- 
2.23.0.rc1.170.gbd704faa3e

From d379784b4461d17b2536effd1b52bae21cd28a32 Mon Sep 17 00:00:00 2001
From: Guillem Jover <guillem@hadrons.org>
Date: Fri, 16 Aug 2019 00:34:03 +0200
Subject: [PATCH 35/35] telnet: Several ioctls have been disabled in the Hurd's
 glibc

But not the related option macros. inetutils uses those macros to decide
whether the ioctls are available, so it is FTBFS now. The Hurd's glibc
is being fixed, but we'll use this for now to get the builds going.
---
 telnet/sys_bsd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/telnet/sys_bsd.c b/telnet/sys_bsd.c
index 662536ab..5eb35cb5 100644
--- a/telnet/sys_bsd.c
+++ b/telnet/sys_bsd.c
@@ -63,6 +63,7 @@
 #include <errno.h>
 #include <arpa/telnet.h>
 #include <sys/select.h>
+#include <sys/ioctl.h>
 #include <unused-parameter.h>
 
 #include "ring.h"
@@ -157,7 +158,7 @@ TerminalRead (char *buf, int n)
 int
 TerminalAutoFlush (void)
 {
-#if defined LNOFLSH
+#if defined TIOCLGET && defined LNOFLSH
   int flush;
 
   ioctl (0, TIOCLGET, (char *) &flush);
@@ -260,7 +261,9 @@ TerminalSaveState (void)
   ioctl (0, TIOCGETP, (char *) &ottyb);
   ioctl (0, TIOCGETC, (char *) &otc);
   ioctl (0, TIOCGLTC, (char *) &oltc);
+#ifdef TIOCLGET
   ioctl (0, TIOCLGET, (char *) &olmode);
+#endif
 
   ntc = otc;
   nltc = oltc;
@@ -755,7 +758,9 @@ TerminalNewMode (register int f)
 #endif
     }
 #ifndef USE_TERMIO
+#ifdef TIOCLSET
   ioctl (tin, TIOCLSET, (char *) &lmode);
+#endif
   ioctl (tin, TIOCSLTC, (char *) &ltc);
   ioctl (tin, TIOCSETC, (char *) &tc);
   ioctl (tin, TIOCSETN, (char *) &sb);
-- 
2.23.0.rc1.170.gbd704faa3e