mirror of
https://git.savannah.nongnu.org/git/lwip.git
synced 2026-05-17 13:46:56 +08:00
Some code cleanup related to netif index handling
Made the macro "netif_index_to_num" private, if someone needs it externally, please complain.
This commit is contained in:
@@ -193,7 +193,7 @@ enum lwip_ipv6_scope_type
|
||||
*/
|
||||
#define ip6_addr_assign_zone(ip6addr, type, netif) \
|
||||
(ip6_addr_set_zone((ip6addr), \
|
||||
ip6_addr_has_scope((ip6addr), (type)) ? netif_num_to_index(netif) : 0))
|
||||
ip6_addr_has_scope((ip6addr), (type)) ? netif_get_index(netif) : 0))
|
||||
|
||||
/**
|
||||
* Test whether an IPv6 address is "zone-compatible" with a network interface.
|
||||
@@ -215,7 +215,7 @@ enum lwip_ipv6_scope_type
|
||||
* @return 1 if the address is scope-compatible with the netif, 0 if not.
|
||||
*/
|
||||
#define ip6_addr_test_zone(ip6addr, netif) \
|
||||
(ip6_addr_equals_zone((ip6addr), netif_num_to_index(netif)))
|
||||
(ip6_addr_equals_zone((ip6addr), netif_get_index(netif)))
|
||||
|
||||
#endif /* !IPV6_CUSTOM_SCOPES */
|
||||
|
||||
|
||||
@@ -497,13 +497,12 @@ err_t netif_add_ip6_address(struct netif *netif, const ip6_addr_t *ip6addr, s8_t
|
||||
#define NETIF_SET_HWADDRHINT(netif, hint)
|
||||
#endif /* LWIP_NETIF_HWADDRHINT */
|
||||
|
||||
/* @ingroup netif */
|
||||
u8_t netif_name_to_index(const char *name);
|
||||
char * netif_index_to_name(u8_t idx, char *name);
|
||||
struct netif* netif_get_by_index(u8_t index);
|
||||
|
||||
/* Interface indexes always start at 1 per RFC 3493, section 4, num starts at 0 */
|
||||
#define netif_num_to_index(netif) ((netif)->num + 1)
|
||||
#define netif_index_to_num(index) ((index) - 1)
|
||||
#define netif_get_index(netif) ((netif)->num + 1)
|
||||
#define NETIF_NO_INDEX (0)
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user