use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class EvpnNlriParser method parseNlri.
@Nullable
private static List<EvpnDestination> parseNlri(final ByteBuf nlri, final PeerSpecificParserConstraint constraints, final Class<? extends AddressFamily> afi, final Class<? extends SubsequentAddressFamily> safi) {
if (!nlri.isReadable()) {
return null;
}
final List<EvpnDestination> dests = new ArrayList<>();
while (nlri.isReadable()) {
final EvpnDestinationBuilder builder = new EvpnDestinationBuilder();
if (MultiPathSupportUtil.isTableTypeSupported(constraints, new BgpTableTypeImpl(afi, safi))) {
builder.setPathId(PathIdUtil.readPathId(nlri));
}
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.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class SimpleNlriRegistry method parseMpReach.
@Override
public MpReachNlri parseMpReach(final ByteBuf buffer, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
final MpReachNlriBuilder builder = new MpReachNlriBuilder();
final Class<? extends AddressFamily> afi = getAfi(buffer);
final Class<? extends SubsequentAddressFamily> safi = getSafi(buffer);
builder.setAfi(afi);
builder.setSafi(safi);
final BgpTableType key = createKey(builder.getAfi(), builder.getSafi());
final int nextHopLength = buffer.readUnsignedByte();
if (nextHopLength != 0) {
final NextHopParserSerializer nextHopParser = this.nextHopParsers.get(key);
if (nextHopParser != null) {
builder.setCNextHop(nextHopParser.parseNextHop(buffer.readSlice(nextHopLength)));
} else {
builder.setCNextHop(NextHopUtil.parseNextHop(buffer.readSlice(nextHopLength)));
LOG.warn("NexHop Parser/Serializer for AFI/SAFI ({},{}) not bound", afi, safi);
}
}
buffer.skipBytes(RESERVED);
final ByteBuf nlri = buffer.slice();
final NlriParser parser = this.handlers.get(key);
if (parser == null) {
LOG.warn(PARSER_NOT_FOUND, key);
} else {
parser.parseNlri(nlri, builder, constraint);
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class SimpleNlriRegistry method parseMpUnreach.
@Override
public MpUnreachNlri parseMpUnreach(final ByteBuf buffer, final PeerSpecificParserConstraint constraint) throws BGPParsingException {
final MpUnreachNlriBuilder builder = new MpUnreachNlriBuilder();
builder.setAfi(getAfi(buffer));
builder.setSafi(getSafi(buffer));
if (buffer.isReadable()) {
final ByteBuf nlri = buffer.slice();
final BgpTableType key = createKey(builder.getAfi(), builder.getSafi());
final NlriParser parser = this.handlers.get(key);
if (parser == null) {
LOG.warn(PARSER_NOT_FOUND, key);
} else {
parser.parseNlri(nlri, builder, constraint);
}
}
return builder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class FSDestinationPortHandler method parseDestinationPort.
private static List<DestinationPorts> parseDestinationPort(final ByteBuf nlri) {
final List<DestinationPorts> ports = new ArrayList<>();
boolean end = false;
// we can do this as all fields will be rewritten in the cycle
final DestinationPortsBuilder builder = new DestinationPortsBuilder();
while (!end) {
final byte b = nlri.readByte();
final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
builder.setOp(op);
final short length = AbstractOperandParser.parseLength(b);
builder.setValue(Uint16.valueOf(ByteArray.bytesToInt(ByteArray.readBytes(nlri, length))));
end = op.getEndOfList();
ports.add(builder.build());
}
return ports;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.update.message.Nlri in project bgpcep by opendaylight.
the class FSIcmpCodeHandler method parseIcmpCode.
private static List<Codes> parseIcmpCode(final ByteBuf nlri) {
final List<Codes> codes = new ArrayList<>();
boolean end = false;
// we can do this as all fields will be rewritten in the cycle
final CodesBuilder builder = new CodesBuilder();
while (!end) {
final byte b = nlri.readByte();
final NumericOperand op = NumericOneByteOperandParser.INSTANCE.parse(b);
builder.setOp(op);
builder.setValue(ByteBufUtils.readUint8(nlri));
end = op.getEndOfList();
codes.add(builder.build());
}
return codes;
}
Aggregations