[ONOS-4240] Support wide community optional path attribute
Change-Id: I667cf229b02c8bcb0d4defd953bcde1595d03802
Showing
7 changed files
with
186 additions
and
70 deletions
| ... | @@ -32,6 +32,7 @@ import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv; | ... | @@ -32,6 +32,7 @@ import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv; |
| 32 | import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv; | 32 | import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv; |
| 33 | import org.onosproject.bgpio.util.Validation; | 33 | import org.onosproject.bgpio.util.Validation; |
| 34 | import org.onosproject.bgpio.util.Constants; | 34 | import org.onosproject.bgpio.util.Constants; |
| 35 | +import org.onosproject.bgpio.types.RpdCapabilityTlv; | ||
| 35 | import org.slf4j.Logger; | 36 | import org.slf4j.Logger; |
| 36 | import org.slf4j.LoggerFactory; | 37 | import org.slf4j.LoggerFactory; |
| 37 | 38 | ||
| ... | @@ -256,26 +257,36 @@ public class BgpOpenMsgVer4 implements BgpOpenMsg { | ... | @@ -256,26 +257,36 @@ public class BgpOpenMsgVer4 implements BgpOpenMsg { |
| 256 | int as4Num = cb.readInt(); | 257 | int as4Num = cb.readInt(); |
| 257 | tlv = new FourOctetAsNumCapabilityTlv(as4Num); | 258 | tlv = new FourOctetAsNumCapabilityTlv(as4Num); |
| 258 | break; | 259 | break; |
| 260 | + case RpdCapabilityTlv.TYPE: | ||
| 261 | + log.debug("RpdCapability"); | ||
| 262 | + if (RpdCapabilityTlv.LENGTH != length) { | ||
| 263 | + throw new BgpParseException("Invalid length received for RpdCapability."); | ||
| 264 | + } | ||
| 265 | + if (length > cb.readableBytes()) { | ||
| 266 | + throw new BgpParseException("Four octet as num tlv length" | ||
| 267 | + + " is more than readableBytes."); | ||
| 268 | + } | ||
| 269 | + short rpdAfi = cb.readShort(); | ||
| 270 | + byte rpdAsafi = cb.readByte(); | ||
| 271 | + byte sendReceive = cb.readByte(); | ||
| 272 | + tlv = new RpdCapabilityTlv(sendReceive); | ||
| 273 | + break; | ||
| 274 | + | ||
| 259 | case MultiProtocolExtnCapabilityTlv.TYPE: | 275 | case MultiProtocolExtnCapabilityTlv.TYPE: |
| 260 | log.debug("MultiProtocolExtnCapabilityTlv"); | 276 | log.debug("MultiProtocolExtnCapabilityTlv"); |
| 261 | 277 | ||
| 278 | + if (MultiProtocolExtnCapabilityTlv.LENGTH != length) { | ||
| 279 | + throw new BgpParseException("Invalid length received for MultiProtocolExtnCapabilityTlv."); | ||
| 280 | + } | ||
| 281 | + | ||
| 262 | if (length > cb.readableBytes()) { | 282 | if (length > cb.readableBytes()) { |
| 263 | throw new BgpParseException("BGP LS tlv length is more than readableBytes."); | 283 | throw new BgpParseException("BGP LS tlv length is more than readableBytes."); |
| 264 | } | 284 | } |
| 265 | short afi = cb.readShort(); | 285 | short afi = cb.readShort(); |
| 266 | byte res = cb.readByte(); | 286 | byte res = cb.readByte(); |
| 267 | byte safi = cb.readByte(); | 287 | byte safi = cb.readByte(); |
| 268 | - if ((afi == Constants.AFI_FLOWSPEC_RPD_VALUE) && (safi == Constants.SAFI_FLOWSPEC_RPD_VALUE)) { | ||
| 269 | - if ((MultiProtocolExtnCapabilityTlv.LENGTH + 1) != length) { | ||
| 270 | - throw new BgpParseException("Invalid length received for MultiProtocolExtnCapabilityTlv."); | ||
| 271 | - } | ||
| 272 | - tlv = new MultiProtocolExtnCapabilityTlv(afi, res, safi, cb.readByte()); | ||
| 273 | - } else { | ||
| 274 | - if (MultiProtocolExtnCapabilityTlv.LENGTH != length) { | ||
| 275 | - throw new BgpParseException("Invalid length received for MultiProtocolExtnCapabilityTlv."); | ||
| 276 | - } | ||
| 277 | tlv = new MultiProtocolExtnCapabilityTlv(afi, res, safi); | 288 | tlv = new MultiProtocolExtnCapabilityTlv(afi, res, safi); |
| 278 | - } | 289 | + |
| 279 | break; | 290 | break; |
| 280 | default: | 291 | default: |
| 281 | log.debug("Warning: Unsupported TLV: " + type); | 292 | log.debug("Warning: Unsupported TLV: " + type); |
| ... | @@ -358,9 +369,7 @@ public class BgpOpenMsgVer4 implements BgpOpenMsg { | ... | @@ -358,9 +369,7 @@ public class BgpOpenMsgVer4 implements BgpOpenMsg { |
| 358 | 369 | ||
| 359 | if (this.isFlowSpecRpdCapabilityTlvSet) { | 370 | if (this.isFlowSpecRpdCapabilityTlvSet) { |
| 360 | BgpValueType tlv; | 371 | BgpValueType tlv; |
| 361 | - tlv = new MultiProtocolExtnCapabilityTlv(Constants.AFI_FLOWSPEC_RPD_VALUE, | 372 | + tlv = new RpdCapabilityTlv(Constants.RPD_CAPABILITY_SEND_VALUE); |
| 362 | - RES, Constants.SAFI_FLOWSPEC_RPD_VALUE, | ||
| 363 | - Constants.RPD_CAPABILITY_SEND_VALUE); | ||
| 364 | this.capabilityTlv.add(tlv); | 373 | this.capabilityTlv.add(tlv); |
| 365 | } | 374 | } |
| 366 | 375 | ... | ... |
| ... | @@ -36,6 +36,7 @@ import org.onosproject.bgpio.types.MpUnReachNlri; | ... | @@ -36,6 +36,7 @@ import org.onosproject.bgpio.types.MpUnReachNlri; |
| 36 | import org.onosproject.bgpio.util.UnSupportedAttribute; | 36 | import org.onosproject.bgpio.util.UnSupportedAttribute; |
| 37 | import org.onosproject.bgpio.util.Validation; | 37 | import org.onosproject.bgpio.util.Validation; |
| 38 | import org.onosproject.bgpio.util.Constants; | 38 | import org.onosproject.bgpio.util.Constants; |
| 39 | +import org.onosproject.bgpio.types.attr.WideCommunity; | ||
| 39 | import org.slf4j.Logger; | 40 | import org.slf4j.Logger; |
| 40 | import org.slf4j.LoggerFactory; | 41 | import org.slf4j.LoggerFactory; |
| 41 | 42 | ||
| ... | @@ -149,6 +150,9 @@ public class BgpPathAttributes { | ... | @@ -149,6 +150,9 @@ public class BgpPathAttributes { |
| 149 | case EXTENDED_COMMUNITY_TYPE: | 150 | case EXTENDED_COMMUNITY_TYPE: |
| 150 | pathAttribute = BgpExtendedCommunity.read(cb); | 151 | pathAttribute = BgpExtendedCommunity.read(cb); |
| 151 | break; | 152 | break; |
| 153 | + case WideCommunity.TYPE: | ||
| 154 | + pathAttribute = WideCommunity.read(cb); | ||
| 155 | + break; | ||
| 152 | default: | 156 | default: |
| 153 | //skip bytes for unsupported attribute types | 157 | //skip bytes for unsupported attribute types |
| 154 | UnSupportedAttribute.read(cb); | 158 | UnSupportedAttribute.read(cb); |
| ... | @@ -214,6 +218,10 @@ public class BgpPathAttributes { | ... | @@ -214,6 +218,10 @@ public class BgpPathAttributes { |
| 214 | BgpExtendedCommunity extendedCommunity = (BgpExtendedCommunity) attr; | 218 | BgpExtendedCommunity extendedCommunity = (BgpExtendedCommunity) attr; |
| 215 | extendedCommunity.write(cb); | 219 | extendedCommunity.write(cb); |
| 216 | break; | 220 | break; |
| 221 | + case WideCommunity.TYPE: | ||
| 222 | + WideCommunity wideCommunity = (WideCommunity) attr; | ||
| 223 | + wideCommunity.write(cb); | ||
| 224 | + break; | ||
| 217 | case MpReachNlri.MPREACHNLRI_TYPE: | 225 | case MpReachNlri.MPREACHNLRI_TYPE: |
| 218 | MpReachNlri mpReach = (MpReachNlri) attr; | 226 | MpReachNlri mpReach = (MpReachNlri) attr; |
| 219 | mpReach.write(cb); | 227 | mpReach.write(cb); | ... | ... |
| ... | @@ -19,7 +19,6 @@ import com.google.common.base.MoreObjects; | ... | @@ -19,7 +19,6 @@ import com.google.common.base.MoreObjects; |
| 19 | import org.jboss.netty.buffer.ChannelBuffer; | 19 | import org.jboss.netty.buffer.ChannelBuffer; |
| 20 | import org.slf4j.Logger; | 20 | import org.slf4j.Logger; |
| 21 | import org.slf4j.LoggerFactory; | 21 | import org.slf4j.LoggerFactory; |
| 22 | -import org.onosproject.bgpio.util.Constants; | ||
| 23 | 22 | ||
| 24 | import java.util.Objects; | 23 | import java.util.Objects; |
| 25 | 24 | ||
| ... | @@ -46,7 +45,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { | ... | @@ -46,7 +45,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { |
| 46 | private final short afi; | 45 | private final short afi; |
| 47 | private final byte res; | 46 | private final byte res; |
| 48 | private final byte safi; | 47 | private final byte safi; |
| 49 | - private final byte rpdSendReceive; | ||
| 50 | 48 | ||
| 51 | /** | 49 | /** |
| 52 | * Constructor to initialize variables. | 50 | * Constructor to initialize variables. |
| ... | @@ -58,24 +56,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { | ... | @@ -58,24 +56,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { |
| 58 | this.afi = afi; | 56 | this.afi = afi; |
| 59 | this.res = res; | 57 | this.res = res; |
| 60 | this.safi = safi; | 58 | this.safi = safi; |
| 61 | - this.rpdSendReceive = Constants.RPD_CAPABILITY_SEND_VALUE; | ||
| 62 | - } | ||
| 63 | - | ||
| 64 | - /** | ||
| 65 | - * Constructor to initialize variables. | ||
| 66 | - * @param afi Address Family Identifiers | ||
| 67 | - * @param res reserved field | ||
| 68 | - * @param safi Subsequent Address Family Identifier | ||
| 69 | - * @param rpdSendReceive indicates whether the sender is | ||
| 70 | - (a) willing to receive Route Policies via BGP FLowSpec from its peer (value 1). | ||
| 71 | - (b) would like to send Route Policies via BGP FLowSpec to its peer (value 2). | ||
| 72 | - (c) both (value 3). | ||
| 73 | - */ | ||
| 74 | - public MultiProtocolExtnCapabilityTlv(short afi, byte res, byte safi, byte rpdSendReceive) { | ||
| 75 | - this.afi = afi; | ||
| 76 | - this.res = res; | ||
| 77 | - this.safi = safi; | ||
| 78 | - this.rpdSendReceive = rpdSendReceive; | ||
| 79 | } | 59 | } |
| 80 | 60 | ||
| 81 | /** | 61 | /** |
| ... | @@ -140,16 +120,9 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { | ... | @@ -140,16 +120,9 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { |
| 140 | 120 | ||
| 141 | @Override | 121 | @Override |
| 142 | public int write(ChannelBuffer cb) { | 122 | public int write(ChannelBuffer cb) { |
| 143 | - boolean isFsRpd = false; | ||
| 144 | int iLenStartIndex = cb.writerIndex(); | 123 | int iLenStartIndex = cb.writerIndex(); |
| 145 | cb.writeByte(TYPE); | 124 | cb.writeByte(TYPE); |
| 146 | - | ||
| 147 | - if ((afi == Constants.AFI_FLOWSPEC_RPD_VALUE) && (safi == Constants.SAFI_FLOWSPEC_RPD_VALUE)) { | ||
| 148 | - cb.writeByte(LENGTH + 1); | ||
| 149 | - isFsRpd = true; | ||
| 150 | - } else { | ||
| 151 | cb.writeByte(LENGTH); | 125 | cb.writeByte(LENGTH); |
| 152 | - } | ||
| 153 | 126 | ||
| 154 | // write afi | 127 | // write afi |
| 155 | cb.writeShort(afi); | 128 | cb.writeShort(afi); |
| ... | @@ -160,11 +133,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { | ... | @@ -160,11 +133,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { |
| 160 | // write safi | 133 | // write safi |
| 161 | cb.writeByte(safi); | 134 | cb.writeByte(safi); |
| 162 | 135 | ||
| 163 | - if (isFsRpd) { | ||
| 164 | - // write Send/Receive (1 octet) | ||
| 165 | - cb.writeByte(rpdSendReceive); | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | return cb.writerIndex() - iLenStartIndex; | 136 | return cb.writerIndex() - iLenStartIndex; |
| 169 | } | 137 | } |
| 170 | 138 | ||
| ... | @@ -177,10 +145,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { | ... | @@ -177,10 +145,6 @@ public class MultiProtocolExtnCapabilityTlv implements BgpValueType { |
| 177 | short afi = cb.readShort(); | 145 | short afi = cb.readShort(); |
| 178 | byte res = cb.readByte(); | 146 | byte res = cb.readByte(); |
| 179 | byte safi = cb.readByte(); | 147 | byte safi = cb.readByte(); |
| 180 | - | ||
| 181 | - if ((afi == Constants.AFI_FLOWSPEC_RPD_VALUE) && (safi == Constants.SAFI_FLOWSPEC_RPD_VALUE)) { | ||
| 182 | - return new MultiProtocolExtnCapabilityTlv(afi, res, safi, cb.readByte()); | ||
| 183 | - } | ||
| 184 | return new MultiProtocolExtnCapabilityTlv(afi, res, safi); | 148 | return new MultiProtocolExtnCapabilityTlv(afi, res, safi); |
| 185 | } | 149 | } |
| 186 | 150 | ... | ... |
| 1 | +/* | ||
| 2 | + * Copyright 2016-present Open Networking Laboratory | ||
| 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.bgpio.types; | ||
| 17 | + | ||
| 18 | +import java.util.Objects; | ||
| 19 | + | ||
| 20 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
| 21 | +import org.onosproject.bgpio.util.Constants; | ||
| 22 | +import org.slf4j.Logger; | ||
| 23 | +import org.slf4j.LoggerFactory; | ||
| 24 | + | ||
| 25 | +import com.google.common.base.MoreObjects; | ||
| 26 | + | ||
| 27 | +/** | ||
| 28 | + * Provides implementation of BGP route policy distribution capability tlv. | ||
| 29 | + */ | ||
| 30 | +public class RpdCapabilityTlv implements BgpValueType { | ||
| 31 | + | ||
| 32 | + protected static final Logger log = LoggerFactory | ||
| 33 | + .getLogger(RpdCapabilityTlv.class); | ||
| 34 | + | ||
| 35 | + public static final byte TYPE = (byte) 129; | ||
| 36 | + public static final byte LENGTH = 4; | ||
| 37 | + private short afi = Constants.AFI_FLOWSPEC_RPD_VALUE; | ||
| 38 | + private byte sAfi = Constants.SAFI_FLOWSPEC_RPD_VALUE; | ||
| 39 | + | ||
| 40 | + private final byte sendReceive; | ||
| 41 | + | ||
| 42 | + /** | ||
| 43 | + * Creates instance of route policy distribution capability. | ||
| 44 | + * @param sendReceive value indicate wherether flow route is only for receive or send or both. | ||
| 45 | + */ | ||
| 46 | + public RpdCapabilityTlv(byte sendReceive) { | ||
| 47 | + this.sendReceive = sendReceive; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + /** | ||
| 51 | + * Creates instance of RpdCapabilityTlv. | ||
| 52 | + * @param sendReceive value indicate wherether flow route is only for receive or send or both. | ||
| 53 | + * @return object of RpdCapabilityTlv | ||
| 54 | + */ | ||
| 55 | + public static RpdCapabilityTlv of(final byte sendReceive) { | ||
| 56 | + return new RpdCapabilityTlv(sendReceive); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + /** | ||
| 60 | + * Returns value of send receive field of route policy distribution capability. | ||
| 61 | + * @return send receive value of route policy distribution capability | ||
| 62 | + */ | ||
| 63 | + public byte sendReceive() { | ||
| 64 | + return sendReceive; | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | + @Override | ||
| 68 | + public short getType() { | ||
| 69 | + return TYPE; | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public int hashCode() { | ||
| 74 | + return Objects.hash(sendReceive); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public boolean equals(Object obj) { | ||
| 79 | + if (this == obj) { | ||
| 80 | + return true; | ||
| 81 | + } | ||
| 82 | + if (obj instanceof RpdCapabilityTlv) { | ||
| 83 | + RpdCapabilityTlv other = (RpdCapabilityTlv) obj; | ||
| 84 | + return Objects.equals(sendReceive, other.sendReceive); | ||
| 85 | + } | ||
| 86 | + return false; | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + @Override | ||
| 90 | + public int write(ChannelBuffer cb) { | ||
| 91 | + int iLenStartIndex = cb.writerIndex(); | ||
| 92 | + cb.writeByte(TYPE); | ||
| 93 | + cb.writeByte(LENGTH); | ||
| 94 | + cb.writeShort(afi); | ||
| 95 | + cb.writeByte(sAfi); | ||
| 96 | + cb.writeByte(sendReceive); | ||
| 97 | + return cb.writerIndex() - iLenStartIndex; | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + /** | ||
| 101 | + * Reads the channel buffer and returns object of RpdCapabilityTlv. | ||
| 102 | + * @param cb type of channel buffer | ||
| 103 | + * @return object of RpdCapabilityTlv | ||
| 104 | + */ | ||
| 105 | + public static RpdCapabilityTlv read(ChannelBuffer cb) { | ||
| 106 | + short afi = cb.readShort(); | ||
| 107 | + byte sAfi = cb.readByte(); | ||
| 108 | + return RpdCapabilityTlv.of(cb.readByte()); | ||
| 109 | + } | ||
| 110 | + | ||
| 111 | + @Override | ||
| 112 | + public String toString() { | ||
| 113 | + return MoreObjects.toStringHelper(getClass()) | ||
| 114 | + .add("Type", TYPE) | ||
| 115 | + .add("Length", LENGTH) | ||
| 116 | + .add("afi", afi) | ||
| 117 | + .add("safi", sAfi) | ||
| 118 | + .add("sendReceive", sendReceive).toString(); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + @Override | ||
| 122 | + public int compareTo(Object o) { | ||
| 123 | + // TODO Auto-generated method stub | ||
| 124 | + return 0; | ||
| 125 | + } | ||
| 126 | +} |
| ... | @@ -43,8 +43,8 @@ public final class Constants { | ... | @@ -43,8 +43,8 @@ public final class Constants { |
| 43 | /* TODO: The Capability Code | 43 | /* TODO: The Capability Code |
| 44 | for this capability is to be specified by the IANA.*/ | 44 | for this capability is to be specified by the IANA.*/ |
| 45 | public static final short AFI_FLOWSPEC_RPD_VALUE = 1; | 45 | public static final short AFI_FLOWSPEC_RPD_VALUE = 1; |
| 46 | - public static final byte SAFI_FLOWSPEC_RPD_VALUE = (byte) 200; | 46 | + public static final byte SAFI_FLOWSPEC_RPD_VALUE = (byte) 133; |
| 47 | - public static final byte VPN_SAFI_FLOWSPEC_RDP_VALUE = (byte) 201; | 47 | + public static final byte VPN_SAFI_FLOWSPEC_RDP_VALUE = (byte) 134; |
| 48 | 48 | ||
| 49 | public static final byte RPD_CAPABILITY_RECEIVE_VALUE = 0; | 49 | public static final byte RPD_CAPABILITY_RECEIVE_VALUE = 0; |
| 50 | public static final byte RPD_CAPABILITY_SEND_VALUE = 1; | 50 | public static final byte RPD_CAPABILITY_SEND_VALUE = 1; | ... | ... |
| ... | @@ -316,11 +316,12 @@ public class BgpOpenMsgTest { | ... | @@ -316,11 +316,12 @@ public class BgpOpenMsgTest { |
| 316 | // OPEN Message with capabilities. | 316 | // OPEN Message with capabilities. |
| 317 | byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, | 317 | byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 318 | (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, | 318 | (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 319 | - (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x00, 0x38, 0x01, 0x04, 0x00, | 319 | + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 320 | - 0x64, 0x00, (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x07, 0x35, 0x1b, 0x02, 0x19, | 320 | + 0x00, 0x3d, 0x01, 0x04, 0x00, (byte) 0xc8, 0x00, (byte) 0xb4, (byte) 0xc0, |
| 321 | - 0x01, 0x04, 0x00, 0x01, 0x00, 0x01, 0x01, 0x04, 0x40, 0x04, 0x00, 0x47, 0x01, | 321 | + (byte) 0xa8, 0x07, 0x35, 0x20, 0x02, 0x1e, 0x01, |
| 322 | - 0x04, 0x00, 0x01, 0x00, (byte) 0x85, 0x01, 0x05, 0x00, 0x01, 0x00, (byte) 0xc8, | 322 | + 0x04, 00, 0x01, 0x00, 0x01, 0x41, 0x04, 0x00, 0x00, 0x00, (byte) 0xc8, 0x01, |
| 323 | - 0x00 }; // Four Octet AS Number-CAPABILITY-TLV | 323 | + 0x04, 0x40, 0x04, 0x00, 0x47, 0x01, 0x04, 0x00, 0x01, 0x00, (byte) 0x85, |
| 324 | + (byte) 0x81, 0x04, 0x00, 0x01, (byte) 0x85, 0x01 }; //RPD capability | ||
| 324 | 325 | ||
| 325 | byte[] testOpenMsg; | 326 | byte[] testOpenMsg; |
| 326 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); | 327 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| ... | @@ -353,11 +354,12 @@ public class BgpOpenMsgTest { | ... | @@ -353,11 +354,12 @@ public class BgpOpenMsgTest { |
| 353 | // OPEN Message with invalid message type. | 354 | // OPEN Message with invalid message type. |
| 354 | byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, | 355 | byte[] openMsg = new byte[] {(byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 355 | (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, | 356 | (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 356 | - (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, 0x00, 0x38, 0x01, 0x04, 0x00, | 357 | + (byte) 0xff, (byte) 0xff, (byte) 0xff, (byte) 0xff, |
| 357 | - 0x64, 0x00, (byte) 0xb4, (byte) 0xc0, (byte) 0xa8, 0x07, 0x35, 0x1b, 0x02, 0x19, | 358 | + 0x00, 0x3d, 0x01, 0x04, 0x00, (byte) 0xc8, 0x00, (byte) 0xb4, (byte) 0xc0, |
| 358 | - 0x01, 0x04, 0x00, 0x01, 0x00, 0x01, 0x01, 0x04, 0x40, 0x04, 0x00, 0x47, 0x01, | 359 | + (byte) 0xa8, 0x07, 0x35, 0x20, 0x02, 0x1e, 0x01, 0x04, 00, 0x01, 0x00, 0x01, 0x41, |
| 359 | - 0x04, 0x00, 0x01, 0x00, (byte) 0x85, 0x01, 0x04, 0x00, 0x01, 0x00, (byte) 0xc8, | 360 | + 0x04, 0x00, 0x00, 0x00, (byte) 0xc8, 0x01, 0x04, 0x40, 0x04, 0x00, |
| 360 | - 0x00 }; | 361 | + 0x47, 0x01, 0x04, 0x00, 0x01, 0x00, (byte) 0x85, |
| 362 | + (byte) 0x81, 0x05, 0x00, 0x01, (byte) 0x85, 0x01 }; //RPD capability | ||
| 361 | 363 | ||
| 362 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); | 364 | ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); |
| 363 | buffer.writeBytes(openMsg); | 365 | buffer.writeBytes(openMsg); | ... | ... |
| ... | @@ -44,6 +44,7 @@ import org.onosproject.bgpio.types.BgpErrorType; | ... | @@ -44,6 +44,7 @@ import org.onosproject.bgpio.types.BgpErrorType; |
| 44 | import org.onosproject.bgpio.types.BgpValueType; | 44 | import org.onosproject.bgpio.types.BgpValueType; |
| 45 | import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv; | 45 | import org.onosproject.bgpio.types.FourOctetAsNumCapabilityTlv; |
| 46 | import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv; | 46 | import org.onosproject.bgpio.types.MultiProtocolExtnCapabilityTlv; |
| 47 | +import org.onosproject.bgpio.types.RpdCapabilityTlv; | ||
| 47 | import org.onosproject.bgpio.util.Constants; | 48 | import org.onosproject.bgpio.util.Constants; |
| 48 | import org.slf4j.Logger; | 49 | import org.slf4j.Logger; |
| 49 | import org.slf4j.LoggerFactory; | 50 | import org.slf4j.LoggerFactory; |
| ... | @@ -784,7 +785,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -784,7 +785,9 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { |
| 784 | log.debug("capabilityValidation"); | 785 | log.debug("capabilityValidation"); |
| 785 | 786 | ||
| 786 | boolean isFourOctetCapabilityExits = false; | 787 | boolean isFourOctetCapabilityExits = false; |
| 788 | + boolean isRpdCapabilityExits = false; | ||
| 787 | int capAsNum = 0; | 789 | int capAsNum = 0; |
| 790 | + byte sendReceive = 0; | ||
| 788 | 791 | ||
| 789 | List<BgpValueType> capabilityTlv = openmsg.getCapabilityTlv(); | 792 | List<BgpValueType> capabilityTlv = openmsg.getCapabilityTlv(); |
| 790 | ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator(); | 793 | ListIterator<BgpValueType> listIterator = capabilityTlv.listIterator(); |
| ... | @@ -798,7 +801,6 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -798,7 +801,6 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { |
| 798 | boolean isFlowSpecVpnv4CapabilityCfg = false; | 801 | boolean isFlowSpecVpnv4CapabilityCfg = false; |
| 799 | MultiProtocolExtnCapabilityTlv tempCapability; | 802 | MultiProtocolExtnCapabilityTlv tempCapability; |
| 800 | boolean isMultiProtocolLsCapability = false; | 803 | boolean isMultiProtocolLsCapability = false; |
| 801 | - boolean isMultiProtocolFlowSpecRpdCapability = false; | ||
| 802 | boolean isMultiProtocolFlowSpecCapability = false; | 804 | boolean isMultiProtocolFlowSpecCapability = false; |
| 803 | boolean isMultiProtocolVpnFlowSpecCapability = false; | 805 | boolean isMultiProtocolVpnFlowSpecCapability = false; |
| 804 | BgpCfg.FlowSpec flowSpec = h.bgpconfig.flowSpecCapability(); | 806 | BgpCfg.FlowSpec flowSpec = h.bgpconfig.flowSpecCapability(); |
| ... | @@ -827,15 +829,16 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -827,15 +829,16 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { |
| 827 | if (SAFI == tempCapability.getSafi()) { | 829 | if (SAFI == tempCapability.getSafi()) { |
| 828 | isMultiProtocolLsCapability = true; | 830 | isMultiProtocolLsCapability = true; |
| 829 | } | 831 | } |
| 830 | - | ||
| 831 | - if (Constants.SAFI_FLOWSPEC_RPD_VALUE == tempCapability.getSafi()) { | ||
| 832 | - isMultiProtocolFlowSpecRpdCapability = true; | ||
| 833 | - } | ||
| 834 | } | 832 | } |
| 835 | if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) { | 833 | if (tlv.getType() == FOUR_OCTET_AS_NUM_CAPA_TYPE) { |
| 836 | isFourOctetCapabilityExits = true; | 834 | isFourOctetCapabilityExits = true; |
| 837 | capAsNum = ((FourOctetAsNumCapabilityTlv) tlv).getInt(); | 835 | capAsNum = ((FourOctetAsNumCapabilityTlv) tlv).getInt(); |
| 838 | } | 836 | } |
| 837 | + | ||
| 838 | + if (tlv.getType() == RpdCapabilityTlv.TYPE) { | ||
| 839 | + isRpdCapabilityExits = true; | ||
| 840 | + sendReceive = ((RpdCapabilityTlv) tlv).sendReceive(); | ||
| 841 | + } | ||
| 839 | } | 842 | } |
| 840 | 843 | ||
| 841 | if (isFourOctetCapabilityExits) { | 844 | if (isFourOctetCapabilityExits) { |
| ... | @@ -850,6 +853,12 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -850,6 +853,12 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { |
| 850 | } | 853 | } |
| 851 | } | 854 | } |
| 852 | 855 | ||
| 856 | + if (isRpdCapabilityExits) { | ||
| 857 | + if (sendReceive > 2) { | ||
| 858 | + throw new BgpParseException(BgpErrorType.OPEN_MESSAGE_ERROR, BgpErrorType.UNSUPPORTED_CAPABILITY, null); | ||
| 859 | + } | ||
| 860 | + } | ||
| 861 | + | ||
| 853 | if ((isLsCapabilityCfg)) { | 862 | if ((isLsCapabilityCfg)) { |
| 854 | if (!isMultiProtocolLsCapability) { | 863 | if (!isMultiProtocolLsCapability) { |
| 855 | tempTlv = new MultiProtocolExtnCapabilityTlv(AFI, RES, SAFI); | 864 | tempTlv = new MultiProtocolExtnCapabilityTlv(AFI, RES, SAFI); |
| ... | @@ -881,10 +890,8 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -881,10 +890,8 @@ class BgpChannelHandler extends IdleStateAwareChannelHandler { |
| 881 | } | 890 | } |
| 882 | 891 | ||
| 883 | if ((isFlowSpecRpdCapabilityCfg)) { | 892 | if ((isFlowSpecRpdCapabilityCfg)) { |
| 884 | - if (!isMultiProtocolFlowSpecRpdCapability) { | 893 | + if (!isRpdCapabilityExits) { |
| 885 | - tempTlv = new MultiProtocolExtnCapabilityTlv(Constants.AFI_FLOWSPEC_RPD_VALUE, | 894 | + tempTlv = new RpdCapabilityTlv(Constants.RPD_CAPABILITY_SEND_VALUE); |
| 886 | - RES, Constants.SAFI_FLOWSPEC_RPD_VALUE, | ||
| 887 | - Constants.RPD_CAPABILITY_SEND_VALUE); | ||
| 888 | unSupportedCapabilityTlv.add(tempTlv); | 895 | unSupportedCapabilityTlv.add(tempTlv); |
| 889 | } | 896 | } |
| 890 | } | 897 | } | ... | ... |
-
Please register or login to post a comment