source: rtems/c/src/libnetworking/lib/getprotoby.c @ c1956b5

Last change on this file since c1956b5 was c1956b5, checked in by Joel Sherrill <joel.sherrill@…>, on 07/14/00 at 18:53:21

Changed name of static table versions to avoid conflict.

  • Property mode set to 100644
File size: 903 bytes
RevLine 
[96b39164]1/*
2 *  $Id$
3 */
4
[39e6e65a]5#include <netdb.h>
6#include <string.h>
7#include <sys/types.h>
8#include <sys/socket.h>
9#include <netinet/in.h>
10
11static const struct protoent prototab[] = {
12                                        { "ip",    NULL, IPPROTO_IP },
13                                        { "icmp",  NULL, IPPROTO_ICMP },
14                                        { "tcp",   NULL, IPPROTO_TCP },
15                                        { "udp",   NULL, IPPROTO_UDP },
16                                        };
17
18/*
19 * Dummy version of BSD getprotobyname()
20 */
21struct protoent *
[c1956b5]22getprotobyname_static (const char *name)
[39e6e65a]23{
24        int i;
25
26        for (i = 0 ; i < (sizeof prototab / sizeof prototab[0]) ; i++) {
27                if (strcmp (name, prototab[i].p_name) == 0)
[ff0f694d]28                        return (struct protoent *) &prototab[i];
[39e6e65a]29        }
30        return NULL;
31}
32
33/*
34 * Dummy version of BSD getprotobynumber()
35 */
36struct protoent *
[c1956b5]37getprotobynumber_static (int proto)
[39e6e65a]38{
39        int i;
40
41        for (i = 0 ; i < (sizeof prototab / sizeof prototab[0]) ; i++) {
42                if (proto == prototab[i].p_proto)
[ff0f694d]43                        return (struct protoent *) &prototab[i];
[39e6e65a]44        }
45        return NULL;
46}
Note: See TracBrowser for help on using the repository browser.