54188d84762483c0a3ae5fbee2941e0f4e82ef45
[bgpcep.git] / pcep / segment-routing / src / main / java / org / opendaylight / protocol / pcep / segment / routing / SegmentRoutingSessionProposalFactory.java
1 /*
2  * Copyright (c) 2014 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
9 package org.opendaylight.protocol.pcep.segment.routing;
10
11 import java.net.InetSocketAddress;
12 import org.opendaylight.protocol.pcep.ietf.initiated00.Stateful07SessionProposalFactory;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.Tlvs1Builder;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev150112.sr.pce.capability.tlv.SrPceCapabilityBuilder;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
17
18 public class SegmentRoutingSessionProposalFactory extends Stateful07SessionProposalFactory {
19
20     private final boolean isSegmentRoutingCapable;
21
22     public SegmentRoutingSessionProposalFactory(final int deadTimer, final int keepAlive, final boolean stateful, final boolean active,
23             final boolean instant, final boolean isSegmentRoutingCapable) {
24         super(deadTimer, keepAlive, stateful, active, instant);
25         this.isSegmentRoutingCapable = isSegmentRoutingCapable;
26     }
27
28     @Override
29     protected void addTlvs(final InetSocketAddress address, final TlvsBuilder builder) {
30         super.addTlvs(address, builder);
31         if (this.isSegmentRoutingCapable) {
32             builder.addAugmentation(Tlvs1.class,
33                     new Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder().setMsd((short) 0).build())
34                             .build());
35         }
36     }
37
38     public boolean isSegmentRoutingCapable() {
39         return this.isSegmentRoutingCapable;
40     }
41
42 }