diff options
author | Diadlo <polsha3@gmail.com> | 2017-08-05 11:10:43 +0300 |
---|---|---|
committer | Diadlo <polsha3@gmail.com> | 2017-08-27 16:02:58 +0300 |
commit | 020e77fbdf6b40b714bd97c34e3cd0b0dd036be2 (patch) | |
tree | 3cb14469386f903d3f8405920f5a579946b6f50b | |
parent | f084f2c621b75a146ccefecbffa9be5f514297e3 (diff) |
Remove 'in_addr' and 'addrinfo' mention from network.h
-rw-r--r-- | toxcore/network.c | 45 | ||||
-rw-r--r-- | toxcore/network.h | 12 |
2 files changed, 22 insertions, 35 deletions
diff --git a/toxcore/network.c b/toxcore/network.c index 151986d9..aeaf4d79 100644 --- a/toxcore/network.c +++ b/toxcore/network.c | |||
@@ -166,6 +166,28 @@ static int make_socktype(int type); | |||
166 | static int make_family(int tox_family); | 166 | static int make_family(int tox_family); |
167 | static int make_tox_family(int family); | 167 | static int make_tox_family(int family); |
168 | 168 | ||
169 | static void get_ip4(IP4 *result, const struct in_addr *addr) | ||
170 | { | ||
171 | result->uint32 = addr->s_addr; | ||
172 | } | ||
173 | |||
174 | static void get_ip6(IP6 *result, const struct in6_addr *addr) | ||
175 | { | ||
176 | assert(sizeof(result->uint8) == sizeof(addr->s6_addr)); | ||
177 | memcpy(result->uint8, addr->s6_addr, sizeof(result->uint8)); | ||
178 | } | ||
179 | |||
180 | static void fill_addr4(IP4 ip, struct in_addr *addr) | ||
181 | { | ||
182 | addr->s_addr = ip.uint32; | ||
183 | } | ||
184 | |||
185 | static void fill_addr6(IP6 ip, struct in6_addr *addr) | ||
186 | { | ||
187 | assert(sizeof(ip.uint8) == sizeof(addr->s6_addr)); | ||
188 | memcpy(addr->s6_addr, ip.uint8, sizeof(ip.uint8)); | ||
189 | } | ||
190 | |||
169 | /* Check if socket is valid. | 191 | /* Check if socket is valid. |
170 | * | 192 | * |
171 | * return 1 if valid | 193 | * return 1 if valid |
@@ -358,29 +380,6 @@ static void loglogdata(Logger *log, const char *message, const uint8_t *buffer, | |||
358 | } | 380 | } |
359 | } | 381 | } |
360 | 382 | ||
361 | void get_ip4(IP4 *result, const struct in_addr *addr) | ||
362 | { | ||
363 | result->uint32 = addr->s_addr; | ||
364 | } | ||
365 | |||
366 | void get_ip6(IP6 *result, const struct in6_addr *addr) | ||
367 | { | ||
368 | assert(sizeof(result->uint8) == sizeof(addr->s6_addr)); | ||
369 | memcpy(result->uint8, addr->s6_addr, sizeof(result->uint8)); | ||
370 | } | ||
371 | |||
372 | |||
373 | void fill_addr4(IP4 ip, struct in_addr *addr) | ||
374 | { | ||
375 | addr->s_addr = ip.uint32; | ||
376 | } | ||
377 | |||
378 | void fill_addr6(IP6 ip, struct in6_addr *addr) | ||
379 | { | ||
380 | assert(sizeof(ip.uint8) == sizeof(addr->s6_addr)); | ||
381 | memcpy(addr->s6_addr, ip.uint8, sizeof(ip.uint8)); | ||
382 | } | ||
383 | |||
384 | /* Basic network functions: | 383 | /* Basic network functions: |
385 | * Function to send packet(data) of length length to ip_port. | 384 | * Function to send packet(data) of length length to ip_port. |
386 | */ | 385 | */ |
diff --git a/toxcore/network.h b/toxcore/network.h index f57c6897..3c98c168 100644 --- a/toxcore/network.h +++ b/toxcore/network.h | |||
@@ -63,10 +63,6 @@ | |||
63 | 63 | ||
64 | #endif | 64 | #endif |
65 | 65 | ||
66 | struct in_addr; | ||
67 | struct in6_addr; | ||
68 | struct addrinfo; | ||
69 | |||
70 | typedef short Family; | 66 | typedef short Family; |
71 | 67 | ||
72 | typedef int Socket; | 68 | typedef int Socket; |
@@ -165,14 +161,6 @@ typedef struct { | |||
165 | } | 161 | } |
166 | IP_Port; | 162 | IP_Port; |
167 | 163 | ||
168 | /* Convert in_addr to IP */ | ||
169 | void get_ip4(IP4 *ip, const struct in_addr *addr); | ||
170 | void get_ip6(IP6 *ip, const struct in6_addr *addr); | ||
171 | |||
172 | /* Conevrt IP to in_addr */ | ||
173 | void fill_addr4(IP4 ip, struct in_addr *addr); | ||
174 | void fill_addr6(IP6 ip, struct in6_addr *addr); | ||
175 | |||
176 | /* Convert values between host and network byte order. | 164 | /* Convert values between host and network byte order. |
177 | */ | 165 | */ |
178 | uint32_t net_htonl(uint32_t hostlong); | 166 | uint32_t net_htonl(uint32_t hostlong); |