• 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
Changing IP Address and Config method using the System configur ation framework.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Changing IP Address and Config method using the System configur ation framework.


  • Subject: Changing IP Address and Config method using the System configur ation framework.
  • From: Sandeep Vaidya <email@hidden>
  • Date: Wed, 18 May 2005 13:59:21 +0530

Title: Changing IP Address and Config method using the System configuration framework.

Hi,

I am able to change the Network settings using the following code which I wrote for setting the IP Address.
I am wondering, there will be any change in the preference file format of the other versions of MAC. Please
let me know if I need to take care of some more things.

void SetIPAddress(char *ipAddr)
{
    CFStringRef strIPAddr;
    CFMutableDictionaryRef  level1 = NULL, level2 = NULL, level3 = NULL;
    CFMutableArrayRef   array;
    SCPreferencesRef        prefs;
   
    prefs = SCPreferencesCreate(NULL, CFSTR("netutils"), NULL);        

    // Need to replace the text hardcoding with the constants
    level1 = SCPreferencesGetValue(prefs, CFSTR("NetworkServices"));
    // Need to replace with the logic to get the interface name.
    level2 = CFDictionaryGetValue(level1, CFSTR("0"));
    level3 = CFDictionaryGetValue(level2, CFSTR("IPv4"));

    array = CFArrayCreateMutable(NULL, 5, &kCFTypeArrayCallBacks);
    strIPAddr = CFStringCreateWithCString(NULL, ipAddr, CFStringGetSystemEncoding());
    CFArrayAppendValue(array, strIPAddr);
    // Need to replace the text hardcoding with the constants
    CFDictionarySetValue(level3, CFSTR("Addresses"), array);
    CFDictionarySetValue(level2, CFSTR("IPv4"), level3);
    // Need to replace with the logic to get the interface name.
    CFDictionarySetValue(level1, CFSTR("0"), level2);
    SCPreferencesSetValue(prefs, CFSTR("NetworkServices"), level1);

    SCPreferencesCommitChanges(prefs);
    SCPreferencesApplyChanges(prefs);      
   
    CFRelease(strIPAddr);
    CFRelease(level1);
    CFRelease(level2);
    CFRelease(level3);
    CFRelease(array);
}

Thanks and Regards
-Sandeep. Vaidya

This message is free from Virus - IMSS
 _______________________________________________
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: Changing IP Address and Config method using the System configur ation framework.
      • From: Allan Nathanson <email@hidden>
  • Prev by Date: Re: Changing IP Address and Config method using the System configurat ion framework.
  • Next by Date: Re: Changing IP Address and Config method using the System configurat ion framework.
  • Previous by thread: Re: Changing IP Address and Config method using the System configurat ion framework.
  • Next by thread: Re: Changing IP Address and Config method using the System configur ation framework.
  • Index(es):
    • Date
    • Thread