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.bgp.rib.impl.spi;
10 import java.util.List;
11 import java.util.Optional;
12 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.AsNumber;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev180329.open.message.BgpParameters;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.types.rev180329.BgpId;
17 * DTO for BGP Session preferences, that contains BGP Open message.
19 public final class BGPSessionPreferences {
21 private final AsNumber as;
23 private final int hold;
25 private final BgpId bgpId;
27 private final List<BgpParameters> params;
29 private final AsNumber remoteAs;
31 private final Optional<byte[]> md5Password;
34 * Creates a new DTO for Open message.
36 * @param as local AS number
37 * @param hold preferred hold timer value, in seconds
38 * @param bgpId local BGP Identifier
39 * @param remoteAs expected remote As Number
40 * @param params list of advertised parameters
41 * @param md5Password - md5password
43 public BGPSessionPreferences(final AsNumber as, final int hold, final BgpId bgpId, final AsNumber remoteAs,
44 final List<BgpParameters> params, final Optional<byte[]> md5Password) {
47 this.bgpId = (bgpId != null) ? new BgpId(bgpId) : null;
48 this.remoteAs = remoteAs;
50 this.md5Password = md5Password;
53 public BGPSessionPreferences(final AsNumber as, final int hold, final BgpId bgpId, final AsNumber remoteAs,
54 final List<BgpParameters> params) {
55 this(as, hold, bgpId, remoteAs, params, Optional.empty());
58 * Returns my AS number.
62 public AsNumber getMyAs() {
67 * Returns initial value of HoldTimer.
69 * @return initial value of HoldTimer
71 public int getHoldTime() {
76 * Returns my BGP Identifier.
78 * @return BGP identifier
80 public BgpId getBgpId() {
85 * Returns expected remote AS number.
89 public AsNumber getExpectedRemoteAs() {
94 * Gets a list of advertised bgp parameters.
96 * @return a list of advertised bgp parameters
98 public List<BgpParameters> getParams() {
103 * Optionally returns peer's MD5 password.
104 * @return Encoded MD5 password.
106 public Optional<byte[]> getMd5Password() {
107 return this.md5Password;