@@ -761,6 +761,7 @@ static uint16_t _mdns_append_a_record(uint8_t * packet, uint16_t * index, uint32
761
761
return record_length ;
762
762
}
763
763
764
+ #if CONFIG_LWIP_IPV6
764
765
/**
765
766
* @brief appends AAAA record to a packet, incrementing the index
766
767
*
@@ -809,6 +810,7 @@ static uint16_t _mdns_append_aaaa_record(uint8_t * packet, uint16_t * index, uin
809
810
record_length += part_length ;
810
811
return record_length ;
811
812
}
813
+ #endif
812
814
813
815
/**
814
816
* @brief Append question to packet
@@ -874,6 +876,7 @@ static bool _mdns_if_is_dup(mdns_if_t tcpip_if)
874
876
return false;
875
877
}
876
878
879
+ #if CONFIG_LWIP_IPV6
877
880
/**
878
881
* @brief Check if IPv6 address is NULL
879
882
*/
@@ -888,6 +891,7 @@ static bool _ipv6_address_is_zero(esp_ip6_addr_t ip6)
888
891
}
889
892
return true;
890
893
}
894
+ #endif
891
895
892
896
/**
893
897
* @brief Append answer to packet
@@ -936,7 +940,9 @@ static uint8_t _mdns_append_answer(uint8_t * packet, uint16_t * index, mdns_out_
936
940
return 2 ;
937
941
}
938
942
return 1 ;
939
- } else if (answer -> type == MDNS_TYPE_AAAA ) {
943
+ }
944
+ #if CONFIG_LWIP_IPV6
945
+ else if (answer -> type == MDNS_TYPE_AAAA ) {
940
946
struct esp_ip6_addr if_ip6 ;
941
947
if (!_mdns_server -> interfaces [tcpip_if ].pcbs [MDNS_IP_PROTOCOL_V6 ].pcb && _mdns_server -> interfaces [tcpip_if ].pcbs [MDNS_IP_PROTOCOL_V6 ].state != PCB_DUP ) {
942
948
return 0 ;
@@ -962,6 +968,7 @@ static uint8_t _mdns_append_answer(uint8_t * packet, uint16_t * index, mdns_out_
962
968
}
963
969
return 1 ;
964
970
}
971
+ #endif
965
972
return 0 ;
966
973
}
967
974
@@ -1235,11 +1242,14 @@ static mdns_tx_packet_t * _mdns_alloc_packet_default(mdns_if_t tcpip_if, mdns_ip
1235
1242
packet -> ip_protocol = ip_protocol ;
1236
1243
packet -> port = MDNS_SERVICE_PORT ;
1237
1244
if (ip_protocol == MDNS_IP_PROTOCOL_V4 ) {
1238
- IP_ADDR4 (& packet -> dst , 224 , 0 , 0 , 251 );
1239
- } else {
1245
+ IP4_ADDR (& packet -> dst .u_addr .ip4 , 224 , 0 , 0 , 251 );
1246
+ }
1247
+ #if CONFIG_LWIP_IPV6
1248
+ else {
1240
1249
esp_ip_addr_t addr = IPADDR6_INIT (0x000002ff , 0 , 0 , 0xfb000000 );
1241
1250
memcpy (& packet -> dst , & addr , sizeof (esp_ip_addr_t ));
1242
1251
}
1252
+ #endif
1243
1253
return packet ;
1244
1254
}
1245
1255
@@ -2253,6 +2263,7 @@ static int _mdns_check_a_collision(esp_ip4_addr_t * ip, mdns_if_t tcpip_if)
2253
2263
return 0 ;//same
2254
2264
}
2255
2265
2266
+ #if CONFIG_LWIP_IPV6
2256
2267
/**
2257
2268
* @brief Detect IPv6 address collision
2258
2269
*/
@@ -2286,6 +2297,7 @@ static int _mdns_check_aaaa_collision(esp_ip6_addr_t * ip, mdns_if_t tcpip_if)
2286
2297
}
2287
2298
return 0 ;//same
2288
2299
}
2300
+ #endif
2289
2301
2290
2302
/**
2291
2303
* @brief Check if parsed name is discovery
@@ -2678,7 +2690,12 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
2678
2690
parsed_packet -> authoritative = header .flags .value == MDNS_FLAGS_AUTHORITATIVE ;
2679
2691
parsed_packet -> distributed = header .flags .value == MDNS_FLAGS_DISTRIBUTED ;
2680
2692
parsed_packet -> id = header .id ;
2693
+ #if CONFIG_LWIP_IPV6
2681
2694
ip_addr_copy (parsed_packet -> src , packet -> src );
2695
+ #else
2696
+ ip4_addr_copy (parsed_packet -> src .u_addr .ip4 , packet -> src .u_addr .ip4 );
2697
+ #endif
2698
+
2682
2699
parsed_packet -> src_port = packet -> src_port ;
2683
2700
2684
2701
if (header .questions ) {
@@ -2977,7 +2994,9 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
2977
2994
}
2978
2995
}
2979
2996
2980
- } else if (type == MDNS_TYPE_AAAA ) {//ipv6
2997
+ }
2998
+ #if CONFIG_LWIP_IPV6
2999
+ else if (type == MDNS_TYPE_AAAA ) {//ipv6
2981
3000
esp_ip_addr_t ip6 ;
2982
3001
ip6 .type = IPADDR_TYPE_V6 ;
2983
3002
memcpy (ip6 .u_addr .ip6 .addr , data_ptr , MDNS_ANSWER_AAAA_SIZE );
@@ -3023,7 +3042,9 @@ void mdns_parse_packet(mdns_rx_packet_t * packet)
3023
3042
}
3024
3043
}
3025
3044
3026
- } else if (type == MDNS_TYPE_A ) {
3045
+ }
3046
+ #endif
3047
+ else if (type == MDNS_TYPE_A ) {
3027
3048
esp_ip_addr_t ip ;
3028
3049
ip .type = IPADDR_TYPE_V4 ;
3029
3050
memcpy (& (ip .u_addr .ip4 .addr ), data_ptr , 4 );
@@ -4276,13 +4297,17 @@ esp_err_t mdns_init(void)
4276
4297
}
4277
4298
#endif
4278
4299
uint8_t i ;
4300
+ #if CONFIG_LWIP_IPV6
4279
4301
esp_ip6_addr_t tmp_addr6 ;
4302
+ #endif
4280
4303
esp_netif_ip_info_t if_ip_info ;
4281
4304
4282
4305
for (i = 0 ; i < MDNS_IF_MAX ; i ++ ) {
4306
+ #if CONFIG_LWIP_IPV6
4283
4307
if (!esp_netif_get_ip6_linklocal (_mdns_get_esp_netif (i ), & tmp_addr6 ) && !_ipv6_address_is_zero (tmp_addr6 )) {
4284
4308
_mdns_enable_pcb (i , MDNS_IP_PROTOCOL_V6 );
4285
4309
}
4310
+ #endif
4286
4311
if (!esp_netif_get_ip_info (_mdns_get_esp_netif (i ), & if_ip_info ) && if_ip_info .ip .addr ) {
4287
4312
_mdns_enable_pcb (i , MDNS_IP_PROTOCOL_V4 );
4288
4313
}
@@ -4818,6 +4843,7 @@ esp_err_t mdns_query_a(const char * name, uint32_t timeout, esp_ip4_addr_t * add
4818
4843
return ESP_ERR_NOT_FOUND ;
4819
4844
}
4820
4845
4846
+ #if CONFIG_LWIP_IPV6
4821
4847
esp_err_t mdns_query_aaaa (const char * name , uint32_t timeout , esp_ip6_addr_t * addr )
4822
4848
{
4823
4849
mdns_result_t * result = NULL ;
@@ -4850,6 +4876,7 @@ esp_err_t mdns_query_aaaa(const char * name, uint32_t timeout, esp_ip6_addr_t *
4850
4876
mdns_query_results_free (result );
4851
4877
return ESP_ERR_NOT_FOUND ;
4852
4878
}
4879
+ #endif
4853
4880
4854
4881
#ifdef MDNS_ENABLE_DEBUG
4855
4882
0 commit comments