use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCase in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method testTELspNlri.
@Test
public void testTELspNlri() throws BGPParsingException {
setUp(this.teLspNlri);
// test BA form
assertNull(this.dest.getDistinguisher());
assertEquals(ProtocolId.RsvpTe, this.dest.getProtocolId());
assertEquals(BigInteger.ONE, this.dest.getIdentifier().getValue());
final TeLspCase teCase = (TeLspCase) this.dest.getObjectType();
assertEquals(new LspId(1L), teCase.getLspId());
assertEquals(new TunnelId(1), teCase.getTunnelId());
assertEquals(new Ipv4Address("1.2.3.4"), ((Ipv4Case) teCase.getAddressFamily()).getIpv4TunnelSenderAddress());
assertEquals(new Ipv4Address("4.3.2.1"), ((Ipv4Case) teCase.getAddressFamily()).getIpv4TunnelEndpointAddress());
// test BI form
final DataContainerNodeAttrBuilder<YangInstanceIdentifier.NodeIdentifier, UnkeyedListEntryNode> linkstateBI = ImmutableUnkeyedListEntryNodeBuilder.create();
linkstateBI.withNodeIdentifier(C_LINKSTATE_NID);
final ImmutableLeafNodeBuilder<String> protocolId = new ImmutableLeafNodeBuilder<>();
protocolId.withNodeIdentifier(LinkstateNlriParser.PROTOCOL_ID_NID);
protocolId.withValue("rsvp-te");
linkstateBI.addChild(protocolId.build());
final ImmutableLeafNodeBuilder<BigInteger> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
identifier.withValue(BigInteger.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
final ImmutableLeafNodeBuilder<Long> lspId = new ImmutableLeafNodeBuilder<>();
lspId.withNodeIdentifier(AbstractTeLspNlriCodec.LSP_ID);
lspId.withValue(1L);
final ImmutableLeafNodeBuilder<Integer> tunnelId = new ImmutableLeafNodeBuilder<>();
tunnelId.withNodeIdentifier(AbstractTeLspNlriCodec.TUNNEL_ID);
tunnelId.withValue(1);
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> addressFamily = Builders.choiceBuilder();
addressFamily.withNodeIdentifier(AbstractTeLspNlriCodec.ADDRESS_FAMILY);
final ImmutableLeafNodeBuilder<String> ipv4TunnelSenderAddress = new ImmutableLeafNodeBuilder<>();
ipv4TunnelSenderAddress.withNodeIdentifier(AbstractTeLspNlriCodec.IPV4_TUNNEL_SENDER_ADDRESS);
ipv4TunnelSenderAddress.withValue("1.2.3.4");
final ImmutableLeafNodeBuilder<String> ipv4TunnelEndPointAddress = new ImmutableLeafNodeBuilder<>();
ipv4TunnelEndPointAddress.withNodeIdentifier(AbstractTeLspNlriCodec.IPV4_TUNNEL_ENDPOINT_ADDRESS);
ipv4TunnelEndPointAddress.withValue("4.3.2.1");
addressFamily.addChild(ipv4TunnelSenderAddress.build());
addressFamily.addChild(ipv4TunnelEndPointAddress.build());
objectType.addChild(lspId.build());
objectType.addChild(tunnelId.build());
objectType.addChild(addressFamily.build());
linkstateBI.addChild(objectType.build());
assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCase in project bgpcep by opendaylight.
the class AbstractTeLspNlriCodec method serializeObjectType.
@Override
protected final void serializeObjectType(final ObjectType objectType, final ByteBuf buffer) {
Preconditions.checkArgument(objectType instanceof TeLspCase);
final TeLspCase teLSP = (TeLspCase) objectType;
final AddressFamily addressFamily = teLSP.getAddressFamily();
if (addressFamily instanceof Ipv4Case) {
serializeIpv4Case(teLSP, (Ipv4Case) addressFamily, buffer);
} else {
serializeIpv6Case(teLSP, (Ipv6Case) addressFamily, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev171207.linkstate.object.type.TeLspCase in project bgpcep by opendaylight.
the class AbstractTeLspNlriCodec method serializeTeLsp.
public static TeLspCase serializeTeLsp(final ChoiceNode objectType) {
final TeLspCaseBuilder teLsp = new TeLspCaseBuilder();
teLsp.setLspId(new LspId((Long) objectType.getChild(LSP_ID).get().getValue()));
teLsp.setTunnelId(new TunnelId((Integer) objectType.getChild(TUNNEL_ID).get().getValue()));
final ChoiceNode addressFamily = (ChoiceNode) objectType.getChild(ADDRESS_FAMILY).get();
teLsp.setAddressFamily(serializeAddressFamily(addressFamily, addressFamily.getChild(IPV4_TUNNEL_SENDER_ADDRESS).isPresent()));
return teLsp.build();
}
Aggregations