use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.CRouterIdentifier in project bgpcep by opendaylight.
the class NodeNlriParser method serializeOspfPseudoNode.
private static CRouterIdentifier serializeOspfPseudoNode(final ContainerNode ospfPseudonode) {
final OspfPseudonodeBuilder nodeBuilder = new OspfPseudonodeBuilder();
ospfPseudonode.findChildByArg(LAN_IFACE_NID).map(lanIface -> new OspfInterfaceIdentifier((Uint32) lanIface.body())).ifPresent(nodeBuilder::setLanInterface);
ospfPseudonode.findChildByArg(OSPF_ROUTER_NID).map(ospfRouter -> (Uint32) ospfRouter.body()).ifPresent(nodeBuilder::setOspfRouterId);
return new OspfPseudonodeCaseBuilder().setOspfPseudonode(nodeBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.CRouterIdentifier in project bgpcep by opendaylight.
the class RouterIdTlvParser method serializeTlvBody.
@Override
public void serializeTlvBody(final CRouterIdentifier tlv, final ByteBuf body) {
if (tlv instanceof IsisNodeCase) {
final IsisNode isis = ((IsisNodeCase) tlv).getIsisNode();
body.writeBytes(isis.getIsoSystemId().getValue());
} else if (tlv instanceof IsisPseudonodeCase) {
final IsisPseudonode isis = ((IsisPseudonodeCase) tlv).getIsisPseudonode();
body.writeBytes(isis.getIsIsRouterIdentifier().getIsoSystemId().getValue());
ByteBufUtils.writeOrZero(body, isis.getPsn());
} else if (tlv instanceof OspfNodeCase) {
ByteBufUtils.writeOrZero(body, ((OspfNodeCase) tlv).getOspfNode().getOspfRouterId());
} else if (tlv instanceof OspfPseudonodeCase) {
final OspfPseudonode node = ((OspfPseudonodeCase) tlv).getOspfPseudonode();
ByteBufUtils.writeOrZero(body, node.getOspfRouterId());
ByteBufUtils.write(body, node.getLanInterface().getValue());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.CRouterIdentifier in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method getVertexId.
/**
* Get Vertex in the Graph by the OSPF Router ID or IS-IS-System ID.
*
* @param routerID The Router Identifier entry
*
* @return Vertex in the Connected Graph that corresponds to this Router ID. Vertex is created if not found.
*/
private static Uint64 getVertexId(final CRouterIdentifier routerID) {
Uint64 rid = Uint64.ZERO;
if (routerID instanceof IsisNodeCase) {
final byte[] isoId = ((IsisNodeCase) routerID).getIsisNode().getIsoSystemId().getValue();
final byte[] convert = { 0, 0, isoId[0], isoId[1], isoId[2], isoId[3], isoId[4], isoId[5] };
rid = Uint64.fromLongBits(ByteBuffer.wrap(convert).getLong());
}
if (routerID instanceof OspfNodeCase) {
rid = ((OspfNodeCase) routerID).getOspfNode().getOspfRouterId().toUint64();
}
LOG.debug("Get Vertex Identifier {}", rid);
return rid;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.CRouterIdentifier in project bgpcep by opendaylight.
the class AbstractNodeDescriptorTlvCodec method parseNodeDescriptor.
protected static NodeIdentifier parseNodeDescriptor(final ByteBuf value, final Map<QName, Object> parsedSubTlvs) {
parsedSubTlvs.putAll(SimpleNlriTypeRegistry.getInstance().parseSubTlvs(value));
final AsNumber asNumber = (AsNumber) parsedSubTlvs.get(AsNumTlvParser.AS_NUMBER_QNAME);
final DomainIdentifier domainId = (DomainIdentifier) parsedSubTlvs.get(DomainIdTlvParser.DOMAIN_ID_QNAME);
final AreaIdentifier areaId = (AreaIdentifier) parsedSubTlvs.get(AreaIdTlvParser.AREA_ID_QNAME);
final CRouterIdentifier routerId = (CRouterIdentifier) parsedSubTlvs.get(CRouterIdentifier.QNAME);
return new NodeIdentifier() {
@Override
public Class<NodeIdentifier> implementedInterface() {
return NodeIdentifier.class;
}
@Override
public AsNumber getAsNumber() {
return asNumber;
}
@Override
public DomainIdentifier getDomainId() {
return domainId;
}
@Override
public AreaIdentifier getAreaId() {
return areaId;
}
@Override
public CRouterIdentifier getCRouterIdentifier() {
return routerId;
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.node.identifier.CRouterIdentifier in project bgpcep by opendaylight.
the class ProtocolUtil method ospfNodeAttributes.
private static org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1 ospfNodeAttributes(final NodeIdentifier node, final NodeAttributes na) {
final org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder tb = new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.ospf.node.attributes.ospf.node.attributes.TedBuilder();
final OspfNodeAttributesBuilder ab = new OspfNodeAttributesBuilder();
if (na != null) {
if (na.getIpv4RouterId() != null) {
tb.setTeRouterIdIpv4(na.getIpv4RouterId());
}
if (na.getIpv6RouterId() != null) {
tb.setTeRouterIdIpv6(na.getIpv6RouterId());
}
if (na.getTopologyIdentifier() != null) {
ab.setMultiTopologyId(nodeMultiTopology(na.getTopologyIdentifier()));
}
final CRouterIdentifier ri = node.getCRouterIdentifier();
if (ri instanceof OspfPseudonodeCase) {
final OspfPseudonode pn = ((OspfPseudonodeCase) ri).getOspfPseudonode();
ab.setRouterType(new PseudonodeBuilder().setPseudonode(Empty.getInstance()).build());
ab.setDrInterfaceId(pn.getLanInterface().getValue());
} else if (ri instanceof OspfNodeCase && na.getNodeFlags() != null) {
// TODO: what should we do with in.getOspfRouterId()?
final NodeFlagBits nf = na.getNodeFlags();
if (nf.getAbr() != null) {
ab.setRouterType(new AbrBuilder().setAbr(nf.getAbr() ? Empty.getInstance() : null).build());
} else if (nf.getExternal() != null) {
ab.setRouterType(new InternalBuilder().setInternal(nf.getExternal() ? null : Empty.getInstance()).build());
}
}
}
ab.setTed(tb.build());
return new org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.ospf.topology.rev131021.IgpNodeAttributes1Builder().setOspfNodeAttributes(ab.build()).build();
}
Aggregations