• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Switching Airport of in code using SCF
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Switching Airport of in code using SCF


  • Subject: Re: Switching Airport of in code using SCF
  • From: Jonathan Guy <email@hidden>
  • Date: Mon, 18 Feb 2008 16:19:56 +0000

Hi
Thanks Allan that seemed to get the setting applied in the system config but Airport remains up after I run the tool and only comes down after a reboot. Is there any way I can force the interface down? I tried SCNetworkInterfaceForceConfigurationRefresh at the end of the code but that didn't work.

Thanks again

Jonathan

This is what I've done:

gPrefsRef = SCPreferencesCreate(nil, CFSTR("InterfaceConfig2"), nil);
if (gPrefsRef == nil) 
errorAndExit("InterfaceConfig failure: SCPreferencesCreate failed");

if (!SCPreferencesLock(gPrefsRef, YES)) 
errorAndExit("InterfaceConfig failure: SCPreferencesLock could not get a lock");


NSEnumerator *e = [(NSArray *)SCNetworkSetCopyServices(SCNetworkSetCopyCurrent(gPrefsRef)) objectEnumerator];
SCNetworkServiceRef service;

while (service = (SCNetworkServiceRef)[e nextObject]) {
interfaceRef = SCNetworkServiceGetInterface(service);
if (isInterfaceOfType(interfaceRef, kSCNetworkInterfaceTypeIEEE80211)) {
CFDictionaryRef dict = (CFMutableDictionaryRef)[NSMutableDictionary dictionaryWithObjectsAndKeys:(NSString *)kSCValNetAirPortJoinModeAutomatic,
 (NSString *)kSCPropNetAirPortJoinMode,
 [NSNumber numberWithInt:0],
 (NSString *)kSCPropNetAirPortPowerEnabled, nil];
if (SCNetworkInterfaceSetConfiguration(interfaceRef, dict) == NO) {
syslog(LOG_LOCAL7 | LOG_ALERT, "InterfaceConfig failure: Could not set Airport interface settings");
}
}
}


if (SCPreferencesCommitChanges(gPrefsRef) == NO)
errorAndExit("InterfaceConfig failure: SCPreferencesCommitChanges failed");
if (SCPreferencesApplyChanges(gPrefsRef) == NO)
errorAndExit("InterfaceConfig failure: SCPreferencesApplyChanges failed");

SCPreferencesUnlock(gPrefsRef);
CFRelease(gPrefsRef);
 _______________________________________________
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

  • Follow-Ups:
    • Re: Switching Airport of in code using SCF
      • From: Allan Nathanson <email@hidden>
  • Prev by Date: Re: Switching Airport of in code using SCF
  • Next by Date: Re: Switching Airport of in code using SCF
  • Previous by thread: Re: Switching Airport of in code using SCF
  • Next by thread: Re: Switching Airport of in code using SCF
  • Index(es):
    • Date
    • Thread