2 * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
8 package org.opendaylight.protocol.bgp.parser.spi;
10 import io.netty.buffer.ByteBuf;
11 import java.util.Optional;
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.reach.MpReachNlri;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.multiprotocol.rev180329.attributes.unreach.MpUnreachNlri;
19 * The codec registry for BGP NLRI, offers services for NLRI encoding/decoding.
22 public interface NlriRegistry {
24 * Decode MP REACH NLRI Attribute.
26 * @param buffer Input buffer.
27 * @param constraint Peer specific constraint.
28 * @return Parsed reach NLRI.
30 MpReachNlri parseMpReach(ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint)
31 throws BGPParsingException;
34 * Decode MP REACH NLRI Attribute.
36 * @param buffer Input buffer.
37 * @param constraint Peer specific constraint.
38 * @return Parsed unreach NLRI.
40 MpUnreachNlri parseMpUnreach(ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint)
41 throws BGPParsingException;
44 * Encode BGP MP REACH NLRI Attribute.
46 * @param mpReachNlri Input reach NLRI.
47 * @param byteAggregator Output buffer.
49 void serializeMpReach(MpReachNlri mpReachNlri, ByteBuf byteAggregator);
52 * Encode BGP MP UNREACH NLRI Attribute.
54 * @param mpUnreachNlri Input unreach NLRI.
55 * @param byteAggregator Output buffer.
57 void serializeMpUnReach(MpUnreachNlri mpUnreachNlri, ByteBuf byteAggregator);
60 * Get all available NLRI encoders.
62 * @return Iterable of NLRI serializers.
64 Iterable<NlriSerializer> getSerializers();
67 * Convert MP_REACH attribute to MP_UNREACH attribute and merge it with original one if it exists.
70 * The default implementation rejects the conversion.
72 * @param mpReachNlri MP_REACH attribute to be converted
73 * @param mpUnreachNlri original MP_UNREACH attribute
74 * @return resulting MP_UNREACH attribute after conversion
76 Optional<MpUnreachNlri> convertMpReachToMpUnReach(MpReachNlri mpReachNlri, @Nullable MpUnreachNlri mpUnreachNlri);