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
8 package org.opendaylight.protocol.bgp.mvpn.impl.attributes.tunnel.identifier;
10 import static org.opendaylight.protocol.bgp.mvpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.parseIpAddress;
11 import static org.opendaylight.protocol.bgp.mvpn.impl.attributes.tunnel.identifier.PAddressPMulticastGroupUtil.serializeIpAddress;
13 import io.netty.buffer.ByteBuf;
14 import org.opendaylight.protocol.bgp.mvpn.spi.attributes.tunnel.identifier.AbstractTunnelIdentifier;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.PmsiTunnelType;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.TunnelIdentifier;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.RsvpTeP2mpLsp;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi.tunnel.tunnel.identifier.RsvpTeP2mpLspBuilder;
19 import org.opendaylight.yangtools.yang.common.netty.ByteBufUtils;
21 public final class RsvpTeP2MpLspParser extends AbstractTunnelIdentifier<RsvpTeP2mpLsp> {
22 private static final int RESERVED = 2;
25 public Class<? extends TunnelIdentifier> getClazz() {
26 return RsvpTeP2mpLsp.class;
30 public int serialize(final RsvpTeP2mpLsp tunnelIdentifier, final ByteBuf buffer) {
31 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel.pmsi
32 .tunnel.tunnel.identifier.rsvp.te.p2mp.lsp
33 .RsvpTeP2mpLsp rsvpTeP2mpLsp = tunnelIdentifier.getRsvpTeP2mpLsp();
34 ByteBufUtils.writeOrZero(buffer, rsvpTeP2mpLsp.getP2mpId());
35 buffer.writeZero(RESERVED);
36 ByteBufUtils.writeOrZero(buffer, rsvpTeP2mpLsp.getTunnelId());
37 serializeIpAddress(rsvpTeP2mpLsp.getExtendedTunnelId(), buffer);
42 public RsvpTeP2mpLsp parse(final ByteBuf buffer) {
43 final org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi.tunnel
44 .pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLspBuilder rsvpTeP2mpLps
45 = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pmsi.tunnel.rev180329.pmsi
46 .tunnel.pmsi.tunnel.tunnel.identifier.rsvp.te.p2mp.lsp.RsvpTeP2mpLspBuilder();
47 rsvpTeP2mpLps.setP2mpId(ByteBufUtils.readUint32(buffer));
48 buffer.skipBytes(RESERVED);
49 rsvpTeP2mpLps.setTunnelId(ByteBufUtils.readUint16(buffer));
50 final int ipLength = buffer.readableBytes();
51 rsvpTeP2mpLps.setExtendedTunnelId(parseIpAddress(ipLength, buffer));
52 return new RsvpTeP2mpLspBuilder().setRsvpTeP2mpLsp(rsvpTeP2mpLps.build()).build();
56 public int getType() {
57 return PmsiTunnelType.RsvpTeP2mpLsp.getIntValue();