#include <SystemConfiguration/SystemConfiguration.h>
#include "SCNetworkConfigurationInternal.h"
+#include "SCPreferencesInternal.h"
#include <SystemConfiguration/SCValidation.h>
#include <SystemConfiguration/SCPrivate.h>
typedef struct {
CFMutableArrayRef vlans;
+ SCPreferencesRef ni_prefs;
SCPreferencesRef prefs;
} addContext, *addContextRef;
CFDictionaryRef vlan_info = (CFDictionaryRef)value;
CFStringRef vlan_name;
CFDictionaryRef vlan_options;
- SCNetworkInterfaceRef vlan_physical;
+ SCNetworkInterfaceRef vlan_physical = NULL;
CFStringRef vlan_physical_if;
CFNumberRef vlan_tag;
assert(vlan != NULL);
// set physical interface and tag
- vlan_physical = _SCNetworkInterfaceCreateWithBSDName(NULL, vlan_physical_if,
- kIncludeBondInterfaces);
+ if (myContext->ni_prefs != NULL) {
+ vlan_physical = __SCNetworkInterfaceCreateWithNIPreferencesUsingBSDName(NULL, myContext->ni_prefs,
+ vlan_physical_if);
+ }
+ if (vlan_physical == NULL) {
+ vlan_physical = _SCNetworkInterfaceCreateWithBSDName(NULL, vlan_physical_if,
+ kIncludeBondInterfaces);
+ }
assert(vlan_physical != NULL);
// since we KNOW that the physical interface supported VLANs when
{
addContext context;
CFDictionaryRef dict;
+ SCPreferencesRef ni_prefs;
CFStringRef path;
-
+
+ if ((prefs == NULL) ||
+ (__SCPreferencesUsingDefaultPrefs(prefs) == TRUE)) {
+ ni_prefs = NULL;
+ }
+ else {
+ ni_prefs = __SCPreferencesCreateNIPrefsFromPrefs(prefs);
+ }
context.vlans = CFArrayCreateMutable(NULL, 0, &kCFTypeArrayCallBacks);
+ context.ni_prefs = ni_prefs;
context.prefs = prefs;
path = CFStringCreateWithFormat(NULL,
if (isA_CFDictionary(dict)) {
my_CFDictionaryApplyFunction(dict, add_configured_interface, &context);
}
-
+ if (ni_prefs != NULL) {
+ CFRelease(ni_prefs);
+ }
return context.vlans;
}
ifr.ifr_data = (caddr_t)&vreq;
if (ioctl(s, SIOCGIFVLAN, (caddr_t)&ifr) == -1) {
- SCLog(TRUE, LOG_ERR, CFSTR("ioctl() failed: %s"), strerror(errno));
+ SCLog(TRUE, LOG_ERR, CFSTR("ioctl(SIOCGIFVLAN) failed: %s"), strerror(errno));
CFRelease(vlans);
vlans = NULL;
_SCErrorSet(kSCStatusFailed);
_SCErrorSet(kSCStatusInvalidArgument);
return NULL;
}
-
+
if (!isA_SCNetworkInterface(physical)) {
_SCErrorSet(kSCStatusInvalidArgument);
return NULL;
interfacePrivate = (SCNetworkInterfacePrivateRef)physical;
if (!interfacePrivate->supportsVLAN) {
- _SCErrorSet(kSCStatusInvalidArgument);
- return NULL;
+ if (__SCPreferencesUsingDefaultPrefs(prefs) == FALSE) {
+ interfacePrivate->supportsVLAN = TRUE;
+ }
+ else {
+ _SCErrorSet(kSCStatusInvalidArgument);
+ return NULL;
+ }
}
if (isA_CFNumber(tag)) {
{
SCNetworkInterfacePrivateRef interfacePrivate;
Boolean ok = TRUE;
-
+ SCPreferencesRef prefs;
+
if (!isA_SCVLANInterface(vlan)) {
_SCErrorSet(kSCStatusInvalidArgument);
return FALSE;
}
interfacePrivate = (SCNetworkInterfacePrivateRef)physical;
+ prefs = interfacePrivate->prefs;
+
if (!interfacePrivate->supportsVLAN) {
- _SCErrorSet(kSCStatusInvalidArgument);
- return FALSE;
+ if (__SCPreferencesUsingDefaultPrefs(prefs) == FALSE) {
+ interfacePrivate->supportsVLAN = TRUE;
+ }
+ else {
+ _SCErrorSet(kSCStatusInvalidArgument);
+ return FALSE;
+ }
}
if (isA_CFNumber(tag)) {