Last change
on this file since 413 was 398, checked in by coas-nagasima, 5 years ago |
mbedTLS版Azure IoT Hub接続サンプルのソースコードを追加
|
-
Property svn:eol-style
set to
native
-
Property svn:mime-type
set to
text/x-csrc;charset=UTF-8
|
File size:
628 bytes
|
Line | |
---|
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 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.