File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,12 @@ 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
+ const fn htons_i32 ( v : i32 ) -> i32 {
123
+ ( v as u16 ) . to_be ( ) as i32
124
+ }
125
+
120
126
/// Constants used in [`socket`](fn.socket.html) and [`socketpair`](fn.socketpair.html)
121
127
/// to specify the protocol to use.
122
128
#[ repr( i32 ) ]
@@ -217,7 +223,7 @@ pub enum SockProtocol {
217
223
// The protocol number is fed into the socket syscall in network byte order.
218
224
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
219
225
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
220
- EthAll = libc:: ETH_P_ALL . to_be ( ) ,
226
+ EthAll = htons_i32 ( libc:: ETH_P_ALL ) ,
221
227
}
222
228
223
229
#[ cfg( any( target_os = "linux" ) ) ]
You can’t perform that action at this time.
0 commit comments