Revert "mdns.c: use constants from dns.h/.c"

This reverts commit 0e883bbbc5.
This commit is contained in:
goldsimon 2016-12-09 13:08:00 +01:00
parent 0e883bbbc5
commit f308694dd4

View File

@ -63,9 +63,6 @@
#include "lwip/ip_addr.h"
#include "lwip/mem.h"
#include "lwip/prot/dns.h"
#include "lwip/dns.h"
#include "lwip/mld6.h"
#include "lwip/igmp.h"
#include <string.h>
@ -81,8 +78,19 @@
#error "If you want to use MDNS, you have to define LWIP_UDP=1 in your lwipopts.h"
#endif
#if LWIP_IPV4
#include "lwip/igmp.h"
/* IPv4 multicast group 224.0.0.251 */
static const ip_addr_t v4group = IPADDR4_INIT(PP_HTONL(0xE00000FBUL));
#endif
#define MDNS_PORT DNS_MQUERY_PORT
#if LWIP_IPV6
#include "lwip/mld6.h"
/* IPv6 multicast group FF02::FB */
static const ip_addr_t v6group = IPADDR6_INIT(PP_HTONL(0xFF020000UL), PP_HTONL(0x00000000UL), PP_HTONL(0x00000000UL), PP_HTONL(0x000000FBUL));
#endif
#define MDNS_PORT 5353
#define MDNS_TTL 255
/* Stored offsets to beginning of domain names
@ -1412,11 +1420,11 @@ mdns_send_outpacket(struct mdns_outpacket *outpkt)
if (IP_IS_V6_VAL(outpkt->dest_addr)) {
#if LWIP_IPV6
mcast_destaddr = &dns_mquery_v6group;
mcast_destaddr = &v6group;
#endif
} else {
#if LWIP_IPV4
mcast_destaddr = &dns_mquery_v4group;
mcast_destaddr = &v4group;
#endif
}
/* Send created packet */
@ -1772,14 +1780,14 @@ mdns_recv(void *arg, struct udp_pcb *pcb, struct pbuf *p, const ip_addr_t *addr,
#if LWIP_IPV6
if (IP_IS_V6(ip_current_dest_addr())) {
if (!ip_addr_cmp(ip_current_dest_addr(), &dns_mquery_v6group)) {
if (!ip_addr_cmp(ip_current_dest_addr(), &v6group)) {
packet.recv_unicast = 1;
}
}
#endif
#if LWIP_IPV4
if (!IP_IS_V6(ip_current_dest_addr())) {
if (!ip_addr_cmp(ip_current_dest_addr(), &dns_mquery_v4group)) {
if (!ip_addr_cmp(ip_current_dest_addr(), &v4group)) {
packet.recv_unicast = 1;
}
}
@ -1875,13 +1883,13 @@ mdns_resp_add_netif(struct netif *netif, const char *hostname, u32_t dns_ttl)
/* Join multicast groups */
#if LWIP_IPV4
res = igmp_joingroup_netif(netif, ip_2_ip4(&dns_mquery_v4group));
res = igmp_joingroup_netif(netif, ip_2_ip4(&v4group));
if (res != ERR_OK) {
goto cleanup;
}
#endif
#if LWIP_IPV6
res = mld6_joingroup_netif(netif, ip_2_ip6(&dns_mquery_v6group));
res = mld6_joingroup_netif(netif, ip_2_ip6(&v6group));
if (res != ERR_OK) {
goto cleanup;
}
@ -1922,10 +1930,10 @@ mdns_resp_remove_netif(struct netif *netif)
/* Leave multicast groups */
#if LWIP_IPV4
igmp_leavegroup_netif(netif, ip_2_ip4(&dns_mquery_v4group));
igmp_leavegroup_netif(netif, ip_2_ip4(&v4group));
#endif
#if LWIP_IPV6
mld6_leavegroup_netif(netif, ip_2_ip6(&dns_mquery_v6group));
mld6_leavegroup_netif(netif, ip_2_ip6(&v6group));
#endif
mem_free(mdns);