Basic HIPPI support - now to find out why arp can't figure out that an
[platform/upstream/net-tools.git] / lib / hw.c
1 /*
2  * lib/hw.c     This file contains the top-level part of the hardware
3  *              support functions module for the NET-2 base distribution.
4  *
5  * Version:     lib/hw.c 1.20 (1998-01-25)
6  *
7  * Maintainer:  Bernd 'eckes' Eckenfels, <net-tools@lina.inka.de>
8  *
9  * Author:      Fred N. van Kempen, <waltje@uwalt.nl.mugnet.org>
10  *              Copyright 1993 MicroWalt Corporation
11  *
12  *              This program is free software; you can redistribute it
13  *              and/or  modify it under  the terms of  the GNU General
14  *              Public  License as  published  by  the  Free  Software
15  *              Foundation;  either  version 2 of the License, or  (at
16  *              your option) any later version.
17  */
18 #include <sys/types.h>
19 #include <sys/socket.h>
20 #include <stdlib.h>
21 #include <stdio.h>
22 #include <errno.h>
23 #include <ctype.h>
24 #include <string.h>
25 #include <unistd.h>
26 #include "config.h"
27 #include "net-support.h"
28 #include "pathnames.h"
29 #define  EXTERN
30 #include "net-locale.h"
31
32
33 extern  struct hwtype   unspec_hwtype;
34 extern  struct hwtype   loop_hwtype;
35
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;
41
42 extern  struct hwtype   ether_hwtype;
43 extern  struct hwtype   fddi_hwtype;
44 extern  struct hwtype   hippi_hwtype;
45 extern  struct hwtype   tr_hwtype;
46
47 extern  struct hwtype   ax25_hwtype;
48 extern  struct hwtype   rose_hwtype;
49 extern  struct hwtype   netrom_hwtype;
50 extern  struct hwtype   tunnel_hwtype;
51
52 extern  struct hwtype   ash_hwtype;
53
54 extern  struct hwtype   ppp_hwtype;
55
56 extern  struct hwtype   arcnet_hwtype;
57
58 extern  struct hwtype   dlci_hwtype;
59 extern  struct hwtype   frad_hwtype;
60
61 extern  struct hwtype   sit_hwtype;
62
63 static struct hwtype *hwtypes[] = {
64
65   &loop_hwtype,
66
67 #if HAVE_HWSLIP
68   &slip_hwtype,
69   &cslip_hwtype,
70   &slip6_hwtype,
71   &cslip6_hwtype,
72   &adaptive_hwtype,
73 #endif
74 #if HAVE_HWASH
75   &ash_hwtype,
76 #endif
77 #if HAVE_HWETHER
78   &ether_hwtype,
79 #endif
80 #if HAVE_HWTR
81   &tr_hwtype,
82 #endif
83 #if HAVE_HWAX25
84   &ax25_hwtype,
85 #endif
86 #if HAVE_HWNETROM
87   &netrom_hwtype,
88 #endif
89 #if HAVE_HWTUNNEL
90   &tunnel_hwtype,
91 #endif
92 #if HAVE_HWPPP
93   &ppp_hwtype,
94 #endif  
95 #if HAVE_HWARC
96   &arcnet_hwtype,
97 #endif  
98 #if HAVE_HWFR
99   &dlci_hwtype,
100   &frad_hwtype,
101 #endif
102 #if HAVE_HWSIT
103   &sit_hwtype,
104 #endif
105 #if HAVE_HWROSE
106   &rose_hwtype,
107 #endif
108 #if HAVE_HWFDDI
109   &fddi_hwtype,
110 #endif
111 #if HAVE_HWHIPPI
112   &hippi_hwtype,
113 #endif
114   &unspec_hwtype,
115   NULL
116 };
117
118 static short sVhwinit = 0;
119
120 void hwinit ()
121 {
122   loop_hwtype.title = NLS_CATSAVE (catfd, loopbackSet, loopback_loop, "Local Loopback");
123   unspec_hwtype.title = NLS_CATSAVE (catfd, loopbackSet, loopback_unspec, "UNSPEC");
124 #if HAVE_HWSLIP
125   slip_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_slip, "Serial Line IP");
126   cslip_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_cslip, "VJ Serial Line IP");
127   slip6_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_slip6, "6-bit Serial Line IP");
128   cslip6_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_cslip6, "VJ 6-bit Serial Line IP");
129   adaptive_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_adaptive, "Adaptive Serial Line IP");
130 #endif
131 #if HAVE_HWETHER
132   ether_hwtype.title = NLS_CATSAVE (catfd, etherSet, ether_ether, "Ethernet");
133 #endif
134 #if HAVE_HWASH
135   ash_hwtype.title = NLS_CATSAVE (catfd, ashSet, ash_hw, "Ash");
136 #endif
137 #if HAVE_HWFDDI
138   fddi_hwtype.title = NLS_CATSAVE (catfd, fddiSet, fddi_fddi, "Fiber Distributed Data Interface");
139 #endif
140 #if HAVE_HWHIPPI
141   hippi_hwtype.title = NLS_CATSAVE (catfd, hippiSet, hippi_hippi, "HIPPI");
142 #endif
143 #if HAVE_HWAX25
144   ax25_hwtype.title = NLS_CATSAVE (catfd, ax25Set, ax25_hw, "AMPR AX.25");
145 #endif
146 #if HAVE_HWROSE
147   rose_hwtype.title = NLS_CATSAVE (catfd, roseSet, rose_hw, "AMPR ROSE");
148 #endif
149 #if HAVE_HWNETROM
150   netrom_hwtype.title = NLS_CATSAVE (catfd, netromSet, netrom_hw, "AMPR NET/ROM");
151 #endif
152 #if HAVE_HWTUNNEL
153   tunnel_hwtype.title = NLS_CATSAVE (catfd, tunnelSet, tunnel_hw, "IPIP Tunnel");
154 #endif
155 #if HAVE_HWPPP
156   ppp_hwtype.title = NLS_CATSAVE (catfd, pppSet, ppp_ppp, "Point-to-Point Protocol");
157 #endif  
158 #if HAVE_HWARC
159   arcnet_hwtype.title = NLS_CATSAVE (catfd, arcnetSet, arcnet_arcnet, "1.5Mbps ARCnet");
160 #endif
161 #if HAVE_HWFR
162   dlci_hwtype.title = NLS_CATSAVE(catfd, dlciSet, dlci_hw, "Frame Relay DLCI");
163   frad_hwtype.title = NLS_CATSAVE(catfd, fradSet, frad_hw, "Frame Relay Access Device");
164 #endif
165 #if HAVE_HWSIT
166   sit_hwtype.title = NLS_CATSAVE(catfd, sitSet, sit_hw, "IPv6-in-IPv4");
167 #endif
168   sVhwinit = 1;
169 }
170
171 /* Check our hardware type table for this type. */
172 struct hwtype *
173 get_hwtype(const char *name)
174 {
175   struct hwtype **hwp;
176
177   if (!sVhwinit)
178     hwinit();
179   
180   hwp = hwtypes;
181   while (*hwp != NULL) {
182         if (!strcmp((*hwp)->name, name)) return(*hwp);
183         hwp++;
184   }
185   return(NULL);
186 }
187
188
189 /* Check our hardware type table for this type. */
190 struct hwtype *
191 get_hwntype(int type)
192 {
193   struct hwtype **hwp;
194
195   if (!sVhwinit)
196     hwinit();
197
198   hwp = hwtypes;
199   while (*hwp != NULL) {
200         if ((*hwp)->type == type) return(*hwp);
201         hwp++;
202   }
203   return(NULL);
204 }