use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters in project bgpcep by opendaylight.
the class CapabilityParameterParser method parseOptionalCapability.
private OptionalCapabilities parseOptionalCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final int capCode = buffer.readUnsignedByte();
final int capLength = buffer.readUnsignedByte();
final ByteBuf paramBody = buffer.readSlice(capLength);
final CParameters ret = this.reg.parseCapability(capCode, paramBody);
if (ret == null) {
LOG.info("Ignoring unsupported capability {}", capCode);
return null;
}
return new OptionalCapabilitiesBuilder().setCParameters(ret).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters in project bgpcep by opendaylight.
the class CapabilityParameterParser method serializeOptionalCapability.
private void serializeOptionalCapability(final OptionalCapabilities optionalCapa, final ByteBuf byteAggregator) {
if (optionalCapa.getCParameters() != null) {
final CParameters cap = optionalCapa.getCParameters();
final ByteBuf bytes = Unpooled.buffer();
this.reg.serializeCapability(cap, bytes);
checkArgument(bytes != null, "Unhandled capability class %s", cap.implementedInterface());
if (LOG.isTraceEnabled()) {
LOG.trace("BGP capability serialized to: {}", ByteBufUtil.hexDump(bytes));
}
byteAggregator.writeBytes(bytes);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters in project bgpcep by opendaylight.
the class LlGracefulCapabilityHandler method parseCapability.
@Override
public CParameters parseCapability(final ByteBuf buffer) {
final BindingMap.Builder<TablesKey, Tables> tables = BindingMap.builder();
while (buffer.isReadable()) {
final short afival = buffer.readShort();
final Class<? extends AddressFamily> afi = this.afiReg.classForFamily(afival);
if (afi == null) {
LOG.debug("Ignoring GR capability for unknown address family {}", afival);
buffer.skipBytes(PER_TABLE_SIZE - 2);
continue;
}
final byte safival = buffer.readByte();
final Class<? extends SubsequentAddressFamily> safi = this.safiReg.classForFamily(safival);
if (safi == null) {
LOG.debug("Ignoring GR capability for unknown subsequent address family {}", safival);
buffer.skipBytes(PER_TABLE_SIZE - 3);
continue;
}
final byte afiFlags = buffer.readByte();
final int staleTime = buffer.readUnsignedMedium();
final Tables table = new TablesBuilder().setAfi(afi).setSafi(safi).setAfiFlags(new Tables.AfiFlags(afiFlags == AFI_FLAG_FORWARDING_STATE)).setLongLivedStaleTime(new Uint24(Uint32.valueOf(staleTime))).build();
tables.add(table);
}
return new CParametersBuilder().addAugmentation(new CParameters1Builder().setLlGracefulRestartCapability(new LlGracefulRestartCapabilityBuilder().setTables(tables.build()).build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters in project bgpcep by opendaylight.
the class GracefulCapabilityHandler method parseCapability.
@Override
public CParameters parseCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final GracefulRestartCapabilityBuilder cb = new GracefulRestartCapabilityBuilder();
final int flagBits = buffer.getByte(0) >> RESTART_FLAGS_SIZE;
cb.setRestartFlags(new RestartFlags((flagBits & Byte.SIZE) != 0));
final int timer = ((buffer.readUnsignedByte() & TIMER_TOPBITS_MASK) << Byte.SIZE) + buffer.readUnsignedByte();
cb.setRestartTime(Uint16.valueOf(timer));
final BindingMap.Builder<TablesKey, Tables> tables = BindingMap.builder();
while (buffer.readableBytes() != 0) {
final int afiVal = buffer.readShort();
final Class<? extends AddressFamily> afi = this.afiReg.classForFamily(afiVal);
if (afi == null) {
LOG.debug("Ignoring GR capability for unknown address family {}", afiVal);
buffer.skipBytes(PER_AFI_SAFI_SIZE - 2);
continue;
}
final int safiVal = buffer.readUnsignedByte();
final Class<? extends SubsequentAddressFamily> safi = this.safiReg.classForFamily(safiVal);
if (safi == null) {
LOG.debug("Ignoring GR capability for unknown subsequent address family {}", safiVal);
buffer.skipBytes(1);
continue;
}
final int flags = buffer.readUnsignedByte();
tables.add(new TablesBuilder().setAfi(afi).setSafi(safi).setAfiFlags(new AfiFlags((flags & AFI_FLAG_FORWARDING_STATE) != 0)).build());
}
cb.setTables(tables.build());
return new CParametersBuilder().addAugmentation(new CParameters1Builder().setGracefulRestartCapability(cb.build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.optional.capabilities.CParameters in project bgpcep by opendaylight.
the class GracefulCapabilityHandler method serializeCapability.
@Override
public void serializeCapability(final CParameters capability, final ByteBuf byteAggregator) {
final CParameters1 aug = capability.augmentation(CParameters1.class);
if (aug == null) {
return;
}
final GracefulRestartCapability grace = aug.getGracefulRestartCapability();
if (grace != null) {
final ByteBuf bytes = serializeCapability(grace);
CapabilityUtil.formatCapability(CODE, bytes, byteAggregator);
}
}
Aggregations