4.104.114.84.95
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 | |
---|
7 | static 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 | */ |
---|
17 | struct protoent * |
---|
18 | getprotobyname (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 | */ |
---|
32 | struct protoent * |
---|
33 | getprotobynumber (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.