mirror of
https://github.com/lunarmodules/luasocket.git
synced 2024-12-26 04:28:20 +01:00
No need for inet_pton.
This commit is contained in:
parent
802567b7de
commit
b1d1e721d1
32
src/inet.c
32
src/inet.c
@ -199,7 +199,7 @@ static int inet_global_getaddrinfo(lua_State *L)
|
||||
lua_pushliteral(L, "family");
|
||||
lua_pushliteral(L, "inet6");
|
||||
lua_settable(L, -3);
|
||||
break;;
|
||||
break;
|
||||
}
|
||||
lua_pushliteral(L, "addr");
|
||||
lua_pushstring(L, hbuf);
|
||||
@ -487,8 +487,7 @@ const char *inet_trybind(p_socket ps, const char *address, const char *serv,
|
||||
}
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* Some systems do not provide this so that we provide our own. It's not
|
||||
* marvelously fast, but it works just fine.
|
||||
* Some systems do not provide these so that we provide our own.
|
||||
\*-------------------------------------------------------------------------*/
|
||||
#ifdef LUASOCKET_INET_ATON
|
||||
int inet_aton(const char *cp, struct in_addr *inp)
|
||||
@ -512,34 +511,7 @@ int inet_aton(const char *cp, struct in_addr *inp)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*-------------------------------------------------------------------------*\
|
||||
* inet_ntop/inet_pton for MinGW from
|
||||
* http://mingw-users.1079350.n2.nabble.com/IPv6-getaddrinfo-amp-inet-ntop-td5891996.html
|
||||
\*-------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef LUASOCKET_INET_PTON
|
||||
const char *inet_ntop(int af, const void *src, char *dst, socklen_t cnt)
|
||||
{
|
||||
if (af == AF_INET) {
|
||||
struct sockaddr_in in;
|
||||
memset(&in, 0, sizeof(in));
|
||||
in.sin_family = AF_INET;
|
||||
memcpy(&in.sin_addr, src, sizeof(struct in_addr));
|
||||
getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in),
|
||||
dst, cnt, NULL, 0, NI_NUMERICHOST);
|
||||
return dst;
|
||||
} else if (af == AF_INET6) {
|
||||
struct sockaddr_in6 in;
|
||||
memset(&in, 0, sizeof(in));
|
||||
in.sin6_family = AF_INET6;
|
||||
memcpy(&in.sin6_addr, src, sizeof(struct in_addr6));
|
||||
getnameinfo((struct sockaddr *)&in, sizeof(struct sockaddr_in6),
|
||||
dst, cnt, NULL, 0, NI_NUMERICHOST);
|
||||
return dst;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int inet_pton(int af, const char *src, void *dst)
|
||||
{
|
||||
struct addrinfo hints, *res;
|
||||
|
@ -285,14 +285,6 @@ static int opt_ip6_setmembership(lua_State *L, p_socket ps, int level, int name)
|
||||
if (!lua_isnil(L, -1)) {
|
||||
if (lua_isnumber(L, -1)) {
|
||||
val.ipv6mr_interface = (unsigned int) lua_tonumber(L, -1);
|
||||
#if 0
|
||||
} else if (lua_isstring(L, -1)) {
|
||||
if (!(val.ipv6mr_interface = if_nametoindex(lua_tostring(L, -1)))) {
|
||||
lua_pushnil(L);
|
||||
lua_pushstring(L, "nonexistent interface");
|
||||
return 2;
|
||||
}
|
||||
#endif
|
||||
} else
|
||||
luaL_argerror(L, -1, "number 'interface' field expected");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user