diff options
-rw-r--r-- | include/arpa/inet.h | 1 | ||||
-rw-r--r-- | src/network/inet_network.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/include/arpa/inet.h b/include/arpa/inet.h index 92938403..fdc501aa 100644 --- a/include/arpa/inet.h +++ b/include/arpa/inet.h @@ -24,6 +24,7 @@ uint32_t ntohl(uint32_t); uint16_t ntohs(uint16_t); in_addr_t inet_addr (const char *); +in_addr_t inet_network (const char *); char *inet_ntoa (struct in_addr); int inet_pton (int, const char *__restrict, void *__restrict); const char *inet_ntop (int, const void *__restrict, char *__restrict, socklen_t); diff --git a/src/network/inet_network.c b/src/network/inet_network.c new file mode 100644 index 00000000..ae60d7f6 --- /dev/null +++ b/src/network/inet_network.c @@ -0,0 +1,11 @@ +#include <sys/socket.h> +#include <netinet/in.h> +#include <arpa/inet.h> +#include "__dns.h" + +in_addr_t inet_network(const char *p) +{ + struct sockaddr_in sin; + if (__ipparse(&sin, AF_INET, p)) return -1; + return ntohl(sin.sin_addr.s_addr); +} |