@Override public ObjectNode encodeCriterion(ObjectNode root, Criterion criterion) { final EthTypeCriterion ethTypeCriterion = (EthTypeCriterion) criterion; return root.put(CriterionCodec.ETH_TYPE, "0x" + Integer.toHexString(ethTypeCriterion.ethType().toShort() & 0xffff)); } }
private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) { TrafficSelector selector = fwd.selector(); EthTypeCriterion ethType = (EthTypeCriterion) selector .getCriterion(Criterion.Type.ETH_TYPE); if ((ethType == null) || ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) && (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST))) { return false; } return true; }
public static EtherType lookup(short etherType) { for (EtherType ethType : EtherType.values()) { if (ethType.ethType().toShort() == etherType) { return ethType; } } return UNKNOWN; }
private boolean isSupportedEthTypeObjective(ForwardingObjective fwd) { TrafficSelector selector = fwd.selector(); EthTypeCriterion ethType = (EthTypeCriterion) selector .getCriterion(Criterion.Type.ETH_TYPE); return !((ethType == null) || ((ethType.ethType().toShort() != Ethernet.TYPE_IPV4) && (ethType.ethType().toShort() != Ethernet.MPLS_UNICAST))); }
/** * Looks up the ethertype by it's numerical representation * and returns it's textual format. * * @param etherType the short value of the ethertype * @return a textual representation */ public EtherType lookup(short etherType) { for (EtherType ethType : EtherType.values()) { if (ethType.ethType().toShort() == etherType) { return ethType; } } return null; }
@Override public void init(Criterion criterion, int bitWidth) throws ByteSequenceTrimException { EthTypeCriterion c = (EthTypeCriterion) criterion; initAsExactMatch(copyFrom(c.ethType().toShort()), bitWidth); } }
(L2ModificationInstruction.ModMplsHeaderInstruction) l2Instruction; result.put(InstructionCodec.ETHERNET_TYPE, pushHeaderInstructions.ethernetType().toShort()); break; case TUNNEL_ID: (L2ModificationInstruction.ModMplsHeaderInstruction) l2Instruction; result.put(InstructionCodec.ETHERNET_TYPE, toHexWithPrefix(popHeaderInstruction.ethernetType().toShort())); break; case DEC_MPLS_TTL:
if (ethType.ethType().toShort() == Ethernet.TYPE_ARP) { if (filters.isEmpty()) { pendingVersatiles.add(fwd);
private Collection<FlowRule> processVersatile(ForwardingObjective forwardingObjective) { log.debug("Processing versatile forwarding objective"); FlowRule.Builder ruleBuilder = DefaultFlowRule.builder() .forDevice(deviceId) .withSelector(forwardingObjective.selector()) .withTreatment(forwardingObjective.treatment()) .withPriority(forwardingObjective.priority()) .fromApp(forwardingObjective.appId()); if (forwardingObjective.permanent()) { ruleBuilder.makePermanent(); } else { ruleBuilder.makeTemporary(TIME_OUT); } //ARP & DHCP Rule EthTypeCriterion ethCriterion = (EthTypeCriterion) forwardingObjective.selector().getCriterion(Criterion.Type.ETH_TYPE); UdpPortCriterion udpPortCriterion = (UdpPortCriterion) forwardingObjective .selector().getCriterion(Criterion.Type.UDP_DST); if (ethCriterion != null) { if (ethCriterion.ethType().toShort() == Ethernet.TYPE_ARP || ethCriterion.ethType().toShort() == Ethernet.TYPE_LLDP) { ruleBuilder.forTable(VNI_TABLE); return Collections.singletonList(ruleBuilder.build()); } else if (udpPortCriterion != null && udpPortCriterion.udpPort().toInt() == DHCP_SERVER_PORT) { ruleBuilder.forTable(VNI_TABLE); return Collections.singletonList(ruleBuilder.build()); } } return Collections.emptySet(); }
@Override public void programArpClassifierRules(DeviceId deviceId, PortNumber inPort, IpAddress dstIp, SegmentationId actionVni, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchInPort(inPort).matchEthType(ETH_TYPE.ethType().toShort()) .matchArpTpa(Ip4Address.valueOf(dstIp.toString())).build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setTunnelId(Long.parseLong(actionVni.segmentationId())) .build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(ARP_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("ArpClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("ArpClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
private ForwardingObjective.Builder createPeerObjBuilder( int nextId, IpPrefix ipAddresses) { TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder(); sbuilder.matchEthType(EthType.EtherType.IPV4.ethType().toShort()); sbuilder.matchIPDst(ipAddresses); DefaultForwardingObjective.Builder builder = DefaultForwardingObjective.builder() .withSelector(sbuilder.build()) .fromApp(appId) .withPriority(getPriorityFromPrefix(ipAddresses)) .withFlag(ForwardingObjective.Flag.SPECIFIC); if (nextId != -1) { builder.nextStep(nextId); } return builder; }
@Override public void programArpClassifierRules(DeviceId deviceId, IpAddress dstIp, SegmentationId actionVni, Objective.Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(ETH_TYPE.ethType().toShort()) .matchArpTpa(Ip4Address.valueOf(dstIp.toString())) .build(); TrafficTreatment treatment = DefaultTrafficTreatment.builder() .setTunnelId(Long.parseLong(actionVni.segmentationId())) .build(); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment).withSelector(selector) .fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(ARP_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { log.debug("ArpClassifierRules-->ADD"); flowObjectiveService.forward(deviceId, objective.add()); } else { log.debug("ArpClassifierRules-->REMOVE"); flowObjectiveService.forward(deviceId, objective.remove()); } }
EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) { fail(fwd, ObjectiveError.UNSUPPORTED); return Collections.emptySet();
(EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) { fail(fwd, ObjectiveError.UNSUPPORTED); return Collections.emptySet();
EthTypeCriterion ethType = (EthTypeCriterion) selector.getCriterion(Criterion.Type.ETH_TYPE); if (ethType == null || ethType.ethType().toShort() != Ethernet.TYPE_IPV4) { fail(fwd, ObjectiveError.UNSUPPORTED); return Collections.emptySet();
.matchEthType(EthType.EtherType.IPV4.ethType().toShort()) .matchVlanId(intf.vlan()) .matchIPProtocol((byte) OSPF_IP_PROTO)
MacAddress dstMac, Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(ARP_TYPE.ethType().toShort()) .matchArpTpa(Ip4Address.valueOf(dstIP.toString())) .matchTunnelId(Long.parseLong(srcVni.segmentationId())).build();
@Override public void programExportPortArpClassifierRules(Port exportPort, DeviceId deviceId, Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(EtherType.ARP.ethType().toShort()) .matchInPort(exportPort.number()).build(); TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); treatment.add(Instructions.createOutput(PortNumber.CONTROLLER)); ForwardingObjective.Builder objective = DefaultForwardingObjective .builder().withTreatment(treatment.build()) .withSelector(selector).fromApp(appId).withFlag(Flag.SPECIFIC) .withPriority(L3_CLASSIFIER_PRIORITY); if (type.equals(Objective.Operation.ADD)) { flowObjectiveService.forward(deviceId, objective.add()); } else { flowObjectiveService.forward(deviceId, objective.remove()); } } }
= (L2ModificationInstruction.PushHeaderInstructions) l2m; return factory.actions().pushVlan( EthType.of(pushVlanInstruction.ethernetType().toShort())); case MPLS_PUSH: L2ModificationInstruction.PushHeaderInstructions pushHeaderInstructions = (L2ModificationInstruction.PushHeaderInstructions) l2m; return factory.actions().pushMpls(EthType.of(pushHeaderInstructions .ethernetType().toShort())); case MPLS_POP: L2ModificationInstruction.PushHeaderInstructions popHeaderInstructions = (L2ModificationInstruction.PushHeaderInstructions) l2m; return factory.actions().popMpls(EthType.of(popHeaderInstructions .ethernetType().toShort())); case MPLS_LABEL: L2ModificationInstruction.ModMplsLabelInstruction mplsLabel =
(PushHeaderInstructions) l2m; return factory().actions().pushMpls(EthType.of(pushHeaderInstructions .ethernetType().toShort())); case MPLS_POP: PushHeaderInstructions popHeaderInstructions = (PushHeaderInstructions) l2m; return factory().actions().popMpls(EthType.of(popHeaderInstructions .ethernetType().toShort())); case MPLS_LABEL: ModMplsLabelInstruction mplsLabel = PushHeaderInstructions pushVlanInstruction = (PushHeaderInstructions) l2m; return factory().actions().pushVlan( EthType.of(pushVlanInstruction.ethernetType().toShort())); case TUNNEL_ID: ModTunnelIdInstruction tunnelId = (ModTunnelIdInstruction) l2m;