1/* 2 * Copyright (c) 2002-2003 Apple Computer, Inc. All rights reserved. 3 * 4 * @APPLE_LICENSE_HEADER_START@ 5 * 6 * This file contains Original Code and/or Modifications of Original Code 7 * as defined in and that are subject to the Apple Public Source License 8 * Version 2.0 (the 'License'). You may not use this file except in 9 * compliance with the License. Please obtain a copy of the License at 10 * http://www.opensource.apple.com/apsl/ and read it before using this 11 * file. 12 * 13 * The Original Code and all software distributed under the License are 14 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 15 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 16 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 18 * Please see the License for the specific language governing rights and 19 * limitations under the License. 20 * 21 * @APPLE_LICENSE_HEADER_END@ 22 23 Change History (most recent first): 24 25$Log: mDNSUNP.h,v $ 26Revision 1.1 2009-06-30 02:31:08 steven 27iTune Server 28 29Revision 1.3 2005/01/10 18:11:29 rpedde 30Fix compile error on solaris 31 32Revision 1.2 2005/01/10 01:07:01 rpedde 33Synchronize mDNS to Apples 58.8 drop 34 35Revision 1.8 2003/08/12 19:56:26 cheshire 36Update to APSL 2.0 37 38Revision 1.7 2003/08/06 18:20:51 cheshire 39Makefile cleanup 40 41Revision 1.6 2003/07/02 21:19:59 cheshire 42<rdar://problem/3313413> Update copyright notices, etc., in source code comments 43 44Revision 1.5 2003/03/13 03:46:21 cheshire 45Fixes to make the code build on Linux 46 47Revision 1.4 2002/12/23 22:13:32 jgraessl 48 49Reviewed by: Stuart Cheshire 50Initial IPv6 support for mDNSResponder. 51 52Revision 1.3 2002/09/21 20:44:53 zarzycki 53Added APSL info 54 55Revision 1.2 2002/09/19 04:20:44 cheshire 56Remove high-ascii characters that confuse some systems 57 58Revision 1.1 2002/09/17 06:24:35 cheshire 59First checkin 60 61*/ 62 63#ifndef __mDNSUNP_h 64#define __mDNSUNP_h 65 66#include <sys/types.h> 67#include <sys/socket.h> 68#include <net/if.h> 69#include <netinet/in.h> 70 71#ifdef __cplusplus 72 extern "C" { 73#endif 74 75#ifdef NOT_HAVE_SOCKLEN_T 76 typedef unsigned int socklen_t; 77#endif 78 79#if !defined(_SS_MAXSIZE) 80 #define sockaddr_storage sockaddr 81#endif 82 83#ifndef NOT_HAVE_SA_LEN 84#define GET_SA_LEN(X) (sizeof(struct sockaddr) > ((struct sockaddr*)&(X))->sa_len ? \ 85 sizeof(struct sockaddr) : ((struct sockaddr*)&(X))->sa_len ) 86#elif mDNSIPv6Support 87#define GET_SA_LEN(X) (((struct sockaddr*)&(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : \ 88 ((struct sockaddr*)&(X))->sa_family == AF_INET6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr)) 89#else 90#define GET_SA_LEN(X) (((struct sockaddr*)&(X))->sa_family == AF_INET ? sizeof(struct sockaddr_in) : sizeof(struct sockaddr)) 91#endif 92 93#define IFI_NAME 16 /* same as IFNAMSIZ in <net/if.h> */ 94#define IFI_HADDR 8 /* allow for 64-bit EUI-64 in future */ 95 96// Renamed from my_in_pktinfo because in_pktinfo is used by Linux. 97 98struct my_in_pktinfo { 99 struct sockaddr_storage ipi_addr; 100 int ipi_ifindex; /* received interface index */ 101 char ipi_ifname[IFI_NAME]; /* received interface name */ 102}; 103 104extern ssize_t recvfrom_flags(int fd, void *ptr, size_t nbytes, int *flagsp, 105 struct sockaddr *sa, socklen_t *salenptr, struct my_in_pktinfo *pktp); 106 107struct ifi_info { 108 char ifi_name[IFI_NAME]; /* interface name, null terminated */ 109 u_char ifi_haddr[IFI_HADDR]; /* hardware address */ 110 u_short ifi_hlen; /* #bytes in hardware address: 0, 6, 8 */ 111 short ifi_flags; /* IFF_xxx constants from <net/if.h> */ 112 short ifi_myflags; /* our own IFI_xxx flags */ 113 int ifi_index; /* interface index */ 114 struct sockaddr *ifi_addr; /* primary address */ 115 struct sockaddr *ifi_brdaddr;/* broadcast address */ 116 struct sockaddr *ifi_dstaddr;/* destination address */ 117 struct ifi_info *ifi_next; /* next of these structures */ 118}; 119 120#define IFI_ALIAS 1 /* ifi_addr is an alias */ 121 122extern struct ifi_info *get_ifi_info(int family, int doaliases); 123extern void free_ifi_info(struct ifi_info *); 124 125#ifdef __cplusplus 126 } 127#endif 128 129#endif 130