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

Side by Side Diff: fusl/src/network/inet_legacy.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/inet_aton.c ('k') | fusl/src/network/inet_ntoa.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 <sys/socket.h>
2 #include <netinet/in.h>
3 #include <arpa/inet.h>
4
5 in_addr_t inet_network(const char *p)
6 {
7 return ntohl(inet_addr(p));
8 }
9
10 struct in_addr inet_makeaddr(in_addr_t n, in_addr_t h)
11 {
12 if (n < 256) h |= n<<24;
13 else if (n < 65536) h |= n<<16;
14 else h |= n<<8;
15 return (struct in_addr){ h };
16 }
17
18 in_addr_t inet_lnaof(struct in_addr in)
19 {
20 uint32_t h = in.s_addr;
21 if (h>>24 < 128) return h & 0xffffff;
22 if (h>>24 < 192) return h & 0xffff;
23 return h & 0xff;
24 }
25
26 in_addr_t inet_netof(struct in_addr in)
27 {
28 uint32_t h = in.s_addr;
29 if (h>>24 < 128) return h >> 24;
30 if (h>>24 < 192) return h >> 16;
31 return h >> 8;
32 }
OLDNEW
« no previous file with comments | « fusl/src/network/inet_aton.c ('k') | fusl/src/network/inet_ntoa.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698