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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « fusl/src/network/ntohs.c ('k') | fusl/src/network/recv.c » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: fusl/src/network/proto.c
diff --git a/fusl/src/network/proto.c b/fusl/src/network/proto.c
new file mode 100644
index 0000000000000000000000000000000000000000..a42d1456e2a6ada5cc131cdb17769f73ba641ef7
--- /dev/null
+++ b/fusl/src/network/proto.c
@@ -0,0 +1,84 @@
+#include <netdb.h>
+#include <string.h>
+
+/* do we really need all these?? */
+
+static int idx;
+static const unsigned char protos[] = {
+ "\000ip\0"
+ "\001icmp\0"
+ "\002igmp\0"
+ "\003ggp\0"
+ "\004ipencap\0"
+ "\005st\0"
+ "\006tcp\0"
+ "\008egp\0"
+ "\014pup\0"
+ "\021udp\0"
+ "\024hmp\0"
+ "\026xns-idp\0"
+ "\033rdp\0"
+ "\035iso-tp4\0"
+ "\044xtp\0"
+ "\045ddp\0"
+ "\046idpr-cmtp\0"
+ "\051ipv6\0"
+ "\053ipv6-route\0"
+ "\054ipv6-frag\0"
+ "\055idrp\0"
+ "\056rsvp\0"
+ "\057gre\0"
+ "\062esp\0"
+ "\063ah\0"
+ "\071skip\0"
+ "\072ipv6-icmp\0"
+ "\073ipv6-nonxt\0"
+ "\074ipv6-opts\0"
+ "\111rspf\0"
+ "\121vmtp\0"
+ "\131ospf\0"
+ "\136ipip\0"
+ "\142encap\0"
+ "\147pim\0"
+ "\377raw"
+};
+
+void endprotoent(void)
+{
+ idx = 0;
+}
+
+void setprotoent(int stayopen)
+{
+ idx = 0;
+}
+
+struct protoent *getprotoent(void)
+{
+ static struct protoent p;
+ static const char *aliases;
+ if (idx >= sizeof protos) return NULL;
+ p.p_proto = protos[idx];
+ p.p_name = (char *)&protos[idx+1];
+ p.p_aliases = (char **)&aliases;
+ idx += strlen(p.p_name) + 2;
+ return &p;
+}
+
+struct protoent *getprotobyname(const char *name)
+{
+ struct protoent *p;
+ endprotoent();
+ do p = getprotoent();
+ while (p && strcmp(name, p->p_name));
+ return p;
+}
+
+struct protoent *getprotobynumber(int num)
+{
+ struct protoent *p;
+ endprotoent();
+ do p = getprotoent();
+ while (p && p->p_proto != num);
+ return p;
+}
« 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