diff options
author | Diego Nehab <diego@impa.br> | 2013-06-04 16:26:49 +0800 |
---|---|---|
committer | Diego Nehab <diego@impa.br> | 2013-06-04 16:26:49 +0800 |
commit | b1d1e721d1b325cacfc6342c696191730dea357d (patch) | |
tree | 93746b337e16c20b23ec7bd8dd532e9a50f9fb2f | |
parent | 802567b7deff65b0b8471ae4ba5c7873caef525f (diff) | |
download | luasocket-b1d1e721d1b325cacfc6342c696191730dea357d.tar.gz luasocket-b1d1e721d1b325cacfc6342c696191730dea357d.tar.bz2 luasocket-b1d1e721d1b325cacfc6342c696191730dea357d.zip |
No need for inet_pton.
-rw-r--r-- | src/inet.c | 32 | ||||
-rw-r--r-- | src/options.c | 8 | ||||
-rw-r--r-- | src/socket.lua | 2 |
3 files changed, 3 insertions, 39 deletions
@@ -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 |
494 | int inet_aton(const char *cp, struct in_addr *inp) | 493 | int 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 |
521 | const 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 | |||
543 | int inet_pton(int af, const char *src, void *dst) | 515 | int 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 | ||
149 | return _M \ No newline at end of file | 149 | return _M |