2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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
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.
21 * @APPLE_LICENSE_HEADER_END@
25 * Modification History
27 * January 19, 2003 Allan Nathanson <ajn@apple.com>
28 * - add advanced reachability APIs
30 * June 10, 2001 Allan Nathanson <ajn@apple.com>
31 * - updated to use service-based "State:" information
33 * June 1, 2001 Allan Nathanson <ajn@apple.com>
34 * - public API conversion
36 * January 30, 2001 Allan Nathanson <ajn@apple.com>
40 #include <sys/types.h>
41 #include <netinet/in.h>
43 #include <sys/socket.h>
45 #include <SystemConfiguration/SystemConfiguration.h>
46 #include <SystemConfiguration/SCPrivate.h>
48 #ifndef kSCEntNetRefreshConfiguration
49 #define kSCEntNetRefreshConfiguration CFSTR("RefreshConfiguration")
50 #endif kSCEntNetRefreshConfiguration
53 SCNetworkCheckReachabilityByAddress(const struct sockaddr
*address
,
55 SCNetworkConnectionFlags
*flags
)
57 SCNetworkReachabilityRef networkAddress
;
59 struct sockaddr_storage ss
;
63 (addrlen
> (int)sizeof(struct sockaddr_storage
))) {
64 _SCErrorSet(kSCStatusInvalidArgument
);
68 bzero(&ss
, sizeof(ss
));
69 bcopy(address
, &ss
, addrlen
);
72 networkAddress
= SCNetworkReachabilityCreateWithAddress(NULL
, (struct sockaddr
*)&ss
);
73 ok
= SCNetworkReachabilityGetFlags(networkAddress
, flags
);
74 CFRelease(networkAddress
);
80 SCNetworkCheckReachabilityByName(const char *nodename
,
81 SCNetworkConnectionFlags
*flags
)
83 SCNetworkReachabilityRef networkAddress
;
87 _SCErrorSet(kSCStatusInvalidArgument
);
91 networkAddress
= SCNetworkReachabilityCreateWithName(NULL
, nodename
);
92 ok
= SCNetworkReachabilityGetFlags(networkAddress
, flags
);
93 CFRelease(networkAddress
);
98 SCNetworkInterfaceRefreshConfiguration(CFStringRef ifName
)
102 SCDynamicStoreRef store
;
104 store
= SCDynamicStoreCreate(NULL
,
105 CFSTR("SCNetworkInterfaceRefreshConfiguration"),
111 key
= SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL
,
112 kSCDynamicStoreDomainState
,
114 kSCEntNetRefreshConfiguration
);
115 ret
= SCDynamicStoreNotifyValue(store
, key
);