use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class NextHopUtilTest method testSerializeNextHop.
@Test
public void testSerializeNextHop() {
CNextHop hop = new Ipv4NextHopCaseBuilder().setIpv4NextHop(new Ipv4NextHopBuilder().setGlobal(IPV4).build()).build();
final ByteBuf buffer = Unpooled.buffer();
NextHopUtil.serializeNextHop(hop, buffer);
assertArrayEquals(IPV4B, ByteArray.readAllBytes(buffer));
hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(IPV6).build()).build();
buffer.clear();
NextHopUtil.serializeNextHop(hop, buffer);
assertArrayEquals(IPV6B, ByteArray.readAllBytes(buffer));
hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(IPV6).setLinkLocal(IPV6L).build()).build();
buffer.clear();
NextHopUtil.serializeNextHop(hop, buffer);
assertArrayEquals(IPV6LB, ByteArray.readAllBytes(buffer));
buffer.clear();
hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setLinkLocal(IPV6L).build()).build();
buffer.clear();
try {
NextHopUtil.serializeNextHop(hop, buffer);
fail("Exception should happen");
} catch (final IllegalArgumentException e) {
assertEquals("Ipv6 Next Hop is missing Global address.", e.getMessage());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class CreateTunnelInstructionExecutor method buildAddressFamily.
private static AddressFamily buildAddressFamily(final TerminationPoint sp, final TerminationPoint dp) {
// We need the IGP augmentation -- it has IP addresses
final TerminationPoint1 sp1 = requireNonNull(sp.getAugmentation(TerminationPoint1.class));
final TerminationPoint1 dp1 = requireNonNull(dp.getAugmentation(TerminationPoint1.class));
// Get the types
final TerminationPointType spt = sp1.getIgpTerminationPointAttributes().getTerminationPointType();
final TerminationPointType dpt = dp1.getIgpTerminationPointAttributes().getTerminationPointType();
// The types have to match
Preconditions.checkArgument(spt.getImplementedInterface().equals(dpt.getImplementedInterface()));
// And they have to actually be Ip
final Ip sips = (Ip) spt;
final Ip dips = (Ip) dpt;
/*
* Now a bit of magic. We need to find 'like' addresses, e.g. both
* IPv4 or both IPv6. We are in IPv6-enabled world now, so let's
* prefer that.
*/
Optional<AddressFamily> ret = findIpv6(sips.getIpAddress(), dips.getIpAddress());
if (!ret.isPresent()) {
ret = findIpv4(sips.getIpAddress(), dips.getIpAddress());
}
// We need to have a ret now
Preconditions.checkArgument(ret != null, "Failed to find like Endpoint addresses");
return ret.get();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class TableTypeActivatorTest method testActivator.
@Test
public void testActivator() {
final TableTypeActivator tableTypeActivator = new TableTypeActivator();
final SimpleBGPTableTypeRegistryProvider registry = new SimpleBGPTableTypeRegistryProvider();
tableTypeActivator.startBGPTableTypeRegistryProvider(registry);
final Optional<Class<? extends AfiSafiType>> afiSafiType = registry.getAfiSafiType(IPV4);
assertEquals(IPV4UNICAST.class, afiSafiType.get());
final Optional<Class<? extends AfiSafiType>> afiSafiType2 = registry.getAfiSafiType(IPV6);
assertEquals(IPV6UNICAST.class, afiSafiType2.get());
final Optional<BgpTableType> tableType = registry.getTableType(IPV4UNICAST.class);
assertEquals(IPV4, tableType.get());
final Optional<BgpTableType> tableType2 = registry.getTableType(IPV6UNICAST.class);
assertEquals(IPV6, tableType2.get());
tableTypeActivator.stopBGPTableTypeRegistryProvider();
tableTypeActivator.close();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class NextHopParserSerializerTest method testSerializeIpv6LinkNextHopCase.
@Test
public void testSerializeIpv6LinkNextHopCase() throws BGPParsingException {
this.hop = new Ipv6NextHopCaseBuilder().setIpv6NextHop(new Ipv6NextHopBuilder().setGlobal(IPV6).setLinkLocal(IPV6L).build()).build();
this.buffer.clear();
this.ipv6NextHopParserSerializer.serializeNextHop(this.hop, this.buffer);
assertArrayEquals(IPV6LB, ByteArray.readAllBytes(this.buffer));
final CNextHop parsedHop = this.ipv6NextHopParserSerializer.parseNextHop(Unpooled.wrappedBuffer(IPV6LB));
assertTrue(parsedHop instanceof Ipv6NextHopCase);
assertEquals(this.hop, parsedHop);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class AbstractVpnNlriParser method serializeNlri.
private static void serializeNlri(final List<VpnDestination> dests, final boolean isWithdrawnRoute, final ByteBuf buffer) {
final ByteBuf nlriByteBuf = Unpooled.buffer();
for (final VpnDestination dest : dests) {
final List<LabelStack> labelStack = dest.getLabelStack();
final IpPrefix prefix = dest.getPrefix();
LOG.debug("Serializing Nlri: VpnDestination={}, IpPrefix={}", dest, prefix);
AbstractVpnNlriParser.serializeLengtField(prefix, labelStack, nlriByteBuf);
LUNlriParser.serializeLabelStackEntries(labelStack, isWithdrawnRoute, nlriByteBuf);
RouteDistinguisherUtil.serializeRouteDistinquisher(dest.getRouteDistinguisher(), nlriByteBuf);
Preconditions.checkArgument(prefix.getIpv6Prefix() != null || prefix.getIpv4Prefix() != null, "Ipv6 or Ipv4 prefix is missing.");
LUNlriParser.serializePrefixField(prefix, nlriByteBuf);
}
buffer.writeBytes(nlriByteBuf);
}
Aggregations