aboutsummaryrefslogtreecommitdiff
path: root/src/inet.c
diff options
context:
space:
mode:
authorDiego Nehab <diego@impa.br>2013-06-04 16:26:49 +0800
committerDiego Nehab <diego@impa.br>2013-06-04 16:26:49 +0800
commitb1d1e721d1b325cacfc6342c696191730dea357d (patch)
tree93746b337e16c20b23ec7bd8dd532e9a50f9fb2f /src/inet.c
parent802567b7deff65b0b8471ae4ba5c7873caef525f (diff)
downloadluasocket-b1d1e721d1b325cacfc6342c696191730dea357d.tar.gz
luasocket-b1d1e721d1b325cacfc6342c696191730dea357d.tar.bz2
luasocket-b1d1e721d1b325cacfc6342c696191730dea357d.zip
No need for inet_pton.
Diffstat (limited to 'src/inet.c')
-rw-r--r--src/inet.c32
1 files changed, 2 insertions, 30 deletions
diff --git a/src/inet.c b/src/inet.c
index 25482a3..1a411f6 100644
--- a/src/inet.c
+++ b/src/inet.c
@@ -199,7 +199,7 @@ static int inet_global_getaddrinfo(lua_State *L)
199 lua_pushliteral(L, "family"); 199 lua_pushliteral(L, "family");
200 lua_pushliteral(L, "inet6"); 200 lua_pushliteral(L, "inet6");
201 lua_settable(L, -3); 201 lua_settable(L, -3);
202 break;; 202 break;
203 } 203 }
204 lua_pushliteral(L, "addr"); 204 lua_pushliteral(L, "addr");
205 lua_pushstring(L, hbuf); 205 lua_pushstring(L, hbuf);
@@ -487,8 +487,7 @@ const char *inet_trybind(p_socket ps, const char *address, const char *serv,
487} 487}
488 488
489/*-------------------------------------------------------------------------*\ 489/*-------------------------------------------------------------------------*\
490* Some systems do not provide this so that we provide our own. It's not 490* Some systems do not provide these so that we provide our own.
491* marvelously fast, but it works just fine.
492\*-------------------------------------------------------------------------*/ 491\*-------------------------------------------------------------------------*/
493#ifdef LUASOCKET_INET_ATON 492#ifdef LUASOCKET_INET_ATON
494int inet_aton(const char *cp, struct in_addr *inp) 493int inet_aton(const char *cp, struct in_addr *inp)
@@ -512,34 +511,7 @@ int inet_aton(const char *cp, struct in_addr *inp)
512} 511}
513#endif 512#endif
514 513
515/*-------------------------------------------------------------------------*\
516* inet_ntop/inet_pton for MinGW from
517* http://mingw-users.1079350.n2.nabble.com/IPv6-getaddrinfo-amp-inet-ntop-td5891996.html
518\*-------------------------------------------------------------------------*/
519
520#ifdef LUASOCKET_INET_PTON 514#ifdef LUASOCKET_INET_PTON
521const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
522{
523 if (af == AF_INET) {
524 struct sockaddr_in in;
525 memset(&in, 0, sizeof(in));
526 in.sin_family = AF_INET;
527 memcpy(&in.sin_addr, src, sizeof(struct in_addr));
528 getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in),
529 dst, cnt, NULL, 0, NI_NUMERICHOST);
530 return dst;
531 } else if (af == AF_INET6) {
532 struct sockaddr_in6 in;
533 memset(&in, 0, sizeof(in));
534 in.sin6_family = AF_INET6;
535 memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
536 getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6),
537 dst, cnt, NULL, 0, NI_NUMERICHOST);
538 return dst;
539 }
540 return NULL;
541}
542
543int inet_pton(int af, const char *src, void *dst) 515int inet_pton(int af, const char *src, void *dst)
544{ 516{
545 struct addrinfo hints, *res; 517 struct addrinfo hints, *res;