2 * Copyright (c) 2000-2003 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
27 * Modification History
29 * January 19, 2003 Allan Nathanson <ajn@apple.com>
30 * - add advanced reachability APIs
32 * June 10, 2001 Allan Nathanson <ajn@apple.com>
33 * - updated to use service-based "State:" information
35 * June 1, 2001 Allan Nathanson <ajn@apple.com>
36 * - public API conversion
38 * January 30, 2001 Allan Nathanson <ajn@apple.com>
42 #include <sys/types.h>
43 #include <netinet/in.h>
45 #include <sys/socket.h>
47 #include <SystemConfiguration/SystemConfiguration.h>
48 #include <SystemConfiguration/SCPrivate.h>
50 #ifndef kSCEntNetRefreshConfiguration
51 #define kSCEntNetRefreshConfiguration CFSTR("RefreshConfiguration")
52 #endif kSCEntNetRefreshConfiguration
55 SCNetworkCheckReachabilityByAddress(const struct sockaddr
*address
,
57 SCNetworkConnectionFlags
*flags
)
59 SCNetworkReachabilityRef networkAddress
;
61 struct sockaddr_storage ss
;
65 (addrlen
> (int)sizeof(struct sockaddr_storage
))) {
66 _SCErrorSet(kSCStatusInvalidArgument
);
70 bzero(&ss
, sizeof(ss
));
71 bcopy(address
, &ss
, addrlen
);
74 networkAddress
= SCNetworkReachabilityCreateWithAddress(NULL
, (struct sockaddr
*)&ss
);
75 ok
= SCNetworkReachabilityGetFlags(networkAddress
, flags
);
76 CFRelease(networkAddress
);
82 SCNetworkCheckReachabilityByName(const char *nodename
,
83 SCNetworkConnectionFlags
*flags
)
85 SCNetworkReachabilityRef networkAddress
;
89 _SCErrorSet(kSCStatusInvalidArgument
);
93 networkAddress
= SCNetworkReachabilityCreateWithName(NULL
, nodename
);
94 ok
= SCNetworkReachabilityGetFlags(networkAddress
, flags
);
95 CFRelease(networkAddress
);
100 SCNetworkInterfaceRefreshConfiguration(CFStringRef ifName
)
104 SCDynamicStoreRef store
= NULL
;
106 store
= SCDynamicStoreCreate(NULL
,
107 CFSTR("SCNetworkInterfaceRefreshConfiguration"),
112 key
= SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL
,
113 kSCDynamicStoreDomainState
,
115 kSCEntNetRefreshConfiguration
);
116 ret
= SCDynamicStoreNotifyValue(store
, key
);