@@ -463,6 +463,17 @@ pub enum ControlMessageOwned {
463
463
target_os = "openbsd" ,
464
464
) ) ]
465
465
Ipv4RecvDstAddr ( libc:: in_addr ) ,
466
+ #[ cfg( any(
467
+ target_os = "linux" ,
468
+ target_os = "android" ,
469
+ ) ) ]
470
+ OrigDstAddrV4 ( libc:: sockaddr_in ) ,
471
+ #[ cfg( any(
472
+ target_os = "linux" ,
473
+ target_os = "android" ,
474
+ ) ) ]
475
+ OrigDstAddrV6 ( libc:: sockaddr_in6 ) ,
476
+
466
477
/// Catch-all variant for unimplemented cmsg types.
467
478
#[ doc( hidden) ]
468
479
Unknown ( UnknownCmsg ) ,
@@ -546,6 +557,16 @@ impl ControlMessageOwned {
546
557
let dl = ptr:: read_unaligned ( p as * const libc:: in_addr ) ;
547
558
ControlMessageOwned :: Ipv4RecvDstAddr ( dl)
548
559
} ,
560
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
561
+ ( libc:: IPPROTO_IP , libc:: IP_ORIGDSTADDR ) => {
562
+ let dl = ptr:: read_unaligned ( p as * const libc:: sockaddr_in ) ;
563
+ ControlMessageOwned :: OrigDstAddrV4 ( dl)
564
+ } ,
565
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
566
+ ( libc:: IPPROTO_IPV6 , libc:: IPV6_ORIGDSTADDR ) => {
567
+ let dl = ptr:: read_unaligned ( p as * const libc:: sockaddr_in6 ) ;
568
+ ControlMessageOwned :: OrigDstAddrV6 ( dl)
569
+ } ,
549
570
( _, _) => {
550
571
let sl = slice:: from_raw_parts ( p, len) ;
551
572
let ucmsg = UnknownCmsg ( * header, Vec :: < u8 > :: from ( & sl[ ..] ) ) ;
@@ -587,6 +608,17 @@ pub enum ControlMessage<'a> {
587
608
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
588
609
ScmCredentials ( & ' a UnixCredentials ) ,
589
610
611
+ #[ cfg( any(
612
+ target_os = "linux" ,
613
+ target_os = "android" ,
614
+ ) ) ]
615
+ OrigDstAddrV4 ( & ' a libc:: sockaddr_in ) ,
616
+ #[ cfg( any(
617
+ target_os = "linux" ,
618
+ target_os = "android" ,
619
+ ) ) ]
620
+ OrigDstAddrV6 ( & ' a libc:: sockaddr_in6 ) ,
621
+
590
622
/// Set IV for `AF_ALG` crypto API.
591
623
///
592
624
/// For further information, please refer to the
@@ -655,6 +687,20 @@ impl<'a> ControlMessage<'a> {
655
687
ControlMessage :: ScmCredentials ( creds) => {
656
688
& creds. 0 as * const libc:: ucred as * const u8
657
689
}
690
+ #[ cfg( any(
691
+ target_os = "linux" ,
692
+ target_os = "android" ,
693
+ ) ) ]
694
+ ControlMessage :: OrigDstAddrV4 ( origaddr) => {
695
+ origaddr as * const libc:: sockaddr_in as * const u8
696
+ } ,
697
+ #[ cfg( any(
698
+ target_os = "linux" ,
699
+ target_os = "android" ,
700
+ ) ) ]
701
+ ControlMessage :: OrigDstAddrV6 ( origaddr) => {
702
+ origaddr as * const libc:: sockaddr_in6 as * const u8
703
+ } ,
658
704
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
659
705
ControlMessage :: AlgSetIv ( iv) => {
660
706
unsafe {
@@ -696,6 +742,20 @@ impl<'a> ControlMessage<'a> {
696
742
ControlMessage :: ScmCredentials ( creds) => {
697
743
mem:: size_of_val ( creds)
698
744
}
745
+ #[ cfg( any(
746
+ target_os = "linux" ,
747
+ target_os = "android" ,
748
+ ) ) ]
749
+ ControlMessage :: OrigDstAddrV4 ( origaddr) => {
750
+ mem:: size_of_val ( origaddr)
751
+ } ,
752
+ #[ cfg( any(
753
+ target_os = "linux" ,
754
+ target_os = "android" ,
755
+ ) ) ]
756
+ ControlMessage :: OrigDstAddrV6 ( origaddr) => {
757
+ mem:: size_of_val ( origaddr)
758
+ } ,
699
759
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
700
760
ControlMessage :: AlgSetIv ( iv) => {
701
761
mem:: size_of :: < libc:: af_alg_iv > ( ) + iv. len ( )
@@ -720,6 +780,10 @@ impl<'a> ControlMessage<'a> {
720
780
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
721
781
ControlMessage :: AlgSetIv ( _) | ControlMessage :: AlgSetOp ( _) |
722
782
ControlMessage :: AlgSetAeadAssoclen ( _) => libc:: SOL_ALG ,
783
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
784
+ ControlMessage :: OrigDstAddrV4 ( _) => libc:: IPPROTO_IP ,
785
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
786
+ ControlMessage :: OrigDstAddrV6 ( _) => libc:: IPPROTO_IPV6 ,
723
787
}
724
788
}
725
789
@@ -734,6 +798,14 @@ impl<'a> ControlMessage<'a> {
734
798
libc:: ALG_SET_IV
735
799
} ,
736
800
#[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
801
+ ControlMessage :: OrigDstAddrV4 ( _) => {
802
+ libc:: IP_ORIGDSTADDR
803
+ } ,
804
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
805
+ ControlMessage :: OrigDstAddrV6 ( _) => {
806
+ libc:: IPV6_ORIGDSTADDR
807
+ } ,
808
+ #[ cfg( any( target_os = "android" , target_os = "linux" ) ) ]
737
809
ControlMessage :: AlgSetOp ( _) => {
738
810
libc:: ALG_SET_OP
739
811
} ,
0 commit comments