OpenCores
URL https://opencores.org/ocsvn/or1k_old/or1k_old/trunk

Subversion Repositories or1k_old

[/] [or1k_old/] [trunk/] [uclinux/] [userland/] [route/] [lib/] [hw.c] - Blame information for rev 1782

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 745 simons
/*
2
 * lib/hw.c   This file contains the top-level part of the hardware
3
 *              support functions module.
4
 *
5
 * Version:     $Id: hw.c,v 1.1 2002-03-17 19:58:53 simons Exp $
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
 *980701 {1.21}  Arnaldo C. Melo       GNU gettext instead of catgets
13
 *
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.
19
 */
20
#include <sys/types.h>
21
#include <sys/socket.h>
22
#include <stdlib.h>
23
#include <stdio.h>
24
#include <errno.h>
25
#include <ctype.h>
26
#include <string.h>
27
#include <unistd.h>
28
#include "config.h"
29
#include "net-support.h"
30
#include "pathnames.h"
31
#include "intl.h"
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 hdlc_hwtype;
62
extern struct hwtype lapb_hwtype;
63
 
64
extern struct hwtype sit_hwtype;
65
 
66
extern struct hwtype irda_hwtype;
67
 
68
static struct hwtype *hwtypes[] =
69
{
70
 
71
    &loop_hwtype,
72
 
73
#if HAVE_HWSLIP
74
    &slip_hwtype,
75
    &cslip_hwtype,
76
    &slip6_hwtype,
77
    &cslip6_hwtype,
78
    &adaptive_hwtype,
79
#endif
80
#if HAVE_HWASH
81
    &ash_hwtype,
82
#endif
83
#if HAVE_HWETHER
84
    &ether_hwtype,
85
#endif
86
#if HAVE_HWTR
87
    &tr_hwtype,
88
#endif
89
#if HAVE_HWAX25
90
    &ax25_hwtype,
91
#endif
92
#if HAVE_HWNETROM
93
    &netrom_hwtype,
94
#endif
95
#if HAVE_HWROSE
96
    &rose_hwtype,
97
#endif
98
#if HAVE_HWTUNNEL
99
    &tunnel_hwtype,
100
#endif
101
#if HAVE_HWPPP
102
    &ppp_hwtype,
103
#endif
104
#if HAVE_HWHDLCLAPB
105
    &hdlc_hwtype,
106
    &lapb_hwtype,
107
#endif
108
#if HAVE_HWARC
109
    &arcnet_hwtype,
110
#endif
111
#if HAVE_HWFR
112
    &dlci_hwtype,
113
    &frad_hwtype,
114
#endif
115
#if HAVE_HWSIT
116
    &sit_hwtype,
117
#endif
118
#if HAVE_HWFDDI
119
    &fddi_hwtype,
120
#endif
121
#if HAVE_HWHIPPI
122
    &hippi_hwtype,
123
#endif
124
#if HAVE_HWIRDA
125
    &irda_hwtype,
126
#endif
127
    &unspec_hwtype,
128
    NULL
129
};
130
 
131
static short sVhwinit = 0;
132
 
133
void hwinit()
134
{
135
    loop_hwtype.title = _("Local Loopback");
136
    unspec_hwtype.title = _("UNSPEC");
137
#if HAVE_HWSLIP
138
    slip_hwtype.title = _("Serial Line IP");
139
    cslip_hwtype.title = _("VJ Serial Line IP");
140
    slip6_hwtype.title = _("6-bit Serial Line IP");
141
    cslip6_hwtype.title = _("VJ 6-bit Serial Line IP");
142
    adaptive_hwtype.title = _("Adaptive Serial Line IP");
143
#endif
144
#if HAVE_HWETHER
145
    ether_hwtype.title = _("Ethernet");
146
#endif
147
#if HAVE_HWASH
148
    ash_hwtype.title = _("Ash");
149
#endif
150
#if HAVE_HWFDDI
151
    fddi_hwtype.title = _("Fiber Distributed Data Interface");
152
#endif
153
#if HAVE_HWHIPPI
154
    hippi_hwtype.title = _("HIPPI");
155
#endif
156
#if HAVE_HWAX25
157
    ax25_hwtype.title = _("AMPR AX.25");
158
#endif
159
#if HAVE_HWROSE
160
    rose_hwtype.title = _("AMPR ROSE");
161
#endif
162
#if HAVE_HWNETROM
163
    netrom_hwtype.title = _("AMPR NET/ROM");
164
#endif
165
#if HAVE_HWTUNNEL
166
    tunnel_hwtype.title = _("IPIP Tunnel");
167
#endif
168
#if HAVE_HWPPP
169
    ppp_hwtype.title = _("Point-to-Point Protocol");
170
#endif
171
#if HAVE_HWHDLCLAPB
172
    hdlc_hwtype.title = _("(Cisco)-HDLC");
173
    lapb_hwtype.title = _("LAPB");
174
#endif
175
#if HAVE_HWARC
176
    arcnet_hwtype.title = _("ARCnet");
177
#endif
178
#if HAVE_HWFR
179
    dlci_hwtype.title = _("Frame Relay DLCI");
180
    frad_hwtype.title = _("Frame Relay Access Device");
181
#endif
182
#if HAVE_HWSIT
183
    sit_hwtype.title = _("IPv6-in-IPv4");
184
#endif
185
#if HAVE_HWIRDA
186
    irda_hwtype.title = _("IrLAP");
187
#endif
188
    sVhwinit = 1;
189
}
190
 
191
/* Check our hardware type table for this type. */
192
struct hwtype *get_hwtype(const char *name)
193
{
194
    struct hwtype **hwp;
195
 
196
    if (!sVhwinit)
197
        hwinit();
198
 
199
    hwp = hwtypes;
200
    while (*hwp != NULL) {
201
        if (!strcmp((*hwp)->name, name))
202
            return (*hwp);
203
        hwp++;
204
    }
205
    return (NULL);
206
}
207
 
208
 
209
/* Check our hardware type table for this type. */
210
struct hwtype *get_hwntype(int type)
211
{
212
    struct hwtype **hwp;
213
 
214
    if (!sVhwinit)
215
        hwinit();
216
 
217
    hwp = hwtypes;
218
    while (*hwp != NULL) {
219
        if ((*hwp)->type == type)
220
            return (*hwp);
221
        hwp++;
222
    }
223
    return (NULL);
224
}
225
 
226
/* type: 0=all, 1=ARPable */
227
void print_hwlist(int type) {
228
    int count = 0;
229
    char * txt;
230
    struct hwtype **hwp;
231
 
232
    if (!sVhwinit)
233
        hwinit();
234
 
235
    hwp = hwtypes;
236
    while (*hwp != NULL) {
237
        if (((type == 1) && ((*hwp)->alen == 0)) || ((*hwp)->type == -1)) {
238
                hwp++; continue;
239
        }
240
        if ((count % 3) == 0) fprintf(stderr,count?"\n    ":"    ");
241
        txt = (*hwp)->name; if (!txt) txt = "..";
242
        fprintf(stderr,"%s (%s) ",txt,(*hwp)->title);
243
        count++;
244
        hwp++;
245
    }
246
    fprintf(stderr,"\n");
247
}
248
 
249
/* return 1 if address is all zeros */
250
int hw_null_address(struct hwtype *hw, void *ap)
251
{
252
    unsigned int i;
253
    unsigned char *address = (unsigned char *)ap;
254
    for (i = 0; i < hw->alen; i++)
255
        if (address[i])
256
            return 0;
257
    return 1;
258
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.