File tree Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Expand file tree Collapse file tree 1 file changed +8
-1
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,13 @@ impl TryFrom<i32> for SockType {
117
117
}
118
118
}
119
119
120
+ /// htons_i32 converts the lower 16 bits of the value into network order and
121
+ /// returns it as an i32. e.g. 0x0000ABCD => 0x0000CDAB
122
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
123
+ const fn htons_i32 ( v : i32 ) -> i32 {
124
+ ( v as u16 ) . to_be ( ) as i32
125
+ }
126
+
120
127
/// Constants used in [`socket`](fn.socket.html) and [`socketpair`](fn.socketpair.html)
121
128
/// to specify the protocol to use.
122
129
#[ repr( i32 ) ]
@@ -217,7 +224,7 @@ pub enum SockProtocol {
217
224
// The protocol number is fed into the socket syscall in network byte order.
218
225
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
219
226
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
220
- EthAll = libc:: ETH_P_ALL . to_be ( ) ,
227
+ EthAll = htons_i32 ( libc:: ETH_P_ALL ) ,
221
228
/// The Controller Area Network raw socket protocol
222
229
/// ([ref](https://docs.kernel.org/networking/can.html#how-to-use-socketcan))
223
230
#[ cfg( target_os = "linux" ) ]
You can’t perform that action at this time.
0 commit comments