Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Getting MTU

On occasion, it may be desirable to have the application aware of an interface’s Maximum Transmission Unit. The MTU for a particular interface may be acquired by calling NetIF_MTU_Get() with the appropriate arguments. 


Code Block
languagecpp
firstline1
titleListing - Calling NetIF_MTU_Get()
linenumberstrue
mtu = NetIF_MTU_Get(if_nbr, &err);   (1)


Panel
bgColor#f0f0f0
  1. NetIF_MTU_Get() requires two arguments. The first function argument is the interface number to get the current configured MTU, and the second argument is a pointer to a NET_ERR to contain the return error code. The interface number is acquired upon the successful addition of the interface, and upon the successful return of the function, the return error variable will contain the value NET_IF_ERR_NONE. The result is returned into a local variable of type NET_MTU.


Setting MTU

 Some networks prefer to operate with a non-standard MTU. If this is the case, the application may specify the MTU for a particular interface by calling NetIF_MTU_Set() with the appropriate arguments.

 

 

 

 

 


Code Block
languagecpp
themeConfluence
firstline1
titleListing - Calling NetIF_MTU_Set()
linenumberstrue
NetIF_MTU_Set(if_nbr, mtu, &err);   (1)


Panel
bgColor#f0f0f0
  1. NetIF_MTU_Set() requires three arguments. The first function argument is the interface number of the interface to set the specified MTU. The second argument is the desired MTU to set, and the third argument is a pointer to a NET_ERR variable that will contain the return error code. The interface number is acquired upon the successful addition of the interface, and upon the successful return of the function, the return error variable will contain the value NET_IF_ERR_NONE and the specified MTU will be set.

Note: The configured MTU cannot be greater than the largest configured transmit buffer size associated with the specified interfaces’ interface’s device minus overhead. Transmit buffer sizes are specified in the device configuration structure for the specified interface. For more information about configuring device buffer sizes, refer to section  Network Interface Configuration.