Software /
code /
prosody
Comparison
util-src/net.c @ 5810:99ad8d42d0c9
util.net: Fix s2sout on Windows (return 0.0.0.0 and :: instead of an empty list)
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 30 Aug 2013 16:14:31 +0200 |
parent | 5752:729c78581308 |
child | 6411:6c8f6364bc48 |
comparison
equal
deleted
inserted
replaced
5804:bb27ba619932 | 5810:99ad8d42d0c9 |
---|---|
40 #ifndef _WIN32 | 40 #ifndef _WIN32 |
41 /* Link-local IPv4 addresses; see RFC 3927 and RFC 5735 */ | 41 /* Link-local IPv4 addresses; see RFC 3927 and RFC 5735 */ |
42 const long ip4_linklocal = htonl(0xa9fe0000); /* 169.254.0.0 */ | 42 const long ip4_linklocal = htonl(0xa9fe0000); /* 169.254.0.0 */ |
43 const long ip4_mask = htonl(0xffff0000); | 43 const long ip4_mask = htonl(0xffff0000); |
44 struct ifaddrs *addr = NULL, *a; | 44 struct ifaddrs *addr = NULL, *a; |
45 #endif | |
45 int n = 1; | 46 int n = 1; |
46 #endif | |
47 int type = luaL_checkoption(L, 1, "both", type_strings); | 47 int type = luaL_checkoption(L, 1, "both", type_strings); |
48 const char link_local = lua_toboolean(L, 2); /* defaults to 0 (false) */ | 48 const char link_local = lua_toboolean(L, 2); /* defaults to 0 (false) */ |
49 const char ipv4 = (type == 0 || type == 1); | 49 const char ipv4 = (type == 0 || type == 1); |
50 const char ipv6 = (type == 0 || type == 2); | 50 const char ipv6 = (type == 0 || type == 2); |
51 | 51 |
90 } | 90 } |
91 /* TODO: Error reporting? */ | 91 /* TODO: Error reporting? */ |
92 } | 92 } |
93 | 93 |
94 freeifaddrs(addr); | 94 freeifaddrs(addr); |
95 #else | |
96 if (ipv4) { | |
97 lua_pushstring(L, "0.0.0.0"); | |
98 lua_rawseti(L, -2, n++); | |
99 } | |
100 if (ipv6) { | |
101 lua_pushstring(L, "::"); | |
102 lua_rawseti(L, -2, n++); | |
103 } | |
95 #endif | 104 #endif |
96 return 1; | 105 return 1; |
97 } | 106 } |
98 | 107 |
99 int luaopen_util_net(lua_State* L) | 108 int luaopen_util_net(lua_State* L) |