use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.
the class AbstractTeLspNlriCodec method serializeObjectType.
@Override
protected final void serializeObjectType(final ObjectType objectType, final ByteBuf buffer) {
Preconditions.checkArgument(objectType instanceof TeLspCase);
final TeLspCase teLSP = (TeLspCase) objectType;
final AddressFamily addressFamily = teLSP.getAddressFamily();
if (addressFamily instanceof Ipv4Case) {
serializeIpv4Case(teLSP, (Ipv4Case) addressFamily, buffer);
} else {
serializeIpv6Case(teLSP, (Ipv6Case) addressFamily, buffer);
}
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.
the class SimpleRIBExtensionProviderContext method registerRIBSupport.
@Override
public <T extends RIBSupport> RIBSupportRegistration<T> registerRIBSupport(final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi, final T support) {
final TablesKey key = new TablesKey(afi, safi);
final RIBSupport prev = this.supports.putIfAbsent(key, support);
Preconditions.checkArgument(prev == null, "AFI %s SAFI %s is already registered with %s", afi, safi, prev);
this.domSupports.put(RibSupportUtils.toYangTablesKey(afi, safi), support);
addClassLoadingSupport(afi, safi, support);
return new AbstractRIBSupportRegistration<T>(support) {
@Override
protected void removeRegistration() {
SimpleRIBExtensionProviderContext.this.supports.remove(key);
}
};
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.
the class Stateful07LSPIdentifierIpv4TlvParser method parseTlv.
@Override
public LspIdentifiers parseTlv(final ByteBuf buffer) throws PCEPDeserializerException {
if (buffer == null) {
return null;
}
Preconditions.checkArgument(buffer.readableBytes() == V4_LENGTH, "Length %s does not match LSP Identifiers Ipv4 tlv length.", buffer.readableBytes());
final Ipv4Builder builder = new Ipv4Builder();
builder.setIpv4TunnelSenderAddress(Ipv4Util.addressForByteBuf(buffer));
final LspId lspId = new LspId((long) buffer.readUnsignedShort());
final TunnelId tunnelId = new TunnelId(buffer.readUnsignedShort());
builder.setIpv4ExtendedTunnelId(new Ipv4ExtendedTunnelId(Ipv4Util.addressForByteBuf(buffer)));
builder.setIpv4TunnelEndpointAddress(Ipv4Util.addressForByteBuf(buffer));
final AddressFamily afi = new Ipv4CaseBuilder().setIpv4(builder.build()).build();
return new LspIdentifiersBuilder().setAddressFamily(afi).setLspId(lspId).setTunnelId(tunnelId).build();
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.
the class AddPathCapabilityHandler method parseCapability.
@Override
public CParameters parseCapability(final ByteBuf buffer) throws BGPDocumentedException, BGPParsingException {
final List<AddressFamilies> families = new ArrayList<>();
while (buffer.isReadable()) {
final int afiVal = buffer.readUnsignedShort();
final Class<? extends AddressFamily> afi = this.afiReg.classForFamily(afiVal);
if (afi == null) {
throw new BGPParsingException("Address Family Identifier: '" + afiVal + "' not supported.");
}
final int safiVal = buffer.readUnsignedByte();
final Class<? extends SubsequentAddressFamily> safi = this.safiReg.classForFamily(safiVal);
if (safi == null) {
throw new BGPParsingException("Subsequent Address Family Identifier: '" + safiVal + "' not supported.");
}
final SendReceive sendReceive = SendReceive.forValue(buffer.readUnsignedByte());
if (sendReceive != null) {
families.add(new AddressFamiliesBuilder().setAfi(afi).setSafi(safi).setSendReceive(sendReceive).build());
}
}
return new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(families).build()).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.ericsson.params.xml.ns.yang.ebgp.rev150901.AddressFamily in project bgpcep by opendaylight.
the class AddPathCapabilityHandler method serializeCapability.
@Override
public void serializeCapability(final CParameters capability, final ByteBuf byteAggregator) {
if ((capability.getAugmentation(CParameters1.class) == null) || (capability.getAugmentation(CParameters1.class).getAddPathCapability() == null)) {
return;
}
final AddPathCapability addPathCap = capability.getAugmentation(CParameters1.class).getAddPathCapability();
final List<AddressFamilies> families = addPathCap.getAddressFamilies();
if (families != null) {
final ByteBuf capBuffer = Unpooled.buffer(families.size() * TRIPLET_BYTE_SIZE);
for (final AddressFamilies addressFamily : families) {
final Class<? extends AddressFamily> afi = addressFamily.getAfi();
final Integer afival = this.afiReg.numberForClass(afi);
Preconditions.checkArgument(afival != null, "Unhandled address family " + afi);
capBuffer.writeShort(afival);
final Class<? extends SubsequentAddressFamily> safi = addressFamily.getSafi();
final Integer safival = this.safiReg.numberForClass(safi);
Preconditions.checkArgument(safival != null, "Unhandled subsequent address family " + safi);
capBuffer.writeByte(safival);
final SendReceive sendReceive = addressFamily.getSendReceive();
Preconditions.checkArgument(sendReceive != null, "Unhandled Send/Receive value");
capBuffer.writeByte(sendReceive.getIntValue());
}
CapabilityUtil.formatCapability(CODE, capBuffer, byteAggregator);
}
}
Aggregations