2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
5 * the License. You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
10 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
11 * specific language governing permissions and limitations under the License.
13 package org.onosproject.bgpio.protocol.linkstate;
15 import java.util.Objects;
17 import org.onlab.packet.IpAddress;
18 import com.google.common.base.MoreObjects;
21 * This Class stores path Attributes, protocol ID and Identifier of LinkState nlri.
23 public class PathAttrNlriDetailsLocalRib {
25 private IpAddress localRibIpAddress;
26 private long localRibAsNum;
27 private int localRibIdentifier;
28 private boolean isLocalRibIbgpSession;
29 private PathAttrNlriDetails localRibNlridetails;
32 * Constructor to initialize parameter.
34 * @param localRibIpAddress peer ip address
35 * @param localRibIdentifier peer identifier
36 * @param localRibAsNum peer As number
37 * @param isLocalRibIbgpSession flag to indicate is Ibgp session
38 * @param localRibNlridetails Nlri details
41 public PathAttrNlriDetailsLocalRib(IpAddress localRibIpAddress, int localRibIdentifier, long localRibAsNum,
42 boolean isLocalRibIbgpSession, PathAttrNlriDetails localRibNlridetails) {
43 this.localRibIpAddress = localRibIpAddress;
44 this.localRibAsNum = localRibAsNum;
45 this.localRibIdentifier = localRibIdentifier;
46 this.isLocalRibIbgpSession = isLocalRibIbgpSession;
47 this.localRibNlridetails = localRibNlridetails;
51 * Gets the Ipaddress updated in local rib.
53 * @return localRibIpAddress ip address
55 public IpAddress localRibIpAddress() {
56 return localRibIpAddress;
60 * Gets the autonomous system number updated in local rib.
62 * @return localRibAsNum autonomous system number
64 public long localRibAsNum() {
69 * Gets the indetifier updated in local rib.
71 * @return localRibIdentifier identifier
73 public int localRibIdentifier() {
74 return localRibIdentifier;
78 * Gets the bgp session type updated in local rib.
80 * @return isLocalRibIbgpSession session type
82 public boolean isLocalRibIbgpSession() {
83 return isLocalRibIbgpSession;
87 * Returns local RIB Nlri details.
89 * @return localRibNlridetails Nlri details in local rib
91 public PathAttrNlriDetails localRibNlridetails() {
92 return this.localRibNlridetails;
96 public int hashCode() {
97 return Objects.hash(localRibIpAddress, localRibIdentifier, localRibAsNum, isLocalRibIbgpSession,
98 localRibNlridetails.hashCode());
102 public boolean equals(Object obj) {
106 if (obj instanceof PathAttrNlriDetailsLocalRib) {
107 PathAttrNlriDetailsLocalRib other = (PathAttrNlriDetailsLocalRib) obj;
108 return Objects.equals(localRibIpAddress, other.localRibIpAddress)
109 && Objects.equals(localRibIdentifier, other.localRibIdentifier)
110 && Objects.equals(localRibAsNum, other.localRibAsNum)
111 && Objects.equals(isLocalRibIbgpSession, other.isLocalRibIbgpSession)
112 && Objects.equals(localRibNlridetails, other.localRibNlridetails);
118 public String toString() {
119 return MoreObjects.toStringHelper(getClass()).add("peerIdentifier", localRibIdentifier)
120 .add("localRibpathAttributes", localRibNlridetails.pathAttributes()).toString();