Search in sources :

Example 1 with BgpPrefixSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.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).getImplementedInterface();
    final ByteBuf buffer = Unpooled.buffer(tlvBytes.length);
    sidTlvReg.serializeBgpPrefixSidTlv(tlv, buffer);
    verify(this.activator.sidTlvSerializer, times(1)).serializeBgpPrefixSidTlv(Mockito.any(BgpPrefixSidTlv.class), Mockito.any(ByteBuf.class));
    sidTlvReg.parseBgpPrefixSidTlv(BgpTestActivator.TYPE, Unpooled.wrappedBuffer(tlvBytes));
    verify(this.activator.sidTlvParser, times(1)).parseBgpPrefixSidTlv(Mockito.any(ByteBuf.class));
}
Also used : BgpPrefixSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv) BgpPrefixSidTlvRegistry(org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvRegistry) ByteBuf(io.netty.buffer.ByteBuf) Test(org.junit.Test)

Example 2 with BgpPrefixSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.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.isProcessIpv6HeadAbility());
    flags.toByteBuf(bytes);
}
Also used : Ipv6SidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.Ipv6SidTlv) BitArray(org.opendaylight.protocol.util.BitArray)

Example 3 with BgpPrefixSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.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());
}
Also used : BgpPrefixSidTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv) BgpPrefixSidTlvs(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvs) ArrayList(java.util.ArrayList) BgpPrefixSidBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.BgpPrefixSidBuilder) BgpPrefixSidTlvsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvsBuilder)

Example 4 with BgpPrefixSidTlv

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.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) {
    Preconditions.checkArgument(tlv instanceof LuOriginatorSrgbTlv, "Incoming TLV is not LuOriginatorSrgbTlv");
    final LuOriginatorSrgbTlv luTlv = (LuOriginatorSrgbTlv) tlv;
    valueBuf.writeZero(ORIGINATOR_FLAGS_BYTES);
    for (final SrgbValue val : luTlv.getSrgbValue()) {
        valueBuf.writeMedium(val.getBase().getValue().intValue());
        valueBuf.writeMedium(val.getRange().getValue().intValue());
    }
}
Also used : LuOriginatorSrgbTlv(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlv) SrgbValue(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.originator.srgb.tlv.SrgbValue)

Aggregations

BgpPrefixSidTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.BgpPrefixSidTlv)2 ByteBuf (io.netty.buffer.ByteBuf)1 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 BgpPrefixSidTlvRegistry (org.opendaylight.protocol.bgp.parser.spi.BgpPrefixSidTlvRegistry)1 BitArray (org.opendaylight.protocol.util.BitArray)1 Ipv6SidTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.inet.rev171207.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.Ipv6SidTlv)1 SrgbValue (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.originator.srgb.tlv.SrgbValue)1 LuOriginatorSrgbTlv (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.labeled.unicast.rev171207.update.attributes.bgp.prefix.sid.bgp.prefix.sid.tlvs.bgp.prefix.sid.tlv.LuOriginatorSrgbTlv)1 BgpPrefixSidBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.BgpPrefixSidBuilder)1 BgpPrefixSidTlvs (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvs)1 BgpPrefixSidTlvsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.bgp.prefix.sid.BgpPrefixSidTlvsBuilder)1