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.14 1999/05/16 16:41:12 philip 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>
29 #include "net-support.h"
30 #include "pathnames.h"
33 extern struct hwtype unspec_hwtype;
34 extern struct hwtype loop_hwtype;
36 extern struct hwtype slip_hwtype;
37 extern struct hwtype cslip_hwtype;
38 extern struct hwtype slip6_hwtype;
39 extern struct hwtype cslip6_hwtype;
40 extern struct hwtype adaptive_hwtype;
42 extern struct hwtype ether_hwtype;
43 extern struct hwtype fddi_hwtype;
44 extern struct hwtype hippi_hwtype;
45 extern struct hwtype tr_hwtype;
47 extern struct hwtype ax25_hwtype;
48 extern struct hwtype rose_hwtype;
49 extern struct hwtype netrom_hwtype;
50 extern struct hwtype tunnel_hwtype;
52 extern struct hwtype ash_hwtype;
54 extern struct hwtype ppp_hwtype;
56 extern struct hwtype arcnet_hwtype;
58 extern struct hwtype dlci_hwtype;
59 extern struct hwtype frad_hwtype;
61 extern struct hwtype hdlc_hwtype;
62 extern struct hwtype lapb_hwtype;
64 extern struct hwtype sit_hwtype;
66 extern struct hwtype irda_hwtype;
68 extern struct hwtype ec_hwtype;
70 static struct hwtype *hwtypes[] =
136 static short sVhwinit = 0;
140 loop_hwtype.title = _("Local Loopback");
141 unspec_hwtype.title = _("UNSPEC");
143 slip_hwtype.title = _("Serial Line IP");
144 cslip_hwtype.title = _("VJ Serial Line IP");
145 slip6_hwtype.title = _("6-bit Serial Line IP");
146 cslip6_hwtype.title = _("VJ 6-bit Serial Line IP");
147 adaptive_hwtype.title = _("Adaptive Serial Line IP");
150 ether_hwtype.title = _("Ethernet");
153 ash_hwtype.title = _("Ash");
156 fddi_hwtype.title = _("Fiber Distributed Data Interface");
159 hippi_hwtype.title = _("HIPPI");
162 ax25_hwtype.title = _("AMPR AX.25");
165 rose_hwtype.title = _("AMPR ROSE");
168 netrom_hwtype.title = _("AMPR NET/ROM");
171 tunnel_hwtype.title = _("IPIP Tunnel");
174 ppp_hwtype.title = _("Point-to-Point Protocol");
177 hdlc_hwtype.title = _("(Cisco)-HDLC");
178 lapb_hwtype.title = _("LAPB");
181 arcnet_hwtype.title = _("ARCnet");
184 dlci_hwtype.title = _("Frame Relay DLCI");
185 frad_hwtype.title = _("Frame Relay Access Device");
188 sit_hwtype.title = _("IPv6-in-IPv4");
191 irda_hwtype.title = _("IrLAP");
194 tr_hwtype.title = _("16/4 Mbps Token Ring");
197 ec_hwtype.title = _("Econet");
202 /* Check our hardware type table for this type. */
203 struct hwtype *get_hwtype(const char *name)
211 while (*hwp != NULL) {
212 if (!strcmp((*hwp)->name, name))
220 /* Check our hardware type table for this type. */
221 struct hwtype *get_hwntype(int type)
229 while (*hwp != NULL) {
230 if ((*hwp)->type == type)
237 /* type: 0=all, 1=ARPable */
238 void print_hwlist(int type) {
247 while (*hwp != NULL) {
248 if (((type == 1) && ((*hwp)->alen == 0)) || ((*hwp)->type == -1)) {
251 if ((count % 3) == 0) fprintf(stderr,count?"\n ":" ");
252 txt = (*hwp)->name; if (!txt) txt = "..";
253 fprintf(stderr,"%s (%s) ",txt,(*hwp)->title);
257 fprintf(stderr,"\n");
260 /* return 1 if address is all zeros */
261 int hw_null_address(struct hwtype *hw, void *ap)
264 unsigned char *address = (unsigned char *)ap;
265 for (i = 0; i < hw->alen; i++)