BUG-5868: Register Evpn Nlri handlers
[bgpcep.git] / bgp / parser-spi / src / main / java / org / opendaylight / protocol / bgp / parser / spi / NextHopParserSerializer.java
1 /*
2  * Copyright (c) 2015 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
9 package org.opendaylight.protocol.bgp.parser.spi;
10
11 import io.netty.buffer.ByteBuf;
12 import javax.annotation.Nonnull;
13 import org.opendaylight.bgp.concepts.NextHopUtil;
14 import org.opendaylight.protocol.bgp.parser.BGPParsingException;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev130919.next.hop.CNextHop;
16
17 /**
18  * Handles Next Hop, by default use {@link NextHopUtil}
19  * which is handles Ipv4 and Ipv6 Next hop.
20  */
21 public interface NextHopParserSerializer {
22     /**
23      * Parse Next hop from buffer,
24      *
25      * @param buffer Encoded Next Hop in ByteBuf.
26      * @return CNextHop
27      * @throws BGPParsingException
28      */
29     default CNextHop parseNextHop(@Nonnull ByteBuf buffer) throws BGPParsingException {
30         return NextHopUtil.parseNextHop(buffer);
31     }
32
33     /**
34      * Serialize Next Hop
35      *
36      * @param cNextHop Next Hop container
37      * @param byteAggregator return Encoded Next Hop in ByteBuf
38      */
39     default void serializeNextHop(@Nonnull CNextHop cNextHop, @Nonnull final ByteBuf byteAggregator) {
40         NextHopUtil.serializeNextHop(cNextHop, byteAggregator);
41     }
42 }