2 * Copyright (c) 2016 Cisco Systems, Inc. and others. 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.evpn.impl.attributes.tunnel.identifier;
11 import com.google.common.base.Preconditions;
12 import io.netty.buffer.ByteBuf;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.BidirPimTree;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.BidirPimTreeBuilder;
17 final class BidirPimTreeParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
19 public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
20 Preconditions.checkArgument(tunnelIdentifier instanceof BidirPimTree,
21 "The tunnelIdentifier %s is not BidirPimTree type.", tunnelIdentifier);
22 PAddressPMulticastGroupUtil
23 .serializeSenderPMulticastGroup(((BidirPimTree) tunnelIdentifier).getBidirPimTree(), buffer);
24 return TunnelType.BIDIR_PIM_TREE.getIntValue();
28 public TunnelIdentifier parse(final ByteBuf buffer) {
29 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
30 .tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder bidirPimTree =
31 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
32 .pmsi.tunnel.tunnel.identifier.bidir.pim.tree.BidirPimTreeBuilder(PAddressPMulticastGroupUtil
33 .parseSenderPMulticastGroup(buffer));
34 return new BidirPimTreeBuilder().setBidirPimTree(bidirPimTree.build()).build();