Re: Changing IP Address and Config method using the System configurat ion framework.
Re: Changing IP Address and Config method using the System configurat ion framework.
- Subject: Re: Changing IP Address and Config method using the System configurat ion framework.
- From: Ian Crew <email@hidden>
- Date: Mon, 16 May 2005 14:35:40 -0700
Hi Sandeep:
Mark Fleming and I worked on a free, open-source product a few years
back to do this sort of thing. It might be useful for you to use
directly, or as an example in your code. Check it out at
http://www.its.queensu.ca/source/msm/
(I've recently tested it with Tiger, and it does seem to work correctly....)
Hope this helps,
Ian Crew
At 6:03 PM +0530 5/16/05, Sandeep Vaidya wrote:
Hi,
I am working on a 10.3.1 Macintosh system. I need to change the
TCP/IP settings of the ethernet adopter.I wrote a small function to
change the IP address given below.
void SetIPAddress(char *ipAddr)
{
ipv4_dict = CFDictionaryCreateMutable(NULL,
0,
&kCFTypeDictionaryKeyCallBacks,
&kCFTypeDictionaryValueCallBacks);
store = SCDynamicStoreCreate(NULL,
CFSTR("IPConfiguration"),
NULL,
NULL);
ipv4_key = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,
kSCDynamicStoreDomainSetup,
kSCCompAnyRegex,
kSCEntNetIPv4);
CFStringRef pattern = SCDynamicStoreKeyCreateNetworkServiceEntity(NULL,
kSCDynamicStoreDomainState,
kSCCompAnyRegex,
kSCEntNetIPv4);
patternList = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
CFArrayAppendValue(patternList, pattern);
// get the Dictionary for Ip Address
ipv4_dict = SCDynamicStoreCopyMultiple(store, NULL, patternList);
result = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
CFDictionaryApplyFunction(ipv4_dict, GetIPAddressListFromValue, result);
// Create Array with the ipAddr to set
array = CFArrayCreateMutable(NULL, 5, &kCFTypeArrayCallBacks);
str = CFStringCreateWithCString(NULL, ipAddr, 20,
CFStringGetSystemEncoding());
CFArrayAppendValue(array, str);
CFDictionarySetValue(ipv4_dict, ipv4_key, array);
Boolean res = SCDynamicStoreSetValue(store, ipv4_key, ipv4_dict);
CFRelease(store);
CFRelease(ipv4_dict);
}
I am able to query the IP adress, but I am not able to set the IP address.
If you know what is the best way to set the IP address, it will be
of great healp to me.
Thanks in Advance
-Sandeep.
--
_______________________________________________________________
Ian Crew
Workstation Support Services
Information Systems and Technology
University of California, Berkeley
email@hidden
Voice: 510-642-7795
Fax: 510-643-5385
_______________________________________________
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