@@ -132,11 +132,6 @@ pub enum SockProtocol {
132
132
Udp = libc:: IPPROTO_UDP ,
133
133
/// Raw sockets ([raw(7)](https://man7.org/linux/man-pages/man7/raw.7.html))
134
134
Raw = libc:: IPPROTO_RAW ,
135
- /// Allows applications and other KEXTs to be notified when certain kernel events occur
136
- /// ([ref](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/NKEConceptual/control/control.html))
137
- #[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
138
- #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
139
- KextEvent = libc:: SYSPROTO_EVENT ,
140
135
/// Allows applications to configure and control a KEXT
141
136
/// ([ref](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/NKEConceptual/control/control.html))
142
137
#[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
@@ -221,20 +216,33 @@ pub enum SockProtocol {
221
216
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
222
217
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
223
218
EthAll = ( libc:: ETH_P_ALL as u16 ) . to_be ( ) as i32 ,
219
+ /// ICMP protocol ([icmp(7)](https://man7.org/linux/man-pages/man7/icmp.7.html))
220
+ Icmp = libc:: IPPROTO_ICMP ,
221
+ /// ICMPv6 protocol (ICMP over IPv6)
222
+ IvmpV6 = libc:: IPPROTO_ICMPV6 ,
223
+ }
224
+
225
+ impl SockProtocol {
224
226
/// The Controller Area Network raw socket protocol
225
227
/// ([ref](https://docs.kernel.org/networking/can.html#how-to-use-socketcan))
226
228
#[ cfg( target_os = "linux" ) ]
227
229
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
228
- CanRaw = libc :: CAN_RAW ,
229
- }
230
+ # [ allow ( non_upper_case_globals ) ]
231
+ pub const CanRaw : SockProtocol = SockProtocol :: Icmp ; // Matches libc::CAN_RAW
230
232
231
- impl SockProtocol {
232
233
/// The Controller Area Network broadcast manager protocol
233
234
/// ([ref](https://docs.kernel.org/networking/can.html#how-to-use-socketcan))
234
235
#[ cfg( target_os = "linux" ) ]
235
236
#[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
236
237
#[ allow( non_upper_case_globals) ]
237
238
pub const CanBcm : SockProtocol = SockProtocol :: NetlinkUserSock ; // Matches libc::CAN_BCM
239
+
240
+ /// Allows applications and other KEXTs to be notified when certain kernel events occur
241
+ /// ([ref](https://developer.apple.com/library/content/documentation/Darwin/Conceptual/NKEConceptual/control/control.html))
242
+ #[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
243
+ #[ cfg_attr( docsrs, doc( cfg( all( ) ) ) ) ]
244
+ #[ allow( non_upper_case_globals) ]
245
+ pub const KextEvent : SockProtocol = SockProtocol :: Icmp ; // Matches libc::SYSPROTO_EVENT
238
246
}
239
247
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
240
248
libc_bitflags ! {
@@ -2441,4 +2449,15 @@ mod tests {
2441
2449
)
2442
2450
. expect ( "Failed to open routing socket" ) ;
2443
2451
}
2452
+ #[ test]
2453
+ fn sock_protocol_constant_matches ( ) {
2454
+ #[ cfg( target_os = "linux" ) ]
2455
+ assert_eq ! ( super :: SockProtocol :: CanRaw as libc:: c_int, libc:: CAN_RAW ) ;
2456
+
2457
+ #[ cfg( target_os = "linux" ) ]
2458
+ assert_eq ! ( super :: SockProtocol :: CanBcm as libc:: c_int, libc:: CAN_BCM ) ;
2459
+
2460
+ #[ cfg( any( target_os = "ios" , target_os = "macos" ) ) ]
2461
+ assert_eq ! ( super :: SockProtocol :: KextEvent as libc:: c_int, libc:: SYSPROTO_EVENT ) ;
2462
+ }
2444
2463
}
0 commit comments