mirror of
https://github.com/espressif/esp-lwip.git
synced 2026-06-05 21:04:45 +00:00
ip6: Add hook for IP6 source address selection
2.1.3-esp: 57c29648 ip6: add a hook for ip6 source address selection
This commit is contained in:
+8
-2
@@ -290,6 +290,14 @@ ip6_select_source_address(struct netif *netif, const ip6_addr_t *dest)
|
||||
u8_t best_pref = 0;
|
||||
u8_t best_bits = 0;
|
||||
|
||||
best_addr = NULL;
|
||||
|
||||
#ifdef LWIP_HOOK_IP6_SELECT_SRC_ADDR
|
||||
if ((best_addr = LWIP_HOOK_IP6_SELECT_SRC_ADDR(netif, dest)) != NULL) {
|
||||
return best_addr;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Start by determining the scope of the given destination address. These
|
||||
* tests are hopefully (roughly) in order of likeliness to match. */
|
||||
if (ip6_addr_isglobal(dest)) {
|
||||
@@ -307,8 +315,6 @@ ip6_select_source_address(struct netif *netif, const ip6_addr_t *dest)
|
||||
dest_scope = IP6_MULTICAST_SCOPE_GLOBAL;
|
||||
}
|
||||
|
||||
best_addr = NULL;
|
||||
|
||||
for (i = 0; i < LWIP_IPV6_NUM_ADDRESSES; i++) {
|
||||
/* Consider only valid (= preferred and deprecated) addresses. */
|
||||
if (!ip6_addr_isvalid(netif_ip6_addr_state(netif, i))) {
|
||||
|
||||
@@ -3080,6 +3080,28 @@
|
||||
#define LWIP_HOOK_ND6_GET_GW(netif, dest)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_HOOK_IP6_SELECT_SRC_ADDR(netif, dest):
|
||||
* Called from ip6_select_source_address() (IPv6)
|
||||
* Signature:\code{.c}
|
||||
* const ip6_addr_t *my_hook(struct netif *netif, const ip6_addr_t *dest);
|
||||
* \endcode
|
||||
* Arguments:
|
||||
* - netif: the netif used for selecting
|
||||
* - dest: the destination IPv6 address
|
||||
* Return values:
|
||||
* - the preferred source IPv6 address of the specified destination IPv6 address
|
||||
* - NULL, in which case none source address is preferred by the hook, lwip
|
||||
* will determine a source address based RFC 6724.
|
||||
*
|
||||
* The returned address MUST be on the specified netif!
|
||||
* This function is meant to implement advanced IPv6 source address selection with
|
||||
* LWIP_HOOK_IP6_SELECT_SRC_ADDR().
|
||||
*/
|
||||
#ifdef __DOXYGEN__
|
||||
#define LWIP_HOOK_IP6_SELECT_SRC_ADDR(netif, dest)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* LWIP_HOOK_VLAN_CHECK(netif, eth_hdr, vlan_hdr):
|
||||
* Called from ethernet_input() if VLAN support is enabled
|
||||
|
||||
Reference in New Issue
Block a user