use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NlriType in project bgpcep by opendaylight.
the class SimpleEvpnNlriRegistryTest method registryTest.
@Test
public void registryTest() {
final ByteBuf buff = SimpleEvpnNlriRegistry.getInstance().serializeEvpn(ETHERNET_AD_ROUTE_CASE, Unpooled.wrappedBuffer(ROUDE_DISTIN));
assertArrayEquals(EthADRParserTest.RESULT, ByteArray.getAllBytes(buff));
final EvpnChoice resultModel = SimpleEvpnNlriRegistry.getInstance().serializeEvpnModel(createEthADRModel());
assertEquals(ETHERNET_AD_ROUTE_CASE, resultModel);
final NlriType type = NlriType.forValue(buff.readUnsignedByte());
// length + RD
buff.skipBytes(VALUE_SIZE);
assertEquals(ETHERNET_AD_ROUTE_CASE, SimpleEvpnNlriRegistry.getInstance().parseEvpn(type, buff));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NlriType in project bgpcep by opendaylight.
the class EvpnNlriParser method parseNlri.
@Nullable
private static List<EvpnDestination> parseNlri(final ByteBuf nlri) {
if (!nlri.isReadable()) {
return null;
}
final List<EvpnDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final EvpnDestinationBuilder builder = new EvpnDestinationBuilder();
final NlriType type = NlriType.forValue(nlri.readUnsignedByte());
final int length = nlri.readUnsignedByte();
final ByteBuf nlriBuf = nlri.readSlice(length);
builder.setRouteDistinguisher(parseRouteDistinguisher(nlriBuf));
builder.setEvpnChoice(SimpleEvpnNlriRegistry.getInstance().parseEvpn(type, nlriBuf));
dests.add(builder.build());
}
return dests;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NlriType in project bgpcep by opendaylight.
the class SimpleNlriTypeRegistry method serializeNlriType.
public void serializeNlriType(final CLinkstateDestination nlri, final ByteBuf byteAggregator) {
if (nlri == null) {
return;
}
requireNonNull(byteAggregator);
final ObjectType objectType = nlri.getObjectType();
final NlriTypeCaseSerializer serializer = this.nlriRegistry.getSerializer((Class<? extends ObjectType>) objectType.getImplementedInterface());
if (serializer == null) {
LOG.warn("Linkstate NLRI serializer for Type: {} was not found.", objectType.getImplementedInterface());
return;
}
final ByteBuf nlriType = Unpooled.buffer();
serializer.serializeTypeNlri(nlri, nlriType);
TlvUtil.writeTLV(serializer.getNlriType(), nlriType, byteAggregator);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.evpn.rev171213.NlriType in project bgpcep by opendaylight.
the class LinkstateAttributeParser method parseAttribute.
@Override
public void parseAttribute(final ByteBuf buffer, final AttributesBuilder builder) throws BGPParsingException {
final CLinkstateDestination lsDestination = getNlriType(builder);
if (lsDestination == null) {
LOG.warn("No Linkstate NLRI found, not parsing Linkstate attribute");
return;
}
final ObjectType nlriType = lsDestination.getObjectType();
final ProtocolId protocolId = lsDestination.getProtocolId();
final Attributes1 a = new Attributes1Builder().setLinkStateAttribute(parseLinkState(nlriType, protocolId, buffer)).build();
builder.addAugmentation(Attributes1.class, a);
}
Aggregations