File tree 2 files changed +12
-1
lines changed
2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -30,6 +30,16 @@ impl TapInterfaceDesc {
30
30
ifreq_ioctl ( self . lower , & mut self . ifreq , imp:: TUNSETIFF ) . map ( |_| ( ) )
31
31
}
32
32
33
+ pub fn interface_mtu ( & mut self ) -> io:: Result < usize > {
34
+ let lower = unsafe {
35
+ let lower = libc:: socket ( libc:: AF_INET , libc:: SOCK_DGRAM , libc:: IPPROTO_IP ) ;
36
+ if lower == -1 { return Err ( io:: Error :: last_os_error ( ) ) }
37
+ lower
38
+ } ;
39
+
40
+ ifreq_ioctl ( lower, & mut self . ifreq , imp:: SIOCGIFMTU ) . map ( |mtu| mtu as usize )
41
+ }
42
+
33
43
fn wait ( & mut self , ms : u32 ) -> io:: Result < bool > {
34
44
unsafe {
35
45
let mut readfds = mem:: uninitialized :: < libc:: fd_set > ( ) ;
Original file line number Diff line number Diff line change @@ -22,9 +22,10 @@ impl TapInterface {
22
22
pub fn new ( name : & str ) -> io:: Result < TapInterface > {
23
23
let mut lower = sys:: TapInterfaceDesc :: new ( name) ?;
24
24
lower. attach_interface ( ) ?;
25
+ let mtu = lower. interface_mtu ( ) ?;
25
26
Ok ( TapInterface {
26
27
lower : Rc :: new ( RefCell :: new ( lower) ) ,
27
- mtu : 1536 // FIXME: get the real value somehow
28
+ mtu : mtu
28
29
} )
29
30
}
30
31
}
You can’t perform that action at this time.
0 commit comments