use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6 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.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6 in project netvirt by opendaylight.
the class AclServiceOFFlowBuilder method programIcmpFlow.
/**
*Converts icmp matches to flows.
* @param acl the access control list
* @return the map containing the flows and the respective flow id
*/
public static Map<String, List<MatchInfoBase>> programIcmpFlow(AceIp acl) {
List<MatchInfoBase> flowMatches = new ArrayList<>();
flowMatches.addAll(addSrcIpMatches(acl));
flowMatches.addAll(addDstIpMatches(acl));
// For ICMP port range indicates type and code
SourcePortRange sourcePortRange = acl.getSourcePortRange();
String flowId = "ICMP_";
if (sourcePortRange != null) {
if (acl.getAceIpVersion() instanceof AceIpv4) {
flowMatches.add(new MatchIcmpv4(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V4_SOURCE_" + sourcePortRange.getLowerPort().getValue() + sourcePortRange.getUpperPort().getValue();
} else if (acl.getAceIpVersion() instanceof AceIpv6) {
flowMatches.add(new MatchIcmpv6(sourcePortRange.getLowerPort().getValue().shortValue(), sourcePortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V6_SOURCE_" + sourcePortRange.getLowerPort().getValue() + "_" + sourcePortRange.getUpperPort().getValue() + "_";
}
}
DestinationPortRange destinationPortRange = acl.getDestinationPortRange();
if (destinationPortRange != null) {
if (acl.getAceIpVersion() instanceof AceIpv4) {
flowMatches.add(new MatchIcmpv4(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V4_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
} else if (acl.getAceIpVersion() instanceof AceIpv6) {
flowMatches.add(new MatchIcmpv6(destinationPortRange.getLowerPort().getValue().shortValue(), destinationPortRange.getUpperPort().getValue().shortValue()));
flowId = flowId + "V6_DESTINATION_" + destinationPortRange.getLowerPort().getValue() + destinationPortRange.getUpperPort().getValue() + "_";
}
}
if (acl.getAceIpVersion() instanceof AceIpv6 && acl.getProtocol() == NwConstants.IP_PROT_ICMP) {
// We are aligning our implementation similar to Neutron Firewall driver where a Security
// Group rule with "Ethertype as IPv6 and Protocol as icmp" is treated as ICMPV6 SG Rule.
flowMatches.add(new MatchIpProtocol(AclConstants.IP_PROT_ICMPV6));
} else {
flowMatches.add(new MatchIpProtocol(acl.getProtocol()));
}
Map<String, List<MatchInfoBase>> flowMatchesMap = new HashMap<>();
flowMatchesMap.put(flowId, flowMatches);
return flowMatchesMap;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6 in project netvirt by opendaylight.
the class AclServiceUtils method doesIpv6AddressExists.
/**
* Does IPv6 address exists in the list of allowed address pair.
*
* @param aaps the allowed address pairs
* @return true, if successful
*/
public static boolean doesIpv6AddressExists(List<AllowedAddressPairs> aaps) {
if (aaps == null) {
return false;
}
for (AllowedAddressPairs aap : aaps) {
IpPrefixOrAddress ipPrefixOrAddress = aap.getIpAddress();
IpPrefix ipPrefix = ipPrefixOrAddress.getIpPrefix();
if (ipPrefix != null) {
if (ipPrefix.getIpv6Prefix() != null) {
return true;
}
} else {
IpAddress ipAddress = ipPrefixOrAddress.getIpAddress();
if (ipAddress != null && ipAddress.getIpv6Address() != null) {
return true;
}
}
}
return false;
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6 in project netvirt by opendaylight.
the class SubnetGwMacChangeListener method handleSubnetGwIpChange.
private void handleSubnetGwIpChange(LearntVpnVipToPort learntVpnVipToPort) {
String macAddress = learntVpnVipToPort.getMacAddress();
if (macAddress == null) {
LOG.error("handleSubnetGwIpChange : Mac address is null for LearntVpnVipToPort for vpn {} prefix {}", learntVpnVipToPort.getVpnName(), learntVpnVipToPort.getPortFixedip());
return;
}
String fixedIp = learntVpnVipToPort.getPortFixedip();
if (fixedIp == null) {
LOG.error("handleSubnetGwIpChange : Fixed ip is null for LearntVpnVipToPort for vpn {}", learntVpnVipToPort.getVpnName());
return;
}
try {
InetAddress address = InetAddress.getByName(fixedIp);
if (address instanceof Inet6Address) {
// TODO: Revisit when IPv6 North-South communication support is added.
LOG.debug("handleSubnetGwIpChange : Skipping ipv6 address {}.", address);
return;
}
} catch (UnknownHostException e) {
LOG.warn("handleSubnetGwIpChange : Invalid ip address {}", fixedIp, e);
return;
}
for (Uuid subnetId : nvpnManager.getSubnetIdsForGatewayIp(new IpAddress(new Ipv4Address(fixedIp)))) {
LOG.trace("handleSubnetGwIpChange : Updating MAC resolution on vpn {} for GW ip {} to {}", learntVpnVipToPort.getVpnName(), fixedIp, macAddress);
extNetworkInstaller.installExtNetGroupEntries(subnetId, macAddress);
}
}
use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.Ipv6 in project netvirt by opendaylight.
the class Ipv6PktHandlerTest method testonPacketReceivedNeighborSolicitationWithInvalidPayload.
@Test
public void testonPacketReceivedNeighborSolicitationWithInvalidPayload() throws Exception {
// incorrect checksum
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
"87", // Code
"00", // Checksum (invalid, should be 67 3C)
"67 3E", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
// unavailable ip
when(ifMgrInstance.obtainV6Interface(any())).thenReturn(null);
counter = pktHandler.getPacketProcessedCounter();
pktHandler.onPacketReceived(new PacketReceivedBuilder().setPayload(ipv6TestUtils.buildPacket(// Destination MAC
"33 33 FF F5 00 00", // Source MAC
"00 01 02 03 04 05", // IPv6
"86 DD", // Version 6, traffic class E0, no flowlabel
"6E 00 00 00", // Payload length
"00 18", // Next header is ICMPv6
"3A", // Hop limit
"FF", // Source IP
"00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00", // Destination IP
"FF 02 00 00 00 00 00 00 00 00 00 01 FF F5 00 00", // ICMPv6 neighbor solicitation
"87", // Code
"00", // Checksum (valid)
"67 3C", // ICMPv6 message body
"00 00 00 00", // Target
"FE 80 00 00 00 00 00 00 C0 00 54 FF FE F5 00 00")).build());
// wait on this thread until the async job is completed in the packet handler.
waitForPacketProcessing();
verify(pktProcessService, times(0)).transmitPacket(any(TransmitPacketInput.class));
}
Aggregations