Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 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 | */ |
| 16 | package org.onosproject.bgp.controller.impl; |
| 17 | |
| 18 | import org.onlab.packet.Ip4Address; |
Shashikanth VH | 4b76e51 | 2015-11-18 15:42:37 +0530 | [diff] [blame] | 19 | import org.onosproject.bgp.controller.BgpConnectPeer; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 20 | import org.onosproject.bgp.controller.BgpPeerCfg; |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 21 | |
| 22 | /** |
| 23 | * BGP Peer configuration information. |
| 24 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 25 | public class BgpPeerConfig implements BgpPeerCfg { |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 26 | 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 VH | 4b76e51 | 2015-11-18 15:42:37 +0530 | [diff] [blame] | 32 | private BgpConnectPeer connectPeer; |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 33 | |
| 34 | /** |
| 35 | * Constructor to initialize the values. |
| 36 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 37 | BgpPeerConfig() { |
Thejaswi N K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 38 | 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 VH | 4b76e51 | 2015-11-18 15:42:37 +0530 | [diff] [blame] | 111 | |
| 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 K | 6a4cd00 | 2015-09-21 17:19:55 +0530 | [diff] [blame] | 121 | } |