Changing IP Address and Config method using the System configurat ion framework.
Changing IP Address and Config method using the System configurat ion framework.
- Subject: Changing IP Address and Config method using the System configurat ion framework.
- From: Sandeep Vaidya <email@hidden>
- Date: Mon, 16 May 2005 18:03:47 +0530
Title: Changing IP Address and Config method using the System configuration framework.
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.
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