Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/apache2/mDNSResponder/dist import latest version
details: https://anonhg.NetBSD.org/src/rev/4c0a1931ed63
branches: trunk
changeset: 358714:4c0a1931ed63
user: christos <christos%NetBSD.org@localhost>
date: Sun Jan 14 19:40:50 2018 +0000
description:
import latest version
diffstat:
external/apache2/mDNSResponder/dist/Clients/ClientCommon.c | 9 +-
external/apache2/mDNSResponder/dist/Clients/dnsctl.c | 303 +-
external/apache2/mDNSResponder/dist/Clients/dnssdutil.c | 7899 ++++++++++
external/apache2/mDNSResponder/dist/mDNSCore/CryptoAlg.c | 2 +-
external/apache2/mDNSResponder/dist/mDNSCore/CryptoAlg.h | 3 +-
external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h | 42 +-
external/apache2/mDNSResponder/dist/mDNSCore/anonymous.c | 58 +-
external/apache2/mDNSResponder/dist/mDNSCore/anonymous.h | 2 +-
external/apache2/mDNSResponder/dist/mDNSCore/dnsproxy.c | 181 +-
external/apache2/mDNSResponder/dist/mDNSCore/dnsproxy.h | 11 +-
external/apache2/mDNSResponder/dist/mDNSCore/dnssec.c | 65 +-
external/apache2/mDNSResponder/dist/mDNSCore/dnssec.h | 3 +-
external/apache2/mDNSResponder/dist/mDNSCore/mDNSDebug.h | 10 +-
external/apache2/mDNSResponder/dist/mDNSCore/nsec.c | 23 +-
external/apache2/mDNSResponder/dist/mDNSCore/nsec.h | 3 +-
external/apache2/mDNSResponder/dist/mDNSCore/nsec3.c | 37 +-
external/apache2/mDNSResponder/dist/mDNSCore/nsec3.h | 2 +-
external/apache2/mDNSResponder/dist/mDNSCore/uDNS.h | 16 +-
external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.h | 2 +-
external/apache2/mDNSResponder/dist/mDNSShared/CommonServices.h | 6 +
external/apache2/mDNSResponder/dist/mDNSShared/GenLinkedList.c | 9 +-
external/apache2/mDNSResponder/dist/mDNSShared/dns_sd_internal.h | 15 +
external/apache2/mDNSResponder/dist/mDNSShared/dns_sd_private.h | 89 +
external/apache2/mDNSResponder/dist/mDNSShared/dnsextd_parser.y | 33 +-
external/apache2/mDNSResponder/dist/mDNSShared/dnssd_ipc.c | 4 +-
external/apache2/mDNSResponder/dist/mDNSShared/mDNSDebug.c | 9 +-
external/apache2/mDNSResponder/dist/mDNSShared/mDNSResponder.8 | 27 +-
external/apache2/mDNSResponder/dist/mDNSShared/uds_daemon.h | 222 +-
external/apache2/mDNSResponder/dist/unittests/CNameRecordTests.c | 400 +
external/apache2/mDNSResponder/dist/unittests/CNameRecordTests.h | 9 +
external/apache2/mDNSResponder/dist/unittests/DNSMessageTest.c | 50 +
external/apache2/mDNSResponder/dist/unittests/DNSMessageTest.h | 8 +
external/apache2/mDNSResponder/dist/unittests/DomainNameTest.c | 28 +
external/apache2/mDNSResponder/dist/unittests/DomainNameTest.h | 7 +
external/apache2/mDNSResponder/dist/unittests/InterfaceTest.c | 19 +
external/apache2/mDNSResponder/dist/unittests/InterfaceTest.h | 9 +
external/apache2/mDNSResponder/dist/unittests/LocalOnlyTimeoutTests.c | 378 +
external/apache2/mDNSResponder/dist/unittests/LocalOnlyTimeoutTests.h | 9 +
external/apache2/mDNSResponder/dist/unittests/ResourceRecordTest.c | 61 +
external/apache2/mDNSResponder/dist/unittests/ResourceRecordTest.h | 10 +
external/apache2/mDNSResponder/dist/unittests/daemon_ut.c | 35 +
external/apache2/mDNSResponder/dist/unittests/mDNSCoreReceiveTest.c | 151 +
external/apache2/mDNSResponder/dist/unittests/mDNSCoreReceiveTest.h | 9 +
external/apache2/mDNSResponder/dist/unittests/main.c | 42 +
external/apache2/mDNSResponder/dist/unittests/mdns_macosx_ut.c | 66 +
external/apache2/mDNSResponder/dist/unittests/mdns_ut.c | 17 +
external/apache2/mDNSResponder/dist/unittests/uds_daemon_ut.c | 43 +
external/apache2/mDNSResponder/dist/unittests/unittest.c | 105 +
external/apache2/mDNSResponder/dist/unittests/unittest.h | 124 +
external/apache2/mDNSResponder/dist/unittests/unittest_common.c | 157 +
external/apache2/mDNSResponder/dist/unittests/unittest_common.h | 57 +
51 files changed, 10570 insertions(+), 309 deletions(-)
diffs (truncated from 12206 to 300 lines):
diff -r 4d43886dda1e -r 4c0a1931ed63 external/apache2/mDNSResponder/dist/Clients/ClientCommon.c
--- a/external/apache2/mDNSResponder/dist/Clients/ClientCommon.c Sun Jan 14 19:37:35 2018 +0000
+++ b/external/apache2/mDNSResponder/dist/Clients/ClientCommon.c Sun Jan 14 19:40:50 2018 +0000
@@ -1,8 +1,8 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
*
- * Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc.
+ * Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Inc.
* ("Apple") in consideration of your agreement to the following terms, and your
* use, installation, modification or redistribution of this Apple software
* constitutes acceptance of these terms. If you do not agree with these terms,
@@ -16,7 +16,7 @@
* the Apple Software in its entirety and without modifications, you must retain
* this notice and the following text and disclaimers in all such redistributions of
* the Apple Software. Neither the name, trademarks, service marks or logos of
- * Apple Computer, Inc. may be used to endorse or promote products derived from the
+ * Apple Inc. may be used to endorse or promote products derived from the
* Apple Software without specific prior written permission from Apple. Except as
* expressly stated in this notice, no other rights or licenses, express or implied,
* are granted by Apple herein, including but not limited to any patent rights that
@@ -49,8 +49,9 @@
while (*cstr && *cstr != '.') // While we have characters in the label...
{
char c = *cstr++;
- if (c == '\\' && *cstr) // If we have a backslash, and it's not the last character of the string
+ if (c == '\\') // If escape character, check next character
{
+ if (*cstr == '\0') break; // If this is the end of the string, then break
c = *cstr++;
if (isdigit(cstr[-1]) && isdigit(cstr[0]) && isdigit(cstr[1]))
{
diff -r 4d43886dda1e -r 4c0a1931ed63 external/apache2/mDNSResponder/dist/Clients/dnsctl.c
--- a/external/apache2/mDNSResponder/dist/Clients/dnsctl.c Sun Jan 14 19:37:35 2018 +0000
+++ b/external/apache2/mDNSResponder/dist/Clients/dnsctl.c Sun Jan 14 19:40:50 2018 +0000
@@ -1,6 +1,6 @@
/* -*- Mode: C; tab-width: 4 -*-
*
- * Copyright (c) 2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2012-2015 Apple Inc. All rights reserved.
*
* dnsctl.c
* Command-line tool using libdns_services.dylib
@@ -17,38 +17,42 @@
#include <sys/time.h>
#include <net/if.h> // if_nametoindex()
-#include <dispatch/dispatch.h>
#include "dns_services.h"
+#include <xpc/xpc.h>
+#include "dns_xpc.h"
//*************************************************************************************************************
// Globals:
//*************************************************************************************************************
static const char kFilePathSep = '/';
+
static DNSXConnRef ClientRef = NULL;
+static xpc_connection_t dnsctl_conn = NULL;
+
//*************************************************************************************************************
// Utility Funcs:
//*************************************************************************************************************
-static void printtimestamp(void)
+static void printtimestamp(void)
{
- struct tm tm;
- int ms;
+ struct tm tm;
+ int ms;
static char date[16];
static char new_date[16];
- struct timeval tv;
+ struct timeval tv;
gettimeofday(&tv, NULL);
localtime_r((time_t*)&tv.tv_sec, &tm);
ms = tv.tv_usec/1000;
strftime(new_date, sizeof(new_date), "%a %d %b %Y", &tm);
//display date only if it has changed
if (strncmp(date, new_date, sizeof(new_date)))
- {
+ {
printf("DATE: ---%s---\n", new_date);
- strncpy(date, new_date, sizeof(date));
- }
- printf("%2d:%02d:%02d.%03d ", tm.tm_hour, tm.tm_min, tm.tm_sec, ms);
+ strlcpy(date, new_date, sizeof(date));
+ }
+ printf("%2d:%02d:%02d.%03d ", tm.tm_hour, tm.tm_min, tm.tm_sec, ms);
}
static void print_usage(const char *arg0)
@@ -56,12 +60,31 @@
fprintf(stderr, "%s USAGE: \n", arg0);
fprintf(stderr, "%s -DP Enable DNS Proxy with Default Parameters \n", arg0);
fprintf(stderr, "%s -DP [-o <output interface>] [-i <input interface(s)>] Enable DNS Proxy \n", arg0);
+ fprintf(stderr, "%s -L [1/2/3/4] Change mDNSResponder Logging Level \n", arg0);
+ fprintf(stderr, "%s -I Print mDNSResponder STATE INFO \n", arg0);
+}
+
+
+static bool DebugEnabled()
+{
+ return true; // keep this true to debug the XPC msgs
+}
+
+static void DebugLog(const char *prefix, xpc_object_t o)
+{
+ if (!DebugEnabled())
+ return;
+
+ char *desc = xpc_copy_description(o);
+ printf("%s: %s \n", prefix, desc);
+ free(desc);
}
//*************************************************************************************************************
// CallBack Funcs:
//*************************************************************************************************************
+
// DNSXEnableProxy Callback from the Daemon
static void dnsproxy_reply(DNSXConnRef connRef, DNSXErrorType errCode)
{
@@ -69,59 +92,108 @@
printtimestamp();
switch (errCode)
{
- case kDNSX_NoError : printf(" SUCCESS \n"); break;
- case kDNSX_DictError : printf(" DICT ERROR \n"); break;
+ case kDNSX_NoError : printf(" SUCCESS \n");
+ break;
case kDNSX_DaemonNotRunning : printf(" NO DAEMON \n");
- DNSXRefDeAlloc(ClientRef); break;
- case kDNSX_Engaged : printf(" ENGAGED \n");
- DNSXRefDeAlloc(ClientRef); break;
+ DNSXRefDeAlloc(ClientRef); break;
+ case kDNSX_BadParam : printf(" BAD PARAMETER \n");
+ DNSXRefDeAlloc(ClientRef); break;
+ case kDNSX_Busy : printf(" BUSY \n");
+ DNSXRefDeAlloc(ClientRef); break;
case kDNSX_UnknownErr :
- default : printf("UNKNOWN ERR \n");
- DNSXRefDeAlloc(ClientRef); break;
+ default : printf(" UNKNOWN ERR \n");
+ DNSXRefDeAlloc(ClientRef); break;
}
fflush(NULL);
+
+}
+//*************************************************************************************************************
+// XPC Funcs:
+//*************************************************************************************************************
+
+static void Init_Connection(const char *servname)
+{
+ dnsctl_conn = xpc_connection_create_mach_service(servname, dispatch_get_main_queue(), XPC_CONNECTION_MACH_SERVICE_PRIVILEGED);
+
+ xpc_connection_set_event_handler(dnsctl_conn, ^(xpc_object_t event)
+ {
+ printf("InitConnection: [%s] \n", xpc_dictionary_get_string(event, XPC_ERROR_KEY_DESCRIPTION));
+ });
+
+ xpc_connection_resume(dnsctl_conn);
+}
+
+static void SendDictToServer(xpc_object_t msg)
+{
+
+ DebugLog("SendDictToServer Sending msg to Daemon", msg);
+
+ xpc_connection_send_message_with_reply(dnsctl_conn, msg, dispatch_get_main_queue(), ^(xpc_object_t recv_msg)
+ {
+ xpc_type_t type = xpc_get_type(recv_msg);
+
+ if (type == XPC_TYPE_DICTIONARY)
+ {
+ DebugLog("SendDictToServer Received reply msg from Daemon", recv_msg);
+ /*
+ // If we ever want to do something based on the reply of the daemon
+ switch (daemon_status)
+ {
+ default:
+ break;
+ }
+ */
+ }
+ else
+ {
+ printf("SendDictToServer Received unexpected reply from daemon [%s]",
+ xpc_dictionary_get_string(recv_msg, XPC_ERROR_KEY_DESCRIPTION));
+ DebugLog("SendDictToServer Unexpected Reply contents", recv_msg);
+ }
+ exit(1);
+ });
}
//*************************************************************************************************************
int main(int argc, char **argv)
{
- DNSXErrorType err;
-
- // Default i/p intf is lo0 and o/p intf is primary interface
- IfIndex Ipintfs[MaxInputIf] = {1, 0, 0, 0, 0};
- IfIndex Opintf = kDNSIfindexAny;
-
// Extract program name from argv[0], which by convention contains the path to this executable
- const char *a0 = strrchr(argv[0], kFilePathSep) + 1;
+ const char *a0 = strrchr(argv[0], kFilePathSep) + 1;
if (a0 == (const char *)1)
a0 = argv[0];
-
+
// Must run as root
- if (0 != geteuid())
- {
- fprintf(stderr, "%s MUST run as root!!\n", a0);
- exit(-1);
+ if (0 != geteuid())
+ {
+ fprintf(stderr, "%s MUST run as root!!\n", a0);
+ exit(-1);
}
if ((sizeof(argv) == 8))
printf("dnsctl running in 64-bit mode\n");
else if ((sizeof(argv) == 4))
printf("dnsctl running in 32-bit mode\n");
-
+
// expects atleast one argument
if (argc < 2)
goto Usage;
-
- if ( !strcmp(argv[1], "-DP") || !strcmp(argv[1], "-dp") )
+
+ printtimestamp();
+ if (!strcasecmp(argv[1], "-DP"))
{
+ DNSXErrorType err;
+ // Default i/p intf is lo0 and o/p intf is primary interface
+ IfIndex Ipintfs[MaxInputIf] = {1, 0, 0, 0, 0};
+ IfIndex Opintf = kDNSIfindexAny;
+
if (argc == 2)
{
- printtimestamp();
- printf("Proceeding to Enable DNSProxy on mDNSResponder with Default Parameters\n");
dispatch_queue_t my_Q = dispatch_queue_create("com.apple.dnsctl.callback_queue", NULL);
err = DNSXEnableProxy(&ClientRef, kDNSProxyEnable, Ipintfs, Opintf, my_Q, dnsproxy_reply);
- }
+ if (err)
+ fprintf(stderr, "DNSXEnableProxy returned %d\n", err);
+ }
else if (argc > 2)
{
argc--;
@@ -129,17 +201,17 @@
if (!strcmp(argv[1], "-o"))
{
Opintf = if_nametoindex(argv[2]);
- if (!Opintf)
+ if (!Opintf)
Opintf = atoi(argv[2]);
- if (!Opintf)
- {
- fprintf(stderr, "Could not parse o/p interface [%s]: Passing default primary \n", argv[2]);
+ if (!Opintf)
+ {
+ fprintf(stderr, "Could not parse o/p interface [%s]: Passing default primary \n", argv[2]);
Opintf = kDNSIfindexAny;
}
argc -= 2;
argv += 2;
}
- if (argc > 2 && !strcmp(argv[1], "-i"))
+ if (argc > 2 && !strcmp(argv[1], "-i"))
{
int i;
argc--;
@@ -148,31 +220,164 @@
{
Ipintfs[i] = if_nametoindex(argv[1]);
if (!Ipintfs[i])
- Ipintfs[i] = atoi(argv[1]);
+ Ipintfs[i] = atoi(argv[1]);
if (!Ipintfs[i])
{
- fprintf(stderr, "Could not parse i/p interface [%s]: Passing default lo0 \n", argv[2]);
+ fprintf(stderr, "Could not parse i/p interface [%s]: Passing default lo0 \n", argv[2]);
Ipintfs[i] = 1;
}
argc--;
argv++;
Home |
Main Index |
Thread Index |
Old Index