2 * Copyright (c) 2013 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.impl;
10 import java.net.InetSocketAddress;
12 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.OpenObject;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.StatefulCapabilityTlv.Flags;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.message.open.message.OpenBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Tlvs;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.TlvsBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.tlvs.StatefulBuilder;
20 public class PCEPSessionProposalFactoryImpl implements PCEPSessionProposalFactory {
22 private final int keepAlive, deadTimer, timeout;
24 private final boolean stateful, active, versioned, instant;
26 public PCEPSessionProposalFactoryImpl(final int deadTimer, final int keepAlive, final boolean stateful, final boolean active,
27 final boolean versioned, final boolean instant, final int timeout) {
28 this.deadTimer = deadTimer;
29 this.keepAlive = keepAlive;
30 this.stateful = stateful;
32 this.versioned = versioned;
33 this.instant = instant;
34 this.timeout = timeout;
38 public OpenObject getSessionProposal(final InetSocketAddress address, final int sessionId) {
39 final Tlvs tlvs = null;
40 final TlvsBuilder builder = new TlvsBuilder();
41 if (PCEPSessionProposalFactoryImpl.this.stateful) {
42 builder.setStateful((new StatefulBuilder().setFlags(new Flags(PCEPSessionProposalFactoryImpl.this.versioned, PCEPSessionProposalFactoryImpl.this.instant, PCEPSessionProposalFactoryImpl.this.active)).build()));
44 return new OpenBuilder().setKeepalive((short) PCEPSessionProposalFactoryImpl.this.keepAlive).setDeadTimer(
45 (short) PCEPSessionProposalFactoryImpl.this.deadTimer).setSessionId((short) sessionId).setTlvs(tlvs).build();
48 public int getKeepAlive() {
49 return this.keepAlive;
52 public int getDeadTimer() {
53 return this.deadTimer;
56 public boolean isStateful() {
60 public boolean isActive() {
64 public boolean isVersioned() {
65 return this.versioned;
68 public boolean isInstant() {
72 public int getTimeout() {