@Override protected IntegerSpace featureValueOf(Interface actual) { return actual.getAllowedVlans(); } }
/** Returns true iff the given trunk interface allows its own native vlan. */ private static boolean trunkWithNativeVlanAllowed(Interface i) { return i.getSwitchportMode() == SwitchportMode.TRUNK && i.getNativeVlan() != null && i.getAllowedVlans().contains(i.getNativeVlan()); }
i -> { if (i.getSwitchportMode() == SwitchportMode.TRUNK) { i.getAllowedVlans().stream() .forEach( vlan ->
&& i2.getSwitchportMode() == SwitchportMode.TRUNK) { i1.getAllowedVlans().stream() .forEach( vlan -> { } else if (i2.getAllowedVlans().contains(vlan)) { if (!i1Tag.equals(i2.getNativeVlan()) && i2.getAllowedVlans().contains(i1Tag)) { edges.add(new Layer2Edge(node1, null, node2, i1Tag, i1Tag)); if (!i2Tag.equals(i1.getNativeVlan()) && i1.getAllowedVlans().contains(i2Tag)) { edges.add(new Layer2Edge(node1, i2Tag, node2, null, i2Tag));
@VisibleForTesting static void tryAddInterfaceToVlans( SpecifierContext ctxt, InterfaceSpecifier interfacesSpecifier, boolean excludeShutInterfaces, IntegerSpace vlans, Map<Integer, ImmutableSet.Builder<NodeInterfacePair>> switchedVlanInterfaces, String node, Interface iface) { if (!interfacesSpecifier.resolve(ImmutableSet.of(node), ctxt).contains(iface) || (excludeShutInterfaces && !iface.getActive()) || (iface.getInterfaceType() != InterfaceType.VLAN && !Boolean.TRUE.equals(iface.getSwitchport()))) { return; } if (iface.getInterfaceType() == InterfaceType.VLAN) { // Add VLAN associated with IRB-type interface tryAddInterfaceToVlan(switchedVlanInterfaces, node, iface, iface.getVlan(), vlans); } else if (iface.getSwitchportMode() == SwitchportMode.ACCESS) { // Add access VLAN when in ACCESS mode tryAddInterfaceToVlan(switchedVlanInterfaces, node, iface, iface.getAccessVlan(), vlans); } else if (iface.getSwitchportMode() == SwitchportMode.TRUNK) { // Add allowed VLANs when in TRUNK mode iface.getAllowedVlans().stream() .forEach( allowedVlan -> tryAddInterfaceToVlan(switchedVlanInterfaces, node, iface, allowedVlan, vlans)); } }
IntegerSpace.Builder vlans = IntegerSpace.builder(); if (iface.getSwitchportMode() == SwitchportMode.TRUNK) { // vlan trunked interface IntegerSpace allowed = iface.getAllowedVlans(); if (!allowed.isEmpty()) {