Committed by
Gerrit Code Review
[onos-2603] - Implement LinkState tag attributes
Change-Id: I674197405a57a8a45a2939e364c59c4565ad756f
Showing
1 changed file
with
22 additions
and
11 deletions
| ... | @@ -15,7 +15,8 @@ | ... | @@ -15,7 +15,8 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.bgpio.types.attr; | 16 | package org.onosproject.bgpio.types.attr; |
| 17 | 17 | ||
| 18 | -import java.util.Arrays; | 18 | +import java.util.ArrayList; |
| 19 | +import java.util.List; | ||
| 19 | import java.util.Objects; | 20 | import java.util.Objects; |
| 20 | 21 | ||
| 21 | import org.jboss.netty.buffer.ChannelBuffer; | 22 | import org.jboss.netty.buffer.ChannelBuffer; |
| ... | @@ -36,18 +37,28 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { | ... | @@ -36,18 +37,28 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { |
| 36 | protected static final Logger log = LoggerFactory | 37 | protected static final Logger log = LoggerFactory |
| 37 | .getLogger(BgpPrefixAttrRouteTag.class); | 38 | .getLogger(BgpPrefixAttrRouteTag.class); |
| 38 | 39 | ||
| 39 | - public static final int ATTR_PREFIX_ROUTETAG = 1153; | 40 | + public static final short ATTR_PREFIX_ROUTETAG = 1153; |
| 40 | 41 | ||
| 41 | /* Prefix Route Tag */ | 42 | /* Prefix Route Tag */ |
| 42 | - private int[] pfxRouteTag; | 43 | + private List<Integer> pfxRouteTag = new ArrayList<Integer>(); |
| 43 | 44 | ||
| 44 | /** | 45 | /** |
| 45 | * Constructor to initialize the values. | 46 | * Constructor to initialize the values. |
| 46 | * | 47 | * |
| 47 | * @param pfxRouteTag prefix route tag | 48 | * @param pfxRouteTag prefix route tag |
| 48 | */ | 49 | */ |
| 49 | - BgpPrefixAttrRouteTag(int[] pfxRouteTag) { | 50 | + public BgpPrefixAttrRouteTag(List<Integer> pfxRouteTag) { |
| 50 | - this.pfxRouteTag = Arrays.copyOf(pfxRouteTag, pfxRouteTag.length); | 51 | + this.pfxRouteTag = pfxRouteTag; |
| 52 | + } | ||
| 53 | + | ||
| 54 | + /** | ||
| 55 | + * Returns object of this class with specified values. | ||
| 56 | + * | ||
| 57 | + * @param pfxRouteTag Prefix Metric | ||
| 58 | + * @return object of BgpPrefixAttrRouteTag | ||
| 59 | + */ | ||
| 60 | + public static BgpPrefixAttrRouteTag of(ArrayList<Integer> pfxRouteTag) { | ||
| 61 | + return new BgpPrefixAttrRouteTag(pfxRouteTag); | ||
| 51 | } | 62 | } |
| 52 | 63 | ||
| 53 | /** | 64 | /** |
| ... | @@ -59,7 +70,8 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { | ... | @@ -59,7 +70,8 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { |
| 59 | */ | 70 | */ |
| 60 | public static BgpPrefixAttrRouteTag read(ChannelBuffer cb) | 71 | public static BgpPrefixAttrRouteTag read(ChannelBuffer cb) |
| 61 | throws BGPParseException { | 72 | throws BGPParseException { |
| 62 | - int[] pfxRouteTag; | 73 | + int tmp; |
| 74 | + ArrayList<Integer> pfxRouteTag = new ArrayList<Integer>(); | ||
| 63 | 75 | ||
| 64 | short lsAttrLength = cb.readShort(); | 76 | short lsAttrLength = cb.readShort(); |
| 65 | int len = lsAttrLength / Integer.SIZE; | 77 | int len = lsAttrLength / Integer.SIZE; |
| ... | @@ -70,13 +82,12 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { | ... | @@ -70,13 +82,12 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { |
| 70 | lsAttrLength); | 82 | lsAttrLength); |
| 71 | } | 83 | } |
| 72 | 84 | ||
| 73 | - pfxRouteTag = new int[lsAttrLength]; | ||
| 74 | - | ||
| 75 | for (int i = 0; i < len; i++) { | 85 | for (int i = 0; i < len; i++) { |
| 76 | - pfxRouteTag[i] = cb.readInt(); | 86 | + tmp = cb.readInt(); |
| 87 | + pfxRouteTag.add(new Integer(tmp)); | ||
| 77 | } | 88 | } |
| 78 | 89 | ||
| 79 | - return new BgpPrefixAttrRouteTag(pfxRouteTag); | 90 | + return BgpPrefixAttrRouteTag.of(pfxRouteTag); |
| 80 | } | 91 | } |
| 81 | 92 | ||
| 82 | /** | 93 | /** |
| ... | @@ -84,7 +95,7 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { | ... | @@ -84,7 +95,7 @@ public class BgpPrefixAttrRouteTag implements BGPValueType { |
| 84 | * | 95 | * |
| 85 | * @return route tag | 96 | * @return route tag |
| 86 | */ | 97 | */ |
| 87 | - int[] getPfxRouteTag() { | 98 | + public List<Integer> getPfxRouteTag() { |
| 88 | return pfxRouteTag; | 99 | return pfxRouteTag; |
| 89 | } | 100 | } |
| 90 | 101 | ... | ... |
-
Please register or login to post a comment