Bump upstreams to 2022.09
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / AttributeRegistry.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 org.eclipse.jdt.annotation.NonNullByDefault;
12 import org.eclipse.jdt.annotation.Nullable;
13 import org.opendaylight.protocol.bgp.parser.BGPDocumentedException;
14 import org.opendaylight.protocol.bgp.parser.BGPError;
15 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.Attributes;
17
18 /**
19  * Attribute serializer/deserializer registry, exposing the capability to parse BGP attributes as a whole.
20  */
21 @NonNullByDefault
22 public interface AttributeRegistry {
23     /**
24      * Parse BGP Attribute from buffer.
25      *
26      * @param buffer Input buffer.
27      * @param constraints Peer specific constraint.
28      * @return Decoded BGP Attribute.
29      * @throws BGPDocumentedException when an unrecoverable error occurs, which is documented via {@link BGPError}
30      * @throws BGPParsingException when a general unrecoverable parsing error occurs
31      */
32     ParsedAttributes parseAttributes(ByteBuf buffer, @Nullable PeerSpecificParserConstraint constraints)
33             throws BGPDocumentedException, BGPParsingException;
34
35     /**
36      * Serialize BGP Attribute to buffer.
37      *
38      * @param attribute Input BGP Attribute.
39      * @param byteAggregator Output buffer.
40      */
41     void serializeAttribute(Attributes attribute, ByteBuf byteAggregator);
42 }