Placing all MDNS code under ifdef HAVE MDNS SUPPORT to minimize risk in main branch.

This commit is contained in:
Christian Huitema 2016-12-22 20:30:14 -08:00
parent 1d24c90768
commit 99fb7100ea
4 changed files with 23 additions and 8 deletions

View File

@ -1682,12 +1682,17 @@ getdns_context_set_namespaces(getdns_context *context,
for (i = 0; i < namespace_count; i++) { for (i = 0; i < namespace_count; i++) {
if (namespaces[i] == GETDNS_NAMESPACE_NETBIOS || if (namespaces[i] == GETDNS_NAMESPACE_NETBIOS ||
#ifndef HAVE_MDNS_SUPPORT
namespaces[i] == GETDNS_NAMESPACE_MDNS ||
#endif
namespaces[i] == GETDNS_NAMESPACE_NIS) namespaces[i] == GETDNS_NAMESPACE_NIS)
r = GETDNS_RETURN_NOT_IMPLEMENTED; r = GETDNS_RETURN_NOT_IMPLEMENTED;
else if (namespaces[i] != GETDNS_NAMESPACE_DNS && else if (namespaces[i] != GETDNS_NAMESPACE_DNS &&
namespaces[i] != GETDNS_NAMESPACE_LOCALNAMES && #ifdef HAVE_MDNS_SUPPORT
namespaces[i] != GETDNS_NAMESPACE_MDNS) namespaces[i] != GETDNS_NAMESPACE_MDNS &&
#endif
namespaces[i] != GETDNS_NAMESPACE_LOCALNAMES )
return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; return GETDNS_RETURN_CONTEXT_UPDATE_FAIL;
} }
GETDNS_FREE(context->my_mf, context->namespaces); GETDNS_FREE(context->my_mf, context->namespaces);

View File

@ -477,6 +477,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
( req, localnames_response); ( req, localnames_response);
break; break;
} }
#ifdef HAVE_MDNS_SUPPORT
} else if (context->namespaces[i] == GETDNS_NAMESPACE_MDNS) { } else if (context->namespaces[i] == GETDNS_NAMESPACE_MDNS) {
/* Check whether the name belongs in the MDNS space */ /* Check whether the name belongs in the MDNS space */
if (!(r = _getdns_mdns_namespace_check(req))) if (!(r = _getdns_mdns_namespace_check(req)))
@ -497,6 +498,7 @@ getdns_general_ns(getdns_context *context, getdns_eventloop *loop,
/* Stop processing more namespaces, since there was a match */ /* Stop processing more namespaces, since there was a match */
break; break;
} }
#endif /* HAVE_MDNS_SUPPORT */
} else if (context->namespaces[i] == GETDNS_NAMESPACE_DNS) { } else if (context->namespaces[i] == GETDNS_NAMESPACE_DNS) {
/* TODO: We will get a good return code here even if /* TODO: We will get a good return code here even if

View File

@ -27,6 +27,8 @@
#include "util-internal.h" #include "util-internal.h"
#include "mdns.h" #include "mdns.h"
#ifdef HAVE_MDNS_SUPPORT
#ifdef USE_WINSOCK #ifdef USE_WINSOCK
typedef u_short sa_family_t; typedef u_short sa_family_t;
#define _getdns_EWOULDBLOCK (WSAGetLastError() == WSATRY_AGAIN ||\ #define _getdns_EWOULDBLOCK (WSAGetLastError() == WSATRY_AGAIN ||\
@ -46,10 +48,12 @@ uint64_t _getdns_get_time_as_uintt64();
#define MDNS_MCAST_IPV4_LONG 0xE00000FB /* 224.0.0.251 */ #define MDNS_MCAST_IPV4_LONG 0xE00000FB /* 224.0.0.251 */
#define MDNS_MCAST_PORT 5353 #define MDNS_MCAST_PORT 5353
static uint8_t mdns_mcast_ipv6[] = { /*
0xFF, 0x02, 0, 0, 0, 0, 0, 0, * TODO: When we start supporting IPv6 with MDNS, need to define this:
0, 0, 0, 0, 0, 0, 0, 0xFB }; * static uint8_t mdns_mcast_ipv6[] = {
* 0xFF, 0x02, 0, 0, 0, 0, 0, 0,
* 0, 0, 0, 0, 0, 0, 0, 0xFB };
*/
static uint8_t mdns_suffix_dot_local[] = { 5, 'l', 'o', 'c', 'a', 'l', 0 }; static uint8_t mdns_suffix_dot_local[] = { 5, 'l', 'o', 'c', 'a', 'l', 0 };
static uint8_t mdns_suffix_254_169_in_addr_arpa[] = { static uint8_t mdns_suffix_254_169_in_addr_arpa[] = {
@ -352,4 +356,6 @@ _getdns_mdns_namespace_check(
ret = GETDNS_RETURN_GOOD; ret = GETDNS_RETURN_GOOD;
return ret; return ret;
} }
#endif /* HAVE_MDNS_SUPPORT */

View File

@ -21,6 +21,7 @@
#ifndef MDNS_H #ifndef MDNS_H
#define MDNS_H #define MDNS_H
#ifdef HAVE_MDNS_SUPPORT
#include "getdns/getdns.h" #include "getdns/getdns.h"
#include "types-internal.h" #include "types-internal.h"
@ -29,5 +30,6 @@ _getdns_submit_mdns_request(getdns_network_req *netreq);
getdns_return_t getdns_return_t
_getdns_mdns_namespace_check(getdns_dns_req *dnsreq); _getdns_mdns_namespace_check(getdns_dns_req *dnsreq);
#endif /* HAVE_MDNS_SUPPORT */
#endif /* MDNS_H */ #endif /* MDNS_H */