@@ -14,72 +14,57 @@ use libc::{c_int, c_void, size_t, sockaddr, socklen_t, EAI_SYSTEM, MSG_PEEK};
1414pub use crate :: sys:: { cvt, cvt_r} ;
1515
1616pub mod netc {
17- #[ cfg( target_os = "freertos" ) ]
18- mod lwip {
19- pub use libc:: {
20- c_int, c_void, c_char, c_long, c_ulong, size_t, ssize_t, AF_INET , AF_INET6 , sa_family_t, in_addr, sockaddr_in, in6_addr,
21- sockaddr_in6, sockaddr, socklen_t, FIONBIO , IPPROTO_IP , IPV6_JOIN_GROUP , IPPROTO_IPV6 , IP_TTL ,
22- ipv6_mreq, ip_mreq, IP_ADD_MEMBERSHIP , IPV6_MULTICAST_LOOP , IP_DROP_MEMBERSHIP , IP_MULTICAST_LOOP ,
23- IP_MULTICAST_TTL , SO_BROADCAST , SOL_SOCKET , SO_SNDTIMEO , SO_RCVTIMEO , SOCK_DGRAM , sockaddr_storage,
24- IPV6_V6ONLY , SOCK_STREAM , SO_REUSEADDR , addrinfo, IPV6_LEAVE_GROUP , IPV6_DROP_MEMBERSHIP , IPV6_ADD_MEMBERSHIP ,
25- iovec,
26- } ;
27-
28- extern "C" {
29- #[ link_name = "lwip_fcntl" ]
30- pub fn fcntl ( s : c_int , cmd : c_int , val : c_int ) -> c_int ;
31- #[ link_name = "lwip_close" ]
32- pub fn close ( s : c_int ) -> ssize_t ;
33- #[ link_name = "lwip_read" ]
34- pub fn read ( s : c_int , mem : * mut c_void , len : size_t ) -> ssize_t ;
35- #[ link_name = "lwip_readv" ]
36- pub fn readv ( s : c_int , iov : * const iovec , iovcnt : c_int ) -> ssize_t ;
37- #[ link_name = "lwip_write" ]
38- pub fn write ( s : c_int , dataptr : * const c_void , len : size_t ) -> ssize_t ;
39- #[ link_name = "lwip_writev" ]
40- pub fn writev ( s : c_int , iov : * const iovec , iovcnt : c_int ) -> ssize_t ;
41- #[ link_name = "lwip_accept" ]
42- pub fn accept ( s : c_int , addr : * mut sockaddr , addrlen : * mut socklen_t ) -> c_int ;
43- #[ link_name = "lwip_bind" ]
44- pub fn bind ( s : c_int , name : * const sockaddr , namelen : socklen_t ) -> c_int ;
45- #[ link_name = "lwip_connect" ]
46- pub fn connect ( s : c_int , name : * const sockaddr , namelen : socklen_t ) -> c_int ;
47- #[ link_name = "lwip_ioctl" ]
48- pub fn ioctl ( fd : c_int , request : c_ulong , ...) -> c_int ;
49- #[ link_name = "lwip_getaddrinfo" ]
50- pub fn getaddrinfo ( nodename : * const c_char , servname : * const c_char , hints : * const addrinfo , res : * mut * mut addrinfo ) -> c_int ;
51- #[ link_name = "lwip_freeaddrinfo" ]
52- pub fn freeaddrinfo ( ai : * mut addrinfo ) ;
53- #[ link_name = "lwip_getsockname" ]
54- pub fn getsockname ( s : c_int , name : * mut sockaddr , namelen : * mut socklen_t ) -> c_int ;
55- #[ link_name = "lwip_getpeername" ]
56- pub fn getpeername ( s : c_int , name : * mut sockaddr , namelen : * mut socklen_t ) -> c_int ;
57- #[ link_name = "lwip_listen" ]
58- pub fn listen ( s : c_int , backlog : c_int ) -> c_int ;
59- #[ link_name = "lwip_send" ]
60- pub fn send ( s : c_int , dataptr : * const c_void , size : size_t , flags : c_int ) -> ssize_t ;
61- #[ link_name = "lwip_sendto" ]
62- pub fn sendto ( s : c_int , dataptr : * const c_void , size : size_t , flags : c_int , to : * const sockaddr , tolen : socklen_t ) -> ssize_t ;
63- #[ link_name = "lwip_recv" ]
64- pub fn recv ( s : c_int , mem : * mut c_void , len : size_t , flags : c_int ) -> ssize_t ;
65- #[ link_name = "lwip_recvfrom" ]
66- pub fn recvfrom ( s : c_int , mem : * mut c_void , len : size_t , flags : c_int , from : * mut sockaddr , fromlen : * mut socklen_t ) -> ssize_t ;
67- #[ link_name = "lwip_getsockopt" ]
68- pub fn getsockopt ( s : c_int , level : c_int , optname : c_int , optval : * mut c_void , optlen : * mut socklen_t ) -> c_int ;
69- #[ link_name = "lwip_setsockopt" ]
70- pub fn setsockopt ( s : c_int , level : c_int , optname : c_int , optval : * const c_void , optlen : socklen_t ) -> c_int ;
71- #[ link_name = "lwip_shutdown" ]
72- pub fn shutdown ( s : c_int , how : c_int ) -> c_int ;
73- #[ link_name = "lwip_socket" ]
74- pub fn socket ( domain : c_int , r#type : c_int , protocol : c_int ) -> c_int ;
75- }
76- }
17+ pub use libc:: * ;
7718
7819 #[ cfg( target_os = "freertos" ) ]
79- pub use lwip:: * ;
80-
81- #[ cfg( not( target_os = "freertos" ) ) ]
82- pub use libc:: * ;
20+ extern "C" {
21+ #[ link_name = "lwip_fcntl" ]
22+ pub fn fcntl ( s : c_int , cmd : c_int , val : c_int ) -> c_int ;
23+ #[ link_name = "lwip_close" ]
24+ pub fn close ( s : c_int ) -> ssize_t ;
25+ #[ link_name = "lwip_read" ]
26+ pub fn read ( s : c_int , mem : * mut c_void , len : size_t ) -> ssize_t ;
27+ #[ link_name = "lwip_readv" ]
28+ pub fn readv ( s : c_int , iov : * const iovec , iovcnt : c_int ) -> ssize_t ;
29+ #[ link_name = "lwip_write" ]
30+ pub fn write ( s : c_int , dataptr : * const c_void , len : size_t ) -> ssize_t ;
31+ #[ link_name = "lwip_writev" ]
32+ pub fn writev ( s : c_int , iov : * const iovec , iovcnt : c_int ) -> ssize_t ;
33+ #[ link_name = "lwip_accept" ]
34+ pub fn accept ( s : c_int , addr : * mut sockaddr , addrlen : * mut socklen_t ) -> c_int ;
35+ #[ link_name = "lwip_bind" ]
36+ pub fn bind ( s : c_int , name : * const sockaddr , namelen : socklen_t ) -> c_int ;
37+ #[ link_name = "lwip_connect" ]
38+ pub fn connect ( s : c_int , name : * const sockaddr , namelen : socklen_t ) -> c_int ;
39+ #[ link_name = "lwip_ioctl" ]
40+ pub fn ioctl ( fd : c_int , request : c_ulong , ...) -> c_int ;
41+ #[ link_name = "lwip_getaddrinfo" ]
42+ pub fn getaddrinfo ( nodename : * const c_char , servname : * const c_char , hints : * const addrinfo , res : * mut * mut addrinfo ) -> c_int ;
43+ #[ link_name = "lwip_freeaddrinfo" ]
44+ pub fn freeaddrinfo ( ai : * mut addrinfo ) ;
45+ #[ link_name = "lwip_getsockname" ]
46+ pub fn getsockname ( s : c_int , name : * mut sockaddr , namelen : * mut socklen_t ) -> c_int ;
47+ #[ link_name = "lwip_getpeername" ]
48+ pub fn getpeername ( s : c_int , name : * mut sockaddr , namelen : * mut socklen_t ) -> c_int ;
49+ #[ link_name = "lwip_listen" ]
50+ pub fn listen ( s : c_int , backlog : c_int ) -> c_int ;
51+ #[ link_name = "lwip_send" ]
52+ pub fn send ( s : c_int , dataptr : * const c_void , size : size_t , flags : c_int ) -> ssize_t ;
53+ #[ link_name = "lwip_sendto" ]
54+ pub fn sendto ( s : c_int , dataptr : * const c_void , size : size_t , flags : c_int , to : * const sockaddr , tolen : socklen_t ) -> ssize_t ;
55+ #[ link_name = "lwip_recv" ]
56+ pub fn recv ( s : c_int , mem : * mut c_void , len : size_t , flags : c_int ) -> ssize_t ;
57+ #[ link_name = "lwip_recvfrom" ]
58+ pub fn recvfrom ( s : c_int , mem : * mut c_void , len : size_t , flags : c_int , from : * mut sockaddr , fromlen : * mut socklen_t ) -> ssize_t ;
59+ #[ link_name = "lwip_getsockopt" ]
60+ pub fn getsockopt ( s : c_int , level : c_int , optname : c_int , optval : * mut c_void , optlen : * mut socklen_t ) -> c_int ;
61+ #[ link_name = "lwip_setsockopt" ]
62+ pub fn setsockopt ( s : c_int , level : c_int , optname : c_int , optval : * const c_void , optlen : socklen_t ) -> c_int ;
63+ #[ link_name = "lwip_shutdown" ]
64+ pub fn shutdown ( s : c_int , how : c_int ) -> c_int ;
65+ #[ link_name = "lwip_socket" ]
66+ pub fn socket ( domain : c_int , r#type : c_int , protocol : c_int ) -> c_int ;
67+ }
8368}
8469
8570pub type wrlen_t = size_t ;
0 commit comments