@@ -499,6 +499,63 @@ cfg_if! {
499499 }
500500}
501501
502+ cfg_if ! {
503+ if #[ cfg( apple_targets) ] {
504+ use std:: fmt;
505+
506+ /// Return type of [`LocalPeerToken`].
507+ ///
508+ /// The audit token is an opaque token which identifies Mach tasks and
509+ /// senders of Mach messages as subjects to the BSM audit system. Only
510+ /// the appropriate BSM library routines should be used to interpret
511+ /// the contents of the audit token as the representation of the
512+ /// subject identity within the token may change over time.
513+ ///
514+ /// Starting with macOS 11, almost all audit functions have been
515+ /// deprecated (see the system header `bsm/libbsm.h`), do not use them
516+ /// if your program target more recent versions of macOS.
517+ ///
518+ /// [`LocalPeerToken`]: crate::sys::socket::sockopt::LocalPeerToken
519+ #[ repr( C ) ]
520+ #[ derive( Default , Copy , Clone , PartialEq , Eq , Hash ) ]
521+ pub struct audit_token_t {
522+ /// Value of the token.
523+ ///
524+ /// This is considered an opaque value, do not rely on its format.
525+ pub val: [ libc:: c_uint; 8 ] ,
526+ }
527+
528+ // Make the debug representation a hex string to make it shorter and clearer.
529+ impl fmt:: Debug for audit_token_t {
530+ fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
531+ f. debug_tuple( "audit_token_t" )
532+ . field( & format!( "0x{:08X}" , self ) )
533+ . finish( )
534+ }
535+ }
536+
537+ impl fmt:: LowerHex for audit_token_t {
538+ fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
539+ for v in self . val {
540+ fmt:: LowerHex :: fmt( & v, f) ?;
541+ }
542+
543+ Ok ( ( ) )
544+ }
545+ }
546+
547+ impl fmt:: UpperHex for audit_token_t {
548+ fn fmt( & self , f: & mut fmt:: Formatter <' _>) -> fmt:: Result {
549+ for v in self . val {
550+ fmt:: UpperHex :: fmt( & v, f) ?;
551+ }
552+
553+ Ok ( ( ) )
554+ }
555+ }
556+ }
557+ }
558+
502559feature ! {
503560#![ feature = "net" ]
504561/// Request for multicast socket operations
0 commit comments