open-plc-utils: new package
[buildroot-gz.git] / package / luasocket / 0001-uClibc-IPv6.patch
blobae70b4dbc103b46319bd81a8b1ee69ae3453d5e4
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
11 @@ -110,6 +110,7 @@
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);
19 @@ -119,7 +120,9 @@
21 return opt_getint(L, ps, IPPROTO_IPV6, IPV6_UNICAST_HOPS);
23 +#endif
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);
29 @@ -129,6 +132,7 @@
31 return opt_getint(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_HOPS);
33 +#endif
35 int opt_set_ip_multicast_loop(lua_State *L, p_socket ps)
37 @@ -140,6 +144,7 @@
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);
45 @@ -149,6 +154,7 @@
47 return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_MULTICAST_LOOP);
49 +#endif
51 int opt_set_linger(lua_State *L, p_socket ps)
53 @@ -221,16 +227,21 @@
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);
62 +#endif
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);
69 +#endif
71 +#ifdef IPV6_V6ONLY
72 int opt_get_ip6_v6only(lua_State *L, p_socket ps)
74 return opt_getboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
75 @@ -240,6 +251,7 @@
77 return opt_setboolean(L, ps, IPPROTO_IPV6, IPV6_V6ONLY);
79 +#endif
81 /*=========================================================================*\
82 * Auxiliar functions
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
87 @@ -32,12 +32,24 @@
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);
93 +#endif
94 +#ifdef IPV6_MULTICAST_HOPS
95 int opt_set_ip6_multicast_hops(lua_State *L, p_socket ps);
96 +#endif
97 +#ifdef IPV6_MULTICAST_LOOP
98 int opt_set_ip6_multicast_loop(lua_State *L, p_socket ps);
99 +#endif
100 +#ifdef IPV6_ADD_MEMBERSHIP
101 int opt_set_ip6_add_membership(lua_State *L, p_socket ps);
102 +#endif
103 +#ifdef IPV6_DROP_MEMBERSHIP
104 int opt_set_ip6_drop_membersip(lua_State *L, p_socket ps);
105 +#endif
106 +#ifdef IPV6_V6ONLY
107 int opt_set_ip6_v6only(lua_State *L, p_socket ps);
108 +#endif
110 /* supported options for getoption */
111 int opt_get_reuseaddr(lua_State *L, p_socket ps);
112 @@ -48,10 +60,18 @@
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);
118 +#endif
119 +#ifdef IPV6_MULTICAST_HOPS
120 int opt_get_ip6_multicast_hops(lua_State *L, p_socket ps);
121 +#endif
122 +#ifdef IPV6_UNICAST_HOPS
123 int opt_get_ip6_unicast_hops(lua_State *L, p_socket ps);
124 +#endif
125 +#ifdef IPV6_V6ONLY
126 int opt_get_ip6_v6only(lua_State *L, p_socket ps);
127 +#endif
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
135 @@ -81,7 +81,9 @@
136 {"keepalive", opt_set_keepalive},
137 {"reuseaddr", opt_set_reuseaddr},
138 {"tcp-nodelay", opt_set_tcp_nodelay},
139 +#ifdef IPV6_V6ONLY
140 {"ipv6-v6only", opt_set_ip6_v6only},
141 +#endif
142 {"linger", opt_set_linger},
143 {NULL, NULL}
145 @@ -366,11 +368,13 @@
146 auxiliar_setclass(L, "tcp{master}", -1);
147 /* initialize remaining structure fields */
148 socket_setnonblocking(&sock);
149 +#ifdef IPV6_V6ONLY
150 if (family == PF_INET6) {
151 int yes = 1;
152 setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
153 (void *)&yes, sizeof(yes));
155 +#endif
156 tcp->sock = sock;
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
163 @@ -78,12 +78,22 @@
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},
170 +#endif
171 +#ifdef IPV6_MULTICAST_LOOP
172 {"ipv6-multicast-loop", opt_set_ip6_multicast_loop},
173 +#endif
174 +#ifdef IPV6_ADD_MEMBERSHIP
175 {"ipv6-add-membership", opt_set_ip6_add_membership},
176 +#endif
177 +#ifdef IPV6_DROP_MEMBERSHIP
178 {"ipv6-drop-membership", opt_set_ip6_drop_membersip},
179 +#endif
180 +#ifdef IPV6_V6ONLY
181 {"ipv6-v6only", opt_set_ip6_v6only},
182 +#endif
183 {NULL, NULL}
186 @@ -92,10 +102,16 @@
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},
193 +#endif
194 +#ifdef IPV6_MULTICAST_LOOP
195 {"ipv6-multicast-loop", opt_get_ip6_multicast_loop},
196 +#endif
197 +#ifdef IPV6_V6ONLY
198 {"ipv6-v6only", opt_get_ip6_v6only},
199 +#endif
200 {NULL, NULL}
203 @@ -416,11 +432,13 @@
204 auxiliar_setclass(L, "udp{unconnected}", -1);
205 /* initialize remaining structure fields */
206 socket_setnonblocking(&sock);
207 +#ifdef IPV6_V6ONLY
208 if (family == PF_INET6) {
209 int yes = 1;
210 setsockopt(sock, IPPROTO_IPV6, IPV6_V6ONLY,
211 (void *)&yes, sizeof(yes));
213 +#endif
214 udp->sock = sock;
215 timeout_init(&udp->tm, -1, -1);
216 udp->family = family;