@@ -783,7 +783,15 @@ impl InterfaceInner {
783783
784784 #[ allow( unused) ] // unused depending on which sockets are enabled
785785 pub ( crate ) fn ip_mtu ( & self ) -> usize {
786- self . caps . ip_mtu ( )
786+ match self . caps . medium {
787+ #[ cfg( feature = "medium-ethernet" ) ]
788+ Medium :: Ethernet => self . caps . max_transmission_unit - 14 ,
789+ #[ cfg( feature = "medium-ip" ) ]
790+ Medium :: Ip => self . caps . max_transmission_unit ,
791+ #[ cfg( feature = "medium-ieee802154" ) ]
792+ Medium :: Ieee802154 => self . caps . max_transmission_unit , // TODO(thvdveld): what is the MTU for Medium::IEEE802
793+ _ => unimplemented ! ( ) ,
794+ }
787795 }
788796
789797 #[ allow( unused) ] // unused depending on which sockets are enabled, and in tests
@@ -1210,7 +1218,7 @@ impl InterfaceInner {
12101218 #[ cfg( feature = "proto-ipv4" ) ]
12111219 IpRepr :: Ipv4 ( repr) => {
12121220 // If we have an IPv4 packet, then we need to check if we need to fragment it.
1213- if total_ip_len > self . caps . ip_mtu ( ) {
1221+ if total_ip_len > self . ip_mtu ( ) {
12141222 #[ cfg( feature = "proto-ipv4-fragmentation" ) ]
12151223 {
12161224 net_debug ! ( "start fragmentation" ) ;
@@ -1219,7 +1227,7 @@ impl InterfaceInner {
12191227 let tx_len = self . caps . max_transmission_unit ;
12201228
12211229 let ip_header_len = repr. buffer_len ( ) ;
1222- let first_frag_ip_len = self . caps . ip_mtu ( ) ;
1230+ let first_frag_ip_len = self . ip_mtu ( ) ;
12231231
12241232 if frag. buffer . len ( ) < total_ip_len {
12251233 net_debug ! (
@@ -1305,7 +1313,7 @@ impl InterfaceInner {
13051313 #[ cfg( feature = "proto-ipv6" ) ]
13061314 IpRepr :: Ipv6 ( _) => {
13071315 // Check if we need to fragment it.
1308- if total_ip_len > self . caps . ip_mtu ( ) {
1316+ if total_ip_len > self . ip_mtu ( ) {
13091317 net_debug ! ( "IPv6 fragmentation support is unimplemented. Dropping." ) ;
13101318 Ok ( ( ) )
13111319 } else {
0 commit comments