net: if: Add function to set IPv4 ttl to interface

We had a functio to get IPv4 ttl but none for setting it.

Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
This commit is contained in:
Jukka Rissanen 2021-03-02 22:53:15 +02:00 committed by Anas Nashif
commit e2083ea099

View file

@ -1553,6 +1553,23 @@ static inline uint8_t net_if_ipv4_get_ttl(struct net_if *iface)
#endif #endif
} }
/**
* @brief Set IPv4 time-to-live value specified to a given interface
*
* @param iface Network interface
* @param ttl Time-to-live value
*/
static inline void net_if_ipv4_set_ttl(struct net_if *iface, uint8_t ttl)
{
#if defined(CONFIG_NET_NATIVE_IPV4)
if (!iface->config.ip.ipv4) {
return;
}
iface->config.ip.ipv4->ttl = ttl;
#endif
}
/** /**
* @brief Check if this IPv4 address belongs to one of the interfaces. * @brief Check if this IPv4 address belongs to one of the interfaces.
* *