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 Apple's mDNSRespo...
details: https://anonhg.NetBSD.org/src/rev/56087be1a25b
branches: trunk
changeset: 747729:56087be1a25b
user: tsarna <tsarna%NetBSD.org@localhost>
date: Tue Sep 29 22:14:03 2009 +0000
description:
Import Apple's mDNSResponder 212.1 per tech-net discussion
diffstat:
external/apache2/mDNSResponder/dist/Clients/ClientCommon.c | 86 +
external/apache2/mDNSResponder/dist/Clients/ClientCommon.h | 49 +
external/apache2/mDNSResponder/dist/Clients/dns-sd.c | 1235 +
external/apache2/mDNSResponder/dist/LICENSE | 13 +
external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.c | 3449 +++
external/apache2/mDNSResponder/dist/mDNSCore/DNSCommon.h | 419 +
external/apache2/mDNSResponder/dist/mDNSCore/DNSDigest.c | 1664 +
external/apache2/mDNSResponder/dist/mDNSCore/mDNS.c | 9793 ++++++++++
external/apache2/mDNSResponder/dist/mDNSCore/mDNSDebug.h | 307 +
external/apache2/mDNSResponder/dist/mDNSCore/mDNSEmbeddedAPI.h | 3478 +++
external/apache2/mDNSResponder/dist/mDNSCore/uDNS.c | 5303 +++++
external/apache2/mDNSResponder/dist/mDNSCore/uDNS.h | 318 +
external/apache2/mDNSResponder/dist/mDNSPosix/PosixDaemon.c | 304 +
external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.c | 1690 +
external/apache2/mDNSResponder/dist/mDNSPosix/mDNSPosix.h | 148 +
external/apache2/mDNSResponder/dist/mDNSPosix/mDNSUNP.c | 793 +
external/apache2/mDNSResponder/dist/mDNSPosix/mDNSUNP.h | 187 +
external/apache2/mDNSResponder/dist/mDNSShared/CommonServices.h | 1556 +
external/apache2/mDNSResponder/dist/mDNSShared/GenLinkedList.c | 332 +
external/apache2/mDNSResponder/dist/mDNSShared/GenLinkedList.h | 107 +
external/apache2/mDNSResponder/dist/mDNSShared/PlatformCommon.c | 269 +
external/apache2/mDNSResponder/dist/mDNSShared/PlatformCommon.h | 47 +
external/apache2/mDNSResponder/dist/mDNSShared/dns-sd.1 | 215 +
external/apache2/mDNSResponder/dist/mDNSShared/dns_sd.h | 2358 ++
external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientlib.c | 439 +
external/apache2/mDNSResponder/dist/mDNSShared/dnssd_clientstub.c | 1872 +
external/apache2/mDNSResponder/dist/mDNSShared/dnssd_ipc.c | 217 +
external/apache2/mDNSResponder/dist/mDNSShared/dnssd_ipc.h | 341 +
external/apache2/mDNSResponder/dist/mDNSShared/mDNSDebug.c | 148 +
external/apache2/mDNSResponder/dist/mDNSShared/mDNSResponder.8 | 149 +
external/apache2/mDNSResponder/dist/mDNSShared/uds_daemon.c | 4517 ++++
external/apache2/mDNSResponder/dist/mDNSShared/uds_daemon.h | 153 +
32 files changed, 41956 insertions(+), 0 deletions(-)
diffs (truncated from 42084 to 300 lines):
diff -r d718a2ae1e96 -r 56087be1a25b external/apache2/mDNSResponder/dist/Clients/ClientCommon.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/apache2/mDNSResponder/dist/Clients/ClientCommon.c Tue Sep 29 22:14:03 2009 +0000
@@ -0,0 +1,86 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2008 Apple Inc. All rights reserved.
+ *
+ * Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, 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,
+ * please do not use, install, modify or redistribute this Apple software.
+ *
+ * In consideration of your agreement to abide by the following terms, and subject
+ * to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+ * copyrights in this original Apple software (the "Apple Software"), to use,
+ * reproduce, modify and redistribute the Apple Software, with or without
+ * modifications, in source and/or binary forms; provided that if you redistribute
+ * 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 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
+ * may be infringed by your derivative works or by other works in which the Apple
+ * Software may be incorporated.
+ *
+ * The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
+ * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+ * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+ * COMBINATION WITH YOUR PRODUCTS.
+ *
+ * IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+ * OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+ * (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Change History (most recent first):
+
+Log: ClientCommon.c,v $
+Revision 1.2 2008/05/08 00:42:03 cheshire
+Removed some unnecessary header files
+
+Revision 1.1 2008/05/08 00:25:48 cheshire
+<rdar://problem/5919272> GetNextLabel insufficiently defensive
+
+
+*/
+
+#include <ctype.h>
+#include <stdio.h> // For stdout, stderr
+
+#include "ClientCommon.h"
+
+const char *GetNextLabel(const char *cstr, char label[64])
+ {
+ char *ptr = label;
+ 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
+ {
+ c = *cstr++;
+ if (isdigit(cstr[-1]) && isdigit(cstr[0]) && isdigit(cstr[1]))
+ {
+ int v0 = cstr[-1] - '0'; // then interpret as three-digit decimal
+ int v1 = cstr[ 0] - '0';
+ int v2 = cstr[ 1] - '0';
+ int val = v0 * 100 + v1 * 10 + v2;
+ // If valid three-digit decimal value, use it
+ // Note that although ascii nuls are possible in DNS labels
+ // we're building a C string here so we have no way to represent that
+ if (val == 0) val = '-';
+ if (val <= 255) { c = (char)val; cstr += 2; }
+ }
+ }
+ *ptr++ = c;
+ if (ptr >= label+64) { label[63] = 0; return(NULL); } // Illegal label more than 63 bytes
+ }
+ *ptr = 0; // Null-terminate label text
+ if (ptr == label) return(NULL); // Illegal empty label
+ if (*cstr) cstr++; // Skip over the trailing dot (if present)
+ return(cstr);
+ }
diff -r d718a2ae1e96 -r 56087be1a25b external/apache2/mDNSResponder/dist/Clients/ClientCommon.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/apache2/mDNSResponder/dist/Clients/ClientCommon.h Tue Sep 29 22:14:03 2009 +0000
@@ -0,0 +1,49 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2008 Apple Inc. All rights reserved.
+ *
+ * Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, 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,
+ * please do not use, install, modify or redistribute this Apple software.
+ *
+ * In consideration of your agreement to abide by the following terms, and subject
+ * to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+ * copyrights in this original Apple software (the "Apple Software"), to use,
+ * reproduce, modify and redistribute the Apple Software, with or without
+ * modifications, in source and/or binary forms; provided that if you redistribute
+ * 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 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
+ * may be infringed by your derivative works or by other works in which the Apple
+ * Software may be incorporated.
+ *
+ * The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
+ * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+ * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+ * COMBINATION WITH YOUR PRODUCTS.
+ *
+ * IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+ * OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+ * (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+ Change History (most recent first):
+
+Log: ClientCommon.h,v $
+Revision 1.1 2008/05/08 00:25:48 cheshire
+<rdar://problem/5919272> GetNextLabel insufficiently defensive
+
+
+*/
+
+extern const char *GetNextLabel(const char *cstr, char label[64]);
diff -r d718a2ae1e96 -r 56087be1a25b external/apache2/mDNSResponder/dist/Clients/dns-sd.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/external/apache2/mDNSResponder/dist/Clients/dns-sd.c Tue Sep 29 22:14:03 2009 +0000
@@ -0,0 +1,1235 @@
+/* -*- Mode: C; tab-width: 4 -*-
+ *
+ * Copyright (c) 2002-2008 Apple Inc. All rights reserved.
+ *
+ * Disclaimer: IMPORTANT: This Apple software is supplied to you by Apple Computer, 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,
+ * please do not use, install, modify or redistribute this Apple software.
+ *
+ * In consideration of your agreement to abide by the following terms, and subject
+ * to these terms, Apple grants you a personal, non-exclusive license, under Apple's
+ * copyrights in this original Apple software (the "Apple Software"), to use,
+ * reproduce, modify and redistribute the Apple Software, with or without
+ * modifications, in source and/or binary forms; provided that if you redistribute
+ * 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 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
+ * may be infringed by your derivative works or by other works in which the Apple
+ * Software may be incorporated.
+ *
+ * The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO
+ * WARRANTIES, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED
+ * WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS USE AND OPERATION ALONE OR IN
+ * COMBINATION WITH YOUR PRODUCTS.
+ *
+ * IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+ * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * ARISING IN ANY WAY OUT OF THE USE, REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION
+ * OF THE APPLE SOFTWARE, HOWEVER CAUSED AND WHETHER UNDER THEORY OF CONTRACT, TORT
+ * (INCLUDING NEGLIGENCE), STRICT LIABILITY OR OTHERWISE, EVEN IF APPLE HAS BEEN
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ * Formatting notes:
+ * This code follows the "Whitesmiths style" C indentation rules. Plenty of discussion
+ * on C indentation can be found on the web, such as <http://www.kafejo.com/komp/1tbs.htm>,
+ * but for the sake of brevity here I will say just this: Curly braces are not syntactially
+ * part of an "if" statement; they are the beginning and ending markers of a compound statement;
+ * therefore common sense dictates that if they are part of a compound statement then they
+ * should be indented to the same level as everything else in that compound statement.
+ * Indenting curly braces at the same level as the "if" implies that curly braces are
+ * part of the "if", which is false. (This is as misleading as people who write "char* x,y;"
+ * thinking that variables x and y are both of type "char*" -- and anyone who doesn't
+ * understand why variable y is not of type "char*" just proves the point that poor code
+ * layout leads people to unfortunate misunderstandings about how the C language really works.)
+
+To build this tool, copy and paste the following into a command line:
+
+OS X:
+gcc dns-sd.c -o dns-sd
+
+POSIX systems:
+gcc dns-sd.c -o dns-sd -I../mDNSShared -ldns_sd
+
+Windows:
+cl dns-sd.c -I../mDNSShared -DNOT_HAVE_GETOPT ws2_32.lib ..\mDNSWindows\DLL\Release\dnssd.lib
+(may require that you run a Visual Studio script such as vsvars32.bat first)
+*/
+
+// For testing changes to dnssd_clientstub.c, uncomment this line and the code will be compiled
+// with an embedded copy of the client stub instead of linking the system library version at runtime.
+// This also useful to work around link errors when you're working on an older version of Mac OS X,
+// and trying to build a newer version of the "dns-sd" command which uses new API entry points that
+// aren't in the system's /usr/lib/libSystem.dylib.
+//#define TEST_NEW_CLIENTSTUB 1
+
+#include <ctype.h>
+#include <stdio.h> // For stdout, stderr
+#include <stdlib.h> // For exit()
+#include <string.h> // For strlen(), strcpy()
+#include <errno.h> // For errno, EINTR
+#include <time.h>
+#include <sys/types.h> // For u_char
+
+#ifdef _WIN32
+ #include <winsock2.h>
+ #include <ws2tcpip.h>
+ #include <Iphlpapi.h>
+ #include <process.h>
+ typedef int pid_t;
+ #define getpid _getpid
+ #define strcasecmp _stricmp
+ #define snprintf _snprintf
+ static const char kFilePathSep = '\\';
+ #ifndef HeapEnableTerminationOnCorruption
+ # define HeapEnableTerminationOnCorruption (HEAP_INFORMATION_CLASS)1
+ #endif
+ #if !defined(IFNAMSIZ)
+ #define IFNAMSIZ 16
+ #endif
+ #define if_nametoindex if_nametoindex_win
+ #define if_indextoname if_indextoname_win
+
+ typedef PCHAR (WINAPI * if_indextoname_funcptr_t)(ULONG index, PCHAR name);
+ typedef ULONG (WINAPI * if_nametoindex_funcptr_t)(PCSTR name);
+
+ unsigned if_nametoindex_win(const char *ifname)
+ {
+ HMODULE library;
+ unsigned index = 0;
+
+ // Try and load the IP helper library dll
+ if ((library = LoadLibrary(TEXT("Iphlpapi")) ) != NULL )
+ {
+ if_nametoindex_funcptr_t if_nametoindex_funcptr;
+
+ // On Vista and above there is a Posix like implementation of if_nametoindex
+ if ((if_nametoindex_funcptr = (if_nametoindex_funcptr_t) GetProcAddress(library, "if_nametoindex")) != NULL )
+ {
+ index = if_nametoindex_funcptr(ifname);
+ }
+
+ FreeLibrary(library);
+ }
+
+ return index;
+ }
+
+ char * if_indextoname_win( unsigned ifindex, char *ifname)
+ {
+ HMODULE library;
+ char * name = NULL;
+
+ // Try and load the IP helper library dll
+ if ((library = LoadLibrary(TEXT("Iphlpapi")) ) != NULL )
+ {
+ if_indextoname_funcptr_t if_indextoname_funcptr;
+
+ // On Vista and above there is a Posix like implementation of if_indextoname
+ if ((if_indextoname_funcptr = (if_indextoname_funcptr_t) GetProcAddress(library, "if_indextoname")) != NULL )
+ {
+ name = if_indextoname_funcptr(ifindex, ifname);
+ }
+
+ FreeLibrary(library);
+ }
+
+ return name;
+ }
+
+#else
+ #include <unistd.h> // For getopt() and optind
+ #include <netdb.h> // For getaddrinfo()
+ #include <sys/time.h> // For struct timeval
+ #include <sys/socket.h> // For AF_INET
+ #include <netinet/in.h> // For struct sockaddr_in()
+ #include <arpa/inet.h> // For inet_addr()
Home |
Main Index |
Thread Index |
Old Index