use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities in project bgpcep by opendaylight.
the class AbstractBGPDispatcherTest method createPreferences.
protected BGPSessionPreferences createPreferences(final InetSocketAddress socketAddress) {
final List<BgpParameters> tlvs = new ArrayList<>();
final List<OptionalCapabilities> capas = new ArrayList<>();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(IPV_4_TT.getAfi()).setSafi(IPV_4_TT.getSafi()).build()).build()).setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(30))).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final BgpId bgpId = new BgpId(IetfInetUtil.INSTANCE.ipv4AddressFor(socketAddress.getAddress()));
return new BGPSessionPreferences(AS_NUMBER, HOLD_TIMER, bgpId, AS_NUMBER, tlvs);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities in project bgpcep by opendaylight.
the class TestUtil method createOptionalCapabilities.
private static List<OptionalCapabilities> createOptionalCapabilities(final boolean multiprotocol) {
final OptionalCapabilitiesBuilder optCapabilitiesBuilder = new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(70))).build()).build());
final CParametersBuilder paramsBuilder = new CParametersBuilder();
if (multiprotocol) {
paramsBuilder.addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()).build());
}
final OptionalCapabilitiesBuilder optCapabilitiesBuilder2 = new OptionalCapabilitiesBuilder().setCParameters(paramsBuilder.setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(Uint32.valueOf(80))).build()).build());
final List<OptionalCapabilities> optCapabilities = new ArrayList<>();
optCapabilities.add(optCapabilitiesBuilder.build());
optCapabilities.add(optCapabilitiesBuilder2.build());
return optCapabilities;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities in project bgpcep by opendaylight.
the class APITest method testBgpExtendedMessageUtil.
@Test
public void testBgpExtendedMessageUtil() {
final List<BgpParameters> params = new ArrayList<>();
final List<OptionalCapabilities> capas = new ArrayList<>();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().build()).build()).build()).build());
capas.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
params.add(new BgpParametersBuilder().setOptionalCapabilities(capas).build());
final Open open1 = new OpenBuilder().setBgpParameters(params).build();
assertTrue(BgpExtendedMessageUtil.advertizedBgpExtendedMessageCapability(open1));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.open.message.bgp.parameters.OptionalCapabilities 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.OptionalCapabilities in project bgpcep by opendaylight.
the class CapabilityParameterParser method parseParameter.
@Override
public BgpParameters parseParameter(final ByteBuf buffer) throws BGPParsingException, BGPDocumentedException {
checkArgument(buffer != null && buffer.readableBytes() != 0, "Byte array cannot be null or empty.");
if (LOG.isTraceEnabled()) {
LOG.trace("Started parsing of BGP Capabilities: {}", Arrays.toString(ByteArray.getAllBytes(buffer)));
}
final List<OptionalCapabilities> optionalCapas = new ArrayList<>();
while (buffer.isReadable()) {
final OptionalCapabilities optionalCapa = parseOptionalCapability(buffer);
if (optionalCapa != null) {
optionalCapas.add(optionalCapa);
}
}
return new BgpParametersBuilder().setOptionalCapabilities(optionalCapas).build();
}
Aggregations