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());
}
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();
}
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;
}
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);
}
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);
}
Aggregations