1 fix build with uClibc without IPv6 support
3 see Pull Request: https://github.com/diegonehab/luasocket/pull/90
5 Signed-off-by: Francois Perrad <francois.perrad@gadz.org>
7 Index: b/luasocket-3.0-rc1/src/options.c
8 ===================================================================
9 --- a/luasocket-3.0-rc1/src/options.c
10 +++ b/luasocket-3.0-rc1/src/options.c
12 return opt_setboolean(L, ps, SOL_SOCKET, SO_BROADCAST);
15 +#ifdef IPV6_UNICAST_HOPS
16 int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps)
18 return opt_setint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
21 return opt_getint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
25 +#ifdef IPV6_MULTICAST_HOPS
26 int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps)
28 return opt_setint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
31 return opt_getint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
35 int opt_set_ip_multicast_loop(lua_State *L, p_socket ps)
38 return opt_getboolean(L, ps, IPPROTO_IP, IP_MULTICAST_LOOP);
41 +#ifdef IPV6_MULTICAST_LOOP
42 int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps)
44 return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
47 return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
51 int opt_set_linger(lua_State *L, p_socket ps)
54 return opt_setmembership(L, ps, IPPROTO_IP, IP_DROP_MEMBERSHIP);
57 +#ifdef IPV6_ADD_MEMBERSHIP
58 int opt_set_ip6_add_membership(lua_State *L, p_socket ps)
60 return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP);
64 +#ifdef IPV6_DROP_MEMBERSHIP
65 int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps)
67 return opt_ip6_setmembership(L, ps, IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP);
72 int opt_get_ip6_v6only(lua_State *L, p_socket ps)
74 return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
77 return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
81 /*=========================================================================*\
83 Index: b/luasocket-3.0-rc1/src/options.h
84 ===================================================================
85 --- a/luasocket-3.0-rc1/src/options.h
86 +++ b/luasocket-3.0-rc1/src/options.h
88 int opt_set_ip_multicast_loop(lua_State *L, p_socket ps);
89 int opt_set_ip_add_membership(lua_State *L, p_socket ps);
90 int opt_set_ip_drop_membersip(lua_State *L, p_socket ps);
91 +#ifdef IPV6_UNICAST_HOPS
92 int opt_set_ip6_unicast_hops(lua_State *L, p_socket ps);
94 +#ifdef IPV6_MULTICAST_HOPS
95 int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps);
97 +#ifdef IPV6_MULTICAST_LOOP
98 int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps);
100 +#ifdef IPV6_ADD_MEMBERSHIP
101 int opt_set_ip6_add_membership(lua_State *L, p_socket ps);
103 +#ifdef IPV6_DROP_MEMBERSHIP
104 int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps);
107 int opt_set_ip6_v6only(lua_State *L, p_socket ps);
110 /* supported options for getoption */
111 int opt_get_reuseaddr(lua_State *L, p_socket ps);
113 int opt_get_ip_multicast_loop(lua_State *L, p_socket ps);
114 int opt_get_ip_multicast_if(lua_State *L, p_socket ps);
115 int opt_get_error(lua_State *L, p_socket ps);
116 +#ifdef IPV6_MULTICAST_LOOP
117 int opt_get_ip6_multicast_loop(lua_State *L, p_socket ps);
119 +#ifdef IPV6_MULTICAST_HOPS
120 int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps);
122 +#ifdef IPV6_UNICAST_HOPS
123 int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
126 int opt_get_ip6_v6only(lua_State *L, p_socket ps);
129 /* invokes the appropriate option handler */
130 int opt_meth_setoption(lua_State *L, p_opt opt, p_socket ps);
131 Index: b/luasocket-3.0-rc1/src/tcp.c
132 ===================================================================
133 --- a/luasocket-3.0-rc1/src/tcp.c
134 +++ b/luasocket-3.0-rc1/src/tcp.c
136 {"keepalive", opt_set_keepalive},
137 {"reuseaddr", opt_set_reuseaddr},
138 {"tcp-nodelay", opt_set_tcp_nodelay},
140 {"ipv6-v6only", opt_set_ip6_v6only},
142 {"linger", opt_set_linger},
145 @@ -366,11 +368,13 @@
146 auxiliar_setclass(L, "tcp{master}", -1);
147 /* initialize remaining structure fields */
148 socket_setnonblocking(&sock);
150 if (family == PF_INET6) {
152 setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
153 (void *)&yes, sizeof(yes));
157 io_init(&tcp->io, (p_send) socket_send, (p_recv) socket_recv,
158 (p_error) socket_ioerror, &tcp->sock);
159 Index: b/luasocket-3.0-rc1/src/udp.c
160 ===================================================================
161 --- a/luasocket-3.0-rc1/src/udp.c
162 +++ b/luasocket-3.0-rc1/src/udp.c
164 {"ip-multicast-loop", opt_set_ip_multicast_loop},
165 {"ip-add-membership", opt_set_ip_add_membership},
166 {"ip-drop-membership", opt_set_ip_drop_membersip},
167 +#ifdef IPV6_UNICAST_HOPS
168 {"ipv6-unicast-hops", opt_set_ip6_unicast_hops},
169 {"ipv6-multicast-hops", opt_set_ip6_unicast_hops},
171 +#ifdef IPV6_MULTICAST_LOOP
172 {"ipv6-multicast-loop", opt_set_ip6_multicast_loop},
174 +#ifdef IPV6_ADD_MEMBERSHIP
175 {"ipv6-add-membership", opt_set_ip6_add_membership},
177 +#ifdef IPV6_DROP_MEMBERSHIP
178 {"ipv6-drop-membership", opt_set_ip6_drop_membersip},
181 {"ipv6-v6only", opt_set_ip6_v6only},
187 {"ip-multicast-if", opt_get_ip_multicast_if},
188 {"ip-multicast-loop", opt_get_ip_multicast_loop},
189 {"error", opt_get_error},
190 +#ifdef IPV6_UNICAST_HOPS
191 {"ipv6-unicast-hops", opt_get_ip6_unicast_hops},
192 {"ipv6-multicast-hops", opt_get_ip6_unicast_hops},
194 +#ifdef IPV6_MULTICAST_LOOP
195 {"ipv6-multicast-loop", opt_get_ip6_multicast_loop},
198 {"ipv6-v6only", opt_get_ip6_v6only},
203 @@ -416,11 +432,13 @@
204 auxiliar_setclass(L, "udp{unconnected}", -1);
205 /* initialize remaining structure fields */
206 socket_setnonblocking(&sock);
208 if (family == PF_INET6) {
210 setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
211 (void *)&yes, sizeof(yes));
215 timeout_init(&udp->tm, -1, -1);
216 udp->family = family;