use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex in project bgpcep by opendaylight.
the class SrLinkAttributesParser method parseEpeAdjacencySegmentIdentifier.
public static EpeAdjSidTlv parseEpeAdjacencySegmentIdentifier(final ByteBuf buffer) {
final Weight weight;
final SidLabelIndex sidValue;
if (buffer.isReadable()) {
final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
weight = new Weight(readUint8(buffer));
buffer.skipBytes(RESERVED);
sidValue = SidLabelIndexParser.parseSidLabelIndexByFlags(Size.forValue(buffer.readableBytes()), buffer, flags.get(VALUE_EPE), flags.get(LOCAL_EPE));
} else {
weight = null;
sidValue = null;
}
return new EpeAdjSidTlv() {
@Override
public Class<EpeAdjSidTlv> implementedInterface() {
return EpeAdjSidTlv.class;
}
@Override
public Weight getWeight() {
return weight;
}
@Override
public SidLabelIndex getSidLabelIndex() {
return sidValue;
}
};
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev200120.sid.label.index.SidLabelIndex in project bgpcep by opendaylight.
the class LinkstateGraphBuilder method getVertex.
/**
* Create Vertex from the Node Attributes.
*
* @param na Node Attributes
* @param cvertex Connected Vertex associated to this Vertex
* @param as As number
*
* @return New Vertex
*/
private static Vertex getVertex(final NodeAttributes na, final Uint64 id, final Uint32 as) {
VertexBuilder builder = new VertexBuilder().setVertexId(id).setAsn(as);
if (na.getIpv4RouterId() != null) {
builder.setRouterId(new IpAddress(na.getIpv4RouterId()));
}
if (na.getIpv6RouterId() != null) {
builder.setRouterId(new IpAddress(na.getIpv6RouterId()));
}
/*
* Set Router Name with dynamic hostname (IS-IS) or IPv4 address in dot decimal format (OSPF)
*/
if (na.getDynamicHostname() != null) {
builder.setName(na.getDynamicHostname());
} else {
int key = id.intValue();
builder.setName((key << 24 & 0xFF) + "." + (key << 16 & 0xFF) + "." + (key << 8 & 0xFF) + "." + (key & 0xFF));
}
if (na.getSrCapabilities() != null) {
final SidLabelIndex labelIndex = na.getSrCapabilities().getSidLabelIndex();
if (labelIndex instanceof LocalLabelCase) {
builder.setSrgb(new SrgbBuilder().setLowerBound(((LocalLabelCase) labelIndex).getLocalLabel().getValue()).setRangeSize(na.getSrCapabilities().getRangeSize().getValue()).build());
} else if (labelIndex instanceof SidCase) {
builder.setSrgb(new SrgbBuilder().setLowerBound(((SidCase) labelIndex).getSid()).setRangeSize(na.getSrCapabilities().getRangeSize().getValue()).build());
}
}
if (na.getNodeFlags() != null) {
if (na.getNodeFlags().getAbr()) {
builder.setVertexType(VertexType.Abr);
}
if (na.getNodeFlags().getExternal()) {
builder.setVertexType(VertexType.AsbrOut);
}
} else {
builder.setVertexType(VertexType.Standard);
}
return builder.build();
}
Aggregations