@@ -175,10 +175,22 @@ impl SocketAddrV6 {
175
175
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
176
176
pub fn flowinfo ( & self ) -> u32 { ntoh ( self . inner . sin6_flowinfo ) }
177
177
178
+ /// Change the flow information associated with this socket address.
179
+ #[ unstable( feature = "sockaddr_setters" , reason = "recent addition" , issue = "31572" ) ]
180
+ pub fn set_flowinfo ( & mut self , new_flowinfo : u32 ) {
181
+ self . inner . sin6_flowinfo = hton ( new_flowinfo)
182
+ }
183
+
178
184
/// Returns the scope ID associated with this address,
179
185
/// corresponding to the `sin6_scope_id` field in C.
180
186
#[ stable( feature = "rust1" , since = "1.0.0" ) ]
181
187
pub fn scope_id ( & self ) -> u32 { ntoh ( self . inner . sin6_scope_id ) }
188
+
189
+ /// Change the scope ID associated with this socket address.
190
+ #[ unstable( feature = "sockaddr_setters" , reason = "recent addition" , issue = "31572" ) ]
191
+ pub fn set_scope_id ( & mut self , new_scope_id : u32 ) {
192
+ self . inner . sin6_scope_id = hton ( new_scope_id)
193
+ }
182
194
}
183
195
184
196
impl FromInner < c:: sockaddr_in > for SocketAddrV4 {
@@ -593,4 +605,20 @@ mod tests {
593
605
addr. set_port ( 8080 ) ;
594
606
assert_eq ! ( addr. port( ) , 8080 ) ;
595
607
}
608
+
609
+ #[ test]
610
+ fn set_flowinfo ( ) {
611
+ let mut v6 = SocketAddrV6 :: new ( Ipv6Addr :: new ( 0x2a02 , 0x6b8 , 0 , 1 , 0 , 0 , 0 , 1 ) , 80 , 10 , 0 ) ;
612
+ assert_eq ! ( v6. flowinfo( ) , 10 ) ;
613
+ v6. set_flowinfo ( 20 ) ;
614
+ assert_eq ! ( v6. flowinfo( ) , 20 ) ;
615
+ }
616
+
617
+ #[ test]
618
+ fn set_scope_id ( ) {
619
+ let mut v6 = SocketAddrV6 :: new ( Ipv6Addr :: new ( 0x2a02 , 0x6b8 , 0 , 1 , 0 , 0 , 0 , 1 ) , 80 , 0 , 10 ) ;
620
+ assert_eq ! ( v6. scope_id( ) , 10 ) ;
621
+ v6. set_scope_id ( 20 ) ;
622
+ assert_eq ! ( v6. scope_id( ) , 20 ) ;
623
+ }
596
624
}
0 commit comments