equal
deleted
inserted
replaced
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) |