Bump MRI upstreams
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / NlriRegistry.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.bgp.parser.spi;
9
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;
17
18 /**
19  * The codec registry for BGP NLRI, offers services for NLRI encoding/decoding.
20  */
21 @NonNullByDefault
22 public interface NlriRegistry {
23     /**
24      * Decode MP REACH NLRI Attribute.
25      *
26      * @param buffer Input buffer.
27      * @param constraint Peer specific constraint.
28      * @return Parsed reach NLRI.
29      */
30     MpReachNlri parseMpReach(ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint)
31             throws BGPParsingException;
32
33     /**
34      * Decode MP REACH NLRI Attribute.
35      *
36      * @param buffer Input buffer.
37      * @param constraint Peer specific constraint.
38      * @return Parsed unreach NLRI.
39      */
40     MpUnreachNlri parseMpUnreach(ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraint)
41             throws BGPParsingException;
42
43     /**
44      * Encode BGP MP REACH NLRI Attribute.
45      *
46      * @param mpReachNlri Input reach NLRI.
47      * @param byteAggregator Output buffer.
48      */
49     void serializeMpReach(MpReachNlri mpReachNlri, ByteBuf byteAggregator);
50
51     /**
52      * Encode BGP MP UNREACH NLRI Attribute.
53      *
54      * @param mpUnreachNlri Input unreach NLRI.
55      * @param byteAggregator Output buffer.
56      */
57     void serializeMpUnReach(MpUnreachNlri mpUnreachNlri, ByteBuf byteAggregator);
58
59     /**
60      * Get all available NLRI encoders.
61      *
62      * @return Iterable of NLRI serializers.
63      */
64     Iterable<NlriSerializer> getSerializers();
65
66     /**
67      * Convert MP_REACH attribute to MP_UNREACH attribute and merge it with original one if it exists.
68      *
69      * <p>
70      * The default implementation rejects the conversion.
71      *
72      * @param mpReachNlri MP_REACH attribute to be converted
73      * @param mpUnreachNlri original MP_UNREACH attribute
74      * @return resulting MP_UNREACH attribute after conversion
75      */
76     Optional<MpUnreachNlri> convertMpReachToMpUnReach(MpReachNlri mpReachNlri, @Nullable MpUnreachNlri mpUnreachNlri);
77 }