blob: 59114fb68e11e89d80dc015a2ec15ca696433a04 [file] [log] [blame]
Thejaswi N K6a4cd002015-09-21 17:19:55 +05301/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2015-present Open Networking Laboratory
Thejaswi N K6a4cd002015-09-21 17:19:55 +05303 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.bgp.controller.impl;
17
18import org.onlab.packet.Ip4Address;
Shashikanth VH4b76e512015-11-18 15:42:37 +053019import org.onosproject.bgp.controller.BgpConnectPeer;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053020import org.onosproject.bgp.controller.BgpPeerCfg;
Thejaswi N K6a4cd002015-09-21 17:19:55 +053021
22/**
23 * BGP Peer configuration information.
24 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053025public class BgpPeerConfig implements BgpPeerCfg {
Thejaswi N K6a4cd002015-09-21 17:19:55 +053026 private int asNumber;
27 private short holdTime;
28 private boolean isIBgp;
29 private Ip4Address peerId = null;
30 private State state;
31 private boolean selfInitiated;
Shashikanth VH4b76e512015-11-18 15:42:37 +053032 private BgpConnectPeer connectPeer;
Thejaswi N K6a4cd002015-09-21 17:19:55 +053033
34 /**
35 * Constructor to initialize the values.
36 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053037 BgpPeerConfig() {
Thejaswi N K6a4cd002015-09-21 17:19:55 +053038 state = State.IDLE;
39 selfInitiated = false;
40 }
41
42 @Override
43 public int getAsNumber() {
44 return this.asNumber;
45 }
46
47 @Override
48 public void setAsNumber(int asNumber) {
49 this.asNumber = asNumber;
50 }
51
52 @Override
53 public short getHoldtime() {
54 return this.holdTime;
55 }
56
57 @Override
58 public void setHoldtime(short holdTime) {
59 this.holdTime = holdTime;
60 }
61
62 @Override
63 public boolean getIsIBgp() {
64 return this.isIBgp;
65 }
66
67 @Override
68 public void setIsIBgp(boolean isIBgp) {
69 this.isIBgp = isIBgp;
70 }
71
72 @Override
73 public String getPeerRouterId() {
74 if (this.peerId != null) {
75 return this.peerId.toString();
76 } else {
77 return null;
78 }
79 }
80
81 @Override
82 public void setPeerRouterId(String peerId) {
83 this.peerId = Ip4Address.valueOf(peerId);
84 }
85
86 @Override
87 public void setPeerRouterId(String peerId, int asNumber) {
88 this.peerId = Ip4Address.valueOf(peerId);
89 this.asNumber = asNumber;
90 }
91
92 @Override
93 public State getState() {
94 return this.state;
95 }
96
97 @Override
98 public void setState(State state) {
99 this.state = state;
100 }
101
102 @Override
103 public boolean getSelfInnitConnection() {
104 return this.selfInitiated;
105 }
106
107 @Override
108 public void setSelfInnitConnection(boolean selfInit) {
109 this.selfInitiated = selfInit;
110 }
Shashikanth VH4b76e512015-11-18 15:42:37 +0530111
112 @Override
113 public BgpConnectPeer connectPeer() {
114 return this.connectPeer;
115 }
116
117 @Override
118 public void setConnectPeer(BgpConnectPeer connectPeer) {
119 this.connectPeer = connectPeer;
120 }
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530121}