Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(384)

Side by Side Diff: fusl/src/network/proto.c

Issue 1573973002: Add a "fork" of musl as //fusl. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « fusl/src/network/ntohs.c ('k') | fusl/src/network/recv.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <netdb.h>
2 #include <string.h>
3
4 /* do we really need all these?? */
5
6 static int idx;
7 static const unsigned char protos[] = {
8 "\000ip\0"
9 "\001icmp\0"
10 "\002igmp\0"
11 "\003ggp\0"
12 "\004ipencap\0"
13 "\005st\0"
14 "\006tcp\0"
15 "\008egp\0"
16 "\014pup\0"
17 "\021udp\0"
18 "\024hmp\0"
19 "\026xns-idp\0"
20 "\033rdp\0"
21 "\035iso-tp4\0"
22 "\044xtp\0"
23 "\045ddp\0"
24 "\046idpr-cmtp\0"
25 "\051ipv6\0"
26 "\053ipv6-route\0"
27 "\054ipv6-frag\0"
28 "\055idrp\0"
29 "\056rsvp\0"
30 "\057gre\0"
31 "\062esp\0"
32 "\063ah\0"
33 "\071skip\0"
34 "\072ipv6-icmp\0"
35 "\073ipv6-nonxt\0"
36 "\074ipv6-opts\0"
37 "\111rspf\0"
38 "\121vmtp\0"
39 "\131ospf\0"
40 "\136ipip\0"
41 "\142encap\0"
42 "\147pim\0"
43 "\377raw"
44 };
45
46 void endprotoent(void)
47 {
48 idx = 0;
49 }
50
51 void setprotoent(int stayopen)
52 {
53 idx = 0;
54 }
55
56 struct protoent *getprotoent(void)
57 {
58 static struct protoent p;
59 static const char *aliases;
60 if (idx >= sizeof protos) return NULL;
61 p.p_proto = protos[idx];
62 p.p_name = (char *)&protos[idx+1];
63 p.p_aliases = (char **)&aliases;
64 idx += strlen(p.p_name) + 2;
65 return &p;
66 }
67
68 struct protoent *getprotobyname(const char *name)
69 {
70 struct protoent *p;
71 endprotoent();
72 do p = getprotoent();
73 while (p && strcmp(name, p->p_name));
74 return p;
75 }
76
77 struct protoent *getprotobynumber(int num)
78 {
79 struct protoent *p;
80 endprotoent();
81 do p = getprotoent();
82 while (p && p->p_proto != num);
83 return p;
84 }
OLDNEW
« no previous file with comments | « fusl/src/network/ntohs.c ('k') | fusl/src/network/recv.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698