From f475de6c8bdcd20d039ba7563c4980b1094c7c76 Mon Sep 17 00:00:00 2001 From: Apple Date: Fri, 15 Jun 2018 00:26:37 +0000 Subject: [PATCH] Libinfo-517.200.9.tar.gz --- Libinfo.xcodeproj/project.pbxproj | 22 + Libinfo/libinfo_common.h | 14 + Libinfo/pseudo_private.h | 19 + Libinfo/pseudo_public.h | 138 ++++ dns.subproj/herror.c | 8 + dns.subproj/res_comp.c | 9 + dns.subproj/res_query.c | 8 +- gen.subproj/configuration_profile.h | 8 +- gen.subproj/ether_addr.c | 6 +- gen.subproj/getifaddrs.c | 7 + gen.subproj/if_indextoname.c | 6 + gen.subproj/if_nameindex.c | 7 + gen.subproj/if_nametoindex.c | 6 + gen.subproj/ifaddrs.h | 9 +- gen.subproj/ip6opt.c | 18 + gen.subproj/rthdr.c | 18 + gen.subproj/vars.c | 15 +- lookup.subproj/cache_module.c | 5 +- lookup.subproj/ds_module.c | 6 +- lookup.subproj/grp.h | 4 +- lookup.subproj/ils.c | 5 +- lookup.subproj/kvbuf.c | 28 +- lookup.subproj/libinfo.c | 103 ++- lookup.subproj/mdns_module.c | 167 +++- lookup.subproj/netdb_async.h | 10 +- lookup.subproj/si_compare.c | 1115 +++++++++++++++++++++++++++ lookup.subproj/si_compare.h | 65 ++ lookup.subproj/si_data.c | 12 +- lookup.subproj/si_getaddrinfo.c | 209 +++-- lookup.subproj/si_module.c | 53 +- lookup.subproj/si_module.h | 11 +- lookup.subproj/thread_data.c | 8 +- membership.subproj/membership.c | 23 +- membership.subproj/membershipPriv.h | 7 +- nis.subproj/getdomainname.c | 5 +- nis.subproj/setdomainname.c | 7 +- nis.subproj/xdr_domainname.c | 5 +- nis.subproj/xdr_keydat.c | 5 +- nis.subproj/xdr_mapname.c | 5 +- nis.subproj/xdr_peername.c | 5 +- nis.subproj/xdr_valdat.c | 5 +- nis.subproj/xdr_ypbind_binding.c | 5 +- nis.subproj/xdr_ypbind_resp.c | 5 +- nis.subproj/xdr_ypbind_resptype.c | 5 +- nis.subproj/xdr_ypbind_setdom.c | 5 +- nis.subproj/xdr_ypmaplist.c | 5 +- nis.subproj/xdr_ypreq_key.c | 5 +- nis.subproj/xdr_ypreq_nokey.c | 5 +- nis.subproj/xdr_ypresp_all.c | 5 +- nis.subproj/xdr_ypresp_key_val.c | 5 +- nis.subproj/xdr_ypresp_maplist.c | 5 +- nis.subproj/xdr_ypresp_master.c | 5 +- nis.subproj/xdr_ypresp_order.c | 5 +- nis.subproj/xdr_ypresp_val.c | 5 +- nis.subproj/xdr_ypstat.c | 5 +- nis.subproj/yp_all.c | 6 +- nis.subproj/yp_bind.c | 7 +- nis.subproj/yp_first.c | 5 +- nis.subproj/yp_get_default_domain.c | 5 +- nis.subproj/yp_maplist.c | 5 +- nis.subproj/yp_master.c | 5 +- nis.subproj/yp_order.c | 5 +- nis.subproj/yp_prot.h | 10 + nis.subproj/yperr_string.c | 5 +- nis.subproj/ypmatch_cache.c | 6 +- nis.subproj/yppasswdd_xdr.c | 6 +- nis.subproj/ypprot_err.c | 5 +- rpc.subproj/auth.h | 6 +- rpc.subproj/auth_none.c | 5 +- rpc.subproj/auth_unix.c | 6 +- rpc.subproj/authunix_prot.c | 5 +- rpc.subproj/bindresvport.c | 6 +- rpc.subproj/clnt.h | 3 +- rpc.subproj/clnt_generic.c | 5 +- rpc.subproj/clnt_perror.c | 10 +- rpc.subproj/clnt_raw.c | 5 +- rpc.subproj/clnt_tcp.c | 5 +- rpc.subproj/clnt_udp.c | 6 +- rpc.subproj/getrpcport.c | 5 +- rpc.subproj/pmap_clnt.c | 6 +- rpc.subproj/pmap_getmaps.c | 5 +- rpc.subproj/pmap_getport.c | 5 +- rpc.subproj/pmap_prot.c | 5 +- rpc.subproj/pmap_prot2.c | 5 +- rpc.subproj/pmap_rmt.c | 8 +- rpc.subproj/rpc_callmsg.c | 5 +- rpc.subproj/rpc_commondata.c | 7 +- rpc.subproj/rpc_prot.c | 8 +- rpc.subproj/svc.c | 18 +- rpc.subproj/svc.h | 4 +- rpc.subproj/svc_auth.c | 5 +- rpc.subproj/svc_raw.c | 5 +- rpc.subproj/svc_run.c | 5 +- rpc.subproj/svc_tcp.c | 6 +- rpc.subproj/svc_udp.c | 6 +- rpc.subproj/xdr.c | 32 +- rpc.subproj/xdr.h | 6 +- rpc.subproj/xdr_array.c | 6 +- rpc.subproj/xdr_float.c | 6 +- rpc.subproj/xdr_mem.c | 5 +- rpc.subproj/xdr_rec.c | 8 +- rpc.subproj/xdr_reference.c | 6 +- rpc.subproj/xdr_stdio.c | 5 +- util.subproj/hton.c | 8 +- util.subproj/rcmd.c | 11 +- xcodescripts/Libinfo.xcconfig | 13 +- xcodescripts/install_files.sh | 5 +- 107 files changed, 2431 insertions(+), 176 deletions(-) create mode 100644 Libinfo/libinfo_common.h create mode 100644 Libinfo/pseudo_private.h create mode 100644 Libinfo/pseudo_public.h create mode 100644 lookup.subproj/si_compare.c create mode 100644 lookup.subproj/si_compare.h diff --git a/Libinfo.xcodeproj/project.pbxproj b/Libinfo.xcodeproj/project.pbxproj index 3aeb56a..5df1489 100644 --- a/Libinfo.xcodeproj/project.pbxproj +++ b/Libinfo.xcodeproj/project.pbxproj @@ -22,6 +22,7 @@ /* 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 */; }; @@ -139,6 +140,8 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 03056CE31F71A8EE0094A9FA /* si_compare.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = si_compare.h; sourceTree = ""; }; + 03056CE51F71A8EF0094A9FA /* si_compare.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; path = si_compare.c; sourceTree = ""; }; 2D31A0FA128074E700D5A84C /* getifmaddrs.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = getifmaddrs.3; sourceTree = ""; }; 2D31A0FB128074E700D5A84C /* getifmaddrs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getifmaddrs.c; sourceTree = ""; }; 2D4070B0129354A700FE81ED /* getnameinfo_link.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = getnameinfo_link.c; sourceTree = ""; }; @@ -147,6 +150,9 @@ 2D5DD5D11608E6E80051891A /* configuration_profile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = configuration_profile.h; sourceTree = ""; }; 2DBB147712DBD63300D710E3 /* inet6_opt_init.3 */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = inet6_opt_init.3; sourceTree = ""; }; 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Libinfo.xcconfig; path = xcodescripts/Libinfo.xcconfig; sourceTree = ""; }; + BDE3980D2044CDA300CAD4A2 /* libinfo_common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libinfo_common.h; sourceTree = ""; }; + BDE3980E2044CDA300CAD4A2 /* pseudo_public.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pseudo_public.h; sourceTree = ""; }; + BDE3980F2044CDA300CAD4A2 /* pseudo_private.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = pseudo_private.h; sourceTree = ""; }; C96579391B94C97100624699 /* muser_module.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = muser_module.c; sourceTree = ""; }; C965793B1B94CF2B00624699 /* libinfo_muser.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = libinfo_muser.h; sourceTree = ""; }; D2AAC0630554660B00DB518D /* libsystem_info.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libsystem_info.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -344,6 +350,7 @@ isa = PBXGroup; children = ( 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */, + BDE3980C2044CDA300CAD4A2 /* Libinfo */, FC5283ED11478C200058CCB0 /* dns.subproj */, FC52840011478C200058CCB0 /* gen.subproj */, FC52841711478C200058CCB0 /* lookup.subproj */, @@ -364,6 +371,16 @@ name = Products; sourceTree = ""; }; + BDE3980C2044CDA300CAD4A2 /* Libinfo */ = { + isa = PBXGroup; + children = ( + BDE3980D2044CDA300CAD4A2 /* libinfo_common.h */, + BDE3980E2044CDA300CAD4A2 /* pseudo_public.h */, + BDE3980F2044CDA300CAD4A2 /* pseudo_private.h */, + ); + path = Libinfo; + sourceTree = ""; + }; FC5283ED11478C200058CCB0 /* dns.subproj */ = { isa = PBXGroup; children = ( @@ -440,6 +457,8 @@ 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 */, @@ -754,6 +773,7 @@ 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 */, @@ -807,6 +827,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */; buildSettings = { + IS_ZIPPERED = YES; PRODUCT_NAME = info; }; name = Release; @@ -835,6 +856,7 @@ isa = XCBuildConfiguration; baseConfigurationReference = 3F397F7D185BD67F00987BCC /* Libinfo.xcconfig */; buildSettings = { + IS_ZIPPERED = YES; PRODUCT_NAME = info; }; name = Debug; diff --git a/Libinfo/libinfo_common.h b/Libinfo/libinfo_common.h new file mode 100644 index 0000000..5325799 --- /dev/null +++ b/Libinfo/libinfo_common.h @@ -0,0 +1,14 @@ +/* + 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__ diff --git a/Libinfo/pseudo_private.h b/Libinfo/pseudo_private.h new file mode 100644 index 0000000..807f610 --- /dev/null +++ b/Libinfo/pseudo_private.h @@ -0,0 +1,19 @@ +/* + 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); diff --git a/Libinfo/pseudo_public.h b/Libinfo/pseudo_public.h new file mode 100644 index 0000000..6007b51 --- /dev/null +++ b/Libinfo/pseudo_public.h @@ -0,0 +1,138 @@ +/* + 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 +#include +#include +#include +#include +#include +#include + +// 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); diff --git a/dns.subproj/herror.c b/dns.subproj/herror.c index 4f4013e..4eba5a5 100644 --- a/dns.subproj/herror.c +++ b/dns.subproj/herror.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* * ++Copyright++ 1987, 1993 * - @@ -58,6 +61,8 @@ static char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; 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 #include #include @@ -73,12 +78,14 @@ const char * const h_errlist[] = { }; 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) { @@ -101,6 +108,7 @@ herror(const char *s) writev(STDERR_FILENO, iov, (v - iov) + 1); } +LIBINFO_EXPORT const char * hstrerror(int err) { diff --git a/dns.subproj/res_comp.c b/dns.subproj/res_comp.c index 82380f4..e216071 100644 --- a/dns.subproj/res_comp.c +++ b/dns.subproj/res_comp.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* * ++Copyright++ 1985, 1993 * - @@ -58,6 +61,8 @@ static char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93"; 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 #include @@ -74,6 +79,7 @@ static char rcsid[] = "$Id: res_comp.c,v 1.4 2003/02/18 17:29:24 majka Exp $"; * '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) { @@ -147,6 +153,7 @@ dn_expand(const u_char *msg, const u_char *eomorig, const u_char *comp_dn, char /* * 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) { @@ -179,6 +186,7 @@ __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) { @@ -187,6 +195,7 @@ _getshort(const u_char *msgp) return u; } +LIBINFO_EXPORT u_int32_t _getlong(const u_char *msgp) { diff --git a/dns.subproj/res_query.c b/dns.subproj/res_query.c index cfba379..7a46d49 100644 --- a/dns.subproj/res_query.c +++ b/dns.subproj/res_query.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2012 Apple Inc. All rights reserved. + * Copyright (c) 1999, 2012-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -22,6 +22,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include @@ -42,8 +44,10 @@ extern int h_errno; #else #define RES_9_STATE_SIZE 512 #endif +LIBINFO_EXPORT char _res[RES_9_STATE_SIZE] = {0}; +LIBINFO_EXPORT int res_init(void) { @@ -124,12 +128,14 @@ _mdns_query(int call, const char *name, int class, int type, u_char *answer, int 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) { diff --git a/gen.subproj/configuration_profile.h b/gen.subproj/configuration_profile.h index b0cff70..fbcb7e5 100644 --- a/gen.subproj/configuration_profile.h +++ b/gen.subproj/configuration_profile.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012 Apple Inc. All rights reserved. + * Copyright (c) 2012-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -25,9 +25,9 @@ #define __CONFIGURATION_PROFILE_H__ #include -#include +#include -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__ */ diff --git a/gen.subproj/ether_addr.c b/gen.subproj/ether_addr.c index 92bc1a1..0516fee 100644 --- a/gen.subproj/ether_addr.c +++ b/gen.subproj/ether_addr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2008 Apple Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -34,6 +34,7 @@ static char sccsid[] = "@(#)ether_addr.c 1.2 88/05/10 4.0NFSSRC; from 1.9 88/02 * "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 #include @@ -51,6 +52,7 @@ static char sccsid[] = "@(#)ether_addr.c 1.2 88/05/10 4.0NFSSRC; from 1.9 88/02 * 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) { @@ -68,6 +70,7 @@ 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) { @@ -87,6 +90,7 @@ 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) { diff --git a/gen.subproj/getifaddrs.c b/gen.subproj/getifaddrs.c index be5d0ac..beae35c 100644 --- a/gen.subproj/getifaddrs.c +++ b/gen.subproj/getifaddrs.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* * Copyright (c) 1995, 1999 * Berkeley Software Design, Inc. All rights reserved. @@ -26,6 +29,8 @@ * NOTE: SIOCGIFCONF case is not LP64 friendly. it also does not perform * try-and-error for region size. */ +#include "libinfo_common.h" + #include #include #include @@ -86,6 +91,7 @@ #define MEMORY_MIN 2048 #define MEMORY_MAX 16777216 +LIBINFO_EXPORT int getifaddrs(struct ifaddrs **pif) { @@ -425,6 +431,7 @@ getifaddrs(struct ifaddrs **pif) return (0); } +LIBINFO_EXPORT void freeifaddrs(struct ifaddrs *ifp) { diff --git a/gen.subproj/if_indextoname.c b/gen.subproj/if_indextoname.c index e0e75a3..13080ce 100644 --- a/gen.subproj/if_indextoname.c +++ b/gen.subproj/if_indextoname.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* $KAME: if_indextoname.c,v 1.7 2000/11/08 03:09:30 itojun Exp $ */ /*- @@ -25,6 +28,8 @@ * BSDI Id: if_indextoname.c,v 2.3 2000/04/17 22:38:05 dab Exp */ +#include "libinfo_common.h" + #include #include #include @@ -55,6 +60,7 @@ * NULL and errno would be set to the proper value (e.g., ENOMEM). */ +LIBINFO_EXPORT char * if_indextoname(unsigned int ifindex, char *ifname) { diff --git a/gen.subproj/if_nameindex.c b/gen.subproj/if_nameindex.c index 06f1f5c..cba6b6e 100644 --- a/gen.subproj/if_nameindex.c +++ b/gen.subproj/if_nameindex.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* $KAME: if_nameindex.c,v 1.8 2000/11/24 08:20:01 itojun Exp $ */ /*- @@ -25,6 +28,8 @@ * BSDI Id: if_nameindex.c,v 2.3 2000/04/17 22:38:05 dab Exp */ +#include "libinfo_common.h" + #include #include #include @@ -75,6 +80,7 @@ * if_nameindex(). */ +LIBINFO_EXPORT struct if_nameindex * if_nameindex(void) { @@ -162,6 +168,7 @@ out: } #ifndef __OpenBSD__ +LIBINFO_EXPORT void if_freenameindex(struct if_nameindex *ptr) { diff --git a/gen.subproj/if_nametoindex.c b/gen.subproj/if_nametoindex.c index e1af130..bc26553 100644 --- a/gen.subproj/if_nametoindex.c +++ b/gen.subproj/if_nametoindex.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* $KAME: if_nametoindex.c,v 1.6 2000/11/24 08:18:54 itojun Exp $ */ /*- @@ -25,6 +28,8 @@ * BSDI Id: if_nametoindex.c,v 2.3 2000/04/17 22:38:05 dab Exp */ +#include "libinfo_common.h" + #include #include #include @@ -53,6 +58,7 @@ * proper value (e.g., ENOMEM). */ +LIBINFO_EXPORT unsigned int if_nametoindex(const char *ifname) { diff --git a/gen.subproj/ifaddrs.h b/gen.subproj/ifaddrs.h index 97cc6ca..cf78188 100644 --- a/gen.subproj/ifaddrs.h +++ b/gen.subproj/ifaddrs.h @@ -1,3 +1,6 @@ +/* + * 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 $ */ /* @@ -28,7 +31,7 @@ #ifndef _IFADDRS_H_ #define _IFADDRS_H_ -#include +#include struct ifaddrs { struct ifaddrs *ifa_next; @@ -60,8 +63,8 @@ struct ifmaddrs { __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 diff --git a/gen.subproj/ip6opt.c b/gen.subproj/ip6opt.c index 10d36b1..14ad8ae 100644 --- a/gen.subproj/ip6opt.c +++ b/gen.subproj/ip6opt.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* $KAME: ip6opt.c,v 1.13 2003/06/06 10:08:20 suz Exp $ */ /* @@ -31,6 +34,8 @@ * $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 @@ -61,6 +66,7 @@ static void inet6_insert_padopt(u_char *p, int len); * 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) { @@ -73,6 +79,7 @@ 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) { @@ -100,6 +107,7 @@ 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) @@ -170,6 +178,7 @@ inet6_option_append(struct cmsghdr *cmsg, const u_int8_t *typep, int multx, * then be built by the caller. * */ +LIBINFO_EXPORT u_int8_t * inet6_option_alloc(struct cmsghdr *cmsg, int datalen, int multx, int plusy) { @@ -233,6 +242,7 @@ 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) { @@ -289,6 +299,7 @@ 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) { @@ -383,6 +394,7 @@ inet6_insert_padopt(u_char *p, int len) * of RFC2292. */ +LIBINFO_EXPORT int inet6_opt_init(void *extbuf, socklen_t extlen) { @@ -399,6 +411,7 @@ 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) { @@ -464,6 +477,7 @@ inet6_opt_append(void *extbuf, socklen_t extlen, int offset, u_int8_t type, sock return(currentlen); } +LIBINFO_EXPORT int inet6_opt_finish(void *extbuf, socklen_t extlen, int offset) { @@ -489,6 +503,7 @@ 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) { @@ -496,6 +511,7 @@ 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) { @@ -544,6 +560,7 @@ inet6_opt_next(void *extbuf, socklen_t extlen, int offset, u_int8_t *typep, sock return(-1); } +LIBINFO_EXPORT int inet6_opt_find(void *extbuf, socklen_t extlen, int offset, u_int8_t type, socklen_t *lenp, void **databufp) { @@ -585,6 +602,7 @@ inet6_opt_find(void *extbuf, socklen_t extlen, int offset, u_int8_t type, sockle return(-1); } +LIBINFO_EXPORT int inet6_opt_get_val(void *databuf, int offset, void *val, socklen_t vallen) { diff --git a/gen.subproj/rthdr.c b/gen.subproj/rthdr.c index 1031311..bfce6da 100644 --- a/gen.subproj/rthdr.c +++ b/gen.subproj/rthdr.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* $KAME: rthdr.c,v 1.19 2003/06/06 10:48:51 itojun Exp $ */ /* @@ -31,6 +34,8 @@ /* __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 @@ -53,6 +58,7 @@ * RFC2292 API */ +LIBINFO_EXPORT size_t inet6_rthdr_space(type, seg) int type, seg; @@ -73,6 +79,7 @@ int type, seg; } } +LIBINFO_EXPORT struct cmsghdr * inet6_rthdr_init(bp, type) void *bp; @@ -104,6 +111,7 @@ int type; } /* ARGSUSED */ +LIBINFO_EXPORT int inet6_rthdr_add(cmsg, addr, flags) struct cmsghdr *cmsg; @@ -149,6 +157,7 @@ u_int flags; } /* ARGSUSED */ +LIBINFO_EXPORT int inet6_rthdr_lasthop(cmsg, flags) struct cmsghdr *cmsg; @@ -199,6 +208,7 @@ struct cmsghdr *out; } #endif +LIBINFO_EXPORT int inet6_rthdr_segments(cmsg) const struct cmsghdr *cmsg; @@ -223,6 +233,7 @@ const struct cmsghdr *cmsg; } } +LIBINFO_EXPORT struct in6_addr * inet6_rthdr_getaddr(cmsg, idx) struct cmsghdr *cmsg; @@ -255,6 +266,7 @@ int idx; } } +LIBINFO_EXPORT int inet6_rthdr_getflags(cmsg, idx) const struct cmsghdr *cmsg; @@ -294,6 +306,7 @@ int idx; * RFC3542 API */ +LIBINFO_EXPORT socklen_t inet6_rth_space(int type, int segments) { @@ -307,6 +320,7 @@ inet6_rth_space(int type, int segments) } } +LIBINFO_EXPORT void * inet6_rth_init(void *bp, socklen_t bp_len, int type, int segments) { @@ -336,6 +350,7 @@ 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) { @@ -360,6 +375,7 @@ inet6_rth_add(void *bp, const struct in6_addr *addr) return (0); } +LIBINFO_EXPORT int inet6_rth_reverse(const void *in, void *out) { @@ -402,6 +418,7 @@ inet6_rth_reverse(const void *in, void *out) return (0); } +LIBINFO_EXPORT int inet6_rth_segments(const void *bp) { @@ -427,6 +444,7 @@ inet6_rth_segments(const void *bp) } } +LIBINFO_EXPORT struct in6_addr * inet6_rth_getaddr(const void *bp, int idx) { diff --git a/gen.subproj/vars.c b/gen.subproj/vars.c index 27e9a45..13fb5d0 100644 --- a/gen.subproj/vars.c +++ b/gen.subproj/vars.c @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. @@ -29,15 +32,17 @@ * $FreeBSD: src/lib/libc/net/vars.c,v 1.1 1999/12/16 18:32:01 shin Exp $ */ +#include "libinfo_common.h" + #include #include /* * 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; diff --git a/lookup.subproj/cache_module.c b/lookup.subproj/cache_module.c index 179468b..e5292ca 100644 --- a/lookup.subproj/cache_module.c +++ b/lookup.subproj/cache_module.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2011 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -35,6 +37,7 @@ #include /* GLOBAL */ +LIBINFO_EXPORT uint32_t gL1CacheEnabled = 1; #define CACHE_COUNT CATEGORY_COUNT diff --git a/lookup.subproj/ds_module.c b/lookup.subproj/ds_module.c index ded2f9e..f0c1519 100644 --- a/lookup.subproj/ds_module.c +++ b/lookup.subproj/ds_module.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2011 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -23,6 +23,8 @@ #ifdef DS_AVAILABLE +#include "libinfo_common.h" + #include #include #include @@ -128,6 +130,7 @@ _ds_serv_cache_free(void *x) if (x != NULL) si_item_release(x); } +LIBINFO_EXPORT void _si_disable_opendirectory(void) { @@ -209,6 +212,7 @@ _ds_child(void) _ds_port = MACH_PORT_NULL; } +LIBINFO_EXPORT int _ds_running(void) { diff --git a/lookup.subproj/grp.h b/lookup.subproj/grp.h index 181b44e..0091ee4 100644 --- a/lookup.subproj/grp.h +++ b/lookup.subproj/grp.h @@ -37,7 +37,7 @@ * * @(#)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_ @@ -83,7 +83,9 @@ __END_DECLS #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 diff --git a/lookup.subproj/ils.c b/lookup.subproj/ils.c index 7a37fef..cc489fa 100644 --- a/lookup.subproj/ils.c +++ b/lookup.subproj/ils.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2010 Apple Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -88,6 +90,7 @@ padsize(size_t curr, size_t item, const uint32_t *align) * @ length (4 bytes) and buffer (requires two parameters) * */ +LIBINFO_EXPORT void * LI_ils_create(char *fmt, ...) { diff --git a/lookup.subproj/kvbuf.c b/lookup.subproj/kvbuf.c index fa2fb51..8e7f6a9 100644 --- a/lookup.subproj/kvbuf.c +++ b/lookup.subproj/kvbuf.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009 Apple Inc. All rights reserved. + * Copyright (c) 2009-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -69,6 +71,7 @@ * (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, ...) { @@ -116,6 +119,7 @@ kvbuf_query(char *fmt, ...) return kv; } +LIBINFO_EXPORT kvbuf_t * kvbuf_query_key_val(const char *key, const char *val) { @@ -188,6 +192,7 @@ 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) { @@ -197,6 +202,7 @@ 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) { @@ -206,6 +212,7 @@ 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) { @@ -230,12 +237,14 @@ 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) { @@ -265,6 +274,7 @@ 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) { @@ -317,6 +327,7 @@ kvbuf_grow(kvbuf_t *kv, uint32_t delta) } } +LIBINFO_EXPORT void kvbuf_add_dict(kvbuf_t *kv) { @@ -348,6 +359,7 @@ kvbuf_add_dict(kvbuf_t *kv) memcpy(p, &x, sizeof(uint32_t)); } +LIBINFO_EXPORT void kvbuf_add_key(kvbuf_t *kv, const char *key) { @@ -397,6 +409,7 @@ 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) { @@ -443,6 +456,7 @@ 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) { @@ -453,6 +467,7 @@ kvbuf_get_len(const char *p) return ntohl(x); } +LIBINFO_EXPORT void kvbuf_add_val(kvbuf_t *kv, const char *val) { @@ -462,6 +477,7 @@ 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) { @@ -470,6 +486,7 @@ kvbuf_make_purgeable(kvbuf_t *kv) if (kv->databuf != NULL) malloc_make_purgeable(kv->databuf); } +LIBINFO_EXPORT int kvbuf_make_nonpurgeable(kvbuf_t *kv) { @@ -485,6 +502,7 @@ kvbuf_make_nonpurgeable(kvbuf_t *kv) return 1; } +LIBINFO_EXPORT void kvbuf_free(kvbuf_t *kv) { @@ -496,6 +514,7 @@ 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) { @@ -532,6 +551,7 @@ kvbuf_append_kvbuf(kvbuf_t *kv, const kvbuf_t *kv2) } /* returns number of dictionaries */ +LIBINFO_EXPORT uint32_t kvbuf_reset(kvbuf_t *kv) { @@ -553,6 +573,7 @@ kvbuf_reset(kvbuf_t *kv) } /* advance to next dictionary, returns key count */ +LIBINFO_EXPORT uint32_t kvbuf_next_dict(kvbuf_t *kv) { @@ -629,6 +650,7 @@ 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) { @@ -715,12 +737,14 @@ 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) { @@ -774,6 +798,7 @@ 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) { @@ -935,6 +960,7 @@ kvbuf_decode(kvbuf_t *kv) return a; } +LIBINFO_EXPORT void kvarray_free(kvarray_t *a) { diff --git a/lookup.subproj/libinfo.c b/lookup.subproj/libinfo.c index e263f03..1a97cf7 100755 --- a/lookup.subproj/libinfo.c +++ b/lookup.subproj/libinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2015 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -88,6 +90,7 @@ si_search_file(void) return search; } +LIBINFO_EXPORT si_mod_t * si_search(void) { @@ -98,6 +101,7 @@ si_search(void) return search; } +LIBINFO_EXPORT void si_search_module_set_flags(const char *name, uint32_t flag) { @@ -196,6 +200,7 @@ si_libinfo_general_callback(si_item_t *item, uint32_t status, void *ctx) /* USER */ +LIBINFO_EXPORT struct passwd * getpwnam(const char *name) { @@ -241,6 +246,7 @@ getpwnam_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct passwd * getpwuid(uid_t uid) { @@ -307,6 +313,7 @@ getpwuid_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct passwd * getpwuuid(uuid_t uuid) { @@ -325,6 +332,7 @@ getpwuuid(uuid_t uuid) return (struct passwd *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void setpwent(void) { @@ -335,6 +343,7 @@ setpwent(void) LI_set_thread_list(CATEGORY_USER, NULL); } +LIBINFO_EXPORT struct passwd * getpwent(void) { @@ -358,6 +367,7 @@ getpwent(void) return (struct passwd *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endpwent(void) { @@ -368,6 +378,7 @@ endpwent(void) LI_set_thread_list(CATEGORY_USER, NULL); } +LIBINFO_EXPORT int setpassent(int ignored) { @@ -386,6 +397,7 @@ setpassent(int ignored) /* GROUP */ +LIBINFO_EXPORT struct group * getgrnam(const char *name) { @@ -432,6 +444,7 @@ getgrnam_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct group * getgrgid(gid_t gid) { @@ -478,6 +491,7 @@ getgruid_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct group * getgruuid(uuid_t uuid) { @@ -496,6 +510,7 @@ getgruuid(uuid_t uuid) return (struct group *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void setgrent(void) { @@ -506,6 +521,7 @@ setgrent(void) LI_set_thread_list(CATEGORY_GROUP, NULL); } +LIBINFO_EXPORT struct group * getgrent(void) { @@ -529,6 +545,7 @@ getgrent(void) return (struct group *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endgrent(void) { @@ -539,6 +556,7 @@ endgrent(void) LI_set_thread_list(CATEGORY_GROUP, NULL); } +LIBINFO_EXPORT int setgroupent(int ignored) { @@ -556,6 +574,7 @@ setgroupent(int ignored) } /* NETGROUP */ +LIBINFO_EXPORT int innetgr(const char *group, const char *host, const char *user, const char *domain) { @@ -579,6 +598,7 @@ innetgr(const char *group, const char *host, const char *user, const char *domai * 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) { @@ -594,6 +614,7 @@ setnetgrent(const char *name) /* N.B. there is no async getnetgrent */ +LIBINFO_EXPORT int getnetgrent(char **host, char **user, char **domain) { @@ -618,6 +639,7 @@ getnetgrent(char **host, char **user, char **domain) return 1; } +LIBINFO_EXPORT void endnetgrent(void) { @@ -722,6 +744,7 @@ getgrouplist_internal(const char *name, int basegid, gid_t *groups, uint32_t *ng return 0; } +LIBINFO_EXPORT int getgrouplist(const char *name, int basegid, int *groups, int *ngroups) { @@ -781,6 +804,7 @@ _getgrouplist_2_internal(const char *name, gid_t basegid, gid_t **groups) return count; } +LIBINFO_EXPORT int32_t getgrouplist_2(const char *name, gid_t basegid, gid_t **groups) { @@ -804,6 +828,7 @@ 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) { @@ -827,6 +852,7 @@ getgroupcount(const char *name, gid_t basegid) /* XXX to do: async getgrouplist_2 */ +LIBINFO_EXPORT int initgroups(const char *name, int basegid) { @@ -875,6 +901,7 @@ initgroups(const char *name, int basegid) /* ALIAS */ +LIBINFO_EXPORT struct aliasent * alias_getbyname(const char *name) { @@ -921,6 +948,7 @@ alias_getbyname_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT void alias_setent(void) { @@ -931,6 +959,7 @@ alias_setent(void) LI_set_thread_list(CATEGORY_ALIAS, NULL); } +LIBINFO_EXPORT struct aliasent * alias_getent(void) { @@ -954,6 +983,7 @@ alias_getent(void) return (struct aliasent *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void alias_endent(void) { @@ -966,6 +996,7 @@ alias_endent(void) /* HOST */ +LIBINFO_EXPORT void freehostent(struct hostent *h) { @@ -1002,6 +1033,7 @@ gethostbynameerrno(const char *name, int *err) return (struct hostent *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT struct hostent * gethostbyname(const char *name) { @@ -1049,12 +1081,14 @@ gethostbyname_async_call(const char *name, si_host_async_callback callback, void 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) { @@ -1080,6 +1114,7 @@ gethostbyname_async_handle_reply(void *param) } #endif +LIBINFO_EXPORT void gethostbyname_async_handleReply(void *param) { @@ -1093,6 +1128,7 @@ gethostbyname_async_handleReply(void *param) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct hostent * gethostbyname2(const char *name, int af) { @@ -1169,6 +1205,7 @@ gethostbyname2_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct hostent * gethostbyaddr(const void *addr, socklen_t len, int type) { @@ -1214,6 +1251,7 @@ gethostbyaddr_async_call(const void *addr, socklen_t len, int type, si_host_asyn 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) { @@ -1222,6 +1260,7 @@ gethostbyaddr_async_start(const char *addr, int len, int family, si_host_async_c return gethostbyaddr_async_call(addr, slen, family, callback, context); } +LIBINFO_EXPORT void gethostbyaddr_async_cancel(mach_port_t p) { @@ -1248,6 +1287,7 @@ gethostbyaddr_async_handle_reply(void *param) } #endif +LIBINFO_EXPORT void gethostbyaddr_async_handleReply(void *param) { @@ -1261,6 +1301,7 @@ gethostbyaddr_async_handleReply(void *param) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct hostent * getipnodebyname(const char *name, int family, int flags, int *err) { @@ -1393,6 +1434,7 @@ is_a4_compat(const char *s) return 1; } +LIBINFO_EXPORT struct hostent * getipnodebyaddr(const void *src, size_t len, int family, int *err) { @@ -1516,6 +1558,7 @@ getipnodebyaddr_async_handleReply(mach_msg_header_t *msg) } #endif +LIBINFO_EXPORT void sethostent(int ignored) { @@ -1526,6 +1569,7 @@ sethostent(int ignored) LI_set_thread_list(CATEGORY_HOST, NULL); } +LIBINFO_EXPORT struct hostent * gethostent(void) { @@ -1549,6 +1593,7 @@ gethostent(void) return (struct hostent *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endhostent(void) { @@ -1561,6 +1606,7 @@ endhostent(void) /* MAC ADDRESS */ +LIBINFO_EXPORT int ether_hostton(const char *name, struct ether_addr *e) { @@ -1591,6 +1637,7 @@ 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) { @@ -1623,6 +1670,7 @@ ether_ntohost(char *name, const struct ether_addr *e) /* NETWORK */ +LIBINFO_EXPORT struct netent * getnetbyname(const char *name) { @@ -1669,6 +1717,7 @@ getnetbyname_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct netent * getnetbyaddr(uint32_t net, int type) { @@ -1719,6 +1768,7 @@ getnetbyaddr_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT void setnetent(int ignored) { @@ -1729,6 +1779,7 @@ setnetent(int ignored) LI_set_thread_list(CATEGORY_NETWORK, NULL); } +LIBINFO_EXPORT struct netent * getnetent(void) { @@ -1752,6 +1803,7 @@ getnetent(void) return (struct netent *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endnetent(void) { @@ -1764,6 +1816,7 @@ endnetent(void) /* SERVICE */ +LIBINFO_EXPORT struct servent * getservbyname(const char *name, const char *proto) { @@ -1810,6 +1863,7 @@ getservbyname_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct servent * getservbyport(int port, const char *proto) { @@ -1856,6 +1910,7 @@ getservbyport_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT void setservent(int ignored) { @@ -1866,6 +1921,7 @@ setservent(int ignored) LI_set_thread_list(CATEGORY_SERVICE, NULL); } +LIBINFO_EXPORT struct servent * getservent(void) { @@ -1889,6 +1945,7 @@ getservent(void) return (struct servent *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endservent(void) { @@ -1901,6 +1958,7 @@ endservent(void) /* PROTOCOL */ +LIBINFO_EXPORT struct protoent * getprotobyname(const char *name) { @@ -1947,6 +2005,7 @@ getprotobyname_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct protoent * getprotobynumber(int number) { @@ -1993,6 +2052,7 @@ getprotobynumber_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT void setprotoent(int ignored) { @@ -2003,6 +2063,7 @@ setprotoent(int ignored) LI_set_thread_list(CATEGORY_PROTOCOL, NULL); } +LIBINFO_EXPORT struct protoent * getprotoent(void) { @@ -2026,6 +2087,7 @@ getprotoent(void) return (struct protoent *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endprotoent(void) { @@ -2038,6 +2100,7 @@ endprotoent(void) /* RPC */ +LIBINFO_EXPORT struct rpcent * getrpcbyname(const char *name) { @@ -2084,6 +2147,7 @@ getrpcbyname_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct rpcent * getrpcbynumber ( @@ -2137,6 +2201,7 @@ getrpcbynumber_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT void setrpcent(int ignored) { @@ -2147,6 +2212,7 @@ setrpcent(int ignored) LI_set_thread_list(CATEGORY_RPC, NULL); } +LIBINFO_EXPORT struct rpcent * getrpcent(void) { @@ -2170,6 +2236,7 @@ getrpcent(void) return (struct rpcent *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endrpcent(void) { @@ -2182,6 +2249,7 @@ endrpcent(void) /* FS */ +LIBINFO_EXPORT struct fstab * getfsspec(const char *spec) { @@ -2238,6 +2306,7 @@ getfsspec_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT struct fstab * getfsfile(const char *file) { @@ -2284,6 +2353,7 @@ getfsfile_async_handle_reply(mach_msg_header_t *msg) si_async_handle_reply(msg); } +LIBINFO_EXPORT int setfsent(void) { @@ -2295,6 +2365,7 @@ setfsent(void) return 1; } +LIBINFO_EXPORT struct fstab * getfsent(void) { @@ -2318,6 +2389,7 @@ getfsent(void) return (struct fstab *)((uintptr_t)item + sizeof(si_item_t)); } +LIBINFO_EXPORT void endfsent(void) { @@ -2389,6 +2461,7 @@ _getaddrinfo_internal(const char *nodename, const char *servname, const struct a return status; } +LIBINFO_EXPORT int getaddrinfo(const char *nodename, const char *servname, const struct addrinfo *hints, struct addrinfo **res) { @@ -2614,6 +2687,7 @@ si_libinfo_addrinfo_callback(si_list_t *list, uint32_t status, void *ctx) } /* 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) { @@ -2656,6 +2730,7 @@ getaddrinfo_async_call(const char *nodename, const char *servname, const struct 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) { @@ -2667,12 +2742,14 @@ getaddrinfo_async_start(mach_port_t *p, const char *nodename, const char *servna 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) { @@ -2680,6 +2757,7 @@ getaddrinfo_async_receive(mach_port_t p, struct addrinfo **res) return EAI_SYSTEM; } +LIBINFO_EXPORT void getaddrinfo_async_cancel(mach_port_t p) { @@ -2690,6 +2768,7 @@ getaddrinfo_async_cancel(mach_port_t p) si_async_cancel(p); } +LIBINFO_EXPORT int32_t getaddrinfo_async_handle_reply(void *param) { @@ -2777,6 +2856,7 @@ _getnameinfo_interface_internal(const struct sockaddr *sa, socklen_t salen, char 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) { @@ -2832,6 +2912,7 @@ si_libinfo_nameinfo_callback(si_item_t *item, uint32_t status, void *ctx) } /* 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) { @@ -2861,6 +2942,7 @@ getnameinfo_async_call(const struct sockaddr *sa, size_t len, int flags, si_name 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) { @@ -2871,12 +2953,14 @@ getnameinfo_async_start(mach_port_t *p, const struct sockaddr *sa, size_t salen, 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) { @@ -2887,6 +2971,7 @@ getnameinfo_async_cancel(mach_port_t p) si_async_cancel(p); } +LIBINFO_EXPORT int32_t getnameinfo_async_handle_reply(void *param) { @@ -3075,6 +3160,7 @@ copy_group_r(struct group *in, struct group *out, char *buffer, int buflen) return 0; } +LIBINFO_EXPORT int getgrnam_r(const char *name, struct group *grp, char *buffer, size_t bufsize, struct group **result) { @@ -3104,6 +3190,7 @@ getgrnam_r(const char *name, struct group *grp, char *buffer, size_t bufsize, st return 0; } +LIBINFO_EXPORT int getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t bufsize, struct group **result) { @@ -3133,6 +3220,7 @@ getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t bufsize, struct gr return 0; } +LIBINFO_EXPORT int getgruuid_r(uuid_t uuid, struct group *grp, char *buffer, size_t bufsize, struct group **result) { @@ -3164,6 +3252,7 @@ getgruuid_r(uuid_t uuid, struct group *grp, char *buffer, size_t bufsize, struct return 0; } +LIBINFO_EXPORT int getpwnam_r(const char *name, struct passwd *pw, char *buffer, size_t bufsize, struct passwd **result) { @@ -3193,6 +3282,7 @@ getpwnam_r(const char *name, struct passwd *pw, char *buffer, size_t bufsize, st return 0; } +LIBINFO_EXPORT int getpwuid_r(uid_t uid, struct passwd *pw, char *buffer, size_t bufsize, struct passwd **result) { @@ -3229,6 +3319,7 @@ getpwuid_r(uid_t uid, struct passwd *pw, char *buffer, size_t bufsize, struct pa return 0; } +LIBINFO_EXPORT int getpwuuid_r(uuid_t uuid, struct passwd *pw, char *buffer, size_t bufsize, struct passwd **result) { @@ -3262,6 +3353,7 @@ getpwuuid_r(uuid_t uuid, struct passwd *pw, char *buffer, size_t bufsize, struct /* misc */ +LIBINFO_EXPORT char * user_from_uid(uid_t uid, int nouser) { @@ -3277,6 +3369,7 @@ user_from_uid(uid_t uid, int nouser) return buf; } +LIBINFO_EXPORT char * group_from_gid(gid_t gid, int nogroup) { @@ -3294,6 +3387,7 @@ group_from_gid(gid_t gid, int nogroup) /* no longer supported */ +LIBINFO_EXPORT const prdb_ent * prdb_getbyname(const char *name) { @@ -3303,6 +3397,7 @@ prdb_getbyname(const char *name) return NULL; } +LIBINFO_EXPORT const prdb_ent * prdb_get(void) { @@ -3312,6 +3407,7 @@ prdb_get(void) return NULL; } +LIBINFO_EXPORT void prdb_set(const char *name) { @@ -3320,6 +3416,7 @@ prdb_set(const char *name) #endif } +LIBINFO_EXPORT void prdb_end(void) { @@ -3328,6 +3425,7 @@ prdb_end(void) #endif } +LIBINFO_EXPORT struct bootparamsent * bootparams_getbyname(const char *name) { @@ -3337,6 +3435,7 @@ bootparams_getbyname(const char *name) return NULL; } +LIBINFO_EXPORT struct bootparamsent * bootparams_getent(void) { @@ -3346,6 +3445,7 @@ bootparams_getent(void) return NULL; } +LIBINFO_EXPORT void bootparams_setent(void) { @@ -3354,6 +3454,7 @@ bootparams_setent(void) #endif } +LIBINFO_EXPORT void bootparams_endent(void) { diff --git a/lookup.subproj/mdns_module.c b/lookup.subproj/mdns_module.c index af65bff..34468a8 100644 --- a/lookup.subproj/mdns_module.c +++ b/lookup.subproj/mdns_module.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2015 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -98,6 +98,7 @@ #include #include #include +#include #include #include #include @@ -182,6 +183,7 @@ static DNSServiceRef _mdns_old_sdref; 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"; @@ -229,7 +231,7 @@ _mdns_debug_message(const char *str, ...) } static char * -_mdns_reverse_ipv4(const char *addr) +_mdns_reverse_ipv4(const uint8_t *addr) { union { @@ -247,7 +249,7 @@ _mdns_reverse_ipv4(const char *addr) } static char * -_mdns_reverse_ipv6(const char *addr) +_mdns_reverse_ipv6(const uint8_t *addr) { char x[65], *p; int i, j; @@ -496,6 +498,64 @@ mdns_hostbyname(si_mod_t *si, const char *name, int af, const char *interface, u 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) { @@ -507,6 +567,7 @@ mdns_hostbyaddr(si_mod_t *si, const void *addr, int af, const char *interface, u int cat; int status; DNSServiceFlags flags = 0; + uint32_t ifindex = 0; if (err != NULL) *err = SI_STATUS_NO_ERROR; @@ -522,17 +583,61 @@ mdns_hostbyaddr(si_mod_t *si, const void *addr, int af, const char *interface, u 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 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; @@ -542,7 +647,14 @@ mdns_hostbyaddr(si_mod_t *si, const void *addr, int af, const char *interface, u _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) { @@ -1155,7 +1267,7 @@ _mdns_query_callback(DNSServiceRef, DNSServiceFlags, uint32_t, DNSServiceErrorTy * 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; @@ -1195,20 +1307,14 @@ _mdns_query_start(mdns_query_context_t *ctx, mdns_reply_t *reply, uint8_t *answe 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); @@ -1636,8 +1742,29 @@ _mdns_timeout(struct timespec *timeout, const struct timespec *deadline) _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; @@ -1743,12 +1870,12 @@ _mdns_search(const char *name, int class, int type, const char *interface, DNSSe */ 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); diff --git a/lookup.subproj/netdb_async.h b/lookup.subproj/netdb_async.h index 6fd7bbf..8633ee3 100644 --- a/lookup.subproj/netdb_async.h +++ b/lookup.subproj/netdb_async.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002-2009 Apple Inc. All rights reserved. + * Copyright (c) 2002-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -30,8 +30,10 @@ #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 @@ -57,10 +59,13 @@ void getaddrinfo_async_cancel(mach_port_t p); 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 */ @@ -70,6 +75,7 @@ int32_t dns_async_send(mach_port_t *p, const char *name, uint16_t dnsclass, uint 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 @@ -165,6 +171,7 @@ void gethostbyname_async_cancel(mach_port_t port); */ 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 @@ -261,6 +268,7 @@ void getipnodebyname_async_cancel(mach_port_t port); @param replyMsg The Mach message. */ void getipnodebyname_async_handleReply(void *replyMsg); +#endif // !LIBINFO_INSTALL_API __END_DECLS diff --git a/lookup.subproj/si_compare.c b/lookup.subproj/si_compare.c new file mode 100644 index 0000000..e7e1994 --- /dev/null +++ b/lookup.subproj/si_compare.c @@ -0,0 +1,1115 @@ +// +// si_compare.c +// Libinfo +// +// Copyright (c) 2011-2017 Apple Inc. All rights reserved. +// +// + +#include "si_compare.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +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 + 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) + { + // 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; +} diff --git a/lookup.subproj/si_compare.h b/lookup.subproj/si_compare.h new file mode 100644 index 0000000..f454814 --- /dev/null +++ b/lookup.subproj/si_compare.h @@ -0,0 +1,65 @@ +// +// si_compare.h +// Libinfo +// +// Copyright (c) 2011-2017 Apple Inc. All rights reserved. +// + +#ifndef __SI_COMPARE_H__ +#define __SI_COMPARE_H__ + +#include +#include +#include +#include + + +__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__ diff --git a/lookup.subproj/si_data.c b/lookup.subproj/si_data.c index d93aafd..302cbad 100644 --- a/lookup.subproj/si_data.c +++ b/lookup.subproj/si_data.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2015 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -28,6 +30,7 @@ #include "si_data.h" #include "si_module.h" +LIBINFO_EXPORT si_list_t * si_list_add(si_list_t *l, si_item_t *e) { @@ -59,6 +62,7 @@ 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) { @@ -105,6 +109,7 @@ 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) { @@ -114,12 +119,14 @@ 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) { @@ -133,6 +140,7 @@ si_list_retain(si_list_t *list) return list; } +LIBINFO_EXPORT void si_list_release(si_list_t *list) { @@ -155,6 +163,7 @@ si_list_release(si_list_t *list) } } +LIBINFO_EXPORT si_item_t * si_item_retain(si_item_t *item) { @@ -168,6 +177,7 @@ si_item_retain(si_item_t *item) return item; } +LIBINFO_EXPORT void si_item_release(si_item_t *item) { diff --git a/lookup.subproj/si_getaddrinfo.c b/lookup.subproj/si_getaddrinfo.c index 6feaa51..6f6930c 100644 --- a/lookup.subproj/si_getaddrinfo.c +++ b/lookup.subproj/si_getaddrinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2015 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,9 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + +#include #include #include #include @@ -29,9 +32,7 @@ #include #include #include -#include -#include -#include +#include #include #include #include @@ -42,6 +43,7 @@ #include #include #include "netdb_async.h" +#include "si_compare.h" #include "si_module.h" #define SOCK_UNSPEC 0 @@ -62,6 +64,7 @@ static int net_config_token = -1; 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); @@ -73,6 +76,20 @@ typedef struct { 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) { @@ -135,6 +152,7 @@ si_inet_config(uint32_t *inet4, uint32_t *inet6) return status; } +LIBINFO_EXPORT void freeaddrinfo(struct addrinfo *a) { @@ -150,6 +168,7 @@ freeaddrinfo(struct addrinfo *a) } } +LIBINFO_EXPORT const char * gai_strerror(int32_t err) { @@ -185,6 +204,7 @@ 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) { @@ -425,6 +445,7 @@ _gai_numericserv(const char *serv, uint16_t *port) return numeric; } +LIBINFO_EXPORT int _gai_serv_to_port(const char *serv, uint32_t proto, uint16_t *port) { @@ -447,6 +468,7 @@ _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) { @@ -472,6 +494,7 @@ si_addrinfo_v4(si_mod_t *si, int32_t flags, int32_t sock, int32_t proto, uint16_ 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) { @@ -498,6 +521,7 @@ si_addrinfo_v4_mapped(si_mod_t *si, int32_t flags, int32_t sock, int32_t proto, } +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) { @@ -533,6 +557,7 @@ si_addrinfo_v6(si_mod_t *si, int32_t flags, int32_t sock, int32_t proto, uint16_ 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) { @@ -728,6 +753,7 @@ _gai_numerichost(const char* nodename, uint32_t *family, int flags, struct in_ad /* 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) { @@ -779,11 +805,11 @@ _gai_addr_sort(const void *a, const void *b) 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 * @@ -863,6 +889,7 @@ _gai_sort_list(si_list_t *in, uint32_t flags) /* _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) { @@ -930,6 +957,7 @@ _gai_simple(si_mod_t *si, const void *nodeptr, const void *servptr, uint32_t fam 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) { @@ -939,6 +967,7 @@ si_srv_byname(si_mod_t *si, const char *qname, const char *interface, uint32_t * return si->vtable->sim_srv_byname(si, qname, interface, err); } +LIBINFO_EXPORT int si_wants_addrinfo(si_mod_t *si) { @@ -1030,6 +1059,116 @@ _gai_srv(si_mod_t *si, const char *node, const char *serv, uint32_t family, uint 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) @@ -1059,11 +1198,9 @@ _gai_nat64_synthesis(si_mod_t *si, const char *node, const void *servptr, int nu } /* 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; @@ -1102,23 +1239,17 @@ _gai_nat64_synthesis(si_mod_t *si, const char *node, const void *servptr, int nu } /* 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; @@ -1134,7 +1265,7 @@ _gai_nat64_synthesis(si_mod_t *si, const char *node, const void *servptr, int nu } } - free(prefixes); + free(synthesized); /* return to standard code path if no NAT64 addresses could be synthesized */ if (NULL == out_list) @@ -1213,13 +1344,10 @@ _gai_nat64_second_pass(si_list_t *out, si_mod_t *si, const char *serv, uint32_t 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))) @@ -1227,31 +1355,6 @@ _gai_nat64_second_pass(si_list_t *out, si_mod_t *si, const char *serv, uint32_t 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) @@ -1276,6 +1379,9 @@ _gai_nat64_second_pass(si_list_t *out, si_mod_t *si, const char *serv, uint32_t 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) { @@ -1717,6 +1823,7 @@ free_build_hostent(build_hostent_t *h) 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) { diff --git a/lookup.subproj/si_module.c b/lookup.subproj/si_module.c index 0c3a998..fdb5561 100644 --- a/lookup.subproj/si_module.c +++ b/lookup.subproj/si_module.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2011 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -169,6 +171,7 @@ si_module_with_path(const char *path, const char *name) return out; } +LIBINFO_EXPORT si_mod_t * si_module_with_name(const char *name) { @@ -255,6 +258,7 @@ si_module_with_name(const char *name) return si; } +LIBINFO_EXPORT si_mod_t * si_module_retain(si_mod_t *si) { @@ -266,6 +270,7 @@ si_module_retain(si_mod_t *si) return si; } +LIBINFO_EXPORT void si_module_release(si_mod_t *si) { @@ -308,6 +313,7 @@ si_module_release(si_mod_t *si) free(si); } +LIBINFO_EXPORT const char * si_module_name(si_mod_t *si) { @@ -316,6 +322,7 @@ si_module_name(si_mod_t *si) return (const char *)si->name; } +LIBINFO_EXPORT int si_module_vers(si_mod_t *si) { @@ -324,6 +331,7 @@ 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) { @@ -496,6 +504,7 @@ si_item_match(si_item_t *item, int cat, const void *name, uint32_t num, int whic return 0; } +LIBINFO_EXPORT int si_item_is_valid(si_item_t *item) { @@ -511,6 +520,7 @@ 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) { @@ -519,6 +529,7 @@ 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) { @@ -527,6 +538,7 @@ 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) { @@ -535,6 +547,7 @@ 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) { @@ -543,6 +556,7 @@ 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) { @@ -551,6 +565,7 @@ 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) { @@ -559,6 +574,7 @@ 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) { @@ -567,6 +583,7 @@ 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) { @@ -575,6 +592,7 @@ 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) { @@ -583,6 +601,7 @@ 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) { @@ -591,6 +610,7 @@ 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) { @@ -599,6 +619,7 @@ si_in_netgroup(struct si_mod_s *si, const char *name, const char *host, const ch 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) { @@ -607,6 +628,7 @@ 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) { @@ -615,6 +637,7 @@ 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) { @@ -623,6 +646,7 @@ si_host_byname(si_mod_t *si, const char *name, int af, const char *interface, ui 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) { @@ -631,6 +655,7 @@ si_host_byaddr(si_mod_t *si, const void *addr, int af, const char *interface, ui return si->vtable->sim_host_byaddr(si, addr, af, interface, err); } +LIBINFO_EXPORT si_list_t * si_host_all(si_mod_t *si) { @@ -639,6 +664,7 @@ 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) { @@ -647,6 +673,7 @@ 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) { @@ -655,6 +682,7 @@ 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) { @@ -663,6 +691,7 @@ 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) { @@ -671,6 +700,7 @@ 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) { @@ -679,6 +709,7 @@ 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) { @@ -687,6 +718,7 @@ 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) { @@ -695,6 +727,7 @@ 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) { @@ -703,6 +736,7 @@ 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) { @@ -711,6 +745,7 @@ 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) { @@ -719,6 +754,7 @@ 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) { @@ -727,6 +763,7 @@ 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) { @@ -735,6 +772,7 @@ 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) { @@ -743,6 +781,7 @@ 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) { @@ -751,6 +790,7 @@ 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) { @@ -759,6 +799,7 @@ 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) { @@ -767,6 +808,7 @@ 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) { @@ -775,6 +817,7 @@ 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) { @@ -783,6 +826,7 @@ 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) { @@ -827,6 +871,7 @@ si_item_call(struct si_mod_s *si, int call, const char *str1, const char *str2, 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) { @@ -1067,7 +1112,7 @@ si_async_launchpad(si_async_workunit_t *r) 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)); @@ -1088,6 +1133,7 @@ si_async_launchpad(si_async_workunit_t *r) #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) { @@ -1114,6 +1160,7 @@ si_async_call(struct si_mod_s *si, int call, const char *str1, const char *str2, return req->port; } +LIBINFO_EXPORT void si_async_cancel(mach_port_t p) { @@ -1153,6 +1200,7 @@ si_async_cancel(mach_port_t p) si_async_workunit_release(r); } +LIBINFO_EXPORT void si_async_handle_reply(mach_msg_header_t *msg) { @@ -1197,6 +1245,7 @@ si_async_handle_reply(mach_msg_header_t *msg) si_async_workunit_release(r); } +LIBINFO_EXPORT char * si_standardize_mac_address(const char *addr) { diff --git a/lookup.subproj/si_module.h b/lookup.subproj/si_module.h index a87c629..51d5baa 100644 --- a/lookup.subproj/si_module.h +++ b/lookup.subproj/si_module.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008-2011 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -24,6 +24,7 @@ #ifndef __SI_MODULE_H__ #define __SI_MODULE_H__ +#include #include #include #include @@ -42,6 +43,8 @@ #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 @@ -367,6 +370,12 @@ si_list_t *si_addrinfo_list_from_hostent(si_mod_t *si, uint32_t flags, uint32_t 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__ */ diff --git a/lookup.subproj/thread_data.c b/lookup.subproj/thread_data.c index d7aa02a..32c3067 100644 --- a/lookup.subproj/thread_data.c +++ b/lookup.subproj/thread_data.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008 Apple Inc. All rights reserved. + * Copyright (c) 2008-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -21,6 +21,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -162,6 +164,7 @@ LI_get_thread_info(uint32_t key) return tdata; } +LIBINFO_EXPORT si_item_t * LI_get_thread_item(uint32_t key) { @@ -173,6 +176,7 @@ LI_get_thread_item(uint32_t key) return tdata->thread_item; } +LIBINFO_EXPORT si_list_t * LI_get_thread_list(uint32_t key) { @@ -184,6 +188,7 @@ 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) { @@ -196,6 +201,7 @@ 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) { diff --git a/membership.subproj/membership.c b/membership.subproj/membership.c index e678d96..55c6a3e 100644 --- a/membership.subproj/membership.c +++ b/membership.subproj/membership.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2015 Apple Inc. All rights reserved. + * Copyright (c) 2004-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -20,6 +20,8 @@ * @APPLE_LICENSE_HEADER_END@ */ +#include "libinfo_common.h" + #include #include #include @@ -231,6 +233,7 @@ compatibility_name_for_uuid(const uuid_t uu, char **result, int *rec_type) } #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) { @@ -401,18 +404,21 @@ mbr_identifier_translate(int id_type, const void *identifier, size_t identifier_ 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) { @@ -443,6 +449,7 @@ 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) { @@ -453,6 +460,7 @@ 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) { @@ -499,6 +507,7 @@ mbr_identifier_to_uuid(int id_type, const void *identifier, size_t identifier_si return rc; } +LIBINFO_EXPORT int mbr_uuid_to_sid_type(const uuid_t uu, nt_sid_t *sid, int *id_type) { @@ -535,6 +544,7 @@ 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) { @@ -552,18 +562,21 @@ 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) { @@ -622,12 +635,14 @@ mbr_check_membership_ext(int userid_type, const void *userid, size_t userid_size #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() { @@ -640,18 +655,21 @@ 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) { @@ -711,6 +729,7 @@ ConvertBytesToDecimal(char *buffer, unsigned long long value) } #endif +LIBINFO_EXPORT int mbr_sid_to_string(const nt_sid_t *sid, char *string) { @@ -748,6 +767,7 @@ 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) { @@ -804,6 +824,7 @@ mbr_string_to_uuid(const char *string, uuid_t uu) 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) { diff --git a/membership.subproj/membershipPriv.h b/membership.subproj/membershipPriv.h index 348f78c..270890c 100644 --- a/membership.subproj/membershipPriv.h +++ b/membership.subproj/membershipPriv.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004 Apple Computer, Inc. All rights reserved. + * Copyright (c) 2004-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -25,6 +25,7 @@ #include #include +#include #define MBR_UU_STRING_SIZE 37 #define MBR_MAX_SID_STRING_SIZE 200 @@ -49,10 +50,10 @@ int mbr_check_membership_by_id(uuid_t user, gid_t group, int *ismember); 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); diff --git a/nis.subproj/getdomainname.c b/nis.subproj/getdomainname.c index 853cc67..5fb7a0f 100644 --- a/nis.subproj/getdomainname.c +++ b/nis.subproj/getdomainname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -25,9 +25,12 @@ * cover for getdomainname() * Copyright (C) 1995 by NeXT Computer, Inc. */ +#include "libinfo_common.h" + #include #include +LIBINFO_EXPORT int getdomainname(char *val, int inlen) { diff --git a/nis.subproj/setdomainname.c b/nis.subproj/setdomainname.c index 1541c01..11c8d6f 100644 --- a/nis.subproj/setdomainname.c +++ b/nis.subproj/setdomainname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -25,11 +25,14 @@ * cover for getdomainname() * Copyright (C) 1995 by NeXT Computer, Inc. */ +#include "libinfo_common.h" + #include #include +LIBINFO_EXPORT int -setdomainname(const char *name, size_t namelen) +setdomainname(const char *name, int namelen) { int mib[2]; diff --git a/nis.subproj/xdr_domainname.c b/nis.subproj/xdr_domainname.c index 5308c1e..7647c74 100644 --- a/nis.subproj/xdr_domainname.c +++ b/nis.subproj/xdr_domainname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_domainname.c,v 1.3 1996/08/19 08:34:58 tholo #include #include +LIBINFO_EXPORT bool_t xdr_domainname(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_keydat.c b/nis.subproj/xdr_keydat.c index 9e0c6f0..ba9964e 100644 --- a/nis.subproj/xdr_keydat.c +++ b/nis.subproj/xdr_keydat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_keydat.c,v 1.4 1996/08/19 08:34:58 tholo Exp #include #include +LIBINFO_EXPORT bool_t xdr_keydat(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_mapname.c b/nis.subproj/xdr_mapname.c index 6c4323a..397f944 100644 --- a/nis.subproj/xdr_mapname.c +++ b/nis.subproj/xdr_mapname.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_mapname.c,v 1.3 1996/08/19 08:34:59 tholo Ex #include #include +LIBINFO_EXPORT bool_t xdr_mapname(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_peername.c b/nis.subproj/xdr_peername.c index 7c4726d..254e4c5 100644 --- a/nis.subproj/xdr_peername.c +++ b/nis.subproj/xdr_peername.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_peername.c,v 1.3 1996/08/19 08:34:59 tholo E #include #include +LIBINFO_EXPORT bool_t xdr_peername(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_valdat.c b/nis.subproj/xdr_valdat.c index 1ab9024..c66acd0 100644 --- a/nis.subproj/xdr_valdat.c +++ b/nis.subproj/xdr_valdat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_valdat.c,v 1.4 1996/08/19 08:35:00 tholo Exp #include #include +LIBINFO_EXPORT bool_t xdr_valdat(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypbind_binding.c b/nis.subproj/xdr_ypbind_binding.c index 53b82fa..8797cff 100644 --- a/nis.subproj/xdr_ypbind_binding.c +++ b/nis.subproj/xdr_ypbind_binding.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypbind_binding.c,v 1.3 1996/08/19 08:35:00 t #include #include +LIBINFO_EXPORT bool_t xdr_ypbind_binding(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypbind_resp.c b/nis.subproj/xdr_ypbind_resp.c index 832973f..bd5e4e3 100644 --- a/nis.subproj/xdr_ypbind_resp.c +++ b/nis.subproj/xdr_ypbind_resp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypbind_resp.c,v 1.3 1996/08/19 08:35:01 thol #include #include +LIBINFO_EXPORT bool_t xdr_ypbind_resp(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypbind_resptype.c b/nis.subproj/xdr_ypbind_resptype.c index 12096e2..76f4804 100644 --- a/nis.subproj/xdr_ypbind_resptype.c +++ b/nis.subproj/xdr_ypbind_resptype.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypbind_resptype.c,v 1.3 1996/08/19 08:35:01 #include #include +LIBINFO_EXPORT bool_t xdr_ypbind_resptype(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypbind_setdom.c b/nis.subproj/xdr_ypbind_setdom.c index be681a2..42fc42c 100644 --- a/nis.subproj/xdr_ypbind_setdom.c +++ b/nis.subproj/xdr_ypbind_setdom.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypbind_setdom.c,v 1.3 1996/08/19 08:35:02 th #include #include +LIBINFO_EXPORT bool_t xdr_ypbind_setdom(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypmaplist.c b/nis.subproj/xdr_ypmaplist.c index 14a3544..3c03717 100644 --- a/nis.subproj/xdr_ypmaplist.c +++ b/nis.subproj/xdr_ypmaplist.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypmaplist.c,v 1.3 1996/08/19 08:35:02 tholo #include #include +LIBINFO_EXPORT bool_t xdr_ypmaplist(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypreq_key.c b/nis.subproj/xdr_ypreq_key.c index eababd8..d83e93f 100644 --- a/nis.subproj/xdr_ypreq_key.c +++ b/nis.subproj/xdr_ypreq_key.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypreq_key.c,v 1.3 1996/08/19 08:35:03 tholo #include #include +LIBINFO_EXPORT bool_t xdr_ypreq_key(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypreq_nokey.c b/nis.subproj/xdr_ypreq_nokey.c index b3e1552..02ed104 100644 --- a/nis.subproj/xdr_ypreq_nokey.c +++ b/nis.subproj/xdr_ypreq_nokey.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypreq_nokey.c,v 1.3 1996/08/19 08:35:03 thol #include #include +LIBINFO_EXPORT bool_t xdr_ypreq_nokey(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypresp_all.c b/nis.subproj/xdr_ypresp_all.c index cee7c8a..69f152e 100644 --- a/nis.subproj/xdr_ypresp_all.c +++ b/nis.subproj/xdr_ypresp_all.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypresp_all.c,v 1.3 1996/08/19 08:35:04 tholo #include #include +LIBINFO_EXPORT bool_t xdr_ypresp_all(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypresp_key_val.c b/nis.subproj/xdr_ypresp_key_val.c index dfb11b8..33e4829 100644 --- a/nis.subproj/xdr_ypresp_key_val.c +++ b/nis.subproj/xdr_ypresp_key_val.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypresp_key_val.c,v 1.3 1996/08/19 08:35:04 t #include #include +LIBINFO_EXPORT bool_t xdr_ypresp_key_val(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypresp_maplist.c b/nis.subproj/xdr_ypresp_maplist.c index db238de..00440ad 100644 --- a/nis.subproj/xdr_ypresp_maplist.c +++ b/nis.subproj/xdr_ypresp_maplist.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypresp_maplist.c,v 1.3 1996/08/19 08:35:05 t #include #include +LIBINFO_EXPORT bool_t xdr_ypresp_maplist(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypresp_master.c b/nis.subproj/xdr_ypresp_master.c index b844a40..3a557bf 100644 --- a/nis.subproj/xdr_ypresp_master.c +++ b/nis.subproj/xdr_ypresp_master.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypresp_master.c,v 1.3 1996/08/19 08:35:05 th #include #include +LIBINFO_EXPORT bool_t xdr_ypresp_master(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypresp_order.c b/nis.subproj/xdr_ypresp_order.c index 4660014..2506f96 100644 --- a/nis.subproj/xdr_ypresp_order.c +++ b/nis.subproj/xdr_ypresp_order.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypresp_order.c,v 1.3 1996/08/19 08:35:06 tho #include #include +LIBINFO_EXPORT bool_t xdr_ypresp_order(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypresp_val.c b/nis.subproj/xdr_ypresp_val.c index 26226e0..3ca84bd 100644 --- a/nis.subproj/xdr_ypresp_val.c +++ b/nis.subproj/xdr_ypresp_val.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypresp_val.c,v 1.3 1996/08/19 08:35:06 tholo #include #include +LIBINFO_EXPORT bool_t xdr_ypresp_val(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/xdr_ypstat.c b/nis.subproj/xdr_ypstat.c index 15a4842..1fa6b6d 100644 --- a/nis.subproj/xdr_ypstat.c +++ b/nis.subproj/xdr_ypstat.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -68,6 +70,7 @@ static char *rcsid = "$OpenBSD: xdr_ypstat.c,v 1.4 1996/12/14 06:49:45 tholo Exp #include #include +LIBINFO_EXPORT bool_t xdr_ypstat(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/yp_all.c b/nis.subproj/yp_all.c index 645df97..d5eb978 100644 --- a/nis.subproj/yp_all.c +++ b/nis.subproj/yp_all.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -75,6 +77,7 @@ static char *rcsid = "$OpenBSD: yp_all.c,v 1.5 1996/12/14 06:49:46 tholo Exp $"; 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; @@ -146,6 +149,7 @@ u_long *objp; } } +LIBINFO_EXPORT int yp_all(indomain, inmap, incallback) const char *indomain; diff --git a/nis.subproj/yp_bind.c b/nis.subproj/yp_bind.c index 14b20bb..aeb79a6 100644 --- a/nis.subproj/yp_bind.c +++ b/nis.subproj/yp_bind.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -57,6 +57,8 @@ 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 #include #include @@ -82,6 +84,7 @@ char _yp_domain[MAXHOSTNAMELEN] = { '\0' }; int _yplib_timeout = 10; +LIBINFO_EXPORT int _yp_dobind(dom, ypdb) const char *dom; @@ -294,6 +297,7 @@ _yp_unbind(ypb) ypb->dom_socket = -1; } +LIBINFO_EXPORT int yp_bind(dom) const char *dom; @@ -301,6 +305,7 @@ yp_bind(dom) return _yp_dobind(dom, NULL); } +LIBINFO_EXPORT void yp_unbind(dom) const char *dom; diff --git a/nis.subproj/yp_first.c b/nis.subproj/yp_first.c index 446d4b6..c07a2c1 100644 --- a/nis.subproj/yp_first.c +++ b/nis.subproj/yp_first.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -72,6 +74,7 @@ static char *rcsid = "$OpenBSD: yp_first.c,v 1.5 1996/12/03 08:20:03 deraadt Exp #include #include "ypinternal.h" +LIBINFO_EXPORT int yp_first(indomain, inmap, outkey, outkeylen, outval, outvallen) const char *indomain; diff --git a/nis.subproj/yp_get_default_domain.c b/nis.subproj/yp_get_default_domain.c index 373d1a4..687f788 100644 --- a/nis.subproj/yp_get_default_domain.c +++ b/nis.subproj/yp_get_default_domain.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -72,6 +74,7 @@ static char *rcsid = "$OpenBSD: yp_get_default_domain.c,v 1.3 1996/08/19 08:35:0 #include #include "ypinternal.h" +LIBINFO_EXPORT int yp_get_default_domain(domp) char **domp; diff --git a/nis.subproj/yp_maplist.c b/nis.subproj/yp_maplist.c index ef7894b..c60ce03 100644 --- a/nis.subproj/yp_maplist.c +++ b/nis.subproj/yp_maplist.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -72,6 +74,7 @@ static char *rcsid = "$OpenBSD: yp_maplist.c,v 1.5 1996/12/03 08:20:04 deraadt E #include #include "ypinternal.h" +LIBINFO_EXPORT int yp_maplist(indomain, outmaplist) const char *indomain; diff --git a/nis.subproj/yp_master.c b/nis.subproj/yp_master.c index 1e13be3..1b72321 100644 --- a/nis.subproj/yp_master.c +++ b/nis.subproj/yp_master.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -72,6 +74,7 @@ static char *rcsid = "$OpenBSD: yp_master.c,v 1.5 1996/12/03 08:20:05 deraadt Ex #include #include "ypinternal.h" +LIBINFO_EXPORT int yp_master(indomain, inmap, outname) const char *indomain; diff --git a/nis.subproj/yp_order.c b/nis.subproj/yp_order.c index 72946d7..3e95b5a 100644 --- a/nis.subproj/yp_order.c +++ b/nis.subproj/yp_order.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -72,6 +74,7 @@ static char *rcsid = "$OpenBSD: yp_order.c,v 1.5 1996/08/19 08:35:11 tholo Exp $ #include #include "ypinternal.h" +LIBINFO_EXPORT int yp_order(indomain, inmap, outorder) const char *indomain; diff --git a/nis.subproj/yp_prot.h b/nis.subproj/yp_prot.h index 94c7588..bf14d73 100644 --- a/nis.subproj/yp_prot.h +++ b/nis.subproj/yp_prot.h @@ -1,3 +1,6 @@ +/* + * Copyright (c) 2018 Apple Inc. All rights reserved. + */ /* * Copyright (c) 1992/3 Theo de Raadt * All rights reserved. @@ -31,6 +34,7 @@ #ifndef _RPCSVC_YP_PROT_H_ #define _RPCSVC_YP_PROT_H_ +#include /* * YPSERV PROTOCOL: @@ -313,11 +317,15 @@ struct yppushresp_xfr { __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 *)); @@ -328,7 +336,9 @@ bool_t xdr_ypresp_key_val __P((XDR *, struct ypresp_key_val *)); 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 *)); diff --git a/nis.subproj/yperr_string.c b/nis.subproj/yperr_string.c index 4b98ee6..cbb7b41 100644 --- a/nis.subproj/yperr_string.c +++ b/nis.subproj/yperr_string.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -71,6 +73,7 @@ static char *rcsid = "$OpenBSD: yperr_string.c,v 1.3 1996/08/19 08:35:12 tholo E #include #include +LIBINFO_EXPORT char * yperr_string(incode) int incode; diff --git a/nis.subproj/ypmatch_cache.c b/nis.subproj/ypmatch_cache.c index 19ae149..94173b8 100644 --- a/nis.subproj/ypmatch_cache.c +++ b/nis.subproj/ypmatch_cache.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -174,6 +176,7 @@ ypmatch_find(map, key, keylen, val, vallen) } #endif +LIBINFO_EXPORT int yp_match(indomain, inmap, inkey, inkeylen, outval, outvallen) const char *indomain; @@ -262,6 +265,7 @@ out: return r; } +LIBINFO_EXPORT int yp_next(indomain, inmap, inkey, inkeylen, outkey, outkeylen, outval, outvallen) const char *indomain; diff --git a/nis.subproj/yppasswdd_xdr.c b/nis.subproj/yppasswdd_xdr.c index 2d3fe2f..b660b1c 100644 --- a/nis.subproj/yppasswdd_xdr.c +++ b/nis.subproj/yppasswdd_xdr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -58,9 +58,12 @@ static char rcsid[] = "$OpenBSD: yppasswdd_xdr.c,v 1.4 1997/08/19 07:00:52 niklas Exp $"; #endif +#include "libinfo_common.h" + #include #include +LIBINFO_EXPORT bool_t xdr_x_passwd(xdrs, objp) XDR *xdrs; @@ -90,6 +93,7 @@ xdr_x_passwd(xdrs, objp) return (TRUE); } +LIBINFO_EXPORT bool_t xdr_yppasswd(xdrs, objp) XDR *xdrs; diff --git a/nis.subproj/ypprot_err.c b/nis.subproj/ypprot_err.c index 7c955fb..a6e080a 100644 --- a/nis.subproj/ypprot_err.c +++ b/nis.subproj/ypprot_err.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -56,6 +56,8 @@ 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 #include #include @@ -71,6 +73,7 @@ static char *rcsid = "$OpenBSD: ypprot_err.c,v 1.4 1996/12/14 06:49:47 tholo Exp #include #include +LIBINFO_EXPORT int ypprot_err(incode) unsigned int incode; diff --git a/rpc.subproj/auth.h b/rpc.subproj/auth.h index 1f9394e..6126919 100644 --- a/rpc.subproj/auth.h +++ b/rpc.subproj/auth.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -66,6 +66,8 @@ #ifndef _RPC_AUTH_H #define _RPC_AUTH_H +#include +#include #include #define MAX_AUTH_BYTES 400 @@ -201,9 +203,11 @@ __BEGIN_DECLS 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 */ diff --git a/rpc.subproj/auth_none.c b/rpc.subproj/auth_none.c index e2901a0..b205bb6 100644 --- a/rpc.subproj/auth_none.c +++ b/rpc.subproj/auth_none.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,6 +64,8 @@ static char *rcsid = "$Id: auth_none.c,v 1.3 2002/02/19 20:36:22 epeyton Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -97,6 +99,7 @@ static struct authnone_private { u_int mcnt; } *authnone_private; +LIBINFO_EXPORT AUTH * authnone_create() { diff --git a/rpc.subproj/auth_unix.c b/rpc.subproj/auth_unix.c index 85318d5..6258c85 100644 --- a/rpc.subproj/auth_unix.c +++ b/rpc.subproj/auth_unix.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -68,6 +68,8 @@ static char *rcsid = "$Id: auth_unix.c,v 1.4 2002/02/19 20:36:22 epeyton Exp $"; * */ +#include "libinfo_common.h" + #include #include #include @@ -123,6 +125,7 @@ static void marshal_new_auth(); * 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; @@ -220,6 +223,7 @@ set_rpc_maxgrouplist(num) * Returns an auth handle with parameters determined by doing lots of * syscalls. */ +LIBINFO_EXPORT AUTH * authunix_create_default() { diff --git a/rpc.subproj/authunix_prot.c b/rpc.subproj/authunix_prot.c index 52ca1a8..e365385 100644 --- a/rpc.subproj/authunix_prot.c +++ b/rpc.subproj/authunix_prot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,6 +64,8 @@ static char *rcsid = "$Id: authunix_prot.c,v 1.4 2002/02/19 20:36:22 epeyton Exp */ +#include "libinfo_common.h" + #include #include #include @@ -75,6 +77,7 @@ static char *rcsid = "$Id: authunix_prot.c,v 1.4 2002/02/19 20:36:22 epeyton Exp /* * XDR for unix authentication parameters. */ +LIBINFO_EXPORT bool_t xdr_authunix_parms(xdrs, p) register XDR *xdrs; diff --git a/rpc.subproj/bindresvport.c b/rpc.subproj/bindresvport.c index 29d82d4..d7ca45f 100644 --- a/rpc.subproj/bindresvport.c +++ b/rpc.subproj/bindresvport.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,6 +63,8 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/bindresvport.c,v 1.12 2000/01/2 * Portions Copyright(C) 1996, Jason Downs. All rights reserved. */ +#include "libinfo_common.h" + #include #include #include @@ -73,6 +75,7 @@ static char *rcsid = "$FreeBSD: src/lib/libc/rpc/bindresvport.c,v 1.12 2000/01/2 /* * Bind a socket to a privileged port for whatever protocol. */ +LIBINFO_EXPORT int bindresvport_sa(sd, sa) int sd; @@ -157,6 +160,7 @@ bindresvport_sa(sd, sa) /* * Bind a socket to a privileged IP port */ +LIBINFO_EXPORT int bindresvport(sd, sin) int sd; diff --git a/rpc.subproj/clnt.h b/rpc.subproj/clnt.h index 4ed9b51..99bb565 100644 --- a/rpc.subproj/clnt.h +++ b/rpc.subproj/clnt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -62,6 +62,7 @@ #ifndef _RPC_CLNT_H_ #define _RPC_CLNT_H_ +#include #include /* diff --git a/rpc.subproj/clnt_generic.c b/rpc.subproj/clnt_generic.c index 231dd67..014e04a 100644 --- a/rpc.subproj/clnt_generic.c +++ b/rpc.subproj/clnt_generic.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -59,6 +59,8 @@ static char *rcsid = "$Id: clnt_generic.c,v 1.3 2002/02/19 20:36:22 epeyton Exp /* * Copyright (C) 1987, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -70,6 +72,7 @@ static char *rcsid = "$Id: clnt_generic.c,v 1.3 2002/02/19 20:36:22 epeyton Exp * 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__ diff --git a/rpc.subproj/clnt_perror.c b/rpc.subproj/clnt_perror.c index a48c79a..b03b303 100644 --- a/rpc.subproj/clnt_perror.c +++ b/rpc.subproj/clnt_perror.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -62,6 +62,8 @@ static char *rcsid = "$Id: clnt_perror.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. * */ +#include "libinfo_common.h" + #include #include #include @@ -86,6 +88,7 @@ _buf() /* * Print reply error info */ +LIBINFO_EXPORT char * clnt_sperror(rpch, s) CLIENT *rpch; @@ -175,6 +178,7 @@ clnt_sperror(rpch, s) return(strstart) ; } +LIBINFO_EXPORT void clnt_perror(rpch, s) CLIENT *rpch; @@ -232,6 +236,7 @@ static struct rpc_errtab rpc_errlist[] = { /* * This interface for use by clntrpc */ +LIBINFO_EXPORT char * clnt_sperrno(stat) enum clnt_stat stat; @@ -246,6 +251,7 @@ clnt_sperrno(stat) return ("RPC: (unknown error code)"); } +LIBINFO_EXPORT void clnt_perrno(num) enum clnt_stat num; @@ -254,6 +260,7 @@ clnt_perrno(num) } +LIBINFO_EXPORT char * clnt_spcreateerror(s) char *s; @@ -287,6 +294,7 @@ clnt_spcreateerror(s) return (str); } +LIBINFO_EXPORT void clnt_pcreateerror(s) char *s; diff --git a/rpc.subproj/clnt_raw.c b/rpc.subproj/clnt_raw.c index e9ecbe5..8ef0d11 100644 --- a/rpc.subproj/clnt_raw.c +++ b/rpc.subproj/clnt_raw.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -67,6 +67,8 @@ static char *rcsid = "$Id: clnt_raw.c,v 1.3 2002/02/19 20:36:22 epeyton Exp $"; * any interference from the kernal. */ +#include "libinfo_common.h" + #include #include #include @@ -107,6 +109,7 @@ void svc_getreq(); /* * Create a client handle for memory based rpc. */ +LIBINFO_EXPORT CLIENT * clntraw_create(prog, vers) #ifdef __LP64__ diff --git a/rpc.subproj/clnt_tcp.c b/rpc.subproj/clnt_tcp.c index 89aae16..f4b3653 100644 --- a/rpc.subproj/clnt_tcp.c +++ b/rpc.subproj/clnt_tcp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -75,6 +75,8 @@ static char *rcsid = "$Id: clnt_tcp.c,v 1.4 2002/03/15 22:07:48 majka Exp $"; * Now go hang yourself. */ +#include "libinfo_common.h" + #include #include #include @@ -264,6 +266,7 @@ fooy: return NULL; } +LIBINFO_EXPORT CLIENT * clnttcp_create(raddr, prog, vers, sockp, sendsz, recvsz) #ifdef __LP64__ diff --git a/rpc.subproj/clnt_udp.c b/rpc.subproj/clnt_udp.c index ab7d0ca..e5a9233 100644 --- a/rpc.subproj/clnt_udp.c +++ b/rpc.subproj/clnt_udp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2007 Apple Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -62,6 +62,8 @@ static char *rcsid = "$Id: clnt_udp.c,v 1.4 2002/03/15 22:07:49 majka Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -259,6 +261,7 @@ fooy: return NULL; } +LIBINFO_EXPORT CLIENT * clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) #ifdef __LP64__ @@ -282,6 +285,7 @@ clntudp_bufcreate(raddr, program, version, wait, sockp, sendsz, recvsz) 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__ diff --git a/rpc.subproj/getrpcport.c b/rpc.subproj/getrpcport.c index dadcfa4..c593440 100644 --- a/rpc.subproj/getrpcport.c +++ b/rpc.subproj/getrpcport.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -60,6 +60,8 @@ static char *rcsid = "$Id: getrpcport.c,v 1.3 2002/02/19 20:36:23 epeyton Exp $" * Copyright (c) 1985 by Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -67,6 +69,7 @@ static char *rcsid = "$Id: getrpcport.c,v 1.3 2002/02/19 20:36:23 epeyton Exp $" #include #include +LIBINFO_EXPORT int getrpcport(host, prognum, versnum, proto) char *host; diff --git a/rpc.subproj/pmap_clnt.c b/rpc.subproj/pmap_clnt.c index 5ddfd00..bfadc5d 100644 --- a/rpc.subproj/pmap_clnt.c +++ b/rpc.subproj/pmap_clnt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,6 +63,8 @@ static char *rcsid = "$Id: pmap_clnt.c,v 1.5 2004/12/19 22:45:44 zarzycki Exp $" * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -90,6 +92,7 @@ void clnt_perror(); * 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__ @@ -134,6 +137,7 @@ pmap_set(program, version, protocol, port) * 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__ diff --git a/rpc.subproj/pmap_getmaps.c b/rpc.subproj/pmap_getmaps.c index b359b9c..3d65ee8 100644 --- a/rpc.subproj/pmap_getmaps.c +++ b/rpc.subproj/pmap_getmaps.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,6 +64,8 @@ static char *rcsid = "$Id: pmap_getmaps.c,v 1.4 2004/12/19 22:45:44 zarzycki Exp * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -83,6 +85,7 @@ extern int errno; * 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; diff --git a/rpc.subproj/pmap_getport.c b/rpc.subproj/pmap_getport.c index fd7e6e3..907c454 100644 --- a/rpc.subproj/pmap_getport.c +++ b/rpc.subproj/pmap_getport.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,6 +63,8 @@ static char *rcsid = "$Id: pmap_getport.c,v 1.4 2004/12/19 22:45:44 zarzycki Exp * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -124,6 +126,7 @@ pmap_getport_timeout(struct sockaddr_in *address, uint32_t program, uint32_t ver return port; } +LIBINFO_EXPORT u_short pmap_getport(address, program, version, protocol) #ifdef __LP64__ diff --git a/rpc.subproj/pmap_prot.c b/rpc.subproj/pmap_prot.c index b3d4a02..e72236c 100644 --- a/rpc.subproj/pmap_prot.c +++ b/rpc.subproj/pmap_prot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,11 +63,14 @@ static char *rcsid = "$Id: pmap_prot.c,v 1.2 1999/10/14 21:56:53 wsanchez Exp $" * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include +LIBINFO_EXPORT bool_t xdr_pmap(xdrs, regs) XDR *xdrs; diff --git a/rpc.subproj/pmap_prot2.c b/rpc.subproj/pmap_prot2.c index 99be504..ab2496f 100644 --- a/rpc.subproj/pmap_prot2.c +++ b/rpc.subproj/pmap_prot2.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,6 +63,8 @@ static char *rcsid = "$Id: pmap_prot2.c,v 1.3 2002/02/19 20:36:24 epeyton Exp $" * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -106,6 +108,7 @@ static char *rcsid = "$Id: pmap_prot2.c,v 1.3 2002/02/19 20:36:24 epeyton Exp $" * 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; diff --git a/rpc.subproj/pmap_rmt.c b/rpc.subproj/pmap_rmt.c index a35084f..4cf6fb7 100644 --- a/rpc.subproj/pmap_rmt.c +++ b/rpc.subproj/pmap_rmt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,6 +64,8 @@ static char *rcsid = "$Id: pmap_rmt.c,v 1.6 2004/12/19 22:45:44 zarzycki Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -89,6 +91,7 @@ static struct timeval timeout = { 3, 0 }; * 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__ @@ -139,6 +142,7 @@ pmap_rmtcall(addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_pt * XDR remote call arguments * written for XDR_ENCODE direction only */ +LIBINFO_EXPORT bool_t xdr_rmtcall_args(xdrs, cap) register XDR *xdrs; @@ -174,6 +178,7 @@ xdr_rmtcall_args(xdrs, cap) * XDR remote call results * written for XDR_DECODE direction only */ +LIBINFO_EXPORT bool_t xdr_rmtcallres(xdrs, crp) register XDR *xdrs; @@ -257,6 +262,7 @@ getbroadcastnets(addrs, sock, buf) typedef bool_t (*resultproc_t)(); +LIBINFO_EXPORT enum clnt_stat clnt_broadcast(prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult) #ifdef __LP64__ diff --git a/rpc.subproj/rpc_callmsg.c b/rpc.subproj/rpc_callmsg.c index 789fd00..39d80dd 100644 --- a/rpc.subproj/rpc_callmsg.c +++ b/rpc.subproj/rpc_callmsg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,6 +63,8 @@ static char *rcsid = "$Id: rpc_callmsg.c,v 1.4 2003/06/23 17:24:59 majka Exp $"; * */ +#include "libinfo_common.h" + #include #include #include @@ -74,6 +76,7 @@ extern bool_t xdr_opaque_auth(); /* * XDR a call message */ +LIBINFO_EXPORT bool_t xdr_callmsg(xdrs, cmsg) register XDR *xdrs; diff --git a/rpc.subproj/rpc_commondata.c b/rpc.subproj/rpc_commondata.c index a3a122c..aac755b 100644 --- a/rpc.subproj/rpc_commondata.c +++ b/rpc.subproj/rpc_commondata.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -55,15 +55,20 @@ static char *rcsid = "$Id: rpc_commondata.c,v 1.3 2002/02/19 20:36:24 epeyton Exp $"; #endif +#include "libinfo_common.h" + #include /* * 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; diff --git a/rpc.subproj/rpc_prot.c b/rpc.subproj/rpc_prot.c index df402b9..e56d12c 100644 --- a/rpc.subproj/rpc_prot.c +++ b/rpc.subproj/rpc_prot.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -68,6 +68,8 @@ static char *rcsid = "$Id: rpc_prot.c,v 1.3 2003/06/23 17:24:59 majka Exp $"; * routines are also in this program. */ +#include "libinfo_common.h" + #include #include @@ -98,6 +100,7 @@ xdr_opaque_auth(xdrs, ap) /* * XDR a DES block */ +LIBINFO_EXPORT bool_t xdr_des_block(xdrs, blkp) register XDR *xdrs; @@ -169,6 +172,7 @@ static struct xdr_discrim reply_dscrm[3] = { /* * XDR a reply message */ +LIBINFO_EXPORT bool_t xdr_replymsg(xdrs, rmsg) register XDR *xdrs; @@ -189,6 +193,7 @@ xdr_replymsg(xdrs, rmsg) * 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; @@ -283,6 +288,7 @@ rejected(rjct_stat, error) /* * given a reply message, fills in the error */ +LIBINFO_EXPORT void _seterr_reply(msg, error) register struct rpc_msg *msg; diff --git a/rpc.subproj/svc.c b/rpc.subproj/svc.c index 9fc4c01..2938b92 100644 --- a/rpc.subproj/svc.c +++ b/rpc.subproj/svc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -66,6 +66,8 @@ static char *rcsid = "$Id: svc.c,v 1.4 2002/02/19 20:36:24 epeyton Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -108,6 +110,7 @@ extern int svc_maxfd; /* * Activate a transport handle. */ +LIBINFO_EXPORT void xprt_register(xprt) SVCXPRT *xprt; @@ -128,6 +131,7 @@ xprt_register(xprt) /* * De-activate a transport handle. */ +LIBINFO_EXPORT void xprt_unregister(xprt) SVCXPRT *xprt; @@ -153,6 +157,7 @@ xprt_unregister(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__ @@ -197,6 +202,7 @@ pmap_it: /* * Remove a service program from the callout list. */ +LIBINFO_EXPORT void svc_unregister(prog, vers) #ifdef __LP64__ @@ -256,6 +262,7 @@ done: /* * Send a reply to an rpc request */ +LIBINFO_EXPORT bool_t svc_sendreply(xprt, xdr_results, xdr_location) register SVCXPRT *xprt; @@ -276,6 +283,7 @@ svc_sendreply(xprt, xdr_results, xdr_location) /* * No procedure error reply */ +LIBINFO_EXPORT void svcerr_noproc(xprt) register SVCXPRT *xprt; @@ -292,6 +300,7 @@ svcerr_noproc(xprt) /* * Can't decode args error reply */ +LIBINFO_EXPORT void svcerr_decode(xprt) register SVCXPRT *xprt; @@ -308,6 +317,7 @@ svcerr_decode(xprt) /* * Some system error */ +LIBINFO_EXPORT void svcerr_systemerr(xprt) register SVCXPRT *xprt; @@ -324,6 +334,7 @@ svcerr_systemerr(xprt) /* * Authentication error reply */ +LIBINFO_EXPORT void svcerr_auth(xprt, why) SVCXPRT *xprt; @@ -341,6 +352,7 @@ svcerr_auth(xprt, why) /* * Auth too weak error reply */ +LIBINFO_EXPORT void svcerr_weakauth(xprt) SVCXPRT *xprt; @@ -352,6 +364,7 @@ svcerr_weakauth(xprt) /* * Program unavailable error reply */ +LIBINFO_EXPORT void svcerr_noprog(xprt) register SVCXPRT *xprt; @@ -368,6 +381,7 @@ svcerr_noprog(xprt) /* * Program version mismatch error reply */ +LIBINFO_EXPORT void svcerr_progvers(xprt, low_vers, high_vers) #ifdef __LP64__ @@ -409,6 +423,7 @@ svcerr_progvers(xprt, low_vers, high_vers) * is mallocated in kernel land. */ +LIBINFO_EXPORT void svc_getreq(rdfds) int rdfds; @@ -420,6 +435,7 @@ svc_getreq(rdfds) svc_getreqset(&readfds); } +LIBINFO_EXPORT void svc_getreqset(readfds) fd_set *readfds; diff --git a/rpc.subproj/svc.h b/rpc.subproj/svc.h index d671045..b322fb1 100644 --- a/rpc.subproj/svc.h +++ b/rpc.subproj/svc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -305,11 +305,13 @@ extern fd_set svc_fdset; 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)); diff --git a/rpc.subproj/svc_auth.c b/rpc.subproj/svc_auth.c index 0d8db83..66ab90b 100644 --- a/rpc.subproj/svc_auth.c +++ b/rpc.subproj/svc_auth.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -63,6 +63,8 @@ static char *rcsid = "$Id: svc_auth.c,v 1.3 2002/02/19 20:36:25 epeyton Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include /* @@ -112,6 +114,7 @@ static struct { * 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; diff --git a/rpc.subproj/svc_raw.c b/rpc.subproj/svc_raw.c index b5ad135..0911a38 100644 --- a/rpc.subproj/svc_raw.c +++ b/rpc.subproj/svc_raw.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -65,6 +65,8 @@ static char *rcsid = "$Id: svc_raw.c,v 1.3 2002/02/19 20:36:25 epeyton Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include @@ -95,6 +97,7 @@ static struct xp_ops server_ops = { svcraw_destroy }; +LIBINFO_EXPORT SVCXPRT * svcraw_create() { diff --git a/rpc.subproj/svc_run.c b/rpc.subproj/svc_run.c index 451591d..5275962 100644 --- a/rpc.subproj/svc_run.c +++ b/rpc.subproj/svc_run.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -60,6 +60,8 @@ static char *rcsid = "$Id: svc_run.c,v 1.3 2002/02/19 20:36:25 epeyton Exp $"; * This is the rpc server side idle loop * Wait for input, call server program. */ +#include "libinfo_common.h" + #include #include #include @@ -67,6 +69,7 @@ static char *rcsid = "$Id: svc_run.c,v 1.3 2002/02/19 20:36:25 epeyton Exp $"; extern int svc_maxfd; +LIBINFO_EXPORT void svc_run() { diff --git a/rpc.subproj/svc_tcp.c b/rpc.subproj/svc_tcp.c index 2eee25c..f7d12d4 100644 --- a/rpc.subproj/svc_tcp.c +++ b/rpc.subproj/svc_tcp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -66,6 +66,8 @@ static char *rcsid = "$Id: svc_tcp.c,v 1.6 2004/06/11 16:28:07 majka Exp $"; * and a record/tcp stream. */ +#include "libinfo_common.h" + #include #include #include @@ -152,6 +154,7 @@ struct tcp_conn { /* kept in xprt->xp_p1 */ * 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; @@ -211,6 +214,7 @@ svctcp_create(sock, sendsize, recvsize) * 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; diff --git a/rpc.subproj/svc_udp.c b/rpc.subproj/svc_udp.c index ac83afc..d30a20d 100644 --- a/rpc.subproj/svc_udp.c +++ b/rpc.subproj/svc_udp.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -64,6 +64,8 @@ static char *rcsid = "$Id: svc_udp.c,v 1.5 2004/10/13 00:24:07 jkh Exp $"; * Copyright (C) 1984, Sun Microsystems, Inc. */ +#include "libinfo_common.h" + #include #include #include @@ -125,6 +127,7 @@ struct svcudp_data { * see (svc.h, xprt_register). * The routines returns NULL if a problem occurred. */ +LIBINFO_EXPORT SVCXPRT * svcudp_bufcreate(sock, sendsz, recvsz) register int sock; @@ -185,6 +188,7 @@ svcudp_bufcreate(sock, sendsz, recvsz) return (xprt); } +LIBINFO_EXPORT SVCXPRT * svcudp_create(sock) int sock; diff --git a/rpc.subproj/xdr.c b/rpc.subproj/xdr.c index c6c287e..fc1ee5d 100644 --- a/rpc.subproj/xdr.c +++ b/rpc.subproj/xdr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -69,6 +69,8 @@ static char *sccsid = "@(#)xdr.c 2.1 88/07/29 4.0 RPCSRC"; * xdr. */ +#include "libinfo_common.h" + #include #include #include @@ -107,6 +109,7 @@ static const char xdr_zero[BYTES_PER_XDR_UNIT] = { 0, 0, 0, 0 }; * Free a data structure using XDR * Not a filter, but a convenient utility nonetheless */ +LIBINFO_EXPORT void xdr_free(proc, objp) xdrproc_t proc; @@ -121,6 +124,7 @@ xdr_free(proc, objp) /* * XDR nothing */ +LIBINFO_EXPORT bool_t xdr_void(void) { @@ -133,6 +137,7 @@ xdr_void(void) * XDR integers */ bool_t +LIBINFO_EXPORT xdr_int(xdrs, ip) XDR *xdrs; int *ip; @@ -162,6 +167,7 @@ xdr_int(xdrs, ip) /* * XDR unsigned integers */ +LIBINFO_EXPORT bool_t xdr_u_int(xdrs, up) XDR *xdrs; @@ -194,6 +200,7 @@ xdr_u_int(xdrs, up) * 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; @@ -219,6 +226,7 @@ xdr_long(xdrs, lp) * 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; @@ -245,6 +253,7 @@ xdr_u_long(xdrs, ulp) * 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; @@ -276,6 +285,7 @@ xdr_int32_t(xdrs, int32_p) * 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; @@ -305,6 +315,7 @@ xdr_u_int32_t(xdrs, u_int32_p) /* * XDR short integers */ +LIBINFO_EXPORT bool_t xdr_short(xdrs, sp) XDR *xdrs; @@ -335,6 +346,7 @@ xdr_short(xdrs, sp) /* * XDR unsigned short integers */ +LIBINFO_EXPORT bool_t xdr_u_short(xdrs, usp) XDR *xdrs; @@ -366,6 +378,7 @@ xdr_u_short(xdrs, usp) /* * XDR 16-bit integers */ +LIBINFO_EXPORT bool_t xdr_int16_t(xdrs, int16_p) XDR *xdrs; @@ -396,6 +409,7 @@ xdr_int16_t(xdrs, int16_p) /* * XDR unsigned 16-bit integers */ +LIBINFO_EXPORT bool_t xdr_u_int16_t(xdrs, u_int16_p) XDR *xdrs; @@ -427,6 +441,7 @@ xdr_u_int16_t(xdrs, u_int16_p) /* * XDR a char */ +LIBINFO_EXPORT bool_t xdr_char(xdrs, cp) XDR *xdrs; @@ -445,6 +460,7 @@ xdr_char(xdrs, cp) /* * XDR an unsigned char */ +LIBINFO_EXPORT bool_t xdr_u_char(xdrs, cp) XDR *xdrs; @@ -463,6 +479,7 @@ xdr_u_char(xdrs, cp) /* * XDR booleans */ +LIBINFO_EXPORT bool_t xdr_bool(xdrs, bp) XDR *xdrs; @@ -493,6 +510,7 @@ xdr_bool(xdrs, bp) /* * XDR enumerations */ +LIBINFO_EXPORT bool_t xdr_enum(xdrs, ep) XDR *xdrs; @@ -519,6 +537,7 @@ xdr_enum(xdrs, ep) * 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; @@ -571,6 +590,7 @@ xdr_opaque(xdrs, cp, cnt) * *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; @@ -627,6 +647,7 @@ xdr_bytes(xdrs, cpp, sizep, maxsize) /* * Implemented here due to commonality of the object. */ +LIBINFO_EXPORT bool_t xdr_netobj(xdrs, np) XDR *xdrs; @@ -647,6 +668,7 @@ xdr_netobj(xdrs, np) * 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; @@ -696,6 +718,7 @@ xdr_union(xdrs, dscmp, unp, choices, dfault) * 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; @@ -763,6 +786,7 @@ xdr_string(xdrs, cpp, maxsize) * Wrapper for xdr_string that can be called directly from * routines like clnt_call */ +LIBINFO_EXPORT bool_t xdr_wrapstring(xdrs, cpp) XDR *xdrs; @@ -782,6 +806,7 @@ xdr_wrapstring(xdrs, cpp) /* * XDR 64-bit integers */ +LIBINFO_EXPORT bool_t xdr_int64_t(xdrs, llp) XDR *xdrs; @@ -815,6 +840,7 @@ xdr_int64_t(xdrs, llp) /* * XDR unsigned 64-bit integers */ +LIBINFO_EXPORT bool_t xdr_u_int64_t(xdrs, ullp) XDR *xdrs; @@ -848,6 +874,7 @@ xdr_u_int64_t(xdrs, ullp) /* * XDR hypers */ +LIBINFO_EXPORT bool_t xdr_hyper(xdrs, llp) XDR *xdrs; @@ -864,6 +891,7 @@ xdr_hyper(xdrs, llp) /* * XDR unsigned hypers */ +LIBINFO_EXPORT bool_t xdr_u_hyper(xdrs, ullp) XDR *xdrs; @@ -880,6 +908,7 @@ xdr_u_hyper(xdrs, ullp) /* * XDR longlong_t's */ +LIBINFO_EXPORT bool_t xdr_longlong_t(xdrs, llp) XDR *xdrs; @@ -896,6 +925,7 @@ xdr_longlong_t(xdrs, llp) /* * XDR u_longlong_t's */ +LIBINFO_EXPORT bool_t xdr_u_longlong_t(xdrs, ullp) XDR *xdrs; diff --git a/rpc.subproj/xdr.h b/rpc.subproj/xdr.h index ff46e00..adcbe30 100644 --- a/rpc.subproj/xdr.h +++ b/rpc.subproj/xdr.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -396,7 +396,9 @@ extern bool_t xdr_u_char(XDR *, unsigned char *); 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 **); @@ -445,7 +447,9 @@ extern bool_t xdrrec_skiprecord(XDR *); /* 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 */ diff --git a/rpc.subproj/xdr_array.c b/rpc.subproj/xdr_array.c index 72ca410..cba99de 100644 --- a/rpc.subproj/xdr_array.c +++ b/rpc.subproj/xdr_array.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -68,6 +68,8 @@ static char *sccsid = "@(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC"; * arrays. See xdr.h for more info on the interface to xdr. */ +#include "libinfo_common.h" + #include #include #include @@ -84,6 +86,7 @@ static char *sccsid = "@(#)xdr_array.c 2.1 88/07/29 4.0 RPCSRC"; * 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; @@ -162,6 +165,7 @@ xdr_array(xdrs, addrp, sizep, maxsize, elsize, elproc) * > 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; diff --git a/rpc.subproj/xdr_float.c b/rpc.subproj/xdr_float.c index 1ef6f04..1a59b57 100644 --- a/rpc.subproj/xdr_float.c +++ b/rpc.subproj/xdr_float.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -57,6 +57,8 @@ 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 /* @@ -118,6 +120,7 @@ static struct sgl_limits { }; #endif /* vax */ +LIBINFO_EXPORT bool_t xdr_float(xdrs, fp) XDR *xdrs; @@ -220,6 +223,7 @@ static struct dbl_limits { #endif /* vax */ +LIBINFO_EXPORT bool_t xdr_double(xdrs, dp) XDR *xdrs; diff --git a/rpc.subproj/xdr_mem.c b/rpc.subproj/xdr_mem.c index fc4dc82..cc919ff 100644 --- a/rpc.subproj/xdr_mem.c +++ b/rpc.subproj/xdr_mem.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -57,6 +57,8 @@ 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 /* @@ -125,6 +127,7 @@ static const struct xdr_ops xdrmem_ops_unaligned = { * The procedure xdrmem_create initializes a stream descriptor for a * memory buffer. */ +LIBINFO_EXPORT void xdrmem_create(xdrs, addr, size, op) XDR *xdrs; diff --git a/rpc.subproj/xdr_rec.c b/rpc.subproj/xdr_rec.c index 77fffec..7e8271e 100644 --- a/rpc.subproj/xdr_rec.c +++ b/rpc.subproj/xdr_rec.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -53,6 +53,8 @@ * Mountain View, California 94043 */ +#include "libinfo_common.h" + #include #if defined(LIBC_SCCS) && !defined(lint) static char *sccsid = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro"; @@ -189,6 +191,7 @@ static bool_t realloc_stream(RECSTREAM *, int); * 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; @@ -490,6 +493,7 @@ xdrrec_destroy(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; @@ -526,6 +530,7 @@ xdrrec_skiprecord(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; @@ -550,6 +555,7 @@ xdrrec_eof(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; diff --git a/rpc.subproj/xdr_reference.c b/rpc.subproj/xdr_reference.c index 77ae3a5..bf4586a 100644 --- a/rpc.subproj/xdr_reference.c +++ b/rpc.subproj/xdr_reference.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -53,6 +53,8 @@ * Mountain View, California 94043 */ +#include "libinfo_common.h" + #include #if defined(LIBC_SCCS) && !defined(lint) static char *sccsid = "@(#)xdr_reference.c 1.11 87/08/11 SMI"; @@ -87,6 +89,7 @@ static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_reference.c,v 1.11 2002/03/ * 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; @@ -144,6 +147,7 @@ xdr_reference(xdrs, pp, size, proc) * > xdr_obj: routine to XDR an object. * */ +LIBINFO_EXPORT bool_t xdr_pointer(xdrs,objpp,obj_size,xdr_obj) XDR *xdrs; diff --git a/rpc.subproj/xdr_stdio.c b/rpc.subproj/xdr_stdio.c index 2bdc4af..5de45d7 100644 --- a/rpc.subproj/xdr_stdio.c +++ b/rpc.subproj/xdr_stdio.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -57,6 +57,8 @@ 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 /* @@ -108,6 +110,7 @@ static const struct xdr_ops xdrstdio_ops = { * 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; diff --git a/util.subproj/hton.c b/util.subproj/hton.c index b40320f..2994e25 100644 --- a/util.subproj/hton.c +++ b/util.subproj/hton.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999-2008 Apple Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -22,24 +22,30 @@ */ /* Copyright (c) 1994 NeXT Computer, Inc. All rights reserved. */ +#include "libinfo_common.h" + #import #import +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); diff --git a/util.subproj/rcmd.c b/util.subproj/rcmd.c index 464250f..4163878 100644 --- a/util.subproj/rcmd.c +++ b/util.subproj/rcmd.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Apple Computer, Inc. All rights reserved. + * Copyright (c) 1999-2018 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -62,6 +62,8 @@ static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; #endif /* LIBC_SCCS and not lint */ +#include "libinfo_common.h" + #include #include #include @@ -109,6 +111,7 @@ int __ivaliduser_sa __P((FILE *, const struct sockaddr *, socklen_t, 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; @@ -336,6 +339,7 @@ bad: return (-1); } +LIBINFO_EXPORT int rcmd(ahost, rport, locuser, remuser, cmd, fd2p) char **ahost; @@ -346,6 +350,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p) return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); } +LIBINFO_EXPORT int rresvport(port) int *port; @@ -353,6 +358,7 @@ rresvport(port) return rresvport_af(port, AF_INET); } +LIBINFO_EXPORT int rresvport_af(alport, family) int *alport, family; @@ -413,6 +419,7 @@ char *__rcmd_errstr; * * Returns 0 if ok, -1 if not ok. */ +LIBINFO_EXPORT int iruserok_sa(ra, rlen, superuser, ruser, luser) const void *ra; @@ -498,6 +505,7 @@ again: return (-1); } +LIBINFO_EXPORT int ruserok(rhost, superuser, ruser, luser) const char *rhost, *ruser, *luser; @@ -533,6 +541,7 @@ ruserok(rhost, superuser, ruser, luser) * * Returns 0 if ok, -1 if not ok. */ +LIBINFO_EXPORT int iruserok(raddr, superuser, ruser, luser) unsigned long raddr; diff --git a/xcodescripts/Libinfo.xcconfig b/xcodescripts/Libinfo.xcconfig index e99d936..3e5caf0 100644 --- a/xcodescripts/Libinfo.xcconfig +++ b/xcodescripts/Libinfo.xcconfig @@ -1,3 +1,5 @@ +// Copyright (c) 2018 Apple Inc. All rights reserved. + #include "/Makefiles/CoreOS/Xcode/BSD.xcconfig" HEADER_SEARCH_PATHS = /usr/local/include $(SDKROOT)/System/Library/Frameworks/System.framework/PrivateHeaders @@ -41,7 +43,6 @@ LIBBLOCKS_LDFLAGS = -lsystem_blocks LIBDNSD_LDFLAGS = -lsystem_dnssd LIBNOTIFY_LDFLAGS = -lsystem_notify LIBXPC_LDFLAGS = -lxpc -LIBNETWORK_LDFLAGS = -lsystem_network LIBTRACE_LDFLAGS = -lsystem_trace CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; @@ -75,4 +76,12 @@ OTHER_CFLAGS = -DDEBUG=1 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 diff --git a/xcodescripts/install_files.sh b/xcodescripts/install_files.sh index 6be8d36..6f13fa9 100755 --- a/xcodescripts/install_files.sh +++ b/xcodescripts/install_files.sh @@ -24,6 +24,7 @@ InstallHeaders /usr/local/include \ 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 @@ -51,8 +52,8 @@ InstallHeaders /usr/include/rpcsvc \ 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 -- 2.45.2