changeset 336:7142a751aca2

add pbvlan methods for Port Based VLAN setup
author ray@terran.dlink.ua
date Fri, 03 Feb 2012 17:30:35 +0200
parents 1ba9fae8224d
children 3c0fed8eac60
files head/sys/dev/switch/switch.c
diffstat 1 files changed, 35 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/head/sys/dev/switch/switch.c	Fri Feb 03 17:30:23 2012 +0200
+++ b/head/sys/dev/switch/switch.c	Fri Feb 03 17:30:35 2012 +0200
@@ -176,6 +176,26 @@
 }
 
 static int
+switch_pbvlan_sub(struct switch_softc *sc, struct vlan_vlan_config *vlan)
+{
+	int error = 0;
+
+	SWITCH_ASSERT_LOCKED(sc);
+
+	if (vlan->cmd == 1) {
+		/* Set */
+		error = SWITCH_PBVLAN_SETPORTS(sc->child, vlan->index,
+		    vlan->d.port.allowed);
+	} else {
+		/* Get */
+		error = SWITCH_PBVLAN_GETPORTS(sc->child, vlan->index,
+		    &vlan->d.port.allowed);
+	}
+
+	return (error);
+}
+
+static int
 vlan_config_sub(struct switch_softc *sc, struct vlan_config *vlan_config)
 {
 
@@ -206,6 +226,21 @@
 		return (EINVAL);
 	}
 
+	switch (vlan->vlan_type) {
+	case VLAN_TYPE_PORT:
+		error = switch_pbvlan_sub(sc, vlan);
+		return (error);
+		break;
+	case VLAN_TYPE_DOT1Q:
+		/* Handled here */
+		break;
+	case VLAN_TYPE_NONE:
+		return (0);
+	case VLAN_TYPE_ISL:
+	default:
+		return (EINVAL);
+	}
+
 	if (vlan->cmd == 1) {
 		/* Set */
 		if (vlan->vlan_type == VLAN_TYPE_DOT1Q) {