2 * lib/hw.c This file contains the top-level part of the hardware
3 * support functions module.
5 * Version: $Id: hw.c,v 1.19 2008/10/03 01:52:04 ecki Exp $
7 * Maintainer: Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
9 * Author: Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
10 * Copyright 1993 MicroWalt Corporation
12 *980701 {1.21} Arnaldo C. Melo GNU gettext instead of catgets
14 * This program is free software; you can redistribute it
15 * and/or modify it under the terms of the GNU General
16 * Public License as published by the Free Software
17 * Foundation; either version 2 of the License, or (at
18 * your option) any later version.
20 #include <sys/types.h>
21 #include <sys/socket.h>
22 #include <net/if_arp.h>
30 #include "net-support.h"
31 #include "pathnames.h"
34 extern struct hwtype unspec_hwtype;
35 extern struct hwtype loop_hwtype;
37 extern struct hwtype slip_hwtype;
38 extern struct hwtype cslip_hwtype;
39 extern struct hwtype slip6_hwtype;
40 extern struct hwtype cslip6_hwtype;
41 extern struct hwtype adaptive_hwtype;
42 extern struct hwtype strip_hwtype;
44 extern struct hwtype ether_hwtype;
45 extern struct hwtype fddi_hwtype;
46 extern struct hwtype hippi_hwtype;
47 extern struct hwtype tr_hwtype;
48 #ifdef ARPHRD_IEEE802_TR
49 extern struct hwtype tr_hwtype1;
52 extern struct hwtype ax25_hwtype;
53 extern struct hwtype rose_hwtype;
54 extern struct hwtype netrom_hwtype;
55 extern struct hwtype x25_hwtype;
56 extern struct hwtype tunnel_hwtype;
58 extern struct hwtype ash_hwtype;
60 extern struct hwtype ppp_hwtype;
62 extern struct hwtype arcnet_hwtype;
64 extern struct hwtype dlci_hwtype;
65 extern struct hwtype frad_hwtype;
67 extern struct hwtype hdlc_hwtype;
68 extern struct hwtype lapb_hwtype;
70 extern struct hwtype sit_hwtype;
72 extern struct hwtype irda_hwtype;
74 extern struct hwtype ec_hwtype;
76 extern struct hwtype ib_hwtype;
78 extern struct hwtype eui64_hwtype;
80 static struct hwtype *hwtypes[] =
103 #ifdef ARPHRD_IEEE802_TR
161 static short sVhwinit = 0;
165 loop_hwtype.title = _("Local Loopback");
166 unspec_hwtype.title = _("UNSPEC");
168 slip_hwtype.title = _("Serial Line IP");
169 cslip_hwtype.title = _("VJ Serial Line IP");
170 slip6_hwtype.title = _("6-bit Serial Line IP");
171 cslip6_hwtype.title = _("VJ 6-bit Serial Line IP");
172 adaptive_hwtype.title = _("Adaptive Serial Line IP");
175 ether_hwtype.title = _("Ethernet");
178 ash_hwtype.title = _("Ash");
181 fddi_hwtype.title = _("Fiber Distributed Data Interface");
184 hippi_hwtype.title = _("HIPPI");
187 ax25_hwtype.title = _("AMPR AX.25");
190 rose_hwtype.title = _("AMPR ROSE");
193 netrom_hwtype.title = _("AMPR NET/ROM");
196 x25_hwtype.title = _("generic X.25");
199 tunnel_hwtype.title = _("IPIP Tunnel");
202 ppp_hwtype.title = _("Point-to-Point Protocol");
205 hdlc_hwtype.title = _("(Cisco)-HDLC");
206 lapb_hwtype.title = _("LAPB");
209 arcnet_hwtype.title = _("ARCnet");
212 dlci_hwtype.title = _("Frame Relay DLCI");
213 frad_hwtype.title = _("Frame Relay Access Device");
216 sit_hwtype.title = _("IPv6-in-IPv4");
219 irda_hwtype.title = _("IrLAP");
222 tr_hwtype.title = _("16/4 Mbps Token Ring");
223 #ifdef ARPHRD_IEEE802_TR
224 tr_hwtype1.title = _("16/4 Mbps Token Ring (New)") ;
228 ec_hwtype.title = _("Econet");
231 ib_hwtype.title = _("InfiniBand");
234 eui64_hwtype.title = _("Generic EUI-64");
239 /* Check our hardware type table for this type. */
240 struct hwtype *get_hwtype(const char *name)
248 while (*hwp != NULL) {
249 if (!strcmp((*hwp)->name, name))
257 /* Check our hardware type table for this type. */
258 struct hwtype *get_hwntype(int type)
266 while (*hwp != NULL) {
267 if ((*hwp)->type == type)
274 /* type: 0=all, 1=ARPable */
275 void print_hwlist(int type) {
284 while (*hwp != NULL) {
285 if (((type == 1) && ((*hwp)->alen == 0)) || ((*hwp)->type == -1)) {
288 if ((count % 3) == 0) fprintf(stderr,count?"\n ":" ");
289 txt = (*hwp)->name; if (!txt) txt = "..";
290 fprintf(stderr,"%s (%s) ",txt,(*hwp)->title);
294 fprintf(stderr,"\n");
297 /* return 1 if address is all zeros */
298 int hw_null_address(struct hwtype *hw, void *ap)
301 unsigned char *address = (unsigned char *)ap;
302 for (i = 0; i < hw->alen; i++)