blob: 51b95a4b499cb46784a1beccaac9af9dab689687 [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;
19import org.onosproject.bgp.controller.BGPPeerCfg;
20
21/**
22 * BGP Peer configuration information.
23 */
24public class BGPPeerConfig implements BGPPeerCfg {
25 private int asNumber;
26 private short holdTime;
27 private boolean isIBgp;
28 private Ip4Address peerId = null;
29 private State state;
30 private boolean selfInitiated;
31
32 /**
33 * Constructor to initialize the values.
34 */
35 BGPPeerConfig() {
36 state = State.IDLE;
37 selfInitiated = false;
38 }
39
40 @Override
41 public int getAsNumber() {
42 return this.asNumber;
43 }
44
45 @Override
46 public void setAsNumber(int asNumber) {
47 this.asNumber = asNumber;
48 }
49
50 @Override
51 public short getHoldtime() {
52 return this.holdTime;
53 }
54
55 @Override
56 public void setHoldtime(short holdTime) {
57 this.holdTime = holdTime;
58 }
59
60 @Override
61 public boolean getIsIBgp() {
62 return this.isIBgp;
63 }
64
65 @Override
66 public void setIsIBgp(boolean isIBgp) {
67 this.isIBgp = isIBgp;
68 }
69
70 @Override
71 public String getPeerRouterId() {
72 if (this.peerId != null) {
73 return this.peerId.toString();
74 } else {
75 return null;
76 }
77 }
78
79 @Override
80 public void setPeerRouterId(String peerId) {
81 this.peerId = Ip4Address.valueOf(peerId);
82 }
83
84 @Override
85 public void setPeerRouterId(String peerId, int asNumber) {
86 this.peerId = Ip4Address.valueOf(peerId);
87 this.asNumber = asNumber;
88 }
89
90 @Override
91 public State getState() {
92 return this.state;
93 }
94
95 @Override
96 public void setState(State state) {
97 this.state = state;
98 }
99
100 @Override
101 public boolean getSelfInnitConnection() {
102 return this.selfInitiated;
103 }
104
105 @Override
106 public void setSelfInnitConnection(boolean selfInit) {
107 this.selfInitiated = selfInit;
108 }
109}