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,
24 "The tunnelIdentifier %s is not MldpMp2mpLsp type.", tunnelIdentifier);
25 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
26 .tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp =
27 ((MldpMp2mpLsp) tunnelIdentifier).getMldpMp2mpLsp();
28 if (!OpaqueUtil.serializeOpaque(mldpMp2mpLsp, buffer)) {
29 return NO_TUNNEL_INFORMATION_PRESENT;
31 return TunnelType.M_LDP_MP_2_MP_LSP.getIntValue();
35 public TunnelIdentifier parse(final ByteBuf buffer) {
36 final Opaque opaque = OpaqueUtil.parseOpaque(buffer);
40 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel.pmsi
41 .tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLsp mldpMp2mpLsp =
42 new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev160812.pmsi.tunnel
43 .pmsi.tunnel.tunnel.identifier.mldp.mp2mp.lsp.MldpMp2mpLspBuilder(opaque).build();
44 return new MldpMp2mpLspBuilder().setMldpMp2mpLsp(mldpMp2mpLsp).build();