From e2083ea099b156938444ac2aae87e1fe0add0909 Mon Sep 17 00:00:00 2001 From: Jukka Rissanen Date: Tue, 2 Mar 2021 22:53:15 +0200 Subject: [PATCH] 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 --- include/net/net_if.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/net/net_if.h b/include/net/net_if.h index 40b110bc354..807fcf40ec9 100644 --- a/include/net/net_if.h +++ b/include/net/net_if.h @@ -1553,6 +1553,23 @@ static inline uint8_t net_if_ipv4_get_ttl(struct net_if *iface) #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. *