use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class ConnectivityManager method buildIntents.
/**
* Builds the required intents between the two pairs of connect points and
* IP addresses.
*
* @param portOne the first connect point
* @param ipOne the first IP address
* @param portTwo the second connect point
* @param ipTwo the second IP address
* @return the intents to install
*/
private Collection<PointToPointIntent> buildIntents(ConnectPoint portOne, IpAddress ipOne, ConnectPoint portTwo, IpAddress ipTwo) {
List<PointToPointIntent> intents = new ArrayList<>();
TrafficTreatment treatment = DefaultTrafficTreatment.emptyTreatment();
TrafficSelector selector;
Key key;
byte tcpProtocol;
byte icmpProtocol;
if (ipOne.isIp4()) {
tcpProtocol = IPv4.PROTOCOL_TCP;
icmpProtocol = IPv4.PROTOCOL_ICMP;
} else {
tcpProtocol = IPv6.PROTOCOL_TCP;
icmpProtocol = IPv6.PROTOCOL_ICMP6;
}
// Path from BGP speaker to BGP peer matching source TCP port 179
selector = buildSelector(tcpProtocol, ipOne, ipTwo, BGP_PORT, null);
key = buildKey(ipOne, ipTwo, SUFFIX_SRC);
intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).priority(PRIORITY_OFFSET).build());
// Path from BGP peer to BGP speaker matching destination TCP port 179
selector = buildSelector(tcpProtocol, ipTwo, ipOne, null, BGP_PORT);
key = buildKey(ipTwo, ipOne, SUFFIX_DST);
intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).priority(PRIORITY_OFFSET).build());
// ICMP path from BGP speaker to BGP peer
selector = buildSelector(icmpProtocol, ipOne, ipTwo, null, null);
key = buildKey(ipOne, ipTwo, SUFFIX_ICMP);
intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portOne)).filteredEgressPoint(new FilteredConnectPoint(portTwo)).priority(PRIORITY_OFFSET).build());
// ICMP path from BGP peer to BGP speaker
selector = buildSelector(icmpProtocol, ipTwo, ipOne, null, null);
key = buildKey(ipTwo, ipOne, SUFFIX_ICMP);
intents.add(PointToPointIntent.builder().appId(appId).key(key).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(portTwo)).filteredEgressPoint(new FilteredConnectPoint(portOne)).priority(PRIORITY_OFFSET).build());
return intents;
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class PointToPointIntentCodec method decode.
@Override
public PointToPointIntent decode(ObjectNode json, CodecContext context) {
PointToPointIntent.Builder builder = PointToPointIntent.builder();
IntentCodec.intentAttributes(json, context, builder);
ConnectivityIntentCodec.intentAttributes(json, context, builder);
ObjectNode ingressJson = nullIsIllegal(get(json, INGRESS_POINT), INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
ConnectPoint ingress = context.codec(ConnectPoint.class).decode(ingressJson, context);
builder.filteredIngressPoint(new FilteredConnectPoint(ingress));
ObjectNode egressJson = nullIsIllegal(get(json, EGRESS_POINT), EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
ConnectPoint egress = context.codec(ConnectPoint.class).decode(egressJson, context);
builder.filteredEgressPoint(new FilteredConnectPoint(egress));
return builder.build();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class MultiPointToSinglePointIntentCodec method decode.
@Override
public MultiPointToSinglePointIntent decode(ObjectNode json, CodecContext context) {
MultiPointToSinglePointIntent.Builder builder = MultiPointToSinglePointIntent.builder();
IntentCodec.intentAttributes(json, context, builder);
ConnectivityIntentCodec.intentAttributes(json, context, builder);
ArrayNode ingressJson = nullIsIllegal((ArrayNode) json.get(INGRESS_POINT), INGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
if (ingressJson != null) {
final JsonCodec<ConnectPoint> connectPointCodec = context.codec(ConnectPoint.class);
JsonNode connectPointsJson = json.get(INGRESS_POINT);
Set<FilteredConnectPoint> ingressCp = new HashSet<>();
if (connectPointsJson != null) {
for (int i = 0; i < connectPointsJson.size(); i++) {
ingressCp.add(new FilteredConnectPoint(connectPointCodec.decode(get(connectPointsJson, i), context)));
}
builder.filteredIngressPoints(ingressCp);
}
}
ObjectNode egressJson = nullIsIllegal(get(json, EGRESS_POINT), EGRESS_POINT + IntentCodec.MISSING_MEMBER_MESSAGE);
ConnectPoint egress = context.codec(ConnectPoint.class).decode(egressJson, context);
builder.filteredEgressPoint(new FilteredConnectPoint(egress));
return builder.build();
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testTwoEgressCompilation.
/**
* Tests a simple topology where two egress points share some path segments
* and some path segments are not shared.
*/
@Test
public void testTwoEgressCompilation() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo);
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
assertThat(intent, is(notNullValue()));
final String[] hops = { S2, S3 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(4));
assertThat(linkIntent.links(), linksHasPath(S1, S2));
assertThat(linkIntent.links(), linksHasPath(S2, S3));
assertThat(linkIntent.links(), linksHasPath(S3, S4));
assertThat(linkIntent.links(), linksHasPath(S3, S5));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
use of org.onosproject.net.FilteredConnectPoint in project onos by opennetworkinglab.
the class DomainIntentInstallerTest method createAnotherDomainIntents.
/**
* Create another domain Intents.
*
* @return the domain Intents
*/
private List<Intent> createAnotherDomainIntents() {
FilteredConnectPoint ingress = new FilteredConnectPoint(CP1);
FilteredConnectPoint egress = new FilteredConnectPoint(CP3);
DomainPointToPointIntent intent = DomainPointToPointIntent.builder().appId(APP_ID).key(KEY1).priority(DEFAULT_PRIORITY).filteredIngressPoint(ingress).filteredEgressPoint(egress).links(ImmutableList.of()).build();
return ImmutableList.of(intent);
}
Aggregations