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

Subversion Repositories or1k_old

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 745 simons
/*
2
 * lib/getroute.c     This file contains a small interface function to
3
 *                      use the AF specific print routine for the routing
4
 *                      table.
5
 *
6
 * NET-LIB      A collection of functions used from the base set of the
7
 *              NET-3 Networking Distribution for the LINUX operating
8
 *              system. (net-tools, net-drivers)
9
 *
10
 * Version:     $Id: getroute.c,v 1.1 2002-03-17 19:58:53 simons Exp $
11
 *
12
 * Author:      Bernd 'eckes' Eckenfels <net-tools@lina.inka.de>
13
 *              Copyright 1999 Bernd Eckenfels, Germany
14
 *
15
 * Modifications:
16
 *
17
 *951020 {0.10} Bernd Eckenfels:        creation
18
 *960202 {0.90} Bernd Eckenfels:        rewrite to use getaftype.
19
 *960204 {0.91} Bernd Eckenfels:        takes constant list of AFs
20
 *960206 {1.01} Bernd Eckenfels:        route_init will enable routing
21
 *                                      support in the AF handlers
22
 *960221 {1.02} Bernd Eckenfels:        renamed from route_info to getroute.c
23
 *960413 {1.03} Bernd Eckenfels:        new RTACTION support
24
 *980701 {1.04} Arnaldo C. Melo:        GNU gettext instead of catgets
25
 *
26
 *              This program is free software; you can redistribute it
27
 *              and/or  modify it under  the terms of  the GNU General
28
 *              Public  License as  published  by  the  Free  Software
29
 *              Foundation;  either  version 2 of the License, or  (at
30
 *              your option) any later version.
31
 */
32
#include <stdio.h>
33
#include <string.h>
34
#include "net-support.h"
35
#include "pathnames.h"
36
#include "version.h"
37
#include "config.h"
38
#include "intl.h"
39
#include "util.h"
40
 
41
extern struct aftype unspec_aftype;
42
extern struct aftype unix_aftype;
43
extern struct aftype inet_aftype;
44
extern struct aftype inet6_aftype;
45
extern struct aftype ax25_aftype;
46
extern struct aftype netrom_aftype;
47
extern struct aftype ipx_aftype;
48
extern struct aftype ddp_aftype;
49
 
50
void getroute_init(void)
51
{
52
#if HAVE_AFINET
53
    inet_aftype.rprint = INET_rprint;
54
#endif
55
#if HAVE_AFINET6
56
    inet6_aftype.rprint = INET6_rprint;
57
#endif
58
#if HAVE_AFNETROM
59
    netrom_aftype.rprint = NETROM_rprint;
60
#endif
61
#if HAVE_AFAX25
62
    ax25_aftype.rprint = AX25_rprint;
63
#endif
64
#if HAVE_AFIPX
65
    ipx_aftype.rprint = IPX_rprint;
66
#endif
67
#if HAVE_AFATALK
68
    ddp_aftype.rprint = DDP_rprint;
69
#endif
70
}
71
 
72
int route_info(const char *afname, int options)
73
{
74
    struct aftype *ap;
75
    char *tmp1, *tmp2;
76
    int found = E_NOTFOUND, rc;
77
    char buf[256];
78
 
79
    safe_strncpy(buf, afname, sizeof(buf));
80
 
81
    tmp1 = buf;
82
 
83
    while (tmp1) {
84
 
85
        ap = NULL;
86
 
87
        if ((tmp2 = index(tmp1, ',')))
88
            *tmp2++ = '\0';
89
 
90
        if (!tmp1[0]) {
91
            tmp1 = tmp2;
92
            continue;
93
        }
94
        ap = get_aftype(tmp1);
95
 
96
        if (!ap) {
97
            fprintf(stderr, _("Address family `%s' not supported.\n"), tmp1);
98
            return (E_OPTERR);
99
        }
100
        tmp1 = tmp2;
101
 
102
        if (!ap->rprint) {
103
            fprintf(stderr, _("No routing for address family `%s'.\n"), ap->name);
104
            return (E_OPTERR);
105
        }
106
        found = 0;
107
 
108
        if ((rc = ap->rprint(options)))
109
            return (rc);
110
 
111
    }
112
    return (found);
113
}

powered by: WebSVN 2.1.0

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