2 * Copyright (c) 2018 AT&T Intellectual Property. 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
9 package org.opendaylight.protocol.bgp.mvpn.impl.nlri;
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import io.netty.buffer.Unpooled;
14 import org.opendaylight.bgp.concepts.RouteDistinguisherUtil;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.NlriType;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.inter.as.i.pmsi.a.d.grouping.InterAsIPmsiAD;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.inter.as.i.pmsi.a.d.grouping.InterAsIPmsiADBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.MvpnChoice;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCase;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.InterAsIPmsiADCaseBuilder;
24 * https://tools.ietf.org/html/rfc6514#section-4.2 .
26 * @author Claudio D. Gasparini
28 public final class InterASIPmsiADHandler extends AbstractMvpnNlri<InterAsIPmsiADCase> {
29 private static final int CONTENT_LENGTH = 12;
32 public int getType() {
33 return NlriType.InterAsIPmsiAD.getIntValue();
37 public InterAsIPmsiADCase parseMvpn(final ByteBuf buffer) {
38 Preconditions.checkArgument(buffer.readableBytes() == CONTENT_LENGTH,
39 "Wrong length of array of bytes. Passed: %s ;", buffer);
40 return new InterAsIPmsiADCaseBuilder()
41 .setInterAsIPmsiAD(new InterAsIPmsiADBuilder()
42 .setRouteDistinguisher(RouteDistinguisherUtil.parseRouteDistinguisher(buffer))
43 .setSourceAs(new AsNumber(buffer.readUnsignedInt()))
49 protected ByteBuf serializeBody(final InterAsIPmsiADCase mvpn) {
50 final InterAsIPmsiAD route = mvpn.getInterAsIPmsiAD();
51 final ByteBuf nlriByteBuf = Unpooled.buffer();
52 RouteDistinguisherUtil.serializeRouteDistinquisher(route.getRouteDistinguisher(), nlriByteBuf);
53 nlriByteBuf.writeInt(route.getSourceAs().getValue().intValue());
58 public Class<? extends MvpnChoice> getClazz() {
59 return InterAsIPmsiADCase.class;