@Override public Optional<MatchBuilder> process(@Nonnull VlanPcpCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final VlanMatchBuilder vlanMatchBuilder = data.getVlanMatchBuilder(); final VlanPcp vlanPcp = source.getVlanPcp(); if (vlanPcp != null) { vlanMatchBuilder .setVlanPcp(new org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanPcp( vlanPcp.getVlanPcp())); matchBuilder.setVlanMatch(vlanMatchBuilder.build()); } return Optional.of(matchBuilder); } }
vlanIdBuilder.setVlanId(srcVlanMatch.getVlanId().getVlanId()); vlanMatchBuilder.setVlanId(vlanIdBuilder.build()); Match match = new MatchBuilder(srcMatch).setVlanMatch(vlanMatchBuilder.build()).build(); Match match1 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_FALSE).build(); Match match2 = new MatchBuilder(srcMatch).setVlanMatch(VLAN_MATCH_TRUE).build(); Optional<? extends Flow> optional2 = injectMatchToFlow(srcFlow, match2); if (optional2.isPresent()) {
@Override public Optional<MatchBuilder> process(@Nonnull VlanVidCase source, MatchResponseConvertorData data, ConvertorExecutor convertorExecutor) { final MatchBuilder matchBuilder = data.getMatchBuilder(); final VlanMatchBuilder vlanMatchBuilder = data.getVlanMatchBuilder(); final VlanVid vlanVid = source.getVlanVid(); if (vlanVid != null) { VlanIdBuilder vlanBuilder = new VlanIdBuilder(); vlanBuilder.setVlanId(new VlanId(vlanVid.getVlanVid())); vlanBuilder.setVlanIdPresent(vlanVid.isCfiBit()); vlanMatchBuilder.setVlanId(vlanBuilder.build()); matchBuilder.setVlanMatch(vlanMatchBuilder.build()); } return Optional.of(matchBuilder); } }
/** * Generates a {@link Flow} for tagging VLAN traffic based on given arguments. * * @param nodeId of {@link Node} from which external interfaces are resolved * @param fdId {@link L2FloodDomain} ordinal to match against * @param vlanId applied to the traffic * @param priority of flow in the table * @return {@link List} of {@link Flow} matching {@link L2FloodDomain} in REG5, * external interfaces of {@link Node} in REG7 and VLAN not set. */ private List<Flow> buildPushVlanFlow(NodeId nodeId, int fdId, Integer vlanId, int priority) { List<Flow> flows = new ArrayList<>(); for (Long portNum : ctx.getSwitchManager().getExternalPortNumbers(nodeId)) { MatchBuilder mb = new MatchBuilder().setVlanMatch(FlowUtils.vlanMatch(0, false)); addNxRegMatch(mb, RegMatch.of(NxmNxReg7.class, BigInteger.valueOf(portNum).longValue()), RegMatch.of(NxmNxReg5.class, Long.valueOf(fdId))); Match match = mb.build(); List<ActionBuilder> pushVlanActions = new ArrayList<>(); pushVlanActions.addAll(FlowUtils.pushVlanActions(vlanId)); pushVlanActions.add(new ActionBuilder().setOrder(0).setAction(nxOutputRegAction(NxmNxReg7.class))); FlowId flowid = FlowIdUtils.newFlowId(TABLE_ID, "external_push_vlan", match); flows.add(base().setPriority(priority) .setId(flowid) .setMatch(match) .setInstructions(FlowUtils.instructions(applyActionIns(pushVlanActions))) .build()); } return flows; }
public static void addMatchVlan(MatchBuilder match, int vlan) { VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(); VlanIdBuilder vlanIdBuilder = new VlanIdBuilder(); VlanId vlanId = new VlanId(vlan); vlanIdBuilder.setVlanId(vlanId); vlanIdBuilder.setVlanIdPresent(true); vlanMatchBuilder.setVlanId(vlanIdBuilder.build()); match.setVlanMatch(vlanMatchBuilder.build()); }
/** * Create Ethernet Destination Match * * @param matchBuilder MatchBuilder Object without a match yet * @param vlanId Integer representing a VLAN ID Integer representing a VLAN ID * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createVlanIdMatch(MatchBuilder matchBuilder, VlanId vlanId, boolean present) { VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(); VlanIdBuilder vlanIdBuilder = new VlanIdBuilder(); vlanIdBuilder.setVlanId(new VlanId(vlanId)); vlanIdBuilder.setVlanIdPresent(present); vlanMatchBuilder.setVlanId(vlanIdBuilder.build()); matchBuilder.setVlanMatch(vlanMatchBuilder.build()); return matchBuilder; }
/** * @return */ private static MatchBuilder createVlanMatch() { final MatchBuilder match = new MatchBuilder(); // vlan match final VlanMatchBuilder vlanBuilder = new VlanMatchBuilder(); final VlanIdBuilder vlanIdBuilder = new VlanIdBuilder(); final VlanId vlanId = new VlanId(10); final VlanPcp vpcp = new VlanPcp((short) 3); vlanBuilder.setVlanPcp(vpcp); vlanIdBuilder.setVlanId(vlanId); vlanIdBuilder.setVlanIdPresent(true); vlanBuilder.setVlanId(vlanIdBuilder.build()); match.setVlanMatch(vlanBuilder.build()); return match; }
public static org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match toMatch( Match sourceMatch) { if (sourceMatch != null) { MatchBuilder targetBuilder = new MatchBuilder(); targetBuilder.setEthernetMatch(ethernetMatch(sourceMatch)); targetBuilder.setIpMatch(ipMatch(sourceMatch)); targetBuilder.setVlanMatch(vlanMatch(sourceMatch)); targetBuilder.setLayer3Match(layer3Match(sourceMatch)); targetBuilder.setLayer4Match(layer4Match(sourceMatch)); targetBuilder.setInPort(inPortMatch(sourceMatch)); return targetBuilder.build(); } return null; }
/** * Generates a {@link Flow} for tagging VLAN traffic based on given arguments. * * @param ipv4Address source IPv4 address * @param vlanId ID of VLAN tag to apply * @param priority priority of the flow in the table * @return {@link Flow} matching IPv4 source address, IPv4 ether-type and VLAN not set. */ private Flow buildPushVlanFlow(Ipv4Address ipv4Address, Integer vlanId, int priority) { // It is not needed here to match against external interfaces because // we only use NAT when going to external networks. Ipv4Prefix natIp = new Ipv4Prefix(ipv4Address.getValue() + "/32"); Match match = new MatchBuilder() .setEthernetMatch(FlowUtils.ethernetMatch(null, null, Long.valueOf(FlowUtils.IPv4))) .setLayer3Match(new Ipv4MatchBuilder().setIpv4Source(natIp).build()) .setVlanMatch(FlowUtils.vlanMatch(0, false)) .build(); List<ActionBuilder> pushVlanActions = new ArrayList<>(); pushVlanActions.addAll(FlowUtils.pushVlanActions(vlanId)); pushVlanActions.add(new ActionBuilder().setOrder(0).setAction(nxOutputRegAction(NxmNxReg7.class))); FlowId flowid = FlowIdUtils.newFlowId(TABLE_ID, "external_nat_push_vlan", match); return base().setPriority(priority) .setId(flowid) .setMatch(match) .setInstructions(FlowUtils.instructions(applyActionIns(pushVlanActions))) .build(); }
Integer vlanId = segmentation.getSegmentationId(); Match match = new MatchBuilder() .setVlanMatch(FlowUtils.vlanMatch(vlanId, true)) .setInPort(connectorId) .build();
/** * Create Ethernet Destination Match * * @param matchBuilder MatchBuilder Object without a match yet * @param vlanId Integer representing a VLAN ID Integer representing a VLAN ID * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createVlanIdMatch(MatchBuilder matchBuilder, Integer vlanId, boolean present) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(VLANTAGGED_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(); VlanIdBuilder vlanIdBuilder = new VlanIdBuilder(); vlanIdBuilder.setVlanId(new VlanId(vlanId)); vlanIdBuilder.setVlanIdPresent(present); vlanMatchBuilder.setVlanId(vlanIdBuilder.build()); matchBuilder.setVlanMatch(vlanMatchBuilder.build()); return matchBuilder; }
/** * Create Ethernet Destination Match * * @param matchBuilder MatchBuilder Object without a match yet * @param vlanId Integer representing a VLAN ID Integer representing a VLAN ID * @param present Boolean telling if there's a VLAN ID or not * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createVlanIdMatch(MatchBuilder matchBuilder, Integer vlanId, boolean present) { EthernetMatchBuilder eth = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(VLANTAGGED_LONG)); eth.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(eth.build()); VlanMatchBuilder vlanMatchBuilder = new VlanMatchBuilder(); VlanIdBuilder vlanIdBuilder = new VlanIdBuilder(); vlanIdBuilder.setVlanId(new VlanId(vlanId)); vlanIdBuilder.setVlanIdPresent(present); vlanMatchBuilder.setVlanId(vlanIdBuilder.build()); matchBuilder.setVlanMatch(vlanMatchBuilder.build()); return matchBuilder; }
.setVlanMatch(vlanMatchBuilder.build()) .setInPort(inPort) .setLayer3Match(ipv4Match);
.setVlanMatch(vlanMatchBuilder.build()) .setInPort(inPort);
if (l2Fd != null && l2Fd.getAugmentation(Segmentation.class) != null) { Integer vlanId = l2Fd.getAugmentation(Segmentation.class).getSegmentationId(); matchBuilder.setVlanMatch(FlowUtils.vlanMatch(0, false)); Action[] pushVlanActions = {FlowUtils.pushVlanAction(), FlowUtils.setVlanId(vlanId)}; flowBuilder.setInstructions(instructions(FlowUtils.applyActionIns(ArrayUtils.addAll(
builder.setVlanMatch(vmatch.build());
vlanIdBuilder.setVlanIdPresent(vlanId != 0); vlanMatchBuilder.setVlanId(vlanIdBuilder.build()); matchBuilder.setVlanMatch(vlanMatchBuilder.build()); matchBuilder.setVlanMatch(vlanMatchBuilder.build());