Shashikanth VH
Committed by Gerrit Code Review

[ONOS-2606] Path nlri to implement local Rib and selection process

Change-Id: I198c713d035883011e742bd752339f12cdb51c36
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
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
6 + *
7 + * http://www.apache.org/licenses/LICENSE-2.0
8 + *
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.
12 + */
13 +package org.onosproject.bgpio.protocol.linkstate;
14 +
15 +import java.util.Objects;
16 +
17 +import org.onlab.packet.IpAddress;
18 +import com.google.common.base.MoreObjects;
19 +
20 +/**
21 + * This Class stores path Attributes, protocol ID and Identifier of LinkState nlri.
22 + */
23 +public class PathAttrNlriDetailsLocalRib {
24 +
25 + private IpAddress localRibIpAddress;
26 + private long localRibAsNum;
27 + private int localRibIdentifier;
28 + private boolean isLocalRibIbgpSession;
29 + private PathAttrNlriDetails localRibNlridetails;
30 +
31 + /**
32 + * Constructor to initialize parameter.
33 + *
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
39 + *
40 + */
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;
48 + }
49 +
50 + /**
51 + * Gets the Ipaddress updated in local rib.
52 + *
53 + * @return localRibIpAddress ip address
54 + */
55 + public IpAddress localRibIpAddress() {
56 + return localRibIpAddress;
57 + }
58 +
59 + /**
60 + * Gets the autonomous system number updated in local rib.
61 + *
62 + * @return localRibAsNum autonomous system number
63 + */
64 + public long localRibAsNum() {
65 + return localRibAsNum;
66 + }
67 +
68 + /**
69 + * Gets the indetifier updated in local rib.
70 + *
71 + * @return localRibIdentifier identifier
72 + */
73 + public int localRibIdentifier() {
74 + return localRibIdentifier;
75 + }
76 +
77 + /**
78 + * Gets the bgp session type updated in local rib.
79 + *
80 + * @return isLocalRibIbgpSession session type
81 + */
82 + public boolean isLocalRibIbgpSession() {
83 + return isLocalRibIbgpSession;
84 + }
85 +
86 + /**
87 + * Returns local RIB Nlri details.
88 + *
89 + * @return localRibNlridetails Nlri details in local rib
90 + */
91 + public PathAttrNlriDetails localRibNlridetails() {
92 + return this.localRibNlridetails;
93 + }
94 +
95 + @Override
96 + public int hashCode() {
97 + return Objects.hash(localRibIpAddress, localRibIdentifier, localRibAsNum, isLocalRibIbgpSession,
98 + localRibNlridetails.hashCode());
99 + }
100 +
101 + @Override
102 + public boolean equals(Object obj) {
103 + if (this == obj) {
104 + return true;
105 + }
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);
113 + }
114 + return false;
115 + }
116 +
117 + @Override
118 + public String toString() {
119 + return MoreObjects.toStringHelper(getClass()).add("peerIdentifier", localRibIdentifier)
120 + .add("localRibpathAttributes", localRibNlridetails.pathAttributes()).toString();
121 + }
122 +}