/* End PBXAggregateTarget section */
/* Begin PBXBuildFile section */
+ 03056CE61F71A8EF0094A9FA /* si_compare.c in Sources */ = {isa = PBXBuildFile; fileRef = 03056CE51F71A8EF0094A9FA /* si_compare.c */; };
2D31A0FC128074E700D5A84C /* getifmaddrs.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D31A0FB128074E700D5A84C /* getifmaddrs.c */; };
2D4070B1129354A700FE81ED /* getnameinfo_link.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D4070B0129354A700FE81ED /* getnameinfo_link.c */; };
2D5DD5D21608E6E80051891A /* configuration_profile.c in Sources */ = {isa = PBXBuildFile; fileRef = 2D5DD5D01608E6E80051891A /* configuration_profile.c */; };
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
+ 03056CE31F71A8EE0094A9FA /* si_compare.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = si_compare.h; sourceTree = "<group>"; };
+ 03056CE51F71A8EF0094A9FA /* si_compare.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = si_compare.c; sourceTree = "<group>"; };
2D31A0FA128074E700D5A84C /* getifmaddrs.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = getifmaddrs.3; sourceTree = "<group>"; };
2D31A0FB128074E700D5A84C /* getifmaddrs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getifmaddrs.c; sourceTree = "<group>"; };
2D4070B0129354A700FE81ED /* getnameinfo_link.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getnameinfo_link.c; sourceTree = "<group>"; };
2D5DD5D11608E6E80051891A /* configuration_profile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = configuration_profile.h; sourceTree = "<group>"; };
2DBB147712DBD63300D710E3 /* inet6_opt_init.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inet6_opt_init.3; sourceTree = "<group>"; };
3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Libinfo.xcconfig; path = xcodescripts/Libinfo.xcconfig; sourceTree = "<group>"; };
+ BDE3980D2044CDA300CAD4A2 /* libinfo_common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libinfo_common.h; sourceTree = "<group>"; };
+ BDE3980E2044CDA300CAD4A2 /* pseudo_public.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pseudo_public.h; sourceTree = "<group>"; };
+ BDE3980F2044CDA300CAD4A2 /* pseudo_private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pseudo_private.h; sourceTree = "<group>"; };
C96579391B94C97100624699 /* muser_module.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = muser_module.c; sourceTree = "<group>"; };
C965793B1B94CF2B00624699 /* libinfo_muser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libinfo_muser.h; sourceTree = "<group>"; };
D2AAC0630554660B00DB518D /* libsystem_info.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libsystem_info.dylib; sourceTree = BUILT_PRODUCTS_DIR; };
isa = PBXGroup;
children = (
3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */,
+ BDE3980C2044CDA300CAD4A2 /* Libinfo */,
FC5283ED11478C200058CCB0 /* dns.subproj */,
FC52840011478C200058CCB0 /* gen.subproj */,
FC52841711478C200058CCB0 /* lookup.subproj */,
name = Products;
sourceTree = "<group>";
};
+ BDE3980C2044CDA300CAD4A2 /* Libinfo */ = {
+ isa = PBXGroup;
+ children = (
+ BDE3980D2044CDA300CAD4A2 /* libinfo_common.h */,
+ BDE3980E2044CDA300CAD4A2 /* pseudo_public.h */,
+ BDE3980F2044CDA300CAD4A2 /* pseudo_private.h */,
+ );
+ path = Libinfo;
+ sourceTree = "<group>";
+ };
FC5283ED11478C200058CCB0 /* dns.subproj */ = {
isa = PBXGroup;
children = (
FC52843111478C200058CCB0 /* printerdb.h */,
FCFDBF0B145CC5C100A39A66 /* pwd.h */,
FC52843211478C200058CCB0 /* search_module.c */,
+ 03056CE51F71A8EF0094A9FA /* si_compare.c */,
+ 03056CE31F71A8EE0094A9FA /* si_compare.h */,
FC52843311478C200058CCB0 /* si_data.c */,
FC52843411478C200058CCB0 /* si_data.h */,
FC52843511478C200058CCB0 /* si_getaddrinfo.c */,
FC52852E11478C200058CCB0 /* clnt_tcp.c in Sources */,
FC52852F11478C200058CCB0 /* clnt_udp.c in Sources */,
FC52853011478C200058CCB0 /* get_myaddress.c in Sources */,
+ 03056CE61F71A8EF0094A9FA /* si_compare.c in Sources */,
FC52853111478C200058CCB0 /* getrpcent.c in Sources */,
FC52853211478C200058CCB0 /* getrpcport.c in Sources */,
FC52853511478C200058CCB0 /* pmap_clnt.c in Sources */,
isa = XCBuildConfiguration;
baseConfigurationReference = 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */;
buildSettings = {
+ IS_ZIPPERED = YES;
PRODUCT_NAME = info;
};
name = Release;
isa = XCBuildConfiguration;
baseConfigurationReference = 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */;
buildSettings = {
+ IS_ZIPPERED = YES;
PRODUCT_NAME = info;
};
name = Debug;
--- /dev/null
+/*
+ Copyright (c) 2018 Apple Inc. All rights reserved.
+*/
+
+#ifndef __LIBINFO_COMMON_H__
+#define __LIBINFO_COMMON_H__
+
+#if (defined(__GNUC__) && (__GNUC__ >= 4))
+#define LIBINFO_EXPORT __attribute__((visibility("default")))
+#else
+#define LIBINFO_EXPORT
+#endif
+
+#endif // __LIBINFO_COMMON_H__
--- /dev/null
+/*
+ Copyright (c) 2018 Apple Inc. All rights reserved.
+
+ This pseduo-header file contains declarations for private symbols that are exported in libsystem_info.dylib but don't
+ have a proper header file. This file allows InstallAPI, which parses header files to infer the symbols exported by a
+ library, to know about these symbols.
+*/
+
+#if (defined(DS_AVAILABLE))
+int _ds_running(void);
+#endif
+mach_port_t _getaddrinfo_interface_async_call(const char *nodename, const char *servname, const struct addrinfo *hints, const char *interface, getaddrinfo_async_callback callback, void *context);
+mach_port_t _getnameinfo_interface_async_call(const struct sockaddr *sa, size_t len, int flags, const char *interface, getnameinfo_async_callback callback, void *context);
+#if (defined(DS_AVAILABLE))
+void _si_disable_opendirectory(void);
+#endif
+extern uint32_t gL1CacheEnabled;
+int32_t getgroupcount(const char *name, gid_t basegid);
+int32_t getgrouplist_2(const char *name, gid_t basegid, gid_t **groups);
--- /dev/null
+/*
+ Copyright (c) 2018 Apple Inc. All rights reserved.
+
+ This pseduo-header file contains declarations for public symbols that are exported in libsystem_info.dylib but don't have
+ a proper header file in the Libinfo project. These symbols are typically declared in header files installed by other
+ projects. The purpose of this file is to allow InstallAPI, which parses header files to infer the symbols exported by a
+ library, to know about these symbols.
+*/
+
+
+#include <arpa/inet.h>
+#include <fstab.h>
+#include <net/ethernet.h>
+#include <net/if.h>
+#include <netinet/in.h>
+#include <stdio.h>
+#include <unistd.h>
+
+// Declared in /usr/include/arpa/inet.h
+// Note: These are currently implemented as macros based on machine endianness. Include for completeness.
+
+#undef ntohl
+uint32_t ntohl(uint32_t x);
+#undef htonl
+uint32_t htonl(uint32_t x);
+#undef ntohs
+uint16_t ntohs(uint16_t x);
+#undef htons
+uint16_t htons(uint16_t x);
+
+
+// Declared in /usr/include/fstab.h
+
+void endfsent(void);
+struct fstab * getfsent(void);
+struct fstab * getfsfile(const char *file);
+struct fstab * getfsspec(const char *spec);
+int setfsent(void);
+
+
+// Declared in /usr/include/net/ethernet.h
+
+struct ether_addr * ether_aton(const char *s);
+int ether_hostton(const char *name, struct ether_addr *e);
+int ether_line(const char *s, struct ether_addr *e, char *hostname);
+char * ether_ntoa(const struct ether_addr *e);
+int ether_ntohost(char *name, const struct ether_addr *e);
+
+
+// Declared in /usr/include/net/if.h
+
+void if_freenameindex(struct if_nameindex *ptr);
+char * if_indextoname(unsigned int ifindex, char *ifname);
+struct if_nameindex * if_nameindex(void);
+unsigned int if_nametoindex(const char *ifname);
+
+
+// Declared in /usr/include/netinet/in.h
+
+extern const struct in6_addr in6addr_any;
+extern const struct in6_addr in6addr_linklocal_allnodes;
+extern const struct in6_addr in6addr_linklocal_allrouters;
+extern const struct in6_addr in6addr_loopback;
+extern const struct in6_addr in6addr_nodelocal_allnodes;
+
+int inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type, socklen_t len, u_int8_t align, void **databufp);
+int inet6_opt_find(void *extbuf, socklen_t extlen, int offset, u_int8_t type, socklen_t *lenp, void **databufp);
+int inet6_opt_finish(void *extbuf, socklen_t extlen, int offset);
+int inet6_opt_get_val(void *databuf, int offset, void *val, socklen_t vallen);
+int inet6_opt_init(void *extbuf, socklen_t extlen);
+int inet6_opt_next(void *extbuf, socklen_t extlen, int offset, u_int8_t *typep, socklen_t *lenp, void **databufp);
+int inet6_opt_set_val(void *databuf, int offset, void *val, socklen_t vallen);
+u_int8_t * inet6_option_alloc(struct cmsghdr *cmsg, int datalen, int multx, int plusy);
+int inet6_option_append(struct cmsghdr *cmsg, const u_int8_t *typep, int multx, int plusy);
+int inet6_option_find(const struct cmsghdr *cmsg, u_int8_t **tptrp, int type);
+int inet6_option_init(void *bp, struct cmsghdr **cmsgp, int type);
+int inet6_option_next(const struct cmsghdr *cmsg, u_int8_t **tptrp);
+int inet6_option_space(int nbytes);
+int inet6_rth_add(void *bp, const struct in6_addr *addr);
+struct in6_addr * inet6_rth_getaddr(const void *bp, int idx);
+void * inet6_rth_init(void *bp, socklen_t bp_len, int type, int segments);
+int inet6_rth_reverse(const void *in, void *out);
+int inet6_rth_segments(const void *bp);
+socklen_t inet6_rth_space(int type, int segments);
+int inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr, u_int flags);
+struct in6_addr * inet6_rthdr_getaddr(struct cmsghdr *cmsg, int idx);
+int inet6_rthdr_getflags(const struct cmsghdr *cmsg, int idx);
+struct cmsghdr * inet6_rthdr_init(void *bp, int type);
+int inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags);
+int inet6_rthdr_segments(const struct cmsghdr *cmsg);
+size_t inet6_rthdr_space(int type, int seg);
+
+
+// Declared in /usr/include/rpcsvc/yp.h
+
+// bool_t xdr_keydat(XDR *xdrs, keydat *objp)
+int xdr_keydat(void *xdrs, void *objp);
+// bool_t xdr_valdat(XDR *xdrs, valdat *objp)
+int xdr_valdat(void *xdrs, void *objp);
+
+
+// Declared in /usr/include/rpcsvc/yppasswd.h
+
+// bool_t xdr_x_passwd(XDR *xdrs, x_passwd *objp)
+int xdr_x_passwd(void *xdrs, void *objp);
+// bool_t xdr_yppasswd(XDR *xdrs, yppasswd *objp)
+int xdr_yppasswd(void *xdrs, void *objp);
+
+
+// Declared in /usr/include/unistd.h
+
+int getdomainname(char *val, int inlen);
+int getgrouplist(const char *name, int basegid, int *groups, int *ngroups);
+int initgroups(const char *name, int basegid);
+int iruserok(unsigned long raddr, int superuser, const char *ruser, const char *luser);
+int iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser, const char *luser);
+int rcmd(char **ahost, int rport, const char *locuser, const char *remuser, const char *cmd, int *fd2p);
+int rcmd_af(char **ahost, int rport, const char *locuser, const char *remuser, const char *cmd, int *fd2p, int af);
+int rresvport(int *port);
+int rresvport_af(int *alport, int family);
+int ruserok(const char *rhost, int superuser, const char *ruser, const char *luser);
+int setdomainname(const char *name, int namelen);
+
+
+// The following symbols are part of the resolv API that have somehow managed to remain in libinfo. There's no header that
+// declares them. Yet, according to https://mariana.itunes.apple.com, some developers are still using some of them, so, for
+// the time being, we'll include them here so that they continue to get exported in libsystem_info.dylib.
+// Note: The current proper resolv library prefixes its symbol names with "res_9_" (see /usr/include/resolv.h).
+
+extern char _res[];
+
+int __dn_skipname(const u_char *comp_dn, const u_char *eom);
+u_int32_t _getlong(const u_char *msgp);
+u_int16_t _getshort(const u_char *msgp);
+int dn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, char *exp_dn, int length);
+int res_init(void);
+int res_query(const char *name, int class, int type, u_char *answer, int anslen);
+int res_search(const char *name, int class, int type, u_char *answer, int anslen);
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/*
* ++Copyright++ 1987, 1993
* -
static char rcsid[] = "$Id: herror.c,v 1.4 2003/04/10 20:21:16 majka Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/uio.h>
#include <netdb.h>
};
const int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] };
+LIBINFO_EXPORT
int h_errno;
/*
* herror --
* print the error indicated by the h_errno value.
*/
+LIBINFO_EXPORT
void
herror(const char *s)
{
writev(STDERR_FILENO, iov, (v - iov) + 1);
}
+LIBINFO_EXPORT
const char *
hstrerror(int err)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/*
* ++Copyright++ 1985, 1993
* -
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 "libinfo_common.h"
+
#include <sys/param.h>
#include <netinet/in.h>
* 'exp_dn' is a pointer to a buffer of size 'length' for the result.
* Return size of compressed name or -1 if there was an error.
*/
+LIBINFO_EXPORT
int
dn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, char *exp_dn, int length)
{
/*
* Skip over a compressed domain name. Return the size or -1.
*/
+LIBINFO_EXPORT
int
__dn_skipname(const u_char *comp_dn, const u_char *eom)
{
* Routines to insert/extract short/long's.
*/
+LIBINFO_EXPORT
u_int16_t
_getshort(const u_char *msgp)
{
return u;
}
+LIBINFO_EXPORT
u_int32_t
_getlong(const u_char *msgp)
{
/*
- * Copyright (c) 1999, 2012 Apple Inc. All rights reserved.
+ * Copyright (c) 1999, 2012-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <dns_sd.h>
#include <errno.h>
#else
#define RES_9_STATE_SIZE 512
#endif
+LIBINFO_EXPORT
char _res[RES_9_STATE_SIZE] = {0};
+LIBINFO_EXPORT
int
res_init(void)
{
return res;
}
+LIBINFO_EXPORT
int
res_query(const char *name, int class, int type, u_char *answer, int anslen)
{
return _mdns_query(SI_CALL_DNS_QUERY, name, class, type, answer, anslen);
}
+LIBINFO_EXPORT
int
res_search(const char *name, int class, int type, u_char *answer, int anslen)
{
/*
- * Copyright (c) 2012 Apple Inc. All rights reserved.
+ * Copyright (c) 2012-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#define __CONFIGURATION_PROFILE_H__
#include <xpc/xpc.h>
-#include <Availability.h>
+#include <os/availability.h>
-char *configuration_profile_create_notification_key(const char *ident) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
-xpc_object_t configuration_profile_copy_property_list(const char *ident) __OSX_AVAILABLE_STARTING(__MAC_10_9, __IPHONE_7_0);
+char *configuration_profile_create_notification_key(const char *ident) API_AVAILABLE(macos(10.9), ios(7.0));
+xpc_object_t configuration_profile_copy_property_list(const char *ident) API_AVAILABLE(macos(10.9), ios(7.0));
#endif /* __CONFIGURATION_PROFILE_H__ */
/*
- * Copyright (c) 1999-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* "x:x:x:x:x:x" where x is a hex number between 0x00 and 0xff; the
* bytes are always in network order.
*/
+#include "libinfo_common.h"
#include <stdlib.h>
#include <string.h>
* the corresponding hosts name.
* Returns zero if successful, non-zero otherwise.
*/
+LIBINFO_EXPORT
int
ether_line(const char *s, struct ether_addr *e, char *hostname)
{
* Converts a 48 bit ethernet number to its string representation.
*/
#define EI(i) (unsigned int)(e->ether_addr_octet[(i)])
+LIBINFO_EXPORT
char *
ether_ntoa(const struct ether_addr *e)
{
/*
* Converts a ethernet address representation back into its 48 bits.
*/
+LIBINFO_EXPORT
struct ether_addr *
ether_aton(const char *s)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/*
* Copyright (c) 1995, 1999
* Berkeley Software Design, Inc. All rights reserved.
* NOTE: SIOCGIFCONF case is not LP64 friendly. it also does not perform
* try-and-error for region size.
*/
+#include "libinfo_common.h"
+
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/socket.h>
#define MEMORY_MIN 2048
#define MEMORY_MAX 16777216
+LIBINFO_EXPORT
int
getifaddrs(struct ifaddrs **pif)
{
return (0);
}
+LIBINFO_EXPORT
void
freeifaddrs(struct ifaddrs *ifp)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/* $KAME: if_indextoname.c,v 1.7 2000/11/08 03:09:30 itojun Exp $ */
/*-
* BSDI Id: if_indextoname.c,v 2.3 2000/04/17 22:38:05 dab Exp
*/
+#include "libinfo_common.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_dl.h>
* NULL and errno would be set to the proper value (e.g., ENOMEM).
*/
+LIBINFO_EXPORT
char *
if_indextoname(unsigned int ifindex, char *ifname)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/* $KAME: if_nameindex.c,v 1.8 2000/11/24 08:20:01 itojun Exp $ */
/*-
* BSDI Id: if_nameindex.c,v 2.3 2000/04/17 22:38:05 dab Exp
*/
+#include "libinfo_common.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_dl.h>
* if_nameindex().
*/
+LIBINFO_EXPORT
struct if_nameindex *
if_nameindex(void)
{
}
#ifndef __OpenBSD__
+LIBINFO_EXPORT
void
if_freenameindex(struct if_nameindex *ptr)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/* $KAME: if_nametoindex.c,v 1.6 2000/11/24 08:18:54 itojun Exp $ */
/*-
* BSDI Id: if_nametoindex.c,v 2.3 2000/04/17 22:38:05 dab Exp
*/
+#include "libinfo_common.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>
* proper value (e.g., ENOMEM).
*/
+LIBINFO_EXPORT
unsigned int
if_nametoindex(const char *ifname)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/* $FreeBSD: src/include/ifaddrs.h,v 1.3.32.1.4.1 2010/06/14 02:09:06 kensmith Exp $ */
/*
#ifndef _IFADDRS_H_
#define _IFADDRS_H_
-#include <Availability.h>
+#include <os/availability.h>
struct ifaddrs {
struct ifaddrs *ifa_next;
__BEGIN_DECLS
extern int getifaddrs(struct ifaddrs **);
extern void freeifaddrs(struct ifaddrs *);
-extern int getifmaddrs(struct ifmaddrs **) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
-extern void freeifmaddrs(struct ifmaddrs *) __OSX_AVAILABLE_STARTING(__MAC_10_7, __IPHONE_4_3);
+extern int getifmaddrs(struct ifmaddrs **) API_AVAILABLE(macos(10.7), ios(4.3), watchos(4.0), tvos(11.0));
+extern void freeifmaddrs(struct ifmaddrs *) API_AVAILABLE(macos(10.7), ios(4.3), watchos(4.0), tvos(11.0));
__END_DECLS
#endif
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/* $KAME: ip6opt.c,v 1.13 2003/06/06 10:08:20 suz Exp $ */
/*
* $FreeBSD: src/lib/libc/net/ip6opt.c,v 1.8.10.2.2.1 2010/06/14 02:09:06 kensmith Exp $
*/
+#include "libinfo_common.h"
+
/*
* These routines support RFC 3542
* __APPLE_USE_RFC_3542 selects the appropriate API in <netinet6/in6.h>
* beginning (the value y in the alignment term "xn + y"), the type
* byte, the length byte, and the option data.
*/
+LIBINFO_EXPORT
int
inet6_option_space(int nbytes)
{
* contain either Hop-by-Hop or Destination options. It returns 0 on
* success or -1 on an error.
*/
+LIBINFO_EXPORT
int
inet6_option_init(void *bp, struct cmsghdr **cmsgp, int type)
{
* plusy is the value y in the alignment term "xn + y" described
* earlier. It must have a value between 0 and 7, inclusive.
*/
+LIBINFO_EXPORT
int
inet6_option_append(struct cmsghdr *cmsg, const u_int8_t *typep, int multx,
int plusy)
* then be built by the caller.
*
*/
+LIBINFO_EXPORT
u_int8_t *
inet6_option_alloc(struct cmsghdr *cmsg, int datalen, int multx, int plusy)
{
* error occurs, the return value is -1 and *tptrp is not NULL.
* (RFC 2292, 6.3.5)
*/
+LIBINFO_EXPORT
int
inet6_option_next(const struct cmsghdr *cmsg, u_int8_t **tptrp)
{
* Note: RFC 2292 says the type of tptrp is u_int8_t *, but we think
* it's a typo. The variable should be type of u_int8_t **.
*/
+LIBINFO_EXPORT
int
inet6_option_find(const struct cmsghdr *cmsg, u_int8_t **tptrp, int type)
{
* of RFC2292.
*/
+LIBINFO_EXPORT
int
inet6_opt_init(void *extbuf, socklen_t extlen)
{
return(2); /* sizeof the next and the length fields */
}
+LIBINFO_EXPORT
int
inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type, socklen_t len, u_int8_t align, void **databufp)
{
return(currentlen);
}
+LIBINFO_EXPORT
int
inet6_opt_finish(void *extbuf, socklen_t extlen, int offset)
{
return(updatelen);
}
+LIBINFO_EXPORT
int
inet6_opt_set_val(void *databuf, int offset, void *val, socklen_t vallen)
{
return(offset + vallen);
}
+LIBINFO_EXPORT
int
inet6_opt_next(void *extbuf, socklen_t extlen, int offset, u_int8_t *typep, socklen_t *lenp, void **databufp)
{
return(-1);
}
+LIBINFO_EXPORT
int
inet6_opt_find(void *extbuf, socklen_t extlen, int offset, u_int8_t type, socklen_t *lenp, void **databufp)
{
return(-1);
}
+LIBINFO_EXPORT
int
inet6_opt_get_val(void *databuf, int offset, void *val, socklen_t vallen)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/* $KAME: rthdr.c,v 1.19 2003/06/06 10:48:51 itojun Exp $ */
/*
/* __FBSDID("$FreeBSD: src/lib/libc/net/rthdr.c,v 1.9.10.1.4.1 2010/06/14 02:09:06 kensmith Exp $"); */
+#include "libinfo_common.h"
+
/*
* These routines support RFC 2292.
* __APPLE_USE_RFC_2292 selects the appropriate API in <netinet6/in6.h>
* RFC2292 API
*/
+LIBINFO_EXPORT
size_t
inet6_rthdr_space(type, seg)
int type, seg;
}
}
+LIBINFO_EXPORT
struct cmsghdr *
inet6_rthdr_init(bp, type)
void *bp;
}
/* ARGSUSED */
+LIBINFO_EXPORT
int
inet6_rthdr_add(cmsg, addr, flags)
struct cmsghdr *cmsg;
}
/* ARGSUSED */
+LIBINFO_EXPORT
int
inet6_rthdr_lasthop(cmsg, flags)
struct cmsghdr *cmsg;
}
#endif
+LIBINFO_EXPORT
int
inet6_rthdr_segments(cmsg)
const struct cmsghdr *cmsg;
}
}
+LIBINFO_EXPORT
struct in6_addr *
inet6_rthdr_getaddr(cmsg, idx)
struct cmsghdr *cmsg;
}
}
+LIBINFO_EXPORT
int
inet6_rthdr_getflags(cmsg, idx)
const struct cmsghdr *cmsg;
* RFC3542 API
*/
+LIBINFO_EXPORT
socklen_t
inet6_rth_space(int type, int segments)
{
}
}
+LIBINFO_EXPORT
void *
inet6_rth_init(void *bp, socklen_t bp_len, int type, int segments)
{
return (bp);
}
+LIBINFO_EXPORT
int
inet6_rth_add(void *bp, const struct in6_addr *addr)
{
return (0);
}
+LIBINFO_EXPORT
int
inet6_rth_reverse(const void *in, void *out)
{
return (0);
}
+LIBINFO_EXPORT
int
inet6_rth_segments(const void *bp)
{
}
}
+LIBINFO_EXPORT
struct in6_addr *
inet6_rth_getaddr(const void *bp, int idx)
{
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/*
* Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
* All rights reserved.
* $FreeBSD: src/lib/libc/net/vars.c,v 1.1 1999/12/16 18:32:01 shin Exp $
*/
+#include "libinfo_common.h"
+
#include <sys/types.h>
#include <netinet/in.h>
/*
* Definitions of some costant IPv6 addresses.
*/
-const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
-const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
-const struct in6_addr in6addr_nodelocal_allnodes = IN6ADDR_NODELOCAL_ALLNODES_INIT;
-const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
-const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
+LIBINFO_EXPORT const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT;
+LIBINFO_EXPORT const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT;
+LIBINFO_EXPORT const struct in6_addr in6addr_nodelocal_allnodes = IN6ADDR_NODELOCAL_ALLNODES_INIT;
+LIBINFO_EXPORT const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT;
+LIBINFO_EXPORT const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT;
/*
- * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <si_module.h>
#include <stdio.h>
#include <unistd.h>
#include <dispatch/dispatch.h>
/* GLOBAL */
+LIBINFO_EXPORT
uint32_t gL1CacheEnabled = 1;
#define CACHE_COUNT CATEGORY_COUNT
/*
- * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#ifdef DS_AVAILABLE
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
if (x != NULL) si_item_release(x);
}
+LIBINFO_EXPORT
void
_si_disable_opendirectory(void)
{
_ds_port = MACH_PORT_NULL;
}
+LIBINFO_EXPORT
int
_ds_running(void)
{
*
* @(#)grp.h 8.2 (Berkeley) 1/21/94
*/
-/* Portions copyright (c) 2000-2011 Apple Inc. All rights reserved. */
+/* Portions copyright (c) 2000-2018 Apple Inc. All rights reserved. */
#ifndef _GRP_H_
#define _GRP_H_
#if !defined(_XOPEN_SOURCE) || defined(_DARWIN_C_SOURCE)
__BEGIN_DECLS
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
void setgrfile(const char *);
+#endif
int setgroupent(int);
__END_DECLS
#endif
/*
- * Copyright (c) 1999-2010 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
* @ length (4 bytes) and buffer (requires two parameters)
*
*/
+LIBINFO_EXPORT
void *
LI_ils_create(char *fmt, ...)
{
/*
- * Copyright (c) 2009 Apple Inc. All rights reserved.
+ * Copyright (c) 2009-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
* (keys are always strings), "s" denotes a string value,
* "i" denotes a 32 bit signed int, and "u" denotes an unsigned.
*/
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_query(char *fmt, ...)
{
return kv;
}
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_query_key_val(const char *key, const char *val)
{
return kv;
}
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_query_key_int(const char *key, int32_t i)
{
return kvbuf_query_key_val(key, str);
}
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_query_key_uint(const char *key, uint32_t u)
{
return kvbuf_query_key_val(key, str);
}
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_new_zone(malloc_zone_t *zone)
{
return kv;
}
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_new(void)
{
return kvbuf_new_zone(malloc_default_zone());
}
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_init_zone(malloc_zone_t *zone, char *buffer, uint32_t length)
{
return kv;
}
+LIBINFO_EXPORT
kvbuf_t *
kvbuf_init(char *buffer, uint32_t length)
{
}
}
+LIBINFO_EXPORT
void
kvbuf_add_dict(kvbuf_t *kv)
{
memcpy(p, &x, sizeof(uint32_t));
}
+LIBINFO_EXPORT
void
kvbuf_add_key(kvbuf_t *kv, const char *key)
{
kv->_val = kv->datalen;
}
+LIBINFO_EXPORT
void
kvbuf_add_val_len(kvbuf_t *kv, const char *val, uint32_t len)
{
* which preceeds a pointer to a key or value. Obviously, calling it with anything
* other than a pointer value which is embedded in a kvbuf_t is asking for trouble.
*/
+LIBINFO_EXPORT
uint32_t
kvbuf_get_len(const char *p)
{
return ntohl(x);
}
+LIBINFO_EXPORT
void
kvbuf_add_val(kvbuf_t *kv, const char *val)
{
kvbuf_add_val_len(kv, val, strlen(val) + 1);
}
+LIBINFO_EXPORT
void
kvbuf_make_purgeable(kvbuf_t *kv)
{
if (kv->databuf != NULL) malloc_make_purgeable(kv->databuf);
}
+LIBINFO_EXPORT
int
kvbuf_make_nonpurgeable(kvbuf_t *kv)
{
return 1;
}
+LIBINFO_EXPORT
void
kvbuf_free(kvbuf_t *kv)
{
}
/* appends a kvbuf to an existing kvbuf */
+LIBINFO_EXPORT
void
kvbuf_append_kvbuf(kvbuf_t *kv, const kvbuf_t *kv2)
{
}
/* returns number of dictionaries */
+LIBINFO_EXPORT
uint32_t
kvbuf_reset(kvbuf_t *kv)
{
}
/* advance to next dictionary, returns key count */
+LIBINFO_EXPORT
uint32_t
kvbuf_next_dict(kvbuf_t *kv)
{
}
/* advance to next key, returns key and sets val_count */
+LIBINFO_EXPORT
char *
kvbuf_next_key(kvbuf_t *kv, uint32_t *val_count)
{
return out;
}
+LIBINFO_EXPORT
char *
kvbuf_next_val(kvbuf_t *kv)
{
return kvbuf_next_val_len(kv, NULL);
}
+LIBINFO_EXPORT
char *
kvbuf_next_val_len(kvbuf_t *kv, uint32_t *len)
{
* memory AND to free the original kvbuf, clients only
* need to call kvarray_free().
*/
+LIBINFO_EXPORT
kvarray_t *
kvbuf_decode(kvbuf_t *kv)
{
return a;
}
+LIBINFO_EXPORT
void
kvarray_free(kvarray_t *a)
{
/*
- * Copyright (c) 2008-2015 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
return search;
}
+LIBINFO_EXPORT
si_mod_t *
si_search(void)
{
return search;
}
+LIBINFO_EXPORT
void
si_search_module_set_flags(const char *name, uint32_t flag)
{
/* USER */
+LIBINFO_EXPORT
struct passwd *
getpwnam(const char *name)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct passwd *
getpwuid(uid_t uid)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct passwd *
getpwuuid(uuid_t uuid)
{
return (struct passwd *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
setpwent(void)
{
LI_set_thread_list(CATEGORY_USER, NULL);
}
+LIBINFO_EXPORT
struct passwd *
getpwent(void)
{
return (struct passwd *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endpwent(void)
{
LI_set_thread_list(CATEGORY_USER, NULL);
}
+LIBINFO_EXPORT
int
setpassent(int ignored)
{
/* GROUP */
+LIBINFO_EXPORT
struct group *
getgrnam(const char *name)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct group *
getgrgid(gid_t gid)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct group *
getgruuid(uuid_t uuid)
{
return (struct group *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
setgrent(void)
{
LI_set_thread_list(CATEGORY_GROUP, NULL);
}
+LIBINFO_EXPORT
struct group *
getgrent(void)
{
return (struct group *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endgrent(void)
{
LI_set_thread_list(CATEGORY_GROUP, NULL);
}
+LIBINFO_EXPORT
int
setgroupent(int ignored)
{
}
/* NETGROUP */
+LIBINFO_EXPORT
int
innetgr(const char *group, const char *host, const char *user, const char *domain)
{
* setnetgrent is really more like a getXXXbyname routine than a
* setXXXent routine, since we are looking up a netgroup by name.
*/
+LIBINFO_EXPORT
void
setnetgrent(const char *name)
{
/* N.B. there is no async getnetgrent */
+LIBINFO_EXPORT
int
getnetgrent(char **host, char **user, char **domain)
{
return 1;
}
+LIBINFO_EXPORT
void
endnetgrent(void)
{
return 0;
}
+LIBINFO_EXPORT
int
getgrouplist(const char *name, int basegid, int *groups, int *ngroups)
{
return count;
}
+LIBINFO_EXPORT
int32_t
getgrouplist_2(const char *name, gid_t basegid, gid_t **groups)
{
return _getgrouplist_2_internal(name, basegid, groups);
}
+LIBINFO_EXPORT
int32_t
getgroupcount(const char *name, gid_t basegid)
{
/* XXX to do: async getgrouplist_2 */
+LIBINFO_EXPORT
int
initgroups(const char *name, int basegid)
{
/* ALIAS */
+LIBINFO_EXPORT
struct aliasent *
alias_getbyname(const char *name)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
void
alias_setent(void)
{
LI_set_thread_list(CATEGORY_ALIAS, NULL);
}
+LIBINFO_EXPORT
struct aliasent *
alias_getent(void)
{
return (struct aliasent *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
alias_endent(void)
{
/* HOST */
+LIBINFO_EXPORT
void
freehostent(struct hostent *h)
{
return (struct hostent *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
struct hostent *
gethostbyname(const char *name)
{
return si_async_call(si_search(), SI_CALL_HOST_BYNAME, name, NULL, NULL, AF_INET, 0, 0, 0, (void *)si_libinfo_general_callback, sictx);
}
+LIBINFO_EXPORT
mach_port_t
gethostbyname_async_start(const char *name, si_host_async_callback callback, void *context)
{
return gethostbyname_async_call(name, callback, context);
}
+LIBINFO_EXPORT
void
gethostbyname_async_cancel(mach_port_t p)
{
}
#endif
+LIBINFO_EXPORT
void
gethostbyname_async_handleReply(void *param)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct hostent *
gethostbyname2(const char *name, int af)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct hostent *
gethostbyaddr(const void *addr, socklen_t len, int type)
{
return si_async_call(si_search(), SI_CALL_HOST_BYADDR, addr, NULL, NULL, (uint32_t)type, 0, addrlen, 0, (void *)si_libinfo_general_callback, sictx);
}
+LIBINFO_EXPORT
mach_port_t
gethostbyaddr_async_start(const char *addr, int len, int family, si_host_async_callback callback, void *context)
{
return gethostbyaddr_async_call(addr, slen, family, callback, context);
}
+LIBINFO_EXPORT
void
gethostbyaddr_async_cancel(mach_port_t p)
{
}
#endif
+LIBINFO_EXPORT
void
gethostbyaddr_async_handleReply(void *param)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct hostent *
getipnodebyname(const char *name, int family, int flags, int *err)
{
return 1;
}
+LIBINFO_EXPORT
struct hostent *
getipnodebyaddr(const void *src, size_t len, int family, int *err)
{
}
#endif
+LIBINFO_EXPORT
void
sethostent(int ignored)
{
LI_set_thread_list(CATEGORY_HOST, NULL);
}
+LIBINFO_EXPORT
struct hostent *
gethostent(void)
{
return (struct hostent *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endhostent(void)
{
/* MAC ADDRESS */
+LIBINFO_EXPORT
int
ether_hostton(const char *name, struct ether_addr *e)
{
/* XXX to do? async ether_hostton */
+LIBINFO_EXPORT
int
ether_ntohost(char *name, const struct ether_addr *e)
{
/* NETWORK */
+LIBINFO_EXPORT
struct netent *
getnetbyname(const char *name)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct netent *
getnetbyaddr(uint32_t net, int type)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
void
setnetent(int ignored)
{
LI_set_thread_list(CATEGORY_NETWORK, NULL);
}
+LIBINFO_EXPORT
struct netent *
getnetent(void)
{
return (struct netent *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endnetent(void)
{
/* SERVICE */
+LIBINFO_EXPORT
struct servent *
getservbyname(const char *name, const char *proto)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct servent *
getservbyport(int port, const char *proto)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
void
setservent(int ignored)
{
LI_set_thread_list(CATEGORY_SERVICE, NULL);
}
+LIBINFO_EXPORT
struct servent *
getservent(void)
{
return (struct servent *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endservent(void)
{
/* PROTOCOL */
+LIBINFO_EXPORT
struct protoent *
getprotobyname(const char *name)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct protoent *
getprotobynumber(int number)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
void
setprotoent(int ignored)
{
LI_set_thread_list(CATEGORY_PROTOCOL, NULL);
}
+LIBINFO_EXPORT
struct protoent *
getprotoent(void)
{
return (struct protoent *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endprotoent(void)
{
/* RPC */
+LIBINFO_EXPORT
struct rpcent *
getrpcbyname(const char *name)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct rpcent *
getrpcbynumber
(
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
void
setrpcent(int ignored)
{
LI_set_thread_list(CATEGORY_RPC, NULL);
}
+LIBINFO_EXPORT
struct rpcent *
getrpcent(void)
{
return (struct rpcent *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endrpcent(void)
{
/* FS */
+LIBINFO_EXPORT
struct fstab *
getfsspec(const char *spec)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
struct fstab *
getfsfile(const char *file)
{
si_async_handle_reply(msg);
}
+LIBINFO_EXPORT
int
setfsent(void)
{
return 1;
}
+LIBINFO_EXPORT
struct fstab *
getfsent(void)
{
return (struct fstab *)((uintptr_t)item + sizeof(si_item_t));
}
+LIBINFO_EXPORT
void
endfsent(void)
{
return status;
}
+LIBINFO_EXPORT
int
getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res)
{
}
/* SPI */
+LIBINFO_EXPORT
mach_port_t
_getaddrinfo_interface_async_call(const char *nodename, const char *servname, const struct addrinfo *hints, const char *interface, si_addrinfo_async_callback callback, void *context)
{
return _getaddrinfo_interface_async_call(nodename, servname, hints, NULL, callback, context);
}
+LIBINFO_EXPORT
int32_t
getaddrinfo_async_start(mach_port_t *p, const char *nodename, const char *servname, const struct addrinfo *hints, si_addrinfo_async_callback callback, void *context)
{
return 0;
}
+LIBINFO_EXPORT
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);
}
+LIBINFO_EXPORT
int32_t
getaddrinfo_async_receive(mach_port_t p, struct addrinfo **res)
{
return EAI_SYSTEM;
}
+LIBINFO_EXPORT
void
getaddrinfo_async_cancel(mach_port_t p)
{
si_async_cancel(p);
}
+LIBINFO_EXPORT
int32_t
getaddrinfo_async_handle_reply(void *param)
{
return 0;
}
+LIBINFO_EXPORT
int
getnameinfo(const struct sockaddr *sa, socklen_t salen, char *node, socklen_t nodelen, char *service, socklen_t servicelen, int flags)
{
}
/* SPI */
+LIBINFO_EXPORT
mach_port_t
_getnameinfo_interface_async_call(const struct sockaddr *sa, size_t len, int flags, const char *interface, si_nameinfo_async_callback callback, void *context)
{
return _getnameinfo_interface_async_call(sa, len, flags, NULL, callback, context);
}
+LIBINFO_EXPORT
int32_t
getnameinfo_async_start(mach_port_t *p, const struct sockaddr *sa, size_t salen, int flags, si_nameinfo_async_callback callback, void *context)
{
return 0;
}
+LIBINFO_EXPORT
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);
}
+LIBINFO_EXPORT
void
getnameinfo_async_cancel(mach_port_t p)
{
si_async_cancel(p);
}
+LIBINFO_EXPORT
int32_t
getnameinfo_async_handle_reply(void *param)
{
return 0;
}
+LIBINFO_EXPORT
int
getgrnam_r(const char *name, struct group *grp, char *buffer, size_t bufsize, struct group **result)
{
return 0;
}
+LIBINFO_EXPORT
int
getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t bufsize, struct group **result)
{
return 0;
}
+LIBINFO_EXPORT
int
getgruuid_r(uuid_t uuid, struct group *grp, char *buffer, size_t bufsize, struct group **result)
{
return 0;
}
+LIBINFO_EXPORT
int
getpwnam_r(const char *name, struct passwd *pw, char *buffer, size_t bufsize, struct passwd **result)
{
return 0;
}
+LIBINFO_EXPORT
int
getpwuid_r(uid_t uid, struct passwd *pw, char *buffer, size_t bufsize, struct passwd **result)
{
return 0;
}
+LIBINFO_EXPORT
int
getpwuuid_r(uuid_t uuid, struct passwd *pw, char *buffer, size_t bufsize, struct passwd **result)
{
/* misc */
+LIBINFO_EXPORT
char *
user_from_uid(uid_t uid, int nouser)
{
return buf;
}
+LIBINFO_EXPORT
char *
group_from_gid(gid_t gid, int nogroup)
{
/* no longer supported */
+LIBINFO_EXPORT
const prdb_ent *
prdb_getbyname(const char *name)
{
return NULL;
}
+LIBINFO_EXPORT
const prdb_ent *
prdb_get(void)
{
return NULL;
}
+LIBINFO_EXPORT
void
prdb_set(const char *name)
{
#endif
}
+LIBINFO_EXPORT
void
prdb_end(void)
{
#endif
}
+LIBINFO_EXPORT
struct bootparamsent *
bootparams_getbyname(const char *name)
{
return NULL;
}
+LIBINFO_EXPORT
struct bootparamsent *
bootparams_getent(void)
{
return NULL;
}
+LIBINFO_EXPORT
void
bootparams_setent(void)
{
#endif
}
+LIBINFO_EXPORT
void
bootparams_endent(void)
{
/*
- * Copyright (c) 2008-2015 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <dns_sd.h>
#include <dnsinfo.h>
#include <errno.h>
+#include <ifaddrs.h>
#include <nameser.h>
#include <notify.h>
#include <pthread.h>
static void _mdns_hostent_clear(mdns_hostent_t *h);
static void _mdns_reply_clear(mdns_reply_t *r);
static int _mdns_search(const char *name, int class, int type, const char *interface, DNSServiceFlags flags, uint8_t *answer, uint32_t *anslen, mdns_reply_t *reply);
+static int _mdns_search_ex(const char *name, int class, int type, uint32_t ifindex, DNSServiceFlags flags, uint8_t *answer, uint32_t *anslen, mdns_reply_t *reply);
static const char hexchar[] = "0123456789abcdef";
}
static char *
-_mdns_reverse_ipv4(const char *addr)
+_mdns_reverse_ipv4(const uint8_t *addr)
{
union
{
}
static char *
-_mdns_reverse_ipv6(const char *addr)
+_mdns_reverse_ipv6(const uint8_t *addr)
{
char x[65], *p;
int i, j;
return out;
}
+static bool _is_v4addr_ifaddr(const uint8_t addrBytes[4])
+{
+ int err;
+ struct ifaddrs *ifaddrs;
+ const struct ifaddrs *ifa;
+ const struct sockaddr_in *sa4;
+ in_addr_t addr;
+ bool found = false;
+
+ err = getifaddrs(&ifaddrs);
+ if (err != 0) goto exit;
+
+ memcpy(&addr, addrBytes, 4);
+ for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next)
+ {
+ if ((ifa->ifa_flags & IFF_UP) == 0) continue;
+ if (!ifa->ifa_addr || (ifa->ifa_addr->sa_family != AF_INET)) continue;
+ sa4 = (const struct sockaddr_in *)ifa->ifa_addr;
+ if (sa4->sin_addr.s_addr == addr)
+ {
+ found = true;
+ break;
+ }
+ }
+ freeifaddrs(ifaddrs);
+
+exit:
+ return found;
+}
+
+static bool _is_v6addr_ifaddr(const uint8_t addrBytes[16], uint32_t ifindex)
+{
+ int err;
+ struct ifaddrs *ifaddrs;
+ const struct ifaddrs *ifa;
+ const struct sockaddr_in6 *sa6;
+ bool found = false;
+
+ err = getifaddrs(&ifaddrs);
+ if (err != 0) goto exit;
+
+ for (ifa = ifaddrs; ifa; ifa = ifa->ifa_next)
+ {
+ if ((ifa->ifa_flags & IFF_UP) == 0) continue;
+ if (!ifa->ifa_addr || (ifa->ifa_addr->sa_family != AF_INET6)) continue;
+ sa6 = (const struct sockaddr_in6 *)ifa->ifa_addr;
+ if ((sa6->sin6_scope_id == ifindex) && (memcmp(&sa6->sin6_addr.s6_addr, addrBytes, 16) == 0))
+ {
+ found = true;
+ break;
+ }
+ }
+ freeifaddrs(ifaddrs);
+
+exit:
+ return found;
+}
+
static si_item_t *
mdns_hostbyaddr(si_mod_t *si, const void *addr, int af, const char *interface, uint32_t *err)
{
int cat;
int status;
DNSServiceFlags flags = 0;
+ uint32_t ifindex = 0;
if (err != NULL) *err = SI_STATUS_NO_ERROR;
switch (af)
{
case AF_INET:
+ {
+ const uint8_t * const target_addr = (const uint8_t *)addr;
+
+ // If no interface is specified; the IPv4 address is a link-local address, i.e., it's in 169.254.0.0/16; and the
+ // IPv4 address belongs to one of the local host's interfaces, then use kDNSServiceInterfaceIndexLocalOnly as
+ // the interface index to pass to DNSServiceQueryRecord(). This is done to get a response directly from
+ // mDNSResponder's authoritative resource records as opposed to issuing an mDNS query, which does not work if
+ // the interface is currently not participating in mDNS. See <rdar://problem/40702045> for more details.
+
+ if (!interface && (target_addr[0] == 169) && (target_addr[1] == 254) && _is_v4addr_ifaddr(target_addr))
+ {
+ ifindex = kDNSServiceInterfaceIndexLocalOnly;
+ }
h.host.h_length = 4;
reply.h4 = &h;
- name = _mdns_reverse_ipv4(addr);
+ name = _mdns_reverse_ipv4(target_addr);
cat = CATEGORY_HOST_IPV4;
break;
+ }
case AF_INET6:
+ {
+ const uint8_t *target_addr = (const uint8_t *)addr;
+ uint8_t fixed_addr[16];
+
+ // If no interface is specified; the IPv6 address is a link-local address, i.e., it's in fe80::/10; and the IPv6
+ // address belongs to one of the local host's interfaces, then use kDNSServiceInterfaceIndexLocalOnly as the
+ // interface index to pass to DNSServiceQueryRecord(). For rationale, see the comment for the AF_INET case.
+
+ if (!interface && (target_addr[0] == 0xFE) && ((target_addr[1] & 0xC0) == 0x80))
+ {
+ // Note: si_nameinfo() embeds the scope ID (interface index) in bytes 2 and 3 in network byte order.
+
+ const uint32_t embedded_index = (target_addr[2] << 8) | target_addr[3];
+
+ memcpy(fixed_addr, target_addr, 16);
+ fixed_addr[2] = 0;
+ fixed_addr[3] = 0;
+
+ if ((embedded_index != 0) && _is_v6addr_ifaddr(fixed_addr, embedded_index))
+ {
+ target_addr = fixed_addr;
+ ifindex = kDNSServiceInterfaceIndexLocalOnly;
+ }
+ else
+ {
+ ifindex = embedded_index;
+ }
+ }
+
h.host.h_length = 16;
reply.h6 = &h;
- name = _mdns_reverse_ipv6(addr);
+ name = _mdns_reverse_ipv6(target_addr);
cat = CATEGORY_HOST_IPV6;
break;
+ }
default:
if (err != NULL) *err = SI_STATUS_H_ERRNO_NO_RECOVERY;
return NULL;
_mdns_debug_message(";; mdns_hostbyaddr %s type %u class %u\n", name, ns_t_ptr, ns_c_in);
- status = _mdns_search(name, ns_c_in, ns_t_ptr, interface, flags, NULL, NULL, &reply);
+ if (interface)
+ {
+ status = _mdns_search(name, ns_c_in, ns_t_ptr, interface, flags, NULL, NULL, &reply);
+ }
+ else
+ {
+ status = _mdns_search_ex(name, ns_c_in, ns_t_ptr, ifindex, flags, NULL, NULL, &reply);
+ }
free(name);
if (status != 0)
{
* initializes the context and starts a DNS-SD query.
*/
static DNSServiceErrorType
-_mdns_query_start(mdns_query_context_t *ctx, mdns_reply_t *reply, uint8_t *answer, uint32_t *anslen, const char* name, int class, int type, const char *interface, DNSServiceFlags flags, int kq)
+_mdns_query_start(mdns_query_context_t *ctx, mdns_reply_t *reply, uint8_t *answer, uint32_t *anslen, const char* name, int class, int type, uint32_t ifindex, DNSServiceFlags flags, int kq)
{
DNSServiceErrorType status;
char *qname = _mdns_ipv6_extract_scope_id(name, &iface);
if (qname == NULL) qname = (char *)name;
- if (interface != NULL)
+ if (ifindex != 0)
{
- /* get interface number from name */
- int iface2 = if_nametoindex(interface);
-
- /* balk if interface name lookup failed */
- if (iface2 == 0) return -1;
-
/* balk if scope id is set AND interface is given AND they don't match */
- if ((iface != 0) && (iface2 != 0) && (iface != iface2)) return -1;
- if (iface2 != 0) iface = iface2;
+ if ((iface != 0) && (iface != ifindex)) return -1;
+ iface = ifindex;
}
- _mdns_debug_message(";; mdns query %s type %d class %d [ctx %p]\n", qname, type, class, ctx);
+ _mdns_debug_message(";; mdns query %s type %d class %d ifindex %d [ctx %p]\n", qname, type, class, (int)iface, ctx);
status = DNSServiceQueryRecord(&ctx->sd, flags, iface, qname, type, class, _mdns_query_callback, ctx);
if (qname != name) free(qname);
_mdns_sub_time(timeout, deadline, &now);
}
-int
+extern int
+si_inet_config(uint32_t *inet4, uint32_t *inet6);
+
+static int
_mdns_search(const char *name, int class, int type, const char *interface, DNSServiceFlags flags, uint8_t *answer, uint32_t *anslen, mdns_reply_t *reply)
+{
+ uint32_t ifindex;
+
+ if (interface)
+ {
+ ifindex = if_nametoindex(interface);
+ if (ifindex == 0) return -1;
+ }
+ else
+ {
+ ifindex = 0;
+ }
+
+ return _mdns_search_ex(name, class, type, ifindex, flags, answer, anslen, reply);
+}
+
+static int
+_mdns_search_ex(const char *name, int class, int type, uint32_t ifindex, DNSServiceFlags flags, uint8_t *answer, uint32_t *anslen, mdns_reply_t *reply)
{
DNSServiceErrorType err = 0;
int kq, n;
*/
if (err == 0)
{
- err = _mdns_query_start(&ctx[n_ctx++], reply, answer, anslen, name, class, (type == 0) ? ns_t_a : type, interface, flags, kq);
+ err = _mdns_query_start(&ctx[n_ctx++], reply, answer, anslen, name, class, (type == 0) ? ns_t_a : type, ifindex, flags, kq);
}
if ((err == 0) && (type == 0))
{
- err = _mdns_query_start(&ctx[n_ctx++], reply, answer, anslen, name, class, ns_t_aaaa, interface, flags, kq);
+ err = _mdns_query_start(&ctx[n_ctx++], reply, answer, anslen, name, class, ns_t_aaaa, ifindex, flags, kq);
}
if (err != 0) _mdns_debug_message(";; initialization error %d\n", err);
/*
- * Copyright (c) 2002-2009 Apple Inc. All rights reserved.
+ * Copyright (c) 2002-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#define gethostbyname_async_handle_reply gethostbyname_async_handleReply
#define gethostbyaddr_async_handle_reply gethostbyaddr_async_handleReply
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
#define getipnodebyaddr_async_handle_reply getipnodebyaddr_async_handleReply
#define getipnodebyname_async_handle_reply getipnodebyname_async_handleReply
+#endif
/* SPI for parallel / fast getaddrinfo */
#define AI_PARALLEL 0x00000008
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);
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
int32_t getnameinfo_async_receive(mach_port_t p, char **host, char **serv);
+#endif
int32_t getnameinfo_async_handle_reply(void *msg);
void getnameinfo_async_cancel(mach_port_t p);
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
/*
* DNS
*/
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);
void dns_async_cancel(mach_port_t p);
+#endif
/*
* Host lookup
*/
void gethostbyname_async_handleReply(void *replyMsg);
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
/*
@typedef getipnodebyaddr_async_callback
@discussion Type of the callback function used when a
@param replyMsg The Mach message.
*/
void getipnodebyname_async_handleReply(void *replyMsg);
+#endif // !LIBINFO_INSTALL_API
__END_DECLS
--- /dev/null
+//
+// si_compare.c
+// Libinfo
+//
+// Copyright (c) 2011-2017 Apple Inc. All rights reserved.
+//
+//
+
+#include "si_compare.h"
+
+#include <dispatch/dispatch.h>
+#include <sys/ioctl.h>
+#include <sys/kern_control.h>
+#include <sys/socketvar.h>
+#include <sys/sys_domain.h>
+#include <netinet/in.h>
+#include <net/netsrc.h>
+#include <net/if.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+#include <os/lock.h>
+#include <os/log.h>
+#include <mach/mach_time.h>
+#include <net/ntstat.h>
+
+enum
+{
+ kPrefer_Dest1 = 1,
+ kPrefer_Dest2 = -1,
+ kPrefer_Equal = 0,
+ kPrefer_Dest1_Slightly = 2,
+ kPrefer_Dest2_Slightly = -2,
+};
+
+enum
+{
+ kLookupFailure = 0,
+ kLookupSuccess_Found = 1,
+ kLookupSuccess_Created = 2,
+};
+
+typedef struct RFC6724Address
+{
+ union sockaddr_in_4_6 addr;
+ uint32_t flags;
+ uint16_t label;
+ uint16_t precedence;
+} RFC6724Address;
+
+typedef struct Destination
+{
+ RFC6724Address d_dst;
+ RFC6724Address d_src;
+ uint32_t d_ifindex;
+ uint32_t d_resolved_ifindex;
+ uint32_t d_min_rtt;
+ uint32_t d_connection_attempts;
+ uint32_t d_connection_successes;
+ unsigned d_routable : 1;
+ unsigned d_direct : 1;
+ unsigned d_awdl : 1;
+} Destination;
+
+typedef struct DestCacheEntry
+{
+ uint64_t dce_time;
+ struct DestCacheEntry *dce_next;
+ Destination dce_entry;
+} DestCacheEntry;
+
+typedef struct DestCompareSettings {
+ uint32_t rtt_leeway;
+ uint32_t rtt_leeway_small;
+ int64_t rtt_failure_threshold;
+ bool bypass_stats;
+} DestCompareSettings;
+
+static DestCacheEntry *cache = NULL;
+static os_unfair_lock cache_lock = OS_UNFAIR_LOCK_INIT;
+static uint64_t cache_timeout = 0ULL;
+static os_log_t si_destination_log = OS_LOG_DEFAULT;
+static DestCompareSettings si_compare_settings = {};
+
+static const uint32_t kLoopbackIndex = 1;
+
+#ifndef TCP_RTT_SCALE
+#define TCP_RTT_SCALE 32 // see netinet/tcp_var.h
+#endif // defined(TCP_RTT_SCALE)
+
+#define SI_DESTINATION_COMPARE_UNLIKELY_BOOL(b) (__builtin_expect(!!((long)(b)), 0L))
+#define SI_DESTINATION_COMPARE_CHECK_ARG_RETURN(arg, toReturn) \
+ do { \
+ if (SI_DESTINATION_COMPARE_UNLIKELY_BOOL(!arg)) { \
+ os_log_fault(si_destination_log, "%{public}s " #arg " is NULL", __FUNCTION__); \
+ return toReturn; \
+ } \
+ } \
+ while (0)
+
+static const uint32_t kFailureAttemptsTolerated = 10;
+static const uint32_t kDefaultRTTLeeway = 100 * TCP_RTT_SCALE;
+static const uint32_t kDefaultRTTLeewaySmall = 10 * TCP_RTT_SCALE;
+
+static void
+si_destination_compare_child_has_forked(void)
+{
+ cache_lock = OS_UNFAIR_LOCK_INIT;
+}
+
+static void
+si_destination_compare_init_once(void)
+{
+ mach_timebase_info_data_t time_base;
+ mach_timebase_info(&time_base);
+
+ cache_timeout = NSEC_PER_SEC;
+ cache_timeout *= time_base.denom;
+ cache_timeout /= time_base.numer;
+
+ si_destination_log = os_log_create("com.apple.network.libinfo", "si_destination_compare");
+
+ si_compare_settings = (DestCompareSettings){
+ .rtt_leeway = kDefaultRTTLeeway,
+ .rtt_leeway_small = kDefaultRTTLeewaySmall,
+ .rtt_failure_threshold = kFailureAttemptsTolerated,
+ .bypass_stats = false
+ };
+
+ (void)pthread_atfork(NULL, NULL, si_destination_compare_child_has_forked);
+}
+
+static void
+si_destination_compare_init(void)
+{
+ static pthread_once_t cache_init = PTHREAD_ONCE_INIT;
+ pthread_once(&cache_init, si_destination_compare_init_once);
+}
+
+#pragma mark -- Netsrc --
+
+int
+si_destination_create_control_socket(const char *control_name)
+{
+ // Creat a socket
+ const int fd = socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL);
+ if (fd == -1)
+ {
+ os_log_error(si_destination_log, "socket(PF_SYSTEM, SOCK_DGRAM, SYSPROTO_CONTROL) failed: %m");
+ return fd;
+ }
+
+ // Disable SIGPIPE <rdar://problem/9049030>
+ int on = 1;
+ if (setsockopt(fd, SOL_SOCKET, SO_NOSIGPIPE, &on, sizeof(on)) != 0)
+ {
+ os_log_error(si_destination_log, "setsockopt(%d, SOL_SOCKET, SO_NOSIGPIPE, ...) failed: %m", fd);
+ close(fd);
+ return -1;
+ }
+
+ // Get the control ID for statistics
+ struct ctl_info ctl = {
+ .ctl_id = 0,
+ .ctl_name = { 0 }
+ };
+ strlcpy(ctl.ctl_name, control_name, sizeof(ctl.ctl_name));
+ if (ioctl(fd, CTLIOCGINFO, &ctl) == -1)
+ {
+ os_log_error(si_destination_log, "ioctl(%d, CTLIOCGINFO, ...) failed: %m", fd);
+ close(fd);
+ return -1;
+ }
+
+ // Connect to the statistics control
+ struct sockaddr_ctl sc = {
+ .sc_len = sizeof(sc),
+ .sc_family = AF_SYSTEM,
+ .ss_sysaddr = SYSPROTO_CONTROL,
+ .sc_id = ctl.ctl_id,
+ .sc_unit = 0,
+ .sc_reserved = { 0, 0, 0, 0, 0 }
+ };
+ if (connect(fd, (struct sockaddr *)&sc, sc.sc_len) != 0)
+ {
+ os_log_error(si_destination_log, "connect(%d, ...) ctl_id=%u, failed: %m", fd, ctl.ctl_id);
+ close(fd);
+ return -1;
+ }
+
+ // increase the receive socket buffer size
+ int rcvbuf = 128 * 1024;
+ if (0 != setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &rcvbuf, sizeof(rcvbuf))) {
+ os_log_error(si_destination_log, "setsockopt(%d, SOL_SOCKET, SO_RCVBUF, %d) failed: %m",
+ fd, rcvbuf);
+ }
+
+ // Set socket to non-blocking operation
+ const int flags = fcntl(fd, F_GETFL, 0);
+ if (-1 != flags) {
+ if (-1 == fcntl(fd, F_SETFL, flags | O_NONBLOCK)) {
+ os_log_error(si_destination_log, "fcntl(%d, F_SETFL, %d) failed: %m", fd, flags | O_NONBLOCK);
+ }
+ } else {
+ os_log_error(si_destination_log, "fcntl(%d, F_GETFL, 0) failed: %m", fd);
+ }
+
+ return fd;
+}
+
+static void
+si_destination_fill_netsrc(Destination *d)
+{
+ static int netsrc_sockfd = -1;
+ static int version = NETSRC_CURVERS;
+
+ if (netsrc_sockfd < 0) {
+ netsrc_sockfd = si_destination_create_control_socket(NETSRC_CTLNAME);
+ }
+ if (netsrc_sockfd < 0) {
+ return;
+ }
+
+ // Make sure we have a socket, create one if necessary
+ struct netsrc_req request = {
+ .nrq_ver = version,
+ .nrq_ifscope = d->d_ifindex,
+ };
+
+ if (d->d_dst.addr.sa.sa_len > sizeof(request._usa)) {
+ os_log_debug(si_destination_log, "sockaddr is too big");
+ return;
+ }
+ memcpy(&request._usa, &d->d_dst, d->d_dst.addr.sa.sa_len);
+ if (send(netsrc_sockfd, &request, sizeof(request), 0) != sizeof(request))
+ {
+ if (errno == EINVAL && version != NETSRC_VERSION1) {
+ // fall back to version 1
+ version = NETSRC_VERSION1;
+ si_destination_fill_netsrc(d);
+ }
+ // Expected when there is no route to host
+ os_log_error(si_destination_log, "send failed: %m");
+ return;
+ }
+
+ // Read the response
+ if (version == NETSRC_VERSION1) {
+#ifdef NETSRC_VERSION2
+ struct netsrc_repv1 v1;
+#else // NETSRC_VERSION2
+ struct netsrc_rep v1;
+#endif // NETSRC_VERSION2
+ if (recv(netsrc_sockfd, &v1, sizeof(v1), 0) != sizeof(v1)) {
+ // Not expected
+ os_log_debug(si_destination_log, "recv failed: %m");
+ return;
+ }
+ d->d_dst.label = v1.nrp_dstlabel;
+ d->d_dst.precedence = v1.nrp_dstprecedence;
+ if (v1.nrq_sin.sin_len <= sizeof(d->d_src.addr)) {
+ memcpy( &d->d_src.addr, &v1._usa, v1.nrq_sin.sin_len);
+ }
+ d->d_src.label = v1.nrp_label;
+ d->d_src.precedence = v1.nrp_precedence;
+ d->d_src.flags = v1.nrp_flags;
+ return;
+ }
+#ifdef NETSRC_VERSION2
+ else if (version == NETSRC_VERSION2) {
+ struct netsrc_repv2 v2;
+ if (recv(netsrc_sockfd, &v2, sizeof(v2), 0) != sizeof(v2)) {
+ // Not expected
+ os_log_debug(si_destination_log, "recv failed: %m");
+ return;
+ }
+ d->d_dst.label = v2.nrp_dstlabel;
+ d->d_dst.precedence = v2.nrp_dstprecedence;
+ d->d_src.addr = v2.nrp_src;
+ d->d_src.label = v2.nrp_label;
+ d->d_src.precedence = v2.nrp_precedence;
+ d->d_src.flags = v2.nrp_flags;
+ d->d_resolved_ifindex = v2.nrp_ifindex;
+ d->d_min_rtt = v2.nrp_min_rtt;
+ d->d_connection_attempts = v2.nrp_connection_attempts;
+ d->d_connection_successes = v2.nrp_connection_successes;
+ d->d_routable = (v2.nrp_flags & NETSRC_FLAG_ROUTEABLE) ? 1 : 0;
+ d->d_direct = (v2.nrp_flags & NETSRC_FLAG_DIRECT) ? 1 : 0;
+ d->d_awdl = (v2.nrp_flags & NETSRC_FLAG_AWDL) ? 1 : 0;
+ return;
+ }
+#endif // NETSRC_VERSION2
+
+ return;
+}
+
+#pragma mark -- Statistics --
+
+static int
+si_destination_compare_statistics(
+ Destination *dst1,
+ Destination *dst2)
+{
+ int slightPreference = kPrefer_Equal;
+ // If we have min round trip times for both, use that
+ if (dst1->d_min_rtt && dst2->d_min_rtt)
+ {
+#define RTT_MSEC_DOUBLE_FROM_DST( dst ) (((double)(dst->d_min_rtt)) / ((double)(TCP_RTT_SCALE)))
+ if (dst1->d_min_rtt < dst2->d_min_rtt)
+ {
+ if (dst1->d_min_rtt + si_compare_settings.rtt_leeway < dst2->d_min_rtt)
+ {
+ os_log_debug(si_destination_log,
+ "prefering 1, dst1 min rtt %f < dst2 min rtt %f, leeway %u small leeway %u",
+ RTT_MSEC_DOUBLE_FROM_DST(dst1), RTT_MSEC_DOUBLE_FROM_DST(dst2),
+ si_compare_settings.rtt_leeway / TCP_RTT_SCALE,
+ si_compare_settings.rtt_leeway_small / TCP_RTT_SCALE);
+ return kPrefer_Dest1;
+ }
+ else if (dst1->d_min_rtt + si_compare_settings.rtt_leeway_small < dst2->d_min_rtt)
+ {
+ slightPreference = kPrefer_Dest1_Slightly;
+ os_log_debug(si_destination_log,
+ "prefering 1 slightly, dst1 min rtt %f < dst2 min rtt %f, leeway %u small leeway %u",
+ RTT_MSEC_DOUBLE_FROM_DST(dst1), RTT_MSEC_DOUBLE_FROM_DST(dst2),
+ si_compare_settings.rtt_leeway / TCP_RTT_SCALE,
+ si_compare_settings.rtt_leeway_small / TCP_RTT_SCALE);
+ }
+ else
+ {
+ os_log_debug(si_destination_log,
+ "not prefering 1, dst1 min rtt %f < dst2 min rtt %f, leeway %u small leeway %u",
+ RTT_MSEC_DOUBLE_FROM_DST(dst1), RTT_MSEC_DOUBLE_FROM_DST(dst2),
+ si_compare_settings.rtt_leeway / TCP_RTT_SCALE,
+ si_compare_settings.rtt_leeway_small / TCP_RTT_SCALE);
+ }
+ }
+ else if (dst1->d_min_rtt > dst2->d_min_rtt)
+ {
+ if (dst1->d_min_rtt > si_compare_settings.rtt_leeway + dst2->d_min_rtt)
+ {
+ os_log_debug(si_destination_log,
+ "prefering 2, dst1 min rtt %f > dst2 min rtt %f, leeway %u small leeway %u",
+ RTT_MSEC_DOUBLE_FROM_DST(dst1), RTT_MSEC_DOUBLE_FROM_DST(dst2),
+ si_compare_settings.rtt_leeway / TCP_RTT_SCALE,
+ si_compare_settings.rtt_leeway_small / TCP_RTT_SCALE);
+ return kPrefer_Dest2;
+ }
+ else if (dst1->d_min_rtt > si_compare_settings.rtt_leeway_small + dst2->d_min_rtt)
+ {
+ slightPreference = kPrefer_Dest2_Slightly;
+ os_log_debug(si_destination_log,
+ "prefering 2 slightly, dst1 min rtt %f > dst2 min rtt %f, leeway %u small leeway %u",
+ RTT_MSEC_DOUBLE_FROM_DST(dst1), RTT_MSEC_DOUBLE_FROM_DST(dst2),
+ si_compare_settings.rtt_leeway / TCP_RTT_SCALE,
+ si_compare_settings.rtt_leeway_small / TCP_RTT_SCALE);
+ }
+ else
+ {
+ os_log_debug(si_destination_log,
+ "not prefering 2, dst1 min rtt %f > dst2 min rtt %f, leeway %u small leeway %u",
+ RTT_MSEC_DOUBLE_FROM_DST(dst1), RTT_MSEC_DOUBLE_FROM_DST(dst2),
+ si_compare_settings.rtt_leeway / TCP_RTT_SCALE,
+ si_compare_settings.rtt_leeway_small / TCP_RTT_SCALE);
+ }
+ }
+ else
+ {
+ os_log_debug(si_destination_log, "no preference, equal min rtt %f", RTT_MSEC_DOUBLE_FROM_DST(dst1));
+ }
+ // we hold on to slightPreference and only use it if no other part of the evaluation had a stronger preference
+#undef RTT_MSEC_DOUBLE_FROM_DST
+ }
+ else if (dst1->d_min_rtt || dst2->d_min_rtt)
+ {
+ // If only dest1 is missing round trip make sure it doesn't have zero successful attempts
+ if (dst1->d_min_rtt == 0 &&
+ dst1->d_connection_successes == 0 &&
+ dst1->d_connection_attempts > 0)
+ {
+ if (dst1->d_connection_attempts > si_compare_settings.rtt_failure_threshold)
+ {
+ os_log_debug(si_destination_log, "prefer 2, dst 1 has no successful connections and %u attempts",
+ dst1->d_connection_attempts);
+ return kPrefer_Dest2;
+ }
+ }
+ // If only dest2 is missing round trip make sure it doesn't have zero successful attempts
+ else if (dst2->d_min_rtt == 0 &&
+ dst2->d_connection_successes == 0 &&
+ dst2->d_connection_attempts > 0)
+ {
+ if (dst2->d_connection_attempts > si_compare_settings.rtt_failure_threshold)
+ {
+ os_log_debug(si_destination_log, "prefer 1, dst 2 has no successful connections and %u attempts",
+ dst2->d_connection_attempts);
+ return kPrefer_Dest1;
+ }
+ }
+ }
+
+ // If we have routes for both...
+ if (dst1->d_routable != 0 && dst2->d_routable != 0)
+ {
+ // <rdar://problem/9070784> Prefer interface that are not peer to peer
+ if (dst1->d_awdl != dst2->d_awdl)
+ {
+ if (dst2->d_awdl)
+ {
+ os_log_debug(si_destination_log, "prefer dst 1, dst 2 is p2p, dst 1 is not");
+ return kPrefer_Dest1;
+ }
+ else if (dst1->d_awdl)
+ {
+ os_log_debug(si_destination_log, "prefer dst 2, dst 1 is p2p, dst 2 is not");
+ return kPrefer_Dest2;
+ }
+ }
+
+ // Prefer loopback routes
+ bool dst1loopback = dst1->d_resolved_ifindex == kLoopbackIndex ||
+ (dst1->d_dst.addr.sa.sa_family == AF_INET6 &&
+ IN6_IS_ADDR_LINKLOCAL(&dst1->d_dst.addr.sin6.sin6_addr) &&
+ dst1->d_dst.addr.sin6.sin6_scope_id == kLoopbackIndex);
+ bool dst2loopback = dst2->d_resolved_ifindex == kLoopbackIndex ||
+ (dst2->d_dst.addr.sa.sa_family == AF_INET6 &&
+ IN6_IS_ADDR_LINKLOCAL(&dst2->d_dst.addr.sin6.sin6_addr) &&
+ dst2->d_dst.addr.sin6.sin6_scope_id == kLoopbackIndex);
+
+ if (dst1loopback && !dst2loopback)
+ {
+ os_log_debug(si_destination_log, "prefer 1, dst 1 is loopback, dst 2 is not");
+ return kPrefer_Dest1;
+ }
+ else if (dst2loopback && !dst1loopback)
+ {
+ os_log_debug(si_destination_log, "prefer 2, dst 2 is loopback, dst 1 is not");
+ return kPrefer_Dest2;
+ }
+
+ // Prefer direct routes
+ if (dst1->d_direct && !dst2->d_direct)
+ {
+ os_log_debug(si_destination_log, "prefer 1, dst 1 is local, dst 2 is not");
+ return kPrefer_Dest1;
+ }
+ else if (dst2->d_direct && !dst1->d_direct)
+ {
+ os_log_debug(si_destination_log, "prefer 2, dst 2 is local, dst 1 is not");
+ return kPrefer_Dest2;
+ }
+ }
+ else if (dst1->d_routable != 0)
+ {
+ // prefer destination we have a route to
+ os_log_debug(si_destination_log, "prefer 1, dst 2 has no route");
+ return kPrefer_Dest1;
+ }
+ else if (dst2->d_routable != 0)
+ {
+ // prefer destination we have a route to
+ os_log_debug(si_destination_log, "prefer 2, dst 1 has no route");
+ return kPrefer_Dest2;
+ }
+ return slightPreference;
+}
+
+#pragma mark -- Cache --
+
+static bool
+sa_equal(
+ const struct sockaddr *sa1,
+ const struct sockaddr *sa2)
+{
+ if (sa1->sa_family != sa2->sa_family)
+ return false;
+
+ /* We don't use bcmp because we don't care about the port number */
+ if (sa1->sa_family == AF_INET)
+ {
+ const struct sockaddr_in *sin1 = (const struct sockaddr_in *)sa1;
+ const struct sockaddr_in *sin2 = (const struct sockaddr_in *)sa2;
+
+ if (sin1->sin_addr.s_addr != sin2->sin_addr.s_addr)
+ return false;
+ return true;
+ }
+
+ if (sa1->sa_family == AF_INET6)
+ {
+ const struct sockaddr_in6 *sin61 = (const struct sockaddr_in6 *)sa1;
+ const struct sockaddr_in6 *sin62 = (const struct sockaddr_in6 *)sa2;
+
+ if (memcmp(&sin61->sin6_addr, &sin62->sin6_addr, sizeof(sin61->sin6_addr)) != 0) {
+ return false;
+ }
+
+ // TBD: Is the flow info relevant?
+
+ if (sin61->sin6_scope_id != sin62->sin6_scope_id) {
+ return false;
+ }
+
+ return true;
+ }
+
+ if (sa1->sa_len != sa2->sa_len) {
+ return false;
+ }
+
+ return (memcmp(sa1, sa2, sa1->sa_len) == 0);
+}
+
+static bool
+si_destination_cache_find(
+ const struct sockaddr *dst_sa,
+ uint32_t ifscope,
+ Destination *out_dst)
+{
+ // Loop through the entries looking for:
+ // - expired items
+ // - macthing item
+ DestCacheEntry **pprev = &cache;
+ uint64_t now = mach_absolute_time();
+ bool result = false;
+
+ while (*pprev != NULL)
+ {
+ // If the item has expired, pull it out of the list
+ if ((now - (*pprev)->dce_time) >= cache_timeout)
+ {
+ DestCacheEntry *expired = *pprev;
+ *pprev = expired->dce_next;
+ memset(expired, 0, sizeof(*expired));
+ free(expired);
+ }
+ else
+ {
+ // If the item matches, copy the entry
+ if (!result && (*pprev)->dce_entry.d_ifindex == ifscope &&
+ sa_equal(dst_sa, &(*pprev)->dce_entry.d_dst.addr.sa))
+ {
+ *out_dst = (*pprev)->dce_entry;
+ result = true;
+ }
+
+ pprev = &(*pprev)->dce_next;
+ }
+ }
+
+ return result;
+}
+
+static bool
+si_destination_cache_create(
+ const struct sockaddr *dst_sa,
+ uint32_t ifscope,
+ Destination *out_dst)
+{
+ DestCacheEntry *cache_entry;
+ Destination *d;
+
+ if (dst_sa->sa_len > sizeof(cache_entry->dce_entry.d_dst.addr)) {
+ os_log_error(si_destination_log, "(dst_sa->sa_len %u > sizeof(cache_entry->dce_entry.d_dst.addr))",
+ dst_sa->sa_len);
+ return false;
+ }
+
+ // Allocate entry
+ cache_entry = calloc(1, sizeof(*cache_entry));
+ if (NULL == cache_entry) {
+ os_log_error(si_destination_log, "calloc(%zu) failed: %m", sizeof(*cache_entry));
+ return false;
+ }
+ d = &cache_entry->dce_entry;
+
+ // Copy the destination sockaddr
+ memcpy(&d->d_dst.addr, dst_sa, dst_sa->sa_len);
+ d->d_ifindex = ifscope;
+
+ // Query the kernel for the matching source, precedence and label
+ si_destination_fill_netsrc(d);
+ *out_dst = *d;
+
+ cache_entry->dce_time = mach_absolute_time();
+ cache_entry->dce_next = cache;
+ cache = cache_entry;
+
+ return true;
+}
+
+static int
+si_destination_lookup(
+ const struct sockaddr *dst_sa,
+ uint32_t ifscope,
+ Destination *out_dst)
+{
+ int lookupResult = kLookupFailure;
+
+ si_destination_compare_init();
+ os_unfair_lock_lock(&cache_lock);
+ if (si_destination_cache_find(dst_sa, ifscope, out_dst)) {
+ lookupResult = kLookupSuccess_Found;
+ } else if (si_destination_cache_create(dst_sa, ifscope, out_dst)) {
+ lookupResult = kLookupSuccess_Created;
+ }
+ os_unfair_lock_unlock(&cache_lock);
+
+ return lookupResult;
+}
+
+#pragma mark -- RFC 6724 --
+
+// https://tools.ietf.org/html/rfc6724
+
+#ifndef IN6_IS_ADDR_TEREDO
+#define IN6_IS_ADDR_TEREDO(x) ((((x)->__u6_addr.__u6_addr16[0]) == htons(0x2001)) && \
+ (((x)->__u6_addr.__u6_addr16[1]) == 0x0000))
+#endif // IN6_IS_ADDR_TEREDO
+
+#ifndef s6_addr16
+#undef IN6_IS_ADDR_6TO4
+#define IN6_IS_ADDR_6TO4(x) (((x)->__u6_addr.__u6_addr16[0]) == htons(0x2002))
+#endif // s6_addr16
+
+#ifndef IN6_IS_ADDR_6BONE
+# define IN6_IS_ADDR_6BONE(x) (((x)->__u6_addr.__u6_addr16[0]) == htons(0x3ffe))
+#endif // IN6_IS_ADDR_6BONE
+
+static int
+rfc6724_scope_ip6(const struct in6_addr *addr)
+{
+ int scope;
+
+ if (addr->s6_addr[0] == 0xfe) {
+ scope = addr->s6_addr[1] & 0xc0;
+
+ switch (scope) {
+ case 0x80:
+ return __IPV6_ADDR_SCOPE_LINKLOCAL;
+ case 0xc0:
+ return __IPV6_ADDR_SCOPE_SITELOCAL;
+ default:
+ return __IPV6_ADDR_SCOPE_GLOBAL; /* just in case */
+ }
+ }
+
+
+ if (addr->s6_addr[0] == 0xff) {
+ scope = addr->s6_addr[1] & 0x0f;
+
+ /*
+ * due to other scope such as reserved,
+ * return scope doesn't work.
+ */
+ switch (scope) {
+ case __IPV6_ADDR_SCOPE_NODELOCAL:
+ return __IPV6_ADDR_SCOPE_NODELOCAL;
+ case __IPV6_ADDR_SCOPE_LINKLOCAL:
+ return __IPV6_ADDR_SCOPE_LINKLOCAL;
+ case __IPV6_ADDR_SCOPE_SITELOCAL:
+ return __IPV6_ADDR_SCOPE_SITELOCAL;
+ default:
+ return __IPV6_ADDR_SCOPE_GLOBAL;
+ }
+ }
+
+ /*
+ * Regard loopback and unspecified addresses as global, since
+ * they have no ambiguity.
+ */
+ static const struct in6_addr in6addr_lo = IN6ADDR_LOOPBACK_INIT;
+ if (memcmp(&in6addr_lo, addr, sizeof(*addr) - 1) == 0) {
+ if (addr->s6_addr[15] == 1) { /* loopback */
+ return __IPV6_ADDR_SCOPE_LINKLOCAL;
+ }
+ if (addr->s6_addr[15] == 0) { /* unspecified */
+ return __IPV6_ADDR_SCOPE_GLOBAL; /* XXX: correct? */
+ }
+ }
+
+ return __IPV6_ADDR_SCOPE_GLOBAL;
+}
+
+static int
+rfc6724_scope_ip(const struct in_addr *addr)
+{
+ uint32_t hostbyteaddr = ntohl(addr->s_addr);
+ if (IN_LOOPBACK(hostbyteaddr) || IN_LINKLOCAL(hostbyteaddr)) {
+ return __IPV6_ADDR_SCOPE_LINKLOCAL;
+ }
+ return __IPV6_ADDR_SCOPE_GLOBAL;
+}
+
+static int
+rfc6724_scope_sa(const struct sockaddr *sa)
+{
+ if (sa->sa_family == AF_INET6) {
+ const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sa;
+ return rfc6724_scope_ip6(&sin6->sin6_addr);
+ } else if (sa->sa_family == AF_INET) {
+ const struct sockaddr_in *sin = (const struct sockaddr_in *)sa;
+ return rfc6724_scope_ip(&sin->sin_addr);
+ }
+ return 0;
+}
+
+static int
+rfc6724_scope(RFC6724Address *addr)
+{
+ return rfc6724_scope_sa(&addr->addr.sa);
+}
+
+// RFC 6724 Section 2.1
+// https://tools.ietf.org/html/rfc6724#section-2.1
+
+// Prefix Precedence Label
+// ::1/128 50 0
+// ::/0 40 1
+// ::ffff:0:0/96 35 4
+// 2002::/16 30 2
+// 2001::/32 5 5
+// fc00::/7 3 13
+// ::/96 1 3
+// fec0::/10 1 11
+// 3ffe::/16 1 12
+
+static int
+rfc6724_precedence(const struct sockaddr *sa)
+{
+ if (sa == NULL) {
+
+ return 0;
+ }
+ SI_DESTINATION_COMPARE_CHECK_ARG_RETURN(sa, 0);
+ if (sa->sa_family == AF_INET6) {
+ const struct sockaddr_in6 *sin6 = (const struct sockaddr_in6 *)sa;
+
+ // ::1/128
+ if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) {
+ return 50;
+ }
+
+ // ::ffff:0:0/96
+ if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) {
+ return 35;
+ }
+
+ // 2002::/16
+ if (IN6_IS_ADDR_6TO4(&sin6->sin6_addr)) {
+ return 30;
+ }
+
+ // 2001::/32
+ if (IN6_IS_ADDR_TEREDO(&sin6->sin6_addr)) {
+ return 5;
+ }
+
+ // fc00::/7
+ if (IN6_IS_ADDR_UNIQUE_LOCAL(&sin6->sin6_addr)) {
+ return 3;
+ }
+
+ // ::/96
+ if (IN6_IS_ADDR_V4COMPAT(&sin6->sin6_addr)) {
+ return 1;
+ }
+
+ // fec0::/10
+ if (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr)) {
+ return 1;
+ }
+
+ // 3ffe::/16
+ if (IN6_IS_ADDR_6BONE(&sin6->sin6_addr)) {
+ return 1;
+ }
+
+ // ::/0
+ return 40;
+ } else if (sa->sa_family == AF_INET) {
+
+ // ::ffff:0:0/96 (IPv4 is treated as a v4-mapped v6 address)
+ return 35;
+ }
+ return 0;
+}
+
+static bool
+rfc6724_native(const RFC6724Address *addr)
+{
+ return !(addr->addr.sa.sa_family == AF_INET6 &&
+ (IN6_IS_ADDR_6TO4(&addr->addr.sin6.sin6_addr) ||
+ IN6_IS_ADDR_TEREDO(&addr->addr.sin6.sin6_addr)));
+}
+
+static int
+common_prefix_length(const union sockaddr_in_4_6 *addr1, const union sockaddr_in_4_6 *addr2)
+{
+ int match = 0;
+ if (addr1->sa.sa_family == AF_INET6 && addr2->sa.sa_family == AF_INET6)
+ {
+ const unsigned char *s = (const unsigned char *)&addr1->sin6.sin6_addr;
+ const unsigned char *d = (const unsigned char *)&addr2->sin6.sin6_addr;
+ const unsigned char *lim = s + 8;
+ unsigned char r;
+
+ while (s < lim) {
+ if ((r = (*d++ ^ *s++)) != 0) {
+ while (r < 128) {
+ match++;
+ r <<= 1;
+ }
+ break;
+ } else {
+ match += 8;
+ }
+ }
+ }
+ return match;
+}
+
+static int
+si_destination_compare_rfc6724(Destination *d1, Destination *d2, int statResult)
+{
+ // Rule 1: Avoid unusable destinations (no source means unusable dest)
+ if (d1->d_src.addr.sa.sa_family == AF_UNSPEC || d2->d_src.addr.sa.sa_family == AF_UNSPEC)
+ {
+ if (d1->d_src.addr.sa.sa_family != AF_UNSPEC)
+ {
+ os_log_debug(si_destination_log, "Rule 1, prefer d1, d2 is not routable");
+ return kPrefer_Dest1;
+ }
+ else if (d2->d_src.addr.sa.sa_family != AF_UNSPEC)
+ {
+ os_log_debug(si_destination_log, "Rule 1, prefer d2, d1 is not routable");
+ return kPrefer_Dest2;
+ }
+ }
+
+ // Rule 2: Prefer matching scope
+ if (rfc6724_scope(&d1->d_dst) != rfc6724_scope(&d1->d_src) || rfc6724_scope(&d2->d_dst) != rfc6724_scope(&d2->d_src))
+ {
+ if (rfc6724_scope(&d1->d_dst) == rfc6724_scope(&d1->d_src))
+ {
+ os_log_debug(si_destination_log, "Rule 2, prefer d1, d2 dst scope does not match src scope");
+ return kPrefer_Dest1;
+ }
+ if (rfc6724_scope(&d2->d_dst) == rfc6724_scope(&d2->d_src))
+ {
+ os_log_debug(si_destination_log, "Rule 2, prefer d2, d1 dst scope does not match src scope");
+ return kPrefer_Dest2;
+ }
+ }
+
+ // Rule 3: Avoid deprecated addresses
+ if ((d1->d_src.flags & NETSRC_IP6_FLAG_DEPRECATED) != (d2->d_src.flags & NETSRC_IP6_FLAG_DEPRECATED))
+ {
+ if ((d1->d_src.flags & NETSRC_IP6_FLAG_DEPRECATED) != 0)
+ {
+ os_log_debug(si_destination_log, "Rule 3, prefer d2, d1 source is deprecated");
+ return kPrefer_Dest1;
+ }
+ if ((d2->d_src.flags & NETSRC_IP6_FLAG_DEPRECATED) != 0)
+ {
+ os_log_debug(si_destination_log, "Rule 3, prefer d1, d2 source is deprecated");
+ return kPrefer_Dest2;
+ }
+ }
+
+ // Rule 3bis: Avoid optimistic addresses, c.f. RFC 4429 which defines them as conceptually similar to deprecated
+ // Note that this rule is not part of RFC 6724
+ if ((d1->d_src.flags & NETSRC_IP6_FLAG_OPTIMISTIC) != (d2->d_src.flags & NETSRC_IP6_FLAG_OPTIMISTIC))
+ {
+ if ((d1->d_src.flags & NETSRC_IP6_FLAG_OPTIMISTIC) != 0)
+ {
+ os_log_debug(si_destination_log, "Rule 3a, prefer d2, d1 source is optimistic");
+ return kPrefer_Dest1;
+ }
+ if ((d2->d_src.flags & NETSRC_IP6_FLAG_OPTIMISTIC) != 0)
+ {
+ os_log_debug(si_destination_log, "Rule 3a, prefer d1, d2 source is optimistic");
+ return kPrefer_Dest2;
+ }
+ }
+
+ // Rule 4: Prefer home addresses
+ // TODO: requires Mobile IPv6 support
+
+ // Rule 5: Prefer matching label
+ if (d1->d_dst.label != d1->d_src.label || d2->d_dst.label != d2->d_src.label)
+ {
+ if (d1->d_dst.label == d1->d_src.label)
+ {
+ os_log_debug(si_destination_log, "Rule 5, prefer d1, d2 dst label does not match src label");
+ return kPrefer_Dest1;
+ }
+ if (d2->d_dst.label == d2->d_src.label)
+ {
+ os_log_debug(si_destination_log, "Rule 5, prefer d2, d1 dst label does not match src label");
+ return kPrefer_Dest2;
+ }
+ }
+
+ // Rule 6: Prefer higher precedence
+ if (d1->d_dst.precedence > d2->d_dst.precedence)
+ {
+ os_log_debug(si_destination_log, "Rule 6, prefer d1, d1 precedence %d > d2 precedence %d",
+ d1->d_dst.precedence, d2->d_dst.precedence);
+ return kPrefer_Dest1;
+ }
+ else if (d2->d_dst.precedence > d1->d_dst.precedence)
+ {
+ os_log_debug(si_destination_log, "Rule 6, prefer d2, d2 precedence %d > d1 precedence %d",
+ d2->d_dst.precedence, d1->d_dst.precedence);
+ return kPrefer_Dest2;
+ }
+
+ // Rule 7: Prefer native transport
+ const bool d1_native = rfc6724_native(&d1->d_src);
+ const bool d2_native = rfc6724_native(&d2->d_src);
+ if (d1_native && !d2_native)
+ {
+ os_log_debug(si_destination_log, "Rule 7, prefer d1, d2 src is not native");
+ return kPrefer_Dest1;
+ }
+ else if (d2_native && !d1_native)
+ {
+ os_log_debug(si_destination_log, "Rule 7, prefer d2, d1 src is not native");
+ return kPrefer_Dest2;
+ }
+
+ // Rule 8: Prefer smaller scope
+ const int scope1 = rfc6724_scope(&d1->d_dst);
+ const int scope2 = rfc6724_scope(&d2->d_dst);
+ if (scope1 < scope2)
+ {
+ os_log_debug(si_destination_log, "Rule 8, prefer d1, d1 scope %d < d2 scope %d", scope1, scope2);
+ return kPrefer_Dest1;
+ }
+ else if (scope2 < scope1)
+ {
+ os_log_debug(si_destination_log, "Rule 8, prefer d2, d2 scope %d < d1 scope %d", scope2, scope1);
+ return kPrefer_Dest2;
+ }
+
+ // RFC6724: Rules 9 and 10 MAY be superseded if the implementation has other means of sorting destination addresses.
+ if ((kPrefer_Dest1 == statResult) || (kPrefer_Dest1_Slightly == statResult)) {
+ return kPrefer_Dest1;
+ } else if ((kPrefer_Dest2 == statResult) || (kPrefer_Dest2_Slightly == statResult)) {
+ return kPrefer_Dest2;
+ }
+
+ // Rule 9: Use longest matching prefix
+ int matchlen1 = common_prefix_length(&d1->d_dst.addr, &d1->d_src.addr);
+ int matchlen2 = common_prefix_length(&d2->d_dst.addr, &d2->d_src.addr);
+ if (matchlen1 && matchlen2)
+ {
+ if (matchlen1 > matchlen2)
+ {
+ os_log_debug(si_destination_log, "Rule 9, prefer d1, d1 shares more common prefix");
+ return kPrefer_Dest1;
+ }
+ else if (matchlen2 > matchlen1)
+ {
+ os_log_debug(si_destination_log, "Rule 9, prefer d2, d2 shares more common prefix");
+ return kPrefer_Dest2;
+ }
+ }
+
+ // Rule 10: Otherwise, leave the order unchanged
+ return kPrefer_Equal;
+}
+
+#pragma mark -- Internal Helper --
+
+static int
+si_destination_compare_internal(
+ const struct sockaddr *dst1,
+ uint32_t dst1ifindex,
+ const struct sockaddr *dst2,
+ uint32_t dst2ifindex,
+ bool statistics)
+{
+ // If either of the destinations is not AF_INET/AF_INET6
+ if ((dst1->sa_family != AF_INET && dst1->sa_family != AF_INET6) ||
+ (dst2->sa_family != AF_INET && dst2->sa_family != AF_INET6))
+ {
+ if (dst1->sa_family == AF_INET || dst1->sa_family == AF_INET6) {
+ return kPrefer_Dest1;
+ } else if (dst2->sa_family == AF_INET || dst2->sa_family == AF_INET6) {
+ return kPrefer_Dest2;
+ } else {
+ return kPrefer_Equal;
+ }
+ }
+
+ Destination d1;
+ Destination d2;
+
+ // Lookup d1 and d2 in the cache
+ int lookupResultD1 = si_destination_lookup(dst1, dst1ifindex, &d1);
+ int lookupResultD2 = si_destination_lookup(dst2, dst2ifindex, &d2);
+ if (lookupResultD1 == kLookupFailure)
+ {
+ os_log_debug(si_destination_log, "si_destination_lookup for dst1 failed");
+ return kPrefer_Equal;
+ }
+ if (lookupResultD2 == kLookupFailure)
+ {
+ os_log_debug(si_destination_log, "si_destination_lookup for dst2 failed");
+ return kPrefer_Equal;
+ }
+
+ int statResult = kPrefer_Equal;
+ if (statistics && !si_compare_settings.bypass_stats)
+ {
+ statResult = si_destination_compare_statistics(&d1, &d2);
+ if ((kPrefer_Dest1 == statResult) || (kPrefer_Dest2 == statResult))
+ {
+ return statResult;
+ }
+ }
+
+ statResult = si_destination_compare_rfc6724(&d1, &d2, statResult);
+
+ if (statResult == kPrefer_Equal) {
+ // Only if all other comparisons are equal, prefer entries that were already in the cache over
+ // ones that are new and we just created.
+
+ // Found < Created
+ if (lookupResultD1 == kLookupSuccess_Found && lookupResultD2 == kLookupSuccess_Created) {
+ os_log_debug(si_destination_log, "prefer d1, known while d2 not known");
+ statResult = kPrefer_Dest1;
+ } else if (lookupResultD2 == kLookupSuccess_Found && lookupResultD1 == kLookupSuccess_Created) {
+ os_log_debug(si_destination_log, "prefer d2, known while d1 not known");
+ statResult = kPrefer_Dest2;
+ }
+ }
+
+ return statResult;
+}
+
+#pragma mark -- SPI --
+
+int
+si_destination_compare(
+ const struct sockaddr *dst1,
+ int dst1ifindex,
+ const struct sockaddr *dst2,
+ int dst2ifindex,
+ bool statistics)
+{
+ SI_DESTINATION_COMPARE_CHECK_ARG_RETURN(dst1, kPrefer_Equal);
+ SI_DESTINATION_COMPARE_CHECK_ARG_RETURN(dst2, kPrefer_Equal);
+
+ si_destination_compare_init();
+
+ const int result = si_destination_compare_internal(dst1, dst1ifindex, dst2, dst2ifindex, statistics);
+
+ os_log_debug(si_destination_log, "%{network:sockaddr}.*P@%u %c %{network:sockaddr}.*P@%u",
+ dst1->sa_len, dst1, dst1ifindex, result == 0 ? '=' : result < 0 ? '<' : '>',
+ dst2->sa_len, dst2, dst2ifindex);
+
+ return result;
+}
+
+int
+si_destination_compare_no_dependencies(const struct sockaddr *dst1,
+ const struct sockaddr *dst2)
+{
+ SI_DESTINATION_COMPARE_CHECK_ARG_RETURN(dst1, kPrefer_Equal);
+ SI_DESTINATION_COMPARE_CHECK_ARG_RETURN(dst2, kPrefer_Equal);
+
+ // Skip rule 1 (requires route to destination address)
+ // Skip rule 2, 3, 5, 7, 9 (requires corresponding source address)
+ // Skip rule 4 (not supported by si_destination_compare() today)
+
+ // Rule 6: Prefer higher precedence
+ const int precedence1 = rfc6724_precedence(dst1);
+ const int precedence2 = rfc6724_precedence(dst2);
+ if (precedence1 > precedence2)
+ {
+ os_log_debug(si_destination_log, "ND Rule 6, prefer d1, d1 precedence %d > d2 precedence %d",
+ precedence1, precedence2);
+ return kPrefer_Dest1;
+ }
+ else if (precedence2 > precedence1)
+ {
+ os_log_debug(si_destination_log, "ND Rule 6, prefer d2, d2 precedence %d > d1 precedence %d",
+ precedence2, precedence1);
+ return kPrefer_Dest2;
+ }
+
+ // Rule 8: Prefer smaller scope
+ const int scope1 = rfc6724_scope_sa(dst1);
+ const int scope2 = rfc6724_scope_sa(dst2);
+ if (scope1 < scope2)
+ {
+ os_log_debug(si_destination_log, "ND Rule 8, prefer d1, d1 scope %d < d2 scope %d",
+ scope1, scope2);
+ return kPrefer_Dest1;
+ }
+ else if (scope2 < scope1)
+ {
+ os_log_debug(si_destination_log, "ND Rule 8, prefer d2, d2 scope %d < d1 scope %d",
+ scope2, scope1);
+ return kPrefer_Dest2;
+ }
+
+ // Rule 10: Otherwise, leave the order unchanged
+
+ return kPrefer_Equal;
+}
--- /dev/null
+//
+// si_compare.h
+// Libinfo
+//
+// Copyright (c) 2011-2017 Apple Inc. All rights reserved.
+//
+
+#ifndef __SI_COMPARE_H__
+#define __SI_COMPARE_H__
+
+#include <sys/cdefs.h>
+#include <sys/socket.h>
+#include <stdbool.h>
+#include <os/availability.h>
+
+
+__BEGIN_DECLS
+
+/*!
+ * @function si_destination_compare
+ *
+ * Equivalent to the si_destination_compare function, but doesn't take any routing table information
+ * into account. This follows rules 6, 8 and 10 of RFC 6724 destination address selection.
+ *
+ * @param destination1
+ * The first potential destination address.
+ *
+ * @param destination2
+ * The second potential destination address.
+ *
+ * @result
+ * Returns -1 if destination1 is less desirable than destination 2. Returns 0 if destination1
+ * is equally as desirable as destination 2. Returns 1 if destination 1 is more desirable than
+ * destination 2.
+ */
+API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
+int si_destination_compare(const struct sockaddr *dst1, int dst1ifindex,
+ const struct sockaddr *dst2, int dst2ifindex,
+ bool statistics);
+
+/*!
+ * @function si_destination_compare_no_dependencies
+ *
+ * Equivalent to the si_destination_compare function, but doesn't take any routing table information
+ * into account. This follows rules 6, 8 and 10 of RFC 6724 destination address selection.
+ *
+ * @param destination1
+ * The first potential destination address.
+ *
+ * @param destination2
+ * The second potential destination address.
+ *
+ * @result
+ * Returns -1 if destination1 is less desirable than destination 2. Returns 0 if destination1
+ * is equally as desirable as destination 2. Returns 1 if destination 1 is more desirable than
+ * destination 2.
+ */
+API_AVAILABLE(macos(10.14), ios(12.0), watchos(5.0), tvos(12.0))
+int
+si_destination_compare_no_dependencies(const struct sockaddr *destination1,
+ const struct sockaddr *destination2);
+
+__END_DECLS
+
+#endif // __SI_COMPARE_H__
/*
- * Copyright (c) 2008-2015 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include "si_data.h"
#include "si_module.h"
+LIBINFO_EXPORT
si_list_t *
si_list_add(si_list_t *l, si_item_t *e)
{
return l;
}
+LIBINFO_EXPORT
si_list_t *
si_list_concat(si_list_t *l, si_list_t *x)
{
return l;
}
+LIBINFO_EXPORT
si_item_t *
si_list_next(si_list_t *list)
{
return list->entry[list->curr++];
}
+LIBINFO_EXPORT
void
si_list_reset(si_list_t *list)
{
if (list != NULL) list->curr = 0;
}
+LIBINFO_EXPORT
si_list_t *
si_list_retain(si_list_t *list)
{
return list;
}
+LIBINFO_EXPORT
void
si_list_release(si_list_t *list)
{
}
}
+LIBINFO_EXPORT
si_item_t *
si_item_retain(si_item_t *item)
{
return item;
}
+LIBINFO_EXPORT
void
si_item_release(si_item_t *item)
{
/*
- * Copyright (c) 2008-2015 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
+#include <dlfcn.h>
#include <netdb.h>
#include <sys/types.h>
#include <ctype.h>
#include <sys/socket.h>
#include <net/if.h>
#include <netinet/in.h>
-#include <network/sa_compare.h>
-#include <network/nat64.h>
-#include <network/path_evaluation.h>
+#include <os/log.h>
#include <arpa/inet.h>
#include <ifaddrs.h>
#include <net/if.h>
#include <pthread.h>
#include <TargetConditionals.h>
#include "netdb_async.h"
+#include "si_compare.h"
#include "si_module.h"
#define SOCK_UNSPEC 0
static uint32_t net_v4_count = 0;
static uint32_t net_v6_count = 0; // includes 6to4 addresses
static pthread_mutex_t net_config_mutex = PTHREAD_MUTEX_INITIALIZER;
+static os_log_t _gai_log = OS_LOG_DEFAULT;
// Libc SPI
int _inet_aton_check(const char *cp, struct in_addr *addr, int strict);
uint64_t ttl;
} build_hostent_t;
+static void
+gai_log_init(void)
+{
+ _gai_log = os_log_create("com.apple.network.libinfo", "getaddrinfo");
+}
+
+static os_log_t
+gai_log(void)
+{
+ static pthread_once_t once = PTHREAD_ONCE_INIT;
+ pthread_once(&once, gai_log_init);
+ return _gai_log;
+}
+
__private_extern__ int
si_inet_config(uint32_t *inet4, uint32_t *inet6)
{
return status;
}
+LIBINFO_EXPORT
void
freeaddrinfo(struct addrinfo *a)
{
}
}
+LIBINFO_EXPORT
const char *
gai_strerror(int32_t err)
{
* string. If the caller specifies both NI_NUMERICHOST and NI_NUMERICSERV,
* we inet_ntop() and printf() and return the results.
*/
+LIBINFO_EXPORT
si_item_t *
si_nameinfo(si_mod_t *si, const struct sockaddr *sa, int flags, const char *interface, uint32_t *err)
{
return numeric;
}
+LIBINFO_EXPORT
int
_gai_serv_to_port(const char *serv, uint32_t proto, uint16_t *port)
{
return 0;
}
+LIBINFO_EXPORT
si_item_t *
si_addrinfo_v4(si_mod_t *si, int32_t flags, int32_t sock, int32_t proto, uint16_t port, struct in_addr *addr, uint16_t iface, const char *cname)
{
return (si_item_t *)LI_ils_create("L448844444Ss", (unsigned long)si, CATEGORY_ADDRINFO, 1, unused, unused, flags, AF_INET, sock, proto, len, sockdata, cname);
}
+LIBINFO_EXPORT
si_item_t *
si_addrinfo_v4_mapped(si_mod_t *si, int32_t flags, int32_t sock, int32_t proto, uint16_t port, struct in_addr *addr, uint16_t iface, const char *cname)
{
}
+LIBINFO_EXPORT
si_item_t *
si_addrinfo_v6(si_mod_t *si, int32_t flags, int32_t sock, int32_t proto, uint16_t port, struct in6_addr *addr, uint16_t iface, const char *cname)
{
return (si_item_t *)LI_ils_create("L448844444Ss", (unsigned long)si, CATEGORY_ADDRINFO, 1, unused, unused, flags, AF_INET6, sock, proto, len, sockdata, cname);
}
+LIBINFO_EXPORT
si_list_t *
si_addrinfo_list(si_mod_t *si, uint32_t flags, int socktype, int proto, struct in_addr *a4, struct in6_addr *a6, int port, int scopeid, const char *cname4, const char *cname6)
{
/* si_addrinfo_list_from_hostent
* Returns an addrinfo list from IPv4 and IPv6 hostent entries
*/
+LIBINFO_EXPORT
si_list_t *
si_addrinfo_list_from_hostent(si_mod_t *si, uint32_t flags, uint32_t socktype, uint32_t proto, uint16_t port, uint16_t scope, const struct hostent *h4, const struct hostent *h6)
{
sq = (struct sockaddr *)q->ai_addr.x;
/*
- * sa_dst_compare(A,B) returns -1 if A is less desirable than B,
+ * si_destination_compare(A,B) returns -1 if A is less desirable than B,
* 0 if they are equally desirable, and 1 if A is more desirable.
* qsort() expects the inverse, so we swap sp and sq.
*/
- return sa_dst_compare(sq, sp, 0);
+ return si_destination_compare(sq, 0, sp, 0, true);
}
static si_list_t *
/* _gai_simple
* Simple lookup via gethostbyname2(3) mechanism.
*/
+LIBINFO_EXPORT
si_list_t *
_gai_simple(si_mod_t *si, const void *nodeptr, const void *servptr, uint32_t family, uint32_t socktype, uint32_t proto, uint32_t flags, const char *interface, uint32_t *err)
{
return _gai_sort_list(out, flags);
}
+LIBINFO_EXPORT
si_list_t *
si_srv_byname(si_mod_t *si, const char *qname, const char *interface, uint32_t *err)
{
return si->vtable->sim_srv_byname(si, qname, interface, err);
}
+LIBINFO_EXPORT
int
si_wants_addrinfo(si_mod_t *si)
{
return result;
}
+#pragma mark -- NAT64 --
+
+static bool (*nat64_v4_requires_synthesis)(const struct in_addr *ipv4_addr) = NULL;
+static int (*nat64_v4_synthesize)(uint32_t *index, const struct in_addr *ipv4, struct in6_addr **out_ipv6_addrs) = NULL;
+
+#if !TARGET_OS_SIMULATOR
+static void _gai_load_libnetwork_once(void)
+{
+ // If the function pointers are already loaded, we don't need to call dlopen
+ if (nat64_v4_requires_synthesis != NULL && nat64_v4_synthesize != NULL) {
+ return;
+ }
+
+ // Using dlopen will trigger libnetwork's init functions which should call
+ // si_set_nat64_v4_synthesize and si_set_nat64_v4_requires_synthesis
+ static void *handle;
+ os_log_debug(gai_log(), "Opening libnetwork.dylib");
+ handle = dlopen("/usr/lib/libnetwork.dylib", RTLD_LAZY | RTLD_LOCAL);
+ if (handle == NULL) {
+ const char *error_description = dlerror();
+ os_log_error(gai_log(), "dlopen(\"...libnetwork.dylib\") failed: %{public}s",
+ error_description ? error_description : "?");
+ } else {
+ if (nat64_v4_requires_synthesis == NULL) {
+ os_log_error(gai_log(), "libnetwork.dylib did not set nat64_v4_requires_synthesis");
+ }
+ if (nat64_v4_synthesize == NULL) {
+ os_log_error(gai_log(), "libnetwork.dylib did not set nat64_v4_synthesize");
+ }
+ }
+}
+
+static void _gai_load_libnetwork(void)
+{
+ static pthread_once_t load_once = PTHREAD_ONCE_INIT;
+ pthread_once(&load_once, _gai_load_libnetwork_once);
+}
+#else
+static void _gai_load_libnetwork(void)
+{
+}
+#endif
+
+static bool _gai_nat64_v4_address_requires_synthesis(const struct in_addr *ipv4_addr)
+{
+ _gai_load_libnetwork();
+ if (nat64_v4_requires_synthesis == NULL) {
+ return false;
+ }
+ bool result = nat64_v4_requires_synthesis(ipv4_addr);
+ os_log_debug(gai_log(), "nat64_v4_requires_synthesis(%{network:in_addr}d) == %{bool}d", ipv4_addr->s_addr, result);
+ return result;
+}
+
+static int _gai_nat64_v4_synthesize(uint32_t *index, const struct in_addr *ipv4, struct in6_addr **out_ipv6_addrs)
+{
+ _gai_load_libnetwork();
+ if (nat64_v4_synthesize == NULL) {
+ return 0;
+ }
+ int result = nat64_v4_synthesize(index, ipv4, out_ipv6_addrs);
+ os_log_debug(gai_log(), "nat64_v4_synthesize(%d, %{network:in_addr}d, ...) returned %d", index != NULL ? *index : 0,
+ ipv4->s_addr, result);
+ return nat64_v4_synthesize(index, ipv4, out_ipv6_addrs);
+}
+
+LIBINFO_EXPORT
+void si_set_nat64_v4_requires_synthesis(bool (*new_requires_synthesis)(const struct in_addr *ipv4_addr))
+{
+ if (new_requires_synthesis == NULL) {
+ os_log_fault(gai_log(), "new_requires_synthesis is NULL");
+ return;
+ }
+ nat64_v4_requires_synthesis = new_requires_synthesis;
+}
+
+LIBINFO_EXPORT
+void si_set_nat64_v4_synthesize(int (*new_synthesize)(uint32_t *index, const struct in_addr *ipv4,
+ struct in6_addr **out_ipv6_addrs))
+{
+ if (new_synthesize == NULL) {
+ os_log_fault(gai_log(), "new_synthesize is NULL");
+ return;
+ }
+ nat64_v4_synthesize = new_synthesize;
+}
+
+LIBINFO_EXPORT
+bool _gai_nat64_can_v4_address_be_synthesized(const struct in_addr *ipv4_addr)
+{
+ if (ipv4_addr == NULL) {
+ os_log_fault(gai_log(), "ipv4_addr is NULL");
+ return false;
+ }
+
+ const in_addr_t addr_hbo = ntohl(ipv4_addr->s_addr); // host byte order
+
+ if (IN_ZERONET(addr_hbo) || // 0.0.0.0/8 Source hosts on local network
+ IN_LOOPBACK(addr_hbo) || // 127.0.0.0/8 Loopback
+ IN_LINKLOCAL(addr_hbo) || // 169.254.0.0/16 Link Local
+ IN_DS_LITE(addr_hbo) || // 192.0.0.0/29 DS-Lite
+ IN_6TO4_RELAY_ANYCAST(addr_hbo) || // 192.88.99.0/24 6to4 Relay Anycast
+ IN_MULTICAST(addr_hbo) || // 224.0.0.0/4 Multicast
+ INADDR_BROADCAST == addr_hbo) { // 255.255.255.255/32 Limited Broadcast
+ return false;
+ }
+
+ return true;
+}
+
static si_list_t *
_gai_nat64_synthesis(si_mod_t *si, const char *node, const void *servptr, int numericserv,
uint32_t family, uint32_t socktype, uint32_t proto, uint32_t flags, const char *interface)
}
/* validate that IPv4 address is eligible for NAT64 synthesis */
-#if defined(NW_NAT64_API_VERSION) && NW_NAT64_API_VERSION >= 2
- if (!nw_nat64_can_v4_address_be_synthesized(&a4)) {
+ if (!_gai_nat64_can_v4_address_be_synthesized(&a4)) {
return NULL;
}
-#endif // NW_NAT64_API_VERSION
/* validate that there is at least an IPv6 address configured */
uint32_t num_inet6 = 0;
}
/* query NAT64 prefixes */
- nw_nat64_prefix_t *prefixes = NULL;
- const int32_t num_prefixes = nw_nat64_copy_prefixes(&ifindex, &prefixes);
- if ((num_prefixes <= 0) || (NULL == prefixes))
- {
- return NULL;
+ struct in6_addr *synthesized = NULL;
+ const size_t count = _gai_nat64_v4_synthesize(&ifindex, &a4, &synthesized);
+ if (count <= 0 || (NULL == synthesized)) {
+ return false;
}
/* add every address to results */
si_list_t *out_list = NULL;
- for (int32_t i = 0; i < num_prefixes; i++)
+ for (size_t i = 0; i < count; i++)
{
- struct in6_addr a6;
- if (!nw_nat64_synthesize_v6(&prefixes[i], &a4, &a6))
- {
- continue;
- }
- si_list_t *temp_list = si_addrinfo_list(si, flags, socktype, proto, NULL, &a6, port, 0, NULL, NULL);
+ si_list_t *temp_list = si_addrinfo_list(si, flags, socktype, proto, NULL, &synthesized[i], port, 0, NULL, NULL);
if (NULL == temp_list)
{
continue;
}
}
- free(prefixes);
+ free(synthesized);
/* return to standard code path if no NAT64 addresses could be synthesized */
if (NULL == out_list)
continue;
}
- /* validate that IPv4 address is eligible for NAT64 synthesis */
-#if defined(NW_NAT64_API_VERSION) && NW_NAT64_API_VERSION >= 2
- if (!nw_nat64_can_v4_address_be_synthesized(addr4))
+ if (!_gai_nat64_v4_address_requires_synthesis(addr4))
{
continue;
}
-#endif // NW_NAT64_API_VERSION
char v4_str[INET_ADDRSTRLEN] = {0};
if (NULL == inet_ntop(AF_INET, addr4, v4_str, sizeof(v4_str)))
continue;
}
- /* skip if we have a path (route) to this address as it might go through a VPN */
- nw_endpoint_t endpoint = nw_endpoint_create_address((struct sockaddr *)a->ai_addr.x);
- if (endpoint == NULL)
- {
- continue;
- }
- nw_path_evaluator_t evaluator = nw_path_create_evaluator_for_endpoint(endpoint, NULL);
- network_release(endpoint);
- if (evaluator == NULL)
- {
- continue;
- }
- nw_path_t path = nw_path_evaluator_copy_path(evaluator);
- network_release(evaluator);
- if (path == NULL)
- {
- continue;
- }
- const nw_path_status_t status = nw_path_get_status(path);
- network_release(path);
- if (status != nw_path_status_unsatisfied)
- {
- continue;
- }
-
uint32_t err = SI_STATUS_NO_ERROR;
si_list_t *temp_list = si_addrinfo(si, v4_str, serv, AF_INET6, socktype, proto, flags2, interface, &err);
if (NULL == temp_list)
return out_list;
}
+#pragma mark -- /NAT64 --
+
+LIBINFO_EXPORT
si_list_t *
si_addrinfo(si_mod_t *si, const char *node, const char *serv, uint32_t family, uint32_t socktype, uint32_t proto, uint32_t flags, const char *interface, uint32_t *err)
{
free(h);
}
+LIBINFO_EXPORT
si_item_t *
si_ipnode_byname(si_mod_t *si, const char *name, int family, int flags, const char *interface, uint32_t *err)
{
/*
- * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <sys/types.h>
#include <sys/socket.h>
#include <net/ethernet.h>
return out;
}
+LIBINFO_EXPORT
si_mod_t *
si_module_with_name(const char *name)
{
return si;
}
+LIBINFO_EXPORT
si_mod_t *
si_module_retain(si_mod_t *si)
{
return si;
}
+LIBINFO_EXPORT
void
si_module_release(si_mod_t *si)
{
free(si);
}
+LIBINFO_EXPORT
const char *
si_module_name(si_mod_t *si)
{
return (const char *)si->name;
}
+LIBINFO_EXPORT
int
si_module_vers(si_mod_t *si)
{
return si->vers;
}
+LIBINFO_EXPORT
int
si_item_match(si_item_t *item, int cat, const void *name, uint32_t num, int which)
{
return 0;
}
+LIBINFO_EXPORT
int
si_item_is_valid(si_item_t *item)
{
return si->vtable->sim_is_valid(si, item);
}
+LIBINFO_EXPORT
si_item_t *
si_user_byname(si_mod_t *si, const char *name)
{
return si->vtable->sim_user_byname(si, name);
}
+LIBINFO_EXPORT
si_item_t *
si_user_byuid(si_mod_t *si, uid_t uid)
{
return si->vtable->sim_user_byuid(si, uid);
}
+LIBINFO_EXPORT
si_item_t *
si_user_byuuid(si_mod_t *si, uuid_t uuid)
{
return si->vtable->sim_user_byuuid(si, uuid);
}
+LIBINFO_EXPORT
si_list_t *
si_user_all(si_mod_t *si)
{
return si->vtable->sim_user_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_group_byname(si_mod_t *si, const char *name)
{
return si->vtable->sim_group_byname(si, name);
}
+LIBINFO_EXPORT
si_item_t *
si_group_bygid(si_mod_t *si, gid_t gid)
{
return si->vtable->sim_group_bygid(si, gid);
}
+LIBINFO_EXPORT
si_item_t *
si_group_byuuid(si_mod_t *si, uuid_t uuid)
{
return si->vtable->sim_group_byuuid(si, uuid);
}
+LIBINFO_EXPORT
si_list_t *
si_group_all(si_mod_t *si)
{
return si->vtable->sim_group_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_grouplist(si_mod_t *si, const char *name, uint32_t count)
{
return si->vtable->sim_grouplist(si, name, count);
}
+LIBINFO_EXPORT
si_list_t *
si_netgroup_byname(struct si_mod_s *si, const char *name)
{
return si->vtable->sim_netgroup_byname(si, name);
}
+LIBINFO_EXPORT
int
si_in_netgroup(struct si_mod_s *si, const char *name, const char *host, const char *user, const char *domain)
{
return si->vtable->sim_in_netgroup(si, name, host, user, domain);
}
+LIBINFO_EXPORT
si_item_t *
si_alias_byname(si_mod_t *si, const char *name)
{
return si->vtable->sim_alias_byname(si, name);
}
+LIBINFO_EXPORT
si_list_t *
si_alias_all(si_mod_t *si)
{
return si->vtable->sim_alias_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_host_byname(si_mod_t *si, const char *name, int af, const char *interface, uint32_t *err)
{
return si->vtable->sim_host_byname(si, name, af, interface, err);
}
+LIBINFO_EXPORT
si_item_t *
si_host_byaddr(si_mod_t *si, const void *addr, int af, const char *interface, uint32_t *err)
{
return si->vtable->sim_host_byaddr(si, addr, af, interface, err);
}
+LIBINFO_EXPORT
si_list_t *
si_host_all(si_mod_t *si)
{
return si->vtable->sim_host_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_mac_byname(struct si_mod_s *si, const char *name)
{
return si->vtable->sim_mac_byname(si, name);
}
+LIBINFO_EXPORT
si_item_t *
si_mac_bymac(struct si_mod_s *si, const char *mac)
{
return si->vtable->sim_mac_bymac(si, mac);
}
+LIBINFO_EXPORT
si_list_t *
si_mac_all(si_mod_t *si)
{
return si->vtable->sim_mac_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_network_byname(si_mod_t *si, const char *name)
{
return si->vtable->sim_network_byname(si, name);
}
+LIBINFO_EXPORT
si_item_t *
si_network_byaddr(si_mod_t *si, uint32_t addr)
{
return si->vtable->sim_network_byaddr(si, addr);
}
+LIBINFO_EXPORT
si_list_t *
si_network_all(si_mod_t *si)
{
return si->vtable->sim_network_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_service_byname(si_mod_t *si, const char *name, const char *proto)
{
return si->vtable->sim_service_byname(si, name, proto);
}
+LIBINFO_EXPORT
si_item_t *
si_service_byport(si_mod_t *si, int port, const char *proto)
{
return si->vtable->sim_service_byport(si, port, proto);
}
+LIBINFO_EXPORT
si_list_t *
si_service_all(si_mod_t *si)
{
return si->vtable->sim_service_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_protocol_byname(si_mod_t *si, const char *name)
{
return si->vtable->sim_protocol_byname(si, name);
}
+LIBINFO_EXPORT
si_item_t *
si_protocol_bynumber(si_mod_t *si, uint32_t number)
{
return si->vtable->sim_protocol_bynumber(si, number);
}
+LIBINFO_EXPORT
si_list_t *
si_protocol_all(si_mod_t *si)
{
return si->vtable->sim_protocol_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_rpc_byname(si_mod_t *si, const char *name)
{
return si->vtable->sim_rpc_byname(si, name);
}
+LIBINFO_EXPORT
si_item_t *
si_rpc_bynumber(si_mod_t *si, int number)
{
return si->vtable->sim_rpc_bynumber(si, number);
}
+LIBINFO_EXPORT
si_list_t *
si_rpc_all(si_mod_t *si)
{
return si->vtable->sim_rpc_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_fs_byspec(si_mod_t *si, const char *spec)
{
return si->vtable->sim_fs_byspec(si, spec);
}
+LIBINFO_EXPORT
si_item_t *
si_fs_byfile(si_mod_t *si, const char *file)
{
return si->vtable->sim_fs_byfile(si, file);
}
+LIBINFO_EXPORT
si_list_t *
si_fs_all(si_mod_t *si)
{
return si->vtable->sim_fs_all(si);
}
+LIBINFO_EXPORT
si_item_t *
si_item_call(struct si_mod_s *si, int call, const char *str1, const char *str2, const char *str3, uint32_t num1, uint32_t num2, uint32_t *err)
{
return NULL;
}
+LIBINFO_EXPORT
si_list_t *
si_list_call(struct si_mod_s *si, int call, const char *str1, const char *str2, const char *str3, uint32_t num1, uint32_t num2, uint32_t num3, uint32_t num4, uint32_t *err)
{
msg.header.msgh_id = r->call;
status = mach_msg(&(msg.header), MACH_SEND_MSG, msg.header.msgh_size, 0, MACH_PORT_NULL, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL);
- if (status != MACH_MSG_SUCCESS)
+ if ((status == MACH_SEND_INVALID_DEST) || (status == MACH_SEND_TIMED_OUT))
{
/* receiver failed - clean up to avoid a port leak */
mach_msg_destroy(&(msg.header));
#endif
}
+LIBINFO_EXPORT
mach_port_t
si_async_call(struct si_mod_s *si, int call, const char *str1, const char *str2, const char *str3, uint32_t num1, uint32_t num2, uint32_t num3, uint32_t num4, void *callback, void *context)
{
return req->port;
}
+LIBINFO_EXPORT
void
si_async_cancel(mach_port_t p)
{
si_async_workunit_release(r);
}
+LIBINFO_EXPORT
void
si_async_handle_reply(mach_msg_header_t *msg)
{
si_async_workunit_release(r);
}
+LIBINFO_EXPORT
char *
si_standardize_mac_address(const char *addr)
{
/*
- * Copyright (c) 2008-2011 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#ifndef __SI_MODULE_H__
#define __SI_MODULE_H__
+#include <stdbool.h>
#include <stdlib.h>
#include <stdint.h>
#include <netinet/in.h>
#define string_equal(A,B) (strcmp(A,B)==0)
#define string_not_equal(A,B) (strcmp(A,B)!=0)
+#define SI_HAS_NAT64_SYNTHESIS 1
+
#define SI_CALL_USER_BYNAME 0
#define SI_CALL_USER_BYUID 1
#define SI_CALL_USER_ALL 2
int _gai_serv_to_port(const char *serv, uint32_t proto, uint16_t *port);
si_list_t *_gai_simple(si_mod_t *si, const void *nodeptr, const void *servptr, uint32_t family, uint32_t socktype, uint32_t proto, uint32_t flags, const char *interface, uint32_t *err);
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
int si_inet_config(uint32_t *inet4, uint32_t *inet6);
+#endif
+
+bool _gai_nat64_can_v4_address_be_synthesized(const struct in_addr *ipv4_addr);
+void si_set_nat64_v4_requires_synthesis(bool (*nat64_v4_requires_synthesis)(const struct in_addr *ipv4_addr));
+void si_set_nat64_v4_synthesize(int (*nat64_v4_synthesize)(uint32_t *index, const struct in_addr *ipv4, struct in6_addr **out_ipv6_addrs));
#endif /* ! __SI_MODULE_H__ */
/*
- * Copyright (c) 2008 Apple Inc. All rights reserved.
+ * Copyright (c) 2008-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <thread_data.h>
#include <pthread.h>
#include <string.h>
return tdata;
}
+LIBINFO_EXPORT
si_item_t *
LI_get_thread_item(uint32_t key)
{
return tdata->thread_item;
}
+LIBINFO_EXPORT
si_list_t *
LI_get_thread_list(uint32_t key)
{
return tdata->thread_list;
}
+LIBINFO_EXPORT
void
LI_set_thread_item(uint32_t key, si_item_t *item)
{
tdata->thread_item = item;
}
+LIBINFO_EXPORT
void
LI_set_thread_list(uint32_t key, si_list_t *list)
{
/*
- * Copyright (c) 2004-2015 Apple Inc. All rights reserved.
+ * Copyright (c) 2004-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* @APPLE_LICENSE_HEADER_END@
*/
+#include "libinfo_common.h"
+
#include <stdlib.h>
#include <sys/errno.h>
#include <sys/types.h>
}
#endif
+LIBINFO_EXPORT
int
mbr_identifier_translate(int id_type, const void *identifier, size_t identifier_size, int target_type, void **result, int *rec_type)
{
return rc;
}
+LIBINFO_EXPORT
int
mbr_uid_to_uuid(uid_t id, uuid_t uu)
{
return mbr_identifier_to_uuid(ID_TYPE_UID, &id, sizeof(id), uu);
}
+LIBINFO_EXPORT
int
mbr_gid_to_uuid(gid_t id, uuid_t uu)
{
return mbr_identifier_to_uuid(ID_TYPE_GID, &id, sizeof(id), uu);
}
+LIBINFO_EXPORT
int
mbr_uuid_to_id(const uuid_t uu, uid_t *id, int *id_type)
{
return rc;
}
+LIBINFO_EXPORT
int
mbr_sid_to_uuid(const nt_sid_t *sid, uuid_t uu)
{
#endif
}
+LIBINFO_EXPORT
int
mbr_identifier_to_uuid(int id_type, const void *identifier, size_t identifier_size, uuid_t uu)
{
return rc;
}
+LIBINFO_EXPORT
int
mbr_uuid_to_sid_type(const uuid_t uu, nt_sid_t *sid, int *id_type)
{
#endif
}
+LIBINFO_EXPORT
int
mbr_uuid_to_sid(const uuid_t uu, nt_sid_t *sid)
{
#endif
}
+LIBINFO_EXPORT
int
mbr_check_membership(const uuid_t user, const uuid_t group, int *ismember)
{
return mbr_check_membership_ext(ID_TYPE_UUID, user, sizeof(uuid_t), ID_TYPE_UUID, group, 0, ismember);
}
+LIBINFO_EXPORT
int
mbr_check_membership_refresh(const uuid_t user, uuid_t group, int *ismember)
{
return mbr_check_membership_ext(ID_TYPE_UUID, user, sizeof(uuid_t), ID_TYPE_UUID, group, 1, ismember);
}
+LIBINFO_EXPORT
int
mbr_check_membership_ext(int userid_type, const void *userid, size_t userid_size, int groupid_type, const void *groupid, int refresh, int *isMember)
{
#endif
}
+LIBINFO_EXPORT
int
mbr_check_membership_by_id(uuid_t user, gid_t group, int *ismember)
{
return mbr_check_membership_ext(ID_TYPE_UUID, user, sizeof(uuid_t), ID_TYPE_GID, &group, 0, ismember);
}
+LIBINFO_EXPORT
int
mbr_reset_cache()
{
#endif
}
+LIBINFO_EXPORT
int
mbr_user_name_to_uuid(const char *name, uuid_t uu)
{
return mbr_identifier_to_uuid(ID_TYPE_USERNAME, name, -1, uu);
}
+LIBINFO_EXPORT
int
mbr_group_name_to_uuid(const char *name, uuid_t uu)
{
return mbr_identifier_to_uuid(ID_TYPE_GROUPNAME, name, -1, uu);
}
+LIBINFO_EXPORT
int
mbr_check_service_membership(const uuid_t user, const char *servicename, int *ismember)
{
}
#endif
+LIBINFO_EXPORT
int
mbr_sid_to_string(const nt_sid_t *sid, char *string)
{
#endif
}
+LIBINFO_EXPORT
int
mbr_string_to_sid(const char *string, nt_sid_t *sid)
{
return uuid_parse(string, uu);
}
+LIBINFO_EXPORT
int
mbr_set_identifier_ttl(int id_type, const void *identifier, size_t identifier_size, unsigned int seconds)
{
/*
- * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include <uuid/uuid.h>
#include <ntsid.h>
+#include <os/availability.h>
#define MBR_UU_STRING_SIZE 37
#define MBR_MAX_SID_STRING_SIZE 200
int mbr_check_membership_refresh(const uuid_t user, uuid_t group, int *ismember);
/* mbr_uuid_to_string should use uuid_unparse from uuid.h */
-int mbr_uuid_to_string(const uuid_t uu, char *string) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
+int mbr_uuid_to_string(const uuid_t uu, char *string) API_DEPRECATED("No longer supported", macos(10.4, 10.8));
/* mbr_string_to_uuid should use uuid_parse from uuid.h */
-int mbr_string_to_uuid(const char *string, uuid_t uu) __OSX_AVAILABLE_BUT_DEPRECATED(__MAC_10_4, __MAC_10_8, __IPHONE_NA, __IPHONE_NA);
+int mbr_string_to_uuid(const char *string, uuid_t uu) API_DEPRECATED("No longer supported", macos(10.4, 10.8));
int mbr_uuid_to_sid_type(const uuid_t uu, nt_sid_t *sid, int *id_type);
int mbr_set_identifier_ttl(int id_type, const void *identifier, size_t identifier_size, unsigned int seconds);
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* cover for getdomainname()
* Copyright (C) 1995 by NeXT Computer, Inc.
*/
+#include "libinfo_common.h"
+
#include <mach/mach_types.h>
#include <sys/sysctl.h>
+LIBINFO_EXPORT
int
getdomainname(char *val, int inlen)
{
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* cover for getdomainname()
* Copyright (C) 1995 by NeXT Computer, Inc.
*/
+#include "libinfo_common.h"
+
#include <mach/mach_types.h>
#include <sys/sysctl.h>
+LIBINFO_EXPORT
int
-setdomainname(const char *name, size_t namelen)
+setdomainname(const char *name, int namelen)
{
int mib[2];
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_domainname.c,v 1.3 1996/08/19 08:34:58 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_domainname(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_keydat.c,v 1.4 1996/08/19 08:34:58 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_keydat(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_mapname.c,v 1.3 1996/08/19 08:34:59 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_mapname(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_peername.c,v 1.3 1996/08/19 08:34:59 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_peername(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_valdat.c,v 1.4 1996/08/19 08:35:00 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_valdat(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypbind_binding.c,v 1.3 1996/08/19 08:35:00 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypbind_binding(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypbind_resp.c,v 1.3 1996/08/19 08:35:01 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypbind_resp(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypbind_resptype.c,v 1.3 1996/08/19 08:35:01 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypbind_resptype(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypbind_setdom.c,v 1.3 1996/08/19 08:35:02 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypbind_setdom(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypmaplist.c,v 1.3 1996/08/19 08:35:02 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypmaplist(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypreq_key.c,v 1.3 1996/08/19 08:35:03 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypreq_key(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypreq_nokey.c,v 1.3 1996/08/19 08:35:03 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypreq_nokey(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypresp_all.c,v 1.3 1996/08/19 08:35:04 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypresp_all(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypresp_key_val.c,v 1.3 1996/08/19 08:35:04 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypresp_key_val(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypresp_maplist.c,v 1.3 1996/08/19 08:35:05 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypresp_maplist(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypresp_master.c,v 1.3 1996/08/19 08:35:05 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypresp_master(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypresp_order.c,v 1.3 1996/08/19 08:35:06 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypresp_order(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypresp_val.c,v 1.3 1996/08/19 08:35:06 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypresp_val(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: xdr_ypstat.c,v 1.4 1996/12/14 06:49:45 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
bool_t
xdr_ypstat(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yp_all.c,v 1.5 1996/12/14 06:49:46 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
int (*ypresp_allfn) __P((u_long, char *, int, char *, int, void *));
void *ypresp_data;
+LIBINFO_EXPORT
bool_t
xdr_ypresp_all_seq(xdrs, objp)
XDR *xdrs;
}
}
+LIBINFO_EXPORT
int
yp_all(indomain, inmap, incallback)
const char *indomain;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yp_bind.c,v 1.9 1997/04/29 21:25:20 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
int _yplib_timeout = 10;
+LIBINFO_EXPORT
int
_yp_dobind(dom, ypdb)
const char *dom;
ypb->dom_socket = -1;
}
+LIBINFO_EXPORT
int
yp_bind(dom)
const char *dom;
return _yp_dobind(dom, NULL);
}
+LIBINFO_EXPORT
void
yp_unbind(dom)
const char *dom;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yp_first.c,v 1.5 1996/12/03 08:20:03 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/ypclnt.h>
#include "ypinternal.h"
+LIBINFO_EXPORT
int
yp_first(indomain, inmap, outkey, outkeylen, outval, outvallen)
const char *indomain;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yp_get_default_domain.c,v 1.3 1996/08/19 08:35:09 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/ypclnt.h>
#include "ypinternal.h"
+LIBINFO_EXPORT
int
yp_get_default_domain(domp)
char **domp;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yp_maplist.c,v 1.5 1996/12/03 08:20:04 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/ypclnt.h>
#include "ypinternal.h"
+LIBINFO_EXPORT
int
yp_maplist(indomain, outmaplist)
const char *indomain;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yp_master.c,v 1.5 1996/12/03 08:20:05 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/ypclnt.h>
#include "ypinternal.h"
+LIBINFO_EXPORT
int
yp_master(indomain, inmap, outname)
const char *indomain;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yp_order.c,v 1.5 1996/08/19 08:35:11 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/ypclnt.h>
#include "ypinternal.h"
+LIBINFO_EXPORT
int
yp_order(indomain, inmap, outorder)
const char *indomain;
+/*
+ * Copyright (c) 2018 Apple Inc. All rights reserved.
+ */
/*
* Copyright (c) 1992/3 Theo de Raadt <deraadt@fsa.ca>
* All rights reserved.
#ifndef _RPCSVC_YP_PROT_H_
#define _RPCSVC_YP_PROT_H_
+#include <rpc/clnt.h>
/*
* YPSERV PROTOCOL:
__BEGIN_DECLS
bool_t xdr_domainname __P((XDR *, char *));
bool_t xdr_peername __P((XDR *, char *));
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
bool_t xdr_datum __P((XDR *, datum *));
+#endif
bool_t xdr_mapname __P((XDR *, char *));
bool_t xdr_ypreq_key __P((XDR *, struct ypreq_key *));
bool_t xdr_ypreq_nokey __P((XDR *, struct ypreq_nokey *));
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
bool_t xdr_yp_inaddr __P((XDR *, struct in_addr *));
+#endif
bool_t xdr_ypbind_binding __P((XDR *, struct ypbind_binding *));
bool_t xdr_ypbind_resptype __P((XDR *, enum ypbind_resptype *));
bool_t xdr_ypstat __P((XDR *, enum ypbind_resptype *));
bool_t xdr_ypresp_all __P((XDR *, struct ypresp_all *));
bool_t xdr_ypresp_all_seq __P((XDR *, unsigned long *));
bool_t xdr_ypresp_master __P((XDR *, struct ypresp_master *));
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
bool_t xdr_ypmaplist_str __P((XDR *, char *));
+#endif
bool_t xdr_ypmaplist __P((XDR *, struct ypmaplist *));
bool_t xdr_ypresp_maplist __P((XDR *, struct ypresp_maplist *));
bool_t xdr_ypresp_order __P((XDR *, struct ypresp_order *));
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: yperr_string.c,v 1.3 1996/08/19 08:35:12 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
char *
yperr_string(incode)
int incode;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: ypmatch_cache.c,v 1.6 1996/12/03 08:20:06 deraadt Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
}
#endif
+LIBINFO_EXPORT
int
yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen)
const char *indomain;
return r;
}
+LIBINFO_EXPORT
int
yp_next(indomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen)
const char *indomain;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char rcsid[] = "$OpenBSD: yppasswdd_xdr.c,v 1.4 1997/08/19 07:00:52 niklas Exp $";
#endif
+#include "libinfo_common.h"
+
#include <rpc/rpc.h>
#include <rpcsvc/yppasswd.h>
+LIBINFO_EXPORT
bool_t
xdr_x_passwd(xdrs, objp)
XDR *xdrs;
return (TRUE);
}
+LIBINFO_EXPORT
bool_t
xdr_yppasswd(xdrs, objp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$OpenBSD: ypprot_err.c,v 1.4 1996/12/14 06:49:47 tholo Exp $";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <rpcsvc/yp.h>
#include <rpcsvc/ypclnt.h>
+LIBINFO_EXPORT
int
ypprot_err(incode)
unsigned int incode;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#ifndef _RPC_AUTH_H
#define _RPC_AUTH_H
+#include <rpc/types.h>
+#include <rpc/xdr.h>
#include <sys/cdefs.h>
#define MAX_AUTH_BYTES 400
extern AUTH *authunix_create __P((char *, int, int, int, int *));
extern AUTH *authunix_create_default __P((void));
extern AUTH *authnone_create __P((void));
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
extern AUTH *authdes_create __P((char *, unsigned int,
struct sockaddr_in *,
des_block *));
+#endif
__END_DECLS
#define AUTH_NONE 0 /* no authentication */
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <stdlib.h>
#include <sys/types.h>
#include <netinet/in.h>
u_int mcnt;
} *authnone_private;
+LIBINFO_EXPORT
AUTH *
authnone_create()
{
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
* Create a unix style authenticator.
* Returns an auth handle with the given stuff in it.
*/
+LIBINFO_EXPORT
AUTH *
authunix_create(machname, uid, gid, len, aup_gids)
char *machname;
* Returns an auth handle with parameters determined by doing lots of
* syscalls.
*/
+LIBINFO_EXPORT
AUTH *
authunix_create_default()
{
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*/
+#include "libinfo_common.h"
+
#include <sys/types.h>
#include <netinet/in.h>
#include <rpc/types.h>
/*
* XDR for unix authentication parameters.
*/
+LIBINFO_EXPORT
bool_t
xdr_authunix_parms(xdrs, p)
register XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Portions Copyright(C) 1996, Jason Downs. All rights reserved.
*/
+#include "libinfo_common.h"
+
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
/*
* Bind a socket to a privileged port for whatever protocol.
*/
+LIBINFO_EXPORT
int
bindresvport_sa(sd, sa)
int sd;
/*
* Bind a socket to a privileged IP port
*/
+LIBINFO_EXPORT
int
bindresvport(sd, sin)
int sd;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#ifndef _RPC_CLNT_H_
#define _RPC_CLNT_H_
+#include <rpc/auth.h>
#include <sys/cdefs.h>
/*
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
/*
* Copyright (C) 1987, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <string.h>
#include <rpc/rpc.h>
#include <sys/socket.h>
* returns client handle. Default options are set, which the user can
* change using the rpc equivalent of ioctl()'s.
*/
+LIBINFO_EXPORT
CLIENT *
clnt_create(hostname, prog, vers, proto)
#ifdef __LP64__
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
/*
* Print reply error info
*/
+LIBINFO_EXPORT
char *
clnt_sperror(rpch, s)
CLIENT *rpch;
return(strstart) ;
}
+LIBINFO_EXPORT
void
clnt_perror(rpch, s)
CLIENT *rpch;
/*
* This interface for use by clntrpc
*/
+LIBINFO_EXPORT
char *
clnt_sperrno(stat)
enum clnt_stat stat;
return ("RPC: (unknown error code)");
}
+LIBINFO_EXPORT
void
clnt_perrno(num)
enum clnt_stat num;
}
+LIBINFO_EXPORT
char *
clnt_spcreateerror(s)
char *s;
return (str);
}
+LIBINFO_EXPORT
void
clnt_pcreateerror(s)
char *s;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* any interference from the kernal.
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <rpc/rpc.h>
/*
* Create a client handle for memory based rpc.
*/
+LIBINFO_EXPORT
CLIENT *
clntraw_create(prog, vers)
#ifdef __LP64__
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Now go hang yourself.
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
return NULL;
}
+LIBINFO_EXPORT
CLIENT *
clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz)
#ifdef __LP64__
/*
- * Copyright (c) 1999-2007 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
return NULL;
}
+LIBINFO_EXPORT
CLIENT *
clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz)
#ifdef __LP64__
return clntudp_bufcreate_timeout(raddr, (uint32_t)program, (uint32_t)version, sockp, (uint32_t)sendsz, (uint32_t)recvsz, &wait, NULL);
}
+LIBINFO_EXPORT
CLIENT *
clntudp_create(raddr, program, version, wait, sockp)
#ifdef __LP64__
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (c) 1985 by Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <string.h>
#include <rpc/rpc.h>
#include <netdb.h>
#include <sys/socket.h>
+LIBINFO_EXPORT
int
getrpcport(host, prognum, versnum, proto)
char *host;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <string.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
* Set a mapping between program,version and port.
* Calls the pmap service remotely to do the mapping.
*/
+LIBINFO_EXPORT
bool_t
pmap_set(program, version, protocol, port)
#ifdef __LP64__
* Remove the mapping between program,version and port.
* Calls the pmap service remotely to do the un-mapping.
*/
+LIBINFO_EXPORT
bool_t
pmap_unset(program, version)
#ifdef __LP64__
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
* Get a copy of the current port maps.
* Calls the pmap service remotely to do get the maps.
*/
+LIBINFO_EXPORT
struct pmaplist *
pmap_getmaps(address)
struct sockaddr_in *address;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <unistd.h>
#include <rpc/rpc.h>
#include <rpc/pmap_prot.h>
return port;
}
+LIBINFO_EXPORT
u_short
pmap_getport(address, program, version, protocol)
#ifdef __LP64__
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
+LIBINFO_EXPORT
bool_t
xdr_pmap(xdrs, regs)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <rpc/types.h>
#include <rpc/xdr.h>
#include <rpc/pmap_prot.h>
* the net, yet is the data that the pointer points to which is interesting;
* this sounds like a job for xdr_reference!
*/
+LIBINFO_EXPORT
bool_t
xdr_pmaplist(xdrs, rp)
register XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <string.h>
#include <unistd.h>
#include <rpc/rpc.h>
* remotely call that routine with the given parameters. This allows
* programs to do a lookup and call in one step.
*/
+LIBINFO_EXPORT
enum clnt_stat
pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_ptr)
#ifdef __LP64__
* XDR remote call arguments
* written for XDR_ENCODE direction only
*/
+LIBINFO_EXPORT
bool_t
xdr_rmtcall_args(xdrs, cap)
register XDR *xdrs;
* XDR remote call results
* written for XDR_DECODE direction only
*/
+LIBINFO_EXPORT
bool_t
xdr_rmtcallres(xdrs, crp)
register XDR *xdrs;
typedef bool_t (*resultproc_t)();
+LIBINFO_EXPORT
enum clnt_stat
clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
#ifdef __LP64__
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*
*/
+#include "libinfo_common.h"
+
#include <stdlib.h>
#include <string.h>
#include <sys/param.h>
/*
* XDR a call message
*/
+LIBINFO_EXPORT
bool_t
xdr_callmsg(xdrs, cmsg)
register XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *rcsid = "$Id: rpc_commondata.c,v 1.3 2002/02/19 20:36:24 epeyton Exp $";
#endif
+#include "libinfo_common.h"
+
#include <rpc/rpc.h>
/*
* This file should only contain common data (global data) that is exported
* by public interfaces
*/
#if defined(__APPLE__)
+LIBINFO_EXPORT
struct opaque_auth _null_auth = {0};
+LIBINFO_EXPORT
fd_set svc_fdset = {{0}};
int svc_maxfd = -1;
+LIBINFO_EXPORT
struct rpc_createerr rpc_createerr = {0};
#else
struct opaque_auth _null_auth;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* routines are also in this program.
*/
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <rpc/rpc.h>
/*
* XDR a DES block
*/
+LIBINFO_EXPORT
bool_t
xdr_des_block(xdrs, blkp)
register XDR *xdrs;
/*
* XDR a reply message
*/
+LIBINFO_EXPORT
bool_t
xdr_replymsg(xdrs, rmsg)
register XDR *xdrs;
* The fields include: rm_xid, rm_direction, rpcvers, prog, and vers.
* The rm_xid is not really static, but the user can easily munge on the fly.
*/
+LIBINFO_EXPORT
bool_t
xdr_callhdr(xdrs, cmsg)
register XDR *xdrs;
/*
* given a reply message, fills in the error
*/
+LIBINFO_EXPORT
void
_seterr_reply(msg, error)
register struct rpc_msg *msg;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <stdlib.h>
#include <string.h>
#include <sys/errno.h>
/*
* Activate a transport handle.
*/
+LIBINFO_EXPORT
void
xprt_register(xprt)
SVCXPRT *xprt;
/*
* De-activate a transport handle.
*/
+LIBINFO_EXPORT
void
xprt_unregister(xprt)
SVCXPRT *xprt;
* The dispatch routine will be called when a rpc request for this
* program number comes in.
*/
+LIBINFO_EXPORT
bool_t
svc_register(xprt, prog, vers, dispatch, protocol)
#ifdef __LP64__
/*
* Remove a service program from the callout list.
*/
+LIBINFO_EXPORT
void
svc_unregister(prog, vers)
#ifdef __LP64__
/*
* Send a reply to an rpc request
*/
+LIBINFO_EXPORT
bool_t
svc_sendreply(xprt, xdr_results, xdr_location)
register SVCXPRT *xprt;
/*
* No procedure error reply
*/
+LIBINFO_EXPORT
void
svcerr_noproc(xprt)
register SVCXPRT *xprt;
/*
* Can't decode args error reply
*/
+LIBINFO_EXPORT
void
svcerr_decode(xprt)
register SVCXPRT *xprt;
/*
* Some system error
*/
+LIBINFO_EXPORT
void
svcerr_systemerr(xprt)
register SVCXPRT *xprt;
/*
* Authentication error reply
*/
+LIBINFO_EXPORT
void
svcerr_auth(xprt, why)
SVCXPRT *xprt;
/*
* Auth too weak error reply
*/
+LIBINFO_EXPORT
void
svcerr_weakauth(xprt)
SVCXPRT *xprt;
/*
* Program unavailable error reply
*/
+LIBINFO_EXPORT
void
svcerr_noprog(xprt)
register SVCXPRT *xprt;
/*
* Program version mismatch error reply
*/
+LIBINFO_EXPORT
void
svcerr_progvers(xprt, low_vers, high_vers)
#ifdef __LP64__
* is mallocated in kernel land.
*/
+LIBINFO_EXPORT
void
svc_getreq(rdfds)
int rdfds;
svc_getreqset(&readfds);
}
+LIBINFO_EXPORT
void
svc_getreqset(readfds)
fd_set *readfds;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
extern int svc_fds;
#endif /* def FD_SETSIZE */
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
/*
* a small program implemented by the svc_rpc implementation itself;
* also see clnt.h for protocol numbers.
*/
extern void rpctest_service();
+#endif
__BEGIN_DECLS
extern void svc_getreq __P((int));
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <rpc/rpc.h>
/*
* There is an assumption that any flavour less than AUTH_NULL is
* invalid.
*/
+LIBINFO_EXPORT
enum auth_stat
_authenticate(rqst, msg)
register struct svc_req *rqst;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <stdlib.h>
#include <rpc/rpc.h>
svcraw_destroy
};
+LIBINFO_EXPORT
SVCXPRT *
svcraw_create()
{
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* This is the rpc server side idle loop
* Wait for input, call server program.
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <unistd.h>
#include <rpc/rpc.h>
extern int svc_maxfd;
+LIBINFO_EXPORT
void
svc_run()
{
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* and a record/tcp stream.
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
* how big the send and receive buffers are via the second and third parms;
* 0 => use the system default.
*/
+LIBINFO_EXPORT
SVCXPRT *
svctcp_create(sock, sendsize, recvsize)
register int sock;
* Like svtcp_create(), except the routine takes any *open* UNIX file
* descriptor as its first input.
*/
+LIBINFO_EXPORT
SVCXPRT *
svcfd_create(fd, sendsize, recvsize)
int fd;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Copyright (C) 1984, Sun Microsystems, Inc.
*/
+#include "libinfo_common.h"
+
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
* see (svc.h, xprt_register).
* The routines returns NULL if a problem occurred.
*/
+LIBINFO_EXPORT
SVCXPRT *
svcudp_bufcreate(sock, sendsz, recvsz)
register int sock;
return (xprt);
}
+LIBINFO_EXPORT
SVCXPRT *
svcudp_create(sock)
int sock;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* xdr.
*/
+#include "libinfo_common.h"
+
#include <err.h>
#include <stdio.h>
#include <stdlib.h>
* Free a data structure using XDR
* Not a filter, but a convenient utility nonetheless
*/
+LIBINFO_EXPORT
void
xdr_free(proc, objp)
xdrproc_t proc;
/*
* XDR nothing
*/
+LIBINFO_EXPORT
bool_t
xdr_void(void)
{
* XDR integers
*/
bool_t
+LIBINFO_EXPORT
xdr_int(xdrs, ip)
XDR *xdrs;
int *ip;
/*
* XDR unsigned integers
*/
+LIBINFO_EXPORT
bool_t
xdr_u_int(xdrs, up)
XDR *xdrs;
* XDR long integers
* same as xdr_u_long - open coded to save a proc call!
*/
+LIBINFO_EXPORT
bool_t
xdr_long(xdrs, lp)
XDR *xdrs;
* XDR unsigned long integers
* same as xdr_long - open coded to save a proc call!
*/
+LIBINFO_EXPORT
bool_t
xdr_u_long(xdrs, ulp)
XDR *xdrs;
* XDR 32-bit integers
* same as xdr_u_int32_t - open coded to save a proc call!
*/
+LIBINFO_EXPORT
bool_t
xdr_int32_t(xdrs, int32_p)
XDR *xdrs;
* XDR unsigned 32-bit integers
* same as xdr_int32_t - open coded to save a proc call!
*/
+LIBINFO_EXPORT
bool_t
xdr_u_int32_t(xdrs, u_int32_p)
XDR *xdrs;
/*
* XDR short integers
*/
+LIBINFO_EXPORT
bool_t
xdr_short(xdrs, sp)
XDR *xdrs;
/*
* XDR unsigned short integers
*/
+LIBINFO_EXPORT
bool_t
xdr_u_short(xdrs, usp)
XDR *xdrs;
/*
* XDR 16-bit integers
*/
+LIBINFO_EXPORT
bool_t
xdr_int16_t(xdrs, int16_p)
XDR *xdrs;
/*
* XDR unsigned 16-bit integers
*/
+LIBINFO_EXPORT
bool_t
xdr_u_int16_t(xdrs, u_int16_p)
XDR *xdrs;
/*
* XDR a char
*/
+LIBINFO_EXPORT
bool_t
xdr_char(xdrs, cp)
XDR *xdrs;
/*
* XDR an unsigned char
*/
+LIBINFO_EXPORT
bool_t
xdr_u_char(xdrs, cp)
XDR *xdrs;
/*
* XDR booleans
*/
+LIBINFO_EXPORT
bool_t
xdr_bool(xdrs, bp)
XDR *xdrs;
/*
* XDR enumerations
*/
+LIBINFO_EXPORT
bool_t
xdr_enum(xdrs, ep)
XDR *xdrs;
* Allows the specification of a fixed size sequence of opaque bytes.
* cp points to the opaque object and cnt gives the byte length.
*/
+LIBINFO_EXPORT
bool_t
xdr_opaque(xdrs, cp, cnt)
XDR *xdrs;
* *cpp is a pointer to the bytes, *sizep is the count.
* If *cpp is NULL maxsize bytes are allocated
*/
+LIBINFO_EXPORT
bool_t
xdr_bytes(xdrs, cpp, sizep, maxsize)
XDR *xdrs;
/*
* Implemented here due to commonality of the object.
*/
+LIBINFO_EXPORT
bool_t
xdr_netobj(xdrs, np)
XDR *xdrs;
* routine may be called.
* If there is no specific or default routine an error is returned.
*/
+LIBINFO_EXPORT
bool_t
xdr_union(xdrs, dscmp, unp, choices, dfault)
XDR *xdrs;
* storage is allocated. The last parameter is the max allowed length
* of the string as specified by a protocol.
*/
+LIBINFO_EXPORT
bool_t
xdr_string(xdrs, cpp, maxsize)
XDR *xdrs;
* Wrapper for xdr_string that can be called directly from
* routines like clnt_call
*/
+LIBINFO_EXPORT
bool_t
xdr_wrapstring(xdrs, cpp)
XDR *xdrs;
/*
* XDR 64-bit integers
*/
+LIBINFO_EXPORT
bool_t
xdr_int64_t(xdrs, llp)
XDR *xdrs;
/*
* XDR unsigned 64-bit integers
*/
+LIBINFO_EXPORT
bool_t
xdr_u_int64_t(xdrs, ullp)
XDR *xdrs;
/*
* XDR hypers
*/
+LIBINFO_EXPORT
bool_t
xdr_hyper(xdrs, llp)
XDR *xdrs;
/*
* XDR unsigned hypers
*/
+LIBINFO_EXPORT
bool_t
xdr_u_hyper(xdrs, ullp)
XDR *xdrs;
/*
* XDR longlong_t's
*/
+LIBINFO_EXPORT
bool_t
xdr_longlong_t(xdrs, llp)
XDR *xdrs;
/*
* XDR u_longlong_t's
*/
+LIBINFO_EXPORT
bool_t
xdr_u_longlong_t(xdrs, ullp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
extern bool_t xdr_vector(XDR *, char *, unsigned int, unsigned int, xdrproc_t);
extern bool_t xdr_float(XDR *, float *);
extern bool_t xdr_double(XDR *, double *);
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
extern bool_t xdr_quadruple(XDR *, long double *);
+#endif
extern bool_t xdr_reference(XDR *, char **, unsigned int, xdrproc_t);
extern bool_t xdr_pointer(XDR *, char **, unsigned int, xdrproc_t);
extern bool_t xdr_wrapstring(XDR *, char **);
/* true if no more input */
extern bool_t xdrrec_eof(XDR *);
+#if (!defined(LIBINFO_INSTALL_API) || !LIBINFO_INSTALL_API)
extern unsigned int xdrrec_readbytes(XDR *, caddr_t, unsigned int);
+#endif
__END_DECLS
#endif /* !_RPC_XDR_H */
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* arrays. See xdr.h for more info on the interface to xdr.
*/
+#include "libinfo_common.h"
+
#include <err.h>
#include <limits.h>
#include <stdio.h>
* elsize is the size (in bytes) of each element, and elproc is the
* xdr procedure to call to handle each element of the array.
*/
+LIBINFO_EXPORT
bool_t
xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc)
XDR *xdrs;
* > elemsize: size of each element
* > xdr_elem: routine to XDR each element
*/
+LIBINFO_EXPORT
bool_t
xdr_vector(xdrs, basep, nelem, elemsize, xdr_elem)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *sccsid = "@(#)xdr_float.c 1.12 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_float.c 2.1 88/07/29 4.0 RPCSRC";
#endif
+#include "libinfo_common.h"
+
#include <sys/cdefs.h>
/*
};
#endif /* vax */
+LIBINFO_EXPORT
bool_t
xdr_float(xdrs, fp)
XDR *xdrs;
#endif /* vax */
+LIBINFO_EXPORT
bool_t
xdr_double(xdrs, dp)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *sccsid = "@(#)xdr_mem.c 1.19 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_mem.c 2.1 88/07/29 4.0 RPCSRC";
#endif
+#include "libinfo_common.h"
+
#include <sys/cdefs.h>
/*
* The procedure xdrmem_create initializes a stream descriptor for a
* memory buffer.
*/
+LIBINFO_EXPORT
void
xdrmem_create(xdrs, addr, size, op)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Mountain View, California 94043
*/
+#include "libinfo_common.h"
+
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
static char *sccsid = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
* write respectively. They are like the system
* calls expect that they take an opaque handle rather than an fd.
*/
+LIBINFO_EXPORT
void
xdrrec_create(xdrs, sendsize, recvsize, tcp_handle, readit, writeit)
XDR *xdrs;
* Before reading (deserializing from the stream, one should always call
* this procedure to guarantee proper record alignment.
*/
+LIBINFO_EXPORT
bool_t
xdrrec_skiprecord(xdrs)
XDR *xdrs;
* Returns TRUE iff there is no more input in the buffer
* after consuming the rest of the current record.
*/
+LIBINFO_EXPORT
bool_t
xdrrec_eof(xdrs)
XDR *xdrs;
* (output) tcp stream. (This let's the package support batched or
* pipelined procedure calls.) TRUE => immmediate flush to tcp connection.
*/
+LIBINFO_EXPORT
bool_t
xdrrec_endofrecord(xdrs, sendnow)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
* Mountain View, California 94043
*/
+#include "libinfo_common.h"
+
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
static char *sccsid = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
* size is the sizeof the referneced structure.
* proc is the routine to handle the referenced structure.
*/
+LIBINFO_EXPORT
bool_t
xdr_reference(xdrs, pp, size, proc)
XDR *xdrs;
* > xdr_obj: routine to XDR an object.
*
*/
+LIBINFO_EXPORT
bool_t
xdr_pointer(xdrs,objpp,obj_size,xdr_obj)
XDR *xdrs;
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char *sccsid = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
static char *sccsid = "@(#)xdr_stdio.c 2.1 88/07/29 4.0 RPCSRC";
#endif
+#include "libinfo_common.h"
+
#include <sys/cdefs.h>
/*
* Sets the xdr stream handle xdrs for use on the stream file.
* Operation flag is set to op.
*/
+LIBINFO_EXPORT
void
xdrstdio_create(xdrs, file, op)
XDR *xdrs;
/*
- * Copyright (c) 1999-2008 Apple Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
*/
/* Copyright (c) 1994 NeXT Computer, Inc. All rights reserved. */
+#include "libinfo_common.h"
+
#import <libkern/OSByteOrder.h>
#import <stdint.h>
+LIBINFO_EXPORT
uint32_t ntohl(uint32_t x)
{
return OSSwapBigToHostInt32(x);
}
+LIBINFO_EXPORT
uint32_t htonl(uint32_t x)
{
return OSSwapHostToBigInt32(x);
}
+LIBINFO_EXPORT
uint16_t ntohs(uint16_t x)
{
return OSSwapBigToHostInt16(x);
}
+LIBINFO_EXPORT
uint16_t htons(uint16_t x)
{
return OSSwapHostToBigInt16(x);
/*
- * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 1999-2018 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94";
#endif /* LIBC_SCCS and not lint */
+#include "libinfo_common.h"
+
#include <sys/param.h>
#include <sys/socket.h>
#include <sys/stat.h>
static int __icheckhost __P((const struct sockaddr *, socklen_t,
const char *));
+LIBINFO_EXPORT
int
rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, af)
char **ahost;
return (-1);
}
+LIBINFO_EXPORT
int
rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
char **ahost;
return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET);
}
+LIBINFO_EXPORT
int
rresvport(port)
int *port;
return rresvport_af(port, AF_INET);
}
+LIBINFO_EXPORT
int
rresvport_af(alport, family)
int *alport, family;
*
* Returns 0 if ok, -1 if not ok.
*/
+LIBINFO_EXPORT
int
iruserok_sa(ra, rlen, superuser, ruser, luser)
const void *ra;
return (-1);
}
+LIBINFO_EXPORT
int
ruserok(rhost, superuser, ruser, luser)
const char *rhost, *ruser, *luser;
*
* Returns 0 if ok, -1 if not ok.
*/
+LIBINFO_EXPORT
int
iruserok(raddr, superuser, ruser, luser)
unsigned long raddr;
+// Copyright (c) 2018 Apple Inc. All rights reserved.
+
#include "<DEVELOPER_DIR>/Makefiles/CoreOS/Xcode/BSD.xcconfig"
HEADER_SEARCH_PATHS = /usr/local/include $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders
LIBDNSD_LDFLAGS = -lsystem_dnssd
LIBNOTIFY_LDFLAGS = -lsystem_notify
LIBXPC_LDFLAGS = -lxpc
-LIBNETWORK_LDFLAGS = -lsystem_network
LIBTRACE_LDFLAGS = -lsystem_trace
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
DYLIB_COMPATIBILITY_VERSION = 1
-OTHER_LDFLAGS = -all_load -umbrella System -L/usr/lib/system $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(LIBC_LDFLAGS) $(LIBDISPATCH_LDFLAGS) $(LIBLAUNCH_LDFLAGS) $(LIBASL_LDFLAGS) $(LIBBLOCKS_LDFLAGS) $(LIBDNSD_LDFLAGS) $(LIBNOTIFY_LDFLAGS) $(LIBXPC_LDFLAGS) $(LIBNETWORK_LDFLAGS) $(LIBTRACE_LDFLAGS)
+OTHER_LDFLAGS = -all_load -umbrella System -L/usr/lib/system $(LIBCOMPILER_RT_LDFLAGS) $(LIBDYLD_LDFLAGS) $(LIBSYSCALL_LDFLAGS) $(LIBMALLOC_LDFLAGS) $(LIBPLATFORM_LDFLAGS) $(LIBPTHREAD_LDFLAGS) $(LIBC_LDFLAGS) $(LIBDISPATCH_LDFLAGS) $(LIBLAUNCH_LDFLAGS) $(LIBASL_LDFLAGS) $(LIBBLOCKS_LDFLAGS) $(LIBDNSD_LDFLAGS) $(LIBNOTIFY_LDFLAGS) $(LIBXPC_LDFLAGS) $(LIBTRACE_LDFLAGS)
+
+// Text-Based API settings
+
+SUPPORTS_TEXT_BASED_API = YES
+TAPI_VERIFY_MODE = Pedantic
+OTHER_TAPI_FLAGS = -D LIBINFO_INSTALL_API=1 -extra-public-header $(SRCROOT)/Libinfo/pseudo_public.h -extra-public-header $(DSTROOT)/usr/include -extra-private-header $(DSTROOT)/usr/local/include -extra-private-header $(SRCROOT)/Libinfo/pseudo_private.h -umbrella System
+
+GCC_SYMBOLS_PRIVATE_EXTERN = YES
lookup.subproj/ils.h \
lookup.subproj/kvbuf.h \
lookup.subproj/libinfo.h \
+ lookup.subproj/si_compare.h \
lookup.subproj/si_data.h \
lookup.subproj/si_module.h \
lookup.subproj/thread_data.h
nis.subproj/yp_prot.h \
nis.subproj/ypclnt.h
-# Don't install man pages for installhdrs nor simulator builds
-if [[ "${ACTION}" == "installhdrs" ]]; then
+# Don't install man pages for installhdrs, installapi, nor simulator builds
+if [[ "${ACTION}" == "installhdrs" ]] || [[ "${ACTION}" == "installapi" ]]; then
exit 0
fi