1/* 2 * Copyright (c) 2006, 2008, 2011, 2012 Apple 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 24#ifndef _SCNETWORKSIGNATURE_H 25#define _SCNETWORKSIGNATURE_H 26 27#include <Availability.h> 28#include <sys/cdefs.h> 29#include <CoreFoundation/CFString.h> 30#include <CoreFoundation/CFArray.h> 31#include <netinet/in.h> 32 33__BEGIN_DECLS 34 35/*! 36 @header SCNetworkSignature 37 @discussion The SCNetworkSignature API provides access to the 38 network identification information. Each routable network 39 has an associated signature that is assigned a unique 40 identifier. The unique identifier allows an application 41 to associate settings with a particular network 42 or set of networks. 43 */ 44 45/*! 46 @function SCNetworkSignatureCopyActiveIdentifiers 47 @discussion Find all currently active networks and return a list of 48 (string) identifiers, one for each network. 49 @param allocator The CFAllocator that should be used to allocate 50 memory for the local dynamic store object. 51 This parameter may be NULL in which case the current 52 default CFAllocator is used. If this reference is not 53 a valid CFAllocator, the behavior is undefined. 54 @result A CFArrayRef containing a list of (string) identifiers, 55 NULL if no networks are currently active. 56 */ 57CFArrayRef /* of CFStringRef's */ 58SCNetworkSignatureCopyActiveIdentifiers(CFAllocatorRef alloc) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); 59 60/*! 61 @function SCNetworkSignatureCopyActiveIdentifierForAddress 62 @discussion Find the one active network associated with the specified 63 address and return the unique (string) identifier that 64 represents it. 65 @param allocator The CFAllocator that should be used to allocate 66 memory for the local dynamic store object. 67 This parameter may be NULL in which case the current 68 default CFAllocator is used. If this reference is not 69 a valid CFAllocator, the behavior is undefined. 70 @param addr The address of interest. Note: currently only AF_INET 71 0.0.0.0 is supported, passing anything else always returns 72 NULL. 73 @result The unique (string) identifier associated with the address, 74 NULL if no network is known. 75 */ 76CFStringRef 77SCNetworkSignatureCopyActiveIdentifierForAddress(CFAllocatorRef alloc, 78 const struct sockaddr * addr) __OSX_AVAILABLE_STARTING(__MAC_10_5,__IPHONE_2_0/*SPI*/); 79 80/*! 81 @function SCNetworkSignatureCopyIdentifierForConnectedSocket 82 @discussion Find the identifier for the given file descriptor 83 corresponding to a connected socket. 84 @param allocator The CFAllocator that should be used to allocate 85 memory for the local dynamic store object. 86 This parameter may be NULL in which case the current 87 default CFAllocator is used. If this reference is not 88 a valid CFAllocator, the behavior is undefined. 89 @param sock_fd The socket file descriptor, must be either AF_INET 90 or AF_INET6. 91 @result The unique (string) identifier associated with the address, 92 NULL if no network is known. 93 */ 94CFStringRef 95SCNetworkSignatureCopyIdentifierForConnectedSocket(CFAllocatorRef alloc, 96 int sock_fd) __OSX_AVAILABLE_STARTING(__MAC_10_7,__IPHONE_5_0/*SPI*/); 97 98__END_DECLS 99 100#endif /* _SCNETWORKSIGNATURE_H */ 101