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

Subversion Repositories or1k

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 745 simons
/*
2
 * lib/netrom_gr.c    This file contains an implementation of the NET/ROM
3
 *                      route support functions.
4
 *
5
 * Version:     $Id: netrom_gr.c,v 1.1 2002-03-17 19:58:53 simons Exp $
6
 *
7
 * Author:      Bernd Eckenfels, <ecki@lina.inka.de>
8
 *              Copyright 1999 Bernd Eckenfels, Germany
9
 *              base on Code from Jonathan Naylor <jsn@Cs.Nott.AC.UK>
10
 *
11
 * Changes:
12
 * 980701 {0.02} Arnaldo Carvalho de Melo   GNU gettext instead of catgets
13
 *
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 "config.h"
22
 
23
#if HAVE_AFNETROM
24
#include <stdlib.h>
25
#include <stdio.h>
26
#include <unistd.h>
27
#include "net-support.h"
28
#include "pathnames.h"
29
#include "intl.h"
30
 
31
/* UGLY */
32
 
33
int NETROM_rprint(int options)
34
{
35
    FILE *f1 = fopen(_PATH_PROCNET_NR_NODES, "r");
36
    FILE *f2 = fopen(_PATH_PROCNET_NR_NEIGH, "r");
37
    char buffer[256];
38
    int qual, n, w;
39
    /*int ext = options & FLAG_EXT;
40
       int numeric = options & FLAG_NUM; */
41
 
42
    f1 = fopen(_PATH_PROCNET_NR_NODES, "r");
43
    if (!f1) perror(_PATH_PROCNET_NR_NODES);
44
    f2 = fopen(_PATH_PROCNET_NR_NEIGH, "r");
45
    if (!f2) perror(_PATH_PROCNET_NR_NEIGH);
46
 
47
    if (f1 == NULL || f2 == NULL) {
48
        printf(_("NET/ROM not configured in this system.\n"));
49
        return 1;
50
    }
51
    printf(_("Kernel NET/ROM routing table\n"));
52
    printf(_("Destination  Mnemonic  Quality  Neighbour  Iface\n"));
53
    fgets(buffer, 256, f1);
54
    while (fgets(buffer, 256, f1)) {
55
        buffer[9] = 0;
56
        buffer[17] = 0;
57
        w = atoi(buffer + 19) - 1;
58
        printf("%-9s    %-7s   ",
59
               buffer, buffer + 10);
60
        qual = atoi(buffer + 24 + 15 * w);
61
        n = atoi(buffer + 32 + 15 * w);
62
        rewind(f2);
63
        fgets(buffer, 256, f2);
64
        while (fgets(buffer, 256, f2)) {
65
            if (atoi(buffer) == n) {
66
                buffer[15] = 0;
67
                buffer[20] = 0;
68
                printf("%3d      %-9s  %s\n",
69
                       qual, buffer + 6, buffer + 16);
70
                break;
71
            }
72
        }
73
    }
74
    fclose(f1);
75
    fclose(f2);
76
    return 0;
77
}
78
 
79
#endif                          /* HAVE_AFNETROM */

powered by: WebSVN 2.1.0

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