@@ -1115,7 +1115,7 @@ static void _mdns_dispatch_tx_packet(mdns_tx_packet_t * p)
1115
1115
1116
1116
#ifdef MDNS_ENABLE_DEBUG
1117
1117
_mdns_dbg_printf ("\nTX[%u][%u]: " , p -> tcpip_if , p -> ip_protocol );
1118
- if (p -> dst .type == IPADDR_TYPE_V4 ) {
1118
+ if (p -> dst .type == ESP_IPADDR_TYPE_V4 ) {
1119
1119
_mdns_dbg_printf ("To: " IPSTR ":%u, " , IP2STR (& p -> dst .u_addr .ip4 ), p -> port );
1120
1120
} else {
1121
1121
_mdns_dbg_printf ("To: " IPV6STR ":%u, " , IPV62STR (p -> dst .u_addr .ip6 ), p -> port );
@@ -1345,11 +1345,12 @@ static mdns_tx_packet_t * _mdns_alloc_packet_default(mdns_if_t tcpip_if, mdns_ip
1345
1345
packet -> ip_protocol = ip_protocol ;
1346
1346
packet -> port = MDNS_SERVICE_PORT ;
1347
1347
if (ip_protocol == MDNS_IP_PROTOCOL_V4 ) {
1348
- IP4_ADDR (& packet -> dst .u_addr .ip4 , 224 , 0 , 0 , 251 );
1348
+ esp_ip_addr_t addr = ESP_IP4ADDR_INIT (224 , 0 , 0 , 251 );
1349
+ memcpy (& packet -> dst , & addr , sizeof (esp_ip_addr_t ));
1349
1350
}
1350
1351
#if CONFIG_LWIP_IPV6
1351
1352
else {
1352
- esp_ip_addr_t addr = IPADDR6_INIT (0x000002ff , 0 , 0 , 0xfb000000 );
1353
+ esp_ip_addr_t addr = ESP_IP6ADDR_INIT (0x000002ff , 0 , 0 , 0xfb000000 );
1353
1354
memcpy (& packet -> dst , & addr , sizeof (esp_ip_addr_t ));
1354
1355
}
1355
1356
#endif
@@ -2973,15 +2974,15 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
2973
2974
{
2974
2975
static mdns_name_t n ;
2975
2976
mdns_header_t header ;
2976
- const uint8_t * data = ( const uint8_t * ) packet -> pb -> payload ;
2977
- size_t len = packet -> pb -> len ;
2977
+ const uint8_t * data = _mdns_get_packet_data ( packet ) ;
2978
+ size_t len = _mdns_get_packet_len ( packet ) ;
2978
2979
const uint8_t * content = data + MDNS_HEAD_LEN ;
2979
2980
bool do_not_reply = false;
2980
2981
mdns_search_once_t * search_result = NULL ;
2981
2982
2982
2983
#ifdef MDNS_ENABLE_DEBUG
2983
2984
_mdns_dbg_printf ("\nRX[%u][%u]: " , packet -> tcpip_if , (uint32_t )packet -> ip_protocol );
2984
- if (packet -> src .type == IPADDR_TYPE_V4 ) {
2985
+ if (packet -> src .type == ESP_IPADDR_TYPE_V4 ) {
2985
2986
_mdns_dbg_printf ("From: " IPSTR ":%u, To: " IPSTR ", " , IP2STR (& packet -> src .u_addr .ip4 ), packet -> src_port , IP2STR (& packet -> dest .u_addr .ip4 ));
2986
2987
} else {
2987
2988
_mdns_dbg_printf ("From: " IPV6STR ":%u, To: " IPV6STR ", " , IPV62STR (packet -> src .u_addr .ip6 ), packet -> src_port , IPV62STR (packet -> dest .u_addr .ip6 ));
@@ -3023,12 +3024,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
3023
3024
parsed_packet -> authoritative = header .flags .value == MDNS_FLAGS_AUTHORITATIVE ;
3024
3025
parsed_packet -> distributed = header .flags .value == MDNS_FLAGS_DISTRIBUTED ;
3025
3026
parsed_packet -> id = header .id ;
3026
- #if CONFIG_LWIP_IPV6
3027
- ip_addr_copy (parsed_packet -> src , packet -> src );
3028
- #else
3029
- ip4_addr_copy (parsed_packet -> src .u_addr .ip4 , packet -> src .u_addr .ip4 );
3030
- #endif
3031
-
3027
+ esp_netif_ip_addr_copy (& parsed_packet -> src , & packet -> src );
3032
3028
parsed_packet -> src_port = packet -> src_port ;
3033
3029
3034
3030
if (header .questions ) {
@@ -3334,7 +3330,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
3334
3330
#if CONFIG_LWIP_IPV6
3335
3331
else if (type == MDNS_TYPE_AAAA ) {//ipv6
3336
3332
esp_ip_addr_t ip6 ;
3337
- ip6 .type = IPADDR_TYPE_V6 ;
3333
+ ip6 .type = ESP_IPADDR_TYPE_V6 ;
3338
3334
memcpy (ip6 .u_addr .ip6 .addr , data_ptr , MDNS_ANSWER_AAAA_SIZE );
3339
3335
if (search_result ) {
3340
3336
//check for more applicable searches (PTR & A/AAAA at the same time)
@@ -3384,7 +3380,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
3384
3380
#endif
3385
3381
else if (type == MDNS_TYPE_A ) {
3386
3382
esp_ip_addr_t ip ;
3387
- ip .type = IPADDR_TYPE_V4 ;
3383
+ ip .type = ESP_IPADDR_TYPE_V4 ;
3388
3384
memcpy (& (ip .u_addr .ip4 .addr ), data_ptr , 4 );
3389
3385
if (search_result ) {
3390
3386
//check for more applicable searches (PTR & A/AAAA at the same time)
@@ -3695,7 +3691,7 @@ static mdns_ip_addr_t * _mdns_result_addr_create_ip(esp_ip_addr_t * ip)
3695
3691
}
3696
3692
memset (a , 0 , sizeof (mdns_ip_addr_t ));
3697
3693
a -> addr .type = ip -> type ;
3698
- if (ip -> type == IPADDR_TYPE_V6 ) {
3694
+ if (ip -> type == ESP_IPADDR_TYPE_V6 ) {
3699
3695
memcpy (a -> addr .u_addr .ip6 .addr , ip -> u_addr .ip6 .addr , 16 );
3700
3696
} else {
3701
3697
a -> addr .u_addr .ip4 .addr = ip -> u_addr .ip4 .addr ;
@@ -3711,10 +3707,10 @@ static void _mdns_result_add_ip(mdns_result_t * r, esp_ip_addr_t * ip)
3711
3707
mdns_ip_addr_t * a = r -> addr ;
3712
3708
while (a ) {
3713
3709
if (a -> addr .type == ip -> type ) {
3714
- if (a -> addr .type == IPADDR_TYPE_V4 && a -> addr .u_addr .ip4 .addr == ip -> u_addr .ip4 .addr ) {
3710
+ if (a -> addr .type == ESP_IPADDR_TYPE_V4 && a -> addr .u_addr .ip4 .addr == ip -> u_addr .ip4 .addr ) {
3715
3711
return ;
3716
3712
}
3717
- if (a -> addr .type == IPADDR_TYPE_V6 && !memcmp (a -> addr .u_addr .ip6 .addr , ip -> u_addr .ip6 .addr , 16 )) {
3713
+ if (a -> addr .type == ESP_IPADDR_TYPE_V6 && !memcmp (a -> addr .u_addr .ip6 .addr , ip -> u_addr .ip6 .addr , 16 )) {
3718
3714
return ;
3719
3715
}
3720
3716
}
@@ -3736,8 +3732,8 @@ static void _mdns_search_result_add_ip(mdns_search_once_t * search, const char *
3736
3732
mdns_result_t * r = NULL ;
3737
3733
mdns_ip_addr_t * a = NULL ;
3738
3734
3739
- if ((search -> type == MDNS_TYPE_A && ip -> type == IPADDR_TYPE_V4 )
3740
- || (search -> type == MDNS_TYPE_AAAA && ip -> type == IPADDR_TYPE_V6 )
3735
+ if ((search -> type == MDNS_TYPE_A && ip -> type == ESP_IPADDR_TYPE_V4 )
3736
+ || (search -> type == MDNS_TYPE_AAAA && ip -> type == ESP_IPADDR_TYPE_V6 )
3741
3737
|| search -> type == MDNS_TYPE_ANY ) {
3742
3738
r = search -> result ;
3743
3739
while (r ) {
@@ -4178,8 +4174,7 @@ static void _mdns_free_action(mdns_action_t * action)
4178
4174
_mdns_free_tx_packet (action -> data .tx_handle .packet );
4179
4175
break ;
4180
4176
case ACTION_RX_HANDLE :
4181
- pbuf_free (action -> data .rx_handle .packet -> pb );
4182
- free (action -> data .rx_handle .packet );
4177
+ _mdns_packet_free (action -> data .rx_handle .packet );
4183
4178
break ;
4184
4179
case ACTION_DELEGATE_HOSTNAME_ADD :
4185
4180
free ((char * )action -> data .delegate_hostname .hostname );
@@ -4379,8 +4374,7 @@ static void _mdns_execute_action(mdns_action_t * action)
4379
4374
break ;
4380
4375
case ACTION_RX_HANDLE :
4381
4376
mdns_parse_packet (action -> data .rx_handle .packet );
4382
- pbuf_free (action -> data .rx_handle .packet -> pb );
4383
- free (action -> data .rx_handle .packet );
4377
+ _mdns_packet_free (action -> data .rx_handle .packet );
4384
4378
break ;
4385
4379
case ACTION_DELEGATE_HOSTNAME_ADD :
4386
4380
_mdns_delegate_hostname_add (action -> data .delegate_hostname .hostname ,
@@ -5421,7 +5415,7 @@ esp_err_t mdns_query_a(const char * name, uint32_t timeout, esp_ip4_addr_t * add
5421
5415
5422
5416
mdns_ip_addr_t * a = result -> addr ;
5423
5417
while (a ) {
5424
- if (a -> addr .type == IPADDR_TYPE_V4 ) {
5418
+ if (a -> addr .type == ESP_IPADDR_TYPE_V4 ) {
5425
5419
addr -> addr = a -> addr .u_addr .ip4 .addr ;
5426
5420
mdns_query_results_free (result );
5427
5421
return ESP_OK ;
@@ -5459,7 +5453,7 @@ esp_err_t mdns_query_aaaa(const char * name, uint32_t timeout, esp_ip6_addr_t *
5459
5453
5460
5454
mdns_ip_addr_t * a = result -> addr ;
5461
5455
while (a ) {
5462
- if (a -> addr .type == IPADDR_TYPE_V6 ) {
5456
+ if (a -> addr .type == ESP_IPADDR_TYPE_V6 ) {
5463
5457
memcpy (addr -> addr , a -> addr .u_addr .ip6 .addr , 16 );
5464
5458
mdns_query_results_free (result );
5465
5459
return ESP_OK ;
0 commit comments