aboutsummaryrefslogtreecommitdiff
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
parent802567b7deff65b0b8471ae4ba5c7873caef525f (diff)
downloadluasocket-b1d1e721d1b325cacfc6342c696191730dea357d.tar.gz
luasocket-b1d1e721d1b325cacfc6342c696191730dea357d.tar.bz2
luasocket-b1d1e721d1b325cacfc6342c696191730dea357d.zip
No need for inet_pton.
-rw-r--r--src/inet.c32
-rw-r--r--src/options.c8
-rw-r--r--src/socket.lua2
3 files changed, 3 insertions, 39 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;
diff --git a/src/options.c b/src/options.c
index 55b65a7..8ac2a14 100644
--- a/src/options.c
+++ b/src/options.c
@@ -285,14 +285,6 @@ static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, int name)
285 if (!lua_isnil(L, -1)) { 285 if (!lua_isnil(L, -1)) {
286 if (lua_isnumber(L, -1)) { 286 if (lua_isnumber(L, -1)) {
287 val.ipv6mr_interface = (unsigned int) lua_tonumber(L, -1); 287 val.ipv6mr_interface = (unsigned int) lua_tonumber(L, -1);
288#if 0
289 } else if (lua_isstring(L, -1)) {
290 if (!(val.ipv6mr_interface = if_nametoindex(lua_tostring(L, -1)))) {
291 lua_pushnil(L);
292 lua_pushstring(L, "nonexistent interface");
293 return 2;
294 }
295#endif
296 } else 288 } else
297 luaL_argerror(L, -1, "number 'interface' field expected"); 289 luaL_argerror(L, -1, "number 'interface' field expected");
298 } 290 }
diff --git a/src/socket.lua b/src/socket.lua
index f2fb8a3..3913e6f 100644
--- a/src/socket.lua
+++ b/src/socket.lua
@@ -146,4 +146,4 @@ sourcet["default"] = sourcet["until-closed"]
146 146
147_M.source = _M.choose(sourcet) 147_M.source = _M.choose(sourcet)
148 148
149return _M \ No newline at end of file 149return _M