blob: 65cd48560de1a5043746a3a97ed985724523dab6 [file] [log] [blame]
Thejaswi N K6a4cd002015-09-21 17:19:55 +05301/*
2 * Copyright 2015 Open Networking Laboratory
3 *
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;
Shashikanth VHdcfb7b52016-02-05 12:56:23 +053033 private FlowSpec flowSpecStatus = FlowSpec.NONE;
Thejaswi N K6a4cd002015-09-21 17:19:55 +053034
35 /**
36 * Constructor to initialize the values.
37 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053038 BgpPeerConfig() {
Thejaswi N K6a4cd002015-09-21 17:19:55 +053039 state = State.IDLE;
40 selfInitiated = false;
41 }
42
43 @Override
44 public int getAsNumber() {
45 return this.asNumber;
46 }
47
48 @Override
49 public void setAsNumber(int asNumber) {
50 this.asNumber = asNumber;
51 }
52
53 @Override
54 public short getHoldtime() {
55 return this.holdTime;
56 }
57
58 @Override
59 public void setHoldtime(short holdTime) {
60 this.holdTime = holdTime;
61 }
62
63 @Override
64 public boolean getIsIBgp() {
65 return this.isIBgp;
66 }
67
68 @Override
69 public void setIsIBgp(boolean isIBgp) {
70 this.isIBgp = isIBgp;
71 }
72
73 @Override
74 public String getPeerRouterId() {
75 if (this.peerId != null) {
76 return this.peerId.toString();
77 } else {
78 return null;
79 }
80 }
81
82 @Override
83 public void setPeerRouterId(String peerId) {
84 this.peerId = Ip4Address.valueOf(peerId);
85 }
86
87 @Override
88 public void setPeerRouterId(String peerId, int asNumber) {
89 this.peerId = Ip4Address.valueOf(peerId);
90 this.asNumber = asNumber;
91 }
92
93 @Override
94 public State getState() {
95 return this.state;
96 }
97
98 @Override
99 public void setState(State state) {
100 this.state = state;
101 }
102
103 @Override
104 public boolean getSelfInnitConnection() {
105 return this.selfInitiated;
106 }
107
108 @Override
109 public void setSelfInnitConnection(boolean selfInit) {
110 this.selfInitiated = selfInit;
111 }
Shashikanth VH4b76e512015-11-18 15:42:37 +0530112
113 @Override
114 public BgpConnectPeer connectPeer() {
115 return this.connectPeer;
116 }
117
118 @Override
119 public void setConnectPeer(BgpConnectPeer connectPeer) {
120 this.connectPeer = connectPeer;
121 }
Shashikanth VHdcfb7b52016-02-05 12:56:23 +0530122
123 @Override
124 public FlowSpec flowSpecStatus() {
125 return flowSpecStatus;
126 }
127
128 @Override
129 public void setFlowSpecStatus(FlowSpec flowSpecStatus) {
130 this.flowSpecStatus = flowSpecStatus;
131 }
Thejaswi N K6a4cd002015-09-21 17:19:55 +0530132}