use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class SimpleRegistryTest method testSimpleBgpPrefixSidTlvRegistry.
@Test
public void testSimpleBgpPrefixSidTlvRegistry() {
final BgpPrefixSidTlvRegistry sidTlvReg = this.ctx.getBgpPrefixSidTlvRegistry();
final byte[] tlvBytes = { 0x00, 0x03, 0x00, 0x00, 0x00 };
final BgpPrefixSidTlv tlv = mock(BgpPrefixSidTlv.class);
doReturn(BgpPrefixSidTlv.class).when(tlv).implementedInterface();
final ByteBuf buffer = Unpooled.buffer(tlvBytes.length);
sidTlvReg.serializeBgpPrefixSidTlv(tlv, buffer);
verify(this.activator.sidTlvSerializer, times(1)).serializeBgpPrefixSidTlv(any(BgpPrefixSidTlv.class), any(ByteBuf.class));
sidTlvReg.parseBgpPrefixSidTlv(BgpTestActivator.TYPE, Unpooled.wrappedBuffer(tlvBytes));
verify(this.activator.sidTlvParser, times(1)).parseBgpPrefixSidTlv(any(ByteBuf.class));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class SrAttributeParserTest method testRangeTlv.
// tools.ietf.org/html/draft-gredler-idr-bgp-ls-segment-routing-ext-00#section-2.3.2
@Test
public void testRangeTlv() {
final byte[] tested = { 0, 0, 0, 5, // sid
4, // sid
(byte) 0x89, // sid
0, // sid
4, // sid
1, // sid
2, // sid
3, // sid
4, // prefix + mpls label
4, // prefix + mpls label
(byte) 0x86, // prefix + mpls label
0, // prefix + mpls label
7, // prefix + mpls label
(byte) 0xac, // prefix + mpls label
1, // prefix + mpls label
0, // prefix + mpls label
0, // prefix + mpls label
1, // prefix + mpls label
2, // prefix + mpls label
0, // binding sid
4, // binding sid
(byte) 0x88, // binding sid
0, // binding sid
0x58, // binding sid
5, // binding sid
0x48, // binding sid
0, // binding sid
0, // prefix
4, // prefix
(byte) 0x86, // prefix
0, // prefix
8, // prefix
(byte) 0xa0, // prefix
1, // prefix
0, // prefix
0, // prefix
1, // prefix
2, // prefix
3, // prefix
4, // sid
4, // sid
(byte) 0x89, // sid
0, // sid
4, // sid
1, // sid
2, // sid
3, // sid
4, // ero metric
4, // ero metric
(byte) 0x8a, // ero metric
0, // ero metric
4, // ero metric
0, // ero metric
0, // ero metric
0, // ero metric
6, // IPv4 ERO
4, // IPv4 ERO
(byte) 0x8b, // IPv4 ERO
0, // IPv4 ERO
8, // IPv4 ERO
0, // IPv4 ERO
0, // IPv4 ERO
0, // IPv4 ERO
0, // IPv4 ERO
9, // IPv4 ERO
8, // IPv4 ERO
7, // IPv4 ERO
6, // Unnumbered Interface ID ERO Sub-TLV
4, // Unnumbered Interface ID ERO Sub-TLV
(byte) 0x8d, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0x0c, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
0, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
1, // Unnumbered Interface ID ERO Sub-TLV
2, // Unnumbered Interface ID ERO Sub-TLV
2, // Unnumbered Interface ID ERO Sub-TLV
2, // Unnumbered Interface ID ERO Sub-TLV
2, // IPv4 ERO backup
4, // IPv4 ERO backup
(byte) 0x8e, // IPv4 ERO backup
0, // IPv4 ERO backup
8, // IPv4 ERO backup
0, // IPv4 ERO backup
0, // IPv4 ERO backup
0, // IPv4 ERO backup
0, // IPv4 ERO backup
3, // IPv4 ERO backup
4, // IPv4 ERO backup
5, // IPv4 ERO backup
6, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
(byte) 0x90, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0x0c, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
0, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
3, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
4, // Unnumbered Interface ID ERO Sub-TLV Backup
4 };
final SrRange parsedRange = RangeTlvParser.parseSrRange(Unpooled.wrappedBuffer(tested), ProtocolId.IsisLevel1);
final List<SubTlvs> rangeSubTlvs = new ArrayList<>();
addSubTlvs(rangeSubTlvs);
final SrRange expected = new SrRangeBuilder().setInterArea(Boolean.FALSE).setRangeSize(Uint16.valueOf(5)).setSubTlvs(rangeSubTlvs).build();
assertEquals(expected, parsedRange);
final ByteBuf serializedRange = Unpooled.buffer();
RangeTlvParser.serializeSrRange(parsedRange, serializedRange);
assertArrayEquals(tested, ByteArray.getAllBytes(serializedRange));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class SimpleBindingSubTlvsRegistry method serializeBindingSubTlvs.
public void serializeBindingSubTlvs(final List<BindingSubTlvs> bindingSubTlvs, final ByteBuf aggregator) {
if (bindingSubTlvs != null) {
for (final BindingSubTlvs subTlv : bindingSubTlvs) {
final BindingSubTlv bindingSubTlv = subTlv.getBindingSubTlv();
final BindingSubTlvsSerializer serializer = handlers.getSerializer(bindingSubTlv.implementedInterface());
if (serializer == null) {
LOG.info("Unknown binding sub Tlv type {}", subTlv);
return;
}
serializer.serializeSubTlv(bindingSubTlv, aggregator);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class LinkstateNlriParser method parseNlri.
/**
* Parses common parts for Link State Nodes, Links and Prefixes, that includes protocol ID and identifier tlv.
*
* @param nlri as byte array
* @return {@link CLinkstateDestination}
*/
private List<CLinkstateDestination> parseNlri(final ByteBuf nlri) {
final List<CLinkstateDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final CLinkstateDestination destination = this.nlriTypeReg.parseNlriType(nlri);
if (destination == null) {
continue;
}
dests.add(destination);
}
return dests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.message.rev200120.Tlv in project bgpcep by opendaylight.
the class PCEPTlvParserTest method testSymbolicNameTlv.
@Test
public void testSymbolicNameTlv() throws PCEPDeserializerException {
final StatefulLspSymbolicNameTlvParser parser = new StatefulLspSymbolicNameTlvParser();
final SymbolicPathName tlv = new SymbolicPathNameBuilder().setPathName(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev200720.SymbolicPathName("Med test of symbolic nameeee".getBytes())).build();
assertEquals(tlv, parser.parseTlv(Unpooled.wrappedBuffer(ByteArray.cutBytes(SYMBOLIC_NAME_BYTES, 4))));
final ByteBuf buff = Unpooled.buffer();
parser.serializeTlv(tlv, buff);
assertArrayEquals(SYMBOLIC_NAME_BYTES, ByteArray.getAllBytes(buff));
}
Aggregations