feat(esp_netif): Added code to expose api to add and remove ipv6 address

pull/13090/head
Abhik Roy 2024-01-09 18:00:47 +08:00
rodzic 22f2ecc400
commit 325a8d7a6e
5 zmienionych plików z 41 dodań i 31 usunięć

Wyświetl plik

@ -96,6 +96,7 @@ void esp_netif_action_got_ip(void *esp_netif, esp_event_base_t base, int32_t eve
IP2STR(&event->ip_info.gw));
}
#if CONFIG_LWIP_IPV6
void esp_netif_action_join_ip6_multicast_group(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data)
{
ESP_LOGD(TAG, "esp_netif action join_ip6_multicast group with netif%p from event_id=%" PRId32, esp_netif, event_id);
@ -114,7 +115,7 @@ void esp_netif_action_add_ip6_address(void *esp_netif, esp_event_base_t base, in
{
ESP_LOGD(TAG, "esp_netif action add_ip6_address with netif%p from event_id=%" PRId32, esp_netif, event_id);
const ip_event_add_ip6_t *addr = (const ip_event_add_ip6_t *)data;
esp_netif_add_ip6_address(esp_netif, addr);
esp_netif_add_ip6_address(esp_netif, addr->addr, addr->preferred);
}
void esp_netif_action_remove_ip6_address(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data)
@ -123,3 +124,4 @@ void esp_netif_action_remove_ip6_address(void *esp_netif, esp_event_base_t base,
const esp_ip6_addr_t *addr = (const esp_ip6_addr_t *)data;
esp_netif_remove_ip6_address(esp_netif, addr);
}
#endif

Wyświetl plik

@ -821,6 +821,35 @@ esp_err_t esp_netif_get_ip6_global(esp_netif_t *esp_netif, esp_ip6_addr_t *if_ip
* number of returned IPv6 addresses
*/
int esp_netif_get_all_ip6(esp_netif_t *esp_netif, esp_ip6_addr_t if_ip6[]);
/**
* @brief Cause the TCP/IP stack to add an IPv6 address to the interface
*
* @param[in] esp_netif Handle to esp-netif instance
* @param[in] addr The address to be added
* @param[in] preferred The preferred status of the address
*
* @return
* - ESP_OK
* - ESP_ERR_ESP_NETIF_INVALID_PARAMS
* - ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED
* - ESP_ERR_NO_MEM
*/
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const esp_ip6_addr_t addr, bool preferred);
/**
* @brief Cause the TCP/IP stack to remove an IPv6 address from the interface
*
* @param[in] esp_netif Handle to esp-netif instance
* @param[in] addr The address to be removed
*
* @return
* - ESP_OK
* - ESP_ERR_ESP_NETIF_INVALID_PARAMS
* - ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED
* - ESP_ERR_NO_MEM
*/
esp_err_t esp_netif_remove_ip6_address(esp_netif_t *esp_netif, const esp_ip6_addr_t *addr);
#endif
/**

Wyświetl plik

@ -455,7 +455,7 @@ esp_err_t esp_netif_leave_ip6_multicast_group(esp_netif_t *esp_netif, const esp_
return ESP_ERR_NOT_SUPPORTED;
}
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const ip_event_add_ip6_t *addr)
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const esp_ip6_addr_t addr, bool preferred)
{
return ESP_ERR_NOT_SUPPORTED;
}

Wyświetl plik

@ -2616,9 +2616,16 @@ static esp_err_t esp_netif_add_ip6_address_api(esp_netif_api_msg_t *msg)
return error;
}
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const ip_event_add_ip6_t *addr)
static esp_err_t esp_netif_add_ip6_address_priv(esp_netif_t *esp_netif, const ip_event_add_ip6_t *addr)
_RUN_IN_LWIP_TASK(esp_netif_add_ip6_address_api, esp_netif, addr)
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const esp_ip6_addr_t addr, bool preferred)
{
const ip_event_add_ip6_t addr_evt = {.addr = addr, .preferred = preferred};
return esp_netif_add_ip6_address_priv(esp_netif, &addr_evt);
}
static esp_err_t esp_netif_remove_ip6_address_api(esp_netif_api_msg_t *msg)
{
esp_ip6_addr_t *addr = (esp_ip6_addr_t *)msg->data;

Wyświetl plik

@ -116,34 +116,6 @@ esp_err_t esp_netif_remove_from_list_unsafe(esp_netif_t* netif);
*/
bool esp_netif_is_netif_listed(esp_netif_t *esp_netif);
/**
* @brief Cause the TCP/IP stack to add an IPv6 address to the interface
*
* @param[in] esp_netif Handle to esp-netif instance
* @param[in] addr The address to be added
*
* @return
* - ESP_OK
* - ESP_ERR_ESP_NETIF_INVALID_PARAMS
* - ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED
* - ESP_ERR_NO_MEM
*/
esp_err_t esp_netif_add_ip6_address(esp_netif_t *esp_netif, const ip_event_add_ip6_t *addr);
/**
* @brief Cause the TCP/IP stack to remove an IPv6 address from the interface
*
* @param[in] esp_netif Handle to esp-netif instance
* @param[in] addr The address to be removed
*
* @return
* - ESP_OK
* - ESP_ERR_ESP_NETIF_INVALID_PARAMS
* - ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED
* - ESP_ERR_NO_MEM
*/
esp_err_t esp_netif_remove_ip6_address(esp_netif_t *esp_netif, const esp_ip6_addr_t *addr);
/**
* @brief Get esp_netif handle based on the if_key
* This doesn't lock the list nor TCPIP context