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);
Assert.assertEquals(L3VPNIPV4UNICAST.class, afiSafiType.get());
final Optional<Class<? extends AfiSafiType>> afiSafiType2 = registry.getAfiSafiType(IPV6);
Assert.assertEquals(L3VPNIPV6UNICAST.class, afiSafiType2.get());
final Optional<BgpTableType> tableType = registry.getTableType(L3VPNIPV4UNICAST.class);
Assert.assertEquals(IPV4, tableType.get());
final Optional<BgpTableType> tableType2 = registry.getTableType(L3VPNIPV6UNICAST.class);
Assert.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 PCEPObjectParserTest method testPccIdReqIPv6Object.
@Test
public void testPccIdReqIPv6Object() throws PCEPDeserializerException {
final byte[] pccIdReqBytes = { /* object header */
0x14, 0x20, 0x00, 0x14, /* ipv6 address */
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 };
final PCEPPccIdReqIPv6ObjectParser parser = new PCEPPccIdReqIPv6ObjectParser();
final PccIdReq pccIdReq = new PccIdReqBuilder().setIpAddress(new IpAddress(new Ipv6Address("::1"))).build();
final ByteBuf result = Unpooled.wrappedBuffer(pccIdReqBytes);
assertEquals(pccIdReq, parser.parseObject(new ObjectHeaderImpl(false, false), result.slice(4, result.readableBytes() - 4)));
final ByteBuf buf = Unpooled.buffer(pccIdReqBytes.length);
parser.serializeObject(pccIdReq, buf);
assertArrayEquals(pccIdReqBytes, buf.array());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class Stateful07LSPIdentifierIpv6TlvParser method serializeTlv.
@Override
public void serializeTlv(final Tlv tlv, final ByteBuf buffer) {
Preconditions.checkArgument(tlv instanceof LspIdentifiers, "LspIdentifiersTlv is mandatory.");
final LspIdentifiers lsp = (LspIdentifiers) tlv;
final ByteBuf body = Unpooled.buffer();
final Ipv6 ipv6 = ((Ipv6Case) lsp.getAddressFamily()).getIpv6();
Preconditions.checkArgument(ipv6.getIpv6TunnelSenderAddress() != null, "Ipv6TunnelSenderAddress is mandatory.");
writeIpv6Address(ipv6.getIpv6TunnelSenderAddress(), body);
Preconditions.checkArgument(lsp.getLspId() != null, "LspId is mandatory.");
writeShort(lsp.getLspId().getValue().shortValue(), body);
Preconditions.checkArgument(lsp.getTunnelId() != null, "TunnelId is mandatory.");
writeUnsignedShort(lsp.getTunnelId().getValue(), body);
Preconditions.checkArgument(ipv6.getIpv6ExtendedTunnelId() != null, "Ipv6ExtendedTunnelId is mandatory.");
writeIpv6Address(ipv6.getIpv6ExtendedTunnelId(), body);
Preconditions.checkArgument(ipv6.getIpv6TunnelEndpointAddress() != null, "Ipv6TunnelEndpointAddress is mandatory.");
writeIpv6Address(ipv6.getIpv6TunnelEndpointAddress(), body);
TlvUtil.formatTlv(TYPE, body, buffer);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class Stateful07LSPIdentifierIpv6TlvParser method parseTlv.
@Override
public LspIdentifiers parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
Preconditions.checkArgument(buffer.readableBytes() == V6_LENGTH, "Length %s does not match LSP Identifiers Ipv6 tlv length.", buffer.readableBytes());
final Ipv6Builder builder = new Ipv6Builder();
builder.setIpv6TunnelSenderAddress(Ipv6Util.addressForByteBuf(buffer));
final LspId lspId = new LspId((long) buffer.readUnsignedShort());
final TunnelId tunnelId = new TunnelId(buffer.readUnsignedShort());
builder.setIpv6ExtendedTunnelId(new Ipv6ExtendedTunnelId(Ipv6Util.addressForByteBuf(buffer)));
builder.setIpv6TunnelEndpointAddress(Ipv6Util.addressForByteBuf(buffer));
final AddressFamily afi = new Ipv6CaseBuilder().setIpv6(builder.build()).build();
return new LspIdentifiersBuilder().setAddressFamily(afi).setLspId(lspId).setTunnelId(tunnelId).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.address.address.Ipv6 in project bgpcep by opendaylight.
the class BGPParserTest method testEORIpv6exLength.
/*
* End of Rib for Ipv6 consists of empty MP_UNREACH_NLRI, with AFI 2 and SAFI 1
*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
* 00 1e <- length (29) - including header
* 02 <- message type
* 00 00 <- withdrawn routes length
* 00 07 <- total path attribute length
* 90 <- attribute flags
* 0f <- attribute type (15 - MP_UNREACH_NLRI)
* 00 03 <- attribute length
* 00 02 <- value (AFI 2: IPv6)
* 01 <- value (SAFI 1)
*/
@Test
public void testEORIpv6exLength() throws Exception {
final byte[] body = ByteArray.cutBytes(inputBytes.get(6), MessageUtil.COMMON_HEADER_LENGTH);
final int messageLength = ByteArray.bytesToInt(ByteArray.subByte(inputBytes.get(6), MessageUtil.MARKER_LENGTH, LENGTH_FIELD_LENGTH));
final Update message = BGPParserTest.updateParser.parseMessageBody(Unpooled.copiedBuffer(body), messageLength);
final Class<? extends AddressFamily> afi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getAfi();
final Class<? extends SubsequentAddressFamily> safi = message.getAttributes().getAugmentation(Attributes2.class).getMpUnreachNlri().getSafi();
assertEquals(Ipv6AddressFamily.class, afi);
assertEquals(UnicastSubsequentAddressFamily.class, safi);
final ByteBuf buffer = Unpooled.buffer();
BGPParserTest.updateParser.serializeMessage(message, buffer);
assertArrayEquals(inputBytes.get(6), ByteArray.readAllBytes(buffer));
}
Aggregations