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.ace.type.AceIpBuilder in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testaddSrcIpMatches_v4NoSrcNetwork.
@Test
public void testaddSrcIpMatches_v4NoSrcNetwork() {
AceIpBuilder builder = new AceIpBuilder();
AceIpv4Builder v4builder = new AceIpv4Builder();
v4builder.setSourceIpv4Network(null);
builder.setAceIpVersion(v4builder.build());
List<MatchInfoBase> flowMatches = AclServiceOFFlowBuilder.addSrcIpMatches(builder.build());
assertTrue(flowMatches.contains(MatchEthernetType.IPV4));
AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, MatchIpv4Source.class);
}
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.ace.type.AceIpBuilder in project netvirt by opendaylight.
the class AclServiceOFFlowBuilderTest method testaddDstIpMatches_v4NoDstNetwork.
@Test
public void testaddDstIpMatches_v4NoDstNetwork() {
AceIpBuilder builder = new AceIpBuilder();
AceIpv4Builder v4builder = new AceIpv4Builder();
v4builder.setDestinationIpv4Network(null);
builder.setAceIpVersion(v4builder.build());
List<MatchInfoBase> flowMatches = AclServiceOFFlowBuilder.addDstIpMatches(builder.build());
assertTrue(flowMatches.contains(MatchEthernetType.IPV4));
AclServiceTestUtils.verifyMatchFieldTypeDontExist(flowMatches, MatchIpv4Destination.class);
}
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.ace.type.AceIpBuilder in project netvirt by opendaylight.
the class AclServiceTestUtils method prepareAceIpBuilder.
public static AceIpBuilder prepareAceIpBuilder(String srcIpv4Net, String dstIpv4Net, String lowerPort, String upperPort, short protocol) {
AceIpBuilder builder = new AceIpBuilder();
AceIpv4Builder v4builder = new AceIpv4Builder();
if (srcIpv4Net != null) {
v4builder.setSourceIpv4Network(new Ipv4Prefix(srcIpv4Net));
} else {
v4builder.setSourceIpv4Network(null);
}
if (dstIpv4Net != null) {
v4builder.setDestinationIpv4Network(new Ipv4Prefix(dstIpv4Net));
} else {
v4builder.setDestinationIpv4Network(null);
}
builder.setAceIpVersion(v4builder.build());
if (lowerPort != null && upperPort != null) {
SourcePortRangeBuilder srcPortBuilder = new SourcePortRangeBuilder();
srcPortBuilder.setLowerPort(PortNumber.getDefaultInstance(lowerPort));
srcPortBuilder.setUpperPort(PortNumber.getDefaultInstance(upperPort));
builder.setSourcePortRange(srcPortBuilder.build());
DestinationPortRangeBuilder dstPortBuilder = new DestinationPortRangeBuilder();
dstPortBuilder.setLowerPort(PortNumber.getDefaultInstance(lowerPort));
dstPortBuilder.setUpperPort(PortNumber.getDefaultInstance(upperPort));
builder.setDestinationPortRange(dstPortBuilder.build());
}
builder.setProtocol(protocol);
return builder;
}
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.ace.type.AceIpBuilder in project netvirt by opendaylight.
the class NeutronSecurityRuleListener method handleEtherType.
private AceIpBuilder handleEtherType(SecurityRule securityRule, AceIpBuilder aceIpBuilder) {
if (NeutronSecurityRuleConstants.ETHERTYPE_IPV4.equals(securityRule.getEthertype())) {
AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
aceIpv4Builder.setSourceIpv4Network(new Ipv4Prefix(NeutronSecurityRuleConstants.IPV4_ALL_NETWORK));
aceIpv4Builder.setDestinationIpv4Network(new Ipv4Prefix(NeutronSecurityRuleConstants.IPV4_ALL_NETWORK));
aceIpBuilder.setAceIpVersion(aceIpv4Builder.build());
} else {
AceIpv6Builder aceIpv6Builder = new AceIpv6Builder();
aceIpv6Builder.setSourceIpv6Network(new Ipv6Prefix(NeutronSecurityRuleConstants.IPV6_ALL_NETWORK));
aceIpv6Builder.setDestinationIpv6Network(new Ipv6Prefix(NeutronSecurityRuleConstants.IPV6_ALL_NETWORK));
aceIpBuilder.setAceIpVersion(aceIpv6Builder.build());
}
return aceIpBuilder;
}
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.ace.type.AceIpBuilder in project netvirt by opendaylight.
the class NeutronSecurityRuleListener method handleRemoteIpPrefix.
private AceIpBuilder handleRemoteIpPrefix(SecurityRule securityRule, AceIpBuilder aceIpBuilder, boolean isDirectionIngress) {
if (securityRule.getRemoteIpPrefix() != null) {
if (securityRule.getRemoteIpPrefix().getIpv4Prefix() != null) {
AceIpv4Builder aceIpv4Builder = new AceIpv4Builder();
if (isDirectionIngress) {
aceIpv4Builder.setSourceIpv4Network(new Ipv4Prefix(securityRule.getRemoteIpPrefix().getIpv4Prefix().getValue()));
} else {
aceIpv4Builder.setDestinationIpv4Network(new Ipv4Prefix(securityRule.getRemoteIpPrefix().getIpv4Prefix().getValue()));
}
aceIpBuilder.setAceIpVersion(aceIpv4Builder.build());
} else {
AceIpv6Builder aceIpv6Builder = new AceIpv6Builder();
if (isDirectionIngress) {
aceIpv6Builder.setSourceIpv6Network(new Ipv6Prefix(securityRule.getRemoteIpPrefix().getIpv6Prefix().getValue()));
} else {
aceIpv6Builder.setDestinationIpv6Network(new Ipv6Prefix(securityRule.getRemoteIpPrefix().getIpv6Prefix().getValue()));
}
aceIpBuilder.setAceIpVersion(aceIpv6Builder.build());
}
} else {
if (securityRule.getEthertype() != null) {
handleEtherType(securityRule, aceIpBuilder);
}
}
return aceIpBuilder;
}
Aggregations