Search in sources :

Example 81 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class AddMultiPointToSinglePointIntentCommand method doExecute.

@Override
protected void doExecute() {
    IntentService service = get(IntentService.class);
    if (deviceStrings.length < 2) {
        return;
    }
    String egressDeviceString = deviceStrings[deviceStrings.length - 1];
    FilteredConnectPoint egress = new FilteredConnectPoint(ConnectPoint.deviceConnectPoint(egressDeviceString));
    Set<FilteredConnectPoint> ingressPoints = new HashSet<>();
    for (int index = 0; index < deviceStrings.length - 1; index++) {
        String ingressDeviceString = deviceStrings[index];
        ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressDeviceString);
        ingressPoints.add(new FilteredConnectPoint(ingress));
    }
    TrafficSelector selector = buildTrafficSelector();
    TrafficTreatment treatment = buildTrafficTreatment();
    List<Constraint> constraints = buildConstraints();
    Intent intent = MultiPointToSinglePointIntent.builder().appId(appId()).key(key()).selector(selector).treatment(treatment).filteredIngressPoints(ingressPoints).filteredEgressPoint(egress).constraints(constraints).priority(priority()).resourceGroup(resourceGroup()).build();
    service.submit(intent);
    print("Multipoint to single point intent submitted:\n%s", intent.toString());
}
Also used : IntentService(org.onosproject.net.intent.IntentService) Constraint(org.onosproject.net.intent.Constraint) TrafficSelector(org.onosproject.net.flow.TrafficSelector) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Intent(org.onosproject.net.intent.Intent) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) Constraint(org.onosproject.net.intent.Constraint) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) HashSet(java.util.HashSet)

Example 82 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class ConnectivityIntentCommand method buildTrafficSelector.

/**
 * Constructs a traffic selector based on the command line arguments
 * presented to the command.
 * @return traffic selector
 */
protected TrafficSelector buildTrafficSelector() {
    IpPrefix srcIpPrefix = null;
    IpPrefix dstIpPrefix = null;
    TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
    if (!isNullOrEmpty(srcIpString)) {
        srcIpPrefix = IpPrefix.valueOf(srcIpString);
        if (srcIpPrefix.isIp4()) {
            selectorBuilder.matchIPSrc(srcIpPrefix);
        } else {
            selectorBuilder.matchIPv6Src(srcIpPrefix);
        }
    }
    if (!isNullOrEmpty(dstIpString)) {
        dstIpPrefix = IpPrefix.valueOf(dstIpString);
        if (dstIpPrefix.isIp4()) {
            selectorBuilder.matchIPDst(dstIpPrefix);
        } else {
            selectorBuilder.matchIPv6Dst(dstIpPrefix);
        }
    }
    if ((srcIpPrefix != null) && (dstIpPrefix != null) && (srcIpPrefix.version() != dstIpPrefix.version())) {
        // ERROR: IP src/dst version mismatch
        throw new IllegalArgumentException("IP source and destination version mismatch");
    }
    // 
    // Set the default EthType based on the IP version if the matching
    // source or destination IP prefixes.
    // 
    Short ethType = null;
    if ((srcIpPrefix != null) && srcIpPrefix.isIp6()) {
        ethType = EthType.IPV6.value();
    }
    if ((dstIpPrefix != null) && dstIpPrefix.isIp6()) {
        ethType = EthType.IPV6.value();
    }
    if (!isNullOrEmpty(ethTypeString)) {
        ethType = EthType.parseFromString(ethTypeString);
    }
    if (ethType != null) {
        selectorBuilder.matchEthType(ethType);
    }
    if (!isNullOrEmpty(vlanString)) {
        selectorBuilder.matchVlanId(VlanId.vlanId(Short.parseShort(vlanString)));
    }
    if (!isNullOrEmpty(srcMacString)) {
        selectorBuilder.matchEthSrc(MacAddress.valueOf(srcMacString));
    }
    if (!isNullOrEmpty(dstMacString)) {
        selectorBuilder.matchEthDst(MacAddress.valueOf(dstMacString));
    }
    if (!isNullOrEmpty(ipProtoString)) {
        short ipProtoShort = IpProtocol.parseFromString(ipProtoString);
        selectorBuilder.matchIPProtocol((byte) ipProtoShort);
    }
    if (!isNullOrEmpty(fLabelString)) {
        selectorBuilder.matchIPv6FlowLabel(Integer.parseInt(fLabelString));
    }
    if (!isNullOrEmpty(icmp6TypeString)) {
        byte icmp6Type = Icmp6Type.parseFromString(icmp6TypeString);
        selectorBuilder.matchIcmpv6Type(icmp6Type);
    }
    if (!isNullOrEmpty(icmp6CodeString)) {
        byte icmp6Code = Icmp6Code.parseFromString(icmp6CodeString);
        selectorBuilder.matchIcmpv6Code(icmp6Code);
    }
    if (!isNullOrEmpty(ndTargetString)) {
        selectorBuilder.matchIPv6NDTargetAddress(Ip6Address.valueOf(ndTargetString));
    }
    if (!isNullOrEmpty(ndSllString)) {
        selectorBuilder.matchIPv6NDSourceLinkLayerAddress(MacAddress.valueOf(ndSllString));
    }
    if (!isNullOrEmpty(ndTllString)) {
        selectorBuilder.matchIPv6NDTargetLinkLayerAddress(MacAddress.valueOf(ndTllString));
    }
    if (!isNullOrEmpty(srcTcpString)) {
        selectorBuilder.matchTcpSrc(TpPort.tpPort(Integer.parseInt(srcTcpString)));
    }
    if (!isNullOrEmpty(dstTcpString)) {
        selectorBuilder.matchTcpDst(TpPort.tpPort(Integer.parseInt(dstTcpString)));
    }
    if (extHdrStringList != null) {
        short extHdr = 0;
        for (String extHdrString : extHdrStringList) {
            extHdr = (short) (extHdr | ExtHeader.parseFromString(extHdrString));
        }
        selectorBuilder.matchIPv6ExthdrFlags(extHdr);
    }
    return selectorBuilder.build();
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 83 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class IntentCycleCommand method generateIntents.

private List<Intent> generateIntents(ConnectPoint ingress, ConnectPoint egress) {
    TrafficSelector.Builder selectorBldr = DefaultTrafficSelector.builder().matchEthType(Ethernet.TYPE_IPV4);
    TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
    List<Intent> intents = Lists.newArrayList();
    for (long i = 0; i < count; i++) {
        TrafficSelector selector = selectorBldr.matchEthSrc(MacAddress.valueOf(i + keyOffset)).build();
        intents.add(PointToPointIntent.builder().appId(appId()).key(Key.of(i + keyOffset, appId())).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(ingress)).filteredEgressPoint(new FilteredConnectPoint(egress)).build());
    }
    return intents;
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Intent(org.onosproject.net.intent.Intent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 84 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class Dhcp6HandlerImpl method requestServerDhcpPacket.

private void requestServerDhcpPacket(Ip6Address serverIp) {
    TrafficSelector serverSelector = DefaultTrafficSelector.builder(SERVER_RELAY_SELECTOR).matchIPv6Src(serverIp.toIpPrefix()).build();
    packetService.requestPackets(serverSelector, PacketPriority.CONTROL, appId);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Example 85 with TrafficSelector

use of org.onosproject.net.flow.TrafficSelector in project onos by opennetworkinglab.

the class Dhcp6HandlerImpl method requestServerLQPacket.

private void requestServerLQPacket(Ip6Address serverIp) {
    TrafficSelector serverSelector = DefaultTrafficSelector.builder(LEASE_QUERY_RESPONSE_SELECTOR).matchIPv6Src(serverIp.toIpPrefix()).build();
    packetService.requestPackets(serverSelector, PacketPriority.CONTROL, appId);
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector)

Aggregations

TrafficSelector (org.onosproject.net.flow.TrafficSelector)396 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)354 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)249 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)235 FlowRule (org.onosproject.net.flow.FlowRule)94 Test (org.junit.Test)85 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)84 PiAction (org.onosproject.net.pi.runtime.PiAction)54 ConnectPoint (org.onosproject.net.ConnectPoint)51 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)48 DeviceId (org.onosproject.net.DeviceId)43 PortNumber (org.onosproject.net.PortNumber)43 List (java.util.List)42 NextObjective (org.onosproject.net.flowobjective.NextObjective)41 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)39 PiActionParam (org.onosproject.net.pi.runtime.PiActionParam)38 Instruction (org.onosproject.net.flow.instructions.Instruction)37 Criterion (org.onosproject.net.flow.criteria.Criterion)36 PiCriterion (org.onosproject.net.flow.criteria.PiCriterion)36 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)35