Commit 292d7088 authored by Fawzi Mohamed's avatar Fawzi Mohamed

zeroconf: apple 320.10.80 and 333.10 changes

Change-Id: Icb0f21d09d803c7fb031816423438e3276ce7b18
Reviewed-by: default avatarFawzi Mohamed <fawzi.mohamed@nokia.com>
parent cd2dab29
......@@ -29,6 +29,10 @@
#include <errno.h>
#include <stdlib.h>
#if APPLE_OSX_mDNSResponder
#include <mach-o/dyld.h>
#endif
#include "dnssd_ipc.h"
namespace ZeroConf { namespace embeddedLib {
......@@ -37,7 +41,6 @@ static int gDaemonErr = kDNSServiceErr_NoError;
}}
extern "C" {
#if defined(_WIN32)
#define _SSIZE_T
......@@ -47,6 +50,7 @@ extern "C" {
#include <ws2tcpip.h>
#include <windows.h>
#include <stdarg.h>
#include <stdio.h>
#define sockaddr_mdns sockaddr_in
#define AF_MDNS AF_INET
......@@ -62,6 +66,7 @@ extern "C" {
#define sleep(X) Sleep((X) * 1000)
#define NOT_HAVE_SA_LEN
namespace ZeroConf { namespace embeddedLib {
static int g_initWinsock = 0;
#define LOG_WARNING kDebugLevelWarning
#define LOG_INFO kDebugLevelInfo
......@@ -78,7 +83,6 @@ namespace ZeroConf { namespace embeddedLib {
if ( buffer ) { vsprintf( buffer, message, args ); OutputDebugStringA( buffer ); free( buffer ); }
WSASetLastError( err );
}
}}
#else
#include <sys/fcntl.h> // For O_RDWR etc.
......@@ -88,6 +92,7 @@ namespace ZeroConf { namespace embeddedLib {
#define sockaddr_mdns sockaddr_un
#define AF_MDNS AF_LOCAL
#endif
#ifdef Q_OS_LINUX
......@@ -1134,6 +1139,34 @@ fail:
syslog(LOG_WARNING, "dnssd_clientstub handle_resolve_response: error reading result from daemon");
}
#if APPLE_OSX_mDNSResponder
static int32_t libSystemVersion = 0;
// Return true if the application linked against a version of libsystem where P2P
// interfaces were included by default when using kDNSServiceInterfaceIndexAny.
// Using 160.0.0 == 0xa00000 as the version threshold.
static int includeP2PWithIndexAny()
{
if (libSystemVersion == 0)
libSystemVersion = NSVersionOfLinkTimeLibrary("System");
if (libSystemVersion < 0xa00000)
return 1;
else
return 0;
}
#else // APPLE_OSX_mDNSResponder
// always return false for non Apple platforms
static int includeP2PWithIndexAny()
{
return 0;
}
#endif // APPLE_OSX_mDNSResponder
DNSServiceErrorType DNSSD_API DNSServiceResolve
(
DNSServiceRef *sdRef,
......@@ -1163,6 +1196,9 @@ DNSServiceErrorType DNSSD_API DNSServiceResolve
return kDNSServiceErr_BadParam;
}
if ((interfaceIndex == kDNSServiceInterfaceIndexAny) && includeP2PWithIndexAny())
flags |= kDNSServiceFlagsIncludeP2P;
err = ConnectToServer(sdRef, flags, resolve_request, handle_resolve_response, reinterpret_cast<void*>(callBack), context);
if (err) return err; // On error ConnectToServer leaves *sdRef set to NULL
......@@ -1221,7 +1257,12 @@ DNSServiceErrorType DNSSD_API DNSServiceQueryRecord
char *ptr;
size_t len;
ipc_msg_hdr *hdr;
DNSServiceErrorType err = ConnectToServer(sdRef, flags, query_request, handle_query_response, reinterpret_cast<void*>(callBack), context);
DNSServiceErrorType err;
if ((interfaceIndex == kDNSServiceInterfaceIndexAny) && includeP2PWithIndexAny())
flags |= kDNSServiceFlagsIncludeP2P;
err = ConnectToServer(sdRef, flags, query_request, handle_query_response, reinterpret_cast<void*>(callBack), context);
if (err) return err; // On error ConnectToServer leaves *sdRef set to NULL
if (!name) name = "\0";
......@@ -1366,7 +1407,12 @@ DNSServiceErrorType DNSSD_API DNSServiceBrowse
char *ptr;
size_t len;
ipc_msg_hdr *hdr;
DNSServiceErrorType err = ConnectToServer(sdRef, flags, browse_request, handle_browse_response, reinterpret_cast<void*>(callBack), context);
DNSServiceErrorType err;
if ((interfaceIndex == kDNSServiceInterfaceIndexAny) && includeP2PWithIndexAny())
flags |= kDNSServiceFlagsIncludeP2P;
err = ConnectToServer(sdRef, flags, browse_request, handle_browse_response, reinterpret_cast<void*>(callBack), context);
if (err) return err; // On error ConnectToServer leaves *sdRef set to NULL
if (!domain) domain = "";
......@@ -1450,6 +1496,9 @@ DNSServiceErrorType DNSSD_API DNSServiceRegister
// No callback must have auto-rename
if (!callBack && (flags & kDNSServiceFlagsNoAutoRename)) return kDNSServiceErr_BadParam;
if ((interfaceIndex == kDNSServiceInterfaceIndexAny) && includeP2PWithIndexAny())
flags |= kDNSServiceFlagsIncludeP2P;
err = ConnectToServer(sdRef, flags, reg_service_request, callBack ? handle_regservice_response : NULL, reinterpret_cast<void*>(callBack), context);
if (err) return err; // On error ConnectToServer leaves *sdRef set to NULL
......@@ -1595,6 +1644,9 @@ DNSServiceErrorType DNSSD_API DNSServiceRegisterRecord
int f2 = (flags & kDNSServiceFlagsUnique) != 0;
if (f1 + f2 != 1) return kDNSServiceErr_BadParam;
if ((interfaceIndex == kDNSServiceInterfaceIndexAny) && includeP2PWithIndexAny())
flags |= kDNSServiceFlagsIncludeP2P;
if (!sdRef) { syslog(LOG_WARNING, "dnssd_clientstub DNSServiceRegisterRecord called with NULL DNSServiceRef"); return kDNSServiceErr_BadParam; }
if (!DNSServiceRefValid(sdRef))
......
......@@ -154,8 +154,9 @@ typedef enum
} reply_op_t;
}}
extern "C" {
#if defined(_WIN64)
# pragma pack(4)
# pragma pack(push,4)
#endif
// Define context object big enough to hold a 64-bit pointer,
......@@ -179,6 +180,10 @@ typedef packedstruct
// index/socket pair uniquely identifies a record. (Used to select records for removal by DNSServiceRemoveRecord())
} ipc_msg_hdr;
#if defined(_WIN64)
# pragma pack(pop)
#endif
// routines to write to and extract data from message buffers.
// caller responsible for bounds checking.
// ptr is the address of the pointer to the start of the field.
......@@ -216,4 +221,5 @@ struct CompileTimeAssertionChecks_dnssd_ipc
char assert1[(sizeof(ipc_msg_hdr) == 28) ? 1 : -1];
};
}}
#endif // DNSSD_IPC_H
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment