use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class AclMatchesTest method invertIpv4MatchTest.
@Test
public void invertIpv4MatchTest() {
AceIpBuilder aceIpBuilder = new AceIpBuilder();
aceIpBuilder.setProtocol(IPProtocols.UDP.shortValue());
aceIpBuilder.setDscp(new Dscp(DSCP_VALUE));
DestinationPortRangeBuilder dstPortRange = new DestinationPortRangeBuilder();
dstPortRange.setLowerPort(new PortNumber(UDP_DST_LOWER_PORT));
dstPortRange.setUpperPort(new PortNumber(UDP_DST_UPPER_PORT));
DestinationPortRange destinationPortRange = dstPortRange.build();
aceIpBuilder.setDestinationPortRange(destinationPortRange);
AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
aceIpv4Builder.setDestinationIpv4Network(new Ipv4Prefix(IPV4_DST_STR));
aceIpv4Builder.setSourceIpv4Network(new Ipv4Prefix(IPV4_SRC_STR));
AceIpv4 aceIpv4 = aceIpv4Builder.build();
aceIpBuilder.setAceIpVersion(aceIpv4);
MatchesBuilder matchesBuilder = new MatchesBuilder();
AceIp aceIp = aceIpBuilder.build();
matchesBuilder.setAceType(aceIp);
Matches matches = matchesBuilder.build();
Matches invertedMatches = AclMatches.invertMatches(matches);
assertNotEquals(matches, invertedMatches);
AceIp invertedAceIp = (AceIp) invertedMatches.getAceType();
assertEquals(invertedAceIp.getDscp(), aceIp.getDscp());
assertEquals(invertedAceIp.getProtocol(), aceIp.getProtocol());
DestinationPortRange invertedDestinationPortRange = invertedAceIp.getDestinationPortRange();
assertNull(invertedDestinationPortRange);
SourcePortRange invertedSourcePortRange = invertedAceIp.getSourcePortRange();
assertEquals(invertedSourcePortRange.getLowerPort(), destinationPortRange.getLowerPort());
assertEquals(invertedSourcePortRange.getUpperPort(), destinationPortRange.getUpperPort());
AceIpv4 invertedAceIpv4 = (AceIpv4) invertedAceIp.getAceIpVersion();
assertEquals(invertedAceIpv4.getDestinationIpv4Network(), aceIpv4.getSourceIpv4Network());
assertEquals(invertedAceIpv4.getSourceIpv4Network(), aceIpv4.getDestinationIpv4Network());
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class StatisticsImpl method createElementCountersResult.
private CounterResultDataStructure createElementCountersResult(CounterRequests counterRequest) {
ElementCountersRequest ecr = createElementCounterRequest(counterRequest.getPortId(), counterRequest.getLportTag(), counterRequest.getDpn(), ElementCountersDirection.valueOf(counterRequest.getTrafficDirection()), counterRequest.getFilters()).iterator().next();
BigInteger dpId = getDpn(ecr.getPortId());
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(ecr.getPortId());
if (interfaceInfo == null) {
return null;
}
int lportTag = interfaceInfo.getInterfaceTag();
List<MatchInfoBase> matches = CountersServiceUtils.getCounterFlowMatch(ecr, lportTag, ElementCountersDirection.valueOf(counterRequest.getTrafficDirection()));
Match match = MDSALUtil.buildMatches(matches);
return counterRetriever.getSwitchFlowCountersDirect(dpId, match);
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class OpenFlow13Provider method createIngressClassifierAclNoMatchFlow.
/*
* Ingress Classifier ACL NoMatch flow:
* If there are no ACL classification matches, then resubmit back to
* the Ingress Dispatcher to let other services handle the packet.
*/
public Flow createIngressClassifierAclNoMatchFlow(NodeId nodeId) {
// This is a MatchAny flow
MatchBuilder match = new MatchBuilder();
List<Action> actionList = new ArrayList<>();
actionList.add(OpenFlow13Utils.createActionResubmitTable(NwConstants.LPORT_DISPATCHER_TABLE, actionList.size()));
InstructionsBuilder isb = OpenFlow13Utils.wrapActionsIntoApplyActionsInstruction(actionList);
String flowIdStr = INGRESS_CLASSIFIER_ACL_FLOW_NAME + "_" + nodeId.getValue();
return OpenFlow13Utils.createFlowBuilder(NwConstants.INGRESS_SFC_CLASSIFIER_ACL_TABLE, INGRESS_CLASSIFIER_ACL_NOMATCH_PRIORITY, INGRESS_CLASSIFIER_ACL_COOKIE, INGRESS_CLASSIFIER_ACL_FLOW_NAME, flowIdStr, match, isb).build();
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class OpenflowRenderer method suppressMatch.
@Override
public void suppressMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
Long port = OpenFlow13Provider.getPortNoFromNodeConnector(connector);
Flow flow = this.openFlow13Provider.createIngressClassifierAclFlow(nodeId, this.openFlow13Provider.getMatchBuilderFromAceMatches(matches), port, nsp, nsi);
ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> this.openFlow13Provider.appendFlowForDelete(nodeId, flow, tx)), LOG, "Error deleting a match");
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.access.control.list.rev160218.access.lists.acl.access.list.entries.ace.Matches in project netvirt by opendaylight.
the class OpenflowRenderer method renderMatch.
@Override
public void renderMatch(NodeId nodeId, String connector, Matches matches, Long nsp, Short nsi) {
Long port = OpenFlow13Provider.getPortNoFromNodeConnector(connector);
Flow flow = this.openFlow13Provider.createIngressClassifierAclFlow(nodeId, this.openFlow13Provider.getMatchBuilderFromAceMatches(matches), port, nsp, nsi);
ListenableFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(tx -> this.openFlow13Provider.appendFlowForCreate(nodeId, flow, tx)), LOG, "Error rendering a match");
}
Aggregations