use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv in project bgpcep by opendaylight.
the class BgpPrefixSidAttributeParser method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPDocumentedException, BGPParsingException {
final BgpPrefixSidBuilder sid = new BgpPrefixSidBuilder();
final List<BgpPrefixSidTlvs> tlvList = new ArrayList<>();
while (buffer.isReadable()) {
final BgpPrefixSidTlv tlv = this.reg.parseBgpPrefixSidTlv(buffer.readUnsignedByte(), buffer);
tlvList.add(new BgpPrefixSidTlvsBuilder().setBgpPrefixSidTlv(tlv).build());
}
builder.setBgpPrefixSid(sid.setBgpPrefixSidTlvs(tlvList).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv in project bgpcep by opendaylight.
the class OriginatorSrgbTlvParser method serializeBgpPrefixSidTlv.
@Override
public void serializeBgpPrefixSidTlv(final BgpPrefixSidTlv tlv, final ByteBuf valueBuf) {
checkArgument(tlv instanceof LuOriginatorSrgbTlv, "Incoming TLV is not LuOriginatorSrgbTlv");
final LuOriginatorSrgbTlv luTlv = (LuOriginatorSrgbTlv) tlv;
valueBuf.writeZero(ORIGINATOR_FLAGS_BYTES);
for (final SrgbValue val : luTlv.nonnullSrgbValue()) {
writeUint24(valueBuf, val.getBase());
writeUint24(valueBuf, val.getRange());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv 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.bgp.message.rev200120.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv in project bgpcep by opendaylight.
the class Ipv6BgpPrefixSidParser method serializeBgpPrefixSidTlv.
@Override
public void serializeBgpPrefixSidTlv(final BgpPrefixSidTlv tlv, final ByteBuf bytes) {
Preconditions.checkArgument(tlv instanceof Ipv6SidTlv, "Incoming TLV is not Ipv6SidTlv");
final Ipv6SidTlv ipv6Tlv = (Ipv6SidTlv) tlv;
bytes.writeZero(RESERVED);
final BitArray flags = new BitArray(FLAGS_SIZE);
flags.set(PROCESS_IPV6_HEADER_FLAG, ipv6Tlv.getProcessIpv6HeadAbility());
flags.toByteBuf(bytes);
}
Aggregations