use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project bgpcep by opendaylight.
the class BindingSidLabelParser method parseBindingSidLabel.
public static SrBindingSidLabels parseBindingSidLabel(final ByteBuf buffer, final ProtocolId protocolId) {
final SrBindingSidLabelsBuilder bindingSid = new SrBindingSidLabelsBuilder();
bindingSid.setWeight(new Weight(buffer.readUnsignedByte()));
final BitArray flags = BitArray.valueOf(buffer, FLAGS_SIZE);
bindingSid.setFlags(parseBindingSidFlags(flags, protocolId));
buffer.skipBytes(RESERVED_BINDING_SID);
bindingSid.setBindingSubTlvs(SimpleBindingSubTlvsRegistry.getInstance().parseBindingSubTlvs(buffer, protocolId));
return bindingSid.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project bgpcep by opendaylight.
the class SrLinkAttributesParser method parseAdjacencySegmentIdentifier.
public static SrAdjIds parseAdjacencySegmentIdentifier(final ByteBuf buffer, final ProtocolId protocolId) {
final Flags adjFlags;
final Weight weight;
final SidLabelIndex sidValue;
if (buffer.isReadable()) {
final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
adjFlags = parseFlags(flags, protocolId);
weight = new Weight(buffer.readUnsignedByte());
buffer.skipBytes(RESERVED);
sidValue = SidLabelIndexParser.parseSidLabelIndex(Size.forValue(buffer.readableBytes()), buffer);
} else {
adjFlags = null;
weight = null;
sidValue = null;
}
return new SrAdjIdsBuilder().setFlags(adjFlags).setSidLabelIndex(sidValue).setWeight(weight).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project bgpcep by opendaylight.
the class SrAttributeParserTest method addSubTlvs.
private static void addSubTlvs(final List<SubTlvs> rangeSubTlvs) {
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new SidLabelTlvCaseBuilder().setSidLabelIndex(new SidCaseBuilder().setSid(16909060L).build()).build()).build());
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new PrefixSidTlvCaseBuilder().setFlags(ISIS_PREFIX_FLAGS).setAlgorithm(Algorithm.StrictShortestPathFirst).setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(66048L)).build()).build()).build());
final List<BindingSubTlvs> bindingSubTlvs = new ArrayList<>();
addBindingSubTlvs(bindingSubTlvs);
rangeSubTlvs.add(new SubTlvsBuilder().setRangeSubTlv(new BindingSidTlvCaseBuilder().setWeight(new Weight((short) 5)).setFlags(BINDING_FLAGS).setBindingSubTlvs(bindingSubTlvs).build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrLanAdjIdIsis.
@Test
public void testSrLanAdjIdIsis() {
final byte[] tested = { (byte) 0x60, 10, 0, 0, 1, 2, 3, 4, 5, 6, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] sidLabel = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] systemId = { 1, 2, 3, 4, 5, 6 };
final SrLanAdjIds srLanAdjId = new SrLanAdjIdsBuilder().setFlags(ISIS_ADJ_FLAGS).setWeight(new Weight((short) 10)).setIsoSystemId(new IsoSystemIdentifier(systemId)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
assertEquals(srLanAdjId, SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1));
final ByteBuf serializedData = SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifier(srLanAdjId);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.segment.routing.ext.rev151014.Weight in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrAdjId.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.2.1
@Test
public void testSrAdjId() {
final byte[] tested = { (byte) 0x60, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] testedOspf = { (byte) 0xc0, 10, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final byte[] sidLabel = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
final SrAdjIds srAdjId = new SrAdjIdsBuilder().setFlags(ISIS_ADJ_FLAGS).setWeight(new Weight((short) 10)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
final SrAdjIds ospfAdj = new SrAdjIdsBuilder().setFlags(OSPF_ADJ_FLAGS).setWeight(new Weight((short) 10)).setSidLabelIndex(new Ipv6AddressCaseBuilder().setIpv6Address(Ipv6Util.addressForByteBuf(Unpooled.copiedBuffer(sidLabel))).build()).build();
assertEquals(srAdjId, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1)).build());
assertEquals(ospfAdj, new SrAdjIdsBuilder(SrLinkAttributesParser.parseAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(testedOspf), ProtocolId.Ospf)).build());
final ByteBuf serializedData = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(srAdjId);
final ByteBuf serializedOspf = SrLinkAttributesParser.serializeAdjacencySegmentIdentifier(ospfAdj);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
assertArrayEquals(testedOspf, ByteArray.readAllBytes(serializedOspf));
}
Aggregations