use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrLanAdjIdsBuilder 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(Uint8.TEN)).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.linkstate.rev200120.linkstate.attribute.SrLanAdjIdsBuilder in project bgpcep by opendaylight.
the class SrLinkAttributesParser method parseLanAdjacencySegmentIdentifier.
public static SrLanAdjIds parseLanAdjacencySegmentIdentifier(final ByteBuf buffer, final ProtocolId protocolId) {
if (!buffer.isReadable()) {
return new SrLanAdjIdsBuilder().build();
}
final SrLanAdjIdsBuilder srLanAdjIdBuilder = new SrLanAdjIdsBuilder();
final BitArray flags = BitArray.valueOf(buffer, FLAGS_BITS_SIZE);
srLanAdjIdBuilder.setFlags(parseFlags(flags, protocolId));
srLanAdjIdBuilder.setWeight(new Weight(readUint8(buffer)));
buffer.skipBytes(RESERVED);
final boolean isValue;
final boolean isLocal;
switch(protocolId) {
case IsisLevel1:
case IsisLevel2:
isValue = flags.get(VALUE_ISIS);
isLocal = flags.get(LOCAL_ISIS);
srLanAdjIdBuilder.setIsoSystemId(new IsoSystemIdentifier(ByteArray.readBytes(buffer, ISO_SYSTEM_ID_SIZE)));
break;
case Ospf:
case OspfV3:
isValue = flags.get(VALUE_OSPF);
isLocal = flags.get(LOCAL_OSPF);
srLanAdjIdBuilder.setNeighborId(Ipv4Util.addressForByteBuf(buffer));
break;
default:
return null;
}
// length determines a type of next field, which is used for parsing
srLanAdjIdBuilder.setSidLabelIndex(SidLabelIndexParser.parseSidLabelIndexByFlags(Size.forValue(buffer.readableBytes()), buffer, isValue, isLocal));
return srLanAdjIdBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.linkstate.attribute.SrLanAdjIdsBuilder in project bgpcep by opendaylight.
the class SrAttributeParserTest method testSrLanAdjIdOspf.
@Test
public void testSrLanAdjIdOspf() {
final byte[] tested = { (byte) 0x60, 10, 0, 0, 1, 2, 3, 4, 0, 0x5d, (byte) 0xc0 };
final SrLanAdjIds srLanAdjId = new SrLanAdjIdsBuilder().setFlags(OSPF_LAN_ADJ_FLAGS).setWeight(new Weight(Uint8.TEN)).setNeighborId(new Ipv4AddressNoZone("1.2.3.4")).setSidLabelIndex(new LocalLabelCaseBuilder().setLocalLabel(new MplsLabel(Uint32.valueOf(24000L))).build()).build();
assertEquals(srLanAdjId, SrLinkAttributesParser.parseLanAdjacencySegmentIdentifier(Unpooled.wrappedBuffer(tested), ProtocolId.Ospf));
final ByteBuf serializedData = SrLinkAttributesParser.serializeLanAdjacencySegmentIdentifier(srLanAdjId);
assertArrayEquals(tested, ByteArray.readAllBytes(serializedData));
}
Aggregations