Porblems passing PPP options to SCNetworkConnectionStart
Porblems passing PPP options to SCNetworkConnectionStart
- Subject: Porblems passing PPP options to SCNetworkConnectionStart
- From: Luis Soltero <email@hidden>
- Date: Tue, 06 Mar 2007 04:22:39 -0500
Hello All,
It seems that several people on this list are developing custom dialup applications and all seem to be having problems
passing PPP options to SCNetworkConnectionStart().
Here are two recent posts requesting help on this issue
http://lists.apple.com/archives/macnetworkprog/2007/Feb/msg00026.html
http://lists.apple.com/archives/Macnetworkprog/2007/Feb/msg00004.html
The common thread to the problem is that no matter how you create the options dictionary, SCNetworkConnectionStart()
just ignores the options.
Here is my attempt to override the username, password, and phone number coded in the PPP network settings for the
default location. This code is based on the developer.apple.com sample dialer
CFStringRef keys[3] = { NULL, NULL, NULL };
CFStringRef vals[3] = { NULL, NULL, NULL };
CFIndex numkeys = 0;
keys[numkeys] = kSCPropNetPPPAuthName;
vals[numkeys++] = CFSTR("email@hidden");
keys[numkeys] = kSCPropNetPPPAuthPassword;
vals[numkeys++] = CFSTR("bogus");
keys[numkeys] = kSCPropNetPPPCommRemoteAddress;
vals[numkeys++] = CFSTR("1234567890");
optionsForDial = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&vals, numkeys,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
if (err == 0) {
ok = SCNetworkConnectionStart(m_hActiveConnection,optionsForDial,false);
if ( ! ok ) {
err = SCError();
}
the connection is dialed using the values in the network preferences and the optional values passed in optionsForDial
are ignored.
a variation of a recent posting which attempts to disable the alerts also fails.
CFMutableDictionaryRef dicc;
if (optionsForDial!=NULL) {
dicc = CFDictionaryCreateMutableCopy(NULL, 0, optionsForDial);
} else {
dicc = CFDictionaryCreateMutable(NULL, 0, &kCFCopyStringDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
}
int elementValue = 0;
CFNumberRef elementNumRef = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &elementValue);
CFDictionaryAddValue (dicc,CFSTR("AlertEnable"), elementNumRef);
CFRelease(elementNumRef);
optionsForDial = dicc;
// Initiate the connection.
if (err == 0) {
ok = SCNetworkConnectionStart(m_hActiveConnection,optionsForDial,false);
if ( ! ok ) {
err = SCError();
}
}
the docs state this
http://developer.apple.com/documentation/Networking/Conceptual/SystemConfigFrameworks/SC_ReachConnect/chapter_5_section_5.html#//apple_ref/doc/uid/TP40001065-CH204-TPXREF107
By default, the SCNetworkConnectionStart function uses the user’s preferred connection settings to start the connection.
You can, however, provide a dictionary of values to override some of these settings for the duration of the connection.
If you do provide a dictionary of additional settings be aware that:
The dictionary must be in the correct format for a network service dictionary (described in “The NetworkServices
Dictionary”). If you do not follow this format precisely, the PPP controller may ignore the dictionary.
The PPP controller merges the settings you provide with the user’s existing settings before the connection is
established, ignoring any inappropriate values in your dictionary.
which leads me to conclude
a) that SCNetworkConnectionStart is busted.
or
b) we dont know how to create a dictionary in the proper "network services dictionary" format.
or
c) the values that we are trying to modify are inappropriate and therefore being ignored.
Can anyone shed any light on this issue? Can anyone provide us with a code sample that builds a dictionary in the
appropriate format and successfully changes some of the default PPP options before dialing.
Any help on this matter is greatly appreciated.
Thanks in advanced for your help.
--luis
--
Luis Soltero, Ph.D., MCS
Director of Software Development, CTO
Global Marine Networks, LLC
StarPilot, LLC
Tel: 865-379-8723
Fax: 865-681-5017
E-Mail: email@hidden
Web: http://www.globalmarinenet.net
Web: http://www.starpilotllc.com
_______________________________________________
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