use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.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.linkstate.rev200120.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.linkstate.rev200120.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.implementedInterface());
if (serializer == null) {
LOG.warn("Linkstate NLRI serializer for Type: {} was not found.", objectType.implementedInterface());
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.linkstate.rev200120.NlriType in project bgpcep by opendaylight.
the class Ipv4NlriHandler method parseIpv4UnreachNlri.
static DestinationMvpnIpv4WithdrawnCase parseIpv4UnreachNlri(final ByteBuf nlri, final boolean addPathSupported) {
final List<MvpnDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final MvpnDestinationBuilder builder = new MvpnDestinationBuilder();
if (addPathSupported) {
builder.setPathId(PathIdUtil.readPathId(nlri));
}
final NlriType type = NlriType.forValue(nlri.readUnsignedByte());
final int length = nlri.readUnsignedByte();
final ByteBuf nlriBuf = nlri.readSlice(length);
builder.setMvpnChoice(SimpleMvpnNlriRegistry.getInstance().parseMvpn(type, nlriBuf));
dests.add(builder.build());
}
return new DestinationMvpnIpv4WithdrawnCaseBuilder().setDestinationMvpn(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.ipv4.rev180417.update.attributes.mp.unreach.nlri.withdrawn.routes.destination.type.destination.mvpn.ipv4.withdrawn._case.DestinationMvpnBuilder().setMvpnDestination(dests).build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.linkstate.rev200120.NlriType in project bgpcep by opendaylight.
the class Ipv4NlriHandler method parseIpv4ReachNlri.
static DestinationMvpnIpv4AdvertizedCase parseIpv4ReachNlri(final ByteBuf nlri, final boolean addPathSupported) {
final List<MvpnDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final MvpnDestinationBuilder builder = new MvpnDestinationBuilder();
if (addPathSupported) {
builder.setPathId(PathIdUtil.readPathId(nlri));
}
final NlriType type = NlriType.forValue(nlri.readUnsignedByte());
final int length = nlri.readUnsignedByte();
final ByteBuf nlriBuf = nlri.readSlice(length);
builder.setMvpnChoice(SimpleMvpnNlriRegistry.getInstance().parseMvpn(type, nlriBuf));
dests.add(builder.build());
}
return new DestinationMvpnIpv4AdvertizedCaseBuilder().setDestinationMvpn(new DestinationMvpnBuilder().setMvpnDestination(dests).build()).build();
}
Aggregations