blob: e06fb0a7680c7f238d75e3c515834aad0a654bb7 [file] [log] [blame]
Priyanka B3b695542015-10-14 17:16:27 +05301/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Priyanka B3b695542015-10-14 17:16:27 +05303 *
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
17package org.onosproject.bgpio.types;
18
Mohammad Shahid30fedc52017-08-09 11:49:40 +053019import com.google.common.base.MoreObjects;
Priyanka B3b695542015-10-14 17:16:27 +053020import org.jboss.netty.buffer.ChannelBuffer;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053021import org.onosproject.bgpio.exceptions.BgpParseException;
Mohammad Shahid30fedc52017-08-09 11:49:40 +053022import org.onosproject.bgpio.protocol.BgpEvpnNlri;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053023import org.onosproject.bgpio.protocol.BgpLSNlri;
Mohammad Shahid30fedc52017-08-09 11:49:40 +053024import org.onosproject.bgpio.protocol.evpn.BgpEvpnNlriImpl;
25import org.onosproject.bgpio.protocol.evpn.BgpEvpnRouteType2Nlri;
Shashikanth VH26fd38a2016-04-26 18:11:37 +053026import org.onosproject.bgpio.protocol.flowspec.BgpFlowSpecNlri;
Mohammad Shahid30fedc52017-08-09 11:49:40 +053027import org.onosproject.bgpio.protocol.linkstate.BgpLinkLsNlriVer4;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053028import org.onosproject.bgpio.protocol.linkstate.BgpNodeLSNlriVer4;
29import org.onosproject.bgpio.protocol.linkstate.BgpPrefixIPv4LSNlriVer4;
Priyanka B3b695542015-10-14 17:16:27 +053030import org.onosproject.bgpio.util.Constants;
31import org.onosproject.bgpio.util.Validation;
32import org.slf4j.Logger;
33import org.slf4j.LoggerFactory;
34
Mohammad Shahid30fedc52017-08-09 11:49:40 +053035import java.util.LinkedList;
36import java.util.List;
37import java.util.ListIterator;
Priyanka B3b695542015-10-14 17:16:27 +053038
39/**
40 * Provides Implementation of MpUnReach Nlri BGP Path Attribute.
41 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053042public class MpUnReachNlri implements BgpValueType {
Priyanka B3b695542015-10-14 17:16:27 +053043
Priyanka Be07ea4d2015-11-21 21:28:10 +053044 private static final Logger log = LoggerFactory.getLogger(MpUnReachNlri.class);
Priyanka B3b695542015-10-14 17:16:27 +053045 public static final byte MPUNREACHNLRI_TYPE = 15;
46 public static final byte LINK_NLRITYPE = 2;
Shashikanth VH510a8d82016-02-12 12:32:43 +053047 public static final byte FLAGS = (byte) 0x90;
Priyanka B3b695542015-10-14 17:16:27 +053048 private boolean isMpUnReachNlri = false;
49 private final short afi;
50 private final byte safi;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053051 private final List<BgpLSNlri> mpUnReachNlri;
Priyanka B3b695542015-10-14 17:16:27 +053052 private final int length;
Shashikanth VH26fd38a2016-04-26 18:11:37 +053053 private BgpFlowSpecNlri bgpFlowSpecNlri;
Mohammad Shahid30fedc52017-08-09 11:49:40 +053054 private List<BgpEvpnNlri> evpnNlri;
Priyanka B3b695542015-10-14 17:16:27 +053055
56 /**
57 * Constructor to initialize parameters.
58 *
59 * @param mpUnReachNlri MpUnReach Nlri attribute
60 * @param afi address family identifier
61 * @param safi subsequent address family identifier
62 * @param length of MpUnReachNlri
63 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +053064 public MpUnReachNlri(List<BgpLSNlri> mpUnReachNlri, short afi, byte safi,
Priyanka B3b695542015-10-14 17:16:27 +053065 int length) {
66 this.mpUnReachNlri = mpUnReachNlri;
67 this.isMpUnReachNlri = true;
68 this.afi = afi;
69 this.safi = safi;
70 this.length = length;
71 }
72
Mohammad Shahid30fedc52017-08-09 11:49:40 +053073 /**
74 * Constructor to initialize parameters.
75 *
76 * @param bgpFlowSpecNlri bgpFlowSpecNlri
77 * @param afi afi
78 * @param safi safi
79 */
Shashikanth VH26fd38a2016-04-26 18:11:37 +053080 public MpUnReachNlri(BgpFlowSpecNlri bgpFlowSpecNlri, short afi, byte safi) {
Shashikanth VH510a8d82016-02-12 12:32:43 +053081 this.mpUnReachNlri = null;
82 this.isMpUnReachNlri = true;
83 this.length = 0;
Shashikanth VH26fd38a2016-04-26 18:11:37 +053084 this.bgpFlowSpecNlri = bgpFlowSpecNlri;
Shashikanth VH510a8d82016-02-12 12:32:43 +053085 this.afi = afi;
86 this.safi = safi;
87 }
88
89 /**
Mohammad Shahid30fedc52017-08-09 11:49:40 +053090 * Constructor to initialize parameters.
91 *
92 * @param evpnNlri evpnNlri
93 * @param afi afi
94 * @param safi safi
95 */
96 public MpUnReachNlri(List<BgpEvpnNlri> evpnNlri, short afi, byte safi) {
97 this.mpUnReachNlri = null;
98 this.isMpUnReachNlri = true;
99 this.length = 0;
100 this.evpnNlri = evpnNlri;
101 this.afi = afi;
102 this.safi = safi;
103 }
104
105 /**
Shashikanth VH510a8d82016-02-12 12:32:43 +0530106 * Returns BGP flow specification info.
107 *
108 * @return BGP flow specification info
109 */
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530110 public BgpFlowSpecNlri bgpFlowSpecNlri() {
111 return this.bgpFlowSpecNlri;
Shashikanth VH510a8d82016-02-12 12:32:43 +0530112 }
113
Priyanka B3b695542015-10-14 17:16:27 +0530114 /**
Mohammad Shahid30fedc52017-08-09 11:49:40 +0530115 * Returns BGP Evpn info.
116 *
117 * @return BGP Evpn info
118 */
119 public List<BgpEvpnNlri> bgpEvpnNlri() {
120 return this.evpnNlri;
121 }
122
123 /**
124 * Returns afi.
125 *
126 * @return afi
127 */
128 public short getAfi() {
129 return this.afi;
130 }
131
132 /**
133 * Returns safi.
134 *
135 * @return safi
136 */
137 public byte getSafi() {
138 return this.safi();
139 }
140
141 /**
142 * Returns mpUnReachNlri details type.
143 *
144 * @return type
145 */
146 public BgpNlriType getNlriDetailsType() {
147 if ((this.afi == Constants.AFI_VALUE)
148 && (this.safi == Constants.SAFI_VALUE)
149 || (this.afi == Constants.AFI_VALUE)
150 && (this.safi == Constants.VPN_SAFI_VALUE)) {
151 return BgpNlriType.LINK_STATE;
152 }
153
154 if ((afi == Constants.AFI_FLOWSPEC_VALUE)
155 && ((safi == Constants.SAFI_FLOWSPEC_VALUE)
156 || (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) {
157 return BgpNlriType.FLOW_SPEC;
158 }
159
160 if ((afi == Constants.AFI_EVPN_VALUE)
161 && (safi == Constants.SAFI_EVPN_VALUE)) {
162 return BgpNlriType.EVPN;
163 }
164
165 return null;
166 }
167
168 /**
Priyanka B3b695542015-10-14 17:16:27 +0530169 * Reads from ChannelBuffer and parses MpUnReachNlri.
170 *
171 * @param cb ChannelBuffer
172 * @return object of MpUnReachNlri
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530173 * @throws BgpParseException while parsing MpUnReachNlri
Priyanka B3b695542015-10-14 17:16:27 +0530174 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530175 public static MpUnReachNlri read(ChannelBuffer cb) throws BgpParseException {
Priyanka B3b695542015-10-14 17:16:27 +0530176 ChannelBuffer tempBuf = cb.copy();
177 Validation parseFlags = Validation.parseAttributeHeader(cb);
178 int len = parseFlags.isShort() ? parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_SHORT
179 : parseFlags.getLength() + Constants.TYPE_AND_LEN_AS_BYTE;
180 ChannelBuffer data = tempBuf.readBytes(len);
181
182 if (!parseFlags.getFirstBit() && parseFlags.getSecondBit()
183 && parseFlags.getThirdBit()) {
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530184 throw new BgpParseException(BgpErrorType.UPDATE_MESSAGE_ERROR,
185 BgpErrorType.ATTRIBUTE_FLAGS_ERROR, data);
Priyanka B3b695542015-10-14 17:16:27 +0530186 }
187
188 if (cb.readableBytes() < parseFlags.getLength()) {
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530189 Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
190 BgpErrorType.ATTRIBUTE_LENGTH_ERROR, parseFlags.getLength());
Priyanka B3b695542015-10-14 17:16:27 +0530191 }
192
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530193 LinkedList<BgpLSNlri> mpUnReachNlri = new LinkedList<>();
194 BgpLSNlri bgpLSNlri = null;
Priyanka B3b695542015-10-14 17:16:27 +0530195 short afi = 0;
196 byte safi = 0;
197 ChannelBuffer tempCb = cb.readBytes(parseFlags.getLength());
198 while (tempCb.readableBytes() > 0) {
199 afi = tempCb.readShort();
200 safi = tempCb.readByte();
201
202 //Supporting only for AFI 16388 / SAFI 71
203 if ((afi == Constants.AFI_VALUE) && (safi == Constants.SAFI_VALUE)
204 || (afi == Constants.AFI_VALUE) && (safi == Constants.VPN_SAFI_VALUE)) {
205 while (tempCb.readableBytes() > 0) {
206 short nlriType = tempCb.readShort();
207 short totNlriLen = tempCb.readShort();
208 if (tempCb.readableBytes() < totNlriLen) {
209 Validation.validateLen(
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530210 BgpErrorType.UPDATE_MESSAGE_ERROR,
211 BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
Priyanka B3b695542015-10-14 17:16:27 +0530212 }
213 tempBuf = tempCb.readBytes(totNlriLen);
214 switch (nlriType) {
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530215 case BgpNodeLSNlriVer4.NODE_NLRITYPE:
216 bgpLSNlri = BgpNodeLSNlriVer4.read(tempBuf, afi, safi);
Priyanka B3b695542015-10-14 17:16:27 +0530217 break;
Priyanka Be07ea4d2015-11-21 21:28:10 +0530218 case BgpLinkLsNlriVer4.LINK_NLRITYPE:
219 bgpLSNlri = BgpLinkLsNlriVer4.read(tempBuf, afi, safi);
Priyanka B3b695542015-10-14 17:16:27 +0530220 break;
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530221 case BgpPrefixIPv4LSNlriVer4.PREFIX_IPV4_NLRITYPE:
222 bgpLSNlri = BgpPrefixIPv4LSNlriVer4.read(tempBuf, afi,
Priyanka B3b695542015-10-14 17:16:27 +0530223 safi);
224 break;
225 default:
226 log.debug("nlriType not supported" + nlriType);
Shashikanth VH510a8d82016-02-12 12:32:43 +0530227 break;
Priyanka B3b695542015-10-14 17:16:27 +0530228 }
229 mpUnReachNlri.add(bgpLSNlri);
230 }
Shashikanth VH510a8d82016-02-12 12:32:43 +0530231 } else if ((afi == Constants.AFI_FLOWSPEC_VALUE)
232 && ((safi == Constants.SAFI_FLOWSPEC_VALUE)
233 || (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) {
234 List<BgpValueType> flowSpecComponents = new LinkedList<>();
Shashikanth VHe3a73bc2016-02-22 20:11:31 +0530235 RouteDistinguisher routeDistinguisher = null;
Shashikanth VH58260662016-02-13 01:12:02 +0530236 if (tempCb.readableBytes() > 0) {
237 BgpValueType flowSpecComponent = null;
Shashikanth VHe3a73bc2016-02-22 20:11:31 +0530238
239 if (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE) {
240 routeDistinguisher = new RouteDistinguisher();
241 routeDistinguisher = RouteDistinguisher.read(tempCb);
242 }
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530243 while (tempCb.readableBytes() > 0) {
subhasis77755e43a82017-02-12 07:46:09 +0530244 short totNlriLen = tempCb.getUnsignedByte(tempCb.readerIndex());
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530245 if (totNlriLen >= BgpFlowSpecNlri.FLOW_SPEC_LEN) {
246 if (tempCb.readableBytes() < 2) {
247 Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
248 BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
249 }
250 totNlriLen = tempCb.readShort();
251 } else {
252 totNlriLen = tempCb.readByte();
Shashikanth VH58260662016-02-13 01:12:02 +0530253 }
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530254 if (tempCb.readableBytes() < totNlriLen) {
255 Validation.validateLen(BgpErrorType.UPDATE_MESSAGE_ERROR,
256 BgpErrorType.ATTRIBUTE_LENGTH_ERROR, totNlriLen);
257 }
258 tempBuf = tempCb.readBytes(totNlriLen);
259 while (tempBuf.readableBytes() > 0) {
260 short type = tempBuf.readByte();
261 switch (type) {
262 case Constants.BGP_FLOWSPEC_DST_PREFIX:
263 flowSpecComponent = BgpFsDestinationPrefix.read(tempBuf);
264 break;
265 case Constants.BGP_FLOWSPEC_SRC_PREFIX:
266 flowSpecComponent = BgpFsSourcePrefix.read(tempBuf);
267 break;
268 case Constants.BGP_FLOWSPEC_IP_PROTO:
269 flowSpecComponent = BgpFsIpProtocol.read(tempBuf);
270 break;
271 case Constants.BGP_FLOWSPEC_PORT:
272 flowSpecComponent = BgpFsPortNum.read(tempBuf);
273 break;
274 case Constants.BGP_FLOWSPEC_DST_PORT:
275 flowSpecComponent = BgpFsDestinationPortNum.read(tempBuf);
276 break;
277 case Constants.BGP_FLOWSPEC_SRC_PORT:
278 flowSpecComponent = BgpFsSourcePortNum.read(tempBuf);
279 break;
280 case Constants.BGP_FLOWSPEC_ICMP_TP:
281 flowSpecComponent = BgpFsIcmpType.read(tempBuf);
282 break;
283 case Constants.BGP_FLOWSPEC_ICMP_CD:
284 flowSpecComponent = BgpFsIcmpCode.read(tempBuf);
285 break;
286 case Constants.BGP_FLOWSPEC_TCP_FLAGS:
287 flowSpecComponent = BgpFsTcpFlags.read(tempBuf);
288 break;
289 case Constants.BGP_FLOWSPEC_PCK_LEN:
290 flowSpecComponent = BgpFsPacketLength.read(tempBuf);
291 break;
292 case Constants.BGP_FLOWSPEC_DSCP:
293 flowSpecComponent = BgpFsDscpValue.read(tempBuf);
294 break;
295 case Constants.BGP_FLOWSPEC_FRAGMENT:
296 flowSpecComponent = BgpFsFragment.read(tempBuf);
297 break;
298 default:
299 log.debug("flow spec type not supported" + type);
300 break;
301 }
302 flowSpecComponents.add(flowSpecComponent);
303 }
Shashikanth VH58260662016-02-13 01:12:02 +0530304 }
Shashikanth VH510a8d82016-02-12 12:32:43 +0530305 }
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530306 BgpFlowSpecNlri flowSpecDetails = new BgpFlowSpecNlri(flowSpecComponents);
Shashikanth VHe3a73bc2016-02-22 20:11:31 +0530307 flowSpecDetails.setRouteDistinguiher(routeDistinguisher);
308 return new MpUnReachNlri(flowSpecDetails, afi, safi);
Mohammad Shahid30fedc52017-08-09 11:49:40 +0530309 } else if ((afi == Constants.AFI_EVPN_VALUE)
310 && (safi == Constants.SAFI_EVPN_VALUE)) {
311 List<BgpEvpnNlri> eVpnComponents = null;
312 while (tempCb.readableBytes() > 0) {
313 BgpEvpnNlri eVpnComponent = BgpEvpnNlriImpl.read(tempCb);
314 eVpnComponents = new LinkedList<>();
315 eVpnComponents.add(eVpnComponent);
316 log.info("=====evpn Component is {} ======", eVpnComponent);
317 }
318
319 return new MpUnReachNlri(eVpnComponents, afi, safi);
Priyanka B3b695542015-10-14 17:16:27 +0530320 } else {
321 //TODO: check with the values got from capability
Shashikanth VH510a8d82016-02-12 12:32:43 +0530322 throw new BgpParseException("Not Supporting afi " + afi + "safi " + safi);
Priyanka B3b695542015-10-14 17:16:27 +0530323 }
324 }
325 return new MpUnReachNlri(mpUnReachNlri, afi, safi,
326 parseFlags.getLength());
327 }
328
329 @Override
330 public short getType() {
331 return MPUNREACHNLRI_TYPE;
332 }
333
334 /**
335 * Returns SAFI.
336 *
337 * @return SAFI
338 */
339 public byte safi() {
340 return this.safi;
341 }
342
343 /**
344 * Returns AFI.
345 *
346 * @return AFI
347 */
348 public short afi() {
349 return this.afi;
350 }
351
352 /**
353 * Returns list of MpUnReach Nlri.
354 *
355 * @return list of MpUnReach Nlri
356 */
Shashikanth VH5dd8dbe2015-11-26 13:22:18 +0530357 public List<BgpLSNlri> mpUnReachNlri() {
Priyanka B3b695542015-10-14 17:16:27 +0530358 return this.mpUnReachNlri;
359 }
360
361 /**
362 * Returns whether MpReachNlri is present.
363 *
364 * @return whether MpReachNlri is present
365 */
366 public boolean isMpUnReachNlriSet() {
367 return this.isMpUnReachNlri;
368 }
369
370 /**
371 * Returns length of MpUnReach.
372 *
373 * @return length of MpUnReach
374 */
375 public int mpUnReachNlriLen() {
376 return this.length;
377 }
378
379 @Override
380 public int write(ChannelBuffer cb) {
Shashikanth VH510a8d82016-02-12 12:32:43 +0530381 int iLenStartIndex = cb.writerIndex();
382 if ((afi == Constants.AFI_FLOWSPEC_VALUE) && ((safi == Constants.SAFI_FLOWSPEC_VALUE) ||
383 (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) {
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530384 List<BgpValueType> flowSpec = bgpFlowSpecNlri.flowSpecComponents();
385 ListIterator<BgpValueType> listIterator = flowSpec.listIterator();
386 boolean isAllFlowTypesIdentical = true;
Shashikanth VH510a8d82016-02-12 12:32:43 +0530387
388 cb.writeByte(FLAGS);
389 cb.writeByte(MPUNREACHNLRI_TYPE);
390
391 int mpUnReachIndx = cb.writerIndex();
392 cb.writeShort(0);
393
394 cb.writeShort(afi);
395 cb.writeByte(safi);
396
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530397 if (bgpFlowSpecNlri.routeDistinguisher() != null) {
398 cb.writeLong(bgpFlowSpecNlri.routeDistinguisher().getRouteDistinguisher());
Shashikanth VH510a8d82016-02-12 12:32:43 +0530399 }
400
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530401 BgpValueType tlv1 = null;
402 if (listIterator.hasNext()) {
403 tlv1 = listIterator.next();
404 }
Shashikanth VH510a8d82016-02-12 12:32:43 +0530405 while (listIterator.hasNext()) {
406 BgpValueType tlv = listIterator.next();
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530407 if (tlv.getType() != tlv1.getType()) {
408 isAllFlowTypesIdentical = false;
Shashikanth VH510a8d82016-02-12 12:32:43 +0530409 break;
Shashikanth VH510a8d82016-02-12 12:32:43 +0530410 }
411 }
412
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530413 if (isAllFlowTypesIdentical) {
414 BgpFlowSpecNlri.updateBufferIdenticalFlowTypes(cb, bgpFlowSpecNlri());
Shashikanth VH510a8d82016-02-12 12:32:43 +0530415 } else {
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530416 BgpFlowSpecNlri.updateBufferNonIdenticalFlowTypes(cb, bgpFlowSpecNlri());
Shashikanth VH510a8d82016-02-12 12:32:43 +0530417 }
Shashikanth VH510a8d82016-02-12 12:32:43 +0530418 int fsNlriLen = cb.writerIndex() - mpUnReachIndx;
419 cb.setShort(mpUnReachIndx, (short) (fsNlriLen - 2));
Mohammad Shahid30fedc52017-08-09 11:49:40 +0530420 } else if ((afi == Constants.AFI_EVPN_VALUE)
421 && (safi == Constants.SAFI_EVPN_VALUE)) {
422
423 cb.writeByte(FLAGS);
424 cb.writeByte(MPUNREACHNLRI_TYPE);
425
426 int mpUnReachDataIndex = cb.writerIndex();
427 cb.writeShort(0);
428 cb.writeShort(afi);
429 cb.writeByte(safi);
430
431 for (BgpEvpnNlri element : evpnNlri) {
432 short routeType = element.getType();
433 switch (routeType) {
434 case Constants.BGP_EVPN_MAC_IP_ADVERTISEMENT:
435 cb.writeByte(element.getType());
436 int iSpecStartIndex = cb.writerIndex();
437 cb.writeByte(0);
438 BgpEvpnRouteType2Nlri macIpAdvNlri =
439 (BgpEvpnRouteType2Nlri) element
440 .getNlri();
441
442 macIpAdvNlri.write(cb);
443 cb.setByte(iSpecStartIndex, (short) (cb.writerIndex()
444 - iSpecStartIndex - 1));
445 break;
446 case Constants.BGP_EVPN_ETHERNET_AUTO_DISCOVERY:
447 break;
448 case Constants.BGP_EVPN_INCLUSIVE_MULTICASE_ETHERNET:
449 break;
450 case Constants.BGP_EVPN_ETHERNET_SEGMENT:
451 break;
452 default:
453 break;
454 }
455 }
456
457 int evpnNlriLen = cb.writerIndex() - mpUnReachDataIndex;
458 cb.setShort(mpUnReachDataIndex, (short) (evpnNlriLen - 2));
Shashikanth VH510a8d82016-02-12 12:32:43 +0530459 }
460
461 return cb.writerIndex() - iLenStartIndex;
Priyanka B3b695542015-10-14 17:16:27 +0530462 }
463
464 @Override
Priyanka B02040732015-11-29 11:30:29 +0530465 public int compareTo(Object o) {
466 // TODO Auto-generated method stub
467 return 0;
468 }
469
470 @Override
Priyanka B3b695542015-10-14 17:16:27 +0530471 public String toString() {
Shashikanth VH510a8d82016-02-12 12:32:43 +0530472 return MoreObjects.toStringHelper(getClass()).omitNullValues()
Priyanka B3b695542015-10-14 17:16:27 +0530473 .add("mpReachNlri", mpUnReachNlri)
Shashikanth VH26fd38a2016-04-26 18:11:37 +0530474 .add("bgpFlowSpecNlri", bgpFlowSpecNlri)
Priyanka B3b695542015-10-14 17:16:27 +0530475 .add("afi", afi)
476 .add("safi", safi)
477 .add("length", length)
478 .toString();
479 }
480}