use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder in project bgpcep by opendaylight.
the class AbstractBGPDispatcherTest method createPreferences.
protected BGPSessionPreferences createPreferences(final InetSocketAddress socketAddress) {
final List<BgpParameters> tlvs = Lists.newArrayList();
final List<OptionalCapabilities> capas = Lists.newArrayList();
capas.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(IPV_4_TT.getAfi()).setSafi(IPV_4_TT.getSafi()).build()).build()).setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(30L)).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(new Ipv4Address(socketAddress.getAddress().getHostAddress()));
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.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder in project bgpcep by opendaylight.
the class BgpPeer method getBgpParameters.
private static List<BgpParameters> getBgpParameters(final AfiSafis afiSafis, final RIB rib, final BGPTableTypeRegistryConsumer tableTypeRegistry) {
final List<BgpParameters> tlvs = new ArrayList<>();
final List<OptionalCapabilities> caps = new ArrayList<>();
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(rib.getLocalAs()).build()).build()).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(BgpExtendedMessageUtil.EXTENDED_MESSAGE_CAPABILITY).build());
caps.add(new OptionalCapabilitiesBuilder().setCParameters(MultiprotocolCapabilitiesUtil.RR_CAPABILITY).build());
final List<AfiSafi> afiSafi = OpenConfigMappingUtil.getAfiSafiWithDefault(afiSafis, false);
final List<AddressFamilies> addPathCapability = OpenConfigMappingUtil.toAddPathCapability(afiSafi, tableTypeRegistry);
if (!addPathCapability.isEmpty()) {
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(addPathCapability).build()).build()).build()).build());
}
final List<BgpTableType> tableTypes = OpenConfigMappingUtil.toTableTypes(afiSafi, tableTypeRegistry);
for (final BgpTableType tableType : tableTypes) {
if (!rib.getLocalTables().contains(tableType)) {
LOG.info("RIB instance does not list {} " + "in its local tables. Incoming data will be dropped.", tableType);
}
caps.add(new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder(tableType).build()).build()).build()).build());
}
tlvs.add(new BgpParametersBuilder().setOptionalCapabilities(caps).build());
return tlvs;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder 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(70L)).build()).build());
final CParametersBuilder paramsBuilder = new CParametersBuilder();
if (multiprotocol) {
final CParameters1Builder params1Builder = new CParameters1Builder();
params1Builder.setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build());
paramsBuilder.addAugmentation(CParameters1.class, params1Builder.build());
}
final OptionalCapabilitiesBuilder optCapabilitiesBuilder2 = new OptionalCapabilitiesBuilder().setCParameters(paramsBuilder.setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(80L)).build()).build());
final List<OptionalCapabilities> optCapabilities = Lists.newArrayList();
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.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder in project bgpcep by opendaylight.
the class ComplementaryTest method testBGPParameter.
@Test
public void testBGPParameter() {
final MultiprotocolCapability cap = new MultiprotocolCapabilityBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final CParameters tlv1 = new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(cap).build()).build();
final MultiprotocolCapability cap1 = new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build();
final CParameters tlv2 = new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(cap1).build()).build();
final List<Tables> tt = new ArrayList<>();
tt.add(new TablesBuilder().setAfi(Ipv6AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build());
tt.add(new TablesBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build());
final GracefulRestartCapability tlv3 = new GracefulRestartCapabilityBuilder().setRestartFlags(new RestartFlags(Boolean.FALSE)).setRestartTime(0).setTables(tt).build();
final CParameters tlv4 = new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber((long) 40)).build()).build();
assertFalse(tlv3.getRestartFlags().isRestartState());
assertEquals(0, tlv3.getRestartTime().intValue());
assertFalse(tlv1.equals(tlv2));
assertNotSame(tlv1.hashCode(), tlv3.hashCode());
assertNotSame(tlv2.toString(), tlv3.toString());
assertEquals(tlv3.getTables(), tt);
assertEquals(cap.getSafi(), cap1.getSafi());
assertNotSame(cap.getAfi(), cap1.getAfi());
assertEquals(40, tlv4.getAs4BytesCapability().getAsNumber().getValue().longValue());
assertEquals(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber((long) 40)).build()).build(), tlv4);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.open.message.bgp.parameters.optional.capabilities.c.parameters.As4BytesCapabilityBuilder in project bgpcep by opendaylight.
the class OpenTest method testSerializeOpen.
@Test
public void testSerializeOpen() throws Exception {
final List<OptionalCapabilities> optionalCapas = Lists.newArrayList();
final OptionalCapabilities optionalCapabilitiesBuilder = new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().setAs4BytesCapability(new As4BytesCapabilityBuilder().setAsNumber(new AsNumber(1000L)).build()).addAugmentation(CParameters1.class, new CParameters1Builder().setGracefulRestartCapability(new GracefulRestartCapabilityBuilder().setRestartFlags(new GracefulRestartCapability.RestartFlags(false)).setRestartTime(0).setTables(Collections.emptyList()).build()).build()).build()).build();
optionalCapas.add(optionalCapabilitiesBuilder);
final List<BgpParameters> tlvs = Lists.newArrayList(new BgpParametersBuilder().setOptionalCapabilities(optionalCapas).build());
final Open open = new OpenBuilder().setBgpIdentifier(new Ipv4Address("127.0.0.1")).setMyAsNumber(30).setHoldTimer(3).setVersion(new ProtocolVersion((short) 4)).setBgpParameters(tlvs).build();
final ByteBuf msg = Unpooled.buffer();
new BGPOpenMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getParameterRegistry()).serializeMessage(open, msg);
final byte[] temp = ByteArray.cutBytes(ByteArray.getAllBytes(msg), 19);
final Open openResult = new BGPOpenMessageParser(ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getParameterRegistry()).parseMessageBody(Unpooled.copiedBuffer(temp), temp.length);
assertEquals(open.getBgpIdentifier(), openResult.getBgpIdentifier());
assertEquals(open.getHoldTimer(), openResult.getHoldTimer());
assertEquals(open.getMyAsNumber(), openResult.getMyAsNumber());
boolean grace = false;
if (openResult.getBgpParameters().get(0).getOptionalCapabilities().get(0).getCParameters().getAs4BytesCapability() != null) {
grace = true;
}
assertEquals(open.getBgpParameters().get(0).getOptionalCapabilities().get(0).getCParameters().getAs4BytesCapability(), openResult.getBgpParameters().get(0).getOptionalCapabilities().get(!grace ? 1 : 0).getCParameters().getAs4BytesCapability());
assertEquals(open.getBgpParameters().get(0).getOptionalCapabilities().get(0).getCParameters().getAugmentation(CParameters1.class).getGracefulRestartCapability(), openResult.getBgpParameters().get(0).getOptionalCapabilities().get(grace ? 1 : 0).getCParameters().getAugmentation(CParameters1.class).getGracefulRestartCapability());
}
Aggregations