use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.IsisNodeCaseBuilder in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method testLinkNlri.
@Test
public void testLinkNlri() throws BGPParsingException {
setUp(this.linkNlri);
// test BA form
assertNull(this.dest.getRouteDistinguisher());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
assertEquals(Uint64.ONE, this.dest.getIdentifier().getValue());
final LinkCase lCase = (LinkCase) this.dest.getObjectType();
final LocalNodeDescriptors local = lCase.getLocalNodeDescriptors();
assertEquals(new AsNumber(Uint32.valueOf(72)), local.getAsNumber());
assertEquals(new DomainIdentifier(Uint32.valueOf(0x28282828L)), local.getDomainId());
assertEquals(new IsisNodeCaseBuilder().setIsisNode(new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x42 })).build()).build(), local.getCRouterIdentifier());
assertEquals("1.1.1.1", local.getBgpRouterId().getValue());
assertEquals(new AsNumber(Uint32.valueOf(258)), local.getMemberAsn());
final RemoteNodeDescriptors remote = lCase.getRemoteNodeDescriptors();
assertEquals(new AsNumber(Uint32.valueOf(72)), remote.getAsNumber());
assertEquals(new DomainIdentifier(Uint32.valueOf(0x28282828L)), remote.getDomainId());
assertEquals(new OspfNodeCaseBuilder().setOspfNode(new OspfNodeBuilder().setOspfRouterId(Uint32.valueOf(0x00000040L)).build()).build(), remote.getCRouterIdentifier());
assertEquals(new AsNumber(Uint32.valueOf(259)), remote.getMemberAsn());
assertEquals("1.1.1.2", remote.getBgpRouterId().getValue());
final LinkDescriptors ld = lCase.getLinkDescriptors();
assertEquals("197.20.160.42", ld.getIpv4InterfaceAddress().getValue());
assertEquals("197.20.160.40", ld.getIpv4NeighborAddress().getValue());
final ByteBuf buffer = Unpooled.buffer();
this.registry.serializeNlriType(this.dest, buffer);
assertArrayEquals(this.linkNlri, ByteArray.readAllBytes(buffer));
// test BI form
final DataContainerNodeBuilder<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("isis-level2");
linkstateBI.addChild(protocolId.build());
final ImmutableLeafNodeBuilder<Uint64> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
identifier.withValue(Uint64.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
// local node descriptors
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> localNodeDescriptors = Builders.containerBuilder();
localNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.LOCAL_NODE_DESCRIPTORS_NID);
final ImmutableLeafNodeBuilder<Uint32> asNumber = new ImmutableLeafNodeBuilder<>();
asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
asNumber.withValue(Uint32.valueOf(72));
localNodeDescriptors.addChild(asNumber.build());
final ImmutableLeafNodeBuilder<Uint32> domainID = new ImmutableLeafNodeBuilder<>();
domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
domainID.withValue(Uint32.valueOf(0x28282828L));
localNodeDescriptors.addChild(domainID.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
crouterId.withNodeIdentifier(C_ROUTER_ID_NID);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> isisNode = Builders.containerBuilder();
isisNode.withNodeIdentifier(NodeNlriParser.ISIS_NODE_NID);
final ImmutableLeafNodeBuilder<byte[]> isoSystemID = new ImmutableLeafNodeBuilder<>();
isoSystemID.withNodeIdentifier(NodeNlriParser.ISO_SYSTEM_NID);
isoSystemID.withValue(new byte[] { 0, 0, 0, 0, 0, (byte) 0x42 });
isisNode.addChild(isoSystemID.build());
crouterId.addChild(isisNode.build());
localNodeDescriptors.addChild(crouterId.build());
final ImmutableLeafNodeBuilder<String> bgpRouterId = new ImmutableLeafNodeBuilder<>();
bgpRouterId.withNodeIdentifier(NodeNlriParser.BGP_ROUTER_NID);
bgpRouterId.withValue("1.1.1.1");
final ImmutableLeafNodeBuilder<Uint32> memberAsn = new ImmutableLeafNodeBuilder<>();
memberAsn.withNodeIdentifier(NodeNlriParser.MEMBER_ASN_NID);
memberAsn.withValue(Uint32.valueOf(258L));
localNodeDescriptors.addChild(bgpRouterId.build());
localNodeDescriptors.addChild(memberAsn.build());
// remote descriptors
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> remoteNodeDescriptors = Builders.containerBuilder();
remoteNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.REMOTE_NODE_DESCRIPTORS_NID);
remoteNodeDescriptors.addChild(asNumber.build());
remoteNodeDescriptors.addChild(domainID.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId2 = Builders.choiceBuilder();
crouterId2.withNodeIdentifier(C_ROUTER_ID_NID);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> ospfNode = Builders.containerBuilder();
ospfNode.withNodeIdentifier(NodeNlriParser.OSPF_NODE_NID);
final ImmutableLeafNodeBuilder<Uint32> ospfRouterId = new ImmutableLeafNodeBuilder<>();
ospfRouterId.withNodeIdentifier(NodeNlriParser.OSPF_ROUTER_NID);
ospfRouterId.withValue(Uint32.valueOf(0x00000040L));
ospfNode.addChild(ospfRouterId.build());
crouterId2.addChild(ospfNode.build());
remoteNodeDescriptors.addChild(crouterId2.build());
final ImmutableLeafNodeBuilder<String> bgpRouterIdRemote = new ImmutableLeafNodeBuilder<>();
bgpRouterIdRemote.withNodeIdentifier(NodeNlriParser.BGP_ROUTER_NID);
bgpRouterIdRemote.withValue("1.1.1.2");
remoteNodeDescriptors.addChild(bgpRouterIdRemote.build());
final ImmutableLeafNodeBuilder<Uint32> memberAsnRemote = new ImmutableLeafNodeBuilder<>();
memberAsnRemote.withNodeIdentifier(NodeNlriParser.MEMBER_ASN_NID);
memberAsnRemote.withValue(Uint32.valueOf(259));
remoteNodeDescriptors.addChild(memberAsnRemote.build());
// link descritpors
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> linkDescriptors = Builders.containerBuilder();
linkDescriptors.withNodeIdentifier(LinkstateNlriParser.LINK_DESCRIPTORS_NID);
final ImmutableLeafNodeBuilder<Uint32> linkLocalIdentifier = new ImmutableLeafNodeBuilder<>();
linkLocalIdentifier.withNodeIdentifier(LinkNlriParser.LINK_LOCAL_NID);
linkLocalIdentifier.withValue(Uint32.valueOf(16909060L));
final ImmutableLeafNodeBuilder<Uint32> linkRemoteIdentifier = new ImmutableLeafNodeBuilder<>();
linkRemoteIdentifier.withNodeIdentifier(LinkNlriParser.LINK_REMOTE_NID);
linkRemoteIdentifier.withValue(Uint32.valueOf(168496141L));
final ImmutableLeafNodeBuilder<String> ipv4InterfaceAddress = new ImmutableLeafNodeBuilder<>();
ipv4InterfaceAddress.withNodeIdentifier(LinkNlriParser.IPV4_IFACE_NID);
ipv4InterfaceAddress.withValue("197.20.160.42");
final ImmutableLeafNodeBuilder<String> ipv4NeighborAddress = new ImmutableLeafNodeBuilder<>();
ipv4NeighborAddress.withNodeIdentifier(LinkNlriParser.IPV4_NEIGHBOR_NID);
ipv4NeighborAddress.withValue("197.20.160.40");
final ImmutableLeafNodeBuilder<Uint16> multiTopologyId = new ImmutableLeafNodeBuilder<>();
multiTopologyId.withNodeIdentifier(TlvUtil.MULTI_TOPOLOGY_NID);
multiTopologyId.withValue(Uint16.valueOf(3));
linkDescriptors.addChild(linkLocalIdentifier.build());
linkDescriptors.addChild(linkRemoteIdentifier.build());
linkDescriptors.addChild(ipv4InterfaceAddress.build());
linkDescriptors.addChild(ipv4NeighborAddress.build());
linkDescriptors.addChild(multiTopologyId.build());
objectType.addChild(localNodeDescriptors.build());
objectType.addChild(remoteNodeDescriptors.build());
objectType.addChild(linkDescriptors.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.rev200120.node.identifier.c.router.identifier.IsisNodeCaseBuilder in project bgpcep by opendaylight.
the class NodeNlriParser method serializeIsisNode.
private static IsisNodeCase serializeIsisNode(final ContainerNode isis) {
final IsisNodeCaseBuilder builder = new IsisNodeCaseBuilder();
final IsisNodeBuilder isisBuilder = new IsisNodeBuilder();
isisBuilder.setIsoSystemId(new IsoSystemIdentifier((byte[]) isis.getChild(ISO_SYSTEM_NID).get().getValue()));
builder.setIsisNode(isisBuilder.build());
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.c.router.identifier.IsisNodeCaseBuilder in project bgpcep by opendaylight.
the class LinkstateNlriParserTest method testPrefixNlri.
@Test
public void testPrefixNlri() throws BGPParsingException {
setUp(this.prefixNlri);
// test BA form
assertNull(this.dest.getRouteDistinguisher());
assertEquals(ProtocolId.IsisLevel2, this.dest.getProtocolId());
assertEquals(Uint64.ONE, this.dest.getIdentifier().getValue());
final PrefixCase pCase = (PrefixCase) this.dest.getObjectType();
final AdvertisingNodeDescriptors local = pCase.getAdvertisingNodeDescriptors();
assertEquals(new AsNumber(Uint32.valueOf(72)), local.getAsNumber());
assertEquals(new DomainIdentifier(Uint32.valueOf(0x28282828L)), local.getDomainId());
assertEquals(new IsisNodeCaseBuilder().setIsisNode(new IsisNodeBuilder().setIsoSystemId(new IsoSystemIdentifier(new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x42 })).build()).build(), local.getCRouterIdentifier());
final PrefixDescriptors pd = pCase.getPrefixDescriptors();
assertEquals(OspfRouteType.External1, pd.getOspfRouteType());
assertEquals(new TopologyIdentifier(Uint16.valueOf(15)), pd.getMultiTopologyId());
assertEquals(new Ipv4Prefix("255.255.0.0/16"), pd.getIpReachabilityInformation().getIpv4Prefix());
final ByteBuf buffer = Unpooled.buffer();
this.registry.serializeNlriType(this.dest, buffer);
assertArrayEquals(this.prefixNlri, ByteArray.readAllBytes(buffer));
// test BI form
final DataContainerNodeBuilder<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("isis-level2");
linkstateBI.addChild(protocolId.build());
final ImmutableLeafNodeBuilder<Uint64> identifier = new ImmutableLeafNodeBuilder<>();
identifier.withNodeIdentifier(LinkstateNlriParser.IDENTIFIER_NID);
identifier.withValue(Uint64.ONE);
linkstateBI.addChild(identifier.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> objectType = Builders.choiceBuilder();
objectType.withNodeIdentifier(LinkstateNlriParser.OBJECT_TYPE_NID);
// advertising node descriptors
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> advertisingNodeDescriptors = Builders.containerBuilder();
advertisingNodeDescriptors.withNodeIdentifier(LinkstateNlriParser.ADVERTISING_NODE_DESCRIPTORS_NID);
final ImmutableLeafNodeBuilder<Uint32> asNumber = new ImmutableLeafNodeBuilder<>();
asNumber.withNodeIdentifier(NodeNlriParser.AS_NUMBER_NID);
asNumber.withValue(Uint32.valueOf(72));
advertisingNodeDescriptors.addChild(asNumber.build());
final ImmutableLeafNodeBuilder<Uint32> domainID = new ImmutableLeafNodeBuilder<>();
domainID.withNodeIdentifier(NodeNlriParser.DOMAIN_NID);
domainID.withValue(Uint32.valueOf(673720360L));
advertisingNodeDescriptors.addChild(domainID.build());
final DataContainerNodeBuilder<NodeIdentifier, ChoiceNode> crouterId = Builders.choiceBuilder();
crouterId.withNodeIdentifier(C_ROUTER_ID_NID);
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> isisNode = Builders.containerBuilder();
isisNode.withNodeIdentifier(NodeNlriParser.ISIS_NODE_NID);
final ImmutableLeafNodeBuilder<byte[]> isoSystemID = new ImmutableLeafNodeBuilder<>();
isoSystemID.withNodeIdentifier(NodeNlriParser.ISO_SYSTEM_NID);
isoSystemID.withValue(new byte[] { 0, 0, 0, 0, 0, (byte) 0x42 });
isisNode.addChild(isoSystemID.build());
crouterId.addChild(isisNode.build());
advertisingNodeDescriptors.addChild(crouterId.build());
// prefix descriptors
final DataContainerNodeBuilder<NodeIdentifier, ContainerNode> prefixDescriptors = Builders.containerBuilder();
prefixDescriptors.withNodeIdentifier(LinkstateNlriParser.PREFIX_DESCRIPTORS_NID);
prefixDescriptors.addChild(asNumber.build());
prefixDescriptors.addChild(domainID.build());
final ImmutableLeafNodeBuilder<Uint16> multiTopologyId = new ImmutableLeafNodeBuilder<>();
multiTopologyId.withNodeIdentifier(TlvUtil.MULTI_TOPOLOGY_NID);
multiTopologyId.withValue(Uint16.valueOf(15));
prefixDescriptors.addChild(multiTopologyId.build());
final ImmutableLeafNodeBuilder<String> ipReachabilityInformation = new ImmutableLeafNodeBuilder<>();
ipReachabilityInformation.withNodeIdentifier(IP_REACH_NID);
ipReachabilityInformation.withValue("255.255.0.0/16");
prefixDescriptors.addChild(ipReachabilityInformation.build());
final ImmutableLeafNodeBuilder<String> ospfRouteType = new ImmutableLeafNodeBuilder<>();
ospfRouteType.withNodeIdentifier(OSPF_ROUTE_NID);
ospfRouteType.withValue("external1");
prefixDescriptors.addChild(ospfRouteType.build());
objectType.addChild(advertisingNodeDescriptors.build());
objectType.addChild(prefixDescriptors.build());
linkstateBI.addChild(objectType.build());
assertEquals(this.dest, LinkstateNlriParser.extractLinkstateDestination(linkstateBI.build()));
}
Aggregations