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

This commit is contained in:
Abhik Roy 2023-12-08 23:40:56 +11:00
parent bed70a9e11
commit 8809589cf7
5 changed files with 41 additions and 18 deletions

View File

@ -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)); 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) 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); 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); 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; 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_priv(esp_netif, addr);
} }
void esp_netif_action_remove_ip6_address(void *esp_netif, esp_event_base_t base, int32_t event_id, void *data) 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; const esp_ip6_addr_t *addr = (const esp_ip6_addr_t *)data;
esp_netif_remove_ip6_address(esp_netif, addr); esp_netif_remove_ip6_address(esp_netif, addr);
} }
#endif

View File

@ -821,6 +821,34 @@ esp_err_t esp_netif_get_ip6_global(esp_netif_t *esp_netif, esp_ip6_addr_t *if_ip
* number of returned IPv6 addresses * number of returned IPv6 addresses
*/ */
int esp_netif_get_all_ip6(esp_netif_t *esp_netif, esp_ip6_addr_t if_ip6[]); 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
*
* @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);
/**
* @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 #endif
/** /**

View File

@ -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; 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_priv(esp_netif_t *esp_netif, const ip_event_add_ip6_t *addr)
{ {
return ESP_ERR_NOT_SUPPORTED; return ESP_ERR_NOT_SUPPORTED;
} }

View File

@ -2623,9 +2623,16 @@ static esp_err_t esp_netif_add_ip6_address_api(esp_netif_api_msg_t *msg)
return error; return error;
} }
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_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) _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)
{
const ip_event_add_ip6_t addr_evt = {.addr = addr, .preferred = true};
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) 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; esp_ip6_addr_t *addr = (esp_ip6_addr_t *)msg->data;

View File

@ -128,21 +128,7 @@ bool esp_netif_is_netif_listed(esp_netif_t *esp_netif);
* - ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED * - ESP_ERR_ESP_NETIF_IP6_ADDR_FAILED
* - ESP_ERR_NO_MEM * - ESP_ERR_NO_MEM
*/ */
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_priv(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 * @brief Get esp_netif handle based on the if_key