use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project bgpcep by opendaylight.
the class AbstractAddPathTest method createParameter.
protected static BgpParameters createParameter(final boolean addPath) {
final OptionalCapabilities mp = new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setMultiprotocolCapability(new MultiprotocolCapabilityBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).build()).build()).build()).build();
final List<OptionalCapabilities> capabilities = Lists.newArrayList(mp);
if (addPath) {
final OptionalCapabilities addPathCapa = new OptionalCapabilitiesBuilder().setCParameters(new CParametersBuilder().addAugmentation(CParameters1.class, new CParameters1Builder().setAddPathCapability(new AddPathCapabilityBuilder().setAddressFamilies(Lists.newArrayList(new AddressFamiliesBuilder().setAfi(Ipv4AddressFamily.class).setSafi(UnicastSubsequentAddressFamily.class).setSendReceive(SendReceive.Both).build())).build()).build()).build()).build();
capabilities.add(addPathCapa);
}
return new BgpParametersBuilder().setOptionalCapabilities(capabilities).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project bgpcep by opendaylight.
the class CapabilityParameterParser method parseParameter.
@Override
public BgpParameters parseParameter(final ByteBuf buffer) throws BGPParsingException, BGPDocumentedException {
Preconditions.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 = Lists.newArrayList();
while (buffer.isReadable()) {
final OptionalCapabilities optionalCapa = parseOptionalCapability(buffer);
if (optionalCapa != null) {
optionalCapas.add(optionalCapa);
}
}
return new BgpParametersBuilder().setOptionalCapabilities(optionalCapas).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project bgpcep by opendaylight.
the class ParserTest method testOpenMessage.
/*
* ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff <- marker
* 00 3d <- length (61) - including header
* 01 <- message type
* 04 <- BGP version
* 00 64 <- My AS Number (AS TRANS in this case)
* 00 b4 <- Hold Time
* 00 00 00 00 <- BGP Identifier
* 20 <- Optional Parameters Length
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 01 <- capability code (MP Extensions for BGP4)
* 04 <- length
* 00 01 00 01 <- AFI 1, SAFI 1
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 01 <- capability code (MP Extensions for BGP4)
* 04 <- length
* 00 02 00 01 <- AFI 2, SAFI 1
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 01 <- capability code (MP Extensions for BGP4)
* 04 <- length
* 40 04 00 47 <- AFI 16388, SAFI 71
* 02 <- opt. param. type (capabilities)
* 06 <- length
* 41 <- capability code (AS4 octet support)
* 04 <- length
* 00 00 00 64 <- AS number
*/
@Test
public void testOpenMessage() throws Exception {
final MessageRegistry msgReg = ServiceLoaderBGPExtensionProviderContext.getSingletonInstance().getMessageRegistry();
final Notification o = msgReg.parseMessage(Unpooled.copiedBuffer(inputBytes.get(3)), null);
final Open open = (Open) o;
final Set<BgpTableType> types = Sets.newHashSet();
for (final BgpParameters param : open.getBgpParameters()) {
for (final OptionalCapabilities optCapa : param.getOptionalCapabilities()) {
final CParameters cParam = optCapa.getCParameters();
if (cParam != null && cParam.getAugmentation(CParameters1.class) != null && cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability() != null) {
final MultiprotocolCapability mp = cParam.getAugmentation(CParameters1.class).getMultiprotocolCapability();
final BgpTableType type = new BgpTableTypeImpl(mp.getAfi(), mp.getSafi());
types.add(type);
}
}
}
final Set<BgpTableType> expected = Sets.newHashSet();
expected.add(new BgpTableTypeImpl(Ipv4AddressFamily.class, UnicastSubsequentAddressFamily.class));
expected.add(new BgpTableTypeImpl(Ipv6AddressFamily.class, UnicastSubsequentAddressFamily.class));
expected.add(new BgpTableTypeImpl(LinkstateAddressFamily.class, LinkstateSubsequentAddressFamily.class));
assertEquals(expected, types);
final ByteBuf buffer = Unpooled.buffer();
msgReg.serializeMessage(o, buffer);
assertArrayEquals(inputBytes.get(3), ByteArray.readAllBytes(buffer));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project bgpcep by opendaylight.
the class PcepStateUtils method showCapabilities.
private static void showCapabilities(final ShellTable table, final PeerCapabilities capa) {
if (capa == null) {
return;
}
final StatefulCapabilitiesStatsAug stateFulCapa = capa.getAugmentation(StatefulCapabilitiesStatsAug.class);
if (stateFulCapa != null) {
addHeader(table, "Stateful Capabilities");
table.addRow().addContent("Stateful", stateFulCapa.isStateful());
table.addRow().addContent("Active", stateFulCapa.isActive());
table.addRow().addContent("Instantiation", stateFulCapa.isInstantiation());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.Capabilities in project netvirt by opendaylight.
the class NeutronPortChangeListener method isPortTypeSwitchdev.
private boolean isPortTypeSwitchdev(final Port port) {
if (!isPortVnicTypeDirect(port)) {
return false;
}
PortBindingExtension portBinding = port.getAugmentation(PortBindingExtension.class);
String profile = portBinding.getProfile();
if (profile == null || profile.isEmpty()) {
LOG.debug("Port {} has no binding:profile values", port.getUuid());
return false;
}
Map<String, JsonElement> mapProfile = unmarshal(profile);
JsonElement capabilities = mapProfile.get(NeutronConstants.BINDING_PROFILE_CAPABILITIES);
LOG.debug("Port {} capabilities: {}", port.getUuid(), capabilities);
if (capabilities == null || !capabilities.isJsonArray()) {
LOG.debug("binding profile capabilities not in array format: {}", capabilities);
return false;
}
JsonArray capabilitiesArray = capabilities.getAsJsonArray();
Gson gson = new Gson();
JsonElement switchdevElement = gson.fromJson(NeutronConstants.SWITCHDEV, JsonElement.class);
return capabilitiesArray.contains(switchdevElement);
}
Aggregations