File tree Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Expand file tree Collapse file tree 3 files changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ Add the ` TCP_FUNCTION_BLK `  sockopt, on FreeBSD.
Original file line number Diff line number Diff line change @@ -300,7 +300,18 @@ sockopt_impl!(
300300    libc:: SO_REUSEPORT_LB , 
301301    bool 
302302) ; 
303+ #[ cfg( target_os = "freebsd" ) ]  
303304#[ cfg( feature = "net" ) ]  
305+ sockopt_impl ! ( 
306+     #[ cfg_attr( docsrs,  doc( cfg( feature = "net" ) ) ) ] 
307+     /// Select or query the set of functions that TCP will use for this connection.  This allows a 
308+      /// user to select an alternate TCP stack. 
309+      TcpFunctionBlk , 
310+     Both , 
311+     libc:: IPPROTO_TCP , 
312+     libc:: TCP_FUNCTION_BLK , 
313+     libc:: tcp_function_set
314+ ) ; 
304315sockopt_impl ! ( 
305316    #[ cfg_attr( docsrs,  doc( cfg( feature = "net" ) ) ) ] 
306317    /// Used to disable Nagle's algorithm. 
Original file line number Diff line number Diff line change @@ -281,6 +281,28 @@ fn test_tcp_congestion() {
281281    assert_eq ! ( getsockopt( & fd,  sockopt:: TcpCongestion ) . unwrap( ) ,  val) ; 
282282} 
283283
284+ #[ test]  
285+ #[ cfg( target_os = "freebsd" ) ]  
286+ fn  test_tcp_function_blk ( )  { 
287+     use  std:: ffi:: CStr ; 
288+ 
289+     let  fd = socket ( 
290+         AddressFamily :: Inet , 
291+         SockType :: Stream , 
292+         SockFlag :: empty ( ) , 
293+         None , 
294+     ) 
295+     . unwrap ( ) ; 
296+ 
297+     let  tfs = getsockopt ( & fd,  sockopt:: TcpFunctionBlk ) . unwrap ( ) ; 
298+     let  name = unsafe  {  CStr :: from_ptr ( tfs. function_set_name . as_ptr ( ) )  } ; 
299+     assert ! ( !name. to_bytes( ) . is_empty( ) ) ; 
300+ 
301+     // We can't know at compile time what options are available.  So just test the setter by a 
302+     // no-op set. 
303+     setsockopt ( & fd,  sockopt:: TcpFunctionBlk ,  & tfs) . unwrap ( ) ; 
304+ } 
305+ 
284306#[ test]  
285307#[ cfg( linux_android) ]  
286308fn  test_bindtodevice ( )  { 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments