use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match in project netvirt by opendaylight.
the class OpenFlow13ProviderTest method checkMatchNsi.
private void checkMatchNsi(Match match, short nsi) {
GeneralAugMatchNodesNodeTableFlow genAug = match.getAugmentation(GeneralAugMatchNodesNodeTableFlow.class);
assertNotNull(genAug);
List<ExtensionList> extensions = genAug.getExtensionList();
for (ExtensionList extensionList : extensions) {
Extension extension = extensionList.getExtension();
NxAugMatchNodesNodeTableFlow nxAugMatch = extension.getAugmentation(NxAugMatchNodesNodeTableFlow.class);
if (nxAugMatch.getNxmNxNsi() != null) {
assertEquals(nxAugMatch.getNxmNxNsi().getNsi().shortValue(), nsi);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv4MatchTest.
@Test
public void buildIpv4MatchTest() {
AceIpv4Builder aceIpv4 = new AceIpv4Builder();
aceIpv4.setDestinationIpv4Network(new Ipv4Prefix(IPV4_DST_STR));
aceIpv4.setSourceIpv4Network(new Ipv4Prefix(IPV4_SRC_STR));
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(aceIpv4.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The layer3 match should be there with src/dst values
Ipv4Match l3 = (Ipv4Match) matchBuilder.getLayer3Match();
assertNotNull(l3);
assertEquals(l3.getIpv4Destination().getValue().toString(), IPV4_DST_STR);
assertEquals(l3.getIpv4Source().getValue().toString(), IPV4_SRC_STR);
// There should be an IPv4 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV4));
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match in project netvirt by opendaylight.
the class AclMatchesTest method buildIpv6MatchTest.
@Test
public void buildIpv6MatchTest() {
AceIpv6Builder aceIpv6 = new AceIpv6Builder();
aceIpv6.setDestinationIpv6Network(new Ipv6Prefix(IPV6_DST_STR));
aceIpv6.setSourceIpv6Network(new Ipv6Prefix(IPV6_SRC_STR));
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setAceIpVersion(aceIpv6.build());
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceIpBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The layer3 match should be there with src/dst values
Ipv6Match l3 = (Ipv6Match) matchBuilder.getLayer3Match();
assertNotNull(l3);
assertEquals(l3.getIpv6Destination().getValue().toString(), IPV6_DST_STR);
assertEquals(l3.getIpv6Source().getValue().toString(), IPV6_SRC_STR);
// There should be an IPv6 etherType set
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetType().getType().getValue(), Long.valueOf(NwConstants.ETHTYPE_IPV6));
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match in project netvirt by opendaylight.
the class AclMatchesTest method buildEthMatchTest.
@Test
public void buildEthMatchTest() {
AceEthBuilder aceEthBuilder = new AceEthBuilder();
aceEthBuilder.setDestinationMacAddress(new MacAddress(MAC_DST_STR));
aceEthBuilder.setSourceMacAddress(new MacAddress(MAC_SRC_STR));
MatchesBuilder matchesBuilder = new MatchesBuilder();
matchesBuilder.setAceType(aceEthBuilder.build());
// Create the aclMatches that is the object to be tested
AclMatches aclMatches = new AclMatches(matchesBuilder.build());
MatchBuilder matchBuilder = aclMatches.buildMatch();
// The ethernet match should be there with src/dst values
EthernetMatch ethMatch = matchBuilder.getEthernetMatch();
assertNotNull(ethMatch);
assertEquals(ethMatch.getEthernetSource().getAddress().getValue(), MAC_SRC_STR);
assertEquals(ethMatch.getEthernetDestination().getAddress().getValue(), MAC_DST_STR);
// The rest should be null
assertNull(matchBuilder.getIpMatch());
assertNull(matchBuilder.getLayer3Match());
assertNull(matchBuilder.getLayer4Match());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.grouping.Match in project netvirt by opendaylight.
the class AclServiceUtils method getFlowForAllowedAddresses.
public static Map<String, List<MatchInfoBase>> getFlowForAllowedAddresses(List<AllowedAddressPairs> syncAllowedAddresses, Map<String, List<MatchInfoBase>> flowMatchesMap, boolean isSourceIpMacMatch) {
if (flowMatchesMap == null) {
return null;
}
Map<String, List<MatchInfoBase>> updatedFlowMatchesMap = new HashMap<>();
MatchInfoBase ipv4Match = MatchEthernetType.IPV4;
MatchInfoBase ipv6Match = MatchEthernetType.IPV6;
for (Entry<String, List<MatchInfoBase>> entry : flowMatchesMap.entrySet()) {
String flowName = entry.getKey();
List<MatchInfoBase> flows = entry.getValue();
// iterate over allow address pair and update match type
for (AllowedAddressPairs aap : syncAllowedAddresses) {
List<MatchInfoBase> matchInfoBaseList;
String flowId;
if (flows.contains(ipv4Match) && isIPv4Address(aap) && isNotIpv4AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv4_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
} else if (flows.contains(ipv6Match) && !isIPv4Address(aap) && isNotIpv6AllNetwork(aap)) {
matchInfoBaseList = updateAAPMatches(isSourceIpMacMatch, flows, aap);
flowId = flowName + "_ipv6_remoteACL_interface_aap_" + getAapFlowId(aap);
updatedFlowMatchesMap.put(flowId, matchInfoBaseList);
}
}
}
return updatedFlowMatchesMap;
}
Aggregations