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 io.netty.buffer.ByteBuf;
12 import io.netty.buffer.Unpooled;
13 import org.opendaylight.bgp.concepts.IpAddressUtil;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.NlriType;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.MvpnChoice;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SPmsiADCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SPmsiADCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.s.pmsi.a.d.grouping.SPmsiAD;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.s.pmsi.a.d.grouping.SPmsiADBuilder;
22 * https://tools.ietf.org/html/rfc6514#section-4.3.
24 * @author Claudio D. Gasparini
26 public final class SPmsiADHandler extends AbstractMvpnNlri<SPmsiADCase> {
29 public int getType() {
30 return NlriType.SPmsiAD.getIntValue();
34 public SPmsiADCase parseMvpn(final ByteBuf buffer) {
35 final SPmsiADBuilder builder = new SPmsiADBuilder(parseRDMulticastSource(buffer));
36 builder.setMulticastGroup(MulticastGroupOpaqueUtil.multicastGroupForByteBuf(buffer));
37 builder.setOrigRouteIp(IpAddressUtil.addressForByteBufWOLength(buffer));
38 return new SPmsiADCaseBuilder().setSPmsiAD(builder.build()).build();
42 protected ByteBuf serializeBody(final SPmsiADCase mvpn) {
43 final SPmsiAD route = mvpn.getSPmsiAD();
44 final ByteBuf nlriByteBuf = Unpooled.buffer();
45 serializeRDMulticastSource(route, nlriByteBuf);
46 MulticastGroupOpaqueUtil.bytesForMulticastGroup(route.getMulticastGroup(), nlriByteBuf);
47 nlriByteBuf.writeBytes(IpAddressUtil.bytesWOLengthFor(route.getOrigRouteIp()));
52 public Class<? extends MvpnChoice> getClazz() {
53 return SPmsiADCase.class;