PROJECTVERSION = 2.8
PROJECT_TYPE = Component
-HFILES = inet.h nameser.h options.h portability.h resolv.h
+HFILES = inet.h nameser8_compat.h options.h portability.h resolv8_compat.h
CFILES = gethnamaddr.c getnetbyaddr.c getnetbyname.c getnetent.c\
getnetnamadr.c herror.c res_comp.c res_data.c res_debug.c\
NEXTSTEP_PB_CFLAGS = -DUSE_OPTIONS_H
-PUBLIC_HEADERS = resolv.h nameser.h
+PUBLIC_HEADERS = resolv8_compat.h nameser8_compat.h
PUBLIC_HEADER_DIR_SUFFIX =
ARPA_HEADER_DIR_SUFFIX = /arpa
ARPA_HEADERS = inet.h
-ARPA_SYMLINKED_HEADERS = nameser.h
+ARPA_SYMLINKED_HEADERS = nameser8_compat.h
AFTER_INSTALLHDRS += arpa_headers
{
DYNAMIC_CODE_GEN = YES;
FILESTABLE = {
- H_FILES = (inet.h, nameser.h, options.h, portability.h, resolv.h);
+ H_FILES = (inet.h, nameser8_compat.h, options.h, portability.h, resolv8_compat.h);
OTHER_LINKED = (
gethnamaddr.c,
getnetbyaddr.c,
sethostent.c
);
OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble);
- PUBLIC_HEADERS = (resolv.h, nameser.h);
+ PUBLIC_HEADERS = (resolv8_compat.h, nameser8_compat.h);
};
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: gethnamaddr.c,v 1.6 2002/06/13 01:04:37 majka Exp $";
+static char rcsid[] = "$Id: gethnamaddr.c,v 1.8 2003/07/03 21:56:17 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#include <ctype.h>
#include <errno.h>
#include <syslog.h>
return (gethostbyname2(name, AF_INET));
}
-struct hostent *
-gethostbyname2(name, af)
- const char *name;
- int af;
-{
- if (_lu_running())
- {
- return getipnodebyname(name, af, 0, &h_errno);
- }
- else
- {
- if (af == AF_INET) return gethostbyname_ipv4(name);
-
- errno = EAFNOSUPPORT;
- h_errno = NETDB_INTERNAL;
- return NULL;
- }
-}
-
static struct hostent *
gethostbyname_ipv4(name)
const char *name;
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: getnetent.c,v 1.3 2002/06/12 17:40:29 epeyton Exp $";
+static char rcsid[] = "$Id: getnetent.c,v 1.4 2003/02/18 17:29:23 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <stdlib.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#include <netdb.h>
#include <string.h>
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93";
static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03";
-static char rcsid[] = "$Id: getnetnamadr.c,v 1.3.44.1 2002/11/19 01:20:51 bbraun Exp $";
+static char rcsid[] = "$Id: getnetnamadr.c,v 1.4 2003/02/18 17:29:23 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <stdlib.h>
#include <netdb.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#include <ctype.h>
#include <errno.h>
#include <string.h>
register int n;
u_char *eom;
int type, class, buflen, ancount, qdcount, haveanswer, i, nchar;
- char aux1[30], aux2[30], *in, *st, *pauxt, *bp, **ap,
+ char aux1[30], aux2[30], ans[30], *in, *st, *pauxt, *bp, **ap,
*paux1 = &aux1[0], *paux2 = &aux2[0], flag = 0;
- static struct netent net_entry;
- static char *net_aliases[MAXALIASES], *netbuf = NULL;
- static char ans[MAXDNAME];
+static struct netent net_entry;
+static char *net_aliases[MAXALIASES], *netbuf = NULL;
if (netbuf == NULL) {
netbuf = malloc(BUFSIZ+1);
h_errno = TRY_AGAIN;
return (NULL);
}
- while (qdcount-- > 0) {
- n = __dn_skipname(cp, eom);
- if (n < 0 || (cp + n + QFIXEDSZ) > eom) {
- h_errno = NO_RECOVERY;
- return(NULL);
- }
- cp += n + QFIXEDSZ;
- }
+ while (qdcount-- > 0)
+ cp += __dn_skipname(cp, eom) + QFIXEDSZ;
ap = net_aliases;
*ap = NULL;
net_entry.n_aliases = net_aliases;
break;
cp += n;
ans[0] = '\0';
- (void)strcpy(ans, bp);
+ (void)strcpy(&ans[0], bp);
GETSHORT(type, cp);
GETSHORT(class, cp);
cp += INT32SZ; /* TTL */
return (NULL);
}
cp += n;
- if ((ap + 2) < &net_aliases[MAXALIASES]) {
- *ap++ = bp;
- bp += strlen(bp) + 1;
- net_entry.n_addrtype =
- (class == C_IN) ? AF_INET : AF_UNSPEC;
- haveanswer++;
- }
+ *ap++ = bp;
+ bp += strlen(bp) + 1;
+ net_entry.n_addrtype =
+ (class == C_IN) ? AF_INET : AF_UNSPEC;
+ haveanswer++;
}
}
if (haveanswer) {
net_entry.n_net = 0L;
break;
case BYNAME:
- ap = net_entry.n_aliases;
- next_alias:
- in = *ap++;
- if (in == NULL) {
- h_errno = HOST_NOT_FOUND;
- return (NULL);
- }
- net_entry.n_name = ans;
+ in = *net_entry.n_aliases;
+ net_entry.n_name = &ans[0];
aux2[0] = '\0';
for (i = 0; i < 4; i++) {
for (st = in, nchar = 0;
- isdigit((unsigned char)*st);
+ *st != '.';
st++, nchar++)
;
-
- if (*st != '.' || nchar == 0 || nchar > 3)
- goto next_alias;
- if (i != 0)
- nchar++;
- (void)strncpy(paux1, in, nchar);
- paux1[nchar] = '\0';
- pauxt = paux2;
- paux2 = strcat(paux1, paux2);
- paux1 = pauxt;
+ if (nchar != 1 || *in != '0' || flag) {
+ flag = 1;
+ (void)strncpy(paux1,
+ (i==0) ? in : in-1,
+ (i==0) ?nchar : nchar+1);
+ paux1[(i==0) ? nchar : nchar+1] = '\0';
+ pauxt = paux2;
+ paux2 = strcat(paux1, paux2);
+ paux1 = pauxt;
+ }
in = ++st;
}
-
- if (strcasecmp(in, "IN-ADDR.ARPA") != 0)
- goto next_alias;
net_entry.n_net = inet_network(paux2);
break;
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: herror.c,v 1.3 2002/02/19 20:36:12 epeyton Exp $";
+static char rcsid[] = "$Id: herror.c,v 1.4 2003/04/10 20:21:16 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
writev(STDERR_FILENO, iov, (v - iov) + 1);
}
-char *
+const char *
hstrerror(err)
int err;
{
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/*
* @(#)inet.h 8.1 (Berkeley) 6/2/93
- * $Id: inet.h,v 1.3 2002/04/19 20:38:01 majka Exp $
+ * $Id: inet.h,v 1.4 2003/05/20 23:00:27 majka Exp $
*/
#ifndef _INET_H_
#include <sys/cdefs.h>
__BEGIN_DECLS
-unsigned long inet_addr __P((const char *));
-int inet_aton __P((const char *, struct in_addr *));
-unsigned long inet_lnaof __P((struct in_addr));
-struct in_addr inet_makeaddr __P((u_long , u_long));
-unsigned long inet_netof __P((struct in_addr));
-unsigned long inet_network __P((const char *));
-char *inet_ntoa __P((struct in_addr));
-int inet_pton __P((int, const char *, void *));
-const char *inet_ntop __P((int, const void *, char *, size_t));
-
-u_int inet_nsap_addr __P((const char *, u_char *, int maxlen));
-char *inet_nsap_ntoa __P((int, const u_char *, char *ascii));
+int ascii2addr(int, const char *, void *);
+char *addr2ascii(int, const void *, int, char *);
+in_addr_t inet_addr(const char *);
+int inet_aton(const char *, struct in_addr *);
+in_addr_t inet_lnaof(struct in_addr);
+struct in_addr inet_makeaddr(in_addr_t, in_addr_t);
+in_addr_t inet_netof(struct in_addr);
+in_addr_t inet_network(const char *);
+char *inet_ntoa(struct in_addr);
+int inet_pton(int, const char *, void *);
+const char *inet_ntop(int, const void *, char *, size_t);
+char *inet_net_ntop(int, const void *, int, char *, size_t);
+int inet_net_pton(int, const char *, void *, size_t);
+char *inet_neta(in_addr_t, char *, size_t);
+u_int inet_nsap_addr(const char *, u_char *, int maxlen);
+char *inet_nsap_ntoa(int, const u_char *, char *ascii);
__END_DECLS
+++ /dev/null
-/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * ++Copyright++ 1983, 1989, 1993
- * -
- * Copyright (c) 1983, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-/*
- * @(#)nameser.h 8.1 (Berkeley) 6/2/93
- * $Id: nameser.h,v 1.2 1999/10/14 21:56:45 wsanchez Exp $
- */
-
-#ifndef _NAMESER_H_
-#define _NAMESER_H_
-
-#include <sys/param.h>
-#if (!defined(BSD)) || (BSD < 199306)
-# include <sys/bitypes.h>
-#else
-# include <sys/types.h>
-#endif
-#include <sys/cdefs.h>
-
-#ifdef _AUX_SOURCE
-#include <sys/types.h> /* ech for A/UX */
-#define res_send ucb_res_send /* already def'd in libc */
-#define _res_close _ucb_res_close /* removing res_send.o from the library */
-#endif /* gives an undefined symbol... */
-
-/*
- * revision information. this is the release date in YYYYMMDD format.
- * it can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__BIND > 19931104)". do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define __BIND 19950621 /* interface version stamp */
-
-/*
- * Define constants based on rfc883
- */
-#define PACKETSZ 512 /* maximum packet size */
-#define MAXDNAME 256 /* maximum domain name */
-#define MAXCDNAME 255 /* maximum compressed domain name */
-#define MAXLABEL 63 /* maximum length of domain label */
-#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
-#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
-#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
-#define INT32SZ 4 /* for systems without 32-bit ints */
-#define INT16SZ 2 /* for systems without 16-bit ints */
-#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */
-
-/*
- * Internet nameserver port number
- */
-#define NAMESERVER_PORT 53
-
-/*
- * Currently defined opcodes
- */
-#define QUERY 0x0 /* standard query */
-#define IQUERY 0x1 /* inverse query */
-#define STATUS 0x2 /* nameserver status query */
-/*#define xxx 0x3*/ /* 0x3 reserved */
-#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
-#ifdef ALLOW_UPDATES
- /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
-# define UPDATEA 0x9 /* add resource record */
-# define UPDATED 0xa /* delete a specific resource record */
-# define UPDATEDA 0xb /* delete all named resource record */
-# define UPDATEM 0xc /* modify a specific resource record */
-# define UPDATEMA 0xd /* modify all named resource record */
-# define ZONEINIT 0xe /* initial zone transfer */
-# define ZONEREF 0xf /* incremental zone referesh */
-#endif
-
-/*
- * Currently defined response codes
- */
-#define NOERROR 0 /* no error */
-#define FORMERR 1 /* format error */
-#define SERVFAIL 2 /* server failure */
-#define NXDOMAIN 3 /* non existent domain */
-#define NOTIMP 4 /* not implemented */
-#define REFUSED 5 /* query refused */
-#ifdef ALLOW_UPDATES
- /* non standard */
-# define NOCHANGE 0xf /* update failed to change db */
-#endif
-
-/*
- * Type values for resources and queries
- */
-#define T_A 1 /* host address */
-#define T_NS 2 /* authoritative server */
-#define T_MD 3 /* mail destination */
-#define T_MF 4 /* mail forwarder */
-#define T_CNAME 5 /* canonical name */
-#define T_SOA 6 /* start of authority zone */
-#define T_MB 7 /* mailbox domain name */
-#define T_MG 8 /* mail group member */
-#define T_MR 9 /* mail rename name */
-#define T_NULL 10 /* null resource record */
-#define T_WKS 11 /* well known service */
-#define T_PTR 12 /* domain name pointer */
-#define T_HINFO 13 /* host information */
-#define T_MINFO 14 /* mailbox information */
-#define T_MX 15 /* mail routing information */
-#define T_TXT 16 /* text strings */
-#define T_RP 17 /* responsible person */
-#define T_AFSDB 18 /* AFS cell database */
-#define T_X25 19 /* X_25 calling address */
-#define T_ISDN 20 /* ISDN calling address */
-#define T_RT 21 /* router */
-#define T_NSAP 22 /* NSAP address */
-#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
-#define T_SIG 24 /* security signature */
-#define T_KEY 25 /* security key */
-#define T_PX 26 /* X.400 mail mapping */
-#define T_GPOS 27 /* geographical position (withdrawn) */
-#define T_AAAA 28 /* IP6 Address */
-#define T_LOC 29 /* Location Information */
- /* non standard */
-#define T_UINFO 100 /* user (finger) information */
-#define T_UID 101 /* user ID */
-#define T_GID 102 /* group ID */
-#define T_UNSPEC 103 /* Unspecified format (binary data) */
- /* Query type values which do not appear in resource records */
-#define T_AXFR 252 /* transfer zone of authority */
-#define T_MAILB 253 /* transfer mailbox records */
-#define T_MAILA 254 /* transfer mail agent records */
-#define T_ANY 255 /* wildcard match */
-
-/*
- * Values for class field
- */
-
-#define C_IN 1 /* the arpa internet */
-#define C_CHAOS 3 /* for chaos net (MIT) */
-#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
- /* Query class values which do not appear in resource records */
-#define C_ANY 255 /* wildcard match */
-
-/*
- * Status return codes for T_UNSPEC conversion routines
- */
-#define CONV_SUCCESS 0
-#define CONV_OVERFLOW (-1)
-#define CONV_BADFMT (-2)
-#define CONV_BADCKSUM (-3)
-#define CONV_BADBUFLEN (-4)
-
-#ifndef BYTE_ORDER
-#if (BSD >= 199103)
-# include <machine/endian.h>
-#else
-#ifdef linux
-# include <endian.h>
-#else
-#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
-#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
-#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
-
-#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
- defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
- defined(__alpha__) || defined(__alpha)
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
-
-#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
- defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
- defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
- defined(apollo) || defined(__convex__) || defined(_CRAY) || \
- defined(__hppa) || defined(__hp9000) || \
- defined(__hp9000s300) || defined(__hp9000s700) || \
- defined (BIT_ZERO_ON_LEFT) || defined(m68k)
-#define BYTE_ORDER BIG_ENDIAN
-#endif
-#endif /* linux */
-#endif /* BSD */
-#endif /* BYTE_ORDER */
-
-#if !defined(BYTE_ORDER) || \
- (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
- BYTE_ORDER != PDP_ENDIAN)
- /* you must determine what the correct bit order is for
- * your compiler - the next line is an intentional error
- * which will force your compiles to bomb until you fix
- * the above macros.
- */
- error "Undefined or invalid BYTE_ORDER";
-#endif
-
-/*
- * Structure for query header. The order of the fields is machine- and
- * compiler-dependent, depending on the byte/bit order and the layout
- * of bit fields. We use bit fields only in int variables, as this
- * is all ANSI requires. This requires a somewhat confusing rearrangement.
- */
-
-typedef struct {
- unsigned id :16; /* query identification number */
-#if BYTE_ORDER == BIG_ENDIAN
- /* fields in third byte */
- unsigned qr: 1; /* response flag */
- unsigned opcode: 4; /* purpose of message */
- unsigned aa: 1; /* authoritive answer */
- unsigned tc: 1; /* truncated message */
- unsigned rd: 1; /* recursion desired */
- /* fields in fourth byte */
- unsigned ra: 1; /* recursion available */
- unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
- unsigned rcode :4; /* response code */
-#endif
-#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
- /* fields in third byte */
- unsigned rd :1; /* recursion desired */
- unsigned tc :1; /* truncated message */
- unsigned aa :1; /* authoritive answer */
- unsigned opcode :4; /* purpose of message */
- unsigned qr :1; /* response flag */
- /* fields in fourth byte */
- unsigned rcode :4; /* response code */
- unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
- unsigned ra :1; /* recursion available */
-#endif
- /* remaining bytes */
- unsigned qdcount :16; /* number of question entries */
- unsigned ancount :16; /* number of answer entries */
- unsigned nscount :16; /* number of authority entries */
- unsigned arcount :16; /* number of resource entries */
-} HEADER;
-
-/*
- * Defines for handling compressed domain names
- */
-#define INDIR_MASK 0xc0
-
-/*
- * Structure for passing resource records around.
- */
-struct rrec {
- int16_t r_zone; /* zone number */
- int16_t r_class; /* class number */
- int16_t r_type; /* type number */
- u_int32_t r_ttl; /* time to live */
- int r_size; /* size of data area */
- char *r_data; /* pointer to data */
-};
-
-extern u_int16_t _getshort __P((const u_char *));
-extern u_int32_t _getlong __P((const u_char *));
-
-/*
- * Inline versions of get/put short/long. Pointer is advanced.
- *
- * These macros demonstrate the property of C whereby it can be
- * portable or it can be elegant but rarely both.
- */
-#define GETSHORT(s, cp) { \
- register u_char *t_cp = (u_char *)(cp); \
- (s) = ((u_int16_t)t_cp[0] << 8) \
- | ((u_int16_t)t_cp[1]) \
- ; \
- (cp) += INT16SZ; \
-}
-
-#define GETLONG(l, cp) { \
- register u_char *t_cp = (u_char *)(cp); \
- (l) = ((u_int32_t)t_cp[0] << 24) \
- | ((u_int32_t)t_cp[1] << 16) \
- | ((u_int32_t)t_cp[2] << 8) \
- | ((u_int32_t)t_cp[3]) \
- ; \
- (cp) += INT32SZ; \
-}
-
-#define PUTSHORT(s, cp) { \
- register u_int16_t t_s = (u_int16_t)(s); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_s >> 8; \
- *t_cp = t_s; \
- (cp) += INT16SZ; \
-}
-
-#define PUTLONG(l, cp) { \
- register u_int32_t t_l = (u_int32_t)(l); \
- register u_char *t_cp = (u_char *)(cp); \
- *t_cp++ = t_l >> 24; \
- *t_cp++ = t_l >> 16; \
- *t_cp++ = t_l >> 8; \
- *t_cp = t_l; \
- (cp) += INT32SZ; \
-}
-
-#endif /* !_NAMESER_H_ */
--- /dev/null
+/*
+ * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ * ++Copyright++ 1983, 1989, 1993
+ * -
+ * Copyright (c) 1983, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*
+ * @(#)nameser.h 8.1 (Berkeley) 6/2/93
+ * $Id: nameser8_compat.h,v 1.2 2003/02/18 17:29:24 majka Exp $
+ */
+
+#ifndef _NAMESER_H_
+#define _NAMESER_H_
+
+#include <sys/param.h>
+#if (!defined(BSD)) || (BSD < 199306)
+# include <sys/bitypes.h>
+#else
+# include <sys/types.h>
+#endif
+#include <sys/cdefs.h>
+
+#ifdef _AUX_SOURCE
+#include <sys/types.h> /* ech for A/UX */
+#define res_send ucb_res_send /* already def'd in libc */
+#define _res_close _ucb_res_close /* removing res_send.o from the library */
+#endif /* gives an undefined symbol... */
+
+/*
+ * revision information. this is the release date in YYYYMMDD format.
+ * it can change every day so the right thing to do with it is use it
+ * in preprocessor commands such as "#if (__BIND > 19931104)". do not
+ * compare for equality; rather, use it to determine whether your resolver
+ * is new enough to contain a certain feature.
+ */
+
+#define __BIND 19950621 /* interface version stamp */
+
+/*
+ * Define constants based on rfc883
+ */
+#define PACKETSZ 512 /* maximum packet size */
+#define MAXDNAME 256 /* maximum domain name */
+#define MAXCDNAME 255 /* maximum compressed domain name */
+#define MAXLABEL 63 /* maximum length of domain label */
+#define HFIXEDSZ 12 /* #/bytes of fixed data in header */
+#define QFIXEDSZ 4 /* #/bytes of fixed data in query */
+#define RRFIXEDSZ 10 /* #/bytes of fixed data in r record */
+#define INT32SZ 4 /* for systems without 32-bit ints */
+#define INT16SZ 2 /* for systems without 16-bit ints */
+#define INADDRSZ 4 /* for sizeof(struct inaddr) != 4 */
+
+/*
+ * Internet nameserver port number
+ */
+#define NAMESERVER_PORT 53
+
+/*
+ * Currently defined opcodes
+ */
+#define QUERY 0x0 /* standard query */
+#define IQUERY 0x1 /* inverse query */
+#define STATUS 0x2 /* nameserver status query */
+/*#define xxx 0x3*/ /* 0x3 reserved */
+#define NS_NOTIFY_OP 0x4 /* notify secondary of SOA change */
+#ifdef ALLOW_UPDATES
+ /* non standard - supports ALLOW_UPDATES stuff from Mike Schwartz */
+# define UPDATEA 0x9 /* add resource record */
+# define UPDATED 0xa /* delete a specific resource record */
+# define UPDATEDA 0xb /* delete all named resource record */
+# define UPDATEM 0xc /* modify a specific resource record */
+# define UPDATEMA 0xd /* modify all named resource record */
+# define ZONEINIT 0xe /* initial zone transfer */
+# define ZONEREF 0xf /* incremental zone referesh */
+#endif
+
+/*
+ * Currently defined response codes
+ */
+#define NOERROR 0 /* no error */
+#define FORMERR 1 /* format error */
+#define SERVFAIL 2 /* server failure */
+#define NXDOMAIN 3 /* non existent domain */
+#define NOTIMP 4 /* not implemented */
+#define REFUSED 5 /* query refused */
+#ifdef ALLOW_UPDATES
+ /* non standard */
+# define NOCHANGE 0xf /* update failed to change db */
+#endif
+
+/*
+ * Type values for resources and queries
+ */
+#define T_A 1 /* host address */
+#define T_NS 2 /* authoritative server */
+#define T_MD 3 /* mail destination */
+#define T_MF 4 /* mail forwarder */
+#define T_CNAME 5 /* canonical name */
+#define T_SOA 6 /* start of authority zone */
+#define T_MB 7 /* mailbox domain name */
+#define T_MG 8 /* mail group member */
+#define T_MR 9 /* mail rename name */
+#define T_NULL 10 /* null resource record */
+#define T_WKS 11 /* well known service */
+#define T_PTR 12 /* domain name pointer */
+#define T_HINFO 13 /* host information */
+#define T_MINFO 14 /* mailbox information */
+#define T_MX 15 /* mail routing information */
+#define T_TXT 16 /* text strings */
+#define T_RP 17 /* responsible person */
+#define T_AFSDB 18 /* AFS cell database */
+#define T_X25 19 /* X_25 calling address */
+#define T_ISDN 20 /* ISDN calling address */
+#define T_RT 21 /* router */
+#define T_NSAP 22 /* NSAP address */
+#define T_NSAP_PTR 23 /* reverse NSAP lookup (deprecated) */
+#define T_SIG 24 /* security signature */
+#define T_KEY 25 /* security key */
+#define T_PX 26 /* X.400 mail mapping */
+#define T_GPOS 27 /* geographical position (withdrawn) */
+#define T_AAAA 28 /* IP6 Address */
+#define T_LOC 29 /* Location Information */
+ /* non standard */
+#define T_UINFO 100 /* user (finger) information */
+#define T_UID 101 /* user ID */
+#define T_GID 102 /* group ID */
+#define T_UNSPEC 103 /* Unspecified format (binary data) */
+ /* Query type values which do not appear in resource records */
+#define T_AXFR 252 /* transfer zone of authority */
+#define T_MAILB 253 /* transfer mailbox records */
+#define T_MAILA 254 /* transfer mail agent records */
+#define T_ANY 255 /* wildcard match */
+
+/*
+ * Values for class field
+ */
+
+#define C_IN 1 /* the arpa internet */
+#define C_CHAOS 3 /* for chaos net (MIT) */
+#define C_HS 4 /* for Hesiod name server (MIT) (XXX) */
+ /* Query class values which do not appear in resource records */
+#define C_ANY 255 /* wildcard match */
+
+/*
+ * Status return codes for T_UNSPEC conversion routines
+ */
+#define CONV_SUCCESS 0
+#define CONV_OVERFLOW (-1)
+#define CONV_BADFMT (-2)
+#define CONV_BADCKSUM (-3)
+#define CONV_BADBUFLEN (-4)
+
+#ifndef BYTE_ORDER
+#if (BSD >= 199103)
+# include <machine/endian.h>
+#else
+#ifdef linux
+# include <endian.h>
+#else
+#define LITTLE_ENDIAN 1234 /* least-significant byte first (vax, pc) */
+#define BIG_ENDIAN 4321 /* most-significant byte first (IBM, net) */
+#define PDP_ENDIAN 3412 /* LSB first in word, MSW first in long (pdp)*/
+
+#if defined(vax) || defined(ns32000) || defined(sun386) || defined(i386) || \
+ defined(MIPSEL) || defined(_MIPSEL) || defined(BIT_ZERO_ON_RIGHT) || \
+ defined(__alpha__) || defined(__alpha)
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
+
+#if defined(sel) || defined(pyr) || defined(mc68000) || defined(sparc) || \
+ defined(is68k) || defined(tahoe) || defined(ibm032) || defined(ibm370) || \
+ defined(MIPSEB) || defined(_MIPSEB) || defined(_IBMR2) || defined(DGUX) ||\
+ defined(apollo) || defined(__convex__) || defined(_CRAY) || \
+ defined(__hppa) || defined(__hp9000) || \
+ defined(__hp9000s300) || defined(__hp9000s700) || \
+ defined (BIT_ZERO_ON_LEFT) || defined(m68k)
+#define BYTE_ORDER BIG_ENDIAN
+#endif
+#endif /* linux */
+#endif /* BSD */
+#endif /* BYTE_ORDER */
+
+#if !defined(BYTE_ORDER) || \
+ (BYTE_ORDER != BIG_ENDIAN && BYTE_ORDER != LITTLE_ENDIAN && \
+ BYTE_ORDER != PDP_ENDIAN)
+ /* you must determine what the correct bit order is for
+ * your compiler - the next line is an intentional error
+ * which will force your compiles to bomb until you fix
+ * the above macros.
+ */
+ error "Undefined or invalid BYTE_ORDER";
+#endif
+
+/*
+ * Structure for query header. The order of the fields is machine- and
+ * compiler-dependent, depending on the byte/bit order and the layout
+ * of bit fields. We use bit fields only in int variables, as this
+ * is all ANSI requires. This requires a somewhat confusing rearrangement.
+ */
+
+typedef struct {
+ unsigned id :16; /* query identification number */
+#if BYTE_ORDER == BIG_ENDIAN
+ /* fields in third byte */
+ unsigned qr: 1; /* response flag */
+ unsigned opcode: 4; /* purpose of message */
+ unsigned aa: 1; /* authoritive answer */
+ unsigned tc: 1; /* truncated message */
+ unsigned rd: 1; /* recursion desired */
+ /* fields in fourth byte */
+ unsigned ra: 1; /* recursion available */
+ unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
+ unsigned rcode :4; /* response code */
+#endif
+#if BYTE_ORDER == LITTLE_ENDIAN || BYTE_ORDER == PDP_ENDIAN
+ /* fields in third byte */
+ unsigned rd :1; /* recursion desired */
+ unsigned tc :1; /* truncated message */
+ unsigned aa :1; /* authoritive answer */
+ unsigned opcode :4; /* purpose of message */
+ unsigned qr :1; /* response flag */
+ /* fields in fourth byte */
+ unsigned rcode :4; /* response code */
+ unsigned unused :3; /* unused bits (MBZ as of 4.9.3a3) */
+ unsigned ra :1; /* recursion available */
+#endif
+ /* remaining bytes */
+ unsigned qdcount :16; /* number of question entries */
+ unsigned ancount :16; /* number of answer entries */
+ unsigned nscount :16; /* number of authority entries */
+ unsigned arcount :16; /* number of resource entries */
+} HEADER;
+
+/*
+ * Defines for handling compressed domain names
+ */
+#define INDIR_MASK 0xc0
+
+/*
+ * Structure for passing resource records around.
+ */
+struct rrec {
+ int16_t r_zone; /* zone number */
+ int16_t r_class; /* class number */
+ int16_t r_type; /* type number */
+ u_int32_t r_ttl; /* time to live */
+ int r_size; /* size of data area */
+ char *r_data; /* pointer to data */
+};
+
+extern u_int16_t _getshort __P((const u_char *));
+extern u_int32_t _getlong __P((const u_char *));
+
+/*
+ * Inline versions of get/put short/long. Pointer is advanced.
+ *
+ * These macros demonstrate the property of C whereby it can be
+ * portable or it can be elegant but rarely both.
+ */
+#define GETSHORT(s, cp) { \
+ register u_char *t_cp = (u_char *)(cp); \
+ (s) = ((u_int16_t)t_cp[0] << 8) \
+ | ((u_int16_t)t_cp[1]) \
+ ; \
+ (cp) += INT16SZ; \
+}
+
+#define GETLONG(l, cp) { \
+ register u_char *t_cp = (u_char *)(cp); \
+ (l) = ((u_int32_t)t_cp[0] << 24) \
+ | ((u_int32_t)t_cp[1] << 16) \
+ | ((u_int32_t)t_cp[2] << 8) \
+ | ((u_int32_t)t_cp[3]) \
+ ; \
+ (cp) += INT32SZ; \
+}
+
+#define PUTSHORT(s, cp) { \
+ register u_int16_t t_s = (u_int16_t)(s); \
+ register u_char *t_cp = (u_char *)(cp); \
+ *t_cp++ = t_s >> 8; \
+ *t_cp = t_s; \
+ (cp) += INT16SZ; \
+}
+
+#define PUTLONG(l, cp) { \
+ register u_int32_t t_l = (u_int32_t)(l); \
+ register u_char *t_cp = (u_char *)(cp); \
+ *t_cp++ = t_l >> 24; \
+ *t_cp++ = t_l >> 16; \
+ *t_cp++ = t_l >> 8; \
+ *t_cp = t_l; \
+ (cp) += INT32SZ; \
+}
+
+#endif /* !_NAMESER_H_ */
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: res_comp.c,v 1.3 2002/02/19 20:36:12 epeyton Exp $";
+static char rcsid[] = "$Id: res_comp.c,v 1.4 2003/02/18 17:29:24 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#include <ctype.h>
#if defined(BSD) && (BSD >= 199103)
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/socket.h>
#include <netinet/in.h>
#include <stdio.h>
-#include <arpa/nameser.h>
-#include <resolv.h>
+#include <arpa/nameser8_compat.h>
+#include <resolv8_compat.h>
/* From res_init.c */
struct __res_state _res = {0};
-__private_extern__ struct __res_state _res_shadow = {0};
/* From getnetent.c */
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: res_debug.c,v 1.3 2002/02/19 20:36:12 epeyton Exp $";
+static char rcsid[] = "$Id: res_debug.c,v 1.4 2003/02/18 17:29:24 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <netdb.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#if defined(BSD) && (BSD >= 199103)
# include <string.h>
#else
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static char rcsid[] = "$Id: res_init.c,v 1.5.88.1 2002/11/06 17:30:17 majka Exp $";
+static char rcsid[] = "$Id: res_init.c,v 1.8 2003/02/18 17:29:24 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <ctype.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#if defined(BSD) && (BSD >= 199103)
# include <unistd.h>
# include <stdlib.h>
extern
#endif /* NeXT */
struct __res_state _res;
-extern struct __res_state _res_shadow;
/*
* Set up default settings. If the configuration file exist, the values
if ((cp = getenv("RES_OPTIONS")) != NULL)
res_setoptions(cp, "env");
_res.options |= RES_INIT;
- _res_shadow = _res;
return (0);
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: res_mkquery.c,v 1.2 1999/10/14 21:56:45 wsanchez Exp $";
+static char rcsid[] = "$Id: res_mkquery.c,v 1.3 2003/02/18 17:29:24 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <netdb.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#if defined(BSD) && (BSD >= 199103)
# include <string.h>
#else
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: res_query.c,v 1.2 1999/10/14 21:56:45 wsanchez Exp $";
+static char rcsid[] = "$Id: res_query.c,v 1.3 2003/02/18 17:29:24 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <netdb.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#include <ctype.h>
#include <errno.h>
#if defined(BSD) && (BSD >= 199306)
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: res_send.c,v 1.2.202.1 2002/11/06 17:30:17 majka Exp $";
+static char rcsid[] = "$Id: res_send.c,v 1.6 2003/02/18 17:29:25 majka Exp $";
#endif /* LIBC_SCCS and not lint */
/* change this to "0"
#include <sys/socket.h>
#include <sys/uio.h>
#include <netinet/in.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <stdio.h>
#include <netdb.h>
#include <errno.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#if defined(BSD) && (BSD >= 199306)
# include <stdlib.h>
# include <string.h>
}
#endif
-extern struct __res_state _res_shadow;
-
static res_send_qhook Qhook = NULL;
static res_send_rhook Rhook = NULL;
return (1);
}
-static int res_using_defaults()
-{
- int i;
-
- if (_res.nscount != _res_shadow.nscount)
- return 0;
-
- for (i = 0; i < _res.nscount; i++) {
- /* Check that the address and port have not changed */
- if ((_res.nsaddr_list[i].sin_addr.s_addr !=
- _res_shadow.nsaddr_list[i].sin_addr.s_addr) ||
- (_res.nsaddr_list[i].sin_port !=
- _res_shadow.nsaddr_list[i].sin_port)) {
- return 0;
- }
- }
-
- return 1;
-}
-
/* Returns whether a dns encoded name should be sent to multicast or not */
static int dns_is_local_name(const u_int8_t *name)
{
const u_int8_t *d1 = NULL; // Second-Level Domain
const u_int8_t *d2 = NULL; // etc.
const u_int8_t *d3 = NULL;
-
+
+ if (name == NULL) return 0;
+
while (*name)
{
d3 = d2;
terrno = ETIMEDOUT;
badns = 0;
- if (res_using_defaults() &&
- dns_is_local_name((u_int8_t*)(buf + DNS_HEADER_SIZE))) {
+ if (dns_is_local_name((u_int8_t*)(buf + DNS_HEADER_SIZE))) {
multicast = 1;
v_circuit = 0;
} else {
+++ /dev/null
-/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * ++Copyright++ 1983, 1987, 1989, 1993
- * -
- * Copyright (c) 1983, 1987, 1989, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- * -
- * Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies, and that
- * the name of Digital Equipment Corporation not be used in advertising or
- * publicity pertaining to distribution of the document or software without
- * specific, written prior permission.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
- * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
- * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
- * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
- * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
- * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- * SOFTWARE.
- * -
- * --Copyright--
- */
-
-/*
- * @(#)resolv.h 8.1 (Berkeley) 6/2/93
- * $Id: resolv.h,v 1.2 1999/10/14 21:56:45 wsanchez Exp $
- */
-
-#ifndef _RESOLV_H_
-#define _RESOLV_H_
-
-#include <sys/param.h>
-#if (!defined(BSD)) || (BSD < 199306)
-# include <sys/bitypes.h>
-#else
-# include <sys/types.h>
-#endif
-#include <sys/cdefs.h>
-#include <stdio.h>
-
-/*
- * revision information. this is the release date in YYYYMMDD format.
- * it can change every day so the right thing to do with it is use it
- * in preprocessor commands such as "#if (__RES > 19931104)". do not
- * compare for equality; rather, use it to determine whether your resolver
- * is new enough to contain a certain feature.
- */
-
-#define __RES 19950621
-
-/*
- * Resolver configuration file.
- * Normally not present, but may contain the address of the
- * inital name server(s) to query and the domain search list.
- */
-
-#ifndef _PATH_RESCONF
-#define _PATH_RESCONF "/etc/resolv.conf"
-#endif
-
-/*
- * Global defines and variables for resolver stub.
- */
-#define MAXNS 3 /* max # name servers we'll track */
-#define MAXDFLSRCH 3 /* # default domain levels to try */
-#define MAXDNSRCH 6 /* max # domains in search path */
-#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
-
-#define RES_TIMEOUT 5 /* min. seconds between retries */
-#define MAXRESOLVSORT 10 /* number of net to sort on */
-#define RES_MAXNDOTS 15 /* should reflect bit field size */
-
-struct __res_state {
- int retrans; /* retransmition time interval */
- int retry; /* number of times to retransmit */
- u_long options; /* option flags - see below. */
- int nscount; /* number of name servers */
- struct sockaddr_in
- nsaddr_list[MAXNS]; /* address of name server */
-#define nsaddr nsaddr_list[0] /* for backward compatibility */
- u_short id; /* current packet id */
- char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
- char defdname[MAXDNAME]; /* default domain */
- u_long pfcode; /* RES_PRF_ flags - see below. */
- unsigned ndots:4; /* threshold for initial abs. query */
- unsigned nsort:4; /* number of elements in sort_list[] */
- char unused[3];
- struct {
- struct in_addr addr;
- u_int32_t mask;
- } sort_list[MAXRESOLVSORT];
-};
-
-/*
- * Resolver options (keep these in synch with res_debug.c, please)
- */
-#define RES_INIT 0x00000001 /* address initialized */
-#define RES_DEBUG 0x00000002 /* print debug messages */
-#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
-#define RES_USEVC 0x00000008 /* use virtual circuit */
-#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
-#define RES_IGNTC 0x00000020 /* ignore trucation errors */
-#define RES_RECURSE 0x00000040 /* recursion desired */
-#define RES_DEFNAMES 0x00000080 /* use default domain name */
-#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
-#define RES_DNSRCH 0x00000200 /* search up local domain tree */
-#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
-#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
-#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
-
-#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
-
-/*
- * Resolver "pfcode" values. Used by dig.
- */
-#define RES_PRF_STATS 0x00000001
-/* 0x00000002 */
-#define RES_PRF_CLASS 0x00000004
-#define RES_PRF_CMD 0x00000008
-#define RES_PRF_QUES 0x00000010
-#define RES_PRF_ANS 0x00000020
-#define RES_PRF_AUTH 0x00000040
-#define RES_PRF_ADD 0x00000080
-#define RES_PRF_HEAD1 0x00000100
-#define RES_PRF_HEAD2 0x00000200
-#define RES_PRF_TTLID 0x00000400
-#define RES_PRF_HEADX 0x00000800
-#define RES_PRF_QUERY 0x00001000
-#define RES_PRF_REPLY 0x00002000
-#define RES_PRF_INIT 0x00004000
-/* 0x00008000 */
-
-/* hooks are still experimental as of 4.9.2 */
-typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
- res_sendhookact;
-
-typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns,
- const u_char **query,
- int *querylen,
- u_char *ans,
- int anssiz,
- int *resplen));
-
-typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns,
- const u_char *query,
- int querylen,
- u_char *ans,
- int anssiz,
- int *resplen));
-
-extern struct __res_state _res;
-
-/* Private routines shared between libc/net, named, nslookup and others. */
-#define dn_skipname __dn_skipname
-#define fp_query __fp_query
-#define fp_nquery __fp_nquery
-#define hostalias __hostalias
-#define putlong __putlong
-#define putshort __putshort
-#define p_class __p_class
-#define p_time __p_time
-#define p_type __p_type
-#define p_cdnname __p_cdnname
-#define p_cdname __p_cdname
-#define p_fqname __p_fqname
-#define p_rr __p_rr
-#define p_option __p_option
-#define res_randomid __res_randomid
-#define res_isourserver __res_isourserver
-#define res_nameinquery __res_nameinquery
-#define res_queriesmatch __res_queriesmatch
-__BEGIN_DECLS
-int __dn_skipname __P((const u_char *, const u_char *));
-void __fp_resstat __P((struct __res_state *, FILE *));
-void __fp_query __P((const u_char *, FILE *));
-void __fp_nquery __P((const u_char *, int, FILE *));
-char *__hostalias __P((const char *));
-void __putlong __P((u_int32_t, u_char *));
-void __putshort __P((u_int16_t, u_char *));
-char *__p_time __P((u_int32_t));
-void __p_query __P((const u_char *));
-const u_char *__p_cdnname __P((const u_char *, const u_char *, int, FILE *));
-const u_char *__p_cdname __P((const u_char *, const u_char *, FILE *));
-const u_char *__p_fqname __P((const u_char *, const u_char *, FILE *));
-const u_char *__p_rr __P((const u_char *, const u_char *, FILE *));
-const char *__p_type __P((int));
-const char *__p_class __P((int));
-const char *__p_option __P((u_long option));
-int dn_comp __P((const char *, u_char *, int, u_char **, u_char **));
-int dn_expand __P((const u_char *, const u_char *, const u_char *,
- char *, int));
-int res_init __P((void));
-u_int16_t res_randomid __P((void));
-int res_query __P((const char *, int, int, u_char *, int));
-int res_search __P((const char *, int, int, u_char *, int));
-int res_querydomain __P((const char *, const char *, int, int,
- u_char *, int));
-int res_mkquery __P((int, const char *, int, int, const u_char *, int,
- const u_char *, u_char *, int));
-int res_send __P((const u_char *, int, u_char *, int));
-int res_isourserver __P((const struct sockaddr_in *));
-int res_nameinquery __P((const char *, int, int,
- const u_char *, const u_char *));
-int res_queriesmatch __P((const u_char *, const u_char *,
- const u_char *, const u_char *));
-__END_DECLS
-
-#endif /* !_RESOLV_H_ */
--- /dev/null
+/*
+ * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ * ++Copyright++ 1983, 1987, 1989, 1993
+ * -
+ * Copyright (c) 1983, 1987, 1989, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*
+ * @(#)resolv.h 8.1 (Berkeley) 6/2/93
+ * $Id: resolv8_compat.h,v 1.2 2003/02/18 17:29:25 majka Exp $
+ */
+
+#ifndef _RESOLV_H_
+#define _RESOLV_H_
+
+#include <sys/param.h>
+#if (!defined(BSD)) || (BSD < 199306)
+# include <sys/bitypes.h>
+#else
+# include <sys/types.h>
+#endif
+#include <sys/cdefs.h>
+#include <stdio.h>
+
+/*
+ * revision information. this is the release date in YYYYMMDD format.
+ * it can change every day so the right thing to do with it is use it
+ * in preprocessor commands such as "#if (__RES > 19931104)". do not
+ * compare for equality; rather, use it to determine whether your resolver
+ * is new enough to contain a certain feature.
+ */
+
+#define __RES 19950621
+
+/*
+ * Resolver configuration file.
+ * Normally not present, but may contain the address of the
+ * inital name server(s) to query and the domain search list.
+ */
+
+#ifndef _PATH_RESCONF
+#define _PATH_RESCONF "/etc/resolv.conf"
+#endif
+
+/*
+ * Global defines and variables for resolver stub.
+ */
+#define MAXNS 3 /* max # name servers we'll track */
+#define MAXDFLSRCH 3 /* # default domain levels to try */
+#define MAXDNSRCH 6 /* max # domains in search path */
+#define LOCALDOMAINPARTS 2 /* min levels in name that is "local" */
+
+#define RES_TIMEOUT 5 /* min. seconds between retries */
+#define MAXRESOLVSORT 10 /* number of net to sort on */
+#define RES_MAXNDOTS 15 /* should reflect bit field size */
+
+struct __res_state {
+ int retrans; /* retransmition time interval */
+ int retry; /* number of times to retransmit */
+ u_long options; /* option flags - see below. */
+ int nscount; /* number of name servers */
+ struct sockaddr_in
+ nsaddr_list[MAXNS]; /* address of name server */
+#define nsaddr nsaddr_list[0] /* for backward compatibility */
+ u_short id; /* current packet id */
+ char *dnsrch[MAXDNSRCH+1]; /* components of domain to search */
+ char defdname[MAXDNAME]; /* default domain */
+ u_long pfcode; /* RES_PRF_ flags - see below. */
+ unsigned ndots:4; /* threshold for initial abs. query */
+ unsigned nsort:4; /* number of elements in sort_list[] */
+ char unused[3];
+ struct {
+ struct in_addr addr;
+ u_int32_t mask;
+ } sort_list[MAXRESOLVSORT];
+};
+
+/*
+ * Resolver options (keep these in synch with res_debug.c, please)
+ */
+#define RES_INIT 0x00000001 /* address initialized */
+#define RES_DEBUG 0x00000002 /* print debug messages */
+#define RES_AAONLY 0x00000004 /* authoritative answers only (!IMPL)*/
+#define RES_USEVC 0x00000008 /* use virtual circuit */
+#define RES_PRIMARY 0x00000010 /* query primary server only (!IMPL) */
+#define RES_IGNTC 0x00000020 /* ignore trucation errors */
+#define RES_RECURSE 0x00000040 /* recursion desired */
+#define RES_DEFNAMES 0x00000080 /* use default domain name */
+#define RES_STAYOPEN 0x00000100 /* Keep TCP socket open */
+#define RES_DNSRCH 0x00000200 /* search up local domain tree */
+#define RES_INSECURE1 0x00000400 /* type 1 security disabled */
+#define RES_INSECURE2 0x00000800 /* type 2 security disabled */
+#define RES_NOALIASES 0x00001000 /* shuts off HOSTALIASES feature */
+
+#define RES_DEFAULT (RES_RECURSE | RES_DEFNAMES | RES_DNSRCH)
+
+/*
+ * Resolver "pfcode" values. Used by dig.
+ */
+#define RES_PRF_STATS 0x00000001
+/* 0x00000002 */
+#define RES_PRF_CLASS 0x00000004
+#define RES_PRF_CMD 0x00000008
+#define RES_PRF_QUES 0x00000010
+#define RES_PRF_ANS 0x00000020
+#define RES_PRF_AUTH 0x00000040
+#define RES_PRF_ADD 0x00000080
+#define RES_PRF_HEAD1 0x00000100
+#define RES_PRF_HEAD2 0x00000200
+#define RES_PRF_TTLID 0x00000400
+#define RES_PRF_HEADX 0x00000800
+#define RES_PRF_QUERY 0x00001000
+#define RES_PRF_REPLY 0x00002000
+#define RES_PRF_INIT 0x00004000
+/* 0x00008000 */
+
+/* hooks are still experimental as of 4.9.2 */
+typedef enum { res_goahead, res_nextns, res_modified, res_done, res_error }
+ res_sendhookact;
+
+typedef res_sendhookact (*res_send_qhook)__P((struct sockaddr_in * const *ns,
+ const u_char **query,
+ int *querylen,
+ u_char *ans,
+ int anssiz,
+ int *resplen));
+
+typedef res_sendhookact (*res_send_rhook)__P((const struct sockaddr_in *ns,
+ const u_char *query,
+ int querylen,
+ u_char *ans,
+ int anssiz,
+ int *resplen));
+
+extern struct __res_state _res;
+
+/* Private routines shared between libc/net, named, nslookup and others. */
+#define dn_skipname __dn_skipname
+#define fp_query __fp_query
+#define fp_nquery __fp_nquery
+#define hostalias __hostalias
+#define putlong __putlong
+#define putshort __putshort
+#define p_class __p_class
+#define p_time __p_time
+#define p_type __p_type
+#define p_cdnname __p_cdnname
+#define p_cdname __p_cdname
+#define p_fqname __p_fqname
+#define p_rr __p_rr
+#define p_option __p_option
+#define res_randomid __res_randomid
+#define res_isourserver __res_isourserver
+#define res_nameinquery __res_nameinquery
+#define res_queriesmatch __res_queriesmatch
+__BEGIN_DECLS
+int __dn_skipname __P((const u_char *, const u_char *));
+void __fp_resstat __P((struct __res_state *, FILE *));
+void __fp_query __P((const u_char *, FILE *));
+void __fp_nquery __P((const u_char *, int, FILE *));
+char *__hostalias __P((const char *));
+void __putlong __P((u_int32_t, u_char *));
+void __putshort __P((u_int16_t, u_char *));
+char *__p_time __P((u_int32_t));
+void __p_query __P((const u_char *));
+const u_char *__p_cdnname __P((const u_char *, const u_char *, int, FILE *));
+const u_char *__p_cdname __P((const u_char *, const u_char *, FILE *));
+const u_char *__p_fqname __P((const u_char *, const u_char *, FILE *));
+const u_char *__p_rr __P((const u_char *, const u_char *, FILE *));
+const char *__p_type __P((int));
+const char *__p_class __P((int));
+const char *__p_option __P((u_long option));
+int dn_comp __P((const char *, u_char *, int, u_char **, u_char **));
+int dn_expand __P((const u_char *, const u_char *, const u_char *,
+ char *, int));
+int res_init __P((void));
+u_int16_t res_randomid __P((void));
+int res_query __P((const char *, int, int, u_char *, int));
+int res_search __P((const char *, int, int, u_char *, int));
+int res_querydomain __P((const char *, const char *, int, int,
+ u_char *, int));
+int res_mkquery __P((int, const char *, int, int, const u_char *, int,
+ const u_char *, u_char *, int));
+int res_send __P((const u_char *, int, u_char *, int));
+int res_isourserver __P((const struct sockaddr_in *));
+int res_nameinquery __P((const char *, int, int,
+ const u_char *, const u_char *));
+int res_queriesmatch __P((const u_char *, const u_char *,
+ const u_char *, const u_char *));
+__END_DECLS
+
+#endif /* !_RESOLV_H_ */
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char sccsid[] = "@(#)sethostent.c 8.1 (Berkeley) 6/4/93";
-static char rcsid[] = "$Id: sethostent.c,v 1.2 1999/10/14 21:56:45 wsanchez Exp $";
+static char rcsid[] = "$Id: sethostent.c,v 1.3 2003/02/18 17:29:25 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/param.h>
#include <netinet/in.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <netdb.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
void _res_close __P((void));
HFILES = ifaddrs.h
-CFILES = aliasdb.c ether_addr.c fstab.c getaddrinfo.c getgrent.c\
- getifaddrs.c getnameinfo.c getproto.c getprotoent.c\
+CFILES = aliasdb.c ether_addr.c fstab.c getgrent.c\
+ getifaddrs.c getproto.c getprotoent.c\
getprotoname.c getpwent.c getservbyname.c getservbyport.c\
getservent.c if_indextoname.c if_nameindex.c if_nametoindex.c\
inet_ntop.c inet_pton.c initgroups.c printerdb.c\
map_v4v6.c ip6opt.c rthdr.c vars.c
-OTHERSRCS = Makefile.preamble Makefile Makefile.postamble getaddrinfo.3\
- getifaddrs.3 if_indextoname.3 inet6_rthdr_space.3\
- gethostbyname.3 getnameinfo.3 inet6_option_space.3\
- linkaddr.3 getprotoent.3 gethostbyname.3 getipnodebyname.3\
+OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\
+ ether_addr.3 getifaddrs.3 if_indextoname.3 inet6_rthdr_space.3\
+ gethostbyname.3 inet6_option_space.3\
+ getprotoent.3 gethostbyname.3 getipnodebyname.3\
getnetent.3 getservent.3 inet6_option_space.3
#
install-man-page:
mkdir -p "$(DSTROOT)/usr/share/man/man3"
- install -c -m 644 getaddrinfo.3 "$(DSTROOT)/usr/share/man/man3"
- $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/freeaddrinfo.3"
- $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/gai_strerror.3"
- install -c -m 644 getnameinfo.3 "$(DSTROOT)/usr/share/man/man3"
install -c -m 644 gethostbyname.3 "$(DSTROOT)/usr/share/man/man3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/endhostent.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/gethostbyaddr.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/herror.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/hstrerror.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/gethostbyname.3" "$(DSTROOT)/usr/share/man/man3/sethostent.3"
+ install -c -m 644 ether_addr.3 "$(DSTROOT)/usr/share/man/man3"
install -c -m 644 getifaddrs.3 "$(DSTROOT)/usr/share/man/man3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/getifaddrs.3" "$(DSTROOT)/usr/share/man/man3/freeifaddrs.3"
install -c -m 644 getipnodebyname.3 "$(DSTROOT)/usr/share/man/man3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_space.3" "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_lasthop.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_space.3" "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_reverse.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_space.3" "$(DSTROOT)/usr/share/man/man3/inet6_rthdr_segments.3"
- install -c -m 644 linkaddr.3 "$(DSTROOT)/usr/share/man/man3"
- $(LN) -f "$(DSTROOT)/usr/share/man/man3/linkaddr.3" "$(DSTROOT)/usr/share/man/man3/link_addr.3"
- $(LN) -f "$(DSTROOT)/usr/share/man/man3/linkaddr.3" "$(DSTROOT)/usr/share/man/man3/link_ntoa.3"
aliasdb.c,
ether_addr.c,
fstab.c,
- getaddrinfo.c,
getgrent.c,
getifaddrs.c,
- getnameinfo.c,
getproto.c,
getprotoent.c,
getprotoname.c,
Makefile.preamble,
Makefile,
Makefile.postamble,
- getaddrinfo.3,
+ ether_addr.3,
getifaddrs.3,
if_indextoname.3,
inet6_rthdr_space.3,
gethostbyname.3,
- getnameinfo.3,
inet6_option_space.3,
getprotoent.3,
gethostbyname.3,
getipnodebyname.3,
getnetent.3,
getservent.3,
- inet6_option_space.3,
- linkaddr.3
- );
+ inet6_option_space.3
+ );
PUBLIC_HEADERS = (ifaddrs.h);
};
LANGUAGE = English;
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
--- /dev/null
+.so man3/ethers.3
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#define EI(i) (unsigned int)(e->ether_addr_octet[(i)])
char *
ether_ntoa(e)
- struct ether_addr *e;
+ const struct ether_addr *e;
{
static char *s;
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/stat.h>
#include <sys/mount.h>
-static FILE *_fs_fp;
+static FILE *_fs_fp = NULL;
static struct fstab _fs_fstab;
static struct fstab _root_fstab;
static char _root_fstype[MFSNAMELEN];
}
for (;;) {
- if (!(cp = fgets(line, sizeof(line), _fs_fp)))
+ if (!(cp = fgets(line, MAXLINELENGTH, _fs_fp)))
return(0);
/* OLD_STYLE_FSTAB */
if (!strpbrk(cp, " \t")) {
continue;
#endif
_fs_fstab.fs_file = strtok((char *)NULL, ":\n");
- /* Only list the root filesystem once */
- if (!(strcmp(_fs_fstab.fs_file, "/"))) {
- continue;
- }
- _fs_fstab.fs_type = strtok((char *)NULL, ":\n");
+ /* Only list the root filesystem once */
+ if (!_fs_fstab.fs_file || !(strcmp(_fs_fstab.fs_file, "/"))) {
+ continue;
+ }
+ _fs_fstab.fs_type = strtok((char *)NULL, ":\n");
if (_fs_fstab.fs_type) {
if (!strcmp(_fs_fstab.fs_type, FSTAB_XX))
continue;
+++ /dev/null
-.\" $FreeBSD: src/lib/libc/net/getaddrinfo.3,v 1.2.2.8 2001/08/17 15:42:38 ru Exp $
-.\" $KAME: getaddrinfo.3,v 1.22 2000/08/09 21:16:17 itojun Exp $
-.\"
-.\" Copyright (c) 1983, 1987, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
-.\"
-.Dd May 25, 1995
-.Dt GETADDRINFO 3
-.Os
-.\"
-.Sh NAME
-.Nm getaddrinfo ,
-.Nm freeaddrinfo ,
-.Nm gai_strerror
-.Nd nodename-to-address translation in protocol-independent manner
-.\"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <netdb.h>
-.Ft int
-.Fn getaddrinfo "const char *nodename" "const char *servname" \
-"const struct addrinfo *hints" "struct addrinfo **res"
-.Ft void
-.Fn freeaddrinfo "struct addrinfo *ai"
-.Ft "char *"
-.Fn gai_strerror "int ecode"
-.\"
-.Sh DESCRIPTION
-The
-.Fn getaddrinfo
-function is defined for protocol-independent nodename-to-address translation.
-It performs the functionality of
-.Xr gethostbyname 3
-and
-.Xr getservbyname 3 ,
-but in a more sophisticated manner.
-.Pp
-The
-.Li addrinfo
-structure is defined as a result of including the
-.Aq Pa netdb.h
-header:
-.Bd -literal -offset
-struct addrinfo {
- int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
- int ai_family; /* PF_xxx */
- int ai_socktype; /* SOCK_xxx */
- int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
- size_t ai_addrlen; /* length of ai_addr */
- char *ai_canonname; /* canonical name for nodename */
- struct sockaddr *ai_addr; /* binary address */
- struct addrinfo *ai_next; /* next structure in linked list */
-};
-.Ed
-.Pp
-The
-.Fa nodename
-and
-.Fa servname
-arguments are pointers to null-terminated strings or
-.Dv NULL .
-One or both of these two arguments must be a
-.Pf non Dv -NULL
-pointer.
-In the normal client scenario, both the
-.Fa nodename
-and
-.Fa servname
-are specified.
-In the normal server scenario, only the
-.Fa servname
-is specified.
-A
-.Pf non Dv -NULL
-.Fa nodename
-string can be either a node name or a numeric host address string
-(i.e., a dotted-decimal IPv4 address or an IPv6 hex address).
-A
-.Pf non Dv -NULL
-.Fa servname
-string can be either a service name or a decimal port number.
-.Pp
-The caller can optionally pass an
-.Li addrinfo
-structure, pointed to by the third argument,
-to provide hints concerning the type of socket that the caller supports.
-In this
-.Fa hints
-structure all members other than
-.Fa ai_flags ,
-.Fa ai_family ,
-.Fa ai_socktype ,
-and
-.Fa ai_protocol
-must be zero or a
-.Dv NULL
-pointer.
-A value of
-.Dv PF_UNSPEC
-for
-.Fa ai_family
-means the caller will accept any protocol family.
-A value of 0 for
-.Fa ai_socktype
-means the caller will accept any socket type.
-A value of 0 for
-.Fa ai_protocol
-means the caller will accept any protocol.
-For example, if the caller handles only TCP and not UDP, then the
-.Fa ai_socktype
-member of the hints structure should be set to
-.Dv SOCK_STREAM
-when
-.Fn getaddrinfo
-is called.
-If the caller handles only IPv4 and not IPv6, then the
-.Fa ai_family
-member of the
-.Fa hints
-structure should be set to
-.Dv PF_INET
-when
-.Fn getaddrinfo
-is called.
-If the third argument to
-.Fn getaddrinfo
-is a
-.Dv NULL
-pointer, this is the same as if the caller had filled in an
-.Li addrinfo
-structure initialized to zero with
-.Fa ai_family
-set to
-.Dv PF_UNSPEC .
-.Pp
-Upon successful return a pointer to a linked list of one or more
-.Li addrinfo
-structures is returned through the final argument.
-The caller can process each
-.Li addrinfo
-structure in this list by following the
-.Fa ai_next
-pointer, until a
-.Dv NULL
-pointer is encountered.
-In each returned
-.Li addrinfo
-structure the three members
-.Fa ai_family ,
-.Fa ai_socktype ,
-and
-.Fa ai_protocol
-are the corresponding arguments for a call to the
-.Fn socket
-function.
-In each
-.Li addrinfo
-structure the
-.Fa ai_addr
-member points to a filled-in socket address structure whose length is
-specified by the
-.Fa ai_addrlen
-member.
-.Pp
-If the
-.Dv AI_PASSIVE
-bit is set in the
-.Fa ai_flags
-member of the
-.Fa hints
-structure, then the caller plans to use the returned socket address
-structure in a call to
-.Fn bind .
-In this case, if the
-.Fa nodename
-argument is a
-.Dv NULL
-pointer, then the IP address portion of the socket
-address structure will be set to
-.Dv INADDR_ANY
-for an IPv4 address or
-.Dv IN6ADDR_ANY_INIT
-for an IPv6 address.
-.Pp
-If the
-.Dv AI_PASSIVE
-bit is not set in the
-.Fa ai_flags
-member of the
-.Fa hints
-structure, then the returned socket address structure will be ready for a
-call to
-.Fn connect
-(for a connection-oriented protocol)
-or either
-.Fn connect ,
-.Fn sendto ,
-or
-.Fn sendmsg
-(for a connectionless protocol).
-In this case, if the
-.Fa nodename
-argument is a
-.Dv NULL
-pointer, then the IP address portion of the
-socket address structure will be set to the loopback address.
-.Pp
-If the
-.Dv AI_CANONNAME
-bit is set in the
-.Fa ai_flags
-member of the
-.Fa hints
-structure, then upon successful return the
-.Fa ai_canonname
-member of the first
-.Li addrinfo
-structure in the linked list will point to a null-terminated string
-containing the canonical name of the specified
-.Fa nodename .
-.Pp
-If the
-.Dv AI_NUMERICHOST
-bit is set in the
-.Fa ai_flags
-member of the
-.Fa hints
-structure, then a
-.Pf non Dv -NULL
-.Fa nodename
-string must be a numeric host address string.
-Otherwise an error of
-.Dv EAI_NONAME
-is returned.
-This flag prevents any type of name resolution service (e.g., the DNS)
-from being called.
-.Pp
-The arguments to
-.Fn getaddrinfo
-must be sufficiently consistent and unambiguous.
-Here are some problem cases you may encounter:
-.Bl -bullet
-.It
-.Fn getaddrinfo
-will fail if the members in the
-.Fa hints
-structure are not consistent.
-For example, for internet address families,
-.Fn getaddrinfo
-will fail if you specify
-.Dv SOCK_STREAM
-to
-.Fa ai_socktype
-while you specify
-.Dv IPPROTO_UDP
-to
-.Fa ai_protocol .
-.It
-If you specify a
-.Fa servname
-which is defined only for certain
-.Fa ai_socktype ,
-.Fn getaddrinfo
-will fail because the arguments are not consistent.
-For example,
-.Fn getaddrinfo
-will return an error if you ask for
-.Dq Li tftp
-service on
-.Dv SOCK_STREAM .
-.It
-For internet address families, if you specify
-.Fa servname
-while you set
-.Fa ai_socktype
-to
-.Dv SOCK_RAW ,
-.Fn getaddrinfo
-will fail, because service names are not defined for the internet
-.Dv SOCK_RAW
-space.
-.It
-If you specify numeric
-.Fa servname ,
-while leaving
-.Fa ai_socktype
-and
-.Fa ai_protocol
-unspecified,
-.Fn getaddrinfo
-will fail.
-This is because the numeric
-.Fa servname
-does not identify any socket type, and
-.Fn getaddrinfo
-is not allowed to glob the argument in such case.
-.El
-.Pp
-All of the information returned by
-.Fn getaddrinfo
-is dynamically allocated:
-the
-.Li addrinfo
-structures, the socket address structures, and canonical node name
-strings pointed to by the addrinfo structures.
-To return this information to the system the function
-.Fn freeaddrinfo
-is called.
-The
-.Fa addrinfo
-structure pointed to by the
-.Fa ai argument
-is freed, along with any dynamic storage pointed to by the structure.
-This operation is repeated until a
-.Dv NULL
-.Fa ai_next
-pointer is encountered.
-.Pp
-To aid applications in printing error messages based on the
-.Dv EAI_xxx
-codes returned by
-.Fn getaddrinfo ,
-.Fn gai_strerror
-is defined.
-The argument is one of the
-.Dv EAI_xxx
-values defined earlier and the return value points to a string describing
-the error.
-If the argument is not one of the
-.Dv EAI_xxx
-values, the function still returns a pointer to a string whose contents
-indicate an unknown error.
-.\"
-.Sh EXTENSIONS
-This implementation supports numeric IPv6 address notation with the
-experimental scope identifier.
-By appending a percent sign and scope identifier to the address, you
-can specify the value of the
-.Li sin6_scope_id
-field of the socket address.
-This makes management of scoped address easier,
-and allows cut-and-paste input of scoped addresses.
-.Pp
-At the moment the code supports only link-local addresses in this format.
-The scope identifier is hardcoded to name of hardware interface associated
-with the link,
-(such as
-.Li ne0 ) .
-For example,
-.Dq Li fe80::1%ne0 ,
-which means
-.Do
-.Li fe80::1
-on the link associated with the
-.Li ne0
-interface
-.Dc .
-.Pp
-This implementation is still very experimental and non-standard.
-The current implementation assumes a one-to-one relationship between
-interfaces and links, which is not necessarily true according to the
-specification.
-.\"
-.Sh EXAMPLES
-The following code tries to connect to
-.Dq Li www.kame.net
-service
-.Dq Li http .
-via stream socket.
-It loops through all the addresses available, regardless of the address family.
-If the destination resolves to an IPv4 address, it will use an
-.Dv AF_INET
-socket.
-Similarly, if it resolves to IPv6, an
-.Dv AF_INET6
-socket is used.
-Observe that there is no hardcoded reference to particular address family.
-The code works even if
-.Fn getaddrinfo
-returns addresses that are not IPv4/v6.
-.Bd -literal -offset indent
-struct addrinfo hints, *res, *res0;
-int error;
-int s;
-const char *cause = NULL;
-
-memset(&hints, 0, sizeof(hints));
-hints.ai_family = PF_UNSPEC;
-hints.ai_socktype = SOCK_STREAM;
-error = getaddrinfo("www.kame.net", "http", &hints, &res0);
-if (error) {
- errx(1, "%s", gai_strerror(error));
- /*NOTREACHED*/
-}
-s = -1;
-cause = "no addresses";
-errno = EADDRNOTAVAIL;
-for (res = res0; res; res = res->ai_next) {
- s = socket(res->ai_family, res->ai_socktype,
- res->ai_protocol);
- if (s < 0) {
- cause = "socket";
- continue;
- }
-
- if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
- cause = "connect";
- close(s);
- s = -1;
- continue;
- }
-
- break; /* okay we got one */
-}
-if (s < 0) {
- err(1, cause);
- /*NOTREACHED*/
-}
-freeaddrinfo(res0);
-.Ed
-.Pp
-The following example tries to open a wildcard listening socket onto service
-.Dq Li http ,
-for all the address families available.
-.Bd -literal -offset indent
-struct addrinfo hints, *res, *res0;
-int error;
-int s[MAXSOCK];
-int nsock;
-const char *cause = NULL;
-
-memset(&hints, 0, sizeof(hints));
-hints.ai_family = PF_UNSPEC;
-hints.ai_socktype = SOCK_STREAM;
-hints.ai_flags = AI_PASSIVE;
-error = getaddrinfo(NULL, "http", &hints, &res0);
-if (error) {
- errx(1, "%s", gai_strerror(error));
- /*NOTREACHED*/
-}
-nsock = 0;
-for (res = res0; res && nsock < MAXSOCK; res = res->ai_next) {
- s[nsock] = socket(res->ai_family, res->ai_socktype,
- res->ai_protocol);
- if (s[nsock] < 0) {
- cause = "socket";
- continue;
- }
-
- if (bind(s[nsock], res->ai_addr, res->ai_addrlen) < 0) {
- cause = "bind";
- close(s[nsock]);
- continue;
- }
-
- if (listen(s[nsock], SOMAXCONN) < 0) {
- cause = "listen";
- close(s[nsock]);
- continue;
- }
-
- nsock++;
-}
-if (nsock == 0) {
- err(1, cause);
- /*NOTREACHED*/
-}
-freeaddrinfo(res0);
-.Ed
-.\"
-.Sh FILES
-.Bl -tag -width /etc/resolv.conf -compact
-.It Pa /etc/hosts
-.It Pa /etc/host.conf
-.It Pa /etc/resolv.conf
-.El
-.\"
-.Sh DIAGNOSTICS
-Error return status from
-.Fn getaddrinfo
-is zero on success and non-zero on errors.
-Non-zero error codes are defined in
-.Aq Pa netdb.h ,
-and as follows:
-.Pp
-.Bl -tag -width EAI_ADDRFAMILY -compact
-.It Dv EAI_ADDRFAMILY
-Address family for
-.Fa nodename
-not supported.
-.It Dv EAI_AGAIN
-Temporary failure in name resolution.
-.It Dv EAI_BADFLAGS
-Invalid value for
-.Fa ai_flags .
-.It Dv EAI_FAIL
-Non-recoverable failure in name resolution.
-.It Dv EAI_FAMILY
-.Fa ai_family
-not supported.
-.It Dv EAI_MEMORY
-Memory allocation failure.
-.It Dv EAI_NODATA
-No address associated with
-.Fa nodename .
-.It Dv EAI_NONAME
-.Fa nodename
-nor
-.Fa servname
-provided, or not known.
-.It Dv EAI_SERVICE
-.Fa servname
-not supported for
-.Fa ai_socktype .
-.It Dv EAI_SOCKTYPE
-.Fa ai_socktype
-not supported.
-.It Dv EAI_SYSTEM
-System error returned in
-.Va errno .
-.El
-.Pp
-If called with an appropriate argument,
-.Fn gai_strerror
-returns a pointer to a string describing the given error code.
-If the argument is not one of the
-.Dv EAI_xxx
-values, the function still returns a pointer to a string whose contents
-indicate an unknown error.
-.\"
-.Sh SEE ALSO
-.Xr gethostbyname 3 ,
-.Xr getnameinfo 3 ,
-.Xr getservbyname 3 ,
-.Xr hosts 5 ,
-.Xr services 5 ,
-.Xr hostname 7 ,
-.Xr named 8
-.Pp
-.Rs
-.%A R. Gilligan
-.%A S. Thomson
-.%A J. Bound
-.%A W. Stevens
-.%T Basic Socket Interface Extensions for IPv6
-.%R RFC2553
-.%D March 1999
-.Re
-.Rs
-.%A Tatsuya Jinmei
-.%A Atsushi Onoe
-.%T "An Extension of Format for IPv6 Scoped Addresses"
-.%R internet draft
-.%N draft-ietf-ipngwg-scopedaddr-format-02.txt
-.%O work in progress material
-.Re
-.Rs
-.%A Craig Metz
-.%T Protocol Independence Using the Sockets API
-.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference"
-.%D June 2000
-.Re
-.\"
-.Sh HISTORY
-The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit.
-.\"
-.Sh STANDARDS
-The
-.Fn getaddrinfo
-function is defined in
-.St -p1003.1g-2000 ,
-and documented in
-.Dq Basic Socket Interface Extensions for IPv6
-(RFC2553).
-.\"
-.Sh BUGS
-The current implementation is not thread-safe.
-.Pp
-The text was shamelessly copied from RFC2553.
+++ /dev/null
-/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-
-#include <netdb.h>
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <rpc/types.h>
-#include <rpc/xdr.h>
-#include <mach/mach.h>
-#include <servers/bootstrap.h>
-#include <nameser.h>
-#include <resolv.h>
-#include <netdb.h>
-#include <arpa/inet.h>
-#include <ifaddrs.h>
-
-#define SOCK_UNSPEC 0
-#define IPPROTO_UNSPEC 0
-
-#define WANT_A4_ONLY 1
-#define WANT_A6_ONLY 2
-#define WANT_A6_PLUS_MAPPED_A4 3
-#define WANT_A6_OR_MAPPED4_IF_NO_A6 4
-
-#define LONG_STRING_LENGTH 8192
-#define _LU_MAXLUSTRLEN 256
-
-extern int _lu_running(void);
-extern mach_port_t _lookupd_port();
-extern int _lookup_link();
-extern int _lookup_one();
-extern int _lookup_all();
-
-struct lu_dict
-{
- int count;
- char *type;
- char *name;
- char *cname;
- char *mx;
- char *ipv4;
- char *ipv6;
- char *service;
- char *port;
- char *protocol;
- char *target;
- char *priority;
- char *weight;
- struct lu_dict *lu_next;
-};
-
-#define LU_NAME 1
-#define LU_CNAME 2
-#define LU_MX 3
-#define LU_IPV4 4
-#define LU_IPV6 5
-#define LU_PORT 6
-#define LU_TARGET 7
-#define LU_PRIORITY 8
-#define LU_WEIGHT 9
-
-static int supported_family[] =
-{
- PF_UNSPEC,
- PF_INET,
- PF_INET6
-};
-static int supported_family_count = 3;
-
-static int supported_socket[] =
-{
- SOCK_RAW,
- SOCK_UNSPEC,
- SOCK_DGRAM,
- SOCK_STREAM
-};
-static int supported_socket_count = 4;
-
-static int supported_protocol[] =
-{
- IPPROTO_UNSPEC,
- IPPROTO_ICMPV6,
- IPPROTO_UDP,
- IPPROTO_TCP
-};
-static int supported_protocol_count = 4;
-
-static int supported_socket_protocol_pair[] =
-{
- SOCK_RAW, IPPROTO_UNSPEC,
- SOCK_RAW, IPPROTO_UDP,
- SOCK_RAW, IPPROTO_TCP,
- SOCK_RAW, IPPROTO_ICMPV6,
- SOCK_UNSPEC, IPPROTO_UNSPEC,
- SOCK_UNSPEC, IPPROTO_UDP,
- SOCK_UNSPEC, IPPROTO_TCP,
- SOCK_UNSPEC, IPPROTO_ICMPV6,
- SOCK_DGRAM, IPPROTO_UNSPEC,
- SOCK_DGRAM, IPPROTO_UDP,
- SOCK_STREAM, IPPROTO_UNSPEC,
- SOCK_STREAM, IPPROTO_TCP
-};
-static int supported_socket_protocol_pair_count = 12;
-
-static int
-gai_family_type_check(int f)
-{
- int i;
-
- for (i = 0; i < supported_family_count; i++)
- {
- if (f == supported_family[i]) return 0;
- }
-
- return 1;
-}
-
-static int
-gai_socket_type_check(int s)
-{
- int i;
-
- for (i = 0; i < supported_socket_count; i++)
- {
- if (s == supported_socket[i]) return 0;
- }
-
- return 1;
-}
-
-static int
-gai_protocol_type_check(int p)
-{
- int i;
-
- for (i = 0; i < supported_protocol_count; i++)
- {
- if (p == supported_protocol[i]) return 0;
- }
-
- return 1;
-}
-
-static int
-gai_socket_protocol_type_check(int s, int p)
-{
- int i, j, ss, sp;
-
- for (i = 0, j = 0; i < supported_socket_protocol_pair_count; i++, j+=2)
- {
- ss = supported_socket_protocol_pair[j];
- sp = supported_socket_protocol_pair[j+1];
- if ((s == ss) && (p == sp)) return 0;
- }
-
- return 1;
-}
-
-static int
-gai_inet_pton(const char *s, struct in6_addr *a6)
-{
- if (s == NULL) return 0;
- if (a6 == NULL) return 0;
- return inet_pton(AF_INET6, s, (void *)&a6->__u6_addr.__u6_addr32[0]);
-}
-
-char *
-gai_strerror(int err)
-{
- switch (err)
- {
- case EAI_ADDRFAMILY: return "Address family for nodename not supported";
- case EAI_AGAIN: return "Temporary failure in name resolution";
- case EAI_BADFLAGS: return "Invalid value for ai_flags";
- case EAI_FAIL: return "Non-recoverable failure in name resolution";
- case EAI_FAMILY: return "ai_family not supported";
- case EAI_MEMORY: return "Memory allocation failure";
- case EAI_NODATA: return "No address associated with nodename";
- case EAI_NONAME: return "nodename nor servname provided, or not known";
- case EAI_SERVICE: return "servname not supported for ai_socktype";
- case EAI_SOCKTYPE: return "ai_socktype not supported";
- case EAI_SYSTEM: return "System error";
- case EAI_BADHINTS: return "Bad hints";
- case EAI_PROTOCOL: return "ai_protocol not supported";
- }
-
- return "Unknown error";
-}
-
-static int
-is_ipv4_address(const char *s)
-{
- struct in_addr a;
-
- if (s == NULL) return 0;
- return inet_aton(s, &a);
-}
-
-static int
-is_ipv6_address(const char *s)
-{
- struct in6_addr a;
-
- if (s == NULL) return 0;
- return gai_inet_pton(s, &a);
-}
-
-static void
-append_addrinfo(struct addrinfo **l, struct addrinfo *a)
-{
- struct addrinfo *x;
-
- if (l == NULL) return;
- if (a == NULL) return;
-
- if (*l == NULL)
- {
- *l = a;
- return;
- }
-
- x = *l;
-
- if (a->ai_family == PF_INET6)
- {
- if (x->ai_family == PF_INET)
- {
- *l = a;
- a->ai_next = x;
- return;
- }
-
- while ((x->ai_next != NULL) && (x->ai_next->ai_family != PF_INET)) x = x->ai_next;
- a->ai_next = x->ai_next;
- x->ai_next = a;
- }
- else
- {
- while (x->ai_next != NULL) x = x->ai_next;
- a->ai_next = NULL;
- x->ai_next = a;
- }
-}
-
-static void
-free_lu_dict(struct lu_dict *d)
-{
- struct lu_dict *next;
-
- while (d != NULL)
- {
- next = d->lu_next;
- if (d->type != NULL) free(d->type);
- if (d->name != NULL) free(d->name);
- if (d->cname != NULL) free(d->cname);
- if (d->mx != NULL) free(d->mx);
- if (d->ipv4 != NULL) free(d->ipv4);
- if (d->ipv6 != NULL) free(d->ipv6);
- if (d->service != NULL) free(d->service);
- if (d->port != NULL) free(d->port);
- if (d->protocol != NULL) free(d->protocol);
- if (d->target != NULL) free(d->target);
- if (d->priority != NULL) free(d->priority);
- if (d->weight != NULL) free(d->weight);
- free(d);
- d = next;
- }
-}
-
-static int
-_lu_str_equal(char *a, char *b)
-{
- if (a == NULL)
- {
- if (b == NULL) return 1;
- return 0;
- }
-
- if (b == NULL) return 0;
-
- if (!strcmp(a, b)) return 1;
- return 0;
-}
-
-static int
-lu_dict_equal(struct lu_dict *a, struct lu_dict *b)
-{
- if (a == NULL) return 0;
- if (b == NULL) return 0;
-
- if (_lu_str_equal(a->type, b->type) == 0) return 0;
- if (_lu_str_equal(a->name, b->name) == 0) return 0;
- if (_lu_str_equal(a->cname, b->cname) == 0) return 0;
- if (_lu_str_equal(a->mx, b->mx) == 0) return 0;
- if (_lu_str_equal(a->ipv4, b->ipv4) == 0) return 0;
- if (_lu_str_equal(a->ipv6, b->ipv6) == 0) return 0;
- if (_lu_str_equal(a->service, b->service) == 0) return 0;
- if (_lu_str_equal(a->port, b->port) == 0) return 0;
- if (_lu_str_equal(a->protocol, b->protocol) == 0) return 0;
- if (_lu_str_equal(a->target, b->target) == 0) return 0;
- if (_lu_str_equal(a->priority, b->priority) == 0) return 0;
- if (_lu_str_equal(a->weight, b->weight) == 0) return 0;
- return 1;
-}
-
-/*
- * Append a single dictionary to a list if it is unique.
- * Free it if it is not appended.
- */
-static void
-merge_lu_dict(struct lu_dict **l, struct lu_dict *d)
-{
- struct lu_dict *x, *e;
-
- if (l == NULL) return;
- if (d == NULL) return;
-
- if (*l == NULL)
- {
- *l = d;
- return;
- }
-
- e = *l;
- for (x = *l; x != NULL; x = x->lu_next)
- {
- e = x;
- if (lu_dict_equal(x, d))
- {
- free_lu_dict(d);
- return;
- }
- }
-
- e->lu_next = d;
-}
-
-static void
-append_lu_dict(struct lu_dict **l, struct lu_dict *d)
-{
- struct lu_dict *x, *next;
-
- if (l == NULL) return;
- if (d == NULL) return;
-
- if (*l == NULL)
- {
- *l = d;
- return;
- }
-
- x = d;
-
- while (x != NULL)
- {
- next = x->lu_next;
- x->lu_next = NULL;
- merge_lu_dict(l, x);
- x = next;
- }
-}
-
-/*
- * We collect values for the following keys:
- *
- * name
- * cname
- * port
- * ip_address
- * ipv6_address
- * target
- * mail_exchanger
- * priority
- * preference
- * weight
- */
-static void
-lookupd_process_dictionary(XDR *inxdr, struct lu_dict **l)
-{
- int i, nkeys, j, nvals;
- int addme;
- char *key, *val;
- struct lu_dict *d;
-
- if (!xdr_int(inxdr, &nkeys)) return;
-
- d = (struct lu_dict *)malloc(sizeof(struct lu_dict));
- memset(d, 0, sizeof(struct lu_dict));
-
- for (i = 0; i < nkeys; i++)
- {
- key = NULL;
-
- if (!xdr_string(inxdr, &key, LONG_STRING_LENGTH))
- {
- free_lu_dict(d);
- return;
- }
-
- addme = 0;
- if (!strcmp(key, "name")) addme = LU_NAME;
- else if (!strcmp(key, "cname")) addme = LU_CNAME;
- else if (!strcmp(key, "mail_exchanger")) addme = LU_MX;
- else if (!strcmp(key, "ip_address")) addme = LU_IPV4;
- else if (!strcmp(key, "ipv6_address")) addme = LU_IPV6;
- else if (!strcmp(key, "port")) addme = LU_PORT;
- else if (!strcmp(key, "target")) addme = LU_TARGET;
- else if (!strcmp(key, "priority")) addme = LU_PRIORITY;
- else if (!strcmp(key, "preference")) addme = LU_PRIORITY;
- else if (!strcmp(key, "weight")) addme = LU_WEIGHT;
- free(key);
-
- if (!xdr_int(inxdr, &nvals))
- {
- free_lu_dict(d);
- return;
- }
-
- for (j = 0; j < nvals; j++)
- {
- val = NULL;
- if (!xdr_string(inxdr, &val, LONG_STRING_LENGTH))
- {
- free_lu_dict(d);
- return;
- }
-
- if (addme == 0) free(val);
- else if (addme == LU_NAME) d->name = val;
- else if (addme == LU_CNAME) d->cname = val;
- else if (addme == LU_MX) d->mx = val;
- else if (addme == LU_IPV4) d->ipv4 = val;
- else if (addme == LU_IPV6) d->ipv6 = val;
- else if (addme == LU_PORT) d->port = val;
- else if (addme == LU_TARGET) d->target = val;
- else if (addme == LU_PRIORITY) d->priority = val;
- else if (addme == LU_WEIGHT) d->weight = val;
-
- if (addme != 0) d->count++;
- addme = 0;
- }
- }
-
- merge_lu_dict(l, d);
-}
-
-static int
-encode_kv(XDR *x, char *k, char *v)
-{
- int n = 1;
-
- if (!xdr_string(x, &k, _LU_MAXLUSTRLEN)) return 1;
- if (!xdr_int(x, &n)) return 1;
- if (!xdr_string(x, &v, _LU_MAXLUSTRLEN)) return 1;
-
- return 0;
-}
-
-static int
-gai_files(struct lu_dict *q, struct lu_dict **list)
-{
- int port, i;
- struct servent *s;
- struct hostent *h;
- struct lu_dict *d;
- char str[64], portstr[64];
- struct in_addr a4;
-
- if (!strcmp(q->type, "service"))
- {
- s = NULL;
- if (q->name != NULL)
- {
- s = getservbyname(q->name, q->protocol);
- }
- else if (q->port != NULL)
- {
- port = atoi(q->port);
- s = getservbyport(port, q->protocol);
- }
- if (s == NULL) return 0;
-
- d = (struct lu_dict *)malloc(sizeof(struct lu_dict));
- memset(d, 0, sizeof(struct lu_dict));
-
- if (s->s_name != NULL) d->name = strdup(s->s_name);
- sprintf(str, "%u", ntohl(s->s_port));
- d->port = strdup(str);
- if (s->s_proto != NULL) d->protocol = strdup(s->s_proto);
-
- merge_lu_dict(list, d);
- return 1;
- }
-
- if (!strcmp(q->type, "host"))
- {
- s = NULL;
- if (q->service != NULL)
- {
- s = getservbyname(q->service, q->protocol);
- }
- else if (q->port != NULL)
- {
- port = atoi(q->port);
- s = getservbyport(port, q->protocol);
- }
-
- sprintf(portstr, "0");
- if (s != NULL) sprintf(portstr, "%u", ntohl(s->s_port));
-
- h = NULL;
- if (q->name != NULL)
- {
- h = gethostbyname(q->name);
- }
- else if (q->ipv4 != NULL)
- {
- if (inet_aton(q->ipv4, &a4) == 0) return -1;
- h = gethostbyaddr((char *)&a4, sizeof(struct in_addr), PF_INET);
- }
- else
- {
- /* gethostbyaddr for IPV6? */
- return 0;
- }
-
- if (h == NULL) return 0;
-
- for (i = 0; h->h_addr_list[i] != 0; i++)
- {
- d = (struct lu_dict *)malloc(sizeof(struct lu_dict));
- memset(d, 0, sizeof(struct lu_dict));
-
- if (h->h_name != NULL)
- {
- d->name = strdup(h->h_name);
- d->target = strdup(h->h_name);
- }
- memmove((void *)&a4.s_addr, h->h_addr_list[i], h->h_length);
-
- sprintf(str, "%s", inet_ntoa(a4));
- d->ipv4 = strdup(str);
-
- if (s != NULL)
- {
- if (s->s_name != NULL) d->service = strdup(s->s_name);
- d->port = strdup(portstr);
- }
-
- merge_lu_dict(list, d);
- }
- return i;
- }
-
- return 0;
-}
-
-static int
-gai_lookupd(struct lu_dict *q, struct lu_dict **list)
-{
- unsigned datalen;
- XDR outxdr;
- XDR inxdr;
- int proc;
- char *listbuf;
- char databuf[_LU_MAXLUSTRLEN * BYTES_PER_XDR_UNIT];
- int n, i, na;
- kern_return_t status;
- mach_port_t server_port;
-
- if (q == NULL) return 0;
- if (q->count == 0) return 0;
- if (q->type == NULL) return 0;
-
- if (list == NULL) return -1;
-
- server_port = MACH_PORT_NULL;
- if (_lu_running()) server_port = _lookupd_port(0);
-
- if (server_port == MACH_PORT_NULL) return gai_files(q, list);
-
- status = _lookup_link(server_port, "query", &proc);
- if (status != KERN_SUCCESS) return gai_files(q, list);
-
- xdrmem_create(&outxdr, databuf, sizeof(databuf), XDR_ENCODE);
-
- /* Encode attribute count */
- na = q->count;
- if (!xdr_int(&outxdr, &na))
- {
- xdr_destroy(&outxdr);
- return -1;
- }
-
- if (encode_kv(&outxdr, "_lookup_category", q->type) != 0)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
-
- if (q->name != NULL)
- {
- if (encode_kv(&outxdr, "name", q->name) != 0)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
- }
-
- if (q->ipv4 != NULL)
- {
- if (encode_kv(&outxdr, "ip_address", q->ipv4) != 0)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
- }
-
- if (q->ipv6 != NULL)
- {
- if (encode_kv(&outxdr, "ipv6_address", q->ipv6) != 0)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
- }
-
- if (q->service != NULL)
- {
- if (encode_kv(&outxdr, "service", q->service) != 0)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
- }
-
- if (q->port != NULL)
- {
- if (encode_kv(&outxdr, "port", q->port) != 0)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
- }
-
- if (q->protocol != NULL)
- {
- if (encode_kv(&outxdr, "protocol", q->protocol) != 0)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
- }
-
- listbuf = NULL;
- datalen = 0;
-
- n = xdr_getpos(&outxdr) / BYTES_PER_XDR_UNIT;
- status = _lookup_all(server_port, proc, databuf, n, &listbuf, &datalen);
- if (status != KERN_SUCCESS)
- {
- xdr_destroy(&outxdr);
- return -1;
- }
-
- xdr_destroy(&outxdr);
-
- datalen *= BYTES_PER_XDR_UNIT;
-
- xdrmem_create(&inxdr, listbuf, datalen, XDR_DECODE);
-
- if (!xdr_int(&inxdr, &n))
- {
- xdr_destroy(&inxdr);
- return -1;
- }
-
- for (i = 0; i < n; i++)
- {
- lookupd_process_dictionary(&inxdr, list);
- }
-
- xdr_destroy(&inxdr);
-
- vm_deallocate(mach_task_self(), (vm_address_t)listbuf, datalen);
-
- return n;
-}
-
-void
-freeaddrinfo(struct addrinfo *a)
-{
- struct addrinfo *next;
-
- while (a != NULL)
- {
- next = a->ai_next;
- if (a->ai_addr != NULL) free(a->ai_addr);
- if (a->ai_canonname != NULL) free(a->ai_canonname);
- free(a);
- a = next;
- }
-}
-
-static struct addrinfo *
-new_addrinfo_v4(int flags, int sock, int proto, unsigned short port, struct in_addr addr, char *cname)
-{
- struct addrinfo *a;
- struct sockaddr_in *sa;
- int len;
-
- a = (struct addrinfo *)malloc(sizeof(struct addrinfo));
- memset(a, 0, sizeof(struct addrinfo));
- a->ai_next = NULL;
-
- a->ai_flags = flags;
- a->ai_family = PF_INET;
- a->ai_socktype = sock;
- a->ai_protocol = proto;
-
- a->ai_addrlen = sizeof(struct sockaddr_in);
- sa = (struct sockaddr_in *)malloc(a->ai_addrlen);
- memset(sa, 0, a->ai_addrlen);
- sa->sin_len = a->ai_addrlen;
- sa->sin_family = PF_INET;
- sa->sin_port = port;
- sa->sin_addr = addr;
- a->ai_addr = (struct sockaddr *)sa;
-
- if (cname != NULL)
- {
- len = strlen(cname) + 1;
- a->ai_canonname = malloc(len);
- memmove(a->ai_canonname, cname, len);
- }
-
- return a;
-}
-
-static struct addrinfo *
-new_addrinfo_v6(int flags, int sock, int proto, unsigned short port, struct in6_addr addr, char *cname)
-{
- struct addrinfo *a;
- struct sockaddr_in6 *sa;
- int len;
-
- a = (struct addrinfo *)malloc(sizeof(struct addrinfo));
- memset(a, 0, sizeof(struct addrinfo));
- a->ai_next = NULL;
-
- a->ai_flags = flags;
- a->ai_family = PF_INET6;
- a->ai_socktype = sock;
- a->ai_protocol = proto;
-
- a->ai_addrlen = sizeof(struct sockaddr_in6);
- sa = (struct sockaddr_in6 *)malloc(a->ai_addrlen);
- memset(sa, 0, a->ai_addrlen);
- sa->sin6_len = a->ai_addrlen;
- sa->sin6_family = PF_INET6;
- sa->sin6_port = port;
- sa->sin6_addr = addr;
- a->ai_addr = (struct sockaddr *)sa;
-
- if (cname != NULL)
- {
- len = strlen(cname) + 1;
- a->ai_canonname = malloc(len);
- memmove(a->ai_canonname, cname, len);
- }
-
- return a;
-}
-
-static void
-grok_nodename(const char *nodename, int family, struct lu_dict *q)
-{
- if (nodename == NULL) return;
- if (q == NULL) return;
-
- if (((family == PF_UNSPEC) || (family == PF_INET)) && is_ipv4_address(nodename))
- {
- q->ipv4 = (char *)nodename;
- }
- else if (((family == PF_UNSPEC) || (family == PF_INET6)) && is_ipv6_address(nodename))
- {
- q->ipv6 = (char *)nodename;
- }
- else
- {
- q->name = (char *)nodename;
- }
-}
-
-static void
-grok_service(const char *servname, struct lu_dict *q)
-{
- int port;
- char *p;
-
- if (servname == NULL) return;
- if (q == NULL) return;
-
- port = 0;
- for (p = (char *)servname; (port == 0) && (*p != '\0'); p++)
- {
- if (!isdigit(*p)) port = -1;
- }
-
- if (port == 0) q->port = (char *)servname;
- else q->service = (char *)servname;
-}
-
-static int
-gai_numerichost(struct lu_dict *h, struct lu_dict **list)
-{
- struct lu_dict *a;
- int n;
-
- if (h == NULL) return 0;
- if (list == NULL) return -1;
-
- n = 0;
-
- if (h->ipv4 != NULL)
- {
- a = (struct lu_dict *)malloc(sizeof(struct lu_dict));
- memset(a, 0, sizeof(struct lu_dict));
- a->ipv4 = strdup(h->ipv4);
- merge_lu_dict(list, a);
- n++;
- }
-
- if (h->ipv6 != NULL)
- {
- a = (struct lu_dict *)malloc(sizeof(struct lu_dict));
- memset(a, 0, sizeof(struct lu_dict));
- a->ipv6 = strdup(h->ipv6);
- merge_lu_dict(list, a);
- n++;
- }
-
- return n;
-}
-
-static int
-gai_numericserv(struct lu_dict *s, struct lu_dict **list)
-{
- struct lu_dict *a;
-
- if (s == NULL) return 0;
- if (s->port == NULL) return 0;
- if (list == NULL) return -1;
-
- a = (struct lu_dict *)malloc(sizeof(struct lu_dict));
- memset(a, 0, sizeof(struct lu_dict));
- a->port = strdup(s->port);
- merge_lu_dict(list, a);
- return 1;
-}
-
-static void
-merge_addr4(struct in_addr a, struct sockaddr_in ***l, int *n)
-{
- int i;
- struct sockaddr_in *sa4;
-
- for (i = 0; i < *n; i++)
- {
- if (((*l)[i]->sin_family == PF_INET) && (a.s_addr == (*l)[i]->sin_addr.s_addr)) return;
- }
-
- sa4 = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
- memset(sa4, 0, sizeof(struct sockaddr_in));
-
- sa4->sin_family = PF_INET;
- sa4->sin_addr = a;
-
- if (*n == 0) *l = (struct sockaddr_in **)malloc(sizeof(struct sockaddr_in *));
- else *l = (struct sockaddr_in **)realloc(*l, (*n + 1) * sizeof(struct sockaddr_in *));
-
- (*l)[*n] = sa4;
- (*n)++;
-}
-
-static void
-merge_addr6(struct in6_addr a, struct sockaddr_in6 ***l, int *n)
-{
- int i;
- struct sockaddr_in6 *sa6;
-
- for (i = 0; i < *n; i++)
- {
- if (((*l)[i]->sin6_family == PF_INET6)
- && (a.__u6_addr.__u6_addr32[0] == (*l)[i]->sin6_addr.__u6_addr.__u6_addr32[0])) return;
- }
-
- sa6 = (struct sockaddr_in6 *)malloc(sizeof(struct sockaddr_in6));
- memset(sa6, 0, sizeof(struct sockaddr_in6));
-
- sa6->sin6_family = PF_INET6;
- sa6->sin6_addr = a;
-
- if (*n == 0) *l = (struct sockaddr_in6 **)malloc(sizeof(struct sockaddr_in6 *));
- else *l = (struct sockaddr_in6 **)realloc(*l, (*n + 1) * sizeof(struct sockaddr_in6 *));
-
- (*l)[*n] = sa6;
- (*n)++;
-}
-
-/*
- * N.B. We use sim_family to store protocol in the sockaddr.
- * sockaddr is just used here as a data structure to keep
- * (port, protocol) pairs.
- */
-static void
-merge_plist(unsigned short port, unsigned short proto, struct sockaddr_in ***l, int *n)
-{
- int i;
- struct sockaddr_in *sa4;
-
- for (i = 0; i < *n; i++)
- {
- if ((port == (*l)[i]->sin_port) && (proto == (*l)[i]->sin_family)) return;
- }
-
- sa4 = (struct sockaddr_in *)malloc(sizeof(struct sockaddr_in));
- memset(sa4, 0, sizeof(struct sockaddr_in));
-
- sa4->sin_port = port;
- sa4->sin_family = proto;
-
- if (*n == 0) *l = (struct sockaddr_in **)malloc(sizeof(struct sockaddr_in *));
- else *l = (struct sockaddr_in **)realloc(*l, (*n + 1) * sizeof(struct sockaddr_in *));
-
- (*l)[*n] = (struct sockaddr_in *)sa4;
- (*n)++;
-}
-
-/*
- * Compute x[n + 1] = (7^5 * x[n]) mod (2^31 - 1).
- * From "Random number generators: good ones are hard to find",
- * Park and Miller, Communications of the ACM, vol. 31, no. 10,
- * October 1988, p. 1195.
- */
-static int
-gai_random()
-{
- static int did_init = 0;
- static unsigned int randseed = 1;
- int x, hi, lo, t;
- struct timeval tv;
-
- if (did_init++ == 0)
- {
- gettimeofday(&tv, NULL);
- randseed = tv.tv_usec;
- if(randseed == 0) randseed = 1;
- }
-
- x = randseed;
- hi = x / 127773;
- lo = x % 127773;
- t = 16807 * lo - 2836 * hi;
- if (t <= 0) t += 0x7fffffff;
- randseed = t;
- return t;
-}
-
-/*
- * Sort by priority and weight.
- */
-void
-lu_prioity_sort(struct lu_dict **l)
-{
- struct lu_dict *d, **nodes;
- unsigned int x, count, i, j, bottom, *pri, *wgt, swap, t;
-
- if (*l == NULL) return;
-
- count = 0;
- for (d = *l; d != NULL; d = d->lu_next) count++;
- nodes = (struct lu_dict **)malloc(count * sizeof(struct lu_dict *));
- pri = (unsigned int *)malloc(count * sizeof(unsigned int));
- wgt = (unsigned int *)malloc(count * sizeof(unsigned int));
-
- for (i = 0, d = *l; d != NULL; d = d->lu_next, i++)
- {
- nodes[i] = d;
-
- x = (unsigned int)-1;
- if (d->priority != NULL) x = atoi(d->priority);
- pri[i] = x;
-
- x = 0;
- if (d->weight != NULL) x = atoi(d->weight);
- wgt[i] = (gai_random() % 10000) * x;
- }
-
- /* bubble sort by priority */
- swap = 1;
- bottom = count - 1;
-
- while (swap == 1)
- {
- swap = 0;
- for (i = 0, j = 1; i < bottom; i++, j++)
- {
- if (pri[i] < pri[j]) continue;
- if ((pri[i] == pri[j]) && (wgt[i] < wgt[j])) continue;
- swap = 1;
-
- t = pri[i];
- pri[i] = pri[j];
- pri[j] = t;
-
- t = wgt[i];
- wgt[i] = wgt[j];
- wgt[j] = t;
-
- d = nodes[i];
- nodes[i] = nodes[j];
- nodes[j] = d;
- }
-
- bottom--;
- }
-
- *l = nodes[0];
- bottom = count - 1;
- for (i = 0, j = 1; i < bottom; i++, j++) nodes[i]->lu_next = nodes[j];
- nodes[bottom]->lu_next = NULL;
-
- free(pri);
- free(wgt);
- free(nodes);
-}
-
-/*
- * Get service records from lookupd
- */
-static void
-gai_serv_lookupd(const char *servname, int proto, int numericserv, struct lu_dict **list)
-{
- struct lu_dict q, *sub;
-
- memset(&q, 0, sizeof(struct lu_dict));
- q.count = 3;
- q.type = "service";
-
- grok_service(servname, &q);
- if (q.service != NULL)
- {
- q.name = q.service;
- q.service = NULL;
- }
-
- if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP))
- {
- sub = NULL;
- q.protocol = "udp";
- if (numericserv == 1) gai_numericserv(&q, &sub);
- else gai_lookupd(&q, &sub);
- append_lu_dict(list, sub);
- for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("udp");
- }
-
- if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP))
- {
- sub = NULL;
- q.protocol = "tcp";
- if (numericserv == 1) gai_numericserv(&q, &sub);
- else gai_lookupd(&q, &sub);
- append_lu_dict(list, sub);
- for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("tcp");
- }
-}
-
-/*
- * Find a service.
- */
-static int
-gai_serv(const char *servname, const struct addrinfo *hints, struct addrinfo **res)
-{
- struct lu_dict *list, *d;
- int proto, family, socktype, setcname, wantv4, wantv6;
- unsigned short port;
- char *loopv4, *loopv6;
- struct addrinfo *a;
- struct in_addr a4;
- struct in6_addr a6;
-
- loopv4 = "127.0.0.1";
- loopv6 = "0:0:0:0:0:0:0:1";
-
- family = PF_UNSPEC;
- proto = IPPROTO_UNSPEC;
- setcname = 0;
-
- if (hints != NULL)
- {
- proto = hints->ai_protocol;
- if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP;
- if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP;
-
- if (hints->ai_flags & AI_CANONNAME) setcname = 1;
-
- if ((hints->ai_flags & AI_PASSIVE) == 1)
- {
- loopv4 = "0.0.0.0";
- loopv6 = "0:0:0:0:0:0:0:0";
- }
-
- family = hints->ai_family;
- }
-
- wantv4 = 1;
- wantv6 = 1;
- if (family == PF_INET6) wantv4 = 0;
- if (family == PF_INET) wantv6 = 0;
-
- list = NULL;
- gai_serv_lookupd(servname, proto, 0, &list);
- if (list == NULL) gai_serv_lookupd(servname, proto, 1, &list);
-
- for (d = list; d != NULL; d = d->lu_next)
- {
- /* We only want records with port and protocol specified */
- if ((d->port == NULL) || (d->protocol == NULL)) continue;
-
- port = htons(atoi(d->port));
- proto = IPPROTO_UDP;
- socktype = SOCK_DGRAM;
- if (!strcasecmp(d->protocol, "tcp"))
- {
- proto = IPPROTO_TCP;
- socktype = SOCK_STREAM;
- }
-
- if (wantv4 == 1)
- {
- inet_aton(loopv4, &a4);
- a = new_addrinfo_v4(0, socktype, proto, port, a4, NULL);
- append_addrinfo(res, a);
- }
-
- if (wantv6 == 1)
- {
- gai_inet_pton(loopv6, &a6);
- a = new_addrinfo_v6(0, socktype, proto, port, a6, NULL);
- append_addrinfo(res, a);
- }
- }
-
- free_lu_dict(list);
-
- /* Set cname in first result */
- if ((setcname == 1) && (*res != NULL))
- {
- if (res[0]->ai_canonname == NULL) res[0]->ai_canonname = strdup("localhost");
- }
-
- return 0;
-}
-
-/*
- * Find a node.
- */
-static void
-gai_node_lookupd(const char *nodename, int family, int numerichost, struct lu_dict **list)
-{
- struct lu_dict q;
-
- memset(&q, 0, sizeof(struct lu_dict));
- q.count = 2;
- q.type = "host";
-
- grok_nodename(nodename, family, &q);
- if (numerichost) gai_numerichost(&q, list);
- else gai_lookupd(&q, list);
-}
-
-/*
- * Find a node.
- */
-static int
-gai_node(const char *nodename, const struct addrinfo *hints, struct addrinfo **res)
-{
- int i, family, numerichost, setcname, a_list_count, wantv4, wantv6;
- struct lu_dict *list, *d, *t;
- char *cname;
- struct in_addr a4;
- struct in6_addr a6;
- struct addrinfo *a;
- struct sockaddr **a_list;
- struct sockaddr_in *sa4;
- struct sockaddr_in6 *sa6;
-
- a_list_count = 0;
- a_list = NULL;
-
- numerichost = 0;
- family = PF_UNSPEC;
- setcname = 0;
- cname = NULL;
-
- if (hints != NULL)
- {
- family = hints->ai_family;
- if (hints->ai_flags & AI_NUMERICHOST) numerichost = 1;
- if (hints->ai_flags & AI_CANONNAME) setcname = 1;
- }
-
- wantv4 = 1;
- wantv6 = 1;
- if (family == PF_INET6) wantv4 = 0;
- if (family == PF_INET) wantv6 = 0;
-
- t = NULL;
- gai_node_lookupd(nodename, family, numerichost, &t);
- if ((t == NULL) && (numerichost == 0))
- {
- gai_node_lookupd(nodename, family, 1, &t);
- }
-
- /* If the nodename is an alias, look up the real name */
- list = NULL;
- for (d = t; d != NULL; d = d->lu_next)
- {
- if (d->cname != NULL)
- {
- if (cname == NULL) cname = strdup(d->cname);
- gai_node_lookupd(d->cname, family, 0, &t);
- }
- }
-
- append_lu_dict(&list, t);
-
- for (d = list; d != NULL; d = d->lu_next)
- {
- /* Check for cname */
- if ((cname == NULL) && (d->name != NULL) && (strchr(d->name, '.') != NULL))
- {
- cname = strdup(d->name);
- }
-
- /* Check for ipv4 address */
- if ((d->ipv4 != NULL) && (wantv4 == 1))
- {
- inet_aton(d->ipv4, &a4);
- merge_addr4(a4, (struct sockaddr_in ***)&a_list, &a_list_count);
- }
-
- /* Check for ipv6 address */
- if ((d->ipv6 != NULL) && (wantv6 == 1))
- {
- gai_inet_pton(d->ipv6, &a6);
- merge_addr6(a6, (struct sockaddr_in6 ***)&a_list, &a_list_count);
- }
- }
-
- /* Last chance for a name */
- for (d = list; (cname == NULL) && (d != NULL); d = d->lu_next)
- {
- if (d->name != NULL) cname = strdup(d->name);
- }
-
- free_lu_dict(list);
-
- for (i = 0; i < a_list_count; i++)
- {
- if (a_list[i]->sa_family == PF_INET)
- {
- sa4 = (struct sockaddr_in *)a_list[i];
- a = new_addrinfo_v4(0, 0, 0, 0, sa4->sin_addr, NULL);
- append_addrinfo(res, a);
- }
- else if (a_list[i]->sa_family == PF_INET6)
- {
- sa6 = (struct sockaddr_in6 *)a_list[i];
- a = new_addrinfo_v6(0, 0, 0, 0, sa6->sin6_addr, NULL);
- append_addrinfo(res, a);
- }
-
- free(a_list[i]);
- }
-
- if (a_list_count > 0) free(a_list);
-
- /* Set cname in first result */
- if ((setcname == 1) && (*res != NULL))
- {
- if (res[0]->ai_canonname == NULL)
- {
- res[0]->ai_canonname = cname;
- cname = NULL;
- }
- }
-
- if (cname != NULL) free(cname);
-
- return 0;
-}
-
-/*
- * Find a service+node.
- */
-static void
-gai_nodeserv_lookupd(const char *nodename, const char *servname, const struct addrinfo *hints, struct lu_dict **list)
-{
- struct lu_dict q, *sub;
- int proto, family;
-
- family = PF_UNSPEC;
- proto = IPPROTO_UNSPEC;
-
- if (hints != NULL)
- {
- if (hints->ai_flags & AI_NUMERICHOST) return;
- family = hints->ai_family;
-
- proto = hints->ai_protocol;
- if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP;
- if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP;
- }
-
- memset(&q, 0, sizeof(struct lu_dict));
- q.count = 4;
- q.type = "host";
-
- grok_nodename(nodename, family, &q);
- grok_service(servname, &q);
-
- if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP))
- {
- sub = NULL;
- q.protocol = "udp";
- gai_lookupd(&q, &sub);
- append_lu_dict(list, sub);
- for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("udp");
- }
-
- if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP))
- {
- sub = NULL;
- q.protocol = "tcp";
- gai_lookupd(&q, &sub);
- append_lu_dict(list, sub);
- for (; sub != NULL; sub = sub->lu_next) sub->protocol = strdup("tcp");
- }
-}
-
-static void
-gai_node_pp(const char *nodename, unsigned short port, int proto, int family, int setcname, struct addrinfo **res)
-{
- struct lu_dict *list, *d;
- int i, wantv4, wantv6, a_list_count, socktype;
- char *cname;
- struct sockaddr **a_list;
- struct in_addr a4;
- struct in6_addr a6;
- struct sockaddr_in *sa4;
- struct sockaddr_in6 *sa6;
- struct addrinfo *a;
-
- socktype = SOCK_UNSPEC;
- if (proto == IPPROTO_UDP) socktype = SOCK_DGRAM;
- if (proto == IPPROTO_TCP) socktype = SOCK_STREAM;
-
- cname = NULL;
-
- wantv4 = 1;
- wantv6 = 1;
- if (family == PF_INET6) wantv4 = 0;
- if (family == PF_INET) wantv6 = 0;
-
- /* Resolve node name */
- list = NULL;
- gai_node_lookupd(nodename, family, 0, &list);
- if (list == NULL)
- {
- gai_node_lookupd(nodename, family, 1, &list);
- }
-
- /* Resolve aliases */
- for (d = list; d != NULL; d = d->lu_next)
- {
- if (d->cname != NULL)
- {
- if (cname == NULL) cname = strdup(d->cname);
- gai_node_lookupd(d->cname, family, 0, &list);
- }
- }
-
- a_list_count = 0;
-
- for (d = list; d != NULL; d = d->lu_next)
- {
- /* Check for cname */
- if ((cname == NULL) && (d->name != NULL) && (strchr(d->name, '.') != NULL))
- {
- cname = strdup(d->name);
- }
-
- /* Check for ipv4 address */
- if ((d->ipv4 != NULL) && (wantv4 == 1))
- {
- inet_aton(d->ipv4, &a4);
- merge_addr4(a4, (struct sockaddr_in ***)&a_list, &a_list_count);
- }
-
- /* Check for ipv6 address */
- if ((d->ipv6 != NULL) && (wantv6 == 1))
- {
- gai_inet_pton(d->ipv6, &a6);
- merge_addr6(a6, (struct sockaddr_in6 ***)&a_list, &a_list_count);
- }
- }
-
- free_lu_dict(list);
-
- for (i = 0; i < a_list_count; i++)
- {
- if (a_list[i]->sa_family == PF_INET)
- {
- sa4 = (struct sockaddr_in *)a_list[i];
- a = new_addrinfo_v4(0, socktype, proto, port, sa4->sin_addr, NULL);
- append_addrinfo(res, a);
- }
- else if (a_list[i]->sa_family == PF_INET6)
- {
- sa6 = (struct sockaddr_in6 *)a_list[i];
- a = new_addrinfo_v6(0, socktype, proto, port, sa6->sin6_addr, NULL);
- append_addrinfo(res, a);
- }
-
- free(a_list[i]);
- }
-
- if (a_list_count > 0) free(a_list);
-
- /* Set cname in first result */
- if ((setcname == 1) && (*res != NULL))
- {
- if (res[0]->ai_canonname == NULL)
- {
- res[0]->ai_canonname = cname;
- cname = NULL;
- }
- }
-
- if (cname != NULL) free(cname);
-}
-
-static int
-gai_nodeserv(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
-{
- struct lu_dict *srv_list, *node_list, *s, *n;
- int numerichost, family, proto, setcname;
- int wantv4, wantv6, i, j, gotmx, p_list_count;
- unsigned short port;
- char *cname;
- struct sockaddr **p_list;
- struct sockaddr_in *sa4;
-
- numerichost = 0;
- family = PF_UNSPEC;
- proto = IPPROTO_UNSPEC;
- setcname = 0;
- cname = NULL;
- wantv4 = 1;
- wantv6 = 1;
-
- if (hints != NULL)
- {
- family = hints->ai_family;
- if (hints->ai_flags & AI_NUMERICHOST) numerichost = 1;
- if (hints->ai_flags & AI_CANONNAME) setcname = 1;
-
- proto = hints->ai_protocol;
- if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP;
- if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP;
- }
-
- if (family == PF_INET6) wantv4 = 0;
- if (family == PF_INET) wantv6 = 0;
-
- /* First check for this particular host / service (e.g. DNS_SRV) */
-
- srv_list = NULL;
- gai_nodeserv_lookupd(nodename, servname, hints, &srv_list);
- lu_prioity_sort(&srv_list);
-
- if (srv_list != NULL)
- {
- for (s = srv_list; s != NULL; s = s->lu_next)
- {
- if (s->port == NULL) continue;
- if (s->protocol == NULL) continue;
-
- i = htons(atoi(s->port));
- j = IPPROTO_UDP;
- if (!strcmp(s->protocol, "tcp")) j = IPPROTO_TCP;
- gai_node_pp(s->target, i, j, family, setcname, res);
- }
-
- free_lu_dict(srv_list);
- return 0;
- }
-
- /*
- * Special case for smtp: collect mail_exchangers.
- */
- gotmx = 0;
- node_list = NULL;
-
- if (!strcmp(servname, "smtp"))
- {
- gai_node_lookupd(nodename, family, numerichost, &node_list);
- if ((node_list == NULL) && (numerichost == 0))
- {
- gai_node_lookupd(nodename, family, 1, &node_list);
- }
-
- lu_prioity_sort(&node_list);
-
- for (n = node_list; (n != NULL) && (gotmx == 0); n = n->lu_next)
- {
- if (n->mx != NULL) gotmx = 1;
- }
-
- if ((gotmx == 0) && (node_list != NULL))
- {
- free_lu_dict(node_list);
- node_list = NULL;
- }
- }
-
- /*
- * Look up service, look up node, and combine port/proto with node addresses.
- */
- srv_list = NULL;
- gai_serv_lookupd(servname, proto, 0, &srv_list);
- if (srv_list == NULL) gai_serv_lookupd(servname, proto, 1, &srv_list);
- if (srv_list == NULL) return 0;
-
- p_list_count = 0;
- for (s = srv_list; s != NULL; s = s->lu_next)
- {
- if (s->port == NULL) continue;
- if (s->protocol == NULL) continue;
-
- i = htons(atoi(s->port));
- j = IPPROTO_UDP;
- if (!strcmp(s->protocol, "tcp")) j = IPPROTO_TCP;
-
- merge_plist(i, j, (struct sockaddr_in ***)&p_list, &p_list_count);
- }
-
- free_lu_dict(srv_list);
-
- for (i = 0; i < p_list_count; i++)
- {
- sa4 = (struct sockaddr_in *)p_list[i];
- port = sa4->sin_port;
- /* N.B. sin_family is overloaded */
- proto = sa4->sin_family;
-
- if (gotmx == 1)
- {
- for (n = node_list; n != NULL; n = n->lu_next)
- {
- if (n->mx != NULL) gai_node_pp(n->mx, port, proto, family, setcname, res);
- }
- }
- else
- {
- gai_node_pp(nodename, port, proto, family, setcname, res);
- }
-
- free(p_list[i]);
- }
-
- if (node_list != NULL) free_lu_dict(node_list);
-
- if (p_list_count > 0) free(p_list);
- return 0;
-}
-
-int
-getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
-{
- int status;
- struct lu_dict *list;
-
- if (res == NULL) return 0;
- *res = NULL;
- list = NULL;
-
- /* Check input */
- if ((nodename == NULL) && (servname == NULL)) return EAI_NONAME;
-
- /* Check hints */
- if (hints != NULL)
- {
- if (hints->ai_addrlen != 0) return EAI_BADHINTS;
- if (hints->ai_canonname != NULL) return EAI_BADHINTS;
- if (hints->ai_addr != NULL) return EAI_BADHINTS;
- if (hints->ai_next != NULL) return EAI_BADHINTS;
-
- /* Check for supported protocol family */
- if (gai_family_type_check(hints->ai_family) != 0) return EAI_FAMILY;
-
- /* Check for supported socket */
- if (gai_socket_type_check(hints->ai_socktype) != 0) return EAI_BADHINTS;
-
- /* Check for supported protocol */
- if (gai_protocol_type_check(hints->ai_protocol) != 0) return EAI_BADHINTS;
-
- /* Check that socket type is compatible with protocol */
- if (gai_socket_protocol_type_check(hints->ai_socktype, hints->ai_protocol) != 0) return EAI_BADHINTS;
- }
-
- status = 0;
-
- if (nodename == NULL)
- {
- /* If node is NULL, find service */
- status = gai_serv(servname, hints, res);
- if ((status == 0) && (*res == NULL)) status = EAI_NODATA;
- return status;
- }
-
- if (servname == NULL)
- {
- /* If service is NULL, find node */
- status = gai_node(nodename, hints, res);
- if ((status == 0) && (*res == NULL)) status = EAI_NODATA;
- return status;
- }
-
- /* Find node + service */
- status = gai_nodeserv(nodename, servname, hints, res);
- if ((status == 0) && (*res == NULL)) status = EAI_NODATA;
- return status;
-}
-
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
.Dv AF_INET ,
for example
.Dv AF_INET6 .
-Currently the
-.Fa af
-argument must be specified as
-.Dv AF_INET
-else the function will return
-.Dv NULL
-after having set
-.Va h_errno
-to
-.Dv NETDB_INTERNAL
+Both of these address families are supported in the Mac OS X implemention.
.Pp
The
.Fn sethostent
and
.Fn endhostent
are redefined,
-when
-.Xr libc 3
-is built to use only the routines to lookup in
+when libc is built to use only the routines to lookup in
.Pa /etc/hosts
and not the name server.
.Pp
#define HAVE_IFM_DATA
#endif
+#ifdef __APPLE__
+#define HAVE_IFM_DATA
+#endif
+
int
getifaddrs(struct ifaddrs **pif)
{
.Fn getnameinfo 3
are recommended.
.Pp
-The current implementation is not thread-safe.
-.Pp
The text was shamelessly copied from RFC2553.
+++ /dev/null
-.\" $FreeBSD: src/lib/libc/net/getnameinfo.3,v 1.2.2.7 2001/08/17 15:42:38 ru Exp $
-.\" $KAME: getnameinfo.3,v 1.17 2000/08/09 21:16:17 itojun Exp $
-.\"
-.\" Copyright (c) 1983, 1987, 1991, 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
-.\"
-.Dd May 25, 1995
-.Dt GETNAMEINFO 3
-.Os
-.\"
-.Sh NAME
-.Nm getnameinfo
-.Nd address-to-nodename translation in protocol-independent manner
-.\"
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <netdb.h>
-.Ft int
-.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \
-"char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags"
-.\"
-.Sh DESCRIPTION
-The
-.Fn getnameinfo
-function is defined for protocol-independent address-to-nodename translation.
-Its functionality is a reverse conversion of
-.Xr getaddrinfo 3 ,
-and implements similar functionality with
-.Xr gethostbyaddr 3
-and
-.Xr getservbyport 3
-in more sophisticated manner.
-.Pp
-This function looks up an IP address and port number provided by the
-caller in the DNS and system-specific database, and returns text
-strings for both in buffers provided by the caller.
-The function indicates successful completion by a zero return value;
-a non-zero return value indicates failure.
-.Pp
-The first argument,
-.Fa sa ,
-points to either a
-.Li sockaddr_in
-structure (for IPv4) or a
-.Li sockaddr_in6
-structure (for IPv6) that holds the IP address and port number.
-The
-.Fa salen
-argument gives the length of the
-.Li sockaddr_in
-or
-.Li sockaddr_in6
-structure.
-.Pp
-The function returns the nodename associated with the IP address in
-the buffer pointed to by the
-.Fa host
-argument.
-The caller provides the size of this buffer via the
-.Fa hostlen
-argument.
-The service name associated with the port number is returned in the buffer
-pointed to by
-.Fa serv ,
-and the
-.Fa servlen
-argument gives the length of this buffer.
-The caller specifies not to return either string by providing a zero
-value for the
-.Fa hostlen
-or
-.Fa servlen
-arguments.
-Otherwise, the caller must provide buffers large enough to hold the
-nodename and the service name, including the terminating null characters.
-.Pp
-Unfortunately most systems do not provide constants that specify the
-maximum size of either a fully-qualified domain name or a service name.
-Therefore to aid the application in allocating buffers for these two
-returned strings the following constants are defined in
-.Aq Pa netdb.h :
-.Bd -literal -offset
-#define NI_MAXHOST 1025
-#define NI_MAXSERV 32
-.Ed
-.Pp
-The first value is actually defined as the constant
-.Dv MAXDNAME
-in recent versions of BIND's
-.Aq Pa arpa/nameser.h
-header
-(older versions of BIND define this constant to be 256)
-and the second is a guess based on the services listed in the current
-Assigned Numbers RFC.
-.Pp
-The final argument is a
-.Fa flag
-that changes the default actions of this function.
-By default the fully-qualified domain name (FQDN) for the host is
-looked up in the DNS and returned.
-If the flag bit
-.Dv NI_NOFQDN
-is set, only the nodename portion of the FQDN is returned for local hosts.
-.Pp
-If the
-.Fa flag
-bit
-.Dv NI_NUMERICHOST
-is set, or if the host's name cannot be located in the DNS,
-the numeric form of the host's address is returned instead of its name
-(e.g., by calling
-.Fn inet_ntop
-instead of
-.Fn getnodebyaddr ) .
-If the
-.Fa flag
-bit
-.Dv NI_NAMEREQD
-is set, an error is returned if the host's name cannot be located in the DNS.
-.Pp
-If the flag bit
-.Dv NI_NUMERICSERV
-is set, the numeric form of the service address is returned
-(e.g., its port number)
-instead of its name.
-The two
-.Dv NI_NUMERICxxx
-flags are required to support the
-.Fl n
-flag that many commands provide.
-.Pp
-A fifth flag bit,
-.Dv NI_DGRAM ,
-specifies that the service is a datagram service, and causes
-.Fn getservbyport
-to be called with a second argument of
-.Dq udp
-instead of its default of
-.Dq tcp .
-This is required for the few ports (512-514)
-that have different services for UDP and TCP.
-.Pp
-These
-.Dv NI_xxx
-flags are defined in
-.Aq Pa netdb.h .
-.\"
-.Sh EXTENSION
-The implementation allows experimental numeric IPv6 address notation with
-scope identifier.
-IPv6 link-local address will appear as string like
-.Dq Li fe80::1%ne0 ,
-if
-.Dv NI_WITHSCOPEID
-bit is enabled in
-.Ar flags
-argument.
-Refer to
-.Xr getaddrinfo 3
-for the notation.
-.\"
-.Sh EXAMPLES
-The following code tries to get numeric hostname, and service name,
-for given socket address.
-Observe that there is no hardcoded reference to particular address family.
-.Bd -literal -offset indent
-struct sockaddr *sa; /* input */
-char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
-
-if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf,
- sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
- errx(1, "could not get numeric hostname");
- /*NOTREACHED*/
-}
-printf("host=%s, serv=%s\\n", hbuf, sbuf);
-.Ed
-.Pp
-The following version checks if the socket address has reverse address mapping.
-.Bd -literal -offset indent
-struct sockaddr *sa; /* input */
-char hbuf[NI_MAXHOST];
-
-if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0,
- NI_NAMEREQD)) {
- errx(1, "could not resolve hostname");
- /*NOTREACHED*/
-}
-printf("host=%s\\n", hbuf);
-.Ed
-.\"
-.Sh FILES
-.Bl -tag -width /etc/resolv.conf -compact
-.It Pa /etc/hosts
-.It Pa /etc/host.conf
-.It Pa /etc/resolv.conf
-.El
-.\"
-.Sh DIAGNOSTICS
-The function indicates successful completion by a zero return value;
-a non-zero return value indicates failure.
-Error codes are as below:
-.Bl -tag -width Er
-.It Bq Er EAI_AGAIN
-The name could not be resolved at this time.
-Future attempts may succeed.
-.It Bq Er EAI_BADFLAGS
-The flags had an invalid value.
-.It Bq Er EAI_FAIL
-A non-recoverable error occurred.
-.It Bq Er EAI_FAMILY
-The address family was not recognized or the address length was invalid
-for the specified family.
-.It Bq Er EAI_MEMORY
-There was a memory allocation failure.
-.It Bq Er EAI_NONAME
-The name does not resolve for the supplied parameters.
-.Dv NI_NAMEREQD
-is set and the host's name cannot be located,
-or both nodename and servname were null.
-.It Bq Er EAI_SYSTEM
-A system error occurred.
-The error code can be found in errno.
-.El
-.\"
-.Sh SEE ALSO
-.Xr getaddrinfo 3 ,
-.Xr gethostbyaddr 3 ,
-.Xr getservbyport 3 ,
-.Xr hosts 5 ,
-.Xr services 5 ,
-.Xr hostname 7 ,
-.Xr named 8
-.Pp
-.Rs
-.%A R. Gilligan
-.%A S. Thomson
-.%A J. Bound
-.%A W. Stevens
-.%T Basic Socket Interface Extensions for IPv6
-.%R RFC2553
-.%D March 1999
-.Re
-.Rs
-.%A Tatsuya Jinmei
-.%A Atsushi Onoe
-.%T "An Extension of Format for IPv6 Scoped Addresses"
-.%R internet draft
-.%N draft-ietf-ipngwg-scopedaddr-format-02.txt
-.%O work in progress material
-.Re
-.Rs
-.%A Craig Metz
-.%T Protocol Independence Using the Sockets API
-.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference"
-.%D June 2000
-.Re
-.\"
-.Sh HISTORY
-The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit.
-.\"
-.Sh STANDARDS
-The
-.Fn getaddrinfo
-function is defined in
-.St -p1003.1g-2000 ,
-and documented in
-.Dq Basic Socket Interface Extensions for IPv6
-(RFC2553).
-.\"
-.Sh BUGS
-The current implementation is not thread-safe.
-.Pp
-The text was shamelessly copied from RFC2553.
-.Pp
-The type of the 2nd argument should be
-.Li socklen_t
-for RFC2553 conformance.
-The current code is based on pre-RFC2553 specification.
+++ /dev/null
-/* $FreeBSD: src/lib/libc/net/getnameinfo.c,v 1.5 2000/07/05 05:09:17 itojun Exp $ */
-/* $KAME: getnameinfo.c,v 1.43 2000/06/12 04:27:03 itojun Exp $ */
-
-/*
- * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. Neither the name of the project nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-/*
- * Issues to be discussed:
- * - Thread safe-ness must be checked
- * - Return values. There seems to be no standard for return value (RFC2553)
- * but INRIA implementation returns EAI_xxx defined for getaddrinfo().
- * - RFC2553 says that we should raise error on short buffer. X/Open says
- * we need to truncate the result. We obey RFC2553 (and X/Open should be
- * modified).
- * - What is "local" in NI_FQDN?
- * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other.
- * - (KAME extension) NI_WITHSCOPEID when called with global address,
- * and sin6_scope_id filled
- */
-
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <net/if.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-#include <arpa/nameser.h>
-#include <netdb.h>
-#include <resolv.h>
-#include <string.h>
-#include <stddef.h>
-#include <errno.h>
-
-#define SUCCESS 0
-#define ANY 0
-#define YES 1
-#define NO 0
-
-static struct afd {
- int a_af;
- int a_addrlen;
- int a_socklen;
- int a_off;
-} afdl [] = {
-#ifdef INET6
- {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6),
- offsetof(struct sockaddr_in6, sin6_addr)},
-#endif
- {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in),
- offsetof(struct sockaddr_in, sin_addr)},
- {0, 0, 0},
-};
-
-struct sockinet {
- u_char si_len;
- u_char si_family;
- u_short si_port;
-};
-
-
-#ifdef INET6
-static int ip6_parsenumeric __P((const struct sockaddr *, const char *, char *,
- size_t, int));
-static int ip6_sa2str __P((const struct sockaddr_in6 *, char *, size_t, int));
-#endif
-
-#define ENI_NOSOCKET EAI_FAIL /*XXX*/
-#define ENI_NOSERVNAME EAI_NONAME
-#define ENI_NOHOSTNAME EAI_NONAME
-#define ENI_MEMORY EAI_MEMORY
-#define ENI_SYSTEM EAI_SYSTEM
-#define ENI_FAMILY EAI_FAMILY
-#define ENI_SALEN EAI_FAMILY
-
-int
-getnameinfo(sa, salen, host, hostlen, serv, servlen, flags)
- const struct sockaddr *sa;
- size_t salen;
- char *host;
- size_t hostlen;
- char *serv;
- size_t servlen;
- int flags;
-{
- struct afd *afd;
- struct servent *sp;
- struct hostent *hp;
- u_short port;
- int family, i;
- const char *addr;
- u_int32_t v4a;
- char numserv[512];
- char numaddr[512];
-
- if (sa == NULL)
- return ENI_NOSOCKET;
-
-#ifdef NOTDEF
- if (sa->sa_len != salen)
- return ENI_SALEN;
-#endif
-
- family = sa->sa_family;
- for (i = 0; afdl[i].a_af; i++)
- if (afdl[i].a_af == family) {
- afd = &afdl[i];
- goto found;
- }
- return ENI_FAMILY;
-
- found:
- if (salen != afd->a_socklen)
- return ENI_SALEN;
-
- /* network byte order */
- port = ((const struct sockinet *)sa)->si_port;
- addr = (const char *)sa + afd->a_off;
-
- if (serv == NULL || servlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that serv == NULL OR servlen == 0
- * means that the caller does not want the result.
- */
- } else {
- if (flags & NI_NUMERICSERV)
- sp = NULL;
- else {
- sp = getservbyport(port,
- (flags & NI_DGRAM) ? "udp" : "tcp");
- }
- if (sp) {
- if (strlen(sp->s_name) > servlen)
- return ENI_MEMORY;
- strcpy(serv, sp->s_name);
- } else {
- snprintf(numserv, sizeof(numserv), "%d", ntohs(port));
- if (strlen(numserv) > servlen)
- return ENI_MEMORY;
- strcpy(serv, numserv);
- }
- }
-
- switch (sa->sa_family) {
- case AF_INET:
- v4a = (u_int32_t)
- ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
- if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a))
- flags |= NI_NUMERICHOST;
- v4a >>= IN_CLASSA_NSHIFT;
- if (v4a == 0)
- flags |= NI_NUMERICHOST;
- break;
-#ifdef INET6
- case AF_INET6:
- {
- const struct sockaddr_in6 *sin6;
- sin6 = (const struct sockaddr_in6 *)sa;
- switch (sin6->sin6_addr.s6_addr[0]) {
- case 0x00:
- if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr))
- ;
- else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr))
- ;
- else
- flags |= NI_NUMERICHOST;
- break;
- default:
- if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) {
- flags |= NI_NUMERICHOST;
- }
- else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
- flags |= NI_NUMERICHOST;
- break;
- }
- }
- break;
-#endif
- }
- if (host == NULL || hostlen == 0) {
- /*
- * do nothing in this case.
- * in case you are wondering if "&&" is more correct than
- * "||" here: RFC2553 says that host == NULL OR hostlen == 0
- * means that the caller does not want the result.
- */
- } else if (flags & NI_NUMERICHOST) {
- int numaddrlen;
-
- /* NUMERICHOST and NAMEREQD conflicts with each other */
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
-
- switch(afd->a_af) {
-#ifdef INET6
- case AF_INET6:
- {
- int error;
-
- if ((error = ip6_parsenumeric(sa, addr, host,
- hostlen, flags)) != 0)
- return(error);
- break;
- }
-#endif
- default:
- if (inet_ntop(afd->a_af, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_SYSTEM;
- numaddrlen = strlen(numaddr);
- if (numaddrlen + 1 > hostlen) /* don't forget terminator */
- return ENI_MEMORY;
- strcpy(host, numaddr);
- break;
- }
- } else {
-#if 0
- int h_error;
- hp = getipnodebyaddr(addr, afd->a_addrlen, afd->a_af, &h_error);
-#else
- hp = gethostbyaddr(addr, afd->a_addrlen, afd->a_af);
-#endif
-
- if (hp) {
-#if 0
- /*
- * commented out, since "for local host" is not
- * implemented here - see RFC2553 p30
- */
- if (flags & NI_NOFQDN) {
- char *p;
- p = strchr(hp->h_name, '.');
- if (p)
- *p = '\0';
- }
-#endif
- if (strlen(hp->h_name) > hostlen) {
-#if 0
- freehostent(hp);
-#endif
- return ENI_MEMORY;
- }
- strcpy(host, hp->h_name);
-#if 0
- freehostent(hp);
-#endif
- } else {
- if (flags & NI_NAMEREQD)
- return ENI_NOHOSTNAME;
- switch(afd->a_af) {
-#ifdef INET6
- case AF_INET6:
- {
- int error;
-
- if ((error = ip6_parsenumeric(sa, addr, host,
- hostlen,
- flags)) != 0)
- return(error);
- break;
- }
-#endif
- default:
- if (inet_ntop(afd->a_af, addr, host,
- hostlen) == NULL)
- return ENI_SYSTEM;
- break;
- }
- }
- }
- return SUCCESS;
-}
-
-#ifdef INET6
-static int
-ip6_parsenumeric(sa, addr, host, hostlen, flags)
- const struct sockaddr *sa;
- const char *addr;
- char *host;
- size_t hostlen;
- int flags;
-{
- int numaddrlen;
- char numaddr[512];
-
- if (inet_ntop(AF_INET6, addr, numaddr, sizeof(numaddr))
- == NULL)
- return ENI_SYSTEM;
-
- numaddrlen = strlen(numaddr);
- if (numaddrlen + 1 > hostlen) /* don't forget terminator */
- return ENI_MEMORY;
- strcpy(host, numaddr);
-
-#ifdef NI_WITHSCOPEID
- if (
-#ifdef DONT_OPAQUE_SCOPEID
- (IN6_IS_ADDR_LINKLOCAL((struct in6_addr *)addr) ||
- IN6_IS_ADDR_MULTICAST((struct in6_addr *)addr)) &&
-#endif
- ((const struct sockaddr_in6 *)sa)->sin6_scope_id) {
-#ifndef ALWAYS_WITHSCOPE
- if (flags & NI_WITHSCOPEID)
-#endif /* !ALWAYS_WITHSCOPE */
- {
- char scopebuf[MAXHOSTNAMELEN];
- int scopelen;
-
- /* ip6_sa2str never fails */
- scopelen = ip6_sa2str((const struct sockaddr_in6 *)sa,
- scopebuf, sizeof(scopebuf),
- flags);
- if (scopelen + 1 + numaddrlen + 1 > hostlen)
- return ENI_MEMORY;
- /*
- * construct <numeric-addr><delim><scopeid>
- */
- memcpy(host + numaddrlen + 1, scopebuf,
- scopelen);
- host[numaddrlen] = SCOPE_DELIMITER;
- host[numaddrlen + 1 + scopelen] = '\0';
- }
- }
-#endif /* NI_WITHSCOPEID */
-
- return 0;
-}
-
-/* ARGSUSED */
-static int
-ip6_sa2str(sa6, buf, bufsiz, flags)
- const struct sockaddr_in6 *sa6;
- char *buf;
- size_t bufsiz;
- int flags;
-{
- unsigned int ifindex = (unsigned int)sa6->sin6_scope_id;
- const struct in6_addr *a6 = &sa6->sin6_addr;
-
-#ifdef NI_NUMERICSCOPE
- if (flags & NI_NUMERICSCOPE) {
- return(snprintf(buf, bufsiz, "%d", sa6->sin6_scope_id));
- }
-#endif
-
- /* if_indextoname() does not take buffer size. not a good api... */
- if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) &&
- bufsiz >= IF_NAMESIZE) {
- char *p = if_indextoname(ifindex, buf);
- if (p) {
- return(strlen(p));
- }
- }
-
- /* last resort */
- return(snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id));
-}
-#endif /* INET6 */
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
/* back over trailing whitespace */
i--;
- while ((buf[i] == ' ') || (buf[i] == '\t') || (buf[i] == '\n')) i--;
+ if (i > -1) { /* did we actually copy anything? */
+ while ((buf[i] == ' ') || (buf[i] == '\t') || (buf[i] == '\n')) i--;
+ }
buf[++i] = '\0';
tokens = appendString(buf, tokens);
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/types.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <stdio.h>
+#include <stdint.h>
#include <string.h>
#include <sys/socket.h>
{
}
-const char *inet_ntop6(const struct in6_addr *addr,char *buf,size_t len)
+#define MAX_V6_ADDR_LEN 64
+
+static const char *hexchars = "0123456789abcdef";
+
+const char *
+inet_ntop6(const struct in6_addr *addr, char *dst, size_t size)
{
- const u_int16_t *ap=addr->__u6_addr.__u6_addr16;
- int colon=2;
- int i;
- char *bp=buf;
+ char hexa[8][5], tmp[MAX_V6_ADDR_LEN];
+ int zr[8];
+ size_t len;
+ int32_t i, j, k, skip;
+ uint8_t x8, hx8;
+ uint16_t x16;
+ struct in_addr a4;
+
+ if (addr == NULL) return NULL;
+
+ memset(tmp, 0, MAX_V6_ADDR_LEN);
+
+ /* check for mapped or compat addresses */
+ i = IN6_IS_ADDR_V4MAPPED(addr);
+ j = IN6_IS_ADDR_V4COMPAT(addr);
+ if ((i != 0) || (j != 0))
+ {
+ a4.s_addr = addr->__u6_addr.__u6_addr32[3];
+ sprintf(tmp, "::%s%s", (i != 0) ? "ffff:" : "", inet_ntoa(a4));
+ len = strlen(tmp) + 1;
+ if (len > size) return NULL;
+ memcpy(dst, tmp, len);
+ return dst;
+ }
- for(i=0;i<8;i++,ap++)
+ k = 0;
+ for (i = 0; i < 16; i += 2)
{
- if(bp>=buf+len-1)
+ j = 0;
+ skip = 1;
+
+ memset(hexa[k], 0, 5);
+
+ x8 = addr->__u6_addr.__u6_addr8[i];
+
+ hx8 = x8 >> 4;
+ if (hx8 != 0)
{
- buf[len-1]=0;
- return buf;
+ skip = 0;
+ hexa[k][j++] = hexchars[hx8];
}
- if(*ap || colon==-1)
+
+ hx8 = x8 & 0x0f;
+ if ((skip == 0) || ((skip == 1) && (hx8 != 0)))
{
- if(colon==2)
- colon=0;
- if(colon)
- colon=-1;
- sprintf(bp,"%x",*ap);
- bp+=strlen(bp);
- if(i!=7)
- *bp++=':';
+ skip = 0;
+ hexa[k][j++] = hexchars[hx8];
}
- else
+
+ x8 = addr->__u6_addr.__u6_addr8[i + 1];
+
+ hx8 = x8 >> 4;
+ if ((skip == 0) || ((skip == 1) && (hx8 != 0)))
{
- if(colon==2)
- {
- *bp++=':';
- *bp++=':';
- }
- else if(!colon && i!=7)
- *bp++=':';
- colon=1;
+ hexa[k][j++] = hexchars[hx8];
}
+
+ hx8 = x8 & 0x0f;
+ hexa[k][j++] = hexchars[hx8];
+
+ k++;
}
- *bp=0;
- return buf;
+
+ /* find runs of zeros for :: convention */
+ j = 0;
+ for (i = 7; i >= 0; i--)
+ {
+ zr[i] = j;
+ x16 = addr->__u6_addr.__u6_addr16[i];
+ if (x16 == 0) j++;
+ else j = 0;
+ zr[i] = j;
+ }
+
+ /* find longest run of zeros */
+ k = -1;
+ j = 0;
+ for(i = 0; i < 8; i++)
+ {
+ if (zr[i] > j)
+ {
+ k = i;
+ j = zr[i];
+ }
+ }
+
+ for(i = 0; i < 8; i++)
+ {
+ if (i != k) zr[i] = 0;
+ }
+
+ len = 0;
+ for (i = 0; i < 8; i++)
+ {
+ if (zr[i] != 0)
+ {
+ /* check for leading zero */
+ if (i == 0) tmp[len++] = ':';
+ tmp[len++] = ':';
+ i += (zr[i] - 1);
+ continue;
+ }
+ for (j = 0; hexa[i][j] != '\0'; j++) tmp[len++] = hexa[i][j];
+ if (i != 7) tmp[len++] = ':';
+ }
+
+ /* trailing NULL */
+ len++;
+
+ if (len > size) return NULL;
+ memcpy(dst, tmp, len);
+ return dst;
}
-const char *inet_ntop4(const struct in_addr *addr,char *buf,size_t len)
+const char *
+inet_ntop4(const struct in_addr *addr, char *buf, size_t len)
{
- const u_int8_t *ap=(u_int8_t*)&addr->s_addr;
+ const u_int8_t *ap = (u_int8_t *)&addr->s_addr;
int i;
char *bp=buf;
- for(i=0;i<4;i++,ap++)
+ for (i = 0; i < 4; i++, ap++)
{
- if(bp>=buf+len-1)
+ if (bp >= buf + len - 1)
{
- buf[len-1]=0;
+ buf[len-1] = 0;
return buf;
}
- sprintf(bp,"%d",*ap);
- bp+=strlen(bp);
- if(i!=3)
- *bp++='.';
+
+ sprintf(bp, "%d", *ap);
+ bp += strlen(bp);
+ if (i != 3) *bp++='.';
}
- *bp=0;
+
+ *bp = 0;
return buf;
}
-const char *inet_ntop(int af,const void *addr,char *buf,size_t len)
+const char *
+inet_ntop(int af, const void *addr, char *buf, size_t len)
{
if(af==AF_INET6)
- return inet_ntop6(addr,buf,len);
+ return inet_ntop6(addr, buf, len);
if(af==AF_INET)
- return inet_ntop4(addr,buf,len);
+ return inet_ntop4(addr, buf, len);
return NULL;
}
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static char rcsid[] = "$Id: inet_pton.c,v 1.2 2002/01/17 22:22:25 majka Exp $";
+static char rcsid[] = "$Id: inet_pton.c,v 1.3 2003/04/10 18:53:29 majka Exp $";
#endif /* LIBC_SCCS and not lint */
#ifdef HAVE_CONFIG_H
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include <string.h>
+#include <stdlib.h>
#include <errno.h>
#define IN6ADDRSZ 16
* Paul Vixie, 1996.
*/
int
-inet_pton(af, src, dst)
- int af;
- const char *src;
- void *dst;
+inet_pton(int af, const char *src, void *dst)
{
- switch (af) {
- case AF_INET:
- return (inet_pton4(src, dst));
+ int status;
+ char *p, *s;
+
+ switch (af)
+ {
+ case AF_INET: return (inet_pton4(src, dst));
+
#ifdef INET6
- case AF_INET6:
- return (inet_pton6(src, dst));
-#endif
- default:
- errno = EAFNOSUPPORT;
- return (-1);
+ case AF_INET6:
+ /* Ignore trailing %xxx (interface specification) */
+
+ p = NULL;
+ s = (char *)src;
+
+ if (src != NULL) p = strrchr(src, '%');
+ if (p != NULL)
+ {
+ s = strdup(src);
+ s[p - src] = '\0';
+ }
+
+ status = inet_pton6(s, dst);
+ if (p != NULL) free(s);
+ return status;
+#endif
+
+ default:
+ errno = EAFNOSUPPORT;
+ return -1;
}
/* NOTREACHED */
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
+++ /dev/null
-.\" Copyright (c) 1993
-.\" The Regents of the University of California. All rights reserved.
-.\"
-.\" This code is derived from software contributed to Berkeley by
-.\" Donn Seeley at BSDI.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
-.\" 4. Neither the name of the University nor the names of its contributors
-.\" may be used to endorse or promote products derived from this software
-.\" without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
-.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
-.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.\" From: @(#)linkaddr.3 8.1 (Berkeley) 7/28/93
-.\" $FreeBSD: src/lib/libc/net/linkaddr.3,v 1.8.2.3 2001/08/17 15:42:38 ru Exp $
-.\"
-.Dd June 17, 1996
-.Dt LINK_ADDR 3
-.Os
-.Sh NAME
-.Nm link_addr ,
-.Nm link_ntoa
-.Nd elementary address specification routines for link level access
-.Sh LIBRARY
-.Lb libc
-.Sh SYNOPSIS
-.Fd #include <sys/types.h>
-.Fd #include <sys/socket.h>
-.Fd #include <net/if_dl.h>
-.Ft void
-.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl"
-.Ft char *
-.Fn link_ntoa "const struct sockaddr_dl *sdl"
-.Sh DESCRIPTION
-The routine
-.Fn link_addr
-interprets character strings representing
-link-level addresses, returning binary information suitable
-for use in system calls.
-The routine
-.Fn link_ntoa
-takes
-a link-level
-address and returns an
-.Tn ASCII
-string representing some of the information present,
-including the link level address itself, and the interface name
-or number, if present.
-This facility is experimental and is
-still subject to change.
-.Pp
-For
-.Fn link_addr ,
-the string
-.Fa addr
-may contain
-an optional network interface identifier of the form
-.Dq "name unit-number" ,
-suitable for the first argument to
-.Xr ifconfig 8 ,
-followed in all cases by a colon and
-an interface address in the form of
-groups of hexadecimal digits
-separated by periods.
-Each group represents a byte of address;
-address bytes are filled left to right from
-low order bytes through high order bytes.
-.Pp
-.\" A regular expression may make this format clearer:
-.\" .Bd -literal -offset indent
-.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)*
-.\" .Ed
-.\" .Pp
-Thus
-.Li le0:8.0.9.13.d.30
-represents an ethernet address
-to be transmitted on the first Lance ethernet interface.
-.Pp
-The direct use of these functions is deprecated in favor of the
-.Xr addr2ascii 3
-interface; however, portable programs cannot rely on the latter as it is
-not yet widely implemented.
-.Sh RETURN VALUES
-.Fn link_ntoa
-always returns a null terminated string.
-.Fn link_addr
-has no return value.
-(See
-.Sx BUGS . )
-.Sh SEE ALSO
-.Xr addr2ascii 3
-.\" .Xr iso 4
-.Sh HISTORY
-The
-.Fn link_addr
-and
-.Fn link_ntoa
-functions appeared in
-.Bx 4.3 Reno .
-.Sh BUGS
-The returned values for link_ntoa
-reside in a static memory area.
-.Pp
-The function
-.Fn link_addr
-should diagnose improperly formed input, and there should be an unambiguous
-way to recognize this.
-.Pp
-If the
-.Va sdl_len
-field of the link socket address
-.Fa sdl
-is 0,
-.Fn link_ntoa
-will not insert a colon before the interface address bytes.
-If this translated address is given to
-.Fn link_addr
-without inserting an initial colon,
-the latter will not interpret it correctly.
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
#include <stdio.h>
#include <string.h>
#include <netdb.h>
-#include <resolv.h>
+#include <resolv8_compat.h>
#include <ctype.h>
#include <syslog.h>
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
PROJECT_TYPE = Component
HFILES = aliasdb.h bootparams.h lookup_types.h lu_overrides.h\
- lu_host.h lu_utils.h netdb_async.h netgr.h printerdb.h
+ lu_host.h lu_utils.h netdb.h netdb_async.h netgr.h printerdb.h
-CFILES = lu_alias.c lu_bootp.c lu_bootparam.c lu_fstab.c lu_group.c\
- lu_host.c lu_host_async.c lu_netgroup.c lu_network.c lu_printer.c\
- lu_protocol.c lu_rpc.c lu_service.c lu_user.c lu_utils.c
-
-OTHERSRCS = Makefile.preamble Makefile Makefile.postamble lookup.defs\
- _lu_types.x
+CFILES = getaddrinfo.c lu_alias.c lu_bootp.c lu_bootparam.c lu_fstab.c\
+ lu_group.c lu_host.c lu_host_async.c lu_netgroup.c lu_network.c\
+ lu_printer.c lu_protocol.c lu_rpc.c lu_service.c lu_user.c lu_utils.c
+OTHERSRCS = Makefile.preamble Makefile Makefile.postamble getaddrinfo.3\
+ getnameinfo.3 lookup.defs _lu_types.x
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
CODE_GEN_STYLE = DYNAMIC
PROF_LIBS = $(LIBS)
-PUBLIC_HEADERS = aliasdb.h bootparams.h printerdb.h
+PUBLIC_HEADERS = aliasdb.h bootparams.h netdb.h printerdb.h
$(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(ASYNC_HEADER_DIR_SUFFIX):
$(MKDIRS) $@
-netinfo_hdrs: $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX)
- $(SILENT) $(FASTCP) $(NETINFO_HDRS) $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX)
+netinfo_hdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX)
+ $(SILENT) $(FASTCP) $(NETINFO_HDRS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX)
-$(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX):
+$(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(NETINFO_HEADER_DIR_SUFFIX):
$(MKDIRS) $@
+
+install-man-page:
+ mkdir -p "$(DSTROOT)/usr/share/man/man3"
+ install -c -m 644 getaddrinfo.3 "$(DSTROOT)/usr/share/man/man3"
+ install -c -m 644 getnameinfo.3 "$(DSTROOT)/usr/share/man/man3"
+ $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/freeaddrinfo.3"
+ $(LN) -f "$(DSTROOT)/usr/share/man/man3/getaddrinfo.3" "$(DSTROOT)/usr/share/man/man3/gai_strerror.3"
PRIVATE_HEADER_DIR = /usr/local/include
ASYNC_HEADER_DIR_SUFFIX = /
NETINFO_HEADER_DIR_SUFFIX = /netinfo
+AFTER_POSTINSTALL += install-man-page
lu_overrides.h,
lu_host.h,
lu_utils.h,
+ netdb.h,
netdb_async.h,
netgr.h,
printerdb.h
);
OTHER_LINKED = (
+ getaddrinfo.c,
lu_alias.c,
lu_bootp.c,
lu_bootparam.c,
lu_service.c,
lu_user.c
);
- OTHER_SOURCES = (Makefile.preamble, Makefile, Makefile.postamble, lookup.defs, _lu_types.x);
+ OTHER_SOURCES = (
+ Makefile.preamble,
+ Makefile,
+ Makefile.postamble,
+ getaddrinfo.3,
+ getnameinfo.3,
+ lookup.defs,
+ _lu_types.x
+ );
PRECOMPILED_HEADERS = ();
PROJECT_HEADERS = ();
- PUBLIC_HEADERS = (aliasdb.h, bootparams.h, printerdb.h);
+ PUBLIC_HEADERS = (aliasdb.h, bootparams.h, netdb.h, printerdb.h);
};
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
--- /dev/null
+.\" $FreeBSD: src/lib/libc/net/getaddrinfo.3,v 1.2.2.8 2001/08/17 15:42:38 ru Exp $
+.\" $KAME: getaddrinfo.3,v 1.22 2000/08/09 21:16:17 itojun Exp $
+.\"
+.\" Copyright (c) 1983, 1987, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
+.\"
+.Dd May 25, 1995
+.Dt GETADDRINFO 3
+.Os
+.\"
+.Sh NAME
+.Nm getaddrinfo ,
+.Nm freeaddrinfo ,
+.Nm gai_strerror
+.Nd nodename-to-address translation in protocol-independent manner
+.\"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.Fd #include <sys/types.h>
+.Fd #include <sys/socket.h>
+.Fd #include <netdb.h>
+.Ft int
+.Fn getaddrinfo "const char *nodename" "const char *servname" \
+"const struct addrinfo *hints" "struct addrinfo **res"
+.Ft void
+.Fn freeaddrinfo "struct addrinfo *ai"
+.Ft "const char *"
+.Fn gai_strerror "int ecode"
+.\"
+.Sh DESCRIPTION
+The
+.Fn getaddrinfo
+function is defined for protocol-independent nodename-to-address translation.
+It performs the functionality of
+.Xr gethostbyname 3
+and
+.Xr getservbyname 3 ,
+but in a more sophisticated manner.
+.Pp
+The
+.Li addrinfo
+structure is defined as a result of including the
+.Aq Pa netdb.h
+header:
+.Bd -literal -offset
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for nodename */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+.Ed
+.Pp
+The
+.Fa nodename
+and
+.Fa servname
+arguments are pointers to null-terminated strings or
+.Dv NULL .
+One or both of these two arguments must be a
+.Pf non Dv -NULL
+pointer.
+In the normal client scenario, both the
+.Fa nodename
+and
+.Fa servname
+are specified.
+In the normal server scenario, only the
+.Fa servname
+is specified.
+A
+.Pf non Dv -NULL
+.Fa nodename
+string can be either a node name or a numeric host address string
+(i.e., a dotted-decimal IPv4 address or an IPv6 hex address).
+A
+.Pf non Dv -NULL
+.Fa servname
+string can be either a service name or a decimal port number.
+.Pp
+The caller can optionally pass an
+.Li addrinfo
+structure, pointed to by the third argument,
+to provide hints concerning the type of socket that the caller supports.
+In this
+.Fa hints
+structure all members other than
+.Fa ai_flags ,
+.Fa ai_family ,
+.Fa ai_socktype ,
+and
+.Fa ai_protocol
+must be zero or a
+.Dv NULL
+pointer.
+A value of
+.Dv PF_UNSPEC
+for
+.Fa ai_family
+means the caller will accept any protocol family.
+A value of 0 for
+.Fa ai_socktype
+means the caller will accept any socket type.
+A value of 0 for
+.Fa ai_protocol
+means the caller will accept any protocol.
+For example, if the caller handles only TCP and not UDP, then the
+.Fa ai_socktype
+member of the hints structure should be set to
+.Dv SOCK_STREAM
+when
+.Fn getaddrinfo
+is called.
+If the caller handles only IPv4 and not IPv6, then the
+.Fa ai_family
+member of the
+.Fa hints
+structure should be set to
+.Dv PF_INET
+when
+.Fn getaddrinfo
+is called.
+If the third argument to
+.Fn getaddrinfo
+is a
+.Dv NULL
+pointer, this is the same as if the caller had filled in an
+.Li addrinfo
+structure initialized to zero with
+.Fa ai_family
+set to
+.Dv PF_UNSPEC .
+.Pp
+Upon successful return a pointer to a linked list of one or more
+.Li addrinfo
+structures is returned through the final argument.
+The caller can process each
+.Li addrinfo
+structure in this list by following the
+.Fa ai_next
+pointer, until a
+.Dv NULL
+pointer is encountered.
+In each returned
+.Li addrinfo
+structure the three members
+.Fa ai_family ,
+.Fa ai_socktype ,
+and
+.Fa ai_protocol
+are the corresponding arguments for a call to the
+.Fn socket
+function.
+In each
+.Li addrinfo
+structure the
+.Fa ai_addr
+member points to a filled-in socket address structure whose length is
+specified by the
+.Fa ai_addrlen
+member.
+.Pp
+If the
+.Dv AI_PASSIVE
+bit is set in the
+.Fa ai_flags
+member of the
+.Fa hints
+structure, then the caller plans to use the returned socket address
+structure in a call to
+.Fn bind .
+In this case, if the
+.Fa nodename
+argument is a
+.Dv NULL
+pointer, then the IP address portion of the socket
+address structure will be set to
+.Dv INADDR_ANY
+for an IPv4 address or
+.Dv IN6ADDR_ANY_INIT
+for an IPv6 address.
+.Pp
+If the
+.Dv AI_PASSIVE
+bit is not set in the
+.Fa ai_flags
+member of the
+.Fa hints
+structure, then the returned socket address structure will be ready for a
+call to
+.Fn connect
+(for a connection-oriented protocol)
+or either
+.Fn connect ,
+.Fn sendto ,
+or
+.Fn sendmsg
+(for a connectionless protocol).
+In this case, if the
+.Fa nodename
+argument is a
+.Dv NULL
+pointer, then the IP address portion of the
+socket address structure will be set to the loopback address.
+.Pp
+If the
+.Dv AI_CANONNAME
+bit is set in the
+.Fa ai_flags
+member of the
+.Fa hints
+structure, then upon successful return the
+.Fa ai_canonname
+member of the first
+.Li addrinfo
+structure in the linked list will point to a null-terminated string
+containing the canonical name of the specified
+.Fa nodename .
+.Pp
+If the
+.Dv AI_NUMERICHOST
+bit is set in the
+.Fa ai_flags
+member of the
+.Fa hints
+structure, then a
+.Pf non Dv -NULL
+.Fa nodename
+string must be a numeric host address string.
+Otherwise an error of
+.Dv EAI_NONAME
+is returned.
+This flag prevents any type of name resolution service (e.g., the DNS)
+from being called.
+.Pp
+The arguments to
+.Fn getaddrinfo
+must be sufficiently consistent and unambiguous.
+Here are some problem cases you may encounter:
+.Bl -bullet
+.It
+.Fn getaddrinfo
+will fail if the members in the
+.Fa hints
+structure are not consistent.
+For example, for internet address families,
+.Fn getaddrinfo
+will fail if you specify
+.Dv SOCK_STREAM
+to
+.Fa ai_socktype
+while you specify
+.Dv IPPROTO_UDP
+to
+.Fa ai_protocol .
+.It
+If you specify a
+.Fa servname
+which is defined only for certain
+.Fa ai_socktype ,
+.Fn getaddrinfo
+will fail because the arguments are not consistent.
+For example,
+.Fn getaddrinfo
+will return an error if you ask for
+.Dq Li tftp
+service on
+.Dv SOCK_STREAM .
+.It
+For internet address families, if you specify
+.Fa servname
+while you set
+.Fa ai_socktype
+to
+.Dv SOCK_RAW ,
+.Fn getaddrinfo
+will fail, because service names are not defined for the internet
+.Dv SOCK_RAW
+space.
+.It
+If you specify numeric
+.Fa servname ,
+while leaving
+.Fa ai_socktype
+and
+.Fa ai_protocol
+unspecified,
+.Fn getaddrinfo
+will fail.
+This is because the numeric
+.Fa servname
+does not identify any socket type, and
+.Fn getaddrinfo
+is not allowed to glob the argument in such case.
+.El
+.Pp
+All of the information returned by
+.Fn getaddrinfo
+is dynamically allocated:
+the
+.Li addrinfo
+structures, the socket address structures, and canonical node name
+strings pointed to by the addrinfo structures.
+To return this information to the system the function
+.Fn freeaddrinfo
+is called.
+The
+.Fa addrinfo
+structure pointed to by the
+.Fa ai argument
+is freed, along with any dynamic storage pointed to by the structure.
+This operation is repeated until a
+.Dv NULL
+.Fa ai_next
+pointer is encountered.
+.Pp
+To aid applications in printing error messages based on the
+.Dv EAI_xxx
+codes returned by
+.Fn getaddrinfo ,
+.Fn gai_strerror
+is defined.
+The argument is one of the
+.Dv EAI_xxx
+values defined earlier and the return value points to a string describing
+the error.
+If the argument is not one of the
+.Dv EAI_xxx
+values, the function still returns a pointer to a string whose contents
+indicate an unknown error.
+.\"
+.Sh EXTENSIONS
+This implementation supports numeric IPv6 address notation with the
+experimental scope identifier.
+By appending a percent sign and scope identifier to the address, you
+can specify the value of the
+.Li sin6_scope_id
+field of the socket address.
+This makes management of scoped address easier,
+and allows cut-and-paste input of scoped addresses.
+.Pp
+At the moment the code supports only link-local addresses in this format.
+The scope identifier is hardcoded to name of hardware interface associated
+with the link,
+(such as
+.Li ne0 ) .
+For example,
+.Dq Li fe80::1%ne0 ,
+which means
+.Do
+.Li fe80::1
+on the link associated with the
+.Li ne0
+interface
+.Dc .
+.Pp
+This implementation is still very experimental and non-standard.
+The current implementation assumes a one-to-one relationship between
+interfaces and links, which is not necessarily true according to the
+specification.
+.\"
+.Sh EXAMPLES
+The following code tries to connect to
+.Dq Li www.kame.net
+service
+.Dq Li http .
+via stream socket.
+It loops through all the addresses available, regardless of the address family.
+If the destination resolves to an IPv4 address, it will use an
+.Dv AF_INET
+socket.
+Similarly, if it resolves to IPv6, an
+.Dv AF_INET6
+socket is used.
+Observe that there is no hardcoded reference to particular address family.
+The code works even if
+.Fn getaddrinfo
+returns addresses that are not IPv4/v6.
+.Bd -literal -offset indent
+struct addrinfo hints, *res, *res0;
+int error;
+int s;
+const char *cause = NULL;
+
+memset(&hints, 0, sizeof(hints));
+hints.ai_family = PF_UNSPEC;
+hints.ai_socktype = SOCK_STREAM;
+error = getaddrinfo("www.kame.net", "http", &hints, &res0);
+if (error) {
+ errx(1, "%s", gai_strerror(error));
+ /*NOTREACHED*/
+}
+s = -1;
+cause = "no addresses";
+errno = EADDRNOTAVAIL;
+for (res = res0; res; res = res->ai_next) {
+ s = socket(res->ai_family, res->ai_socktype,
+ res->ai_protocol);
+ if (s < 0) {
+ cause = "socket";
+ continue;
+ }
+
+ if (connect(s, res->ai_addr, res->ai_addrlen) < 0) {
+ cause = "connect";
+ close(s);
+ s = -1;
+ continue;
+ }
+
+ break; /* okay we got one */
+}
+if (s < 0) {
+ err(1, cause);
+ /*NOTREACHED*/
+}
+freeaddrinfo(res0);
+.Ed
+.Pp
+The following example tries to open a wildcard listening socket onto service
+.Dq Li http ,
+for all the address families available.
+.Bd -literal -offset indent
+struct addrinfo hints, *res, *res0;
+int error;
+int s[MAXSOCK];
+int nsock;
+const char *cause = NULL;
+
+memset(&hints, 0, sizeof(hints));
+hints.ai_family = PF_UNSPEC;
+hints.ai_socktype = SOCK_STREAM;
+hints.ai_flags = AI_PASSIVE;
+error = getaddrinfo(NULL, "http", &hints, &res0);
+if (error) {
+ errx(1, "%s", gai_strerror(error));
+ /*NOTREACHED*/
+}
+nsock = 0;
+for (res = res0; res && nsock < MAXSOCK; res = res->ai_next) {
+ s[nsock] = socket(res->ai_family, res->ai_socktype,
+ res->ai_protocol);
+ if (s[nsock] < 0) {
+ cause = "socket";
+ continue;
+ }
+
+ if (bind(s[nsock], res->ai_addr, res->ai_addrlen) < 0) {
+ cause = "bind";
+ close(s[nsock]);
+ continue;
+ }
+
+ if (listen(s[nsock], SOMAXCONN) < 0) {
+ cause = "listen";
+ close(s[nsock]);
+ continue;
+ }
+
+ nsock++;
+}
+if (nsock == 0) {
+ err(1, cause);
+ /*NOTREACHED*/
+}
+freeaddrinfo(res0);
+.Ed
+.\"
+.Sh FILES
+.Bl -tag -width /etc/resolv.conf -compact
+.It Pa /etc/hosts
+.It Pa /etc/host.conf
+.It Pa /etc/resolv.conf
+.El
+.\"
+.Sh DIAGNOSTICS
+Error return status from
+.Fn getaddrinfo
+is zero on success and non-zero on errors.
+Non-zero error codes are defined in
+.Aq Pa netdb.h ,
+and as follows:
+.Pp
+.Bl -tag -width EAI_ADDRFAMILY -compact
+.It Dv EAI_ADDRFAMILY
+Address family for
+.Fa nodename
+not supported.
+.It Dv EAI_AGAIN
+Temporary failure in name resolution.
+.It Dv EAI_BADFLAGS
+Invalid value for
+.Fa ai_flags .
+.It Dv EAI_FAIL
+Non-recoverable failure in name resolution.
+.It Dv EAI_FAMILY
+.Fa ai_family
+not supported.
+.It Dv EAI_MEMORY
+Memory allocation failure.
+.It Dv EAI_NODATA
+No address associated with
+.Fa nodename .
+.It Dv EAI_NONAME
+.Fa nodename
+nor
+.Fa servname
+provided, or not known.
+.It Dv EAI_SERVICE
+.Fa servname
+not supported for
+.Fa ai_socktype .
+.It Dv EAI_SOCKTYPE
+.Fa ai_socktype
+not supported.
+.It Dv EAI_SYSTEM
+System error returned in
+.Va errno .
+.El
+.Pp
+If called with an appropriate argument,
+.Fn gai_strerror
+returns a pointer to a string describing the given error code.
+If the argument is not one of the
+.Dv EAI_xxx
+values, the function still returns a pointer to a string whose contents
+indicate an unknown error.
+.\"
+.Sh SEE ALSO
+.Xr gethostbyname 3 ,
+.Xr getnameinfo 3 ,
+.Xr getservbyname 3 ,
+.Xr hosts 5 ,
+.Xr services 5 ,
+.Xr hostname 7 ,
+.Xr named 8
+.Pp
+.Rs
+.%A R. Gilligan
+.%A S. Thomson
+.%A J. Bound
+.%A W. Stevens
+.%T Basic Socket Interface Extensions for IPv6
+.%R RFC2553
+.%D March 1999
+.Re
+.Rs
+.%A Tatsuya Jinmei
+.%A Atsushi Onoe
+.%T "An Extension of Format for IPv6 Scoped Addresses"
+.%R internet draft
+.%N draft-ietf-ipngwg-scopedaddr-format-02.txt
+.%O work in progress material
+.Re
+.Rs
+.%A Craig Metz
+.%T Protocol Independence Using the Sockets API
+.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference"
+.%D June 2000
+.Re
+.\"
+.Sh HISTORY
+The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit.
+.\"
+.Sh STANDARDS
+The
+.Fn getaddrinfo
+function is defined in
+.St -p1003.1g-2000 ,
+and documented in
+.Dq Basic Socket Interface Extensions for IPv6
+(RFC2553).
+.\"
+.Sh BUGS
+The current implementation is not thread-safe.
+.Pp
+The text was shamelessly copied from RFC2553.
--- /dev/null
+/*
+ * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include <netdb.h>
+#include <sys/types.h>
+#include <stdint.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <rpc/types.h>
+#include <rpc/xdr.h>
+#include <mach/mach.h>
+#include <servers/bootstrap.h>
+#include <ifaddrs.h>
+#include "lu_utils.h"
+#include "netdb_async.h"
+
+#define SOCK_UNSPEC 0
+#define IPPROTO_UNSPEC 0
+
+#define LONG_STRING_LENGTH 8192
+#define _LU_MAXLUSTRLEN 256
+#define LU_QBUF_SIZE 8192
+
+#define MAX_LOOKUP_ATTEMPTS 10
+
+#define INET_NTOP_AF_INET_OFFSET 4
+#define INET_NTOP_AF_INET6_OFFSET 8
+
+extern mach_port_t _lookupd_port();
+
+static int gai_proc = -1;
+static int gni_proc = -1;
+
+static int32_t supported_family[] =
+{
+ PF_UNSPEC,
+ PF_INET,
+ PF_INET6
+};
+static int32_t supported_family_count = 3;
+
+static int32_t supported_socket[] =
+{
+ SOCK_RAW,
+ SOCK_UNSPEC,
+ SOCK_DGRAM,
+ SOCK_STREAM
+};
+static int32_t supported_socket_count = 4;
+
+static int32_t supported_protocol[] =
+{
+ IPPROTO_UNSPEC,
+ IPPROTO_ICMPV6,
+ IPPROTO_UDP,
+ IPPROTO_TCP
+};
+static int32_t supported_protocol_count = 4;
+
+static int32_t supported_socket_protocol_pair[] =
+{
+ SOCK_RAW, IPPROTO_UNSPEC,
+ SOCK_RAW, IPPROTO_UDP,
+ SOCK_RAW, IPPROTO_TCP,
+ SOCK_RAW, IPPROTO_ICMPV6,
+ SOCK_UNSPEC, IPPROTO_UNSPEC,
+ SOCK_UNSPEC, IPPROTO_UDP,
+ SOCK_UNSPEC, IPPROTO_TCP,
+ SOCK_UNSPEC, IPPROTO_ICMPV6,
+ SOCK_DGRAM, IPPROTO_UNSPEC,
+ SOCK_DGRAM, IPPROTO_UDP,
+ SOCK_STREAM, IPPROTO_UNSPEC,
+ SOCK_STREAM, IPPROTO_TCP
+};
+static int32_t supported_socket_protocol_pair_count = 12;
+
+static int
+gai_family_type_check(int32_t f)
+{
+ int32_t i;
+
+ for (i = 0; i < supported_family_count; i++)
+ {
+ if (f == supported_family[i]) return 0;
+ }
+
+ return 1;
+}
+
+static int
+gai_socket_type_check(int32_t s)
+{
+ int32_t i;
+
+ for (i = 0; i < supported_socket_count; i++)
+ {
+ if (s == supported_socket[i]) return 0;
+ }
+
+ return 1;
+}
+
+static int
+gai_protocol_type_check(int32_t p)
+{
+ int32_t i;
+
+ for (i = 0; i < supported_protocol_count; i++)
+ {
+ if (p == supported_protocol[i]) return 0;
+ }
+
+ return 1;
+}
+
+static int
+gai_socket_protocol_type_check(int32_t s, int32_t p)
+{
+ int32_t i, j, ss, sp;
+
+ for (i = 0, j = 0; i < supported_socket_protocol_pair_count; i++, j+=2)
+ {
+ ss = supported_socket_protocol_pair[j];
+ sp = supported_socket_protocol_pair[j+1];
+ if ((s == ss) && (p == sp)) return 0;
+ }
+
+ return 1;
+}
+
+const char *
+gai_strerror(int32_t err)
+{
+ switch (err)
+ {
+ case EAI_ADDRFAMILY: return "Address family for nodename not supported";
+ case EAI_AGAIN: return "Temporary failure in name resolution";
+ case EAI_BADFLAGS: return "Invalid value for ai_flags";
+ case EAI_FAIL: return "Non-recoverable failure in name resolution";
+ case EAI_FAMILY: return "ai_family not supported";
+ case EAI_MEMORY: return "Memory allocation failure";
+ case EAI_NODATA: return "No address associated with nodename";
+ case EAI_NONAME: return "nodename nor servname provided, or not known";
+ case EAI_SERVICE: return "servname not supported for ai_socktype";
+ case EAI_SOCKTYPE: return "ai_socktype not supported";
+ case EAI_SYSTEM: return "System error";
+ case EAI_BADHINTS: return "Bad hints";
+ case EAI_PROTOCOL: return "ai_protocol not supported";
+ }
+
+ return "Unknown error";
+}
+
+static void
+append_addrinfo(struct addrinfo **l, struct addrinfo *a)
+{
+ struct addrinfo *x;
+
+ if (l == NULL) return;
+ if (a == NULL) return;
+
+ if (*l == NULL)
+ {
+ *l = a;
+ return;
+ }
+
+ x = *l;
+
+ if (a->ai_family == PF_INET6)
+ {
+ if (x->ai_family == PF_INET)
+ {
+ *l = a;
+ a->ai_next = x;
+ return;
+ }
+
+ while ((x->ai_next != NULL) && (x->ai_next->ai_family != PF_INET)) x = x->ai_next;
+ a->ai_next = x->ai_next;
+ x->ai_next = a;
+ }
+ else
+ {
+ while (x->ai_next != NULL) x = x->ai_next;
+ a->ai_next = NULL;
+ x->ai_next = a;
+ }
+}
+
+static int
+encode_kv(XDR *x, const char *k, const char *v)
+{
+ int32_t n = 1;
+
+ if (!xdr_string(x, (char **)&k, _LU_MAXLUSTRLEN)) return 1;
+ if (!xdr_int(x, &n)) return 1;
+ if (!xdr_string(x, (char **)&v, _LU_MAXLUSTRLEN)) return 1;
+
+ return 0;
+}
+
+void
+freeaddrinfo(struct addrinfo *a)
+{
+ struct addrinfo *next;
+
+ while (a != NULL)
+ {
+ next = a->ai_next;
+ if (a->ai_addr != NULL) free(a->ai_addr);
+ if (a->ai_canonname != NULL) free(a->ai_canonname);
+ free(a);
+ a = next;
+ }
+}
+
+static struct addrinfo *
+new_addrinfo_v4(int32_t flags, int32_t sock, int32_t proto, uint16_t port, struct in_addr addr, uint32_t iface, char *cname)
+{
+ struct addrinfo *a;
+ struct sockaddr_in *sa;
+ int32_t len;
+
+ a = (struct addrinfo *)calloc(1, sizeof(struct addrinfo));
+ if (a == NULL) return NULL;
+
+ a->ai_next = NULL;
+
+ a->ai_flags = flags;
+ a->ai_family = PF_INET;
+ a->ai_socktype = sock;
+ a->ai_protocol = proto;
+
+ a->ai_addrlen = sizeof(struct sockaddr_in);
+
+ sa = (struct sockaddr_in *)calloc(1, a->ai_addrlen);
+ if (sa == NULL)
+ {
+ free(a);
+ return NULL;
+ }
+
+ sa->sin_len = a->ai_addrlen;
+ sa->sin_family = PF_INET;
+ sa->sin_port = htons(port);
+ sa->sin_addr = addr;
+
+ /* Kludge: Jam the interface number into sin_zero. */
+ memmove(sa->sin_zero, &iface, sizeof(uint32_t));
+
+ a->ai_addr = (struct sockaddr *)sa;
+
+ if (cname != NULL)
+ {
+ len = strlen(cname) + 1;
+ a->ai_canonname = malloc(len);
+ memmove(a->ai_canonname, cname, len);
+ }
+
+ return a;
+}
+
+static struct addrinfo *
+new_addrinfo_v6(int32_t flags, int32_t sock, int32_t proto, uint16_t port, struct in6_addr addr, uint32_t scopeid, char *cname)
+{
+ struct addrinfo *a;
+ struct sockaddr_in6 *sa;
+ int32_t len;
+
+ a = (struct addrinfo *)calloc(1, sizeof(struct addrinfo));
+ if (a == NULL) return NULL;
+
+ a->ai_next = NULL;
+
+ a->ai_flags = flags;
+ a->ai_family = PF_INET6;
+ a->ai_socktype = sock;
+ a->ai_protocol = proto;
+
+ a->ai_addrlen = sizeof(struct sockaddr_in6);
+
+ sa = (struct sockaddr_in6 *)calloc(1, a->ai_addrlen);
+ if (sa == NULL)
+ {
+ free(a);
+ return NULL;
+ }
+
+ sa->sin6_len = a->ai_addrlen;
+ sa->sin6_family = PF_INET6;
+ sa->sin6_port = htons(port);
+ sa->sin6_addr = addr;
+ sa->sin6_scope_id = scopeid;
+ a->ai_addr = (struct sockaddr *)sa;
+
+ if (cname != NULL)
+ {
+ len = strlen(cname) + 1;
+ a->ai_canonname = malloc(len);
+ memmove(a->ai_canonname, cname, len);
+ }
+
+ return a;
+}
+
+/*
+ * getaddrinfo support in lookupd
+ * Input dict may contain the following
+ *
+ * name: nodename
+ * service: servname
+ * protocol: [IPPROTO_UNSPEC] | IPPROTO_UDP | IPPROTO_TCP
+ * socktype: [SOCK_UNSPEC] | SOCK_DGRAM | SOCK_STREAM
+ * family: [PF_UNSPEC] | PF_INET | PF_INET6
+ * canonname: [0] | 1
+ * passive: [0] | 1
+ * numerichost: [0] | 1
+ *
+ * Output dictionary may contain the following
+ * All values are encoded as strings.
+ *
+ * flags: unsigned long
+ * family: unsigned long
+ * socktype: unsigned long
+ * protocol: unsigned long
+ * port: unsigned long
+ * address: char *
+ * scopeid: unsigned long
+ * canonname: char *
+ *
+ */
+
+static struct addrinfo *
+gai_lookupd_process_dictionary(XDR *inxdr)
+{
+ int32_t i, nkeys, nvals;
+ char *key, *val;
+ uint32_t flags, family, socktype, protocol, longport, scopeid;
+ uint16_t port;
+ char *addr, *canonname;
+ struct addrinfo *a;
+ struct in_addr a4;
+ struct in6_addr a6;
+
+ flags = 0;
+ family = PF_UNSPEC;
+ socktype = SOCK_UNSPEC;
+ protocol = IPPROTO_UNSPEC;
+ port = 0;
+ scopeid = 0;
+ addr = NULL;
+ canonname = NULL;
+
+ if (!xdr_int(inxdr, &nkeys)) return NULL;
+
+ for (i = 0; i < nkeys; i++)
+ {
+ key = NULL;
+ val = NULL;
+
+ if (!xdr_string(inxdr, &key, LONG_STRING_LENGTH)) return NULL;
+ if (!xdr_int(inxdr, &nvals))
+ {
+ free(key);
+ return NULL;
+ }
+
+ if (nvals != 1)
+ {
+ free(key);
+ return NULL;
+ }
+
+ if (!xdr_string(inxdr, &val, LONG_STRING_LENGTH))
+ {
+ free(key);
+ return NULL;
+ }
+
+ if (!strcmp(key, "flags"))
+ {
+ flags = atoi(val);
+ }
+ else if (!strcmp(key, "family"))
+ {
+ family = atoi(val);
+ }
+ else if (!strcmp(key, "socktype"))
+ {
+ socktype = atoi(val);
+ }
+ else if (!strcmp(key, "protocol"))
+ {
+ protocol = atoi(val);
+ }
+ else if (!strcmp(key, "port"))
+ {
+ longport = atoi(val);
+ port = longport;
+ }
+ else if (!strcmp(key, "scopeid"))
+ {
+ scopeid = atoi(val);
+ }
+ else if (!strcmp(key, "address")) addr = strdup(val);
+ else if (!strcmp(key, "canonname")) canonname = strdup(val);
+ free(key);
+ free(val);
+ }
+
+ if (family == PF_UNSPEC)
+ {
+ if (addr != NULL) free(addr);
+ if (canonname != NULL) free(canonname);
+ return NULL;
+ }
+
+ a = NULL;
+ if (family == PF_INET)
+ {
+ inet_aton(addr, &a4);
+ a = new_addrinfo_v4(flags, socktype, protocol, port, a4, scopeid, canonname);
+ }
+ else if (family == PF_INET6)
+ {
+ inet_pton(AF_INET6, addr, &a6);
+ a = new_addrinfo_v6(flags, socktype, protocol, port, a6, scopeid, canonname);
+ }
+
+ if (addr != NULL) free(addr);
+ if (canonname != NULL) free(canonname);
+
+ return a;
+}
+
+static int
+gai_make_query(const char *nodename, const char *servname, const struct addrinfo *hints, char *buf, uint32_t *len)
+{
+ int32_t numerichost, family, proto, socktype, canonname, passive;
+ uint32_t na;
+ XDR outxdr;
+ char str[64], *cname;
+
+ numerichost = 0;
+ family = PF_UNSPEC;
+ proto = IPPROTO_UNSPEC;
+ socktype = SOCK_UNSPEC;
+ canonname = 0;
+ passive = 0;
+ cname = NULL;
+
+ if (hints != NULL)
+ {
+ family = hints->ai_family;
+ if (hints->ai_flags & AI_NUMERICHOST) numerichost = 1;
+ if (hints->ai_flags & AI_CANONNAME) canonname = 1;
+ if ((hints->ai_flags & AI_PASSIVE) == 1) passive = 1;
+
+ proto = hints->ai_protocol;
+ if (hints->ai_socktype == SOCK_DGRAM)
+ {
+ socktype = SOCK_DGRAM;
+ proto = IPPROTO_UDP;
+ }
+ if (hints->ai_socktype == SOCK_STREAM)
+ {
+ socktype = SOCK_STREAM;
+ proto = IPPROTO_TCP;
+ }
+ }
+
+ xdrmem_create(&outxdr, buf, *len, XDR_ENCODE);
+
+ /* Attribute count */
+ na = 0;
+ if (nodename != NULL) na++;
+ if (servname != NULL) na++;
+ if (proto != IPPROTO_UNSPEC) na++;
+ if (socktype != SOCK_UNSPEC) na++;
+ if (family != PF_UNSPEC) na++;
+ if (canonname != 0) na++;
+ if (passive != 0) na++;
+ if (numerichost != 0) na++;
+
+ if (!xdr_int(&outxdr, &na))
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+
+ if (nodename != NULL)
+ {
+ if (encode_kv(&outxdr, "name", nodename) != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (servname != NULL)
+ {
+ if (encode_kv(&outxdr, "service", servname) != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (proto != IPPROTO_UNSPEC)
+ {
+ snprintf(str, 64, "%u", proto);
+ if (encode_kv(&outxdr, "protocol", str) != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (socktype != SOCK_UNSPEC)
+ {
+ snprintf(str, 64, "%u", socktype);
+ if (encode_kv(&outxdr, "socktype", str) != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (family != PF_UNSPEC)
+ {
+ snprintf(str, 64, "%u", family);
+ if (encode_kv(&outxdr, "family", str) != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (canonname != 0)
+ {
+ if (encode_kv(&outxdr, "canonname", "1") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (passive != 0)
+ {
+ if (encode_kv(&outxdr, "passive", "1") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (numerichost != 0)
+ {
+ if (encode_kv(&outxdr, "numerichost", "1") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ *len = xdr_getpos(&outxdr);
+
+ xdr_destroy(&outxdr);
+
+ return 0;
+}
+
+static int32_t
+is_a_number(const char *s)
+{
+ int32_t i, len;
+
+ if (s == NULL) return 0;
+
+ len = strlen(s);
+ for (i = 0; i < len; i++)
+ {
+ if (isdigit(s[i]) == 0) return 0;
+ }
+
+ return 1;
+}
+
+int
+gai_files(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
+{
+ int32_t i, numericserv, numerichost, family, proto, wantv4, wantv6;
+ int16_t port;
+ struct servent *s;
+ struct hostent *h;
+ char *protoname, *loopv4, *loopv6;
+ struct in_addr a4;
+ struct in6_addr a6;
+ struct addrinfo *a;
+
+ numericserv = 0;
+ if (servname != NULL) numericserv = is_a_number(servname);
+
+ family = PF_UNSPEC;
+ if (hints != NULL) family = hints->ai_family;
+
+ numerichost = 0;
+
+ if (nodename == NULL)
+ {
+ numerichost = 1;
+
+ loopv4 = "127.0.0.1";
+ loopv6 = "0:0:0:0:0:0:0:1";
+
+ if ((hints != NULL) && ((hints->ai_flags & AI_PASSIVE) == 1))
+ {
+ loopv4 = "0.0.0.0";
+ loopv6 = "0:0:0:0:0:0:0:0";
+ }
+
+ if ((family == PF_UNSPEC) || (family == PF_INET))
+ {
+ inet_pton(AF_INET, loopv4, &a4);
+ }
+
+ if ((family == PF_UNSPEC) || (family == PF_INET6))
+ {
+ inet_pton(AF_INET6, loopv6, &a6);
+ }
+ }
+ else
+ {
+ if ((family == PF_UNSPEC) || (family == PF_INET))
+ {
+ numerichost = inet_pton(AF_INET, nodename, &a4);
+ if ((numerichost == 1) && (family == PF_UNSPEC)) family = PF_INET;
+ }
+
+ if ((family == PF_UNSPEC) || (family == PF_INET6))
+ {
+ numerichost = inet_pton(AF_INET6, nodename, &a6);
+ if ((numerichost == 1) && (family == PF_UNSPEC)) family = PF_INET6;
+ }
+ }
+
+ wantv4 = 1;
+ wantv6 = 1;
+ if (family == PF_INET6) wantv4 = 0;
+ if (family == PF_INET) wantv6 = 0;
+
+ proto = IPPROTO_UNSPEC;
+ protoname = NULL;
+
+ if (hints != NULL)
+ {
+ proto = hints->ai_protocol;
+ if (proto == IPPROTO_UNSPEC)
+ {
+ if (hints->ai_socktype == SOCK_DGRAM) proto = IPPROTO_UDP;
+ else if (hints->ai_socktype == SOCK_STREAM) proto = IPPROTO_TCP;
+ }
+ }
+
+ if (proto == IPPROTO_UDP) protoname = "udp";
+ else if (proto == IPPROTO_TCP) protoname = "tcp";
+
+ s = NULL;
+ port = 0;
+
+ if (numericserv != 0)
+ {
+ port = htons(atoi(servname));
+ }
+ else if (servname != NULL)
+ {
+ s = getservbyname(servname, protoname);
+ if (s != NULL) port = s->s_port;
+ }
+
+ /* new_addrinfo_v4 and new_addrinfo_v6 expect port in host byte order */
+ port = ntohs(port);
+
+ if (numerichost != 0)
+ {
+ if (wantv4 == 1)
+ {
+ if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP))
+ {
+ a = new_addrinfo_v4(0, SOCK_DGRAM, IPPROTO_UDP, port, a4, 0, NULL);
+ append_addrinfo(res, a);
+ }
+
+ if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP))
+ {
+ a = new_addrinfo_v4(0, SOCK_STREAM, IPPROTO_TCP, port, a4, 0, NULL);
+ append_addrinfo(res, a);
+ }
+ }
+
+ if (wantv6 == 1)
+ {
+ if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP))
+ {
+ a = new_addrinfo_v6(0, SOCK_DGRAM, IPPROTO_UDP, port, a6, 0, NULL);
+ append_addrinfo(res, a);
+ }
+
+ if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP))
+ {
+ a = new_addrinfo_v6(0, SOCK_STREAM, IPPROTO_TCP, port, a6, 0, NULL);
+ append_addrinfo(res, a);
+ }
+ }
+
+ return 0;
+ }
+
+ if (wantv4 == 1)
+ {
+ h = gethostbyname(nodename);
+ if (h == NULL) return 0;
+
+ for (i = 0; h->h_addr_list[i] != 0; i++)
+ {
+ memmove((void *)&a4.s_addr, h->h_addr_list[i], h->h_length);
+
+ if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_UDP))
+ {
+ a = new_addrinfo_v4(0, SOCK_DGRAM, IPPROTO_UDP, port, a4, 0, NULL);
+ append_addrinfo(res, a);
+ }
+
+ if ((proto == IPPROTO_UNSPEC) || (proto == IPPROTO_TCP))
+ {
+ a = new_addrinfo_v4(0, SOCK_STREAM, IPPROTO_TCP, port, a4, 0, NULL);
+ append_addrinfo(res, a);
+ }
+ }
+ }
+
+ return 0;
+}
+
+static int
+gai_lookupd(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
+{
+ uint32_t n, i, qlen, rlen;
+ XDR inxdr;
+ char qbuf[LU_QBUF_SIZE];
+ char *rbuf;
+ char *cname;
+ mach_port_t server_port;
+ kern_return_t status;
+ struct addrinfo *a;
+
+ server_port = MACH_PORT_NULL;
+ if (_lu_running()) server_port = _lookupd_port(0);
+ if (server_port == MACH_PORT_NULL)
+ {
+ /* lookupd isn't available - fall back to the flat files */
+ return gai_files(nodename, servname, hints, res);
+ }
+
+ if (gai_proc < 0)
+ {
+ status = _lookup_link(server_port, "getaddrinfo", &gai_proc);
+ if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ }
+
+ qlen = LU_QBUF_SIZE;
+ i = gai_make_query(nodename, servname, hints, qbuf, &qlen);
+ if (i != 0) return EAI_SYSTEM;
+
+ qlen /= BYTES_PER_XDR_UNIT;
+
+ rbuf = NULL;
+
+ status = _lookup_all(server_port, gai_proc, (unit *)qbuf, qlen, &rbuf, &rlen);
+ if (status != KERN_SUCCESS) return EAI_NODATA;
+
+ rlen *= BYTES_PER_XDR_UNIT;
+
+ xdrmem_create(&inxdr, rbuf, rlen, XDR_DECODE);
+
+ if (!xdr_int(&inxdr, &n))
+ {
+ xdr_destroy(&inxdr);
+ return EAI_SYSTEM;
+ }
+
+ cname = NULL;
+ for (i = 0; i < n; i++)
+ {
+ a = gai_lookupd_process_dictionary(&inxdr);
+ if ((cname == NULL) && (a->ai_canonname != NULL)) cname = a->ai_canonname;
+ append_addrinfo(res, a);
+ }
+
+ xdr_destroy(&inxdr);
+ if (rbuf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)rbuf, rlen);
+
+ if ((cname != NULL) && (res != NULL) && (res[0] != NULL) && (res[0]->ai_canonname == NULL))
+ {
+ res[0]->ai_canonname = strdup(cname);
+ }
+
+ return 0;
+}
+
+static int
+gai_checkhints(const struct addrinfo *hints)
+{
+ if (hints == NULL) return 0;
+ if (hints->ai_addrlen != 0) return EAI_BADHINTS;
+ if (hints->ai_canonname != NULL) return EAI_BADHINTS;
+ if (hints->ai_addr != NULL) return EAI_BADHINTS;
+ if (hints->ai_next != NULL) return EAI_BADHINTS;
+
+ /* Check for supported protocol family */
+ if (gai_family_type_check(hints->ai_family) != 0) return EAI_FAMILY;
+
+ /* Check for supported socket */
+ if (gai_socket_type_check(hints->ai_socktype) != 0) return EAI_BADHINTS;
+
+ /* Check for supported protocol */
+ if (gai_protocol_type_check(hints->ai_protocol) != 0) return EAI_BADHINTS;
+
+ /* Check that socket type is compatible with protocol */
+ if (gai_socket_protocol_type_check(hints->ai_socktype, hints->ai_protocol) != 0) return EAI_BADHINTS;
+
+ return 0;
+}
+
+int
+getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
+{
+ int32_t status, nodenull, servnull;
+
+ if (res == NULL) return 0;
+ *res = NULL;
+
+ /* Check input */
+ nodenull = 0;
+ if ((nodename == NULL) || (nodename[0] == '\0')) nodenull = 1;
+
+ servnull = 0;
+ if ((servname == NULL) || (servname[0] == '\0')) servnull = 1;
+
+ if ((nodenull == 1) && (servnull == 1)) return EAI_NONAME;
+ status = gai_checkhints(hints);
+ if (status != 0) return status;
+
+ if (nodenull == 1) status = gai_lookupd(NULL, servname, hints, res);
+ else if (servnull == 1) status = gai_lookupd(nodename, NULL, hints, res);
+ else status = gai_lookupd(nodename, servname, hints, res);
+
+ if ((status == 0) && (*res == NULL)) status = EAI_NODATA;
+
+ return status;
+}
+
+int32_t
+getaddrinfo_async_start(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints, getaddrinfo_async_callback callback, void *context)
+{
+ int32_t status;
+ uint32_t i, qlen;
+ char qbuf[LU_QBUF_SIZE];
+ mach_port_t server_port;
+
+ *p = MACH_PORT_NULL;
+
+ if ((nodename == NULL) && (servname == NULL)) return EAI_NONAME;
+
+ status = gai_checkhints(hints);
+ if (status != 0) return EAI_BADHINTS;
+
+ server_port = MACH_PORT_NULL;
+ if (_lu_running()) server_port = _lookupd_port(0);
+ if (server_port == MACH_PORT_NULL) return EAI_SYSTEM;
+
+ if (gai_proc < 0)
+ {
+ status = _lookup_link(server_port, "getaddrinfo", &gai_proc);
+ if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ }
+
+ qlen = LU_QBUF_SIZE;
+ i = gai_make_query(nodename, servname, hints, qbuf, &qlen);
+ if (i != 0) return EAI_SYSTEM;
+
+ qlen /= BYTES_PER_XDR_UNIT;
+
+ return lu_async_start(p, gai_proc, qbuf, qlen, (void *)callback, context);
+}
+
+int32_t
+getaddrinfo_async_send(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints)
+{
+ return getaddrinfo_async_start(p, nodename, servname, hints, NULL, NULL);
+}
+
+static int
+gai_extract_data(char *buf, uint32_t len, struct addrinfo **res)
+{
+ XDR xdr;
+ uint32_t i, n;
+ char *cname;
+ struct addrinfo *a;
+
+ *res = NULL;
+
+ if (buf == NULL) return EAI_NODATA;
+ if (len == 0) return EAI_NODATA;
+
+ xdrmem_create(&xdr, buf, len, XDR_DECODE);
+
+ if (!xdr_int(&xdr, &n))
+ {
+ xdr_destroy(&xdr);
+ return EAI_SYSTEM;
+ }
+
+ cname = NULL;
+ for (i = 0; i < n; i++)
+ {
+ a = gai_lookupd_process_dictionary(&xdr);
+ if (a == NULL) break;
+
+ if ((cname == NULL) && (a->ai_canonname != NULL)) cname = a->ai_canonname;
+ append_addrinfo(res, a);
+ }
+
+ xdr_destroy(&xdr);
+
+ if ((cname != NULL) && (res != NULL) && (res[0] != NULL) && (res[0]->ai_canonname == NULL))
+ {
+ res[0]->ai_canonname = strdup(cname);
+ }
+
+ if (*res == NULL) return EAI_NODATA;
+ return 0;
+}
+
+int32_t
+getaddrinfo_async_receive(mach_port_t p, struct addrinfo **res)
+{
+ kern_return_t status;
+ char *buf;
+ uint32_t len;
+
+ if (res == NULL) return 0;
+ *res = NULL;
+
+ buf = NULL;
+ len = 0;
+
+ status = lu_async_receive(p, &buf, &len);
+ if (status < 0) return EAI_FAIL;
+
+ status = gai_extract_data(buf, len, res);
+ if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len);
+ if (status != 0) return status;
+
+ if (*res == NULL) return EAI_NODATA;
+
+ return 0;
+}
+
+int32_t
+getaddrinfo_async_handle_reply(void *msg)
+{
+ getaddrinfo_async_callback callback;
+ void *context;
+ char *buf;
+ uint32_t len;
+ int status;
+ struct addrinfo *res;
+
+ callback = (getaddrinfo_async_callback)NULL;
+ context = NULL;
+ buf = NULL;
+ len = 0;
+ res = NULL;
+
+ status = lu_async_handle_reply(msg, &buf, &len, (void **)&callback, &context);
+ if (status != KERN_SUCCESS)
+ {
+ if (status == MIG_REPLY_MISMATCH) return 0;
+ if (callback != NULL) callback(EAI_SYSTEM, NULL, context);
+ return EAI_SYSTEM;
+ }
+
+ status = gai_extract_data(buf, len, &res);
+ if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len);
+ if (status != 0)
+ {
+ if (callback != NULL) callback(status, NULL, context);
+ return status;
+ }
+
+ if (res == NULL)
+ {
+ callback(EAI_NODATA, NULL, context);
+ return EAI_NODATA;
+ }
+
+ callback(0, res, context);
+ return 0;
+}
+
+/*
+ * getnameinfo
+ */
+
+/*
+ * getnameinfo support in lookupd
+ * Input dict may contain the following
+ *
+ * ip_address: node address
+ * ipv6_address: node address
+ * port: service number
+ * protocol: [tcp] | udp
+ * fqdn: [1] | 0
+ * numerichost: [0] | 1
+ * name_required: [0] | 1
+ * numericserv: [0] | 1
+ *
+ * Output dictionary may contain the following
+ * All values are encoded as strings.
+ *
+ * name: char *
+ * service: char *
+ */
+
+static int
+gni_lookupd_process_dictionary(XDR *inxdr, char **host, char **serv)
+{
+ int32_t i, nkeys, nvals;
+ char *key, *val;
+
+ if ((host == NULL) || (serv == NULL)) return EAI_SYSTEM;
+ if (!xdr_int(inxdr, &nkeys)) return EAI_SYSTEM;
+
+ for (i = 0; i < nkeys; i++)
+ {
+ key = NULL;
+ val = NULL;
+
+ if (!xdr_string(inxdr, &key, LONG_STRING_LENGTH)) return EAI_SYSTEM;
+ if (!xdr_int(inxdr, &nvals))
+ {
+ free(key);
+ return EAI_SYSTEM;
+ }
+
+ if (nvals != 1)
+ {
+ free(key);
+ return EAI_SYSTEM;
+ }
+
+ if (!xdr_string(inxdr, &val, LONG_STRING_LENGTH))
+ {
+ free(key);
+ return EAI_SYSTEM;
+ }
+
+ if (!strcmp(key, "name"))
+ {
+ *host = val;
+ val = NULL;
+ }
+
+ else if (!strcmp(key, "service"))
+ {
+ *serv = val;
+ val = NULL;
+ }
+
+ if (key != NULL) free(key);
+ if (val != NULL) free(val);
+ }
+
+ return 0;
+}
+
+static int
+gni_make_query(const struct sockaddr *sa, size_t salen, int wanthost, int wantserv, int flags, char *buf, uint32_t *len)
+{
+ XDR outxdr;
+ uint16_t port;
+ char str[_LU_MAXLUSTRLEN], *key, ifname[IF_NAMESIZE];
+ uint32_t a4, ifnum, offset, na, proto, fqdn, numerichost, numericserv, name_req;
+ struct sockaddr_in6 *s6;
+
+ if (sa == NULL) return EAI_FAIL;
+ if (sa->sa_len != salen) return EAI_FAMILY;
+
+ proto = IPPROTO_TCP;
+ fqdn = 1;
+ numerichost = 0;
+ numericserv = 0;
+ name_req = 0;
+
+ offset = INET_NTOP_AF_INET_OFFSET;
+ key = "ip_address";
+ port = 0;
+
+ if (sa->sa_family == PF_INET)
+ {
+ a4 = ntohl(((const struct sockaddr_in *)sa)->sin_addr.s_addr);
+ if (IN_MULTICAST(a4) || IN_EXPERIMENTAL(a4)) flags |= NI_NUMERICHOST;
+ a4 >>= IN_CLASSA_NSHIFT;
+ if (a4 == 0) flags |= NI_NUMERICHOST;
+
+ port = ((struct sockaddr_in *)sa)->sin_port;
+ }
+ else if (sa->sa_family == PF_INET6)
+ {
+ s6 = (struct sockaddr_in6 *)sa;
+ switch (s6->sin6_addr.s6_addr[0])
+ {
+ case 0x00:
+ if (IN6_IS_ADDR_V4MAPPED(&s6->sin6_addr))
+ {
+ }
+ else if (IN6_IS_ADDR_LOOPBACK(&s6->sin6_addr))
+ {
+ }
+ else
+ {
+ flags |= NI_NUMERICHOST;
+ }
+ break;
+ default:
+ if (IN6_IS_ADDR_LINKLOCAL(&s6->sin6_addr))
+ {
+ flags |= NI_NUMERICHOST;
+ }
+ else if (IN6_IS_ADDR_MULTICAST(&s6->sin6_addr))
+ {
+ flags |= NI_NUMERICHOST;
+ }
+ break;
+ }
+
+ offset = INET_NTOP_AF_INET6_OFFSET;
+ key = "ipv6_address";
+ port = s6->sin6_port;
+ }
+ else
+ {
+ return EAI_FAMILY;
+ }
+
+ na = 0;
+
+ if (wanthost != 0) na++;
+ if (wantserv != 0) na++;
+
+ if (flags & NI_NOFQDN)
+ {
+ fqdn = 0;
+ na++;
+ }
+
+ if (flags & NI_NUMERICHOST)
+ {
+ numerichost = 1;
+ na++;
+ }
+
+ if (flags & NI_NUMERICSERV)
+ {
+ numericserv = 1;
+ na++;
+ }
+
+ if (flags & NI_NAMEREQD)
+ {
+ name_req = 1;
+ na++;
+ }
+
+ if (flags & NI_DGRAM)
+ {
+ proto = IPPROTO_UDP;
+ na++;
+ }
+
+ xdrmem_create(&outxdr, buf, *len, XDR_ENCODE);
+
+ if (!xdr_int(&outxdr, &na))
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+
+ if (wanthost != 0)
+ {
+ inet_ntop(sa->sa_family, (char *)(sa) + offset, str, _LU_MAXLUSTRLEN);
+
+ if ((flags & NI_WITHSCOPEID) && (sa->sa_family == AF_INET6))
+ {
+ ifnum = ((struct sockaddr_in6 *)sa)->sin6_scope_id;
+ if (if_indextoname(ifnum, ifname) != NULL)
+ {
+ strcat(str, "%");
+ strcat(str, ifname);
+ }
+ }
+
+ if (encode_kv(&outxdr, key, str) != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (wantserv != 0)
+ {
+ snprintf(str, _LU_MAXLUSTRLEN, "%hu", port);
+ if (encode_kv(&outxdr, "port", str) != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (proto == IPPROTO_UDP)
+ {
+ if (encode_kv(&outxdr, "protocol", "udp") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (fqdn == 0)
+ {
+ if (encode_kv(&outxdr, "fqdn", "0") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (numerichost == 1)
+ {
+ if (encode_kv(&outxdr, "numerichost", "1") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (numericserv == 1)
+ {
+ if (encode_kv(&outxdr, "numericserv", "1") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ if (name_req == 1)
+ {
+ if (encode_kv(&outxdr, "name_required", "1") != 0)
+ {
+ xdr_destroy(&outxdr);
+ return EAI_SYSTEM;
+ }
+ }
+
+ *len = xdr_getpos(&outxdr);
+
+ xdr_destroy(&outxdr);
+
+ return 0;
+}
+
+int
+getnameinfo(const struct sockaddr *sa, socklen_t salen, char *host, size_t hostlen, char *serv, size_t servlen, int flags)
+{
+ uint32_t n, i, qlen, rlen;
+ int wanth, wants;
+ XDR inxdr;
+ char qbuf[LU_QBUF_SIZE];
+ char *rbuf, *hval, *sval;
+ mach_port_t server_port;
+ kern_return_t status;
+ struct sockaddr_in *s4;
+ struct sockaddr_in6 *s6;
+
+ /* Check input */
+ if (sa == NULL) return EAI_FAIL;
+
+ /* V4 mapped and compat addresses are converted to plain V4 */
+ if (sa->sa_family == AF_INET6)
+ {
+ s6 = (struct sockaddr_in6 *)sa;
+ if ((IN6_IS_ADDR_V4MAPPED(&s6->sin6_addr)) || (IN6_IS_ADDR_V4COMPAT(&s6->sin6_addr)))
+ {
+ s4 = (struct sockaddr_in *)calloc(1, sizeof(struct sockaddr_in));
+ s4->sin_len = sizeof(struct sockaddr_in);
+ s4->sin_family = AF_INET;
+ s4->sin_port = s6->sin6_port;
+ memcpy(&(s4->sin_addr.s_addr), &(s6->sin6_addr.s6_addr[12]), 4);
+
+ i = getnameinfo((const struct sockaddr *)s4, s4->sin_len, host, hostlen, serv, servlen, flags);
+ free(s4);
+ return i;
+ }
+ }
+
+ wanth = 0;
+ if ((host != NULL) && (hostlen != 0)) wanth = 1;
+
+ wants = 0;
+ if ((serv != NULL) && (servlen != 0)) wants = 1;
+
+ if ((wanth == 0) && (wants == 0)) return 0;
+
+ /*
+ * Special cases handled by the library
+ */
+ if ((wanth == 1) && (flags & NI_NUMERICHOST))
+ {
+ i = INET_NTOP_AF_INET_OFFSET;
+ if (sa->sa_family == PF_INET6) i = INET_NTOP_AF_INET6_OFFSET;
+ if (inet_ntop(sa->sa_family, (char *)(sa) + i, host, hostlen) == NULL) return EAI_FAIL;
+
+ if (wants == 0) return 0;
+ }
+
+ if ((wants == 1) && (flags & NI_NUMERICSERV))
+ {
+ if (sa->sa_family == PF_INET)
+ {
+ s4 = (struct sockaddr_in *)sa;
+ n = snprintf(serv, servlen, "%hu", ntohs(s4->sin_port));
+ if (n >= servlen) return EAI_FAIL;
+ }
+ else if (sa->sa_family == PF_INET6)
+ {
+ s6 = (struct sockaddr_in6 *)sa;
+ n = snprintf(serv, servlen, "%hu", ntohs(s6->sin6_port));
+ if (n >= servlen) return EAI_FAIL;
+ }
+ else return EAI_FAMILY;
+
+ if (wanth == 0) return 0;
+ }
+
+ if ((wanth == 1) && (flags & NI_NUMERICHOST) && (wants == 1) && (flags & NI_NUMERICSERV)) return 0;
+
+ /*
+ * Ask lookupd
+ */
+ server_port = MACH_PORT_NULL;
+ if (_lu_running()) server_port = _lookupd_port(0);
+ if (server_port == MACH_PORT_NULL) return EAI_SYSTEM;
+
+ if (gni_proc < 0)
+ {
+ status = _lookup_link(server_port, "getnameinfo", &gni_proc);
+ if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ }
+
+ qlen = LU_QBUF_SIZE;
+ i = gni_make_query(sa, salen, wanth, wants, flags, qbuf, &qlen);
+ if (i != 0) return EAI_SYSTEM;
+
+ qlen /= BYTES_PER_XDR_UNIT;
+
+ rbuf = NULL;
+
+ status = _lookup_all(server_port, gni_proc, (unit *)qbuf, qlen, &rbuf, &rlen);
+ if (status != KERN_SUCCESS) return EAI_NONAME;
+
+ rlen *= BYTES_PER_XDR_UNIT;
+
+ xdrmem_create(&inxdr, rbuf, rlen, XDR_DECODE);
+
+ if (!xdr_int(&inxdr, &n))
+ {
+ xdr_destroy(&inxdr);
+ return EAI_SYSTEM;
+ }
+
+ if (n != 1)
+ {
+ xdr_destroy(&inxdr);
+ return EAI_NONAME;
+ }
+
+ hval = NULL;
+ sval = NULL;
+
+ i = gni_lookupd_process_dictionary(&inxdr, &hval, &sval);
+
+ xdr_destroy(&inxdr);
+ if (rbuf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)rbuf, rlen);
+
+ if (i != 0) return i;
+
+ i = 0;
+ if (hval != NULL) i = strlen(hval) + 1;
+ if ((host != NULL) && (hostlen != 0) && (i != 0))
+ {
+ if (i > hostlen) return EAI_FAIL;
+ memcpy(host, hval, i);
+ free(hval);
+ }
+
+ i = 0;
+ if (sval != NULL) i = strlen(sval) + 1;
+ if ((serv != NULL) && (servlen != 0) && (i != 0))
+ {
+ if (i > servlen) return EAI_FAIL;
+ memcpy(serv, sval, i);
+ free(sval);
+ }
+
+ return 0;
+}
+
+int32_t
+getnameinfo_async_start(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags, getnameinfo_async_callback callback, void *context)
+{
+ uint32_t i, qlen;
+ char qbuf[LU_QBUF_SIZE];
+ mach_port_t server_port;
+ kern_return_t status;
+
+ /* Check input */
+ if (sa == NULL) return EAI_FAIL;
+
+ server_port = MACH_PORT_NULL;
+ if (_lu_running()) server_port = _lookupd_port(0);
+ if (server_port == MACH_PORT_NULL) return EAI_SYSTEM;
+
+ if (gni_proc < 0)
+ {
+ status = _lookup_link(server_port, "getnameinfo", &gni_proc);
+ if (status != KERN_SUCCESS) return EAI_SYSTEM;
+ }
+
+ qlen = LU_QBUF_SIZE;
+ i = gni_make_query(sa, salen, 1, 1, flags, qbuf, &qlen);
+ if (i != 0) return EAI_SYSTEM;
+
+ qlen /= BYTES_PER_XDR_UNIT;
+
+ return lu_async_start(p, gni_proc, qbuf, qlen, (void *)callback, context);
+}
+
+int32_t
+getnameinfo_async_send(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags)
+{
+ return getnameinfo_async_start(p, sa, salen, flags, NULL, NULL);
+}
+
+static int
+gni_extract_data(char *buf, uint32_t len, char **host, char **serv)
+{
+ XDR xdr;
+ uint32_t n;
+
+ *host = NULL;
+ *serv = NULL;
+
+ if (buf == NULL) return EAI_NODATA;
+ if (len == 0) return EAI_NODATA;
+
+ xdrmem_create(&xdr, buf, len, XDR_DECODE);
+
+ if (!xdr_int(&xdr, &n))
+ {
+ xdr_destroy(&xdr);
+ return EAI_SYSTEM;
+ }
+
+ if (n != 1)
+ {
+ xdr_destroy(&xdr);
+ return EAI_NONAME;
+ }
+
+ return gni_lookupd_process_dictionary(&xdr, host, serv);
+}
+
+int32_t
+getnameinfo_async_receive(mach_port_t p, char **host, char **serv)
+{
+ kern_return_t status;
+ char *buf;
+ uint32_t len;
+
+ buf = NULL;
+ len = 0;
+
+ status = lu_async_receive(p, &buf, &len);
+ if (status < 0) return EAI_FAIL;
+
+ status = gni_extract_data(buf, len, host, serv);
+ if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len);
+ if (status != 0) return status;
+
+ return 0;
+}
+
+int32_t
+getnameinfo_async_handle_reply(void *msg)
+{
+ getnameinfo_async_callback callback;
+ void *context;
+ char *buf, *hval, *sval;
+ uint32_t len;
+ int status;
+
+ callback = (getnameinfo_async_callback)NULL;
+ context = NULL;
+ buf = NULL;
+ len = 0;
+
+ status = lu_async_handle_reply(msg, &buf, &len, (void **)&callback, &context);
+ if (status != KERN_SUCCESS)
+ {
+ if (status == MIG_REPLY_MISMATCH) return 0;
+ if (callback != NULL) callback(EAI_SYSTEM, NULL, NULL, context);
+ return EAI_SYSTEM;
+ }
+
+ hval = NULL;
+ sval = NULL;
+
+ status = gni_extract_data(buf, len, &hval, &sval);
+ if (buf != NULL) vm_deallocate(mach_task_self(), (vm_address_t)buf, len);
+ if (status != 0)
+ {
+ if (callback != NULL) callback(status, NULL, NULL, context);
+ return status;
+ }
+
+ callback(0, hval, sval, context);
+ return 0;
+}
--- /dev/null
+.\" $FreeBSD: src/lib/libc/net/getnameinfo.3,v 1.2.2.7 2001/08/17 15:42:38 ru Exp $
+.\" $KAME: getnameinfo.3,v 1.17 2000/08/09 21:16:17 itojun Exp $
+.\"
+.\" Copyright (c) 1983, 1987, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" From: @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95
+.\"
+.Dd May 25, 1995
+.Dt GETNAMEINFO 3
+.Os
+.\"
+.Sh NAME
+.Nm getnameinfo
+.Nd address-to-nodename translation in protocol-independent manner
+.\"
+.Sh LIBRARY
+.Lb libc
+.Sh SYNOPSIS
+.Fd #include <sys/types.h>
+.Fd #include <sys/socket.h>
+.Fd #include <netdb.h>
+.Ft int
+.Fn getnameinfo "const struct sockaddr *sa" "socklen_t salen" \
+"char *host" "size_t hostlen" "char *serv" "size_t servlen" "int flags"
+.\"
+.Sh DESCRIPTION
+The
+.Fn getnameinfo
+function is defined for protocol-independent address-to-nodename translation.
+Its functionality is a reverse conversion of
+.Xr getaddrinfo 3 ,
+and implements similar functionality with
+.Xr gethostbyaddr 3
+and
+.Xr getservbyport 3
+in more sophisticated manner.
+.Pp
+This function looks up an IP address and port number provided by the
+caller in the DNS and system-specific database, and returns text
+strings for both in buffers provided by the caller.
+The function indicates successful completion by a zero return value;
+a non-zero return value indicates failure.
+.Pp
+The first argument,
+.Fa sa ,
+points to either a
+.Li sockaddr_in
+structure (for IPv4) or a
+.Li sockaddr_in6
+structure (for IPv6) that holds the IP address and port number.
+The
+.Fa salen
+argument gives the length of the
+.Li sockaddr_in
+or
+.Li sockaddr_in6
+structure.
+.Pp
+The function returns the nodename associated with the IP address in
+the buffer pointed to by the
+.Fa host
+argument.
+The caller provides the size of this buffer via the
+.Fa hostlen
+argument.
+The service name associated with the port number is returned in the buffer
+pointed to by
+.Fa serv ,
+and the
+.Fa servlen
+argument gives the length of this buffer.
+The caller specifies not to return either string by providing a zero
+value for the
+.Fa hostlen
+or
+.Fa servlen
+arguments.
+Otherwise, the caller must provide buffers large enough to hold the
+nodename and the service name, including the terminating null characters.
+.Pp
+Unfortunately most systems do not provide constants that specify the
+maximum size of either a fully-qualified domain name or a service name.
+Therefore to aid the application in allocating buffers for these two
+returned strings the following constants are defined in
+.Aq Pa netdb.h :
+.Bd -literal -offset
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
+.Ed
+.Pp
+The first value is actually defined as the constant
+.Dv MAXDNAME
+in recent versions of BIND's
+.Aq Pa arpa/nameser.h
+header
+(older versions of BIND define this constant to be 256)
+and the second is a guess based on the services listed in the current
+Assigned Numbers RFC.
+.Pp
+The final argument is a
+.Fa flag
+that changes the default actions of this function.
+By default the fully-qualified domain name (FQDN) for the host is
+looked up in the DNS and returned.
+If the flag bit
+.Dv NI_NOFQDN
+is set, only the nodename portion of the FQDN is returned for local hosts.
+.Pp
+If the
+.Fa flag
+bit
+.Dv NI_NUMERICHOST
+is set, or if the host's name cannot be located in the DNS,
+the numeric form of the host's address is returned instead of its name
+(e.g., by calling
+.Fn inet_ntop
+instead of
+.Fn getnodebyaddr ) .
+If the
+.Fa flag
+bit
+.Dv NI_NAMEREQD
+is set, an error is returned if the host's name cannot be located in the DNS.
+.Pp
+If the flag bit
+.Dv NI_NUMERICSERV
+is set, the numeric form of the service address is returned
+(e.g., its port number)
+instead of its name.
+The two
+.Dv NI_NUMERICxxx
+flags are required to support the
+.Fl n
+flag that many commands provide.
+.Pp
+A fifth flag bit,
+.Dv NI_DGRAM ,
+specifies that the service is a datagram service, and causes
+.Fn getservbyport
+to be called with a second argument of
+.Dq udp
+instead of its default of
+.Dq tcp .
+This is required for the few ports (512-514)
+that have different services for UDP and TCP.
+.Pp
+These
+.Dv NI_xxx
+flags are defined in
+.Aq Pa netdb.h .
+.\"
+.Sh EXTENSION
+The implementation allows experimental numeric IPv6 address notation with
+scope identifier.
+IPv6 link-local address will appear as string like
+.Dq Li fe80::1%ne0 ,
+if
+.Dv NI_WITHSCOPEID
+bit is enabled in
+.Ar flags
+argument.
+Refer to
+.Xr getaddrinfo 3
+for the notation.
+.\"
+.Sh EXAMPLES
+The following code tries to get numeric hostname, and service name,
+for given socket address.
+Observe that there is no hardcoded reference to particular address family.
+.Bd -literal -offset indent
+struct sockaddr *sa; /* input */
+char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV];
+
+if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), sbuf,
+ sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) {
+ errx(1, "could not get numeric hostname");
+ /*NOTREACHED*/
+}
+printf("host=%s, serv=%s\\n", hbuf, sbuf);
+.Ed
+.Pp
+The following version checks if the socket address has reverse address mapping.
+.Bd -literal -offset indent
+struct sockaddr *sa; /* input */
+char hbuf[NI_MAXHOST];
+
+if (getnameinfo(sa, sa->sa_len, hbuf, sizeof(hbuf), NULL, 0,
+ NI_NAMEREQD)) {
+ errx(1, "could not resolve hostname");
+ /*NOTREACHED*/
+}
+printf("host=%s\\n", hbuf);
+.Ed
+.\"
+.Sh FILES
+.Bl -tag -width /etc/resolv.conf -compact
+.It Pa /etc/hosts
+.It Pa /etc/host.conf
+.It Pa /etc/resolv.conf
+.El
+.\"
+.Sh DIAGNOSTICS
+The function indicates successful completion by a zero return value;
+a non-zero return value indicates failure.
+Error codes are as below:
+.Bl -tag -width Er
+.It Bq Er EAI_AGAIN
+The name could not be resolved at this time.
+Future attempts may succeed.
+.It Bq Er EAI_BADFLAGS
+The flags had an invalid value.
+.It Bq Er EAI_FAIL
+A non-recoverable error occurred.
+.It Bq Er EAI_FAMILY
+The address family was not recognized or the address length was invalid
+for the specified family.
+.It Bq Er EAI_MEMORY
+There was a memory allocation failure.
+.It Bq Er EAI_NONAME
+The name does not resolve for the supplied parameters.
+.Dv NI_NAMEREQD
+is set and the host's name cannot be located,
+or both nodename and servname were null.
+.It Bq Er EAI_SYSTEM
+A system error occurred.
+The error code can be found in errno.
+.El
+.\"
+.Sh SEE ALSO
+.Xr getaddrinfo 3 ,
+.Xr gethostbyaddr 3 ,
+.Xr getservbyport 3 ,
+.Xr hosts 5 ,
+.Xr services 5 ,
+.Xr hostname 7 ,
+.Xr named 8
+.Pp
+.Rs
+.%A R. Gilligan
+.%A S. Thomson
+.%A J. Bound
+.%A W. Stevens
+.%T Basic Socket Interface Extensions for IPv6
+.%R RFC2553
+.%D March 1999
+.Re
+.Rs
+.%A Tatsuya Jinmei
+.%A Atsushi Onoe
+.%T "An Extension of Format for IPv6 Scoped Addresses"
+.%R internet draft
+.%N draft-ietf-ipngwg-scopedaddr-format-02.txt
+.%O work in progress material
+.Re
+.Rs
+.%A Craig Metz
+.%T Protocol Independence Using the Sockets API
+.%B "Proceedings of the freenix track: 2000 USENIX annual technical conference"
+.%D June 2000
+.Re
+.\"
+.Sh HISTORY
+The implementation first appeared in WIDE Hydrangea IPv6 protocol stack kit.
+.\"
+.Sh STANDARDS
+The
+.Fn getaddrinfo
+function is defined in
+.St -p1003.1g-2000 ,
+and documented in
+.Dq Basic Socket Interface Extensions for IPv6
+(RFC2553).
+.\"
+.Sh BUGS
+The current implementation is not thread-safe.
+.Pp
+The text was shamelessly copied from RFC2553.
+.Pp
+The type of the 2nd argument should be
+.Li socklen_t
+for RFC2553 conformance.
+The current code is based on pre-RFC2553 specification.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <arpa/inet.h>
#include <net/if.h>
#include <netinet/if_ether.h>
+#include <net/ethernet.h>
#include <pthread.h>
#include "_lu_types.h"
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include "lu_utils.h"
#include "lu_overrides.h"
+#define GROUP_CACHE_SIZE 10
+#define DEFAULT_GROUP_CACHE_TTL 10
+
+static pthread_mutex_t _group_cache_lock = PTHREAD_MUTEX_INITIALIZER;
+static void *_group_cache[GROUP_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+static unsigned int _group_cache_best_before[GROUP_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static unsigned int _group_cache_index = 0;
+static unsigned int _group_cache_ttl = DEFAULT_GROUP_CACHE_TTL;
+
static pthread_mutex_t _group_lock = PTHREAD_MUTEX_INITIALIZER;
#define GR_GET_NAME 1
g->gr_passwd = vals[0];
j = 1;
}
- else if ((g->gr_gid == -2) && (!strcmp("gid", key)))
+ else if ((g->gr_gid == (gid_t)-2) && (!strcmp("gid", key)))
{
g->gr_gid = atoi(vals[0]);
+ if ((g->gr_gid == 0) && (strcmp(vals[0], "0"))) g->gr_gid = -2;
}
else if ((g->gr_mem == NULL) && (!strcmp("users", key)))
{
free(in);
}
+__private_extern__ unsigned int
+get_group_cache_ttl()
+{
+ return _group_cache_ttl;
+}
+
+__private_extern__ void
+set_group_cache_ttl(unsigned int ttl)
+{
+ int i;
+
+ pthread_mutex_lock(&_group_cache_lock);
+
+ _group_cache_ttl = ttl;
+
+ if (ttl == 0)
+ {
+ for (i = 0; i < GROUP_CACHE_SIZE; i++)
+ {
+ if (_group_cache[i] == NULL) continue;
+
+ free_group((struct group *)_group_cache[i]);
+ _group_cache[i] = NULL;
+ _group_cache_best_before[i] = 0;
+ }
+ }
+
+ pthread_mutex_unlock(&_group_cache_lock);
+}
+
+static void
+cache_group(struct group *gr)
+{
+ struct timeval now;
+ struct group *grcache;
+
+ if (_group_cache_ttl == 0) return;
+ if (gr == NULL) return;
+
+ pthread_mutex_lock(&_group_cache_lock);
+
+ grcache = copy_group(gr);
+
+ gettimeofday(&now, NULL);
+
+ if (_group_cache[_group_cache_index] != NULL)
+ free_group((struct group *)_group_cache[_group_cache_index]);
+
+ _group_cache[_group_cache_index] = grcache;
+ _group_cache_best_before[_group_cache_index] = now.tv_sec + _group_cache_ttl;
+ _group_cache_index = (_group_cache_index + 1) % GROUP_CACHE_SIZE;
+
+ pthread_mutex_unlock(&_group_cache_lock);
+}
+
+static struct group *
+cache_getgrnam(const char *name)
+{
+ int i;
+ struct group *gr, *res;
+ struct timeval now;
+
+ if (_group_cache_ttl == 0) return NULL;
+ if (name == NULL) return NULL;
+
+ pthread_mutex_lock(&_group_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ for (i = 0; i < GROUP_CACHE_SIZE; i++)
+ {
+ if (_group_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _group_cache_best_before[i]) continue;
+
+ gr = (struct group *)_group_cache[i];
+
+ if (gr->gr_name == NULL) continue;
+
+ if (!strcmp(name, gr->gr_name))
+ {
+ res = copy_group(gr);
+ pthread_mutex_unlock(&_group_cache_lock);
+ return res;
+ }
+ }
+
+ pthread_mutex_unlock(&_group_cache_lock);
+ return NULL;
+}
+
+static struct group *
+cache_getgrgid(int gid)
+{
+ int i;
+ struct group *gr, *res;
+ struct timeval now;
+
+ if (_group_cache_ttl == 0) return NULL;
+
+ pthread_mutex_lock(&_group_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ for (i = 0; i < GROUP_CACHE_SIZE; i++)
+ {
+ if (_group_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _group_cache_best_before[i]) continue;
+
+ gr = (struct group *)_group_cache[i];
+
+ if ((gid_t)gid == gr->gr_gid)
+ {
+ res = copy_group(gr);
+ pthread_mutex_unlock(&_group_cache_lock);
+ return res;
+ }
+ }
+
+ pthread_mutex_unlock(&_group_cache_lock);
+ return NULL;
+}
+
static struct group *
lu_getgrgid(int gid)
{
return g;
}
+int
+_old_getgrouplist(const char *uname, int agroup, int *groups, int *grpcnt)
+{
+ struct group *grp;
+ int i, ngroups;
+ int ret, maxgroups;
+
+ ret = 0;
+ ngroups = 0;
+ maxgroups = *grpcnt;
+
+ /*
+ * When installing primary group, duplicate it;
+ * the first element of groups is the effective gid
+ * and will be overwritten when a setgid file is executed.
+ */
+ groups[ngroups++] = agroup;
+ if (maxgroups > 1) groups[ngroups++] = agroup;
+
+ /*
+ * Scan the group file to find additional groups.
+ */
+ setgrent();
+
+ while ((grp = getgrent()))
+ {
+ if (grp->gr_gid == (gid_t)agroup) continue;
+ for (i = 0; grp->gr_mem[i]; i++)
+ {
+ if (!strcmp(grp->gr_mem[i], uname))
+ {
+ if (ngroups >= maxgroups)
+ {
+ ret = -1;
+ break;
+ }
+
+ groups[ngroups++] = grp->gr_gid;
+ break;
+ }
+ }
+ }
+
+ endgrent();
+ *grpcnt = ngroups;
+ return ret;
+}
+
static int
-lu_initgroups(const char *name, int basegid)
+lu_getgrouplist(const char *name, int basegid, int *groups, int *grpcnt, int dupbase)
{
unsigned int datalen;
XDR outxdr;
static int proc = -1;
char *lookup_buf;
char namebuf[_LU_MAXLUSTRLEN + BYTES_PER_XDR_UNIT];
- int groups[NGROUPS];
int ngroups;
int a_group;
int i, j, count;
- groups[0] = basegid;
-
+ if (groups == NULL) return -1;
+ if (*grpcnt == 0) return -1;
+
+ ngroups = 0;
+ groups[ngroups++] = basegid;
+ if (*grpcnt == 1) return 0;
+
+ if (dupbase != 0)
+ {
+ /* getgrouplist duplicates the primary group! */
+ groups[ngroups++] = basegid;
+ if (*grpcnt == 2) return 0;
+ }
+
if (proc < 0)
{
if (_lookup_link(_lu_port, "initgroups", &proc) != KERN_SUCCESS)
return -1;
}
- if (count > NGROUPS) count = NGROUPS;
-
- ngroups = 0;
-
for (i = 0; i < count; i++)
{
if (!xdr_int(&inxdr, &a_group)) break;
- for (j = 0; j < ngroups; j++)
+ j = 0;
+ if (dupbase != 0) j = 1;
+ for (; j < ngroups; j++)
{
if (groups[j] == a_group) break;
}
- if (j >= ngroups) groups[ngroups++] = a_group;
-
+
+ if (j >= ngroups)
+ {
+ groups[ngroups++] = a_group;
+ if (ngroups == *grpcnt) break;
+ }
}
+
xdr_destroy(&inxdr);
vm_deallocate(mach_task_self(), (vm_address_t)lookup_buf, datalen);
+ *grpcnt = ngroups;
+ return 0;
+}
+
+int
+getgrouplist(const char *uname, int agroup, int *groups, int *grpcnt)
+{
+ if (_lu_running())
+ {
+ return lu_getgrouplist(uname, agroup, groups, grpcnt, 1);
+ }
+
+ return _old_getgrouplist(uname, agroup, groups, grpcnt);
+}
+
+static int
+lu_initgroups(const char *name, int basegid)
+{
+ int status, ngroups, groups[NGROUPS];
+
+ ngroups = NGROUPS;
+ status = lu_getgrouplist(name, basegid, groups, &ngroups, 0);
+ if (status < 0) return status;
+
return setgroups(ngroups, groups);
}
tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info));
_lu_data_set_key(_lu_data_key_group, tdata);
}
-\r
+
if (tdata->lu_vm == NULL)
{
if (proc < 0)
getgr_internal(const char *name, gid_t gid, int source)
{
struct group *res = NULL;
+ int from_cache;
- if (_lu_running())
+ from_cache = 0;
+ res = NULL;
+
+ switch (source)
+ {
+ case GR_GET_NAME:
+ res = cache_getgrnam(name);
+ break;
+ case GR_GET_GID:
+ res = cache_getgrgid(gid);
+ break;
+ default: res = NULL;
+ }
+
+ if (res != NULL)
+ {
+ from_cache = 1;
+ }
+ else if (_lu_running())
{
switch (source)
{
pthread_mutex_unlock(&_group_lock);
}
+ if (from_cache == 0) cache_group(res);
+
return res;
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include "lu_host.h"
#include "lu_utils.h"
+#define HOST_CACHE_SIZE 10
+#define DEFAULT_HOST_CACHE_TTL 10
+
+#define CACHE_BYNAME 0
+#define CACHE_BYADDR 1
+
+static pthread_mutex_t _host_cache_lock = PTHREAD_MUTEX_INITIALIZER;
+static unsigned int _host_cache_ttl = DEFAULT_HOST_CACHE_TTL;
+
+static void *_host_byname_cache[HOST_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+static int _host_byname_cache_flavor[HOST_CACHE_SIZE] = { WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING };
+static unsigned int _host_byname_cache_best_before[HOST_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static unsigned int _host_byname_cache_index = 0;
+
+static void *_host_byaddr_cache[HOST_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+static int _host_byaddr_cache_flavor[HOST_CACHE_SIZE] = { WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING, WANT_NOTHING };
+static unsigned int _host_byaddr_cache_best_before[HOST_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static unsigned int _host_byaddr_cache_index = 0;
+
static pthread_mutex_t _host_lock = PTHREAD_MUTEX_INITIALIZER;
extern struct hostent *_res_gethostbyaddr();
free(mapvals);
}
+ if (h->h_addr_list == NULL)
+ {
+ freehostent(h);
+ *err = NO_DATA;
+ return NULL;
+ }
+
if (h->h_name == NULL) h->h_name = strdup("");
if (h->h_aliases == NULL) h->h_aliases = (char **)calloc(1, sizeof(char *));
- if (h->h_addr_list == NULL) h->h_addr_list = (char **)calloc(1, sizeof(char *));
return h;
}
return h;
}
+__private_extern__ unsigned int
+get_host_cache_ttl()
+{
+ return _host_cache_ttl;
+}
+
+__private_extern__ void
+set_host_cache_ttl(unsigned int ttl)
+{
+ int i;
+
+ pthread_mutex_lock(&_host_cache_lock);
+
+ _host_cache_ttl = ttl;
+
+ if (ttl == 0)
+ {
+ for (i = 0; i < HOST_CACHE_SIZE; i++)
+ {
+ if (_host_byname_cache[i] == NULL) continue;
+
+ freehostent((struct hostent *)_host_byname_cache[i]);
+ _host_byname_cache[i] = NULL;
+ _host_byname_cache_flavor[i] = WANT_NOTHING;
+ _host_byname_cache_best_before[i] = 0;
+ }
+
+ for (i = 0; i < HOST_CACHE_SIZE; i++)
+ {
+ if (_host_byaddr_cache[i] == NULL) continue;
+
+ freehostent((struct hostent *)_host_byaddr_cache[i]);
+ _host_byaddr_cache[i] = NULL;
+ _host_byaddr_cache_flavor[i] = WANT_NOTHING;
+ _host_byaddr_cache_best_before[i] = 0;
+ }
+ }
+
+ pthread_mutex_unlock(&_host_cache_lock);
+}
+
+static void
+cache_host(struct hostent *h, int want, int how)
+{
+ struct timeval now;
+ struct hostent *hcache;
+
+ if (_host_cache_ttl == 0) return;
+ if (h == NULL) return;
+
+ pthread_mutex_lock(&_host_cache_lock);
+
+ hcache = copy_host(h);
+
+ gettimeofday(&now, NULL);
+
+ if (how == CACHE_BYNAME)
+ {
+ if (_host_byname_cache[_host_byname_cache_index] != NULL)
+ freehostent((struct hostent *)_host_byname_cache[_host_byname_cache_index]);
+
+ _host_byname_cache[_host_byname_cache_index] = hcache;
+ _host_byname_cache_flavor[_host_byname_cache_index] = want;
+ _host_byname_cache_best_before[_host_byname_cache_index] = now.tv_sec + _host_cache_ttl;
+ _host_byname_cache_index = (_host_byname_cache_index + 1) % HOST_CACHE_SIZE;
+ }
+ else
+ {
+ if (_host_byaddr_cache[_host_byaddr_cache_index] != NULL)
+ freehostent((struct hostent *)_host_byaddr_cache[_host_byaddr_cache_index]);
+
+ _host_byaddr_cache[_host_byaddr_cache_index] = hcache;
+ _host_byaddr_cache_flavor[_host_byaddr_cache_index] = want;
+ _host_byaddr_cache_best_before[_host_byaddr_cache_index] = now.tv_sec + _host_cache_ttl;
+ _host_byaddr_cache_index = (_host_byaddr_cache_index + 1) % HOST_CACHE_SIZE;
+ }
+
+ pthread_mutex_unlock(&_host_cache_lock);
+}
+
+static struct hostent *
+cache_gethostbyname(const char *name, int want)
+{
+ int i;
+ struct hostent *h, *res;
+ char **aliases;
+ struct timeval now;
+
+ if (_host_cache_ttl == 0) return NULL;
+ if (name == NULL) return NULL;
+
+ pthread_mutex_lock(&_host_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ for (i = 0; i < HOST_CACHE_SIZE; i++)
+ {
+ if (_host_byname_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _host_byname_cache_best_before[i]) continue;
+
+ if (_host_byname_cache_flavor[i] != want) continue;
+
+ h = (struct hostent *)_host_byname_cache[i];
+
+ if (h->h_name != NULL)
+ {
+ if (!strcmp(name, h->h_name))
+ {
+ res = copy_host(h);
+ pthread_mutex_unlock(&_host_cache_lock);
+ return res;
+ }
+ }
+
+ aliases = h->h_aliases;
+ if (aliases == NULL)
+ {
+ pthread_mutex_unlock(&_host_cache_lock);
+ return NULL;
+ }
+
+ for (; *aliases != NULL; *aliases++)
+ {
+ if (!strcmp(name, *aliases))
+ {
+ res = copy_host(h);
+ pthread_mutex_unlock(&_host_cache_lock);
+ return res;
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&_host_cache_lock);
+ return NULL;
+}
+
+static struct hostent *
+cache_gethostbyaddr(const char *addr, int want)
+{
+ int i, j, len;
+ struct hostent *h, *res;
+ struct timeval now;
+
+ if (addr == NULL) return NULL;
+ if (_host_cache_ttl == 0) return NULL;
+
+ pthread_mutex_lock(&_host_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ len = IPV4_ADDR_LEN;
+ if (want > WANT_A4_ONLY) len = IPV6_ADDR_LEN;
+
+ for (i = 0; i < HOST_CACHE_SIZE; i++)
+ {
+ if (_host_byaddr_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _host_byaddr_cache_best_before[i]) continue;
+
+ if (_host_byaddr_cache_flavor[i] != want) continue;
+
+ h = (struct hostent *)_host_byaddr_cache[i];
+
+ if (h->h_addr_list == NULL) continue;
+
+ for (j = 0; h->h_addr_list[j] != NULL; j++)
+ {
+ if (memcmp(addr, h->h_addr_list[j], len) == 0)
+ {
+ res = copy_host(h);
+ pthread_mutex_unlock(&_host_cache_lock);
+ return res;
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&_host_cache_lock);
+ return NULL;
+}
+
static struct hostent *
lu_gethostbyaddr(const char *addr, int want, int *err)
{
family = AF_INET;
len = IPV4_ADDR_LEN;
- if (want > WANT_A4_ONLY)
+ if ((want == WANT_A6_ONLY) || (want == WANT_A6_PLUS_MAPPED_A4))
{
family = AF_INET6;
len = IPV6_ADDR_LEN;
struct lu_thread_info *tdata;
tdata = _lu_data_create_key(_lu_data_key_host, free_lu_thread_info_host);
- _lu_data_free_vm_xdr(tdata);\r
+ _lu_data_free_vm_xdr(tdata);
}
static void
tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info));
_lu_data_set_key(_lu_data_key_host, tdata);
}
-\r
+
if (tdata->lu_vm == NULL)
{
if (proc < 0)
gethostbyaddrerrno(const char *addr, int len, int type, int *err)
{
struct hostent *res = NULL;
- int want;
+ int want, from_cache;
*err = 0;
want = WANT_A4_ONLY;
if (type == AF_INET6) want = WANT_A6_ONLY;
- if (_lu_running())
+ if ((type == AF_INET6) && (len == 16) && (is_a4_mapped((const char *)addr) || is_a4_compat((const char *)addr)))
+ {
+ addr += 12;
+ len = 4;
+ type = AF_INET;
+ want = WANT_MAPPED_A4_ONLY;
+ }
+
+ from_cache = 0;
+ res = cache_gethostbyaddr(addr, want);
+
+ if (res != NULL)
+ {
+ from_cache = 1;
+ }
+ else if (_lu_running())
{
res = lu_gethostbyaddr(addr, want, err);
}
pthread_mutex_unlock(&_host_lock);
}
+ if (from_cache == 0) cache_host(res, want, CACHE_BYADDR);
+
return res;
}
{
struct hostent *res = NULL;
struct in_addr addr;
- int i, is_addr;
+ int i, is_addr, from_cache;
*err = 0;
if ((is_addr == 1) && (name[i-1] == '.')) is_addr = 0;
+ res = NULL;
+ from_cache = 0;
+
if (is_addr == 1)
{
if (inet_aton(name, &addr) == 0)
}
res = fake_hostent(name, addr);
}
+
+ if (res == NULL)
+ {
+ res = cache_gethostbyname(name, WANT_A4_ONLY);
+ }
+
+ if (res != NULL)
+ {
+ from_cache = 1;
+ }
else if (_lu_running())
{
res = lu_gethostbyname(name, WANT_A4_ONLY, err);
}
res = gethostbyaddrerrno((char *)&addr, sizeof(addr), AF_INET, err);
- if (res == NULL) {
+ if (res == NULL)
+ {
res = fake_hostent(name, addr);
}
}
+ if (from_cache == 0) cache_host(res, WANT_A4_ONLY, CACHE_BYNAME);
+
return res;
}
return (struct hostent *)tdata->lu_entry;
}
+struct hostent *
+gethostbyname2(const char *name, int af)
+{
+ struct hostent *res;
+ struct lu_thread_info *tdata;
+
+ res = getipnodebyname(name, af, 0, &h_errno);
+ if (res == NULL)
+ {
+ errno = EAFNOSUPPORT;
+ h_errno = NETDB_INTERNAL;
+ return NULL;
+ }
+
+ tdata = _lu_data_create_key(_lu_data_key_host, free_lu_thread_info_host);
+ if (tdata == NULL)
+ {
+ tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info));
+ _lu_data_set_key(_lu_data_key_host, tdata);
+ }
+
+ recycle_host(tdata, res);
+ return (struct hostent *)tdata->lu_entry;
+}
+
struct hostent *
gethostent(void)
{
*err = 0;
- if ((af == AF_INET6) && (len == 16) && (is_a4_mapped((const char *)src) || is_a4_compat((const char *)src)))
- {
- src += 12;
- len = 4;
- af = AF_INET;
- }
-
res = gethostbyaddrerrno((const char *)src, len, af, err);
- if (res == NULL) {
+ if (res == NULL)
+ {
return NULL;
}
- if (res->h_name == NULL) {
+ if (res->h_name == NULL)
+ {
freehostent(res);
return NULL;
}
struct hostent *
getipnodebyname(const char *name, int af, int flags, int *err)
{
- int status, want, really_want, if4, if6;
+ int status, want, really_want, if4, if6, from_cache;
struct hostent *res;
struct ifaddrs *ifa, *ifap;
struct in_addr addr4;
}
}
- res = NULL;
+ from_cache = 0;
+ res = cache_gethostbyname(name, want);
- if (_lu_running())
+ if (res != NULL)
+ {
+ from_cache = 1;
+ }
+ else if (_lu_running())
{
res = lu_gethostbyname(name, want, err);
if ((res == NULL) &&
return NULL;
}
+ if (from_cache == 0) cache_host(res, want, CACHE_BYNAME);
+
return res;
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/cdefs.h>
+#define WANT_NOTHING 0xfeedface
#define WANT_A4_ONLY 0
#define WANT_A6_ONLY 1
#define WANT_A6_PLUS_MAPPED_A4 2
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
#include <netdb.h>
-#include <netdb_async.h> /* async gethostbyXXX function prototypes */
+/* async gethostbyXXX function prototypes */
+#include <netdb_async.h>
#include <pthread.h>
#include <stdlib.h>
#include <mach/mach.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <net/if.h>
+#include <libkern/OSByteOrder.h>
#include "lu_host.h"
#include "lu_utils.h"
extern int h_errno;
+#define msgh_request_port msgh_remote_port
+#define msgh_reply_port msgh_local_port
-#define msgh_request_port msgh_remote_port
-#define msgh_reply_port msgh_local_port
-
-typedef union {
- gethostbyaddr_async_callback hostAddr;
- gethostbyname_async_callback hostName;
- getipnodebyaddr_async_callback nodeAddr;
- getipnodebyname_async_callback nodeName;
+typedef union
+{
+ gethostbyaddr_async_callback hostAddr;
+ gethostbyname_async_callback hostName;
+ getipnodebyaddr_async_callback nodeAddr;
+ getipnodebyname_async_callback nodeName;
} a_request_callout_t;
-typedef struct a_requests {
- struct a_requests *next;
- int retry;
- struct {
- int proc;
- ooline_data data;
- unsigned int dataLen;
- int want;
+typedef struct a_requests
+{
+ struct a_requests *next;
+ int retry;
+ struct
+ {
+ int proc;
+ ooline_data data;
+ unsigned int dataLen;
+ int want;
} request;
- mach_port_t replyPort;
- a_request_callout_t callout;
- void *context;
- struct hostent *hent; /* if reply known in XXX_start() */
+ mach_port_t replyPort;
+ a_request_callout_t callout;
+ void *context;
+ struct hostent *hent; /* if reply known in XXX_start() */
} a_requests_t;
-static a_requests_t *a_requests = NULL;
-static pthread_mutex_t a_requests_lock = PTHREAD_MUTEX_INITIALIZER;
+static a_requests_t *a_requests = NULL;
+static pthread_mutex_t a_requests_lock = PTHREAD_MUTEX_INITIALIZER;
#define MAX_LOOKUP_ATTEMPTS 10
-
static kern_return_t
-_lookup_all_tx
-(
- mach_port_t server,
- int proc,
- ooline_data indata,
- mach_msg_type_number_t indataCnt,
- mach_port_t *replyPort
-)
+_lookup_all_tx(mach_port_t server, int proc, ooline_data indata, mach_msg_type_number_t indataCnt, mach_port_t *replyPort)
{
- typedef struct {
- mach_msg_header_t Head;
- NDR_record_t NDR;
- int proc;
- mach_msg_type_number_t indataCnt;
- unit indata[4096];
+ typedef struct
+ {
+ mach_msg_header_t Head;
+ NDR_record_t NDR;
+ int proc;
+ mach_msg_type_number_t indataCnt;
+ unit indata[4096];
} Request;
- Request In;
- register Request *InP = &In;
- mach_msg_return_t mr;
- unsigned int msgh_size;
+ Request In;
+ register Request *InP = &In;
+ mach_msg_return_t mr;
+ unsigned int msgh_size;
- if (indataCnt > 4096) {
- return MIG_ARRAY_TOO_LARGE;
- }
+ if (indataCnt > 4096) return MIG_ARRAY_TOO_LARGE;
- if (*replyPort == MACH_PORT_NULL) {
- mr = mach_port_allocate(mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- replyPort);
- if (mr != KERN_SUCCESS) {
- return mr;
- }
+ if (*replyPort == MACH_PORT_NULL)
+ {
+ mr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, replyPort);
+ if (mr != KERN_SUCCESS) return mr;
}
msgh_size = (sizeof(Request) - 16384) + ((4 * indataCnt));
- InP->Head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
-/* InP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */
- InP->Head.msgh_request_port = server;
- InP->Head.msgh_reply_port = *replyPort;
- InP->Head.msgh_id = 4241776;
- InP->NDR = NDR_record;
- InP->proc = proc;
- InP->indataCnt = indataCnt;
- (void)memcpy((char *)InP->indata, (const char *)indata, 4 * indataCnt);
-
- mr = mach_msg(&InP->Head, /* msg */
- MACH_SEND_MSG, /* options */
- msgh_size, /* send_size */
- 0, /* rcv_size */
- MACH_PORT_NULL, /* rcv_name */
- MACH_MSG_TIMEOUT_NONE, /* timeout */
- MACH_PORT_NULL); /* notify */
- switch (mr) {
- case MACH_MSG_SUCCESS :
+ InP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_COPY_SEND, MACH_MSG_TYPE_MAKE_SEND_ONCE);
+// InP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */
+ InP->Head.msgh_request_port = server;
+ InP->Head.msgh_reply_port = *replyPort;
+ InP->Head.msgh_id = 4241776;
+ InP->NDR = NDR_record;
+ InP->proc = proc;
+ InP->indataCnt = indataCnt;
+ memcpy((char *)InP->indata, (const char *)indata, 4 * indataCnt);
+
+ mr = mach_msg(&InP->Head, /* msg */
+ MACH_SEND_MSG, /* options */
+ msgh_size, /* send_size */
+ 0, /* rcv_size */
+ MACH_PORT_NULL, /* rcv_name */
+ MACH_MSG_TIMEOUT_NONE, /* timeout */
+ MACH_PORT_NULL); /* notify */
+
+ switch (mr)
+ {
+ case MACH_MSG_SUCCESS:
mr = KERN_SUCCESS;
break;
case MACH_SEND_INVALID_REPLY :
- (void)mach_port_destroy(mach_task_self(), *replyPort);
+ (void)mach_port_mod_refs(mach_task_self(), *replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
+ *replyPort = MACH_PORT_NULL;
break;
default:
break;
return mr;
}
-
static kern_return_t
-_lookup_all_rx
-(
- void *msg,
- ooline_data *outdata,
- mach_msg_type_number_t *outdataCnt,
- security_token_t *token
-)
+_lookup_all_rx(void *msg, ooline_data *outdata, mach_msg_type_number_t *outdataCnt, security_token_t *token)
{
- typedef struct {
- mach_msg_header_t Head;
- mach_msg_body_t msgh_body;
- mach_msg_ool_descriptor_t outdata;
- NDR_record_t NDR;
- mach_msg_type_number_t outdataCnt;
- mach_msg_format_0_trailer_t trailer;
+ typedef struct
+ {
+ mach_msg_header_t Head;
+ mach_msg_body_t msgh_body;
+ mach_msg_ool_descriptor_t outdata;
+ NDR_record_t NDR;
+ mach_msg_type_number_t outdataCnt;
+ mach_msg_format_0_trailer_t trailer;
} Reply;
/*
* typedef struct {
- * mach_msg_header_t Head;
- * NDR_record_t NDR;
- * kern_return_t RetCode;
+ * mach_msg_header_t Head;
+ * NDR_record_t NDR;
+ * kern_return_t RetCode;
* } mig_reply_error_t;
*/
- register Reply *OutP = msg;
- mach_msg_format_0_trailer_t *TrailerP;
- boolean_t msgh_simple;
+ register Reply *OutP = msg;
+ mach_msg_format_0_trailer_t *TrailerP;
+ boolean_t msgh_simple;
- if (OutP->Head.msgh_id != (4241776 + 100)) {
- if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE)
- return MIG_SERVER_DIED;
- else
- return MIG_REPLY_MISMATCH;
+ if (OutP->Head.msgh_id != (4241776 + 100))
+ {
+ if (OutP->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) return MIG_SERVER_DIED;
+ else return MIG_REPLY_MISMATCH;
}
msgh_simple = !(OutP->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX);
- TrailerP = (mach_msg_format_0_trailer_t *)((vm_offset_t)OutP +
- round_msg(OutP->Head.msgh_size));
- if (TrailerP->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0)
- return MIG_TRAILER_ERROR;
+ TrailerP = (mach_msg_format_0_trailer_t *)((vm_offset_t)OutP + round_msg(OutP->Head.msgh_size));
+ if (TrailerP->msgh_trailer_type != MACH_MSG_TRAILER_FORMAT_0) return MIG_TRAILER_ERROR;
+
+ if (OutP->NDR.int_rep != NDR_record.int_rep)
+ {
+ if (msgh_simple)
+ {
+ ((mig_reply_error_t *)OutP)->RetCode = OSReadSwapInt32(&(((mig_reply_error_t *)OutP)->RetCode), 0);
+ }
+ else
+ {
+ OutP->outdataCnt = OSReadSwapInt32(&(OutP->outdataCnt), 0);
+ }
+ }
- if (msgh_simple && ((mig_reply_error_t *)OutP)->RetCode != KERN_SUCCESS)
- return ((mig_reply_error_t *)OutP)->RetCode;
+ if (msgh_simple && ((mig_reply_error_t *)OutP)->RetCode != KERN_SUCCESS) return ((mig_reply_error_t *)OutP)->RetCode;
- *outdata = (ooline_data)(OutP->outdata.address);
+ *outdata = (ooline_data)(OutP->outdata.address);
*outdataCnt = OutP->outdataCnt;
*token = TrailerP->msgh_sender;
return KERN_SUCCESS;
}
-
static a_requests_t *
request_extract(mach_port_t port)
{
- a_requests_t *request0, *request;
+ a_requests_t *request0, *request;
pthread_mutex_lock(&a_requests_lock);
+
request0 = NULL;
- request = a_requests;
- while (request) {
- if (port == request->replyPort) {
+ request = a_requests;
+
+ while (request != NULL)
+ {
+ if (port == request->replyPort)
+ {
/* request found, remove from list */
- if (request0) {
+ if (request0 != NULL)
+ {
request0->next = request->next;
- } else {
+ }
+ else
+ {
a_requests = request->next;
}
+
break;
- } else {
+ }
+ else
+ {
/* not this request, skip to next */
request0 = request;
- request = request->next;
+ request = request->next;
}
}
+
pthread_mutex_unlock(&a_requests_lock);
return request;
}
-
static void
request_queue(a_requests_t *request)
{
pthread_mutex_lock(&a_requests_lock);
+
request->next = a_requests;
a_requests = request;
+
pthread_mutex_unlock(&a_requests_lock);
return;
}
-
static boolean_t
sendCannedReply(a_requests_t *request, int *error)
{
/*
* typedef struct {
- * mach_msg_header_t Head;
- * NDR_record_t NDR;
- * kern_return_t RetCode;
+ * mach_msg_header_t Head;
+ * NDR_record_t NDR;
+ * kern_return_t RetCode;
* } mig_reply_error_t;
*/
- mig_reply_error_t Out;
- register mig_reply_error_t *OutP = &Out;
+ mig_reply_error_t Out;
+ register mig_reply_error_t *OutP = &Out;
+ kern_return_t kr;
+ mach_msg_return_t mr;
+ unsigned int msgh_size;
- kern_return_t kr;
- mach_msg_return_t mr;
- unsigned int msgh_size;
+ mach_port_t sendPort;
+ mach_msg_type_name_t sendType;
/*
* allocate reply port
*/
- kr = mach_port_allocate(mach_task_self(),
- MACH_PORT_RIGHT_RECEIVE,
- &request->replyPort);
- if (kr != KERN_SUCCESS) {
+ kr = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &request->replyPort);
+ if (kr != KERN_SUCCESS)
+ {
*error = NO_RECOVERY;
return FALSE;
}
- kr = mach_port_insert_right(mach_task_self(),
- request->replyPort,
- request->replyPort,
- MACH_MSG_TYPE_MAKE_SEND);
- if (kr != KERN_SUCCESS) {
- (void) mach_port_destroy(mach_task_self(), request->replyPort);
+ kr = mach_port_extract_right(mach_task_self(), request->replyPort, MACH_MSG_TYPE_MAKE_SEND_ONCE, &sendPort, &sendType);
+ if (kr != KERN_SUCCESS)
+ {
+ (void)mach_port_destroy(mach_task_self(), request->replyPort);
+ request->replyPort = MACH_PORT_NULL;
*error = NO_RECOVERY;
return FALSE;
}
* queue reply message
*/
msgh_size = sizeof(Out);
- OutP->Head.msgh_bits = MACH_MSGH_BITS(19, 0);
-/* OutP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */
- OutP->Head.msgh_request_port = request->replyPort;
- OutP->Head.msgh_reply_port = MACH_PORT_NULL;
- OutP->Head.msgh_id = 4241776 + 100;
- OutP->RetCode = MIG_REMOTE_ERROR;
- OutP->NDR = NDR_record;
-
- mr = mach_msg(&OutP->Head, /* msg */
- MACH_SEND_MSG, /* options */
- msgh_size, /* send_size */
- 0, /* rcv_size */
- MACH_PORT_NULL, /* rcv_name */
- MACH_MSG_TIMEOUT_NONE, /* timeout */
- MACH_PORT_NULL); /* notify */
- if (mr != MACH_MSG_SUCCESS) {
- if (mr == MACH_SEND_INVALID_REPLY) {
+ OutP->Head.msgh_bits = MACH_MSGH_BITS(MACH_MSG_TYPE_MOVE_SEND_ONCE, 0);
+// OutP->Head.msgh_size = msgh_size; /* msgh_size passed as argument */
+ OutP->Head.msgh_request_port = sendPort;
+ OutP->Head.msgh_reply_port = MACH_PORT_NULL;
+ OutP->Head.msgh_id = 4241776 + 100;
+ OutP->RetCode = MIG_REMOTE_ERROR;
+ OutP->NDR = NDR_record;
+
+ mr = mach_msg(&OutP->Head, MACH_SEND_MSG, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+ if (mr != MACH_MSG_SUCCESS)
+ {
+ if (mr == MACH_SEND_INVALID_REPLY)
+ {
(void)mach_port_destroy(mach_task_self(), request->replyPort);
+ request->replyPort = MACH_PORT_NULL;
}
+
*error = NO_RECOVERY;
return FALSE;
}
return TRUE;
}
+static void
+_async_cancel(mach_port_t port)
+{
+ a_requests_t *request;
-mach_port_t
-_gethostbyaddr_async_start(const char *addr,
- int len,
- int type,
- a_request_callout_t callout,
- void *context,
- int *error)
+ request = request_extract(port);
+ if (request)
+ {
+ (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
+ if (request->request.data) free(request->request.data);
+ if (request->hent) freehostent(request->hent);
+ free(request);
+ }
+
+ return;
+}
+
+static mach_port_t
+_gethostbyaddr_async_start(const char *addr, int len, int type, a_request_callout_t callout, void *context, int *error)
{
- void *address;
- int proc;
- a_requests_t *request;
- int want;
+ void *address;
+ int proc;
+ a_requests_t *request;
+ int want;
+ static int proc4 = -1;
+ struct in_addr *v4addr;
+ static int proc6 = -1;
+ struct in6_addr *v6addr;
+
+ want = WANT_A4_ONLY;
+ if (type == AF_INET6) want = WANT_A6_ONLY;
+
+ if ((type == AF_INET6) && (len == 16) && (is_a4_mapped((const char *)addr) || is_a4_compat((const char *)addr)))
+ {
+ addr += 12;
+ len = 4;
+ type = AF_INET;
+ want = WANT_MAPPED_A4_ONLY;
+ }
- switch (type) {
- case AF_INET :
+ switch (type)
+ {
+ case AF_INET:
{
- static int proc4 = -1;
- struct in_addr *v4addr;
-
- if (proc4 < 0) {
- if (_lookup_link(_lu_port, "gethostbyaddr", &proc4) != KERN_SUCCESS) {
+ if (proc4 < 0)
+ {
+ if (_lookup_link(_lu_port, "gethostbyaddr", &proc4) != KERN_SUCCESS)
+ {
*error = NO_RECOVERY;
return MACH_PORT_NULL;
}
}
- if (len != sizeof(struct in_addr)) {
+ if (len != sizeof(struct in_addr))
+ {
*error = NO_RECOVERY;
return NULL;
}
v4addr->s_addr = htonl(v4addr->s_addr);
address = (void *)v4addr;
- proc = proc4;
- want = WANT_A4_ONLY;
+ proc = proc4;
break;
}
- case AF_INET6 :
+ case AF_INET6:
{
- static int proc6 = -1;
- struct in6_addr *v6addr;
-
- if (proc6 < 0) {
- if (_lookup_link(_lu_port, "getipv6nodebyaddr", &proc6) != KERN_SUCCESS) {
+ if (proc6 < 0)
+ {
+ if (_lookup_link(_lu_port, "getipv6nodebyaddr", &proc6) != KERN_SUCCESS)
+ {
*error = NO_RECOVERY;
return MACH_PORT_NULL;
}
}
- if (len != sizeof(struct in6_addr)) {
+ if (len != sizeof(struct in6_addr))
+ {
*error = NO_RECOVERY;
return NULL;
}
v6addr->__u6_addr.__u6_addr32[3] = htonl(v6addr->__u6_addr.__u6_addr32[3]);
address = (void *)v6addr;
- proc = proc6;
- want = WANT_A6_ONLY;
+ proc = proc6;
break;
}
- default:
+ default:
*error = NO_RECOVERY;
return MACH_PORT_NULL;
}
request = malloc(sizeof(a_requests_t));
- request->next = NULL;
- request->retry = MAX_LOOKUP_ATTEMPTS;
- request->request.proc = proc;
- request->request.data = (ooline_data)address;
+ request->next = NULL;
+ request->retry = MAX_LOOKUP_ATTEMPTS;
+ request->request.proc = proc;
+ request->request.data = (ooline_data)address;
request->request.dataLen = len / BYTES_PER_XDR_UNIT;
- request->request.want = want;
- request->replyPort = MACH_PORT_NULL;
- request->callout = callout;
- request->context = context;
- request->hent = NULL;
+ request->request.want = want;
+ request->replyPort = MACH_PORT_NULL;
+ request->callout = callout;
+ request->context = context;
+ request->hent = NULL;
/*
* allocate reply port, send query to lookupd
*/
- if (_lookup_all_tx(_lu_port,
- request->request.proc,
- request->request.data,
- request->request.dataLen,
- &request->replyPort) == KERN_SUCCESS) {
+ if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS)
+ {
request_queue(request);
- } else {
+ }
+ else
+ {
if (request->request.data) free(request->request.data);
free(request);
*error = NO_RECOVERY;
return request->replyPort;
}
-
-boolean_t
-_gethostbyaddr_async_handleReply(void *replyMsg,
- a_requests_t **requestP,
- struct hostent **he,
- int *error)
+static boolean_t
+_gethostbyaddr_async_handleReply(void *replyMsg, a_requests_t **requestP, struct hostent **he, int *error)
{
- int count;
- ooline_data data;
- unsigned int datalen;
- XDR inxdr;
- mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg;
- a_requests_t *request;
- kern_return_t status;
- security_token_t token;
+ int count;
+ ooline_data data;
+ unsigned int datalen;
+ XDR inxdr;
+ mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg;
+ a_requests_t *request;
+ kern_return_t status;
+ security_token_t token;
request = request_extract(msg->msgh_local_port);
- if (!request) {
+ if (!request)
+ {
/* excuse me, what happenned to the request info? */
return FALSE;
}
*requestP = request;
- *he = NULL;
- *error = 0;
+ *he = NULL;
+ *error = 0;
/* unpack the reply */
status = _lookup_all_rx(replyMsg, &data, &datalen, &token);
- switch (status) {
- case KERN_SUCCESS :
+ switch (status)
+ {
+ case KERN_SUCCESS:
break;
- case MIG_SERVER_DIED :
- if (--request->retry > 0) {
+ case MIG_SERVER_DIED:
+ if (--request->retry > 0)
+ {
/* retry the request */
- if (_lookup_all_tx(_lu_port,
- request->request.proc,
- request->request.data,
- request->request.dataLen,
- &request->replyPort) == KERN_SUCCESS) {
+ if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS)
+ {
request_queue(request);
return FALSE;
}
}
/* fall through */
- default :
+ default:
*error = HOST_NOT_FOUND;
return TRUE;
}
datalen *= BYTES_PER_XDR_UNIT;
- if (token.val[0] != 0) {
+ if (token.val[0] != 0)
+ {
vm_deallocate(mach_task_self(), (vm_address_t)data, datalen);
*error = NO_RECOVERY;
return TRUE;
xdrmem_create(&inxdr, data, datalen, XDR_DECODE);
count = 0;
- if (!xdr_int(&inxdr, &count)) {
+ if (!xdr_int(&inxdr, &count))
+ {
xdr_destroy(&inxdr);
vm_deallocate(mach_task_self(), (vm_address_t)data, datalen);
*error = NO_RECOVERY;
return TRUE;
}
- if (count == 0) {
+ if (count == 0)
+ {
xdr_destroy(&inxdr);
vm_deallocate(mach_task_self(), (vm_address_t)data, datalen);
*error = HOST_NOT_FOUND;
- *he = NULL;
+ *he = NULL;
return TRUE;
}
return TRUE;
}
-
mach_port_t
-gethostbyaddr_async_start(const char *addr,
- int len,
- int type,
- gethostbyaddr_async_callback callout,
- void *context)
+gethostbyaddr_async_start(const char *addr, int len, int type, gethostbyaddr_async_callback callout, void *context)
{
- a_request_callout_t cb;
- mach_port_t mp;
+ a_request_callout_t cb;
+ mach_port_t mp;
- if (!_lu_running()) {
+ if (!_lu_running())
+ {
h_errno = NO_RECOVERY;
return MACH_PORT_NULL;
}
return mp;
}
+void
+gethostbyaddr_async_cancel(mach_port_t port)
+{
+ _async_cancel(port);
+ return;
+}
void
gethostbyaddr_async_handleReply(void *replyMsg)
{
- int error = 0;
- struct hostent *he = NULL;
- a_requests_t *request = NULL;
+ int error = 0;
+ struct hostent *he = NULL;
+ a_requests_t *request = NULL;
- if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error)) {
+ if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error))
+ {
/* if we have an answer to provide */
h_errno = error;
(request->callout.hostAddr)(he, request->context);
- (void)mach_port_destroy(mach_task_self(), request->replyPort);
+ (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
if (request->request.data) free(request->request.data);
free(request);
- if (he) freehostent(he);
+ if (he != NULL) freehostent(he);
}
return;
}
-
mach_port_t
-getipnodebyaddr_async_start(const void *addr,
- size_t len,
- int af,
- int *error,
- getipnodebyaddr_async_callback callout,
- void *context)
+getipnodebyaddr_async_start(const void *addr, size_t len, int af, int *error, getipnodebyaddr_async_callback callout, void *context)
{
- a_request_callout_t cb;
- mach_port_t mp;
+ a_request_callout_t cb;
+ mach_port_t mp;
- if (!_lu_running()) {
+ if (!_lu_running())
+ {
*error = NO_RECOVERY;
return MACH_PORT_NULL;
}
- if ((af == AF_INET6) &&
- (len == sizeof(struct in6_addr)) &&
- (is_a4_mapped((const char *)addr) || is_a4_compat((const char *)addr))) {
- /*
- * this is really a v4 address
- */
- addr += sizeof(struct in6_addr) - sizeof(struct in_addr);
- len = sizeof(struct in_addr);
- af = AF_INET;
- }
-
cb.nodeAddr = callout;
mp = _gethostbyaddr_async_start(addr, len, af, cb, context, error);
return mp;
}
+void
+getipnodebyaddr_async_cancel(mach_port_t port)
+{
+ _async_cancel(port);
+ return;
+}
void
getipnodebyaddr_async_handleReply(void *replyMsg)
{
- int error = 0;
- struct hostent *he = NULL;
- a_requests_t *request = NULL;
+ int error = 0;
+ struct hostent *he = NULL;
+ a_requests_t *request = NULL;
- if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error)) {
+ if (_gethostbyaddr_async_handleReply(replyMsg, &request, &he, &error))
+ {
/* if we have an answer to provide */
(request->callout.nodeAddr)(he, error, request->context);
- (void)mach_port_destroy(mach_task_self(), request->replyPort);
+ (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
if (request->request.data) free(request->request.data);
free(request);
/*
* Note: it is up to the callback function to call
- * freehostent().
+ * freehostent().
*/
}
return;
}
-
-mach_port_t
-_gethostbyname_async_start(const char *name,
- int want,
- int *error,
- a_request_callout_t callout,
- void *context)
+static mach_port_t
+_gethostbyname_async_start(const char *name, int want, int *error, a_request_callout_t callout, void *context)
{
- int af;
- boolean_t is_addr = FALSE;
- mach_port_t mp = MACH_PORT_NULL;
- XDR outxdr;
- static int proc;
- a_requests_t *request;
-
- if ((name == NULL) || (name[0] == '\0')) {
+ int af;
+ boolean_t is_addr = FALSE;
+ mach_port_t mp = MACH_PORT_NULL;
+ XDR outxdr;
+ static int proc;
+ a_requests_t *request;
+ static int proc4 = -1;
+ static int proc6 = -1;
+ struct in_addr v4addr;
+ struct in6_addr v6addr;
+
+ if ((name == NULL) || (name[0] == '\0'))
+ {
*error = NO_DATA;
return MACH_PORT_NULL;
}
- af = (want == WANT_A4_ONLY) ? AF_INET : AF_INET6;
-
- if ((af == AF_INET) || (want == WANT_MAPPED_A4_ONLY)) {
- static int proc4 = -1;
+ af = (want == WANT_A4_ONLY) ? AF_INET: AF_INET6;
- if (proc4 < 0) {
- if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS) {
+ if ((af == AF_INET) || (want == WANT_MAPPED_A4_ONLY))
+ {
+ if (proc4 < 0)
+ {
+ if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS)
+ {
*error = NO_RECOVERY;
return MACH_PORT_NULL;
}
}
proc = proc4;
- } else /* if (af == AF_INET6) */ {
- static int proc6 = -1;
-
- if (proc6 < 0) {
+ }
+ else /* if (af == AF_INET6) */
+ {
+ if (proc6 < 0)
+ {
if (_lookup_link(_lu_port, "getipv6nodebyname", &proc6) != KERN_SUCCESS)
{
*error = NO_RECOVERY;
}
request = malloc(sizeof(a_requests_t));
- request->next = NULL;
- request->retry = MAX_LOOKUP_ATTEMPTS;
- request->request.proc = proc;
- request->request.data = NULL;
+ request->next = NULL;
+ request->retry = MAX_LOOKUP_ATTEMPTS;
+ request->request.proc = proc;
+ request->request.data = NULL;
request->request.dataLen = 0;
- request->request.want = want;
- request->replyPort = MACH_PORT_NULL;
- request->callout = callout;
- request->context = context;
- request->hent = NULL;
-
- switch (af) {
- case AF_INET :
+ request->request.want = want;
+ request->replyPort = MACH_PORT_NULL;
+ request->callout = callout;
+ request->context = context;
+ request->hent = NULL;
+
+ switch (af)
+ {
+ case AF_INET:
{
- struct in_addr v4addr;
-
memset(&v4addr, 0, sizeof(struct in_addr));
- if (inet_aton(name, &v4addr) == 1) {
+ if (inet_aton(name, &v4addr) == 1)
+ {
/* return a fake hostent */
request->hent = fake_hostent(name, v4addr);
is_addr = TRUE;
break;
}
- case AF_INET6 :
+ case AF_INET6:
{
- struct in_addr v4addr;
- struct in6_addr v6addr;
-
memset(&v6addr, 0, sizeof(struct in6_addr));
- if (inet_pton(af, name, &v6addr) == 1) {
+ if (inet_pton(af, name, &v6addr) == 1)
+ {
/* return a fake hostent */
request->hent = fake_hostent6(name, v6addr);
is_addr = TRUE;
}
memset(&v4addr, 0, sizeof(struct in_addr));
- if (inet_aton(name, &v4addr) == 1) {
- if (want == WANT_A4_ONLY) {
+ if (inet_aton(name, &v4addr) == 1)
+ {
+ if (want == WANT_A4_ONLY)
+ {
free(request);
*error = HOST_NOT_FOUND;
return MACH_PORT_NULL;
break;
}
- default:
+ default:
free(request);
*error = NO_RECOVERY;
return MACH_PORT_NULL;
}
- if (is_addr) {
+ if (is_addr)
+ {
/*
* queue reply message
*/
- if (sendCannedReply(request, error)) {
+ if (sendCannedReply(request, error))
+ {
request_queue(request);
return request->replyPort;
- } else {
+ }
+ else
+ {
freehostent(request->hent);
free(request);
return MACH_PORT_NULL;
}
request->request.dataLen = _LU_MAXLUSTRLEN + BYTES_PER_XDR_UNIT;
- request->request.data = malloc(request->request.dataLen);
+ request->request.data = malloc(request->request.dataLen);
xdrmem_create(&outxdr, request->request.data, request->request.dataLen, XDR_ENCODE);
- if (!xdr__lu_string(&outxdr, (_lu_string *)&name)) {
+ if (!xdr__lu_string(&outxdr, (_lu_string *)&name))
+ {
xdr_destroy(&outxdr);
free(request->request.data);
free(request);
/*
* allocate reply port, send query to lookupd
*/
- if (_lookup_all_tx(_lu_port,
- request->request.proc,
- request->request.data,
- request->request.dataLen,
- &request->replyPort) == KERN_SUCCESS) {
+ if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS)
+ {
request_queue(request);
mp = request->replyPort;
- } else {
+ }
+ else
+ {
free(request->request.data);
free(request);
*error = NO_RECOVERY;
return mp;
}
-
-boolean_t
-_gethostbyname_async_handleReply(void *replyMsg,
- a_requests_t **requestP,
- struct hostent **he,
- int *error)
+static boolean_t
+_gethostbyname_async_handleReply(void *replyMsg, a_requests_t **requestP, struct hostent **he, int *error)
{
-
- int count;
- unsigned int datalen;
- XDR inxdr;
- ooline_data data;
- mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg;
- a_requests_t *request;
- kern_return_t status;
- security_token_t token;
- int want;
+ int count;
+ unsigned int datalen;
+ XDR inxdr;
+ ooline_data data;
+ mach_msg_header_t *msg = (mach_msg_header_t *)replyMsg;
+ a_requests_t *request;
+ kern_return_t status;
+ security_token_t token;
+ int want;
request = request_extract(msg->msgh_local_port);
- if (!request) {
+ if (!request)
+ {
/* excuse me, what happenned to the request info? */
return FALSE;
}
*requestP = request;
- *he = NULL;
- *error = 0;
+ *he = NULL;
+ *error = 0;
- if (request->hent) {
+ if (request->hent)
+ {
/*
* if the reply was already available when the
* request was made
/* unpack the reply */
status = _lookup_all_rx(replyMsg, &data, &datalen, &token);
- switch (status) {
- case KERN_SUCCESS :
+ switch (status)
+ {
+ case KERN_SUCCESS:
break;
- case MIG_SERVER_DIED :
- if (--request->retry > 0) {
+ case MIG_SERVER_DIED:
+ if (--request->retry > 0)
+ {
/*
* retry the request
*/
- if (_lookup_all_tx(_lu_port,
- request->request.proc,
- request->request.data,
- request->request.dataLen,
- &request->replyPort) == KERN_SUCCESS) {
+ if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS)
+ {
request_queue(request);
return FALSE;
}
}
/* fall through */
- default :
+ default:
*error = HOST_NOT_FOUND;
return TRUE;
}
datalen *= BYTES_PER_XDR_UNIT;
- if (token.val[0] != 0) {
+ if (token.val[0] != 0)
+ {
vm_deallocate(mach_task_self(), (vm_address_t)data, datalen);
*error = NO_RECOVERY;
return TRUE;
xdrmem_create(&inxdr, data, datalen, XDR_DECODE);
count = 0;
- if (!xdr_int(&inxdr, &count)) {
+ if (!xdr_int(&inxdr, &count))
+ {
xdr_destroy(&inxdr);
vm_deallocate(mach_task_self(), (vm_address_t)data, datalen);
*error = NO_RECOVERY;
return TRUE;
}
- if (count == 0) {
+ if (count == 0)
+ {
xdr_destroy(&inxdr);
vm_deallocate(mach_task_self(), (vm_address_t)data, datalen);
*error = HOST_NOT_FOUND;
return TRUE;
}
-
mach_port_t
-gethostbyname_async_start(const char *name,
- gethostbyname_async_callback callout,
- void *context)
+gethostbyname_async_start(const char *name, gethostbyname_async_callback callout, void *context)
{
- a_request_callout_t cb;
- int error;
- mach_port_t mp = MACH_PORT_NULL;
+ a_request_callout_t cb;
+ int error;
+ mach_port_t mp = MACH_PORT_NULL;
- if (!_lu_running()) {
+ if (!_lu_running())
+ {
h_errno = NO_RECOVERY;
return MACH_PORT_NULL;
}
cb.hostName = callout;
mp = _gethostbyname_async_start(name, WANT_A4_ONLY, &error, cb, context);
- if (!mp) {
+ if (mp == MACH_PORT_NULL)
+ {
h_errno = error;
}
+
return mp;
}
+void
+gethostbyname_async_cancel(mach_port_t port)
+{
+ _async_cancel(port);
+ return;
+}
void
gethostbyname_async_handleReply(void *replyMsg)
{
- int error;
- struct hostent *he;
- a_requests_t *request;
+ int error;
+ struct hostent *he;
+ a_requests_t *request;
- if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error)) {
+ if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error))
+ {
/* if we have an answer to provide */
h_errno = error;
(request->callout.hostAddr)(he, request->context);
- (void)mach_port_destroy(mach_task_self(), request->replyPort);
+ (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
if (request->request.data) free(request->request.data);
free(request);
- if (he) freehostent(he);
+ if (he != NULL) freehostent(he);
}
return;
}
-
mach_port_t
-getipnodebyname_async_start(const char *name,
- int af,
- int flags,
- int *error,
- getipnodebyname_async_callback callout,
- void *context)
+getipnodebyname_async_start(const char *name, int af, int flags, int *error, getipnodebyname_async_callback callout, void *context)
{
- a_request_callout_t cb;
- int if4 = 0;
- int if6 = 0;
- mach_port_t mp = MACH_PORT_NULL;
- int want = WANT_A4_ONLY;
-
- if (!_lu_running()) {
+ a_request_callout_t cb;
+ int if4 = 0;
+ int if6 = 0;
+ mach_port_t mp = MACH_PORT_NULL;
+ int want = WANT_A4_ONLY;
+ struct ifaddrs *ifa, *ifap;
+
+ if (!_lu_running())
+ {
h_errno = NO_RECOVERY;
return MACH_PORT_NULL;
}
/*
* IF AI_ADDRCONFIG is set, we need to know what interface flavors we really have.
*/
- if (flags & AI_ADDRCONFIG) {
- struct ifaddrs *ifa, *ifap;
-
- if (getifaddrs(&ifa) < 0) {
+ if (flags & AI_ADDRCONFIG)
+ {
+ if (getifaddrs(&ifa) < 0)
+ {
*error = NO_RECOVERY;
return MACH_PORT_NULL;
}
- for (ifap = ifa; ifap != NULL; ifap = ifap->ifa_next) {
- if (ifap->ifa_addr == NULL)
- continue;
- if ((ifap->ifa_flags & IFF_UP) == 0)
- continue;
- if (ifap->ifa_addr->sa_family == AF_INET) {
+ for (ifap = ifa; ifap != NULL; ifap = ifap->ifa_next)
+ {
+ if (ifap->ifa_addr == NULL) continue;
+ if ((ifap->ifa_flags & IFF_UP) == 0) continue;
+ if (ifap->ifa_addr->sa_family == AF_INET)
+ {
if4++;
- } else if (ifap->ifa_addr->sa_family == AF_INET6) {
+ }
+ else if (ifap->ifa_addr->sa_family == AF_INET6)
+ {
if6++;
}
}
freeifaddrs(ifa);
/* Bail out if there are no interfaces */
- if ((if4 == 0) && (if6 == 0)) {
+ if ((if4 == 0) && (if6 == 0))
+ {
*error = NO_ADDRESS;
return MACH_PORT_NULL;
}
* Figure out what we want.
* If user asked for AF_INET, we only want V4 addresses.
*/
- switch (af) {
- case AF_INET :
+ switch (af)
+ {
+ case AF_INET:
{
want = WANT_A4_ONLY;
- if ((flags & AI_ADDRCONFIG) && (if4 == 0)) {
+ if ((flags & AI_ADDRCONFIG) && (if4 == 0))
+ {
*error = NO_ADDRESS;
return MACH_PORT_NULL;
}
}
break;
- case AF_INET6 :
+
+ case AF_INET6:
{
want = WANT_A6_ONLY;
- if (flags & (AI_V4MAPPED|AI_V4MAPPED_CFG)) {
- if (flags & AI_ALL) {
+ if (flags & (AI_V4MAPPED|AI_V4MAPPED_CFG))
+ {
+ if (flags & AI_ALL)
+ {
want = WANT_A6_PLUS_MAPPED_A4;
- } else {
+ }
+ else
+ {
want = WANT_A6_OR_MAPPED_A4_IF_NO_A6;
}
- } else {
- if ((flags & AI_ADDRCONFIG) && (if6 == 0)) {
+ }
+ else
+ {
+ if ((flags & AI_ADDRCONFIG) && (if6 == 0))
+ {
*error = NO_ADDRESS;
return MACH_PORT_NULL;
}
return mp;
}
+void
+getipnodebyname_async_cancel(mach_port_t port)
+{
+ _async_cancel(port);
+ return;
+}
void
getipnodebyname_async_handleReply(void *replyMsg)
{
- int error = 0;
- struct hostent *he = NULL;
- a_requests_t *request = NULL;
+ int error = 0;
+ struct hostent *he = NULL;
+ a_requests_t *request = NULL;
+ static int proc4 = -1;
- if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error)) {
+ if (_gethostbyname_async_handleReply(replyMsg, &request, &he, &error))
+ {
/*
* we have an answer to provide
*/
- if ((he == NULL) &&
- (error == HOST_NOT_FOUND) &&
- ((request->request.want == WANT_A6_PLUS_MAPPED_A4) ||
- (request->request.want == WANT_A6_OR_MAPPED_A4_IF_NO_A6))) {
+ if ((he == NULL) && (error == HOST_NOT_FOUND) && ((request->request.want == WANT_A6_PLUS_MAPPED_A4) || (request->request.want == WANT_A6_OR_MAPPED_A4_IF_NO_A6)))
+ {
/*
* no host found (yet), if requested we send a
* followup query to lookupd.
*/
- static int proc4 = -1;
-
- if (proc4 < 0) {
- if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS) {
+ if (proc4 < 0)
+ {
+ if (_lookup_link(_lu_port, "gethostbyname", &proc4) != KERN_SUCCESS)
+ {
error = NO_RECOVERY;
goto answer;
}
request->request.proc = proc4;
request->request.want = WANT_MAPPED_A4_ONLY;
- if (_lookup_all_tx(_lu_port,
- request->request.proc,
- request->request.data,
- request->request.dataLen,
- &request->replyPort) == KERN_SUCCESS) {
+ if (_lookup_all_tx(_lu_port, request->request.proc, request->request.data, request->request.dataLen, &request->replyPort) == KERN_SUCCESS)
+ {
request_queue(request);
return;
- } else {
+ }
+ else
+ {
error = NO_RECOVERY;
}
}
- answer :
+answer:
(request->callout.nodeName)(he, error, request->context);
- (void)mach_port_destroy(mach_task_self(), request->replyPort);
- if (request->request.data) free(request->request.data);
+ (void)mach_port_mod_refs(mach_task_self(), request->replyPort, MACH_PORT_RIGHT_RECEIVE, -1);
+ if (request->request.data != NULL) free(request->request.data);
free(request);
/*
* Note: it is up to the callback function to call
- * freehostent().
+ * freehostent().
*/
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
{
struct lu_thread_info *tdata;
- tdata = _lu_data_create_key(_lu_data_key_service, free_lu_thread_info_protocol);
+ tdata = _lu_data_create_key(_lu_data_key_protocol, free_lu_thread_info_protocol);
_lu_data_free_vm_xdr(tdata);
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include "lookup.h"
#include "lu_utils.h"
+#define SERVICE_CACHE_SIZE 10
+#define DEFAULT_SERVICE_CACHE_TTL 10
+
+static pthread_mutex_t _service_cache_lock = PTHREAD_MUTEX_INITIALIZER;
+static void *_service_cache[SERVICE_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+static unsigned int _service_cache_best_before[SERVICE_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static unsigned int _service_cache_index = 0;
+static unsigned int _service_cache_ttl = DEFAULT_SERVICE_CACHE_TTL;
+
static pthread_mutex_t _service_lock = PTHREAD_MUTEX_INITIALIZER;
#define S_GET_NAME 1
free(in);
}
+__private_extern__ unsigned int
+get_service_cache_ttl()
+{
+ return _service_cache_ttl;
+}
+
+__private_extern__ void
+set_service_cache_ttl(unsigned int ttl)
+{
+ int i;
+
+ pthread_mutex_lock(&_service_cache_lock);
+
+ _service_cache_ttl = ttl;
+
+ if (ttl == 0)
+ {
+ for (i = 0; i < SERVICE_CACHE_SIZE; i++)
+ {
+ if (_service_cache[i] == NULL) continue;
+
+ free_service((struct servent *)_service_cache[i]);
+ _service_cache[i] = NULL;
+ _service_cache_best_before[i] = 0;
+ }
+ }
+
+ pthread_mutex_unlock(&_service_cache_lock);
+}
+
+static void
+cache_service(struct servent *s)
+{
+ struct timeval now;
+ struct servent *scache;
+
+ if (_service_cache_ttl == 0) return;
+ if (s == NULL) return;
+
+ pthread_mutex_lock(&_service_cache_lock);
+
+ scache = copy_service(s);
+
+ gettimeofday(&now, NULL);
+
+ if (_service_cache[_service_cache_index] != NULL)
+ free_service((struct servent *)_service_cache[_service_cache_index]);
+
+ _service_cache[_service_cache_index] = scache;
+ _service_cache_best_before[_service_cache_index] = now.tv_sec + _service_cache_ttl;
+ _service_cache_index = (_service_cache_index + 1) % SERVICE_CACHE_SIZE;
+
+ pthread_mutex_unlock(&_service_cache_lock);
+}
+
+static struct servent *
+cache_getservbyname(const char *name, const char *proto)
+{
+ int i;
+ struct servent *s, *res;
+ struct timeval now;
+ char **aliases;
+
+ if (_service_cache_ttl == 0) return NULL;
+ if (name == NULL) return NULL;
+
+ pthread_mutex_lock(&_service_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ for (i = 0; i < SERVICE_CACHE_SIZE; i++)
+ {
+ if (_service_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _service_cache_best_before[i]) continue;
+
+ s = (struct servent *)_service_cache[i];
+
+ if (s->s_name != NULL)
+ {
+ if (!strcmp(name, s->s_name))
+ {
+ if ((proto == NULL) || ((s->s_proto != NULL) && (!strcmp(proto, s->s_proto))))
+ {
+ res = copy_service(s);
+ pthread_mutex_unlock(&_service_cache_lock);
+ return res;
+ }
+ }
+ }
+
+ aliases = s->s_aliases;
+ if (aliases == NULL)
+ {
+ pthread_mutex_unlock(&_service_cache_lock);
+ return NULL;
+ }
+
+ for (; *aliases != NULL; *aliases++)
+ {
+ if (!strcmp(name, *aliases))
+ {
+ if ((proto == NULL) || ((s->s_proto != NULL) && (!strcmp(proto, s->s_proto))))
+ {
+ res = copy_service(s);
+ pthread_mutex_unlock(&_service_cache_lock);
+ return res;
+ }
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&_service_cache_lock);
+ return NULL;
+}
+
+static struct servent *
+cache_getservbyport(int port, const char *proto)
+{
+ int i;
+ struct servent *s, *res;
+ struct timeval now;
+
+ if (_service_cache_ttl == 0) return NULL;
+
+ pthread_mutex_lock(&_service_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ for (i = 0; i < SERVICE_CACHE_SIZE; i++)
+ {
+ if (_service_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _service_cache_best_before[i]) continue;
+
+ s = (struct servent *)_service_cache[i];
+
+ if (port == s->s_port)
+ {
+ if ((proto == NULL) || ((s->s_proto != NULL) && (!strcmp(proto, s->s_proto))))
+ {
+ res = copy_service(s);
+ pthread_mutex_unlock(&_service_cache_lock);
+ return res;
+ }
+ }
+ }
+
+ pthread_mutex_unlock(&_service_cache_lock);
+ return NULL;
+}
+
static struct servent *
lu_getservbyport(int port, const char *proto)
{
tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info));
_lu_data_set_key(_lu_data_key_service, tdata);
}
-\r
+
if (tdata->lu_vm == NULL)
{
if (proc < 0)
{
struct servent *res = NULL;
struct lu_thread_info *tdata;
+ int from_cache;
tdata = _lu_data_create_key(_lu_data_key_service, free_lu_thread_info_service);
if (tdata == NULL)
_lu_data_set_key(_lu_data_key_service, tdata);
}
- if (_lu_running())
+ from_cache = 0;
+ res = NULL;
+
+ switch (source)
+ {
+ case S_GET_NAME:
+ res = cache_getservbyname(name, proto);
+ break;
+ case S_GET_PORT:
+ res = cache_getservbyport(port, proto);
+ break;
+ default: res = NULL;
+ }
+
+ if (res != NULL)
+ {
+ from_cache = 1;
+ }
+ else if (_lu_running())
{
switch (source)
{
pthread_mutex_unlock(&_service_lock);
}
+ if (from_cache == 0) cache_service(res);
+
recycle_service(tdata, res);
return (struct servent *)tdata->lu_entry;
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include "lu_utils.h"
#include "lu_overrides.h"
+#define USER_CACHE_SIZE 10
+#define DEFAULT_USER_CACHE_TTL 10
+
+static pthread_mutex_t _user_cache_lock = PTHREAD_MUTEX_INITIALIZER;
+static void *_user_cache[USER_CACHE_SIZE] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
+static unsigned int _user_cache_best_before[USER_CACHE_SIZE] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static unsigned int _user_cache_index = 0;
+static unsigned int _user_cache_ttl = DEFAULT_USER_CACHE_TTL;
+
static pthread_mutex_t _user_lock = PTHREAD_MUTEX_INITIALIZER;
#define PW_GET_NAME 1
p->pw_shell = vals[0];
j = 1;
}
- else if ((p->pw_uid == -2) && (!strcmp("uid", key)))
+ else if ((p->pw_uid == (uid_t)-2) && (!strcmp("uid", key)))
{
p->pw_uid = atoi(vals[0]);
+ if ((p->pw_uid == 0) && (strcmp(vals[0], "0"))) p->pw_uid = -2;
}
- else if ((p->pw_gid == -2) && (!strcmp("gid", key)))
+ else if ((p->pw_gid == (gid_t)-2) && (!strcmp("gid", key)))
{
p->pw_gid = atoi(vals[0]);
+ if ((p->pw_gid == 0) && (strcmp(vals[0], "0"))) p->pw_gid = -2;
}
else if (!strcmp("change", key))
{
free(in);
}
+__private_extern__ unsigned int
+get_user_cache_ttl()
+{
+ return _user_cache_ttl;
+}
+
+__private_extern__ void
+set_user_cache_ttl(unsigned int ttl)
+{
+ int i;
+
+ pthread_mutex_lock(&_user_cache_lock);
+
+ _user_cache_ttl = ttl;
+
+ if (ttl == 0)
+ {
+ for (i = 0; i < USER_CACHE_SIZE; i++)
+ {
+ if (_user_cache[i] == NULL) continue;
+
+ free_user((struct passwd *)_user_cache[i]);
+ _user_cache[i] = NULL;
+ _user_cache_best_before[i] = 0;
+ }
+ }
+
+ pthread_mutex_unlock(&_user_cache_lock);
+}
+
+static void
+cache_user(struct passwd *pw)
+{
+ struct timeval now;
+ struct passwd *pwcache;
+
+ if (_user_cache_ttl == 0) return;
+ if (pw == NULL) return;
+
+ pthread_mutex_lock(&_user_cache_lock);
+
+ pwcache = copy_user(pw);
+
+ gettimeofday(&now, NULL);
+
+ if (_user_cache[_user_cache_index] != NULL)
+ free_user((struct passwd *)_user_cache[_user_cache_index]);
+
+ _user_cache[_user_cache_index] = pwcache;
+ _user_cache_best_before[_user_cache_index] = now.tv_sec + _user_cache_ttl;
+ _user_cache_index = (_user_cache_index + 1) % USER_CACHE_SIZE;
+
+ pthread_mutex_unlock(&_user_cache_lock);
+}
+
+static struct passwd *
+cache_getpwnam(const char *name)
+{
+ int i;
+ struct passwd *pw, *res;
+ struct timeval now;
+
+ if (_user_cache_ttl == 0) return NULL;
+ if (name == NULL) return NULL;
+
+ pthread_mutex_lock(&_user_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ for (i = 0; i < USER_CACHE_SIZE; i++)
+ {
+ if (_user_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _user_cache_best_before[i]) continue;
+
+ pw = (struct passwd *)_user_cache[i];
+
+ if (pw->pw_name == NULL) continue;
+
+ if (!strcmp(name, pw->pw_name))
+ {
+ res = copy_user(pw);
+ pthread_mutex_unlock(&_user_cache_lock);
+ return res;
+ }
+ }
+
+ pthread_mutex_unlock(&_user_cache_lock);
+ return NULL;
+}
+
+static struct passwd *
+cache_getpwuid(int uid)
+{
+ int i;
+ struct passwd *pw, *res;
+ struct timeval now;
+
+ if (_user_cache_ttl == 0) return NULL;
+
+ pthread_mutex_lock(&_user_cache_lock);
+
+ gettimeofday(&now, NULL);
+
+ for (i = 0; i < USER_CACHE_SIZE; i++)
+ {
+ if (_user_cache_best_before[i] == 0) continue;
+ if ((unsigned int)now.tv_sec > _user_cache_best_before[i]) continue;
+
+ pw = (struct passwd *)_user_cache[i];
+
+ if ((uid_t)uid == pw->pw_uid)
+ {
+ res = copy_user(pw);
+ pthread_mutex_unlock(&_user_cache_lock);
+ return res;
+ }
+ }
+
+ pthread_mutex_unlock(&_user_cache_lock);
+ return NULL;
+}
+
static struct passwd *
lu_getpwuid(int uid)
{
tdata = (struct lu_thread_info *)calloc(1, sizeof(struct lu_thread_info));
_lu_data_set_key(_lu_data_key_user, tdata);
}
-\r
+
if (tdata->lu_vm == NULL)
{
if (proc < 0)
static struct passwd *
getpw_internal(const char *name, uid_t uid, int source)
{
- struct passwd *res = NULL;
- static char *loginName = NULL;
- static struct passwd *loginEnt = NULL;
+ static char *loginName = NULL;
+ static struct passwd *loginEnt = NULL;
+ struct passwd *res;
+ char *l;
+ int from_cache;
if (loginName == NULL)
{
- char *l = getlogin();
-
- pthread_mutex_lock(&_user_lock);
- if ((loginEnt == NULL) && (l != NULL) && (*l != '\0'))
+ l = getlogin();
+ if ((l != NULL) && (strcmp("root", l) != 0))
{
- if (_lu_running())
+ pthread_mutex_lock(&_user_lock);
+ if ((loginEnt == NULL) && (l != NULL) && (*l != '\0'))
{
- loginEnt = lu_getpwnam(l);
- }
- else
- {
- loginEnt = copy_user(_old_getpwnam(l));
- }
+ if (_lu_running())
+ {
+ loginEnt = lu_getpwnam(l);
+ }
+ else
+ {
+ loginEnt = copy_user(_old_getpwnam(l));
+ }
- loginName = l;
+ loginName = l;
+ }
+ pthread_mutex_unlock(&_user_lock);
}
- pthread_mutex_unlock(&_user_lock);
}
if (loginEnt != NULL)
}
}
- if (_lu_running())
+ from_cache = 0;
+ res = NULL;
+
+ switch (source)
+ {
+ case PW_GET_NAME:
+ res = cache_getpwnam(name);
+ break;
+ case PW_GET_UID:
+ res = cache_getpwuid(uid);
+ break;
+ default: res = NULL;
+ }
+
+ if (res != NULL)
+ {
+ from_cache = 1;
+ }
+ else if (_lu_running())
{
switch (source)
{
pthread_mutex_unlock(&_user_lock);
}
+ if (from_cache == 0) cache_user(res);
+
return res;
}
if (_lu_running()) lu_endpwent();
else _old_endpwent();
}
-\rint
+
+int
getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t bufsize, struct passwd **result)
{
return getpw_r(name, -2, PW_GET_NAME, pwd, buffer, bufsize, result);
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include "_lu_types.h"
#include "lookup.h"
#include "lu_utils.h"
+#include "netdb_async.h"
#define MAX_LOOKUP_ATTEMPTS 10
+#define _LU_MAXLUSTRLEN 256
+#define QBUF_SIZE 4096
+
+#define LU_MESSAGE_SEND_ID 4241776
+#define LU_MESSAGE_REPLY_ID 4241876
-static pthread_key_t _info_key = NULL;
+static pthread_key_t _info_key = NULL;
static pthread_once_t _info_key_initialized = PTHREAD_ONCE_INIT;
struct _lu_data_s
void (**idata_destructor)(void *);
};
-#define _LU_MAXLUSTRLEN 256
+typedef struct _lu_async_request_s
+{
+ mach_port_t reply_port;
+ uint32_t retry;
+ uint32_t proc;
+ void *context;
+ void *callback;
+ ooline_data request_buffer;
+ mach_msg_type_number_t request_buffer_len;
+ struct _lu_async_request_s *next;
+} _lu_async_request_t;
+
+typedef struct
+{
+ mach_msg_header_t head;
+ NDR_record_t NDR;
+ int proc;
+ mach_msg_type_number_t query_data_len;
+ unit query_data[QBUF_SIZE];
+} _lu_query_msg_t;
+
+typedef struct
+{
+ mach_msg_header_t head;
+ mach_msg_body_t msgh_body;
+ mach_msg_ool_descriptor_t reply_data;
+ NDR_record_t NDR;
+ mach_msg_type_number_t reply_data_len;
+ mach_msg_format_0_trailer_t trailer;
+} _lu_reply_msg_t;
+
+static pthread_mutex_t _lu_worklist_lock = PTHREAD_MUTEX_INITIALIZER;
+static _lu_async_request_t *_lu_worklist = NULL;
+
+/* Send an asynchronous query message to lookupd */
+static kern_return_t
+_lu_async_send(_lu_async_request_t *r)
+{
+ _lu_query_msg_t in;
+ register _lu_query_msg_t *inp = ∈
+ mach_msg_return_t status;
+ unsigned int msgh_size;
+
+ if (r == NULL) return KERN_FAILURE;
+
+ if (r->retry == 0) return MIG_SERVER_DIED;
+ r->retry--;
+
+ if (r->request_buffer_len > QBUF_SIZE) return MIG_ARRAY_TOO_LARGE;
+
+ msgh_size = (sizeof(_lu_query_msg_t) - 16384) + ((4 * r->request_buffer_len));
+ inp->head.msgh_bits = MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE);
+ inp->head.msgh_remote_port = _lu_port;
+ inp->head.msgh_local_port = r->reply_port;
+ inp->head.msgh_id = LU_MESSAGE_SEND_ID;
+ inp->NDR = NDR_record;
+ inp->proc = r->proc;
+ inp->query_data_len = r->request_buffer_len;
+ memcpy(inp->query_data, r->request_buffer, 4 * r->request_buffer_len);
+
+ status = mach_msg(&inp->head, MACH_SEND_MSG, msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
+ if (status == MACH_MSG_SUCCESS) return KERN_SUCCESS;
+
+ if (status == MACH_SEND_INVALID_REPLY)
+ {
+ mach_port_mod_refs(mach_task_self(), r->reply_port, MACH_PORT_RIGHT_RECEIVE, -1);
+ r->reply_port = MACH_PORT_NULL;
+ }
+
+ return status;
+}
+
+static _lu_async_request_t *
+_lu_worklist_remove(mach_port_t p)
+{
+ _lu_async_request_t *r, *n;
+
+ if (p == MACH_PORT_NULL) return NULL;
+ if (_lu_worklist == NULL) return NULL;
+
+ pthread_mutex_lock(&_lu_worklist_lock);
+
+ if (_lu_worklist->reply_port == p)
+ {
+ r = _lu_worklist;
+ _lu_worklist = r->next;
+ pthread_mutex_unlock(&_lu_worklist_lock);
+ return r;
+ }
+
+ for (r = _lu_worklist; r != NULL; r = r->next)
+ {
+ n = r->next;
+ if (n == NULL) break;
+
+ if (n->reply_port == p)
+ {
+ r->next = n->next;
+ pthread_mutex_unlock(&_lu_worklist_lock);
+ return n;
+ }
+ }
+
+ pthread_mutex_unlock(&_lu_worklist_lock);
+ return NULL;
+}
+
+static _lu_async_request_t *
+_lu_worklist_find(mach_port_t p)
+{
+ _lu_async_request_t *r;
+
+ if (p == MACH_PORT_NULL) return NULL;
+ if (_lu_worklist == NULL) return NULL;
+
+ pthread_mutex_lock(&_lu_worklist_lock);
+
+ for (r = _lu_worklist; r != NULL; r = r->next)
+ {
+ if (r->reply_port == p)
+ {
+ pthread_mutex_unlock(&_lu_worklist_lock);
+ return r;
+ }
+ }
+
+ pthread_mutex_unlock(&_lu_worklist_lock);
+ return NULL;
+}
+
+static void
+_lu_free_request(_lu_async_request_t *r)
+{
+ if (r == NULL) return;
+
+ if (r->request_buffer != NULL) free(r->request_buffer);
+ r->request_buffer = NULL;
+
+ if (r->reply_port != MACH_PORT_NULL) mach_port_destroy(mach_task_self(), r->reply_port);
+ r->reply_port = MACH_PORT_NULL;
+
+ free(r);
+}
+
+/* Receive an asynchronous reply message from lookupd */
+kern_return_t
+lu_async_receive(mach_port_t p, char **buf, uint32_t *len)
+{
+ _lu_reply_msg_t *r;
+ kern_return_t status;
+ uint32_t size;
+ _lu_async_request_t *req;
+
+ size = sizeof(_lu_reply_msg_t);
+
+ r = (_lu_reply_msg_t *)calloc(1, size);
+ if (r == NULL) return KERN_RESOURCE_SHORTAGE;
+
+ r->head.msgh_local_port = p;
+ r->head.msgh_size = size;
+ status = mach_msg(&(r->head), MACH_RCV_MSG, 0, size, r->head.msgh_local_port, 0, MACH_PORT_NULL);
+ if (status != KERN_SUCCESS)
+ {
+ free(r);
+ return status;
+ }
+
+ req = _lu_worklist_remove(r->head.msgh_local_port);
+ if (req == NULL)
+ {
+ free(r);
+ return KERN_FAILURE;
+ }
+
+ *buf = r->reply_data.address;
+ *len = r->reply_data.size;
+
+ free(r);
+
+ _lu_free_request(req);
+ return KERN_SUCCESS;
+}
+
+static void
+_lu_worklist_append(_lu_async_request_t *r)
+{
+ _lu_async_request_t *p;
+
+ if (r == NULL) return;
+
+ pthread_mutex_lock(&_lu_worklist_lock);
+
+ if (_lu_worklist == NULL)
+ {
+ _lu_worklist = r;
+ pthread_mutex_unlock(&_lu_worklist_lock);
+ return;
+ }
+
+ for (p = _lu_worklist; p->next != NULL; p = p->next);
+ p->next = r;
+
+ pthread_mutex_unlock(&_lu_worklist_lock);
+}
+
+void
+lu_async_call_cancel(mach_port_t p)
+{
+ _lu_async_request_t *req;
+
+ req = _lu_worklist_remove(p);
+ if (req != NULL) _lu_free_request(req);
+ else if (p != MACH_PORT_NULL) mach_port_destroy(mach_task_self(), p);
+}
+
+static _lu_async_request_t *
+_lu_create_request(uint32_t proc, const char *buf, uint32_t len, void *callback, void *context)
+{
+ _lu_async_request_t *r;
+ kern_return_t status;
+
+ if (_lu_port == NULL) return NULL;
+
+ r = (_lu_async_request_t *)calloc(1, sizeof(_lu_async_request_t));
+ if (r == NULL) return NULL;
+
+ status = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &(r->reply_port));
+ if (status != KERN_SUCCESS)
+ {
+ _lu_free_request(r);
+ return NULL;
+ }
+
+ r->retry = MAX_LOOKUP_ATTEMPTS;
+
+ r->context = context;
+ r->callback = callback;
+ r->proc = proc;
+
+ r->request_buffer = malloc(len * BYTES_PER_XDR_UNIT);
+ memcpy(r->request_buffer, buf, len * BYTES_PER_XDR_UNIT);
+ r->request_buffer_len = len;
+
+ r->next = NULL;
+
+ return r;
+}
+
+kern_return_t
+lu_async_start(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len, void *callback, void *context)
+{
+ _lu_async_request_t *r;
+ kern_return_t status;
+ uint32_t retry;
+
+ if (p == NULL) return KERN_FAILURE;
+
+ *p = MACH_PORT_NULL;
+
+ if (!_lu_running()) return KERN_FAILURE;
+
+ /* Make a request struct to keep track */
+ r = _lu_create_request(proc, buf, len, callback, context);
+ if (r == NULL) return KERN_FAILURE;
+
+ status = MIG_SERVER_DIED;
+ for (retry = 0; (status == MIG_SERVER_DIED) && (retry < MAX_LOOKUP_ATTEMPTS); retry++)
+ {
+ /* send to lookupd */
+ status = _lu_async_send(r);
+ }
+
+ if (status != KERN_SUCCESS)
+ {
+ _lu_free_request(r);
+ return status;
+ }
+
+ /* Add request to worklist */
+ _lu_worklist_append(r);
+
+ *p = r->reply_port;
+ return KERN_SUCCESS;
+}
+
+kern_return_t
+lu_async_send(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len)
+{
+ return lu_async_start(p, proc, buf, len, NULL, NULL);
+}
+
+int
+lu_async_handle_reply(void *msg, char **buf, uint32_t *len, void **callback, void **context)
+{
+ _lu_reply_msg_t *r;
+ _lu_async_request_t *req;
+ kern_return_t status;
+ uint32_t retry;
+
+ if (msg == NULL) return -1;
+ r = (_lu_reply_msg_t *)msg;
+
+ /* If reply status was an error, resend */
+ if (r->head.msgh_id != LU_MESSAGE_REPLY_ID)
+ {
+ if (r->head.msgh_id == MACH_NOTIFY_SEND_ONCE)
+ {
+ /* if MiG server (lookupd) died */
+ req = _lu_worklist_find(r->head.msgh_local_port);
+ if (req == NULL) return -1;
+
+ status = MIG_SERVER_DIED;
+ for (retry = 0; (status == MIG_SERVER_DIED) && (retry < MAX_LOOKUP_ATTEMPTS); retry++)
+ {
+ /* send to lookupd */
+ status = _lu_async_send(req);
+ }
+
+ if (status != KERN_SUCCESS) return -1;
+ }
+ return MIG_REPLY_MISMATCH;
+ }
+
+ req = _lu_worklist_remove(r->head.msgh_local_port);
+ if (req == NULL) return -1;
+
+ *buf = r->reply_data.address;
+ *len = r->reply_data.size;
+ *callback = req->callback;
+ *context = req->context;
+
+ _lu_free_request(req);
+ return 0;
+}
ni_proplist *
_lookupd_xdr_dictionary(XDR *inxdr)
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
--- /dev/null
+/*
+ * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+/*
+ * ++Copyright++ 1980, 1983, 1988, 1993
+ * -
+ * Copyright (c) 1980, 1983, 1988, 1993
+ * The Regents of the University of California. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ * must display the following acknowledgement:
+ * This product includes software developed by the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ * -
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
+ * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ * -
+ * --Copyright--
+ */
+
+/*
+ * @(#)netdb.h 8.1 (Berkeley) 6/2/93
+ */
+
+#ifndef _NETDB_H_
+#define _NETDB_H_
+
+#include <sys/param.h>
+#include <sys/cdefs.h>
+#include <sys/socket.h>
+
+#define _PATH_HEQUIV "/etc/hosts.equiv"
+#define _PATH_HOSTS "/etc/hosts"
+#define _PATH_NETWORKS "/etc/networks"
+#define _PATH_PROTOCOLS "/etc/protocols"
+#define _PATH_SERVICES "/etc/services"
+
+extern int h_errno;
+
+/*
+ * Structures returned by network data base library. All addresses are
+ * supplied in host order, and returned in network order (suitable for
+ * use in system calls).
+ */
+struct hostent {
+ char *h_name; /* official name of host */
+ char **h_aliases; /* alias list */
+ int h_addrtype; /* host address type */
+ int h_length; /* length of address */
+ char **h_addr_list; /* list of addresses from name server */
+#define h_addr h_addr_list[0] /* address, for backward compatiblity */
+};
+
+/*
+ * Assumption here is that a network number
+ * fits in an unsigned long -- probably a poor one.
+ */
+struct netent {
+ char *n_name; /* official name of net */
+ char **n_aliases; /* alias list */
+ int n_addrtype; /* net address type */
+ unsigned long n_net; /* network # */
+};
+
+struct servent {
+ char *s_name; /* official service name */
+ char **s_aliases; /* alias list */
+ int s_port; /* port # */
+ char *s_proto; /* protocol to use */
+};
+
+struct protoent {
+ char *p_name; /* official protocol name */
+ char **p_aliases; /* alias list */
+ int p_proto; /* protocol # */
+};
+
+struct addrinfo {
+ int ai_flags; /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
+ int ai_family; /* PF_xxx */
+ int ai_socktype; /* SOCK_xxx */
+ int ai_protocol; /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+ size_t ai_addrlen; /* length of ai_addr */
+ char *ai_canonname; /* canonical name for hostname */
+ struct sockaddr *ai_addr; /* binary address */
+ struct addrinfo *ai_next; /* next structure in linked list */
+};
+
+struct rpcent {
+ char *r_name; /* name of server for this rpc program */
+ char **r_aliases; /* alias list */
+ int r_number; /* rpc program number */
+};
+
+/*
+ * Error return codes from gethostbyname() and gethostbyaddr()
+ * (left in extern int h_errno).
+ */
+
+#define NETDB_INTERNAL -1 /* see errno */
+#define NETDB_SUCCESS 0 /* no problem */
+#define HOST_NOT_FOUND 1 /* Authoritative Answer Host not found */
+#define TRY_AGAIN 2 /* Non-Authoritative Host not found, or SERVERFAIL */
+#define NO_RECOVERY 3 /* Non recoverable errors, FORMERR, REFUSED, NOTIMP */
+#define NO_DATA 4 /* Valid name, no data record of requested type */
+#define NO_ADDRESS NO_DATA /* no address, look for MX record */
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#define EAI_ADDRFAMILY 1 /* address family for hostname not supported */
+#define EAI_AGAIN 2 /* temporary failure in name resolution */
+#define EAI_BADFLAGS 3 /* invalid value for ai_flags */
+#define EAI_FAIL 4 /* non-recoverable failure in name resolution */
+#define EAI_FAMILY 5 /* ai_family not supported */
+#define EAI_MEMORY 6 /* memory allocation failure */
+#define EAI_NODATA 7 /* no address associated with hostname */
+#define EAI_NONAME 8 /* hostname nor servname provided, or not known */
+#define EAI_SERVICE 9 /* servname not supported for ai_socktype */
+#define EAI_SOCKTYPE 10 /* ai_socktype not supported */
+#define EAI_SYSTEM 11 /* system error returned in errno */
+#define EAI_BADHINTS 12
+#define EAI_PROTOCOL 13
+#define EAI_MAX 14
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#define AI_PASSIVE 0x00000001 /* get address to use bind() */
+#define AI_CANONNAME 0x00000002 /* fill ai_canonname */
+#define AI_NUMERICHOST 0x00000004 /* prevent name resolution */
+/* valid flags for addrinfo */
+#define AI_MASK (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
+
+#define AI_ALL 0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
+#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
+#define AI_ADDRCONFIG 0x00000400 /* only if any address is assigned */
+#define AI_V4MAPPED 0x00000800 /* accept IPv4-mapped IPv6 address */
+/* special recommended flags for getipnodebyname */
+#define AI_DEFAULT (AI_V4MAPPED_CFG | AI_ADDRCONFIG)
+
+/*
+ * Constants for getnameinfo()
+ */
+#define NI_MAXHOST 1025
+#define NI_MAXSERV 32
+
+/*
+ * Flag values for getnameinfo()
+ */
+#define NI_NOFQDN 0x00000001
+#define NI_NUMERICHOST 0x00000002
+#define NI_NAMEREQD 0x00000004
+#define NI_NUMERICSERV 0x00000008
+#define NI_DGRAM 0x00000010
+#define NI_WITHSCOPEID 0x00000020
+
+/*
+ * Scope delimit character
+ */
+#define SCOPE_DELIMITER '%'
+
+__BEGIN_DECLS
+void endhostent(void);
+void endnetent(void);
+void endprotoent(void);
+void endservent(void);
+void freehostent(struct hostent *);
+struct hostent *gethostbyaddr(const char *, int, int);
+struct hostent *gethostbyname(const char *);
+struct hostent *gethostbyname2(const char *, int);
+struct hostent *gethostent(void);
+struct hostent *getipnodebyaddr(const void *, size_t, int, int *);
+struct hostent *getipnodebyname(const char *, int, int, int *);
+struct netent *getnetbyaddr(long, int);
+struct netent *getnetbyname(const char *);
+struct netent *getnetent(void);
+struct protoent *getprotobyname(const char *);
+struct protoent *getprotobynumber(int);
+struct protoent *getprotoent(void);
+struct servent *getservbyname(const char *, const char *);
+struct servent *getservbyport(int, const char *);
+struct servent *getservent(void);
+struct rpcent *getrpcbyname(const char *name);
+struct rpcent *getrpcbynumber(long number);
+struct rpcent *getrpcent(void);
+void setrpcent(int stayopen);
+void endrpcent(void);
+
+void herror(const char *);
+const char *hstrerror(int);
+int innetgr(const char *, const char *, const char *, const char *);
+void sethostent(int);
+/* void sethostfile(const char *); */
+void setnetent(int);
+void setprotoent(int);
+void setservent(int);
+const char *gai_strerror(int);
+void freeaddrinfo(struct addrinfo *);
+int getaddrinfo(const char *, const char *, const struct addrinfo *, struct addrinfo **);
+int getnameinfo(const struct sockaddr *, socklen_t, char *, size_t, char *, size_t, int);
+__END_DECLS
+
+#endif /* !_NETDB_H_ */
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 2002 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
#include <mach/mach.h>
#include <netdb.h>
+#define gethostbyname_async_handle_reply gethostbyname_async_handleReply
+#define gethostbyaddr_async_handle_reply gethostbyaddr_async_handleReply
+#define getipnodebyaddr_async_handle_reply getipnodebyaddr_async_handleReply
+#define getipnodebyname_async_handle_reply getipnodebyname_async_handleReply
+
__BEGIN_DECLS
/*
- @typedef gethostbyaddr_async_callback
- @discussion Type of the callback function used when a
- gethostbyaddr_async_start() request is delivered.
- @param hent The resolved host entry.
- @param context The context provided when the request
- was initiated.
+ * Private asynchronous lookup API
*/
-typedef void (*gethostbyaddr_async_callback) (
- struct hostent *hent,
- void *context
- );
-/*!
- @function gethostbyaddr_async_start
- @description Asynchronously resolves an Internet address
- @param addr The address to be resolved.
- @param len The length, in bytes, of the address.
- @param type
- @param callout The function to be called when the specified
- address has been resolved.
- @param context A user specified context which will be passed
- to the callout function.
- @result A mach reply port which will be sent a message when
- the addr resolution has completed. This message
- should be passed to the gethostbyaddr_async_handleReply
- function. A NULL value indicates that no address
- was specified or some other error occurred which
- prevented the resolution from being started.
+/*
+ * Cancel an outstanding call and free its resources.
*/
-mach_port_t
-gethostbyaddr_async_start (
- const char *addr,
- int len,
- int type,
- gethostbyaddr_async_callback callout,
- void *context
- );
+extern void lu_async_call_cancel(mach_port_t p);
+/*
+ * Make an asynchronous lookupd call.
+ * Sends data buffer to lookupd and returns a port.
+ * The buffer must be encoded for lookupd.
+ */
+extern kern_return_t lu_async_start(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len, void *callback, void *context);
+extern kern_return_t lu_async_send(mach_port_t *p, uint32_t proc, const char *buf, uint32_t len);
-/*!
- @function gethostbyaddr_async_handleReply
- @description This function should be called with the Mach message sent
- to the port returned by the call to gethostbyaddr_async_start.
- The reply message will be interpreted and will result in a
- call to the specified callout function.
- @param replyMsg The Mach message.
+/*
+ * Receive a reply for an asynchronous lookupd call.
+ * Receives the reply message and gets a raw (undecoded) data buffer.
+ */
+extern kern_return_t lu_async_receive(mach_port_t p, char **buf, uint32_t *len);
+
+/*
+ * Takes a reply message and provides the callback, context, and raw data buffers.
+ * This routine does not invoke the callback. Type-specific asynchronous
+ * routines built on top of this API will decode the data buffer and invoke
+ * the callback routine.
+ */
+extern int lu_async_handle_reply(void *msg, char **buf, uint32_t *len, void **callback, void **context);
+
+
+/*
+ * Type-specific routines.
*/
-void
-gethostbyaddr_async_handleReply (
- void *replyMsg
- );
+
+/*
+ * getaddrinfo
+ */
+typedef void (*getaddrinfo_async_callback)(int32_t status, struct addrinfo *res, void *context);
+int32_t getaddrinfo_async_start(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints, getaddrinfo_async_callback callback, void *context);
+int32_t getaddrinfo_async_send(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints);
+int32_t getaddrinfo_async_receive(mach_port_t p, struct addrinfo **res);
+int32_t getaddrinfo_async_handle_reply(void *msg);
+
+/*
+ * getnameinfo
+ */
+typedef void (*getnameinfo_async_callback)(int32_t status, char *host, char *serv, void *context);
+int32_t getnameinfo_async_start(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags, getnameinfo_async_callback callback, void *context);
+int32_t getnameinfo_async_send(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags);
+int32_t getnameinfo_async_receive(mach_port_t p, char **host, char **serv);
+int32_t getnameinfo_async_handle_reply(void *msg);
/*
- @typedef gethostbyname_async_callback
- @discussion Type of the callback function used when a
- gethostbyname_async_start() request is delivered.
- @param hent The resolved host entry.
- @param context The context provided when the request
- was initiated.
+ * DNS
*/
-typedef void (*gethostbyname_async_callback) (
- struct hostent *hent,
- void *context
- );
+typedef void (*dns_async_callback)(int32_t status, char *buf, uint32_t len, struct sockaddr *from, int fromlen, void *context);
+int32_t dns_async_start(mach_port_t *p, const char *name, uint16_t dnsclass, uint16_t dnstype, uint32_t do_search, dns_async_callback callback, void *context);
+int32_t dns_async_send(mach_port_t *p, const char *name, uint16_t dnsclass, uint16_t dnstype, uint32_t do_search);
+int32_t dns_async_receive(mach_port_t p, char **buf, uint32_t *len, struct sockaddr **from, uint32_t *fromlen);
+int32_t dns_async_handle_reply(void *msg);
+
+/*
+ * Host lookup asynchronous API
+ * These routines don't use the asynchronous lookupd access support
+ * described above. There will eventually be converted.
+ * The API is syntactically similar.
+ */
+
+/*
+ @typedef gethostbyaddr_async_callback
+ @discussion Type of the callback function used when a
+ gethostbyaddr_async_start() request is delivered.
+ @param hent The resolved host entry.
+ @param context The context provided when the request
+ was initiated.
+ */
+typedef void (*gethostbyaddr_async_callback)(struct hostent *hent, void *context);
/*!
- @function gethostbyname_async_start
- @description Asynchronously resolves a hostname
- @param name The hostname to be resolved.
- @param callout The function to be called when the specified
- hostname has been resolved.
- @param context A user specified context which will be passed
- to the callout function.
- @result A mach reply port which will be sent a message when
- the name resolution has completed. This message
- should be passed to the gethostbyname_async_handleReply
- function. A NULL value indicates that no hostname
- was specified or some other error occurred which
- prevented the resolution from being started.
+ @function gethostbyaddr_async_start
+ @description Asynchronously resolves an Internet address
+ @param addr The address to be resolved.
+ @param len The length, in bytes, of the address.
+ @param type
+ @param callout The function to be called when the specified
+ address has been resolved.
+ @param context A user specified context which will be passed
+ to the callout function.
+ @result A mach reply port which will be sent a message when
+ the addr resolution has completed. This message
+ should be passed to the gethostbyaddr_async_handleReply
+ function. A NULL value indicates that no address
+ was specified or some other error occurred which
+ prevented the resolution from being started.
*/
mach_port_t
-gethostbyname_async_start (
- const char *name,
- gethostbyname_async_callback callout,
- void *context
- );
+gethostbyaddr_async_start(const char *addr, int len, int type, gethostbyaddr_async_callback callout, void *context);
+/*!
+ @function gethostbyaddr_async_cancel
+ @description Cancel an asynchronous request currently in progress.
+ @param port The mach reply port associated with the request to be cancelled.
+ */
+void gethostbyaddr_async_cancel(mach_port_t port);
/*!
- @function gethostbyname_async_handleReply
- @description This function should be called with the Mach message sent
- to the port returned by the call to gethostbyname_async_start.
- The reply message will be interpreted and will result in a
- call to the specified callout function.
- @param replyMsg The Mach message.
+ @function gethostbyaddr_async_handleReply
+ @description This function should be called with the Mach message sent
+ to the port returned by the call to gethostbyaddr_async_start.
+ The reply message will be interpreted and will result in a
+ call to the specified callout function.
+ @param replyMsg The Mach message.
*/
-void
-gethostbyname_async_handleReply (
- void *replyMsg
- );
+void gethostbyaddr_async_handleReply(void *replyMsg);
+/*
+ @typedef gethostbyname_async_callback
+ @discussion Type of the callback function used when a
+ gethostbyname_async_start() request is delivered.
+ @param hent The resolved host entry.
+ @param context The context provided when the request was initiated.
+ */
+typedef void (*gethostbyname_async_callback)(struct hostent *hent, void *context);
+
+/*!
+ @function gethostbyname_async_start
+ @description Asynchronously resolves a hostname
+ @param name The hostname to be resolved.
+ @param callout The function to be called when the specified
+ hostname has been resolved.
+ @param context A user specified context which will be passed
+ to the callout function.
+ @result A mach reply port which will be sent a message when
+ the name resolution has completed. This message
+ should be passed to the gethostbyname_async_handleReply
+ function. A NULL value indicates that no hostname
+ was specified or some other error occurred which
+ prevented the resolution from being started.
+ */
+mach_port_t gethostbyname_async_start(const char *name, gethostbyname_async_callback callout, void *context);
+
+/*!
+ @function gethostbyname_async_cancel
+ @description Cancel an asynchronous request currently in progress.
+ @param port The mach reply port associated with the request to be cancelled.
+ */
+void gethostbyname_async_cancel(mach_port_t port);
+
+/*!
+ @function gethostbyname_async_handleReply
+ @description This function should be called with the Mach message sent
+ to the port returned by the call to gethostbyname_async_start.
+ The reply message will be interpreted and will result in a
+ call to the specified callout function.
+ @param replyMsg The Mach message.
+ */
+void gethostbyname_async_handleReply(void *replyMsg);
/*
- @typedef getipnodebyaddr_async_callback
- @discussion Type of the callback function used when a
- getipnodebyaddr_async_start() request is delivered.
- @param hent The resolved host entry. If not NULL, the caller
- must call freehostent() on the host entry.
- @param error If error code if the resolved host entry is NULL
- @param context The context provided when the request
- was initiated.
+ @typedef getipnodebyaddr_async_callback
+ @discussion Type of the callback function used when a
+ getipnodebyaddr_async_start() request is delivered.
+ @param hent The resolved host entry. If not NULL, the caller
+ must call freehostent() on the host entry.
+ @param error If error code if the resolved host entry is NULL
+ @param context The context provided when the request was initiated.
*/
-typedef void (*getipnodebyaddr_async_callback) (
- struct hostent *hent,
- int error,
- void *context
- );
+typedef void (*getipnodebyaddr_async_callback)(struct hostent *hent, int error, void *context);
/*!
- @function getipnodebyaddr_async_start
- @description Asynchronously resolves an Internet address
- @param addr The address to be resolved.
- @param len The length, in bytes, of the address.
- @param af The address family
- @param error
- @param callout The function to be called when the specified
- address has been resolved.
- @param context A user specified context which will be passed
- to the callout function.
- @result A mach reply port which will be sent a message when
- the addr resolution has completed. This message
- should be passed to the getipnodebyaddr_async_handleReply
- function. A NULL value indicates that no address
- was specified or some other error occurred which
- prevented the resolution from being started.
+ @function getipnodebyaddr_async_start
+ @description Asynchronously resolves an Internet address
+ @param addr The address to be resolved.
+ @param len The length, in bytes, of the address.
+ @param af The address family
+ @param error
+ @param callout The function to be called when the specified
+ address has been resolved.
+ @param context A user specified context which will be passed
+ to the callout function.
+ @result A mach reply port which will be sent a message when
+ the addr resolution has completed. This message
+ should be passed to the getipnodebyaddr_async_handleReply
+ function. A NULL value indicates that no address
+ was specified or some other error occurred which
+ prevented the resolution from being started.
*/
-mach_port_t
-getipnodebyaddr_async_start (
- const void *addr,
- size_t len,
- int af,
- int *error,
- getipnodebyaddr_async_callback callout,
- void *context
- );
+mach_port_t getipnodebyaddr_async_start(const void *addr, size_t len, int af, int *error, getipnodebyaddr_async_callback callout, void *context);
+/*!
+ @function getipnodebyaddr_async_cancel
+ @description Cancel an asynchronous request currently in progress.
+ @param port The mach reply port associated with the request to be cancelled.
+ */
+void getipnodebyaddr_async_cancel(mach_port_t port);
/*!
- @function getipnodebyaddr_async_handleReply
- @description This function should be called with the Mach message sent
- to the port returned by the call to getipnodebyaddr_async_start.
- The reply message will be interpreted and will result in a
- call to the specified callout function.
- @param replyMsg The Mach message.
+ @function getipnodebyaddr_async_handleReply
+ @description This function should be called with the Mach message sent
+ to the port returned by the call to getipnodebyaddr_async_start.
+ The reply message will be interpreted and will result in a
+ call to the specified callout function.
+ @param replyMsg The Mach message.
*/
-void
-getipnodebyaddr_async_handleReply (
- void *replyMsg
- );
+void getipnodebyaddr_async_handleReply(void *replyMsg);
/*
- @typedef getipnodebyname_async_callback
- @discussion Type of the callback function used when a
- getipnodebyname_async_start() request is delivered.
- @param hent The resolved host entry. If not NULL, the caller
- must call freehostent() on the host entry.
- @param error If error code if the resolved host entry is NULL
- @param context The context provided when the request
- was initiated.
+ @typedef getipnodebyname_async_callback
+ @discussion Type of the callback function used when a
+ getipnodebyname_async_start() request is delivered.
+ @param hent The resolved host entry. If not NULL, the caller
+ must call freehostent() on the host entry.
+ @param error If error code if the resolved host entry is NULL
+ @param context The context provided when the request was initiated.
*/
-typedef void (*getipnodebyname_async_callback) (
- struct hostent *hent,
- int error,
- void *context
- );
+typedef void (*getipnodebyname_async_callback)(struct hostent *hent, int error, void *context);
/*!
- @function getipnodebyname_async_start
- @description Asynchronously resolves a hostname
- @param name The hostname to be resolved.
- @param af
- @param flags
- @param error
- @param callout The function to be called when the specified
- hostname has been resolved.
- @param context A user specified context which will be passed
- to the callout function.
- @result A mach reply port which will be sent a message when
- the name resolution has completed. This message
- should be passed to the getipnodebyname_async_handleReply
- function. A NULL value indicates that no hostname
- was specified or some other error occurred which
- prevented the resolution from being started.
+ @function getipnodebyname_async_start
+ @description Asynchronously resolves a hostname
+ @param name The hostname to be resolved.
+ @param af
+ @param flags
+ @param error
+ @param callout The function to be called when the specified
+ hostname has been resolved.
+ @param context A user specified context which will be passed
+ to the callout function.
+ @result A mach reply port which will be sent a message when
+ the name resolution has completed. This message
+ should be passed to the getipnodebyname_async_handleReply
+ function. A NULL value indicates that no hostname
+ was specified or some other error occurred which
+ prevented the resolution from being started.
*/
-mach_port_t
-getipnodebyname_async_start (
- const char *name,
- int af,
- int flags,
- int *error,
- getipnodebyname_async_callback callout,
- void *context
- );
+mach_port_t getipnodebyname_async_start(const char *name, int af, int flags, int *error, getipnodebyname_async_callback callout, void *context);
+/*!
+ @function getipnodebyname_async_cancel
+ @description Cancel an asynchronous request currently in progress.
+ @param port The mach reply port associated with the request to be cancelled.
+ */
+void getipnodebyname_async_cancel(mach_port_t port);
/*!
- @function getipnodebyname_async_handleReply
- @description This function should be called with the Mach message sent
- to the port returned by the call to getipnodebyname_async_start.
- The reply message will be interpreted and will result in a
- call to the specified callout function.
- @param replyMsg The Mach message.
+ @function getipnodebyname_async_handleReply
+ @description This function should be called with the Mach message sent
+ to the port returned by the call to getipnodebyname_async_start.
+ The reply message will be interpreted and will result in a
+ call to the specified callout function.
+ @param replyMsg The Mach message.
*/
-void
-getipnodebyname_async_handleReply (
- void *replyMsg
- );
+void getipnodebyname_async_handleReply(void *replyMsg);
__END_DECLS
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
return NULL;
}
+ if (!txtRecord) {
+ txtRecord = "";
+ }
+
result = mach_port_allocate(mach_task_self(), MACH_PORT_RIGHT_RECEIVE, &clientPort);
if (result != KERN_SUCCESS) {
printf("Mach port receive creation failed, %s\n", mach_error_string(result));
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
-* "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
* Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
#include <mach/mach_types.h>
-#define DNS_SERVICE_DISCOVERY_SERVER "DNSServiceDiscoveryServer"
+#define DNS_SERVICE_DISCOVERY_SERVER "com.apple.mDNSResponder"
typedef char DNSCString[1024];
typedef char sockaddr_t[128];
* Copyright (c) 2001 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
* Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License"). You may not use this file except in compliance with the
- * License. Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
- *
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
PROJECTVERSION = 2.8
PROJECT_TYPE = Component
-HFILES = DNSServiceDiscoveryDefines.h DNSServiceDiscovery.h
+HFILES = DNSServiceDiscoveryDefines.h DNSServiceDiscovery.h dns_sd.h dnssd_ipc.h
-CFILES = DNSServiceDiscovery.c
+CFILES = DNSServiceDiscovery.c dnssd_clientstub.c dnssd_ipc.c
OTHERSRCS = Makefile.preamble Makefile Makefile.postamble\
DNSServiceDiscoveryReply.defs DNSServiceDiscoveryRequest.defs
-
+
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
CODE_GEN_STYLE = DYNAMIC
MAKEFILE = subproj.make
DEBUG_LIBS = $(LIBS)
PROF_LIBS = $(LIBS)
+PUBLIC_HEADERS = dns_sd.h
# derived files should go.
#
-mdns_hdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX)
- $(SILENT) $(FASTCP) $(MDNS_HDRS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX)
+mdns_hdrs: $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX) $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX)
+ $(SILENT) $(FASTCP) $(INTERNAL_MDNS_HDRS) $(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX)
+ $(SILENT) $(FASTCP) $(PUBLIC_MDNS_HEADERS) $(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX)
$(DSTROOT)$(PRIVATE_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX):
$(MKDIRS) $@
+
+$(DSTROOT)$(PUBLIC_HDR_INSTALLDIR)$(MDNS_HEADER_DIR_SUFFIX):
+ $(MKDIRS) $@
# Additional flags (MiG generated files)
OTHER_OFILES = DNSServiceDiscoveryRequestUser.o DNSServiceDiscoveryReplyServer.o
-#private headers
-MDNS_HDRS = DNSServiceDiscoveryRequest.defs DNSServiceDiscoveryRequest.h \
- DNSServiceDiscoveryReply.defs DNSServiceDiscoveryReply.h DNSServiceDiscoveryDefines.h
+# private headers
+INTERNAL_MDNS_HDRS = DNSServiceDiscoveryRequest.defs\
+ DNSServiceDiscoveryRequest.h \
+ DNSServiceDiscoveryReply.defs\
+ DNSServiceDiscoveryReply.h \
+ DNSServiceDiscoveryDefines.h
-BEFORE_INSTALLHDRS += $(SFILE_DIR) $(MDNS_HDRS)
+# public headers
+PUBLIC_MDNS_HEADERS = DNSServiceDiscovery.h
+
+BEFORE_INSTALLHDRS += $(SFILE_DIR) $(INTERNAL_MDNS_HDRS)
AFTER_INSTALLHDRS += mdns_hdrs
PRIVATE_HEADER_DIR = /AppleInternal/Developer/Headers
MDNS_HEADER_DIR_SUFFIX = /DNSServiceDiscovery
-# public headers
-OTHER_PUBLIC_HEADERS = DNSServiceDiscovery.h
-PUBLIC_HEADER_DIR_SUFFIX = /DNSServiceDiscovery
DYNAMIC_CODE_GEN = YES;
English_RESOURCES = {};
FILESTABLE = {
- H_FILES = (DNSServiceDiscoveryDefines.h, DNSServiceDiscovery.h);
- OTHER_LINKED = (DNSServiceDiscovery.c);
+ H_FILES = (DNSServiceDiscoveryDefines.h, DNSServiceDiscovery.h, dns_sd.h, dnssd_ipc.h);
+ OTHER_LINKED = (DNSServiceDiscovery.c, dnssd_clientstub.c, dnssd_ipc.c);
OTHER_RESOURCES = ();
OTHER_SOURCES = (
Makefile.preamble,
DNSServiceDiscoveryReply.defs,
DNSServiceDiscoveryRequest.defs
);
- PUBLIC_HEADERS = ();
+ PUBLIC_HEADERS = (dns_sd.h);
SUBPROJECTS = ();
};
LANGUAGE = English;
--- /dev/null
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#ifndef _DNS_SD_H
+#define _DNS_SD_H
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <stdint.h>
+#include <netinet/in.h>
+
+
+/* DNSServiceRef, DNSRecordRef
+ *
+ * Opaque internal data types.
+ * Note: client is responsible for serializing access to these structures if
+ * they are shared between concurrent threads.
+ */
+
+typedef struct _DNSServiceRef_t *DNSServiceRef;
+typedef struct _DNSRecordRef_t *DNSRecordRef;
+
+/* General flags used in functions defined below */
+enum
+ {
+ kDNSServiceFlagsMoreComing = 1,
+ kDNSServiceFlagsFinished = 0, /* i.e. bit not set */
+ /* MoreComing indicates to a Browse callback that another result is
+ * queued. Applications should not update their UI to display browse
+ * results when the MoreComing flag is set, instead deferring the update
+ * until the callback's flag is Finished. */
+
+ kDNSServiceFlagsAdd = 2,
+ kDNSServiceFlagsDefault = 4,
+ kDNSServiceFlagsRemove = 0, /* i.e. bit not set */
+ /* Flags for domain enumeration and browse reply callbacks.
+ * "Default" applies only to enumeration and is only valid in
+ * conjuction with "Add"
+ */
+
+ kDNSServiceFlagsNoAutoRename = 8,
+ kDNSServiceFlagsAutoRename = 0, /* i.e. bit not set */
+ /* Flag for specifying renaming behavior on name conflict when registering
+ * non-shared records. NoAutorename is only valid if a name is explicitly
+ * specified when registering a service (ie the default name is not used.)
+ */
+
+
+ kDNSServiceFlagsShared = 16,
+ kDNSServiceFlagsUnique = 32,
+ /* Flag for registering individual records on a connected
+ * DNSServiceRef. Shared indicates that there may be multiple records
+ * with this name on the network (e.g. PTR records). Unique indicates that the
+ * record's name is to be unique on the network (e.g. SRV records).
+ */
+
+ kDNSServiceFlagsBrowseDomains = 64,
+ kDNSServiceFlagsRegistrationDomains = 128
+ /* Flags for specifying domain enumeration type in DNSServiceEnumerateDomains.
+ * BrowseDomains enumerates domains recommended for browsing, RegistrationDomains
+ * enumerates domains recommended for registration.
+ */
+ };
+
+/* possible error code values */
+enum
+ {
+ kDNSServiceErr_NoError = 0,
+ kDNSServiceErr_Unknown = -65537, /* 0xFFFE FFFF */
+ kDNSServiceErr_NoSuchName = -65538,
+ kDNSServiceErr_NoMemory = -65539,
+ kDNSServiceErr_BadParam = -65540,
+ kDNSServiceErr_BadReference = -65541,
+ kDNSServiceErr_BadState = -65542,
+ kDNSServiceErr_BadFlags = -65543,
+ kDNSServiceErr_Unsupported = -65544,
+ kDNSServiceErr_NotInitialized = -65545,
+ kDNSServiceErr_AlreadyRegistered = -65547,
+ kDNSServiceErr_NameConflict = -65548,
+ kDNSServiceErr_Invalid = -65549,
+ kDNSServiceErr_Incompatible = -65551, /* client library incompatible with daemon */
+ kDNSServiceErr_BadinterfaceIndex = -65552
+ /* mDNS Error codes are in the range
+ * FFFE FF00 (-65792) to FFFE FFFF (-65537) */
+ };
+
+
+/* Maximum length, in bytes, of a domain name represented as an escaped C-String */
+#define kDNSServiceMaxDomainName 1005
+
+
+typedef uint32_t DNSServiceFlags;
+typedef int32_t DNSServiceErrorType;
+
+
+/*********************************************************************************************
+ *
+ * Unix Domain Socket access, DNSServiceRef deallocation, and data processing functions
+ *
+ *********************************************************************************************/
+
+
+/* DNSServiceRefSockFD()
+ *
+ * Access underlying Unix domain socket for an initialized DNSServiceRef.
+ * The DNS Service Discovery implmementation uses this socket to communicate between
+ * the client and the mDNSResponder daemon. The application MUST NOT directly read from
+ * or write to this socket. Access to the socket is provided so that it can be used as a
+ * run loop source, or in a select() loop: when data is available for reading on the socket,
+ * DNSServiceProcessResult() should be called, which will extract the daemon's reply from
+ * the socket, and pass it to the appropriate application callback. By using a run loop or
+ * select(), results from the daemon can be processed asynchronously. Without using these
+ * constructs, DNSServiceProcessResult() will block until the response from the daemon arrives.
+ * The client is responsible for ensuring that the data on the socket is processed in a timely
+ * fashion - the daemon may terminate its connection with a client that does not clear its
+ * socket buffer.
+ *
+ * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
+ *
+ * return value: The DNSServiceRef's underlying socket descriptor, or -1 on
+ * error.
+ */
+
+int DNSServiceRefSockFD(DNSServiceRef sdRef);
+
+/* DNSServiceProcessResult()
+ *
+ * Read a reply from the daemon, calling the appropriate application callback. This call will
+ * block until the daemon's response is received. Use DNSServiceRefSockFD() in
+ * conjunction with a run loop or select() to determine the presence of a response from the
+ * server before calling this function to process the reply without blocking. Call this function
+ * at any point if it is acceptable to block until the daemon's response arrives. Note that the
+ * client is responsible for ensuring that DNSServiceProcessResult() is called whenever there is
+ * a reply from the daemon - the daemon may terminate its connection with a client that does not
+ * process the daemon's responses.
+ *
+ * sdRef: A DNSServiceRef initialized by any of the DNSService calls
+ * that take a callback parameter.
+ *
+ * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
+ * an error code indicating the specific failure that occurred.
+ */
+
+DNSServiceErrorType DNSServiceProcessResult(DNSServiceRef sdRef);
+
+/* DNSServiceRefDeallocate()
+ *
+ * Terminate a connection with the daemon and free memory associated with the DNSServiceRef.
+ * Any services or records registered with this DNSServiceRef will be deregistered. Any
+ * Browse, Resolve, or Query operations called with this reference will be terminated.
+ *
+ * Note: If the reference's underlying socket is used in a run loop or select() call, it should
+ * be removed BEFORE DNSServiceRefDeallocate() is called, as this function closes the reference's
+ * socket.
+ *
+ * Note: If the reference was initialized with DNSServiceCreateConnection(), any DNSRecordRefs
+ * created via this reference will be invalidated by this call - the resource records are
+ * deregistered, and their DNSRecordRefs may not be used in subsequent functions. Similarly,
+ * if the reference was initialized with DNSServiceRegister, and an extra resource record was
+ * added to the service via DNSServiceAddRecord(), the DNSRecordRef created by the Add() call
+ * is invalidated when this function is called - the DNSRecordRef may not be used in subsequent
+ * functions.
+ *
+ * Note: This call is to be used only with the DNSServiceRef defined by this API. It is
+ * not compatible with dns_service_discovery_ref objects defined in the legacy Mach-based
+ * DNSServiceDiscovery.h API.
+ *
+ * sdRef: A DNSServiceRef initialized by any of the DNSService calls.
+ *
+ */
+
+void DNSServiceRefDeallocate(DNSServiceRef sdRef);
+
+
+/*********************************************************************************************
+ *
+ * Domain Enumeration
+ *
+ *********************************************************************************************/
+
+/* DNSServiceEnumerateDomains()
+ *
+ * Asynchronously enumerate domains available for browsing and registration.
+ * Currently, the only domain returned is "local.", but other domains will be returned in future.
+ *
+ * The enumeration MUST be cancelled via DNSServiceRefDeallocate() when no more domains
+ * are to be found.
+ *
+ *
+ * DNSServiceDomainEnumReply Callback Parameters:
+ *
+ * sdRef: The DNSServiceRef initialized by DNSServiceEnumerateDomains().
+ *
+ * flags: Possible values are:
+ * 1 (MoreComing)
+ * 2 (Add/Remove)
+ * 4 (Add Default)
+ *
+ * interfaceIndex: Specifies the interface on which the domain exists. (The index for a given
+ * interface is determined via the if_nametoindex() family of calls.)
+ *
+ * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise indicates
+ * the failure that occurred (other parameters are undefined if errorCode is nonzero).
+ *
+ * replyDomain: The name of the domain.
+ *
+ * context: The context pointer passed to DNSServiceEnumerateDomains.
+ *
+ */
+
+typedef void (*DNSServiceDomainEnumReply)
+ (
+ DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *replyDomain,
+ void *context
+ );
+
+/* DNSServiceEnumerateDomains() Parameters:
+ *
+ *
+ * sdRef: A pointer to an uninitialized sdRef. May be passed to
+ * DNSServiceRefDeallocate() to cancel the enumeration.
+ *
+ * flags: Possible values are:
+ * 0 (BrowseDomains) to enumerate domains recommended for browsing.
+ * 32 (RegistrationDomains) to enumerate domains recommended for registration.
+ *
+ * interfaceIndex: If non-zero, specifies the interface on which to look for domains.
+ * (the index for a given interface is determined via the if_nametoindex()
+ * family of calls.) Most applications will pass 0 to enumerate domains on
+ * all interfaces.
+ *
+ * callBack: The function to be called when a domain is found or the call asynchronously
+ * fails.
+ *
+ * context: An application context pointer which is passed to the callback function
+ * (may be NULL).
+ *
+ * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
+ * errors are delivered to the callback), otherwise returns an error code indicating
+ * the error that occurred (the callback is not invoked and the DNSServiceRef
+ * is not initialized.)
+ */
+
+DNSServiceErrorType DNSServiceEnumerateDomains
+ (
+ DNSServiceRef *sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceDomainEnumReply callBack,
+ void *context /* may be NULL */
+ );
+
+/*********************************************************************************************
+ *
+ * Service Registration
+ *
+ *********************************************************************************************/
+
+/* Register a service that is discovered via Browse() and Resolve() calls.
+ *
+ *
+ * DNSServiceRegisterReply() Callback Parameters:
+ *
+ * sdRef: The DNSServiceRef initialized by DNSServiceRegister().
+ *
+ * flags: Currently unused, reserved for future use.
+ *
+ * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
+ * indicate the failure that occurred (including name conflicts, if the
+ * kDNSServiceFlagsNoAutoRenameOnConflict flag was passed to the
+ * callout.) Other parameters are undefined if errorCode is nonzero.
+ *
+ * name: The service name registered (if the application did not specify a name in
+ * DNSServiceRegister(), this indicates what name was automatically chosen).
+ *
+ * regtype: The type of service registered, as it was passed to the callout.
+ *
+ * domain: The domain on which the service was registered (if the application did not
+ * specify a domain in DNSServiceRegister(), this indicates the default domain
+ * on which the service was registered).
+ *
+ * context: The context pointer that was passed to the callout.
+ *
+ */
+
+typedef void (*DNSServiceRegisterReply)
+ (
+ DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ DNSServiceErrorType errorCode,
+ const char *name,
+ const char *regtype,
+ const char *domain,
+ void *context
+ );
+
+/* DNSServiceRegister() Parameters:
+ *
+ * sdRef: A pointer to an uninitialized sdRef. If this call succeeds, the reference
+ * may be passed to
+ * DNSServiceRefDeallocate() to deregister the service.
+ *
+ * interfaceIndex: If non-zero, specifies the interface on which to register the service
+ * (the index for a given interface is determined via the if_nametoindex()
+ * family of calls.) Most applications will pass 0 to register on all
+ * available interfaces. Pass -1 to register a service only on the local
+ * machine (service will not be visible to remote hosts.)
+ *
+ * flags: Indicates the renaming behavior on name conflict (most applications
+ * will pass 0). See flag definitions above for details.
+ *
+ * name: If non-NULL, specifies the service name to be registered.
+ * Most applications will not specify a name, in which case the
+ * computer name is used (this name is communicated to the client via
+ * the callback).
+ *
+ * regtype: The service type followed by the protocol, separated by a dot
+ * (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
+ *
+ * domain: If non-NULL, specifies the domain on which to advertise the service.
+ * Most applications will not specify a domain, instead automatically
+ * registering in the default domain(s).
+ *
+ * host: If non-NULL, specifies the SRV target host name. Most applications
+ * will not specify a host, instead automatically using the machine's
+ * default host name(s). Note that specifying a non-NULL host does NOT
+ * create an address record for that host - the application is responsible
+ * for ensuring that the appropriate address record exists, or creating it
+ * via DNSServiceRegisterRecord().
+ *
+ * port: The port on which the service accepts connections. Pass 0 for a
+ * "placeholder" service (i.e. a service that will not be discovered by
+ * browsing, but will cause a name conflict if another client tries to
+ * register that same name.) Most clients will not use placeholder services.
+ *
+ * txtLen: The length of the txtRecord, in bytes. Must be zero if the txtRecord is NULL.
+ *
+ * txtRecord: The txt record rdata. May be NULL. Note that a non-NULL txtRecord
+ * MUST be a properly formatted DNS TXT record, i.e. <length byte> <data>
+ * <length byte> <data> ...
+ *
+ * callBack: The function to be called when the registration completes or asynchronously
+ * fails. The client MAY pass NULL for the callback - The client will NOT be notified
+ * of the default values picked on its behalf, and the client will NOT be notified of any
+ * asynchronous errors (e.g. out of memory errors, etc.) that may prevent the registration
+ * of the service. The client may NOT pass the NoAutoRename flag if the callback is NULL.
+ * The client may still deregister the service at any time via DNSServiceRefDeallocate().
+ *
+ * context: An application context pointer which is passed to the callback function
+ * (may be NULL).
+ *
+ * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
+ * errors are delivered to the callback), otherwise returns an error code indicating
+ * the error that occurred (the callback is never invoked and the DNSServiceRef
+ * is not initialized.)
+ *
+ */
+
+DNSServiceErrorType DNSServiceRegister
+ (
+ DNSServiceRef *sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ const char *name, /* may be NULL */
+ const char *regtype,
+ const char *domain, /* may be NULL */
+ const char *host, /* may be NULL */
+ uint16_t port,
+ uint16_t txtLen,
+ const void *txtRecord, /* may be NULL */
+ DNSServiceRegisterReply callBack, /* may be NULL */
+ void *context /* may be NULL */
+ );
+
+/* DNSServiceAddRecord()
+ *
+ * Add a record to a registered service. The name of the record will be the same as the
+ * registered service's name.
+ * The record can later be updated or deregistered by passing the RecordRef initialized
+ * by this function to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
+ *
+ *
+ * Parameters;
+ *
+ * sdRef: A DNSServiceRef initialized by DNSServiceRegister().
+ *
+ * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
+ * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
+ * If the above DNSServiceRef is passed to DNSServiceRefDeallocate(), RecordRef is also
+ * invalidated and may not be used further.
+ *
+ * flags: Currently ignored, reserved for future use.
+ *
+ * rrtype: The type of the record (e.g. TXT, SRV, etc), as defined in nameser.h.
+ *
+ * rdlen: The length, in bytes, of the rdata.
+ *
+ * rdata: The raw rdata to be contained in the added resource record.
+ *
+ * ttl: The time to live of the resource record, in seconds.
+ *
+ * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
+ * error code indicating the error that occurred (the RecordRef is not initialized).
+ */
+
+DNSServiceErrorType DNSServiceAddRecord
+ (
+ DNSServiceRef sdRef,
+ DNSRecordRef *RecordRef,
+ DNSServiceFlags flags,
+ uint16_t rrtype,
+ uint16_t rdlen,
+ const void *rdata,
+ uint32_t ttl
+ );
+
+/* DNSServiceUpdateRecord
+ *
+ * Update a registered resource record. The record must either be:
+ * - The primary txt record of a service registered via DNSServiceRegister()
+ * - A record added to a registered service via DNSServiceAddRecord()
+ * - An individual record registered by DNSServiceRegisterRecord()
+ *
+ *
+ * Parameters:
+ *
+ * sdRef: A DNSServiceRef that was initialized by DNSServiceRegister()
+ * or DNSServiceCreateConnection().
+ *
+ * RecordRef: A DNSRecordRef initialized by DNSServiceAddRecord, or NULL to update the
+ * service's primary txt record.
+ *
+ * flags: Currently ignored, reserved for future use.
+ *
+ * rdlen: The length, in bytes, of the new rdata.
+ *
+ * rdata: The new rdata to be contained in the updated resource record.
+ *
+ * ttl: The time to live of the updated resource record, in seconds.
+ *
+ * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
+ * error code indicating the error that occurred.
+ */
+
+DNSServiceErrorType DNSServiceUpdateRecord
+ (
+ DNSServiceRef sdRef,
+ DNSRecordRef RecordRef, /* may be NULL */
+ DNSServiceFlags flags,
+ uint16_t rdlen,
+ const void *rdata,
+ uint32_t ttl
+ );
+
+/* DNSServiceRemoveRecord
+ *
+ * Remove a record previously added to a service record set via DNSServiceAddRecord(), or deregister
+ * an record registered individually via DNSServiceRegisterRecord().
+ *
+ * Parameters:
+ *
+ * sdRef: A DNSServiceRef initialized by DNSServiceRegister() (if the
+ * record being removed was registered via DNSServiceAddRecord()) or by
+ * DNSServiceCreateConnection() (if the record being removed was registered via
+ * DNSServiceRegisterRecord()).
+ *
+ * recordRef: A DNSRecordRef initialized by a successful call to DNSServiceAddRecord()
+ * or DNSServiceRegisterRecord().
+ *
+ * flags: Currently ignored, reserved for future use.
+ *
+ * return value: Returns kDNSServiceErr_NoError on success, otherwise returns an
+ * error code indicating the error that occurred.
+ */
+
+DNSServiceErrorType DNSServiceRemoveRecord
+ (
+ DNSServiceRef sdRef,
+ DNSRecordRef RecordRef,
+ DNSServiceFlags flags
+ );
+
+
+/*********************************************************************************************
+ *
+ * Service Discovery
+ *
+ *********************************************************************************************/
+
+
+/* Browse for instances of a service.
+ *
+ *
+ * DNSServiceBrowseReply() Parameters:
+ *
+ * sdRef: The DNSServiceRef initialized by DNSServiceBrowse().
+ *
+ * flags: Possible values are MoreComing and Add/Remove. See flag definitions
+ * for details.
+ *
+ * interfaceIndex: The interface on which the service is advertised. This index should
+ * be passed to DNSServiceResolve() when resolving the service.
+ *
+ * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
+ * indicate the failure that occurred. Other parameters are undefined if
+ * the errorCode is nonzero.
+ *
+ * serviceName: The service name discovered.
+ *
+ * regtype: The service type, as passed in to DNSServiceBrowse().
+ *
+ * domain: The domain on which the service was discovered (if the application did not
+ * specify a domain in DNSServicBrowse(), this indicates the domain on which the
+ * service was discovered.)
+ *
+ * context: The context pointer that was passed to the callout.
+ *
+ */
+
+typedef void (*DNSServiceBrowseReply)
+ (
+ DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *serviceName,
+ const char *regtype,
+ const char *replyDomain,
+ void *context
+ );
+
+/* DNSServiceBrowse() Parameters:
+ *
+ * sdRef: A pointer to an uninitialized sdRef. May be passed to
+ * DNSServiceRefDeallocate() to terminate the browse.
+ *
+ * flags: Currently ignored, reserved for future use.
+ *
+ * interfaceIndex: If non-zero, specifies the interface on which to browse for services
+ * (the index for a given interface is determined via the if_nametoindex()
+ * family of calls.) Most applications will pass 0 to browse on all available
+ * interfaces. Pass -1 to only browse for services provided on the local host.
+ *
+ * regtype: The service type being browsed for followed by the protocol, separated by a
+ * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
+ *
+ * domain: If non-NULL, specifies the domain on which to browse for services.
+ * Most applications will not specify a domain, instead browsing on the
+ * default domain(s).
+ *
+ * callBack: The function to be called when an instance of the service being browsed for
+ * is found, or if the call asynchronously fails.
+ *
+ * context: An application context pointer which is passed to the callback function
+ * (may be NULL).
+ *
+ * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
+ * errors are delivered to the callback), otherwise returns an error code indicating
+ * the error that occurred (the callback is not invoked and the DNSServiceRef
+ * is not initialized.)
+ */
+
+DNSServiceErrorType DNSServiceBrowse
+ (
+ DNSServiceRef *sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ const char *regtype,
+ const char *domain, /* may be NULL */
+ DNSServiceBrowseReply callBack,
+ void *context /* may be NULL */
+ );
+
+/* DNSServiceResolve()
+ *
+ * Resolve a service name discovered via DNSServiceBrowse() to a target host name, port number, and
+ * txt record.
+ *
+ * Note: Applications should NOT use DNSServiceResolve() solely for txt record monitoring - use
+ * DNSServiceQueryRecord() instead, as it is more efficient for this task.
+ *
+ * Note: When the desired results have been returned, the client MUST terminate the resolve by calling
+ * DNSServiceRefDeallocate().
+ *
+ * Note: DNSServiceResolve() behaves correctly for typical services that have a single SRV record and
+ * a single TXT record (the TXT record may be empty.) To resolve non-standard services with multiple
+ * SRV or TXT records, DNSServiceQueryRecord() should be used.
+ *
+ * DNSServiceResolveReply Callback Parameters:
+ *
+ * sdRef: The DNSServiceRef initialized by DNSServiceResolve().
+ *
+ * flags: Currently unused, reserved for future use.
+ *
+ * interfaceIndex: The interface on which the service was resolved.
+ *
+ * errorCode: Will be kDNSServiceErr_NoError (0) on success, otherwise will
+ * indicate the failure that occurred. Other parameters are undefined if
+ * the errorCode is nonzero.
+ *
+ * fullname: The full service domain name, in the form <servicename>.<protocol>.<domain>.
+ * (Any literal dots (".") are escaped with a backslash ("\."), and literal
+ * backslashes are escaped with a second backslash ("\\"), e.g. a web server
+ * named "Dr. Pepper" would have the fullname "Dr\.\032Pepper._http._tcp.local.").
+ * This is the appropriate format to pass to standard system DNS APIs such as
+ * res_query(), or to the special-purpose functions included in this API that
+ * take fullname parameters.
+ *
+ * hosttarget: The target hostname of the machine providing the service. This name can
+ * be passed to functions like gethostbyname() to identify the host's IP address.
+ *
+ * port: The port number on which connections are accepted for this service.
+ *
+ * txtLen: The length of the txt record, in bytes.
+ *
+ * txtRecord: The service's primary txt record, in standard txt record format.
+ *
+
+ * context: The context pointer that was passed to the callout.
+ *
+ */
+
+typedef void (*DNSServiceResolveReply)
+ (
+ DNSServiceRef sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *fullname,
+ const char *hosttarget,
+ uint16_t port,
+ uint16_t txtLen,
+ const char *txtRecord,
+ void *context
+ );
+
+/* DNSServiceResolve() Parameters
+ *
+ * sdRef: A pointer to an uninitialized sdRef. May be passed to
+ * DNSServiceRefDeallocate() to terminate the resolve.
+ *
+ * flags: Currently ignored, reserved for future use.
+ *
+ * interfaceIndex: The interface on which to resolve the service. The client should
+ * pass the interface on which the servicename was discovered, i.e.
+ * the interfaceIndex passed to the DNSServiceBrowseReply callback,
+ * or 0 to resolve the named service on all available interfaces.
+ *
+ * name: The servicename to be resolved.
+ *
+ * regtype: The service type being resolved followed by the protocol, separated by a
+ * dot (e.g. "_ftp._tcp"). The transport protocol must be "_tcp" or "_udp".
+ *
+ * domain: The domain on which the service is registered, i.e. the domain passed
+ * to the DNSServiceBrowseReply callback.
+ *
+ * callBack: The function to be called when a result is found, or if the call
+ * asynchronously fails.
+ *
+ * context: An application context pointer which is passed to the callback function
+ * (may be NULL).
+ *
+ * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
+ * errors are delivered to the callback), otherwise returns an error code indicating
+ * the error that occurred (the callback is never invoked and the DNSServiceRef
+ * is not initialized.)
+ */
+
+
+DNSServiceErrorType DNSServiceResolve
+ (
+ DNSServiceRef *sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ const char *name,
+ const char *regtype,
+ const char *domain,
+ DNSServiceResolveReply callBack,
+ void *context /* may be NULL */
+ );
+
+
+/*********************************************************************************************
+ *
+ * Special Purpose Calls (most applications will not use these)
+ *
+ *********************************************************************************************/
+
+/* DNS Naming Conventions:
+ *
+ * The following functions refer to resource records by their full domain name, unlike the above
+ * functions which divide the name into servicename/regtype/domain fields. In the above functions,
+ * a dot (".") is considered to be a literal dot in the servicename field (e.g. "Dr. Pepper") and
+ * a label separator in the regtype ("_ftp._tcp") or domain ("apple.com") fields. Literal dots in
+ * the domain field would be escaped with a backslash, and literal backslashes would be escaped with
+ * a second backslash (this is generally not an issue, as domain names on the Internet today almost
+ * never use characters other than letters, digits, or hyphens, and the dots are label separators.)
+ * Furthermore, this is transparent to the caller, so long as the fields are passed between functions
+ * without manipulation. However, the following, special-purpose calls use a single, full domain name.
+ * As such, all dots are considered to be label separators, unless escaped, and all backslashes are
+ * considered to be escape characters, unless preceded by a second backslash. For example, the name
+ * "Dr. Smith \ Dr. Johnson" could be passed literally as a service name parameter in the above calls,
+ * but in the special purpose call, the dots and backslash would have to be escaped
+ * (e.g. "Dr\. Smith \\ Dr\. Johnson._ftp._tcp.apple.com" for an ftp service on the apple.com domain.)
+ */
+
+/* DNSServiceConstructFullName()
+ *
+ * Concatenate a three-part domain name (as returned by the above callbacks) into a properly-escaped
+ * full domain name. Note that callbacks in the above functions ALREADY ESCAPE strings where necessary.
+ *
+ * Parameters:
+ *
+ * fullName: A pointer to a buffer that where the resulting full domain name is to be written.
+ * The buffer must be kDNSServiceDiscoveryMaxDomainName (1005) bytes in length to
+ * accommodate the longest legal domain name without buffer overrun.
+ *
+ * service: The service name - any dots or slashes must NOT be escaped.
+ * May be NULL (to construct a PTR record name, e.g.
+ * "_ftp._tcp.apple.com").
+ *
+ * regtype: The service type followed by the protocol, separated by a dot
+ * (e.g. "_ftp._tcp").
+ *
+ * domain: The domain name, e.g. "apple.com". Any literal dots or backslashes
+ * must be escaped.
+ *
+ * return value: Returns 0 on success, -1 on error.
+ *
+ */
+
+int DNSServiceConstructFullName
+ (
+ char *fullName,
+ const char *service, /* may be NULL */
+ const char *regtype,
+ const char *domain
+ );
+
+/* DNSServiceCreateConnection()
+ *
+ * Create a connection to the daemon allowing efficient registration of
+ * multiple individual records.
+ *
+ *
+ * Parameters:
+ *
+ * sdRef: A pointer to an uninitialized DNSServiceRef. Deallocating
+ * the reference (via DNSServiceRefDeallocate()) severs the
+ * connection and deregisters all records registered on this connection.
+ *
+ * return value: Returns kDNSServiceErr_NoError on success, otherwise returns
+ * an error code indicating the specific failure that occurred (in which
+ * case the DNSServiceRef is not initialized).
+ */
+
+DNSServiceErrorType DNSServiceCreateConnection(DNSServiceRef *sdRef);
+
+
+/* DNSServiceRegisterRecord
+ *
+ * Register an individual resource record on a connected DNSServiceRef.
+ *
+ * Note that name conflicts occurring for records registered via this call must be handled
+ * by the client in the callback.
+ *
+ *
+ * DNSServiceRegisterRecordReply() parameters:
+ *
+ * sdRef: The connected DNSServiceRef initialized by
+ * DNSServiceDiscoveryConnect().
+ *
+ * RecordRef: The DNSRecordRef initialized by DNSServiceRegisterRecord(). If the above
+ * DNSServiceRef is passed to DNSServiceRefDeallocate(), this DNSRecordRef is
+ * invalidated, and may not be used further.
+ *
+ * flags: Currently unused, reserved for future use.
+ *
+ * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
+ * indicate the failure that occurred (including name conflicts.)
+ * Other parameters are undefined if errorCode is nonzero.
+ *
+ * context: The context pointer that was passed to the callout.
+ *
+ */
+
+ typedef void (*DNSServiceRegisterRecordReply)
+ (
+ DNSServiceRef sdRef,
+ DNSRecordRef RecordRef,
+ DNSServiceFlags flags,
+ DNSServiceErrorType errorCode,
+ void *context
+ );
+
+
+/* DNSServiceRegisterRecord() Parameters:
+ *
+ * sdRef: A DNSServiceRef initialized by DNSServiceCreateConnection().
+ *
+ * RecordRef: A pointer to an uninitialized DNSRecordRef. Upon succesfull completion of this
+ * call, this ref may be passed to DNSServiceUpdateRecord() or DNSServiceRemoveRecord().
+ * (To deregister ALL records registered on a single connected DNSServiceRef
+ * and deallocate each of their corresponding DNSServiceRecordRefs, call
+ * DNSServiceRefDealloocate()).
+ *
+ * flags: Possible values are Shared/Unique (see flag type definitions for details).
+ *
+ * interfaceIndex: If non-zero, specifies the interface on which to register the record
+ * (the index for a given interface is determined via the if_nametoindex()
+ * family of calls.) Passing 0 causes the record to be registered on all interfaces.
+ * Passing -1 causes the record to only be visible on the local host.
+ *
+ * fullname: The full domain name of the resource record.
+ *
+ * rrtype: The numerical type of the resource record (e.g. PTR, SRV, etc), as defined
+ * in nameser.h.
+ *
+ * rrclass: The class of the resource record, as defined in nameser.h (usually 1 for the
+ * Internet class).
+ *
+ * rdlen: Length, in bytes, of the rdata.
+ *
+ * rdata: A pointer to the raw rdata, as it is to appear in the DNS record.
+ *
+ * ttl: The time to live of the resource record, in seconds.
+ *
+ * callBack: The function to be called when a result is found, or if the call
+ * asynchronously fails (e.g. because of a name conflict.)
+ *
+ * context: An application context pointer which is passed to the callback function
+ * (may be NULL).
+ *
+ * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
+ * errors are delivered to the callback), otherwise returns an error code indicating
+ * the error that occurred (the callback is never invoked and the DNSRecordRef is
+ * not initialized.)
+ */
+
+
+DNSServiceErrorType DNSServiceRegisterRecord
+ (
+ DNSServiceRef sdRef,
+ DNSRecordRef *RecordRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ const char *fullname,
+ uint16_t rrtype,
+ uint16_t rrclass,
+ uint16_t rdlen,
+ const void *rdata,
+ uint32_t ttl,
+ DNSServiceRegisterRecordReply callBack,
+ void *context /* may be NULL */
+ );
+
+
+/* DNSServiceQueryRecord
+ *
+ * Query for an arbitrary DNS record.
+ *
+ *
+ * DNSServiceQueryRecordReply() Callback Parameters:
+ *
+ * sdRef: The DNSServiceRef initialized by DNSServiceQueryRecord().
+ *
+ * flags: Possible values are Finished/MoreComing.
+ *
+ * interfaceIndex: The interface on which the query was resolved (the index for a given
+ * interface is determined via the if_nametoindex() family of calls).
+ *
+ * errorCode: Will be kDNSServiceErr_NoError on success, otherwise will
+ * indicate the failure that occurred. Other parameters are undefined if
+ * errorCode is nonzero.
+ *
+ * fullname: The resource record's full domain name.
+ *
+ * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
+ *
+ * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
+ *
+ * rdlen: The length, in bytes, of the resource record rdata.
+ *
+ * rdata: The raw rdata of the resource record.
+ *
+ * ttl: The resource record's time to live, in seconds.
+ *
+ * context: The context pointer that was passed to the callout.
+ *
+ */
+
+typedef void (*DNSServiceQueryRecordReply)
+ (
+ DNSServiceRef DNSServiceRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ DNSServiceErrorType errorCode,
+ const char *fullname,
+ uint16_t rrtype,
+ uint16_t rrclass,
+ uint16_t rdlen,
+ const void *rdata,
+ uint32_t ttl,
+ void *context
+ );
+
+/* DNSServiceQueryRecord() Parameters:
+ *
+ * sdRef: A pointer to an uninitialized DNSServiceRef.
+ *
+ * flags: Currently unused, reserved for future use.
+ *
+ * interfaceIndex: If non-zero, specifies the interface on which to issue the query
+ * (the index for a given interface is determined via the if_nametoindex()
+ * family of calls.) Passing 0 causes the name to be queried for on all
+ * interfaces. Passing -1 causes the name to be queried for only on the
+ * local host.
+ *
+ * fullname: The full domain name of the resource record to be queried for.
+ *
+ * rrtype: The numerical type of the resource record to be queried for (e.g. PTR, SRV, etc)
+ * as defined in nameser.h.
+ *
+ * rrclass: The class of the resource record, as defined in nameser.h
+ * (usually 1 for the Internet class).
+ *
+ * callBack: The function to be called when a result is found, or if the call
+ * asynchronously fails.
+ *
+ * context: An application context pointer which is passed to the callback function
+ * (may be NULL).
+ *
+ * return value: Returns kDNSServiceErr_NoError on succeses (any subsequent, asynchronous
+ * errors are delivered to the callback), otherwise returns an error code indicating
+ * the error that occurred (the callback is never invoked and the DNSServiceRef
+ * is not initialized.)
+ */
+
+DNSServiceErrorType DNSServiceQueryRecord
+ (
+ DNSServiceRef *sdRef,
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ const char *fullname,
+ uint16_t rrtype,
+ uint16_t rrclass,
+ DNSServiceQueryRecordReply callBack,
+ void *context /* may be NULL */
+ );
+
+/* DNSServiceReconfirmRecord
+ *
+ * Instruct the daemon to verify the validity of a resource record that appears to
+ * be out of date (e.g. because tcp connection to a service's target failed.)
+ * Causes the record to be flushed from the daemon's cache (as well as all other
+ * daemons' caches on the network) if the record is determined to be invalid.
+ *
+ * Parameters:
+ *
+ * flags: Currently unused, reserved for future use.
+ *
+ * fullname: The resource record's full domain name.
+ *
+ * rrtype: The resource record's type (e.g. PTR, SRV, etc) as defined in nameser.h.
+ *
+ * rrclass: The class of the resource record, as defined in nameser.h (usually 1).
+ *
+ * rdlen: The length, in bytes, of the resource record rdata.
+ *
+ * rdata: The raw rdata of the resource record.
+ *
+ */
+
+void DNSServiceReconfirmRecord
+ (
+ DNSServiceFlags flags,
+ uint32_t interfaceIndex,
+ const char *fullname,
+ uint16_t rrtype,
+ uint16_t rrclass,
+ uint16_t rdlen,
+ const void *rdata
+ );
+
+
+#endif // _DNS_SD_H
+
--- /dev/null
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include "dnssd_ipc.h"
+#include <errno.h>
+#include <sys/time.h>
+
+
+
+#define CTL_PATH_PREFIX "/tmp/dnssd_clippath."
+// error socket (if needed) is named "dnssd_clipath.[pid].xxx:n" where xxx are the
+// last 3 digits of the time (in seconds) and n is the 6-digit microsecond time
+
+// general utility functions
+static DNSServiceRef connect_to_server(void);
+DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reuse_sd);
+static ipc_msg_hdr *create_hdr(int op, int *len, char **data_start, int reuse_socket);
+static int my_read(int sd, char *buf, int len);
+static int my_write(int sd, char *buf, int len);
+static int domain_ends_in_dot(const char *dom);
+// server response handlers
+static void handle_query_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *msg);
+static void handle_browse_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data);
+static void handle_regservice_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data);
+static void handle_regrecord_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data);
+static void handle_enumeration_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data);
+static void handle_resolve_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data);
+
+typedef struct _DNSServiceRef_t
+ {
+ int sockfd; // connected socket between client and daemon
+ int op; // request/reply_op_t
+ process_reply_callback process_reply;
+ void *app_callback;
+ void *app_context;
+ uint32_t max_index; //largest assigned record index - 0 if no additl. recs registered
+ } _DNSServiceRef_t;
+
+typedef struct _DNSRecordRef_t
+ {
+ void *app_context;
+ DNSServiceRegisterRecordReply app_callback;
+ DNSRecordRef recref;
+ int record_index; // index is unique to the ServiceDiscoveryRef
+ DNSServiceRef sdr;
+ } _DNSRecordRef_t;
+
+
+// exported functions
+
+int DNSServiceRefSockFD(DNSServiceRef sdRef)
+ {
+ if (!sdRef) return -1;
+ return sdRef->sockfd;
+ }
+
+// handle reply from server, calling application client callback. If there is no reply
+// from the daemon on the socket contained in sdRef, the call will block.
+DNSServiceErrorType DNSServiceProcessResult(DNSServiceRef sdRef)
+ {
+ ipc_msg_hdr hdr;
+ char *data;
+
+ if (!sdRef || sdRef->sockfd < 0 || !sdRef->process_reply)
+ return kDNSServiceErr_BadReference;
+
+ if (my_read(sdRef->sockfd, (void *)&hdr, sizeof(hdr)) < 0)
+ return kDNSServiceErr_Unknown;
+ if (hdr.version != VERSION)
+ return kDNSServiceErr_Incompatible;
+ data = malloc(hdr.datalen);
+ if (!data) return kDNSServiceErr_NoMemory;
+ if (my_read(sdRef->sockfd, data, hdr.datalen) < 0)
+ return kDNSServiceErr_Unknown;
+ sdRef->process_reply(sdRef, &hdr, data);
+ free(data);
+ return kDNSServiceErr_NoError;
+ }
+
+
+void DNSServiceRefDeallocate(DNSServiceRef sdRef)
+ {
+ if (!sdRef) return;
+ if (sdRef->sockfd > 0) close(sdRef->sockfd);
+ free(sdRef);
+ }
+
+
+DNSServiceErrorType DNSServiceResolve
+ (
+ DNSServiceRef *sdRef,
+ const DNSServiceFlags flags,
+ const uint32_t interfaceIndex,
+ const char *name,
+ const char *regtype,
+ const char *domain,
+ const DNSServiceResolveReply callBack,
+ void *context
+ )
+ {
+ char *msg = NULL, *ptr;
+ int len;
+ ipc_msg_hdr *hdr;
+ DNSServiceRef sdr;
+ DNSServiceErrorType err;
+
+ if (!sdRef) return kDNSServiceErr_BadParam;
+ *sdRef = NULL;
+
+ // calculate total message length
+ len = sizeof(flags);
+ len += sizeof(interfaceIndex);
+ len += strlen(name) + 1;
+ len += strlen(regtype) + 1;
+ len += strlen(domain) + 1;
+
+ hdr = create_hdr(resolve_request, &len, &ptr, 1);
+ if (!hdr) goto error;
+ msg = (void *)hdr;
+
+ put_flags(flags, &ptr);
+ put_long(interfaceIndex, &ptr);
+ put_string(name, &ptr);
+ put_string(regtype, &ptr);
+ put_string(domain, &ptr);
+
+ sdr = connect_to_server();
+ if (!sdr) goto error;
+ err = deliver_request(msg, sdr, 1);
+ if (err)
+ {
+ DNSServiceRefDeallocate(sdr);
+ return err;
+ }
+ sdr->op = resolve_request;
+ sdr->process_reply = handle_resolve_response;
+ sdr->app_callback = callBack;
+ sdr->app_context = context;
+ *sdRef = sdr;
+
+ return err;
+
+error:
+ if (msg) free(msg);
+ if (*sdRef) { free(*sdRef); *sdRef = NULL; }
+ return kDNSServiceErr_Unknown;
+ }
+
+
+static void handle_resolve_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data)
+ {
+ DNSServiceFlags flags;
+ char fullname[kDNSServiceMaxDomainName];
+ char target[kDNSServiceMaxDomainName];
+ uint16_t port, txtlen;
+ uint32_t ifi;
+ DNSServiceErrorType err;
+ char *txtrecord;
+
+ (void)hdr; //unused
+
+ flags = get_flags(&data);
+ ifi = get_long(&data);
+ err = get_error_code(&data);
+ get_string(&data, fullname, kDNSServiceMaxDomainName);
+ get_string(&data, target, kDNSServiceMaxDomainName);
+ port = get_short(&data);
+ txtlen = get_short(&data);
+ txtrecord = get_rdata(&data, txtlen);
+
+ ((DNSServiceResolveReply)sdr->app_callback)(sdr, flags, ifi, err, fullname, target, port, txtlen, txtrecord, sdr->app_context);
+ }
+
+
+
+
+DNSServiceErrorType DNSServiceQueryRecord
+(
+ DNSServiceRef *sdRef,
+ const DNSServiceFlags flags,
+ const uint32_t interfaceIndex,
+ const char *name,
+ const uint16_t rrtype,
+ const uint16_t rrclass,
+ const DNSServiceQueryRecordReply callBack,
+ void *context
+ )
+ {
+ char *msg = NULL, *ptr;
+ int len;
+ ipc_msg_hdr *hdr;
+ DNSServiceRef sdr;
+ DNSServiceErrorType err;
+
+ if (!sdRef) return kDNSServiceErr_BadParam;
+ *sdRef = NULL;
+
+ if (!name) name = "\0";
+
+ // calculate total message length
+ len = sizeof(flags);
+ len += sizeof(uint32_t); //interfaceIndex
+ len += strlen(name) + 1;
+ len += 2 * sizeof(uint16_t); // rrtype, rrclass
+
+ hdr = create_hdr(query_request, &len, &ptr, 1);
+ if (!hdr) goto error;
+ msg = (void *)hdr;
+
+ put_flags(flags, &ptr);
+ put_long(interfaceIndex, &ptr);
+ put_string(name, &ptr);
+ put_short(rrtype, &ptr);
+ put_short(rrclass, &ptr);
+
+ sdr = connect_to_server();
+ if (!sdr) goto error;
+ err = deliver_request(msg, sdr, 1);
+ if (err)
+ {
+ DNSServiceRefDeallocate(sdr);
+ return err;
+ }
+
+ sdr->op = query_request;
+ sdr->process_reply = handle_query_response;
+ sdr->app_callback = callBack;
+ sdr->app_context = context;
+ *sdRef = sdr;
+ return err;
+
+error:
+ if (msg) free(msg);
+ if (*sdRef) { free(*sdRef); *sdRef = NULL; }
+ return kDNSServiceErr_Unknown;
+ }
+
+
+static void handle_query_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data)
+ {
+ DNSServiceFlags flags;
+ uint32_t interfaceIndex, ttl;
+ DNSServiceErrorType errorCode;
+ char name[256];
+ uint16_t rrtype, rrclass, rdlen;
+ char *rdata;
+ (void)hdr;//Unused
+
+ flags = get_flags(&data);
+ interfaceIndex = get_long(&data);
+ errorCode = get_error_code(&data);
+ (get_string(&data, name, 256) < 0);
+ rrtype = get_short(&data);
+ rrclass = get_short(&data);
+ rdlen = get_short(&data);
+ rdata = get_rdata(&data, rdlen);
+ ttl = get_long(&data);
+ if (!rdata) return;
+ ((DNSServiceQueryRecordReply)sdr->app_callback)(sdr, flags, interfaceIndex, errorCode, name, rrtype, rrclass,
+ rdlen, rdata, ttl, sdr->app_context);
+ return;
+ }
+
+DNSServiceErrorType DNSServiceBrowse
+(
+ DNSServiceRef *sdRef,
+ const DNSServiceFlags flags,
+ const uint32_t interfaceIndex,
+ const char *regtype,
+ const char *domain,
+ const DNSServiceBrowseReply callBack,
+ void *context
+ )
+ {
+ char *msg = NULL, *ptr;
+ int len;
+ ipc_msg_hdr *hdr;
+ DNSServiceRef sdr;
+ DNSServiceErrorType err;
+
+ if (!sdRef) return kDNSServiceErr_BadParam;
+ *sdRef = NULL;
+
+ if (!domain) domain = "";
+
+ len = sizeof(flags);
+ len += sizeof(interfaceIndex);
+ len += strlen(regtype) + 1;
+ len += strlen(domain) + 1;
+
+ hdr = create_hdr(browse_request, &len, &ptr, 1);
+ if (!hdr) goto error;
+ msg = (char *)hdr;
+ put_flags(flags, &ptr);
+ put_long(interfaceIndex, &ptr);
+ put_string(regtype, &ptr);
+ put_string(domain, &ptr);
+
+ sdr = connect_to_server();
+ if (!sdr) goto error;
+ err = deliver_request(msg, sdr, 1);
+ if (err)
+ {
+ DNSServiceRefDeallocate(sdr);
+ return err;
+ }
+ sdr->op = browse_request;
+ sdr->process_reply = handle_browse_response;
+ sdr->app_callback = callBack;
+ sdr->app_context = context;
+ *sdRef = sdr;
+ return err;
+
+error:
+ if (msg) free(msg);
+ if (*sdRef) { free(*sdRef); *sdRef = NULL; }
+ return kDNSServiceErr_Unknown;
+ }
+
+
+
+
+static void handle_browse_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data)
+ {
+ DNSServiceFlags flags;
+ uint32_t interfaceIndex;
+ DNSServiceErrorType errorCode;
+ char replyName[256], replyType[256], replyDomain[256];
+ (void)hdr;//Unused
+
+ flags = get_flags(&data);
+ interfaceIndex = get_long(&data);
+ errorCode = get_error_code(&data);
+ get_string(&data, replyName, 256);
+ get_string(&data, replyType, 256);
+ get_string(&data, replyDomain, 256);
+ ((DNSServiceBrowseReply)sdr->app_callback)(sdr, flags, interfaceIndex, errorCode, replyName, replyType, replyDomain, sdr->app_context);
+ }
+
+
+DNSServiceErrorType DNSServiceRegister
+ (
+ DNSServiceRef *sdRef,
+ const DNSServiceFlags flags,
+ const uint32_t interfaceIndex,
+ const char *name,
+ const char *regtype,
+ const char *domain,
+ const char *host,
+ const uint16_t port,
+ const uint16_t txtLen,
+ const void *txtRecord,
+ const DNSServiceRegisterReply callBack,
+ void *context
+ )
+ {
+ char *msg = NULL, *ptr;
+ int len;
+ ipc_msg_hdr *hdr;
+ DNSServiceRef sdr;
+ DNSServiceErrorType err;
+
+ if (!sdRef) return kDNSServiceErr_BadParam;
+ *sdRef = NULL;
+
+ if (!name) name = "";
+ if (!regtype) return kDNSServiceErr_BadParam;
+ if (!domain) domain = "";
+ if (!host) host = "";
+ if (!txtRecord) (char *)txtRecord = "";
+
+ // auto-name must also have auto-rename
+ if (!name[0] && (flags & kDNSServiceFlagsNoAutoRename))
+ return kDNSServiceErr_BadParam;
+
+ // no callback must have auto-name
+ if (!callBack && name[0]) return kDNSServiceErr_BadParam;
+
+ len = sizeof(DNSServiceFlags);
+ len += sizeof(uint32_t); // interfaceIndex
+ len += strlen(name) + strlen(regtype) + strlen(domain) + strlen(host) + 4;
+ len += 2 * sizeof(uint16_t); // port, txtLen
+ len += txtLen;
+
+ hdr = create_hdr(reg_service_request, &len, &ptr, 1);
+ if (!hdr) goto error;
+ if (!callBack) hdr->flags |= IPC_FLAGS_NOREPLY;
+ msg = (char *)hdr;
+ put_flags(flags, &ptr);
+ put_long(interfaceIndex, &ptr);
+ put_string(name, &ptr);
+ put_string(regtype, &ptr);
+ put_string(domain, &ptr);
+ put_string(host, &ptr);
+ put_short(port, &ptr);
+ put_short(txtLen, &ptr);
+ put_rdata(txtLen, txtRecord, &ptr);
+
+ sdr = connect_to_server();
+ if (!sdr) goto error;
+ err = deliver_request(msg, sdr, 1);
+ if (err)
+ {
+ DNSServiceRefDeallocate(sdr);
+ return err;
+ }
+
+ sdr->op = reg_service_request;
+ sdr->process_reply = callBack ? handle_regservice_response : NULL;
+ sdr->app_callback = callBack;
+ sdr->app_context = context;
+ *sdRef = sdr;
+
+ return err;
+
+error:
+ if (msg) free(msg);
+ if (*sdRef) { free(*sdRef); *sdRef = NULL; }
+ return kDNSServiceErr_Unknown;
+ }
+
+
+static void handle_regservice_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data)
+ {
+ DNSServiceFlags flags;
+ uint32_t interfaceIndex;
+ DNSServiceErrorType errorCode;
+ char name[256], regtype[256], domain[256];
+ (void)hdr;//Unused
+
+ flags = get_flags(&data);
+ interfaceIndex = get_long(&data);
+ errorCode = get_error_code(&data);
+ get_string(&data, name, 256);
+ get_string(&data, regtype, 256);
+ get_string(&data, domain, 256);
+ ((DNSServiceRegisterReply)sdr->app_callback)(sdr, flags, errorCode, name, regtype, domain, sdr->app_context);
+ }
+
+DNSServiceErrorType DNSServiceEnumerateDomains
+(
+ DNSServiceRef *sdRef,
+ const DNSServiceFlags flags,
+ const uint32_t interfaceIndex,
+ const DNSServiceDomainEnumReply callBack,
+ void *context
+ )
+ {
+ char *msg = NULL, *ptr;
+ int len;
+ ipc_msg_hdr *hdr;
+ DNSServiceRef sdr;
+ DNSServiceErrorType err;
+
+
+ if (!sdRef) return kDNSServiceErr_BadParam;
+ *sdRef = NULL;
+
+ len = sizeof(DNSServiceFlags);
+ len += sizeof(uint32_t);
+
+ hdr = create_hdr(enumeration_request, &len, &ptr, 1);
+ if (!hdr) goto error;
+ msg = (void *)hdr;
+
+ put_flags(flags, &ptr);
+ put_long(interfaceIndex, &ptr);
+
+ sdr = connect_to_server();
+ if (!sdr) goto error;
+ err = deliver_request(msg, sdr, 1);
+ if (err)
+ {
+ DNSServiceRefDeallocate(sdr);
+ return err;
+ }
+
+ sdr->op = enumeration_request;
+ sdr->process_reply = handle_enumeration_response;
+ sdr->app_callback = callBack;
+ sdr->app_context = context;
+ *sdRef = sdr;
+ return err;
+
+error:
+ if (msg) free(msg);
+ if (*sdRef) { free(*sdRef); *sdRef = NULL; }
+ return kDNSServiceErr_Unknown;
+ }
+
+
+static void handle_enumeration_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data)
+ {
+ DNSServiceFlags flags;
+ uint32_t interfaceIndex;
+ DNSServiceErrorType err;
+ char domain[256];
+ (void)hdr;//Unused
+
+ flags = get_flags(&data);
+ interfaceIndex = get_long(&data);
+ err = get_error_code(&data);
+ get_string(&data, domain, 256);
+ ((DNSServiceDomainEnumReply)sdr->app_callback)(sdr, flags, interfaceIndex, err, domain, sdr->app_context);
+ }
+
+
+DNSServiceErrorType DNSServiceCreateConnection(DNSServiceRef *sdRef)
+ {
+ if (!sdRef) return kDNSServiceErr_BadParam;
+ *sdRef = connect_to_server();
+ if (!*sdRef)
+ return kDNSServiceErr_Unknown;
+ (*sdRef)->op = connection;
+ (*sdRef)->process_reply = handle_regrecord_response;
+ return 0;
+ }
+
+
+
+static void handle_regrecord_response(DNSServiceRef sdr, ipc_msg_hdr *hdr, char *data)
+ {
+ DNSServiceFlags flags;
+ uint32_t interfaceIndex;
+ DNSServiceErrorType errorCode;
+ DNSRecordRef rref = hdr->client_context.context;
+
+ if (sdr->op != connection)
+ {
+ rref->app_callback(rref->sdr, rref, 0, kDNSServiceErr_Unknown, rref->app_context);
+ return;
+ }
+ flags = get_flags(&data);
+ interfaceIndex = get_long(&data);
+ errorCode = get_error_code(&data);
+
+ rref->app_callback(rref->sdr, rref, flags, errorCode, rref->app_context);
+ }
+
+DNSServiceErrorType DNSServiceRegisterRecord
+(
+ const DNSServiceRef sdRef,
+ DNSRecordRef *RecordRef,
+ const DNSServiceFlags flags,
+ const uint32_t interfaceIndex,
+ const char *fullname,
+ const uint16_t rrtype,
+ const uint16_t rrclass,
+ const uint16_t rdlen,
+ const void *rdata,
+ const uint32_t ttl,
+ const DNSServiceRegisterRecordReply callBack,
+ void *context
+ )
+ {
+ char *msg = NULL, *ptr;
+ int len;
+ ipc_msg_hdr *hdr = NULL;
+ DNSServiceRef tmp = NULL;
+ DNSRecordRef rref = NULL;
+
+ if (!sdRef || sdRef->op != connection || sdRef->sockfd < 0)
+ return kDNSServiceErr_BadReference;
+ *RecordRef = NULL;
+
+ len = sizeof(DNSServiceFlags);
+ len += 2 * sizeof(uint32_t); // interfaceIndex, ttl
+ len += 3 * sizeof(uint16_t); // rrtype, rrclass, rdlen
+ len += strlen(fullname) + 1;
+ len += rdlen;
+
+ hdr = create_hdr(reg_record_request, &len, &ptr, 0);
+ if (!hdr) goto error;
+ msg = (char *)hdr;
+ put_flags(flags, &ptr);
+ put_long(interfaceIndex, &ptr);
+ put_string(fullname, &ptr);
+ put_short(rrtype, &ptr);
+ put_short(rrclass, &ptr);
+ put_short(rdlen, &ptr);
+ put_rdata(rdlen, rdata, &ptr);
+ put_long(ttl, &ptr);
+
+ rref = malloc(sizeof(_DNSRecordRef_t));
+ if (!rref) goto error;
+ rref->app_context = context;
+ rref->app_callback = callBack;
+ rref->record_index = sdRef->max_index++;
+ rref->sdr = sdRef;
+ *RecordRef = rref;
+ hdr->client_context.context = rref;
+ hdr->reg_index = rref->record_index;
+
+ return deliver_request(msg, sdRef, 0);
+
+error:
+ if (rref) free(rref);
+ if (tmp) free(tmp);
+ if (hdr) free(hdr);
+ return kDNSServiceErr_Unknown;
+ }
+
+//sdRef returned by DNSServiceRegister()
+DNSServiceErrorType DNSServiceAddRecord
+ (
+ const DNSServiceRef sdRef,
+ DNSRecordRef *RecordRef,
+ const DNSServiceFlags flags,
+ const uint16_t rrtype,
+ const uint16_t rdlen,
+ const void *rdata,
+ const uint32_t ttl
+ )
+ {
+ ipc_msg_hdr *hdr;
+ int len = 0;
+ char *ptr;
+ DNSRecordRef rref;
+
+ if (!sdRef || (sdRef->op != reg_service_request) || !RecordRef)
+ return kDNSServiceErr_BadReference;
+ *RecordRef = NULL;
+
+ len += 2 * sizeof(uint16_t); //rrtype, rdlen
+ len += rdlen;
+ len += sizeof(uint32_t);
+ len += sizeof(DNSServiceFlags);
+
+ hdr = create_hdr(add_record_request, &len, &ptr, 0);
+ if (!hdr) return kDNSServiceErr_Unknown;
+ put_flags(flags, &ptr);
+ put_short(rrtype, &ptr);
+ put_short(rdlen, &ptr);
+ put_rdata(rdlen, rdata, &ptr);
+ put_long(ttl, &ptr);
+
+ rref = malloc(sizeof(_DNSRecordRef_t));
+ if (!rref) goto error;
+ rref->app_context = NULL;
+ rref->app_callback = NULL;
+ rref->record_index = sdRef->max_index++;
+ rref->sdr = sdRef;
+ *RecordRef = rref;
+ hdr->client_context.context = rref;
+ hdr->reg_index = rref->record_index;
+ return deliver_request((char *)hdr, sdRef, 0);
+
+error:
+ if (hdr) free(hdr);
+ if (rref) free(rref);
+ if (*RecordRef) *RecordRef = NULL;
+ return kDNSServiceErr_Unknown;
+}
+
+
+//DNSRecordRef returned by DNSServiceRegisterRecord or DNSServiceAddRecord
+DNSServiceErrorType DNSServiceUpdateRecord
+ (
+ const DNSServiceRef sdRef,
+ DNSRecordRef RecordRef,
+ const DNSServiceFlags flags,
+ const uint16_t rdlen,
+ const void *rdata,
+ const uint32_t ttl
+ )
+ {
+ ipc_msg_hdr *hdr;
+ int len = 0;
+ char *ptr;
+
+ if (!sdRef || !RecordRef || !sdRef->max_index)
+ return kDNSServiceErr_BadReference;
+
+ len += sizeof(uint16_t);
+ len += rdlen;
+ len += sizeof(uint32_t);
+ len += sizeof(DNSServiceFlags);
+
+ hdr = create_hdr(update_record_request, &len, &ptr, 0);
+ if (!hdr) return kDNSServiceErr_Unknown;
+ hdr->reg_index = RecordRef ? RecordRef->record_index : TXT_RECORD_INDEX;
+ put_flags(flags, &ptr);
+ put_short(rdlen, &ptr);
+ put_rdata(rdlen, rdata, &ptr);
+ put_long(ttl, &ptr);
+ return deliver_request((char *)hdr, sdRef, 0);
+ }
+
+
+
+DNSServiceErrorType DNSServiceRemoveRecord
+(
+ const DNSServiceRef sdRef,
+ const DNSRecordRef RecordRef,
+ const DNSServiceFlags flags
+ )
+ {
+ ipc_msg_hdr *hdr;
+ int len = 0;
+ char *ptr;
+ DNSServiceErrorType err;
+
+ if (!sdRef || !RecordRef || !sdRef->max_index)
+ return kDNSServiceErr_BadReference;
+
+ len += sizeof(flags);
+ hdr = create_hdr(remove_record_request, &len, &ptr, 0);
+ if (!hdr) return kDNSServiceErr_Unknown;
+ hdr->reg_index = RecordRef->record_index;
+ put_flags(flags, &ptr);
+ err = deliver_request((char *)hdr, sdRef, 0);
+ if (!err) free(RecordRef);
+ return err;
+ }
+
+
+void DNSServiceReconfirmRecord
+(
+ const DNSServiceFlags flags,
+ const uint32_t interfaceIndex,
+ const char *fullname,
+ const uint16_t rrtype,
+ const uint16_t rrclass,
+ const uint16_t rdlen,
+ const void *rdata
+ )
+ {
+ char *ptr;
+ int len;
+ ipc_msg_hdr *hdr;
+ DNSServiceRef tmp;
+
+ len = sizeof(DNSServiceFlags);
+ len += sizeof(uint32_t);
+ len += strlen(fullname) + 1;
+ len += 3 * sizeof(uint16_t);
+ len += rdlen;
+ tmp = connect_to_server();
+ if (!tmp) return;
+ hdr = create_hdr(reconfirm_record_request, &len, &ptr, 1);
+ if (!hdr) return;
+
+ put_flags(flags, &ptr);
+ put_long(interfaceIndex, &ptr);
+ put_string(fullname, &ptr);
+ put_short(rrtype, &ptr);
+ put_short(rrclass, &ptr);
+ put_short(rdlen, &ptr);
+ put_rdata(rdlen, rdata, &ptr);
+ my_write(tmp->sockfd, (char *)hdr, len);
+ DNSServiceRefDeallocate(tmp);
+ }
+
+
+int DNSServiceConstructFullName
+ (
+ char *fullName,
+ const char *service, /* may be NULL */
+ const char *regtype,
+ const char *domain
+ )
+ {
+ int len;
+ u_char c;
+ char *fn = fullName;
+ const char *s = service;
+ const char *r = regtype;
+ const char *d = domain;
+
+ if (service)
+ {
+ while(*s)
+ {
+ c = *s++;
+ if (c == '.' || (c == '\\')) *fn++ = '\\'; // escape dot and backslash literals
+ else if (c <= ' ') // escape non-printable characters
+ {
+ *fn++ = '\\';
+ *fn++ = (char) ('0' + (c / 100));
+ *fn++ = (char) ('0' + (c / 10) % 10);
+ c = (u_char)('0' + (c % 10));
+ }
+ *fn++ = c;
+ }
+ *fn++ = '.';
+ }
+
+ if (!regtype) return -1;
+ len = strlen(regtype);
+ if (domain_ends_in_dot(regtype)) len--;
+ if (len < 4) return -1; // regtype must end in _udp or _tcp
+ if (strncmp((regtype + len - 4), "_tcp", 4) && strncmp((regtype + len - 4), "_udp", 4)) return -1;
+ while(*r)
+ *fn++ = *r++;
+ if (!domain_ends_in_dot(regtype)) *fn++ = '.';
+
+ if (!domain) return -1;
+ len = strlen(domain);
+ if (!len) return -1;
+ while(*d)
+ *fn++ = *d++;
+ if (!domain_ends_in_dot(domain)) *fn++ = '.';
+ *fn = '\0';
+ return 0;
+ }
+
+static int domain_ends_in_dot(const char *dom)
+ {
+ while(*dom && *(dom + 1))
+ {
+ if (*dom == '\\') // advance past escaped byte sequence
+ {
+ if (*(dom + 1) >= '0' && *(dom + 1) <= '9') dom += 4;
+ else dom += 2;
+ }
+ else dom++; // else read one character
+ }
+ return (*dom == '.');
+ }
+
+
+
+ // return a connected service ref (deallocate with DNSServiceRefDeallocate)
+static DNSServiceRef connect_to_server(void)
+ {
+ struct sockaddr_un saddr;
+ DNSServiceRef sdr;
+
+ sdr = malloc(sizeof(_DNSServiceRef_t));
+ if (!sdr) return NULL;
+
+ if ((sdr->sockfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
+ {
+ free(sdr);
+ return NULL;
+ }
+
+ saddr.sun_family = AF_LOCAL;
+ strcpy(saddr.sun_path, MDNS_UDS_SERVERPATH);
+ if (connect(sdr->sockfd, (struct sockaddr *)&saddr, sizeof(saddr)) < 0)
+ {
+ free(sdr);
+ return NULL;
+ }
+ return sdr;
+ }
+
+
+
+
+int my_write(int sd, char *buf, int len)
+ {
+ if (send(sd, buf, len, MSG_WAITALL) != len) return -1;
+ return 0;
+ }
+
+
+// read len bytes. return 0 on success, -1 on error
+int my_read(int sd, char *buf, int len)
+ {
+ if (recv(sd, buf, len, MSG_WAITALL) != len) return -1;
+ return 0;
+ }
+
+
+DNSServiceErrorType deliver_request(void *msg, DNSServiceRef sdr, int reuse_sd)
+ {
+ ipc_msg_hdr *hdr = msg;
+ mode_t mask;
+ struct sockaddr_un caddr, daddr; // (client and daemon address structs)
+ char *path = NULL;
+ int listenfd = -1, errsd = -1, len;
+ DNSServiceErrorType err = kDNSServiceErr_Unknown;
+
+ if (!hdr || sdr->sockfd < 0) return kDNSServiceErr_Unknown;
+
+ if (!reuse_sd)
+ {
+ // setup temporary error socket
+ if ((listenfd = socket(AF_LOCAL, SOCK_STREAM, 0)) < 0)
+ goto cleanup;
+
+ bzero(&caddr, sizeof(caddr));
+ caddr.sun_family = AF_LOCAL;
+ caddr.sun_len = sizeof(struct sockaddr_un);
+ path = (char *)msg + sizeof(ipc_msg_hdr);
+ strcpy(caddr.sun_path, path);
+ mask = umask(0);
+ if (bind(listenfd, (struct sockaddr *)&caddr, sizeof(caddr)) < 0)
+ {
+ umask(mask);
+ goto cleanup;
+ }
+ umask(mask);
+ listen(listenfd, 1);
+ }
+
+ if (my_write(sdr->sockfd, msg, hdr->datalen + sizeof(ipc_msg_hdr)) < 0)
+ goto cleanup;
+ free(msg);
+ msg = NULL;
+
+ if (reuse_sd) errsd = sdr->sockfd;
+ else
+ {
+ len = sizeof(daddr);
+ errsd = accept(listenfd, (struct sockaddr *)&daddr, &len);
+ if (errsd < 0) goto cleanup;
+ }
+
+ len = recv(errsd, &err, sizeof(err), MSG_WAITALL);
+ if (len != sizeof(err))
+ {
+ err = kDNSServiceErr_Unknown;
+ }
+cleanup:
+ if (!reuse_sd && listenfd > 0) close(listenfd);
+ if (!reuse_sd && errsd > 0) close(errsd);
+ if (!reuse_sd && path) unlink(path);
+ if (msg) free(msg);
+ return err;
+ }
+
+
+
+/* create_hdr
+ *
+ * allocate and initialize an ipc message header. value of len should initially be the
+ * length of the data, and is set to the value of the data plus the header. data_start
+ * is set to point to the beginning of the data section. reuse_socket should be non-zero
+ * for calls that can receive an immediate error return value on their primary socket.
+ * if zero, the path to a control socket is appended at the beginning of the message buffer.
+ * data_start is set past this string.
+ */
+
+static ipc_msg_hdr *create_hdr(int op, int *len, char **data_start, int reuse_socket)
+ {
+ char *msg = NULL;
+ ipc_msg_hdr *hdr;
+ int datalen;
+ char ctrl_path[256];
+ struct timeval time;
+
+ if (!reuse_socket)
+ {
+ if (gettimeofday(&time, NULL) < 0) return NULL;
+ sprintf(ctrl_path, "%s%d-%.3x-%.6u", CTL_PATH_PREFIX, (int)getpid(),
+ time.tv_sec & 0xFFF, time.tv_usec);
+
+ *len += strlen(ctrl_path) + 1;
+ }
+
+
+ datalen = *len;
+ *len += sizeof(ipc_msg_hdr);
+
+ // write message to buffer
+ msg = malloc(*len);
+ if (!msg) return NULL;
+
+ bzero(msg, *len);
+ hdr = (void *)msg;
+ hdr->datalen = datalen;
+ hdr->version = VERSION;
+ hdr->op.request_op = op;
+ if (reuse_socket) hdr->flags |= IPC_FLAGS_REUSE_SOCKET;
+ *data_start = msg + sizeof(ipc_msg_hdr);
+ if (!reuse_socket) put_string(ctrl_path, data_start);
+ return hdr;
+ }
--- /dev/null
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+#include "dnssd_ipc.h"
+
+
+void put_flags(const DNSServiceFlags flags, char **ptr)
+ {
+ memcpy(*ptr, &flags, sizeof(DNSServiceFlags));
+ *ptr += sizeof(flags);
+ }
+
+DNSServiceFlags get_flags(char **ptr)
+ {
+ DNSServiceFlags flags;
+
+ flags = *(DNSServiceFlags *)*ptr;
+ *ptr += sizeof(DNSServiceFlags);
+ return flags;
+ }
+
+void put_long(const uint32_t l, char **ptr)
+ {
+
+ *(uint32_t *)(*ptr) = l;
+ *ptr += sizeof(uint32_t);
+ }
+
+uint32_t get_long(char **ptr)
+ {
+ uint32_t l;
+
+ l = *(uint32_t *)(*ptr);
+ *ptr += sizeof(uint32_t);
+ return l;
+ }
+
+void put_error_code(const DNSServiceErrorType error, char **ptr)
+ {
+ memcpy(*ptr, &error, sizeof(error));
+ *ptr += sizeof(DNSServiceErrorType);
+ }
+
+DNSServiceErrorType get_error_code(char **ptr)
+ {
+ DNSServiceErrorType error;
+
+ error = *(DNSServiceErrorType *)(*ptr);
+ *ptr += sizeof(DNSServiceErrorType);
+ return error;
+ }
+
+void put_short(const uint16_t s, char **ptr)
+ {
+ *(uint16_t *)(*ptr) = s;
+ *ptr += sizeof(uint16_t);
+ }
+
+uint16_t get_short(char **ptr)
+ {
+ uint16_t s;
+
+ s = *(uint16_t *)(*ptr);
+ *ptr += sizeof(uint16_t);
+ return s;
+ }
+
+
+int put_string(const char *str, char **ptr)
+ {
+ if (!str) str = "";
+ strcpy(*ptr, str);
+ *ptr += strlen(str) + 1;
+ return 0;
+ }
+
+// !!!KRS we don't properly handle the case where the string is longer than the buffer!!!
+int get_string(char **ptr, char *buffer, int buflen)
+ {
+ int overrun;
+
+ overrun = (int)strlen(*ptr) < buflen ? 0 : -1;
+ strncpy(buffer, *ptr, buflen - 1);
+ buffer[buflen - 1] = '\0';
+ *ptr += strlen(buffer) + 1;
+ return overrun;
+ }
+
+void put_rdata(const int rdlen, const char *rdata, char **ptr)
+ {
+ memcpy(*ptr, rdata, rdlen);
+ *ptr += rdlen;
+ }
+
+char *get_rdata(char **ptr, int rdlen)
+ {
+ char *rd;
+
+ rd = *ptr;
+ *ptr += rdlen;
+ return rd;
+ }
+
+
+
+
+
+
+
+
+
--- /dev/null
+/*
+ * Copyright (c) 2003 Apple Computer, Inc. All rights reserved.
+ *
+ * @APPLE_LICENSE_HEADER_START@
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
+ * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
+ * @APPLE_LICENSE_HEADER_END@
+ */
+
+
+
+#ifndef DNSSD_IPC_H
+#define DNSSD_IPC_H
+
+#include "dns_sd.h"
+#include <sys/types.h>
+#include <unistd.h>
+#include <sys/un.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+
+#define UDSDEBUG // verbose debug output
+
+// General UDS constants
+#define MDNS_UDS_SERVERPATH "/var/run/mDNSResponder"
+#define LISTENQ 100
+#define TXT_RECORD_INDEX -1 // record index for default text record
+#define MAX_CTLPATH 256 // longest legal control path length
+
+// IPC data encoding constants and types
+#define VERSION 1
+#define IPC_FLAGS_NOREPLY 1 // set flag if no asynchronous replies are to be sent to client
+#define IPC_FLAGS_REUSE_SOCKET 2 // set flag if synchronous errors are to be sent via the primary socket
+ // (if not set, first string in message buffer must be path to error socket
+
+
+typedef enum
+ {
+ connection = 1, // connected socket via DNSServiceConnect()
+ reg_record_request, // reg/remove record only valid for connected sockets
+ remove_record_request,
+ enumeration_request,
+ reg_service_request,
+ browse_request,
+ resolve_request,
+ query_request,
+ reconfirm_record_request,
+ add_record_request,
+ update_record_request
+ } request_op_t;
+
+typedef enum
+ {
+ enumeration_reply = 64,
+ reg_service_reply,
+ browse_reply,
+ resolve_reply,
+ query_reply,
+ reg_record_reply
+ } reply_op_t;
+
+
+typedef struct ipc_msg_hdr_struct ipc_msg_hdr;
+
+
+// client stub callback to process message from server and deliver results to
+// client application
+
+typedef void (*process_reply_callback)
+ (
+ DNSServiceRef sdr,
+ ipc_msg_hdr *hdr,
+ char *msg
+ );
+
+// allow 64-bit client to interoperate w/ 32-bit daemon
+typedef union
+ {
+ void *context;
+ uint32_t ptr64[2];
+ } client_context_t;
+
+
+typedef struct ipc_msg_hdr_struct
+ {
+ uint32_t version;
+ uint32_t datalen;
+ uint32_t flags;
+ union
+ {
+ request_op_t request_op;
+ reply_op_t reply_op;
+ } op;
+ client_context_t client_context; // context passed from client, returned by server in corresponding reply
+ int reg_index; // identifier for a record registered via DNSServiceRegisterRecord() on a
+ // socket connected by DNSServiceConnect(). Must be unique in the scope of the connection, such that and
+ // index/socket pair uniquely identifies a record. (Used to select records for removal by DNSServiceRemoveRecord())
+ } ipc_msg_hdr_struct;
+
+
+
+
+// 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.
+// it is advanced to point to the next field, or the end of the message
+
+
+void put_flags(const DNSServiceFlags flags, char **ptr);
+DNSServiceFlags get_flags(char **ptr);
+
+void put_long(const uint32_t l, char **ptr);
+uint32_t get_long(char **ptr);
+
+void put_error_code(const DNSServiceErrorType, char **ptr);
+DNSServiceErrorType get_error_code(char **ptr);
+
+int put_string(const char *str, char **ptr);
+int get_string(char **ptr, char *buffer, int buflen);
+
+void put_rdata(const int rdlen, const char *rdata, char **ptr);
+char *get_rdata(char **ptr, int rdlen); // return value is rdata pointed to by *ptr -
+ // rdata is not copied from buffer.
+
+void put_short(uint16_t s, char **ptr);
+uint16_t get_short(char **ptr);
+
+
+
+#endif // DNSSD_IPC_H
+
+
+
+
+
+
+
+
+
+
+
PROF_LIBS = $(LIBS)
-PUBLIC_HEADERS = ni.h ni_util.h nibind_prot.x ni_prot.x
+PRIVATE_HEADERS = ni.h ni_util.h nibind_prot.x ni_prot.x
NETINFO_HEADERS = nibind_prot.h ni_prot.h
AFTER_PREBUILD = $(NETINFO_HEADERS)
AFTER_POSTINSTALL += install-netinfo-man
-OTHER_PUBLIC_HEADERS = $(NETINFO_HEADERS)
+OTHER_PRIVATE_HEADERS = $(NETINFO_HEADERS)
BEFORE_INSTALLHEADERS += $(NETINFO_HEADERS)
-PUBLIC_HEADER_DIR_SUFFIX = /netinfo
+PRIVATE_HEADER_DIR = /usr/local/include/netinfo
netinfo.3,
netinfo.5
);
- PUBLIC_HEADERS = (ni.h, ni_util.h);
+ PRIVATE_HEADERS = (ni.h, ni_util.h, ni_prot.x, nibind_prot.x);
};
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
if (!xdr_u_int(xdr, &port) ||
!xdr_u_int(xdr, &len) ||
- !(buf = xdr_inline(xdr, len))) {
+ !(buf = (long *)xdr_inline(xdr, len))) {
return (0);
}
xdrmem_create(&bufxdr, (char *)buf, len * BYTES_PER_XDR_UNIT,
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#define SUN_RPC 1
#endif
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#include <rpc/rpc.h>
#include <netinfo/ni_prot.h>
#include <netinfo/nibind_prot.h>
void ni_setabort(void *, int);
void ni_needwrite(void *, int);
-#endif __NI_HEADER__
\ No newline at end of file
+#ifdef __cplusplus
+}
+#endif
+
+#endif __NI_HEADER__
+
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <rpc/xdr.h>
#include <net/if.h>
#include <ctype.h>
+#include <errno.h>
#include "clib.h"
#include "sys_interfaces.h"
ni_clear(ni);
if (get_daddr(dupni, ".", ni) == 0)
{
- if (oldni->abort == 1) break;
+ if (oldni->abort == 1)
+ {
+ ni_free(dupni);
+ break;
+ }
}
else
{
void *
-ni_new(
- void *oldni,
- const char *domain
- )
+ni_new(void *oldni, const char *domain)
{
ni_private *ni;
ni_status status;
struct sockaddr_in sin;
struct hostent *he;
- if (oldni == NULL) {
+ if (domain == NULL) return NULL;
+
+ sep = index(domain, '@');
+ if (sep != NULL)
+ {
+ tag = strncpy((char *)malloc(sep - domain + 1), domain, sep - domain);
+ tag[sep - domain] = '\0';
+ addr = strcpy ((char *)malloc(strlen(sep + 1)), sep + 1);
+ sin.sin_addr.s_addr = inet_addr(addr);
+ if (sin.sin_addr.s_addr == INADDR_NONE)
+ {
+ he = gethostbyname(addr);
+ if (he == NULL)
+ {
+ free(addr);
+ free(tag);
+ return NULL;
+ }
+
+ bcopy(he->h_addr_list[0], &sin.sin_addr.s_addr, he->h_length);
+ }
+
+ ni = ni_connect(&sin, tag);
+ free(addr);
+ free(tag);
+
+ return (void *)ni;
+ }
+
+ ni = NULL;
+
+ if (oldni == NULL)
+ {
ni = ni_alloc();
- if (!connectlocal(ni)) {
+ if (connectlocal(ni) == 0)
+ {
free(ni);
- return (NULL);
+ return NULL;
}
- if (strcmp(domain, "..") == 0) {
+
+ if (strcmp(domain, ".") == 0) return (void *)ni;
+
+ if (strcmp(domain, "..") == 0)
+ {
oldni = ni;
status = getparent((ni_private *)oldni, &ni);
ni_free(oldni);
- if (status != NI_OK) {
- return (NULL);
- }
- } else if ((sep = index(domain, '@')) != NULL) {
- free(ni);
- tag = strncpy((char *)malloc(sep-domain+1), domain, sep-domain);
- tag[sep-domain] = '\0';
- addr = strcpy ((char *)malloc(strlen(sep+1)), sep+1);
- sin.sin_addr.s_addr = inet_addr(addr);
- if (sin.sin_addr.s_addr == INADDR_NONE) {
- he = gethostbyname(addr);
- if (he == NULL) {
- free(addr);
- free(tag);
- return (NULL);
- }
- bcopy(he->h_addr_list[0], &sin.sin_addr.s_addr, he->h_length);
- }
- ni = ni_connect(&sin, tag);
- free(addr);
- free(tag);
- } else if (strcmp(domain, ".") != 0) {
- /*
- * nothing else makes sense
- */
- free(ni);
- return (NULL);
- }
- } else {
- if (strcmp(domain, "..") == 0) {
- status = getparent((ni_private *)oldni, &ni);
- if (status != NI_OK) {
- return (NULL);
- }
- } else if ((sep = index(domain, '@')) != NULL) {
- tag = strncpy((char *)malloc(sep-domain+1), domain, sep-domain);
- tag[sep-domain] = '\0';
- addr = strcpy ((char *)malloc(strlen(sep+1)), sep+1);
- sin.sin_addr.s_addr = inet_addr(addr);
- if (sin.sin_addr.s_addr == INADDR_NONE) {
- he = gethostbyname(addr);
- if (he == NULL) {
- free(addr);
- free(tag);
- return (NULL);
- }
- bcopy(he->h_addr_list[0], &sin.sin_addr.s_addr, he->h_length);
- }
- ni = ni_connect(&sin, tag);
- free(addr);
- free(tag);
- } else {
- ni = ni_alloc();
- *ni = *NIP(oldni);
- ni_clear(ni);
- if (!get_daddr(oldni, (ni_name)domain, ni)) {
- ni_free(ni);
- ni = NULL;
- }
+ if (status != NI_OK) return NULL;
+ return (void *)ni;
}
+
+ ni_free(ni);
+ return NULL;
}
- return ((void *)ni);
+
+ if (strcmp(domain, "..") == 0)
+ {
+ status = getparent((ni_private *)oldni, &ni);
+ if (status != NI_OK) return NULL;
+ return (void *)ni;
+ }
+
+ ni = ni_alloc();
+ *ni = *NIP(oldni);
+ ni_clear(ni);
+ if (!get_daddr(oldni, (ni_name)domain, ni))
+ {
+ ni_free(ni);
+ return NULL;
+ }
+
+ return (void *)ni;
}
int proto
)
{
+ struct sockaddr_in bindsin;
int sock;
int reuse = 1;
+ memset(&bindsin, 0, sizeof(bindsin));
+
/*
* If no port number given ask the pmap for one
*/
if (sock < 0) {
return (-1);
}
- (void)bindresvport(sock, (struct sockaddr_in *)0);
+ if (-1 == bindresvport(sock, NULL) && errno == EADDRNOTAVAIL) {
+ /* XXX - we're hitting this case way too often under load */
+ /* fail gracefully: some address is better than none most of the time */
+ syslog(LOG_DEBUG, "Libinfo[%s():%d] bindresvport(): %m", __func__, __LINE__);
+ if (-1 == bind(sock, &bindsin, sizeof(bindsin))) {
+ /* The system is really sad now if it can't give me any address... */
+ syslog(LOG_DEBUG, "Libinfo[%s():%d] bind(): %m", __func__, __LINE__);
+ (void)close(sock);
+ return -1;
+ }
+ }
setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, &reuse, sizeof(int));
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuse, sizeof(int));
if (proto == IPPROTO_TCP) {
if (connect(sock, (struct sockaddr *)raddr,
sizeof(*raddr)) < 0) {
+ syslog(LOG_DEBUG, "Libinfo[%s():%d] connect(): %m", __func__, __LINE__);
(void)close(sock);
return (-1);
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <netinfo/ni.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#define NI_INDEX_NULL ((ni_index)-1)
#define NI_INIT(objp) bzero((void *)(objp), sizeof(*(objp)))
*/
ni_status ni_url(char *, void **, ni_id *);
-#endif !_NI_UTIL_H_
\ No newline at end of file
+#ifdef __cplusplus
+}
+#endif
+
+#endif !_NI_UTIL_H_
+
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
OTHERSRCS = Makefile.preamble Makefile yp_all.3 yp_bind.3 yp_first.3\
yp_get_default_domain.3 yp_master.3 yp_match.3 yp_next.3\
yp_order.3 yp_unbind.3 ypclnt.3 yperr_string.3 ypprot_err.3\
- ypserv.acl.5
+ Makefile.postamble
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
--- /dev/null
+###############################################################################
+# NeXT Makefile.postamble Template
+# Copyright 1993, NeXT Computer, Inc.
+#
+# This Makefile is used for configuring the standard app makefiles associated
+# with ProjectBuilder.
+#
+# Use this template to set attributes for a project, sub-project, bundle, or
+# palette. Each node in the project's tree of sub-projects and bundles
+# should have it's own Makefile.preamble and Makefile.postamble. Additional
+# rules (e.g., after_install) that are defined by the developer should be
+# defined in this file.
+#
+###############################################################################
+#
+# Here are the variables exported by the common "app" makefiles that can be
+# used in any customizations you make to the template below:
+#
+# PRODUCT_ROOT - Name of the directory to which resources are copied.
+# OFILE_DIR - Directory into which .o object files are generated.
+# (Note that this name is calculated based on the target
+# architectures specified in Project Builder).
+# DERIVED_SRC_DIR - Directory used for all other derived files
+# ALL_CFLAGS - All the flags passed to the cc(1) driver for compilations
+#
+# NAME - name of application, bundle, subproject, palette, etc.
+# LANGUAGE - langage in which the project is written (default "English")
+# ENGLISH - boolean flag set iff $(LANGUAGE) = "English"
+# JAPANESE - boolean flag set iff $(LANGUAGE) = "Japanese"
+# LOCAL_RESOURCES - localized resources (e.g. nib's, images) of project
+# GLOBAL_RESOURCES - non-localized resources of project
+# PROJECTVERSION - version of ProjectBuilder that output Makefile
+# APPICON - application icon file
+# DOCICONS - dock icon files
+# ICONSECTIONS - Specifies icon sections when linking executable
+#
+# CLASSES - Class implementation files in project.
+# HFILES - Header files in project.
+# MFILES - Other Objective-C source files in project.
+# CFILES - Other C source files in project.
+# PSWFILES - .psw files in the project
+# PSWMFILES - .pswm files in the project
+# SUBPROJECTS - Subprojects of this project
+# BUNDLES - Bundle subprojects of this project
+# OTHERSRCS - Other miscellaneous sources of this project
+# OTHERLINKED - Source files not matching a standard source extention
+#
+# LIBS - Libraries to link with when making app target
+# DEBUG_LIBS - Libraries to link with when making debug target
+# PROF_LIBS - Libraries to link with when making profile target
+# OTHERLINKEDOFILES - Other relocatable files to (always) link in.
+#
+# APP_MAKEFILE_DIR - Directory in which to find generic set of Makefiles
+# MAKEFILEDIR - Directory in which to find $(MAKEFILE)
+# MAKEFILE - Top level mechanism Makefile (e.g., app.make, bundle.make)
+# INSTALLDIR - Directory app will be installed into by 'install' target
+#
+###############################################################################
+
+
+# Change defaults assumed by the standard makefiles here. Edit the
+# following default values as appropriate. (Note that if no Makefile.postamble
+# exists, these values will have defaults set in common.make).
+
+# Versioning of frameworks, libraries, bundles, and palettes:
+#CURRENTLY_ACTIVE_VERSION = YES # Set to "NO" to produce a compatibility binary
+#DEPLOY_WITH_VERSION_NAME = A
+#COMPATIBILITY_PROJECT_VERSION = 1
+
+# Some compiler flags can be easily overridden here, but onlytake effect at
+# the top-level:
+#OPTIMIZATION_CFLAG = -O
+#DEBUG_SYMBOLS_CFLAG = -g
+#WARNING_CFLAGS = -Wall
+#DEBUG_BUILD_CFLAGS = -DDEBUG
+#PROFILE_BUILD_CFLAGS = -pg -DPROFILE
+
+# Flags passed to yacc
+#YFLAGS = -d
+
+# Library and Framework projects only:
+# 1. If you want something other than the default .dylib name, override it here
+#DYLIB_INSTALL_NAME = lib$(NAME).dylib
+
+# 2. If you want to change the -install_name flag from the absolute path to the development area, change it here. One good choice is the installation directory. Another one might be none at all.
+#DYLIB_INSTALL_DIR = $(INSTALLDIR)
+
+# Ownership and permissions of files installed by 'install' target
+#INSTALL_AS_USER = root # User/group ownership
+#INSTALL_AS_GROUP = wheel # (probably want to set both of these)
+#INSTALL_PERMISSIONS = # If set, 'install' chmod's executable to this
+
+# Options to strip for various project types. Note: -S strips debugging symbols
+# (executables can be stripped down further with -x or, if they load no bundles, with no
+# options at all).
+#APP_STRIP_OPTS = -S
+#TOOL_STRIP_OPTS = -S
+#LIBRARY_STRIP_OPTS = -S # for .a archives
+#DYNAMIC_STRIP_OPTS = -S # for bundles and shared libraries
+
+#########################################################################
+# Put rules to extend the behavior of the standard Makefiles here. "Official"
+# user-defined rules are:
+# * before_install
+# * after_install
+# * after_installhdrs
+# You should avoid redefining things like "install" or "app", as they are
+# owned by the top-level Makefile API and no context has been set up for where
+# derived files should go.
+
+# BUILD_OFILES_LIST_ONLY = YES
+
+MAN3DIR=/usr/share/man/man3
+MAN5DIR=/usr/share/man/man5
+
+install-nis-man:
+ install -m 755 -o root -g wheel -d $(DSTROOT)$(MAN3DIR)
+ install -m 644 -o root -g wheel -c yp_all.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_bind.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_first.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_get_default_domain.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_master.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_match.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_next.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_order.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yp_unbind.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c ypclnt.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c yperr_string.3 "$(DSTROOT)$(MAN3DIR)"
+ install -m 644 -o root -g wheel -c ypprot_err.3 "$(DSTROOT)$(MAN3DIR)"
);
OTHER_SOURCES = (
Makefile.preamble,
+ Makefile.postamble,
Makefile,
yp_all.3,
yp_bind.3,
yp_unbind.3,
ypclnt.3,
yperr_string.3,
- ypprot_err.3,
- ypserv.acl.5
+ ypprot_err.3
);
PUBLIC_HEADERS = (ypclnt.h, yp_prot.h);
};
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/sysctl.h>
int
-getdomainname(char *val, size_t len)
+getdomainname(char *val, int len)
{
int mib[2];
mib[0] = CTL_KERN;
mib[1] = KERN_DOMAINNAME;
- return sysctl(mib, 2, (void *)val, &len, NULL, 0);
+ return sysctl(mib, 2, (void *)val, (size_t *)&len, NULL, 0);
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
void _yp_unbind __P((struct dom_binding *));
int _yp_check __P((char **));
-int getdomainname(char *val, size_t len);
-
#ifdef YPMATCHCACHE
static bool_t ypmatch_add __P((const char *, const char *,
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
+++ /dev/null
-.\" $OpenBSD: ypserv.acl.5,v 1.5 1996/07/04 21:17:15 deraadt Exp $
-.\" Copyright (c) 1994 Mats O Jansson <moj@stacken.kth.se>
-.\" All rights reserved.
-.\"
-.\" Redistribution and use in source and binary forms, with or without
-.\" modification, are permitted provided that the following conditions
-.\" are met:
-.\" 1. Redistributions of source code must retain the above copyright
-.\" notice, this list of conditions and the following disclaimer.
-.\" 2. Redistributions in binary form must reproduce the above copyright
-.\" notice, this list of conditions and the following disclaimer in the
-.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by Mats O Jansson
-.\" 4. The name of the author may not be used to endorse or promote products
-.\" derived from this software without specific prior written permission.
-.\"
-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
-.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
-.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-.\" SUCH DAMAGE.
-.\"
-.Dd July 2, 1994
-.Dt YPSERV.ACL 5
-.Os
-.Sh NAME
-.Nm ypserv.acl
-.Nd
-.Xr ypserv 8
-configuration file
-.Sh DESCRIPTION
-The
-.Nm ypserv.acl
-file controls which hosts can connect to the
-.Nm YP
-server.
-.Pp
-The format is more complex than the format for
-.Xr securenet 5 .
-The first two verbs on each line controls if the line will
-.Nm allow
-or
-.Nm deny
-access for a
-.Nm host ,
-network
-.Nm (net)
-or
-.Nm all
-hosts.
-.Pp
-The
-.Nm YP
-server reads the configuration file and build a list in memory. This list
-is processed from the beginning for every incomming request. As soon a
-match is found in the list the search terminates and it returns success
-or failure depending on
-.Nm allow
-or
-.Nm deny .
-If no match was found in the list success is returned.
-.Pp
-If access is denied every call will cause a
-.Nm no such domain
-error for the caller.
-.Pp
-There is no default name for this file. Start
-.Nm ypserv
-with a
-.Ar -a filename
-to read a file with this format.
-.Pp
-The following different syntax can be used:
-.Pp
-<
-.Nm allow|deny
->
-.Nm host
-<
-.Nm hostname|ip-address
->
-.Pp
-If
-.Nm hostname
-has more than one ip address then all will be added to the list.
-.Pp
-<
-.Nm allow|deny
->
-.Nm net
-<
-.Nm netname|netnumber
->
-.Op Nm netmask <netname|netnumber>
-.Pp
-If
-.Nm netmask
-part of the command isn't given then the netmask will be assumed to be a
-class A, B or C net depending on the net number.
-.Pp
-<
-.Nm allow|deny
->
-.Nm all
-.Pp
-A line containing one of these commands will always match any host.
-.Sh EXAMPLES
-.Pp
-A configuration file might appear as follows:
-.Bd -literal
-# This is an example of an access control file to be used by ypserv.
-#
-# This file is parsed line by line. First match will terminate the check
-# of the caller.
-#
-
-###########################################################################
-# This is the commands that will match a single host
-#
-# allow host <hostname|ip-address>
-# deny host <hostname|ip-address>
-#
-# To process hostname gethostbyname is called. If the hostname has
-# multiple ip-addresses all will be added (I hope). ip-address
-# processed by inet_aton.
-deny host jodie
-
-###########################################################################
-# This is the commands that will match a network
-#
-# allow net <netname|netnumber> [netmask <netname|netnumber>]
-# deny net <netname|netnumber> [netmask <netname|netnumber>]
-#
-# To process netname getnetbyname is called, and inet_aton is used for
-# netnumber. inet_aton both access numbers as 255.255.255.0 and 0xffffff00.
-#
-# If netmask isn't given the parser will assume netmask from the first bits
-# of the network number. So if the network is subneted the you have to add
-# the netmask. In my case I've got the network 139.58.253.0 at home so too
-# allow any of my computers to talk with the server I need the following
-# line
-#
-allow net mojathome netmask 255.255.255.0
-
-###########################################################################
-# At last we have a command that will match any caller:
-#
-# allow all
-# deny all
-#
-
-# reject all connections
-deny all
-
-.Ed
-.Sh FILES
-.Bl -tag -width /var/yp/ypserv.acl -compact
-.It Pa /var/yp/ypserv.acl
-A
-.Xr ypserv 8
-configuration file.
-.El
-.Sh SEE ALSO
-.Xr yp 8 ,
-.Xr ypserv 8 ,
-.Xr securenet 5
-.Sh AUTHOR
-Mats O Jansson <moj@stacken.kth.se>
-
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <sys/socket.h>
#include <netinet/in.h>
-/*
- * Bind a socket to a privileged IP port
- */
-int
-bindresvport(sd, sin)
- int sd;
- struct sockaddr_in *sin;
-{
- return bindresvport_sa(sd, (struct sockaddr *)sin);
-}
-
/*
* Bind a socket to a privileged port for whatever protocol.
*/
}
return (error);
}
+
+/*
+ * Bind a socket to a privileged IP port
+ */
+int
+bindresvport(sd, sin)
+ int sd;
+ struct sockaddr_in *sin;
+{
+ return bindresvport_sa(sd, (struct sockaddr *)sin);
+}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* from: @(#)clnt.h 1.31 88/02/08 SMI
* from: @(#)clnt.h 2.1 88/07/29 4.0 RPCSRC
- * $Id: clnt.h,v 1.2 1999/10/14 21:56:52 wsanchez Exp $
+ * $Id: clnt.h,v 1.3 2003/07/03 21:56:21 majka Exp $
*/
/*
* Created by individual implementations, see e.g. rpc_udp.c.
* Client is responsible for initializing auth, see e.g. auth_none.c.
*/
-typedef struct {
- AUTH *cl_auth; /* authenticator */
+typedef struct CLIENT CLIENT;
+struct CLIENT
+{
+ AUTH *cl_auth; /* authenticator */
struct clnt_ops {
- enum clnt_stat (*cl_call)(); /* call remote procedure */
- void (*cl_abort)(); /* abort a call */
- void (*cl_geterr)(); /* get specific error code */
- bool_t (*cl_freeres)(); /* frees results */
- void (*cl_destroy)();/* destroy this structure */
- bool_t (*cl_control)();/* the ioctl() of rpc */
+ enum clnt_stat (*cl_call)(CLIENT *, u_long, xdrproc_t, void *, xdrproc_t, void *, struct timeval); /* call remote procedure */
+ void (*cl_abort)(void); /* abort a call */
+ void (*cl_geterr)(CLIENT *, struct rpc_err *); /* get specific error code */
+ bool_t (*cl_freeres)(CLIENT *, xdrproc_t, void *); /* frees results */
+ void (*cl_destroy)(CLIENT *); /* destroy this structure */
+ bool_t (*cl_control)(CLIENT *, int, char *); /* the ioctl() of rpc */
} *cl_ops;
- caddr_t cl_private; /* private stuff */
-} CLIENT;
-
+ caddr_t cl_private; /* private stuff */
+};
/*
* client side rpc interface ops
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)clnt_perror.c 2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$Id: clnt_perror.c,v 1.3 2002/02/19 20:36:22 epeyton Exp $";
+static char *rcsid = "$Id: clnt_perror.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
#endif
/*
(void) sprintf(&str[strlen(str)], "Error %d",
rpc_createerr.cf_error.re_errno);
break;
+ default: break;
}
(void) strcat(str, "\n");
return (str);
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)pmap_rmt.c 1.21 87/08/27 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)pmap_rmt.c 2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$Id: pmap_rmt.c,v 1.4 2002/03/15 22:07:50 majka Exp $";
+static char *rcsid = "$Id: pmap_rmt.c,v 1.5 2003/06/05 21:43:28 majka Exp $";
#endif
/*
fd_set readfds;
register int i;
bool_t done = FALSE;
- register u_long xid;
+ u_long xid;
u_long port;
struct in_addr addrs[20];
struct sockaddr_in baddr, raddr; /* broadcast and response addresses */
/* baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */
rfd = open("/dev/random", O_RDONLY, 0);
- if ((rfd < 0) || (read(rfd, &msg.rm_xid, sizeof(msg.rm_xid)) != sizeof(msg.rm_xid)))
+ if ((rfd < 0) || (read(rfd, &xid, sizeof(xid)) != sizeof(xid)))
{
gettimeofday(&t, (struct timezone *)0);
- msg.rm_xid = getpid() ^ t.tv_sec ^ t.tv_usec;
+ xid = getpid() ^ t.tv_sec ^ t.tv_usec;
}
if (rfd > 0) close(rfd);
t.tv_usec = 0;
+ msg.rm_xid = xid;
msg.rm_direction = CALL;
msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
msg.rm_call.cb_prog = PMAPPROG;
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)rpc_callmsg.c 1.4 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)rpc_callmsg.c 2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$Id: rpc_callmsg.c,v 1.3 2002/02/19 20:36:24 epeyton Exp $";
+static char *rcsid = "$Id: rpc_callmsg.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
#endif
/*
if (cmsg->rm_call.cb_verf.oa_length > MAX_AUTH_BYTES) {
return (FALSE);
}
- buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
+ buf = (long *)XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT
+ RNDUP(cmsg->rm_call.cb_cred.oa_length)
+ 2 * BYTES_PER_XDR_UNIT
+ RNDUP(cmsg->rm_call.cb_verf.oa_length));
}
}
if (xdrs->x_op == XDR_DECODE) {
- buf = XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
+ buf = (long *)XDR_INLINE(xdrs, 8 * BYTES_PER_XDR_UNIT);
if (buf != NULL) {
cmsg->rm_xid = IXDR_GET_LONG(buf);
cmsg->rm_direction = IXDR_GET_ENUM(buf, enum msg_type);
oa->oa_base = (caddr_t)
mem_alloc(oa->oa_length);
}
- buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
+ buf = (long *)XDR_INLINE(xdrs, RNDUP(oa->oa_length));
if (buf == NULL) {
if (xdr_opaque(xdrs, oa->oa_base,
oa->oa_length) == FALSE) {
}
}
oa = &cmsg->rm_call.cb_verf;
- buf = XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
+ buf = (long *)XDR_INLINE(xdrs, 2 * BYTES_PER_XDR_UNIT);
if (buf == NULL) {
if (xdr_enum(xdrs, &oa->oa_flavor) == FALSE ||
xdr_u_int(xdrs, &oa->oa_length) == FALSE) {
oa->oa_base = (caddr_t)
mem_alloc(oa->oa_length);
}
- buf = XDR_INLINE(xdrs, RNDUP(oa->oa_length));
+ buf = (long *)XDR_INLINE(xdrs, RNDUP(oa->oa_length));
if (buf == NULL) {
if (xdr_opaque(xdrs, oa->oa_base,
oa->oa_length) == FALSE) {
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)rpc_prot.c 1.36 87/08/11 Copyr 1984 Sun Micro";*/
-static char *rcsid = "$Id: rpc_prot.c,v 1.2 1999/10/14 21:56:54 wsanchez Exp $";
+static char *rcsid = "$Id: rpc_prot.c,v 1.3 2003/06/23 17:24:59 majka Exp $";
#endif
/*
if (! xdr_u_long(xdrs, &(ar->ar_vers.low)))
return (FALSE);
return (xdr_u_long(xdrs, &(ar->ar_vers.high)));
+ default: break;
}
return (TRUE); /* TRUE => open ended set of problems */
}
case AUTH_ERROR:
error->re_status = RPC_AUTHERROR;
return;
+ default: break;
}
/* something's wrong, but we don't know what ... */
error->re_status = RPC_FAILED;
error->re_vers.low = msg->acpted_rply.ar_vers.low;
error->re_vers.high = msg->acpted_rply.ar_vers.high;
break;
+
+ default: break;
}
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)svc_auth_unix.c 1.28 88/02/08 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)svc_auth_unix.c 2.3 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$Id: svc_auth_unix.c,v 1.4 2002/02/19 20:36:25 epeyton Exp $";
+static char *rcsid = "$Id: svc_auth_unix.c,v 1.5 2003/06/23 17:24:59 majka Exp $";
#endif
/*
aup->aup_gids = area->area_gids;
auth_len = (u_int)msg->rm_call.cb_cred.oa_length;
xdrmem_create(&xdrs, msg->rm_call.cb_cred.oa_base, auth_len,XDR_DECODE);
- buf = XDR_INLINE(&xdrs, auth_len);
+ buf = (long *)XDR_INLINE(&xdrs, auth_len);
if (buf != NULL) {
aup->aup_time = IXDR_GET_LONG(buf);
str_len = IXDR_GET_U_LONG(buf);
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)svc_tcp.c 2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$Id: svc_tcp.c,v 1.3.84.1 2002/10/18 21:16:15 bbraun Exp $";
+static char *rcsid = "$Id: svc_tcp.c,v 1.5 2003/06/23 17:24:59 majka Exp $";
#endif
/*
register int sock = xprt->xp_sock;
fd_set readfds;
bool_t ready = FALSE;
- struct timeval delta, start, tv, tmp1, tmp2;
- delta = wait_per_try;
- gettimeofday(&start, NULL);
do
{
FD_COPY(&svc_fdset, &readfds);
FD_SET(sock, &readfds);
- tv = delta;
- switch( select(max(svc_maxfd, sock) + 1, &readfds, (fd_set*)NULL, (fd_set*)NULL, &tv) ) {
- case -1:
- if( errno != EINTR )
- goto fatal_err;
- gettimeofday(&tmp1, NULL);
- timersub(&tmp1, &start, &tmp2);
- timersub(&wait_per_try, &tmp2, &tmp1);
- if( tmp1.tv_sec < 0 || !timerisset(&tmp1) )
- goto fatal_err;
- delta = tmp1;
- continue;
- case 0:
+ if (select(max(svc_maxfd, sock) + 1, &readfds, NULL, NULL, &wait_per_try) <= 0)
+ {
+ if (errno == EINTR) continue;
goto fatal_err;
- default:
- if(!FD_ISSET(sock, &readfds)) {
- svc_getreqset(&readfds);
- gettimeofday(&tmp1, NULL);
- timersub(&tmp1, &start, &tmp2);
- timersub(&wait_per_try, &tmp2, &tmp1);
- if( tmp1.tv_sec < 0 || !timerisset(&tmp1) )
- goto fatal_err;
- delta = tmp1;
- continue;
- } else {
- ready = TRUE;
- }
+ }
+ else if (FD_ISSET(sock, &readfds))
+ {
+ ready = TRUE;
+ }
+ else
+ {
+ svc_getreqset(&readfds);
}
} while (!ready);
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)xdr.c 1.35 87/08/12";*/
/*static char *sccsid = "from: @(#)xdr.c 2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$Id: xdr.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $";
+static char *rcsid = "$Id: xdr.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
#endif
/*
case XDR_ENCODE:
size = strlen(sp);
break;
+ default: break;
}
if (! xdr_u_int(xdrs, &size)) {
return (FALSE);
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* from: @(#)xdr.h 1.19 87/04/22 SMI
* from: @(#)xdr.h 2.2 88/07/29 4.0 RPCSRC
- * $Id: xdr.h,v 1.2 1999/10/14 21:56:54 wsanchez Exp $
+ * $Id: xdr.h,v 1.3 2003/06/23 17:24:59 majka Exp $
*/
/*
* an operations vector for the paticular implementation (e.g. see xdr_mem.c),
* and two private fields for the use of the particular impelementation.
*/
-typedef struct {
+typedef struct __rpc_xdr {
enum xdr_op x_op; /* operation; fast additional param */
struct xdr_ops {
- bool_t (*x_getlong)(); /* get a long from underlying stream */
- bool_t (*x_putlong)(); /* put a long to " */
- bool_t (*x_getbytes)();/* get some bytes from " */
- bool_t (*x_putbytes)();/* put some bytes to " */
- u_int (*x_getpostn)();/* returns bytes off from beginning */
- bool_t (*x_setpostn)();/* lets you reposition the stream */
- long * (*x_inline)(); /* buf quick ptr to buffered data */
- void (*x_destroy)(); /* free privates of this xdr_stream */
+ bool_t (*x_getlong)(struct __rpc_xdr *, long *);
+ bool_t (*x_putlong)(struct __rpc_xdr *, long *);
+ bool_t (*x_getbytes)(struct __rpc_xdr *, caddr_t, u_int);
+ bool_t (*x_putbytes)(struct __rpc_xdr *, caddr_t, u_int);
+ u_int (*x_getpostn)(struct __rpc_xdr *);
+ bool_t (*x_setpostn)(struct __rpc_xdr *, u_int);
+ long *(*x_inline)(struct __rpc_xdr *, u_int);
+ void (*x_destroy)(struct __rpc_xdr *);
} *x_ops;
- caddr_t x_public; /* users' data */
- caddr_t x_private; /* pointer to private data */
- caddr_t x_base; /* private used for position info */
- int x_handy; /* extra private word */
+ caddr_t x_public; /* users' data */
+ caddr_t x_private; /* pointer to private data */
+ caddr_t x_base; /* private used for position info */
+ int x_handy; /* extra private word */
} XDR;
/*
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)xdr_array.c 1.10 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$Id: xdr_array.c,v 1.3.84.1 2002/08/06 19:46:15 bbraun Exp $";
+static char *rcsid = "$Id: xdr_array.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
#endif
/*
#include <string.h>
#include <rpc/types.h>
#include <rpc/xdr.h>
-#include <limits.h>
#define LASTUNSIGNED ((u_int)0-1)
return (FALSE);
}
c = *sizep;
- if ((c > maxsize || UINT_MAX/elsize < c) &&
- (xdrs->x_op != XDR_FREE)) {
+ if ((c > maxsize) && (xdrs->x_op != XDR_FREE)) {
return (FALSE);
}
nodesize = c * elsize;
case XDR_FREE:
return (TRUE);
+
+ default: break;
}
/*
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$Id: xdr_mem.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $";
+static char *rcsid = "$Id: xdr_mem.c,v 1.5 2003/06/23 17:24:59 majka Exp $";
#endif
/*
void *addr;
#else
caddr_t addr;
-#endif /* !NeXT */
+#endif
u_int size;
enum xdr_op op;
{
}
static void
-xdrmem_destroy(/*xdrs*/)
- /*XDR *xdrs;*/
+xdrmem_destroy(XDR *xdrs)
{
}
register XDR *xdrs;
long *lp;
{
-
if ((xdrs->x_handy -= sizeof(long)) < 0)
return (FALSE);
*lp = (long)ntohl((u_long)(*((long *)(xdrs->x_private))));
register XDR *xdrs;
long *lp;
{
-
if ((xdrs->x_handy -= sizeof(long)) < 0)
return (FALSE);
*(long *)xdrs->x_private = (long)htonl((u_long)(*lp));
xdrmem_getpos(xdrs)
register XDR *xdrs;
{
-
return ((u_int)xdrs->x_private - (u_int)xdrs->x_base);
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";*/
/*static char *sccsid = "from: @(#)xdr_rec.c 2.2 88/08/01 4.0 RPCSRC";*/
-static char *rcsid = "$Id: xdr_rec.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $";
+static char *rcsid = "$Id: xdr_rec.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
#endif
/*
return (TRUE);
}
break;
+ default: break;
}
return (FALSE);
}
rstrm->in_finger += len;
}
break;
+ default: break;
}
return (buf);
}
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#if defined(LIBC_SCCS) && !defined(lint)
/*static char *sccsid = "from: @(#)xdr_reference.c 1.11 87/08/11 SMI";*/
/*static char *sccsid = "from: @(#)xdr_reference.c 2.1 88/07/29 4.0 RPCSRC";*/
-static char *rcsid = "$Id: xdr_reference.c,v 1.3 2002/02/19 20:36:26 epeyton Exp $";
+static char *rcsid = "$Id: xdr_reference.c,v 1.4 2003/06/23 17:24:59 majka Exp $";
#endif
/*
}
bzero(loc, (int)size);
break;
+ default: break;
}
stat = (*proc)(xdrs, loc, LASTUNSIGNED);
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
PROJECTVERSION = 2.8
PROJECT_TYPE = Component
-CFILES = getgrouplist.c glob.c hton.c putpwpasswd.c pwcache.c rcmd.c\
+CFILES = glob.c hton.c putpwpasswd.c pwcache.c rcmd.c\
rcmdsh.c
-OTHERSRCS = Makefile Makefile.preamble Makefile.postamble rcmd.3
+OTHERSRCS = Makefile Makefile.preamble Makefile.postamble rcmd.3 hosts.equiv.5
MAKEFILEDIR = $(MAKEFILEPATH)/pb_makefiles
$(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/rresvport.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/rresvport_af.3"
$(LN) -f "$(DSTROOT)/usr/share/man/man3/rcmd.3" "$(DSTROOT)/usr/share/man/man3/ruserok.3"
+ mkdir -p "$(DSTROOT)/usr/share/man/man5"
+ install -c -m 644 hosts.equiv.5 "$(DSTROOT)/usr/share/man/man5"
AFTER_POSTINSTALL += install-man-page
OTHER_CFLAGS = \
- -DINET6=1 \
+ -DINET6=1
{
DYNAMIC_CODE_GEN = YES;
FILESTABLE = {
- OTHER_LINKED = (getgrouplist.c, glob.c, hton.c, putpwpasswd.c, pwcache.c, rcmd.c, rcmdsh.c);
- OTHER_SOURCES = (Makefile, Makefile.preamble, Makefile.postamble, rcmd.3);
+ OTHER_LINKED = (glob.c, hton.c, putpwpasswd.c, pwcache.c, rcmd.c, rcmdsh.c);
+ OTHER_SOURCES = (Makefile, Makefile.preamble, Makefile.postamble, rcmd.3, hosts.equiv.5);
};
LANGUAGE = English;
MAKEFILEDIR = "$(MAKEFILEPATH)/pb_makefiles";
+++ /dev/null
-/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
- *
- * @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
- * The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
- * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
- * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
- * @APPLE_LICENSE_HEADER_END@
- */
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#if defined(LIBC_SCCS) && !defined(lint)
-static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94";
-#endif /* LIBC_SCCS and not lint */
-
-/*
- * get credential
- */
-#include <sys/types.h>
-#include <string.h>
-#include <grp.h>
-
-int
-getgrouplist(uname, agroup, groups, grpcnt)
- const char *uname;
- int agroup;
- register int *groups;
- int *grpcnt;
-{
- register struct group *grp;
- register int i, ngroups;
- int ret, maxgroups;
-
- ret = 0;
- ngroups = 0;
- maxgroups = *grpcnt;
- /*
- * When installing primary group, duplicate it;
- * the first element of groups is the effective gid
- * and will be overwritten when a setgid file is executed.
- */
- groups[ngroups++] = agroup;
- if (maxgroups > 1)
- groups[ngroups++] = agroup;
- /*
- * Scan the group file to find additional groups.
- */
- setgrent();
- while ((grp = getgrent())) {
- if (grp->gr_gid == agroup)
- continue;
- for (i = 0; grp->gr_mem[i]; i++) {
- if (!strcmp(grp->gr_mem[i], uname)) {
- if (ngroups >= maxgroups) {
- ret = -1;
- break;
- }
- groups[ngroups++] = grp->gr_gid;
- break;
- }
- }
- }
- endgrent();
- *grpcnt = ngroups;
- return (ret);
-}
* Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
- *
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
- *
+ *
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
+ *
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
- *
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
+ *
* @APPLE_LICENSE_HEADER_END@
*/
/*
--- /dev/null
+.\" $OpenBSD: hosts.equiv.5,v 1.1 1997/11/30 05:35:25 deraadt Exp $
+.\"
+.\" Copyright (c) 1997 Todd Vierling
+.\" Copyright (c) 1997 The NetBSD Foundation, Inc.
+.\" All rights reserved.
+.\"
+.\" This code is derived from software contributed to The NetBSD Foundation
+.\" by Todd Vierling <tv@pobox.com>.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the NetBSD
+.\" Foundation, Inc. and its contributors.
+.\" 4. Neither the name of The NetBSD Foundation nor the names of its
+.\" contributors may be used to endorse or promote products derived
+.\" from this software without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+.\" POSSIBILITY OF SUCH DAMAGE.
+.\"
+.Dd November 26, 1997
+.Dt HOSTS.EQUIV 5
+.Os
+.Sh NAME
+.Nm hosts.equiv ,
+.Nm .rhosts
+.Nd trusted remote hosts and host-user pairs
+.Sh DESCRIPTION
+The
+.Nm hosts.equiv
+and
+.Nm .rhosts
+files list hosts and users which are ``trusted'' by the local host when a
+connection is made via
+.Xr rlogind 8 ,
+.Xr rshd 8 ,
+or any other server that uses
+.Xr ruserok 3 .
+This mechanism bypasses password checks, and is required for access via
+.Xr rsh 1 .
+.Pp
+Each line of these files has the format:
+.Pp
+.Bd -unfilled -offset indent -compact
+hostname [username]
+.Ed
+.Pp
+The
+.Em hostname
+may be specified as a host name (typically a fully qualified host
+name in a DNS environment) or address,
+.Em +@netgroup
+(from which only the host names are checked),
+or a ``+'' wildcard (allow all hosts).
+.Pp
+The
+.Em username ,
+if specified, may be given as a user name on the remote host,
+.Em +@netgroup
+(from which only the user names are checked),
+or a ``+'' wildcard (allow all remote users).
+.Pp
+If a
+.Em username
+is specified, only that user from the specified host may login to the
+local machine. If a
+.Em username
+is not specified, any user may login with the same user name.
+.Sh EXAMPLES
+.Li somehost
+.Bd -filled -offset indent -compact
+A common usage: users on
+.Em somehost
+may login to the local host as the same user name.
+.Ed
+.Li somehost username
+.Bd -filled -offset indent -compact
+The user
+.Em username
+on
+.Em somehost
+may login to the local host. If specified in
+.Em /etc/hosts.equiv ,
+the user may login with only the same user name.
+.Ed
+.Li +@anetgroup username
+.Bd -filled -offset indent -compact
+The user
+.Em username
+may login to the local host from any machine listed in the netgroup
+.Em anetgroup .
+.Ed
+.Bd -literal -compact
++
++ +
+.Ed
+.Bd -filled -offset indent -compact
+Two severe security hazards. In the first case, allows a user on any
+machine to login to the local host as the same user name. In the second
+case, allows any user on any machine to login to the local host (as any
+user, if in
+.Em /etc/hosts.equiv ) .
+.Ed
+.Sh WARNINGS
+The username checks provided by this mechanism are
+.Em not
+secure, as the remote user name is received by the server unchecked
+for validity. Therefore this mechanism should only be used
+in an environment where all hosts are completely trusted.
+.Pp
+A numeric host address instead of a host name can help security
+considerations somewhat; the address is then used directly by
+.Xr iruserok 3 .
+.Pp
+When a username (or netgroup, or +) is specified in
+.Em /etc/hosts.equiv ,
+that user (or group of users, or all users, respectively) may login to
+the local host as
+.Em any local user .
+Usernames in
+.Em /etc/hosts.equiv
+should therefore be used with extreme caution, or not at all.
+.Pp
+A
+.Em .rhosts
+file must be owned by the user whose home directory it resides in, and
+must be writable only by that user.
+.Pp
+Logins as root only check root's
+.Em .rhosts
+file; the
+.Em /etc/hosts.equiv
+file is not checked for security. Access permitted through root's
+.Em .rhosts
+file is typically only for
+.Xr rsh 1 ,
+as root must still login on the console for an interactive login such as
+.Xr rlogin 1 .
+.Sh FILES
+.Bl -tag -width /etc/hosts.equiv -compact
+.It Pa /etc/hosts.equiv
+Global trusted host-user pairs list
+.It Pa ~/.rhosts
+Per-user trusted host-user pairs list
+.El
+.Sh SEE ALSO
+.Xr rcp 1 ,
+.Xr rlogin 1 ,
+.Xr rsh 1 ,
+.Xr rcmd 3 ,
+.Xr ruserok 3 ,
+.Xr netgroup 5
+.Re
+.Sh HISTORY
+The
+.Nm .rhosts
+file format appeared in
+.Bx 4.2 .
+.Sh BUGS
+The
+.Xr ruserok 3
+implementation currently skips negative entries (preceded with a
+``-'' sign) and does not treat them as ``short-circuit'' negative entries.
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <grp.h>
#include <pwd.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <utmp.h>
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/
#include <rpcsvc/yp_prot.h>
#include <rpcsvc/ypclnt.h>
#endif
-#include <arpa/nameser.h>
+#include <arpa/nameser8_compat.h>
/* wrapper for KAME-special getnameinfo() */
#ifndef NI_WITHSCOPEID
#endif
extern int innetgr __P(( const char *, const char *, const char *, const char * ));
+extern int bindresvport_sa(int, struct sockaddr *);
#define max(a, b) ((a > b) ? a : b)
static int __icheckhost __P((const struct sockaddr *, socklen_t,
const char *));
-
-int
-rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
- char **ahost;
- in_port_t rport;
- const char *locuser, *remuser, *cmd;
- int *fd2p;
-{
- return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET);
-}
-
int
rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
char **ahost;
return (-1);
}
+int
+rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
+ char **ahost;
+ in_port_t rport;
+ const char *locuser, *remuser, *cmd;
+ int *fd2p;
+{
+ return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET);
+}
+
int
rresvport(port)
int *port;
int __check_rhosts_file = 1;
char *__rcmd_errstr;
-int
-ruserok(rhost, superuser, ruser, luser)
- const char *rhost, *ruser, *luser;
- int superuser;
-{
- struct addrinfo hints, *res, *r;
- int error;
-
- memset(&hints, 0, sizeof(hints));
- hints.ai_family = PF_UNSPEC;
- hints.ai_socktype = SOCK_DGRAM; /*dummy*/
- error = getaddrinfo(rhost, "0", &hints, &res);
- if (error)
- return (-1);
-
- for (r = res; r; r = r->ai_next) {
- if (iruserok_sa(r->ai_addr, r->ai_addrlen, superuser, ruser,
- luser) == 0) {
- freeaddrinfo(res);
- return (0);
- }
- }
- freeaddrinfo(res);
- return (-1);
-}
-
-/*
- * New .rhosts strategy: We are passed an ip address. We spin through
- * hosts.equiv and .rhosts looking for a match. When the .rhosts only
- * has ip addresses, we don't have to trust a nameserver. When it
- * contains hostnames, we spin through the list of addresses the nameserver
- * gives us and look for a match.
- *
- * Returns 0 if ok, -1 if not ok.
- */
-int
-iruserok(raddr, superuser, ruser, luser)
- unsigned long raddr;
- int superuser;
- const char *ruser, *luser;
-{
- struct sockaddr_in sin;
-
- memset(&sin, 0, sizeof(sin));
- sin.sin_family = AF_INET;
- sin.sin_len = sizeof(struct sockaddr_in);
- memcpy(&sin.sin_addr, &raddr, sizeof(sin.sin_addr));
- return iruserok_sa((struct sockaddr *)&sin, sin.sin_len, superuser,
- ruser, luser);
-}
-
/*
* AF independent extension of iruserok.
*
return (-1);
}
+int
+ruserok(rhost, superuser, ruser, luser)
+ const char *rhost, *ruser, *luser;
+ int superuser;
+{
+ struct addrinfo hints, *res, *r;
+ int error;
+
+ memset(&hints, 0, sizeof(hints));
+ hints.ai_family = PF_UNSPEC;
+ hints.ai_socktype = SOCK_DGRAM; /*dummy*/
+ error = getaddrinfo(rhost, "0", &hints, &res);
+ if (error)
+ return (-1);
+
+ for (r = res; r; r = r->ai_next) {
+ if (iruserok_sa(r->ai_addr, r->ai_addrlen, superuser, ruser,
+ luser) == 0) {
+ freeaddrinfo(res);
+ return (0);
+ }
+ }
+ freeaddrinfo(res);
+ return (-1);
+}
+
+/*
+ * New .rhosts strategy: We are passed an ip address. We spin through
+ * hosts.equiv and .rhosts looking for a match. When the .rhosts only
+ * has ip addresses, we don't have to trust a nameserver. When it
+ * contains hostnames, we spin through the list of addresses the nameserver
+ * gives us and look for a match.
+ *
+ * Returns 0 if ok, -1 if not ok.
+ */
+int
+iruserok(raddr, superuser, ruser, luser)
+ unsigned long raddr;
+ int superuser;
+ const char *ruser, *luser;
+{
+ struct sockaddr_in sin;
+
+ memset(&sin, 0, sizeof(sin));
+ sin.sin_family = AF_INET;
+ sin.sin_len = sizeof(struct sockaddr_in);
+ memcpy(&sin.sin_addr, &raddr, sizeof(sin.sin_addr));
+ return iruserok_sa((struct sockaddr *)&sin, sin.sin_len, superuser,
+ ruser, luser);
+}
+
/*
* XXX
* Don't make static, used by lpd(8).
#else
#define ypdomain NULL
#endif
- /* We need to get the damn hostname back for netgroup matching. */
- if (getnameinfo(raddr, salen, hname, sizeof(hname), NULL, 0,
- NI_NAMEREQD) != 0)
- return (-1);
+ /*
+ * We try to get the hostname back for netgroup matching.
+ * However, the .rosts file may contain IP addresses as well
+ * as names, so a name is not always required.
+ */
+ getnameinfo(raddr, salen, hname, sizeof(hname), NULL, 0, NI_NAMEREQD);
while (fgets(buf, sizeof(buf), hostf)) {
p = buf;
*
* @APPLE_LICENSE_HEADER_START@
*
- * Portions Copyright (c) 1999 Apple Computer, Inc. All Rights
- * Reserved. This file contains Original Code and/or Modifications of
- * Original Code as defined in and that are subject to the Apple Public
- * Source License Version 1.1 (the "License"). You may not use this file
- * except in compliance with the License. Please obtain a copy of the
- * License at http://www.apple.com/publicsource and read it before using
- * this file.
+ * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
+ *
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
* The Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
* INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON- INFRINGEMENT. Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
*
* @APPLE_LICENSE_HEADER_END@
*/