bharat saraswal
Committed by Gerrit Code Review

Implementation of PcInitate and PcUpdate messages

Change-Id: I746a5860a8b4a8022d747a02075ed3237741c53a
Showing 53 changed files with 16164 additions and 31 deletions
...@@ -15,3 +15,4 @@ dependency-reduced-pom.xml ...@@ -15,3 +15,4 @@ dependency-reduced-pom.xml
15 15
16 core/store/trivial/data/ 16 core/store/trivial/data/
17 core/store/apps 17 core/store/apps
18 +/bin/
......
...@@ -19,6 +19,7 @@ package org.onosproject.pcepio.protocol; ...@@ -19,6 +19,7 @@ package org.onosproject.pcepio.protocol;
19 import java.util.LinkedList; 19 import java.util.LinkedList;
20 20
21 import org.jboss.netty.buffer.ChannelBuffer; 21 import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.exceptions.PcepParseException;
22 import org.onosproject.pcepio.types.PcepObjectHeader; 23 import org.onosproject.pcepio.types.PcepObjectHeader;
23 import org.onosproject.pcepio.types.PcepValueType; 24 import org.onosproject.pcepio.types.PcepValueType;
24 25
...@@ -62,7 +63,7 @@ public interface PcepCloseMsg extends PcepObject, PcepMessage { ...@@ -62,7 +63,7 @@ public interface PcepCloseMsg extends PcepObject, PcepMessage {
62 void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv); 63 void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv);
63 64
64 @Override 65 @Override
65 - void writeTo(ChannelBuffer channelBuffer); 66 + void writeTo(ChannelBuffer channelBuffer) throws PcepParseException;
66 67
67 /** 68 /**
68 * Builder interface with get and set functions to build Close message. 69 * Builder interface with get and set functions to build Close message.
......
...@@ -18,6 +18,7 @@ package org.onosproject.pcepio.protocol; ...@@ -18,6 +18,7 @@ package org.onosproject.pcepio.protocol;
18 18
19 import org.jboss.netty.buffer.ChannelBuffer; 19 import org.jboss.netty.buffer.ChannelBuffer;
20 import org.onosproject.pcepio.exceptions.PcepParseException; 20 import org.onosproject.pcepio.exceptions.PcepParseException;
21 +import org.onosproject.pcepio.protocol.ver1.PcepFactoryVer1;
21 import org.slf4j.Logger; 22 import org.slf4j.Logger;
22 import org.slf4j.LoggerFactory; 23 import org.slf4j.LoggerFactory;
23 24
...@@ -35,15 +36,15 @@ public final class PcepFactories { ...@@ -35,15 +36,15 @@ public final class PcepFactories {
35 /* 36 /*
36 * Returns the instance of PCEP Version. 37 * Returns the instance of PCEP Version.
37 * 38 *
38 - * @param version 39 + * @param version PCEP version
39 * @return PCEP version 40 * @return PCEP version
40 */ 41 */
41 public static PcepFactory getFactory(PcepVersion version) { 42 public static PcepFactory getFactory(PcepVersion version) {
42 switch (version) { 43 switch (version) {
43 case PCEP_1: 44 case PCEP_1:
44 - // TODO : to get the pcep version 1 factory 45 + return PcepFactoryVer1.INSTANCE;
45 default: 46 default:
46 - throw new IllegalArgumentException("[PcepFactory:]Unknown version: " + version); 47 + throw new IllegalArgumentException("Unknown version: " + version);
47 } 48 }
48 } 49 }
49 50
...@@ -53,7 +54,6 @@ public final class PcepFactories { ...@@ -53,7 +54,6 @@ public final class PcepFactories {
53 public PcepMessage readFrom(ChannelBuffer bb) throws PcepParseException { 54 public PcepMessage readFrom(ChannelBuffer bb) throws PcepParseException {
54 55
55 if (!bb.readable()) { 56 if (!bb.readable()) {
56 - log.debug("Empty message received");
57 throw new PcepParseException("Empty message received"); 57 throw new PcepParseException("Empty message received");
58 } 58 }
59 59
...@@ -75,13 +75,12 @@ public final class PcepFactories { ...@@ -75,13 +75,12 @@ public final class PcepFactories {
75 switch (packetVersion) { 75 switch (packetVersion) {
76 76
77 case 1: 77 case 1:
78 - // TODO : get the factory for version 1 78 + factory = org.onosproject.pcepio.protocol.ver1.PcepFactoryVer1.INSTANCE;
79 break; 79 break;
80 default: 80 default:
81 throw new IllegalArgumentException("Unknown Packet version: " + packetVersion); 81 throw new IllegalArgumentException("Unknown Packet version: " + packetVersion);
82 } 82 }
83 - // TODO : Read the PCEP message from the factory 83 + return factory.getReader().readFrom(bb);
84 - return null;
85 } 84 }
86 } 85 }
87 86
......
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.onosproject.pcepio.exceptions.PcepParseException;
20 +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
21 +import org.onosproject.pcepio.protocol.PcepAttribute;
22 +import org.onosproject.pcepio.protocol.PcepEndPointsObject;
23 +import org.onosproject.pcepio.protocol.PcepEroObject;
24 +import org.onosproject.pcepio.protocol.PcepLspObject;
25 +import org.onosproject.pcepio.protocol.PcepSrpObject;
26 +import org.slf4j.Logger;
27 +import org.slf4j.LoggerFactory;
28 +
29 +import com.google.common.base.MoreObjects;
30 +import com.google.common.base.MoreObjects.ToStringHelper;
31 +
32 +/**
33 + * Provides PcInitiatedLspRequest for PCEP Initiate message.
34 + * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03.
35 + */
36 +public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest {
37 +
38 + /*
39 + * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
40 + <PCE-initiated-lsp-instantiation> ::= <SRP>
41 + <LSP>
42 + <END-POINTS>
43 + <ERO>
44 + [<attribute-list>]
45 + <PCE-initiated-lsp-deletion> ::= <SRP>
46 + <LSP>
47 + */
48 +
49 + protected static final Logger log = LoggerFactory.getLogger(PcInitiatedLspRequestVer1.class);
50 +
51 + //PCEP SRP Object
52 + private PcepSrpObject srpObject;
53 + //PCEP LSP Object
54 + private PcepLspObject lspObject;
55 + //PCEP End Point Object
56 + private PcepEndPointsObject endPointsObject;
57 + //PCEP ERO Object
58 + private PcepEroObject eroObject;
59 + //PCEP Attribute list
60 + private PcepAttribute pcepAttribute;
61 +
62 + /**
63 + * Default constructor.
64 + */
65 + public PcInitiatedLspRequestVer1() {
66 + srpObject = null;
67 + lspObject = null;
68 + endPointsObject = null;
69 + eroObject = null;
70 + pcepAttribute = null;
71 +
72 + }
73 +
74 + /**
75 + * Constructor to initialize all parameters of PC initiated lsp request.
76 + *
77 + * @param srpObject PCEP srp Object
78 + * @param lspObject PCEP lsp object
79 + * @param endPointsObject PCPE endpoints object
80 + * @param eroObject PCEP ero object
81 + * @param pcepAttribute PCEP attribute
82 + */
83 + public PcInitiatedLspRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject,
84 + PcepEndPointsObject endPointsObject, PcepEroObject eroObject, PcepAttribute pcepAttribute) {
85 + this.srpObject = srpObject;
86 + this.lspObject = lspObject;
87 + this.endPointsObject = endPointsObject;
88 + this.eroObject = eroObject;
89 + this.pcepAttribute = pcepAttribute;
90 +
91 + }
92 +
93 + @Override
94 + public PcepSrpObject getSrpObject() {
95 + return srpObject;
96 + }
97 +
98 + @Override
99 + public PcepLspObject getLspObject() {
100 + return lspObject;
101 + }
102 +
103 + @Override
104 + public PcepEndPointsObject getEndPointsObject() {
105 + return endPointsObject;
106 + }
107 +
108 + @Override
109 + public PcepEroObject getEroObject() {
110 + return eroObject;
111 + }
112 +
113 + @Override
114 + public PcepAttribute getPcepAttribute() {
115 + return pcepAttribute;
116 + }
117 +
118 + @Override
119 + public void setSrpObject(PcepSrpObject srpobj) {
120 + this.srpObject = srpobj;
121 +
122 + }
123 +
124 + @Override
125 + public void setLspObject(PcepLspObject lspObject) {
126 + this.lspObject = lspObject;
127 + }
128 +
129 + @Override
130 + public void setEndPointsObject(PcepEndPointsObject endPointsObject) {
131 + this.endPointsObject = endPointsObject;
132 + }
133 +
134 + @Override
135 + public void setEroObject(PcepEroObject eroObject) {
136 + this.eroObject = eroObject;
137 + }
138 +
139 + @Override
140 + public void setPcepAttribute(PcepAttribute pcepAttribute) {
141 + this.pcepAttribute = pcepAttribute;
142 + }
143 +
144 + /**
145 + * Builder class for PC initiated lsp reuqest.
146 + */
147 + public static class Builder implements PcInitiatedLspRequest.Builder {
148 +
149 + private boolean bIsSRPObjectSet = false;
150 + private boolean bIsLSPObjectSet = false;
151 + private boolean bIsEndPointsObjectSet = false;
152 + private boolean bIsEROObjectSet = false;
153 + private boolean bIsPcepAttributeSet = false;
154 + private boolean bIsbRFlagSet = false;
155 +
156 + //PCEP SRP Object
157 + private PcepSrpObject srpObject;
158 + //PCEP LSP Object
159 + private PcepLspObject lspObject;
160 + //PCEP End Point Object
161 + private PcepEndPointsObject endPointsObject;
162 + //PCEP ERO Object
163 + private PcepEroObject eroObject;
164 + //PCEP Attribute list
165 + private PcepAttribute pcepAttribute;
166 +
167 + @Override
168 + public PcInitiatedLspRequest build() throws PcepParseException {
169 +
170 + //PCEP SRP Object
171 + PcepSrpObject srpObject = null;
172 + //PCEP LSP Object
173 + PcepLspObject lspObject = null;
174 + //PCEP End Point Object
175 + PcepEndPointsObject endPointsObject = null;
176 + //PCEP ERO Object
177 + PcepEroObject eroObject = null;
178 + //PCEP Attribute list
179 + PcepAttribute pcepAttribute = null;
180 + boolean bRFlag = false;
181 +
182 + if (!this.bIsSRPObjectSet) {
183 + throw new PcepParseException("Srp object NOT Set while building PcInitiatedLspRequest");
184 + } else {
185 + srpObject = this.srpObject;
186 + bRFlag = srpObject.getRFlag();
187 + }
188 +
189 + if (bRFlag) {
190 + this.bIsbRFlagSet = true;
191 + } else {
192 + this.bIsbRFlagSet = false;
193 + }
194 +
195 + if (!this.bIsLSPObjectSet) {
196 + throw new PcepParseException("LSP Object NOT Set while building PcInitiatedLspRequest");
197 + } else {
198 + lspObject = this.lspObject;
199 + }
200 + if (!this.bIsbRFlagSet) {
201 +
202 + if (!this.bIsEndPointsObjectSet) {
203 + throw new PcepParseException("EndPoints Object NOT Set while building PcInitiatedLspRequest");
204 + } else {
205 + endPointsObject = this.endPointsObject;
206 + }
207 + if (!this.bIsEROObjectSet) {
208 + throw new PcepParseException("ERO Object NOT Set while building PcInitiatedLspRequest");
209 + } else {
210 + eroObject = this.eroObject;
211 + }
212 + if (bIsPcepAttributeSet) {
213 + pcepAttribute = this.pcepAttribute;
214 + }
215 + }
216 + return new PcInitiatedLspRequestVer1(srpObject, lspObject, endPointsObject, eroObject, pcepAttribute);
217 + }
218 +
219 + @Override
220 + public PcepSrpObject getSrpObject() {
221 + return this.srpObject;
222 + }
223 +
224 + @Override
225 + public PcepLspObject getLspObject() {
226 + return this.lspObject;
227 + }
228 +
229 + @Override
230 + public PcepEndPointsObject getEndPointsObject() {
231 + return this.endPointsObject;
232 + }
233 +
234 + @Override
235 + public PcepEroObject getEroObject() {
236 + return this.eroObject;
237 + }
238 +
239 + @Override
240 + public PcepAttribute getPcepAttribute() {
241 + return this.pcepAttribute;
242 + }
243 +
244 + @Override
245 + public Builder setSrpObject(PcepSrpObject srpobj) {
246 + this.srpObject = srpobj;
247 + this.bIsSRPObjectSet = true;
248 + return this;
249 +
250 + }
251 +
252 + @Override
253 + public Builder setLspObject(PcepLspObject lspObject) {
254 + this.lspObject = lspObject;
255 + this.bIsLSPObjectSet = true;
256 + return this;
257 + }
258 +
259 + @Override
260 + public Builder setEndPointsObject(PcepEndPointsObject endPointsObject) {
261 + this.endPointsObject = endPointsObject;
262 + this.bIsEndPointsObjectSet = true;
263 + return this;
264 + }
265 +
266 + @Override
267 + public Builder setEroObject(PcepEroObject eroObject) {
268 + this.eroObject = eroObject;
269 + this.bIsEROObjectSet = true;
270 + return this;
271 + }
272 +
273 + @Override
274 + public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
275 + this.pcepAttribute = pcepAttribute;
276 + this.bIsPcepAttributeSet = true;
277 + return this;
278 + }
279 +
280 + }
281 +
282 + @Override
283 + public void print() {
284 +
285 + log.debug(" PC-INITIATED LSP INITIATION REQUEST");
286 + srpObject.print();
287 + lspObject.print();
288 + //if PC initiate then print end point and ero object [pcepattribute].
289 + if (endPointsObject instanceof PcepEndPointsObject) {
290 + endPointsObject.print();
291 + }
292 +
293 + if (eroObject instanceof PcepEroObject) {
294 + eroObject.print();
295 + }
296 +
297 + if (pcepAttribute instanceof PcepAttribute) {
298 + pcepAttribute.print();
299 + }
300 + }
301 +
302 + @Override
303 + public String toString() {
304 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
305 + toStrHelper
306 + .add("SRP Object", srpObject)
307 + .add("LSP object", lspObject);
308 +
309 + if (endPointsObject instanceof PcepEndPointsObject) {
310 + toStrHelper
311 + .add("End Point Object", endPointsObject);
312 + }
313 + if (eroObject instanceof PcepEroObject) {
314 + toStrHelper
315 + .add("ERO Object", eroObject);
316 + }
317 + if (pcepAttribute instanceof PcepAttribute) {
318 + toStrHelper
319 + .add("Pcep Attribute", pcepAttribute);
320 + }
321 + return toStrHelper.toString();
322 + }
323 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +/*
20 + * Provides PCEP Attribute List.
21 + */
22 +import java.util.LinkedList;
23 +import java.util.ListIterator;
24 +
25 +import org.jboss.netty.buffer.ChannelBuffer;
26 +import org.onosproject.pcepio.exceptions.PcepParseException;
27 +import org.onosproject.pcepio.protocol.PcepAttribute;
28 +import org.onosproject.pcepio.protocol.PcepBandwidthObject;
29 +import org.onosproject.pcepio.protocol.PcepIroObject;
30 +import org.onosproject.pcepio.protocol.PcepLspaObject;
31 +import org.onosproject.pcepio.protocol.PcepMetricObject;
32 +import org.onosproject.pcepio.types.PcepObjectHeader;
33 +import org.slf4j.Logger;
34 +import org.slf4j.LoggerFactory;
35 +
36 +import com.google.common.base.MoreObjects;
37 +import com.google.common.base.MoreObjects.ToStringHelper;
38 +
39 +/* Reference : RFC5440
40 + * where:
41 + * <attribute-list> ::=[<LSPA>]
42 + * [<BANDWIDTH>]
43 + * [<metric-list>]
44 + * [<IRO>]
45 + *
46 + * <metric-list> ::=<METRIC>[<metric-list>]
47 + */
48 +
49 +public class PcepAttributeVer1 implements PcepAttribute {
50 +
51 + protected static final Logger log = LoggerFactory.getLogger(PcepAttributeVer1.class);
52 +
53 + public static final int OBJECT_HEADER_LENGTH = 4;
54 +
55 + //PCEP LSPA Object
56 + private PcepLspaObject lspaObject;
57 + private boolean isLspaObjectSet;
58 +
59 + //PCEP Bandwidth Object
60 + private PcepBandwidthObject bandwidthObject;
61 + private boolean isBandwidthObjectSet;
62 +
63 + //PCEP Metric list
64 + private LinkedList<PcepMetricObject> llMetricList;
65 + private boolean isMetricListSet;
66 +
67 + //PCEP IRO object
68 + private PcepIroObject iroObject;
69 + private boolean isIroObjectSet;
70 +
71 + /**
72 + * Default constructor to initialize member variables.
73 + */
74 + public PcepAttributeVer1() {
75 +
76 + lspaObject = null;
77 + bandwidthObject = null;
78 + llMetricList = null;
79 + iroObject = null;
80 + this.isLspaObjectSet = false;
81 + this.isBandwidthObjectSet = false;
82 + this.isMetricListSet = false;
83 + this.isIroObjectSet = false;
84 + }
85 +
86 + /**
87 + * Constructor to initialize all parameters for PCEP attribute.
88 + *
89 + * @param lspaObject PCEP lspa Object.
90 + * @param bandwidthObject PCEP bandwidth object.
91 + * @param llMetricList list of PCEP metric objects.
92 + * @param iroObject PCEP iro object.
93 + */
94 + public PcepAttributeVer1(PcepLspaObject lspaObject, PcepBandwidthObject bandwidthObject,
95 + LinkedList<PcepMetricObject> llMetricList, PcepIroObject iroObject) {
96 +
97 + this.lspaObject = lspaObject;
98 + this.bandwidthObject = bandwidthObject;
99 + this.llMetricList = llMetricList;
100 + this.iroObject = iroObject;
101 + if (lspaObject == null) {
102 + this.isLspaObjectSet = false;
103 + } else {
104 + this.isLspaObjectSet = true;
105 + }
106 + if (bandwidthObject == null) {
107 + this.isBandwidthObjectSet = false;
108 + } else {
109 + this.isBandwidthObjectSet = true;
110 + }
111 + if (llMetricList == null) {
112 + this.isMetricListSet = false;
113 + } else {
114 + this.isMetricListSet = true;
115 + }
116 + if (iroObject == null) {
117 + this.isIroObjectSet = false;
118 + } else {
119 + this.isIroObjectSet = true;
120 + }
121 + }
122 +
123 + /**
124 + * constructor to initialize bandwidthObject.
125 + *
126 + * @param bandwidthObject bandwidth object
127 + */
128 + public PcepAttributeVer1(PcepBandwidthObject bandwidthObject) {
129 + this.isLspaObjectSet = false;
130 +
131 + this.bandwidthObject = bandwidthObject;
132 + this.isBandwidthObjectSet = true;
133 +
134 + this.isMetricListSet = false;
135 +
136 + this.isIroObjectSet = false;
137 + }
138 +
139 + /**
140 + * Parse list for MeticObject.
141 + *
142 + * @param cb of type channel buffer
143 + * @return true if parsing metric list is success
144 + * @throws PcepParseException when a non metric object is received
145 + */
146 + public boolean parseMetricList(ChannelBuffer cb) throws PcepParseException {
147 +
148 + if (null == llMetricList) {
149 + llMetricList = new LinkedList<PcepMetricObject>();
150 + }
151 +
152 + PcepMetricObject metriclist;
153 +
154 + //caller should verify for metric object
155 + byte yObjClass = PcepMetricObjectVer1.METRIC_OBJ_CLASS;
156 + byte yObjType = PcepMetricObjectVer1.METRIC_OBJ_TYPE;
157 +
158 + while ((yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS)
159 + && (yObjType == PcepMetricObjectVer1.METRIC_OBJ_TYPE)) {
160 +
161 + metriclist = PcepMetricObjectVer1.read(cb);
162 + llMetricList.add(metriclist);
163 + yObjClass = 0;
164 + yObjType = 0;
165 +
166 + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
167 + cb.markReaderIndex();
168 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
169 + cb.resetReaderIndex();
170 + yObjClass = tempObjHeader.getObjClass();
171 + yObjType = tempObjHeader.getObjType();
172 + }
173 + }
174 + return true;
175 + }
176 +
177 + /**
178 + * Reads lspa , bandwidth , Metriclist and Iro objects and sets the objects.
179 + *
180 + * @param cb of type channel buffer
181 + * @return instance of Pcep Attribute
182 + * @throws PcepParseException while parsing Pcep Attributes from channel buffer
183 + */
184 +
185 + public static PcepAttribute read(ChannelBuffer cb) throws PcepParseException {
186 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
187 + return null;
188 + }
189 + //check whether any pcep attribute is present
190 + cb.markReaderIndex();
191 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
192 + cb.resetReaderIndex();
193 + byte yObjClass = tempObjHeader.getObjClass();
194 +
195 + if (PcepLspaObjectVer1.LSPA_OBJ_CLASS != yObjClass && PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS != yObjClass
196 + && PcepMetricObjectVer1.METRIC_OBJ_CLASS != yObjClass && PcepIroObjectVer1.IRO_OBJ_CLASS != yObjClass) {
197 + //No PCEP attribute is present
198 + return null;
199 + }
200 +
201 + PcepAttributeVer1 pcepAttribute = new PcepAttributeVer1();
202 +
203 + //If LSPA present then store it.LSPA is optional
204 + if (yObjClass == PcepLspaObjectVer1.LSPA_OBJ_CLASS) {
205 + pcepAttribute.setLspaObject(PcepLspaObjectVer1.read(cb));
206 + yObjClass = checkNextObject(cb);
207 + }
208 +
209 + //If BANDWIDTH present then store it.BANDWIDTH is optional
210 + if (yObjClass == PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS) {
211 + pcepAttribute.setBandwidthObject(PcepBandwidthObjectVer1.read(cb));
212 + yObjClass = checkNextObject(cb);
213 + }
214 +
215 + //If Metric list present then store it.MetricList is optional
216 + if (yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS) {
217 + pcepAttribute.parseMetricList(cb);
218 + yObjClass = checkNextObject(cb);
219 + }
220 +
221 + //If IRO present then store it.IRO is optional
222 + if (yObjClass == PcepIroObjectVer1.IRO_OBJ_CLASS) {
223 + pcepAttribute.setIroObject(PcepIroObjectVer1.read(cb));
224 + }
225 +
226 + PcepLspaObject lspaObject = pcepAttribute.getLspaObject();
227 + PcepBandwidthObject bandwidthObject = pcepAttribute.getBandwidthObject();
228 + LinkedList<PcepMetricObject> metriclist = pcepAttribute.llMetricList;
229 + PcepIroObject iroObject = pcepAttribute.getIroObject();
230 +
231 + return new PcepAttributeVer1(lspaObject, bandwidthObject, metriclist, iroObject);
232 + }
233 +
234 + /**
235 + * Checks whether there is a more object or not.
236 + *
237 + * @param cb of type channel buffer
238 + * @return instance of object header
239 + */
240 + private static byte checkNextObject(ChannelBuffer cb) {
241 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
242 + return 0;
243 + }
244 + cb.markReaderIndex();
245 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
246 + cb.resetReaderIndex();
247 + return tempObjHeader.getObjClass();
248 + }
249 +
250 + @Override
251 + public int write(ChannelBuffer cb) throws PcepParseException {
252 + int iLenStartIndex = cb.writerIndex();
253 + //PCEP LSPA object is optional
254 + if (this.isLspaObjectSet) {
255 + this.lspaObject.write(cb);
256 + }
257 +
258 + //PCEP BANDWIDTH object is optional
259 + if (this.isBandwidthObjectSet) {
260 + this.bandwidthObject.write(cb);
261 + }
262 +
263 + //PCEP Metric list is optional
264 + if (this.isMetricListSet) {
265 + ListIterator<PcepMetricObject> listIterator = this.llMetricList.listIterator();
266 + while (listIterator.hasNext()) {
267 + listIterator.next().write(cb);
268 + }
269 + }
270 +
271 + //PCEP IRO object is optional
272 + if (this.isIroObjectSet) {
273 + this.iroObject.write(cb);
274 + }
275 + return cb.writerIndex() - iLenStartIndex;
276 + }
277 +
278 + @Override
279 + public PcepLspaObject getLspaObject() {
280 + return lspaObject;
281 + }
282 +
283 + @Override
284 + public PcepBandwidthObject getBandwidthObject() {
285 + return bandwidthObject;
286 + }
287 +
288 + @Override
289 + public LinkedList<PcepMetricObject> getMetricObjectList() {
290 + return llMetricList;
291 + }
292 +
293 + @Override
294 + public PcepIroObject getIroObject() {
295 + return iroObject;
296 + }
297 +
298 + @Override
299 + public void setBandwidthObject(PcepBandwidthObject bandwidthObject) {
300 + this.isBandwidthObjectSet = true;
301 + this.bandwidthObject = bandwidthObject;
302 + }
303 +
304 + @Override
305 + public void setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) {
306 + this.isMetricListSet = true;
307 + this.llMetricList = llMetricList;
308 +
309 + }
310 +
311 + @Override
312 + public void setLspaObject(PcepLspaObject lspaObject) {
313 + this.isLspaObjectSet = true;
314 + this.lspaObject = lspaObject;
315 + }
316 +
317 + @Override
318 + public void setIroObject(PcepIroObject iroObject) {
319 + this.isIroObjectSet = true;
320 + this.iroObject = iroObject;
321 + }
322 +
323 + /**
324 + * Builder class for PCEP attributes.
325 + */
326 + public static class Builder implements PcepAttribute.Builder {
327 +
328 + //PCEP LSPA Object
329 + private PcepLspaObject lspaObject;
330 + private boolean isLspaObjectSet;
331 +
332 + //PCEP BANDWIDTH Object
333 + private PcepBandwidthObject bandwidthObject;
334 + private boolean isBandwidthObjectSet;
335 +
336 + //PCEP Metric list
337 + private LinkedList<PcepMetricObject> llMetricList;
338 + private boolean isMetricListSet;
339 +
340 + //PCEP IRO object
341 + private PcepIroObject iroObject;
342 + private boolean isIroObjectSet;
343 +
344 + @Override
345 + public PcepAttribute build() {
346 +
347 + //PCEP LSPA Object
348 + PcepLspaObject lspaObject = null;
349 +
350 + //PCEP BANDWIDTH Object
351 + PcepBandwidthObject bandwidthObject = null;
352 +
353 + //PCEP Metric list
354 + LinkedList<PcepMetricObject> llMetricList = null;
355 +
356 + //PCEP IRO object
357 + PcepIroObject iroObject = null;
358 +
359 + if (this.isLspaObjectSet) {
360 + lspaObject = this.lspaObject;
361 + }
362 + if (this.isBandwidthObjectSet) {
363 + bandwidthObject = this.bandwidthObject;
364 + }
365 + if (this.isMetricListSet) {
366 + llMetricList = this.llMetricList;
367 + }
368 + if (this.isIroObjectSet) {
369 + iroObject = this.iroObject;
370 + }
371 + return new PcepAttributeVer1(lspaObject, bandwidthObject, llMetricList, iroObject);
372 + }
373 +
374 + @Override
375 + public PcepLspaObject getLspaObject() {
376 + return this.lspaObject;
377 + }
378 +
379 + @Override
380 + public PcepBandwidthObject getBandwidthObject() {
381 + return this.bandwidthObject;
382 + }
383 +
384 + @Override
385 + public LinkedList<PcepMetricObject> getMetricObjectList() {
386 + return this.llMetricList;
387 + }
388 +
389 + @Override
390 + public PcepIroObject getIroObject() {
391 + return this.iroObject;
392 + }
393 +
394 + @Override
395 + public Builder setBandwidthObject(PcepBandwidthObject bandwidthObject) {
396 + this.isBandwidthObjectSet = true;
397 + this.bandwidthObject = bandwidthObject;
398 + return this;
399 + }
400 +
401 + @Override
402 + public Builder setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) {
403 + this.isMetricListSet = true;
404 + this.llMetricList = llMetricList;
405 + return this;
406 + }
407 +
408 + @Override
409 + public Builder setLspaObject(PcepLspaObject lspaObject) {
410 + this.isLspaObjectSet = true;
411 + this.lspaObject = lspaObject;
412 + return this;
413 + }
414 +
415 + @Override
416 + public Builder setIroObject(PcepIroObject iroObject) {
417 + this.isIroObjectSet = true;
418 + this.iroObject = iroObject;
419 + return this;
420 + }
421 + }
422 +
423 + @Override
424 + public void print() {
425 +
426 + log.debug("ATTRIBUTE LIST");
427 + if (lspaObject instanceof PcepLspaObject) {
428 + lspaObject.print();
429 + }
430 +
431 + if (bandwidthObject instanceof PcepBandwidthObject) {
432 + bandwidthObject.print();
433 + }
434 +
435 + if (llMetricList != null) {
436 + log.debug("METRIC LIST");
437 + ListIterator<PcepMetricObject> listIterator = llMetricList.listIterator();
438 + while (listIterator.hasNext()) {
439 + listIterator.next().print();
440 + }
441 + }
442 + if (iroObject instanceof PcepIroObject) {
443 + iroObject.print();
444 + }
445 + }
446 +
447 + @Override
448 + public String toString() {
449 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
450 +
451 + if (lspaObject instanceof PcepLspaObject) {
452 + toStrHelper
453 + .add("PCEP lspa Object", lspaObject);
454 + }
455 + if (bandwidthObject instanceof PcepBandwidthObject) {
456 + toStrHelper
457 + .add("bandwidth Object", bandwidthObject);
458 + }
459 + if (llMetricList instanceof PcepMetricObject) {
460 + toStrHelper
461 + .add("Pcep Metric object List", llMetricList);
462 + }
463 + if (iroObject instanceof PcepIroObject) {
464 + toStrHelper
465 + .add("iro Object", iroObject);
466 + }
467 + return toStrHelper.toString();
468 + }
469 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.jboss.netty.buffer.ChannelBuffer;
20 +import org.onosproject.pcepio.exceptions.PcepParseException;
21 +import org.onosproject.pcepio.protocol.PcepBandwidthObject;
22 +import org.onosproject.pcepio.types.PcepObjectHeader;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +/**
29 + * Provides PcepBandwidthObject.
30 + */
31 +public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
32 +
33 + /*
34 + * RFC : 5440 , section : 7.7.
35 + 0 1 2 3
36 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 + | Bandwidth |
39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 +
41 + The BANDWIDTH Object format
42 + */
43 +
44 + protected static final Logger log = LoggerFactory.getLogger(PcepBandwidthObjectVer1.class);
45 + /*
46 + * Requested bandwidth: BANDWIDTH Object-Type is 1.
47 + Bandwidth of an existing TE LSP for which a re-optimization is
48 + requested. BANDWIDTH Object-Type is 2.
49 + */
50 + //Right now handling type 1
51 + public static final byte BANDWIDTH_OBJ_TYPE = 1;
52 + public static final byte BANDWIDTH_OBJ_CLASS = 5;
53 + public static final byte BANDWIDTH_OBJECT_VERSION = 1;
54 + public static final short BANDWIDTH_OBJ_MINIMUM_LENGTH = 8;
55 +
56 + static final PcepObjectHeader DEFAULT_BANDWIDTH_OBJECT_HEADER = new PcepObjectHeader(BANDWIDTH_OBJ_CLASS,
57 + BANDWIDTH_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
58 + BANDWIDTH_OBJ_MINIMUM_LENGTH);
59 +
60 + private PcepObjectHeader bandwidthObjHeader;
61 + private int iBandwidth;
62 +
63 + /**
64 + * Constructor to bandwidth object header and bandwidth.
65 + *
66 + * @param bandwidthObjHeader bandwidth object header
67 + * @param iBandwidth bandwidth value
68 + */
69 + public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, int iBandwidth) {
70 + this.bandwidthObjHeader = bandwidthObjHeader;
71 + this.iBandwidth = iBandwidth;
72 + }
73 +
74 + /**
75 + * Constructor to initialize bandwidth.
76 + *
77 + * @param iBandwidth bandwidth value
78 + */
79 + public PcepBandwidthObjectVer1(int iBandwidth) {
80 + this.bandwidthObjHeader = DEFAULT_BANDWIDTH_OBJECT_HEADER;
81 + this.iBandwidth = iBandwidth;
82 + }
83 +
84 + /**
85 + * Returns Object Header.
86 + *
87 + * @return bandwidthObjHeader
88 + */
89 + public PcepObjectHeader getBandwidthObjHeader() {
90 + return this.bandwidthObjHeader;
91 + }
92 +
93 + /**
94 + * Sets Object Header.
95 + *
96 + * @param obj bandwidth object header
97 + */
98 + public void setBandwidthObjHeader(PcepObjectHeader obj) {
99 + this.bandwidthObjHeader = obj;
100 + }
101 +
102 + @Override
103 + public int getBandwidth() {
104 + return this.iBandwidth;
105 + }
106 +
107 + @Override
108 + public void setBandwidth(int iBandwidth) {
109 + this.iBandwidth = iBandwidth;
110 + }
111 +
112 + /**
113 + * Reads from channel buffer and returns object of PcepBandwidthObject.
114 + *
115 + * @param cb channel buffer to parse
116 + * @return object of PcepBandwidthObject
117 + * @throws PcepParseException while parsing channel buffer
118 + */
119 + public static PcepBandwidthObject read(ChannelBuffer cb) throws PcepParseException {
120 +
121 + PcepObjectHeader bandwidthObjHeader;
122 + int iBandwidth;
123 +
124 + bandwidthObjHeader = PcepObjectHeader.read(cb);
125 + iBandwidth = cb.readInt();
126 +
127 + return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth);
128 + }
129 +
130 + @Override
131 + public int write(ChannelBuffer cb) throws PcepParseException {
132 +
133 + //write Object header
134 + int objStartIndex = cb.writerIndex();
135 + int objLenIndex = bandwidthObjHeader.write(cb);
136 +
137 + if (objLenIndex <= 0) {
138 + throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex);
139 + }
140 +
141 + cb.writeInt(iBandwidth);
142 + short hLength = (short) (cb.writerIndex() - objStartIndex);
143 + cb.setShort(objLenIndex, hLength);
144 + //will be helpful during print().
145 + bandwidthObjHeader.setObjLen(hLength);
146 +
147 + return cb.writerIndex() - objStartIndex;
148 + }
149 +
150 + /**
151 + * builder class for PCEP bandwidth object.
152 + */
153 + public static class Builder implements PcepBandwidthObject.Builder {
154 +
155 + private PcepObjectHeader bandwidthObjHeader;
156 + private boolean bIsHeaderSet = false;
157 +
158 + private int iBandwidth;
159 + private boolean bIsBandwidthSet = false;
160 +
161 + private boolean bPFlag;
162 + private boolean bIsPFlagSet = false;
163 +
164 + private boolean bIFlag;
165 + private boolean bIsIFlagSet = false;
166 +
167 + @Override
168 + public PcepBandwidthObject build() throws PcepParseException {
169 +
170 + PcepObjectHeader bandwidthObjHeader = this.bIsHeaderSet ? this.bandwidthObjHeader
171 + : DEFAULT_BANDWIDTH_OBJECT_HEADER;
172 +
173 + if (bIsPFlagSet) {
174 + bandwidthObjHeader.setPFlag(bPFlag);
175 + }
176 +
177 + if (bIsIFlagSet) {
178 + bandwidthObjHeader.setIFlag(bIFlag);
179 + }
180 +
181 + if (!this.bIsBandwidthSet) {
182 + throw new PcepParseException("bandwidth not Set while building Bandwidth Object.");
183 + }
184 +
185 + return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth);
186 + }
187 +
188 + @Override
189 + public int getBandwidth() {
190 + return this.iBandwidth;
191 + }
192 +
193 + @Override
194 + public PcepObjectHeader getBandwidthObjHeader() {
195 + return this.bandwidthObjHeader;
196 + }
197 +
198 + @Override
199 + public Builder setBandwidthObjHeader(PcepObjectHeader obj) {
200 + this.bandwidthObjHeader = obj;
201 + return this;
202 + }
203 +
204 + @Override
205 + public Builder setBandwidth(int iBandwidth) {
206 + this.iBandwidth = iBandwidth;
207 + this.bIsBandwidthSet = true;
208 + return this;
209 + }
210 +
211 + @Override
212 + public Builder setPFlag(boolean value) {
213 + this.bPFlag = value;
214 + this.bIsPFlagSet = true;
215 + return this;
216 + }
217 +
218 + @Override
219 + public Builder setIFlag(boolean value) {
220 + this.bIFlag = value;
221 + this.bIsIFlagSet = true;
222 + return this;
223 + }
224 +
225 + }
226 +
227 + @Override
228 + public void print() {
229 +
230 + log.debug("BANDWIDTH OBJECT");
231 + bandwidthObjHeader.print();
232 + log.debug("Bandwidth: " + iBandwidth);
233 + }
234 +
235 + @Override
236 + public String toString() {
237 + return MoreObjects.toStringHelper(getClass())
238 + .add("bandwidth Object Header", bandwidthObjHeader)
239 + .add("Bandwidth", iBandwidth)
240 + .toString();
241 + }
242 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcepCloseMsg;
25 +import org.onosproject.pcepio.protocol.PcepMessageReader;
26 +import org.onosproject.pcepio.protocol.PcepMessageWriter;
27 +import org.onosproject.pcepio.protocol.PcepType;
28 +import org.onosproject.pcepio.protocol.PcepVersion;
29 +import org.onosproject.pcepio.types.PcepObjectHeader;
30 +import org.onosproject.pcepio.types.PcepValueType;
31 +import org.slf4j.Logger;
32 +import org.slf4j.LoggerFactory;
33 +
34 +import com.google.common.base.MoreObjects;
35 +
36 +/*
37 + * RFC : 5440 , section : 6.8
38 + * <Close Message> ::= <Common Header> <CLOSE>
39 + *
40 + 0 1 2 3
41 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | Ver | Flags | Message-Type | Message-Length |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 + | Reserved | Flags | Reason |
48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 + | |
50 + // Optional TLVs //
51 + | |
52 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 + */
54 +class PcepCloseMsgVer1 implements PcepCloseMsg {
55 +
56 + protected static final Logger log = LoggerFactory.getLogger(PcepCloseMsgVer1.class);
57 +
58 + // Pcep version: 1
59 + public static final byte PACKET_VERSION = 1;
60 + public static final int PACKET_MINIMUM_LENGTH = 12;
61 + public static final PcepType MSG_TYPE = PcepType.CLOSE;
62 + public static final byte CLOSE_OBJ_TYPE = 1;
63 + public static final byte CLOSE_OBJ_CLASS = 15;
64 + public static final byte CLOSE_OBJECT_VERSION = 1;
65 + public static final byte DEFAULT_REASON = 1; // Default reason to close
66 + public static final short CLOSE_OBJ_MINIMUM_LENGTH = 8;
67 + public static final int SHIFT_FLAG = 5;
68 + static final PcepObjectHeader DEFAULT_CLOSE_HEADER = new PcepObjectHeader(CLOSE_OBJ_CLASS, CLOSE_OBJ_TYPE,
69 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, CLOSE_OBJ_MINIMUM_LENGTH);
70 +
71 + private final PcepObjectHeader closeObjHeader;
72 + private byte yReason;
73 + private LinkedList<PcepValueType> llOptionalTlv;
74 +
75 + public static final PcepCloseMsgVer1.Reader READER = new Reader();
76 +
77 + static class Reader implements PcepMessageReader<PcepCloseMsg> {
78 + PcepObjectHeader closeObjHeader;
79 + byte yReason;
80 + // Optional TLV
81 + private LinkedList<PcepValueType> llOptionalTlv;
82 +
83 + @Override
84 + public PcepCloseMsg readFrom(ChannelBuffer cb) throws PcepParseException {
85 +
86 + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
87 + throw new PcepParseException("Packet size is less than the minimum length.");
88 + }
89 + // fixed value property version == 1
90 + byte version = cb.readByte();
91 + version = (byte) (version >> SHIFT_FLAG);
92 + if (version != PACKET_VERSION) {
93 + throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version);
94 + }
95 + // fixed value property type == 7
96 + byte type = cb.readByte();
97 + if (type != MSG_TYPE.getType()) {
98 + throw new PcepParseException("Wrong type. Expected=PcepType.CLOSE(7), got=" + type);
99 + }
100 + short length = cb.readShort();
101 + if (length < PACKET_MINIMUM_LENGTH) {
102 + throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
103 + + length);
104 + }
105 + closeObjHeader = PcepObjectHeader.read(cb);
106 + // Reserved
107 + cb.readShort();
108 + // Flags
109 + cb.readByte();
110 + // Reason
111 + yReason = cb.readByte();
112 + // parse optional TLV
113 + llOptionalTlv = parseOptionalTlv(cb);
114 + return new PcepCloseMsgVer1(closeObjHeader, yReason, llOptionalTlv);
115 + }
116 + }
117 +
118 + /**
119 + * Parse the list of Optional Tlvs.
120 + *
121 + * @param cb channel buffer
122 + * @return list of Optional Tlvs
123 + * @throws PcepParseException when fails to parse optional tlvs
124 + */
125 + public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
126 +
127 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
128 + /*
129 + rfc 5440:
130 + Optional TLVs may be included within the CLOSE object body. The
131 + specification of such TLVs is outside the scope of this document.
132 + */
133 + return llOptionalTlv;
134 + }
135 +
136 + /**
137 + * constructor to initialize PCEP close Message with all the parameters.
138 + *
139 + * @param closeObjHeader object header for close message
140 + * @param yReason reason for closing the channel
141 + * @param llOptionalTlv list of optional tlvs
142 + */
143 + PcepCloseMsgVer1(PcepObjectHeader closeObjHeader, byte yReason, LinkedList<PcepValueType> llOptionalTlv) {
144 +
145 + this.closeObjHeader = closeObjHeader;
146 + this.yReason = yReason;
147 + this.llOptionalTlv = llOptionalTlv;
148 + }
149 +
150 + /**
151 + * Builder class for PCEP close message.
152 + */
153 + static class Builder implements PcepCloseMsg.Builder {
154 +
155 + // PCEP Close message fields
156 + private boolean bIsHeaderSet = false;
157 + private PcepObjectHeader closeObjHeader;
158 + private boolean bIsReasonSet = false;
159 + private byte yReason;
160 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
161 +
162 + private boolean bIsPFlagSet = false;
163 + private boolean bPFlag;
164 +
165 + private boolean bIsIFlagSet = false;
166 + private boolean bIFlag;
167 +
168 + @Override
169 + public PcepVersion getVersion() {
170 + return PcepVersion.PCEP_1;
171 + }
172 +
173 + @Override
174 + public PcepType getType() {
175 + return PcepType.CLOSE;
176 + }
177 +
178 + @Override
179 + public PcepCloseMsg build() {
180 +
181 + PcepObjectHeader closeObjHeader = this.bIsHeaderSet ? this.closeObjHeader : DEFAULT_CLOSE_HEADER;
182 + byte yReason = this.bIsReasonSet ? this.yReason : DEFAULT_REASON;
183 +
184 + if (bIsPFlagSet) {
185 + closeObjHeader.setPFlag(bPFlag);
186 + }
187 +
188 + if (bIsIFlagSet) {
189 + closeObjHeader.setIFlag(bIFlag);
190 + }
191 + return new PcepCloseMsgVer1(closeObjHeader, yReason, this.llOptionalTlv);
192 + }
193 +
194 + @Override
195 + public PcepObjectHeader getCloseObjHeader() {
196 + return this.closeObjHeader;
197 + }
198 +
199 + @Override
200 + public Builder setCloseObjHeader(PcepObjectHeader obj) {
201 + this.closeObjHeader = obj;
202 + this.bIsHeaderSet = true;
203 + return this;
204 + }
205 +
206 + @Override
207 + public byte getReason() {
208 + return this.yReason;
209 + }
210 +
211 + @Override
212 + public Builder setReason(byte value) {
213 + this.yReason = value;
214 + this.bIsReasonSet = true;
215 + return this;
216 + }
217 +
218 + @Override
219 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
220 + this.llOptionalTlv = llOptionalTlv;
221 + return this;
222 + }
223 +
224 + @Override
225 + public LinkedList<PcepValueType> getOptionalTlv() {
226 + return this.llOptionalTlv;
227 + }
228 +
229 + @Override
230 + public Builder setPFlag(boolean value) {
231 + this.bPFlag = value;
232 + this.bIsPFlagSet = true;
233 + return this;
234 + }
235 +
236 + @Override
237 + public Builder setIFlag(boolean value) {
238 + this.bIFlag = value;
239 + this.bIsIFlagSet = true;
240 + return this;
241 + }
242 + }
243 +
244 + @Override
245 + public void writeTo(ChannelBuffer cb) throws PcepParseException {
246 + WRITER.write(cb, this);
247 + }
248 +
249 + static final Writer WRITER = new Writer();
250 +
251 + static class Writer implements PcepMessageWriter<PcepCloseMsgVer1> {
252 +
253 + @Override
254 + public void write(ChannelBuffer cb, PcepCloseMsgVer1 message) throws PcepParseException {
255 + int startIndex = cb.writerIndex();
256 + // first 3 bits set to version
257 + cb.writeByte((byte) (PACKET_VERSION << SHIFT_FLAG));
258 + // message type
259 + cb.writeByte(MSG_TYPE.getType());
260 + // length is length of variable message, will be updated at the end
261 + // Store the position of message
262 + // length in buffer
263 + int msgLenIndex = cb.writerIndex();
264 + cb.writeShort((short) 0);
265 + int objStartIndex = cb.writerIndex();
266 + int objLenIndex = message.closeObjHeader.write(cb);
267 + if (objLenIndex <= 0) {
268 + throw new PcepParseException("Failed to write Close object header.");
269 + }
270 + // first 3 bits set to version
271 + cb.writeShort(0); // Reserved
272 + cb.writeByte(0); // Flags
273 + cb.writeByte(message.yReason);
274 + // Pack optional TLV
275 + packOptionalTlv(cb, message);
276 + int length = cb.writerIndex() - objStartIndex;
277 + cb.setShort(objLenIndex, (short) length);
278 + // will be helpful during print().
279 + message.closeObjHeader.setObjLen((short) length);
280 + // As per RFC the length of object should be
281 + // multiples of 4
282 + int pad = length % 4;
283 + if (pad != 0) {
284 + pad = 4 - pad;
285 + for (int i = 0; i < pad; i++) {
286 + cb.writeByte((byte) 0);
287 + }
288 + length = length + pad;
289 + }
290 + // update message length field
291 + length = cb.writerIndex() - startIndex;
292 + cb.setShort(msgLenIndex, (short) length);
293 + }
294 +
295 + public void packOptionalTlv(ChannelBuffer cb, PcepCloseMsgVer1 message) {
296 +
297 + LinkedList<PcepValueType> llOptionalTlv = message.llOptionalTlv;
298 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
299 + while (listIterator.hasNext()) {
300 + listIterator.next().write(cb);
301 + }
302 + }
303 + }
304 +
305 + @Override
306 + public PcepVersion getVersion() {
307 + return PcepVersion.PCEP_1;
308 + }
309 +
310 + @Override
311 + public PcepType getType() {
312 + return MSG_TYPE;
313 + }
314 +
315 + @Override
316 + public byte getReason() {
317 + return this.yReason;
318 + }
319 +
320 + @Override
321 + public void setReason(byte value) {
322 + this.yReason = value;
323 + }
324 +
325 + @Override
326 + public LinkedList<PcepValueType> getOptionalTlv() {
327 + return this.llOptionalTlv;
328 + }
329 +
330 + @Override
331 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
332 + this.llOptionalTlv = llOptionalTlv;
333 + }
334 +
335 + @Override
336 + public void print() {
337 + log.debug("CLOSE MESSAGE");
338 + closeObjHeader.print();
339 + int x = yReason & 0xFF;
340 + log.debug("Reason: " + x);
341 + log.debug("OPTINAL TLV:");
342 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
343 + while (listIterator.hasNext()) {
344 + listIterator.next().print();
345 + }
346 + }
347 +
348 + @Override
349 + public String toString() {
350 + return MoreObjects.toStringHelper(getClass())
351 + .add("close Object Header", closeObjHeader)
352 + .add("Reason", yReason)
353 + .add("Optional Tlv list", llOptionalTlv)
354 + .toString();
355 + }
356 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.jboss.netty.buffer.ChannelBuffer;
20 +import org.onosproject.pcepio.exceptions.PcepParseException;
21 +import org.onosproject.pcepio.protocol.PcepEndPointsObject;
22 +import org.onosproject.pcepio.types.PcepObjectHeader;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +public class PcepEndPointsObjectVer1 implements PcepEndPointsObject {
29 +
30 + /*
31 + * RFC : 5440 , section : 7.6
32 + * An End point is defined as follows:
33 + END-POINTS Object-Class is 4.
34 +
35 + END-POINTS Object-Type is 1 for IPv4 and 2 for IPv6.
36 + 0 1 2 3
37 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 + | Source IPv4 address |
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | Destination IPv4 address |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 +
46 + */
47 + protected static final Logger log = LoggerFactory.getLogger(PcepEndPointsObjectVer1.class);
48 +
49 + static final byte END_POINTS_OBJ_TYPE = 1;
50 + static final byte END_POINTS_OBJ_CLASS = 4;
51 + static final byte END_POINTS_OBJECT_VERSION = 1;
52 + static final short END_POINTS_OBJ_MINIMUM_LENGTH = 12;
53 + public static byte endPointObjType;
54 +
55 + static final PcepObjectHeader DEFAULT_END_POINTS_OBJECT_HEADER = new PcepObjectHeader(END_POINTS_OBJ_CLASS,
56 + END_POINTS_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
57 + END_POINTS_OBJ_MINIMUM_LENGTH);
58 +
59 + private PcepObjectHeader endPointsObjHeader;
60 + public int sourceIpAddress;
61 + public int destIpAddress;
62 +
63 + /**
64 + * Constructor to initialize all variables.
65 + *
66 + * @param endPointsObjHeader end points object header
67 + * @param sourceIpAddress source IP address
68 + * @param destIpAddress destination IP address
69 + */
70 + public PcepEndPointsObjectVer1(PcepObjectHeader endPointsObjHeader, int sourceIpAddress, int destIpAddress) {
71 +
72 + this.endPointsObjHeader = endPointsObjHeader;
73 + this.sourceIpAddress = sourceIpAddress;
74 + this.destIpAddress = destIpAddress;
75 + }
76 +
77 + /**
78 + * Sets End Points Object Header.
79 + *
80 + * @param obj of PcepObjectHeader
81 + */
82 + public void setEndPointsObjHeader(PcepObjectHeader obj) {
83 + this.endPointsObjHeader = obj;
84 + }
85 +
86 + @Override
87 + public void setSourceIpAddress(int sourceIpAddress) {
88 + this.sourceIpAddress = sourceIpAddress;
89 + }
90 +
91 + @Override
92 + public void setDestIpAddress(int destIpAddress) {
93 + this.destIpAddress = destIpAddress;
94 + }
95 +
96 + @Override
97 + public int getSourceIpAddress() {
98 + return this.sourceIpAddress;
99 + }
100 +
101 + @Override
102 + public int getDestIpAddress() {
103 + return this.destIpAddress;
104 + }
105 +
106 + /**
107 + * Reads from channel buffer and returns object of PcepEndPointsObject.
108 + *
109 + * @param cb of channel buffer
110 + * @return object of PcepEndPointsObject
111 + * @throws PcepParseException while parsing channel buffer
112 + */
113 + public static PcepEndPointsObject read(ChannelBuffer cb) throws PcepParseException {
114 +
115 + PcepObjectHeader endPointsObjHeader;
116 + int sourceIpAddress;
117 + int destIpAddress;
118 +
119 + endPointsObjHeader = PcepObjectHeader.read(cb);
120 + if (END_POINTS_OBJ_TYPE == endPointsObjHeader.getObjType()
121 + && END_POINTS_OBJ_CLASS == endPointsObjHeader.getObjClass()) {
122 + sourceIpAddress = cb.readInt();
123 + destIpAddress = cb.readInt();
124 + } else {
125 + throw new PcepParseException("Expected PcepEndPointsObject.");
126 + }
127 + return new PcepEndPointsObjectVer1(endPointsObjHeader, sourceIpAddress, destIpAddress);
128 + }
129 +
130 + @Override
131 + public int write(ChannelBuffer cb) throws PcepParseException {
132 +
133 + int objStartIndex = cb.writerIndex();
134 + //write common header
135 + int objLenIndex = endPointsObjHeader.write(cb);
136 +
137 + //write source IPv4 IP
138 + cb.writeInt(sourceIpAddress);
139 + //write destination IPv4 IP
140 + cb.writeInt(destIpAddress);
141 +
142 + int length = cb.writerIndex() - objStartIndex;
143 + //now write EndPoints Object Length
144 + cb.setShort(objLenIndex, (short) length);
145 + //will be helpful during print().
146 + endPointsObjHeader.setObjLen((short) length);
147 +
148 + return cb.writerIndex();
149 +
150 + }
151 +
152 + /**
153 + * Builder class for PCEP end points objects.
154 + */
155 + public static class Builder implements PcepEndPointsObject.Builder {
156 +
157 + private boolean bIsHeaderSet = false;
158 + private boolean bIsSourceIpAddressset = false;
159 + private boolean bIsDestIpAddressset = false;
160 + private PcepObjectHeader endpointsObjHeader;
161 + private int sourceIpAddress;
162 + private int destIpAddress;
163 +
164 + private boolean bIsPFlagSet = false;
165 + private boolean bPFlag;
166 +
167 + private boolean bIsIFlagSet = false;
168 + private boolean bIFlag;
169 +
170 + @Override
171 + public PcepEndPointsObject build() throws PcepParseException {
172 +
173 + PcepObjectHeader endpointsObjHeader = this.bIsHeaderSet ? this.endpointsObjHeader
174 + : DEFAULT_END_POINTS_OBJECT_HEADER;
175 +
176 + if (bIsPFlagSet) {
177 + endpointsObjHeader.setPFlag(bPFlag);
178 + }
179 +
180 + if (bIsIFlagSet) {
181 + endpointsObjHeader.setIFlag(bIFlag);
182 + }
183 +
184 + if (!this.bIsSourceIpAddressset) {
185 + throw new PcepParseException("SourceIpAddress not set while building EndPoints object");
186 + }
187 +
188 + if (!this.bIsDestIpAddressset) {
189 + throw new PcepParseException("DestIpAddress not set while building EndPoints object");
190 + }
191 +
192 + return new PcepEndPointsObjectVer1(endpointsObjHeader, this.sourceIpAddress, this.destIpAddress);
193 + }
194 +
195 + @Override
196 + public PcepObjectHeader getEndPointsObjHeader() {
197 + return this.endpointsObjHeader;
198 + }
199 +
200 + @Override
201 + public Builder setEndPointsObjHeader(PcepObjectHeader obj) {
202 + this.endpointsObjHeader = obj;
203 + this.bIsHeaderSet = true;
204 + return this;
205 + }
206 +
207 + @Override
208 + public int getSourceIpAddress() {
209 + return this.sourceIpAddress;
210 + }
211 +
212 + @Override
213 + public Builder setSourceIpAddress(int sourceIpAddress) {
214 + this.sourceIpAddress = sourceIpAddress;
215 + this.bIsSourceIpAddressset = true;
216 + return this;
217 + }
218 +
219 + @Override
220 + public int getDestIpAddress() {
221 + return this.destIpAddress;
222 + }
223 +
224 + @Override
225 + public Builder setDestIpAddress(int destIpAddress) {
226 + this.destIpAddress = destIpAddress;
227 + this.bIsDestIpAddressset = true;
228 + return this;
229 + }
230 +
231 + @Override
232 + public Builder setPFlag(boolean value) {
233 + this.bPFlag = value;
234 + this.bIsPFlagSet = true;
235 + return this;
236 + }
237 +
238 + @Override
239 + public Builder setIFlag(boolean value) {
240 + this.bIFlag = value;
241 + this.bIsIFlagSet = true;
242 + return this;
243 + }
244 +
245 + }
246 +
247 + @Override
248 + public void print() {
249 +
250 + log.debug("ENDPOINT OBJECT");
251 + long lTemp;
252 + lTemp = sourceIpAddress & 0xFFFFFFFF;
253 + String str = "Source IP Address: " + lTemp;
254 + log.debug(str);
255 + lTemp = destIpAddress & 0xFFFFFFFF;
256 + str = "destination IP Address: " + lTemp;
257 + log.debug(str);
258 + }
259 +
260 + @Override
261 + public String toString() {
262 + return MoreObjects.toStringHelper(getClass())
263 + .add("sourceIpAddress", sourceIpAddress)
264 + .add("destIpAddress", destIpAddress)
265 + .toString();
266 + }
267 +
268 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcepEroObject;
25 +import org.onosproject.pcepio.types.AutonomousSystemTlv;
26 +import org.onosproject.pcepio.types.IPv4SubObject;
27 +import org.onosproject.pcepio.types.IPv6SubObject;
28 +import org.onosproject.pcepio.types.PathKeySubObject;
29 +import org.onosproject.pcepio.types.PcepErrorDetailInfo;
30 +import org.onosproject.pcepio.types.PcepObjectHeader;
31 +import org.onosproject.pcepio.types.PcepValueType;
32 +import org.onosproject.pcepio.types.SrEroSubObject;
33 +import org.slf4j.Logger;
34 +import org.slf4j.LoggerFactory;
35 +
36 +import com.google.common.base.MoreObjects;
37 +
38 +/*
39 + * rfc3209
40 + 0 1 2 3
41 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + | |
46 + // (Subobjects) //
47 + | |
48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 +
50 + If a Path message contains multiple EXPLICIT_ROUTE objects, only the
51 + first object is meaningful. Subsequent EXPLICIT_ROUTE objects MAY be
52 + ignored and SHOULD NOT be propagated.
53 +
54 + In current implementation, only strict hops are supported. So,
55 + empty ERO with no sub-objects is considered illegal.
56 +
57 + Subobjects:
58 + 0 1
59 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
60 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+
61 + |L| Type | Length | (Subobject contents) |
62 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+
63 +
64 + L
65 +
66 + The L bit is an attribute of the subobject. The L bit is set
67 + if the subobject represents a loose hop in the explicit route.
68 + If the bit is not set, the subobject represents a strict hop in
69 + the explicit route.
70 +
71 + Type
72 +
73 + The Type indicates the type of contents of the subobject.
74 +
75 +
76 + Subobject 1: IPv4 address
77 +
78 + 0 1 2 3
79 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
80 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 + |L| Type | Length | IPv4 address (4 bytes) |
82 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
83 + | IPv4 address (continued) | Prefix Length | Resvd |
84 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85 +
86 + Subobject 2: IPv6 Prefix
87 +
88 + 0 1 2 3
89 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
90 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91 + |L| Type | Length | IPv6 address (16 bytes) |
92 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93 + | IPv6 address (continued) |
94 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 + | IPv6 address (continued) |
96 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97 + | IPv6 address (continued) |
98 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
99 + | IPv6 address (continued) | Prefix Length | Resvd |
100 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
101 +
102 + Subobject 3: Autonomous System Number
103 +
104 + The contents of an Autonomous System (AS) number subobject are a 2-
105 + octet AS number. The abstract node represented by this subobject is
106 + the set of nodes belonging to the autonomous system.
107 +
108 + The length of the AS number subobject is 4 octets.
109 +
110 + Subobject 4: PATH_KEY_32_BIT_SUB_OBJ_TYPE:
111 +
112 + Pathkey subobject(RFC 5520):
113 + 0 1 2 3
114 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
115 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
116 + |L| Type | Length | Path-Key |
117 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
118 + | PCE ID (4 bytes) |
119 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120 +
121 + Subobject 5: SR_ERO_SUB_OBJ_TYPE:
122 +
123 + SR-ERO subobject: (draft-ietf-pce-segment-routing-00)
124 + 0 1 2 3
125 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
126 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
127 + |L| Type | Length | ST | Flags |F|S|C|M|
128 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
129 + | SID |
130 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131 + // NAI (variable) //
132 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
133 + */
134 +public class PcepEroObjectVer1 implements PcepEroObject {
135 +
136 + protected static final Logger log = LoggerFactory.getLogger(PcepEroObjectVer1.class);
137 +
138 + public static final byte ERO_OBJ_TYPE = 1;
139 + public static final byte ERO_OBJ_CLASS = 7;
140 + public static final byte ERO_OBJECT_VERSION = 1;
141 + public static final short ERO_OBJ_MINIMUM_LENGTH = 12;
142 + public static final byte IPV4_TYPE = 1;
143 + public static final byte PATH_KEY_32_BIT_SUB_OBJ_TYPE = 64;
144 + public static final int LABEL_SUB_OBJ_TYPE = 3;
145 + public static final int SR_ERO_SUB_OBJ_TYPE = 96;
146 + public static final int OBJECT_HEADER_LENGTH = 4;
147 + public static final int YTYPE_SHIFT_VALUE = 0x7F;
148 +
149 + static final PcepObjectHeader DEFAULT_ERO_OBJECT_HEADER = new PcepObjectHeader(ERO_OBJ_CLASS, ERO_OBJ_TYPE,
150 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, ERO_OBJ_MINIMUM_LENGTH);
151 +
152 + private PcepObjectHeader eroObjHeader;
153 + private LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
154 +
155 + /**
156 + * reset variables.
157 + */
158 + public PcepEroObjectVer1() {
159 + this.eroObjHeader = null;
160 + this.llSubObjects = null;
161 + }
162 +
163 + /**
164 + * Constructor to initialize parameters of ERO object.
165 + *
166 + * @param eroObjHeader ERO object header
167 + * @param llSubObjects list of sub objects.
168 + */
169 + public PcepEroObjectVer1(PcepObjectHeader eroObjHeader, LinkedList<PcepValueType> llSubObjects) {
170 +
171 + this.eroObjHeader = eroObjHeader;
172 + this.llSubObjects = llSubObjects;
173 + }
174 +
175 + /**
176 + * Returns ERO object header.
177 + *
178 + * @return eroObjHeader ERO object header
179 + */
180 + public PcepObjectHeader getEroObjHeader() {
181 + return this.eroObjHeader;
182 + }
183 +
184 + /**
185 + * Sets Object Header.
186 + *
187 + * @param obj ERO object header
188 + */
189 + public void setEroObjHeader(PcepObjectHeader obj) {
190 + this.eroObjHeader = obj;
191 + }
192 +
193 + @Override
194 + public LinkedList<PcepValueType> getSubObjects() {
195 + return this.llSubObjects;
196 + }
197 +
198 + @Override
199 + public void setSubObjects(LinkedList<PcepValueType> llSubObjects) {
200 + this.llSubObjects = llSubObjects;
201 + }
202 +
203 + /**
204 + * Reads from channel buffer and returns object of PcepEroObject.
205 + *
206 + * @param cb channel buffer.
207 + * @return object of PcepEroObject
208 + * @throws PcepParseException when ERO object is not present in channel buffer
209 + */
210 + public static PcepEroObject read(ChannelBuffer cb) throws PcepParseException {
211 +
212 + PcepObjectHeader eroObjHeader;
213 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
214 +
215 + eroObjHeader = PcepObjectHeader.read(cb);
216 +
217 + if (eroObjHeader.getObjClass() != PcepEroObjectVer1.ERO_OBJ_CLASS) {
218 + log.debug("ErrorType:" + PcepErrorDetailInfo.ERROR_TYPE_6 + " ErrorValue:"
219 + + PcepErrorDetailInfo.ERROR_VALUE_9);
220 + throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_9);
221 + }
222 +
223 + if (eroObjHeader.getObjLen() > OBJECT_HEADER_LENGTH) {
224 + ChannelBuffer tempCb = cb.readBytes(eroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
225 + llSubObjects = parseSubObjects(tempCb);
226 + }
227 + return new PcepEroObjectVer1(eroObjHeader, llSubObjects);
228 + }
229 +
230 + /**
231 + * Parse list of Sub Objects.
232 + *
233 + * @param cb channel buffer
234 + * @return list of Sub Objects
235 + * @throws PcepParseException when fails to parse sub object list
236 + */
237 + protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
238 +
239 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
240 +
241 + while (0 < cb.readableBytes()) {
242 +
243 + //check the Type of the TLV
244 + byte yType = cb.readByte();
245 + yType = (byte) (yType & (YTYPE_SHIFT_VALUE));
246 + byte hLength = cb.readByte();
247 +
248 + PcepValueType subObj;
249 +
250 + switch (yType) {
251 +
252 + case IPv4SubObject.TYPE:
253 + subObj = IPv4SubObject.read(cb);
254 + break;
255 + case IPv6SubObject.TYPE:
256 + byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH];
257 + cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH);
258 + subObj = new IPv6SubObject(ipv6Value);
259 + break;
260 + case AutonomousSystemTlv.TYPE:
261 + subObj = AutonomousSystemTlv.read(cb);
262 + break;
263 + case PathKeySubObject.TYPE:
264 + subObj = PathKeySubObject.read(cb);
265 + break;
266 + case SrEroSubObject.TYPE:
267 + subObj = SrEroSubObject.read(cb);
268 + break;
269 + default:
270 + throw new PcepParseException("Unexpected sub object. Type: " + (int) yType);
271 + }
272 + // Check for the padding
273 + int pad = hLength % 4;
274 + if (0 < pad) {
275 + pad = 4 - pad;
276 + if (pad <= cb.readableBytes()) {
277 + cb.skipBytes(pad);
278 + }
279 + }
280 +
281 + llSubObjects.add(subObj);
282 + }
283 + if (0 < cb.readableBytes()) {
284 + throw new PcepParseException("Subobject parsing error. Extra bytes received.");
285 + }
286 + return llSubObjects;
287 + }
288 +
289 + @Override
290 + public int write(ChannelBuffer cb) throws PcepParseException {
291 +
292 + //write Object header
293 + int objStartIndex = cb.writerIndex();
294 +
295 + int objLenIndex = eroObjHeader.write(cb);
296 +
297 + if (objLenIndex <= 0) {
298 + throw new PcepParseException("Failed to write ERO object header. Index " + objLenIndex);
299 + }
300 +
301 + ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
302 +
303 + while (listIterator.hasNext()) {
304 + listIterator.next().write(cb);
305 + }
306 +
307 + //Update object length now
308 + int length = cb.writerIndex() - objStartIndex;
309 + cb.setShort(objLenIndex, (short) length);
310 + //will be helpful during print().
311 + eroObjHeader.setObjLen((short) length);
312 +
313 + //As per RFC the length of object should be multiples of 4
314 + int pad = length % 4;
315 +
316 + if (pad != 0) {
317 + pad = 4 - pad;
318 + for (int i = 0; i < pad; i++) {
319 + cb.writeByte((byte) 0);
320 + }
321 + length = length + pad;
322 + }
323 +
324 + objLenIndex = cb.writerIndex();
325 + return objLenIndex;
326 + }
327 +
328 + /**
329 + * Builder class for PCEP ERO object.
330 + */
331 + public static class Builder implements PcepEroObject.Builder {
332 +
333 + private boolean bIsHeaderSet = false;
334 +
335 + private boolean bIsPFlagSet = false;
336 + private boolean bPFlag;
337 +
338 + private boolean bIsIFlagSet = false;
339 + private boolean bIFlag;
340 +
341 + private PcepObjectHeader eroObjHeader;
342 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
343 +
344 + @Override
345 + public PcepEroObject build() {
346 +
347 + PcepObjectHeader eroObjHeader = this.bIsHeaderSet ? this.eroObjHeader : DEFAULT_ERO_OBJECT_HEADER;
348 +
349 + if (bIsPFlagSet) {
350 + eroObjHeader.setPFlag(bPFlag);
351 + }
352 +
353 + if (bIsIFlagSet) {
354 + eroObjHeader.setIFlag(bIFlag);
355 + }
356 +
357 + return new PcepEroObjectVer1(eroObjHeader, this.llSubObjects);
358 + }
359 +
360 + @Override
361 + public PcepObjectHeader getEroObjHeader() {
362 + return this.eroObjHeader;
363 + }
364 +
365 + @Override
366 + public Builder setEroObjHeader(PcepObjectHeader obj) {
367 + this.eroObjHeader = obj;
368 + this.bIsHeaderSet = true;
369 + return this;
370 + }
371 +
372 + @Override
373 + public LinkedList<PcepValueType> getSubObjects() {
374 + return this.llSubObjects;
375 + }
376 +
377 + @Override
378 + public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) {
379 + this.llSubObjects = llSubObjects;
380 + return this;
381 + }
382 +
383 + @Override
384 + public Builder setPFlag(boolean value) {
385 + this.bPFlag = value;
386 + this.bIsPFlagSet = true;
387 + return this;
388 + }
389 +
390 + @Override
391 + public Builder setIFlag(boolean value) {
392 + this.bIFlag = value;
393 + this.bIsIFlagSet = true;
394 + return this;
395 + }
396 +
397 + }
398 +
399 + @Override
400 + public void print() {
401 +
402 + log.debug("ERO OBJECT");
403 + eroObjHeader.print();
404 + log.debug("SUBOBJECTS:");
405 + ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
406 + while (listIterator.hasNext()) {
407 + listIterator.next().print();
408 + }
409 + }
410 +
411 + @Override
412 + public String toString() {
413 + return MoreObjects.toStringHelper(getClass())
414 + .add("ero obj Header", eroObjHeader)
415 + .add("Sub-Objects", llSubObjects)
416 + .toString();
417 + }
418 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
20 +import org.onosproject.pcepio.protocol.PcepAttribute;
21 +import org.onosproject.pcepio.protocol.PcepBandwidthObject;
22 +import org.onosproject.pcepio.protocol.PcepCloseMsg;
23 +import org.onosproject.pcepio.protocol.PcepEndPointsObject;
24 +import org.onosproject.pcepio.protocol.PcepEroObject;
25 +import org.onosproject.pcepio.protocol.PcepFactory;
26 +import org.onosproject.pcepio.protocol.PcepInitiateMsg;
27 +import org.onosproject.pcepio.protocol.PcepKeepaliveMsg;
28 +import org.onosproject.pcepio.protocol.PcepLspObject;
29 +import org.onosproject.pcepio.protocol.PcepLspaObject;
30 +import org.onosproject.pcepio.protocol.PcepMessage;
31 +import org.onosproject.pcepio.protocol.PcepMessageReader;
32 +import org.onosproject.pcepio.protocol.PcepMetricObject;
33 +import org.onosproject.pcepio.protocol.PcepMsgPath;
34 +
35 +import org.onosproject.pcepio.protocol.PcepSrpObject;
36 +import org.onosproject.pcepio.protocol.PcepUpdateMsg;
37 +import org.onosproject.pcepio.protocol.PcepUpdateRequest;
38 +import org.onosproject.pcepio.protocol.PcepVersion;
39 +
40 +public class PcepFactoryVer1 implements PcepFactory {
41 +
42 + public static final PcepFactoryVer1 INSTANCE = new PcepFactoryVer1();
43 +
44 + @Override
45 + public org.onosproject.pcepio.protocol.PcepOpenMsg.Builder buildOpenMsg() {
46 + // TODO Auto-generated method stub
47 + return null;
48 + }
49 +
50 + @Override
51 + public org.onosproject.pcepio.protocol.PcepOpenObject.Builder buildOpenObject() {
52 + // TODO Auto-generated method stub
53 + return null;
54 + }
55 +
56 + @Override
57 + public PcepKeepaliveMsg.Builder buildKeepaliveMsg() {
58 + return new PcepKeepaliveMsgVer1.Builder();
59 + }
60 +
61 + @Override
62 + public PcepCloseMsg.Builder buildCloseMsg() {
63 + return new PcepCloseMsgVer1.Builder();
64 + }
65 +
66 + @Override
67 + public PcepUpdateMsg.Builder buildUpdateMsg() {
68 + return new PcepUpdateMsgVer1.Builder();
69 + }
70 +
71 + @Override
72 + public org.onosproject.pcepio.protocol.PcepReportMsg.Builder buildReportMsg() {
73 + // TODO Auto-generated method stub
74 + return null;
75 + }
76 +
77 + @Override
78 + public PcepInitiateMsg.Builder buildPcepInitiateMsg() {
79 + return new PcepInitiateMsgVer1.Builder();
80 + }
81 +
82 + @Override
83 + public PcepLspObject.Builder buildLspObject() {
84 + return new PcepLspObjectVer1.Builder();
85 + }
86 +
87 + @Override
88 + public PcepMessageReader<PcepMessage> getReader() {
89 + return PcepMessageVer1.READER;
90 + }
91 +
92 + @Override
93 + public PcepVersion getVersion() {
94 + return PcepVersion.PCEP_1;
95 + }
96 +
97 + @Override
98 + public PcepSrpObject.Builder buildSrpObject() {
99 + return new PcepSrpObjectVer1.Builder();
100 + }
101 +
102 + @Override
103 + public PcepEndPointsObject.Builder buildEndPointsObject() {
104 + return new PcepEndPointsObjectVer1.Builder();
105 + }
106 +
107 + @Override
108 + public PcepEroObject.Builder buildEroObject() {
109 + return new PcepEroObjectVer1.Builder();
110 + }
111 +
112 + @Override
113 + public org.onosproject.pcepio.protocol.PcepRroObject.Builder buildRroObject() {
114 + // TODO Auto-generated method stub
115 + return null;
116 + }
117 +
118 + @Override
119 + public PcepLspaObject.Builder buildLspaObject() {
120 + return new PcepLspaObjectVer1.Builder();
121 + }
122 +
123 + @Override
124 + public org.onosproject.pcepio.protocol.PcepIroObject.Builder buildIroObject() {
125 + // TODO Auto-generated method stub
126 + return null;
127 + }
128 +
129 + @Override
130 + public PcepMetricObject.Builder buildMetricObject() {
131 + return new PcepMetricObjectVer1.Builder();
132 + }
133 +
134 + @Override
135 + public PcepBandwidthObject.Builder buildBandwidthObject() {
136 + return new PcepBandwidthObjectVer1.Builder();
137 + }
138 +
139 + @Override
140 + public PcepMsgPath.Builder buildPcepMsgPath() {
141 + return new PcepMsgPathVer1.Builder();
142 + }
143 +
144 + @Override
145 + public org.onosproject.pcepio.protocol.PcepStateReport.Builder buildPcepStateReport() {
146 + // TODO Auto-generated method stub
147 + return null;
148 + }
149 +
150 + @Override
151 + public PcepUpdateRequest.Builder buildPcepUpdateRequest() {
152 + return new PcepUpdateRequestVer1.Builder();
153 + }
154 +
155 + @Override
156 + public PcInitiatedLspRequest.Builder buildPcInitiatedLspRequest() {
157 + return new PcInitiatedLspRequestVer1.Builder();
158 + }
159 +
160 + @Override
161 + public PcepAttribute.Builder buildPcepAttribute() {
162 + return new PcepAttributeVer1.Builder();
163 + }
164 +
165 + @Override
166 + public org.onosproject.pcepio.protocol.PcepLabelUpdateMsg.Builder buildPcepLabelUpdateMsg() {
167 + // TODO Auto-generated method stub
168 + return null;
169 + }
170 +
171 + @Override
172 + public org.onosproject.pcepio.protocol.PcepLabelUpdate.Builder buildPcepLabelUpdateObject() {
173 + // TODO Auto-generated method stub
174 + return null;
175 + }
176 +
177 + @Override
178 + public org.onosproject.pcepio.protocol.PcepLabelObject.Builder buildLabelObject() {
179 + // TODO Auto-generated method stub
180 + return null;
181 + }
182 +
183 + @Override
184 + public org.onosproject.pcepio.protocol.PcepErrorMsg.Builder buildPcepErrorMsg() {
185 + // TODO Auto-generated method stub
186 + return null;
187 + }
188 +
189 + @Override
190 + public org.onosproject.pcepio.protocol.PcepErrorObject.Builder buildPcepErrorObject() {
191 + // TODO Auto-generated method stub
192 + return null;
193 + }
194 +
195 + @Override
196 + public org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency.Builder buildFecIpv4Adjacency() {
197 + // TODO Auto-generated method stub
198 + return null;
199 + }
200 +
201 + @Override
202 + public org.onosproject.pcepio.protocol.PcepErrorInfo.Builder buildPcepErrorInfo() {
203 + // TODO Auto-generated method stub
204 + return null;
205 + }
206 +
207 + @Override
208 + public org.onosproject.pcepio.protocol.PcepError.Builder buildPcepError() {
209 + // TODO Auto-generated method stub
210 + return null;
211 + }
212 +
213 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
25 +import org.onosproject.pcepio.protocol.PcepAttribute;
26 +import org.onosproject.pcepio.protocol.PcepEndPointsObject;
27 +import org.onosproject.pcepio.protocol.PcepEroObject;
28 +import org.onosproject.pcepio.protocol.PcepInitiateMsg;
29 +import org.onosproject.pcepio.protocol.PcepLspObject;
30 +import org.onosproject.pcepio.protocol.PcepMessageReader;
31 +import org.onosproject.pcepio.protocol.PcepMessageWriter;
32 +import org.onosproject.pcepio.protocol.PcepSrpObject;
33 +import org.onosproject.pcepio.protocol.PcepType;
34 +import org.onosproject.pcepio.protocol.PcepVersion;
35 +import org.slf4j.Logger;
36 +import org.slf4j.LoggerFactory;
37 +
38 +import com.google.common.base.MoreObjects;
39 +
40 +class PcepInitiateMsgVer1 implements PcepInitiateMsg {
41 +
42 + protected static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgVer1.class);
43 +
44 + // Ref : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03, section 5.1
45 + /* <PCInitiate Message> ::= <Common Header>
46 + * <PCE-initiated-lsp-list>
47 + * Where:
48 + * <PCE-initiated-lsp-list> ::= <PCE-initiated-lsp-request>[<PCE-initiated-lsp-list>]
49 + * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
50 + * <PCE-initiated-lsp-instantiation> ::= <SRP>
51 + * <LSP>
52 + * <END-POINTS>
53 + * <ERO>
54 + * [<attribute-list>]
55 + * <PCE-initiated-lsp-deletion> ::= <SRP>
56 + * <LSP>
57 + */
58 +
59 + static final byte PACKET_VERSION = 1;
60 + /* considering LspDelete Request PcInitiate msg will contain
61 + * common header
62 + * srp object
63 + * lsp object
64 + * so min length for this can be
65 + * PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+SrpObjectMinLen(12)+LspObjectMinLen(8)
66 + */
67 + public static final short PACKET_MINIMUM_LENGTH = 24;
68 + public static final short MINIMUM_COMMON_HEADER_LENGTH = 4;
69 + public static final PcepType MSG_TYPE = PcepType.INITIATE;
70 + private LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
71 + public static final PcepInitiateMsgVer1.Reader READER = new Reader();
72 +
73 + static class Reader implements PcepMessageReader<PcepInitiateMsg> {
74 +
75 + LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
76 +
77 + @Override
78 + public PcepInitiateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
79 +
80 + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
81 + return null;
82 + }
83 +
84 + llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>();
85 +
86 + byte version = cb.readByte();
87 + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
88 + if (version != PACKET_VERSION) {
89 + throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), received=" + version);
90 + }
91 + byte type = cb.readByte();
92 + if (type != MSG_TYPE.getType()) {
93 + throw new PcepParseException("Wrong type. Expected=PcepType.INITIATE(12), recived=" + type);
94 + }
95 + short length = cb.readShort();
96 +
97 + if (length < PACKET_MINIMUM_LENGTH) {
98 + throw new PcepParseException("Wrong length. Initiate message length expected to be >= "
99 + + PACKET_MINIMUM_LENGTH + ", but received=" + length);
100 + }
101 +
102 + log.debug("reading PcInitiate message of length " + length);
103 +
104 + // parse Start initiate/deletion list
105 + if (!parsePcInitiatedLspRequestList(cb)) {
106 + throw new PcepParseException("Parsing PCE-initiated-lsp-Request-list failed");
107 + }
108 +
109 + return new PcepInitiateMsgVer1(llPcInitiatedLspRequestList);
110 + }
111 +
112 + /**
113 + * To parse PcInitiatedLspRequestList from PcInitiate Message.
114 + *
115 + * @param cb of type channel buffer
116 + * @return true if parsing PcInitiatedLspRequestList is success, false otherwise
117 + * @throws PcepParseException while parsing from channel buffer
118 + */
119 + public boolean parsePcInitiatedLspRequestList(ChannelBuffer cb) throws PcepParseException {
120 +
121 + boolean isDelLspRequest = false;
122 +
123 + if (null == cb) {
124 + throw new PcepParseException("Channel buffer is empty");
125 + }
126 +
127 + while (0 < cb.readableBytes()) {
128 + PcInitiatedLspRequest pceInitLspReq = new PcInitiatedLspRequestVer1();
129 +
130 + //store SRP object
131 + PcepSrpObject srpObj;
132 + srpObj = PcepSrpObjectVer1.read(cb);
133 + pceInitLspReq.setSrpObject(srpObj);
134 + isDelLspRequest = srpObj.getRFlag();
135 +
136 + //store LSP object
137 + PcepLspObject lspObj;
138 + lspObj = PcepLspObjectVer1.read(cb);
139 + pceInitLspReq.setLspObject(lspObj);
140 +
141 + /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects
142 + * so if R bit is not set then we should read for Ero and EndPoint objects also.
143 + */
144 + if (!isDelLspRequest) {
145 +
146 + //store EndPoint object
147 + PcepEndPointsObject endPointObj;
148 + endPointObj = PcepEndPointsObjectVer1.read(cb);
149 + pceInitLspReq.setEndPointsObject(endPointObj);
150 +
151 + //store ERO object
152 + PcepEroObject eroObj;
153 + eroObj = PcepEroObjectVer1.read(cb);
154 + pceInitLspReq.setEroObject(eroObj);
155 +
156 + if (cb.readableBytes() > MINIMUM_COMMON_HEADER_LENGTH) {
157 + pceInitLspReq.setPcepAttribute(PcepAttributeVer1.read(cb));
158 + }
159 + }
160 + llPcInitiatedLspRequestList.add(pceInitLspReq);
161 + }
162 +
163 + return true;
164 + }
165 + }
166 +
167 + /**
168 + * Constructor to initialize PcInitiatedLspRequest.
169 + *
170 + * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequest
171 + */
172 + PcepInitiateMsgVer1(LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList) {
173 +
174 + if (llPcInitiatedLspRequestList == null) {
175 + throw new NullPointerException("PcInitiatedLspRequestList cannot be null.");
176 + }
177 + this.llPcInitiatedLspRequestList = llPcInitiatedLspRequestList;
178 + }
179 +
180 + /**
181 + * Builder class for PCEP initiate message.
182 + */
183 + static class Builder implements PcepInitiateMsg.Builder {
184 +
185 + // Pcep initiate message fields
186 + LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
187 +
188 + @Override
189 + public PcepVersion getVersion() {
190 + return PcepVersion.PCEP_1;
191 + }
192 +
193 + @Override
194 + public PcepType getType() {
195 + return PcepType.INITIATE;
196 + }
197 +
198 + @Override
199 + public PcepInitiateMsg build() {
200 + return new PcepInitiateMsgVer1(this.llPcInitiatedLspRequestList);
201 + }
202 +
203 + @Override
204 + public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
205 + return this.llPcInitiatedLspRequestList;
206 + }
207 +
208 + @Override
209 + public Builder setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) {
210 + this.llPcInitiatedLspRequestList = ll;
211 + return this;
212 + }
213 + }
214 +
215 + @Override
216 + public void writeTo(ChannelBuffer cb) throws PcepParseException {
217 + WRITER.write(cb, this);
218 + }
219 +
220 + static final Writer WRITER = new Writer();
221 +
222 + static class Writer implements PcepMessageWriter<PcepInitiateMsgVer1> {
223 +
224 + @Override
225 + public void write(ChannelBuffer cb, PcepInitiateMsgVer1 message) throws PcepParseException {
226 +
227 + boolean isDelLspRequest = false;
228 + int startIndex = cb.writerIndex();
229 + // first 3 bits set to version
230 + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
231 + // message type 0xC
232 + cb.writeByte(MSG_TYPE.getType());
233 + // length is length of variable message, will be updated at the end
234 + // Store the position of message
235 + // length in buffer
236 + int msgLenIndex = cb.writerIndex();
237 + cb.writeShort(0);
238 +
239 + ListIterator<PcInitiatedLspRequest> listIterator = message.llPcInitiatedLspRequestList.listIterator();
240 +
241 + while (listIterator.hasNext()) {
242 +
243 + PcInitiatedLspRequest listReq = listIterator.next();
244 +
245 + //Srp Object is mandatory
246 + PcepSrpObject srpObj = listReq.getSrpObject();
247 + if (srpObj instanceof PcepSrpObject) {
248 + isDelLspRequest = srpObj.getRFlag();
249 + srpObj.write(cb);
250 + } else {
251 + throw new PcepParseException("SRP Object is mandatory for PcInitiate message.");
252 + }
253 +
254 + //LSP Object is mandatory
255 + PcepLspObject lspObj = listReq.getLspObject();
256 + if (lspObj instanceof PcepLspObject) {
257 + lspObj.write(cb);
258 + } else {
259 + throw new PcepParseException("LSP Object is mandatory for PcInitiate message.");
260 + }
261 +
262 + /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects
263 + * so if R bit is not set then we should read for Ero and EndPoint objects also.
264 + */
265 +
266 + if (!isDelLspRequest) {
267 +
268 + //EndPoints object is mandatory
269 + PcepEndPointsObject endPointObj = listReq.getEndPointsObject();
270 + if (endPointObj instanceof PcepEndPointsObject) {
271 + endPointObj.write(cb);
272 + } else {
273 + throw new PcepParseException("End points Object is mandatory for PcInitiate message.");
274 + }
275 +
276 + //Ero object is mandatory
277 + PcepEroObject eroObj = listReq.getEroObject();
278 + if (eroObj instanceof PcepEroObject) {
279 + eroObj.write(cb);
280 + } else {
281 + throw new PcepParseException("ERO Object is mandatory for PcInitiate message.");
282 + }
283 +
284 + //PcepAttribute is optional
285 + PcepAttribute pcepAttribute = listReq.getPcepAttribute();
286 + if (pcepAttribute instanceof PcepAttribute) {
287 + pcepAttribute.write(cb);
288 + }
289 + }
290 + }
291 +
292 + // PCInitiate message length field
293 + int length = cb.writerIndex() - startIndex;
294 + cb.setShort(msgLenIndex, (short) length);
295 + }
296 + }
297 +
298 + @Override
299 + public PcepVersion getVersion() {
300 + return PcepVersion.PCEP_1;
301 + }
302 +
303 + @Override
304 + public PcepType getType() {
305 + return MSG_TYPE;
306 + }
307 +
308 + @Override
309 + public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
310 + return this.llPcInitiatedLspRequestList;
311 + }
312 +
313 + @Override
314 + public void setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) {
315 + this.llPcInitiatedLspRequestList = ll;
316 + }
317 +
318 + @Override
319 + public void print() {
320 +
321 + log.debug("PCEP INITIATE MESSAGE");
322 + ListIterator<PcInitiatedLspRequest> listIterator = llPcInitiatedLspRequestList.listIterator();
323 + while (listIterator.hasNext()) {
324 + listIterator.next().print();
325 + }
326 + }
327 +
328 + @Override
329 + public String toString() {
330 + return MoreObjects.toStringHelper(getClass())
331 + .add("PC initiaited lsp request list", llPcInitiatedLspRequestList)
332 + .toString();
333 + }
334 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcepIroObject;
25 +import org.onosproject.pcepio.types.IPv4SubObject;
26 +import org.onosproject.pcepio.types.PcepObjectHeader;
27 +import org.onosproject.pcepio.types.PcepValueType;
28 +import org.slf4j.Logger;
29 +import org.slf4j.LoggerFactory;
30 +
31 +import com.google.common.base.MoreObjects;
32 +
33 +/*
34 + 0 1 2 3
35 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 + | |
38 + // (Sub-objects) //
39 + | |
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 +
42 + The IRO Object format
43 +
44 + Each IPV4 suboject
45 +
46 + 0 1 2 3
47 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 + |L| Type | Length | IPv4 address (4 bytes) |
50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 + | IPv4 address (continued) | Prefix Length | Resvd |
52 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 + */
54 +public class PcepIroObjectVer1 implements PcepIroObject {
55 +
56 + protected static final Logger log = LoggerFactory.getLogger(PcepIroObjectVer1.class);
57 +
58 + public static final byte IRO_OBJ_TYPE = 1;
59 + public static final byte IRO_OBJ_CLASS = 10;
60 + public static final byte IRO_OBJECT_VERSION = 1;
61 + public static final short IRO_OBJ_MINIMUM_LENGTH = 12;
62 + public static final int OBJECT_HEADER_LENGTH = 4;
63 + public static final int YTYPE_SHIFT_VALUE = 0x7F;
64 +
65 + public static final PcepObjectHeader DEFAULT_IRO_OBJECT_HEADER = new PcepObjectHeader(IRO_OBJ_CLASS, IRO_OBJ_TYPE,
66 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, IRO_OBJ_MINIMUM_LENGTH);
67 +
68 + private short iroObjType = 0;
69 + private byte yLength;
70 + private byte yPrefixLength;
71 + private byte yResvd;
72 + private PcepObjectHeader iroObjHeader;
73 + private LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
74 +
75 + /**
76 + * Default constructor.
77 + */
78 + public PcepIroObjectVer1() {
79 + this.iroObjHeader = null;
80 + this.iroObjType = 0;
81 + this.yLength = 0;
82 + }
83 +
84 + /**
85 + * Constructor to initialize member variables.
86 + *
87 + * @param iroObjHeader IRO object header
88 + * @param llSubObjects list of sub-objects
89 + */
90 + public PcepIroObjectVer1(PcepObjectHeader iroObjHeader, LinkedList<PcepValueType> llSubObjects) {
91 + this.iroObjHeader = iroObjHeader;
92 + this.llSubObjects = llSubObjects;
93 + }
94 +
95 + /**
96 + * Returns object header.
97 + *
98 + * @return iroObjHeader IRO object header
99 + */
100 + public PcepObjectHeader getIroObjHeader() {
101 + return this.iroObjHeader;
102 + }
103 +
104 + /**
105 + * Sets IRO Object Header.
106 + *
107 + * @param obj IRO object header
108 + */
109 + public void setIroObjHeader(PcepObjectHeader obj) {
110 + this.iroObjHeader = obj;
111 + }
112 +
113 + @Override
114 + public LinkedList<PcepValueType> getSubObjects() {
115 + return this.llSubObjects;
116 + }
117 +
118 + @Override
119 + public void setSubObjects(LinkedList<PcepValueType> llSubObjects) {
120 + this.llSubObjects = llSubObjects;
121 + }
122 +
123 + /**
124 + * Reads from channel buffer and return object of PcepIroObject.
125 + *
126 + * @param cb of type channel buffer
127 + * @return object of PcepIroObject
128 + * @throws PcepParseException while parsing from channel buffer
129 + */
130 + public static PcepIroObject read(ChannelBuffer cb) throws PcepParseException {
131 +
132 + PcepObjectHeader iroObjHeader;
133 + LinkedList<PcepValueType> llSubObjects;
134 +
135 + iroObjHeader = PcepObjectHeader.read(cb);
136 +
137 + //take only IroObject buffer.
138 + ChannelBuffer tempCb = cb.readBytes(iroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
139 + llSubObjects = parseSubObjects(tempCb);
140 + return new PcepIroObjectVer1(iroObjHeader, llSubObjects);
141 + }
142 +
143 + /**
144 + * Returns linked list of sub objects.
145 + *
146 + * @param cb of type channel buffer
147 + * @return linked list of sub objects
148 + * @throws PcepParseException while parsing subobjects from channel buffer
149 + */
150 + protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
151 +
152 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
153 +
154 + while (0 < cb.readableBytes()) {
155 +
156 + //check the Type of the Subobjects.
157 + byte yType = cb.readByte();
158 + yType = (byte) (yType & (YTYPE_SHIFT_VALUE));
159 + byte hLength = cb.readByte();
160 +
161 + PcepValueType subObj;
162 + switch (yType) {
163 +
164 + case IPv4SubObject.TYPE:
165 + subObj = IPv4SubObject.read(cb);
166 + break;
167 +
168 + default:
169 + throw new PcepParseException("Invalid sub object. Type: " + (int) yType);
170 + }
171 +
172 + // Check for the padding
173 + int pad = hLength % 4;
174 + if (0 < pad) {
175 + pad = 4 - pad;
176 + if (pad <= cb.readableBytes()) {
177 + cb.skipBytes(pad);
178 + }
179 + }
180 + llSubObjects.add(subObj);
181 + }
182 + return llSubObjects;
183 + }
184 +
185 + @Override
186 + public int write(ChannelBuffer cb) throws PcepParseException {
187 + //write Object header
188 + int objStartIndex = cb.writerIndex();
189 +
190 + int objLenIndex = iroObjHeader.write(cb);
191 +
192 + if (objLenIndex <= 0) {
193 + throw new PcepParseException(" ObjectLength is " + objLenIndex);
194 + }
195 +
196 + ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
197 + while (listIterator.hasNext()) {
198 + listIterator.next().write(cb);
199 + }
200 +
201 + //Update object length now
202 + int length = cb.writerIndex() - objStartIndex;
203 + //will be helpful during print().
204 + iroObjHeader.setObjLen((short) length);
205 + // As per RFC the length of object should be
206 + // multiples of 4
207 + int pad = length % 4;
208 + if (pad != 0) {
209 + pad = 4 - pad;
210 + for (int i = 0; i < pad; i++) {
211 + cb.writeByte((byte) 0);
212 + }
213 + length = length + pad;
214 + }
215 + cb.setShort(objLenIndex, (short) length);
216 + objLenIndex = cb.writerIndex();
217 + return objLenIndex;
218 + }
219 +
220 + public static class Builder implements PcepIroObject.Builder {
221 +
222 + private boolean bIsHeaderSet = false;
223 +
224 + private PcepObjectHeader iroObjHeader;
225 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
226 +
227 + private boolean bIsPFlagSet = false;
228 + private boolean bPFlag;
229 +
230 + private boolean bIsIFlagSet = false;
231 + private boolean bIFlag;
232 +
233 + @Override
234 + public PcepIroObject build() {
235 +
236 + PcepObjectHeader iroObjHeader = this.bIsHeaderSet ? this.iroObjHeader : DEFAULT_IRO_OBJECT_HEADER;
237 +
238 + if (bIsPFlagSet) {
239 + iroObjHeader.setPFlag(bPFlag);
240 + }
241 +
242 + if (bIsIFlagSet) {
243 + iroObjHeader.setIFlag(bIFlag);
244 + }
245 +
246 + return new PcepIroObjectVer1(iroObjHeader, this.llSubObjects);
247 + }
248 +
249 + @Override
250 + public PcepObjectHeader getIroObjHeader() {
251 + return this.iroObjHeader;
252 + }
253 +
254 + @Override
255 + public Builder setIroObjHeader(PcepObjectHeader obj) {
256 + this.iroObjHeader = obj;
257 + this.bIsHeaderSet = true;
258 + return this;
259 + }
260 +
261 + @Override
262 + public LinkedList<PcepValueType> getSubObjects() {
263 + return this.llSubObjects;
264 + }
265 +
266 + @Override
267 + public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) {
268 + this.llSubObjects = llSubObjects;
269 + return this;
270 + }
271 +
272 + @Override
273 + public Builder setPFlag(boolean value) {
274 + this.bPFlag = value;
275 + this.bIsPFlagSet = true;
276 + return this;
277 + }
278 +
279 + @Override
280 + public Builder setIFlag(boolean value) {
281 + this.bIFlag = value;
282 + this.bIsIFlagSet = true;
283 + return this;
284 + }
285 +
286 + }
287 +
288 + @Override
289 + public void print() {
290 + log.debug("IRO OBJECT");
291 + iroObjHeader.print();
292 + log.debug("SUBOBJECTS:");
293 + ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
294 + while (listIterator.hasNext()) {
295 + listIterator.next().print();
296 + }
297 + }
298 +
299 + @Override
300 + public String toString() {
301 + return MoreObjects.toStringHelper(getClass())
302 + .add("IRO object header", iroObjHeader)
303 + .add("List of sub object", llSubObjects)
304 + .toString();
305 + }
306 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.jboss.netty.buffer.ChannelBuffer;
20 +import org.onosproject.pcepio.exceptions.PcepParseException;
21 +import org.onosproject.pcepio.protocol.PcepKeepaliveMsg;
22 +import org.onosproject.pcepio.protocol.PcepMessageReader;
23 +import org.onosproject.pcepio.protocol.PcepMessageWriter;
24 +import org.onosproject.pcepio.protocol.PcepType;
25 +import org.onosproject.pcepio.protocol.PcepVersion;
26 +import org.slf4j.Logger;
27 +import org.slf4j.LoggerFactory;
28 +
29 +class PcepKeepaliveMsgVer1 implements PcepKeepaliveMsg {
30 +
31 + /*
32 + <Keepalive Message>::= <Common Header>
33 +
34 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 + | Ver | Flags | Message-Type | Message-Length |
37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 + */
39 +
40 + protected static final Logger log = LoggerFactory.getLogger(PcepKeepaliveMsgVer1.class);
41 + // Pcep version: 1
42 + public static final byte PACKET_VERSION = 1;
43 + public static final int PACKET_MINIMUM_LENGTH = 4;
44 + public static final PcepType MSG_TYPE = PcepType.KEEP_ALIVE;
45 +
46 + public static final PcepKeepaliveMsgVer1.Reader READER = new Reader();
47 +
48 + static class Reader implements PcepMessageReader<PcepKeepaliveMsg> {
49 +
50 + @Override
51 + public PcepKeepaliveMsg readFrom(ChannelBuffer cb) throws PcepParseException {
52 +
53 + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
54 + throw new PcepParseException("Packet size is less than the minimum required length.");
55 + }
56 + // fixed value property version == 1
57 + byte version = cb.readByte();
58 + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
59 + if (version != PACKET_VERSION) {
60 + throw new PcepParseException("Wrong version: Expected=PcepVersion.KEEP_ALIVE_1(2), got=" + version);
61 + }
62 + // fixed value property type == 2
63 + byte type = cb.readByte();
64 + if (type != MSG_TYPE.getType()) {
65 + throw new PcepParseException("Wrong type: Expected=PcepType.KEEP_ALIVE_1(2), got=" + type);
66 + }
67 + short length = cb.readShort();
68 + if (length < PACKET_MINIMUM_LENGTH) {
69 + throw new PcepParseException("Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
70 + + length);
71 + }
72 + return new PcepKeepaliveMsgVer1();
73 + }
74 + }
75 +
76 + /**
77 + * Default constructor.
78 + */
79 + PcepKeepaliveMsgVer1() {
80 + }
81 +
82 + static class Builder implements PcepKeepaliveMsg.Builder {
83 + @Override
84 + public PcepVersion getVersion() {
85 + return PcepVersion.PCEP_1;
86 + }
87 +
88 + @Override
89 + public PcepType getType() {
90 + return PcepType.KEEP_ALIVE;
91 + }
92 +
93 + @Override
94 + public PcepKeepaliveMsg build() {
95 + return new PcepKeepaliveMsgVer1();
96 + }
97 + }
98 +
99 + @Override
100 + public void writeTo(ChannelBuffer cb) {
101 + WRITER.write(cb, this);
102 + }
103 +
104 + static final Writer WRITER = new Writer();
105 +
106 + static class Writer implements PcepMessageWriter<PcepKeepaliveMsgVer1> {
107 +
108 + @Override
109 + public void write(ChannelBuffer cb, PcepKeepaliveMsgVer1 message) {
110 + int startIndex = cb.writerIndex();
111 + // first 3 bits set to version
112 + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
113 + // message type
114 + cb.writeByte(MSG_TYPE.getType());
115 + // length is length of variable message, will be updated at the end
116 + // Store the position of message
117 + // length in buffer
118 + int msgLenIndex = cb.writerIndex();
119 + cb.writeShort((short) 0);
120 + // update message length field
121 + int length = cb.writerIndex() - startIndex;
122 + cb.setShort(msgLenIndex, (short) length);
123 + }
124 + }
125 +
126 + @Override
127 + public PcepVersion getVersion() {
128 + return PcepVersion.PCEP_1;
129 + }
130 +
131 + @Override
132 + public PcepType getType() {
133 + return MSG_TYPE;
134 + }
135 +
136 + @Override
137 + public void print() {
138 + log.debug("KEEPALIVE MESSAGE");
139 + }
140 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcepLspObject;
25 +import org.onosproject.pcepio.types.PcepErrorDetailInfo;
26 +import org.onosproject.pcepio.types.PcepObjectHeader;
27 +import org.onosproject.pcepio.types.PcepValueType;
28 +import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
29 +import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
30 +import org.onosproject.pcepio.types.StatefulRsvpErrorSpecTlv;
31 +import org.onosproject.pcepio.types.SymbolicPathNameTlv;
32 +import org.slf4j.Logger;
33 +import org.slf4j.LoggerFactory;
34 +
35 +import com.google.common.base.MoreObjects;
36 +
37 +/*
38 + message format.
39 + Reference : draft-ietf-pce-stateful-pce-11, section 7.3.
40 + 0 1 2 3
41 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + | PLSP-ID | Flag | O|A|R|S|D|
46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 + // TLVs //
48 + | |
49 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 +
51 + The LSP Object format
52 + */
53 +
54 +public class PcepLspObjectVer1 implements PcepLspObject {
55 +
56 + protected static final Logger log = LoggerFactory.getLogger(PcepLspObjectVer1.class);
57 +
58 + public static final byte LSP_OBJ_TYPE = 1;
59 + public static final byte LSP_OBJ_CLASS = 32;
60 + public static final byte LSP_OBJECT_VERSION = 1;
61 +
62 + // LSP_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ LspObjectHeaderLen(4)+TlvAssumedMinLength(8)
63 + public static final short LSP_OBJ_MINIMUM_LENGTH = 16;
64 +
65 + public static final int DEFAULT_PLSPID = 0;
66 + public static final byte DEFAULT_OFLAG = 1;
67 + public static final boolean DEFAULT_AFLAG = false;
68 + public static final boolean DEFAULT_RFLAG = false;
69 + public static final boolean DEFAULT_SFLAG = false;
70 + public static final boolean DEFAULT_DFLAG = false;
71 + public static final int OBJECT_HEADER_LENGTH = 4;
72 + public static final int PLSPID_SHIFT_VALUE = 12;
73 + public static final int OFLAG_SHIFT_VALUE = 4;
74 + public static final int AFLAG_SHIFT_VALUE = 3;
75 + public static final int RFLAG_SHIFT_VALUE = 2;
76 + public static final int SFLAG_SHIFT_VALUE = 1;
77 + public static final int PLSPID_TEMP_SHIFT_VALUE = 0xFFFFF000;
78 + public static final int OFLAG_TEMP_SHIFT_VALUE = 0x70;
79 + public static final int AFLAG_TEMP_SHIFT_VALUE = 0x08;
80 + public static final int RFLAG_TEMP_SHIFT_VALUE = 0x04;
81 + public static final int SFLAG_TEMP_SHIFT_VALUE = 0x02;
82 + public static final int DFLAG_TEMP_SHIFT_VALUE = 0x01;
83 + public static final int BIT_SET = 1;
84 + public static final int BIT_RESET = 0;
85 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
86 +
87 + static final PcepObjectHeader DEFAULT_LSP_OBJECT_HEADER = new PcepObjectHeader(LSP_OBJ_CLASS, LSP_OBJ_TYPE,
88 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSP_OBJ_MINIMUM_LENGTH);
89 +
90 + private PcepObjectHeader lspObjHeader;
91 + private int iPlspId;
92 + // 3-bits
93 + private byte yOFlag;
94 + private boolean bAFlag;
95 + private boolean bRFlag;
96 + private boolean bSFlag;
97 + private boolean bDFlag;
98 +
99 + // Optional TLV
100 + private LinkedList<PcepValueType> llOptionalTlv;
101 +
102 + /**
103 + * Constructor to initialize all the member variables.
104 + *
105 + * @param lspObjHeader lsp object header
106 + * @param iPlspId plsp id
107 + * @param yOFlag O flag
108 + * @param bAFlag A flag
109 + * @param bRFlag R flag
110 + * @param bSFlag S flag
111 + * @param bDFlag D flag
112 + * @param llOptionalTlv list of optional tlv
113 + */
114 + public PcepLspObjectVer1(PcepObjectHeader lspObjHeader, int iPlspId, byte yOFlag, boolean bAFlag, boolean bRFlag,
115 + boolean bSFlag, boolean bDFlag, LinkedList<PcepValueType> llOptionalTlv) {
116 +
117 + this.lspObjHeader = lspObjHeader;
118 + this.iPlspId = iPlspId;
119 + this.yOFlag = yOFlag;
120 + this.bAFlag = bAFlag;
121 + this.bRFlag = bRFlag;
122 + this.bSFlag = bSFlag;
123 + this.bDFlag = bDFlag;
124 + this.llOptionalTlv = llOptionalTlv;
125 + }
126 +
127 + /**
128 + * Sets lsp Object Header.
129 + *
130 + * @param obj lsp object header
131 + */
132 + public void setLspObjHeader(PcepObjectHeader obj) {
133 + this.lspObjHeader = obj;
134 + }
135 +
136 + @Override
137 + public void setPlspId(int iPlspId) {
138 + this.iPlspId = iPlspId;
139 + }
140 +
141 + @Override
142 + public void setOFlag(byte yOFlag) {
143 + this.yOFlag = yOFlag;
144 + }
145 +
146 + @Override
147 + public void setAFlag(boolean bAFlag) {
148 + this.bAFlag = bAFlag;
149 + }
150 +
151 + @Override
152 + public void setRFlag(boolean bRFlag) {
153 + this.bRFlag = bRFlag;
154 + }
155 +
156 + @Override
157 + public void setSFlag(boolean bSFlag) {
158 + this.bSFlag = bSFlag;
159 + }
160 +
161 + @Override
162 + public void setDFlag(boolean bDFlag) {
163 + this.bDFlag = bDFlag;
164 + }
165 +
166 + /**
167 + * Returns lsp object header.
168 + *
169 + * @return lspObjHeader
170 + */
171 + public PcepObjectHeader getLspObjHeader() {
172 + return this.lspObjHeader;
173 + }
174 +
175 + @Override
176 + public int getPlspId() {
177 + return this.iPlspId;
178 + }
179 +
180 + @Override
181 + public byte getOFlag() {
182 + return this.yOFlag;
183 + }
184 +
185 + @Override
186 + public boolean getAFlag() {
187 + return this.bAFlag;
188 + }
189 +
190 + @Override
191 + public boolean getRFlag() {
192 + return this.bRFlag;
193 + }
194 +
195 + @Override
196 + public boolean getSFlag() {
197 + return this.bSFlag;
198 + }
199 +
200 + @Override
201 + public boolean getDFlag() {
202 + return this.bDFlag;
203 + }
204 +
205 + @Override
206 + public LinkedList<PcepValueType> getOptionalTlv() {
207 + return this.llOptionalTlv;
208 + }
209 +
210 + @Override
211 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
212 + this.llOptionalTlv = llOptionalTlv;
213 + }
214 +
215 + /**
216 + * Parse channel buffer and returns object of PcepLspObject.
217 + *
218 + * @param cb of type channel buffer
219 + * @return object of PcepLspObject
220 + * @throws PcepParseException when lsp object is not present in channel buffer
221 + */
222 + public static PcepLspObject read(ChannelBuffer cb) throws PcepParseException {
223 +
224 + PcepObjectHeader lspObjHeader;
225 + int iPlspId;
226 + // 3-bits
227 + byte yOFlag;
228 + boolean bAFlag;
229 + boolean bRFlag;
230 + boolean bSFlag;
231 + boolean bDFlag;
232 +
233 + // Optional TLV
234 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
235 +
236 + lspObjHeader = PcepObjectHeader.read(cb);
237 +
238 + if (lspObjHeader.getObjClass() != PcepLspObjectVer1.LSP_OBJ_CLASS) {
239 + throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_8);
240 + }
241 + //take only LspObject buffer.
242 + ChannelBuffer tempCb = cb.readBytes(lspObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
243 +
244 + Integer iTemp = tempCb.readInt();
245 + iPlspId = (iTemp & PLSPID_TEMP_SHIFT_VALUE) >> PLSPID_SHIFT_VALUE;
246 + Integer iX = (iTemp & OFLAG_TEMP_SHIFT_VALUE) >> OFLAG_SHIFT_VALUE;
247 + yOFlag = iX.byteValue();
248 + iX = (iTemp & AFLAG_TEMP_SHIFT_VALUE) >> AFLAG_SHIFT_VALUE;
249 + bAFlag = (iX > 0) ? true : false;
250 + iX = (iTemp & RFLAG_TEMP_SHIFT_VALUE) >> RFLAG_SHIFT_VALUE;
251 + bRFlag = (iX > 0) ? true : false;
252 + iX = (iTemp & SFLAG_TEMP_SHIFT_VALUE) >> SFLAG_SHIFT_VALUE;
253 + bSFlag = (iX > 0) ? true : false;
254 + iX = iTemp & DFLAG_TEMP_SHIFT_VALUE;
255 + bDFlag = (iX > 0) ? true : false;
256 +
257 + // parse optional TLV
258 + llOptionalTlv = parseOptionalTlv(tempCb);
259 +
260 + return new PcepLspObjectVer1(lspObjHeader, iPlspId, yOFlag, bAFlag, bRFlag, bSFlag, bDFlag, llOptionalTlv);
261 + }
262 +
263 + @Override
264 + public int write(ChannelBuffer cb) throws PcepParseException {
265 +
266 + //write Object header
267 + int objStartIndex = cb.writerIndex();
268 +
269 + int objLenIndex = lspObjHeader.write(cb);
270 +
271 + if (objLenIndex <= 0) {
272 + throw new PcepParseException("Failed to write lsp object header. Index " + objLenIndex);
273 + }
274 +
275 + int iTemp = iPlspId << PLSPID_SHIFT_VALUE;
276 + iTemp = iTemp | (yOFlag << OFLAG_SHIFT_VALUE);
277 + byte bFlag;
278 + iTemp = bAFlag ? (iTemp | AFLAG_TEMP_SHIFT_VALUE) : iTemp;
279 +
280 + bFlag = (bRFlag) ? (byte) BIT_SET : BIT_RESET;
281 + iTemp = iTemp | (bFlag << RFLAG_SHIFT_VALUE);
282 + bFlag = (bSFlag) ? (byte) BIT_SET : BIT_RESET;
283 + iTemp = iTemp | (bFlag << SFLAG_SHIFT_VALUE);
284 + bFlag = (bDFlag) ? (byte) BIT_SET : BIT_RESET;
285 + iTemp = iTemp | bFlag;
286 + cb.writeInt(iTemp);
287 +
288 + // Add optional TLV
289 + packOptionalTlv(cb);
290 +
291 + //Update object length now
292 + int length = cb.writerIndex() - objStartIndex;
293 + //will be helpful during print().
294 + lspObjHeader.setObjLen((short) length);
295 + // As per RFC the length of object should be
296 + // multiples of 4
297 +
298 + cb.setShort(objLenIndex, (short) length);
299 +
300 + return length;
301 + }
302 +
303 + /**
304 + * Returns Linked list of optional tlvs.
305 + *
306 + * @param cb of channel buffer.
307 + * @return list of optional tlvs
308 + * @throws PcepParseException when unsupported tlv is received
309 + */
310 + protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
311 +
312 + LinkedList<PcepValueType> llOutOptionalTlv;
313 +
314 + llOutOptionalTlv = new LinkedList<PcepValueType>();
315 +
316 + while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
317 +
318 + PcepValueType tlv;
319 + short hType = cb.readShort();
320 + short hLength = cb.readShort();
321 + int iValue = 0;
322 +
323 + switch (hType) {
324 +
325 + case StatefulIPv4LspIdentidiersTlv.TYPE:
326 + tlv = StatefulIPv4LspIdentidiersTlv.read(cb);
327 + break;
328 + case StatefulLspErrorCodeTlv.TYPE:
329 + iValue = cb.readInt();
330 + tlv = new StatefulLspErrorCodeTlv(iValue);
331 + break;
332 + case StatefulRsvpErrorSpecTlv.TYPE:
333 + tlv = StatefulRsvpErrorSpecTlv.read(cb);
334 + break;
335 + case SymbolicPathNameTlv.TYPE:
336 + tlv = SymbolicPathNameTlv.read(cb, hLength);
337 + break;
338 + default:
339 + throw new PcepParseException("Received unsupported TLV type :" + hType);
340 + }
341 + // Check for the padding
342 + int pad = hLength % 4;
343 + if (0 < pad) {
344 + pad = 4 - pad;
345 + if (pad <= cb.readableBytes()) {
346 + cb.skipBytes(pad);
347 + }
348 + }
349 +
350 + llOutOptionalTlv.add(tlv);
351 + }
352 +
353 + if (0 < cb.readableBytes()) {
354 +
355 + throw new PcepParseException("Optional Tlv parsing error. Extra bytes received.");
356 + }
357 + return llOutOptionalTlv;
358 + }
359 +
360 + /**
361 + * returns writer index.
362 + *
363 + * @param cb of type channel buffer
364 + * @return length of bytes written to channel buffer
365 + */
366 + protected int packOptionalTlv(ChannelBuffer cb) {
367 +
368 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
369 + int startIndex = cb.writerIndex();
370 +
371 + while (listIterator.hasNext()) {
372 + PcepValueType tlv = listIterator.next();
373 +
374 + if (null == tlv) {
375 + log.debug("tlv is null from OptionalTlv list");
376 + continue;
377 + }
378 +
379 + tlv.write(cb);
380 +
381 + // need to take care of padding
382 + int pad = tlv.getLength() % 4;
383 +
384 + if (0 != pad) {
385 + pad = 4 - pad;
386 + for (int i = 0; i < pad; ++i) {
387 + cb.writeByte((byte) 0);
388 + }
389 + }
390 + }
391 +
392 + return cb.writerIndex() - startIndex;
393 + }
394 +
395 + /**
396 + * Builder class for PCEP lsp Object.
397 + */
398 + public static class Builder implements PcepLspObject.Builder {
399 +
400 + private boolean bIsHeaderSet = false;
401 + private boolean bIsPlspIdSet = false;
402 + private boolean bIsOFlagSet = false;
403 + private boolean bIsRFlagSet = false;
404 + private boolean bIsAFlagSet = false;
405 + private boolean bIsDFlagSet = false;
406 + private boolean bIsSFlagSet = false;
407 +
408 + private PcepObjectHeader lspObjHeader;
409 + private byte yOFlag;
410 + private boolean bAFlag;
411 + private boolean bDFlag;
412 + private boolean bSFlag;
413 + private boolean bRFlag;
414 + LinkedList<PcepValueType> llOptionalTlv = null;
415 +
416 + private int plspId;
417 +
418 + private boolean bIsPFlagSet = false;
419 + private boolean bPFlag;
420 +
421 + private boolean bIsIFlagSet = false;
422 + private boolean bIFlag;
423 +
424 + @Override
425 + public PcepLspObject build() {
426 + PcepObjectHeader lspObjHeader = this.bIsHeaderSet ? this.lspObjHeader : DEFAULT_LSP_OBJECT_HEADER;
427 +
428 + int plspId = this.bIsPlspIdSet ? this.plspId : DEFAULT_PLSPID;
429 + byte yOFlag = this.bIsOFlagSet ? this.yOFlag : DEFAULT_OFLAG;
430 + boolean bAFlag = this.bIsAFlagSet ? this.bAFlag : DEFAULT_AFLAG;
431 + boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_RFLAG;
432 + boolean bSFlag = this.bIsSFlagSet ? this.bSFlag : DEFAULT_SFLAG;
433 + boolean bDFlag = this.bIsDFlagSet ? this.bDFlag : DEFAULT_DFLAG;
434 +
435 + if (bIsPFlagSet) {
436 + lspObjHeader.setPFlag(bPFlag);
437 + }
438 +
439 + if (bIsIFlagSet) {
440 + lspObjHeader.setIFlag(bIFlag);
441 + }
442 +
443 + return new PcepLspObjectVer1(lspObjHeader, plspId, yOFlag, bAFlag, bRFlag, bSFlag, bDFlag, llOptionalTlv);
444 + }
445 +
446 + @Override
447 + public PcepObjectHeader getLspObjHeader() {
448 + return this.lspObjHeader;
449 + }
450 +
451 + @Override
452 + public Builder setLspObjHeader(PcepObjectHeader obj) {
453 + this.lspObjHeader = obj;
454 + this.bIsHeaderSet = true;
455 + return this;
456 + }
457 +
458 + @Override
459 + public int getPlspId() {
460 + return this.plspId;
461 + }
462 +
463 + @Override
464 + public Builder setPlspId(int value) {
465 + this.plspId = value;
466 + this.bIsPlspIdSet = true;
467 + return this;
468 + }
469 +
470 + @Override
471 + public byte getOFlag() {
472 + return this.yOFlag;
473 + }
474 +
475 + @Override
476 + public Builder setOFlag(byte value) {
477 + this.yOFlag = value;
478 + this.bIsOFlagSet = true;
479 + return this;
480 + }
481 +
482 + @Override
483 + public boolean getAFlag() {
484 + return this.bAFlag;
485 + }
486 +
487 + @Override
488 + public Builder setAFlag(boolean value) {
489 + this.bAFlag = value;
490 + this.bIsAFlagSet = true;
491 + return this;
492 + }
493 +
494 + @Override
495 + public boolean getRFlag() {
496 + return this.bRFlag;
497 + }
498 +
499 + @Override
500 + public Builder setRFlag(boolean value) {
501 + this.bRFlag = value;
502 + this.bIsRFlagSet = true;
503 + return this;
504 + }
505 +
506 + @Override
507 + public boolean getSFlag() {
508 + return this.bSFlag;
509 + }
510 +
511 + @Override
512 + public Builder setSFlag(boolean value) {
513 + this.bSFlag = value;
514 + this.bIsSFlagSet = true;
515 + return this;
516 + }
517 +
518 + @Override
519 + public boolean getDFlag() {
520 + return this.bDFlag;
521 + }
522 +
523 + @Override
524 + public Builder setDFlag(boolean value) {
525 + this.bDFlag = value;
526 + this.bIsDFlagSet = true;
527 + return this;
528 + }
529 +
530 + @Override
531 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
532 + this.llOptionalTlv = llOptionalTlv;
533 + return this;
534 + }
535 +
536 + @Override
537 + public LinkedList<PcepValueType> getOptionalTlv() {
538 + return this.llOptionalTlv;
539 + }
540 +
541 + @Override
542 + public Builder setPFlag(boolean value) {
543 + this.bPFlag = value;
544 + this.bIsPFlagSet = true;
545 + return this;
546 + }
547 +
548 + @Override
549 + public Builder setIFlag(boolean value) {
550 + this.bIFlag = value;
551 + this.bIsIFlagSet = true;
552 + return this;
553 + }
554 +
555 + }
556 +
557 + @Override
558 + public void print() {
559 +
560 + log.debug("LSP OBJECT");
561 + long lTemp = iPlspId & 0xFFFFFFFF;
562 + log.debug("PLSP Id: " + lTemp);
563 + lTemp = yOFlag & 0xFFFF;
564 + log.debug("O Flag: " + lTemp);
565 + lTemp = (bAFlag) ? 1 : 0;
566 + log.debug("A Flag: " + lTemp);
567 + lTemp = (bRFlag) ? 1 : 0;
568 + log.debug("R Flag: " + lTemp);
569 + lTemp = (bSFlag) ? 1 : 0;
570 + log.debug("S Flag: " + lTemp);
571 + lTemp = (bDFlag) ? 1 : 0;
572 + log.debug("D Flag: " + lTemp);
573 +
574 + log.debug("OPTIONAL TLV:");
575 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
576 + while (listIterator.hasNext()) {
577 + listIterator.next().print();
578 + }
579 + }
580 +
581 + @Override
582 + public String toString() {
583 + return MoreObjects.toStringHelper(getClass())
584 + .add("Plsp ID value", iPlspId)
585 + .add("o flag", yOFlag)
586 + .add("A flag", bAFlag)
587 + .add("R flag", bRFlag)
588 + .add("S flag", bSFlag)
589 + .add("D flag", bDFlag)
590 + .add("List of optional tlv", llOptionalTlv)
591 + .toString();
592 + }
593 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcepLspaObject;
25 +import org.onosproject.pcepio.types.PcepObjectHeader;
26 +import org.onosproject.pcepio.types.PcepValueType;
27 +import org.slf4j.Logger;
28 +import org.slf4j.LoggerFactory;
29 +
30 +import com.google.common.base.MoreObjects;
31 +
32 +public class PcepLspaObjectVer1 implements PcepLspaObject {
33 +
34 + /* LSPA Object Body Format
35 +
36 + 0 1 2 3
37 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 + | Exclude-any |
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 + | Include-any |
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | Include-all |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + | Setup Prio | Holding Prio | Flags |L| Reserved |
46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 + | |
48 + | Optional TLVs |
49 + | |
50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 + */
52 +
53 + protected static final Logger log = LoggerFactory.getLogger(PcepLspaObjectVer1.class);
54 +
55 + public static final byte LSPA_OBJ_TYPE = 1;
56 + public static final byte LSPA_OBJ_CLASS = 9;
57 + public static final byte LSPA_OBJECT_VERSION = 1;
58 + public static final short LSPA_OBJ_MINIMUM_LENGTH = 20;
59 + public static final int OBJECT_HEADER_LENGTH = 4;
60 +
61 + static final PcepObjectHeader DEFAULT_LSPA_OBJECT_HEADER = new PcepObjectHeader(LSPA_OBJ_CLASS, LSPA_OBJ_TYPE,
62 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSPA_OBJ_MINIMUM_LENGTH);
63 +
64 + public static final int SETUP_PRIORITY_SHIFT_VALUE = 24;
65 + public static final int HOLD_PRIORITY_SHIFT_VALUE = 16;
66 + public static final int BFLAG_SHIFT_VALUE = 8;
67 + public static final int LFLAG_SET = 1;
68 + public static final int LFLAG_RESET = 0;
69 + private PcepObjectHeader lspaObjHeader;
70 + private int iExcludeAny;
71 + private int iIncludeAny;
72 + private int iIncludeAll;
73 + private byte cSetupPriority;
74 + private byte cHoldPriority;
75 + private byte flags;
76 + private byte reserved;
77 + private boolean bLFlag;
78 + private LinkedList<PcepValueType> llOptionalTlv; //Optional TLV
79 +
80 + /**
81 + * Constructor to initialize member variables.
82 + *
83 + * @param lspaObjHeader lspa object header
84 + * @param bLFlag b l flag
85 + * @param iExcludeAny excludeAny value
86 + * @param iIncludeAny includeAny value
87 + * @param iIncludeAll includeAll value
88 + * @param cSetupPriority setup priority value
89 + * @param cHoldPriority hold priority value
90 + * @param llOptionalTlv list of optional tlv
91 + */
92 + public PcepLspaObjectVer1(PcepObjectHeader lspaObjHeader, boolean bLFlag, int iExcludeAny, int iIncludeAny,
93 + int iIncludeAll, byte cSetupPriority, byte cHoldPriority, LinkedList<PcepValueType> llOptionalTlv) {
94 +
95 + this.lspaObjHeader = lspaObjHeader;
96 + this.bLFlag = bLFlag;
97 + this.iExcludeAny = iExcludeAny;
98 + this.iIncludeAny = iIncludeAny;
99 + this.iIncludeAll = iIncludeAll;
100 + this.cSetupPriority = cSetupPriority;
101 + this.cHoldPriority = cHoldPriority;
102 + this.llOptionalTlv = llOptionalTlv;
103 + }
104 +
105 + /**
106 + * Sets Object Header.
107 + *
108 + * @param obj lspa object header
109 + */
110 + public void setLspaObjHeader(PcepObjectHeader obj) {
111 + this.lspaObjHeader = obj;
112 + }
113 +
114 + @Override
115 + public void setExcludeAny(int iExcludeAny) {
116 + this.iExcludeAny = iExcludeAny;
117 + }
118 +
119 + @Override
120 + public void setIncludeAny(int iIncludeAny) {
121 + this.iIncludeAny = iIncludeAny;
122 + }
123 +
124 + @Override
125 + public void setSetupPriority(byte cSetupPriority) {
126 + this.cSetupPriority = cSetupPriority;
127 + }
128 +
129 + @Override
130 + public void setHoldPriority(byte cHoldPriority) {
131 + this.cHoldPriority = cHoldPriority;
132 + }
133 +
134 + @Override
135 + public void setLFlag(boolean bLFlag) {
136 + this.bLFlag = bLFlag;
137 + }
138 +
139 + /**
140 + * Returns lspa Object Header.
141 + *
142 + * @return lspa Object Header
143 + */
144 + public PcepObjectHeader getLspaObjHeader() {
145 + return this.lspaObjHeader;
146 + }
147 +
148 + @Override
149 + public int getExcludeAny() {
150 + return this.iExcludeAny;
151 + }
152 +
153 + @Override
154 + public int getIncludeAny() {
155 + return this.iIncludeAny;
156 + }
157 +
158 + @Override
159 + public int getIncludeAll() {
160 + return this.iIncludeAll;
161 + }
162 +
163 + @Override
164 + public byte getSetupPriority() {
165 + return this.cSetupPriority;
166 + }
167 +
168 + @Override
169 + public byte getHoldPriority() {
170 + return this.cHoldPriority;
171 + }
172 +
173 + @Override
174 + public boolean getLFlag() {
175 + return this.bLFlag;
176 + }
177 +
178 + @Override
179 + public void setIncludeAll(int value) {
180 + this.iIncludeAll = value;
181 +
182 + }
183 +
184 + @Override
185 + public LinkedList<PcepValueType> getOptionalTlv() {
186 + return this.llOptionalTlv;
187 + }
188 +
189 + @Override
190 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
191 + this.llOptionalTlv = llOptionalTlv;
192 +
193 + }
194 +
195 + /**
196 + * Reads channel buffer and returns object of PcepLspaObject.
197 + *
198 + * @param cb of type channel buffer.
199 + * @return object of PcepLspaObject
200 + * @throws PcepParseException while parsing lspa object from channel buffer
201 + */
202 + public static PcepLspaObject read(ChannelBuffer cb) throws PcepParseException {
203 +
204 + log.debug("LspaObject::read");
205 + PcepObjectHeader lspaObjHeader;
206 + int iExcludeAny;
207 + int iIncludeAny;
208 + int iIncludeAll;
209 + byte cSetupPriority;
210 + byte cHoldPriority;
211 + boolean bLFlag;
212 + byte flags;
213 +
214 + // Optional TLV
215 + LinkedList<PcepValueType> llOptionalTlv;
216 +
217 + lspaObjHeader = PcepObjectHeader.read(cb);
218 +
219 + //take only Lspa Object buffer.
220 + ChannelBuffer tempCb = cb.readBytes(lspaObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
221 + iExcludeAny = tempCb.readInt();
222 + iIncludeAny = tempCb.readInt();
223 + iIncludeAll = tempCb.readInt();
224 + cSetupPriority = tempCb.readByte();
225 + cHoldPriority = tempCb.readByte();
226 + flags = tempCb.readByte();
227 + tempCb.readByte();
228 +
229 + bLFlag = (flags & (byte) LFLAG_SET) == LFLAG_SET ? true : false;
230 +
231 + llOptionalTlv = parseOptionalTlv(tempCb);
232 +
233 + return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
234 + cHoldPriority, llOptionalTlv);
235 + }
236 +
237 + @Override
238 + public int write(ChannelBuffer cb) throws PcepParseException {
239 +
240 + //write Object header
241 + int objStartIndex = cb.writerIndex();
242 +
243 + int objLenIndex = lspaObjHeader.write(cb);
244 +
245 + if (objLenIndex <= 0) {
246 + throw new PcepParseException("Failed to write lspa object header. Index " + objLenIndex);
247 + }
248 +
249 + cb.writeInt(iExcludeAny);
250 + cb.writeInt(iIncludeAny);
251 + cb.writeInt(iIncludeAll);
252 +
253 + int iTemp = cSetupPriority << SETUP_PRIORITY_SHIFT_VALUE;
254 + iTemp = iTemp | (cHoldPriority << HOLD_PRIORITY_SHIFT_VALUE);
255 + byte bFlag;
256 + bFlag = (bLFlag) ? (byte) LFLAG_SET : LFLAG_RESET;
257 + iTemp = iTemp | (bFlag << BFLAG_SHIFT_VALUE);
258 + cb.writeInt(iTemp);
259 +
260 + // Add optional TLV
261 + if (!packOptionalTlv(cb)) {
262 + throw new PcepParseException("Faild to write lspa objects tlv to channel buffer");
263 + }
264 +
265 + short length = (short) (cb.writerIndex() - objStartIndex);
266 +
267 + lspaObjHeader.setObjLen(length); //will be helpful during print().
268 +
269 + //As per RFC the length of object should be multiples of 4
270 + short pad = (short) (length % 4);
271 +
272 + if (pad != 0) {
273 + pad = (short) (4 - pad);
274 + for (int i = 0; i < pad; i++) {
275 + cb.writeByte((byte) 0);
276 + }
277 + length = (short) (length + pad);
278 + }
279 + cb.setShort(objLenIndex, length);
280 + return cb.writerIndex();
281 + }
282 +
283 + /**
284 + * Parse list of optional tlvs.
285 + *
286 + * @param cb channel buffer
287 + * @return list of optional tlvs.
288 + * @throws PcepParseException when fails to parse optional tlv list.
289 + */
290 + public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
291 +
292 + LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
293 +
294 + return llOutOptionalTlv;
295 + }
296 +
297 + /**
298 + * Writes optional tlvs to channel buffer.
299 + *
300 + * @param cb channel buffer
301 + * @return true
302 + */
303 + protected boolean packOptionalTlv(ChannelBuffer cb) {
304 + int hTlvType;
305 + int hTlvLength;
306 +
307 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
308 + while (listIterator.hasNext()) {
309 + PcepValueType tlv = listIterator.next();
310 + if (null == tlv) {
311 + log.debug("Warning: tlv is null from OptionalTlv list");
312 + continue;
313 + }
314 + hTlvType = tlv.getType();
315 + hTlvLength = tlv.getLength();
316 + if (0 == hTlvLength) {
317 + log.debug("Warning: invalid length in tlv of OptionalTlv list");
318 + continue;
319 + }
320 +
321 + cb.writeShort(hTlvType);
322 + cb.writeShort(hTlvLength);
323 +
324 + switch (hTlvType) {
325 + //TODO: optional TLV for LSPA to be added
326 +
327 + default:
328 + log.debug("Warning: PcepLspaObject: unknown tlv");
329 + }
330 +
331 + // As per RFC the length of object should
332 + // be multiples of 4
333 + int pad = hTlvLength % 4;
334 +
335 + if (0 < pad) {
336 + pad = 4 - pad;
337 + if (pad <= cb.readableBytes()) {
338 + cb.skipBytes(pad);
339 + }
340 + }
341 + }
342 + return true;
343 + }
344 +
345 + /**
346 + * builder class for PCEP lspa object.
347 + */
348 + public static class Builder implements PcepLspaObject.Builder {
349 + private boolean bIsHeaderSet = false;
350 +
351 + private PcepObjectHeader lspaObjHeader;
352 +
353 + private boolean bLFlag;
354 + private int iExcludeAny;
355 + private boolean bIsExcludeAnySet = false;
356 + private int iIncludeAny;
357 + private boolean bIsIncludeAnySet = false;
358 + private int iIncludeAll;
359 + private boolean bIsIncludeAllSet = false;
360 + private byte cSetupPriority;
361 + private boolean bIsSetupPrioritySet = false;
362 + private byte cHoldPriority;
363 + private boolean bIsHoldPrioritySet = false;
364 + private LinkedList<PcepValueType> llOptionalTlv;
365 +
366 + private boolean bIsPFlagSet = false;
367 + private boolean bPFlag;
368 +
369 + private boolean bIsIFlagSet = false;
370 + private boolean bIFlag;
371 +
372 + @Override
373 + public PcepLspaObject build() throws PcepParseException {
374 +
375 + PcepObjectHeader lspaObjHeader = this.bIsHeaderSet ? this.lspaObjHeader : DEFAULT_LSPA_OBJECT_HEADER;
376 +
377 + if (!this.bIsExcludeAnySet) {
378 + throw new PcepParseException("ExcludeAny NOT Set while building PcepLspaObject.");
379 + }
380 + if (!this.bIsIncludeAnySet) {
381 + throw new PcepParseException("IncludeAny NOT Set while building PcepLspaObject.");
382 + }
383 + if (!this.bIsIncludeAllSet) {
384 + throw new PcepParseException("IncludeAll NOT Set while building PcepLspaObject.");
385 + }
386 + if (!this.bIsSetupPrioritySet) {
387 + throw new PcepParseException("Setup Priority NOT Set while building PcepLspaObject.");
388 + }
389 + if (!this.bIsHoldPrioritySet) {
390 + throw new PcepParseException("Hold Priority NOT Set while building PcepLspaObject.");
391 + }
392 +
393 + if (bIsPFlagSet) {
394 + lspaObjHeader.setPFlag(bPFlag);
395 + }
396 +
397 + if (bIsIFlagSet) {
398 + lspaObjHeader.setIFlag(bIFlag);
399 + }
400 +
401 + return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
402 + cHoldPriority, llOptionalTlv);
403 + }
404 +
405 + @Override
406 + public PcepObjectHeader getLspaObjHeader() {
407 + return this.lspaObjHeader;
408 + }
409 +
410 + @Override
411 + public Builder setLspaObjHeader(PcepObjectHeader obj) {
412 + this.lspaObjHeader = obj;
413 + this.bIsHeaderSet = true;
414 + return this;
415 + }
416 +
417 + @Override
418 + public boolean getLFlag() {
419 + return this.bLFlag;
420 + }
421 +
422 + @Override
423 + public Builder setLFlag(boolean value) {
424 + this.bLFlag = value;
425 + return this;
426 + }
427 +
428 + @Override
429 + public int getExcludeAny() {
430 + return this.iExcludeAny;
431 + }
432 +
433 + @Override
434 + public Builder setExcludeAny(int value) {
435 + this.iExcludeAny = value;
436 + this.bIsExcludeAnySet = true;
437 + return this;
438 + }
439 +
440 + @Override
441 + public int getIncludeAny() {
442 + return this.iIncludeAny;
443 + }
444 +
445 + @Override
446 + public Builder setIncludeAny(int value) {
447 + this.iIncludeAny = value;
448 + this.bIsIncludeAnySet = true;
449 + return this;
450 + }
451 +
452 + @Override
453 + public int getIncludeAll() {
454 + return this.iIncludeAll;
455 + }
456 +
457 + @Override
458 + public Builder setIncludeAll(int value) {
459 + this.iIncludeAll = value;
460 + this.bIsIncludeAllSet = true;
461 + return this;
462 + }
463 +
464 + @Override
465 + public byte getSetupPriority() {
466 + return this.cSetupPriority;
467 + }
468 +
469 + @Override
470 + public Builder setSetupPriority(byte value) {
471 + this.cSetupPriority = value;
472 + this.bIsSetupPrioritySet = true;
473 + return this;
474 + }
475 +
476 + @Override
477 + public byte getHoldPriority() {
478 + return this.cHoldPriority;
479 + }
480 +
481 + @Override
482 + public Builder setHoldPriority(byte value) {
483 + this.cHoldPriority = value;
484 + this.bIsHoldPrioritySet = true;
485 + return this;
486 + }
487 +
488 + @Override
489 + public LinkedList<PcepValueType> getOptionalTlv() {
490 + return this.llOptionalTlv;
491 + }
492 +
493 + @Override
494 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
495 + this.llOptionalTlv = llOptionalTlv;
496 +
497 + return this;
498 + }
499 +
500 + @Override
501 + public Builder setPFlag(boolean value) {
502 + this.bPFlag = value;
503 + this.bIsPFlagSet = true;
504 + return this;
505 + }
506 +
507 + @Override
508 + public Builder setIFlag(boolean value) {
509 + this.bIFlag = value;
510 + this.bIsIFlagSet = true;
511 + return this;
512 + }
513 +
514 + }
515 +
516 + @Override
517 + public void print() {
518 + log.debug("LSPA OBJECT");
519 + long lTemp = flags & 0xFF;
520 + lTemp = (bLFlag) ? 1 : 0;
521 + log.debug("l Flag: " + lTemp);
522 + lTemp = cSetupPriority & 0xFF;
523 + log.debug("SetupPriority: " + lTemp);
524 + lTemp = cHoldPriority & 0xFF;
525 + log.debug("HoldPriority: " + lTemp);
526 + lTemp = iIncludeAll & 0xFFFFFFFF;
527 + log.debug("IncludeAll: " + lTemp);
528 + lTemp = iIncludeAny & 0xFFFFFFFF;
529 + log.debug("IncludeAny: " + lTemp);
530 + lTemp = iExcludeAny & 0xFFFFFFFF;
531 + log.debug("iExcludeAny: " + lTemp);
532 +
533 + log.debug("OPTIONAL TLV:");
534 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
535 + while (listIterator.hasNext()) {
536 + listIterator.next().print();
537 + }
538 + }
539 +
540 + @Override
541 + public String toString() {
542 + return MoreObjects.toStringHelper(getClass())
543 + .add("L flag", bLFlag)
544 + .add("Setup priority", cSetupPriority)
545 + .add("hold priority", cHoldPriority)
546 + .add("Include all", iIncludeAll)
547 + .add("Include any", iIncludeAny)
548 + .add("Exclude any", iExcludeAny)
549 + .add("List of optional tlv", llOptionalTlv)
550 + .toString();
551 + }
552 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.jboss.netty.buffer.ChannelBuffer;
20 +import org.onosproject.pcepio.exceptions.PcepParseException;
21 +import org.onosproject.pcepio.protocol.PcepFactories;
22 +import org.onosproject.pcepio.protocol.PcepMessage;
23 +import org.onosproject.pcepio.protocol.PcepMessageReader;
24 +import org.onosproject.pcepio.types.PcepErrorDetailInfo;
25 +import org.slf4j.Logger;
26 +import org.slf4j.LoggerFactory;
27 +
28 +public abstract class PcepMessageVer1 {
29 +
30 + protected static final Logger log = LoggerFactory.getLogger(PcepFactories.class);
31 +
32 + // version: 1.0
33 + static final byte WIRE_VERSION = 1;
34 + static final int MINIMUM_LENGTH = 4;
35 + static final int PACKET_VERSION = 1;
36 + static final byte OPEN_MSG_TYPE = 0x1;
37 + static final byte KEEPALIVE_MSG_TYPE = 0x2;
38 + static final byte REPORT_MSG_TYPE = 0xa;
39 + static final byte TE_REPORT_MSG_TYPE = 0xe;
40 + static final byte UPDATE_MSG_TYPE = 0xb;
41 + static final byte INITIATE_MSG_TYPE = 0xc;
42 + static final byte CLOSE_MSG_TYPE = 0x7;
43 + static final byte ERROR_MSG_TYPE = 0x6;
44 + static final byte LABEL_UPDATE_MSG_TYPE = 0xD;
45 + public static final int SHIFT_FLAG = 5;
46 + static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
47 +
48 + public static final PcepMessageVer1.Reader READER = new Reader();
49 +
50 + static class Reader implements PcepMessageReader<PcepMessage> {
51 + @Override
52 + public PcepMessage readFrom(ChannelBuffer cb) throws PcepParseException {
53 +
54 + if (cb.readableBytes() < MINIMUM_LENGTH) {
55 + throw new PcepParseException("Packet should have minimum length: " + MINIMUM_LENGTH);
56 + }
57 +
58 + try {
59 + int start = cb.readerIndex();
60 + // fixed value property version == 1
61 + byte version = cb.readByte();
62 + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
63 + if (version != (byte) PACKET_VERSION) {
64 + throw new PcepParseException("Wrong version. Expected=PcepVersion.Message_1(1), got=" + version);
65 + }
66 +
67 + byte type = cb.readByte();
68 + short length = cb.readShort();
69 + cb.readerIndex(start);
70 +
71 + switch (type) {
72 +
73 + case OPEN_MSG_TYPE:
74 + log.debug("OPEN MESSAGE is received");
75 + // message type value 1 means it is open message
76 + // return
77 + // TODO: Read open message from channel buffer.
78 + case KEEPALIVE_MSG_TYPE:
79 + log.debug("KEEPALIVE MESSAGE is received");
80 + // message type value 2 means it is Keepalive message
81 + return PcepKeepaliveMsgVer1.READER.readFrom(cb.readBytes(length));
82 + case ERROR_MSG_TYPE:
83 + log.debug("ERROR MESSAGE is received");
84 + // message type value 6 means it is error message
85 + // return
86 + // TODO: Read Error message from channel buffer.
87 + case REPORT_MSG_TYPE:
88 + log.debug("REPORT MESSAGE is received");
89 + // message type value 10 means it is Report message
90 + // return
91 + // TODO: Read Report message from channel buffer.
92 + case UPDATE_MSG_TYPE:
93 + log.debug("UPDATE MESSAGE is received");
94 + //message type value 11 means it is Update message
95 + return PcepUpdateMsgVer1.READER.readFrom(cb.readBytes(length));
96 + case INITIATE_MSG_TYPE:
97 + log.debug("INITIATE MESSAGE is received");
98 + //message type value 12 means it is PcInitiate message
99 + return PcepInitiateMsgVer1.READER.readFrom(cb.readBytes(length));
100 + case CLOSE_MSG_TYPE:
101 + log.debug("CLOSE MESSAGE is received");
102 + // message type value 7 means it is Close message
103 + return PcepCloseMsgVer1.READER.readFrom(cb.readBytes(length));
104 + case TE_REPORT_MSG_TYPE:
105 + log.debug("TE REPORT MESSAGE is received");
106 + // message type value 14 means it is TE REPORT message
107 + // return
108 + // TODO: Read TE Report message from channel buffer.
109 + case LABEL_UPDATE_MSG_TYPE:
110 + log.debug("LABEL UPDATE MESSAGE is received");
111 + // message type value 13 means it is LABEL UPDATE message
112 + // return
113 + // TODO: Read Label update message from channel buffer.
114 + default:
115 + throw new PcepParseException("ERROR: UNKNOWN MESSAGE is received. Msg Type: " + type);
116 + }
117 + } catch (IndexOutOfBoundsException e) {
118 + throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_1, PcepErrorDetailInfo.ERROR_VALUE_1);
119 + }
120 + }
121 + }
122 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.jboss.netty.buffer.ChannelBuffer;
20 +import org.onosproject.pcepio.exceptions.PcepParseException;
21 +import org.onosproject.pcepio.protocol.PcepMetricObject;
22 +import org.onosproject.pcepio.types.PcepObjectHeader;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +/*
29 + METRIC Object Body Format.
30 +
31 + 0 1 2 3
32 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
33 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
34 + | Reserved | Flags |C|B| T |
35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 + | metric-value |
37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 + */
39 +
40 +public class PcepMetricObjectVer1 implements PcepMetricObject {
41 +
42 + protected static final Logger log = LoggerFactory.getLogger(PcepMetricObjectVer1.class);
43 +
44 + public static final byte METRIC_OBJ_TYPE = 1;
45 + public static final byte METRIC_OBJ_CLASS = 6;
46 + public static final byte METRIC_OBJECT_VERSION = 1;
47 + public static final short METRIC_OBJ_MINIMUM_LENGTH = 12;
48 + public static final int OBJECT_HEADER_LENGTH = 4;
49 + public static final int IFLAG_SHIFT_VALUE = 9;
50 + public static final int BTYPE_SHIFT_VALUE = 8;
51 + public static final int CFLAG_SET = 1;
52 + public static final int CFLAG_RESET = 0;
53 + public static final int BFLAG_SET = 1;
54 + public static final int BFLAG_RESET = 0;
55 + public static final byte CFLAG_CHECK = 0x02;
56 +
57 + static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS,
58 + METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
59 + METRIC_OBJ_MINIMUM_LENGTH);
60 +
61 + private PcepObjectHeader metricObjHeader;
62 + private int iMetricVal;
63 + private byte yFlag; // 6-flags
64 + private boolean bCFlag;
65 + private boolean bBFlag;
66 + private byte bType;
67 +
68 + /**
69 + * Default constructor.
70 + */
71 + public PcepMetricObjectVer1() {
72 + this.metricObjHeader = null;
73 + this.iMetricVal = 0;
74 + this.yFlag = 0;
75 + this.bCFlag = false;
76 + this.bBFlag = false;
77 + this.bType = 0;
78 +
79 + }
80 +
81 + /**
82 + * Constructor to initialize all member variables.
83 + *
84 + * @param metricObjHeader metric object header
85 + * @param iMetricVal metric value
86 + * @param yFlag Y flag
87 + * @param bCFlag C flag
88 + * @param bBFlag B flag
89 + * @param bType Type value
90 + */
91 + public PcepMetricObjectVer1(PcepObjectHeader metricObjHeader, int iMetricVal, byte yFlag, boolean bCFlag,
92 + boolean bBFlag, byte bType) {
93 +
94 + this.metricObjHeader = metricObjHeader;
95 + this.iMetricVal = iMetricVal;
96 + this.yFlag = yFlag;
97 + this.bCFlag = bCFlag;
98 + this.bBFlag = bBFlag;
99 + this.bType = bType;
100 +
101 + }
102 +
103 + @Override
104 + public void setMetricVal(int value) {
105 + this.iMetricVal = value;
106 +
107 + }
108 +
109 + @Override
110 + public int getMetricVal() {
111 + return this.iMetricVal;
112 + }
113 +
114 + @Override
115 + public byte getYFlag() {
116 + return this.yFlag;
117 + }
118 +
119 + @Override
120 + public void setYFlag(byte value) {
121 + this.yFlag = value;
122 + }
123 +
124 + @Override
125 + public boolean getCFlag() {
126 + return this.bCFlag;
127 + }
128 +
129 + @Override
130 + public void setCFlag(boolean value) {
131 + this.bCFlag = value;
132 + }
133 +
134 + @Override
135 + public boolean getBFlag() {
136 + return this.bBFlag;
137 + }
138 +
139 + @Override
140 + public void setBFlag(boolean value) {
141 + this.bBFlag = value;
142 + }
143 +
144 + @Override
145 + public byte getBType() {
146 + return this.bType;
147 + }
148 +
149 + @Override
150 + public void setBType(byte value) {
151 + this.bType = value;
152 + }
153 +
154 + /**
155 + * Sets metric Object Header.
156 + *
157 + * @param obj metric object header
158 + */
159 + public void setMetricObjHeader(PcepObjectHeader obj) {
160 + this.metricObjHeader = obj;
161 + }
162 +
163 + /**
164 + * Returns metric Object Header.
165 + *
166 + * @return metricObjHeader
167 + */
168 + public PcepObjectHeader getMetricObjHeader() {
169 + return this.metricObjHeader;
170 + }
171 +
172 + /**
173 + * Reads from channel buffer and returns object of PcepMetricObject.
174 + *
175 + * @param cb of channel buffer.
176 + * @return object of PcepMetricObject
177 + * @throws PcepParseException when metric object is not present in channel buffer
178 + */
179 + public static PcepMetricObject read(ChannelBuffer cb) throws PcepParseException {
180 +
181 + log.debug("MetricObject::read");
182 + PcepObjectHeader metricObjHeader;
183 + int iMetricVal;
184 + byte yFlag; // 6-flags
185 + boolean bCFlag;
186 + boolean bBFlag;
187 + byte bType;
188 +
189 + metricObjHeader = PcepObjectHeader.read(cb);
190 +
191 + if (metricObjHeader.getObjClass() != METRIC_OBJ_CLASS) {
192 + throw new PcepParseException("This object is not a Metric Object. Object Class: "
193 + + metricObjHeader.getObjClass());
194 + }
195 +
196 + //take only metric buffer.
197 + ChannelBuffer tempCb = cb.readBytes(metricObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
198 +
199 + tempCb.readShort();
200 + yFlag = tempCb.readByte();
201 + bType = tempCb.readByte();
202 + bCFlag = (yFlag & CFLAG_CHECK) == CFLAG_CHECK ? true : false;
203 + bBFlag = (yFlag & BFLAG_SET) == BFLAG_SET ? true : false;
204 + iMetricVal = tempCb.readInt();
205 +
206 + return new PcepMetricObjectVer1(metricObjHeader, iMetricVal, yFlag, bCFlag, bBFlag, bType);
207 + }
208 +
209 + @Override
210 + public int write(ChannelBuffer cb) throws PcepParseException {
211 + //write Object header
212 + int objStartIndex = cb.writerIndex();
213 +
214 + int objLenIndex = metricObjHeader.write(cb);
215 +
216 + if (objLenIndex <= 0) {
217 + throw new PcepParseException("Error: ObjectLength is " + objLenIndex);
218 + }
219 +
220 + int iFlag = (bCFlag) ? CFLAG_SET : CFLAG_RESET;
221 + int iTemp = iFlag << IFLAG_SHIFT_VALUE;
222 + iFlag = (bBFlag) ? BFLAG_SET : BFLAG_RESET;
223 + iTemp = iTemp | (iFlag << BTYPE_SHIFT_VALUE);
224 + iTemp = iTemp | bType;
225 + cb.writeInt(iTemp);
226 + cb.writeInt(iMetricVal);
227 +
228 + short hLength = (short) (cb.writerIndex() - objStartIndex);
229 + cb.setShort(objLenIndex, hLength);
230 + //will be helpful during print().
231 + metricObjHeader.setObjLen(hLength);
232 + return hLength;
233 + }
234 +
235 + /**
236 + * Builder class for PCEP metric object.
237 + */
238 + public static class Builder implements PcepMetricObject.Builder {
239 +
240 + private boolean bIsHeaderSet = false;
241 + private PcepObjectHeader metricObjHeader;
242 + private int iMetricVal;
243 + private boolean bIsMetricValSet = false;
244 + private byte yFlag; // 6-flags
245 + private boolean bCFlag;
246 + private boolean bBFlag;
247 + private byte bType;
248 + private boolean bIsbTypeSet = false;
249 +
250 + private boolean bIsPFlagSet = false;
251 + private boolean bPFlag;
252 +
253 + private boolean bIsIFlagSet = false;
254 + private boolean bIFlag;
255 +
256 + @Override
257 + public PcepMetricObject build() throws PcepParseException {
258 +
259 + PcepObjectHeader metricObjHeader = this.bIsHeaderSet ? this.metricObjHeader : DEFAULT_METRIC_OBJECT_HEADER;
260 +
261 + if (!this.bIsMetricValSet) {
262 + throw new PcepParseException(" Metric Value NOT Set while building PcepMetricObject.");
263 + }
264 + if (!this.bIsbTypeSet) {
265 + throw new PcepParseException(" Type NOT Set while building PcepMetricObject.");
266 + }
267 +
268 + if (bIsPFlagSet) {
269 + metricObjHeader.setPFlag(bPFlag);
270 + }
271 +
272 + if (bIsIFlagSet) {
273 + metricObjHeader.setIFlag(bIFlag);
274 + }
275 +
276 + return new PcepMetricObjectVer1(metricObjHeader, iMetricVal, yFlag, bCFlag, bBFlag, bType);
277 + }
278 +
279 + @Override
280 + public PcepObjectHeader getMetricObjHeader() {
281 + return this.metricObjHeader;
282 + }
283 +
284 + @Override
285 + public Builder setMetricObjHeader(PcepObjectHeader obj) {
286 + this.metricObjHeader = obj;
287 + this.bIsHeaderSet = true;
288 + return this;
289 + }
290 +
291 + @Override
292 + public int getMetricVal() {
293 + return this.iMetricVal;
294 + }
295 +
296 + @Override
297 + public Builder setMetricVal(int value) {
298 + this.iMetricVal = value;
299 + this.bIsMetricValSet = true;
300 + return this;
301 + }
302 +
303 + @Override
304 + public byte getYFlag() {
305 + return this.yFlag;
306 + }
307 +
308 + @Override
309 + public Builder setYFlag(byte value) {
310 + this.yFlag = value;
311 + return this;
312 + }
313 +
314 + @Override
315 + public boolean getCFlag() {
316 + return this.bCFlag;
317 + }
318 +
319 + @Override
320 + public Builder setCFlag(boolean value) {
321 + this.bCFlag = value;
322 + return this;
323 + }
324 +
325 + @Override
326 + public boolean getBFlag() {
327 + return this.bBFlag;
328 + }
329 +
330 + @Override
331 + public Builder setBFlag(boolean value) {
332 + this.bBFlag = value;
333 + return this;
334 + }
335 +
336 + @Override
337 + public byte getBType() {
338 + return this.bType;
339 + }
340 +
341 + @Override
342 + public Builder setBType(byte value) {
343 + this.bType = value;
344 + this.bIsbTypeSet = true;
345 + return this;
346 + }
347 +
348 + @Override
349 + public Builder setPFlag(boolean value) {
350 + this.bPFlag = value;
351 + this.bIsPFlagSet = true;
352 + return this;
353 + }
354 +
355 + @Override
356 + public Builder setIFlag(boolean value) {
357 + this.bIFlag = value;
358 + this.bIsIFlagSet = true;
359 + return this;
360 + }
361 +
362 + }
363 +
364 + @Override
365 + public void print() {
366 +
367 + log.debug("METRIC OBJECT");
368 + long lTemp = iMetricVal & 0xFFFFFFFF;
369 + log.debug("iMetricVal: " + lTemp);
370 + lTemp = (bBFlag) ? 1 : 0;
371 + log.debug("B Flag: " + lTemp);
372 + lTemp = (bCFlag) ? 1 : 0;
373 + log.debug("C Flag: " + lTemp);
374 + lTemp = bType & 0xFF;
375 + log.debug("Type: " + lTemp);
376 + }
377 +
378 + @Override
379 + public String toString() {
380 + return MoreObjects.toStringHelper(getClass())
381 + .add("Metric value", iMetricVal)
382 + .add("B flag", bBFlag)
383 + .add("C flag", bCFlag)
384 + .add("B-type", bType)
385 + .toString();
386 + }
387 +}
1 +package org.onosproject.pcepio.protocol.ver1;
2 +
3 +import org.jboss.netty.buffer.ChannelBuffer;
4 +import org.onosproject.pcepio.exceptions.PcepParseException;
5 +import org.onosproject.pcepio.protocol.PcepAttribute;
6 +import org.onosproject.pcepio.protocol.PcepEroObject;
7 +import org.onosproject.pcepio.protocol.PcepMsgPath;
8 +import org.slf4j.Logger;
9 +import org.slf4j.LoggerFactory;
10 +
11 +import com.google.common.base.MoreObjects;
12 +
13 +/**
14 + * Provides PCEP Message PAth for update message.
15 + * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
16 + */
17 +public class PcepMsgPathVer1 implements PcepMsgPath {
18 +
19 + /*
20 + * <path> ::= <ERO><attribute-list>
21 + */
22 +
23 + protected static final Logger log = LoggerFactory.getLogger(PcepMsgPathVer1.class);
24 + //PcepEroObject
25 + private PcepEroObject eroObj;
26 + private boolean isEroObjectSet;
27 + // PcepAttribute
28 + private PcepAttribute attrList;
29 + private boolean isAttributeListSet;
30 +
31 + /**
32 + * constructor to initialize objects.
33 + */
34 + public PcepMsgPathVer1() {
35 + eroObj = null;
36 + attrList = null;
37 + isEroObjectSet = false;
38 + isAttributeListSet = false;
39 + }
40 +
41 + @Override
42 + public PcepEroObject getEroObject() {
43 + return eroObj;
44 + }
45 +
46 + @Override
47 + public PcepAttribute getPcepAttribute() {
48 + return attrList;
49 + }
50 +
51 + @Override
52 + public void setEroObject(PcepEroObject eroObj) {
53 + this.eroObj = eroObj;
54 + }
55 +
56 + @Override
57 + public void setPcepAttribute(PcepAttribute attrList) {
58 + this.attrList = attrList;
59 + }
60 +
61 + /**
62 + * constructor to initialize member variables.
63 + *
64 + * @param eroObj pcep ero object
65 + * @param attrList pcep attribute
66 + */
67 + public PcepMsgPathVer1(PcepEroObject eroObj, PcepAttribute attrList) {
68 + this.eroObj = eroObj;
69 + isEroObjectSet = true;
70 + this.attrList = attrList;
71 + if (attrList == null) {
72 + isAttributeListSet = false;
73 + } else {
74 + isAttributeListSet = true;
75 + }
76 + }
77 +
78 + @Override
79 + public PcepMsgPath read(ChannelBuffer cb) throws PcepParseException {
80 + PcepEroObject eroObj;
81 + PcepAttribute attrList;
82 +
83 + eroObj = PcepEroObjectVer1.read(cb);
84 + attrList = PcepAttributeVer1.read(cb);
85 +
86 + return new PcepMsgPathVer1(eroObj, attrList);
87 + }
88 +
89 + @Override
90 + public int write(ChannelBuffer cb) throws PcepParseException {
91 + int iLenStartIndex = cb.writerIndex();
92 +
93 + //write Object header
94 + if (this.isEroObjectSet) {
95 + this.eroObj.write(cb);
96 + }
97 + if (this.isAttributeListSet) {
98 + attrList.write(cb);
99 + }
100 +
101 + return cb.writerIndex() - iLenStartIndex;
102 + }
103 +
104 + /**
105 + * builder class for PCEP Message path.
106 + */
107 + public static class Builder implements PcepMsgPath.Builder {
108 +
109 + private boolean bIsEROObjectSet = false;
110 + private boolean bIsPcepAttributeSet = false;
111 +
112 + //PCEP ERO Object
113 + private PcepEroObject eroObject;
114 + //PCEP Attribute list
115 + private PcepAttribute pcepAttribute;
116 +
117 + @Override
118 + public PcepMsgPath build() throws PcepParseException {
119 +
120 + //PCEP ERO Object
121 + PcepEroObject eroObject = null;
122 + //PCEP Attribute list
123 + PcepAttribute pcepAttribute = null;
124 +
125 + if (!this.bIsEROObjectSet) {
126 + throw new PcepParseException("ERO Object NOT Set while building PcepMsgPath.");
127 + } else {
128 + eroObject = this.eroObject;
129 + }
130 + if (!this.bIsPcepAttributeSet) {
131 + throw new PcepParseException("Pcep Attributes NOT Set while building PcepMsgPath.");
132 + } else {
133 + pcepAttribute = this.pcepAttribute;
134 + }
135 +
136 + return new PcepMsgPathVer1(eroObject, pcepAttribute);
137 + }
138 +
139 + @Override
140 + public PcepEroObject getEroObject() {
141 + return this.eroObject;
142 + }
143 +
144 + @Override
145 + public PcepAttribute getPcepAttribute() {
146 + return this.pcepAttribute;
147 + }
148 +
149 + @Override
150 + public Builder setEroObject(PcepEroObject eroObject) {
151 + this.eroObject = eroObject;
152 + this.bIsEROObjectSet = true;
153 + return this;
154 + }
155 +
156 + @Override
157 + public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
158 + this.pcepAttribute = pcepAttribute;
159 + this.bIsPcepAttributeSet = true;
160 + return this;
161 + }
162 +
163 + }
164 +
165 + @Override
166 + public void print() {
167 +
168 + log.debug("PcepMsgPath");
169 + eroObj.print();
170 + attrList.print();
171 + }
172 +
173 + @Override
174 + public String toString() {
175 + return MoreObjects.toStringHelper(getClass())
176 + .add("ERO object", eroObj)
177 + .add("Attribute list", attrList)
178 + .toString();
179 + }
180 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcepSrpObject;
25 +import org.onosproject.pcepio.types.PcepObjectHeader;
26 +import org.onosproject.pcepio.types.PcepValueType;
27 +import org.onosproject.pcepio.types.SymbolicPathNameTlv;
28 +import org.slf4j.Logger;
29 +import org.slf4j.LoggerFactory;
30 +
31 +import com.google.common.base.MoreObjects;
32 +
33 +public class PcepSrpObjectVer1 implements PcepSrpObject {
34 +
35 + /*
36 + * ref : draft-ietf-pce-stateful-pce-10, section : 7.2
37 + 0 1 2 3
38 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 + | Flags |R|
43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 + | SRP-ID-number |
45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 + | |
47 + // Optional TLVs //
48 + | |
49 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 +
51 + */
52 + protected static final Logger log = LoggerFactory.getLogger(PcepSrpObjectVer1.class);
53 +
54 + public static final byte SRP_OBJ_TYPE = 1;
55 + public static final byte SRP_OBJ_CLASS = 33;
56 + public static final byte SRP_OBJECT_VERSION = 1;
57 + public static final short SRP_OBJ_MINIMUM_LENGTH = 12;
58 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
59 + public static final boolean DEFAULT_RFLAG = false;
60 +
61 + static final PcepObjectHeader DEFAULT_SRP_OBJECT_HEADER = new PcepObjectHeader(SRP_OBJ_CLASS, SRP_OBJ_TYPE,
62 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, SRP_OBJ_MINIMUM_LENGTH);
63 +
64 + private PcepObjectHeader srpObjHeader;
65 + private static int flags;
66 + private boolean bRFlag;
67 + private int srpId;
68 +
69 + //Optional TLV
70 + private LinkedList<PcepValueType> llOptionalTlv;
71 + public static final byte BBIT_SET = 1;
72 + public static final byte BBIT_RESET = 0;
73 +
74 + /**
75 + * Constructor to initialize member variables.
76 + *
77 + * @param srpObjHeader srp object header
78 + * @param bRFlag R flag
79 + * @param srpID srp Id
80 + * @param llOptionalTlv list of optional tlv
81 + */
82 + public PcepSrpObjectVer1(PcepObjectHeader srpObjHeader, boolean bRFlag, int srpID,
83 + LinkedList<PcepValueType> llOptionalTlv) {
84 +
85 + this.srpObjHeader = srpObjHeader;
86 + this.bRFlag = bRFlag;
87 + this.srpId = srpID;
88 + this.llOptionalTlv = llOptionalTlv;
89 + }
90 +
91 + /**
92 + * sets the SRP object header.
93 + *
94 + * @param obj srp object header
95 + */
96 + public void setSrpObjHeader(PcepObjectHeader obj) {
97 + this.srpObjHeader = obj;
98 + }
99 +
100 + @Override
101 + public void setSrpID(int srpID) {
102 + this.srpId = srpID;
103 + }
104 +
105 + @Override
106 + public void setRFlag(boolean bRFlag) {
107 + this.bRFlag = bRFlag;
108 + }
109 +
110 + /**
111 + * Returns SRP object header.
112 + *
113 + * @return srpObjHeader
114 + */
115 + public PcepObjectHeader getSrpObjHeader() {
116 + return this.srpObjHeader;
117 + }
118 +
119 + @Override
120 + public int getSrpID() {
121 + return this.srpId;
122 + }
123 +
124 + @Override
125 + public boolean getRFlag() {
126 + return this.bRFlag;
127 + }
128 +
129 + @Override
130 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
131 + this.llOptionalTlv = llOptionalTlv;
132 +
133 + }
134 +
135 + @Override
136 + public LinkedList<PcepValueType> getOptionalTlv() {
137 + return this.llOptionalTlv;
138 + }
139 +
140 + /**
141 + * Reads from channel buffer and returns instance of PCEP SRP object.
142 + *
143 + * @param cb of channel buffer.
144 + * @return PCEP SRP object
145 + * @throws PcepParseException when srp object is not received in channel buffer
146 + */
147 + public static PcepSrpObject read(ChannelBuffer cb) throws PcepParseException {
148 +
149 + log.debug("SrpObject::read");
150 + PcepObjectHeader srpObjHeader;
151 + boolean bRFlag;
152 +
153 + int srpID;
154 + int flags;
155 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
156 +
157 + srpObjHeader = PcepObjectHeader.read(cb);
158 +
159 + if (SRP_OBJ_CLASS != srpObjHeader.getObjClass()) {
160 + throw new PcepParseException("SRP object expected. But received " + srpObjHeader.getObjClass());
161 + }
162 +
163 + //take only SrpObject buffer.
164 + ChannelBuffer tempCb = cb.readBytes(srpObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
165 + flags = tempCb.readInt();
166 + bRFlag = (0 < flags) ? true : false;
167 + srpID = tempCb.readInt();
168 +
169 + llOptionalTlv = parseOptionalTlv(tempCb);
170 +
171 + return new PcepSrpObjectVer1(srpObjHeader, bRFlag, srpID, llOptionalTlv);
172 + }
173 +
174 + @Override
175 + public int write(ChannelBuffer cb) throws PcepParseException {
176 +
177 + int objStartIndex = cb.writerIndex();
178 +
179 + //write common header
180 + int objLenIndex = srpObjHeader.write(cb);
181 +
182 + //write Flags
183 + byte bFlag;
184 +
185 + bFlag = (bRFlag) ? BBIT_SET : BBIT_RESET;
186 +
187 + cb.writeInt(bFlag);
188 +
189 + //write SrpId
190 + cb.writeInt(srpId);
191 +
192 + // Add optional TLV
193 + if (!packOptionalTlv(cb)) {
194 + throw new PcepParseException("Failed to write srp tlv to channel buffer.");
195 + }
196 +
197 + //now write SRP Object Length
198 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
199 +
200 + return cb.writerIndex();
201 + }
202 +
203 + /**
204 + * Parse Optional TLvs from the channel buffer.
205 + *
206 + * @param cb of type channel buffer
207 + * @return list of optional tlvs
208 + * @throws PcepParseException when unsupported tlv is received in srp object
209 + */
210 + public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
211 +
212 + LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
213 +
214 + while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
215 +
216 + PcepValueType tlv;
217 + short hType = cb.readShort();
218 + short hLength = cb.readShort();
219 +
220 + switch (hType) {
221 +
222 + case SymbolicPathNameTlv.TYPE:
223 + tlv = SymbolicPathNameTlv.read(cb, hLength);
224 + cb.skipBytes(hLength);
225 + break;
226 +
227 + default:
228 + throw new PcepParseException("Unsupported TLV received in SRP Object.");
229 + }
230 +
231 + // Check for the padding
232 + int pad = hLength % 4;
233 + if (0 < pad) {
234 + pad = 4 - pad;
235 + if (pad <= cb.readableBytes()) {
236 + cb.skipBytes(pad);
237 + }
238 + }
239 + llOutOptionalTlv.add(tlv);
240 + }
241 +
242 + return llOutOptionalTlv;
243 + }
244 +
245 + /**
246 + * Writes optional tlvs to channel buffer.
247 + *
248 + * @param cb of type channel buffer
249 + * @return true if writing optional tlv to channel buffer is success.
250 + */
251 + protected boolean packOptionalTlv(ChannelBuffer cb) {
252 +
253 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
254 +
255 + while (listIterator.hasNext()) {
256 + PcepValueType tlv = listIterator.next();
257 +
258 + if (null == tlv) {
259 + log.debug("tlv is null from OptionalTlv list");
260 + continue;
261 + }
262 + tlv.write(cb);
263 +
264 + // need to take care of padding
265 + int pad = tlv.getLength() % 4;
266 +
267 + if (0 != pad) {
268 + pad = 4 - pad;
269 + for (int i = 0; i < pad; ++i) {
270 + cb.writeByte((byte) 0);
271 + }
272 + }
273 + }
274 +
275 + return true;
276 + }
277 +
278 + /**
279 + * builder class for PCEP srp Object.
280 + */
281 + public static class Builder implements PcepSrpObject.Builder {
282 + private boolean bIsHeaderSet = false;
283 + private boolean bIsSrpIdset = false;
284 + private boolean bIsRFlagSet = false;
285 +
286 + private PcepObjectHeader srpObjHeader;
287 + private int srpId;
288 + private boolean bRFlag;
289 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
290 +
291 + private boolean bIsPFlagSet = false;
292 + private boolean bPFlag;
293 +
294 + private boolean bIsIFlagSet = false;
295 + private boolean bIFlag;
296 +
297 + @Override
298 + public PcepSrpObject build() throws PcepParseException {
299 + PcepObjectHeader srpObjHeader = this.bIsHeaderSet ? this.srpObjHeader : DEFAULT_SRP_OBJECT_HEADER;
300 +
301 + boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_RFLAG;
302 +
303 + if (!this.bIsSrpIdset) {
304 + throw new PcepParseException("SrpID not set while building SRP Object.");
305 + }
306 +
307 + if (bIsPFlagSet) {
308 + srpObjHeader.setPFlag(bPFlag);
309 + }
310 +
311 + if (bIsIFlagSet) {
312 + srpObjHeader.setIFlag(bIFlag);
313 + }
314 +
315 + return new PcepSrpObjectVer1(srpObjHeader, bRFlag, this.srpId, this.llOptionalTlv);
316 + }
317 +
318 + @Override
319 + public PcepObjectHeader getSrpObjHeader() {
320 + return this.srpObjHeader;
321 + }
322 +
323 + @Override
324 + public Builder setSrpObjHeader(PcepObjectHeader obj) {
325 + this.srpObjHeader = obj;
326 + this.bIsHeaderSet = true;
327 + return this;
328 + }
329 +
330 + @Override
331 + public int getSrpID() {
332 + return this.srpId;
333 + }
334 +
335 + @Override
336 + public Builder setSrpID(int srpID) {
337 + this.srpId = srpID;
338 + this.bIsSrpIdset = true;
339 + return this;
340 + }
341 +
342 + @Override
343 + public boolean getRFlag() {
344 + return this.bRFlag;
345 + }
346 +
347 + @Override
348 + public Builder setRFlag(boolean bRFlag) {
349 + this.bRFlag = bRFlag;
350 + this.bIsRFlagSet = true;
351 + return this;
352 + }
353 +
354 + @Override
355 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
356 + this.llOptionalTlv = llOptionalTlv;
357 + return this;
358 + }
359 +
360 + @Override
361 + public LinkedList<PcepValueType> getOptionalTlv() {
362 + return this.llOptionalTlv;
363 + }
364 +
365 + @Override
366 + public Builder setPFlag(boolean value) {
367 + this.bPFlag = value;
368 + this.bIsPFlagSet = true;
369 + return this;
370 + }
371 +
372 + @Override
373 + public Builder setIFlag(boolean value) {
374 + this.bIFlag = value;
375 + this.bIsIFlagSet = true;
376 + return this;
377 + }
378 +
379 + }
380 +
381 + @Override
382 + public void print() {
383 +
384 + log.debug("SRP OBJECT");
385 + long lTemp = (bRFlag) ? 1 : 0;
386 + log.debug("r Flag: " + lTemp);
387 + log.debug("SrpID: " + srpId);
388 +
389 + log.debug("OPTIONAL TLV");
390 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
391 + while (listIterator.hasNext()) {
392 + listIterator.next().print();
393 + }
394 + }
395 + @Override
396 + public String toString() {
397 + return MoreObjects.toStringHelper(getClass())
398 + .add("R flag", bRFlag)
399 + .add("SRP ID", srpId)
400 + .add("Optional tlv list", llOptionalTlv)
401 + .toString();
402 + }
403 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import java.util.LinkedList;
20 +import java.util.ListIterator;
21 +
22 +import org.jboss.netty.buffer.ChannelBuffer;
23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 +import org.onosproject.pcepio.protocol.PcepLspObject;
25 +import org.onosproject.pcepio.protocol.PcepMessageReader;
26 +import org.onosproject.pcepio.protocol.PcepMessageWriter;
27 +import org.onosproject.pcepio.protocol.PcepMsgPath;
28 +import org.onosproject.pcepio.protocol.PcepSrpObject;
29 +import org.onosproject.pcepio.protocol.PcepType;
30 +import org.onosproject.pcepio.protocol.PcepUpdateMsg;
31 +import org.onosproject.pcepio.protocol.PcepUpdateRequest;
32 +import org.onosproject.pcepio.protocol.PcepVersion;
33 +import org.slf4j.Logger;
34 +import org.slf4j.LoggerFactory;
35 +
36 +import com.google.common.base.MoreObjects;
37 +
38 +/**
39 + * PCEP Update Message: A Path Computation LSP Update Request message
40 + * (also referred to as PCUpd message) is a PCEP message sent by a PCE
41 + * to a PCC to update attributes of an LSP.
42 + */
43 +
44 +class PcepUpdateMsgVer1 implements PcepUpdateMsg {
45 +
46 + // Pcep version: 1
47 +
48 + /* The format of the PCUpd message is as follows:
49 + * <PCUpd Message> ::= <Common Header>
50 + * <update-request-list>
51 + * Where:
52 + * <update-request-list> ::= <update-request>[<update-request-list>]
53 + * <update-request> ::= <SRP>
54 + * <LSP>
55 + * <path>
56 + * Where:
57 + * <path> ::= <ERO><attribute-list>
58 + * Where:
59 + * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
60 + * where:
61 + * <attribute-list> ::=[<LSPA>]
62 + * [<BANDWIDTH>]
63 + * [<metric-list>]
64 + * [<IRO>]
65 + * <metric-list> ::=<METRIC>[<metric-list>]
66 + *
67 + * 0 1 2 3
68 + * 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
69 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
70 + * | Ver | Flags | Message-Type | Message-Length |
71 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 + * | |
73 + * // UPDATE REQUEST LIST //
74 + * | |
75 + * +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 + *
77 + * Reference:Internet-Draft-PCEP Extensions-for-Stateful-PCE-10
78 + */
79 +
80 + protected static final Logger log = LoggerFactory.getLogger(PcepUpdateMsgVer1.class);
81 +
82 + public static final byte PACKET_VERSION = 1;
83 + // UpdateMsgMinLength = SrpObjMinLentgh(12)+LspObjMinLength(8)+EroObjMinLength(12)+ CommonHeaderLength(4)
84 + public static final short PACKET_MINIMUM_LENGTH = 36;
85 + public static final PcepType MSG_TYPE = PcepType.UPDATE;
86 + //Update Request List
87 + private LinkedList<PcepUpdateRequest> llUpdateRequestList;
88 +
89 + public static final PcepUpdateMsgVer1.Reader READER = new Reader();
90 +
91 + //Reader reads UpdateMessage from the channel.
92 + static class Reader implements PcepMessageReader<PcepUpdateMsg> {
93 +
94 + LinkedList<PcepUpdateRequest> llUpdateRequestList;
95 +
96 + @Override
97 + public PcepUpdateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
98 +
99 + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
100 + throw new PcepParseException("Readable bytes is less than update message minimum length");
101 + }
102 +
103 + llUpdateRequestList = new LinkedList<PcepUpdateRequest>();
104 +
105 + // fixed value property version == 1
106 + byte version = cb.readByte();
107 + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
108 + if (version != PACKET_VERSION) {
109 + throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), got=" + version);
110 + }
111 + // fixed value property type == 11
112 + byte type = cb.readByte();
113 + if (type != MSG_TYPE.getType()) {
114 + throw new PcepParseException("Wrong type. Expected=PcepType.UPDATE(11), got=" + type);
115 + }
116 + short length = cb.readShort();
117 + if (length < PACKET_MINIMUM_LENGTH) {
118 + throw new PcepParseException("Wrong length. Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: "
119 + + length);
120 + }
121 +
122 + log.debug("reading update message of length " + length);
123 +
124 + // parse Update Request list
125 + if (!parseUpdateRequestList(cb)) {
126 + throw new PcepParseException("parsing Update Request List Failed.");
127 + }
128 +
129 + return new PcepUpdateMsgVer1(llUpdateRequestList);
130 + }
131 +
132 + /**
133 + * Parse update request list.
134 + *
135 + * @param cb of type channel buffer
136 + * @return true after parsing Update Request List
137 + * @throws PcepParseException while parsing update request list from channel buffer
138 + */
139 + public boolean parseUpdateRequestList(ChannelBuffer cb) throws PcepParseException {
140 +
141 + /* <update-request-list>
142 + * Where:
143 + * <update-request-list> ::= <update-request>[<update-request-list>]
144 + * <update-request> ::= <SRP>
145 + * <LSP>
146 + * <path>
147 + * Where:
148 + * <path> ::= <ERO><attribute-list>
149 + * Where:
150 + * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
151 + */
152 +
153 + while (0 < cb.readableBytes()) {
154 +
155 + PcepUpdateRequest pceUpdateReq = new PcepUpdateRequestVer1();
156 +
157 + //Read SRP Object and Store it.
158 + PcepSrpObject srpObj;
159 + srpObj = PcepSrpObjectVer1.read(cb);
160 + pceUpdateReq.setSrpObject(srpObj);
161 +
162 + //Read LSP object and Store it.
163 + PcepLspObject lspObj;
164 + lspObj = PcepLspObjectVer1.read(cb);
165 + pceUpdateReq.setLspObject(lspObj);
166 +
167 + // Read Msg Path and store it.
168 + PcepMsgPath msgPath = new PcepMsgPathVer1().read(cb);
169 + pceUpdateReq.setMsgPath(msgPath);
170 +
171 + llUpdateRequestList.add(pceUpdateReq);
172 + }
173 + return true;
174 + }
175 + }
176 +
177 + /**
178 + * Constructor to initialize llUpdateRequestList.
179 + *
180 + * @param llUpdateRequestList list of PcepUpdateRequest.
181 + */
182 + PcepUpdateMsgVer1(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
183 + this.llUpdateRequestList = llUpdateRequestList;
184 + }
185 +
186 + /**
187 + * builder class for PCPE update message.
188 + */
189 + static class Builder implements PcepUpdateMsg.Builder {
190 +
191 + // PCEP report message fields
192 + LinkedList<PcepUpdateRequest> llUpdateRequestList;
193 +
194 + @Override
195 + public PcepVersion getVersion() {
196 + return PcepVersion.PCEP_1;
197 + }
198 +
199 + @Override
200 + public PcepType getType() {
201 + return PcepType.UPDATE;
202 + }
203 +
204 + @Override
205 + public PcepUpdateMsg build() {
206 + return new PcepUpdateMsgVer1(this.llUpdateRequestList);
207 + }
208 +
209 + @Override
210 + public LinkedList<PcepUpdateRequest> getUpdateRequestList() {
211 + return this.llUpdateRequestList;
212 + }
213 +
214 + @Override
215 + public Builder setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
216 + this.llUpdateRequestList = llUpdateRequestList;
217 + return this;
218 + }
219 +
220 + }
221 +
222 + @Override
223 + public void writeTo(ChannelBuffer cb) throws PcepParseException {
224 + WRITER.write(cb, this);
225 + }
226 +
227 + static final Writer WRITER = new Writer();
228 +
229 + //Writer writes UpdateMessage to the channel buffer.
230 + static class Writer implements PcepMessageWriter<PcepUpdateMsgVer1> {
231 +
232 + @Override
233 + public void write(ChannelBuffer cb, PcepUpdateMsgVer1 message) throws PcepParseException {
234 +
235 + int startIndex = cb.writerIndex();
236 + // first 3 bits set to version
237 + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
238 + // message type
239 + cb.writeByte(MSG_TYPE.getType());
240 + /* length is length of variable message, will be updated at the end
241 + * Store the position of message
242 + * length in buffer
243 + */
244 + int msgLenIndex = cb.writerIndex();
245 +
246 + cb.writeShort((short) 0);
247 + ListIterator<PcepUpdateRequest> listIterator = message.llUpdateRequestList.listIterator();
248 +
249 + while (listIterator.hasNext()) {
250 +
251 + PcepUpdateRequest updateReq = listIterator.next();
252 +
253 + //SRP object is mandatory
254 + PcepSrpObject srpObj = updateReq.getSrpObject();
255 + srpObj.write(cb);
256 +
257 + //LSP object is mandatory
258 + PcepLspObject lspObj = updateReq.getLspObject();
259 + lspObj.write(cb);
260 +
261 + //PATH object is mandatory
262 + PcepMsgPath msgPath = updateReq.getMsgPath();
263 + msgPath.write(cb);
264 + }
265 +
266 + // update message length field
267 + int length = cb.writerIndex() - startIndex;
268 + cb.setShort(msgLenIndex, (short) length);
269 + }
270 + }
271 +
272 + @Override
273 + public PcepVersion getVersion() {
274 + return PcepVersion.PCEP_1;
275 + }
276 +
277 + @Override
278 + public PcepType getType() {
279 + return MSG_TYPE;
280 + }
281 +
282 + @Override
283 + public LinkedList<PcepUpdateRequest> getUpdateRequestList() {
284 + return this.llUpdateRequestList;
285 + }
286 +
287 + @Override
288 + public void setUpdateRequestList(LinkedList<PcepUpdateRequest> llUpdateRequestList) {
289 + this.llUpdateRequestList = llUpdateRequestList;
290 + }
291 +
292 + @Override
293 + public void print() {
294 +
295 + log.debug("PCEP UPDATE MESSAGE");
296 + ListIterator<PcepUpdateRequest> listIterator = llUpdateRequestList.listIterator();
297 + while (listIterator.hasNext()) {
298 + listIterator.next().print();
299 + }
300 + }
301 +
302 + @Override
303 + public String toString() {
304 + return MoreObjects.toStringHelper(getClass())
305 + .add("Update Request list", llUpdateRequestList)
306 + .toString();
307 + }
308 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.protocol.ver1;
18 +
19 +import org.onosproject.pcepio.exceptions.PcepParseException;
20 +import org.onosproject.pcepio.protocol.PcepLspObject;
21 +import org.onosproject.pcepio.protocol.PcepMsgPath;
22 +import org.onosproject.pcepio.protocol.PcepSrpObject;
23 +import org.onosproject.pcepio.protocol.PcepUpdateRequest;
24 +import org.slf4j.Logger;
25 +import org.slf4j.LoggerFactory;
26 +
27 +import com.google.common.base.MoreObjects;
28 +
29 +/*
30 + * PCEP Update Request List.
31 + */
32 +public class PcepUpdateRequestVer1 implements PcepUpdateRequest {
33 +
34 + /* <update-request-list>
35 + * Where:
36 + * <update-request-list> ::= <update-request>[<update-request-list>]
37 + * <update-request> ::= <SRP>
38 + * <LSP>
39 + * <path>
40 + * Where:
41 + * <path> ::= <ERO><attribute-list>
42 + * Where:
43 + * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
44 + */
45 +
46 + protected static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class);
47 +
48 + //PCEP SRP Object
49 + private PcepSrpObject srpObject;
50 + //PCEP LSP Object
51 + private PcepLspObject lspObject;
52 + //PCEP Message path
53 + private PcepMsgPath msgPath;
54 +
55 + /**
56 + * Default constructor.
57 + */
58 + public PcepUpdateRequestVer1() {
59 + srpObject = null;
60 + lspObject = null;
61 + msgPath = null;
62 + }
63 +
64 + /**
65 + * Constructor to initialize all member variables.
66 + *
67 + * @param srpObject srp object
68 + * @param lspObject lsp object
69 + * @param msgPath message path object
70 + */
71 + public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) {
72 + this.srpObject = srpObject;
73 + this.lspObject = lspObject;
74 + this.msgPath = msgPath;
75 + }
76 +
77 + @Override
78 + public PcepSrpObject getSrpObject() {
79 + return srpObject;
80 + }
81 +
82 + @Override
83 + public PcepLspObject getLspObject() {
84 + return lspObject;
85 + }
86 +
87 + @Override
88 + public PcepMsgPath getMsgPath() {
89 + return msgPath;
90 + }
91 +
92 + @Override
93 + public void setSrpObject(PcepSrpObject srpObject) {
94 + this.srpObject = srpObject;
95 +
96 + }
97 +
98 + @Override
99 + public void setLspObject(PcepLspObject lspObject) {
100 + this.lspObject = lspObject;
101 + }
102 +
103 + @Override
104 + public void setMsgPath(PcepMsgPath msgPath) {
105 + this.msgPath = msgPath;
106 + }
107 +
108 + /**
109 + * Builder class for PCEP update request.
110 + */
111 + public static class Builder implements PcepUpdateRequest.Builder {
112 +
113 + private boolean bIsSRPObjectSet = false;
114 + private boolean bIsLSPObjectSet = false;
115 + private boolean bIsPcepMsgPathSet = false;
116 +
117 + //PCEP SRP Object
118 + private PcepSrpObject srpObject;
119 + //PCEP LSP Object
120 + private PcepLspObject lspObject;
121 + //PCEP Attribute list
122 + private PcepMsgPath msgPath;
123 +
124 + @Override
125 + public PcepUpdateRequest build() throws PcepParseException {
126 +
127 + //PCEP SRP Object
128 + PcepSrpObject srpObject = null;
129 + //PCEP LSP Object
130 + PcepLspObject lspObject = null;
131 + //PCEP Attribute list
132 + PcepMsgPath msgPath = null;
133 +
134 + if (!this.bIsSRPObjectSet) {
135 + throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest.");
136 + } else {
137 + srpObject = this.srpObject;
138 + }
139 + if (!this.bIsLSPObjectSet) {
140 + throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest.");
141 + } else {
142 + lspObject = this.lspObject;
143 + }
144 + if (!this.bIsPcepMsgPathSet) {
145 + throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest.");
146 + } else {
147 + msgPath = this.msgPath;
148 + }
149 +
150 + return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath);
151 + }
152 +
153 + @Override
154 + public PcepSrpObject getSrpObject() {
155 + return this.srpObject;
156 + }
157 +
158 + @Override
159 + public PcepLspObject getLspObject() {
160 + return this.lspObject;
161 + }
162 +
163 + @Override
164 + public PcepMsgPath getMsgPath() {
165 + return this.msgPath;
166 + }
167 +
168 + @Override
169 + public Builder setSrpObject(PcepSrpObject srpobj) {
170 + this.srpObject = srpobj;
171 + this.bIsSRPObjectSet = true;
172 + return this;
173 +
174 + }
175 +
176 + @Override
177 + public Builder setLspObject(PcepLspObject lspObject) {
178 + this.lspObject = lspObject;
179 + this.bIsLSPObjectSet = true;
180 + return this;
181 + }
182 +
183 + @Override
184 + public Builder setMsgPath(PcepMsgPath msgPath) {
185 + this.msgPath = msgPath;
186 + this.bIsPcepMsgPathSet = true;
187 + return this;
188 + }
189 + }
190 +
191 + @Override
192 + public void print() {
193 +
194 + log.debug("UPDATE REQUEST");
195 + srpObject.print();
196 + lspObject.print();
197 + }
198 +
199 + @Override
200 + public String toString() {
201 + return MoreObjects.toStringHelper(getClass())
202 + .add("SRP Object", srpObject)
203 + .add("LSP object", lspObject)
204 + .add("message path object", msgPath)
205 + .toString();
206 + }
207 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2015 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.pcepio.types;
17 +
18 +import java.util.Objects;
19 +
20 +import org.jboss.netty.buffer.ChannelBuffer;
21 +import org.onosproject.pcepio.protocol.PcepVersion;
22 +import org.slf4j.Logger;
23 +import org.slf4j.LoggerFactory;
24 +
25 +import com.google.common.base.MoreObjects;
26 +
27 +/**
28 + * Provides Autonomous System Tlv which contains opaque value (32 Bit AS Number).
29 + */
30 +public class AutonomousSystemTlv implements PcepValueType {
31 +
32 + /* Reference :RFC3209
33 + * 0 1 2 3
34 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 + | Type=[TBD10] | Length=4 |
37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 + | opaque value (32 Bit AS Number) |
39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 + */
41 +
42 + protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class);
43 +
44 + public static final short TYPE = 100; //TODD:change this TBD10
45 + public static final short LENGTH = 4;
46 +
47 + private final int rawValue;
48 +
49 + /**
50 + * constructor to initialize Autonomous system tlv value.
51 + *
52 + * @param rawValue value of Autonomous system tlv
53 + */
54 + public AutonomousSystemTlv(int rawValue) {
55 + this.rawValue = rawValue;
56 + }
57 +
58 + /**
59 + * To create instance of AutonomousSystemTlv.
60 + *
61 + * @param raw opaque value ofc 32 Bit AS Number
62 + * @return object of AutonomousSystemTlv
63 + */
64 + public static AutonomousSystemTlv of(final int raw) {
65 + return new AutonomousSystemTlv(raw);
66 + }
67 +
68 + /**
69 + * Returns opaque value of 32 Bit AS Number.
70 + *
71 + * @return int value of rawValue
72 + */
73 + public int getInt() {
74 + return rawValue;
75 + }
76 +
77 + @Override
78 + public PcepVersion getVersion() {
79 + return PcepVersion.PCEP_1;
80 + }
81 +
82 + @Override
83 + public short getType() {
84 + return TYPE;
85 + }
86 +
87 + @Override
88 + public short getLength() {
89 + return LENGTH;
90 + }
91 +
92 + @Override
93 + public int hashCode() {
94 + return Objects.hash(rawValue);
95 + }
96 +
97 + @Override
98 + public boolean equals(Object obj) {
99 + if (this == obj) {
100 + return true;
101 + }
102 + if (obj instanceof AutonomousSystemTlv) {
103 + AutonomousSystemTlv other = (AutonomousSystemTlv) obj;
104 + return Objects.equals(rawValue, other.rawValue);
105 + }
106 + return false;
107 + }
108 +
109 + @Override
110 + public int write(ChannelBuffer c) {
111 + int iLenStartIndex = c.writerIndex();
112 + c.writeShort(TYPE);
113 + c.writeShort(LENGTH);
114 + c.writeInt(rawValue);
115 + return c.writerIndex() - iLenStartIndex;
116 + }
117 +
118 + /**
119 + * Reads the channel buffer and returns object of AutonomousSystemTlv.
120 + *
121 + * @param c type of channel buffer
122 + * @return object of AutonomousSystemTlv
123 + */
124 + public static AutonomousSystemTlv read(ChannelBuffer c) {
125 + return AutonomousSystemTlv.of(c.readInt());
126 + }
127 +
128 + @Override
129 + public void print() {
130 + log.debug("AutonomousSystemTlv");
131 + log.debug("Type: " + TYPE);
132 + log.debug("Length: " + LENGTH);
133 + log.debug("Value: " + rawValue);
134 + }
135 +
136 + @Override
137 + public String toString() {
138 + return MoreObjects.toStringHelper(getClass())
139 + .add("TYPE", TYPE)
140 + .add("Length", LENGTH)
141 + .add("value", rawValue)
142 + .toString();
143 + }
144 +}
...@@ -10,14 +10,17 @@ import org.onosproject.pcepio.protocol.PcepOpenObject; ...@@ -10,14 +10,17 @@ import org.onosproject.pcepio.protocol.PcepOpenObject;
10 import org.slf4j.Logger; 10 import org.slf4j.Logger;
11 import org.slf4j.LoggerFactory; 11 import org.slf4j.LoggerFactory;
12 12
13 +import com.google.common.base.MoreObjects;
14 +import com.google.common.base.MoreObjects.ToStringHelper;
15 +
13 /* 16 /*
14 * Provide the error object list with open object. 17 * Provide the error object list with open object.
15 */ 18 */
16 public class ErrorObjListWithOpen { 19 public class ErrorObjListWithOpen {
17 //errorObjList is mandatory 20 //errorObjList is mandatory
18 - LinkedList<PcepErrorObject> llerrorObjList; 21 + private LinkedList<PcepErrorObject> llerrorObjList;
19 // openObject is optional 22 // openObject is optional
20 - PcepOpenObject openObject; 23 + private PcepOpenObject openObject;
21 // flag to check if open object is set or not 24 // flag to check if open object is set or not
22 public boolean isOpenObjectSet; 25 public boolean isOpenObjectSet;
23 protected static final Logger log = LoggerFactory.getLogger(ErrorObjListWithOpen.class); 26 protected static final Logger log = LoggerFactory.getLogger(ErrorObjListWithOpen.class);
...@@ -49,6 +52,11 @@ public class ErrorObjListWithOpen { ...@@ -49,6 +52,11 @@ public class ErrorObjListWithOpen {
49 isOpenObjectSet = false; 52 isOpenObjectSet = false;
50 } 53 }
51 54
55 + /**
56 + * Returns error type.
57 + *
58 + * @return error type
59 + */
52 public LinkedList<Integer> getErrorType() { 60 public LinkedList<Integer> getErrorType() {
53 LinkedList<Integer> errorType = new LinkedList<Integer>(); 61 LinkedList<Integer> errorType = new LinkedList<Integer>();
54 if (llerrorObjList != null) { 62 if (llerrorObjList != null) {
...@@ -56,7 +64,7 @@ public class ErrorObjListWithOpen { ...@@ -56,7 +64,7 @@ public class ErrorObjListWithOpen {
56 int error; 64 int error;
57 PcepErrorObject errorObj; 65 PcepErrorObject errorObj;
58 while (errObjListIterator.hasNext()) { 66 while (errObjListIterator.hasNext()) {
59 - errorObj = errObjListIterator.next(); 67 + errorObj = errObjListIterator.next();
60 error = errorObj.getErrorType(); 68 error = errorObj.getErrorType();
61 errorType.add(error); 69 errorType.add(error);
62 } 70 }
...@@ -64,6 +72,11 @@ public class ErrorObjListWithOpen { ...@@ -64,6 +72,11 @@ public class ErrorObjListWithOpen {
64 return errorType; 72 return errorType;
65 } 73 }
66 74
75 + /**
76 + * Returns error value.
77 + *
78 + * @return error value
79 + */
67 public LinkedList<Integer> getErrorValue() { 80 public LinkedList<Integer> getErrorValue() {
68 LinkedList<Integer> errorValue = new LinkedList<Integer>(); 81 LinkedList<Integer> errorValue = new LinkedList<Integer>();
69 if (llerrorObjList != null) { 82 if (llerrorObjList != null) {
...@@ -71,7 +84,7 @@ public class ErrorObjListWithOpen { ...@@ -71,7 +84,7 @@ public class ErrorObjListWithOpen {
71 int error; 84 int error;
72 PcepErrorObject errorObj; 85 PcepErrorObject errorObj;
73 while (errObjListIterator.hasNext()) { 86 while (errObjListIterator.hasNext()) {
74 - errorObj = errObjListIterator.next(); 87 + errorObj = errObjListIterator.next();
75 error = errorObj.getErrorValue(); 88 error = errorObj.getErrorValue();
76 errorValue.add(error); 89 errorValue.add(error);
77 90
...@@ -79,7 +92,8 @@ public class ErrorObjListWithOpen { ...@@ -79,7 +92,8 @@ public class ErrorObjListWithOpen {
79 } 92 }
80 return errorValue; 93 return errorValue;
81 } 94 }
82 - /* 95 +
96 + /**
83 * Checks whether error object list is empty or not. 97 * Checks whether error object list is empty or not.
84 * 98 *
85 * @return whether error object list is empty or not 99 * @return whether error object list is empty or not
...@@ -90,7 +104,7 @@ public class ErrorObjListWithOpen { ...@@ -90,7 +104,7 @@ public class ErrorObjListWithOpen {
90 return (!this.llerrorObjList.isEmpty()) ? true : false; 104 return (!this.llerrorObjList.isEmpty()) ? true : false;
91 } 105 }
92 106
93 - /* 107 + /**
94 * Write Error Object List and Open Object to channel buffer. 108 * Write Error Object List and Open Object to channel buffer.
95 * 109 *
96 * @param bb of type channel buffer 110 * @param bb of type channel buffer
...@@ -121,7 +135,7 @@ public class ErrorObjListWithOpen { ...@@ -121,7 +135,7 @@ public class ErrorObjListWithOpen {
121 return bb.writerIndex() - iLenStartIndex; 135 return bb.writerIndex() - iLenStartIndex;
122 } 136 }
123 137
124 - /* 138 + /**
125 * Prints the attributes of ErrorObject List with open Object. 139 * Prints the attributes of ErrorObject List with open Object.
126 */ 140 */
127 public void print() { 141 public void print() {
...@@ -137,4 +151,19 @@ public class ErrorObjListWithOpen { ...@@ -137,4 +151,19 @@ public class ErrorObjListWithOpen {
137 openObject.print(); 151 openObject.print();
138 } 152 }
139 } 153 }
154 +
155 + @Override
156 + public String toString() {
157 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
158 +
159 + if (openObject == null) {
160 + toStrHelper
161 + .add("error Obj List", llerrorObjList);
162 + } else {
163 + toStrHelper
164 + .add("error Obj List", llerrorObjList)
165 + .add("open Object", openObject);
166 + }
167 + return toStrHelper.toString();
168 + }
140 } 169 }
......
1 +/*
2 + * Copyright 2015 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 +
17 +/**
18 + * @author b00295750
19 + *
20 + */
21 +package org.onosproject.pcepio.types;
22 +
23 +import java.util.Objects;
24 +
25 +import org.jboss.netty.buffer.ChannelBuffer;
26 +import org.onosproject.pcepio.protocol.PcepVersion;
27 +import org.slf4j.Logger;
28 +import org.slf4j.LoggerFactory;
29 +
30 +import com.google.common.base.MoreObjects;
31 +
32 +/**
33 + * Provides IPv4 Sub Object.
34 + */
35 +public class IPv4SubObject implements PcepValueType {
36 +
37 + /*Reference : RFC 4874:3.1.1
38 + * 0 1 2 3
39 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 + |L| Type | Length | IPv4 address (4 bytes) |
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | IPv4 address (continued) | Prefix Length | Resvd |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + */
46 + protected static final Logger log = LoggerFactory.getLogger(IPv4SubObject.class);
47 +
48 + public static final byte TYPE = 0x01;
49 + public static final byte LENGTH = 8;
50 + public static final byte VALUE_LENGTH = 6;
51 + public static final byte OBJ_LENGTH = 8;
52 + public static final byte LBIT = 0;
53 + public static final int SHIFT_LBIT_POSITION = 7;
54 + private int ipAddress;
55 + private byte prefixLen;
56 + private byte resvd;
57 +
58 + /**
59 + * Constructor to initialize ipv4 address.
60 + *
61 + * @param ipAddr ipv4 address
62 + */
63 + public IPv4SubObject(int ipAddr) {
64 + this.ipAddress = ipAddr;
65 + }
66 +
67 + /**
68 + * constructor to initialize ipAddress, prefixLen and resvd.
69 + *
70 + * @param ipAddress ipv4 address
71 + * @param prefixLen prefix length
72 + * @param resvd reserved flags value
73 + */
74 + public IPv4SubObject(int ipAddress, byte prefixLen, byte resvd) {
75 + this.ipAddress = ipAddress;
76 + this.prefixLen = prefixLen;
77 + this.resvd = resvd;
78 + }
79 +
80 + /**
81 + * Returns a new instance of IPv4SubObject.
82 + *
83 + * @param ipAddress ipv4 address
84 + * @param prefixLen prefix length
85 + * @param resvd reserved flags value
86 + * @return object of IPv4SubObject
87 + */
88 + public static IPv4SubObject of(int ipAddress, byte prefixLen, byte resvd) {
89 + return new IPv4SubObject(ipAddress, prefixLen, resvd);
90 + }
91 +
92 + /**
93 + * Returns prefixLen of IPv4 IP address.
94 + *
95 + * @return byte value of rawValue
96 + */
97 + public byte getPrefixLen() {
98 + return prefixLen;
99 + }
100 +
101 + /**
102 + * Returns value of IPv4 IP address.
103 + *
104 + * @return int value of ipv4 address
105 + */
106 + public int getIpAddress() {
107 + return ipAddress;
108 + }
109 +
110 + @Override
111 + public PcepVersion getVersion() {
112 + return PcepVersion.PCEP_1;
113 + }
114 +
115 + @Override
116 + public short getType() {
117 + return TYPE;
118 + }
119 +
120 + @Override
121 + public short getLength() {
122 + return LENGTH;
123 + }
124 +
125 + @Override
126 + public int hashCode() {
127 + return Objects.hash(ipAddress, prefixLen, resvd);
128 + }
129 +
130 + @Override
131 + public boolean equals(Object obj) {
132 + if (this == obj) {
133 + return true;
134 + }
135 + if (obj instanceof IPv4SubObject) {
136 + IPv4SubObject other = (IPv4SubObject) obj;
137 + return Objects.equals(this.ipAddress, other.ipAddress) && Objects.equals(this.prefixLen, other.prefixLen)
138 + && Objects.equals(this.resvd, other.resvd);
139 + }
140 + return false;
141 + }
142 +
143 + /**
144 + * Reads the channel buffer and returns object of IPv4SubObject.
145 + *
146 + * @param c type of channel buffer
147 + * @return object of IPv4SubObject
148 + */
149 + public static PcepValueType read(ChannelBuffer c) {
150 + int ipAddess = c.readInt();
151 + byte prefixLen = c.readByte();
152 + byte resvd = c.readByte();
153 + return new IPv4SubObject(ipAddess, prefixLen, resvd);
154 + }
155 +
156 + @Override
157 + public int write(ChannelBuffer c) {
158 + int iLenStartIndex = c.writerIndex();
159 + byte bValue = LBIT;
160 + bValue = (byte) (bValue << SHIFT_LBIT_POSITION);
161 + bValue = (byte) (bValue | TYPE);
162 + c.writeByte(bValue);
163 + c.writeByte(OBJ_LENGTH);
164 + c.writeInt(ipAddress);
165 + c.writeByte(prefixLen);
166 + c.writeByte(resvd);
167 +
168 + return c.writerIndex() - iLenStartIndex;
169 + }
170 +
171 + @Override
172 + public void print() {
173 + log.debug("IPv4SubObject");
174 + log.debug("Type: " + TYPE);
175 + log.debug("Length: " + LENGTH);
176 + log.debug("IPv4 address: " + String.format("%08X", ipAddress));
177 + log.debug("Prefix Length: " + prefixLen);
178 + }
179 +
180 + @Override
181 + public String toString() {
182 + return MoreObjects.toStringHelper(getClass())
183 + .add("Type", TYPE)
184 + .add("Length", LENGTH)
185 + .add("IPv4 Address", ipAddress)
186 + .add("Prefix Length", prefixLen)
187 + .toString();
188 + }
189 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +/**
29 + * Provides IPv6 Sub Object.
30 + */
31 +public class IPv6SubObject implements PcepValueType {
32 +
33 + /* reference :RFC 4874.
34 + Subobject : IPv6 address
35 +
36 + 0 1 2 3
37 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 + | Type | Length | IPv6 address (16 bytes) |
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 + | IPv6 address (continued) |
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | IPv6 address (continued) |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + | IPv6 address (continued) |
46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 + | IPv6 address (continued) | Prefix Length | Flags |
48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 +
50 + Type
51 +
52 + 0x02 IPv6 address
53 +
54 + Length
55 +
56 + The Length contains the total length of the subobject in bytes,
57 + including the Type and Length fields. The Length is always 20.
58 +
59 + IPv6 address
60 +
61 + A 128-bit unicast host address.
62 +
63 + Prefix length
64 +
65 + 128
66 +
67 + Flags
68 +
69 + 0x01 Local protection available
70 +
71 + Indicates that the link downstream of this node is
72 + protected via a local repair mechanism. This flag can
73 + only be set if the Local protection flag was set in the
74 + SESSION_ATTRIBUTE object of the corresponding Path
75 + message.
76 +
77 + 0x02 Local protection in use
78 +
79 + Indicates that a local repair mechanism is in use to
80 + maintain this tunnel (usually in the face of an outage
81 + of the link it was previously routed over).
82 + */
83 + protected static final Logger log = LoggerFactory.getLogger(IPv6SubObject.class);
84 +
85 + public static final short TYPE = 0x02;
86 + public static final short LENGTH = 20;
87 + public static final byte VALUE_LENGTH = 18;
88 +
89 + private static final byte[] NONE_VAL = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
90 + public static final IPv6SubObject NONE = new IPv6SubObject(NONE_VAL);
91 +
92 + private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
93 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
94 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
95 + public static final IPv6SubObject NO_MASK = new IPv6SubObject(NO_MASK_VAL);
96 + public static final IPv6SubObject FULL_MASK = NONE;
97 +
98 + private final byte[] rawValue;
99 +
100 + /**
101 + * constructor to initialize rawValue with ipv6 address.
102 + *
103 + * @param rawValue ipv6 address
104 + */
105 + public IPv6SubObject(byte[] rawValue) {
106 + this.rawValue = rawValue;
107 + }
108 +
109 + /**
110 + * To create instance of IPv6SubObject.
111 + *
112 + * @param raw byte array of ipv6 address
113 + * @return object of IPv6SubObject
114 + */
115 + public static IPv6SubObject of(final byte[] raw) {
116 + //check NONE_VAL
117 + boolean bFoundNONE = true;
118 + //value starts from 3rd byte.
119 + for (int i = 2; i < 20; ++i) {
120 + if (NONE_VAL[i] != raw[i]) {
121 + bFoundNONE = false;
122 + }
123 + }
124 +
125 + if (bFoundNONE) {
126 + return NONE;
127 + }
128 +
129 + //check NO_MASK_VAL
130 + boolean bFoundNoMask = true;
131 + //value starts from 3rd byte.
132 + for (int i = 2; i < 20; ++i) {
133 + if (0xFF != raw[i]) {
134 + bFoundNoMask = false;
135 + }
136 + }
137 + if (bFoundNoMask) {
138 + return NO_MASK;
139 + }
140 +
141 + return new IPv6SubObject(raw);
142 + }
143 +
144 + /**
145 + * Returns value of IPv6 Sub Object.
146 + *
147 + * @return byte array of ipv6 address
148 + */
149 + public byte[] getValue() {
150 + return rawValue;
151 + }
152 +
153 + @Override
154 + public PcepVersion getVersion() {
155 + return PcepVersion.PCEP_1;
156 + }
157 +
158 + @Override
159 + public short getType() {
160 + return TYPE;
161 + }
162 +
163 + @Override
164 + public short getLength() {
165 + return LENGTH;
166 + }
167 +
168 + @Override
169 + public int hashCode() {
170 + return Objects.hash(rawValue);
171 + }
172 +
173 + @Override
174 + public boolean equals(Object obj) {
175 + if (this == obj) {
176 + return true;
177 + }
178 + if (obj instanceof IPv6SubObject) {
179 + IPv6SubObject other = (IPv6SubObject) obj;
180 + return Objects.equals(rawValue, other.rawValue);
181 + }
182 + return false;
183 + }
184 +
185 + @Override
186 + public int write(ChannelBuffer c) {
187 + int iStartIndex = c.writerIndex();
188 + c.writeShort(TYPE);
189 + c.writeShort(LENGTH);
190 + c.writeBytes(rawValue);
191 + return c.writerIndex() - iStartIndex;
192 + }
193 +
194 + /**
195 + * Reads the channel buffer and returns object of IPv6SubObject.
196 + *
197 + * @param c type of channel buffer
198 + * @return object of IPv6SubObject
199 + */
200 + public static IPv6SubObject read20Bytes(ChannelBuffer c) {
201 + byte[] yTemp = new byte[20];
202 + c.readBytes(yTemp, 0, 20);
203 + return IPv6SubObject.of(yTemp);
204 + }
205 +
206 + @Override
207 + public void print() {
208 + log.debug("IPv6SubObject");
209 + log.debug("Type: ", TYPE);
210 + log.debug("Length: ", LENGTH);
211 + if (null != rawValue) {
212 + StringBuffer result = new StringBuffer();
213 + for (byte b : rawValue) {
214 + result.append(String.format("%02X ", b));
215 + }
216 + log.debug(result.toString());
217 + }
218 + }
219 +
220 + @Override
221 + public String toString() {
222 + return MoreObjects.toStringHelper(getClass())
223 + .add("Type", TYPE)
224 + .add("Length", LENGTH)
225 + .add("IPv6 Address", rawValue)
226 + .toString();
227 + }
228 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +/**
29 + * Path Key SubObject: When a PCC needs to expand a path-key in order to expand a CPS, it
30 + * issues a Path Computation Request (PCReq) to the PCE identified in
31 + * the PKS in the RSVP-TE ERO that it is processing. The PCC supplies
32 + * the PKS to be expanded in a PATH-KEY SubObject in the PCReq message.
33 + */
34 +public class PathKeySubObject implements PcepValueType {
35 +
36 + /*
37 + Pathkey subobject(RFC 5520):
38 + 0 1 2 3
39 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 + |L| Type | Length | Path-Key |
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | PCE ID (4 bytes) |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + */
46 +
47 + protected static final Logger log = LoggerFactory.getLogger(PathKeySubObject.class);
48 +
49 + public static final byte TYPE = 0x40;
50 + public static final byte LENGTH = 8;
51 + private final short pathKey;
52 + private final int pceID;
53 +
54 + /**
55 + * Constructor for Path Key sub Object which initializes pathKey and pceId.
56 + *
57 + * @param pathKey path key provided by PCC
58 + * @param pceID ID for the PCE
59 + */
60 + public PathKeySubObject(short pathKey, int pceID) {
61 + this.pathKey = pathKey;
62 + this.pceID = pceID;
63 + }
64 +
65 + /**
66 + * Creates Path Key sub Object which initializes pathKey and pceId.
67 + *
68 + * @param pathKey path key provided by PCC
69 + * @param pceID PCE id
70 + * @return new object of type path key sub object
71 + */
72 + public static PathKeySubObject of(short pathKey, int pceID) {
73 + return new PathKeySubObject(pathKey, pceID);
74 + }
75 +
76 + /**
77 + * Returns Path Key.
78 + *
79 + * @return pathKey
80 + */
81 + public short getPathKey() {
82 + return pathKey;
83 + }
84 +
85 + /**
86 + * Returns pceID.
87 + *
88 + * @return pceID
89 + */
90 + public int getPceId() {
91 + return pceID;
92 + }
93 +
94 + @Override
95 + public PcepVersion getVersion() {
96 + return PcepVersion.PCEP_1;
97 + }
98 +
99 + @Override
100 + public short getType() {
101 + return TYPE;
102 + }
103 +
104 + @Override
105 + public short getLength() {
106 + return LENGTH;
107 + }
108 +
109 + @Override
110 + public int hashCode() {
111 + return Objects.hash(pathKey, pceID);
112 + }
113 +
114 + @Override
115 + public boolean equals(Object obj) {
116 + if (this == obj) {
117 + return true;
118 + }
119 + if (obj instanceof PathKeySubObject) {
120 + PathKeySubObject other = (PathKeySubObject) obj;
121 + return Objects.equals(this.pathKey, other.pathKey) && Objects.equals(this.pceID, other.pceID);
122 + }
123 + return false;
124 + }
125 +
126 + @Override
127 + public int write(ChannelBuffer c) {
128 + int iLenStartIndex = c.writerIndex();
129 + c.writeShort(TYPE);
130 + c.writeShort(LENGTH);
131 +
132 + c.writeShort(pathKey);
133 + c.writeInt(pceID);
134 +
135 + return c.writerIndex() - iLenStartIndex;
136 + }
137 +
138 + /**
139 + * Reads the channel buffer and returns new path key sub objects.
140 + *
141 + * @param c of type channel buffer
142 + * @return object of type path key sub object
143 + */
144 + public static PcepValueType read(ChannelBuffer c) {
145 + Short pathKey = c.readShort();
146 + int pceID = c.readInt();
147 + return new PathKeySubObject(pathKey, pceID);
148 + }
149 +
150 + @Override
151 + public void print() {
152 + log.debug("PathKeySubObject");
153 + log.debug("Type: " + TYPE);
154 + log.debug("Length: " + LENGTH);
155 + log.debug("Path Key: " + pathKey);
156 + log.debug("PCEID: " + pceID);
157 + }
158 +
159 + @Override
160 + public String toString() {
161 + return MoreObjects.toStringHelper(getClass())
162 + .add("Type", TYPE).add("Length", LENGTH)
163 + .add("Path Key", pathKey)
164 + .add("PCE ID", pceID)
165 + .toString();
166 + }
167 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +/*
20 + * Provide the PCEP Error Info Details.
21 + */
22 +public final class PcepErrorDetailInfo {
23 +
24 + private PcepErrorDetailInfo() {
25 + }
26 +
27 + // Error Types
28 + /**
29 + Error- Meaning Reference:RFC 5440
30 + Type
31 + 1 PCEP session establishment failure
32 + Error-value=1: reception of an invalid Open message or a non Open message.
33 + Error-value=2: no Open message received before the expiration of the OpenWait timer
34 + Error-value=3: unacceptable and non-negotiable session characteristics
35 + Error-value=4: unacceptable but negotiable session characteristics
36 + Error-value=5: reception of a second Open message with still unacceptable session characteristics
37 + Error-value=6: reception of a PCErr message proposing unacceptable session characteristics
38 + Error-value=7: No Keepalive or PCErr message received before the expiration of the KeepWait timer
39 + Error-value=8: PCEP version not supported
40 + 2 Capability not supported
41 + 3 Unknown Object
42 + Error-value=1: Unrecognized object class
43 + Error-value=2: Unrecognized object Type
44 + 4 Not supported object
45 + Error-value=1: Not supported object class
46 + Error-value=2: Not supported object Type
47 + 5 Policy violation
48 + Error-value=1: C bit of the METRIC object set (request rejected)
49 + Error-value=2: O bit of the RP object cleared (request rejected)
50 + 6 Mandatory Object missing
51 + Error-value=1: RP object missing
52 + Error-value=2: RRO missing for a re-optimization request (R bit of the RP object set)
53 + Error-value=3: END-POINTS object missing
54 + 7 Synchronized path computation request missing
55 + 8 Unknown request reference
56 + 9 Attempt to establish a second PCEP session
57 + 10 Reception of an invalid object
58 + Error-value=1: reception of an object with P flag not set although the P flag must be
59 + set according to this specification.
60 + */
61 + public static final byte ERROR_TYPE_1 = 1;
62 + public static final byte ERROR_TYPE_2 = 2;
63 + public static final byte ERROR_TYPE_3 = 3;
64 + public static final byte ERROR_TYPE_4 = 4;
65 + public static final byte ERROR_TYPE_5 = 5;
66 + public static final byte ERROR_TYPE_6 = 6;
67 + public static final byte ERROR_TYPE_7 = 7;
68 + public static final byte ERROR_TYPE_8 = 8;
69 + public static final byte ERROR_TYPE_9 = 9;
70 + public static final byte ERROR_TYPE_10 = 10;
71 +
72 + // Error Values
73 + public static final byte ERROR_VALUE_1 = 1;
74 + public static final byte ERROR_VALUE_2 = 2;
75 + public static final byte ERROR_VALUE_3 = 3;
76 + public static final byte ERROR_VALUE_4 = 4;
77 + public static final byte ERROR_VALUE_5 = 5;
78 + public static final byte ERROR_VALUE_6 = 6;
79 + public static final byte ERROR_VALUE_7 = 7;
80 + public static final byte ERROR_VALUE_8 = 8;
81 + public static final byte ERROR_VALUE_9 = 9;
82 + public static final byte ERROR_VALUE_10 = 10;
83 +}
...@@ -9,7 +9,9 @@ import org.onosproject.pcepio.protocol.PcepSrpObject; ...@@ -9,7 +9,9 @@ import org.onosproject.pcepio.protocol.PcepSrpObject;
9 import org.slf4j.Logger; 9 import org.slf4j.Logger;
10 import org.slf4j.LoggerFactory; 10 import org.slf4j.LoggerFactory;
11 11
12 -/* 12 +import com.google.common.base.MoreObjects;
13 +
14 +/**
13 * Provides Pcep Label. 15 * Provides Pcep Label.
14 * REference :draft-zhao-pce-pcep-extension-for-pce-controller-01. 16 * REference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
15 */ 17 */
...@@ -18,13 +20,13 @@ public class PcepLabelDownload { ...@@ -18,13 +20,13 @@ public class PcepLabelDownload {
18 protected static final Logger log = LoggerFactory.getLogger(PcepLabelDownload.class); 20 protected static final Logger log = LoggerFactory.getLogger(PcepLabelDownload.class);
19 21
20 //PCEP SPR Object 22 //PCEP SPR Object
21 - PcepSrpObject srpObject; 23 + private PcepSrpObject srpObject;
22 //PCEP LSP Object 24 //PCEP LSP Object
23 - PcepLspObject lspObject; 25 + private PcepLspObject lspObject;
24 //LinkList of Labels 26 //LinkList of Labels
25 - LinkedList<PcepLabelObject> llLabelList; 27 + private LinkedList<PcepLabelObject> llLabelList;
26 28
27 - /* 29 + /**
28 * Returns SRP Object. 30 * Returns SRP Object.
29 * 31 *
30 * @return PCEP SRP Object 32 * @return PCEP SRP Object
...@@ -33,7 +35,7 @@ public class PcepLabelDownload { ...@@ -33,7 +35,7 @@ public class PcepLabelDownload {
33 return srpObject; 35 return srpObject;
34 } 36 }
35 37
36 - /* 38 + /**
37 * Sets the Pcep Srp Object. 39 * Sets the Pcep Srp Object.
38 * 40 *
39 * @param srpobj PCEP SRP Object 41 * @param srpobj PCEP SRP Object
...@@ -42,7 +44,7 @@ public class PcepLabelDownload { ...@@ -42,7 +44,7 @@ public class PcepLabelDownload {
42 this.srpObject = srpobj; 44 this.srpObject = srpobj;
43 } 45 }
44 46
45 - /* 47 + /**
46 * Returns LSP Object. 48 * Returns LSP Object.
47 * 49 *
48 * @return PCEP LSP Object 50 * @return PCEP LSP Object
...@@ -51,7 +53,7 @@ public class PcepLabelDownload { ...@@ -51,7 +53,7 @@ public class PcepLabelDownload {
51 return lspObject; 53 return lspObject;
52 } 54 }
53 55
54 - /* 56 + /**
55 * Sets the Pcep LSP Object. 57 * Sets the Pcep LSP Object.
56 * 58 *
57 * @param lspObject PCEP LSP Object 59 * @param lspObject PCEP LSP Object
...@@ -60,7 +62,7 @@ public class PcepLabelDownload { ...@@ -60,7 +62,7 @@ public class PcepLabelDownload {
60 this.lspObject = lspObject; 62 this.lspObject = lspObject;
61 } 63 }
62 64
63 - /* 65 + /**
64 * Returns a list of labels. 66 * Returns a list of labels.
65 * 67 *
66 * @return llLabelList list of pcep label objects 68 * @return llLabelList list of pcep label objects
...@@ -69,7 +71,7 @@ public class PcepLabelDownload { ...@@ -69,7 +71,7 @@ public class PcepLabelDownload {
69 return llLabelList; 71 return llLabelList;
70 } 72 }
71 73
72 - /* 74 + /**
73 * set the llLabelList list of type PcepLableObject. 75 * set the llLabelList list of type PcepLableObject.
74 * 76 *
75 * @param llLabelList list of pcep label objects 77 * @param llLabelList list of pcep label objects
...@@ -78,7 +80,7 @@ public class PcepLabelDownload { ...@@ -78,7 +80,7 @@ public class PcepLabelDownload {
78 this.llLabelList = llLabelList; 80 this.llLabelList = llLabelList;
79 } 81 }
80 82
81 - /* 83 + /**
82 * Prints the attribute of PcepLableObject. 84 * Prints the attribute of PcepLableObject.
83 */ 85 */
84 public void print() { 86 public void print() {
...@@ -92,4 +94,13 @@ public class PcepLabelDownload { ...@@ -92,4 +94,13 @@ public class PcepLabelDownload {
92 listIterator.next().print(); 94 listIterator.next().print();
93 } 95 }
94 } 96 }
97 +
98 + @Override
99 + public String toString() {
100 + return MoreObjects.toStringHelper(getClass())
101 + .add("SRP object", srpObject)
102 + .add("LSP object", lspObject)
103 + .add("label object list", llLabelList)
104 + .toString();
105 + }
95 } 106 }
......
...@@ -22,6 +22,8 @@ import org.onosproject.pcepio.protocol.PcepSrpObject; ...@@ -22,6 +22,8 @@ import org.onosproject.pcepio.protocol.PcepSrpObject;
22 import org.slf4j.Logger; 22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory; 23 import org.slf4j.LoggerFactory;
24 24
25 +import com.google.common.base.MoreObjects;
26 +
25 /** 27 /**
26 * Provide PCEP Label Map. 28 * Provide PCEP Label Map.
27 * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01. 29 * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
...@@ -30,11 +32,11 @@ public class PcepLabelMap { ...@@ -30,11 +32,11 @@ public class PcepLabelMap {
30 32
31 protected static final Logger log = LoggerFactory.getLogger(PcepLabelMap.class); 33 protected static final Logger log = LoggerFactory.getLogger(PcepLabelMap.class);
32 //PCEP SRP Object 34 //PCEP SRP Object
33 - PcepSrpObject srpObject; 35 + private PcepSrpObject srpObject;
34 //PCEP Label Object 36 //PCEP Label Object
35 - PcepLabelObject labelObject; 37 + private PcepLabelObject labelObject;
36 //PCEP FEC Object 38 //PCEP FEC Object
37 - PcepFecObject fecObject; 39 + private PcepFecObject fecObject;
38 40
39 /** 41 /**
40 * Sets Fec Object. 42 * Sets Fec Object.
...@@ -99,4 +101,13 @@ public class PcepLabelMap { ...@@ -99,4 +101,13 @@ public class PcepLabelMap {
99 labelObject.print(); 101 labelObject.print();
100 fecObject.print(); 102 fecObject.print();
101 } 103 }
104 +
105 + @Override
106 + public String toString() {
107 + return MoreObjects.toStringHelper(getClass())
108 + .add("SRP object", srpObject)
109 + .add("Label object", labelObject)
110 + .add("Fec object", fecObject)
111 + .toString();
112 + }
102 } 113 }
......
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepNai;
23 +
24 +import com.google.common.base.MoreObjects;
25 +
26 +public class PcepNaiIpv4Adjacency implements PcepNai {
27 +
28 + public static final byte ST_TYPE = 0x03;
29 + private final int localIpv4Addr;
30 + private final int remoteIpv4Addr;
31 +
32 + /**
33 + * Constructor to initialize variables.
34 + *
35 + * @param localIpv4 local ipv4 address
36 + * @param remoteIpv4 remote ipv4 address
37 + */
38 + public PcepNaiIpv4Adjacency(int localIpv4, int remoteIpv4) {
39 + this.localIpv4Addr = localIpv4;
40 + this.remoteIpv4Addr = remoteIpv4;
41 + }
42 +
43 + @Override
44 + public byte getType() {
45 + return ST_TYPE;
46 + }
47 +
48 + @Override
49 + public int write(ChannelBuffer bb) {
50 + int iLenStartIndex = bb.writerIndex();
51 + bb.writeInt(localIpv4Addr);
52 + bb.writeInt(remoteIpv4Addr);
53 + return bb.writerIndex() - iLenStartIndex;
54 + }
55 +
56 + /**
57 + * Reads the channel buffer and returns object of PcepNAIIpv4AdjacencyVer1.
58 + *
59 + * @param cb of channel buffer
60 + * @return object of PcepNAIIpv4Adjacency
61 + */
62 + public static PcepNaiIpv4Adjacency read(ChannelBuffer cb) {
63 + int localIpv4 = cb.readInt();
64 + int remoteIpv4 = cb.readInt();
65 + return new PcepNaiIpv4Adjacency(localIpv4, remoteIpv4);
66 + }
67 +
68 + @Override
69 + public int hashCode() {
70 + return Objects.hash(localIpv4Addr, remoteIpv4Addr);
71 + }
72 +
73 + @Override
74 + public boolean equals(Object obj) {
75 + if (this == obj) {
76 + return true;
77 + }
78 + if (obj instanceof PcepNaiIpv4Adjacency) {
79 + PcepNaiIpv4Adjacency other = (PcepNaiIpv4Adjacency) obj;
80 + return Objects.equals(this.localIpv4Addr, other.localIpv4Addr)
81 + && Objects.equals(this.remoteIpv4Addr, other.remoteIpv4Addr);
82 + }
83 + return false;
84 + }
85 +
86 + @Override
87 + public String toString() {
88 + return MoreObjects.toStringHelper(getClass())
89 + .add("local IPv4 Address", localIpv4Addr)
90 + .add("remote IPv4 Address", remoteIpv4Addr)
91 + .toString();
92 + }
93 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepNai;
23 +
24 +import com.google.common.base.MoreObjects;
25 +
26 +public class PcepNaiIpv4NodeId implements PcepNai {
27 +
28 + public static final byte ST_TYPE = 0x01;
29 +
30 + private final int ipv4NodeId;
31 +
32 + /**
33 + * Constructor to initialize ipv4NodeId.
34 + *
35 + * @param value ipv4 node id
36 + */
37 + public PcepNaiIpv4NodeId(int value) {
38 + this.ipv4NodeId = value;
39 + }
40 +
41 + /**
42 + * Returns an object of PcepNaiIpv4NodeId.
43 + *
44 + * @param value ipv4 node id
45 + * @return object of PcepNaiIpv4NodeId
46 + */
47 + public static PcepNaiIpv4NodeId of(int value) {
48 + return new PcepNaiIpv4NodeId(value);
49 + }
50 +
51 + @Override
52 + public byte getType() {
53 + return ST_TYPE;
54 + }
55 +
56 + @Override
57 + public int write(ChannelBuffer bb) {
58 + int iLenStartIndex = bb.writerIndex();
59 + bb.writeInt(ipv4NodeId);
60 + return bb.writerIndex() - iLenStartIndex;
61 + }
62 +
63 + /**
64 + * Reads from the channel buffer and returns object of PcepNAIIpv4NodeIdVer1.
65 + *
66 + * @param bb of channel buffer.
67 + * @return object of PcepNAIIpv4NodeIdVer1
68 + */
69 + public static PcepNaiIpv4NodeId read(ChannelBuffer bb) {
70 + return new PcepNaiIpv4NodeId(bb.readInt());
71 + }
72 +
73 + @Override
74 + public int hashCode() {
75 + return Objects.hash(ipv4NodeId);
76 + }
77 +
78 + @Override
79 + public boolean equals(Object obj) {
80 + if (this == obj) {
81 + return true;
82 + }
83 + if (obj instanceof PcepNaiIpv4NodeId) {
84 + PcepNaiIpv4NodeId other = (PcepNaiIpv4NodeId) obj;
85 + return Objects.equals(this.ipv4NodeId, other.ipv4NodeId);
86 + }
87 + return false;
88 + }
89 +
90 + @Override
91 + public String toString() {
92 + return MoreObjects.toStringHelper(getClass())
93 + .add("IPv4 Node Id", ipv4NodeId)
94 + .toString();
95 + }
96 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepNai;
23 +
24 +import com.google.common.base.MoreObjects;
25 +
26 +public class PcepNaiIpv6Adjacency implements PcepNai {
27 +
28 + public static final byte ST_TYPE = 0x04;
29 + public static final byte IPV6_LEN = 0x10;
30 +
31 + private final byte[] localIpv6Addr;
32 + private final byte[] remoteIpv6Addr;
33 +
34 + /**
35 + * Constructor to initialize local ipv6 and remote ipv6.
36 + *
37 + * @param localIpv6 local ipv6 address
38 + * @param remoteIpv6 remote ipv6 address
39 + */
40 + public PcepNaiIpv6Adjacency(byte[] localIpv6, byte[] remoteIpv6) {
41 + this.localIpv6Addr = localIpv6;
42 + this.remoteIpv6Addr = remoteIpv6;
43 + }
44 +
45 + @Override
46 + public byte getType() {
47 + return ST_TYPE;
48 + }
49 +
50 + @Override
51 + public int write(ChannelBuffer bb) {
52 + int iLenStartIndex = bb.writerIndex();
53 + bb.writeBytes(localIpv6Addr);
54 + bb.writeBytes(remoteIpv6Addr);
55 + return bb.writerIndex() - iLenStartIndex;
56 + }
57 +
58 + /**
59 + * Reads from channel buffer and returns object of PcepNAIIpv6AdjacencyVer1.
60 + *
61 + * @param bb of type channel buffer
62 + * @return object of PcepNAIIpv6AdjacencyVer1
63 + */
64 + public static PcepNaiIpv6Adjacency read(ChannelBuffer bb) {
65 + byte[] localIpv6 = new byte[IPV6_LEN];
66 + bb.readBytes(localIpv6, 0, IPV6_LEN);
67 + byte[] remoteIpv6 = new byte[IPV6_LEN];
68 + bb.readBytes(remoteIpv6, 0, IPV6_LEN);
69 + return new PcepNaiIpv6Adjacency(localIpv6, remoteIpv6);
70 + }
71 +
72 + @Override
73 + public int hashCode() {
74 + return Objects.hash(localIpv6Addr, remoteIpv6Addr);
75 + }
76 +
77 + @Override
78 + public boolean equals(Object obj) {
79 + if (this == obj) {
80 + return true;
81 + }
82 + if (obj instanceof PcepNaiIpv6Adjacency) {
83 + PcepNaiIpv6Adjacency other = (PcepNaiIpv6Adjacency) obj;
84 + return Objects.equals(this.localIpv6Addr, other.localIpv6Addr)
85 + && Objects.equals(this.remoteIpv6Addr, other.remoteIpv6Addr);
86 + }
87 + return false;
88 + }
89 +
90 + /**
91 + * Creates object of PcepNaiIpv6Adjacency with local ipv6 address and remote ipv6 address.
92 + *
93 + * @param localIpv6Addr local ipv6 address
94 + * @param remoteIpv6Addr remote ipv6 address
95 + * @return object of PcepNaiIpv6Adjacency
96 + */
97 +
98 + public static PcepNaiIpv6Adjacency of(final byte[] localIpv6Addr, final byte[] remoteIpv6Addr) {
99 + return new PcepNaiIpv6Adjacency(localIpv6Addr, remoteIpv6Addr);
100 + }
101 +
102 + @Override
103 + public String toString() {
104 + return MoreObjects.toStringHelper(getClass())
105 + .add("local IPV6 address", localIpv6Addr)
106 + .add("remote IPV6 address", remoteIpv6Addr)
107 + .toString();
108 + }
109 +
110 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepNai;
23 +
24 +import com.google.common.base.MoreObjects;
25 +
26 +public class PcepNaiIpv6NodeId implements PcepNai {
27 +
28 + public static final byte ST_TYPE = 0x02;
29 + public static final byte IPV6_LEN = 0x10;
30 +
31 + private final byte[] ipv6NodeId;
32 +
33 + /**
34 + * Constructor to initialize ipv6NodeId.
35 + *
36 + * @param value ipv6 node id
37 + */
38 + public PcepNaiIpv6NodeId(byte[] value) {
39 + this.ipv6NodeId = value;
40 + }
41 +
42 + @Override
43 + public byte getType() {
44 + return ST_TYPE;
45 + }
46 +
47 + @Override
48 + public int write(ChannelBuffer cb) {
49 + int iLenStartIndex = cb.writerIndex();
50 + cb.writeBytes(ipv6NodeId);
51 + return cb.writerIndex() - iLenStartIndex;
52 + }
53 +
54 + /**
55 + * Reads from the channel buffer and returns object of PcepNAIIpv6NodeId.
56 + *
57 + * @param cb of type channel buffer.
58 + * @return object of PcepNAIIpv6NodeId
59 + */
60 + public static PcepNaiIpv6NodeId read(ChannelBuffer cb) {
61 + byte[] ipv6NodeId = new byte[IPV6_LEN];
62 + cb.readBytes(ipv6NodeId, 0, IPV6_LEN);
63 + return new PcepNaiIpv6NodeId(ipv6NodeId);
64 + }
65 +
66 + @Override
67 + public int hashCode() {
68 + return Objects.hash(ipv6NodeId);
69 + }
70 +
71 + @Override
72 + public boolean equals(Object obj) {
73 + if (this == obj) {
74 + return true;
75 + }
76 + if (obj instanceof PcepNaiIpv6NodeId) {
77 + PcepNaiIpv6NodeId other = (PcepNaiIpv6NodeId) obj;
78 + return Objects.equals(this.ipv6NodeId, other.ipv6NodeId);
79 + }
80 + return false;
81 + }
82 +
83 + @Override
84 + public String toString() {
85 + return MoreObjects.toStringHelper(getClass())
86 + .add("IPV6 node ID", ipv6NodeId)
87 + .toString();
88 + }
89 +}
1 +package org.onosproject.pcepio.types;
2 +
3 +import java.util.Objects;
4 +
5 +import org.jboss.netty.buffer.ChannelBuffer;
6 +import org.onosproject.pcepio.protocol.PcepNai;
7 +
8 +import com.google.common.base.MoreObjects;
9 +
10 +public class PcepNaiUnnumberedAdjacencyIpv4 implements PcepNai {
11 + /**
12 + * draft-ietf-pce-segment-routing-03 section 5.3.2.
13 + */
14 + public static final byte ST_TYPE = 0x05;
15 +
16 + private final int localNodeId;
17 + private final int localInterfaceId;
18 + private final int remoteNodeId;
19 + private final int remoteInterfaceId;
20 +
21 + /**
22 + * Constructor to initialize all the member variables.
23 + *
24 + * @param localNodeId local node id
25 + * @param localInterfaceId local interface id
26 + * @param remoteNodeId remote node id
27 + * @param remoteInterfaceId remote interface id
28 + */
29 + public PcepNaiUnnumberedAdjacencyIpv4(int localNodeId, int localInterfaceId, int remoteNodeId,
30 + int remoteInterfaceId) {
31 + this.localNodeId = localNodeId;
32 + this.localInterfaceId = localInterfaceId;
33 + this.remoteNodeId = remoteNodeId;
34 + this.remoteInterfaceId = remoteInterfaceId;
35 + }
36 +
37 + /**
38 + * Returns PCEP Nai Unnumbered Adjacency Ipv4 object.
39 + *
40 + * @param localNodeId local node id
41 + * @param localInterfaceId local interface if
42 + * @param remoteNodeId remote node id
43 + * @param remoteInterfaceId remote interface id
44 + * @return PCEP Nai Unnumbered Adjacency Ipv4 object
45 + */
46 + public static PcepNaiUnnumberedAdjacencyIpv4 of(int localNodeId, int localInterfaceId, int remoteNodeId,
47 + int remoteInterfaceId) {
48 + return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
49 + }
50 +
51 + @Override
52 + public byte getType() {
53 + return ST_TYPE;
54 + }
55 +
56 + @Override
57 + public int write(ChannelBuffer bb) {
58 + int iLenStartIndex = bb.writerIndex();
59 + bb.writeInt(localNodeId);
60 + bb.writeInt(localInterfaceId);
61 + bb.writeInt(remoteNodeId);
62 + bb.writeInt(remoteInterfaceId);
63 + return bb.writerIndex() - iLenStartIndex;
64 + }
65 +
66 + /**
67 + * Reads from channel buffer and return object of PcepNAIUnnumberedAdjacencyIpv4.
68 + *
69 + * @param bb of type channel buffer
70 + * @return object of PcepNAIUnnumberedAdjacencyIpv4
71 + */
72 + public static PcepNaiUnnumberedAdjacencyIpv4 read(ChannelBuffer bb) {
73 + int localNodeId;
74 + int localInterfaceId;
75 + int remoteNodeId;
76 + int remoteInterfaceId;
77 + localNodeId = bb.readInt();
78 + localInterfaceId = bb.readInt();
79 + remoteNodeId = bb.readInt();
80 + remoteInterfaceId = bb.readInt();
81 + return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
82 + }
83 +
84 + @Override
85 + public int hashCode() {
86 + return Objects.hash(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
87 + }
88 +
89 + @Override
90 + public boolean equals(Object obj) {
91 + if (this == obj) {
92 + return true;
93 + }
94 + if (obj instanceof PcepNaiUnnumberedAdjacencyIpv4) {
95 + PcepNaiUnnumberedAdjacencyIpv4 other = (PcepNaiUnnumberedAdjacencyIpv4) obj;
96 + return Objects.equals(this.localNodeId, other.localNodeId)
97 + && Objects.equals(this.localInterfaceId, other.localInterfaceId)
98 + && Objects.equals(this.remoteNodeId, other.remoteNodeId)
99 + && Objects.equals(this.remoteInterfaceId, other.remoteInterfaceId);
100 + }
101 + return false;
102 + }
103 +
104 + @Override
105 + public String toString() {
106 + return MoreObjects.toStringHelper(getClass())
107 + .add("local Node Id", localNodeId)
108 + .add("local Interface Id", localInterfaceId)
109 + .add("remote Node Id", remoteNodeId)
110 + .add("remote Interface Id:", remoteInterfaceId)
111 + .toString();
112 + }
113 +}
...@@ -20,6 +20,8 @@ import org.jboss.netty.buffer.ChannelBuffer; ...@@ -20,6 +20,8 @@ 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 22
23 +import com.google.common.base.MoreObjects;
24 +
23 /** 25 /**
24 * Provides PCEP Object Header which is common for all the objects. 26 * Provides PCEP Object Header which is common for all the objects.
25 * Reference : RFC 5440. 27 * Reference : RFC 5440.
...@@ -66,7 +68,6 @@ public class PcepObjectHeader { ...@@ -66,7 +68,6 @@ public class PcepObjectHeader {
66 * @param bIFlag I flag 68 * @param bIFlag I flag
67 * @param objLen PCEP object length 69 * @param objLen PCEP object length
68 */ 70 */
69 -
70 public PcepObjectHeader(byte objClass, byte objType, boolean bPFlag, boolean bIFlag, short objLen) { 71 public PcepObjectHeader(byte objClass, byte objType, boolean bPFlag, boolean bIFlag, short objLen) {
71 this.objClass = objClass; 72 this.objClass = objClass;
72 this.objType = objType; 73 this.objType = objType;
...@@ -221,4 +222,15 @@ public class PcepObjectHeader { ...@@ -221,4 +222,15 @@ public class PcepObjectHeader {
221 log.debug("P flag: " + bPFlag); 222 log.debug("P flag: " + bPFlag);
222 log.debug("I flag: " + bIFlag); 223 log.debug("I flag: " + bIFlag);
223 } 224 }
225 +
226 + @Override
227 + public String toString() {
228 + return MoreObjects.toStringHelper(getClass())
229 + .add("Object class:", objClass)
230 + .add("Object type:", objType)
231 + .add("Object length:", objLen)
232 + .add("P flag:", bPFlag)
233 + .add("I flag:", bIFlag)
234 + .toString();
235 + }
224 } 236 }
......
1 +/*
2 + * Copyright 2015 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.pcepio.types;
17 +
18 +import org.jboss.netty.buffer.ChannelBuffer;
19 +
20 +public interface PcepRsvpErrorSpec extends PcepValueType {
21 +
22 + /**
23 + * To write the object information to channelBuffer.
24 + *
25 + * @param cb of type channel buffer
26 + */
27 + @Override
28 + int write(ChannelBuffer cb);
29 +
30 + /**
31 + * Returns class number.
32 + *
33 + * @return class number
34 + */
35 + byte getClassNum();
36 +
37 + /**
38 + * Returns class type.
39 + *
40 + * @return class type
41 + */
42 + byte getClassType();
43 +
44 + @Override
45 + String toString();
46 +
47 +}
1 +/*
2 + * Copyright 2015 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.pcepio.types;
17 +
18 +import org.jboss.netty.buffer.ChannelBuffer;
19 +import org.onosproject.pcepio.protocol.PcepVersion;
20 +
21 +import com.google.common.base.MoreObjects;
22 +
23 +public class PcepRsvpIpv4ErrorSpec implements PcepRsvpErrorSpec {
24 +
25 + /*
26 + RSVP error spec object header.
27 + 0 1 2 3
28 + +-------------+-------------+-------------+-------------+
29 + | Length (bytes) | Class-Num | C-Type |
30 + +-------------+-------------+-------------+-------------+
31 + | |
32 + // (Object contents) //
33 + | |
34 + +-------------+-------------+-------------+-------------+
35 +
36 + Ref : ERROR_SPEC @ RFC2205
37 +
38 + IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
39 + +-------------+-------------+-------------+-------------+
40 + | IPv4 Error Node Address (4 bytes) |
41 + +-------------+-------------+-------------+-------------+
42 + | Flags | Error Code | Error Value |
43 + +-------------+-------------+-------------+-------------+
44 +
45 + */
46 +
47 + PcepRsvpSpecObjHeader objHeader;
48 + public static final byte CLASS_NUM = 0x06;
49 + public static final byte CLASS_TYPE = 0x01;
50 + public static final byte CLASS_LENGTH = 0x0c;
51 + private int ipv4Addr;
52 + private byte flags;
53 + private byte errCode;
54 + private short errValue;
55 +
56 + /**
57 + * Constructor to initialize obj header, ipv4 addr, flags, err code and err value.
58 + *
59 + * @param objHeader rsvp ipv4 error spec object header
60 + * @param ipv4Addr ipv4 address
61 + * @param flags flags value
62 + * @param errCode error code value
63 + * @param errValue error value
64 + */
65 + public PcepRsvpIpv4ErrorSpec(PcepRsvpSpecObjHeader objHeader, int ipv4Addr, byte flags, byte errCode,
66 + short errValue) {
67 + this.objHeader = objHeader;
68 + this.ipv4Addr = ipv4Addr;
69 + this.flags = flags;
70 + this.errCode = errCode;
71 + this.errValue = errValue;
72 + }
73 +
74 + /**
75 + * Constructor to initialize ipv4 address, flags, err code and err value.
76 + *
77 + * @param ipv4Addr ipv4 address
78 + * @param flags flags value
79 + * @param errCode error code
80 + * @param errValue error value
81 + */
82 + public PcepRsvpIpv4ErrorSpec(int ipv4Addr, byte flags, byte errCode, short errValue) {
83 + this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
84 + this.ipv4Addr = ipv4Addr;
85 + this.flags = flags;
86 + this.errCode = errCode;
87 + this.errValue = errValue;
88 + }
89 +
90 + @Override
91 + public int write(ChannelBuffer cb) {
92 + int objLenIndex = objHeader.write(cb);
93 + cb.writeInt(ipv4Addr);
94 + cb.writeByte(flags);
95 + cb.writeByte(errCode);
96 + cb.writeShort(errValue);
97 + short objLen = (short) (cb.writerIndex() - objLenIndex);
98 + cb.setShort(objLenIndex, objLen);
99 + return objLen;
100 + }
101 +
102 + /**
103 + * Reads PCPE RSVP error spec from channel buffer and returns PCEP rsvp IPv4 error spec object.
104 + *
105 + * @param cb channel buffer
106 + * @return PCEP rsvp IPv4 error spec object
107 + */
108 + public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
109 + PcepRsvpSpecObjHeader objHeader;
110 + int ipv4Addr;
111 + byte flags;
112 + byte errCode;
113 + short errValue;
114 +
115 + objHeader = PcepRsvpSpecObjHeader.read(cb);
116 + ipv4Addr = cb.readInt();
117 + flags = cb.readByte();
118 + errCode = cb.readByte();
119 + errValue = cb.readShort();
120 + return new PcepRsvpIpv4ErrorSpec(objHeader, ipv4Addr, flags, errCode, errValue);
121 + }
122 +
123 + @Override
124 + public PcepVersion getVersion() {
125 + return PcepVersion.PCEP_1;
126 + }
127 +
128 + @Override
129 + public short getType() {
130 + return StatefulRsvpErrorSpecTlv.TYPE;
131 + }
132 +
133 + @Override
134 + public short getLength() {
135 + return CLASS_LENGTH;
136 + }
137 +
138 + @Override
139 + public byte getClassNum() {
140 + return CLASS_NUM;
141 + }
142 +
143 + @Override
144 + public byte getClassType() {
145 + return CLASS_TYPE;
146 + }
147 +
148 + @Override
149 + public void print() {
150 + // TODO Auto-generated method stub
151 + }
152 +
153 + @Override
154 + public String toString() {
155 + return MoreObjects.toStringHelper(getClass())
156 + .add("IPv4 Address:", ipv4Addr)
157 + .add("flags:", flags)
158 + .add("error Code:", errCode)
159 + .add("error Value:", errValue)
160 + .toString();
161 + }
162 +}
1 +package org.onosproject.pcepio.types;
2 +
3 +import org.jboss.netty.buffer.ChannelBuffer;
4 +import org.onosproject.pcepio.protocol.PcepVersion;
5 +
6 +import com.google.common.base.MoreObjects;
7 +
8 +public class PcepRsvpIpv6ErrorSpec implements PcepRsvpErrorSpec {
9 +
10 + /*
11 + 0 1 2 3
12 + +-------------+-------------+-------------+-------------+
13 + | Length (bytes) | Class-Num | C-Type |
14 + +-------------+-------------+-------------+-------------+
15 + | |
16 + // (Object contents) //
17 + | |
18 + +-------------+-------------+-------------+-------------+
19 +
20 + Ref : ERROR_SPEC @ RFC2205
21 +
22 + IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
23 + +-------------+-------------+-------------+-------------+
24 + | |
25 + + +
26 + | |
27 + + IPv6 Error Node Address (16 bytes) +
28 + | |
29 + + +
30 + | |
31 + +-------------+-------------+-------------+-------------+
32 + | Flags | Error Code | Error Value |
33 + +-------------+-------------+-------------+-------------+ */
34 +
35 + PcepRsvpSpecObjHeader objHeader;
36 + public static final byte CLASS_NUM = 0x06;
37 + public static final byte CLASS_TYPE = 0x02;
38 + public static final byte CLASS_LENGTH = 0x18;
39 + public static final byte IPV6_LEN = 0x10;
40 +
41 + private byte[] ipv6Addr;
42 + private byte flags;
43 + private byte errCode;
44 + private short errValue;
45 +
46 + /**
47 + * Constructor to initialize obj header, ipv6 addr, flags, err code and err value.
48 + *
49 + * @param objHeader rsvp ipv6 error spec object header
50 + * @param ipv6Addr ipv6 address
51 + * @param flags flags value
52 + * @param errCode error code
53 + * @param errValue error value
54 + */
55 + public PcepRsvpIpv6ErrorSpec(PcepRsvpSpecObjHeader objHeader, byte[] ipv6Addr, byte flags, byte errCode,
56 + short errValue) {
57 + this.objHeader = objHeader;
58 + this.ipv6Addr = ipv6Addr;
59 + this.flags = flags;
60 + this.errCode = errCode;
61 + this.errValue = errValue;
62 + }
63 +
64 + /**
65 + * Constructor to initialize ipv6 addr, flags, err code and err value.
66 + *
67 + * @param ipv6Addr ipv6 address
68 + * @param flags flags value
69 + * @param errCode error code
70 + * @param errValue error value
71 + */
72 + public PcepRsvpIpv6ErrorSpec(byte[] ipv6Addr, byte flags, byte errCode, short errValue) {
73 + this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
74 + this.ipv6Addr = ipv6Addr;
75 + this.flags = flags;
76 + this.errCode = errCode;
77 + this.errValue = errValue;
78 + }
79 +
80 + @Override
81 + public int write(ChannelBuffer cb) {
82 + int objLenIndex = objHeader.write(cb);
83 + cb.writeBytes(ipv6Addr);
84 + cb.writeByte(flags);
85 + cb.writeByte(errCode);
86 + cb.writeShort(errValue);
87 + short objLen = (short) (cb.writerIndex() - objLenIndex);
88 + cb.setShort(objLenIndex, objLen);
89 + return objLen;
90 + }
91 +
92 + /**
93 + * Returns PCEP rsvp IPv6 error spce object.
94 + *
95 + * @param cb channel buffer
96 + * @return PCEP rsvp IPv6 error spce object
97 + */
98 + public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
99 + PcepRsvpSpecObjHeader objHeader;
100 + byte[] ipv6Addr = new byte[IPV6_LEN];
101 + byte flags;
102 + byte errCode;
103 + short errValue;
104 +
105 + objHeader = PcepRsvpSpecObjHeader.read(cb);
106 + cb.readBytes(ipv6Addr, 0, IPV6_LEN);
107 + flags = cb.readByte();
108 + errCode = cb.readByte();
109 + errValue = cb.readShort();
110 + return new PcepRsvpIpv6ErrorSpec(objHeader, ipv6Addr, flags, errCode, errValue);
111 + }
112 +
113 + @Override
114 + public PcepVersion getVersion() {
115 + return PcepVersion.PCEP_1;
116 + }
117 +
118 + @Override
119 + public short getType() {
120 + return StatefulRsvpErrorSpecTlv.TYPE;
121 + }
122 +
123 + @Override
124 + public short getLength() {
125 + return CLASS_LENGTH;
126 + }
127 +
128 + @Override
129 + public byte getClassNum() {
130 + return CLASS_NUM;
131 + }
132 +
133 + @Override
134 + public byte getClassType() {
135 + return CLASS_TYPE;
136 + }
137 +
138 + @Override
139 + public void print() {
140 + // TODO Auto-generated method stub
141 + }
142 +
143 + @Override
144 + public String toString() {
145 + return MoreObjects.toStringHelper(getClass())
146 + .add("IPv6 Address:", ipv6Addr)
147 + .add("flags:", flags)
148 + .add("error Code:", errCode)
149 + .add("error Value:", errValue)
150 + .toString();
151 + }
152 +}
...@@ -20,6 +20,8 @@ import org.jboss.netty.buffer.ChannelBuffer; ...@@ -20,6 +20,8 @@ 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 22
23 +import com.google.common.base.MoreObjects;
24 +
23 /** 25 /**
24 * Provides PcepRsvpObjectHeader. 26 * Provides PcepRsvpObjectHeader.
25 */ 27 */
...@@ -36,7 +38,7 @@ public class PcepRsvpObjectHeader { ...@@ -36,7 +38,7 @@ public class PcepRsvpObjectHeader {
36 +-------------+-------------+-------------+-------------+ 38 +-------------+-------------+-------------+-------------+
37 39
38 ERROR_SPEC object Header 40 ERROR_SPEC object Header
39 - */ 41 + */
40 42
41 protected static final Logger log = LoggerFactory.getLogger(PcepRsvpObjectHeader.class); 43 protected static final Logger log = LoggerFactory.getLogger(PcepRsvpObjectHeader.class);
42 44
...@@ -158,4 +160,13 @@ public class PcepRsvpObjectHeader { ...@@ -158,4 +160,13 @@ public class PcepRsvpObjectHeader {
158 log.debug("Object C-Type: " + objClassType); 160 log.debug("Object C-Type: " + objClassType);
159 log.debug("Object Length: " + objLen); 161 log.debug("Object Length: " + objLen);
160 } 162 }
163 +
164 + @Override
165 + public String toString() {
166 + return MoreObjects.toStringHelper(getClass())
167 + .add("Object Class-Num: " , objClassNum)
168 + .add("Object C-Type: " , objClassType)
169 + .add("Object Length: " , objLen)
170 + .toString();
171 + }
161 } 172 }
......
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import org.jboss.netty.buffer.ChannelBuffer;
20 +import org.slf4j.Logger;
21 +import org.slf4j.LoggerFactory;
22 +
23 +import com.google.common.base.MoreObjects;
24 +
25 +/**
26 + * Provides PcepRsvpObjectHeader.
27 + */
28 +public class PcepRsvpSpecObjHeader {
29 +
30 + /*
31 + 0 1 2 3
32 + +-------------+-------------+-------------+-------------+
33 + | Length (bytes) | Class-Num | C-Type |
34 + +-------------+-------------+-------------+-------------+
35 + | |
36 + // (Object contents) //
37 + | |
38 + +-------------+-------------+-------------+-------------+
39 +
40 + ERROR_SPEC object Header
41 + */
42 +
43 + protected static final Logger log = LoggerFactory.getLogger(PcepRsvpSpecObjHeader.class);
44 +
45 + private short objLen;
46 + private byte objClassNum;
47 + private byte objClassType;
48 +
49 + /**
50 + * Constructor to initialize length, class num and type.
51 + *
52 + * @param objLen object length
53 + * @param objClassNum pcep rsvp error spec object class num
54 + * @param objClassType pcep rsvp error spec object class type
55 + */
56 + public PcepRsvpSpecObjHeader(short objLen, byte objClassNum, byte objClassType) {
57 + this.objLen = objLen;
58 + this.objClassNum = objClassNum;
59 + this.objClassType = objClassType;
60 + }
61 +
62 + /**
63 + * Sets the Class num.
64 + *
65 + * @param value pcep rsvp error spec object class num
66 + */
67 + public void setObjClassNum(byte value) {
68 + this.objClassNum = value;
69 + }
70 +
71 + /**
72 + * Sets the Class type.
73 + *
74 + * @param value pcep rsvp error spec object class type
75 + */
76 + public void setObjClassType(byte value) {
77 + this.objClassType = value;
78 + }
79 +
80 + /**
81 + * Sets the Class Length.
82 + *
83 + * @param value pcep rsvp error spec object length
84 + */
85 + public void setObjLen(short value) {
86 + this.objLen = value;
87 + }
88 +
89 + /**
90 + * Returns Object Length.
91 + *
92 + * @return objLen pcep rsvp error spec object length
93 + */
94 + public short getObjLen() {
95 + return this.objLen;
96 + }
97 +
98 + /**
99 + * Returns Object num.
100 + *
101 + * @return objClassNum pcep rsvp error spec object class num
102 + */
103 + public byte getObjClassNum() {
104 + return this.objClassNum;
105 + }
106 +
107 + /**
108 + * Returns Object type.
109 + *
110 + * @return objClassType pcep rsvp error spec object class type
111 + */
112 + public byte getObjClassType() {
113 + return this.objClassType;
114 + }
115 +
116 + /**
117 + * Writes the byte stream of PcepRsvpObjectHeader to channel buffer.
118 + *
119 + * @param bb of type channel buffer
120 + * @return object length index
121 + */
122 + public int write(ChannelBuffer bb) {
123 + int objLenIndex = bb.writerIndex();
124 + bb.writeShort(objLen);
125 + bb.writeByte(objClassNum);
126 + bb.writeByte(objClassType);
127 + return bb.writerIndex() - objLenIndex;
128 + }
129 +
130 + /**
131 + * Reads the PcepRsvpObjectHeader.
132 + *
133 + * @param bb of type channel buffer
134 + * @return PcepRsvpObjectHeader
135 + */
136 + public static PcepRsvpSpecObjHeader read(ChannelBuffer bb) {
137 + byte objClassNum;
138 + byte objClassType;
139 + short objLen;
140 + objLen = bb.readShort();
141 + objClassNum = bb.readByte();
142 + objClassType = bb.readByte();
143 +
144 + return new PcepRsvpSpecObjHeader(objLen, objClassNum, objClassType);
145 + }
146 +
147 + /**
148 + * Prints the attribute of PcepRsvpObjectHeader.
149 + */
150 + public void print() {
151 +
152 + log.debug("PcepObjectHeader");
153 + log.debug("Object Class-Num: " + objClassNum);
154 + log.debug("Object C-Type: " + objClassType);
155 + log.debug("Object Length: " + objLen);
156 + }
157 + @Override
158 + public String toString() {
159 + return MoreObjects.toStringHelper(getClass())
160 + .add("Object Class-Num: " , objClassNum)
161 + .add("Object C-Type: " , objClassType)
162 + .add("Object Length: " , objLen)
163 + .toString();
164 + }
165 +}
1 +/*
2 + * Copyright 2015 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.pcepio.types;
17 +
18 +import java.util.LinkedList;
19 +import java.util.ListIterator;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.exceptions.PcepParseException;
23 +import org.onosproject.pcepio.protocol.PcepVersion;
24 +
25 +import com.google.common.base.MoreObjects;
26 +
27 +public class PcepRsvpUserErrorSpec implements PcepRsvpErrorSpec {
28 +
29 + /*
30 + RSVP error spec object header.
31 + 0 1 2 3
32 + +-------------+-------------+-------------+-------------+
33 + | Length (bytes) | Class-Num | C-Type |
34 + +-------------+-------------+-------------+-------------+
35 + | |
36 + // (Object contents) //
37 + | |
38 + +-------------+-------------+-------------+-------------+
39 +
40 + Ref : USER_ERROR_SPEC @ RFC5284.
41 + USER_ERROR_SPEC object: Class = 194, C-Type = 1
42 +
43 + 0 1 2 3
44 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
45 + +---------------+---------------+---------------+---------------+
46 + | Enterprise Number |
47 + +---------------+---------------+---------------+---------------+
48 + | Sub Org | Err Desc Len | User Error Value |
49 + +---------------+---------------+---------------+---------------+
50 + | |
51 + ~ Error Description ~
52 + | |
53 + +---------------+---------------+---------------+---------------+
54 + | |
55 + ~ User-Defined Subobjects ~
56 + | |
57 + +---------------+---------------+---------------+---------------+
58 + */
59 +
60 + public static final byte CLASS_NUM = (byte) 0xc2;
61 + public static final byte CLASS_TYPE = 0x01;
62 +
63 + private PcepRsvpSpecObjHeader objHeader;
64 + private int enterpriseNum;
65 + private byte subOrg;
66 + private byte errDescLen;
67 + private short userErrorValue;
68 + private byte[] errDesc;
69 + private LinkedList<PcepValueType> llRsvpUserSpecSubObj;
70 +
71 + /**
72 + * Default constructor.
73 + *
74 + * @param objHeader pcep rsvp spec object header
75 + * @param enterpriseNum enterprise number
76 + * @param subOrg organization identifier value
77 + * @param errDescLen error description length
78 + * @param userErrorValue user error value
79 + * @param errDesc error description
80 + * @param llRsvpUserSpecSubObj list of subobjects
81 + */
82 + public PcepRsvpUserErrorSpec(PcepRsvpSpecObjHeader objHeader, int enterpriseNum, byte subOrg, byte errDescLen,
83 + short userErrorValue, byte[] errDesc, LinkedList<PcepValueType> llRsvpUserSpecSubObj) {
84 + this.objHeader = objHeader;
85 + this.enterpriseNum = enterpriseNum;
86 + this.subOrg = subOrg;
87 + this.errDescLen = errDescLen;
88 + this.userErrorValue = userErrorValue;
89 + this.errDesc = errDesc;
90 + this.llRsvpUserSpecSubObj = llRsvpUserSpecSubObj;
91 + }
92 +
93 + @Override
94 + public int write(ChannelBuffer cb) {
95 + int objLenIndex = objHeader.write(cb);
96 + cb.writeInt(enterpriseNum);
97 + cb.writeByte(subOrg);
98 + cb.writeByte(errDescLen);
99 + cb.writeShort(userErrorValue);
100 + cb.writeBytes(errDesc);
101 +
102 + if (null != llRsvpUserSpecSubObj) {
103 +
104 + ListIterator<PcepValueType> listIterator = llRsvpUserSpecSubObj.listIterator();
105 +
106 + while (listIterator.hasNext()) {
107 + PcepValueType tlv = listIterator.next();
108 + if (null == tlv) {
109 + continue;
110 + }
111 + tlv.write(cb);
112 + // need to take care of padding
113 + int pad = tlv.getLength() % 4;
114 + if (0 != pad) {
115 + pad = 4 - pad;
116 + for (int i = 0; i < pad; ++i) {
117 + cb.writeByte((byte) 0);
118 + }
119 + }
120 + }
121 + }
122 + short objLen = (short) (cb.writerIndex() - objLenIndex);
123 + cb.setShort(objLenIndex, objLen);
124 + return objLen;
125 + }
126 +
127 + /**
128 + * Reads the channel buffer and returns object of PcepRsvpErrorSpec.
129 + *
130 + * @param cb of type channel buffer
131 + * @return object of PcepRsvpErrorSpec
132 + * @throws PcepParseException when expected object is not received
133 + */
134 + public static PcepRsvpErrorSpec read(ChannelBuffer cb) throws PcepParseException {
135 + PcepRsvpSpecObjHeader objHeader;
136 + int enterpriseNum;
137 + byte subOrg;
138 + byte errDescLen;
139 + short userErrorValue;
140 + byte[] errDesc;
141 + LinkedList<PcepValueType> llRsvpUserSpecSubObj = null;
142 +
143 + objHeader = PcepRsvpSpecObjHeader.read(cb);
144 +
145 + if (CLASS_NUM != objHeader.getObjClassNum() || CLASS_TYPE != objHeader.getObjClassType()) {
146 + throw new PcepParseException("Expected PcepRsvpUserErrorSpec object.");
147 + }
148 + enterpriseNum = cb.readInt();
149 + subOrg = cb.readByte();
150 + errDescLen = cb.readByte();
151 + userErrorValue = cb.readShort();
152 + errDesc = new byte[errDescLen];
153 + cb.readBytes(errDesc, 0, errDescLen);
154 +
155 + llRsvpUserSpecSubObj = parseErrSpecSubObj(cb);
156 +
157 + return new PcepRsvpUserErrorSpec(objHeader, enterpriseNum, subOrg, errDescLen, userErrorValue, errDesc,
158 + llRsvpUserSpecSubObj);
159 + }
160 +
161 + private static LinkedList<PcepValueType> parseErrSpecSubObj(ChannelBuffer cb) throws PcepParseException {
162 + LinkedList<PcepValueType> llRsvpUserSpecSubObj = new LinkedList<PcepValueType>();
163 + while (0 < cb.readableBytes()) {
164 + PcepValueType tlv = null;
165 + short hType = cb.readShort();
166 + int iValue = 0;
167 + //short hLength = cb.readShort();
168 + switch (hType) {
169 + case AutonomousSystemTlv.TYPE:
170 + iValue = cb.readInt();
171 + tlv = new AutonomousSystemTlv(iValue);
172 + break;
173 + default:
174 + throw new PcepParseException("Unsupported Sub TLV type :" + hType);
175 + }
176 + llRsvpUserSpecSubObj.add(tlv);
177 + }
178 + return llRsvpUserSpecSubObj;
179 + }
180 +
181 + @Override
182 + public PcepVersion getVersion() {
183 + return PcepVersion.PCEP_1;
184 + }
185 +
186 + @Override
187 + public short getType() {
188 + return StatefulRsvpErrorSpecTlv.TYPE;
189 + }
190 +
191 + @Override
192 + public short getLength() {
193 + return objHeader.getObjLen();
194 + }
195 +
196 + @Override
197 + public byte getClassNum() {
198 + return CLASS_NUM;
199 + }
200 +
201 + @Override
202 + public byte getClassType() {
203 + return CLASS_TYPE;
204 + }
205 +
206 + @Override
207 + public void print() {
208 + // TODO Auto-generated method stub
209 + }
210 +
211 + @Override
212 + public String toString() {
213 + return MoreObjects.toStringHelper(getClass())
214 + .add("enterprise Number:", enterpriseNum)
215 + .add("sub Organization:", subOrg)
216 + .add("err Desc Length:", errDescLen)
217 + .add("user Error Value:", userErrorValue)
218 + .add("err Desc:", errDesc)
219 + .add("Rsvp User Spec Sub Object:", llRsvpUserSpecSubObj)
220 + .toString();
221 + }
222 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepNai;
23 +import org.onosproject.pcepio.protocol.PcepVersion;
24 +import org.slf4j.Logger;
25 +import org.slf4j.LoggerFactory;
26 +
27 +import com.google.common.base.MoreObjects;
28 +
29 +/*
30 + * Provides SrEroSubObject.
31 + */
32 +public class SrEroSubObject implements PcepValueType {
33 + /*
34 + SR-ERO subobject: (draft-ietf-pce-segment-routing-00)
35 + 0 1 2 3
36 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 + |L| Type | Length | ST | Flags |F|S|C|M|
39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 + | SID |
41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 + // NAI (variable) //
43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 +
45 +
46 +
47 + NAI
48 +
49 + 0 1 2 3
50 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
51 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 + | Local IPv4 address |
53 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 + | Remote IPv4 address |
55 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 +
57 + NAI for IPv4 Adjacency
58 +
59 + 0 1 2 3
60 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
61 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 + // Local IPv6 address (16 bytes) //
63 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 + // Remote IPv6 address (16 bytes) //
65 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 +
67 + NAI for IPv6 adjacency
68 +
69 + 0 1 2 3
70 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
71 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 + | Local Node-ID |
73 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 + | Local Interface ID |
75 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 + | Remote Node-ID |
77 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 + | Remote Interface ID |
79 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 +
81 + NAI for Unnumbered adjacency with IPv4 Node IDs
82 +
83 + */
84 + protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
85 +
86 + public static final short TYPE = 0x60; //TODO : type to be defined
87 + public static final short LENGTH = 12;
88 + public static final short VALUE_LENGTH = 10;
89 + public static final int SET = 1;
90 + public static final byte MFLAG_SET = 0x01;
91 + public static final byte CFLAG_SET = 0x02;
92 + public static final byte SFLAG_SET = 0x04;
93 + public static final byte FFLAG_SET = 0x08;
94 + public static final byte SHIFT_ST = 12;
95 +
96 + private final boolean bFFlag;
97 + private final boolean bSFlag;
98 + private final boolean bCFlag;
99 + private final boolean bMFlag;
100 + private final byte st;
101 +
102 + private final int sID;
103 + private final PcepNai nai;
104 +
105 + /**
106 + * Constructor to initialize member variables.
107 + *
108 + * @param st SID type
109 + * @param bFFlag F flag
110 + * @param bSFlag S flag
111 + * @param bCFlag C flag
112 + * @param bMFlag M flag
113 + * @param sID segment identifier value
114 + * @param nai NAI associated with SID
115 + */
116 + public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
117 + PcepNai nai) {
118 + this.st = st;
119 + this.bFFlag = bFFlag;
120 + this.bSFlag = bSFlag;
121 + this.bCFlag = bCFlag;
122 + this.bMFlag = bMFlag;
123 + this.sID = sID;
124 + this.nai = nai;
125 + }
126 +
127 + /**
128 + * Creates object of SrEroSubObject.
129 + *
130 + * @param st SID type
131 + * @param bFFlag F flag
132 + * @param bSFlag S flag
133 + * @param bCFlag C flag
134 + * @param bMFlag M flag
135 + * @param sID segment identifier value
136 + * @param nai NAI associated with SID
137 + * @return object of SrEroSubObject
138 + */
139 + public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
140 + PcepNai nai) {
141 + return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
142 + }
143 +
144 + /**
145 + * Returns SID type.
146 + * @return st sid type
147 + */
148 + public byte getSt() {
149 + return st;
150 + }
151 +
152 + /**
153 + * Returns bFFlag.
154 + * @return bFFlag
155 + */
156 + public boolean getFFlag() {
157 + return bFFlag;
158 + }
159 +
160 + /**
161 + * Returns bSFlag.
162 + * @return bSFlag
163 + */
164 + public boolean getSFlag() {
165 + return bSFlag;
166 + }
167 +
168 + /**
169 + * Returns bCFlag.
170 + * @return bCFlag
171 + */
172 + public boolean getCFlag() {
173 + return bCFlag;
174 + }
175 +
176 + /**
177 + * Returns bMFlag.
178 + * @return bMFlag
179 + */
180 + public boolean getMFlag() {
181 + return bMFlag;
182 + }
183 +
184 + /**
185 + * Returns sID.
186 + * @return sID
187 + */
188 + public int getSID() {
189 + return sID;
190 + }
191 +
192 + /**
193 + * Returns nai.
194 + * @return nai
195 + */
196 + public PcepNai getNai() {
197 + return nai;
198 + }
199 +
200 + @Override
201 + public PcepVersion getVersion() {
202 + return PcepVersion.PCEP_1;
203 + }
204 +
205 + @Override
206 + public short getType() {
207 + return TYPE;
208 + }
209 +
210 + @Override
211 + public short getLength() {
212 + return LENGTH;
213 + }
214 +
215 + @Override
216 + public int hashCode() {
217 + return Objects.hash(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
218 + }
219 +
220 + @Override
221 + public boolean equals(Object obj) {
222 + if (this == obj) {
223 + return true;
224 + }
225 + if (obj instanceof SrEroSubObject) {
226 + SrEroSubObject other = (SrEroSubObject) obj;
227 + return Objects.equals(this.st, other.st) && Objects.equals(this.bFFlag, other.bFFlag)
228 + && Objects.equals(this.bSFlag, other.bSFlag) && Objects.equals(this.bCFlag, other.bCFlag)
229 + && Objects.equals(this.bMFlag, other.bMFlag) && Objects.equals(this.sID, other.sID)
230 + && Objects.equals(this.nai, other.nai);
231 + }
232 + return false;
233 + }
234 +
235 + @Override
236 + public int write(ChannelBuffer c) {
237 + int iLenStartIndex = c.writerIndex();
238 +
239 + c.writeShort(TYPE);
240 + c.writeShort(LENGTH);
241 +
242 + short temp = 0;
243 + if (bMFlag) {
244 + temp = (short) (temp | MFLAG_SET);
245 + }
246 + if (bCFlag) {
247 + temp = (short) (temp | CFLAG_SET);
248 + }
249 + if (bSFlag) {
250 + temp = (short) (temp | SFLAG_SET);
251 + }
252 + if (bFFlag) {
253 + temp = (short) (temp | FFLAG_SET);
254 + }
255 + short tempST = (short) (st << SHIFT_ST);
256 + temp = (short) (temp | tempST);
257 + c.writeShort(temp);
258 + c.writeInt(sID);
259 + nai.write(c);
260 +
261 + return c.writerIndex() - iLenStartIndex;
262 + }
263 +
264 + /**
265 + * Reads the channel buffer and returns object of SrEroSubObject.
266 + * @param c of type channel buffer
267 + * @return object of SrEroSubObject
268 + */
269 + public static PcepValueType read(ChannelBuffer c) {
270 + short temp = c.readShort();
271 + boolean bMFlag;
272 + boolean bCFlag;
273 + boolean bSFlag;
274 + boolean bFFlag;
275 + byte st;
276 + PcepNai nai = null;
277 +
278 + bMFlag = (temp & MFLAG_SET) == MFLAG_SET ? true : false;
279 + bCFlag = (temp & CFLAG_SET) == CFLAG_SET ? true : false;
280 + bSFlag = (temp & SFLAG_SET) == SFLAG_SET ? true : false;
281 + bFFlag = (temp & FFLAG_SET) == FFLAG_SET ? true : false;
282 +
283 + st = (byte) (temp >> SHIFT_ST);
284 +
285 + int sID = c.readInt();
286 + switch (st) {
287 + case 0x01:
288 + nai = PcepNaiIpv4NodeId.read(c);
289 + break;
290 + case 0x02:
291 + nai = PcepNaiIpv6NodeId.read(c);
292 + break;
293 + case 0x03:
294 + nai = PcepNaiIpv4Adjacency.read(c);
295 + break;
296 + case 0x04:
297 + nai = PcepNaiIpv6Adjacency.read(c);
298 + break;
299 + case 0x05:
300 + nai = PcepNaiUnnumberedAdjacencyIpv4.read(c);
301 + break;
302 + default:
303 + nai = null;
304 + break;
305 + }
306 +
307 + return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
308 + }
309 +
310 + @Override
311 + public void print() {
312 + log.debug("SrEroSubObject");
313 + log.debug("Type: " + TYPE);
314 + log.debug("Length: " + LENGTH);
315 +
316 + log.debug("st:" + st + " bFFlag:" + bFFlag + " bSFlag:" + bSFlag + " bCFlag:" + bCFlag + " bMFlag:" + bMFlag
317 + + " sID:" + sID + " nAI:" + nai);
318 +
319 + }
320 +
321 + @Override
322 + public String toString() {
323 + return MoreObjects.toStringHelper(getClass())
324 + .add("Type", TYPE)
325 + .add("Length", LENGTH)
326 + .add("st", st)
327 + .add("bFflag", bFFlag)
328 + .add("bSFlag", bSFlag)
329 + .add("bCFlag", bCFlag)
330 + .add("bMFlag", bMFlag)
331 + .add("sID", sID)
332 + .add("nAI", nai)
333 + .toString();
334 + }
335 +
336 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +/**
29 + * Provides StatefulIPv4LspIdentidiersTlv.
30 + */
31 +public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
32 +
33 + /* IPV4-LSP-IDENTIFIERS TLV format
34 + *
35 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
36 + *
37 +
38 + 0 1 2 3
39 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 + | Type=18 | Length=16 |
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | IPv4 Tunnel Sender Address |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + | LSP ID | Tunnel ID |
46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 + | Extended Tunnel ID |
48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 + | IPv4 Tunnel Endpoint Address |
50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 +
52 + */
53 + protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class);
54 +
55 + public static final short TYPE = 18;
56 + public static final short LENGTH = 16;
57 + public static final int VALUE_LENGTH = 16;
58 + private final int ipv4IngressAddress;
59 + private final short lspId;
60 + private final short tunnelId;
61 + private final int extendedTunnelId;
62 + private final int ipv4EgressAddress;
63 +
64 + /**
65 + * Constructor to initialize member variables.
66 + *
67 + * @param ipv4IngressAddress ingress ipv4 address
68 + * @param lspId lsp id
69 + * @param tunnelId tunnel id
70 + * @param extendedTunnelId extended tunnel id
71 + * @param ipv4EgressAddress egress ipv4 address
72 + */
73 + public StatefulIPv4LspIdentidiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
74 + int ipv4EgressAddress) {
75 +
76 + this.ipv4IngressAddress = ipv4IngressAddress;
77 + this.lspId = lspId;
78 + this.tunnelId = tunnelId;
79 + this.extendedTunnelId = extendedTunnelId;
80 + this.ipv4EgressAddress = ipv4EgressAddress;
81 + }
82 +
83 + /**
84 + * Creates object of StatefulIPv4LspIdentidiersTlv.
85 + *
86 + * @param ipv4IngressAddress ingress ipv4 address
87 + * @param lspId lsp id
88 + * @param tunnelId tunnel id
89 + * @param extendedTunnelId extended tunnel id
90 + * @param ipv4EgressAddress egress ipv4 address
91 + * @return object of StatefulIPv4LspIdentidiersTlv
92 + */
93 + public static StatefulIPv4LspIdentidiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
94 + int extendedTunnelId, int ipv4EgressAddress) {
95 + return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
96 + ipv4EgressAddress);
97 + }
98 +
99 + /**
100 + * Returns tunnel id.
101 + *
102 + * @return tunnelId
103 + */
104 + public short getTunnelId() {
105 + return this.tunnelId;
106 + }
107 +
108 + /**
109 + * Returns extendedTunnelId.
110 + *
111 + * @return extendedTunnelId
112 + */
113 + public int getextendedTunnelId() {
114 + return this.extendedTunnelId;
115 + }
116 +
117 + @Override
118 + public PcepVersion getVersion() {
119 + return PcepVersion.PCEP_1;
120 + }
121 +
122 + /**
123 + * Returns ipv4IngressAddress.
124 + *
125 + * @return ipv4IngressAddress
126 + */
127 + public int getIpv4IngressAddress() {
128 + return ipv4IngressAddress;
129 + }
130 +
131 + /**
132 + * Returns ipv4EgressAddress.
133 + *
134 + * @return ipv4EgressAddress
135 + */
136 + public int getIpv4EgressAddress() {
137 + return ipv4EgressAddress;
138 + }
139 +
140 + @Override
141 + public short getType() {
142 + return TYPE;
143 + }
144 +
145 + @Override
146 + public short getLength() {
147 + return LENGTH;
148 + }
149 +
150 + @Override
151 + public int hashCode() {
152 + return Objects.hash(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, ipv4EgressAddress);
153 + }
154 +
155 + @Override
156 + public boolean equals(Object obj) {
157 + if (this == obj) {
158 + return true;
159 + }
160 + if (obj instanceof StatefulIPv4LspIdentidiersTlv) {
161 + StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj;
162 + return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
163 + && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
164 + && Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
165 + && Objects.equals(this.ipv4EgressAddress, other.ipv4EgressAddress);
166 + }
167 + return false;
168 + }
169 +
170 + @Override
171 + public int write(ChannelBuffer c) {
172 + int iLenStartIndex = c.writerIndex();
173 + c.writeShort(TYPE);
174 + c.writeShort(LENGTH);
175 + c.writeInt(ipv4IngressAddress);
176 + c.writeShort(lspId);
177 + c.writeShort(tunnelId);
178 + c.writeInt(extendedTunnelId);
179 + c.writeInt(ipv4EgressAddress);
180 +
181 + return c.writerIndex() - iLenStartIndex;
182 + }
183 +
184 + /**
185 + * Reads the channel buffer and returns object of StatefulIPv4LspIdentidiersTlv.
186 + *
187 + * @param c of type channel buffer
188 + * @return object of StatefulIPv4LspIdentidiersTlv
189 + */
190 + public static PcepValueType read(ChannelBuffer c) {
191 + int ipv4IngressAddress = c.readInt();
192 + short lspId = c.readShort();
193 + short tunnelId = c.readShort();
194 + int extendedTunnelId = c.readInt();
195 + int ipv4EgressAddress = c.readInt();
196 + return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
197 + ipv4EgressAddress);
198 + }
199 +
200 + @Override
201 + public void print() {
202 +
203 + log.debug("StatefulIPv4LspIdentidiersTlv");
204 + log.debug("Type: " + TYPE);
205 + log.debug("Length: " + LENGTH);
206 + log.debug("Ipv4IngressAddress: " + ipv4IngressAddress);
207 + log.debug("LspId: " + lspId);
208 + log.debug("TunnelId: " + tunnelId);
209 + log.debug("ExtendedTunnelId: " + extendedTunnelId);
210 + log.debug("Ipv4EgressAddress: " + ipv4EgressAddress);
211 + }
212 +
213 + @Override
214 + public String toString() {
215 + return MoreObjects.toStringHelper(getClass())
216 + .add("Type:", TYPE)
217 + .add("Length:", LENGTH)
218 + .add("Ipv4IngressAddress:", ipv4IngressAddress)
219 + .add("LspId:", lspId)
220 + .add("TunnelId:", tunnelId)
221 + .add("ExtendedTunnelId:", extendedTunnelId)
222 + .add("Ipv4EgressAddress:", ipv4EgressAddress)
223 + .toString();
224 + }
225 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +/**
29 + * Provides StatefulLspErrorCodeTlv.
30 + */
31 +public class StatefulLspErrorCodeTlv implements PcepValueType {
32 +
33 + /* LSP-ERROR-CODE TLV format
34 + *
35 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
36 + *
37 +
38 + 0 1 2 3
39 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 + | Type=20 | Length=4 |
42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 + | LSP Error Code |
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 +
46 + */
47 +
48 + protected static final Logger log = LoggerFactory.getLogger(StatefulLspErrorCodeTlv.class);
49 +
50 + public static final short TYPE = 20;
51 + public static final short LENGTH = 4;
52 + private final int rawValue;
53 +
54 + /**
55 + * Constructor to initialize raw Value.
56 + *
57 + * @param rawValue lsp error code value
58 + */
59 + public StatefulLspErrorCodeTlv(int rawValue) {
60 + this.rawValue = rawValue;
61 + }
62 +
63 + /**
64 + * Creates object of StatefulLspErrorCodeTlv.
65 + *
66 + * @param raw lsp error code value
67 + * @return object of StatefulLspErrorCodeTlv
68 + */
69 + public static StatefulLspErrorCodeTlv of(int raw) {
70 + return new StatefulLspErrorCodeTlv(raw);
71 + }
72 +
73 + @Override
74 + public PcepVersion getVersion() {
75 + return PcepVersion.PCEP_1;
76 + }
77 +
78 + /**
79 + * Returns lsp error code value.
80 + *
81 + * @return lsp error code value
82 + */
83 + public int getInt() {
84 + return rawValue;
85 + }
86 +
87 + @Override
88 + public short getLength() {
89 + return LENGTH;
90 + }
91 +
92 + @Override
93 + public short getType() {
94 + return TYPE;
95 + }
96 +
97 + @Override
98 + public int hashCode() {
99 + return Objects.hash(rawValue);
100 + }
101 +
102 + @Override
103 + public boolean equals(Object obj) {
104 + if (this == obj) {
105 + return true;
106 + }
107 + if (obj instanceof StatefulLspErrorCodeTlv) {
108 + StatefulLspErrorCodeTlv other = (StatefulLspErrorCodeTlv) obj;
109 + return Objects.equals(this.rawValue, other.rawValue);
110 + }
111 + return false;
112 + }
113 +
114 + @Override
115 + public int write(ChannelBuffer c) {
116 + int iLenStartIndex = c.writerIndex();
117 + c.writeShort(TYPE);
118 + c.writeShort(LENGTH);
119 + c.writeInt(rawValue);
120 + return c.writerIndex() - iLenStartIndex;
121 + }
122 +
123 + /**
124 + * Reads the channel buffer and returns object of StatefulLspErrorCodeTlv.
125 + *
126 + * @param c of type channel buffer
127 + * @return object of StatefulLspErrorCodeTlv
128 + */
129 + public static StatefulLspErrorCodeTlv read(ChannelBuffer c) {
130 + return StatefulLspErrorCodeTlv.of(c.readInt());
131 + }
132 +
133 + @Override
134 + public void print() {
135 +
136 + log.debug("StatefulLspErrorCodeTlv");
137 + log.debug("Type: " + TYPE);
138 + log.debug("Length: " + LENGTH);
139 + log.debug("Value: " + rawValue);
140 + }
141 +
142 + @Override
143 + public String toString() {
144 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
145 + .toString();
146 + }
147 +
148 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.exceptions.PcepParseException;
23 +import org.onosproject.pcepio.protocol.PcepVersion;
24 +import org.slf4j.Logger;
25 +import org.slf4j.LoggerFactory;
26 +
27 +import com.google.common.base.MoreObjects;
28 +import com.google.common.base.MoreObjects.ToStringHelper;
29 +
30 +/**
31 + * Provides StatefulRsvpErrorSpecTlv.
32 + */
33 +public class StatefulRsvpErrorSpecTlv implements PcepValueType {
34 +
35 + protected static final Logger log = LoggerFactory.getLogger(StatefulRsvpErrorSpecTlv.class);
36 +
37 + /* RSVP-ERROR-SPEC TLV format
38 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
39 + *
40 + *
41 +
42 + 0 1 2 3
43 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 + | Type=21 | Length (variable) |
46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 + | |
48 + + RSVP ERROR_SPEC or USER_ERROR_SPEC Object +
49 + | |
50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 +
52 + 0 1 2 3
53 + +-------------+-------------+-------------+-------------+
54 + | Length (bytes) | Class-Num | C-Type |
55 + +-------------+-------------+-------------+-------------+
56 + | |
57 + // (Object contents) //
58 + | |
59 + +-------------+-------------+-------------+-------------+
60 +
61 + Ref : ERROR_SPEC @ RFC2205
62 +
63 + IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
64 + +-------------+-------------+-------------+-------------+
65 + | IPv4 Error Node Address (4 bytes) |
66 + +-------------+-------------+-------------+-------------+
67 + | Flags | Error Code | Error Value |
68 + +-------------+-------------+-------------+-------------+
69 +
70 +
71 + IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
72 + +-------------+-------------+-------------+-------------+
73 + | |
74 + + +
75 + | |
76 + + IPv6 Error Node Address (16 bytes) +
77 + | |
78 + + +
79 + | |
80 + +-------------+-------------+-------------+-------------+
81 + | Flags | Error Code | Error Value |
82 + +-------------+-------------+-------------+-------------+
83 +
84 +
85 + Ref : USER_ERROR_SPEC @ RFC5284
86 + USER_ERROR_SPEC object: Class = 194, C-Type = 1
87 + 0 1 2 3
88 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
89 + +---------------+---------------+---------------+---------------+
90 + | Enterprise Number |
91 + +---------------+---------------+---------------+---------------+
92 + | Sub Org | Err Desc Len | User Error Value |
93 + +---------------+---------------+---------------+---------------+
94 + | |
95 + ~ Error Description ~
96 + | |
97 + +---------------+---------------+---------------+---------------+
98 + | |
99 + ~ User-Defined Subobjects ~
100 + | |
101 + +---------------+---------------+---------------+---------------+
102 +
103 + */
104 +
105 + public static final short TYPE = 21;
106 + public static final int OBJECT_HEADER_LENGTH = 4;
107 + private final short hLength;
108 +
109 + private final PcepRsvpErrorSpec rsvpErrSpecObj;
110 + private final boolean isErrSpceObjSet;
111 +
112 + /**
113 + * Constructor to initialize errSpecObj.
114 + *
115 + * @param rsvpErrSpecObj Rsvp error spec object
116 + * @param hLength length of rsvp error spec object
117 + */
118 + public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj, short hLength) {
119 + this.rsvpErrSpecObj = rsvpErrSpecObj;
120 + this.isErrSpceObjSet = true;
121 + this.hLength = hLength;
122 + }
123 +
124 + /**
125 + * Returns PcepRsvpErrorSpecObject.
126 + *
127 + * @return rsvpErrSpecObj
128 + */
129 + public PcepRsvpErrorSpec getPcepRsvpErrorSpec() {
130 + return this.rsvpErrSpecObj;
131 + }
132 +
133 + @Override
134 + public PcepVersion getVersion() {
135 + return PcepVersion.PCEP_1;
136 + }
137 +
138 + @Override
139 + public short getType() {
140 + return TYPE;
141 + }
142 +
143 + @Override
144 + public short getLength() {
145 + return hLength;
146 + }
147 +
148 + /**
149 + * Reads channel buffer and returns object of StatefulRsvpErrorSpecTlv.
150 + *
151 + * @param cb of type channel buffer
152 + * @return object of StatefulRsvpErrorSpecTlv
153 + */
154 + public static PcepValueType read(ChannelBuffer cb) throws PcepParseException {
155 +
156 + PcepRsvpErrorSpec rsvpErrSpecObj = null;
157 + PcepRsvpSpecObjHeader rsvpErrSpecObjHeader;
158 +
159 + cb.markReaderIndex();
160 + rsvpErrSpecObjHeader = PcepRsvpSpecObjHeader.read(cb);
161 + cb.resetReaderIndex();
162 +
163 + if (PcepRsvpIpv4ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
164 + && PcepRsvpIpv4ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
165 + rsvpErrSpecObj = PcepRsvpIpv4ErrorSpec.read(cb);
166 + } else if (PcepRsvpIpv6ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
167 + && PcepRsvpIpv6ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
168 + rsvpErrSpecObj = PcepRsvpIpv6ErrorSpec.read(cb);
169 + } else if (PcepRsvpUserErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
170 + && PcepRsvpUserErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
171 + rsvpErrSpecObj = PcepRsvpUserErrorSpec.read(cb);
172 + }
173 + return rsvpErrSpecObj;
174 + }
175 +
176 + @Override
177 + public int hashCode() {
178 + return Objects.hash(rsvpErrSpecObj.hashCode());
179 + }
180 +
181 + @Override
182 + public boolean equals(Object obj) {
183 + if (this == obj) {
184 + return true;
185 + }
186 + if (obj instanceof StatefulRsvpErrorSpecTlv) {
187 + StatefulRsvpErrorSpecTlv other = (StatefulRsvpErrorSpecTlv) obj;
188 + return Objects.equals(this.rsvpErrSpecObj, other.rsvpErrSpecObj);
189 + }
190 + return false;
191 + }
192 +
193 + @Override
194 + public int write(ChannelBuffer c) {
195 + int iStartIndex = c.writerIndex();
196 + c.writeShort(TYPE);
197 + int tlvLenIndex = c.writerIndex();
198 + c.writeShort(hLength);
199 + if (isErrSpceObjSet) {
200 + rsvpErrSpecObj.write(c);
201 + }
202 + short tlvLen = (short) (c.writerIndex() - iStartIndex + 4);
203 + c.setShort(tlvLenIndex, tlvLen);
204 +
205 + return tlvLen;
206 + }
207 +
208 + @Override
209 + public void print() {
210 +
211 + log.debug("StatefulRsvpErrorSpecTlv");
212 + log.debug("Type: " + TYPE);
213 + log.debug("Length: " + hLength);
214 + if (isErrSpceObjSet) {
215 + rsvpErrSpecObj.print();
216 + }
217 + }
218 +
219 + @Override
220 + public String toString() {
221 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
222 +
223 + if (!isErrSpceObjSet) {
224 + toStrHelper
225 + .add("Type", TYPE)
226 + .add("Length", hLength);
227 + } else {
228 + toStrHelper
229 + .add("Type", TYPE)
230 + .add("Length", hLength)
231 + .add("RSVP Error Spec Object", rsvpErrSpecObj);
232 + }
233 + return toStrHelper.toString();
234 + }
235 +}
1 +/*
2 + * Copyright 2015 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 +
17 +package org.onosproject.pcepio.types;
18 +
19 +import java.util.Objects;
20 +
21 +import org.jboss.netty.buffer.ChannelBuffer;
22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 +import org.slf4j.Logger;
24 +import org.slf4j.LoggerFactory;
25 +
26 +import com.google.common.base.MoreObjects;
27 +
28 +/**
29 + * Provides SymbolicPathNameTlv.
30 + */
31 +public class SymbolicPathNameTlv implements PcepValueType {
32 +
33 + /*
34 + * SYMBOLIC-PATH-NAME TLV format
35 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
36 + *
37 + 0 1 2 3
38 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 + | Type=17 | Length (variable) |
41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 + | |
43 + // Symbolic Path Name //
44 + | |
45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 + */
47 + protected static final Logger log = LoggerFactory.getLogger(SymbolicPathNameTlv.class);
48 +
49 + public static final short TYPE = 17;
50 + private short hLength;
51 +
52 + private final byte[] rawValue;
53 +
54 + /**
55 + * Constructor to initialize raw Value.
56 + *
57 + * @param rawValue Symbolic path name
58 + */
59 + public SymbolicPathNameTlv(byte[] rawValue) {
60 + this.rawValue = rawValue;
61 + this.hLength = (short) rawValue.length;
62 + }
63 +
64 + /**
65 + * Constructor to initialize raw Value.
66 + *
67 + * @param rawValue Symbolic path name
68 + * @param hLength length of Symbolic path name
69 + */
70 + public SymbolicPathNameTlv(byte[] rawValue, short hLength) {
71 + this.rawValue = rawValue;
72 + if (0 == hLength) {
73 + this.hLength = (short) rawValue.length;
74 + } else {
75 + this.hLength = hLength;
76 + }
77 + }
78 +
79 + /**
80 + * Creates an object of SymbolicPathNameTlv.
81 + *
82 + * @param raw Symbolic path name
83 + * @param hLength length of Symbolic path name
84 + * @return object of SymbolicPathNameTlv
85 + */
86 + public static SymbolicPathNameTlv of(final byte[] raw, short hLength) {
87 + return new SymbolicPathNameTlv(raw, hLength);
88 + }
89 +
90 + /**
91 + * Returns Symbolic path name.
92 + *
93 + * @return Symbolic path name byte array
94 + */
95 + public byte[] getValue() {
96 + return rawValue;
97 + }
98 +
99 + @Override
100 + public PcepVersion getVersion() {
101 + return PcepVersion.PCEP_1;
102 + }
103 +
104 + @Override
105 + public short getType() {
106 + return TYPE;
107 + }
108 +
109 + @Override
110 + public short getLength() {
111 + return hLength;
112 + }
113 +
114 + @Override
115 + public int hashCode() {
116 + return Objects.hash(rawValue);
117 + }
118 +
119 + @Override
120 + public boolean equals(Object obj) {
121 + if (this == obj) {
122 + return true;
123 + }
124 + if (obj instanceof SymbolicPathNameTlv) {
125 + SymbolicPathNameTlv other = (SymbolicPathNameTlv) obj;
126 + return Objects.equals(this.rawValue, other.rawValue);
127 + }
128 + return false;
129 + }
130 +
131 + @Override
132 + public int write(ChannelBuffer c) {
133 + int iLenStartIndex = c.writerIndex();
134 + c.writeShort(TYPE);
135 + c.writeShort(hLength);
136 + c.writeBytes(rawValue);
137 + return c.writerIndex() - iLenStartIndex;
138 + }
139 +
140 + /**
141 + * Reads channel buffer and returns object of SymbolicPathNameTlv.
142 + *
143 + * @param c of type channel buffer
144 + * @param hLength length of bytes to read
145 + * @return object of SymbolicPathNameTlv
146 + */
147 + public static SymbolicPathNameTlv read(ChannelBuffer c, short hLength) {
148 + byte[] symbolicPathName = new byte[hLength];
149 + c.readBytes(symbolicPathName, 0, hLength);
150 + return new SymbolicPathNameTlv(symbolicPathName, hLength);
151 + }
152 +
153 + @Override
154 + public void print() {
155 + log.debug("SymbolicPathNameTlv");
156 + log.debug("Type: " + TYPE);
157 + log.debug("Length: " + hLength);
158 + log.debug("Symbolic Path Name : " + rawValue);
159 + }
160 +
161 + @Override
162 + public String toString() {
163 + return MoreObjects.toStringHelper(getClass()).add("Symbolic Path Name ", rawValue).toString();
164 + }
165 +}
1 +/*
2 + * Copyright 2014-2015 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.pcepio;
17 +
18 +import org.jboss.netty.buffer.ChannelBuffer;
19 +import org.jboss.netty.buffer.ChannelBuffers;
20 +import org.junit.After;
21 +import org.junit.Assert;
22 +import org.junit.Before;
23 +import org.junit.Test;
24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 +import org.onosproject.pcepio.protocol.PcepFactories;
26 +import org.onosproject.pcepio.protocol.PcepMessage;
27 +import org.onosproject.pcepio.protocol.PcepMessageReader;
28 +import org.onosproject.pcepio.protocol.PcepCloseMsg;
29 +
30 +import java.util.Arrays;
31 +
32 +import org.slf4j.Logger;
33 +import org.slf4j.LoggerFactory;
34 +
35 +public class PcepCloseMsgTest {
36 + protected static final Logger log = LoggerFactory.getLogger(PcepCloseMsgTest.class);
37 +
38 + @Before
39 + public void startUp() {
40 + }
41 +
42 + @After
43 + public void tearDown() {
44 +
45 + }
46 +
47 + @Test
48 + public void closeMessageTest1() throws PcepParseException {
49 + byte[] closeMsg = new byte[] {0x20, 0x07, 0x00, 0x0C, /* common header */
50 + 0x0f, 0x10, 0x00, 0x08, 0x00, 0x00, 0x00, 0x02 };
51 +
52 + byte[] testCloseMsg = {0};
53 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
54 + buffer.writeBytes(closeMsg);
55 +
56 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
57 + PcepMessage message = null;
58 + try {
59 + message = reader.readFrom(buffer);
60 + } catch (PcepParseException e) {
61 + e.printStackTrace();
62 + }
63 +
64 + if (message instanceof PcepCloseMsg) {
65 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
66 + message.writeTo(buf);
67 + testCloseMsg = buf.array();
68 +
69 + int iReadLen = buf.writerIndex() - 0;
70 + testCloseMsg = new byte[iReadLen];
71 + buf.readBytes(testCloseMsg, 0, iReadLen);
72 + if (Arrays.equals(closeMsg, testCloseMsg)) {
73 + Assert.assertArrayEquals(closeMsg, testCloseMsg);
74 + log.debug("CloseMsg are equal :" + closeMsg);
75 + } else {
76 + Assert.fail("test case failed");
77 + log.debug("not equal");
78 + }
79 + } else {
80 + Assert.fail("test case failed");
81 + log.debug("not equal");
82 + }
83 + }
84 +}
1 +/*
2 + * Copyright 2014-2015 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.pcepio;
17 +
18 +import java.util.Arrays;
19 +
20 +import org.jboss.netty.buffer.ChannelBuffer;
21 +import org.jboss.netty.buffer.ChannelBuffers;
22 +import org.junit.After;
23 +import org.junit.Assert;
24 +import org.junit.Before;
25 +import org.junit.Test;
26 +import org.onosproject.pcepio.exceptions.PcepParseException;
27 +import org.onosproject.pcepio.protocol.PcepFactories;
28 +import org.onosproject.pcepio.protocol.PcepInitiateMsg;
29 +import org.onosproject.pcepio.protocol.PcepMessage;
30 +import org.onosproject.pcepio.protocol.PcepMessageReader;
31 +import org.slf4j.Logger;
32 +import org.slf4j.LoggerFactory;
33 +
34 +public class PcepInitiateMsgTest {
35 +
36 + protected static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgTest.class);
37 +
38 + @Before
39 + public void startUp() {
40 +
41 + }
42 +
43 + @After
44 + public void tearDown() {
45 +
46 + }
47 +
48 + @Test
49 + public void initiateMessageTest1() throws PcepParseException {
50 +
51 + /* srp, lsp, end-point, ERO.
52 + */
53 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, 0x54,
54 + 0x21, 0x10, 0x00, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
55 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x00, 0x08, //LSP object
56 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
57 + 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
58 + 0x00, 0x00, 0x00, 0x00, 0x02, 0x02, 0x02, 0x02,
59 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathTlv
60 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
61 + 0x07, 0x10, 0x00, 0x14, //ERO object
62 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
63 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
64 +
65 + byte[] testInitiateCreationMsg = {0};
66 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
67 + buffer.writeBytes(initiateCreationMsg);
68 +
69 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
70 + PcepMessage message = null;
71 + try {
72 + message = reader.readFrom(buffer);
73 + } catch (PcepParseException e) {
74 + e.printStackTrace();
75 + }
76 +
77 + if (message instanceof PcepInitiateMsg) {
78 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
79 + message.writeTo(buf);
80 + testInitiateCreationMsg = buf.array();
81 +
82 + int iReadLen = buf.writerIndex() - 0;
83 + testInitiateCreationMsg = new byte[iReadLen];
84 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
85 +
86 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
87 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
88 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
89 + } else {
90 + Assert.fail("test case failed");
91 + log.debug("not equal");
92 + }
93 + } else {
94 + Assert.fail("test case failed");
95 + log.debug("not equal");
96 + }
97 + }
98 +
99 + @Test
100 + public void initiateMessageTest2() throws PcepParseException {
101 + /* srp, lsp.
102 + */
103 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x34,
104 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
105 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x20, 0x10, //LSP object
106 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
107 + 0x01, 0x01, 0x01, 0x01, 0x00, 0x43, (byte) 0x83, 0x01,
108 + 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02,
109 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33 }; //SymbolicPathTlv
110 +
111 + byte[] testInitiateDeletionMsg = {0};
112 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
113 + buffer.writeBytes(initiateDeletionMsg);
114 +
115 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
116 + PcepMessage message = null;
117 + try {
118 + message = reader.readFrom(buffer);
119 + } catch (PcepParseException e) {
120 + e.printStackTrace();
121 + }
122 +
123 + if (message instanceof PcepInitiateMsg) {
124 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
125 + message.writeTo(buf);
126 + testInitiateDeletionMsg = buf.array();
127 +
128 + int iReadLen = buf.writerIndex() - 0;
129 + testInitiateDeletionMsg = new byte[iReadLen];
130 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
131 +
132 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
133 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
134 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
135 + } else {
136 + Assert.fail("test case failed");
137 + log.debug("not equal");
138 + }
139 + } else {
140 + Assert.fail("test case failed");
141 + log.debug("not equal");
142 + }
143 + }
144 +
145 + @Test
146 + public void initiateMessageTest3() throws PcepParseException {
147 +
148 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
149 + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO.
150 + */
151 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64,
152 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
153 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
154 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
155 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
156 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
157 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
158 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
159 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
160 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
161 + 0x07, 0x10, 0x00, 0x14, //ERO object
162 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
163 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
164 +
165 + byte[] testInitiateCreationMsg = {0};
166 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
167 + buffer.writeBytes(initiateCreationMsg);
168 +
169 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
170 + PcepMessage message = null;
171 + try {
172 + message = reader.readFrom(buffer);
173 + } catch (PcepParseException e) {
174 + e.printStackTrace();
175 + }
176 +
177 + if (message instanceof PcepInitiateMsg) {
178 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
179 + message.writeTo(buf);
180 + testInitiateCreationMsg = buf.array();
181 +
182 + int iReadLen = buf.writerIndex() - 0;
183 + testInitiateCreationMsg = new byte[iReadLen];
184 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
185 +
186 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
187 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
188 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
189 + } else {
190 + Assert.fail("test case failed");
191 + log.debug("not equal");
192 + }
193 + } else {
194 + Assert.fail("test case failed");
195 + log.debug("not equal");
196 + }
197 + }
198 +
199 + @Test
200 + public void initiateMessageTest4() throws PcepParseException {
201 +
202 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
203 + * StatefulLspErrorCodeTlv), END-POINT, ERO.
204 + */
205 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64,
206 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
207 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
208 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
209 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
210 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
211 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
212 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
213 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
214 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
215 + 0x07, 0x10, 0x00, 0x14, //ERO object
216 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
217 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
218 +
219 + byte[] testInitiateCreationMsg = {0};
220 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
221 + buffer.writeBytes(initiateCreationMsg);
222 +
223 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
224 + PcepMessage message = null;
225 + try {
226 + message = reader.readFrom(buffer);
227 + } catch (PcepParseException e) {
228 + e.printStackTrace();
229 + }
230 +
231 + if (message instanceof PcepInitiateMsg) {
232 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
233 + message.writeTo(buf);
234 + testInitiateCreationMsg = buf.array();
235 +
236 + int iReadLen = buf.writerIndex() - 0;
237 + testInitiateCreationMsg = new byte[iReadLen];
238 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
239 +
240 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
241 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
242 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
243 + } else {
244 + Assert.fail("test case failed");
245 + log.debug("not equal");
246 + }
247 + } else {
248 + Assert.fail("test case failed");
249 + log.debug("not equal");
250 + }
251 + }
252 +
253 + @Test
254 + public void initiateMessageTest5() throws PcepParseException {
255 +
256 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
257 + * END-POINT, ERO.
258 + */
259 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x5c,
260 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
261 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
262 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
263 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
264 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
265 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
266 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
267 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
268 + 0x07, 0x10, 0x00, 0x14, //ERO object
269 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
270 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00 };
271 +
272 + byte[] testInitiateCreationMsg = {0};
273 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
274 + buffer.writeBytes(initiateCreationMsg);
275 +
276 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
277 + PcepMessage message = null;
278 + try {
279 + message = reader.readFrom(buffer);
280 + } catch (PcepParseException e) {
281 + e.printStackTrace();
282 + }
283 +
284 + if (message instanceof PcepInitiateMsg) {
285 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
286 + message.writeTo(buf);
287 + testInitiateCreationMsg = buf.array();
288 +
289 + int iReadLen = buf.writerIndex() - 0;
290 + testInitiateCreationMsg = new byte[iReadLen];
291 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
292 +
293 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
294 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
295 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
296 + } else {
297 + Assert.fail("test case failed");
298 + log.debug("not equal");
299 + }
300 + } else {
301 + Assert.fail("test case failed");
302 + log.debug("not equal");
303 + }
304 + }
305 +
306 + @Test
307 + public void initiateMessageTest6() throws PcepParseException {
308 +
309 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
310 + * END-POINT, ERO.
311 + */
312 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x5c,
313 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
314 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
315 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
316 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
317 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
318 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
319 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
320 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
321 + 0x07, 0x10, 0x00, 0x14, //ERO object
322 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
323 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00 };
324 +
325 + byte[] testInitiateCreationMsg = {0};
326 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
327 + buffer.writeBytes(initiateCreationMsg);
328 +
329 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
330 + PcepMessage message = null;
331 + try {
332 + message = reader.readFrom(buffer);
333 + } catch (PcepParseException e) {
334 + e.printStackTrace();
335 + }
336 +
337 + if (message instanceof PcepInitiateMsg) {
338 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
339 + message.writeTo(buf);
340 + testInitiateCreationMsg = buf.array();
341 +
342 + int iReadLen = buf.writerIndex() - 0;
343 + testInitiateCreationMsg = new byte[iReadLen];
344 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
345 +
346 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
347 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
348 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
349 + } else {
350 + Assert.fail("test case failed");
351 + log.debug("not equal");
352 + }
353 + } else {
354 + Assert.fail("test case failed");
355 + log.debug("not equal");
356 + }
357 + }
358 +
359 + @Test
360 + public void initiateMessageTest7() throws PcepParseException {
361 +
362 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
363 + * END-POINT, ERO.
364 + */
365 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x54,
366 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03,
367 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
368 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
369 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
370 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
371 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
372 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
373 + 0x07, 0x10, 0x00, 0x14, //ERO object
374 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
375 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
376 +
377 + byte[] testInitiateCreationMsg = {0};
378 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
379 + buffer.writeBytes(initiateCreationMsg);
380 +
381 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
382 + PcepMessage message = null;
383 + try {
384 + message = reader.readFrom(buffer);
385 + } catch (PcepParseException e) {
386 + e.printStackTrace();
387 + }
388 +
389 + if (message instanceof PcepInitiateMsg) {
390 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
391 + message.writeTo(buf);
392 + testInitiateCreationMsg = buf.array();
393 +
394 + int iReadLen = buf.writerIndex() - 0;
395 + testInitiateCreationMsg = new byte[iReadLen];
396 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
397 +
398 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
399 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
400 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
401 + } else {
402 + Assert.fail("test case failed");
403 + log.debug("not equal");
404 + }
405 + } else {
406 + Assert.fail("test case failed");
407 + log.debug("not equal");
408 + }
409 + }
410 +
411 + @Test
412 + public void initiateMessageTest8() throws PcepParseException {
413 +
414 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv),
415 + * END-POINT, ERO.
416 + */
417 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x4c,
418 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
419 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
420 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
421 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
422 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
423 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
424 + 0x07, 0x10, 0x00, 0x14, //ERO object
425 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
426 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
427 +
428 + byte[] testInitiateCreationMsg = {0};
429 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
430 + buffer.writeBytes(initiateCreationMsg);
431 +
432 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
433 + PcepMessage message = null;
434 + try {
435 + message = reader.readFrom(buffer);
436 + } catch (PcepParseException e) {
437 + e.printStackTrace();
438 + }
439 +
440 + if (message instanceof PcepInitiateMsg) {
441 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
442 + message.writeTo(buf);
443 + testInitiateCreationMsg = buf.array();
444 +
445 + int iReadLen = buf.writerIndex() - 0;
446 + testInitiateCreationMsg = new byte[iReadLen];
447 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
448 +
449 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
450 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
451 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
452 + } else {
453 + Assert.fail("test case failed");
454 + log.debug("not equal");
455 + }
456 + } else {
457 + Assert.fail("test case failed");
458 + log.debug("not equal");
459 + }
460 + }
461 +
462 + @Test
463 + public void initiateMessageTest9() throws PcepParseException {
464 +
465 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv),
466 + * END-POINT, ERO.
467 + */
468 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x3c,
469 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
470 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
471 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
472 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
473 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
474 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
475 + 0x07, 0x10, 0x00, 0x04};
476 +
477 + byte[] testInitiateCreationMsg = {0};
478 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
479 + buffer.writeBytes(initiateCreationMsg);
480 +
481 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
482 + PcepMessage message = null;
483 + try {
484 + message = reader.readFrom(buffer);
485 + } catch (PcepParseException e) {
486 + e.printStackTrace();
487 + }
488 +
489 + if (message instanceof PcepInitiateMsg) {
490 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
491 + message.writeTo(buf);
492 + testInitiateCreationMsg = buf.array();
493 +
494 + int iReadLen = buf.writerIndex() - 0;
495 + testInitiateCreationMsg = new byte[iReadLen];
496 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
497 +
498 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
499 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
500 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
501 + } else {
502 + Assert.fail("test case failed");
503 + log.debug("not equal");
504 + }
505 + } else {
506 + Assert.fail("test case failed");
507 + log.debug("not equal");
508 + }
509 + }
510 +
511 + @Test
512 + public void initiateMessageTest10() throws PcepParseException {
513 +
514 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, StatefulRsvpErrorSpecTlv).
515 + */
516 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x44,
517 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
518 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
519 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
520 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
521 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f,
522 + (byte) 0xb6, 0x02, 0x4e, 0x20, 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
523 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08 //StatefulLspErrorCodeTlv
524 + };
525 +
526 + byte[] testInitiateDeletionMsg = {0};
527 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
528 + buffer.writeBytes(initiateDeletionMsg);
529 +
530 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
531 + PcepMessage message = null;
532 + try {
533 + message = reader.readFrom(buffer);
534 + } catch (PcepParseException e) {
535 + e.printStackTrace();
536 + }
537 +
538 + if (message instanceof PcepInitiateMsg) {
539 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
540 + message.writeTo(buf);
541 + testInitiateDeletionMsg = buf.array();
542 +
543 + int iReadLen = buf.writerIndex() - 0;
544 + testInitiateDeletionMsg = new byte[iReadLen];
545 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
546 +
547 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
548 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
549 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
550 + } else {
551 + Assert.fail("test case failed");
552 + log.debug("not equal");
553 + }
554 + } else {
555 + Assert.fail("test case failed");
556 + log.debug("not equal");
557 + }
558 + }
559 +
560 + @Test
561 + public void initiateMessageTest11() throws PcepParseException {
562 +
563 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
564 + StatefulLspErrorCodeTlv).*/
565 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x44,
566 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
567 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
568 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
569 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
570 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
571 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
572 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
573 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08}; //StatefulLspErrorCodeTlv
574 +
575 + byte[] testInitiateDeletionMsg = {0};
576 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
577 + buffer.writeBytes(initiateDeletionMsg);
578 +
579 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
580 + PcepMessage message = null;
581 + try {
582 + message = reader.readFrom(buffer);
583 + } catch (PcepParseException e) {
584 + e.printStackTrace();
585 + }
586 +
587 + if (message instanceof PcepInitiateMsg) {
588 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
589 + message.writeTo(buf);
590 + testInitiateDeletionMsg = buf.array();
591 +
592 + int iReadLen = buf.writerIndex() - 0;
593 + testInitiateDeletionMsg = new byte[iReadLen];
594 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
595 +
596 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
597 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
598 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
599 + } else {
600 + Assert.fail("test case failed");
601 + log.debug("not equal");
602 + }
603 + } else {
604 + Assert.fail("test case failed");
605 + log.debug("not equal");
606 + }
607 + }
608 +
609 + @Test
610 + public void initiateMessageTest12() throws PcepParseException {
611 +
612 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv).
613 + */
614 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x3c,
615 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
616 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
617 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
618 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
619 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
620 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 //SymbolicPathNameTlv
621 + };
622 +
623 + byte[] testInitiateDeletionMsg = {0};
624 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
625 + buffer.writeBytes(initiateDeletionMsg);
626 +
627 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
628 + PcepMessage message = null;
629 + try {
630 + message = reader.readFrom(buffer);
631 + } catch (PcepParseException e) {
632 + e.printStackTrace();
633 + }
634 +
635 + if (message instanceof PcepInitiateMsg) {
636 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
637 + message.writeTo(buf);
638 + testInitiateDeletionMsg = buf.array();
639 +
640 + int iReadLen = buf.writerIndex() - 0;
641 + testInitiateDeletionMsg = new byte[iReadLen];
642 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
643 +
644 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
645 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
646 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
647 + } else {
648 + Assert.fail("test case failed");
649 + log.debug("not equal");
650 + }
651 + } else {
652 + Assert.fail("test case failed");
653 + log.debug("not equal");
654 + }
655 + }
656 +
657 + @Test
658 + public void initiateMessageTest13() throws PcepParseException {
659 +
660 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv).
661 + */
662 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x3c,
663 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
664 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
665 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
666 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
667 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
668 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00 }; //SymbolicPathNameTlv
669 +
670 + byte[] testInitiateDeletionMsg = {0};
671 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
672 + buffer.writeBytes(initiateDeletionMsg);
673 +
674 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
675 + PcepMessage message = null;
676 + try {
677 + message = reader.readFrom(buffer);
678 + } catch (PcepParseException e) {
679 + e.printStackTrace();
680 + }
681 +
682 + if (message instanceof PcepInitiateMsg) {
683 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
684 + message.writeTo(buf);
685 + testInitiateDeletionMsg = buf.array();
686 +
687 + int iReadLen = buf.writerIndex() - 0;
688 + testInitiateDeletionMsg = new byte[iReadLen];
689 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
690 +
691 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
692 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
693 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
694 + } else {
695 + Assert.fail("test case failed");
696 + log.debug("not equal");
697 + }
698 + } else {
699 + Assert.fail("test case failed");
700 + log.debug("not equal");
701 + }
702 + }
703 +
704 + @Test
705 + public void initiateMessageTest14() throws PcepParseException {
706 +
707 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv).
708 + */
709 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x34,
710 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
711 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
712 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
713 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
714 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
715 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20 };
716 +
717 + byte[] testInitiateDeletionMsg = {0};
718 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
719 + buffer.writeBytes(initiateDeletionMsg);
720 +
721 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
722 + PcepMessage message = null;
723 + try {
724 + message = reader.readFrom(buffer);
725 + } catch (PcepParseException e) {
726 + e.printStackTrace();
727 + }
728 +
729 + if (message instanceof PcepInitiateMsg) {
730 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
731 + message.writeTo(buf);
732 + testInitiateDeletionMsg = buf.array();
733 +
734 + int iReadLen = buf.writerIndex() - 0;
735 + testInitiateDeletionMsg = new byte[iReadLen];
736 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
737 +
738 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
739 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
740 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
741 + } else {
742 + Assert.fail("test case failed");
743 + log.debug("not equal");
744 + }
745 + } else {
746 + Assert.fail("test case failed");
747 + log.debug("not equal");
748 + }
749 + }
750 +
751 + @Test
752 + public void initiateMessageTest15() throws PcepParseException {
753 +
754 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv).
755 + */
756 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x2c,
757 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
758 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
759 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
760 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
761 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
762 +
763 + byte[] testInitiateDeletionMsg = {0};
764 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
765 + buffer.writeBytes(initiateDeletionMsg);
766 +
767 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
768 + PcepMessage message = null;
769 + try {
770 + message = reader.readFrom(buffer);
771 + } catch (PcepParseException e) {
772 + e.printStackTrace();
773 + }
774 +
775 + if (message instanceof PcepInitiateMsg) {
776 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
777 + message.writeTo(buf);
778 + testInitiateDeletionMsg = buf.array();
779 +
780 + int iReadLen = buf.writerIndex() - 0;
781 + testInitiateDeletionMsg = new byte[iReadLen];
782 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
783 +
784 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
785 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
786 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
787 + } else {
788 + Assert.fail("test case failed");
789 + log.debug("not equal");
790 + }
791 + } else {
792 + Assert.fail("test case failed");
793 + log.debug("not equal");
794 + }
795 + }
796 +
797 + @Test
798 + public void initiateMessageTest16() throws PcepParseException {
799 +
800 + //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
801 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x50,
802 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
803 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
804 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
805 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
806 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
807 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
808 + 0x07, 0x10, 0x00, 0x04, //ERO object
809 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
810 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
811 +
812 + byte[] testInitiateCreationMsg = {0};
813 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
814 + buffer.writeBytes(initiateCreationMsg);
815 +
816 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
817 + PcepMessage message = null;
818 + try {
819 + message = reader.readFrom(buffer);
820 + } catch (PcepParseException e) {
821 + e.printStackTrace();
822 + }
823 +
824 + if (message instanceof PcepInitiateMsg) {
825 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
826 + message.writeTo(buf);
827 + testInitiateCreationMsg = buf.array();
828 +
829 + int iReadLen = buf.writerIndex() - 0;
830 + testInitiateCreationMsg = new byte[iReadLen];
831 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
832 +
833 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
834 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
835 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
836 + } else {
837 + Assert.fail("test case failed");
838 + log.debug("not equal");
839 + }
840 + } else {
841 + Assert.fail("test case failed");
842 + log.debug("not equal");
843 + }
844 + }
845 +
846 + @Test
847 + public void initiateMessageTest17() throws PcepParseException {
848 +
849 + //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
850 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x58,
851 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
852 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
853 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
854 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
855 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
856 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
857 + 0x07, 0x10, 0x00, 0x04, //ERO object
858 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
859 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
860 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
861 +
862 + byte[] testInitiateCreationMsg = {0};
863 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
864 + buffer.writeBytes(initiateCreationMsg);
865 +
866 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
867 + PcepMessage message = null;
868 + try {
869 + message = reader.readFrom(buffer);
870 + } catch (PcepParseException e) {
871 + e.printStackTrace();
872 + }
873 +
874 + if (message instanceof PcepInitiateMsg) {
875 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
876 + message.writeTo(buf);
877 + testInitiateCreationMsg = buf.array();
878 +
879 + int iReadLen = buf.writerIndex() - 0;
880 + testInitiateCreationMsg = new byte[iReadLen];
881 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
882 +
883 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
884 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
885 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
886 + } else {
887 + Assert.fail("test case failed");
888 + log.debug("not equal");
889 + }
890 + } else {
891 + Assert.fail("test case failed");
892 + log.debug("not equal");
893 + }
894 + }
895 +
896 + @Test
897 + public void initiateMessageTest18() throws PcepParseException {
898 + //srp,lsp (StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list
899 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64,
900 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
901 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
902 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
903 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
904 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
905 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
906 + 0x07, 0x10, 0x00, 0x04, //ERO object
907 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
908 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
909 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
910 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
911 +
912 + byte[] testInitiateCreationMsg = {0};
913 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
914 + buffer.writeBytes(initiateCreationMsg);
915 +
916 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
917 + PcepMessage message = null;
918 + try {
919 + message = reader.readFrom(buffer);
920 + } catch (PcepParseException e) {
921 + e.printStackTrace();
922 + }
923 +
924 + if (message instanceof PcepInitiateMsg) {
925 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
926 + message.writeTo(buf);
927 + testInitiateCreationMsg = buf.array();
928 +
929 + int iReadLen = buf.writerIndex() - 0;
930 + testInitiateCreationMsg = new byte[iReadLen];
931 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
932 +
933 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
934 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
935 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
936 + } else {
937 + Assert.fail("test case failed");
938 + log.debug("not equal");
939 + }
940 + } else {
941 + Assert.fail("test case failed");
942 + log.debug("not equal");
943 + }
944 + }
945 +
946 + @Test
947 + public void initiateMessageTest19() throws PcepParseException {
948 + //srp,lsp(all tlvs),end-point,ero,lspa,bandwidth,metric-list
949 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x74,
950 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
951 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
952 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
953 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
954 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
955 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathTlv
956 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08,
957 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
958 + 0x07, 0x10, 0x00, 0x04, //ERO object
959 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
960 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
961 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
962 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
963 +
964 + byte[] testInitiateCreationMsg = {0};
965 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
966 + buffer.writeBytes(initiateCreationMsg);
967 +
968 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
969 + PcepMessage message = null;
970 + try {
971 + message = reader.readFrom(buffer);
972 + } catch (PcepParseException e) {
973 + e.printStackTrace();
974 + }
975 +
976 + if (message instanceof PcepInitiateMsg) {
977 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
978 + message.writeTo(buf);
979 + testInitiateCreationMsg = buf.array();
980 +
981 + int iReadLen = buf.writerIndex() - 0;
982 + testInitiateCreationMsg = new byte[iReadLen];
983 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
984 +
985 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
986 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
987 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
988 + } else {
989 + Assert.fail("test case failed");
990 + log.debug("not equal");
991 + }
992 + } else {
993 + Assert.fail("test case failed");
994 + log.debug("not equal");
995 + }
996 + }
997 +
998 + @Test
999 + public void initiateMessageTest20() throws PcepParseException {
1000 + /* srp,lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, srp,
1001 + * lsp(SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv).
1002 + */
1003 + byte[] initiateDeletionMsg = new byte[] {0x20, 0x0C, 0x00, 0x64,
1004 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
1005 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1006 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1007 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1008 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1009 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1010 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, //SRP object
1011 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1012 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1013 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1014 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1015 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20};
1016 +
1017 + byte[] testInitiateDeletionMsg = {0};
1018 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1019 + buffer.writeBytes(initiateDeletionMsg);
1020 +
1021 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1022 + PcepMessage message = null;
1023 + try {
1024 + message = reader.readFrom(buffer);
1025 + } catch (PcepParseException e) {
1026 + e.printStackTrace();
1027 + }
1028 +
1029 + if (message instanceof PcepInitiateMsg) {
1030 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1031 + message.writeTo(buf);
1032 + testInitiateDeletionMsg = buf.array();
1033 +
1034 + int iReadLen = buf.writerIndex() - 0;
1035 + testInitiateDeletionMsg = new byte[iReadLen];
1036 + buf.readBytes(testInitiateDeletionMsg, 0, iReadLen);
1037 +
1038 + if (Arrays.equals(initiateDeletionMsg, testInitiateDeletionMsg)) {
1039 + Assert.assertArrayEquals(initiateDeletionMsg, testInitiateDeletionMsg);
1040 + log.debug("PCInitiate Msg are equal :" + initiateDeletionMsg);
1041 + } else {
1042 + Assert.fail("test case failed");
1043 + log.debug("not equal");
1044 + }
1045 + } else {
1046 + Assert.fail("test case failed");
1047 + log.debug("not equal");
1048 + }
1049 + }
1050 +
1051 + @Test
1052 + public void initiateMessageTest21() throws PcepParseException {
1053 + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
1054 + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero
1055 + */
1056 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x94,
1057 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1058 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1059 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1060 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1061 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1062 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1063 + 0x07, 0x10, 0x00, 0x14, //ERO object
1064 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1065 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1066 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1067 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1068 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1069 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1070 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1071 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1072 + 0x07, 0x10, 0x00, 0x14, //ERO object
1073 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1074 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00};
1075 +
1076 + byte[] testInitiateCreationMsg = {0};
1077 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1078 + buffer.writeBytes(initiateCreationMsg);
1079 +
1080 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1081 + PcepMessage message = null;
1082 + try {
1083 + message = reader.readFrom(buffer);
1084 + } catch (PcepParseException e) {
1085 + e.printStackTrace();
1086 + }
1087 +
1088 + if (message instanceof PcepInitiateMsg) {
1089 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1090 + message.writeTo(buf);
1091 + testInitiateCreationMsg = buf.array();
1092 +
1093 + int iReadLen = buf.writerIndex() - 0;
1094 + testInitiateCreationMsg = new byte[iReadLen];
1095 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1096 +
1097 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1098 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1099 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1100 + } else {
1101 + Assert.fail("test case failed");
1102 + log.debug("not equal");
1103 + }
1104 + } else {
1105 + Assert.fail("test case failed");
1106 + log.debug("not equal");
1107 + }
1108 + }
1109 +
1110 + @Test
1111 + public void initiateMessageTest22() throws PcepParseException {
1112 + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
1113 + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa
1114 + */
1115 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xA8,
1116 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1117 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1118 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1119 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1120 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1121 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1122 + 0x07, 0x10, 0x00, 0x14, //ERO object
1123 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1124 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1125 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1126 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1127 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1128 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1129 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1130 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1131 + 0x07, 0x10, 0x00, 0x14, //ERO object
1132 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1133 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1134 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1135 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
1136 +
1137 + byte[] testInitiateCreationMsg = {0};
1138 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1139 + buffer.writeBytes(initiateCreationMsg);
1140 +
1141 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1142 + PcepMessage message = null;
1143 + try {
1144 + message = reader.readFrom(buffer);
1145 + } catch (PcepParseException e) {
1146 + e.printStackTrace();
1147 + }
1148 +
1149 + if (message instanceof PcepInitiateMsg) {
1150 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1151 + message.writeTo(buf);
1152 + testInitiateCreationMsg = buf.array();
1153 +
1154 + int iReadLen = buf.writerIndex() - 0;
1155 + testInitiateCreationMsg = new byte[iReadLen];
1156 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1157 +
1158 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1159 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1160 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1161 + } else {
1162 + Assert.fail("test case failed");
1163 + log.debug("not equal");
1164 + }
1165 + } else {
1166 + Assert.fail("test case failed");
1167 + log.debug("not equal");
1168 + }
1169 + }
1170 +
1171 + @Test
1172 + public void initiateMessageTest23() throws PcepParseException {
1173 + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
1174 + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth
1175 + */
1176 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xB0,
1177 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1178 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1179 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1180 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1181 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1182 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1183 + 0x07, 0x10, 0x00, 0x14, //ERO object
1184 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1185 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1186 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1187 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1188 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1189 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1190 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1191 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1192 + 0x07, 0x10, 0x00, 0x14, //ERO object
1193 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1194 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1195 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1196 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1197 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00}; //Bandwidth object
1198 +
1199 + byte[] testInitiateCreationMsg = {0};
1200 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1201 + buffer.writeBytes(initiateCreationMsg);
1202 +
1203 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1204 + PcepMessage message = null;
1205 + try {
1206 + message = reader.readFrom(buffer);
1207 + } catch (PcepParseException e) {
1208 + e.printStackTrace();
1209 + }
1210 +
1211 + if (message instanceof PcepInitiateMsg) {
1212 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1213 + message.writeTo(buf);
1214 + testInitiateCreationMsg = buf.array();
1215 +
1216 + int iReadLen = buf.writerIndex() - 0;
1217 + testInitiateCreationMsg = new byte[iReadLen];
1218 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1219 +
1220 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1221 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1222 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1223 + } else {
1224 + Assert.fail("test case failed");
1225 + log.debug("not equal");
1226 + }
1227 + } else {
1228 + Assert.fail("test case failed");
1229 + log.debug("not equal");
1230 + }
1231 + }
1232 +
1233 + @Test
1234 + public void initiateMessageTest24() throws PcepParseException {
1235 + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,
1236 + * srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth*/
1237 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xBC,
1238 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1239 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1240 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1241 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1242 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1243 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1244 + 0x07, 0x10, 0x00, 0x14, //ERO object
1245 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1246 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1247 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1248 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1249 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1250 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1251 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1252 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1253 + 0x07, 0x10, 0x00, 0x14, //ERO object
1254 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1255 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1256 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1257 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1258 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1259 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
1260 +
1261 + byte[] testInitiateCreationMsg = {0};
1262 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1263 + buffer.writeBytes(initiateCreationMsg);
1264 +
1265 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1266 + PcepMessage message = null;
1267 + try {
1268 + message = reader.readFrom(buffer);
1269 + } catch (PcepParseException e) {
1270 + e.printStackTrace();
1271 + }
1272 +
1273 + if (message instanceof PcepInitiateMsg) {
1274 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1275 + message.writeTo(buf);
1276 + testInitiateCreationMsg = buf.array();
1277 +
1278 + int iReadLen = buf.writerIndex() - 0;
1279 + testInitiateCreationMsg = new byte[iReadLen];
1280 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1281 +
1282 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1283 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1284 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1285 + } else {
1286 + Assert.fail("test case failed");
1287 + log.debug("not equal");
1288 + }
1289 + } else {
1290 + Assert.fail("test case failed");
1291 + log.debug("not equal");
1292 + }
1293 + }
1294 +
1295 + @Test
1296 + public void initiateMessageTest25() throws PcepParseException {
1297 +
1298 + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,
1299 + * srp,lsp(StatefulIPv4LspIdentidiersTlv),
1300 + * end-point,ero,lspa,bandwidth,metric-list */
1301 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xC4,
1302 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1303 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1304 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1305 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1306 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1307 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1308 + 0x07, 0x10, 0x00, 0x14, //ERO object
1309 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1310 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1311 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1312 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1313 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1314 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1315 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1316 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1317 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1318 + 0x07, 0x10, 0x00, 0x14, //ERO object
1319 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1320 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1321 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1322 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1323 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1324 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
1325 +
1326 + byte[] testInitiateCreationMsg = {0};
1327 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1328 + buffer.writeBytes(initiateCreationMsg);
1329 +
1330 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1331 + PcepMessage message = null;
1332 + try {
1333 + message = reader.readFrom(buffer);
1334 + } catch (PcepParseException e) {
1335 + e.printStackTrace();
1336 + }
1337 +
1338 + if (message instanceof PcepInitiateMsg) {
1339 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1340 + message.writeTo(buf);
1341 + testInitiateCreationMsg = buf.array();
1342 +
1343 + int iReadLen = buf.writerIndex() - 0;
1344 + testInitiateCreationMsg = new byte[iReadLen];
1345 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1346 +
1347 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1348 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1349 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1350 + } else {
1351 + Assert.fail("test case failed");
1352 + log.debug("not equal");
1353 + }
1354 + } else {
1355 + Assert.fail("test case failed");
1356 + log.debug("not equal");
1357 + }
1358 + }
1359 +
1360 + @Test
1361 + public void initiateMessageTest26() throws PcepParseException {
1362 +
1363 + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,bandwidth,metric-list,
1364 + * srp,lsp(StatefulIPv4LspIdentidiersTlv),
1365 + * end-point,ero,lspa,bandwidth,metric-list */
1366 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xD0,
1367 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1368 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1369 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1370 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1371 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1372 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1373 + 0x07, 0x10, 0x00, 0x14, //ERO object
1374 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1375 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1376 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1377 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
1378 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1379 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1380 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1381 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1382 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1383 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1384 + 0x07, 0x10, 0x00, 0x14, //ERO object
1385 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1386 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1387 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1388 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1389 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1390 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
1391 +
1392 + byte[] testInitiateCreationMsg = {0};
1393 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1394 + buffer.writeBytes(initiateCreationMsg);
1395 +
1396 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1397 + PcepMessage message = null;
1398 + try {
1399 + message = reader.readFrom(buffer);
1400 + } catch (PcepParseException e) {
1401 + e.printStackTrace();
1402 + }
1403 +
1404 + if (message instanceof PcepInitiateMsg) {
1405 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1406 + message.writeTo(buf);
1407 + testInitiateCreationMsg = buf.array();
1408 +
1409 + int iReadLen = buf.writerIndex() - 0;
1410 + testInitiateCreationMsg = new byte[iReadLen];
1411 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1412 +
1413 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1414 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1415 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1416 + } else {
1417 + Assert.fail("test case failed");
1418 + log.debug("not equal");
1419 + }
1420 + } else {
1421 + Assert.fail("test case failed");
1422 + log.debug("not equal");
1423 + }
1424 + }
1425 +
1426 + @Test
1427 + public void initiateMessageTest27() throws PcepParseException {
1428 +
1429 + /*srp,lsp(StatefulIPv4LspIdentidiersTlv),end-point,ero,lspa,bandwidth,metric-list,
1430 + * srp,lsp(StatefulIPv4LspIdentidiersTlv),
1431 + * end-point,ero,lspa,bandwidth,metric-list */
1432 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xE4,
1433 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1434 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1435 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1436 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1437 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1438 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1439 + 0x07, 0x10, 0x00, 0x14, //ERO object
1440 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1441 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1442 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1443 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1444 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1445 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
1446 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1447 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1448 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1449 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1450 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1451 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1452 + 0x07, 0x10, 0x00, 0x14, //ERO object
1453 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x01, 0x00, 0x00,
1454 + 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1455 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1456 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
1457 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1458 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
1459 +
1460 + byte[] testInitiateCreationMsg = {0};
1461 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1462 + buffer.writeBytes(initiateCreationMsg);
1463 +
1464 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1465 + PcepMessage message = null;
1466 + try {
1467 + message = reader.readFrom(buffer);
1468 + } catch (PcepParseException e) {
1469 + e.printStackTrace();
1470 + }
1471 +
1472 + if (message instanceof PcepInitiateMsg) {
1473 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1474 + message.writeTo(buf);
1475 + testInitiateCreationMsg = buf.array();
1476 +
1477 + int iReadLen = buf.writerIndex() - 0;
1478 + testInitiateCreationMsg = new byte[iReadLen];
1479 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1480 +
1481 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1482 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1483 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1484 + } else {
1485 + Assert.fail("test case failed");
1486 + log.debug("not equal");
1487 + }
1488 + } else {
1489 + Assert.fail("test case failed");
1490 + log.debug("not equal");
1491 + }
1492 + }
1493 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2014-2015 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.pcepio;
17 +
18 +import java.util.Arrays;
19 +import org.jboss.netty.buffer.ChannelBuffer;
20 +import org.jboss.netty.buffer.ChannelBuffers;
21 +import org.junit.After;
22 +import org.junit.Assert;
23 +import org.junit.Before;
24 +import org.junit.Test;
25 +import org.onosproject.pcepio.exceptions.PcepParseException;
26 +import org.onosproject.pcepio.protocol.PcepFactories;
27 +import org.onosproject.pcepio.protocol.PcepInitiateMsg;
28 +import org.onosproject.pcepio.protocol.PcepMessage;
29 +import org.onosproject.pcepio.protocol.PcepMessageReader;
30 +import org.slf4j.Logger;
31 +import org.slf4j.LoggerFactory;
32 +
33 +public class PcepInitiateMsgTest2 {
34 +
35 + protected static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgTest.class);
36 +
37 + @Before
38 + public void startUp() {
39 +
40 + }
41 +
42 + @After
43 + public void tearDown() {
44 +
45 + }
46 +
47 + @Test
48 + public void initiateMessageTest1() throws PcepParseException {
49 +
50 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
51 + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC-LIST.
52 + */
53 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0xA4,
54 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
55 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
56 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03,
57 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
58 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
59 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
60 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
61 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
62 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
63 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
64 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
65 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
66 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
67 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
68 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
69 + 0x05, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
70 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, //Metric object
71 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
72 +
73 + byte[] testInitiateCreationMsg = {0};
74 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
75 + buffer.writeBytes(initiateCreationMsg);
76 +
77 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
78 + PcepMessage message = null;
79 + try {
80 + message = reader.readFrom(buffer);
81 + } catch (PcepParseException e) {
82 + e.printStackTrace();
83 + }
84 +
85 + if (message instanceof PcepInitiateMsg) {
86 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
87 + message.writeTo(buf);
88 + testInitiateCreationMsg = buf.array();
89 +
90 + int iReadLen = buf.writerIndex() - 0;
91 + testInitiateCreationMsg = new byte[iReadLen];
92 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
93 +
94 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
95 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
96 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
97 + } else {
98 + Assert.fail("test case failed");
99 + log.debug("not equal");
100 + }
101 + } else {
102 + Assert.fail("test case failed");
103 + log.debug("not equal");
104 + }
105 + }
106 +
107 + @Test
108 + public void initiateMessageTest2() throws PcepParseException {
109 +
110 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
111 + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
112 + */
113 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x98,
114 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
115 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
116 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
117 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
118 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
119 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
120 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
121 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
122 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
123 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
124 + // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
125 + // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
126 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
127 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
128 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
129 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
130 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
131 + 0x05, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
132 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 };
133 +
134 + byte[] testInitiateCreationMsg = {0};
135 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
136 + buffer.writeBytes(initiateCreationMsg);
137 +
138 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
139 + PcepMessage message = null;
140 + try {
141 + message = reader.readFrom(buffer);
142 + } catch (PcepParseException e) {
143 + e.printStackTrace();
144 + }
145 +
146 + if (message instanceof PcepInitiateMsg) {
147 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
148 + message.writeTo(buf);
149 + testInitiateCreationMsg = buf.array();
150 +
151 + int iReadLen = buf.writerIndex() - 0;
152 + testInitiateCreationMsg = new byte[iReadLen];
153 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
154 +
155 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
156 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
157 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
158 + } else {
159 + Assert.fail("test case failed");
160 + log.debug("not equal");
161 + }
162 + } else {
163 + Assert.fail("test case failed");
164 + log.debug("not equal");
165 + }
166 + }
167 +
168 + @Test
169 + public void initiateMessageTest3() throws PcepParseException {
170 +
171 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
172 + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA, BANDWIDTH.
173 + */
174 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x8c,
175 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
176 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
177 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
178 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
179 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
180 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
181 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
182 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
183 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
184 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
185 + // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
186 + //0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
187 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
188 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
189 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
190 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
191 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
192 + 0x05, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 };
193 +
194 + byte[] testInitiateCreationMsg = {0};
195 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
196 + buffer.writeBytes(initiateCreationMsg);
197 +
198 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
199 + PcepMessage message = null;
200 + try {
201 + message = reader.readFrom(buffer);
202 + } catch (PcepParseException e) {
203 + e.printStackTrace();
204 + }
205 +
206 + if (message instanceof PcepInitiateMsg) {
207 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
208 + message.writeTo(buf);
209 + testInitiateCreationMsg = buf.array();
210 +
211 + int iReadLen = buf.writerIndex() - 0;
212 + testInitiateCreationMsg = new byte[iReadLen];
213 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
214 +
215 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
216 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
217 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
218 + } else {
219 + Assert.fail("test case failed");
220 + log.debug("not equal");
221 + }
222 + } else {
223 + Assert.fail("test case failed");
224 + log.debug("not equal");
225 + }
226 + }
227 +
228 + @Test
229 + public void initiateMessageTest4() throws PcepParseException {
230 +
231 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
232 + * StatefulLspErrorCodeTlv, StatefulRsvpErrorSpecTlv), END-POINTS, ERO, LSPA.
233 + */
234 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x84,
235 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
236 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
237 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
238 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
239 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
240 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
241 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
242 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
243 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
244 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
245 + // 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
246 + // 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
247 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
248 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
249 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
250 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
251 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
252 +
253 + byte[] testInitiateCreationMsg = {0};
254 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
255 + buffer.writeBytes(initiateCreationMsg);
256 +
257 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
258 + PcepMessage message = null;
259 + try {
260 + message = reader.readFrom(buffer);
261 + } catch (PcepParseException e) {
262 + e.printStackTrace();
263 + }
264 +
265 + if (message instanceof PcepInitiateMsg) {
266 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
267 + message.writeTo(buf);
268 + testInitiateCreationMsg = buf.array();
269 +
270 + int iReadLen = buf.writerIndex() - 0;
271 + testInitiateCreationMsg = new byte[iReadLen];
272 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
273 +
274 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
275 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
276 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
277 + } else {
278 + Assert.fail("test case failed");
279 + log.debug("not equal");
280 + }
281 + } else {
282 + Assert.fail("test case failed");
283 + log.debug("not equal");
284 + }
285 + }
286 +
287 + @Test
288 + public void initiateMessageTest5() throws PcepParseException {
289 +
290 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
291 + * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA.
292 + */
293 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x84,
294 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
295 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
296 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
297 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
298 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
299 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
300 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
301 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
302 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
303 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
304 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
305 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
306 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
307 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
308 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
309 +
310 + byte[] testInitiateCreationMsg = {0};
311 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
312 + buffer.writeBytes(initiateCreationMsg);
313 +
314 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
315 + PcepMessage message = null;
316 + try {
317 + message = reader.readFrom(buffer);
318 + } catch (PcepParseException e) {
319 + e.printStackTrace();
320 + }
321 +
322 + if (message instanceof PcepInitiateMsg) {
323 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
324 + message.writeTo(buf);
325 + testInitiateCreationMsg = buf.array();
326 +
327 + int iReadLen = buf.writerIndex() - 0;
328 + testInitiateCreationMsg = new byte[iReadLen];
329 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
330 +
331 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
332 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
333 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
334 + } else {
335 + Assert.fail("test case failed");
336 + log.debug("not equal");
337 + }
338 + } else {
339 + Assert.fail("test case failed");
340 + log.debug("not equal");
341 + }
342 + }
343 +
344 + @Test
345 + public void initiateMessageTest6() throws PcepParseException {
346 +
347 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
348 + * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
349 + */
350 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x8c,
351 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
352 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
353 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
354 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
355 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
356 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
357 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
358 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
359 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
360 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
361 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
362 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
363 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
364 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
365 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
366 + 0x05, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 };
367 +
368 + byte[] testInitiateCreationMsg = {0};
369 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
370 + buffer.writeBytes(initiateCreationMsg);
371 +
372 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
373 + PcepMessage message = null;
374 + try {
375 + message = reader.readFrom(buffer);
376 + } catch (PcepParseException e) {
377 + e.printStackTrace();
378 + }
379 +
380 + if (message instanceof PcepInitiateMsg) {
381 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
382 + message.writeTo(buf);
383 + testInitiateCreationMsg = buf.array();
384 +
385 + int iReadLen = buf.writerIndex() - 0;
386 + testInitiateCreationMsg = new byte[iReadLen];
387 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
388 +
389 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
390 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
391 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
392 + } else {
393 + Assert.fail("test case failed");
394 + log.debug("not equal");
395 + }
396 + } else {
397 + Assert.fail("test case failed");
398 + log.debug("not equal");
399 + }
400 + }
401 +
402 + @Test
403 + public void initiateMessageTest7() throws PcepParseException {
404 +
405 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv,
406 + * StatefulLspErrorCodeTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
407 + */
408 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x98,
409 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
410 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
411 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
412 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
413 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
414 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
415 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
416 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
417 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
418 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
419 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
420 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
421 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
422 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
423 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
424 + 0x05, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
425 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 };
426 +
427 + byte[] testInitiateCreationMsg = {0};
428 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
429 + buffer.writeBytes(initiateCreationMsg);
430 +
431 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
432 + PcepMessage message = null;
433 + try {
434 + message = reader.readFrom(buffer);
435 + } catch (PcepParseException e) {
436 + e.printStackTrace();
437 + }
438 +
439 + if (message instanceof PcepInitiateMsg) {
440 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
441 + message.writeTo(buf);
442 + testInitiateCreationMsg = buf.array();
443 +
444 + int iReadLen = buf.writerIndex() - 0;
445 + testInitiateCreationMsg = new byte[iReadLen];
446 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
447 +
448 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
449 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
450 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
451 + } else {
452 + Assert.fail("test case failed");
453 + log.debug("not equal");
454 + }
455 + } else {
456 + Assert.fail("test case failed");
457 + log.debug("not equal");
458 + }
459 + }
460 +
461 + @Test
462 + public void initiateMessageTest8() throws PcepParseException {
463 +
464 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
465 + * END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
466 + */
467 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x90,
468 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
469 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
470 + 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
471 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
472 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
473 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
474 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
475 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
476 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
477 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
478 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
479 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
480 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
481 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
482 + 0x05, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00,
483 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 };
484 +
485 + byte[] testInitiateCreationMsg = {0};
486 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
487 + buffer.writeBytes(initiateCreationMsg);
488 +
489 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
490 + PcepMessage message = null;
491 + try {
492 + message = reader.readFrom(buffer);
493 + } catch (PcepParseException e) {
494 + e.printStackTrace();
495 + }
496 +
497 + if (message instanceof PcepInitiateMsg) {
498 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
499 + message.writeTo(buf);
500 + testInitiateCreationMsg = buf.array();
501 +
502 + int iReadLen = buf.writerIndex() - 0;
503 + testInitiateCreationMsg = new byte[iReadLen];
504 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
505 +
506 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
507 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
508 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
509 + } else {
510 + Assert.fail("test case failed");
511 + log.debug("not equal");
512 + }
513 + } else {
514 + Assert.fail("test case failed");
515 + log.debug("not equal");
516 + }
517 + }
518 +
519 + @Test
520 + public void initiateMessageTest9() throws PcepParseException {
521 +
522 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
523 + * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
524 + */
525 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x84,
526 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
527 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
528 + 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03, //LSP object
529 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
530 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
531 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
532 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
533 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
534 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
535 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
536 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
537 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
538 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
539 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
540 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
541 +
542 + byte[] testInitiateCreationMsg = {0};
543 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
544 + buffer.writeBytes(initiateCreationMsg);
545 +
546 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
547 + PcepMessage message = null;
548 + try {
549 + message = reader.readFrom(buffer);
550 + } catch (PcepParseException e) {
551 + e.printStackTrace();
552 + }
553 +
554 + if (message instanceof PcepInitiateMsg) {
555 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
556 + message.writeTo(buf);
557 + testInitiateCreationMsg = buf.array();
558 +
559 + int iReadLen = buf.writerIndex() - 0;
560 + testInitiateCreationMsg = new byte[iReadLen];
561 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
562 +
563 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
564 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
565 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
566 + } else {
567 + Assert.fail("test case failed");
568 + log.debug("not equal");
569 + }
570 + } else {
571 + Assert.fail("test case failed");
572 + log.debug("not equal");
573 + }
574 + }
575 +
576 + @Test
577 + public void initiateMessageTest10() throws PcepParseException {
578 +
579 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
580 + * END-POINTS, ERO, LSPA OBJECT.
581 + */
582 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x70,
583 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
584 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
585 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
586 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
587 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
588 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
589 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
590 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
591 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
592 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
593 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
594 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
595 +
596 + byte[] testInitiateCreationMsg = {0};
597 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
598 + buffer.writeBytes(initiateCreationMsg);
599 +
600 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
601 + PcepMessage message = null;
602 + try {
603 + message = reader.readFrom(buffer);
604 + } catch (PcepParseException e) {
605 + e.printStackTrace();
606 + }
607 +
608 + if (message instanceof PcepInitiateMsg) {
609 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
610 + message.writeTo(buf);
611 + testInitiateCreationMsg = buf.array();
612 +
613 + int iReadLen = buf.writerIndex() - 0;
614 + testInitiateCreationMsg = new byte[iReadLen];
615 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
616 +
617 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
618 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
619 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
620 + } else {
621 + Assert.fail("test case failed");
622 + log.debug("not equal");
623 + }
624 + } else {
625 + Assert.fail("test case failed");
626 + log.debug("not equal");
627 + }
628 + }
629 +
630 + @Test
631 + public void initiateMessageTest11() throws PcepParseException {
632 +
633 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
634 + * END-POINTS, ERO, LSPA OBJECT.
635 + */
636 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x7C,
637 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
638 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
639 + 0x20, 0x10, 0x00, 0x30, 0x00, 0x00, 0x10, 0x03,
640 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
641 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
642 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
643 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
644 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
645 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
646 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
647 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
648 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
649 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
650 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
651 +
652 + byte[] testInitiateCreationMsg = {0};
653 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
654 + buffer.writeBytes(initiateCreationMsg);
655 +
656 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
657 + PcepMessage message = null;
658 + try {
659 + message = reader.readFrom(buffer);
660 + } catch (PcepParseException e) {
661 + e.printStackTrace();
662 + }
663 +
664 + if (message instanceof PcepInitiateMsg) {
665 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
666 + message.writeTo(buf);
667 +
668 + int iReadLen = buf.writerIndex() - 0;
669 + testInitiateCreationMsg = new byte[iReadLen];
670 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
671 +
672 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
673 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
674 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
675 + } else {
676 + Assert.fail("test case failed");
677 + log.debug("not equal");
678 + }
679 + } else {
680 + Assert.fail("test case failed");
681 + log.debug("not equal");
682 + }
683 + }
684 +
685 + @Test
686 + public void initiateMessageTest12() throws PcepParseException {
687 +
688 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
689 + * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
690 + */
691 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x78,
692 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
693 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
694 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
695 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
696 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
697 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
698 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
699 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
700 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
701 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
702 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
703 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
704 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
705 +
706 + byte[] testInitiateCreationMsg = {0};
707 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
708 + buffer.writeBytes(initiateCreationMsg);
709 +
710 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
711 + PcepMessage message = null;
712 + try {
713 + message = reader.readFrom(buffer);
714 + } catch (PcepParseException e) {
715 + e.printStackTrace();
716 + }
717 +
718 + if (message instanceof PcepInitiateMsg) {
719 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
720 + message.writeTo(buf);
721 + testInitiateCreationMsg = buf.array();
722 +
723 + int iReadLen = buf.writerIndex() - 0;
724 + testInitiateCreationMsg = new byte[iReadLen];
725 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
726 +
727 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
728 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
729 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
730 + } else {
731 + Assert.fail("test case failed");
732 + log.debug("not equal");
733 + }
734 + } else {
735 + Assert.fail("test case failed");
736 + log.debug("not equal");
737 + }
738 + }
739 +
740 + @Test
741 + public void initiateMessageTest13() throws PcepParseException {
742 +
743 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspDbVerTlv),
744 + * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
745 + */
746 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x84,
747 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
748 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
749 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03,
750 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
751 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
752 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
753 + 0x00, 0x11, 0x00, 0x04, 0x54, 0x31, 0x32, 0x33, //SymbolicPathNameTlv
754 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
755 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
756 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
757 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
758 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
759 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
760 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 };
761 +
762 + byte[] testInitiateCreationMsg = {0};
763 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
764 + buffer.writeBytes(initiateCreationMsg);
765 +
766 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
767 + PcepMessage message = null;
768 + try {
769 + message = reader.readFrom(buffer);
770 + } catch (PcepParseException e) {
771 + e.printStackTrace();
772 + }
773 +
774 + if (message instanceof PcepInitiateMsg) {
775 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
776 + message.writeTo(buf);
777 + testInitiateCreationMsg = buf.array();
778 +
779 + int iReadLen = buf.writerIndex() - 0;
780 + testInitiateCreationMsg = new byte[iReadLen];
781 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
782 +
783 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
784 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
785 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
786 + } else {
787 + Assert.fail("test case failed");
788 + log.debug("not equal");
789 + }
790 + } else {
791 + Assert.fail("test case failed");
792 + log.debug("not equal");
793 + }
794 + }
795 +
796 + @Test
797 + public void initiateMessageTest14() throws PcepParseException {
798 +
799 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
800 + * END-POINTS, ERO, LSPA, BANDWIDTH , METRIC OBJECT.
801 + */
802 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x7c,
803 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
804 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
805 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
806 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
807 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
808 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
809 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
810 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
811 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
812 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
813 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
814 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
815 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 };
816 +
817 + byte[] testInitiateCreationMsg = {0};
818 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
819 + buffer.writeBytes(initiateCreationMsg);
820 +
821 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
822 + PcepMessage message = null;
823 + try {
824 + message = reader.readFrom(buffer);
825 + } catch (PcepParseException e) {
826 + e.printStackTrace();
827 + }
828 +
829 + if (message instanceof PcepInitiateMsg) {
830 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
831 + message.writeTo(buf);
832 + testInitiateCreationMsg = buf.array();
833 +
834 + int iReadLen = buf.writerIndex() - 0;
835 + testInitiateCreationMsg = new byte[iReadLen];
836 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
837 +
838 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
839 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
840 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
841 + } else {
842 + Assert.fail("test case failed");
843 + log.debug("not equal");
844 + }
845 + } else {
846 + Assert.fail("test case failed");
847 + log.debug("not equal");
848 + }
849 + }
850 +
851 + @Test
852 + public void initiateMessageTest15() throws PcepParseException {
853 +
854 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
855 + * END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
856 + */
857 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x70,
858 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
859 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
860 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
861 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
862 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
863 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
864 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
865 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
866 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
867 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
868 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
869 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
870 +
871 + byte[] testInitiateCreationMsg = {0};
872 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
873 + buffer.writeBytes(initiateCreationMsg);
874 +
875 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
876 + PcepMessage message = null;
877 + try {
878 + message = reader.readFrom(buffer);
879 + } catch (PcepParseException e) {
880 + e.printStackTrace();
881 + }
882 +
883 + if (message instanceof PcepInitiateMsg) {
884 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
885 + message.writeTo(buf);
886 + testInitiateCreationMsg = buf.array();
887 +
888 + int iReadLen = buf.writerIndex() - 0;
889 + testInitiateCreationMsg = new byte[iReadLen];
890 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
891 +
892 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
893 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
894 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
895 + } else {
896 + Assert.fail("test case failed");
897 + log.debug("not equal");
898 + }
899 + } else {
900 + Assert.fail("test case failed");
901 + log.debug("not equal");
902 + }
903 + }
904 +
905 + @Test
906 + public void initiateMessageTest16() throws PcepParseException {
907 +
908 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv),
909 + * END-POINTS, ERO, LSPA OBJECT.
910 + */
911 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x68,
912 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
913 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
914 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
915 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
916 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
917 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
918 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
919 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
920 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
921 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
922 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
923 +
924 + byte[] testInitiateCreationMsg = {0};
925 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
926 + buffer.writeBytes(initiateCreationMsg);
927 +
928 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
929 + PcepMessage message = null;
930 + try {
931 + message = reader.readFrom(buffer);
932 + } catch (PcepParseException e) {
933 + e.printStackTrace();
934 + }
935 +
936 + if (message instanceof PcepInitiateMsg) {
937 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
938 + message.writeTo(buf);
939 + testInitiateCreationMsg = buf.array();
940 +
941 + int iReadLen = buf.writerIndex() - 0;
942 + testInitiateCreationMsg = new byte[iReadLen];
943 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
944 +
945 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
946 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
947 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
948 + } else {
949 + Assert.fail("test case failed");
950 + log.debug("not equal");
951 + }
952 + } else {
953 + Assert.fail("test case failed");
954 + log.debug("not equal");
955 + }
956 + }
957 +
958 + @Test
959 + public void initiateMessageTest17() throws PcepParseException {
960 +
961 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
962 + */
963 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x5c,
964 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
965 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
966 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
967 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
968 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
969 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
970 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
971 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
972 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
973 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
974 +
975 + byte[] testInitiateCreationMsg = {0};
976 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
977 + buffer.writeBytes(initiateCreationMsg);
978 +
979 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
980 + PcepMessage message = null;
981 + try {
982 + message = reader.readFrom(buffer);
983 + } catch (PcepParseException e) {
984 + e.printStackTrace();
985 + }
986 +
987 + if (message instanceof PcepInitiateMsg) {
988 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
989 + message.writeTo(buf);
990 + testInitiateCreationMsg = buf.array();
991 +
992 + int iReadLen = buf.writerIndex() - 0;
993 + testInitiateCreationMsg = new byte[iReadLen];
994 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
995 +
996 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
997 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
998 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
999 + } else {
1000 + Assert.fail("test case failed");
1001 + log.debug("not equal");
1002 + }
1003 + } else {
1004 + Assert.fail("test case failed");
1005 + log.debug("not equal");
1006 + }
1007 + }
1008 +
1009 + @Test
1010 + public void initiateMessageTest18() throws PcepParseException {
1011 +
1012 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
1013 + */
1014 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64,
1015 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1016 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, (byte) 0x83,
1017 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1018 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1019 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1020 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1021 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
1022 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1023 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1024 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1025 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1026 +
1027 + byte[] testInitiateCreationMsg = {0};
1028 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1029 + buffer.writeBytes(initiateCreationMsg);
1030 +
1031 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1032 + PcepMessage message = null;
1033 + try {
1034 + message = reader.readFrom(buffer);
1035 + } catch (PcepParseException e) {
1036 + e.printStackTrace();
1037 + }
1038 +
1039 + if (message instanceof PcepInitiateMsg) {
1040 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1041 + message.writeTo(buf);
1042 + testInitiateCreationMsg = buf.array();
1043 +
1044 + int iReadLen = buf.writerIndex() - 0;
1045 + testInitiateCreationMsg = new byte[iReadLen];
1046 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1047 +
1048 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1049 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1050 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1051 + } else {
1052 + Assert.fail("test case failed");
1053 + log.debug("not equal");
1054 + }
1055 + } else {
1056 + Assert.fail("test case failed");
1057 + log.debug("not equal");
1058 + }
1059 + }
1060 +
1061 + @Test
1062 + public void initiateMessageTest19() throws PcepParseException {
1063 +
1064 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
1065 + */
1066 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x70,
1067 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1068 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1069 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1070 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1071 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1072 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1073 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
1074 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1075 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1076 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1077 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1078 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 };
1079 +
1080 + byte[] testInitiateCreationMsg = {0};
1081 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1082 + buffer.writeBytes(initiateCreationMsg);
1083 +
1084 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1085 + PcepMessage message = null;
1086 + try {
1087 + message = reader.readFrom(buffer);
1088 + } catch (PcepParseException e) {
1089 + e.printStackTrace();
1090 + }
1091 +
1092 + if (message instanceof PcepInitiateMsg) {
1093 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1094 + message.writeTo(buf);
1095 + testInitiateCreationMsg = buf.array();
1096 +
1097 + int iReadLen = buf.writerIndex() - 0;
1098 + testInitiateCreationMsg = new byte[iReadLen];
1099 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1100 +
1101 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1102 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1103 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1104 + } else {
1105 + Assert.fail("test case failed");
1106 + log.debug("not equal");
1107 + }
1108 + } else {
1109 + Assert.fail("test case failed");
1110 + log.debug("not equal");
1111 + }
1112 + }
1113 +
1114 + @Test
1115 + public void initiateMessageTest20() throws PcepParseException {
1116 +
1117 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
1118 + */
1119 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x60,
1120 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1121 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1122 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1123 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1124 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1125 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1126 + 0x07, 0x10, 0x00, 0x04, //ERO object
1127 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1128 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1129 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1130 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 };
1131 +
1132 + byte[] testInitiateCreationMsg = {0};
1133 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1134 + buffer.writeBytes(initiateCreationMsg);
1135 +
1136 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1137 + PcepMessage message = null;
1138 + try {
1139 + message = reader.readFrom(buffer);
1140 + } catch (PcepParseException e) {
1141 + e.printStackTrace();
1142 + }
1143 +
1144 + if (message instanceof PcepInitiateMsg) {
1145 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1146 + message.writeTo(buf);
1147 + testInitiateCreationMsg = buf.array();
1148 +
1149 + int iReadLen = buf.writerIndex() - 0;
1150 + testInitiateCreationMsg = new byte[iReadLen];
1151 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1152 +
1153 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1154 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1155 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1156 + } else {
1157 + Assert.fail("test case failed");
1158 + log.debug("not equal");
1159 + }
1160 + } else {
1161 + Assert.fail("test case failed");
1162 + log.debug("not equal");
1163 + }
1164 + }
1165 +
1166 + @Test
1167 + public void initiateMessageTest21() throws PcepParseException {
1168 +
1169 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
1170 + */
1171 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x54,
1172 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1173 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1174 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1175 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1176 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1177 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1178 + 0x07, 0x10, 0x00, 0x04,
1179 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1180 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1181 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1182 +
1183 + byte[] testInitiateCreationMsg = {0};
1184 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1185 + buffer.writeBytes(initiateCreationMsg);
1186 +
1187 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1188 + PcepMessage message = null;
1189 + try {
1190 + message = reader.readFrom(buffer);
1191 + } catch (PcepParseException e) {
1192 + e.printStackTrace();
1193 + }
1194 +
1195 + if (message instanceof PcepInitiateMsg) {
1196 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1197 + message.writeTo(buf);
1198 + testInitiateCreationMsg = buf.array();
1199 +
1200 + int iReadLen = buf.writerIndex() - 0;
1201 + testInitiateCreationMsg = new byte[iReadLen];
1202 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1203 +
1204 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1205 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1206 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1207 + } else {
1208 + Assert.fail("test case failed");
1209 + log.debug("not equal");
1210 + }
1211 + } else {
1212 + Assert.fail("test case failed");
1213 + log.debug("not equal");
1214 + }
1215 + }
1216 +
1217 + @Test
1218 + public void initiateMessageTest22() throws PcepParseException {
1219 +
1220 + /* SRP, LSP (StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
1221 + */
1222 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x4c,
1223 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1224 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1225 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1226 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1227 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1228 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1229 + 0x07, 0x10, 0x00, 0x04, //ERO object
1230 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1231 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1232 +
1233 + byte[] testInitiateCreationMsg = {0};
1234 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1235 + buffer.writeBytes(initiateCreationMsg);
1236 +
1237 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1238 + PcepMessage message = null;
1239 + try {
1240 + message = reader.readFrom(buffer);
1241 + } catch (PcepParseException e) {
1242 + e.printStackTrace();
1243 + }
1244 +
1245 + if (message instanceof PcepInitiateMsg) {
1246 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1247 + message.writeTo(buf);
1248 + testInitiateCreationMsg = buf.array();
1249 +
1250 + int iReadLen = buf.writerIndex() - 0;
1251 + testInitiateCreationMsg = new byte[iReadLen];
1252 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1253 +
1254 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1255 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1256 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1257 + } else {
1258 + Assert.fail("test case failed");
1259 + log.debug("not equal");
1260 + }
1261 + } else {
1262 + Assert.fail("test case failed");
1263 + log.debug("not equal");
1264 + }
1265 + }
1266 +
1267 + @Test
1268 + public void initiateMessageTest23() throws PcepParseException {
1269 +
1270 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA OBJECT.
1271 + */
1272 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x54,
1273 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1274 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1275 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1276 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1277 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1278 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1279 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1280 + 0x07, 0x10, 0x00, 0x04, //ERO object
1281 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1282 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1283 +
1284 + byte[] testInitiateCreationMsg = {0};
1285 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1286 + buffer.writeBytes(initiateCreationMsg);
1287 +
1288 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1289 + PcepMessage message = null;
1290 + try {
1291 + message = reader.readFrom(buffer);
1292 + } catch (PcepParseException e) {
1293 + e.printStackTrace();
1294 + }
1295 +
1296 + if (message instanceof PcepInitiateMsg) {
1297 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1298 + message.writeTo(buf);
1299 + testInitiateCreationMsg = buf.array();
1300 +
1301 + int iReadLen = buf.writerIndex() - 0;
1302 + testInitiateCreationMsg = new byte[iReadLen];
1303 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1304 +
1305 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1306 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1307 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1308 + } else {
1309 + Assert.fail("test case failed");
1310 + log.debug("not equal");
1311 + }
1312 + } else {
1313 + Assert.fail("test case failed");
1314 + log.debug("not equal");
1315 + }
1316 + }
1317 +
1318 + @Test
1319 + public void initiateMessageTest25() throws PcepParseException {
1320 +
1321 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS, ERO, LSPA BANDWIDTH OBJECT.
1322 + */
1323 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x5c,
1324 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1325 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1326 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1327 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1328 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1329 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1330 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1331 + 0x07, 0x10, 0x00, 0x04, //ERO object
1332 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1333 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1334 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1335 +
1336 + byte[] testInitiateCreationMsg = {0};
1337 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1338 + buffer.writeBytes(initiateCreationMsg);
1339 +
1340 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1341 + PcepMessage message = null;
1342 + try {
1343 + message = reader.readFrom(buffer);
1344 + } catch (PcepParseException e) {
1345 + e.printStackTrace();
1346 + }
1347 +
1348 + if (message instanceof PcepInitiateMsg) {
1349 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1350 + message.writeTo(buf);
1351 + testInitiateCreationMsg = buf.array();
1352 +
1353 + int iReadLen = buf.writerIndex() - 0;
1354 + testInitiateCreationMsg = new byte[iReadLen];
1355 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1356 +
1357 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1358 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1359 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1360 + } else {
1361 + Assert.fail("test case failed");
1362 + log.debug("not equal");
1363 + }
1364 + } else {
1365 + Assert.fail("test case failed");
1366 + log.debug("not equal");
1367 + }
1368 + }
1369 +
1370 + @Test
1371 + public void initiateMessageTest26() throws PcepParseException {
1372 +
1373 + /* SRP, LSP (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), END-POINTS,
1374 + * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
1375 + */
1376 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x68,
1377 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1378 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1379 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x03, //LSP object
1380 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1381 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1382 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1383 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1384 + 0x07, 0x10, 0x00, 0x04, //ERO object
1385 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1386 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1387 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1388 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
1389 +
1390 + byte[] testInitiateCreationMsg = {0};
1391 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1392 + buffer.writeBytes(initiateCreationMsg);
1393 +
1394 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1395 + PcepMessage message = null;
1396 + try {
1397 + message = reader.readFrom(buffer);
1398 + } catch (PcepParseException e) {
1399 + e.printStackTrace();
1400 + }
1401 +
1402 + if (message instanceof PcepInitiateMsg) {
1403 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1404 + message.writeTo(buf);
1405 + testInitiateCreationMsg = buf.array();
1406 +
1407 + int iReadLen = buf.writerIndex() - 0;
1408 + testInitiateCreationMsg = new byte[iReadLen];
1409 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1410 +
1411 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1412 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1413 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1414 + } else {
1415 + Assert.fail("test case failed");
1416 + log.debug("not equal");
1417 + }
1418 + } else {
1419 + Assert.fail("test case failed");
1420 + log.debug("not equal");
1421 + }
1422 + }
1423 +
1424 + @Test
1425 + public void initiateMessageTest27() throws PcepParseException {
1426 +
1427 + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH, METRIC OBJECT.
1428 + */
1429 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x54,
1430 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1431 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1432 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1433 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1434 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1435 + 0x07, 0x10, 0x00, 0x04, //ERO object
1436 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1437 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1438 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1439 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
1440 +
1441 + byte[] testInitiateCreationMsg = {0};
1442 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1443 + buffer.writeBytes(initiateCreationMsg);
1444 +
1445 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1446 + PcepMessage message = null;
1447 + try {
1448 + message = reader.readFrom(buffer);
1449 + } catch (PcepParseException e) {
1450 + e.printStackTrace();
1451 + }
1452 +
1453 + if (message instanceof PcepInitiateMsg) {
1454 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1455 + message.writeTo(buf);
1456 + testInitiateCreationMsg = buf.array();
1457 +
1458 + int iReadLen = buf.writerIndex() - 0;
1459 + testInitiateCreationMsg = new byte[iReadLen];
1460 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1461 +
1462 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1463 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1464 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1465 + } else {
1466 + Assert.fail("test case failed");
1467 + log.debug("not equal");
1468 + }
1469 + } else {
1470 + Assert.fail("test case failed");
1471 + log.debug("not equal");
1472 + }
1473 + }
1474 +
1475 + @Test
1476 + public void initiateMessageTest28() throws PcepParseException {
1477 +
1478 + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA, BANDWIDTH OBJECT.
1479 + */
1480 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x48,
1481 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1482 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1483 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1484 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1485 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1486 + 0x07, 0x10, 0x00, 0x04, //ERO object
1487 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1488 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1489 + 0x05, 0x20, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1490 +
1491 + byte[] testInitiateCreationMsg = {0};
1492 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1493 + buffer.writeBytes(initiateCreationMsg);
1494 +
1495 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1496 + PcepMessage message = null;
1497 + try {
1498 + message = reader.readFrom(buffer);
1499 + } catch (PcepParseException e) {
1500 + e.printStackTrace();
1501 + }
1502 +
1503 + if (message instanceof PcepInitiateMsg) {
1504 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1505 + message.writeTo(buf);
1506 + testInitiateCreationMsg = buf.array();
1507 +
1508 + int iReadLen = buf.writerIndex() - 0;
1509 + testInitiateCreationMsg = new byte[iReadLen];
1510 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1511 +
1512 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1513 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1514 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1515 + } else {
1516 + Assert.fail("test case failed");
1517 + log.debug("not equal");
1518 + }
1519 + } else {
1520 + Assert.fail("test case failed");
1521 + log.debug("not equal");
1522 + }
1523 + }
1524 +
1525 + @Test
1526 + public void initiateMessageTest29() throws PcepParseException {
1527 +
1528 + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
1529 + */
1530 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x40,
1531 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1532 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1533 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1534 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1535 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1536 + 0x07, 0x10, 0x00, 0x04, //ERO object
1537 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1538 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1539 +
1540 + byte[] testInitiateCreationMsg = {0};
1541 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1542 + buffer.writeBytes(initiateCreationMsg);
1543 +
1544 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1545 + PcepMessage message = null;
1546 + try {
1547 + message = reader.readFrom(buffer);
1548 + } catch (PcepParseException e) {
1549 + e.printStackTrace();
1550 + }
1551 +
1552 + if (message instanceof PcepInitiateMsg) {
1553 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1554 + message.writeTo(buf);
1555 + testInitiateCreationMsg = buf.array();
1556 +
1557 + int iReadLen = buf.writerIndex() - 0;
1558 + testInitiateCreationMsg = new byte[iReadLen];
1559 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1560 +
1561 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1562 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1563 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1564 + } else {
1565 + Assert.fail("test case failed");
1566 + log.debug("not equal");
1567 + }
1568 + } else {
1569 + Assert.fail("test case failed");
1570 + log.debug("not equal");
1571 + }
1572 + }
1573 +
1574 + @Test
1575 + public void initiateMessageTest30() throws PcepParseException {
1576 +
1577 + /* SRP, LSP (SymbolicPathNameTlv, SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
1578 + */
1579 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x50,
1580 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1581 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1582 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1583 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1584 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1585 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
1586 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1587 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1588 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1589 +
1590 + byte[] testInitiateCreationMsg = {0};
1591 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1592 + buffer.writeBytes(initiateCreationMsg);
1593 +
1594 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1595 + PcepMessage message = null;
1596 + try {
1597 + message = reader.readFrom(buffer);
1598 + } catch (PcepParseException e) {
1599 + e.printStackTrace();
1600 + }
1601 +
1602 + if (message instanceof PcepInitiateMsg) {
1603 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1604 + message.writeTo(buf);
1605 + testInitiateCreationMsg = buf.array();
1606 +
1607 + int iReadLen = buf.writerIndex() - 0;
1608 + testInitiateCreationMsg = new byte[iReadLen];
1609 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1610 +
1611 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1612 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1613 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1614 + } else {
1615 + Assert.fail("test case failed");
1616 + log.debug("not equal");
1617 + }
1618 + } else {
1619 + Assert.fail("test case failed");
1620 + log.debug("not equal");
1621 + }
1622 + }
1623 +
1624 + @Test
1625 + public void initiateMessageTest31() throws PcepParseException {
1626 +
1627 + /* SRP, LSP (SymbolicPathNameTlv), END-POINTS, ERO, LSPA OBJECT.
1628 + */
1629 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x48,
1630 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1631 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1632 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1633 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1634 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
1635 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1636 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1637 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1638 +
1639 + byte[] testInitiateCreationMsg = {0};
1640 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1641 + buffer.writeBytes(initiateCreationMsg);
1642 +
1643 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1644 + PcepMessage message = null;
1645 + try {
1646 + message = reader.readFrom(buffer);
1647 + } catch (PcepParseException e) {
1648 + e.printStackTrace();
1649 + }
1650 +
1651 + if (message instanceof PcepInitiateMsg) {
1652 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1653 + message.writeTo(buf);
1654 + testInitiateCreationMsg = buf.array();
1655 +
1656 + int iReadLen = buf.writerIndex() - 0;
1657 + testInitiateCreationMsg = new byte[iReadLen];
1658 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1659 +
1660 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1661 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1662 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1663 + } else {
1664 + Assert.fail("test case failed");
1665 + log.debug("not equal");
1666 + }
1667 + } else {
1668 + Assert.fail("test case failed");
1669 + log.debug("not equal");
1670 + }
1671 + }
1672 +
1673 + @Test
1674 + public void initiateMessageTest32() throws PcepParseException {
1675 +
1676 + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
1677 + * ERO, LSPA, BANDWIDTH, METRIC OBJECT.
1678 + */
1679 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x64,
1680 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1681 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1682 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1683 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1684 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1685 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1686 + 0x07, 0x10, 0x00, 0x04, //ERO object
1687 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1688 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1689 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1690 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
1691 +
1692 + byte[] testInitiateCreationMsg = {0};
1693 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1694 + buffer.writeBytes(initiateCreationMsg);
1695 +
1696 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1697 + PcepMessage message = null;
1698 + try {
1699 + message = reader.readFrom(buffer);
1700 + } catch (PcepParseException e) {
1701 + e.printStackTrace();
1702 + }
1703 +
1704 + if (message instanceof PcepInitiateMsg) {
1705 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1706 + message.writeTo(buf);
1707 + testInitiateCreationMsg = buf.array();
1708 +
1709 + int iReadLen = buf.writerIndex() - 0;
1710 + testInitiateCreationMsg = new byte[iReadLen];
1711 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1712 +
1713 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1714 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1715 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1716 + } else {
1717 + Assert.fail("test case failed");
1718 + log.debug("not equal");
1719 + }
1720 + } else {
1721 + Assert.fail("test case failed");
1722 + log.debug("not equal");
1723 + }
1724 + }
1725 +
1726 + @Test
1727 + public void initiateMessageTest33() throws PcepParseException {
1728 +
1729 + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
1730 + * ERO, LSPA, BANDWIDTH OBJECT.
1731 + */
1732 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x58,
1733 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1734 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1735 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1736 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1737 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1738 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1739 + 0x07, 0x10, 0x00, 0x04, //ERO object
1740 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1741 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1742 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1743 +
1744 + byte[] testInitiateCreationMsg = {0};
1745 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1746 + buffer.writeBytes(initiateCreationMsg);
1747 +
1748 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1749 + PcepMessage message = null;
1750 + try {
1751 + message = reader.readFrom(buffer);
1752 + } catch (PcepParseException e) {
1753 + e.printStackTrace();
1754 + }
1755 +
1756 + if (message instanceof PcepInitiateMsg) {
1757 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1758 + message.writeTo(buf);
1759 + testInitiateCreationMsg = buf.array();
1760 +
1761 + int iReadLen = buf.writerIndex() - 0;
1762 + testInitiateCreationMsg = new byte[iReadLen];
1763 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1764 +
1765 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1766 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1767 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1768 + } else {
1769 + Assert.fail("test case failed");
1770 + log.debug("not equal");
1771 + }
1772 + } else {
1773 + Assert.fail("test case failed");
1774 + log.debug("not equal");
1775 + }
1776 + }
1777 +
1778 + @Test
1779 + public void initiateMessageTest34() throws PcepParseException {
1780 +
1781 + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
1782 + * ERO, LSPA OBJECT.
1783 + */
1784 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x50,
1785 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1786 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1787 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1788 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1789 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1790 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1791 + 0x07, 0x10, 0x00, 0x04, //ERO object
1792 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1793 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1794 +
1795 + byte[] testInitiateCreationMsg = {0};
1796 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1797 + buffer.writeBytes(initiateCreationMsg);
1798 +
1799 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1800 + PcepMessage message = null;
1801 + try {
1802 + message = reader.readFrom(buffer);
1803 + } catch (PcepParseException e) {
1804 + e.printStackTrace();
1805 + }
1806 +
1807 + if (message instanceof PcepInitiateMsg) {
1808 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1809 + message.writeTo(buf);
1810 + testInitiateCreationMsg = buf.array();
1811 +
1812 + int iReadLen = buf.writerIndex() - 0;
1813 + testInitiateCreationMsg = new byte[iReadLen];
1814 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1815 +
1816 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1817 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1818 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1819 + } else {
1820 + Assert.fail("test case failed");
1821 + log.debug("not equal");
1822 + }
1823 + } else {
1824 + Assert.fail("test case failed");
1825 + log.debug("not equal");
1826 + }
1827 + }
1828 +
1829 + @Test
1830 + public void initiateMessageTest35() throws PcepParseException {
1831 +
1832 + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
1833 + * ERO, LSPA OBJECT.
1834 + */
1835 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x60,
1836 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1837 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1838 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1839 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1840 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1841 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1842 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
1843 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1844 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1845 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1846 +
1847 + byte[] testInitiateCreationMsg = {0};
1848 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1849 + buffer.writeBytes(initiateCreationMsg);
1850 +
1851 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1852 + PcepMessage message = null;
1853 + try {
1854 + message = reader.readFrom(buffer);
1855 + } catch (PcepParseException e) {
1856 + e.printStackTrace();
1857 + }
1858 +
1859 + if (message instanceof PcepInitiateMsg) {
1860 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1861 + message.writeTo(buf);
1862 + testInitiateCreationMsg = buf.array();
1863 +
1864 + int iReadLen = buf.writerIndex() - 0;
1865 + testInitiateCreationMsg = new byte[iReadLen];
1866 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1867 +
1868 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1869 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1870 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1871 + } else {
1872 + Assert.fail("test case failed");
1873 + log.debug("not equal");
1874 + }
1875 + } else {
1876 + Assert.fail("test case failed");
1877 + log.debug("not equal");
1878 + }
1879 + }
1880 +
1881 + @Test
1882 + public void initiateMessageTest36() throws PcepParseException {
1883 +
1884 + /* SRP, LSP ( StatefulLspDbVerTlv), END-POINTS,
1885 + * ERO, LSPA OBJECT.
1886 + */
1887 + byte[] initiateCreationMsg = new byte[] {0x20, 0x0C, 0x00, (byte) 0x58,
1888 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1889 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1890 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1891 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1892 + 0x04, 0x12, 0x00, 0x0C, 0x01, 0x01, 0x01, 0x01, 0x02, 0x02, 0x02, 0x02, //Endpoints Object
1893 + 0x07, 0x10, 0x00, 0x14, (byte) 0x01, 0x08, 0x0C, 0x01, //ERO object
1894 + 0x01, 0x01, 0x00, 0x00, (byte) 0x01, 0x08, 0x0C, 0x01, 0x01, 0x02, 0x00, 0x00,
1895 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1896 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1897 +
1898 + byte[] testInitiateCreationMsg = {0};
1899 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1900 + buffer.writeBytes(initiateCreationMsg);
1901 +
1902 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1903 + PcepMessage message = null;
1904 + try {
1905 + message = reader.readFrom(buffer);
1906 + } catch (PcepParseException e) {
1907 + e.printStackTrace();
1908 + }
1909 +
1910 + if (message instanceof PcepInitiateMsg) {
1911 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1912 + message.writeTo(buf);
1913 + testInitiateCreationMsg = buf.array();
1914 +
1915 + int iReadLen = buf.writerIndex() - 0;
1916 + testInitiateCreationMsg = new byte[iReadLen];
1917 + buf.readBytes(testInitiateCreationMsg, 0, iReadLen);
1918 +
1919 + if (Arrays.equals(initiateCreationMsg, testInitiateCreationMsg)) {
1920 + Assert.assertArrayEquals(initiateCreationMsg, testInitiateCreationMsg);
1921 + log.debug("PCInitiate Msg are equal :" + initiateCreationMsg);
1922 + } else {
1923 + Assert.fail("test case failed");
1924 + log.debug("not equal");
1925 + }
1926 + } else {
1927 + Assert.fail("test case failed");
1928 + log.debug("not equal");
1929 + }
1930 + }
1931 +}
1932 +
1 +/*
2 + * Copyright 2014-2015 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.pcepio;
17 +
18 +import java.util.Arrays;
19 +
20 +import org.jboss.netty.buffer.ChannelBuffer;
21 +import org.jboss.netty.buffer.ChannelBuffers;
22 +import org.junit.After;
23 +import org.junit.Assert;
24 +import org.junit.Before;
25 +import org.junit.Test;
26 +import org.onosproject.pcepio.exceptions.PcepParseException;
27 +import org.onosproject.pcepio.protocol.PcepFactories;
28 +import org.onosproject.pcepio.protocol.PcepKeepaliveMsg;
29 +import org.onosproject.pcepio.protocol.PcepMessage;
30 +import org.onosproject.pcepio.protocol.PcepMessageReader;
31 +import org.slf4j.Logger;
32 +import org.slf4j.LoggerFactory;
33 +
34 +public class PcepKeepaliveMsgTest {
35 +
36 + protected static final Logger log = LoggerFactory.getLogger(PcepKeepaliveMsgTest.class);
37 +
38 + @Before
39 + public void startUp() {
40 +
41 + }
42 +
43 + @After
44 + public void tearDown() {
45 +
46 + }
47 +
48 + @Test
49 + public void keepaliveMessageTest1() throws PcepParseException {
50 +
51 + byte[] keepaliveMsg = new byte[] {0x20, 0x02, 0x00, 0x04 };
52 +
53 + byte[] testKeepaliveMsg = {0};
54 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
55 + buffer.writeBytes(keepaliveMsg);
56 +
57 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
58 + PcepMessage message = null;
59 + try {
60 + message = reader.readFrom(buffer);
61 + } catch (PcepParseException e) {
62 + e.printStackTrace();
63 + }
64 +
65 + if (message instanceof PcepKeepaliveMsg) {
66 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
67 + message.writeTo(buf);
68 + testKeepaliveMsg = buf.array();
69 +
70 + int iReadLen = buf.writerIndex() - 0;
71 + testKeepaliveMsg = new byte[iReadLen];
72 + buf.readBytes(testKeepaliveMsg, 0, iReadLen);
73 +
74 + if (Arrays.equals(keepaliveMsg, testKeepaliveMsg)) {
75 + Assert.assertArrayEquals(keepaliveMsg, testKeepaliveMsg);
76 + log.debug("keepaliveMsg are equal :" + keepaliveMsg);
77 + } else {
78 + Assert.fail("test case failed");
79 + log.debug("not equal");
80 + }
81 + } else {
82 + Assert.fail("test case failed");
83 + log.debug("not equal");
84 + }
85 + }
86 +}
1 +/*
2 + * Copyright 2014-2015 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.pcepio;
17 +
18 +import org.jboss.netty.buffer.ChannelBuffer;
19 +import org.jboss.netty.buffer.ChannelBuffers;
20 +import org.junit.After;
21 +import org.junit.Assert;
22 +import org.junit.Before;
23 +import org.junit.Test;
24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 +import org.onosproject.pcepio.protocol.PcepFactories;
26 +import org.onosproject.pcepio.protocol.PcepMessage;
27 +import org.onosproject.pcepio.protocol.PcepMessageReader;
28 +import org.onosproject.pcepio.protocol.PcepUpdateMsg;
29 +
30 +import java.util.Arrays;
31 +
32 +import org.slf4j.Logger;
33 +import org.slf4j.LoggerFactory;
34 +
35 +public class PcepUpdateMsgTest {
36 +
37 + protected static final Logger log = LoggerFactory.getLogger(PcepUpdateMsgTest.class);
38 +
39 + @Before
40 + public void startUp() {
41 + }
42 +
43 + @After
44 + public void tearDown() {
45 +
46 + }
47 +
48 + @Test
49 + public void pcepUpdateMsgTest1() throws PcepParseException {
50 + //Srp, Lsp (StatefulIPv4LspIdentidiersTlv), Ero.
51 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x30,
52 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
53 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
54 + 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
55 + 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
56 + 0x07, 0x10, 0x00, 0x04 }; //ERO object
57 +
58 + byte[] testupdateMsg = {0};
59 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
60 + buffer.writeBytes(updateMsg);
61 +
62 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
63 + PcepMessage message = null;
64 + try {
65 + message = reader.readFrom(buffer);
66 + } catch (PcepParseException e) {
67 + e.printStackTrace();
68 + }
69 +
70 + if (message instanceof PcepUpdateMsg) {
71 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
72 + message.writeTo(buf);
73 + testupdateMsg = buf.array();
74 +
75 + int iReadLen = buf.writerIndex() - 0;
76 + testupdateMsg = new byte[iReadLen];
77 + buf.readBytes(testupdateMsg, 0, iReadLen);
78 +
79 + if (Arrays.equals(updateMsg, testupdateMsg)) {
80 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
81 + log.debug("updateMsg are equal :" + updateMsg);
82 + } else {
83 + Assert.fail("test case failed");
84 + log.debug("not equal");
85 + }
86 + } else {
87 + Assert.fail("test case failed");
88 + log.debug("not equal");
89 + }
90 +
91 + }
92 +
93 + @Test
94 + public void pcepUpdateMsgTest2() throws PcepParseException {
95 +
96 + /* Srp(SymbolicPathNameTlv), Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
97 + * StatefulLspErrorCodeTlv), Ero, Lspa, Metric-list.
98 + */
99 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x94,
100 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
101 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
102 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object // lsp object
103 + 0x00, 0x12, 0x00, 0x10, (byte) 0xb6, 0x02, 0x4e, 0x1f, //StatefulIPv4LspIdentidiersTlv
104 + 0x00, 0x01, (byte) 0x80, 0x01, (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
105 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
106 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
107 + 0x07, 0x10, 0x00, 0x24, 0x01, 0x08, 0x11, 0x01, //ERO object
108 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
109 + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
110 + 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00,
111 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
112 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
113 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01,
114 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
115 +
116 + byte[] testupdateMsg = {0};
117 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
118 + buffer.writeBytes(updateMsg);
119 +
120 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
121 + PcepMessage message = null;
122 + try {
123 + message = reader.readFrom(buffer);
124 + } catch (PcepParseException e) {
125 + e.printStackTrace();
126 + }
127 +
128 + if (message instanceof PcepUpdateMsg) {
129 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
130 + message.writeTo(buf);
131 + testupdateMsg = buf.array();
132 +
133 + int iReadLen = buf.writerIndex() - 0;
134 + testupdateMsg = new byte[iReadLen];
135 + buf.readBytes(testupdateMsg, 0, iReadLen);
136 +
137 + if (Arrays.equals(updateMsg, testupdateMsg)) {
138 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
139 + log.debug("updateMsg are equal :" + updateMsg);
140 + } else {
141 + Assert.fail("test case failed");
142 + log.debug("not equal");
143 + }
144 + } else {
145 + Assert.fail("test case failed");
146 + log.debug("not equal");
147 + }
148 +
149 + }
150 +
151 +
152 + @Test
153 + public void pcepUpdateMsgTest3() throws PcepParseException {
154 +
155 + // Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv), Ero
156 +
157 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x38,
158 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
159 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
160 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
161 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
162 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
163 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
164 + 0x07, 0x10, 0x00, 0x04 }; //ERO object
165 +
166 + byte[] testupdateMsg = {0};
167 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
168 + buffer.writeBytes(updateMsg);
169 +
170 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
171 + PcepMessage message = null;
172 + try {
173 + message = reader.readFrom(buffer);
174 + } catch (PcepParseException e) {
175 + e.printStackTrace();
176 + }
177 +
178 + if (message instanceof PcepUpdateMsg) {
179 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
180 + message.writeTo(buf);
181 + testupdateMsg = buf.array();
182 +
183 + int iReadLen = buf.writerIndex() - 0;
184 + testupdateMsg = new byte[iReadLen];
185 + buf.readBytes(testupdateMsg, 0, iReadLen);
186 +
187 + if (Arrays.equals(updateMsg, testupdateMsg)) {
188 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
189 + log.debug("updateMsg are equal :" + updateMsg);
190 + } else {
191 + Assert.fail("test case failed");
192 + log.debug("not equal");
193 + }
194 + } else {
195 + Assert.fail("test case failed");
196 + log.debug("not equal");
197 + }
198 +
199 + }
200 +
201 + @Test
202 + public void pcepUpdateMsgTest4() throws PcepParseException {
203 +
204 + // Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv), Ero
205 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
206 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
207 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
208 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
209 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
210 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
211 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
212 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
213 + 0x07, 0x10, 0x00, 0x04 }; //ERO object
214 +
215 + byte[] testupdateMsg = {0};
216 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
217 + buffer.writeBytes(updateMsg);
218 +
219 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
220 + PcepMessage message = null;
221 + try {
222 + message = reader.readFrom(buffer);
223 + } catch (PcepParseException e) {
224 + e.printStackTrace();
225 + }
226 +
227 + if (message instanceof PcepUpdateMsg) {
228 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
229 + message.writeTo(buf);
230 + testupdateMsg = buf.array();
231 +
232 + int iReadLen = buf.writerIndex() - 0;
233 + testupdateMsg = new byte[iReadLen];
234 + buf.readBytes(testupdateMsg, 0, iReadLen);
235 +
236 + if (Arrays.equals(updateMsg, testupdateMsg)) {
237 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
238 + log.debug("updateMsg are equal :" + updateMsg);
239 + } else {
240 + Assert.fail("test case failed");
241 + log.debug("not equal");
242 + }
243 + } else {
244 + Assert.fail("test case failed");
245 + log.debug("not equal");
246 + }
247 +
248 + }
249 +
250 + @Test
251 + public void pcepUpdateMsgTest5() throws PcepParseException {
252 +
253 + /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
254 + * Ero
255 + */
256 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
257 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
258 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
259 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
260 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
261 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
262 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
263 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
264 + 0x07, 0x10, 0x00, 0x04 }; //ERO object
265 +
266 + byte[] testupdateMsg = {0};
267 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
268 + buffer.writeBytes(updateMsg);
269 +
270 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
271 + PcepMessage message = null;
272 + try {
273 + message = reader.readFrom(buffer);
274 + } catch (PcepParseException e) {
275 + e.printStackTrace();
276 + }
277 +
278 + if (message instanceof PcepUpdateMsg) {
279 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
280 + message.writeTo(buf);
281 + testupdateMsg = buf.array();
282 +
283 + int iReadLen = buf.writerIndex() - 0;
284 + testupdateMsg = new byte[iReadLen];
285 + buf.readBytes(testupdateMsg, 0, iReadLen);
286 +
287 + if (Arrays.equals(updateMsg, testupdateMsg)) {
288 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
289 + log.debug("updateMsg are equal :" + updateMsg);
290 + } else {
291 + Assert.fail("test case failed");
292 + log.debug("not equal");
293 + }
294 + } else {
295 + Assert.fail("test case failed");
296 + log.debug("not equal");
297 + }
298 +
299 + }
300 +
301 + @Test
302 + public void pcepUpdateMsgTest6() throws PcepParseException {
303 +
304 + /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
305 + * StatefulLspErrorCodeTlv), Ero
306 + */
307 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
308 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
309 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
310 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
311 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
312 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
313 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
314 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
315 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
316 + 0x07, 0x10, 0x00, 0x04 };
317 +
318 + byte[] testupdateMsg = {0};
319 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
320 + buffer.writeBytes(updateMsg);
321 +
322 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
323 + PcepMessage message = null;
324 + try {
325 + message = reader.readFrom(buffer);
326 + } catch (PcepParseException e) {
327 + e.printStackTrace();
328 + }
329 +
330 + if (message instanceof PcepUpdateMsg) {
331 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
332 + message.writeTo(buf);
333 + testupdateMsg = buf.array();
334 +
335 + int iReadLen = buf.writerIndex() - 0;
336 + testupdateMsg = new byte[iReadLen];
337 + buf.readBytes(testupdateMsg, 0, iReadLen);
338 +
339 + if (Arrays.equals(updateMsg, testupdateMsg)) {
340 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
341 + log.debug("updateMsg are equal :" + updateMsg);
342 + } else {
343 + Assert.fail("test case failed");
344 + log.debug("not equal");
345 + }
346 + } else {
347 + Assert.fail("test case failed");
348 + log.debug("not equal");
349 + }
350 +
351 + }
352 +
353 + @Test
354 + public void pcepUpdateMsgTest7() throws PcepParseException {
355 +
356 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
357 + * StatefulLspErrorCodeTlv), Ero
358 + */
359 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
360 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
361 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
362 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
363 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
364 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
365 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
366 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
367 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
368 + 0x07, 0x10, 0x00, 0x04}; //ERO object
369 +
370 + byte[] testupdateMsg = {0};
371 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
372 + buffer.writeBytes(updateMsg);
373 +
374 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
375 + PcepMessage message = null;
376 + try {
377 + message = reader.readFrom(buffer);
378 + } catch (PcepParseException e) {
379 + e.printStackTrace();
380 + }
381 +
382 + if (message instanceof PcepUpdateMsg) {
383 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
384 + message.writeTo(buf);
385 + testupdateMsg = buf.array();
386 +
387 + int iReadLen = buf.writerIndex() - 0;
388 + testupdateMsg = new byte[iReadLen];
389 + buf.readBytes(testupdateMsg, 0, iReadLen);
390 +
391 + if (Arrays.equals(updateMsg, testupdateMsg)) {
392 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
393 + log.debug("updateMsg are equal :" + updateMsg);
394 + } else {
395 + Assert.fail("test case failed");
396 + log.debug("not equal");
397 + }
398 + } else {
399 + Assert.fail("test case failed");
400 + log.debug("not equal");
401 + }
402 + }
403 +
404 + @Test
405 + public void pcepUpdateMsgTest8() throws PcepParseException {
406 +
407 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
408 + * StatefulLspErrorCodeTlv), Ero (IPv4SubObject)
409 + */
410 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
411 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
412 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
413 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
414 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
415 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
416 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
417 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
418 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
419 + 0x07, 0x10, 0x00, 0x0c, 0x01, 0x08, 0x11, 0x01, //ERO object
420 + 0x01, 0x01, 0x04, 0x00 };
421 +
422 + byte[] testupdateMsg = {0};
423 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
424 + buffer.writeBytes(updateMsg);
425 +
426 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
427 + PcepMessage message = null;
428 + try {
429 + message = reader.readFrom(buffer);
430 + } catch (PcepParseException e) {
431 + e.printStackTrace();
432 + }
433 +
434 + if (message instanceof PcepUpdateMsg) {
435 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
436 + message.writeTo(buf);
437 + testupdateMsg = buf.array();
438 +
439 + int iReadLen = buf.writerIndex() - 0;
440 + testupdateMsg = new byte[iReadLen];
441 + buf.readBytes(testupdateMsg, 0, iReadLen);
442 +
443 + if (Arrays.equals(updateMsg, testupdateMsg)) {
444 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
445 + log.debug("updateMsg are equal :" + updateMsg);
446 + } else {
447 + Assert.fail("test case failed");
448 + log.debug("not equal");
449 + }
450 + } else {
451 + Assert.fail("test case failed");
452 + log.debug("not equal");
453 + }
454 + }
455 +
456 + @Test
457 + public void pcepUpdateMsgTest9() throws PcepParseException {
458 +
459 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
460 + * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject)
461 + */
462 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
463 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
464 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
465 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
466 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
467 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
468 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
469 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
470 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
471 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
472 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
473 + 0x01, 0x01, 0x04, 0x00 };
474 +
475 + byte[] testupdateMsg = {0};
476 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
477 + buffer.writeBytes(updateMsg);
478 +
479 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
480 + PcepMessage message = null;
481 + try {
482 + message = reader.readFrom(buffer);
483 + } catch (PcepParseException e) {
484 + e.printStackTrace();
485 + }
486 +
487 + if (message instanceof PcepUpdateMsg) {
488 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
489 + message.writeTo(buf);
490 + testupdateMsg = buf.array();
491 +
492 + int iReadLen = buf.writerIndex() - 0;
493 + testupdateMsg = new byte[iReadLen];
494 + buf.readBytes(testupdateMsg, 0, iReadLen);
495 +
496 + if (Arrays.equals(updateMsg, testupdateMsg)) {
497 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
498 + log.debug("updateMsg are equal :" + updateMsg);
499 + } else {
500 + Assert.fail("test case failed");
501 + log.debug("not equal");
502 + }
503 + } else {
504 + Assert.fail("test case failed");
505 + log.debug("not equal");
506 + }
507 + }
508 +
509 + @Test
510 + public void pcepUpdateMsgTest10() throws PcepParseException {
511 +
512 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
513 + * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject), Lspa
514 + */
515 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x6c,
516 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
517 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
518 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
519 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
520 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
521 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
522 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
523 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
524 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
525 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
526 + 0x01, 0x01, 0x04, 0x00,
527 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
528 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
529 +
530 + byte[] testupdateMsg = {0};
531 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
532 + buffer.writeBytes(updateMsg);
533 +
534 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
535 + PcepMessage message = null;
536 + try {
537 + message = reader.readFrom(buffer);
538 + } catch (PcepParseException e) {
539 + e.printStackTrace();
540 + }
541 +
542 + if (message instanceof PcepUpdateMsg) {
543 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
544 + message.writeTo(buf);
545 + testupdateMsg = buf.array();
546 +
547 + int iReadLen = buf.writerIndex() - 0;
548 + testupdateMsg = new byte[iReadLen];
549 + buf.readBytes(testupdateMsg, 0, iReadLen);
550 +
551 + if (Arrays.equals(updateMsg, testupdateMsg)) {
552 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
553 + log.debug("updateMsg are equal :" + updateMsg);
554 + } else {
555 + Assert.fail("test case failed");
556 + log.debug("not equal");
557 + }
558 + } else {
559 + Assert.fail("test case failed");
560 + log.debug("not equal");
561 + }
562 + }
563 +
564 + @Test
565 + public void pcepUpdateMsgTest11() throws PcepParseException {
566 +
567 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
568 + * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject),Lspa, Metric Object
569 + */
570 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
571 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
572 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
573 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
574 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
575 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
576 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
577 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
578 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
579 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
580 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
581 + 0x01, 0x01, 0x04, 0x00,
582 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
583 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
584 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
585 +
586 + byte[] testupdateMsg = {0};
587 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
588 + buffer.writeBytes(updateMsg);
589 +
590 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
591 + PcepMessage message = null;
592 + try {
593 + message = reader.readFrom(buffer);
594 + } catch (PcepParseException e) {
595 + e.printStackTrace();
596 + }
597 +
598 + if (message instanceof PcepUpdateMsg) {
599 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
600 + message.writeTo(buf);
601 + testupdateMsg = buf.array();
602 +
603 + int iReadLen = buf.writerIndex() - 0;
604 + testupdateMsg = new byte[iReadLen];
605 + buf.readBytes(testupdateMsg, 0, iReadLen);
606 +
607 + if (Arrays.equals(updateMsg, testupdateMsg)) {
608 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
609 + log.debug("updateMsg are equal :" + updateMsg);
610 + } else {
611 + Assert.fail("test case failed");
612 + log.debug("not equal");
613 + }
614 + } else {
615 + Assert.fail("test case failed");
616 + log.debug("not equal");
617 + }
618 + }
619 +
620 + @Test
621 + public void pcepUpdateMsgTest12() throws PcepParseException {
622 +
623 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
624 + * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
625 + */
626 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
627 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
628 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
629 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
630 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
631 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
632 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
633 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
634 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
635 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
636 + 0x01, 0x01, 0x04, 0x00,
637 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
638 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
639 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
640 +
641 + byte[] testupdateMsg = {0};
642 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
643 + buffer.writeBytes(updateMsg);
644 +
645 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
646 + PcepMessage message = null;
647 + try {
648 + message = reader.readFrom(buffer);
649 + } catch (PcepParseException e) {
650 + e.printStackTrace();
651 + }
652 +
653 + if (message instanceof PcepUpdateMsg) {
654 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
655 + message.writeTo(buf);
656 + testupdateMsg = buf.array();
657 +
658 + int iReadLen = buf.writerIndex() - 0;
659 + testupdateMsg = new byte[iReadLen];
660 + buf.readBytes(testupdateMsg, 0, iReadLen);
661 +
662 + if (Arrays.equals(updateMsg, testupdateMsg)) {
663 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
664 + log.debug("updateMsg are equal :" + updateMsg);
665 + } else {
666 + Assert.fail("test case failed");
667 + log.debug("not equal");
668 + }
669 + } else {
670 + Assert.fail("test case failed");
671 + log.debug("not equal");
672 + }
673 + }
674 +
675 + @Test
676 + public void pcepUpdateMsgTest13() throws PcepParseException {
677 +
678 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
679 + * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
680 + */
681 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
682 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
683 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
684 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
685 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
686 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
687 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
688 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
689 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
690 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
691 + 0x01, 0x01, 0x04, 0x00,
692 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
693 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
694 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
695 +
696 + byte[] testupdateMsg = {0};
697 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
698 + buffer.writeBytes(updateMsg);
699 +
700 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
701 + PcepMessage message = null;
702 + try {
703 + message = reader.readFrom(buffer);
704 + } catch (PcepParseException e) {
705 + e.printStackTrace();
706 + }
707 +
708 + if (message instanceof PcepUpdateMsg) {
709 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
710 + message.writeTo(buf);
711 + testupdateMsg = buf.array();
712 +
713 + int iReadLen = buf.writerIndex() - 0;
714 + testupdateMsg = new byte[iReadLen];
715 + buf.readBytes(testupdateMsg, 0, iReadLen);
716 +
717 + if (Arrays.equals(updateMsg, testupdateMsg)) {
718 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
719 + log.debug("updateMsg are equal :" + updateMsg);
720 + } else {
721 + Assert.fail("test case failed");
722 + log.debug("not equal");
723 + }
724 + } else {
725 + Assert.fail("test case failed");
726 + log.debug("not equal");
727 + }
728 + }
729 +
730 + @Test
731 + public void pcepUpdateMsgTest14() throws PcepParseException {
732 +
733 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
734 + * Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
735 + */
736 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
737 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
738 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
739 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
740 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
741 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
742 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
743 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
744 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
745 + 0x01, 0x01, 0x04, 0x00,
746 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
747 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
748 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
749 +
750 + byte[] testupdateMsg = {0};
751 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
752 + buffer.writeBytes(updateMsg);
753 +
754 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
755 + PcepMessage message = null;
756 + try {
757 + message = reader.readFrom(buffer);
758 + } catch (PcepParseException e) {
759 + e.printStackTrace();
760 + }
761 +
762 + if (message instanceof PcepUpdateMsg) {
763 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
764 + message.writeTo(buf);
765 + testupdateMsg = buf.array();
766 +
767 + int iReadLen = buf.writerIndex() - 0;
768 + testupdateMsg = new byte[iReadLen];
769 + buf.readBytes(testupdateMsg, 0, iReadLen);
770 +
771 + if (Arrays.equals(updateMsg, testupdateMsg)) {
772 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
773 + log.debug("updateMsg are equal :" + updateMsg);
774 + } else {
775 + Assert.fail("test case failed");
776 + log.debug("not equal");
777 + }
778 + } else {
779 + Assert.fail("test case failed");
780 + log.debug("not equal");
781 + }
782 + }
783 +
784 + @Test
785 + public void pcepUpdateMsgTest15() throws PcepParseException {
786 +
787 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv),
788 + * Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
789 + */
790 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
791 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
792 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
793 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
794 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
795 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
796 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
797 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
798 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
799 + 0x01, 0x01, 0x04, 0x00,
800 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
801 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
802 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
803 +
804 + byte[] testupdateMsg = {0};
805 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
806 + buffer.writeBytes(updateMsg);
807 +
808 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
809 + PcepMessage message = null;
810 + try {
811 + message = reader.readFrom(buffer);
812 + } catch (PcepParseException e) {
813 + e.printStackTrace();
814 + }
815 +
816 + if (message instanceof PcepUpdateMsg) {
817 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
818 + message.writeTo(buf);
819 + testupdateMsg = buf.array();
820 +
821 + int iReadLen = buf.writerIndex() - 0;
822 + testupdateMsg = new byte[iReadLen];
823 + buf.readBytes(testupdateMsg, 0, iReadLen);
824 +
825 + if (Arrays.equals(updateMsg, testupdateMsg)) {
826 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
827 + log.debug("updateMsg are equal :" + updateMsg);
828 + } else {
829 + Assert.fail("test case failed");
830 + log.debug("not equal");
831 + }
832 + } else {
833 + Assert.fail("test case failed");
834 + log.debug("not equal");
835 + }
836 + }
837 +
838 + @Test
839 + public void pcepUpdateMsgTest16() throws PcepParseException {
840 +
841 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
842 + * Ero (IPv4SubObject, IPv4SubObject),Lspa, metric Object
843 + */
844 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
845 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
846 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
847 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
848 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
849 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
850 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
851 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
852 + 0x01, 0x01, 0x04, 0x00,
853 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
854 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
855 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
856 +
857 + byte[] testupdateMsg = {0};
858 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
859 + buffer.writeBytes(updateMsg);
860 +
861 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
862 + PcepMessage message = null;
863 + try {
864 + message = reader.readFrom(buffer);
865 + } catch (PcepParseException e) {
866 + e.printStackTrace();
867 + }
868 +
869 + if (message instanceof PcepUpdateMsg) {
870 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
871 + message.writeTo(buf);
872 + testupdateMsg = buf.array();
873 +
874 + int iReadLen = buf.writerIndex() - 0;
875 + testupdateMsg = new byte[iReadLen];
876 + buf.readBytes(testupdateMsg, 0, iReadLen);
877 +
878 + if (Arrays.equals(updateMsg, testupdateMsg)) {
879 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
880 + log.debug("updateMsg are equal :" + updateMsg);
881 + } else {
882 + Assert.fail("test case failed");
883 + log.debug("not equal");
884 + }
885 + } else {
886 + Assert.fail("test case failed");
887 + log.debug("not equal");
888 + }
889 + }
890 +
891 + @Test
892 + public void pcepUpdateMsgTest17() throws PcepParseException {
893 +
894 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
895 + * Ero (IPv4SubObject, IPv4SubObject),Lspa
896 + */
897 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
898 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
899 + 0x20, 0x10, 0x00, 0x1c, 0x00, 0x00, 0x10, 0x05, //LSP object
900 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
901 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
902 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
903 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
904 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
905 + 0x01, 0x01, 0x04, 0x00,
906 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
907 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
908 +
909 + byte[] testupdateMsg = {0};
910 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
911 + buffer.writeBytes(updateMsg);
912 +
913 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
914 + PcepMessage message = null;
915 + try {
916 + message = reader.readFrom(buffer);
917 + } catch (PcepParseException e) {
918 + e.printStackTrace();
919 + }
920 +
921 + if (message instanceof PcepUpdateMsg) {
922 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
923 + message.writeTo(buf);
924 + testupdateMsg = buf.array();
925 +
926 + int iReadLen = buf.writerIndex() - 0;
927 + testupdateMsg = new byte[iReadLen];
928 + buf.readBytes(testupdateMsg, 0, iReadLen);
929 +
930 + if (Arrays.equals(updateMsg, testupdateMsg)) {
931 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
932 + log.debug("updateMsg are equal :" + updateMsg);
933 + } else {
934 + Assert.fail("test case failed");
935 + log.debug("not equal");
936 + }
937 + } else {
938 + Assert.fail("test case failed");
939 + log.debug("not equal");
940 + }
941 + }
942 +
943 + @Test
944 + public void pcepUpdateMsgTest18() throws PcepParseException {
945 +
946 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
947 + * Ero (IPv4SubObject, IPv4SubObject),Metric Object
948 + */
949 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
950 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
951 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
952 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
953 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
954 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
955 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
956 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
957 + 0x01, 0x01, 0x04, 0x00,
958 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
959 +
960 + byte[] testupdateMsg = {0};
961 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
962 + buffer.writeBytes(updateMsg);
963 +
964 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
965 + PcepMessage message = null;
966 + try {
967 + message = reader.readFrom(buffer);
968 + } catch (PcepParseException e) {
969 + e.printStackTrace();
970 + }
971 +
972 + if (message instanceof PcepUpdateMsg) {
973 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
974 + message.writeTo(buf);
975 + testupdateMsg = buf.array();
976 +
977 + int iReadLen = buf.writerIndex() - 0;
978 + testupdateMsg = new byte[iReadLen];
979 + buf.readBytes(testupdateMsg, 0, iReadLen);
980 +
981 + if (Arrays.equals(updateMsg, testupdateMsg)) {
982 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
983 + log.debug("updateMsg are equal :" + updateMsg);
984 + } else {
985 + Assert.fail("test case failed");
986 + log.debug("not equal");
987 + }
988 + } else {
989 + Assert.fail("test case failed");
990 + log.debug("not equal");
991 + }
992 + }
993 +
994 + @Test
995 + public void pcepUpdateMsgTest19() throws PcepParseException {
996 +
997 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
998 + * Ero (IPv4SubObject, IPv4SubObject),Metric-list
999 + */
1000 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
1001 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1002 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
1003 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1004 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1005 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1006 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1007 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1008 + 0x01, 0x01, 0x04, 0x00,
1009 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
1010 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01 }; //Metric object
1011 +
1012 + byte[] testupdateMsg = {0};
1013 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1014 + buffer.writeBytes(updateMsg);
1015 +
1016 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1017 + PcepMessage message = null;
1018 + try {
1019 + message = reader.readFrom(buffer);
1020 + } catch (PcepParseException e) {
1021 + e.printStackTrace();
1022 + }
1023 +
1024 + if (message instanceof PcepUpdateMsg) {
1025 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1026 + message.writeTo(buf);
1027 + testupdateMsg = buf.array();
1028 +
1029 + int iReadLen = buf.writerIndex() - 0;
1030 + testupdateMsg = new byte[iReadLen];
1031 + buf.readBytes(testupdateMsg, 0, iReadLen);
1032 +
1033 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1034 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1035 + log.debug("updateMsg are equal :" + updateMsg);
1036 + } else {
1037 + Assert.fail("test case failed");
1038 + log.debug("not equal");
1039 + }
1040 + } else {
1041 + Assert.fail("test case failed");
1042 + log.debug("not equal");
1043 + }
1044 + }
1045 +
1046 + @Test
1047 + public void pcepUpdateMsgTest20() throws PcepParseException {
1048 +
1049 + /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
1050 + * StatefulLspErrorCodeTlv),Ero (IPv4SubObject, IPv4SubObject),Lspa, Bandwidth, Metric Object
1051 + */
1052 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
1053 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1054 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1055 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
1056 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1057 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1058 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1059 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1060 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1061 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1062 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1063 + 0x01, 0x01, 0x04, 0x00,
1064 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1065 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1066 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1067 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1068 +
1069 + byte[] testupdateMsg = {0};
1070 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1071 + buffer.writeBytes(updateMsg);
1072 +
1073 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1074 + PcepMessage message = null;
1075 + try {
1076 + message = reader.readFrom(buffer);
1077 + } catch (PcepParseException e) {
1078 + e.printStackTrace();
1079 + }
1080 +
1081 + if (message instanceof PcepUpdateMsg) {
1082 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1083 + message.writeTo(buf);
1084 + testupdateMsg = buf.array();
1085 +
1086 + int iReadLen = buf.writerIndex() - 0;
1087 + testupdateMsg = new byte[iReadLen];
1088 + buf.readBytes(testupdateMsg, 0, iReadLen);
1089 +
1090 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1091 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1092 + log.debug("updateMsg are equal :" + updateMsg);
1093 + } else {
1094 + Assert.fail("test case failed");
1095 + log.debug("not equal");
1096 + }
1097 + } else {
1098 + Assert.fail("test case failed");
1099 + log.debug("not equal");
1100 + }
1101 + }
1102 +
1103 + @Test
1104 + public void pcepUpdateMsgTest21() throws PcepParseException {
1105 +
1106 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1107 + * Ero (IPv4SubObject, IPv4SubObject), Bandwidth
1108 + */
1109 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
1110 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1111 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
1112 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1113 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1114 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1115 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1116 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1117 + 0x01, 0x01, 0x04, 0x00,
1118 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1119 +
1120 + byte[] testupdateMsg = {0};
1121 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1122 + buffer.writeBytes(updateMsg);
1123 +
1124 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1125 + PcepMessage message = null;
1126 + try {
1127 + message = reader.readFrom(buffer);
1128 + } catch (PcepParseException e) {
1129 + e.printStackTrace();
1130 + }
1131 +
1132 + if (message instanceof PcepUpdateMsg) {
1133 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1134 + message.writeTo(buf);
1135 + testupdateMsg = buf.array();
1136 +
1137 + int iReadLen = buf.writerIndex() - 0;
1138 + testupdateMsg = new byte[iReadLen];
1139 + buf.readBytes(testupdateMsg, 0, iReadLen);
1140 +
1141 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1142 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1143 + log.debug("updateMsg are equal :" + updateMsg);
1144 + } else {
1145 + Assert.fail("test case failed");
1146 + log.debug("not equal");
1147 + }
1148 + } else {
1149 + Assert.fail("test case failed");
1150 + log.debug("not equal");
1151 + }
1152 + }
1153 +
1154 + @Test
1155 + public void pcepUpdateMsgTest22() throws PcepParseException {
1156 +
1157 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1158 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth
1159 + */
1160 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5C,
1161 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1162 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
1163 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1164 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1165 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1166 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1167 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1168 + 0x01, 0x01, 0x04, 0x00,
1169 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1170 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1171 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1172 +
1173 + byte[] testupdateMsg = {0};
1174 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1175 + buffer.writeBytes(updateMsg);
1176 +
1177 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1178 + PcepMessage message = null;
1179 + try {
1180 + message = reader.readFrom(buffer);
1181 + } catch (PcepParseException e) {
1182 + e.printStackTrace();
1183 + }
1184 +
1185 + if (message instanceof PcepUpdateMsg) {
1186 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1187 + message.writeTo(buf);
1188 + testupdateMsg = buf.array();
1189 +
1190 + int iReadLen = buf.writerIndex() - 0;
1191 + testupdateMsg = new byte[iReadLen];
1192 + buf.readBytes(testupdateMsg, 0, iReadLen);
1193 +
1194 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1195 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1196 + log.debug("updateMsg are equal :" + updateMsg);
1197 + } else {
1198 + Assert.fail("test case failed");
1199 + log.debug("not equal");
1200 + }
1201 + } else {
1202 + Assert.fail("test case failed");
1203 + log.debug("not equal");
1204 + }
1205 + }
1206 +
1207 + @Test
1208 + public void pcepUpdateMsgTest23() throws PcepParseException {
1209 +
1210 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1211 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1212 + */
1213 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
1214 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1215 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
1216 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1217 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1218 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1219 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1220 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1221 + 0x01, 0x01, 0x04, 0x00,
1222 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1223 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1224 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1225 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1226 +
1227 + byte[] testupdateMsg = {0};
1228 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1229 + buffer.writeBytes(updateMsg);
1230 +
1231 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1232 + PcepMessage message = null;
1233 + try {
1234 + message = reader.readFrom(buffer);
1235 + } catch (PcepParseException e) {
1236 + e.printStackTrace();
1237 + }
1238 +
1239 + if (message instanceof PcepUpdateMsg) {
1240 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1241 + message.writeTo(buf);
1242 + testupdateMsg = buf.array();
1243 +
1244 + int iReadLen = buf.writerIndex() - 0;
1245 + testupdateMsg = new byte[iReadLen];
1246 + buf.readBytes(testupdateMsg, 0, iReadLen);
1247 +
1248 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1249 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1250 + log.debug("updateMsg are equal :" + updateMsg);
1251 + } else {
1252 + Assert.fail("test case failed");
1253 + log.debug("not equal");
1254 + }
1255 + } else {
1256 + Assert.fail("test case failed");
1257 + log.debug("not equal");
1258 + }
1259 + }
1260 +
1261 + @Test
1262 + public void pcepUpdateMsgTest24() throws PcepParseException {
1263 +
1264 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
1265 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1266 + */
1267 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
1268 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1269 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
1270 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1271 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1272 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1273 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1274 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1275 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1276 + 0x01, 0x01, 0x04, 0x00,
1277 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1278 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1279 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1280 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1281 +
1282 + byte[] testupdateMsg = {0};
1283 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1284 + buffer.writeBytes(updateMsg);
1285 +
1286 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1287 + PcepMessage message = null;
1288 + try {
1289 + message = reader.readFrom(buffer);
1290 + } catch (PcepParseException e) {
1291 + e.printStackTrace();
1292 + }
1293 +
1294 + if (message instanceof PcepUpdateMsg) {
1295 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1296 + message.writeTo(buf);
1297 + testupdateMsg = buf.array();
1298 +
1299 + int iReadLen = buf.writerIndex() - 0;
1300 + testupdateMsg = new byte[iReadLen];
1301 + buf.readBytes(testupdateMsg, 0, iReadLen);
1302 +
1303 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1304 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1305 + log.debug("updateMsg are equal :" + updateMsg);
1306 + } else {
1307 + Assert.fail("test case failed");
1308 + log.debug("not equal");
1309 + }
1310 + } else {
1311 + Assert.fail("test case failed");
1312 + log.debug("not equal");
1313 + }
1314 + }
1315 +
1316 + @Test
1317 + public void pcepUpdateMsgTest25() throws PcepParseException {
1318 +
1319 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv)
1320 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1321 + */
1322 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x70,
1323 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1324 + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object
1325 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1326 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1327 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1328 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1329 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1330 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1331 + 0x01, 0x01, 0x04, 0x00,
1332 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1333 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1334 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1335 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1336 +
1337 + byte[] testupdateMsg = {0};
1338 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1339 + buffer.writeBytes(updateMsg);
1340 +
1341 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1342 + PcepMessage message = null;
1343 + try {
1344 + message = reader.readFrom(buffer);
1345 + } catch (PcepParseException e) {
1346 + e.printStackTrace();
1347 + }
1348 +
1349 + if (message instanceof PcepUpdateMsg) {
1350 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1351 + message.writeTo(buf);
1352 + testupdateMsg = buf.array();
1353 +
1354 + int iReadLen = buf.writerIndex() - 0;
1355 + testupdateMsg = new byte[iReadLen];
1356 + buf.readBytes(testupdateMsg, 0, iReadLen);
1357 +
1358 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1359 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1360 + log.debug("updateMsg are equal :" + updateMsg);
1361 + } else {
1362 + Assert.fail("test case failed");
1363 + log.debug("not equal");
1364 + }
1365 + } else {
1366 + Assert.fail("test case failed");
1367 + log.debug("not equal");
1368 + }
1369 + }
1370 +
1371 + @Test
1372 + public void pcepUpdateMsgTest26() throws PcepParseException {
1373 +
1374 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspErrorCodeTlv)
1375 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1376 + */
1377 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
1378 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1379 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
1380 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1381 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1382 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1383 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1384 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1385 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1386 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1387 + 0x01, 0x01, 0x04, 0x00,
1388 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1389 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1390 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1391 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1392 +
1393 + byte[] testupdateMsg = {0};
1394 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1395 + buffer.writeBytes(updateMsg);
1396 +
1397 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1398 + PcepMessage message = null;
1399 + try {
1400 + message = reader.readFrom(buffer);
1401 + } catch (PcepParseException e) {
1402 + e.printStackTrace();
1403 + }
1404 +
1405 + if (message instanceof PcepUpdateMsg) {
1406 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1407 + message.writeTo(buf);
1408 + testupdateMsg = buf.array();
1409 +
1410 + int iReadLen = buf.writerIndex() - 0;
1411 + testupdateMsg = new byte[iReadLen];
1412 + buf.readBytes(testupdateMsg, 0, iReadLen);
1413 +
1414 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1415 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1416 + log.debug("updateMsg are equal :" + updateMsg);
1417 + } else {
1418 + Assert.fail("test case failed");
1419 + log.debug("not equal");
1420 + }
1421 + } else {
1422 + Assert.fail("test case failed");
1423 + log.debug("not equal");
1424 + }
1425 + }
1426 +
1427 + @Test
1428 + public void pcepUpdateMsgTest27() throws PcepParseException {
1429 +
1430 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv, StatefulLspErrorCodeTlv)
1431 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1432 + */
1433 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x78,
1434 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1435 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
1436 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1437 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1438 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1439 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1440 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1441 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1442 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1443 + 0x01, 0x01, 0x04, 0x00,
1444 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1445 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1446 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1447 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1448 +
1449 + byte[] testupdateMsg = {0};
1450 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1451 + buffer.writeBytes(updateMsg);
1452 +
1453 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1454 + PcepMessage message = null;
1455 + try {
1456 + message = reader.readFrom(buffer);
1457 + } catch (PcepParseException e) {
1458 + e.printStackTrace();
1459 + }
1460 +
1461 + if (message instanceof PcepUpdateMsg) {
1462 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1463 + message.writeTo(buf);
1464 + testupdateMsg = buf.array();
1465 +
1466 + int iReadLen = buf.writerIndex() - 0;
1467 + testupdateMsg = new byte[iReadLen];
1468 + buf.readBytes(testupdateMsg, 0, iReadLen);
1469 +
1470 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1471 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1472 + log.debug("updateMsg are equal :" + updateMsg);
1473 + } else {
1474 + Assert.fail("test case failed");
1475 + log.debug("not equal");
1476 + }
1477 + } else {
1478 + Assert.fail("test case failed");
1479 + log.debug("not equal");
1480 + }
1481 + }
1482 +
1483 + @Test
1484 + public void pcepUpdateMsgTest28() throws PcepParseException {
1485 +
1486 + /* Srp, Lsp (SymbolicPathNameTlv, StatefulIPv4LspIdentidiersTlv, SymbolicPathNameTlv,
1487 + * StatefulLspErrorCodeTlv), Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1488 + */
1489 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x80,
1490 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1491 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1492 + 0x20, 0x10, 0x00, 0x2c, 0x00, 0x00, 0x10, 0x03, //LSP object
1493 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1494 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1495 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1496 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1497 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1498 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1499 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1500 + 0x01, 0x01, 0x04, 0x00,
1501 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1502 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1503 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1504 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1505 +
1506 + byte[] testupdateMsg = {0};
1507 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1508 + buffer.writeBytes(updateMsg);
1509 +
1510 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1511 + PcepMessage message = null;
1512 + try {
1513 + message = reader.readFrom(buffer);
1514 + } catch (PcepParseException e) {
1515 + e.printStackTrace();
1516 + }
1517 +
1518 + if (message instanceof PcepUpdateMsg) {
1519 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1520 + message.writeTo(buf);
1521 + testupdateMsg = buf.array();
1522 +
1523 + int iReadLen = buf.writerIndex() - 0;
1524 + testupdateMsg = new byte[iReadLen];
1525 + buf.readBytes(testupdateMsg, 0, iReadLen);
1526 +
1527 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1528 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1529 + log.debug("updateMsg are equal :" + updateMsg);
1530 + } else {
1531 + Assert.fail("test case failed");
1532 + log.debug("not equal");
1533 + }
1534 + } else {
1535 + Assert.fail("test case failed");
1536 + log.debug("not equal");
1537 + }
1538 + }
1539 +
1540 + @Test
1541 + public void pcepUpdateMsgTest29() throws PcepParseException {
1542 +
1543 + /* Srp, Lsp (StatefulIPv4LspIdentidiersTlv),
1544 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1545 + */
1546 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
1547 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1548 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
1549 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1550 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1551 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1552 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1553 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1554 + 0x01, 0x01, 0x04, 0x00,
1555 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1556 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1557 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1558 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1559 +
1560 + byte[] testupdateMsg = {0};
1561 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1562 + buffer.writeBytes(updateMsg);
1563 +
1564 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1565 + PcepMessage message = null;
1566 + try {
1567 + message = reader.readFrom(buffer);
1568 + } catch (PcepParseException e) {
1569 + e.printStackTrace();
1570 + }
1571 +
1572 + if (message instanceof PcepUpdateMsg) {
1573 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1574 + message.writeTo(buf);
1575 + testupdateMsg = buf.array();
1576 +
1577 + int iReadLen = buf.writerIndex() - 0;
1578 + testupdateMsg = new byte[iReadLen];
1579 + buf.readBytes(testupdateMsg, 0, iReadLen);
1580 +
1581 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1582 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1583 + log.debug("updateMsg are equal :" + updateMsg);
1584 + } else {
1585 + Assert.fail("test case failed");
1586 + log.debug("not equal");
1587 + }
1588 + } else {
1589 + Assert.fail("test case failed");
1590 + log.debug("not equal");
1591 + }
1592 + }
1593 +
1594 + @Test
1595 + public void pcepUpdateMsgTest30() throws PcepParseException {
1596 +
1597 + /* Srp, Lsp ,
1598 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1599 + */
1600 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1601 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1602 + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
1603 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1604 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1605 + 0x01, 0x01, 0x04, 0x00,
1606 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1607 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1608 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1609 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20}; //Metric object
1610 +
1611 + byte[] testupdateMsg = {0};
1612 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1613 + buffer.writeBytes(updateMsg);
1614 +
1615 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1616 + PcepMessage message = null;
1617 + try {
1618 + message = reader.readFrom(buffer);
1619 + } catch (PcepParseException e) {
1620 + e.printStackTrace();
1621 + }
1622 +
1623 + if (message instanceof PcepUpdateMsg) {
1624 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1625 + message.writeTo(buf);
1626 + testupdateMsg = buf.array();
1627 +
1628 + int iReadLen = buf.writerIndex() - 0;
1629 + testupdateMsg = new byte[iReadLen];
1630 + buf.readBytes(testupdateMsg, 0, iReadLen);
1631 +
1632 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1633 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1634 + log.debug("updateMsg are equal :" + updateMsg);
1635 + } else {
1636 + Assert.fail("test case failed");
1637 + log.debug("not equal");
1638 + }
1639 + } else {
1640 + Assert.fail("test case failed");
1641 + log.debug("not equal");
1642 + }
1643 + }
1644 +
1645 + @Test
1646 + public void pcepUpdateMsgTest31() throws PcepParseException {
1647 +
1648 + /* Srp, Lsp (StatefulLspErrorCodeTlv),
1649 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1650 + */
1651 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
1652 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1653 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1654 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1655 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1656 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1657 + 0x01, 0x01, 0x04, 0x00,
1658 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1659 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1660 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1661 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1662 +
1663 + byte[] testupdateMsg = {0};
1664 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1665 + buffer.writeBytes(updateMsg);
1666 +
1667 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1668 + PcepMessage message = null;
1669 + try {
1670 + message = reader.readFrom(buffer);
1671 + } catch (PcepParseException e) {
1672 + e.printStackTrace();
1673 + }
1674 +
1675 + if (message instanceof PcepUpdateMsg) {
1676 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1677 + message.writeTo(buf);
1678 + testupdateMsg = buf.array();
1679 +
1680 + int iReadLen = buf.writerIndex() - 0;
1681 + testupdateMsg = new byte[iReadLen];
1682 + buf.readBytes(testupdateMsg, 0, iReadLen);
1683 +
1684 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1685 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1686 + log.debug("updateMsg are equal :" + updateMsg);
1687 + } else {
1688 + Assert.fail("test case failed");
1689 + log.debug("not equal");
1690 + }
1691 + } else {
1692 + Assert.fail("test case failed");
1693 + log.debug("not equal");
1694 + }
1695 + }
1696 +
1697 + @Test
1698 + public void pcepUpdateMsgTest32() throws PcepParseException {
1699 +
1700 + /* Srp, Lsp,
1701 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1702 + */
1703 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1704 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1705 + 0x20, 0x10, 0x00, 0x8, 0x00, 0x00, 0x10, 0x03, //LSP object
1706 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1707 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1708 + 0x01, 0x01, 0x04, 0x00,
1709 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1710 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1711 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1712 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1713 +
1714 + byte[] testupdateMsg = {0};
1715 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1716 + buffer.writeBytes(updateMsg);
1717 +
1718 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1719 + PcepMessage message = null;
1720 + try {
1721 + message = reader.readFrom(buffer);
1722 + } catch (PcepParseException e) {
1723 + e.printStackTrace();
1724 + }
1725 +
1726 + if (message instanceof PcepUpdateMsg) {
1727 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1728 + message.writeTo(buf);
1729 + testupdateMsg = buf.array();
1730 +
1731 + int iReadLen = buf.writerIndex() - 0;
1732 + testupdateMsg = new byte[iReadLen];
1733 + buf.readBytes(testupdateMsg, 0, iReadLen);
1734 +
1735 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1736 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1737 + log.debug("updateMsg are equal :" + updateMsg);
1738 + } else {
1739 + Assert.fail("test case failed");
1740 + log.debug("not equal");
1741 + }
1742 + } else {
1743 + Assert.fail("test case failed");
1744 + log.debug("not equal");
1745 + }
1746 + }
1747 +
1748 + @Test
1749 + public void pcepUpdateMsgTest33() throws PcepParseException {
1750 +
1751 + /* Srp, Lsp (SymbolicPathNameTlv),
1752 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1753 + */
1754 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
1755 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1756 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1757 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1758 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1759 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1760 + 0x01, 0x01, 0x04, 0x00,
1761 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1762 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1763 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1764 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1765 +
1766 + byte[] testupdateMsg = {0};
1767 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1768 + buffer.writeBytes(updateMsg);
1769 +
1770 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1771 + PcepMessage message = null;
1772 + try {
1773 + message = reader.readFrom(buffer);
1774 + } catch (PcepParseException e) {
1775 + e.printStackTrace();
1776 + }
1777 +
1778 + if (message instanceof PcepUpdateMsg) {
1779 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1780 + message.writeTo(buf);
1781 + testupdateMsg = buf.array();
1782 +
1783 + int iReadLen = buf.writerIndex() - 0;
1784 + testupdateMsg = new byte[iReadLen];
1785 + buf.readBytes(testupdateMsg, 0, iReadLen);
1786 +
1787 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1788 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1789 + log.debug("updateMsg are equal :" + updateMsg);
1790 + } else {
1791 + Assert.fail("test case failed");
1792 + log.debug("not equal");
1793 + }
1794 + } else {
1795 + Assert.fail("test case failed");
1796 + log.debug("not equal");
1797 + }
1798 + }
1799 +
1800 + @Test
1801 + public void pcepUpdateMsgTest34() throws PcepParseException {
1802 +
1803 + /* Srp, Lsp (SymbolicPathNameTlv, SymbolicPathNameTlv),
1804 + * Ero (IPv4SubObject, IPv4SubObject), Lspa, Bandwidth, Metric Object
1805 + */
1806 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
1807 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1808 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1809 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1810 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1811 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO object
1812 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1813 + 0x01, 0x01, 0x04, 0x00,
1814 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1815 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
1816 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1817 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1818 +
1819 + byte[] testupdateMsg = {0};
1820 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1821 + buffer.writeBytes(updateMsg);
1822 +
1823 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1824 + PcepMessage message = null;
1825 + try {
1826 + message = reader.readFrom(buffer);
1827 + } catch (PcepParseException e) {
1828 + e.printStackTrace();
1829 + }
1830 +
1831 + if (message instanceof PcepUpdateMsg) {
1832 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1833 + message.writeTo(buf);
1834 + testupdateMsg = buf.array();
1835 +
1836 + int iReadLen = buf.writerIndex() - 0;
1837 + testupdateMsg = new byte[iReadLen];
1838 + buf.readBytes(testupdateMsg, 0, iReadLen);
1839 +
1840 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1841 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1842 + log.debug("updateMsg are equal :" + updateMsg);
1843 + } else {
1844 + Assert.fail("test case failed");
1845 + log.debug("not equal");
1846 + }
1847 + } else {
1848 + Assert.fail("test case failed");
1849 + log.debug("not equal");
1850 + }
1851 + }
1852 +}
1 +/*
2 + * Copyright 2014-2015 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.pcepio;
17 +
18 +import org.jboss.netty.buffer.ChannelBuffer;
19 +import org.jboss.netty.buffer.ChannelBuffers;
20 +import org.junit.After;
21 +import org.junit.Assert;
22 +import org.junit.Before;
23 +import org.junit.Test;
24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 +import org.onosproject.pcepio.protocol.PcepFactories;
26 +import org.onosproject.pcepio.protocol.PcepMessage;
27 +import org.onosproject.pcepio.protocol.PcepMessageReader;
28 +import org.onosproject.pcepio.protocol.PcepUpdateMsg;
29 +
30 +import java.util.Arrays;
31 +
32 +import org.slf4j.Logger;
33 +import org.slf4j.LoggerFactory;
34 +
35 +/**
36 + * Test cases for PCEP update message.
37 + */
38 +public class PcepUpdateMsgTest2 {
39 +
40 + protected static final Logger log = LoggerFactory.getLogger(PcepUpdateMsgTest2.class);
41 +
42 + @Before
43 + public void startUp() {
44 + }
45 +
46 + @After
47 + public void tearDown() {
48 +
49 + }
50 +
51 + @Test
52 + public void pcepUpdateMsgTest1() throws PcepParseException {
53 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x8c,
54 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
55 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
56 + 0x20, 0x10, 0x00, 0x38, 0x00, 0x00, 0x10, 0x03, //LSP object
57 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
58 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
59 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
60 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
61 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
62 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
63 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
64 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
65 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
66 + 0x01, 0x01, 0x04, 0x00,
67 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
68 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
69 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
70 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object
71 +
72 + byte[] testupdateMsg = {0};
73 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
74 + buffer.writeBytes(updateMsg);
75 +
76 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
77 + PcepMessage message = null;
78 + try {
79 + message = reader.readFrom(buffer);
80 + } catch (PcepParseException e) {
81 + e.printStackTrace();
82 + }
83 +
84 + if (message instanceof PcepUpdateMsg) {
85 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
86 + message.writeTo(buf);
87 + testupdateMsg = buf.array();
88 +
89 + int iReadLen = buf.writerIndex() - 0;
90 + testupdateMsg = new byte[iReadLen];
91 + buf.readBytes(testupdateMsg, 0, iReadLen);
92 +
93 + if (Arrays.equals(updateMsg, testupdateMsg)) {
94 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
95 + log.debug("updateMsg are equal :" + updateMsg);
96 + } else {
97 + Assert.fail("test case failed");
98 + log.debug("not equal");
99 + }
100 + } else {
101 + Assert.fail("test case failed");
102 + log.debug("not equal");
103 + }
104 + }
105 +
106 + @Test
107 + public void pcepUpdateMsgTest2() throws PcepParseException {
108 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x68,
109 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
110 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
111 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
112 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
113 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
114 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
115 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
116 + 0x01, 0x01, 0x04, 0x00,
117 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSP object
118 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
119 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
120 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //metric object
121 +
122 + byte[] testupdateMsg = {0};
123 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
124 + buffer.writeBytes(updateMsg);
125 +
126 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
127 + PcepMessage message = null;
128 + try {
129 + message = reader.readFrom(buffer);
130 + } catch (PcepParseException e) {
131 + e.printStackTrace();
132 + }
133 +
134 + if (message instanceof PcepUpdateMsg) {
135 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
136 + message.writeTo(buf);
137 + testupdateMsg = buf.array();
138 +
139 + int iReadLen = buf.writerIndex() - 0;
140 + testupdateMsg = new byte[iReadLen];
141 + buf.readBytes(testupdateMsg, 0, iReadLen);
142 +
143 + if (Arrays.equals(updateMsg, testupdateMsg)) {
144 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
145 + log.debug("updateMsg are equal :" + updateMsg);
146 + } else {
147 + Assert.fail("test case failed");
148 + log.debug("not equal");
149 + }
150 + } else {
151 + Assert.fail("test case failed");
152 + log.debug("not equal");
153 + }
154 + }
155 +
156 + @Test
157 + public void pcepUpdateMsgTest3() throws PcepParseException {
158 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
159 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
160 + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
161 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
162 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
163 + 0x01, 0x01, 0x04, 0x00,
164 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
165 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
166 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
167 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
168 +
169 + byte[] testupdateMsg = {0};
170 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
171 + buffer.writeBytes(updateMsg);
172 +
173 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
174 + PcepMessage message = null;
175 + try {
176 + message = reader.readFrom(buffer);
177 + } catch (PcepParseException e) {
178 + e.printStackTrace();
179 + }
180 +
181 + if (message instanceof PcepUpdateMsg) {
182 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
183 + message.writeTo(buf);
184 + testupdateMsg = buf.array();
185 +
186 + int iReadLen = buf.writerIndex() - 0;
187 + testupdateMsg = new byte[iReadLen];
188 + buf.readBytes(testupdateMsg, 0, iReadLen);
189 +
190 + if (Arrays.equals(updateMsg, testupdateMsg)) {
191 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
192 + log.debug("updateMsg are equal :" + updateMsg);
193 + } else {
194 + Assert.fail("test case failed");
195 + log.debug("not equal");
196 + }
197 + } else {
198 + Assert.fail("test case failed");
199 + log.debug("not equal");
200 + }
201 + }
202 +
203 + @Test
204 + public void pcepUpdateMsgTest4() throws PcepParseException {
205 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
206 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
207 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
208 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
209 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
210 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
211 + 0x01, 0x01, 0x04, 0x00,
212 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
213 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
214 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
215 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
216 +
217 + byte[] testupdateMsg = {0};
218 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
219 + buffer.writeBytes(updateMsg);
220 +
221 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
222 + PcepMessage message = null;
223 + try {
224 + message = reader.readFrom(buffer);
225 + } catch (PcepParseException e) {
226 + e.printStackTrace();
227 + }
228 +
229 + if (message instanceof PcepUpdateMsg) {
230 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
231 + message.writeTo(buf);
232 + testupdateMsg = buf.array();
233 +
234 + int iReadLen = buf.writerIndex() - 0;
235 + testupdateMsg = new byte[iReadLen];
236 + buf.readBytes(testupdateMsg, 0, iReadLen);
237 +
238 + if (Arrays.equals(updateMsg, testupdateMsg)) {
239 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
240 + log.debug("updateMsg are equal :" + updateMsg);
241 + } else {
242 + Assert.fail("test case failed");
243 + log.debug("not equal");
244 + }
245 + } else {
246 + Assert.fail("test case failed");
247 + log.debug("not equal");
248 + }
249 + }
250 +
251 + @Test
252 + public void pcepUpdateMsgTest5() throws PcepParseException {
253 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
254 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
255 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
256 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
257 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
258 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
259 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
260 + 0x01, 0x01, 0x04, 0x00,
261 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
262 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
263 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
264 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
265 +
266 + byte[] testupdateMsg = {0};
267 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
268 + buffer.writeBytes(updateMsg);
269 +
270 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
271 + PcepMessage message = null;
272 + try {
273 + message = reader.readFrom(buffer);
274 + } catch (PcepParseException e) {
275 + e.printStackTrace();
276 + }
277 +
278 + if (message instanceof PcepUpdateMsg) {
279 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
280 + message.writeTo(buf);
281 + testupdateMsg = buf.array();
282 +
283 + int iReadLen = buf.writerIndex() - 0;
284 + testupdateMsg = new byte[iReadLen];
285 + buf.readBytes(testupdateMsg, 0, iReadLen);
286 +
287 + if (Arrays.equals(updateMsg, testupdateMsg)) {
288 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
289 + log.debug("updateMsg are equal :" + updateMsg);
290 + } else {
291 + Assert.fail("test case failed");
292 + log.debug("not equal");
293 + }
294 + } else {
295 + Assert.fail("test case failed");
296 + log.debug("not equal");
297 + }
298 + }
299 +
300 + @Test
301 + public void pcepUpdateMsgTest6() throws PcepParseException {
302 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
303 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
304 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
305 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
306 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
307 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
308 + 0x01, 0x01, 0x04, 0x00,
309 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
310 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
311 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
312 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
313 +
314 + byte[] testupdateMsg = {0};
315 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
316 + buffer.writeBytes(updateMsg);
317 +
318 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
319 + PcepMessage message = null;
320 + try {
321 + message = reader.readFrom(buffer);
322 + } catch (PcepParseException e) {
323 + e.printStackTrace();
324 + }
325 +
326 + if (message instanceof PcepUpdateMsg) {
327 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
328 + message.writeTo(buf);
329 + testupdateMsg = buf.array();
330 +
331 + int iReadLen = buf.writerIndex() - 0;
332 + testupdateMsg = new byte[iReadLen];
333 + buf.readBytes(testupdateMsg, 0, iReadLen);
334 +
335 + if (Arrays.equals(updateMsg, testupdateMsg)) {
336 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
337 + log.debug("updateMsg are equal :" + updateMsg);
338 + } else {
339 + Assert.fail("test case failed");
340 + log.debug("not equal");
341 + }
342 + } else {
343 + Assert.fail("test case failed");
344 + log.debug("not equal");
345 + }
346 + }
347 +
348 + @Test
349 + public void pcepUpdateMsgTest7() throws PcepParseException {
350 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
351 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
352 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
353 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
354 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
355 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
356 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
357 + 0x01, 0x01, 0x04, 0x00,
358 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
359 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
360 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
361 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
362 +
363 + byte[] testupdateMsg = {0};
364 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
365 + buffer.writeBytes(updateMsg);
366 +
367 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
368 + PcepMessage message = null;
369 + try {
370 + message = reader.readFrom(buffer);
371 + } catch (PcepParseException e) {
372 + e.printStackTrace();
373 + }
374 +
375 + if (message instanceof PcepUpdateMsg) {
376 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
377 + message.writeTo(buf);
378 + testupdateMsg = buf.array();
379 +
380 + int iReadLen = buf.writerIndex() - 0;
381 + testupdateMsg = new byte[iReadLen];
382 + buf.readBytes(testupdateMsg, 0, iReadLen);
383 +
384 + if (Arrays.equals(updateMsg, testupdateMsg)) {
385 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
386 + log.debug("updateMsg are equal :" + updateMsg);
387 + } else {
388 + Assert.fail("test case failed");
389 + log.debug("not equal");
390 + }
391 + } else {
392 + Assert.fail("test case failed");
393 + log.debug("not equal");
394 + }
395 + }
396 +
397 + @Test
398 + public void pcepUpdateMsgTest8() throws PcepParseException {
399 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
400 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
401 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
402 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
403 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
404 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
405 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
406 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
407 + 0x01, 0x01, 0x04, 0x00,
408 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
409 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
410 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
411 +
412 + byte[] testupdateMsg = {0};
413 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
414 + buffer.writeBytes(updateMsg);
415 +
416 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
417 + PcepMessage message = null;
418 + try {
419 + message = reader.readFrom(buffer);
420 + } catch (PcepParseException e) {
421 + e.printStackTrace();
422 + }
423 +
424 + if (message instanceof PcepUpdateMsg) {
425 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
426 + message.writeTo(buf);
427 + testupdateMsg = buf.array();
428 +
429 + int iReadLen = buf.writerIndex() - 0;
430 + testupdateMsg = new byte[iReadLen];
431 + buf.readBytes(testupdateMsg, 0, iReadLen);
432 +
433 + if (Arrays.equals(updateMsg, testupdateMsg)) {
434 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
435 + log.debug("updateMsg are equal :" + updateMsg);
436 + } else {
437 + Assert.fail("test case failed");
438 + log.debug("not equal");
439 + }
440 + } else {
441 + Assert.fail("test case failed");
442 + log.debug("not equal");
443 + }
444 + }
445 +
446 + @Test
447 + public void pcepUpdateMsgTest9() throws PcepParseException {
448 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
449 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
450 + 0x20, 0x10, 0x00, 0x18, 0x00, 0x00, 0x10, 0x03,
451 + 0x00, 0x15, 0x00, 0x0c, //StatefulRsvpErrorSpecTlv
452 + 0x00, 0x0c, 0x06, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x00, 0x05,
453 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
454 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
455 + 0x01, 0x01, 0x04, 0x00,
456 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
457 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
458 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
459 +
460 + byte[] testupdateMsg = {0};
461 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
462 + buffer.writeBytes(updateMsg);
463 +
464 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
465 + PcepMessage message = null;
466 + try {
467 + message = reader.readFrom(buffer);
468 + } catch (PcepParseException e) {
469 + e.printStackTrace();
470 + }
471 +
472 + if (message instanceof PcepUpdateMsg) {
473 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
474 + message.writeTo(buf);
475 + testupdateMsg = buf.array();
476 +
477 + int iReadLen = buf.writerIndex() - 0;
478 + testupdateMsg = new byte[iReadLen];
479 + buf.readBytes(testupdateMsg, 0, iReadLen);
480 +
481 + if (Arrays.equals(updateMsg, testupdateMsg)) {
482 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
483 + log.debug("updateMsg are equal :" + updateMsg);
484 + } else {
485 + Assert.fail("test case failed");
486 + log.debug("not equal");
487 + }
488 + } else {
489 + Assert.fail("test case failed");
490 + log.debug("not equal");
491 + }
492 + }
493 +
494 + @Test
495 + public void pcepUpdateMsgTest10() throws PcepParseException {
496 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
497 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
498 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
499 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
500 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
501 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
502 + 0x01, 0x01, 0x04, 0x00,
503 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPa object
504 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
505 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
506 +
507 + byte[] testupdateMsg = {0};
508 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
509 + buffer.writeBytes(updateMsg);
510 +
511 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
512 + PcepMessage message = null;
513 + try {
514 + message = reader.readFrom(buffer);
515 + } catch (PcepParseException e) {
516 + e.printStackTrace();
517 + }
518 +
519 + if (message instanceof PcepUpdateMsg) {
520 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
521 + message.writeTo(buf);
522 + testupdateMsg = buf.array();
523 +
524 + int iReadLen = buf.writerIndex() - 0;
525 + testupdateMsg = new byte[iReadLen];
526 + buf.readBytes(testupdateMsg, 0, iReadLen);
527 +
528 + if (Arrays.equals(updateMsg, testupdateMsg)) {
529 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
530 + log.debug("updateMsg are equal :" + updateMsg);
531 + } else {
532 + Assert.fail("test case failed");
533 + log.debug("not equal");
534 + }
535 + } else {
536 + Assert.fail("test case failed");
537 + log.debug("not equal");
538 + }
539 + }
540 +
541 + @Test
542 + public void pcepUpdateMsgTest11() throws PcepParseException {
543 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
544 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
545 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
546 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
547 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
548 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
549 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
550 + 0x01, 0x01, 0x04, 0x00,
551 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
552 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
553 + 0x05, 0x20, 0x00, 0x04}; //Bandwidth object
554 +
555 + byte[] testupdateMsg = {0};
556 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
557 + buffer.writeBytes(updateMsg);
558 +
559 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
560 + PcepMessage message = null;
561 + try {
562 + message = reader.readFrom(buffer);
563 + } catch (PcepParseException e) {
564 + e.printStackTrace();
565 + }
566 +
567 + if (message instanceof PcepUpdateMsg) {
568 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
569 + message.writeTo(buf);
570 + testupdateMsg = buf.array();
571 +
572 + int iReadLen = buf.writerIndex() - 0;
573 + testupdateMsg = new byte[iReadLen];
574 + buf.readBytes(testupdateMsg, 0, iReadLen);
575 +
576 + if (Arrays.equals(updateMsg, testupdateMsg)) {
577 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
578 + log.debug("updateMsg are equal :" + updateMsg);
579 + } else {
580 + Assert.fail("test case failed");
581 + log.debug("not equal");
582 + }
583 + } else {
584 + Assert.fail("test case failed");
585 + log.debug("not equal");
586 + }
587 + }
588 +
589 + @Test
590 + public void pcepUpdateMsgTest12() throws PcepParseException {
591 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
592 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
593 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
594 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
595 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
596 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
597 + 0x01, 0x01, 0x04, 0x00,
598 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
599 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
600 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
601 +
602 + byte[] testupdateMsg = {0};
603 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
604 + buffer.writeBytes(updateMsg);
605 +
606 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
607 + PcepMessage message = null;
608 + try {
609 + message = reader.readFrom(buffer);
610 + } catch (PcepParseException e) {
611 + e.printStackTrace();
612 + }
613 +
614 + if (message instanceof PcepUpdateMsg) {
615 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
616 + message.writeTo(buf);
617 + testupdateMsg = buf.array();
618 +
619 + int iReadLen = buf.writerIndex() - 0;
620 + testupdateMsg = new byte[iReadLen];
621 + buf.readBytes(testupdateMsg, 0, iReadLen);
622 +
623 + if (Arrays.equals(updateMsg, testupdateMsg)) {
624 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
625 + log.debug("updateMsg are equal :" + updateMsg);
626 + } else {
627 + Assert.fail("test case failed");
628 + log.debug("not equal");
629 + }
630 + } else {
631 + Assert.fail("test case failed");
632 + log.debug("not equal");
633 + }
634 + }
635 +
636 + @Test
637 + public void pcepUpdateMsgTest13() throws PcepParseException {
638 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
639 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
640 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
641 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
642 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
643 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
644 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
645 + 0x01, 0x01, 0x04, 0x00,
646 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
647 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
648 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
649 +
650 + byte[] testupdateMsg = {0};
651 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
652 + buffer.writeBytes(updateMsg);
653 +
654 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
655 + PcepMessage message = null;
656 + try {
657 + message = reader.readFrom(buffer);
658 + } catch (PcepParseException e) {
659 + e.printStackTrace();
660 + }
661 +
662 + if (message instanceof PcepUpdateMsg) {
663 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
664 + message.writeTo(buf);
665 + testupdateMsg = buf.array();
666 +
667 + int iReadLen = buf.writerIndex() - 0;
668 + testupdateMsg = new byte[iReadLen];
669 + buf.readBytes(testupdateMsg, 0, iReadLen);
670 +
671 + if (Arrays.equals(updateMsg, testupdateMsg)) {
672 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
673 + log.debug("updateMsg are equal :" + updateMsg);
674 + } else {
675 + Assert.fail("test case failed");
676 + log.debug("not equal");
677 + }
678 + } else {
679 + Assert.fail("test case failed");
680 + log.debug("not equal");
681 + }
682 + }
683 +
684 + @Test
685 + public void pcepUpdateMsgTest14() throws PcepParseException {
686 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x60,
687 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
688 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
689 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
690 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
691 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
692 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
693 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
694 + 0x01, 0x01, 0x04, 0x00,
695 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
696 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
697 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
698 +
699 + byte[] testupdateMsg = {0};
700 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
701 + buffer.writeBytes(updateMsg);
702 +
703 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
704 + PcepMessage message = null;
705 + try {
706 + message = reader.readFrom(buffer);
707 + } catch (PcepParseException e) {
708 + e.printStackTrace();
709 + }
710 +
711 + if (message instanceof PcepUpdateMsg) {
712 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
713 + message.writeTo(buf);
714 + testupdateMsg = buf.array();
715 +
716 + int iReadLen = buf.writerIndex() - 0;
717 + testupdateMsg = new byte[iReadLen];
718 + buf.readBytes(testupdateMsg, 0, iReadLen);
719 +
720 + if (Arrays.equals(updateMsg, testupdateMsg)) {
721 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
722 + log.debug("updateMsg are equal :" + updateMsg);
723 + } else {
724 + Assert.fail("test case failed");
725 + log.debug("not equal");
726 + }
727 + } else {
728 + Assert.fail("test case failed");
729 + log.debug("not equal");
730 + }
731 + }
732 +
733 + @Test
734 + public void pcepUpdateMsgTest15() throws PcepParseException {
735 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
736 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
737 + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
738 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
739 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
740 + 0x01, 0x01, 0x04, 0x00,
741 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //lspa object
742 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
743 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
744 +
745 + byte[] testupdateMsg = {0};
746 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
747 + buffer.writeBytes(updateMsg);
748 +
749 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
750 + PcepMessage message = null;
751 + try {
752 + message = reader.readFrom(buffer);
753 + } catch (PcepParseException e) {
754 + e.printStackTrace();
755 + }
756 +
757 + if (message instanceof PcepUpdateMsg) {
758 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
759 + message.writeTo(buf);
760 + testupdateMsg = buf.array();
761 +
762 + int iReadLen = buf.writerIndex() - 0;
763 + testupdateMsg = new byte[iReadLen];
764 + buf.readBytes(testupdateMsg, 0, iReadLen);
765 +
766 + if (Arrays.equals(updateMsg, testupdateMsg)) {
767 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
768 + log.debug("updateMsg are equal :" + updateMsg);
769 + } else {
770 + Assert.fail("test case failed");
771 + log.debug("not equal");
772 + }
773 + } else {
774 + Assert.fail("test case failed");
775 + log.debug("not equal");
776 + }
777 + }
778 +
779 + @Test
780 + public void pcepUpdateMsgTest16() throws PcepParseException {
781 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
782 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
783 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
784 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
785 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
786 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
787 + 0x01, 0x01, 0x04, 0x00,
788 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
789 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
790 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
791 +
792 + byte[] testupdateMsg = {0};
793 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
794 + buffer.writeBytes(updateMsg);
795 +
796 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
797 + PcepMessage message = null;
798 + try {
799 + message = reader.readFrom(buffer);
800 + } catch (PcepParseException e) {
801 + e.printStackTrace();
802 + }
803 +
804 + if (message instanceof PcepUpdateMsg) {
805 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
806 + message.writeTo(buf);
807 + testupdateMsg = buf.array();
808 +
809 + int iReadLen = buf.writerIndex() - 0;
810 + testupdateMsg = new byte[iReadLen];
811 + buf.readBytes(testupdateMsg, 0, iReadLen);
812 +
813 + if (Arrays.equals(updateMsg, testupdateMsg)) {
814 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
815 + log.debug("updateMsg are equal :" + updateMsg);
816 + } else {
817 + Assert.fail("test case failed");
818 + log.debug("not equal");
819 + }
820 + } else {
821 + Assert.fail("test case failed");
822 + log.debug("not equal");
823 + }
824 + }
825 +
826 + @Test
827 + public void pcepUpdateMsgTest17() throws PcepParseException {
828 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x58,
829 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
830 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
831 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
832 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
833 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
834 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
835 + 0x01, 0x01, 0x04, 0x00,
836 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
837 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
838 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
839 +
840 + byte[] testupdateMsg = {0};
841 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
842 + buffer.writeBytes(updateMsg);
843 +
844 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
845 + PcepMessage message = null;
846 + try {
847 + message = reader.readFrom(buffer);
848 + } catch (PcepParseException e) {
849 + e.printStackTrace();
850 + }
851 +
852 + if (message instanceof PcepUpdateMsg) {
853 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
854 + message.writeTo(buf);
855 + testupdateMsg = buf.array();
856 +
857 + int iReadLen = buf.writerIndex() - 0;
858 + testupdateMsg = new byte[iReadLen];
859 + buf.readBytes(testupdateMsg, 0, iReadLen);
860 +
861 + if (Arrays.equals(updateMsg, testupdateMsg)) {
862 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
863 + log.debug("updateMsg are equal :" + updateMsg);
864 + } else {
865 + Assert.fail("test case failed");
866 + log.debug("not equal");
867 + }
868 + } else {
869 + Assert.fail("test case failed");
870 + log.debug("not equal");
871 + }
872 + }
873 +
874 + @Test
875 + public void pcepUpdateMsgTest18() throws PcepParseException {
876 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
877 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
878 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
879 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
880 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
881 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
882 + 0x01, 0x01, 0x04, 0x00,
883 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
884 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
885 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
886 +
887 + byte[] testupdateMsg = {0};
888 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
889 + buffer.writeBytes(updateMsg);
890 +
891 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
892 + PcepMessage message = null;
893 + try {
894 + message = reader.readFrom(buffer);
895 + } catch (PcepParseException e) {
896 + e.printStackTrace();
897 + }
898 +
899 + if (message instanceof PcepUpdateMsg) {
900 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
901 + message.writeTo(buf);
902 + testupdateMsg = buf.array();
903 +
904 + int iReadLen = buf.writerIndex() - 0;
905 + testupdateMsg = new byte[iReadLen];
906 + buf.readBytes(testupdateMsg, 0, iReadLen);
907 +
908 + if (Arrays.equals(updateMsg, testupdateMsg)) {
909 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
910 + log.debug("updateMsg are equal :" + updateMsg);
911 + } else {
912 + Assert.fail("test case failed");
913 + log.debug("not equal");
914 + }
915 + } else {
916 + Assert.fail("test case failed");
917 + log.debug("not equal");
918 + }
919 + }
920 +
921 + @Test
922 + public void pcepUpdateMsgTest19() throws PcepParseException {
923 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x5c,
924 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
925 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
926 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
927 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
928 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
929 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
930 + 0x01, 0x01, 0x04, 0x00,
931 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00,
932 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00,
933 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
934 +
935 + byte[] testupdateMsg = {0};
936 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
937 + buffer.writeBytes(updateMsg);
938 +
939 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
940 + PcepMessage message = null;
941 + try {
942 + message = reader.readFrom(buffer);
943 + } catch (PcepParseException e) {
944 + e.printStackTrace();
945 + }
946 +
947 + if (message instanceof PcepUpdateMsg) {
948 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
949 + message.writeTo(buf);
950 + testupdateMsg = buf.array();
951 +
952 + int iReadLen = buf.writerIndex() - 0;
953 + testupdateMsg = new byte[iReadLen];
954 + buf.readBytes(testupdateMsg, 0, iReadLen);
955 +
956 + if (Arrays.equals(updateMsg, testupdateMsg)) {
957 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
958 + log.debug("updateMsg are equal :" + updateMsg);
959 + } else {
960 + Assert.fail("test case failed");
961 + log.debug("not equal");
962 + }
963 + } else {
964 + Assert.fail("test case failed");
965 + log.debug("not equal");
966 + }
967 + }
968 +
969 + @Test
970 + public void pcepUpdateMsgTest20() throws PcepParseException {
971 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
972 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
973 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
974 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
975 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
976 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
977 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
978 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
979 + 0x01, 0x01, 0x04, 0x00,
980 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
981 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
982 +
983 + byte[] testupdateMsg = {0};
984 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
985 + buffer.writeBytes(updateMsg);
986 +
987 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
988 + PcepMessage message = null;
989 + try {
990 + message = reader.readFrom(buffer);
991 + } catch (PcepParseException e) {
992 + e.printStackTrace();
993 + }
994 +
995 + if (message instanceof PcepUpdateMsg) {
996 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
997 + message.writeTo(buf);
998 + testupdateMsg = buf.array();
999 +
1000 + int iReadLen = buf.writerIndex() - 0;
1001 + testupdateMsg = new byte[iReadLen];
1002 + buf.readBytes(testupdateMsg, 0, iReadLen);
1003 +
1004 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1005 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1006 + log.debug("updateMsg are equal :" + updateMsg);
1007 + } else {
1008 + Assert.fail("test case failed");
1009 + log.debug("not equal");
1010 + }
1011 + } else {
1012 + Assert.fail("test case failed");
1013 + log.debug("not equal");
1014 + }
1015 + }
1016 +
1017 + @Test
1018 + public void pcepUpdateMsgTest21() throws PcepParseException {
1019 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
1020 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1021 + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
1022 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1023 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1024 + 0x01, 0x01, 0x04, 0x00,
1025 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1026 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1027 +
1028 + byte[] testupdateMsg = {0};
1029 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1030 + buffer.writeBytes(updateMsg);
1031 +
1032 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1033 + PcepMessage message = null;
1034 + try {
1035 + message = reader.readFrom(buffer);
1036 + } catch (PcepParseException e) {
1037 + e.printStackTrace();
1038 + }
1039 +
1040 + if (message instanceof PcepUpdateMsg) {
1041 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1042 + message.writeTo(buf);
1043 + testupdateMsg = buf.array();
1044 +
1045 + int iReadLen = buf.writerIndex() - 0;
1046 + testupdateMsg = new byte[iReadLen];
1047 + buf.readBytes(testupdateMsg, 0, iReadLen);
1048 +
1049 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1050 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1051 + log.debug("updateMsg are equal :" + updateMsg);
1052 + } else {
1053 + Assert.fail("test case failed");
1054 + log.debug("not equal");
1055 + }
1056 + } else {
1057 + Assert.fail("test case failed");
1058 + log.debug("not equal");
1059 + }
1060 + }
1061 +
1062 + @Test
1063 + public void pcepUpdateMsgTest22() throws PcepParseException {
1064 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
1065 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1066 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1067 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1068 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1069 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1070 + 0x01, 0x01, 0x04, 0x00,
1071 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1072 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1073 +
1074 + byte[] testupdateMsg = {0};
1075 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1076 + buffer.writeBytes(updateMsg);
1077 +
1078 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1079 + PcepMessage message = null;
1080 + try {
1081 + message = reader.readFrom(buffer);
1082 + } catch (PcepParseException e) {
1083 + e.printStackTrace();
1084 + }
1085 +
1086 + if (message instanceof PcepUpdateMsg) {
1087 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1088 + message.writeTo(buf);
1089 + testupdateMsg = buf.array();
1090 +
1091 + int iReadLen = buf.writerIndex() - 0;
1092 + testupdateMsg = new byte[iReadLen];
1093 + buf.readBytes(testupdateMsg, 0, iReadLen);
1094 +
1095 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1096 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1097 + log.debug("updateMsg are equal :" + updateMsg);
1098 + } else {
1099 + Assert.fail("test case failed");
1100 + log.debug("not equal");
1101 + }
1102 + } else {
1103 + Assert.fail("test case failed");
1104 + log.debug("not equal");
1105 + }
1106 + }
1107 +
1108 + @Test
1109 + public void pcepUpdateMsgTest23() throws PcepParseException {
1110 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
1111 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1112 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1113 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1114 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1115 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1116 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1117 + 0x01, 0x01, 0x04, 0x00,
1118 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1119 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1120 +
1121 + byte[] testupdateMsg = {0};
1122 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1123 + buffer.writeBytes(updateMsg);
1124 +
1125 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1126 + PcepMessage message = null;
1127 + try {
1128 + message = reader.readFrom(buffer);
1129 + } catch (PcepParseException e) {
1130 + e.printStackTrace();
1131 + }
1132 +
1133 + if (message instanceof PcepUpdateMsg) {
1134 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1135 + message.writeTo(buf);
1136 + testupdateMsg = buf.array();
1137 +
1138 + int iReadLen = buf.writerIndex() - 0;
1139 + testupdateMsg = new byte[iReadLen];
1140 + buf.readBytes(testupdateMsg, 0, iReadLen);
1141 +
1142 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1143 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1144 + log.debug("updateMsg are equal :" + updateMsg);
1145 + } else {
1146 + Assert.fail("test case failed");
1147 + log.debug("not equal");
1148 + }
1149 + } else {
1150 + Assert.fail("test case failed");
1151 + log.debug("not equal");
1152 + }
1153 + }
1154 +
1155 + @Test
1156 + public void pcepUpdateMsgTest24() throws PcepParseException {
1157 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
1158 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1159 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1160 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1161 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1162 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1163 + 0x01, 0x01, 0x04, 0x00,
1164 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1165 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1166 +
1167 + byte[] testupdateMsg = {0};
1168 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1169 + buffer.writeBytes(updateMsg);
1170 +
1171 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1172 + PcepMessage message = null;
1173 + try {
1174 + message = reader.readFrom(buffer);
1175 + } catch (PcepParseException e) {
1176 + e.printStackTrace();
1177 + }
1178 +
1179 + if (message instanceof PcepUpdateMsg) {
1180 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1181 + message.writeTo(buf);
1182 + testupdateMsg = buf.array();
1183 +
1184 + int iReadLen = buf.writerIndex() - 0;
1185 + testupdateMsg = new byte[iReadLen];
1186 + buf.readBytes(testupdateMsg, 0, iReadLen);
1187 +
1188 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1189 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1190 + log.debug("updateMsg are equal :" + updateMsg);
1191 + } else {
1192 + Assert.fail("test case failed");
1193 + log.debug("not equal");
1194 + }
1195 + } else {
1196 + Assert.fail("test case failed");
1197 + log.debug("not equal");
1198 + }
1199 + }
1200 +
1201 + @Test
1202 + public void pcepUpdateMsgTest25() throws PcepParseException {
1203 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x50,
1204 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1205 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1206 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1207 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1208 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1209 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1210 + 0x01, 0x01, 0x04, 0x00,
1211 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
1212 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1213 +
1214 + byte[] testupdateMsg = {0};
1215 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1216 + buffer.writeBytes(updateMsg);
1217 +
1218 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1219 + PcepMessage message = null;
1220 + try {
1221 + message = reader.readFrom(buffer);
1222 + } catch (PcepParseException e) {
1223 + e.printStackTrace();
1224 + }
1225 +
1226 + if (message instanceof PcepUpdateMsg) {
1227 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1228 + message.writeTo(buf);
1229 + testupdateMsg = buf.array();
1230 +
1231 + int iReadLen = buf.writerIndex() - 0;
1232 + testupdateMsg = new byte[iReadLen];
1233 + buf.readBytes(testupdateMsg, 0, iReadLen);
1234 +
1235 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1236 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1237 + log.debug("updateMsg are equal :" + updateMsg);
1238 + } else {
1239 + Assert.fail("test case failed");
1240 + log.debug("not equal");
1241 + }
1242 + } else {
1243 + Assert.fail("test case failed");
1244 + log.debug("not equal");
1245 + }
1246 + }
1247 +
1248 + @Test
1249 + public void pcepUpdateMsgTest26() throws PcepParseException {
1250 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1251 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1252 + 0x20, 0x10, 0x00, 0x1C, 0x00, 0x00, 0x10, 0x03, //LSP object
1253 + 0x00, 0x12, 0x00, 0x10, //StatefulIPv4LspIdentidiersTlv
1254 + (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x00, 0x01, (byte) 0x80, 0x01,
1255 + (byte) 0xb6, 0x02, 0x4e, 0x1f, (byte) 0xb6, 0x02, 0x4e, 0x20,
1256 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1257 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1258 + 0x01, 0x01, 0x04, 0x00,
1259 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1260 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1261 +
1262 + byte[] testupdateMsg = {0};
1263 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1264 + buffer.writeBytes(updateMsg);
1265 +
1266 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1267 + PcepMessage message = null;
1268 + try {
1269 + message = reader.readFrom(buffer);
1270 + } catch (PcepParseException e) {
1271 + e.printStackTrace();
1272 + }
1273 +
1274 + if (message instanceof PcepUpdateMsg) {
1275 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1276 + message.writeTo(buf);
1277 + testupdateMsg = buf.array();
1278 +
1279 + int iReadLen = buf.writerIndex() - 0;
1280 + testupdateMsg = new byte[iReadLen];
1281 + buf.readBytes(testupdateMsg, 0, iReadLen);
1282 +
1283 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1284 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1285 + log.debug("updateMsg are equal :" + updateMsg);
1286 + } else {
1287 + Assert.fail("test case failed");
1288 + log.debug("not equal");
1289 + }
1290 + } else {
1291 + Assert.fail("test case failed");
1292 + log.debug("not equal");
1293 + }
1294 + }
1295 +
1296 + @Test
1297 + public void pcepUpdateMsgTest27() throws PcepParseException {
1298 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x34,
1299 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1300 + 0x20, 0x10, 0x00, 0x08, 0x00, 0x00, 0x10, 0x03, //LSP object
1301 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1302 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1303 + 0x01, 0x01, 0x04, 0x00,
1304 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1305 +
1306 + byte[] testupdateMsg = {0};
1307 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1308 + buffer.writeBytes(updateMsg);
1309 +
1310 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1311 + PcepMessage message = null;
1312 + try {
1313 + message = reader.readFrom(buffer);
1314 + } catch (PcepParseException e) {
1315 + e.printStackTrace();
1316 + }
1317 +
1318 + if (message instanceof PcepUpdateMsg) {
1319 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1320 + message.writeTo(buf);
1321 + testupdateMsg = buf.array();
1322 +
1323 + int iReadLen = buf.writerIndex() - 0;
1324 + testupdateMsg = new byte[iReadLen];
1325 + buf.readBytes(testupdateMsg, 0, iReadLen);
1326 +
1327 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1328 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1329 + log.debug("updateMsg are equal :" + updateMsg);
1330 + } else {
1331 + Assert.fail("test case failed");
1332 + log.debug("not equal");
1333 + }
1334 + } else {
1335 + Assert.fail("test case failed");
1336 + log.debug("not equal");
1337 + }
1338 + }
1339 +
1340 + @Test
1341 + public void pcepUpdateMsgTest28() throws PcepParseException {
1342 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x40,
1343 + 0x21, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1344 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
1345 + 0x00, 0x14, 0x00, 0x04, 0x00, 0x00, 0x00, 0x08, //StatefulLspErrorCodeTlv
1346 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1347 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1348 + 0x01, 0x01, 0x04, 0x00,
1349 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1350 +
1351 + byte[] testupdateMsg = {0};
1352 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1353 + buffer.writeBytes(updateMsg);
1354 +
1355 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1356 + PcepMessage message = null;
1357 + try {
1358 + message = reader.readFrom(buffer);
1359 + } catch (PcepParseException e) {
1360 + e.printStackTrace();
1361 + }
1362 +
1363 + if (message instanceof PcepUpdateMsg) {
1364 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1365 + message.writeTo(buf);
1366 + testupdateMsg = buf.array();
1367 +
1368 + int iReadLen = buf.writerIndex() - 0;
1369 + testupdateMsg = new byte[iReadLen];
1370 + buf.readBytes(testupdateMsg, 0, iReadLen);
1371 +
1372 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1373 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1374 + log.debug("updateMsg are equal :" + updateMsg);
1375 + } else {
1376 + Assert.fail("test case failed");
1377 + log.debug("not equal");
1378 + }
1379 + } else {
1380 + Assert.fail("test case failed");
1381 + log.debug("not equal");
1382 + }
1383 + }
1384 +
1385 + @Test
1386 + public void pcepUpdateMsgTest29() throws PcepParseException {
1387 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x54,
1388 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1389 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1390 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1391 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1392 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1393 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1394 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1395 + 0x01, 0x01, 0x04, 0x00,
1396 + 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
1397 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00 };
1398 +
1399 + byte[] testupdateMsg = {0};
1400 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1401 + buffer.writeBytes(updateMsg);
1402 +
1403 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1404 + PcepMessage message = null;
1405 + try {
1406 + message = reader.readFrom(buffer);
1407 + } catch (PcepParseException e) {
1408 + e.printStackTrace();
1409 + }
1410 +
1411 + if (message instanceof PcepUpdateMsg) {
1412 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1413 + message.writeTo(buf);
1414 + testupdateMsg = buf.array();
1415 +
1416 + int iReadLen = buf.writerIndex() - 0;
1417 + testupdateMsg = new byte[iReadLen];
1418 + buf.readBytes(testupdateMsg, 0, iReadLen);
1419 +
1420 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1421 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1422 + log.debug("updateMsg are equal :" + updateMsg);
1423 + } else {
1424 + Assert.fail("test case failed");
1425 + log.debug("not equal");
1426 + }
1427 + } else {
1428 + Assert.fail("test case failed");
1429 + log.debug("not equal");
1430 + }
1431 + }
1432 +
1433 + @Test
1434 + public void pcepUpdateMsgTest30() throws PcepParseException {
1435 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x48,
1436 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1437 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1438 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1439 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1440 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1441 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1442 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1443 + 0x01, 0x01, 0x04, 0x00,
1444 + 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00 }; //Bandwidth object
1445 +
1446 + byte[] testupdateMsg = {0};
1447 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1448 + buffer.writeBytes(updateMsg);
1449 +
1450 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1451 + PcepMessage message = null;
1452 + try {
1453 + message = reader.readFrom(buffer);
1454 + } catch (PcepParseException e) {
1455 + e.printStackTrace();
1456 + }
1457 +
1458 + if (message instanceof PcepUpdateMsg) {
1459 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1460 + message.writeTo(buf);
1461 + testupdateMsg = buf.array();
1462 +
1463 + int iReadLen = buf.writerIndex() - 0;
1464 + testupdateMsg = new byte[iReadLen];
1465 + buf.readBytes(testupdateMsg, 0, iReadLen);
1466 +
1467 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1468 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1469 + log.debug("updateMsg are equal :" + updateMsg);
1470 + } else {
1471 + Assert.fail("test case failed");
1472 + log.debug("not equal");
1473 + }
1474 + } else {
1475 + Assert.fail("test case failed");
1476 + log.debug("not equal");
1477 + }
1478 + }
1479 +
1480 + @Test
1481 + public void pcepUpdateMsgTest31() throws PcepParseException {
1482 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x4c,
1483 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1484 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1485 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1486 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1487 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1488 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1489 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1490 + 0x01, 0x01, 0x04, 0x00,
1491 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1492 +
1493 + byte[] testupdateMsg = {0};
1494 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1495 + buffer.writeBytes(updateMsg);
1496 +
1497 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1498 + PcepMessage message = null;
1499 + try {
1500 + message = reader.readFrom(buffer);
1501 + } catch (PcepParseException e) {
1502 + e.printStackTrace();
1503 + }
1504 +
1505 + if (message instanceof PcepUpdateMsg) {
1506 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1507 + message.writeTo(buf);
1508 + testupdateMsg = buf.array();
1509 +
1510 + int iReadLen = buf.writerIndex() - 0;
1511 + testupdateMsg = new byte[iReadLen];
1512 + buf.readBytes(testupdateMsg, 0, iReadLen);
1513 +
1514 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1515 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1516 + log.debug("updateMsg are equal :" + updateMsg);
1517 + } else {
1518 + Assert.fail("test case failed");
1519 + log.debug("not equal");
1520 + }
1521 + } else {
1522 + Assert.fail("test case failed");
1523 + log.debug("not equal");
1524 + }
1525 + }
1526 +
1527 + @Test
1528 + public void pcepUpdateMsgTest32() throws PcepParseException {
1529 + byte[] updateMsg = new byte[] {0x20, 0x0b, 0x00, (byte) 0x64,
1530 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, //SRP object
1531 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //SymbolicPathNameTlv
1532 + 0x20, 0x10, 0x00, 0x14, 0x00, 0x00, 0x10, 0x03, //LSP object
1533 + 0x00, 0x17, 0x00, 0x08, //StatefulLspDbVerTlv
1534 + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,
1535 + 0x07, 0x10, 0x00, 0x14, 0x01, 0x08, 0x11, 0x01, //ERO Object
1536 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
1537 + 0x01, 0x01, 0x04, 0x00,
1538 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
1539 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
1540 + 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20 }; //Metric object
1541 +
1542 + byte[] testupdateMsg = {0};
1543 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
1544 + buffer.writeBytes(updateMsg);
1545 +
1546 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
1547 + PcepMessage message = null;
1548 + try {
1549 + message = reader.readFrom(buffer);
1550 + } catch (PcepParseException e) {
1551 + e.printStackTrace();
1552 + }
1553 +
1554 + if (message instanceof PcepUpdateMsg) {
1555 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
1556 + message.writeTo(buf);
1557 + testupdateMsg = buf.array();
1558 +
1559 + int iReadLen = buf.writerIndex() - 0;
1560 + testupdateMsg = new byte[iReadLen];
1561 + buf.readBytes(testupdateMsg, 0, iReadLen);
1562 +
1563 + if (Arrays.equals(updateMsg, testupdateMsg)) {
1564 + Assert.assertArrayEquals(updateMsg, testupdateMsg);
1565 + log.debug("updateMsg are equal :" + updateMsg);
1566 + } else {
1567 + Assert.fail("test case failed");
1568 + log.debug("not equal");
1569 + }
1570 + } else {
1571 + Assert.fail("test case failed");
1572 + log.debug("not equal");
1573 + }
1574 + }
1575 +}
1576 +
1 +/*
2 + * Copyright 2015 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.pcepio;
17 +
18 +import org.junit.Test;
19 +import org.onosproject.pcepio.types.SymbolicPathNameTlv;
20 +
21 +import com.google.common.testing.EqualsTester;
22 +
23 +/**
24 + * Test case for Symbolic path tlv.
25 + */
26 +public class SymbolicPathNameTlvTest {
27 +
28 + byte[] value1 = {0x41 };
29 + Short length1 = new Short((short) 2);
30 + final SymbolicPathNameTlv tlv1 = SymbolicPathNameTlv.of(value1, length1);
31 +
32 + byte[] value2 = {0x41 };
33 + Short length2 = new Short((short) 2);
34 + final SymbolicPathNameTlv tlv2 = SymbolicPathNameTlv.of(value1, length2);
35 +
36 + byte[] value3 = {0x41, 0x43 };
37 + Short length3 = new Short((short) 3);
38 + final SymbolicPathNameTlv tlv3 = SymbolicPathNameTlv.of(value3, length3);
39 +
40 + @Test
41 + public void basics() {
42 + new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
43 + }
44 +
45 +}