]>
Commit | Line | Data |
---|---|---|
ea8adc8c | 1 | macro_rules! unimpl { |
60c5eb7d | 2 | () => { |
cdc7bbd5 XL |
3 | return Err(io::Error::new_const( |
4 | io::ErrorKind::Unsupported, | |
5 | &"No networking available on L4Re.", | |
6 | )); | |
60c5eb7d | 7 | }; |
ea8adc8c XL |
8 | } |
9 | ||
10 | pub mod net { | |
11 | #![allow(warnings)] | |
60c5eb7d | 12 | use crate::convert::TryFrom; |
532ac7d7 | 13 | use crate::fmt; |
48663c56 | 14 | use crate::io::{self, IoSlice, IoSliceMut}; |
60c5eb7d | 15 | use crate::net::{Ipv4Addr, Ipv6Addr, Shutdown, SocketAddr}; |
532ac7d7 | 16 | use crate::sys::fd::FileDesc; |
60c5eb7d | 17 | use crate::sys_common::{AsInner, FromInner, IntoInner}; |
532ac7d7 | 18 | use crate::time::Duration; |
532ac7d7 XL |
19 | |
20 | #[allow(unused_extern_crates)] | |
ea8adc8c XL |
21 | pub extern crate libc as netc; |
22 | ||
23 | pub struct Socket(FileDesc); | |
24 | impl Socket { | |
25 | pub fn new(_: &SocketAddr, _: libc::c_int) -> io::Result<Socket> { | |
26 | unimpl!(); | |
27 | } | |
28 | ||
29 | pub fn new_raw(_: libc::c_int, _: libc::c_int) -> io::Result<Socket> { | |
30 | unimpl!(); | |
31 | } | |
32 | ||
33 | pub fn new_pair(_: libc::c_int, _: libc::c_int) -> io::Result<(Socket, Socket)> { | |
34 | unimpl!(); | |
35 | } | |
36 | ||
37 | pub fn connect_timeout(&self, _: &SocketAddr, _: Duration) -> io::Result<()> { | |
38 | unimpl!(); | |
39 | } | |
40 | ||
60c5eb7d XL |
41 | pub fn accept( |
42 | &self, | |
43 | _: *mut libc::sockaddr, | |
44 | _: *mut libc::socklen_t, | |
45 | ) -> io::Result<Socket> { | |
ea8adc8c XL |
46 | unimpl!(); |
47 | } | |
48 | ||
49 | pub fn duplicate(&self) -> io::Result<Socket> { | |
50 | unimpl!(); | |
51 | } | |
52 | ||
53 | pub fn read(&self, _: &mut [u8]) -> io::Result<usize> { | |
54 | unimpl!(); | |
55 | } | |
56 | ||
48663c56 | 57 | pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result<usize> { |
9fa01778 XL |
58 | unimpl!(); |
59 | } | |
60 | ||
f9f354fc XL |
61 | pub fn is_read_vectored(&self) -> bool { |
62 | unimpl!(); | |
63 | } | |
64 | ||
ea8adc8c XL |
65 | pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> { |
66 | unimpl!(); | |
67 | } | |
68 | ||
69 | pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { | |
70 | unimpl!(); | |
71 | } | |
72 | ||
73 | pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { | |
74 | unimpl!(); | |
75 | } | |
76 | ||
77 | pub fn write(&self, _: &[u8]) -> io::Result<usize> { | |
78 | unimpl!(); | |
79 | } | |
80 | ||
48663c56 | 81 | pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result<usize> { |
9fa01778 XL |
82 | unimpl!(); |
83 | } | |
84 | ||
f9f354fc XL |
85 | pub fn is_write_vectored(&self) -> bool { |
86 | unimpl!(); | |
87 | } | |
88 | ||
ea8adc8c XL |
89 | pub fn set_timeout(&self, _: Option<Duration>, _: libc::c_int) -> io::Result<()> { |
90 | unimpl!(); | |
91 | } | |
92 | ||
93 | pub fn timeout(&self, _: libc::c_int) -> io::Result<Option<Duration>> { | |
94 | unimpl!(); | |
95 | } | |
96 | ||
97 | pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { | |
98 | unimpl!(); | |
99 | } | |
100 | ||
94222f64 XL |
101 | pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> { |
102 | unimpl!(); | |
103 | } | |
104 | ||
105 | pub fn linger(&self) -> io::Result<Option<Duration>> { | |
106 | unimpl!(); | |
107 | } | |
108 | ||
ea8adc8c XL |
109 | pub fn set_nodelay(&self, _: bool) -> io::Result<()> { |
110 | unimpl!(); | |
111 | } | |
112 | ||
113 | pub fn nodelay(&self) -> io::Result<bool> { | |
114 | unimpl!(); | |
115 | } | |
116 | ||
117 | pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { | |
118 | unimpl!(); | |
119 | } | |
120 | ||
121 | pub fn take_error(&self) -> io::Result<Option<io::Error>> { | |
122 | unimpl!(); | |
123 | } | |
124 | } | |
125 | ||
126 | impl AsInner<libc::c_int> for Socket { | |
60c5eb7d XL |
127 | fn as_inner(&self) -> &libc::c_int { |
128 | self.0.as_inner() | |
129 | } | |
ea8adc8c XL |
130 | } |
131 | ||
132 | impl FromInner<libc::c_int> for Socket { | |
60c5eb7d XL |
133 | fn from_inner(fd: libc::c_int) -> Socket { |
134 | Socket(FileDesc::new(fd)) | |
135 | } | |
ea8adc8c XL |
136 | } |
137 | ||
138 | impl IntoInner<libc::c_int> for Socket { | |
60c5eb7d XL |
139 | fn into_inner(self) -> libc::c_int { |
140 | self.0.into_raw() | |
141 | } | |
ea8adc8c XL |
142 | } |
143 | ||
144 | pub struct TcpStream { | |
145 | inner: Socket, | |
146 | } | |
147 | ||
148 | impl TcpStream { | |
0731742a | 149 | pub fn connect(_: io::Result<&SocketAddr>) -> io::Result<TcpStream> { |
ea8adc8c XL |
150 | unimpl!(); |
151 | } | |
152 | ||
153 | pub fn connect_timeout(_: &SocketAddr, _: Duration) -> io::Result<TcpStream> { | |
154 | unimpl!(); | |
155 | } | |
156 | ||
60c5eb7d XL |
157 | pub fn socket(&self) -> &Socket { |
158 | &self.inner | |
159 | } | |
ea8adc8c | 160 | |
60c5eb7d XL |
161 | pub fn into_socket(self) -> Socket { |
162 | self.inner | |
163 | } | |
ea8adc8c XL |
164 | |
165 | pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> { | |
166 | unimpl!(); | |
167 | } | |
168 | ||
169 | pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> { | |
170 | unimpl!(); | |
171 | } | |
172 | ||
173 | pub fn read_timeout(&self) -> io::Result<Option<Duration>> { | |
174 | unimpl!(); | |
175 | } | |
176 | ||
177 | pub fn write_timeout(&self) -> io::Result<Option<Duration>> { | |
178 | unimpl!(); | |
179 | } | |
180 | ||
181 | pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> { | |
182 | unimpl!(); | |
183 | } | |
184 | ||
185 | pub fn read(&self, _: &mut [u8]) -> io::Result<usize> { | |
186 | unimpl!(); | |
187 | } | |
188 | ||
48663c56 | 189 | pub fn read_vectored(&self, _: &mut [IoSliceMut<'_>]) -> io::Result<usize> { |
9fa01778 XL |
190 | unimpl!(); |
191 | } | |
192 | ||
f9f354fc XL |
193 | pub fn is_read_vectored(&self) -> bool { |
194 | unimpl!(); | |
195 | } | |
196 | ||
ea8adc8c XL |
197 | pub fn write(&self, _: &[u8]) -> io::Result<usize> { |
198 | unimpl!(); | |
199 | } | |
200 | ||
48663c56 | 201 | pub fn write_vectored(&self, _: &[IoSlice<'_>]) -> io::Result<usize> { |
9fa01778 XL |
202 | unimpl!(); |
203 | } | |
204 | ||
f9f354fc XL |
205 | pub fn is_write_vectored(&self) -> bool { |
206 | unimpl!(); | |
207 | } | |
208 | ||
ea8adc8c XL |
209 | pub fn peer_addr(&self) -> io::Result<SocketAddr> { |
210 | unimpl!(); | |
211 | } | |
212 | ||
213 | pub fn socket_addr(&self) -> io::Result<SocketAddr> { | |
214 | unimpl!(); | |
215 | } | |
216 | ||
217 | pub fn shutdown(&self, _: Shutdown) -> io::Result<()> { | |
218 | unimpl!(); | |
219 | } | |
220 | ||
221 | pub fn duplicate(&self) -> io::Result<TcpStream> { | |
222 | unimpl!(); | |
223 | } | |
224 | ||
94222f64 XL |
225 | pub fn set_linger(&self, _: Option<Duration>) -> io::Result<()> { |
226 | unimpl!(); | |
227 | } | |
228 | ||
229 | pub fn linger(&self) -> io::Result<Option<Duration>> { | |
230 | unimpl!(); | |
231 | } | |
232 | ||
ea8adc8c XL |
233 | pub fn set_nodelay(&self, _: bool) -> io::Result<()> { |
234 | unimpl!(); | |
235 | } | |
236 | ||
237 | pub fn nodelay(&self) -> io::Result<bool> { | |
238 | unimpl!(); | |
239 | } | |
240 | ||
241 | pub fn set_ttl(&self, _: u32) -> io::Result<()> { | |
242 | unimpl!(); | |
243 | } | |
244 | ||
245 | pub fn ttl(&self) -> io::Result<u32> { | |
246 | unimpl!(); | |
247 | } | |
248 | ||
249 | pub fn take_error(&self) -> io::Result<Option<io::Error>> { | |
250 | unimpl!(); | |
251 | } | |
252 | ||
253 | pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { | |
254 | unimpl!(); | |
255 | } | |
256 | } | |
257 | ||
258 | impl FromInner<Socket> for TcpStream { | |
259 | fn from_inner(socket: Socket) -> TcpStream { | |
260 | TcpStream { inner: socket } | |
261 | } | |
262 | } | |
263 | ||
264 | impl fmt::Debug for TcpStream { | |
532ac7d7 | 265 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
ea8adc8c XL |
266 | write!(f, "No networking support available on L4Re") |
267 | } | |
268 | } | |
269 | ||
270 | pub struct TcpListener { | |
271 | inner: Socket, | |
272 | } | |
273 | ||
274 | impl TcpListener { | |
0731742a | 275 | pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<TcpListener> { |
ea8adc8c XL |
276 | unimpl!(); |
277 | } | |
278 | ||
60c5eb7d XL |
279 | pub fn socket(&self) -> &Socket { |
280 | &self.inner | |
281 | } | |
ea8adc8c | 282 | |
60c5eb7d XL |
283 | pub fn into_socket(self) -> Socket { |
284 | self.inner | |
285 | } | |
ea8adc8c XL |
286 | |
287 | pub fn socket_addr(&self) -> io::Result<SocketAddr> { | |
288 | unimpl!(); | |
289 | } | |
290 | ||
291 | pub fn accept(&self) -> io::Result<(TcpStream, SocketAddr)> { | |
292 | unimpl!(); | |
293 | } | |
294 | ||
295 | pub fn duplicate(&self) -> io::Result<TcpListener> { | |
296 | unimpl!(); | |
297 | } | |
298 | ||
299 | pub fn set_ttl(&self, _: u32) -> io::Result<()> { | |
300 | unimpl!(); | |
301 | } | |
302 | ||
303 | pub fn ttl(&self) -> io::Result<u32> { | |
304 | unimpl!(); | |
305 | } | |
306 | ||
307 | pub fn set_only_v6(&self, _: bool) -> io::Result<()> { | |
308 | unimpl!(); | |
309 | } | |
310 | ||
311 | pub fn only_v6(&self) -> io::Result<bool> { | |
312 | unimpl!(); | |
313 | } | |
314 | ||
315 | pub fn take_error(&self) -> io::Result<Option<io::Error>> { | |
316 | unimpl!(); | |
317 | } | |
318 | ||
319 | pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { | |
320 | unimpl!(); | |
321 | } | |
322 | } | |
323 | ||
324 | impl FromInner<Socket> for TcpListener { | |
325 | fn from_inner(socket: Socket) -> TcpListener { | |
326 | TcpListener { inner: socket } | |
327 | } | |
328 | } | |
329 | ||
330 | impl fmt::Debug for TcpListener { | |
532ac7d7 | 331 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
ea8adc8c XL |
332 | write!(f, "No networking support available on L4Re.") |
333 | } | |
334 | } | |
335 | ||
336 | pub struct UdpSocket { | |
337 | inner: Socket, | |
338 | } | |
339 | ||
340 | impl UdpSocket { | |
0731742a | 341 | pub fn bind(_: io::Result<&SocketAddr>) -> io::Result<UdpSocket> { |
ea8adc8c XL |
342 | unimpl!(); |
343 | } | |
344 | ||
60c5eb7d XL |
345 | pub fn socket(&self) -> &Socket { |
346 | &self.inner | |
347 | } | |
ea8adc8c | 348 | |
60c5eb7d XL |
349 | pub fn into_socket(self) -> Socket { |
350 | self.inner | |
351 | } | |
ea8adc8c | 352 | |
532ac7d7 XL |
353 | pub fn peer_addr(&self) -> io::Result<SocketAddr> { |
354 | unimpl!(); | |
355 | } | |
356 | ||
ea8adc8c XL |
357 | pub fn socket_addr(&self) -> io::Result<SocketAddr> { |
358 | unimpl!(); | |
359 | } | |
360 | ||
361 | pub fn recv_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { | |
362 | unimpl!(); | |
363 | } | |
364 | ||
365 | pub fn peek_from(&self, _: &mut [u8]) -> io::Result<(usize, SocketAddr)> { | |
366 | unimpl!(); | |
367 | } | |
368 | ||
369 | pub fn send_to(&self, _: &[u8], _: &SocketAddr) -> io::Result<usize> { | |
370 | unimpl!(); | |
371 | } | |
372 | ||
373 | pub fn duplicate(&self) -> io::Result<UdpSocket> { | |
374 | unimpl!(); | |
375 | } | |
376 | ||
377 | pub fn set_read_timeout(&self, _: Option<Duration>) -> io::Result<()> { | |
378 | unimpl!(); | |
379 | } | |
380 | ||
381 | pub fn set_write_timeout(&self, _: Option<Duration>) -> io::Result<()> { | |
382 | unimpl!(); | |
383 | } | |
384 | ||
385 | pub fn read_timeout(&self) -> io::Result<Option<Duration>> { | |
386 | unimpl!(); | |
387 | } | |
388 | ||
389 | pub fn write_timeout(&self) -> io::Result<Option<Duration>> { | |
390 | unimpl!(); | |
391 | } | |
392 | ||
393 | pub fn set_broadcast(&self, _: bool) -> io::Result<()> { | |
394 | unimpl!(); | |
395 | } | |
396 | ||
397 | pub fn broadcast(&self) -> io::Result<bool> { | |
398 | unimpl!(); | |
399 | } | |
400 | ||
401 | pub fn set_multicast_loop_v4(&self, _: bool) -> io::Result<()> { | |
402 | unimpl!(); | |
403 | } | |
404 | ||
405 | pub fn multicast_loop_v4(&self) -> io::Result<bool> { | |
406 | unimpl!(); | |
407 | } | |
408 | ||
409 | pub fn set_multicast_ttl_v4(&self, _: u32) -> io::Result<()> { | |
410 | unimpl!(); | |
411 | } | |
412 | ||
413 | pub fn multicast_ttl_v4(&self) -> io::Result<u32> { | |
414 | unimpl!(); | |
415 | } | |
416 | ||
417 | pub fn set_multicast_loop_v6(&self, _: bool) -> io::Result<()> { | |
418 | unimpl!(); | |
419 | } | |
420 | ||
421 | pub fn multicast_loop_v6(&self) -> io::Result<bool> { | |
422 | unimpl!(); | |
423 | } | |
424 | ||
60c5eb7d XL |
425 | pub fn join_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { |
426 | unimpl!(); | |
ea8adc8c XL |
427 | } |
428 | ||
60c5eb7d XL |
429 | pub fn join_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { |
430 | unimpl!(); | |
ea8adc8c XL |
431 | } |
432 | ||
60c5eb7d XL |
433 | pub fn leave_multicast_v4(&self, _: &Ipv4Addr, _: &Ipv4Addr) -> io::Result<()> { |
434 | unimpl!(); | |
ea8adc8c XL |
435 | } |
436 | ||
60c5eb7d XL |
437 | pub fn leave_multicast_v6(&self, _: &Ipv6Addr, _: u32) -> io::Result<()> { |
438 | unimpl!(); | |
ea8adc8c XL |
439 | } |
440 | ||
441 | pub fn set_ttl(&self, _: u32) -> io::Result<()> { | |
442 | unimpl!(); | |
443 | } | |
444 | ||
445 | pub fn ttl(&self) -> io::Result<u32> { | |
446 | unimpl!(); | |
447 | } | |
448 | ||
449 | pub fn take_error(&self) -> io::Result<Option<io::Error>> { | |
450 | unimpl!(); | |
451 | } | |
452 | ||
453 | pub fn set_nonblocking(&self, _: bool) -> io::Result<()> { | |
454 | unimpl!(); | |
455 | } | |
456 | ||
457 | pub fn recv(&self, _: &mut [u8]) -> io::Result<usize> { | |
458 | unimpl!(); | |
459 | } | |
460 | ||
461 | pub fn peek(&self, _: &mut [u8]) -> io::Result<usize> { | |
462 | unimpl!(); | |
463 | } | |
464 | ||
465 | pub fn send(&self, _: &[u8]) -> io::Result<usize> { | |
466 | unimpl!(); | |
467 | } | |
468 | ||
0731742a | 469 | pub fn connect(&self, _: io::Result<&SocketAddr>) -> io::Result<()> { |
ea8adc8c XL |
470 | unimpl!(); |
471 | } | |
472 | } | |
473 | ||
474 | impl FromInner<Socket> for UdpSocket { | |
475 | fn from_inner(socket: Socket) -> UdpSocket { | |
476 | UdpSocket { inner: socket } | |
477 | } | |
478 | } | |
479 | ||
480 | impl fmt::Debug for UdpSocket { | |
532ac7d7 | 481 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
ea8adc8c XL |
482 | write!(f, "No networking support on L4Re available.") |
483 | } | |
484 | } | |
485 | ||
486 | pub struct LookupHost { | |
487 | original: *mut libc::addrinfo, | |
488 | cur: *mut libc::addrinfo, | |
489 | } | |
490 | ||
491 | impl Iterator for LookupHost { | |
492 | type Item = SocketAddr; | |
493 | fn next(&mut self) -> Option<SocketAddr> { | |
494 | None | |
495 | } | |
496 | } | |
497 | ||
0731742a XL |
498 | impl LookupHost { |
499 | pub fn port(&self) -> u16 { | |
500 | unimpl!(); | |
501 | } | |
502 | } | |
503 | ||
ea8adc8c XL |
504 | unsafe impl Sync for LookupHost {} |
505 | unsafe impl Send for LookupHost {} | |
506 | ||
532ac7d7 | 507 | impl TryFrom<&str> for LookupHost { |
0731742a XL |
508 | type Error = io::Error; |
509 | ||
532ac7d7 | 510 | fn try_from(_v: &str) -> io::Result<LookupHost> { |
0731742a XL |
511 | unimpl!(); |
512 | } | |
513 | } | |
514 | ||
515 | impl<'a> TryFrom<(&'a str, u16)> for LookupHost { | |
516 | type Error = io::Error; | |
517 | ||
518 | fn try_from(_v: (&'a str, u16)) -> io::Result<LookupHost> { | |
519 | unimpl!(); | |
520 | } | |
ea8adc8c | 521 | } |
ea8adc8c | 522 | } |