/*
- * Copyright (c) 2004 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2004-2007 Apple Inc. All rights reserved.
*
* @APPLE_LICENSE_HEADER_START@
*
#include "net_service.h"
#include "net_interface.h"
#include "net_protocol.h"
+#include "prefs.h"
/* -------------------- */
SCNetworkInterfaceRef interface;
CFStringRef interfaceName;
Boolean ok;
- CFArrayRef order;
- CFMutableArrayRef newOrder;
SCNetworkServiceRef service = NULL;
CFStringRef serviceName;
CFStringRef setName;
ok = SCNetworkServiceSetName(service, serviceName);
CFRelease(serviceName);
if (!ok) {
- SCPrint(TRUE, stdout, CFSTR("service not created: %s\n"), SCErrorString(SCError()));
- CFRelease(service);
- return;
+ SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError()));
+ (void)SCNetworkServiceRemove(service);
+ goto done;
}
}
ok = SCNetworkSetAddService(net_set, service);
if (!ok) {
- SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError()));
- (void)SCNetworkServiceRemove(service);
- goto done;
- }
-
- net_changed = TRUE;
-
- order = SCNetworkSetGetServiceOrder(net_set);
- if (order == NULL) {
- newOrder = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
- } else {
- newOrder = CFArrayCreateMutableCopy(NULL, 0, order);
- }
- CFArrayAppendValue(newOrder, SCNetworkServiceGetServiceID(service));
- ok = SCNetworkSetSetServiceOrder(net_set, newOrder);
- CFRelease(newOrder);
- if (!ok) {
- SCPrint(TRUE, stdout, CFSTR("%s\n"), SCErrorString(SCError()));
+ SCPrint(TRUE, stdout, CFSTR("service not created: %s\n"), SCErrorString(SCError()));
(void)SCNetworkServiceRemove(service);
goto done;
}
- interfaceName = SCNetworkInterfaceGetLocalizedDisplayName(interface);
- if (interfaceName == NULL) {
- interfaceName = SCNetworkInterfaceGetBSDName(interface);
- }
- if (interfaceName != NULL) {
- if (!SCNetworkServiceSetName(service, interfaceName)) {
- CFIndex i;
-
- for (i = 2; i < 100; i++) {
- serviceName = CFStringCreateWithFormat(NULL, NULL, CFSTR("%@ %d"), interfaceName, i);
- ok = SCNetworkServiceSetName(service, serviceName);
- CFRelease(serviceName);
- if (ok) {
- break;
- }
- }
- }
- }
+ _prefs_changed = TRUE;
if (net_service != NULL) CFRelease(net_service);
net_service = CFRetain(service);
return;
}
- net_changed = TRUE;
-
+ _prefs_changed = TRUE;
return;
}
return;
}
- net_changed = TRUE;
-
+ _prefs_changed = TRUE;
return;
}
goto done;
}
- net_changed = TRUE;
+ _prefs_changed = TRUE;
serviceName = SCNetworkServiceGetName(service);
if (serviceName != NULL) {
return;
}
- net_changed = TRUE;
+ _prefs_changed = TRUE;
} else if (strcmp(command, "order") == 0) {
char *end;
return;
}
- net_changed = TRUE;
+ _prefs_changed = TRUE;
} else {
SCPrint(TRUE, stdout, CFSTR("set order to what?\n"));
return;