2 * Copyright (c) 2014 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.pcep.lsp.setup.type01;
10 import io.netty.buffer.ByteBuf;
11 import org.opendaylight.protocol.pcep.impl.object.PCEPRequestParameterObjectParser;
12 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
13 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.PathSetupTypeTlv;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs1Builder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs2;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs3;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.Tlvs4;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.lsp.setup.type._01.rev140507.path.setup.type.tlv.PathSetupType;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.Tlv;
22 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.Tlvs;
23 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.rp.object.rp.TlvsBuilder;
25 public class PcepRpObjectWithPstTlvParser extends PCEPRequestParameterObjectParser {
27 public PcepRpObjectWithPstTlvParser(final TlvRegistry tlvReg, final VendorInformationTlvRegistry viTlvReg) {
28 super(tlvReg, viTlvReg);
32 public void addTlv(final TlvsBuilder builder, final Tlv tlv) {
33 super.addTlv(builder, tlv);
34 final Tlvs1Builder tlvBuilder = new Tlvs1Builder();
35 final Tlvs1 tlvs = builder.getAugmentation(Tlvs1.class);
36 if (tlvs != null && tlvs.getPathSetupType() != null) {
37 tlvBuilder.setPathSetupType(tlvs.getPathSetupType());
39 if (tlv instanceof PathSetupType) {
40 tlvBuilder.setPathSetupType((PathSetupType) tlv);
42 builder.addAugmentation(Tlvs1.class, tlvBuilder.build()).build();
46 public void serializeTlvs(final Tlvs tlvs, final ByteBuf body) {
50 super.serializeTlvs(tlvs, body);
51 if (tlvs.getAugmentation(Tlvs1.class) != null) {
52 serializePathSetupType(tlvs.getAugmentation(Tlvs1.class), body);
53 } else if (tlvs.getAugmentation(Tlvs2.class) != null) {
54 serializePathSetupType(tlvs.getAugmentation(Tlvs2.class), body);
55 } else if (tlvs.getAugmentation(Tlvs3.class) != null) {
56 serializePathSetupType(tlvs.getAugmentation(Tlvs3.class), body);
57 } else if (tlvs.getAugmentation(Tlvs4.class) != null) {
58 serializePathSetupType(tlvs.getAugmentation(Tlvs4.class), body);
62 private void serializePathSetupType(final PathSetupTypeTlv pstTlv, final ByteBuf body) {
63 if (pstTlv.getPathSetupType() != null) {
64 serializeTlv(pstTlv.getPathSetupType(), body);