Which settings can be overridden duration of the connection?
Which settings can be overridden duration of the connection?
- Subject: Which settings can be overridden duration of the connection?
- From: zheng ying <email@hidden>
- Date: Fri, 10 Apr 2009 22:44:45 +0800
I use SCNetworkConnectionStart to connect the network, but I found the DNS can not setting by options dictionary.
the API doc says:
Some of the settings can be overridden for the duration of the
connection. These are specified in an options dictionary. The options
dictionary uses the same format as a network service defined in the
system configuration preferences schema.
but which settings can be overridden duration of the connection?
who can give me a doc. or something about that.
Here some test code for dialup, the DNS settting No effect.
...
//set PPP
CFDictionaryRef dictOptionsPPP = nil;
if(authType == AUTHTYPE_PAP || authType == AUTHTYPE_CHAP)
{
dictOptionsPPP = CFDictionaryCreate(NULL, (const void **)&keysPPP, (const void **)&valsPPP, 5, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
else
{
dictOptionsPPP = CFDictionaryCreate(NULL, (const void **)&keysPPP, (const void **)&valsPPP, 4, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
}
CFStringRef keysModem[] = { kSCPropNetModemConnectionScript };
CFStringRef valsModem[] = { CFSTR("Modem_SCRIPT") };
CFDictionaryRef dictOptionsModem = CFDictionaryCreate(NULL, (const
void **)&keysModem, (const void **)&valsModem, 1,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
//set DNS -----------------
NO effect I don't kown why CFStringRef strDNS[1];
strDNS[0] = CFSTR("132.168.111.111");
CFArrayRef arrayDNSAddress = CFArrayCreate(NULL,(const void **)&strDNS,1,&kCFTypeArrayCallBacks);
CFStringRef keysDNS[] = { kSCPropNetDNSServerAddresses };
CFTypeRef valsDNS[] = { arrayDNSAddress };
CFDictionaryRef dictOptionsDNS = nil;
dictOptionsDNS = CFDictionaryCreate(NULL, (const void **)&keysDNS, (const void **)&valsDNS, 1, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFStringRef keys[] = { kSCEntNetPPP, kSCEntNetModem, kSCEntNetDNS};
CFDictionaryRef vals[] = { dictOptionsPPP, dictOptionsModem , dictOptionsDNS};
CFDictionaryRef dictOptionsForDial = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&vals, 3, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
// start connecting
if (!SCNetworkConnectionStart( _connectionModem, dictOptionsForDial, false))
{
CNSLog(@"Failed connect");
nErr = ERR_MODEM_FAIL_CONNECT;
}
...
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden