Add Ash support
[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.13 (1996-04-13)
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  * Changes:
13  *960413 {1.13} Mike Mclagan    :       DLCI/FRAD support
14  *
15  *              This program is free software; you can redistribute it
16  *              and/or  modify it under  the terms of  the GNU General
17  *              Public  License as  published  by  the  Free  Software
18  *              Foundation;  either  version 2 of the License, or  (at
19  *              your option) any later version.
20  */
21 #include <sys/types.h>
22 #include <sys/socket.h>
23 #include <stdlib.h>
24 #include <stdio.h>
25 #include <errno.h>
26 #include <ctype.h>
27 #include <string.h>
28 #include <unistd.h>
29 #include "config.h"
30 #include "net-support.h"
31 #include "pathnames.h"
32 #define  EXTERN
33 #include "net-locale.h"
34
35
36 extern  struct hwtype   unspec_hwtype;
37 extern  struct hwtype   loop_hwtype;
38
39 extern  struct hwtype   slip_hwtype;
40 extern  struct hwtype   cslip_hwtype;
41 extern  struct hwtype   slip6_hwtype;
42 extern  struct hwtype   cslip6_hwtype;
43 extern  struct hwtype   adaptive_hwtype;
44
45 extern  struct hwtype   ether_hwtype;
46 extern  struct hwtype   tr_hwtype;
47
48 extern  struct hwtype   ax25_hwtype;
49 extern  struct hwtype   netrom_hwtype;
50 extern  struct hwtype   tunnel_hwtype;
51 extern  struct hwtype   ash_hwtype;
52
53 extern struct hwtype    ppp_hwtype;
54
55 extern struct hwtype    arcnet_hwtype;
56
57 extern struct hwtype   dlci_hwtype;
58 extern struct hwtype   frad_hwtype;
59
60 extern struct hwtype   sit_hwtype;
61
62 static struct hwtype *hwtypes[] = {
63
64   &loop_hwtype,
65
66 #if HAVE_HWSLIP
67   &slip_hwtype,
68   &cslip_hwtype,
69   &slip6_hwtype,
70   &cslip6_hwtype,
71   &adaptive_hwtype,
72 #endif
73 #if HAVE_HWASH
74   &ash_hwtype,
75 #endif
76 #if HAVE_HWETHER
77   &ether_hwtype,
78 #endif
79 #if HAVE_HWTR
80   &tr_hwtype,
81 #endif
82 #if HAVE_HWAX25
83   &ax25_hwtype,
84 #endif
85 #if HAVE_HWNETROM
86   &netrom_hwtype,
87 #endif
88 #if HAVE_HWTUNNEL
89   &tunnel_hwtype,
90 #endif
91 #if HAVE_HWPPP
92   &ppp_hwtype,
93 #endif  
94 #if HAVE_HWARC
95   &arcnet_hwtype,
96 #endif  
97 #if HAVE_HWFR
98   &dlci_hwtype,
99   &frad_hwtype,
100 #endif
101 #if HAVE_HWSIT
102   &sit_hwtype,
103 #endif
104   &unspec_hwtype,
105   NULL
106 };
107
108 static short sVhwinit = 0;
109
110 void hwinit ()
111 {
112   loop_hwtype.title = NLS_CATSAVE (catfd, loopbackSet, loopback_loop, "Local Loopback");
113 #if HAVE_HWSLIP
114   slip_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_slip, "Serial Line IP");
115   cslip_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_cslip, "VJ Serial Line IP");
116   slip6_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_slip6, "6-bit Serial Line IP");
117   cslip6_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_cslip6, "VJ 6-bit Serial Line IP");
118   adaptive_hwtype.title = NLS_CATSAVE (catfd, slipSet, slip_adaptive, "Adaptive Serial Line IP");
119 #endif
120   unspec_hwtype.title = NLS_CATSAVE (catfd, loopbackSet, loopback_unspec, "UNSPEC");
121 #if HAVE_HWETHER
122   ether_hwtype.title = NLS_CATSAVE (catfd, etherSet, ether_ether, "Ethernet");
123 #endif
124 #if HAVE_HWASH
125   ash_hwtype.title = NLS_CATSAVE (catfd, ashSet, ash_hw, "64Mbps ASH");
126 #endif
127 #if HAVE_HWAX25
128   ax25_hwtype.title = NLS_CATSAVE (catfd, ax25Set, ax25_hw, "AMPR AX.25");
129 #endif
130 #if HAVE_HWNETROM
131   netrom_hwtype.title = NLS_CATSAVE (catfd, netromSet, netrom_hw, "AMPR NET/ROM");
132 #endif
133 #if HAVE_HWTUNNEL
134   tunnel_hwtype.title = NLS_CATSAVE (catfd, tunnelSet, tunnel_hw, "IPIP Tunnel");
135 #endif
136 #if HAVE_HWPPP
137   ppp_hwtype.title = NLS_CATSAVE (catfd, pppSet, ppp_ppp, "Point-to-Point Protocol");
138 #endif  
139 #if HAVE_HWARC
140   arcnet_hwtype.title = NLS_CATSAVE (catfd, arcnetSet, arcnet_arcnet, "1.5Mbps ARCnet");
141 #endif
142 #if HAVE_HWFR
143    dlci_hwtype.title = NLS_CATSAVE(catfd, dlciSet, dlci_hw, "Frame Relay DLCI");
144    frad_hwtype.title = NLS_CATSAVE(catfd, fradSet, frad_hw, "Frame Relay Access Device");
145 #endif
146 #if HAVE_HWSIT
147    sit_hwtype.title = NLS_CATSAVE(catfd, sitSet, sit_hw, "IPv6-in-IPv4");
148 #endif
149     sVhwinit = 1;
150 }
151
152 /* Check our hardware type table for this type. */
153 struct hwtype *
154 get_hwtype(const char *name)
155 {
156   struct hwtype **hwp;
157
158   if (!sVhwinit)
159     hwinit();
160   
161   hwp = hwtypes;
162   while (*hwp != NULL) {
163         if (!strcmp((*hwp)->name, name)) return(*hwp);
164         hwp++;
165   }
166   return(NULL);
167 }
168
169
170 /* Check our hardware type table for this type. */
171 struct hwtype *
172 get_hwntype(int type)
173 {
174   struct hwtype **hwp;
175
176   if (!sVhwinit)
177     hwinit();
178
179   hwp = hwtypes;
180   while (*hwp != NULL) {
181         if ((*hwp)->type == type) return(*hwp);
182         hwp++;
183   }
184   return(NULL);
185 }