Icmp: get tos parameter in icmp reply

This commit is contained in:
xueyunfei 2022-06-15 14:39:03 +08:00
parent b569f4069a
commit 45ad770c37
2 changed files with 7 additions and 0 deletions

View File

@ -49,6 +49,7 @@ typedef struct {
uint32_t elapsed_time_ms;
uint32_t total_time_ms;
uint8_t ttl;
uint8_t tos;
uint32_t flags;
void (*on_ping_success)(esp_ping_handle_t hdl, void *args);
void (*on_ping_timeout)(esp_ping_handle_t hdl, void *args);
@ -113,6 +114,7 @@ static int esp_ping_receive(esp_ping_t *ep)
if ((iecho->id == ep->packet_hdr->id) && (iecho->seqno == ep->packet_hdr->seqno)) {
ep->received++;
ep->ttl = iphdr->_ttl;
ep->tos = iphdr->_tos;
ep->recv_len = lwip_ntohs(IPH_LEN(iphdr)) - data_head; // The data portion of ICMP
return len;
}
@ -356,6 +358,10 @@ esp_err_t esp_ping_get_profile(esp_ping_handle_t hdl, esp_ping_profile_t profile
from = &ep->packet_hdr->seqno;
copy_size = sizeof(ep->packet_hdr->seqno);
break;
case ESP_PING_PROF_TOS:
from = &ep->tos;
copy_size = sizeof(ep->tos);
break;
case ESP_PING_PROF_TTL:
from = &ep->ttl;
copy_size = sizeof(ep->ttl);

View File

@ -93,6 +93,7 @@ typedef struct {
*/
typedef enum {
ESP_PING_PROF_SEQNO, /*!< Sequence number of a ping procedure */
ESP_PING_PROF_TOS, /*!< Type of service of a ping procedure */
ESP_PING_PROF_TTL, /*!< Time to live of a ping procedure */
ESP_PING_PROF_REQUEST, /*!< Number of request packets sent out */
ESP_PING_PROF_REPLY, /*!< Number of reply packets received */