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.SourceActiveADCase;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.mvpn.mvpn.choice.SourceActiveADCaseBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.source.active.a.d.grouping.SourceActiveAD;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.mvpn.rev180417.source.active.a.d.grouping.SourceActiveADBuilder;
22 * https://tools.ietf.org/html/rfc6514#section-4.5.
24 * @author Claudio D. Gasparini
26 public final class SourceActiveADHandler extends AbstractMvpnNlri<SourceActiveADCase> {
28 public int getType() {
29 return NlriType.SourceActiveAD.getIntValue();
33 public SourceActiveADCase parseMvpn(final ByteBuf buffer) {
34 final SourceActiveADBuilder builder = new SourceActiveADBuilder(parseRDMulticastSource(buffer));
35 builder.setMulticastGroup(IpAddressUtil.addressForByteBuf(buffer));
36 return new SourceActiveADCaseBuilder().setSourceActiveAD(builder.build()).build();
41 protected ByteBuf serializeBody(final SourceActiveADCase mvpn) {
42 final SourceActiveAD route = mvpn.getSourceActiveAD();
43 final ByteBuf nlriByteBuf = Unpooled.buffer();
44 serializeRDMulticastSource(route, nlriByteBuf);
45 nlriByteBuf.writeBytes(IpAddressUtil.bytesFor(route.getMulticastGroup()));
50 public Class<? extends MvpnChoice> getClazz() {
51 return SourceActiveADCase.class;