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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [uclinux/] [userland/] [route/] [lib/] [ipx_gr.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 745 simons
/* support for ap->rresolv missing */
2
/*
3
   Modifications:
4
   1998-07-01 - Arnaldo Carvalho de Melo - GNU gettext instead of catgets,
5
   snprintf instead of sprintf
6
 */
7
 
8
#include "config.h"
9
 
10
#if HAVE_AFIPX
11
#include <asm/types.h>
12
#include <sys/types.h>
13
#include <sys/socket.h>
14
#if (__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1)
15
#include <netipx/ipx.h>
16
#else
17
#include "ipx.h"
18
#endif
19
#include <stdlib.h>
20
#include <stdio.h>
21
#include <errno.h>
22
#include <ctype.h>
23
#include <string.h>
24
#include <unistd.h>
25
#include <netinet/in.h>
26
#include "version.h"
27
#include "net-support.h"
28
#include "pathnames.h"
29
#include "intl.h"
30
 
31
/* UGLY */
32
 
33
int IPX_rprint(int options)
34
{
35
    /* int ext = options & FLAG_EXT; */
36
    int numeric = options & FLAG_NUM;
37
    char buff[1024];
38
    char net[128], router_net[128];
39
    char router_node[128];
40
    int num;
41
    FILE *fp = fopen(_PATH_PROCNET_IPX_ROUTE, "r");
42
    struct aftype *ap;
43
    struct sockaddr sa;
44
 
45
    if ((ap = get_afntype(AF_IPX)) == NULL) {
46
        EINTERN("lib/ipx_rt.c", "AF_IPX missing");
47
        return (-1);
48
    }
49
 
50
    if (!fp) {
51
        perror(_PATH_PROCNET_IPX_ROUTE);
52
        printf(_("IPX not configured in this system.\n"));
53
        return 1;
54
    }
55
 
56
    printf(_("Kernel IPX routing table\n"));    /* xxx */
57
    printf(_("Destination               Router Net                Router Node\n"));
58
 
59
    fgets(buff, 1023, fp);
60
 
61
    while (fgets(buff, 1023, fp)) {
62
        num = sscanf(buff, "%s %s %s", net, router_net, router_node);
63
        if (num < 3)
64
            continue;
65
 
66
        /* Fetch and resolve the Destination */
67
        (void) ap->input(5, net, &sa);
68
        strcpy(net, ap->sprint(&sa, numeric));
69
 
70
        /* Fetch and resolve the Router Net */
71
        (void) ap->input(5, router_net, &sa);
72
        strcpy(router_net, ap->sprint(&sa, numeric));
73
 
74
        /* Fetch and resolve the Router Node */
75
        (void) ap->input(2, router_node, &sa);
76
        strcpy(router_node, ap->sprint(&sa, numeric));
77
 
78
        printf("%-25s %-25s %-25s\n", net, router_net, router_node);
79
    }
80
 
81
    (void) fclose(fp);
82
    return (0);
83
}
84
 
85
#endif                          /* HAVE_AFIPX */

powered by: WebSVN 2.1.0

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