1 #include "DNSCommon.h" // Defines general DNS utility routines
3 // To match *either* a v4 or v6 instance of this interface
4 mDNSlocal mDNSInterfaceID
SearchForInterfaceByAddr(mDNSAddr
* addr
)
6 NetworkInterfaceInfoOSX
*i
;
7 for (i
= mDNSStorage
.p
->InterfaceList
; i
; i
= i
->next
)
10 if ((i
->ifinfo
.ip
.type
== mDNSAddrType_IPv4
) &&
11 i
->ifinfo
.ip
.ip
.v4
.NotAnInteger
== addr
->ip
.v4
.NotAnInteger
)
12 return i
->ifinfo
.InterfaceID
;
13 else if ((i
->ifinfo
.ip
.type
== mDNSAddrType_IPv6
) &&
14 (i
->ifinfo
.ip
.ip
.v6
.l
[0] == addr
->ip
.v6
.l
[0] &&
15 i
->ifinfo
.ip
.ip
.v6
.l
[1] == addr
->ip
.v6
.l
[1] &&
16 i
->ifinfo
.ip
.ip
.v6
.l
[2] == addr
->ip
.v6
.l
[2] &&
17 i
->ifinfo
.ip
.ip
.v6
.l
[3] == addr
->ip
.v6
.l
[3])
19 return i
->ifinfo
.InterfaceID
;
24 mDNSexport
void SetInterfaces_ut(mDNSInterfaceID
* pri_id
, mDNSAddr
*pri_v4
, mDNSAddr
* pri_v6
, mDNSAddr
* pri_router
)
26 mDNSs32 utc
= mDNSPlatformUTC();
28 MarkAllInterfacesInactive(utc
);
29 UpdateInterfaceList(utc
);
30 ClearInactiveInterfaces(utc
);
31 SetupActiveInterfaces(utc
);
33 // set primary interface info
36 NetworkChangedKey_IPv4
= SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL
, kSCDynamicStoreDomainState
, kSCEntNetIPv4
);
37 NetworkChangedKey_IPv6
= SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL
, kSCDynamicStoreDomainState
, kSCEntNetIPv6
);
38 NetworkChangedKey_Hostnames
= SCDynamicStoreKeyCreateHostNames(NULL
);
39 NetworkChangedKey_Computername
= SCDynamicStoreKeyCreateComputerName(NULL
);
40 NetworkChangedKey_DNS
= SCDynamicStoreKeyCreateNetworkGlobalEntity(NULL
, kSCDynamicStoreDomainState
, kSCEntNetDNS
);
41 NetworkChangedKey_StateInterfacePrefix
= SCDynamicStoreKeyCreateNetworkInterfaceEntity(NULL
, kSCDynamicStoreDomainState
, CFSTR(""), NULL
);
43 mDNSPlatformGetPrimaryInterface(pri_v4
, pri_v6
, pri_router
);
44 addr
= (pri_v4
->type
== mDNSAddrType_IPv4
) ? pri_v4
: pri_v6
;
45 *pri_id
= SearchForInterfaceByAddr(addr
);
47 CFRelease(NetworkChangedKey_IPv4
);
48 CFRelease(NetworkChangedKey_IPv6
);
49 CFRelease(NetworkChangedKey_Hostnames
);
50 CFRelease(NetworkChangedKey_Computername
);
51 CFRelease(NetworkChangedKey_DNS
);
52 CFRelease(NetworkChangedKey_StateInterfacePrefix
);
56 mDNSexport mDNSBool
mDNSMacOSXCreateEtcHostsEntry_ut(const domainname
*domain
, const struct sockaddr
*sa
, const domainname
*cname
, char *ifname
, AuthHash
*auth
)
58 return mDNSMacOSXCreateEtcHostsEntry(domain
, sa
, cname
, ifname
, auth
);
61 mDNSexport
void UpdateEtcHosts_ut(void *context
)
63 mDNS_Lock(&mDNSStorage
);
64 UpdateEtcHosts(&mDNSStorage
, context
);
65 mDNS_Unlock(&mDNSStorage
);