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 static org.opendaylight.protocol.bgp.evpn.impl.attributes.tunnel.identifier.TunnelIdentifierHandler.NO_TUNNEL_INFORMATION_PRESENT;
13 import com.google.common.base.Preconditions;
14 import io.netty.buffer.ByteBuf;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.Opaque;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpMp2mpLsp;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.MldpMp2mpLspBuilder;
20 final class MldpMp2mpLspParser implements TunnelIdentifierSerializer, TunnelIdentifierParser {
22 public int serialize(final TunnelIdentifier tunnelIdentifier, final ByteBuf buffer) {
23 Preconditions.checkArgument(tunnelIdentifier instanceof MldpMp2mpLsp, "The tunnelIdentifier %s is not MldpMp2mpLsp type.", tunnelIdentifier);
24 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.
25 MldpMp2mpLsp mldpMp2mpLsp = ((MldpMp2mpLsp) tunnelIdentifier).getMldpMp2mpLsp();
26 if (!OpaqueUtil.serializeOpaque(mldpMp2mpLsp, buffer)) {
27 return NO_TUNNEL_INFORMATION_PRESENT;
29 return TunnelType.M_LDP_MP_2_MP_LSP.getIntValue();
33 public TunnelIdentifier parse(final ByteBuf buffer) {
34 final Opaque opaque = OpaqueUtil.parseOpaque(buffer);
38 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.
39 MldpMp2mpLsp mldpMp2mpLsp = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.
40 MldpMp2mpLspBuilder(opaque).build();
41 return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();