Committed by
Gerrit Code Review
[onos-2603] - Multi-Topology ID
Change-Id: I59f9f01ad7d1acc56e16dd8115caf5b53b4a8a3c
Showing
1 changed file
with
21 additions
and
11 deletions
... | @@ -13,9 +13,10 @@ | ... | @@ -13,9 +13,10 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | - | ||
17 | package org.onosproject.bgpio.types.attr; | 16 | package org.onosproject.bgpio.types.attr; |
18 | 17 | ||
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; |
... | @@ -39,18 +40,28 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { | ... | @@ -39,18 +40,28 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { |
39 | public static final int ATTRNODE_MULTITOPOLOGY = 263; | 40 | public static final int ATTRNODE_MULTITOPOLOGY = 263; |
40 | 41 | ||
41 | /* Opaque Node Attribute */ | 42 | /* Opaque Node Attribute */ |
42 | - private short[] multiTopologyId; | 43 | + private List<Short> multiTopologyId = new ArrayList<Short>(); |
43 | 44 | ||
44 | /** | 45 | /** |
45 | * Constructor to initialize the Node attribute multi-topology ID. | 46 | * Constructor to initialize the Node attribute multi-topology ID. |
46 | * | 47 | * |
47 | * @param multiTopologyId multi-topology ID | 48 | * @param multiTopologyId multi-topology ID |
48 | */ | 49 | */ |
49 | - BgpAttrNodeMultiTopologyId(short[] multiTopologyId) { | 50 | + public BgpAttrNodeMultiTopologyId(List<Short> multiTopologyId) { |
50 | this.multiTopologyId = multiTopologyId; | 51 | this.multiTopologyId = multiTopologyId; |
51 | } | 52 | } |
52 | 53 | ||
53 | /** | 54 | /** |
55 | + * Returns object of this class with specified values. | ||
56 | + * | ||
57 | + * @param multiTopologyId Prefix Metric | ||
58 | + * @return object of BgpAttrNodeMultiTopologyId | ||
59 | + */ | ||
60 | + public static BgpAttrNodeMultiTopologyId of(ArrayList<Short> multiTopologyId) { | ||
61 | + return new BgpAttrNodeMultiTopologyId(multiTopologyId); | ||
62 | + } | ||
63 | + | ||
64 | + /** | ||
54 | * Reads the Multi-topology ID of Node attribute. | 65 | * Reads the Multi-topology ID of Node attribute. |
55 | * | 66 | * |
56 | * @param cb ChannelBuffer | 67 | * @param cb ChannelBuffer |
... | @@ -59,21 +70,20 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { | ... | @@ -59,21 +70,20 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { |
59 | */ | 70 | */ |
60 | public static BgpAttrNodeMultiTopologyId read(ChannelBuffer cb) | 71 | public static BgpAttrNodeMultiTopologyId read(ChannelBuffer cb) |
61 | throws BGPParseException { | 72 | throws BGPParseException { |
62 | - | 73 | + ArrayList<Short> multiTopologyId = new ArrayList<Short>(); |
63 | - log.debug("BgpAttrNodeMultiTopologyId"); | 74 | + short tempMultiTopologyId; |
64 | short lsAttrLength = cb.readShort(); | 75 | short lsAttrLength = cb.readShort(); |
65 | int len = lsAttrLength / 2; // Length is 2*n and n is the number of MT-IDs | 76 | int len = lsAttrLength / 2; // Length is 2*n and n is the number of MT-IDs |
66 | 77 | ||
67 | if (cb.readableBytes() < lsAttrLength) { | 78 | if (cb.readableBytes() < lsAttrLength) { |
68 | Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, | 79 | Validation.validateLen(BGPErrorType.UPDATE_MESSAGE_ERROR, |
69 | BGPErrorType.ATTRIBUTE_LENGTH_ERROR, | 80 | BGPErrorType.ATTRIBUTE_LENGTH_ERROR, |
70 | - cb.readableBytes()); | 81 | + lsAttrLength); |
71 | } | 82 | } |
72 | 83 | ||
73 | - short[] multiTopologyId; | ||
74 | - multiTopologyId = new short[len]; | ||
75 | for (int i = 0; i < len; i++) { | 84 | for (int i = 0; i < len; i++) { |
76 | - multiTopologyId[i] = cb.readShort(); | 85 | + tempMultiTopologyId = cb.readShort(); |
86 | + multiTopologyId.add(new Short(tempMultiTopologyId)); | ||
77 | } | 87 | } |
78 | 88 | ||
79 | return new BgpAttrNodeMultiTopologyId(multiTopologyId); | 89 | return new BgpAttrNodeMultiTopologyId(multiTopologyId); |
... | @@ -84,7 +94,7 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { | ... | @@ -84,7 +94,7 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { |
84 | * | 94 | * |
85 | * @return multitopology ID | 95 | * @return multitopology ID |
86 | */ | 96 | */ |
87 | - short[] getAttrMultiTopologyId() { | 97 | + public List<Short> attrMultiTopologyId() { |
88 | return multiTopologyId; | 98 | return multiTopologyId; |
89 | } | 99 | } |
90 | 100 | ||
... | @@ -113,7 +123,7 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { | ... | @@ -113,7 +123,7 @@ public class BgpAttrNodeMultiTopologyId implements BGPValueType { |
113 | 123 | ||
114 | @Override | 124 | @Override |
115 | public int write(ChannelBuffer cb) { | 125 | public int write(ChannelBuffer cb) { |
116 | - // TODO Auto-generated method stub | 126 | + // TODO This will be implemented in the next version |
117 | return 0; | 127 | return 0; |
118 | } | 128 | } |
119 | 129 | ... | ... |
-
Please register or login to post a comment