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; }
private static MatchBuilder createInphyportMatch(NodeId nodeId) { MatchBuilder match = new MatchBuilder(); match.setInPort(new NodeConnectorId(nodeId + ":202")); match.setInPhyPort(new NodeConnectorId(nodeId + ":10122")); return match; }
public static FlowBuilder getPipelineFlow(short table, short gotoTable) { FlowBuilder flowBuilder = new FlowBuilder(); flowBuilder.setMatch(new MatchBuilder().build()); String flowName = "DEFAULT_PIPELINE_FLOW_" + table; return initFlowBuilder(flowBuilder, flowName, table) .setPriority(0); }
private FlowBuilder createBaseFlowForPortMatch(NodeConnector nc) { FlowBuilder floodFlow = new FlowBuilder().setTableId(flowTableId).setFlowName("flood"); floodFlow.setId(new FlowId(Long.toString(floodFlow.hashCode()))); Match match = new MatchBuilder().setInPort(nc.getId()).build(); floodFlow.setMatch(match) // .setPriority(flowPriority) // .setBufferId(OFConstants.OFP_NO_BUFFER) // .setHardTimeout(flowHardTimeout) // .setIdleTimeout(flowIdleTimeout) // .setCookie(new FlowCookie(BigInteger.valueOf(flowCookieInc.getAndIncrement()))) .setFlags(new FlowModFlags(false, false, false, false, false)); return floodFlow; }
/** * 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(); }
private static MatchBuilder createMatch33() { final MatchBuilder match = new MatchBuilder(); final Ipv4MatchBuilder ipv4Match = new Ipv4MatchBuilder(); final Ipv4Prefix prefix = new Ipv4Prefix("10.0.0.10"); ipv4Match.setIpv4Source(prefix); final Ipv4Match i4m = ipv4Match.build(); match.setLayer3Match(i4m); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0xfffeL)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); return match; }
private static MatchBuilder createLLDPMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x88ccL)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); return match; }
private Flow buildIngressExternalArpFlow(short goToTable, MacAddress srcMacAddress, int priority, OrdinalFactory.EndpointFwdCtxOrdinals epFwdCtxOrdinals) { if (srcMacAddress == null) { return null; } MatchBuilder mb = new MatchBuilder() .setEthernetMatch(ethernetMatch(srcMacAddress, null, ARP)); FlowBuilder flowBuilder = base(tableId).setPriority(priority); flowBuilder.setInstructions(instructions(applyActionIns(createEpFwdCtxActions(epFwdCtxOrdinals)), gotoTableIns(goToTable))); flowBuilder.setId(FlowIdUtils.newFlowId(tableId, "inbound-external-arp", mb.build())); flowBuilder.setMatch(mb.build()); return flowBuilder.build(); }
/** * @return */ private static MatchBuilder createICMPv6Match() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x86ddL)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version ipmatch.setIpProtocol((short) 58); match.setIpMatch(ipmatch.build()); final Icmpv6MatchBuilder icmpv6match = new Icmpv6MatchBuilder(); // icmpv6 // match icmpv6match.setIcmpv6Type((short) 135); icmpv6match.setIcmpv6Code((short) 1); match.setIcmpv6Match(icmpv6match.build()); return match; }
if (segmentation != null) { Integer vlanId = segmentation.getSegmentationId(); Match match = new MatchBuilder() .setVlanMatch(FlowUtils.vlanMatch(vlanId, true)) .setInPort(connectorId) .build(); List<Instruction> instructions = new ArrayList<>(); instructions.add(FlowUtils.popVlanInstruction(0));
/** * @return */ private static MatchBuilder createL4UDPMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x0800L)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version ipmatch.setIpProtocol((short) 17); match.setIpMatch(ipmatch.build()); final PortNumber srcport = new PortNumber(1325); final PortNumber dstport = new PortNumber(42); final UdpMatchBuilder udpmatch = new UdpMatchBuilder(); // udp match udpmatch.setUdpDestinationPort(dstport); udpmatch.setUdpSourcePort(srcport); match.setLayer4Match(udpmatch.build()); return match; }
/** * @return */ private static MatchBuilder createICMPv4Match() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder eth = new EthernetMatchBuilder(); final EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(0x0800L)); eth.setEthernetType(ethTypeBuilder.build()); match.setEthernetMatch(eth.build()); final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version ipmatch.setIpProtocol((short) 1); match.setIpMatch(ipmatch.build()); final Icmpv4MatchBuilder icmpv4match = new Icmpv4MatchBuilder(); // icmpv4 // match icmpv4match.setIcmpv4Type((short) 8); icmpv4match.setIcmpv4Code((short) 0); match.setIcmpv4Match(icmpv4match.build()); return match; }
/** * 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; }
/** * @return */ private static MatchBuilder createToSMatch() { final MatchBuilder match = new MatchBuilder(); final EthernetMatchBuilder ethmatch = new EthernetMatchBuilder(); final EthernetTypeBuilder ethtype = new EthernetTypeBuilder(); final EtherType type = new EtherType(0x0800L); ethmatch.setEthernetType(ethtype.setType(type).build()); match.setEthernetMatch(ethmatch.build()); final IpMatchBuilder ipmatch = new IpMatchBuilder(); // ipv4 version ipmatch.setIpProtocol((short) 6); final Dscp dscp = new Dscp((short) 8); ipmatch.setIpDscp(dscp); match.setIpMatch(ipmatch.build()); return match; }
private void programConntrackInvDropRule(Long dpidLong, String segmentationId, long localPort, String attachMac, Integer priority, boolean write) { MatchBuilder matchBuilder = new MatchBuilder(); String flowName = "Ingress_Fixed_Conntrk_InvDrop_" + segmentationId + "_" + localPort + "_"; matchBuilder = MatchUtils.createV4EtherMatchWithType(matchBuilder,null,attachMac, MatchUtils.ETHERTYPE_IPV4); matchBuilder = MatchUtils.addCtState(matchBuilder,MatchUtils.TRACKED_INV_CT_STATE, MatchUtils.TRACKED_INV_CT_STATE_MASK); FlowBuilder flowBuilder = FlowUtils.createFlowBuilder(flowName, priority, matchBuilder, getTable()); addPipelineInstruction(flowBuilder, null, true); NodeBuilder nodeBuilder = FlowUtils.createNodeBuilder(dpidLong); syncFlow(flowBuilder ,nodeBuilder, write); }
/** * Create Destination UDP Port Match * * @param matchBuilder MatchBuilder Object without a match yet * @param udpDstPort Integer representing a destination UDP port * @return matchBuilder Map MatchBuilder Object with a match */ public static MatchBuilder createSetDstUdpMatch(MatchBuilder matchBuilder, PortNumber udpDstPort) { EthernetMatchBuilder ethType = new EthernetMatchBuilder(); EthernetTypeBuilder ethTypeBuilder = new EthernetTypeBuilder(); ethTypeBuilder.setType(new EtherType(IPV4_LONG)); ethType.setEthernetType(ethTypeBuilder.build()); matchBuilder.setEthernetMatch(ethType.build()); IpMatchBuilder ipmatch = new IpMatchBuilder(); ipmatch.setIpProtocol((short) 17); matchBuilder.setIpMatch(ipmatch.build()); UdpMatchBuilder udpmatch = new UdpMatchBuilder(); udpmatch.setUdpDestinationPort(udpDstPort); matchBuilder.setLayer4Match(udpmatch.build()); return matchBuilder; }
public static void addMatchDstIpv6(MatchBuilder match, Ipv6Prefix dstIp) { Ipv6MatchBuilder ipv6match = new Ipv6MatchBuilder(); ipv6match.setIpv6Destination(dstIp); match.setLayer3Match(mergeIpv6Match(match, ipv6match)); }
/** * Convert the ACL into an OpenFlow {@link MatchBuilder} * @return {@link MatchBuilder} */ //TODO: Matches will overwrite previous matches for ethernet and ip since these methods // can be called successively for the same ACL. // This requires fixing the MatchUtils to preserve previously set fields. protected MatchBuilder buildMatch() { if (matches.getAceType() instanceof AceEth) { addEthMatch(); } else if (matches.getAceType() instanceof AceIp) { addIpMatch(); } LOG.info("buildMatch: {}", matchBuilder.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; }
/** * @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; }