![]() |
Network Component
Version 7.2
MDK Middleware for IPv4 and IPv6 Networking
|
Generic functions for all kinds of interfaces help to get or set interface options. More...
Content | |
Enumerations | |
Common enumerations for all Interfaces. | |
Functions | |
netStatus | netIF_GetOption (uint32_t if_id, netIF_Option option, uint8_t *buf, uint32_t buf_len) |
Get the current value of an Interface option. [thread-safe]. | |
netStatus | netIF_SetOption (uint32_t if_id, netIF_Option option, const uint8_t *buf, uint32_t buf_len) |
Set the value of an Interface option. [thread-safe]. | |
Generic functions for all kinds of interfaces help to get or set interface options.
These functions are used to read various interface settings (such as the IP4 address, subnet mask, default gateway etc.), and to change these settings at run time. For example, you can read the IP address assigned via DHCP using the netIF_GetOption function, or change a static IP address using the netIF_SetOption function.
netStatus netIF_GetOption | ( | uint32_t | if_id, |
netIF_Option | option, | ||
uint8_t * | buf, | ||
uint32_t | buf_len | ||
) |
Get the current value of an Interface option. [thread-safe].
[in] | if_id | Interface identification (class and number). |
[in] | option | Interface option as specified by netIF_Option. |
[out] | buf | buffer to store the option value to |
[in] | buf_len | length of buffer |
The function netIF_GetOption retrieves the current value of an option for the interface specified by if_id.
The argument if_id is composed of the network interface class identifier and an interface number (or-ed). The interface class identifier is specified with the following defines:
The argument buf points to a buffer that will be used to store the value of the option.
The argument buf_len specifies the length of the buffer buf.
Code Example
netStatus netIF_SetOption | ( | uint32_t | if_id, |
netIF_Option | option, | ||
const uint8_t * | buf, | ||
uint32_t | buf_len | ||
) |
Set the value of an Interface option. [thread-safe].
[in] | if_id | Interface identification (class and number). |
[in] | option | Interface option as specified by netIF_Option. |
[in] | buf | buffer containing the option value |
[in] | buf_len | length of buffer |
The function netIF_SetOption sets different options for the interface identified by the argument if_id.
The argument if_id is composed of the network interface class identifier and an interface number (or-ed). The interface class identifier is specified with the following defines:
The argument option specifies the interface option that is to be set (see below).
The argument buf points to a buffer containing the value of the option to be set.
The argument buf_len specifies the actual length of the buffer buf and must match the length of the corresponding option as specified with argument option (see below).
Option | Description | Length |
---|---|---|
netIF_OptionMAC_Address | Ethernet MAC Address | 6 bytes |
netIF_OptionIP4_Address | IPv4 Address | 4 bytes |
netIF_OptionIP4_SubnetMask | IPv4 Subnet mask | 4 bytes |
netIF_OptionIP4_DefaultGateway | IPv4 Default Gateway | 4 bytes |
netIF_OptionIP4_PrimaryDNS | IPv4 Primary DNS | 4 bytes |
netIF_OptionIP4_SecondaryDNS | IPv4 Secondary DNS | 4 bytes |
netIF_OptionIP6_LinkLocalAddress | IPv6 Link-local Address | 16 bytes |
netIF_OptionIP6_StaticAddress | IPv6 Static Address | 16 bytes |
netIF_OptionIP6_DynamicAddress | IPv6 Dynamic Address | 16 bytes |
netIF_OptionIP6_SubnetPrefixLength | IPv6 Subnet Prefix-length | 1 byte |
netIF_OptionIP6_DefaultGateway | IPv6 Default Gateway | 16 bytes |
netIF_OptionIP6_PrimaryDNS | IPv6 Primary DNS | 16 bytes |
netIF_OptionIP6_SecondaryDNS | IPv6 Secondary DNS | 16 bytes |
Code Example