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

Subversion Repositories or1k

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

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 745 simons
/*
2
 * lib/econet.c       This file contains an implementation of the Econet
3
 *              support functions for the net-tools.
4
 *              (NET-3 base distribution).
5
 *
6
 * Version:     $Id: econet.c,v 1.1 2002-03-17 19:58:53 simons Exp $
7
 *
8
 * Author:      Philip Blundell <philb@gnu.org>
9
 *
10
 * Modified:
11
 *
12
 *              This program is free software; you can redistribute it
13
 *              and/or  modify it under  the terms of  the GNU General
14
 *              Public  License as  published  by  the  Free  Software
15
 *              Foundation;  either  version 2 of the License, or  (at
16
 *              your option) any later version.
17
 */
18
 
19
#include "config.h"
20
 
21
#if HAVE_AFECONET
22
 
23
#include <sys/types.h>
24
#include <sys/socket.h>
25
#include <stdio.h>
26
#include <neteconet/ec.h>
27
 
28
#include "version.h"
29
#include "net-support.h"
30
#include "pathnames.h"
31
#include "intl.h"
32
 
33
 
34
/* Display an Econet address */
35
static char *
36
 ec_print(unsigned char *ptr)
37
{
38
    static char buff[64];
39
    struct ec_addr *ec = (struct ec_addr *) ptr;
40
    sprintf(buff, "%d.%d", ec->net, ec->station);
41
    return buff;
42
}
43
 
44
 
45
/* Display an Econet socket address */
46
static char *
47
 ec_sprint(struct sockaddr *sap, int numeric)
48
{
49
    struct sockaddr_ec *sec = (struct sockaddr_ec *) sap;
50
 
51
    if (sap->sa_family != AF_ECONET)
52
        return _("[NONE SET]");
53
 
54
    return ec_print((unsigned char *) &sec->addr);
55
}
56
 
57
static int ec_input(int type, char *bufp, struct sockaddr *sap)
58
{
59
    struct sockaddr_ec *sec = (struct sockaddr_ec *) sap;
60
    int net, stn;
61
    switch (sscanf(bufp, "%d.%d", &net, &stn)) {
62
    case 2:
63
        sec->addr.station = stn;
64
        sec->addr.net = net;
65
        return 0;
66
    case 1:
67
        if (sscanf(bufp, "%d", &stn) == 1) {
68
            sec->addr.net = 0;
69
            sec->addr.station = stn;
70
            return 0;
71
        }
72
    }
73
    return -1;
74
}
75
 
76
struct aftype ec_aftype =
77
{
78
    "ec", NULL, AF_ECONET, 0,
79
    ec_print, ec_sprint, ec_input, NULL,
80
    NULL, NULL, NULL,
81
    -1,
82
    "/proc/sys/net/econet"
83
};
84
 
85
#endif                          /* HAVE_AFECONET */

powered by: WebSVN 2.1.0

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