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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [net/] [common/] [v2_0/] [src/] [getproto.c] - Blame information for rev 279

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

Line No. Rev Author Line
1 27 unneback
//==========================================================================
2
//
3
//      lib/getproto.c
4
//
5
//      getprotobyname(), getprotobynumber()
6
//
7
//==========================================================================
8
//####BSDCOPYRIGHTBEGIN####
9
//
10
// -------------------------------------------
11
//
12
// Portions of this software may have been derived from OpenBSD or other sources,
13
// and are covered by the appropriate copyright disclaimers included herein.
14
//
15
// -------------------------------------------
16
//
17
//####BSDCOPYRIGHTEND####
18
//==========================================================================
19
//#####DESCRIPTIONBEGIN####
20
//
21
// Author(s):    gthomas
22
// Contributors: gthomas
23
// Date:         2000-01-10
24
// Purpose:      
25
// Description:  
26
//              
27
//
28
//####DESCRIPTIONEND####
29
//
30
//==========================================================================
31
 
32
#include <sys/param.h>
33
#include <netdb.h>
34
#include <errno.h>
35
 
36
static struct protoent protocols[] = {
37
    { "ip",         0}, // internet protocol, pseudo protocol number
38
    { "icmp",       1}, // internet control message protocol
39
    { "igmp",       2}, // Internet Group Management
40
    { "ggp",        3}, // gateway-gateway protocol
41
    { "ipencap",    4}, // IP encapsulated in IP (officially ``IP'')
42
    { "st",         5}, // ST datagram mode
43
    { "tcp",        6}, // transmission control protocol
44
    { "egp",        8}, // exterior gateway protocol
45
    { "pup",       12}, // PARC universal packet protocol
46
    { "udp",       17}, // user datagram protocol
47
    { "hmp",       20}, // host monitoring protocol
48
    { "xns-idp",   22}, // Xerox NS IDP
49
    { "rdp",       27}, // "reliable datagram" protocol
50
    { "iso-tp4",   29}, // ISO Transport Protocol class 4
51
    { "xtp",       36}, // Xpress Tranfer Protocol
52
    { "ddp",       37}, // Datagram Delivery Protocol
53
    { "idpr-cmtp", 39}, // IDPR Control Message Transport
54
    { "rspf",      73}, //Radio Shortest Path First.
55
    { "vmtp",      81}, // Versatile Message Transport
56
    { "ospf",      89}, // Open Shortest Path First IGP
57
    { "ipip",      94}, // Yet Another IP encapsulation
58
    { "encap",     98}, // Yet Another IP encapsulation
59
    { 0, 0}
60
};
61
 
62
struct protoent *
63
getprotobyname(const char *name)
64
{
65
    struct protoent *p = protocols;
66
    while (p->p_name) {
67
        if (strcmp(name, p->p_name) == 0) {
68
            return p;
69
        }
70
        p++;
71
    }
72
    errno = ENOENT;
73
    return (struct protoent *)0;
74
}
75
 
76
struct protoent *
77
getprotobynumber(const int num)
78
{
79
    struct protoent *p = protocols;
80
    while (p->p_name) {
81
        if (p->p_proto == num) {
82
            return p;
83
        }
84
        p++;
85
    }
86
    errno = ENOENT;
87
    return (struct protoent *)0;
88
}

powered by: WebSVN 2.1.0

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