Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +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 | |
| 17 | package org.onosproject.bgpio.types; |
| 18 | |
| 19 | import java.util.LinkedList; |
| 20 | import java.util.List; |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 21 | import java.util.ListIterator; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 22 | |
| 23 | import org.jboss.netty.buffer.ChannelBuffer; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 24 | import org.onosproject.bgpio.exceptions.BgpParseException; |
| 25 | import org.onosproject.bgpio.protocol.BgpLSNlri; |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 26 | import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 27 | import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4; |
| 28 | import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4; |
Priyanka B | e07ea4d | 2015-11-21 21:28:10 +0530 | [diff] [blame] | 29 | import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 30 | import org.onosproject.bgpio.util.Constants; |
| 31 | import org.onosproject.bgpio.util.Validation; |
| 32 | import org.slf4j.Logger; |
| 33 | import org.slf4j.LoggerFactory; |
| 34 | |
| 35 | import com.google.common.base.MoreObjects; |
| 36 | |
| 37 | /** |
| 38 | * Provides Implementation of MpUnReach Nlri BGP Path Attribute. |
| 39 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 40 | public class MpUnReachNlri implements BgpValueType { |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 41 | |
Priyanka B | e07ea4d | 2015-11-21 21:28:10 +0530 | [diff] [blame] | 42 | private static final Logger log = LoggerFactory.getLogger(MpUnReachNlri.class); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 43 | public static final byte MPUNREACHNLRI_TYPE = 15; |
| 44 | public static final byte LINK_NLRITYPE = 2; |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 45 | public static final byte FLAGS = (byte) 0x90; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 46 | private boolean isMpUnReachNlri = false; |
| 47 | private final short afi; |
| 48 | private final byte safi; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 49 | private final List<BgpLSNlri> mpUnReachNlri; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 50 | private final int length; |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 51 | private BgpFlowSpecNlri bgpFlowSpecNlri; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 52 | |
| 53 | /** |
| 54 | * Constructor to initialize parameters. |
| 55 | * |
| 56 | * @param mpUnReachNlri MpUnReach Nlri attribute |
| 57 | * @param afi address family identifier |
| 58 | * @param safi subsequent address family identifier |
| 59 | * @param length of MpUnReachNlri |
| 60 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 61 | public MpUnReachNlri(List<BgpLSNlri> mpUnReachNlri, short afi, byte safi, |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 62 | int length) { |
| 63 | this.mpUnReachNlri = mpUnReachNlri; |
| 64 | this.isMpUnReachNlri = true; |
| 65 | this.afi = afi; |
| 66 | this.safi = safi; |
| 67 | this.length = length; |
| 68 | } |
| 69 | |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 70 | public MpUnReachNlri(BgpFlowSpecNlri bgpFlowSpecNlri, short afi, byte safi) { |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 71 | this.mpUnReachNlri = null; |
| 72 | this.isMpUnReachNlri = true; |
| 73 | this.length = 0; |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 74 | this.bgpFlowSpecNlri = bgpFlowSpecNlri; |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 75 | this.afi = afi; |
| 76 | this.safi = safi; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * Returns BGP flow specification info. |
| 81 | * |
| 82 | * @return BGP flow specification info |
| 83 | */ |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 84 | public BgpFlowSpecNlri bgpFlowSpecNlri() { |
| 85 | return this.bgpFlowSpecNlri; |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 86 | } |
| 87 | |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 88 | /** |
| 89 | * Reads from ChannelBuffer and parses MpUnReachNlri. |
| 90 | * |
| 91 | * @param cb ChannelBuffer |
| 92 | * @return object of MpUnReachNlri |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 93 | * @throws BgpParseException while parsing MpUnReachNlri |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 94 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 95 | public static MpUnReachNlri read(ChannelBuffer cb) throws BgpParseException { |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 96 | ChannelBuffer tempBuf = cb.copy(); |
| 97 | Validation parseFlags = Validation.parseAttributeHeader(cb); |
| 98 | int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT |
| 99 | : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE; |
| 100 | ChannelBuffer data = tempBuf.readBytes(len); |
| 101 | |
| 102 | if (!parseFlags.getFirstBit() && parseFlags.getSecondBit() |
| 103 | && parseFlags.getThirdBit()) { |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 104 | throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR, |
| 105 | BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 106 | } |
| 107 | |
| 108 | if (cb.readableBytes() < parseFlags.getLength()) { |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 109 | Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, |
| 110 | BgpErrorType.ATTRIBUTE_LENGTH_ERROR, parseFlags.getLength()); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 111 | } |
| 112 | |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 113 | LinkedList<BgpLSNlri> mpUnReachNlri = new LinkedList<>(); |
| 114 | BgpLSNlri bgpLSNlri = null; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 115 | short afi = 0; |
| 116 | byte safi = 0; |
| 117 | ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength()); |
| 118 | while (tempCb.readableBytes() > 0) { |
| 119 | afi = tempCb.readShort(); |
| 120 | safi = tempCb.readByte(); |
| 121 | |
| 122 | //Supporting only for AFI 16388 / SAFI 71 |
| 123 | if ((afi == Constants.AFI_VALUE) && (safi == Constants.SAFI_VALUE) |
| 124 | || (afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) { |
| 125 | while (tempCb.readableBytes() > 0) { |
| 126 | short nlriType = tempCb.readShort(); |
| 127 | short totNlriLen = tempCb.readShort(); |
| 128 | if (tempCb.readableBytes() < totNlriLen) { |
| 129 | Validation.validateLen( |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 130 | BgpErrorType.UPDATE_MESSAGE_ERROR, |
| 131 | BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 132 | } |
| 133 | tempBuf = tempCb.readBytes(totNlriLen); |
| 134 | switch (nlriType) { |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 135 | case BgpNodeLSNlriVer4.NODE_NLRITYPE: |
| 136 | bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 137 | break; |
Priyanka B | e07ea4d | 2015-11-21 21:28:10 +0530 | [diff] [blame] | 138 | case BgpLinkLsNlriVer4.LINK_NLRITYPE: |
| 139 | bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 140 | break; |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 141 | case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE: |
| 142 | bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi, |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 143 | safi); |
| 144 | break; |
| 145 | default: |
| 146 | log.debug("nlriType not supported" + nlriType); |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 147 | break; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 148 | } |
| 149 | mpUnReachNlri.add(bgpLSNlri); |
| 150 | } |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 151 | } else if ((afi == Constants.AFI_FLOWSPEC_VALUE) |
| 152 | && ((safi == Constants.SAFI_FLOWSPEC_VALUE) |
| 153 | || (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) { |
| 154 | List<BgpValueType> flowSpecComponents = new LinkedList<>(); |
Shashikanth VH | e3a73bc | 2016-02-22 20:11:31 +0530 | [diff] [blame] | 155 | RouteDistinguisher routeDistinguisher = null; |
Shashikanth VH | 5826066 | 2016-02-13 01:12:02 +0530 | [diff] [blame] | 156 | if (tempCb.readableBytes() > 0) { |
| 157 | BgpValueType flowSpecComponent = null; |
Shashikanth VH | e3a73bc | 2016-02-22 20:11:31 +0530 | [diff] [blame] | 158 | |
| 159 | if (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE) { |
| 160 | routeDistinguisher = new RouteDistinguisher(); |
| 161 | routeDistinguisher = RouteDistinguisher.read(tempCb); |
| 162 | } |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 163 | while (tempCb.readableBytes() > 0) { |
subhasis777 | 55e43a8 | 2017-02-12 07:46:09 +0530 | [diff] [blame^] | 164 | short totNlriLen = tempCb.getUnsignedByte(tempCb.readerIndex()); |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 165 | if (totNlriLen >= BgpFlowSpecNlri.FLOW_SPEC_LEN) { |
| 166 | if (tempCb.readableBytes() < 2) { |
| 167 | Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, |
| 168 | BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen); |
| 169 | } |
| 170 | totNlriLen = tempCb.readShort(); |
| 171 | } else { |
| 172 | totNlriLen = tempCb.readByte(); |
Shashikanth VH | 5826066 | 2016-02-13 01:12:02 +0530 | [diff] [blame] | 173 | } |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 174 | if (tempCb.readableBytes() < totNlriLen) { |
| 175 | Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR, |
| 176 | BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen); |
| 177 | } |
| 178 | tempBuf = tempCb.readBytes(totNlriLen); |
| 179 | while (tempBuf.readableBytes() > 0) { |
| 180 | short type = tempBuf.readByte(); |
| 181 | switch (type) { |
| 182 | case Constants.BGP_FLOWSPEC_DST_PREFIX: |
| 183 | flowSpecComponent = BgpFsDestinationPrefix.read(tempBuf); |
| 184 | break; |
| 185 | case Constants.BGP_FLOWSPEC_SRC_PREFIX: |
| 186 | flowSpecComponent = BgpFsSourcePrefix.read(tempBuf); |
| 187 | break; |
| 188 | case Constants.BGP_FLOWSPEC_IP_PROTO: |
| 189 | flowSpecComponent = BgpFsIpProtocol.read(tempBuf); |
| 190 | break; |
| 191 | case Constants.BGP_FLOWSPEC_PORT: |
| 192 | flowSpecComponent = BgpFsPortNum.read(tempBuf); |
| 193 | break; |
| 194 | case Constants.BGP_FLOWSPEC_DST_PORT: |
| 195 | flowSpecComponent = BgpFsDestinationPortNum.read(tempBuf); |
| 196 | break; |
| 197 | case Constants.BGP_FLOWSPEC_SRC_PORT: |
| 198 | flowSpecComponent = BgpFsSourcePortNum.read(tempBuf); |
| 199 | break; |
| 200 | case Constants.BGP_FLOWSPEC_ICMP_TP: |
| 201 | flowSpecComponent = BgpFsIcmpType.read(tempBuf); |
| 202 | break; |
| 203 | case Constants.BGP_FLOWSPEC_ICMP_CD: |
| 204 | flowSpecComponent = BgpFsIcmpCode.read(tempBuf); |
| 205 | break; |
| 206 | case Constants.BGP_FLOWSPEC_TCP_FLAGS: |
| 207 | flowSpecComponent = BgpFsTcpFlags.read(tempBuf); |
| 208 | break; |
| 209 | case Constants.BGP_FLOWSPEC_PCK_LEN: |
| 210 | flowSpecComponent = BgpFsPacketLength.read(tempBuf); |
| 211 | break; |
| 212 | case Constants.BGP_FLOWSPEC_DSCP: |
| 213 | flowSpecComponent = BgpFsDscpValue.read(tempBuf); |
| 214 | break; |
| 215 | case Constants.BGP_FLOWSPEC_FRAGMENT: |
| 216 | flowSpecComponent = BgpFsFragment.read(tempBuf); |
| 217 | break; |
| 218 | default: |
| 219 | log.debug("flow spec type not supported" + type); |
| 220 | break; |
| 221 | } |
| 222 | flowSpecComponents.add(flowSpecComponent); |
| 223 | } |
Shashikanth VH | 5826066 | 2016-02-13 01:12:02 +0530 | [diff] [blame] | 224 | } |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 225 | } |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 226 | BgpFlowSpecNlri flowSpecDetails = new BgpFlowSpecNlri(flowSpecComponents); |
Shashikanth VH | e3a73bc | 2016-02-22 20:11:31 +0530 | [diff] [blame] | 227 | flowSpecDetails.setRouteDistinguiher(routeDistinguisher); |
| 228 | return new MpUnReachNlri(flowSpecDetails, afi, safi); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 229 | } else { |
| 230 | //TODO: check with the values got from capability |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 231 | throw new BgpParseException("Not Supporting afi " + afi + "safi " + safi); |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 232 | } |
| 233 | } |
| 234 | return new MpUnReachNlri(mpUnReachNlri, afi, safi, |
| 235 | parseFlags.getLength()); |
| 236 | } |
| 237 | |
| 238 | @Override |
| 239 | public short getType() { |
| 240 | return MPUNREACHNLRI_TYPE; |
| 241 | } |
| 242 | |
| 243 | /** |
| 244 | * Returns SAFI. |
| 245 | * |
| 246 | * @return SAFI |
| 247 | */ |
| 248 | public byte safi() { |
| 249 | return this.safi; |
| 250 | } |
| 251 | |
| 252 | /** |
| 253 | * Returns AFI. |
| 254 | * |
| 255 | * @return AFI |
| 256 | */ |
| 257 | public short afi() { |
| 258 | return this.afi; |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * Returns list of MpUnReach Nlri. |
| 263 | * |
| 264 | * @return list of MpUnReach Nlri |
| 265 | */ |
Shashikanth VH | 5dd8dbe | 2015-11-26 13:22:18 +0530 | [diff] [blame] | 266 | public List<BgpLSNlri> mpUnReachNlri() { |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 267 | return this.mpUnReachNlri; |
| 268 | } |
| 269 | |
| 270 | /** |
| 271 | * Returns whether MpReachNlri is present. |
| 272 | * |
| 273 | * @return whether MpReachNlri is present |
| 274 | */ |
| 275 | public boolean isMpUnReachNlriSet() { |
| 276 | return this.isMpUnReachNlri; |
| 277 | } |
| 278 | |
| 279 | /** |
| 280 | * Returns length of MpUnReach. |
| 281 | * |
| 282 | * @return length of MpUnReach |
| 283 | */ |
| 284 | public int mpUnReachNlriLen() { |
| 285 | return this.length; |
| 286 | } |
| 287 | |
| 288 | @Override |
| 289 | public int write(ChannelBuffer cb) { |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 290 | int iLenStartIndex = cb.writerIndex(); |
| 291 | if ((afi == Constants.AFI_FLOWSPEC_VALUE) && ((safi == Constants.SAFI_FLOWSPEC_VALUE) || |
| 292 | (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) { |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 293 | List<BgpValueType> flowSpec = bgpFlowSpecNlri.flowSpecComponents(); |
| 294 | ListIterator<BgpValueType> listIterator = flowSpec.listIterator(); |
| 295 | boolean isAllFlowTypesIdentical = true; |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 296 | |
| 297 | cb.writeByte(FLAGS); |
| 298 | cb.writeByte(MPUNREACHNLRI_TYPE); |
| 299 | |
| 300 | int mpUnReachIndx = cb.writerIndex(); |
| 301 | cb.writeShort(0); |
| 302 | |
| 303 | cb.writeShort(afi); |
| 304 | cb.writeByte(safi); |
| 305 | |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 306 | if (bgpFlowSpecNlri.routeDistinguisher() != null) { |
| 307 | cb.writeLong(bgpFlowSpecNlri.routeDistinguisher().getRouteDistinguisher()); |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 308 | } |
| 309 | |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 310 | BgpValueType tlv1 = null; |
| 311 | if (listIterator.hasNext()) { |
| 312 | tlv1 = listIterator.next(); |
| 313 | } |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 314 | while (listIterator.hasNext()) { |
| 315 | BgpValueType tlv = listIterator.next(); |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 316 | if (tlv.getType() != tlv1.getType()) { |
| 317 | isAllFlowTypesIdentical = false; |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 318 | break; |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 319 | } |
| 320 | } |
| 321 | |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 322 | if (isAllFlowTypesIdentical) { |
| 323 | BgpFlowSpecNlri.updateBufferIdenticalFlowTypes(cb, bgpFlowSpecNlri()); |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 324 | } else { |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 325 | BgpFlowSpecNlri.updateBufferNonIdenticalFlowTypes(cb, bgpFlowSpecNlri()); |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 326 | } |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 327 | int fsNlriLen = cb.writerIndex() - mpUnReachIndx; |
| 328 | cb.setShort(mpUnReachIndx, (short) (fsNlriLen - 2)); |
| 329 | } |
| 330 | |
| 331 | return cb.writerIndex() - iLenStartIndex; |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 332 | } |
| 333 | |
| 334 | @Override |
Priyanka B | 0204073 | 2015-11-29 11:30:29 +0530 | [diff] [blame] | 335 | public int compareTo(Object o) { |
| 336 | // TODO Auto-generated method stub |
| 337 | return 0; |
| 338 | } |
| 339 | |
| 340 | @Override |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 341 | public String toString() { |
Shashikanth VH | 510a8d8 | 2016-02-12 12:32:43 +0530 | [diff] [blame] | 342 | return MoreObjects.toStringHelper(getClass()).omitNullValues() |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 343 | .add("mpReachNlri", mpUnReachNlri) |
Shashikanth VH | 26fd38a | 2016-04-26 18:11:37 +0530 | [diff] [blame] | 344 | .add("bgpFlowSpecNlri", bgpFlowSpecNlri) |
Priyanka B | 3b69554 | 2015-10-14 17:16:27 +0530 | [diff] [blame] | 345 | .add("afi", afi) |
| 346 | .add("safi", safi) |
| 347 | .add("length", length) |
| 348 | .toString(); |
| 349 | } |
| 350 | } |