2 * Copyright (c) 2015 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.pcc.mock.protocol;
10 import static java.util.Objects.requireNonNull;
12 import java.math.BigInteger;
13 import java.net.InetSocketAddress;
14 import javax.annotation.Nonnull;
15 import org.opendaylight.protocol.pcep.PCEPPeerProposal;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs3;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.Tlvs3Builder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.sync.optimizations.rev150714.lsp.db.version.tlv.LspDbVersionBuilder;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.open.TlvsBuilder;
21 public class PCCServerPeerProposal implements PCEPPeerProposal {
22 private boolean isAfterReconnection;
23 private final BigInteger dbVersion;
25 public PCCServerPeerProposal(@Nonnull final BigInteger dbVersion) {
26 this.dbVersion = dbVersion;
30 public void setPeerSpecificProposal(@Nonnull final InetSocketAddress address, @Nonnull final TlvsBuilder openBuilder) {
31 requireNonNull(address);
32 final LspDbVersionBuilder lspDbVersionBuilder = new LspDbVersionBuilder();
33 if (this.isAfterReconnection) {
34 lspDbVersionBuilder.setLspDbVersionValue(this.dbVersion);
36 this.isAfterReconnection = true;
38 openBuilder.addAugmentation(Tlvs3.class, new Tlvs3Builder().setLspDbVersion(lspDbVersionBuilder.build()).build());