source: rtems/cpukit/libnetworking/lib/getprotoby.c @ 6e401331

4.104.115
Last change on this file since 6e401331 was b25b88e7, checked in by Ralf Corsepius <ralf.corsepius@…>, on 03/28/10 at 05:50:29

Add HAVE_CONFIG_H support to let files receive configure defines.

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