BUG-139: Implement PCEP state synchronization avoidance
[bgpcep.git] / pcep / ietf-stateful07 / src / main / java / org / opendaylight / protocol / pcep / ietf / initiated00 / Stateful07SessionProposalFactory.java
1 /*
2  * Copyright (c) 2013 Cisco Systems, Inc. and others.  All rights reserved.
3  *
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
7  */
8 package org.opendaylight.protocol.pcep.ietf.initiated00;
9
10 import java.net.InetSocketAddress;
11 import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
12 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.crabbe.initiated.rev131126.Stateful1Builder;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.Tlvs1Builder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev131222.stateful.capability.tlv.StatefulBuilder;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
18
19 public class Stateful07SessionProposalFactory extends BasePCEPSessionProposalFactory {
20
21     private final boolean stateful, active, instant, triggeredSync, triggeredResync, deltaLspSync, includeDbVersion;
22
23     public Stateful07SessionProposalFactory(final int deadTimer, final int keepAlive, final boolean stateful, final boolean active,
24             final boolean instant, final boolean triggeredSync, final boolean triggeredResync, final boolean deltaLspSync, final boolean includeDbVersion) {
25         super(deadTimer, keepAlive);
26         this.stateful = stateful;
27         this.active = active;
28         this.instant = instant;
29         this.triggeredSync = triggeredSync;
30         this.triggeredResync = triggeredResync;
31         this.deltaLspSync = deltaLspSync;
32         this.includeDbVersion = includeDbVersion;
33     }
34
35     @Override
36     protected void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
37         if (Stateful07SessionProposalFactory.this.stateful) {
38             builder.addAugmentation(
39                     Tlvs1.class,
40                     new Tlvs1Builder().setStateful(
41                             new StatefulBuilder().setLspUpdateCapability(this.active)
42                             .addAugmentation(Stateful1.class, new Stateful1Builder().setInitiation(this.instant).build())
43                             .addAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1.class, new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Stateful1Builder()
44                                 .setTriggeredInitialSync(this.triggeredSync)
45                                 .setTriggeredResync(this.triggeredResync)
46                                 .setDeltaLspSyncCapability(this.deltaLspSync)
47                                 .setIncludeDbVersion(this.includeDbVersion)
48                                 .build())
49                             .build()).build()).build();
50         }
51     }
52
53     public boolean isStateful() {
54         return this.stateful;
55     }
56
57     public boolean isActive() {
58         return this.active;
59     }
60
61     public boolean isInstant() {
62         return this.instant;
63     }
64
65     public boolean isTriggeredSync() {
66         return this.triggeredSync;
67     }
68
69     public boolean isTriggeredResync() {
70         return this.triggeredResync;
71     }
72
73     public boolean isDeltaLspSync() {
74         return this.deltaLspSync;
75     }
76
77     public boolean isIncludeDbVersion() {
78         return this.includeDbVersion;
79     }
80 }