Sho SHIMIZU
Committed by Gerrit Code Review

ONOS-4561: Exclude non standard VLAN IDs

Change-Id: I3f7542521d0867e71f11263e46d6116cd6120428
......@@ -18,6 +18,7 @@ package org.onosproject.driver.query;
import java.util.Set;
import java.util.stream.IntStream;
import com.google.common.collect.ImmutableSet;
import org.onlab.packet.VlanId;
import org.onlab.util.GuavaCollectors;
import org.onosproject.net.PortNumber;
......@@ -36,6 +37,9 @@ public class FullVlanAvailable
private static final int MAX_VLAN_ID = VlanId.MAX_VLAN;
private static final Set<VlanId> ENTIRE_VLAN = getEntireVlans();
private static final Set<Integer> EXCLUDED = ImmutableSet.of(
(int) VlanId.NO_VID,
(int) VlanId.RESERVED);
@Override
public Set<VlanId> queryVlanIds(PortNumber port) {
......@@ -44,6 +48,7 @@ public class FullVlanAvailable
private static Set<VlanId> getEntireVlans() {
return IntStream.range(0, MAX_VLAN_ID)
.filter(x -> !EXCLUDED.contains(x))
.mapToObj(x -> VlanId.vlanId((short) x))
.collect(GuavaCollectors.toImmutableSet());
}
......
......@@ -29,6 +29,9 @@ public final class VlanId extends Identifier<Short> {
// required.
public static final short ANY_VALUE = (short) 0x1000;
public static final short NO_VID = 0; // 0 is not used for VLAN ID
public static final short RESERVED = 4095; // represents all tagged traffic
public static final VlanId NONE = VlanId.vlanId(UNTAGGED);
public static final VlanId ANY = VlanId.vlanId(ANY_VALUE);
......