source: rtems/c/src/exec/libnetworking/lib/getprotoby.c @ ff0f694d

4.104.114.84.95
Last change on this file since ff0f694d was ff0f694d, checked in by Joel Sherrill <joel.sherrill@…>, on 08/20/98 at 21:47:37

Fixed many warnings.

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