public String toString() { EtherType ethType = lookup(this.etherType); return (ethType == null ? String.format("0x%04x", etherType) : ethType.toString()); }
.matchInPort(intf.connectPoint().port()) .matchEthDst(intf.mac()) .matchEthType(EthType.EtherType.IPV4.ethType().toShort()) .matchVlanId(intf.vlan()) .matchIPDst(ip.ipAddress().toIpPrefix()) .matchEthSrc(intf.mac()) .matchVlanId(intf.vlan()) .matchEthType(EthType.EtherType.IPV4.ethType().toShort()) .matchIPSrc(ip.ipAddress().toIpPrefix()) .build(); .matchEthType(EthType.EtherType.ARP.ethType().toShort()) .matchVlanId(intf.vlan()) .build(); .matchEthSrc(intf.mac()) .matchVlanId(intf.vlan()) .matchEthType(EthType.EtherType.ARP.ethType().toShort()) .matchArpSpa(ip.ipAddress().getIp4Address()) .build();
MacAddress dstMac, Operation type) { TrafficSelector selector = DefaultTrafficSelector.builder() .matchEthType(ARP_TYPE.ethType().toShort()) .matchArpTpa(Ip4Address.valueOf(dstIP.toString())) .matchTunnelId(Long.parseLong(srcVni.segmentationId())).build();
.matchEthType(EthType.EtherType.IPV4.ethType().toShort()) .matchVlanId(intf.vlan()) .matchIPProtocol((byte) OSPF_IP_PROTO)
@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()); } }
@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()); } }
@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()); } } }
/** * Returns the ethertype match needed. If the selector provides * an ethertype, it will be used. IPv4 will be used otherwise. * * @param selector the traffic selector. * @return the ethertype we should match against */ private EthType getEthType(TrafficSelector selector) { Criterion c = selector.getCriterion(Criterion.Type.ETH_TYPE); if (c != null && c instanceof EthTypeCriterion) { EthTypeCriterion ethertype = (EthTypeCriterion) c; return ethertype.ethType(); } else { return EthType.EtherType.IPV4.ethType(); } }
/** * Helper function to define the match on the ethertype. * If the selector define an ethertype we will use it, * otherwise IPv4 will be used by default. * * @param selector the traffic selector * @return the ethertype we should match */ private EthType getEthType(TrafficSelector selector) { Criterion c = selector.getCriterion(Criterion.Type.ETH_TYPE); if (c != null && c instanceof EthTypeCriterion) { EthTypeCriterion ethertype = (EthTypeCriterion) c; return ethertype.ethType(); } return EthType.EtherType.IPV4.ethType(); }
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; }
/** * 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; }