Committed by
Gerrit Code Review
[onos-2603] - Implements BgpLinkAttrUnRsrvdLinkBandwidth
Change-Id: I335c593c88fb63317079204ab10f8fe808901431
Showing
1 changed file
with
23 additions
and
10 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; |
... | @@ -43,7 +44,7 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { | ... | @@ -43,7 +44,7 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { |
43 | public short sType; | 44 | public short sType; |
44 | 45 | ||
45 | /* ISIS administrative group */ | 46 | /* ISIS administrative group */ |
46 | - private float[] maxUnResBandwidth; | 47 | + private List<Float> maxUnResBandwidth = new ArrayList<Float>(); |
47 | 48 | ||
48 | /** | 49 | /** |
49 | * Constructor to initialize the values. | 50 | * Constructor to initialize the values. |
... | @@ -51,13 +52,24 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { | ... | @@ -51,13 +52,24 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { |
51 | * @param maxUnResBandwidth Maximum Unreserved bandwidth | 52 | * @param maxUnResBandwidth Maximum Unreserved bandwidth |
52 | * @param sType returns the tag value | 53 | * @param sType returns the tag value |
53 | */ | 54 | */ |
54 | - BgpLinkAttrUnRsrvdLinkBandwidth(float[] maxUnResBandwidth, short sType) { | 55 | + public BgpLinkAttrUnRsrvdLinkBandwidth(List<Float> maxUnResBandwidth, |
55 | - this.maxUnResBandwidth = Arrays.copyOf(maxUnResBandwidth, | 56 | + short sType) { |
56 | - maxUnResBandwidth.length); | 57 | + this.maxUnResBandwidth = maxUnResBandwidth; |
57 | this.sType = sType; | 58 | this.sType = sType; |
58 | } | 59 | } |
59 | 60 | ||
60 | /** | 61 | /** |
62 | + * Returns object of this class with specified values. | ||
63 | + * | ||
64 | + * @param linkPfxMetric Prefix Metric | ||
65 | + * @param sType returns the tag value | ||
66 | + * @return object of BgpLinkAttrUnRsrvdLinkBandwidth | ||
67 | + */ | ||
68 | + public static BgpLinkAttrUnRsrvdLinkBandwidth of(List<Float> linkPfxMetric, short sType) { | ||
69 | + return new BgpLinkAttrUnRsrvdLinkBandwidth(linkPfxMetric, sType); | ||
70 | + } | ||
71 | + | ||
72 | + /** | ||
61 | * Reads the BGP link attributes of Maximum link bandwidth. | 73 | * Reads the BGP link attributes of Maximum link bandwidth. |
62 | * | 74 | * |
63 | * @param cb Channel buffer | 75 | * @param cb Channel buffer |
... | @@ -67,7 +79,8 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { | ... | @@ -67,7 +79,8 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { |
67 | public static BgpLinkAttrUnRsrvdLinkBandwidth read(ChannelBuffer cb, | 79 | public static BgpLinkAttrUnRsrvdLinkBandwidth read(ChannelBuffer cb, |
68 | short sType) | 80 | short sType) |
69 | throws BGPParseException { | 81 | throws BGPParseException { |
70 | - float[] maxUnResBandwidth; | 82 | + ArrayList<Float> maxUnResBandwidth = new ArrayList<Float>(); |
83 | + float tmp; | ||
71 | short lsAttrLength = cb.readShort(); | 84 | short lsAttrLength = cb.readShort(); |
72 | 85 | ||
73 | if ((lsAttrLength != MAX_BANDWIDTH_LEN * NO_OF_PRIORITY) | 86 | if ((lsAttrLength != MAX_BANDWIDTH_LEN * NO_OF_PRIORITY) |
... | @@ -77,12 +90,12 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { | ... | @@ -77,12 +90,12 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { |
77 | lsAttrLength); | 90 | lsAttrLength); |
78 | } | 91 | } |
79 | 92 | ||
80 | - maxUnResBandwidth = new float[NO_OF_PRIORITY]; | ||
81 | for (int i = 0; i < NO_OF_PRIORITY; i++) { | 93 | for (int i = 0; i < NO_OF_PRIORITY; i++) { |
82 | - maxUnResBandwidth[i] = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS; | 94 | + tmp = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS; |
95 | + maxUnResBandwidth.add(new Float(tmp)); | ||
83 | } | 96 | } |
84 | 97 | ||
85 | - return new BgpLinkAttrUnRsrvdLinkBandwidth(maxUnResBandwidth, sType); | 98 | + return BgpLinkAttrUnRsrvdLinkBandwidth.of(maxUnResBandwidth, sType); |
86 | } | 99 | } |
87 | 100 | ||
88 | /** | 101 | /** |
... | @@ -90,7 +103,7 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { | ... | @@ -90,7 +103,7 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BGPValueType { |
90 | * | 103 | * |
91 | * @return unreserved bandwidth. | 104 | * @return unreserved bandwidth. |
92 | */ | 105 | */ |
93 | - float[] getLinkAttrUnRsrvdLinkBandwidth() { | 106 | + public List<Float> getLinkAttrUnRsrvdLinkBandwidth() { |
94 | return maxUnResBandwidth; | 107 | return maxUnResBandwidth; |
95 | } | 108 | } |
96 | 109 | ... | ... |
-
Please register or login to post a comment