Skip to content

Commit 138e41d

Browse files
committed
WIP: add socket constants already present in libc
1 parent a29c9d7 commit 138e41d

File tree

2 files changed

+192
-5
lines changed

2 files changed

+192
-5
lines changed

src/sys/socket/addr.rs

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,196 @@ pub enum AddressFamily {
3232
Packet = libc::AF_PACKET,
3333
#[cfg(any(target_os = "macos", target_os = "ios"))]
3434
System = libc::AF_SYSTEM,
35+
#[cfg(any(target_os = "linux", target_os = "android"))]
36+
Ax25 = libc::AF_AX25,
37+
Ipx = libc::AF_IPX,
38+
AppleTalk = libc::AF_APPLETALK,
39+
#[cfg(any(target_os = "linux", target_os = "android"))]
40+
NetRom = libc::AF_NETROM,
41+
#[cfg(any(target_os = "linux", target_os = "android"))]
42+
Bridge = libc::AF_BRIDGE,
43+
#[cfg(any(target_os = "linux", target_os = "android"))]
44+
AtmPvc = libc::AF_ATMPVC,
45+
#[cfg(any(target_os = "linux", target_os = "android"))]
46+
X25 = libc::AF_X25,
47+
#[cfg(any(target_os = "linux", target_os = "android"))]
48+
Rose = libc::AF_ROSE,
49+
Decnet = libc::AF_DECnet,
50+
#[cfg(any(target_os = "linux", target_os = "android"))]
51+
NetBeui = libc::AF_NETBEUI,
52+
#[cfg(any(target_os = "linux", target_os = "android"))]
53+
Security = libc::AF_SECURITY,
54+
#[cfg(any(target_os = "linux", target_os = "android"))]
55+
Key = libc::AF_KEY,
56+
#[cfg(any(target_os = "linux", target_os = "android"))]
57+
Ash = libc::AF_ASH,
58+
#[cfg(any(target_os = "linux", target_os = "android"))]
59+
Econet = libc::AF_ECONET,
60+
#[cfg(any(target_os = "linux", target_os = "android"))]
61+
AtmSvc = libc::AF_ATMSVC,
62+
#[cfg(any(target_os = "linux", target_os = "android"))]
63+
Rds = libc::AF_RDS,
64+
Sna = libc::AF_SNA,
65+
#[cfg(any(target_os = "linux", target_os = "android"))]
66+
Irda = libc::AF_IRDA,
67+
#[cfg(any(target_os = "linux", target_os = "android"))]
68+
Pppox = libc::AF_PPPOX,
69+
#[cfg(any(target_os = "linux", target_os = "android"))]
70+
Wanpipe = libc::AF_WANPIPE,
71+
#[cfg(any(target_os = "linux", target_os = "android"))]
72+
Llc = libc::AF_LLC,
73+
#[cfg(target_os = "linux")]
74+
Ib = libc::AF_IB,
75+
#[cfg(target_os = "linux")]
76+
Mpls = libc::AF_MPLS,
77+
#[cfg(any(target_os = "linux", target_os = "android"))]
78+
Can = libc::AF_CAN,
79+
#[cfg(any(target_os = "linux", target_os = "android"))]
80+
Tipc = libc::AF_TIPC,
81+
Bluetooth = libc::AF_BLUETOOTH,
82+
#[cfg(any(target_os = "linux", target_os = "android"))]
83+
Iucv = libc::AF_IUCV,
84+
#[cfg(any(target_os = "linux", target_os = "android"))]
85+
RxRpc = libc::AF_RXRPC,
86+
Isdn = libc::AF_ISDN,
87+
#[cfg(any(target_os = "linux", target_os = "android"))]
88+
Phonet = libc::AF_PHONET,
89+
#[cfg(any(target_os = "linux", target_os = "android"))]
90+
Ieee802154 = libc::AF_IEEE802154,
91+
#[cfg(any(target_os = "linux", target_os = "android"))]
92+
Caif = libc::AF_CAIF,
93+
#[cfg(any(target_os = "linux", target_os = "android"))]
94+
Alg = libc::AF_ALG,
95+
#[cfg(target_os = "linux")]
96+
Nfc = libc::AF_NFC,
97+
#[cfg(target_os = "linux")]
98+
Vsock = libc::AF_VSOCK,
99+
#[cfg(any(target_os = "macos",
100+
target_os = "ios",
101+
target_os = "freebsd",
102+
target_os = "netbsd",
103+
target_os = "openbsd",
104+
target_os = "dragonfly"))]
105+
ImpLink = libc::AF_IMPLINK,
106+
#[cfg(any(target_os = "macos",
107+
target_os = "ios",
108+
target_os = "freebsd",
109+
target_os = "netbsd",
110+
target_os = "openbsd",
111+
target_os = "dragonfly"))]
112+
Pup = libc::AF_PUP,
113+
#[cfg(any(target_os = "macos",
114+
target_os = "ios",
115+
target_os = "freebsd",
116+
target_os = "netbsd",
117+
target_os = "openbsd",
118+
target_os = "dragonfly"))]
119+
Chaos = libc::AF_CHAOS,
120+
#[cfg(any(target_os = "macos",
121+
target_os = "ios",
122+
target_os = "freebsd",
123+
target_os = "netbsd",
124+
target_os = "openbsd",
125+
target_os = "dragonfly"))]
126+
Ns = libc::AF_NS,
127+
#[cfg(any(target_os = "macos",
128+
target_os = "ios",
129+
target_os = "freebsd",
130+
target_os = "netbsd",
131+
target_os = "openbsd",
132+
target_os = "dragonfly"))]
133+
Iso = libc::AF_ISO,
134+
#[cfg(any(target_os = "macos",
135+
target_os = "ios",
136+
target_os = "freebsd",
137+
target_os = "netbsd",
138+
target_os = "openbsd",
139+
target_os = "dragonfly"))]
140+
Osi = libc::AF_OSI,
141+
#[cfg(any(target_os = "macos",
142+
target_os = "ios",
143+
target_os = "freebsd",
144+
target_os = "netbsd",
145+
target_os = "openbsd",
146+
target_os = "dragonfly"))]
147+
Datakit = libc::AF_DATAKIT,
148+
#[cfg(any(target_os = "macos",
149+
target_os = "ios",
150+
target_os = "freebsd",
151+
target_os = "netbsd",
152+
target_os = "openbsd",
153+
target_os = "dragonfly"))]
154+
Ccitt = libc::AF_CCITT,
155+
#[cfg(any(target_os = "macos",
156+
target_os = "ios",
157+
target_os = "freebsd",
158+
target_os = "netbsd",
159+
target_os = "openbsd",
160+
target_os = "dragonfly"))]
161+
Dli = libc::AF_DLI,
162+
#[cfg(any(target_os = "macos",
163+
target_os = "ios",
164+
target_os = "freebsd",
165+
target_os = "netbsd",
166+
target_os = "openbsd",
167+
target_os = "dragonfly"))]
168+
Lat = libc::AF_LAT,
169+
#[cfg(any(target_os = "macos",
170+
target_os = "ios",
171+
target_os = "freebsd",
172+
target_os = "netbsd",
173+
target_os = "openbsd",
174+
target_os = "dragonfly"))]
175+
Hylink = libc::AF_HYLINK,
176+
#[cfg(any(target_os = "macos",
177+
target_os = "ios",
178+
target_os = "freebsd",
179+
target_os = "netbsd",
180+
target_os = "openbsd",
181+
target_os = "dragonfly"))]
182+
Link = libc::AF_LINK,
183+
#[cfg(any(target_os = "macos",
184+
target_os = "ios",
185+
target_os = "freebsd",
186+
target_os = "netbsd",
187+
target_os = "openbsd",
188+
target_os = "dragonfly"))]
189+
Xtp = libc::AF_XTP,
190+
#[cfg(any(target_os = "macos",
191+
target_os = "ios",
192+
target_os = "freebsd",
193+
target_os = "netbsd",
194+
target_os = "openbsd",
195+
target_os = "dragonfly"))]
196+
Coip = libc::AF_COIP,
197+
#[cfg(any(target_os = "macos",
198+
target_os = "ios",
199+
target_os = "freebsd",
200+
target_os = "netbsd",
201+
target_os = "openbsd",
202+
target_os = "dragonfly"))]
203+
Cnt = libc::AF_CNT,
204+
#[cfg(any(target_os = "macos",
205+
target_os = "ios",
206+
target_os = "freebsd",
207+
target_os = "netbsd",
208+
target_os = "openbsd",
209+
target_os = "dragonfly"))]
210+
Rtip = libc::AF_RTIP,
211+
#[cfg(any(target_os = "macos",
212+
target_os = "ios",
213+
target_os = "freebsd",
214+
target_os = "netbsd",
215+
target_os = "openbsd",
216+
target_os = "dragonfly"))]
217+
Pip = libc::AF_PIP,
218+
#[cfg(any(target_os = "macos",
219+
target_os = "ios",
220+
target_os = "freebsd",
221+
target_os = "netbsd",
222+
target_os = "openbsd",
223+
target_os = "dragonfly"))]
224+
Natm = libc::AF_NATM,
35225
}
36226

37227
#[derive(Copy)]

src/sys/socket/sockopt.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,11 @@ sockopt_impl!(Both, TcpKeepAlive, libc::IPPROTO_TCP, libc::TCP_KEEPALIVE, u32);
166166
sockopt_impl!(Both, TcpKeepIdle, libc::IPPROTO_TCP, libc::TCP_KEEPIDLE, u32);
167167
sockopt_impl!(Both, RcvBuf, libc::SOL_SOCKET, libc::SO_RCVBUF, usize);
168168
sockopt_impl!(Both, SndBuf, libc::SOL_SOCKET, libc::SO_SNDBUF, usize);
169-
#[cfg(target_os = "linux")]
169+
#[cfg(any(target_os = "linux", target_os = "android"))]
170170
sockopt_impl!(SetOnly, RcvBufForce, libc::SOL_SOCKET, libc::SO_RCVBUFFORCE, usize);
171-
#[cfg(all(target_os = "linux", not(target_arch="arm")))]
171+
#[cfg(any(target_os = "linux", target_os = "android"))]
172172
sockopt_impl!(SetOnly, SndBufForce, libc::SOL_SOCKET, libc::SO_SNDBUFFORCE, usize);
173173
sockopt_impl!(GetOnly, SockType, libc::SOL_SOCKET, libc::SO_TYPE, super::SockType);
174-
#[cfg(any(target_os = "freebsd",
175-
target_os = "linux",
176-
target_os = "nacl"))]
177174
sockopt_impl!(GetOnly, AcceptConn, libc::SOL_SOCKET, libc::SO_ACCEPTCONN, bool);
178175
#[cfg(any(target_os = "linux", target_os = "android"))]
179176
sockopt_impl!(GetOnly, OriginalDst, libc::SOL_IP, libc::SO_ORIGINAL_DST, sockaddr_in);

0 commit comments

Comments
 (0)