Sho SHIMIZU
Committed by Ray Milkey

Use LF as line separator

Change-Id: Iaaed8d5bf5157ceba403f53cf86dd535a70f41f8
Showing 89 changed files with 18304 additions and 18304 deletions
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import org.onosproject.pcepio.exceptions.PcepParseException; 19 +import org.onosproject.pcepio.exceptions.PcepParseException;
20 -import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; 20 +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
21 -import org.onosproject.pcepio.protocol.PcepAttribute; 21 +import org.onosproject.pcepio.protocol.PcepAttribute;
22 -import org.onosproject.pcepio.protocol.PcepEndPointsObject; 22 +import org.onosproject.pcepio.protocol.PcepEndPointsObject;
23 -import org.onosproject.pcepio.protocol.PcepEroObject; 23 +import org.onosproject.pcepio.protocol.PcepEroObject;
24 -import org.onosproject.pcepio.protocol.PcepLspObject; 24 +import org.onosproject.pcepio.protocol.PcepLspObject;
25 -import org.onosproject.pcepio.protocol.PcepSrpObject; 25 +import org.onosproject.pcepio.protocol.PcepSrpObject;
26 -import org.slf4j.Logger; 26 +import org.slf4j.Logger;
27 -import org.slf4j.LoggerFactory; 27 +import org.slf4j.LoggerFactory;
28 - 28 +
29 -import com.google.common.base.MoreObjects; 29 +import com.google.common.base.MoreObjects;
30 -import com.google.common.base.MoreObjects.ToStringHelper; 30 +import com.google.common.base.MoreObjects.ToStringHelper;
31 - 31 +
32 -/** 32 +/**
33 - * Provides PcInitiatedLspRequest for PCEP Initiate message. 33 + * Provides PcInitiatedLspRequest for PCEP Initiate message.
34 - * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03. 34 + * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03.
35 - */ 35 + */
36 -public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest { 36 +public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest {
37 - 37 +
38 - /* 38 + /*
39 - * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>) 39 + * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
40 - <PCE-initiated-lsp-instantiation> ::= <SRP> 40 + <PCE-initiated-lsp-instantiation> ::= <SRP>
41 - <LSP> 41 + <LSP>
42 - <END-POINTS> 42 + <END-POINTS>
43 - <ERO> 43 + <ERO>
44 - [<attribute-list>] 44 + [<attribute-list>]
45 - <PCE-initiated-lsp-deletion> ::= <SRP> 45 + <PCE-initiated-lsp-deletion> ::= <SRP>
46 - <LSP> 46 + <LSP>
47 - */ 47 + */
48 - 48 +
49 - protected static final Logger log = LoggerFactory.getLogger(PcInitiatedLspRequestVer1.class); 49 + protected static final Logger log = LoggerFactory.getLogger(PcInitiatedLspRequestVer1.class);
50 - 50 +
51 - //PCEP SRP Object 51 + //PCEP SRP Object
52 - private PcepSrpObject srpObject; 52 + private PcepSrpObject srpObject;
53 - //PCEP LSP Object 53 + //PCEP LSP Object
54 - private PcepLspObject lspObject; 54 + private PcepLspObject lspObject;
55 - //PCEP End Point Object 55 + //PCEP End Point Object
56 - private PcepEndPointsObject endPointsObject; 56 + private PcepEndPointsObject endPointsObject;
57 - //PCEP ERO Object 57 + //PCEP ERO Object
58 - private PcepEroObject eroObject; 58 + private PcepEroObject eroObject;
59 - //PCEP Attribute list 59 + //PCEP Attribute list
60 - private PcepAttribute pcepAttribute; 60 + private PcepAttribute pcepAttribute;
61 - 61 +
62 - /** 62 + /**
63 - * Default constructor. 63 + * Default constructor.
64 - */ 64 + */
65 - public PcInitiatedLspRequestVer1() { 65 + public PcInitiatedLspRequestVer1() {
66 - srpObject = null; 66 + srpObject = null;
67 - lspObject = null; 67 + lspObject = null;
68 - endPointsObject = null; 68 + endPointsObject = null;
69 - eroObject = null; 69 + eroObject = null;
70 - pcepAttribute = null; 70 + pcepAttribute = null;
71 - 71 +
72 - } 72 + }
73 - 73 +
74 - /** 74 + /**
75 - * Constructor to initialize all parameters of PC initiated lsp request. 75 + * Constructor to initialize all parameters of PC initiated lsp request.
76 - * 76 + *
77 - * @param srpObject PCEP srp Object 77 + * @param srpObject PCEP srp Object
78 - * @param lspObject PCEP lsp object 78 + * @param lspObject PCEP lsp object
79 - * @param endPointsObject PCPE endpoints object 79 + * @param endPointsObject PCPE endpoints object
80 - * @param eroObject PCEP ero object 80 + * @param eroObject PCEP ero object
81 - * @param pcepAttribute PCEP attribute 81 + * @param pcepAttribute PCEP attribute
82 - */ 82 + */
83 - public PcInitiatedLspRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, 83 + public PcInitiatedLspRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject,
84 - PcepEndPointsObject endPointsObject, PcepEroObject eroObject, PcepAttribute pcepAttribute) { 84 + PcepEndPointsObject endPointsObject, PcepEroObject eroObject, PcepAttribute pcepAttribute) {
85 - this.srpObject = srpObject; 85 + this.srpObject = srpObject;
86 - this.lspObject = lspObject; 86 + this.lspObject = lspObject;
87 - this.endPointsObject = endPointsObject; 87 + this.endPointsObject = endPointsObject;
88 - this.eroObject = eroObject; 88 + this.eroObject = eroObject;
89 - this.pcepAttribute = pcepAttribute; 89 + this.pcepAttribute = pcepAttribute;
90 - 90 +
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public PcepSrpObject getSrpObject() { 94 + public PcepSrpObject getSrpObject() {
95 - return srpObject; 95 + return srpObject;
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public PcepLspObject getLspObject() { 99 + public PcepLspObject getLspObject() {
100 - return lspObject; 100 + return lspObject;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public PcepEndPointsObject getEndPointsObject() { 104 + public PcepEndPointsObject getEndPointsObject() {
105 - return endPointsObject; 105 + return endPointsObject;
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public PcepEroObject getEroObject() { 109 + public PcepEroObject getEroObject() {
110 - return eroObject; 110 + return eroObject;
111 - } 111 + }
112 - 112 +
113 - @Override 113 + @Override
114 - public PcepAttribute getPcepAttribute() { 114 + public PcepAttribute getPcepAttribute() {
115 - return pcepAttribute; 115 + return pcepAttribute;
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public void setSrpObject(PcepSrpObject srpobj) { 119 + public void setSrpObject(PcepSrpObject srpobj) {
120 - this.srpObject = srpobj; 120 + this.srpObject = srpobj;
121 - 121 +
122 - } 122 + }
123 - 123 +
124 - @Override 124 + @Override
125 - public void setLspObject(PcepLspObject lspObject) { 125 + public void setLspObject(PcepLspObject lspObject) {
126 - this.lspObject = lspObject; 126 + this.lspObject = lspObject;
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public void setEndPointsObject(PcepEndPointsObject endPointsObject) { 130 + public void setEndPointsObject(PcepEndPointsObject endPointsObject) {
131 - this.endPointsObject = endPointsObject; 131 + this.endPointsObject = endPointsObject;
132 - } 132 + }
133 - 133 +
134 - @Override 134 + @Override
135 - public void setEroObject(PcepEroObject eroObject) { 135 + public void setEroObject(PcepEroObject eroObject) {
136 - this.eroObject = eroObject; 136 + this.eroObject = eroObject;
137 - } 137 + }
138 - 138 +
139 - @Override 139 + @Override
140 - public void setPcepAttribute(PcepAttribute pcepAttribute) { 140 + public void setPcepAttribute(PcepAttribute pcepAttribute) {
141 - this.pcepAttribute = pcepAttribute; 141 + this.pcepAttribute = pcepAttribute;
142 - } 142 + }
143 - 143 +
144 - /** 144 + /**
145 - * Builder class for PC initiated lsp reuqest. 145 + * Builder class for PC initiated lsp reuqest.
146 - */ 146 + */
147 - public static class Builder implements PcInitiatedLspRequest.Builder { 147 + public static class Builder implements PcInitiatedLspRequest.Builder {
148 - 148 +
149 - private boolean bIsSRPObjectSet = false; 149 + private boolean bIsSRPObjectSet = false;
150 - private boolean bIsLSPObjectSet = false; 150 + private boolean bIsLSPObjectSet = false;
151 - private boolean bIsEndPointsObjectSet = false; 151 + private boolean bIsEndPointsObjectSet = false;
152 - private boolean bIsEROObjectSet = false; 152 + private boolean bIsEROObjectSet = false;
153 - private boolean bIsPcepAttributeSet = false; 153 + private boolean bIsPcepAttributeSet = false;
154 - private boolean bIsbRFlagSet = false; 154 + private boolean bIsbRFlagSet = false;
155 - 155 +
156 - //PCEP SRP Object 156 + //PCEP SRP Object
157 - private PcepSrpObject srpObject; 157 + private PcepSrpObject srpObject;
158 - //PCEP LSP Object 158 + //PCEP LSP Object
159 - private PcepLspObject lspObject; 159 + private PcepLspObject lspObject;
160 - //PCEP End Point Object 160 + //PCEP End Point Object
161 - private PcepEndPointsObject endPointsObject; 161 + private PcepEndPointsObject endPointsObject;
162 - //PCEP ERO Object 162 + //PCEP ERO Object
163 - private PcepEroObject eroObject; 163 + private PcepEroObject eroObject;
164 - //PCEP Attribute list 164 + //PCEP Attribute list
165 - private PcepAttribute pcepAttribute; 165 + private PcepAttribute pcepAttribute;
166 - 166 +
167 - @Override 167 + @Override
168 - public PcInitiatedLspRequest build() throws PcepParseException { 168 + public PcInitiatedLspRequest build() throws PcepParseException {
169 - 169 +
170 - //PCEP SRP Object 170 + //PCEP SRP Object
171 - PcepSrpObject srpObject = null; 171 + PcepSrpObject srpObject = null;
172 - //PCEP LSP Object 172 + //PCEP LSP Object
173 - PcepLspObject lspObject = null; 173 + PcepLspObject lspObject = null;
174 - //PCEP End Point Object 174 + //PCEP End Point Object
175 - PcepEndPointsObject endPointsObject = null; 175 + PcepEndPointsObject endPointsObject = null;
176 - //PCEP ERO Object 176 + //PCEP ERO Object
177 - PcepEroObject eroObject = null; 177 + PcepEroObject eroObject = null;
178 - //PCEP Attribute list 178 + //PCEP Attribute list
179 - PcepAttribute pcepAttribute = null; 179 + PcepAttribute pcepAttribute = null;
180 - boolean bRFlag = false; 180 + boolean bRFlag = false;
181 - 181 +
182 - if (!this.bIsSRPObjectSet) { 182 + if (!this.bIsSRPObjectSet) {
183 - throw new PcepParseException("Srp object NOT Set while building PcInitiatedLspRequest"); 183 + throw new PcepParseException("Srp object NOT Set while building PcInitiatedLspRequest");
184 - } else { 184 + } else {
185 - srpObject = this.srpObject; 185 + srpObject = this.srpObject;
186 - bRFlag = srpObject.getRFlag(); 186 + bRFlag = srpObject.getRFlag();
187 - } 187 + }
188 - 188 +
189 - if (bRFlag) { 189 + if (bRFlag) {
190 - this.bIsbRFlagSet = true; 190 + this.bIsbRFlagSet = true;
191 - } else { 191 + } else {
192 - this.bIsbRFlagSet = false; 192 + this.bIsbRFlagSet = false;
193 - } 193 + }
194 - 194 +
195 - if (!this.bIsLSPObjectSet) { 195 + if (!this.bIsLSPObjectSet) {
196 - throw new PcepParseException("LSP Object NOT Set while building PcInitiatedLspRequest"); 196 + throw new PcepParseException("LSP Object NOT Set while building PcInitiatedLspRequest");
197 - } else { 197 + } else {
198 - lspObject = this.lspObject; 198 + lspObject = this.lspObject;
199 - } 199 + }
200 - if (!this.bIsbRFlagSet) { 200 + if (!this.bIsbRFlagSet) {
201 - 201 +
202 - if (!this.bIsEndPointsObjectSet) { 202 + if (!this.bIsEndPointsObjectSet) {
203 - throw new PcepParseException("EndPoints Object NOT Set while building PcInitiatedLspRequest"); 203 + throw new PcepParseException("EndPoints Object NOT Set while building PcInitiatedLspRequest");
204 - } else { 204 + } else {
205 - endPointsObject = this.endPointsObject; 205 + endPointsObject = this.endPointsObject;
206 - } 206 + }
207 - if (!this.bIsEROObjectSet) { 207 + if (!this.bIsEROObjectSet) {
208 - throw new PcepParseException("ERO Object NOT Set while building PcInitiatedLspRequest"); 208 + throw new PcepParseException("ERO Object NOT Set while building PcInitiatedLspRequest");
209 - } else { 209 + } else {
210 - eroObject = this.eroObject; 210 + eroObject = this.eroObject;
211 - } 211 + }
212 - if (bIsPcepAttributeSet) { 212 + if (bIsPcepAttributeSet) {
213 - pcepAttribute = this.pcepAttribute; 213 + pcepAttribute = this.pcepAttribute;
214 - } 214 + }
215 - } 215 + }
216 - return new PcInitiatedLspRequestVer1(srpObject, lspObject, endPointsObject, eroObject, pcepAttribute); 216 + return new PcInitiatedLspRequestVer1(srpObject, lspObject, endPointsObject, eroObject, pcepAttribute);
217 - } 217 + }
218 - 218 +
219 - @Override 219 + @Override
220 - public PcepSrpObject getSrpObject() { 220 + public PcepSrpObject getSrpObject() {
221 - return this.srpObject; 221 + return this.srpObject;
222 - } 222 + }
223 - 223 +
224 - @Override 224 + @Override
225 - public PcepLspObject getLspObject() { 225 + public PcepLspObject getLspObject() {
226 - return this.lspObject; 226 + return this.lspObject;
227 - } 227 + }
228 - 228 +
229 - @Override 229 + @Override
230 - public PcepEndPointsObject getEndPointsObject() { 230 + public PcepEndPointsObject getEndPointsObject() {
231 - return this.endPointsObject; 231 + return this.endPointsObject;
232 - } 232 + }
233 - 233 +
234 - @Override 234 + @Override
235 - public PcepEroObject getEroObject() { 235 + public PcepEroObject getEroObject() {
236 - return this.eroObject; 236 + return this.eroObject;
237 - } 237 + }
238 - 238 +
239 - @Override 239 + @Override
240 - public PcepAttribute getPcepAttribute() { 240 + public PcepAttribute getPcepAttribute() {
241 - return this.pcepAttribute; 241 + return this.pcepAttribute;
242 - } 242 + }
243 - 243 +
244 - @Override 244 + @Override
245 - public Builder setSrpObject(PcepSrpObject srpobj) { 245 + public Builder setSrpObject(PcepSrpObject srpobj) {
246 - this.srpObject = srpobj; 246 + this.srpObject = srpobj;
247 - this.bIsSRPObjectSet = true; 247 + this.bIsSRPObjectSet = true;
248 - return this; 248 + return this;
249 - 249 +
250 - } 250 + }
251 - 251 +
252 - @Override 252 + @Override
253 - public Builder setLspObject(PcepLspObject lspObject) { 253 + public Builder setLspObject(PcepLspObject lspObject) {
254 - this.lspObject = lspObject; 254 + this.lspObject = lspObject;
255 - this.bIsLSPObjectSet = true; 255 + this.bIsLSPObjectSet = true;
256 - return this; 256 + return this;
257 - } 257 + }
258 - 258 +
259 - @Override 259 + @Override
260 - public Builder setEndPointsObject(PcepEndPointsObject endPointsObject) { 260 + public Builder setEndPointsObject(PcepEndPointsObject endPointsObject) {
261 - this.endPointsObject = endPointsObject; 261 + this.endPointsObject = endPointsObject;
262 - this.bIsEndPointsObjectSet = true; 262 + this.bIsEndPointsObjectSet = true;
263 - return this; 263 + return this;
264 - } 264 + }
265 - 265 +
266 - @Override 266 + @Override
267 - public Builder setEroObject(PcepEroObject eroObject) { 267 + public Builder setEroObject(PcepEroObject eroObject) {
268 - this.eroObject = eroObject; 268 + this.eroObject = eroObject;
269 - this.bIsEROObjectSet = true; 269 + this.bIsEROObjectSet = true;
270 - return this; 270 + return this;
271 - } 271 + }
272 - 272 +
273 - @Override 273 + @Override
274 - public Builder setPcepAttribute(PcepAttribute pcepAttribute) { 274 + public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
275 - this.pcepAttribute = pcepAttribute; 275 + this.pcepAttribute = pcepAttribute;
276 - this.bIsPcepAttributeSet = true; 276 + this.bIsPcepAttributeSet = true;
277 - return this; 277 + return this;
278 - } 278 + }
279 - } 279 + }
280 - 280 +
281 - @Override 281 + @Override
282 - public String toString() { 282 + public String toString() {
283 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 283 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
284 - toStrHelper.add("SrpObject", srpObject).add("LspObject", lspObject); 284 + toStrHelper.add("SrpObject", srpObject).add("LspObject", lspObject);
285 - 285 +
286 - if (endPointsObject instanceof PcepEndPointsObject) { 286 + if (endPointsObject instanceof PcepEndPointsObject) {
287 - toStrHelper.add("EndPointObject", endPointsObject); 287 + toStrHelper.add("EndPointObject", endPointsObject);
288 - } 288 + }
289 - if (eroObject instanceof PcepEroObject) { 289 + if (eroObject instanceof PcepEroObject) {
290 - toStrHelper.add("EroObject", eroObject); 290 + toStrHelper.add("EroObject", eroObject);
291 - } 291 + }
292 - if (pcepAttribute instanceof PcepAttribute) { 292 + if (pcepAttribute instanceof PcepAttribute) {
293 - toStrHelper.add("PcepAttribute", pcepAttribute); 293 + toStrHelper.add("PcepAttribute", pcepAttribute);
294 - } 294 + }
295 - return toStrHelper.toString(); 295 + return toStrHelper.toString();
296 - } 296 + }
297 -} 297 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepAttribute; 24 +import org.onosproject.pcepio.protocol.PcepAttribute;
25 -import org.onosproject.pcepio.protocol.PcepBandwidthObject; 25 +import org.onosproject.pcepio.protocol.PcepBandwidthObject;
26 -import org.onosproject.pcepio.protocol.PcepIroObject; 26 +import org.onosproject.pcepio.protocol.PcepIroObject;
27 -import org.onosproject.pcepio.protocol.PcepLspaObject; 27 +import org.onosproject.pcepio.protocol.PcepLspaObject;
28 -import org.onosproject.pcepio.protocol.PcepMetricObject; 28 +import org.onosproject.pcepio.protocol.PcepMetricObject;
29 -import org.onosproject.pcepio.types.PcepObjectHeader; 29 +import org.onosproject.pcepio.types.PcepObjectHeader;
30 -import org.slf4j.Logger; 30 +import org.slf4j.Logger;
31 -import org.slf4j.LoggerFactory; 31 +import org.slf4j.LoggerFactory;
32 - 32 +
33 -import com.google.common.base.MoreObjects; 33 +import com.google.common.base.MoreObjects;
34 -import com.google.common.base.MoreObjects.ToStringHelper; 34 +import com.google.common.base.MoreObjects.ToStringHelper;
35 - 35 +
36 -/** 36 +/**
37 - * Provides PCEP Attribute List. 37 + * Provides PCEP Attribute List.
38 - */ 38 + */
39 -public class PcepAttributeVer1 implements PcepAttribute { 39 +public class PcepAttributeVer1 implements PcepAttribute {
40 - 40 +
41 - /* Reference : RFC5440 41 + /* Reference : RFC5440
42 - * where: 42 + * where:
43 - * <attribute-list> ::=[<LSPA>] 43 + * <attribute-list> ::=[<LSPA>]
44 - * [<BANDWIDTH>] 44 + * [<BANDWIDTH>]
45 - * [<metric-list>] 45 + * [<metric-list>]
46 - * [<IRO>] 46 + * [<IRO>]
47 - * 47 + *
48 - * <metric-list> ::=<METRIC>[<metric-list>] 48 + * <metric-list> ::=<METRIC>[<metric-list>]
49 - */ 49 + */
50 - protected static final Logger log = LoggerFactory.getLogger(PcepAttributeVer1.class); 50 + protected static final Logger log = LoggerFactory.getLogger(PcepAttributeVer1.class);
51 - 51 +
52 - public static final int OBJECT_HEADER_LENGTH = 4; 52 + public static final int OBJECT_HEADER_LENGTH = 4;
53 - 53 +
54 - //PCEP LSPA Object 54 + //PCEP LSPA Object
55 - private PcepLspaObject lspaObject; 55 + private PcepLspaObject lspaObject;
56 - private boolean isLspaObjectSet; 56 + private boolean isLspaObjectSet;
57 - 57 +
58 - //PCEP Bandwidth Object 58 + //PCEP Bandwidth Object
59 - private PcepBandwidthObject bandwidthObject; 59 + private PcepBandwidthObject bandwidthObject;
60 - private boolean isBandwidthObjectSet; 60 + private boolean isBandwidthObjectSet;
61 - 61 +
62 - //PCEP Metric list 62 + //PCEP Metric list
63 - private LinkedList<PcepMetricObject> llMetricList; 63 + private LinkedList<PcepMetricObject> llMetricList;
64 - private boolean isMetricListSet; 64 + private boolean isMetricListSet;
65 - 65 +
66 - //PCEP IRO object 66 + //PCEP IRO object
67 - private PcepIroObject iroObject; 67 + private PcepIroObject iroObject;
68 - private boolean isIroObjectSet; 68 + private boolean isIroObjectSet;
69 - 69 +
70 - /** 70 + /**
71 - * Default constructor to initialize member variables. 71 + * Default constructor to initialize member variables.
72 - */ 72 + */
73 - public PcepAttributeVer1() { 73 + public PcepAttributeVer1() {
74 - 74 +
75 - lspaObject = null; 75 + lspaObject = null;
76 - bandwidthObject = null; 76 + bandwidthObject = null;
77 - llMetricList = null; 77 + llMetricList = null;
78 - iroObject = null; 78 + iroObject = null;
79 - this.isLspaObjectSet = false; 79 + this.isLspaObjectSet = false;
80 - this.isBandwidthObjectSet = false; 80 + this.isBandwidthObjectSet = false;
81 - this.isMetricListSet = false; 81 + this.isMetricListSet = false;
82 - this.isIroObjectSet = false; 82 + this.isIroObjectSet = false;
83 - } 83 + }
84 - 84 +
85 - /** 85 + /**
86 - * Constructor to initialize all parameters for PCEP attribute. 86 + * Constructor to initialize all parameters for PCEP attribute.
87 - * 87 + *
88 - * @param lspaObject PCEP lspa Object. 88 + * @param lspaObject PCEP lspa Object.
89 - * @param bandwidthObject PCEP bandwidth object. 89 + * @param bandwidthObject PCEP bandwidth object.
90 - * @param llMetricList list of PCEP metric objects. 90 + * @param llMetricList list of PCEP metric objects.
91 - * @param iroObject PCEP iro object. 91 + * @param iroObject PCEP iro object.
92 - */ 92 + */
93 - public PcepAttributeVer1(PcepLspaObject lspaObject, PcepBandwidthObject bandwidthObject, 93 + public PcepAttributeVer1(PcepLspaObject lspaObject, PcepBandwidthObject bandwidthObject,
94 - LinkedList<PcepMetricObject> llMetricList, PcepIroObject iroObject) { 94 + LinkedList<PcepMetricObject> llMetricList, PcepIroObject iroObject) {
95 - 95 +
96 - this.lspaObject = lspaObject; 96 + this.lspaObject = lspaObject;
97 - this.bandwidthObject = bandwidthObject; 97 + this.bandwidthObject = bandwidthObject;
98 - this.llMetricList = llMetricList; 98 + this.llMetricList = llMetricList;
99 - this.iroObject = iroObject; 99 + this.iroObject = iroObject;
100 - if (lspaObject == null) { 100 + if (lspaObject == null) {
101 - this.isLspaObjectSet = false; 101 + this.isLspaObjectSet = false;
102 - } else { 102 + } else {
103 - this.isLspaObjectSet = true; 103 + this.isLspaObjectSet = true;
104 - } 104 + }
105 - if (bandwidthObject == null) { 105 + if (bandwidthObject == null) {
106 - this.isBandwidthObjectSet = false; 106 + this.isBandwidthObjectSet = false;
107 - } else { 107 + } else {
108 - this.isBandwidthObjectSet = true; 108 + this.isBandwidthObjectSet = true;
109 - } 109 + }
110 - if (llMetricList == null) { 110 + if (llMetricList == null) {
111 - this.isMetricListSet = false; 111 + this.isMetricListSet = false;
112 - } else { 112 + } else {
113 - this.isMetricListSet = true; 113 + this.isMetricListSet = true;
114 - } 114 + }
115 - if (iroObject == null) { 115 + if (iroObject == null) {
116 - this.isIroObjectSet = false; 116 + this.isIroObjectSet = false;
117 - } else { 117 + } else {
118 - this.isIroObjectSet = true; 118 + this.isIroObjectSet = true;
119 - } 119 + }
120 - } 120 + }
121 - 121 +
122 - /** 122 + /**
123 - * constructor to initialize bandwidthObject. 123 + * constructor to initialize bandwidthObject.
124 - * 124 + *
125 - * @param bandwidthObject bandwidth object 125 + * @param bandwidthObject bandwidth object
126 - */ 126 + */
127 - public PcepAttributeVer1(PcepBandwidthObject bandwidthObject) { 127 + public PcepAttributeVer1(PcepBandwidthObject bandwidthObject) {
128 - this.isLspaObjectSet = false; 128 + this.isLspaObjectSet = false;
129 - 129 +
130 - this.bandwidthObject = bandwidthObject; 130 + this.bandwidthObject = bandwidthObject;
131 - this.isBandwidthObjectSet = true; 131 + this.isBandwidthObjectSet = true;
132 - 132 +
133 - this.isMetricListSet = false; 133 + this.isMetricListSet = false;
134 - 134 +
135 - this.isIroObjectSet = false; 135 + this.isIroObjectSet = false;
136 - } 136 + }
137 - 137 +
138 - /** 138 + /**
139 - * Parse list for MeticObject. 139 + * Parse list for MeticObject.
140 - * 140 + *
141 - * @param cb of type channel buffer 141 + * @param cb of type channel buffer
142 - * @return true if parsing metric list is success 142 + * @return true if parsing metric list is success
143 - * @throws PcepParseException when a non metric object is received 143 + * @throws PcepParseException when a non metric object is received
144 - */ 144 + */
145 - public boolean parseMetricList(ChannelBuffer cb) throws PcepParseException { 145 + public boolean parseMetricList(ChannelBuffer cb) throws PcepParseException {
146 - 146 +
147 - if (null == llMetricList) { 147 + if (null == llMetricList) {
148 - llMetricList = new LinkedList<PcepMetricObject>(); 148 + llMetricList = new LinkedList<PcepMetricObject>();
149 - } 149 + }
150 - 150 +
151 - PcepMetricObject metriclist; 151 + PcepMetricObject metriclist;
152 - 152 +
153 - //caller should verify for metric object 153 + //caller should verify for metric object
154 - byte yObjClass = PcepMetricObjectVer1.METRIC_OBJ_CLASS; 154 + byte yObjClass = PcepMetricObjectVer1.METRIC_OBJ_CLASS;
155 - byte yObjType = PcepMetricObjectVer1.METRIC_OBJ_TYPE; 155 + byte yObjType = PcepMetricObjectVer1.METRIC_OBJ_TYPE;
156 - 156 +
157 - while ((yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS) 157 + while ((yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS)
158 - && (yObjType == PcepMetricObjectVer1.METRIC_OBJ_TYPE)) { 158 + && (yObjType == PcepMetricObjectVer1.METRIC_OBJ_TYPE)) {
159 - 159 +
160 - metriclist = PcepMetricObjectVer1.read(cb); 160 + metriclist = PcepMetricObjectVer1.read(cb);
161 - llMetricList.add(metriclist); 161 + llMetricList.add(metriclist);
162 - yObjClass = 0; 162 + yObjClass = 0;
163 - yObjType = 0; 163 + yObjType = 0;
164 - 164 +
165 - if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { 165 + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
166 - cb.markReaderIndex(); 166 + cb.markReaderIndex();
167 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 167 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
168 - cb.resetReaderIndex(); 168 + cb.resetReaderIndex();
169 - yObjClass = tempObjHeader.getObjClass(); 169 + yObjClass = tempObjHeader.getObjClass();
170 - yObjType = tempObjHeader.getObjType(); 170 + yObjType = tempObjHeader.getObjType();
171 - } 171 + }
172 - } 172 + }
173 - return true; 173 + return true;
174 - } 174 + }
175 - 175 +
176 - /** 176 + /**
177 - * Reads lspa , bandwidth , Metriclist and Iro objects and sets the objects. 177 + * Reads lspa , bandwidth , Metriclist and Iro objects and sets the objects.
178 - * 178 + *
179 - * @param cb of type channel buffer 179 + * @param cb of type channel buffer
180 - * @return instance of Pcep Attribute 180 + * @return instance of Pcep Attribute
181 - * @throws PcepParseException while parsing Pcep Attributes from channel buffer 181 + * @throws PcepParseException while parsing Pcep Attributes from channel buffer
182 - */ 182 + */
183 - 183 +
184 - public static PcepAttribute read(ChannelBuffer cb) throws PcepParseException { 184 + public static PcepAttribute read(ChannelBuffer cb) throws PcepParseException {
185 - if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { 185 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
186 - return null; 186 + return null;
187 - } 187 + }
188 - //check whether any pcep attribute is present 188 + //check whether any pcep attribute is present
189 - cb.markReaderIndex(); 189 + cb.markReaderIndex();
190 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 190 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
191 - cb.resetReaderIndex(); 191 + cb.resetReaderIndex();
192 - byte yObjClass = tempObjHeader.getObjClass(); 192 + byte yObjClass = tempObjHeader.getObjClass();
193 - 193 +
194 - if (PcepLspaObjectVer1.LSPA_OBJ_CLASS != yObjClass && PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS != yObjClass 194 + if (PcepLspaObjectVer1.LSPA_OBJ_CLASS != yObjClass && PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS != yObjClass
195 - && PcepMetricObjectVer1.METRIC_OBJ_CLASS != yObjClass && PcepIroObjectVer1.IRO_OBJ_CLASS != yObjClass) { 195 + && PcepMetricObjectVer1.METRIC_OBJ_CLASS != yObjClass && PcepIroObjectVer1.IRO_OBJ_CLASS != yObjClass) {
196 - //No PCEP attribute is present 196 + //No PCEP attribute is present
197 - return null; 197 + return null;
198 - } 198 + }
199 - 199 +
200 - PcepAttributeVer1 pcepAttribute = new PcepAttributeVer1(); 200 + PcepAttributeVer1 pcepAttribute = new PcepAttributeVer1();
201 - 201 +
202 - //If LSPA present then store it.LSPA is optional 202 + //If LSPA present then store it.LSPA is optional
203 - if (yObjClass == PcepLspaObjectVer1.LSPA_OBJ_CLASS) { 203 + if (yObjClass == PcepLspaObjectVer1.LSPA_OBJ_CLASS) {
204 - pcepAttribute.setLspaObject(PcepLspaObjectVer1.read(cb)); 204 + pcepAttribute.setLspaObject(PcepLspaObjectVer1.read(cb));
205 - yObjClass = checkNextObject(cb); 205 + yObjClass = checkNextObject(cb);
206 - } 206 + }
207 - 207 +
208 - //If BANDWIDTH present then store it.BANDWIDTH is optional 208 + //If BANDWIDTH present then store it.BANDWIDTH is optional
209 - if (yObjClass == PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS) { 209 + if (yObjClass == PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS) {
210 - pcepAttribute.setBandwidthObject(PcepBandwidthObjectVer1.read(cb)); 210 + pcepAttribute.setBandwidthObject(PcepBandwidthObjectVer1.read(cb));
211 - yObjClass = checkNextObject(cb); 211 + yObjClass = checkNextObject(cb);
212 - } 212 + }
213 - 213 +
214 - //If Metric list present then store it.MetricList is optional 214 + //If Metric list present then store it.MetricList is optional
215 - if (yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS) { 215 + if (yObjClass == PcepMetricObjectVer1.METRIC_OBJ_CLASS) {
216 - pcepAttribute.parseMetricList(cb); 216 + pcepAttribute.parseMetricList(cb);
217 - yObjClass = checkNextObject(cb); 217 + yObjClass = checkNextObject(cb);
218 - } 218 + }
219 - 219 +
220 - //If IRO present then store it.IRO is optional 220 + //If IRO present then store it.IRO is optional
221 - if (yObjClass == PcepIroObjectVer1.IRO_OBJ_CLASS) { 221 + if (yObjClass == PcepIroObjectVer1.IRO_OBJ_CLASS) {
222 - pcepAttribute.setIroObject(PcepIroObjectVer1.read(cb)); 222 + pcepAttribute.setIroObject(PcepIroObjectVer1.read(cb));
223 - } 223 + }
224 - 224 +
225 - PcepLspaObject lspaObject = pcepAttribute.getLspaObject(); 225 + PcepLspaObject lspaObject = pcepAttribute.getLspaObject();
226 - PcepBandwidthObject bandwidthObject = pcepAttribute.getBandwidthObject(); 226 + PcepBandwidthObject bandwidthObject = pcepAttribute.getBandwidthObject();
227 - LinkedList<PcepMetricObject> metriclist = pcepAttribute.llMetricList; 227 + LinkedList<PcepMetricObject> metriclist = pcepAttribute.llMetricList;
228 - PcepIroObject iroObject = pcepAttribute.getIroObject(); 228 + PcepIroObject iroObject = pcepAttribute.getIroObject();
229 - 229 +
230 - return new PcepAttributeVer1(lspaObject, bandwidthObject, metriclist, iroObject); 230 + return new PcepAttributeVer1(lspaObject, bandwidthObject, metriclist, iroObject);
231 - } 231 + }
232 - 232 +
233 - /** 233 + /**
234 - * Checks whether there is a more object or not. 234 + * Checks whether there is a more object or not.
235 - * 235 + *
236 - * @param cb of type channel buffer 236 + * @param cb of type channel buffer
237 - * @return instance of object header 237 + * @return instance of object header
238 - */ 238 + */
239 - private static byte checkNextObject(ChannelBuffer cb) { 239 + private static byte checkNextObject(ChannelBuffer cb) {
240 - if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { 240 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
241 - return 0; 241 + return 0;
242 - } 242 + }
243 - cb.markReaderIndex(); 243 + cb.markReaderIndex();
244 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 244 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
245 - cb.resetReaderIndex(); 245 + cb.resetReaderIndex();
246 - return tempObjHeader.getObjClass(); 246 + return tempObjHeader.getObjClass();
247 - } 247 + }
248 - 248 +
249 - @Override 249 + @Override
250 - public int write(ChannelBuffer cb) throws PcepParseException { 250 + public int write(ChannelBuffer cb) throws PcepParseException {
251 - int iLenStartIndex = cb.writerIndex(); 251 + int iLenStartIndex = cb.writerIndex();
252 - //PCEP LSPA object is optional 252 + //PCEP LSPA object is optional
253 - if (this.isLspaObjectSet) { 253 + if (this.isLspaObjectSet) {
254 - this.lspaObject.write(cb); 254 + this.lspaObject.write(cb);
255 - } 255 + }
256 - 256 +
257 - //PCEP BANDWIDTH object is optional 257 + //PCEP BANDWIDTH object is optional
258 - if (this.isBandwidthObjectSet) { 258 + if (this.isBandwidthObjectSet) {
259 - this.bandwidthObject.write(cb); 259 + this.bandwidthObject.write(cb);
260 - } 260 + }
261 - 261 +
262 - //PCEP Metric list is optional 262 + //PCEP Metric list is optional
263 - if (this.isMetricListSet) { 263 + if (this.isMetricListSet) {
264 - ListIterator<PcepMetricObject> listIterator = this.llMetricList.listIterator(); 264 + ListIterator<PcepMetricObject> listIterator = this.llMetricList.listIterator();
265 - while (listIterator.hasNext()) { 265 + while (listIterator.hasNext()) {
266 - listIterator.next().write(cb); 266 + listIterator.next().write(cb);
267 - } 267 + }
268 - } 268 + }
269 - 269 +
270 - //PCEP IRO object is optional 270 + //PCEP IRO object is optional
271 - if (this.isIroObjectSet) { 271 + if (this.isIroObjectSet) {
272 - this.iroObject.write(cb); 272 + this.iroObject.write(cb);
273 - } 273 + }
274 - return cb.writerIndex() - iLenStartIndex; 274 + return cb.writerIndex() - iLenStartIndex;
275 - } 275 + }
276 - 276 +
277 - @Override 277 + @Override
278 - public PcepLspaObject getLspaObject() { 278 + public PcepLspaObject getLspaObject() {
279 - return lspaObject; 279 + return lspaObject;
280 - } 280 + }
281 - 281 +
282 - @Override 282 + @Override
283 - public PcepBandwidthObject getBandwidthObject() { 283 + public PcepBandwidthObject getBandwidthObject() {
284 - return bandwidthObject; 284 + return bandwidthObject;
285 - } 285 + }
286 - 286 +
287 - @Override 287 + @Override
288 - public LinkedList<PcepMetricObject> getMetricObjectList() { 288 + public LinkedList<PcepMetricObject> getMetricObjectList() {
289 - return llMetricList; 289 + return llMetricList;
290 - } 290 + }
291 - 291 +
292 - @Override 292 + @Override
293 - public PcepIroObject getIroObject() { 293 + public PcepIroObject getIroObject() {
294 - return iroObject; 294 + return iroObject;
295 - } 295 + }
296 - 296 +
297 - @Override 297 + @Override
298 - public void setBandwidthObject(PcepBandwidthObject bandwidthObject) { 298 + public void setBandwidthObject(PcepBandwidthObject bandwidthObject) {
299 - this.isBandwidthObjectSet = true; 299 + this.isBandwidthObjectSet = true;
300 - this.bandwidthObject = bandwidthObject; 300 + this.bandwidthObject = bandwidthObject;
301 - } 301 + }
302 - 302 +
303 - @Override 303 + @Override
304 - public void setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) { 304 + public void setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) {
305 - this.isMetricListSet = true; 305 + this.isMetricListSet = true;
306 - this.llMetricList = llMetricList; 306 + this.llMetricList = llMetricList;
307 - 307 +
308 - } 308 + }
309 - 309 +
310 - @Override 310 + @Override
311 - public void setLspaObject(PcepLspaObject lspaObject) { 311 + public void setLspaObject(PcepLspaObject lspaObject) {
312 - this.isLspaObjectSet = true; 312 + this.isLspaObjectSet = true;
313 - this.lspaObject = lspaObject; 313 + this.lspaObject = lspaObject;
314 - } 314 + }
315 - 315 +
316 - @Override 316 + @Override
317 - public void setIroObject(PcepIroObject iroObject) { 317 + public void setIroObject(PcepIroObject iroObject) {
318 - this.isIroObjectSet = true; 318 + this.isIroObjectSet = true;
319 - this.iroObject = iroObject; 319 + this.iroObject = iroObject;
320 - } 320 + }
321 - 321 +
322 - /** 322 + /**
323 - * Builder class for PCEP attributes. 323 + * Builder class for PCEP attributes.
324 - */ 324 + */
325 - public static class Builder implements PcepAttribute.Builder { 325 + public static class Builder implements PcepAttribute.Builder {
326 - 326 +
327 - //PCEP LSPA Object 327 + //PCEP LSPA Object
328 - private PcepLspaObject lspaObject; 328 + private PcepLspaObject lspaObject;
329 - private boolean isLspaObjectSet; 329 + private boolean isLspaObjectSet;
330 - 330 +
331 - //PCEP BANDWIDTH Object 331 + //PCEP BANDWIDTH Object
332 - private PcepBandwidthObject bandwidthObject; 332 + private PcepBandwidthObject bandwidthObject;
333 - private boolean isBandwidthObjectSet; 333 + private boolean isBandwidthObjectSet;
334 - 334 +
335 - //PCEP Metric list 335 + //PCEP Metric list
336 - private LinkedList<PcepMetricObject> llMetricList; 336 + private LinkedList<PcepMetricObject> llMetricList;
337 - private boolean isMetricListSet; 337 + private boolean isMetricListSet;
338 - 338 +
339 - //PCEP IRO object 339 + //PCEP IRO object
340 - private PcepIroObject iroObject; 340 + private PcepIroObject iroObject;
341 - private boolean isIroObjectSet; 341 + private boolean isIroObjectSet;
342 - 342 +
343 - @Override 343 + @Override
344 - public PcepAttribute build() { 344 + public PcepAttribute build() {
345 - 345 +
346 - //PCEP LSPA Object 346 + //PCEP LSPA Object
347 - PcepLspaObject lspaObject = null; 347 + PcepLspaObject lspaObject = null;
348 - 348 +
349 - //PCEP BANDWIDTH Object 349 + //PCEP BANDWIDTH Object
350 - PcepBandwidthObject bandwidthObject = null; 350 + PcepBandwidthObject bandwidthObject = null;
351 - 351 +
352 - //PCEP Metric list 352 + //PCEP Metric list
353 - LinkedList<PcepMetricObject> llMetricList = null; 353 + LinkedList<PcepMetricObject> llMetricList = null;
354 - 354 +
355 - //PCEP IRO object 355 + //PCEP IRO object
356 - PcepIroObject iroObject = null; 356 + PcepIroObject iroObject = null;
357 - 357 +
358 - if (this.isLspaObjectSet) { 358 + if (this.isLspaObjectSet) {
359 - lspaObject = this.lspaObject; 359 + lspaObject = this.lspaObject;
360 - } 360 + }
361 - if (this.isBandwidthObjectSet) { 361 + if (this.isBandwidthObjectSet) {
362 - bandwidthObject = this.bandwidthObject; 362 + bandwidthObject = this.bandwidthObject;
363 - } 363 + }
364 - if (this.isMetricListSet) { 364 + if (this.isMetricListSet) {
365 - llMetricList = this.llMetricList; 365 + llMetricList = this.llMetricList;
366 - } 366 + }
367 - if (this.isIroObjectSet) { 367 + if (this.isIroObjectSet) {
368 - iroObject = this.iroObject; 368 + iroObject = this.iroObject;
369 - } 369 + }
370 - return new PcepAttributeVer1(lspaObject, bandwidthObject, llMetricList, iroObject); 370 + return new PcepAttributeVer1(lspaObject, bandwidthObject, llMetricList, iroObject);
371 - } 371 + }
372 - 372 +
373 - @Override 373 + @Override
374 - public PcepLspaObject getLspaObject() { 374 + public PcepLspaObject getLspaObject() {
375 - return this.lspaObject; 375 + return this.lspaObject;
376 - } 376 + }
377 - 377 +
378 - @Override 378 + @Override
379 - public PcepBandwidthObject getBandwidthObject() { 379 + public PcepBandwidthObject getBandwidthObject() {
380 - return this.bandwidthObject; 380 + return this.bandwidthObject;
381 - } 381 + }
382 - 382 +
383 - @Override 383 + @Override
384 - public LinkedList<PcepMetricObject> getMetricObjectList() { 384 + public LinkedList<PcepMetricObject> getMetricObjectList() {
385 - return this.llMetricList; 385 + return this.llMetricList;
386 - } 386 + }
387 - 387 +
388 - @Override 388 + @Override
389 - public PcepIroObject getIroObject() { 389 + public PcepIroObject getIroObject() {
390 - return this.iroObject; 390 + return this.iroObject;
391 - } 391 + }
392 - 392 +
393 - @Override 393 + @Override
394 - public Builder setBandwidthObject(PcepBandwidthObject bandwidthObject) { 394 + public Builder setBandwidthObject(PcepBandwidthObject bandwidthObject) {
395 - this.isBandwidthObjectSet = true; 395 + this.isBandwidthObjectSet = true;
396 - this.bandwidthObject = bandwidthObject; 396 + this.bandwidthObject = bandwidthObject;
397 - return this; 397 + return this;
398 - } 398 + }
399 - 399 +
400 - @Override 400 + @Override
401 - public Builder setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) { 401 + public Builder setMetricObjectList(LinkedList<PcepMetricObject> llMetricList) {
402 - this.isMetricListSet = true; 402 + this.isMetricListSet = true;
403 - this.llMetricList = llMetricList; 403 + this.llMetricList = llMetricList;
404 - return this; 404 + return this;
405 - } 405 + }
406 - 406 +
407 - @Override 407 + @Override
408 - public Builder setLspaObject(PcepLspaObject lspaObject) { 408 + public Builder setLspaObject(PcepLspaObject lspaObject) {
409 - this.isLspaObjectSet = true; 409 + this.isLspaObjectSet = true;
410 - this.lspaObject = lspaObject; 410 + this.lspaObject = lspaObject;
411 - return this; 411 + return this;
412 - } 412 + }
413 - 413 +
414 - @Override 414 + @Override
415 - public Builder setIroObject(PcepIroObject iroObject) { 415 + public Builder setIroObject(PcepIroObject iroObject) {
416 - this.isIroObjectSet = true; 416 + this.isIroObjectSet = true;
417 - this.iroObject = iroObject; 417 + this.iroObject = iroObject;
418 - return this; 418 + return this;
419 - } 419 + }
420 - } 420 + }
421 - 421 +
422 - @Override 422 + @Override
423 - public String toString() { 423 + public String toString() {
424 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 424 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
425 - 425 +
426 - if (lspaObject instanceof PcepLspaObject) { 426 + if (lspaObject instanceof PcepLspaObject) {
427 - toStrHelper.add("lspaObject", lspaObject); 427 + toStrHelper.add("lspaObject", lspaObject);
428 - } 428 + }
429 - if (bandwidthObject instanceof PcepBandwidthObject) { 429 + if (bandwidthObject instanceof PcepBandwidthObject) {
430 - toStrHelper.add("bandwidthObject", bandwidthObject); 430 + toStrHelper.add("bandwidthObject", bandwidthObject);
431 - } 431 + }
432 - if (llMetricList instanceof PcepMetricObject) { 432 + if (llMetricList instanceof PcepMetricObject) {
433 - toStrHelper.add("MetricObjectList", llMetricList); 433 + toStrHelper.add("MetricObjectList", llMetricList);
434 - } 434 + }
435 - if (iroObject instanceof PcepIroObject) { 435 + if (iroObject instanceof PcepIroObject) {
436 - toStrHelper.add("IroObject", iroObject); 436 + toStrHelper.add("IroObject", iroObject);
437 - } 437 + }
438 - return toStrHelper.toString(); 438 + return toStrHelper.toString();
439 - } 439 + }
440 } 440 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
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.PcepEndPointsObject; 21 +import org.onosproject.pcepio.protocol.PcepEndPointsObject;
22 -import org.onosproject.pcepio.types.PcepObjectHeader; 22 +import org.onosproject.pcepio.types.PcepObjectHeader;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Provides PCEP Endpoints Object. 29 + * Provides PCEP Endpoints Object.
30 - */ 30 + */
31 -public class PcepEndPointsObjectVer1 implements PcepEndPointsObject { 31 +public class PcepEndPointsObjectVer1 implements PcepEndPointsObject {
32 - 32 +
33 - /* 33 + /*
34 - * RFC : 5440 , section : 7.6 34 + * RFC : 5440 , section : 7.6
35 - * An End point is defined as follows: 35 + * An End point is defined as follows:
36 - END-POINTS Object-Class is 4. 36 + END-POINTS Object-Class is 4.
37 - 37 +
38 - END-POINTS Object-Type is 1 for IPv4 and 2 for IPv6. 38 + END-POINTS Object-Type is 1 for IPv4 and 2 for IPv6.
39 - 0 1 2 3 39 + 0 1 2 3
40 - 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 + 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
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | Object-Class | OT |Res|P|I| Object Length (bytes) | 42 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - | Source IPv4 address | 44 + | Source IPv4 address |
45 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 - | Destination IPv4 address | 46 + | Destination IPv4 address |
47 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 - 48 +
49 - */ 49 + */
50 - protected static final Logger log = LoggerFactory.getLogger(PcepEndPointsObjectVer1.class); 50 + protected static final Logger log = LoggerFactory.getLogger(PcepEndPointsObjectVer1.class);
51 - 51 +
52 - static final byte END_POINTS_OBJ_TYPE = 1; 52 + static final byte END_POINTS_OBJ_TYPE = 1;
53 - static final byte END_POINTS_OBJ_CLASS = 4; 53 + static final byte END_POINTS_OBJ_CLASS = 4;
54 - static final byte END_POINTS_OBJECT_VERSION = 1; 54 + static final byte END_POINTS_OBJECT_VERSION = 1;
55 - static final short END_POINTS_OBJ_MINIMUM_LENGTH = 12; 55 + static final short END_POINTS_OBJ_MINIMUM_LENGTH = 12;
56 - public static byte endPointObjType; 56 + public static byte endPointObjType;
57 - 57 +
58 - static final PcepObjectHeader DEFAULT_END_POINTS_OBJECT_HEADER = new PcepObjectHeader(END_POINTS_OBJ_CLASS, 58 + static final PcepObjectHeader DEFAULT_END_POINTS_OBJECT_HEADER = new PcepObjectHeader(END_POINTS_OBJ_CLASS,
59 - END_POINTS_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, 59 + END_POINTS_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
60 - END_POINTS_OBJ_MINIMUM_LENGTH); 60 + END_POINTS_OBJ_MINIMUM_LENGTH);
61 - 61 +
62 - private PcepObjectHeader endPointsObjHeader; 62 + private PcepObjectHeader endPointsObjHeader;
63 - public int sourceIpAddress; 63 + public int sourceIpAddress;
64 - public int destIpAddress; 64 + public int destIpAddress;
65 - 65 +
66 - /** 66 + /**
67 - * Constructor to initialize all variables. 67 + * Constructor to initialize all variables.
68 - * 68 + *
69 - * @param endPointsObjHeader end points object header 69 + * @param endPointsObjHeader end points object header
70 - * @param sourceIpAddress source IP address 70 + * @param sourceIpAddress source IP address
71 - * @param destIpAddress destination IP address 71 + * @param destIpAddress destination IP address
72 - */ 72 + */
73 - public PcepEndPointsObjectVer1(PcepObjectHeader endPointsObjHeader, int sourceIpAddress, int destIpAddress) { 73 + public PcepEndPointsObjectVer1(PcepObjectHeader endPointsObjHeader, int sourceIpAddress, int destIpAddress) {
74 - 74 +
75 - this.endPointsObjHeader = endPointsObjHeader; 75 + this.endPointsObjHeader = endPointsObjHeader;
76 - this.sourceIpAddress = sourceIpAddress; 76 + this.sourceIpAddress = sourceIpAddress;
77 - this.destIpAddress = destIpAddress; 77 + this.destIpAddress = destIpAddress;
78 - } 78 + }
79 - 79 +
80 - /** 80 + /**
81 - * Sets End Points Object Header. 81 + * Sets End Points Object Header.
82 - * 82 + *
83 - * @param obj of PcepObjectHeader 83 + * @param obj of PcepObjectHeader
84 - */ 84 + */
85 - public void setEndPointsObjHeader(PcepObjectHeader obj) { 85 + public void setEndPointsObjHeader(PcepObjectHeader obj) {
86 - this.endPointsObjHeader = obj; 86 + this.endPointsObjHeader = obj;
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public void setSourceIpAddress(int sourceIpAddress) { 90 + public void setSourceIpAddress(int sourceIpAddress) {
91 - this.sourceIpAddress = sourceIpAddress; 91 + this.sourceIpAddress = sourceIpAddress;
92 - } 92 + }
93 - 93 +
94 - @Override 94 + @Override
95 - public void setDestIpAddress(int destIpAddress) { 95 + public void setDestIpAddress(int destIpAddress) {
96 - this.destIpAddress = destIpAddress; 96 + this.destIpAddress = destIpAddress;
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public int getSourceIpAddress() { 100 + public int getSourceIpAddress() {
101 - return this.sourceIpAddress; 101 + return this.sourceIpAddress;
102 - } 102 + }
103 - 103 +
104 - @Override 104 + @Override
105 - public int getDestIpAddress() { 105 + public int getDestIpAddress() {
106 - return this.destIpAddress; 106 + return this.destIpAddress;
107 - } 107 + }
108 - 108 +
109 - /** 109 + /**
110 - * Reads from channel buffer and returns object of PcepEndPointsObject. 110 + * Reads from channel buffer and returns object of PcepEndPointsObject.
111 - * 111 + *
112 - * @param cb of channel buffer 112 + * @param cb of channel buffer
113 - * @return object of PcepEndPointsObject 113 + * @return object of PcepEndPointsObject
114 - * @throws PcepParseException while parsing channel buffer 114 + * @throws PcepParseException while parsing channel buffer
115 - */ 115 + */
116 - public static PcepEndPointsObject read(ChannelBuffer cb) throws PcepParseException { 116 + public static PcepEndPointsObject read(ChannelBuffer cb) throws PcepParseException {
117 - 117 +
118 - PcepObjectHeader endPointsObjHeader; 118 + PcepObjectHeader endPointsObjHeader;
119 - int sourceIpAddress; 119 + int sourceIpAddress;
120 - int destIpAddress; 120 + int destIpAddress;
121 - 121 +
122 - endPointsObjHeader = PcepObjectHeader.read(cb); 122 + endPointsObjHeader = PcepObjectHeader.read(cb);
123 - if (END_POINTS_OBJ_TYPE == endPointsObjHeader.getObjType() 123 + if (END_POINTS_OBJ_TYPE == endPointsObjHeader.getObjType()
124 - && END_POINTS_OBJ_CLASS == endPointsObjHeader.getObjClass()) { 124 + && END_POINTS_OBJ_CLASS == endPointsObjHeader.getObjClass()) {
125 - sourceIpAddress = cb.readInt(); 125 + sourceIpAddress = cb.readInt();
126 - destIpAddress = cb.readInt(); 126 + destIpAddress = cb.readInt();
127 - } else { 127 + } else {
128 - throw new PcepParseException("Expected PcepEndPointsObject."); 128 + throw new PcepParseException("Expected PcepEndPointsObject.");
129 - } 129 + }
130 - return new PcepEndPointsObjectVer1(endPointsObjHeader, sourceIpAddress, destIpAddress); 130 + return new PcepEndPointsObjectVer1(endPointsObjHeader, sourceIpAddress, destIpAddress);
131 - } 131 + }
132 - 132 +
133 - @Override 133 + @Override
134 - public int write(ChannelBuffer cb) throws PcepParseException { 134 + public int write(ChannelBuffer cb) throws PcepParseException {
135 - 135 +
136 - int objStartIndex = cb.writerIndex(); 136 + int objStartIndex = cb.writerIndex();
137 - //write common header 137 + //write common header
138 - int objLenIndex = endPointsObjHeader.write(cb); 138 + int objLenIndex = endPointsObjHeader.write(cb);
139 - 139 +
140 - //write source IPv4 IP 140 + //write source IPv4 IP
141 - cb.writeInt(sourceIpAddress); 141 + cb.writeInt(sourceIpAddress);
142 - //write destination IPv4 IP 142 + //write destination IPv4 IP
143 - cb.writeInt(destIpAddress); 143 + cb.writeInt(destIpAddress);
144 - 144 +
145 - int length = cb.writerIndex() - objStartIndex; 145 + int length = cb.writerIndex() - objStartIndex;
146 - //now write EndPoints Object Length 146 + //now write EndPoints Object Length
147 - cb.setShort(objLenIndex, (short) length); 147 + cb.setShort(objLenIndex, (short) length);
148 - //will be helpful during print(). 148 + //will be helpful during print().
149 - endPointsObjHeader.setObjLen((short) length); 149 + endPointsObjHeader.setObjLen((short) length);
150 - 150 +
151 - return cb.writerIndex(); 151 + return cb.writerIndex();
152 - 152 +
153 - } 153 + }
154 - 154 +
155 - /** 155 + /**
156 - * Builder class for PCEP end points objects. 156 + * Builder class for PCEP end points objects.
157 - */ 157 + */
158 - public static class Builder implements PcepEndPointsObject.Builder { 158 + public static class Builder implements PcepEndPointsObject.Builder {
159 - 159 +
160 - private boolean bIsHeaderSet = false; 160 + private boolean bIsHeaderSet = false;
161 - private boolean bIsSourceIpAddressset = false; 161 + private boolean bIsSourceIpAddressset = false;
162 - private boolean bIsDestIpAddressset = false; 162 + private boolean bIsDestIpAddressset = false;
163 - private PcepObjectHeader endpointsObjHeader; 163 + private PcepObjectHeader endpointsObjHeader;
164 - private int sourceIpAddress; 164 + private int sourceIpAddress;
165 - private int destIpAddress; 165 + private int destIpAddress;
166 - 166 +
167 - private boolean bIsPFlagSet = false; 167 + private boolean bIsPFlagSet = false;
168 - private boolean bPFlag; 168 + private boolean bPFlag;
169 - 169 +
170 - private boolean bIsIFlagSet = false; 170 + private boolean bIsIFlagSet = false;
171 - private boolean bIFlag; 171 + private boolean bIFlag;
172 - 172 +
173 - @Override 173 + @Override
174 - public PcepEndPointsObject build() throws PcepParseException { 174 + public PcepEndPointsObject build() throws PcepParseException {
175 - 175 +
176 - PcepObjectHeader endpointsObjHeader = this.bIsHeaderSet ? this.endpointsObjHeader 176 + PcepObjectHeader endpointsObjHeader = this.bIsHeaderSet ? this.endpointsObjHeader
177 - : DEFAULT_END_POINTS_OBJECT_HEADER; 177 + : DEFAULT_END_POINTS_OBJECT_HEADER;
178 - 178 +
179 - if (bIsPFlagSet) { 179 + if (bIsPFlagSet) {
180 - endpointsObjHeader.setPFlag(bPFlag); 180 + endpointsObjHeader.setPFlag(bPFlag);
181 - } 181 + }
182 - 182 +
183 - if (bIsIFlagSet) { 183 + if (bIsIFlagSet) {
184 - endpointsObjHeader.setIFlag(bIFlag); 184 + endpointsObjHeader.setIFlag(bIFlag);
185 - } 185 + }
186 - 186 +
187 - if (!this.bIsSourceIpAddressset) { 187 + if (!this.bIsSourceIpAddressset) {
188 - throw new PcepParseException("SourceIpAddress not set while building EndPoints object"); 188 + throw new PcepParseException("SourceIpAddress not set while building EndPoints object");
189 - } 189 + }
190 - 190 +
191 - if (!this.bIsDestIpAddressset) { 191 + if (!this.bIsDestIpAddressset) {
192 - throw new PcepParseException("DestIpAddress not set while building EndPoints object"); 192 + throw new PcepParseException("DestIpAddress not set while building EndPoints object");
193 - } 193 + }
194 - 194 +
195 - return new PcepEndPointsObjectVer1(endpointsObjHeader, this.sourceIpAddress, this.destIpAddress); 195 + return new PcepEndPointsObjectVer1(endpointsObjHeader, this.sourceIpAddress, this.destIpAddress);
196 - } 196 + }
197 - 197 +
198 - @Override 198 + @Override
199 - public PcepObjectHeader getEndPointsObjHeader() { 199 + public PcepObjectHeader getEndPointsObjHeader() {
200 - return this.endpointsObjHeader; 200 + return this.endpointsObjHeader;
201 - } 201 + }
202 - 202 +
203 - @Override 203 + @Override
204 - public Builder setEndPointsObjHeader(PcepObjectHeader obj) { 204 + public Builder setEndPointsObjHeader(PcepObjectHeader obj) {
205 - this.endpointsObjHeader = obj; 205 + this.endpointsObjHeader = obj;
206 - this.bIsHeaderSet = true; 206 + this.bIsHeaderSet = true;
207 - return this; 207 + return this;
208 - } 208 + }
209 - 209 +
210 - @Override 210 + @Override
211 - public int getSourceIpAddress() { 211 + public int getSourceIpAddress() {
212 - return this.sourceIpAddress; 212 + return this.sourceIpAddress;
213 - } 213 + }
214 - 214 +
215 - @Override 215 + @Override
216 - public Builder setSourceIpAddress(int sourceIpAddress) { 216 + public Builder setSourceIpAddress(int sourceIpAddress) {
217 - this.sourceIpAddress = sourceIpAddress; 217 + this.sourceIpAddress = sourceIpAddress;
218 - this.bIsSourceIpAddressset = true; 218 + this.bIsSourceIpAddressset = true;
219 - return this; 219 + return this;
220 - } 220 + }
221 - 221 +
222 - @Override 222 + @Override
223 - public int getDestIpAddress() { 223 + public int getDestIpAddress() {
224 - return this.destIpAddress; 224 + return this.destIpAddress;
225 - } 225 + }
226 - 226 +
227 - @Override 227 + @Override
228 - public Builder setDestIpAddress(int destIpAddress) { 228 + public Builder setDestIpAddress(int destIpAddress) {
229 - this.destIpAddress = destIpAddress; 229 + this.destIpAddress = destIpAddress;
230 - this.bIsDestIpAddressset = true; 230 + this.bIsDestIpAddressset = true;
231 - return this; 231 + return this;
232 - } 232 + }
233 - 233 +
234 - @Override 234 + @Override
235 - public Builder setPFlag(boolean value) { 235 + public Builder setPFlag(boolean value) {
236 - this.bPFlag = value; 236 + this.bPFlag = value;
237 - this.bIsPFlagSet = true; 237 + this.bIsPFlagSet = true;
238 - return this; 238 + return this;
239 - } 239 + }
240 - 240 +
241 - @Override 241 + @Override
242 - public Builder setIFlag(boolean value) { 242 + public Builder setIFlag(boolean value) {
243 - this.bIFlag = value; 243 + this.bIFlag = value;
244 - this.bIsIFlagSet = true; 244 + this.bIsIFlagSet = true;
245 - return this; 245 + return this;
246 - } 246 + }
247 - } 247 + }
248 - 248 +
249 - @Override 249 + @Override
250 - public String toString() { 250 + public String toString() {
251 - return MoreObjects.toStringHelper(getClass()).add("sourceIpAddress", sourceIpAddress) 251 + return MoreObjects.toStringHelper(getClass()).add("sourceIpAddress", sourceIpAddress)
252 - .add("destIpAddress", destIpAddress).toString(); 252 + .add("destIpAddress", destIpAddress).toString();
253 - } 253 + }
254 - 254 +
255 -} 255 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepEroObject; 24 +import org.onosproject.pcepio.protocol.PcepEroObject;
25 -import org.onosproject.pcepio.types.AutonomousSystemTlv; 25 +import org.onosproject.pcepio.types.AutonomousSystemTlv;
26 -import org.onosproject.pcepio.types.IPv4SubObject; 26 +import org.onosproject.pcepio.types.IPv4SubObject;
27 -import org.onosproject.pcepio.types.IPv6SubObject; 27 +import org.onosproject.pcepio.types.IPv6SubObject;
28 -import org.onosproject.pcepio.types.PathKeySubObject; 28 +import org.onosproject.pcepio.types.PathKeySubObject;
29 -import org.onosproject.pcepio.types.PcepErrorDetailInfo; 29 +import org.onosproject.pcepio.types.PcepErrorDetailInfo;
30 -import org.onosproject.pcepio.types.PcepObjectHeader; 30 +import org.onosproject.pcepio.types.PcepObjectHeader;
31 -import org.onosproject.pcepio.types.PcepValueType; 31 +import org.onosproject.pcepio.types.PcepValueType;
32 -import org.onosproject.pcepio.types.SrEroSubObject; 32 +import org.onosproject.pcepio.types.SrEroSubObject;
33 -import org.slf4j.Logger; 33 +import org.slf4j.Logger;
34 -import org.slf4j.LoggerFactory; 34 +import org.slf4j.LoggerFactory;
35 - 35 +
36 -import com.google.common.base.MoreObjects; 36 +import com.google.common.base.MoreObjects;
37 - 37 +
38 -/** 38 +/**
39 - * Provides PCEP Ero Object. 39 + * Provides PCEP Ero Object.
40 - */ 40 + */
41 -public class PcepEroObjectVer1 implements PcepEroObject { 41 +public class PcepEroObjectVer1 implements PcepEroObject {
42 - /* 42 + /*
43 - * rfc3209 43 + * rfc3209
44 - 0 1 2 3 44 + 0 1 2 3
45 - 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 + 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
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - | Object-Class | OT |Res|P|I| Object Length (bytes) | 47 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
48 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 - | | 49 + | |
50 - // (Subobjects) // 50 + // (Subobjects) //
51 - | | 51 + | |
52 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 52 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 - 53 +
54 - If a Path message contains multiple EXPLICIT_ROUTE objects, only the 54 + If a Path message contains multiple EXPLICIT_ROUTE objects, only the
55 - first object is meaningful. Subsequent EXPLICIT_ROUTE objects MAY be 55 + first object is meaningful. Subsequent EXPLICIT_ROUTE objects MAY be
56 - ignored and SHOULD NOT be propagated. 56 + ignored and SHOULD NOT be propagated.
57 - 57 +
58 - In current implementation, only strict hops are supported. So, 58 + In current implementation, only strict hops are supported. So,
59 - empty ERO with no sub-objects is considered illegal. 59 + empty ERO with no sub-objects is considered illegal.
60 - 60 +
61 - Subobjects: 61 + Subobjects:
62 - 0 1 62 + 0 1
63 - 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 63 + 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5
64 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+ 64 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+
65 - |L| Type | Length | (Subobject contents) | 65 + |L| Type | Length | (Subobject contents) |
66 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+ 66 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-------------//----------------+
67 - 67 +
68 - L 68 + L
69 - 69 +
70 - The L bit is an attribute of the subobject. The L bit is set 70 + The L bit is an attribute of the subobject. The L bit is set
71 - if the subobject represents a loose hop in the explicit route. 71 + if the subobject represents a loose hop in the explicit route.
72 - If the bit is not set, the subobject represents a strict hop in 72 + If the bit is not set, the subobject represents a strict hop in
73 - the explicit route. 73 + the explicit route.
74 - 74 +
75 - Type 75 + Type
76 - 76 +
77 - The Type indicates the type of contents of the subobject. 77 + The Type indicates the type of contents of the subobject.
78 - 78 +
79 - 79 +
80 - Subobject 1: IPv4 address 80 + Subobject 1: IPv4 address
81 - 81 +
82 - 0 1 2 3 82 + 0 1 2 3
83 - 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 83 + 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
84 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 84 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85 - |L| Type | Length | IPv4 address (4 bytes) | 85 + |L| Type | Length | IPv4 address (4 bytes) |
86 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 86 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
87 - | IPv4 address (continued) | Prefix Length | Resvd | 87 + | IPv4 address (continued) | Prefix Length | Resvd |
88 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 88 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
89 - 89 +
90 - Subobject 2: IPv6 Prefix 90 + Subobject 2: IPv6 Prefix
91 - 91 +
92 - 0 1 2 3 92 + 0 1 2 3
93 - 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 93 + 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
94 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 94 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 - |L| Type | Length | IPv6 address (16 bytes) | 95 + |L| Type | Length | IPv6 address (16 bytes) |
96 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 96 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
97 - | IPv6 address (continued) | 97 + | IPv6 address (continued) |
98 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 98 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
99 - | IPv6 address (continued) | 99 + | IPv6 address (continued) |
100 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 100 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
101 - | IPv6 address (continued) | 101 + | IPv6 address (continued) |
102 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 102 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
103 - | IPv6 address (continued) | Prefix Length | Resvd | 103 + | IPv6 address (continued) | Prefix Length | Resvd |
104 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 104 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
105 - 105 +
106 - Subobject 3: Autonomous System Number 106 + Subobject 3: Autonomous System Number
107 - 107 +
108 - The contents of an Autonomous System (AS) number subobject are a 2- 108 + The contents of an Autonomous System (AS) number subobject are a 2-
109 - octet AS number. The abstract node represented by this subobject is 109 + octet AS number. The abstract node represented by this subobject is
110 - the set of nodes belonging to the autonomous system. 110 + the set of nodes belonging to the autonomous system.
111 - 111 +
112 - The length of the AS number subobject is 4 octets. 112 + The length of the AS number subobject is 4 octets.
113 - 113 +
114 - Subobject 4: PATH_KEY_32_BIT_SUB_OBJ_TYPE: 114 + Subobject 4: PATH_KEY_32_BIT_SUB_OBJ_TYPE:
115 - 115 +
116 - Pathkey subobject(RFC 5520): 116 + Pathkey subobject(RFC 5520):
117 - 0 1 2 3 117 + 0 1 2 3
118 - 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 118 + 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
119 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 119 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
120 - |L| Type | Length | Path-Key | 120 + |L| Type | Length | Path-Key |
121 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 121 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
122 - | PCE ID (4 bytes) | 122 + | PCE ID (4 bytes) |
123 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 123 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
124 - 124 +
125 - Subobject 5: SR_ERO_SUB_OBJ_TYPE: 125 + Subobject 5: SR_ERO_SUB_OBJ_TYPE:
126 - 126 +
127 - SR-ERO subobject: (draft-ietf-pce-segment-routing-00) 127 + SR-ERO subobject: (draft-ietf-pce-segment-routing-00)
128 - 0 1 2 3 128 + 0 1 2 3
129 - 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 129 + 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
130 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 130 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
131 - |L| Type | Length | ST | Flags |F|S|C|M| 131 + |L| Type | Length | ST | Flags |F|S|C|M|
132 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 132 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
133 - | SID | 133 + | SID |
134 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 134 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
135 - // NAI (variable) // 135 + // NAI (variable) //
136 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 136 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
137 - */ 137 + */
138 - 138 +
139 - protected static final Logger log = LoggerFactory.getLogger(PcepEroObjectVer1.class); 139 + protected static final Logger log = LoggerFactory.getLogger(PcepEroObjectVer1.class);
140 - 140 +
141 - public static final byte ERO_OBJ_TYPE = 1; 141 + public static final byte ERO_OBJ_TYPE = 1;
142 - public static final byte ERO_OBJ_CLASS = 7; 142 + public static final byte ERO_OBJ_CLASS = 7;
143 - public static final byte ERO_OBJECT_VERSION = 1; 143 + public static final byte ERO_OBJECT_VERSION = 1;
144 - public static final short ERO_OBJ_MINIMUM_LENGTH = 12; 144 + public static final short ERO_OBJ_MINIMUM_LENGTH = 12;
145 - public static final byte IPV4_TYPE = 1; 145 + public static final byte IPV4_TYPE = 1;
146 - public static final byte PATH_KEY_32_BIT_SUB_OBJ_TYPE = 64; 146 + public static final byte PATH_KEY_32_BIT_SUB_OBJ_TYPE = 64;
147 - public static final int LABEL_SUB_OBJ_TYPE = 3; 147 + public static final int LABEL_SUB_OBJ_TYPE = 3;
148 - public static final int SR_ERO_SUB_OBJ_TYPE = 96; 148 + public static final int SR_ERO_SUB_OBJ_TYPE = 96;
149 - public static final int OBJECT_HEADER_LENGTH = 4; 149 + public static final int OBJECT_HEADER_LENGTH = 4;
150 - public static final int YTYPE_SHIFT_VALUE = 0x7F; 150 + public static final int YTYPE_SHIFT_VALUE = 0x7F;
151 - 151 +
152 - static final PcepObjectHeader DEFAULT_ERO_OBJECT_HEADER = new PcepObjectHeader(ERO_OBJ_CLASS, ERO_OBJ_TYPE, 152 + static final PcepObjectHeader DEFAULT_ERO_OBJECT_HEADER = new PcepObjectHeader(ERO_OBJ_CLASS, ERO_OBJ_TYPE,
153 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, ERO_OBJ_MINIMUM_LENGTH); 153 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, ERO_OBJ_MINIMUM_LENGTH);
154 - 154 +
155 - private PcepObjectHeader eroObjHeader; 155 + private PcepObjectHeader eroObjHeader;
156 - private LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 156 + private LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
157 - 157 +
158 - /** 158 + /**
159 - * reset variables. 159 + * reset variables.
160 - */ 160 + */
161 - public PcepEroObjectVer1() { 161 + public PcepEroObjectVer1() {
162 - this.eroObjHeader = null; 162 + this.eroObjHeader = null;
163 - this.llSubObjects = null; 163 + this.llSubObjects = null;
164 - } 164 + }
165 - 165 +
166 - /** 166 + /**
167 - * Constructor to initialize parameters of ERO object. 167 + * Constructor to initialize parameters of ERO object.
168 - * 168 + *
169 - * @param eroObjHeader ERO object header 169 + * @param eroObjHeader ERO object header
170 - * @param llSubObjects list of sub objects. 170 + * @param llSubObjects list of sub objects.
171 - */ 171 + */
172 - public PcepEroObjectVer1(PcepObjectHeader eroObjHeader, LinkedList<PcepValueType> llSubObjects) { 172 + public PcepEroObjectVer1(PcepObjectHeader eroObjHeader, LinkedList<PcepValueType> llSubObjects) {
173 - 173 +
174 - this.eroObjHeader = eroObjHeader; 174 + this.eroObjHeader = eroObjHeader;
175 - this.llSubObjects = llSubObjects; 175 + this.llSubObjects = llSubObjects;
176 - } 176 + }
177 - 177 +
178 - /** 178 + /**
179 - * Returns ERO object header. 179 + * Returns ERO object header.
180 - * 180 + *
181 - * @return eroObjHeader ERO object header 181 + * @return eroObjHeader ERO object header
182 - */ 182 + */
183 - public PcepObjectHeader getEroObjHeader() { 183 + public PcepObjectHeader getEroObjHeader() {
184 - return this.eroObjHeader; 184 + return this.eroObjHeader;
185 - } 185 + }
186 - 186 +
187 - /** 187 + /**
188 - * Sets Object Header. 188 + * Sets Object Header.
189 - * 189 + *
190 - * @param obj ERO object header 190 + * @param obj ERO object header
191 - */ 191 + */
192 - public void setEroObjHeader(PcepObjectHeader obj) { 192 + public void setEroObjHeader(PcepObjectHeader obj) {
193 - this.eroObjHeader = obj; 193 + this.eroObjHeader = obj;
194 - } 194 + }
195 - 195 +
196 - @Override 196 + @Override
197 - public LinkedList<PcepValueType> getSubObjects() { 197 + public LinkedList<PcepValueType> getSubObjects() {
198 - return this.llSubObjects; 198 + return this.llSubObjects;
199 - } 199 + }
200 - 200 +
201 - @Override 201 + @Override
202 - public void setSubObjects(LinkedList<PcepValueType> llSubObjects) { 202 + public void setSubObjects(LinkedList<PcepValueType> llSubObjects) {
203 - this.llSubObjects = llSubObjects; 203 + this.llSubObjects = llSubObjects;
204 - } 204 + }
205 - 205 +
206 - /** 206 + /**
207 - * Reads from channel buffer and returns object of PcepEroObject. 207 + * Reads from channel buffer and returns object of PcepEroObject.
208 - * 208 + *
209 - * @param cb channel buffer. 209 + * @param cb channel buffer.
210 - * @return object of PcepEroObject 210 + * @return object of PcepEroObject
211 - * @throws PcepParseException when ERO object is not present in channel buffer 211 + * @throws PcepParseException when ERO object is not present in channel buffer
212 - */ 212 + */
213 - public static PcepEroObject read(ChannelBuffer cb) throws PcepParseException { 213 + public static PcepEroObject read(ChannelBuffer cb) throws PcepParseException {
214 - 214 +
215 - PcepObjectHeader eroObjHeader; 215 + PcepObjectHeader eroObjHeader;
216 - LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 216 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
217 - 217 +
218 - eroObjHeader = PcepObjectHeader.read(cb); 218 + eroObjHeader = PcepObjectHeader.read(cb);
219 - 219 +
220 - if (eroObjHeader.getObjClass() != PcepEroObjectVer1.ERO_OBJ_CLASS) { 220 + if (eroObjHeader.getObjClass() != PcepEroObjectVer1.ERO_OBJ_CLASS) {
221 - log.debug("ErrorType:" + PcepErrorDetailInfo.ERROR_TYPE_6 + " ErrorValue:" 221 + log.debug("ErrorType:" + PcepErrorDetailInfo.ERROR_TYPE_6 + " ErrorValue:"
222 - + PcepErrorDetailInfo.ERROR_VALUE_9); 222 + + PcepErrorDetailInfo.ERROR_VALUE_9);
223 - throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_9); 223 + throw new PcepParseException(PcepErrorDetailInfo.ERROR_TYPE_6, PcepErrorDetailInfo.ERROR_VALUE_9);
224 - } 224 + }
225 - 225 +
226 - if (eroObjHeader.getObjLen() > OBJECT_HEADER_LENGTH) { 226 + if (eroObjHeader.getObjLen() > OBJECT_HEADER_LENGTH) {
227 - ChannelBuffer tempCb = cb.readBytes(eroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); 227 + ChannelBuffer tempCb = cb.readBytes(eroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
228 - llSubObjects = parseSubObjects(tempCb); 228 + llSubObjects = parseSubObjects(tempCb);
229 - } 229 + }
230 - return new PcepEroObjectVer1(eroObjHeader, llSubObjects); 230 + return new PcepEroObjectVer1(eroObjHeader, llSubObjects);
231 - } 231 + }
232 - 232 +
233 - /** 233 + /**
234 - * Parse list of Sub Objects. 234 + * Parse list of Sub Objects.
235 - * 235 + *
236 - * @param cb channel buffer 236 + * @param cb channel buffer
237 - * @return list of Sub Objects 237 + * @return list of Sub Objects
238 - * @throws PcepParseException when fails to parse sub object list 238 + * @throws PcepParseException when fails to parse sub object list
239 - */ 239 + */
240 - protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException { 240 + protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
241 - 241 +
242 - LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 242 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
243 - 243 +
244 - while (0 < cb.readableBytes()) { 244 + while (0 < cb.readableBytes()) {
245 - 245 +
246 - //check the Type of the TLV 246 + //check the Type of the TLV
247 - byte yType = cb.readByte(); 247 + byte yType = cb.readByte();
248 - yType = (byte) (yType & (YTYPE_SHIFT_VALUE)); 248 + yType = (byte) (yType & (YTYPE_SHIFT_VALUE));
249 - byte hLength = cb.readByte(); 249 + byte hLength = cb.readByte();
250 - 250 +
251 - PcepValueType subObj; 251 + PcepValueType subObj;
252 - 252 +
253 - switch (yType) { 253 + switch (yType) {
254 - 254 +
255 - case IPv4SubObject.TYPE: 255 + case IPv4SubObject.TYPE:
256 - subObj = IPv4SubObject.read(cb); 256 + subObj = IPv4SubObject.read(cb);
257 - break; 257 + break;
258 - case IPv6SubObject.TYPE: 258 + case IPv6SubObject.TYPE:
259 - byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH]; 259 + byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH];
260 - cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH); 260 + cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH);
261 - subObj = new IPv6SubObject(ipv6Value); 261 + subObj = new IPv6SubObject(ipv6Value);
262 - break; 262 + break;
263 - case AutonomousSystemTlv.TYPE: 263 + case AutonomousSystemTlv.TYPE:
264 - subObj = AutonomousSystemTlv.read(cb); 264 + subObj = AutonomousSystemTlv.read(cb);
265 - break; 265 + break;
266 - case PathKeySubObject.TYPE: 266 + case PathKeySubObject.TYPE:
267 - subObj = PathKeySubObject.read(cb); 267 + subObj = PathKeySubObject.read(cb);
268 - break; 268 + break;
269 - case SrEroSubObject.TYPE: 269 + case SrEroSubObject.TYPE:
270 - subObj = SrEroSubObject.read(cb); 270 + subObj = SrEroSubObject.read(cb);
271 - break; 271 + break;
272 - default: 272 + default:
273 - throw new PcepParseException("Unexpected sub object. Type: " + (int) yType); 273 + throw new PcepParseException("Unexpected sub object. Type: " + (int) yType);
274 - } 274 + }
275 - // Check for the padding 275 + // Check for the padding
276 - int pad = hLength % 4; 276 + int pad = hLength % 4;
277 - if (0 < pad) { 277 + if (0 < pad) {
278 - pad = 4 - pad; 278 + pad = 4 - pad;
279 - if (pad <= cb.readableBytes()) { 279 + if (pad <= cb.readableBytes()) {
280 - cb.skipBytes(pad); 280 + cb.skipBytes(pad);
281 - } 281 + }
282 - } 282 + }
283 - 283 +
284 - llSubObjects.add(subObj); 284 + llSubObjects.add(subObj);
285 - } 285 + }
286 - if (0 < cb.readableBytes()) { 286 + if (0 < cb.readableBytes()) {
287 - throw new PcepParseException("Subobject parsing error. Extra bytes received."); 287 + throw new PcepParseException("Subobject parsing error. Extra bytes received.");
288 - } 288 + }
289 - return llSubObjects; 289 + return llSubObjects;
290 - } 290 + }
291 - 291 +
292 - @Override 292 + @Override
293 - public int write(ChannelBuffer cb) throws PcepParseException { 293 + public int write(ChannelBuffer cb) throws PcepParseException {
294 - 294 +
295 - //write Object header 295 + //write Object header
296 - int objStartIndex = cb.writerIndex(); 296 + int objStartIndex = cb.writerIndex();
297 - 297 +
298 - int objLenIndex = eroObjHeader.write(cb); 298 + int objLenIndex = eroObjHeader.write(cb);
299 - 299 +
300 - if (objLenIndex <= 0) { 300 + if (objLenIndex <= 0) {
301 - throw new PcepParseException("Failed to write ERO object header. Index " + objLenIndex); 301 + throw new PcepParseException("Failed to write ERO object header. Index " + objLenIndex);
302 - } 302 + }
303 - 303 +
304 - ListIterator<PcepValueType> listIterator = llSubObjects.listIterator(); 304 + ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
305 - 305 +
306 - while (listIterator.hasNext()) { 306 + while (listIterator.hasNext()) {
307 - listIterator.next().write(cb); 307 + listIterator.next().write(cb);
308 - } 308 + }
309 - 309 +
310 - //Update object length now 310 + //Update object length now
311 - int length = cb.writerIndex() - objStartIndex; 311 + int length = cb.writerIndex() - objStartIndex;
312 - cb.setShort(objLenIndex, (short) length); 312 + cb.setShort(objLenIndex, (short) length);
313 - //will be helpful during print(). 313 + //will be helpful during print().
314 - eroObjHeader.setObjLen((short) length); 314 + eroObjHeader.setObjLen((short) length);
315 - 315 +
316 - //As per RFC the length of object should be multiples of 4 316 + //As per RFC the length of object should be multiples of 4
317 - int pad = length % 4; 317 + int pad = length % 4;
318 - 318 +
319 - if (pad != 0) { 319 + if (pad != 0) {
320 - pad = 4 - pad; 320 + pad = 4 - pad;
321 - for (int i = 0; i < pad; i++) { 321 + for (int i = 0; i < pad; i++) {
322 - cb.writeByte((byte) 0); 322 + cb.writeByte((byte) 0);
323 - } 323 + }
324 - length = length + pad; 324 + length = length + pad;
325 - } 325 + }
326 - 326 +
327 - objLenIndex = cb.writerIndex(); 327 + objLenIndex = cb.writerIndex();
328 - return objLenIndex; 328 + return objLenIndex;
329 - } 329 + }
330 - 330 +
331 - /** 331 + /**
332 - * Builder class for PCEP ERO object. 332 + * Builder class for PCEP ERO object.
333 - */ 333 + */
334 - public static class Builder implements PcepEroObject.Builder { 334 + public static class Builder implements PcepEroObject.Builder {
335 - 335 +
336 - private boolean bIsHeaderSet = false; 336 + private boolean bIsHeaderSet = false;
337 - 337 +
338 - private boolean bIsPFlagSet = false; 338 + private boolean bIsPFlagSet = false;
339 - private boolean bPFlag; 339 + private boolean bPFlag;
340 - 340 +
341 - private boolean bIsIFlagSet = false; 341 + private boolean bIsIFlagSet = false;
342 - private boolean bIFlag; 342 + private boolean bIFlag;
343 - 343 +
344 - private PcepObjectHeader eroObjHeader; 344 + private PcepObjectHeader eroObjHeader;
345 - LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 345 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
346 - 346 +
347 - @Override 347 + @Override
348 - public PcepEroObject build() { 348 + public PcepEroObject build() {
349 - 349 +
350 - PcepObjectHeader eroObjHeader = this.bIsHeaderSet ? this.eroObjHeader : DEFAULT_ERO_OBJECT_HEADER; 350 + PcepObjectHeader eroObjHeader = this.bIsHeaderSet ? this.eroObjHeader : DEFAULT_ERO_OBJECT_HEADER;
351 - 351 +
352 - if (bIsPFlagSet) { 352 + if (bIsPFlagSet) {
353 - eroObjHeader.setPFlag(bPFlag); 353 + eroObjHeader.setPFlag(bPFlag);
354 - } 354 + }
355 - 355 +
356 - if (bIsIFlagSet) { 356 + if (bIsIFlagSet) {
357 - eroObjHeader.setIFlag(bIFlag); 357 + eroObjHeader.setIFlag(bIFlag);
358 - } 358 + }
359 - 359 +
360 - return new PcepEroObjectVer1(eroObjHeader, this.llSubObjects); 360 + return new PcepEroObjectVer1(eroObjHeader, this.llSubObjects);
361 - } 361 + }
362 - 362 +
363 - @Override 363 + @Override
364 - public PcepObjectHeader getEroObjHeader() { 364 + public PcepObjectHeader getEroObjHeader() {
365 - return this.eroObjHeader; 365 + return this.eroObjHeader;
366 - } 366 + }
367 - 367 +
368 - @Override 368 + @Override
369 - public Builder setEroObjHeader(PcepObjectHeader obj) { 369 + public Builder setEroObjHeader(PcepObjectHeader obj) {
370 - this.eroObjHeader = obj; 370 + this.eroObjHeader = obj;
371 - this.bIsHeaderSet = true; 371 + this.bIsHeaderSet = true;
372 - return this; 372 + return this;
373 - } 373 + }
374 - 374 +
375 - @Override 375 + @Override
376 - public LinkedList<PcepValueType> getSubObjects() { 376 + public LinkedList<PcepValueType> getSubObjects() {
377 - return this.llSubObjects; 377 + return this.llSubObjects;
378 - } 378 + }
379 - 379 +
380 - @Override 380 + @Override
381 - public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) { 381 + public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) {
382 - this.llSubObjects = llSubObjects; 382 + this.llSubObjects = llSubObjects;
383 - return this; 383 + return this;
384 - } 384 + }
385 - 385 +
386 - @Override 386 + @Override
387 - public Builder setPFlag(boolean value) { 387 + public Builder setPFlag(boolean value) {
388 - this.bPFlag = value; 388 + this.bPFlag = value;
389 - this.bIsPFlagSet = true; 389 + this.bIsPFlagSet = true;
390 - return this; 390 + return this;
391 - } 391 + }
392 - 392 +
393 - @Override 393 + @Override
394 - public Builder setIFlag(boolean value) { 394 + public Builder setIFlag(boolean value) {
395 - this.bIFlag = value; 395 + this.bIFlag = value;
396 - this.bIsIFlagSet = true; 396 + this.bIsIFlagSet = true;
397 - return this; 397 + return this;
398 - } 398 + }
399 - } 399 + }
400 - 400 +
401 - @Override 401 + @Override
402 - public String toString() { 402 + public String toString() {
403 - return MoreObjects.toStringHelper(getClass()).add("EroObjHeader", eroObjHeader).add("SubObjects", llSubObjects) 403 + return MoreObjects.toStringHelper(getClass()).add("EroObjHeader", eroObjHeader).add("SubObjects", llSubObjects)
404 - .toString(); 404 + .toString();
405 - } 405 + }
406 -} 406 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.protocol.ver1; 16 +package org.onosproject.pcepio.protocol.ver1;
17 - 17 +
18 -import java.util.LinkedList; 18 +import java.util.LinkedList;
19 -import java.util.ListIterator; 19 +import java.util.ListIterator;
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.exceptions.PcepParseException;
23 -import org.onosproject.pcepio.protocol.PcepError; 23 +import org.onosproject.pcepio.protocol.PcepError;
24 -import org.onosproject.pcepio.protocol.PcepErrorInfo; 24 +import org.onosproject.pcepio.protocol.PcepErrorInfo;
25 -import org.onosproject.pcepio.protocol.PcepErrorObject; 25 +import org.onosproject.pcepio.protocol.PcepErrorObject;
26 -import org.onosproject.pcepio.protocol.PcepRPObject; 26 +import org.onosproject.pcepio.protocol.PcepRPObject;
27 -import org.onosproject.pcepio.protocol.PcepTEObject; 27 +import org.onosproject.pcepio.protocol.PcepTEObject;
28 -import org.onosproject.pcepio.types.PcepObjectHeader; 28 +import org.onosproject.pcepio.types.PcepObjectHeader;
29 -import org.slf4j.Logger; 29 +import org.slf4j.Logger;
30 -import org.slf4j.LoggerFactory; 30 +import org.slf4j.LoggerFactory;
31 - 31 +
32 -import com.google.common.base.MoreObjects; 32 +import com.google.common.base.MoreObjects;
33 - 33 +
34 -/** 34 +/**
35 - * Provides PCEP Error Info. 35 + * Provides PCEP Error Info.
36 - * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02. 36 + * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02.
37 - */ 37 + */
38 -public class PcepErrorInfoVer1 implements PcepErrorInfo { 38 +public class PcepErrorInfoVer1 implements PcepErrorInfo {
39 - 39 +
40 - protected static final Logger log = LoggerFactory.getLogger(PcepErrorInfoVer1.class); 40 + protected static final Logger log = LoggerFactory.getLogger(PcepErrorInfoVer1.class);
41 - //Error list is optional 41 + //Error list is optional
42 - private LinkedList<PcepError> errList; 42 + private LinkedList<PcepError> errList;
43 - 43 +
44 - /** 44 + /**
45 - * Constructor to add PCEP error object to the list. 45 + * Constructor to add PCEP error object to the list.
46 - * 46 + *
47 - * @param llRPObjList list of PCEP RP object 47 + * @param llRPObjList list of PCEP RP object
48 - * @param llTEObjList list of PCEP TE object 48 + * @param llTEObjList list of PCEP TE object
49 - * @param llErrObjList list of PCEP error object 49 + * @param llErrObjList list of PCEP error object
50 - */ 50 + */
51 - public PcepErrorInfoVer1(LinkedList<PcepRPObject> llRPObjList, LinkedList<PcepTEObject> llTEObjList, 51 + public PcepErrorInfoVer1(LinkedList<PcepRPObject> llRPObjList, LinkedList<PcepTEObject> llTEObjList,
52 - LinkedList<PcepErrorObject> llErrObjList) { 52 + LinkedList<PcepErrorObject> llErrObjList) {
53 - this.errList = new LinkedList<PcepError>(); 53 + this.errList = new LinkedList<PcepError>();
54 - if ((null != llErrObjList) && (!llErrObjList.isEmpty())) { 54 + if ((null != llErrObjList) && (!llErrObjList.isEmpty())) {
55 - this.errList.add(new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList)); 55 + this.errList.add(new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList));
56 - } 56 + }
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Constructor to initialize error info. 60 + * Constructor to initialize error info.
61 - * 61 + *
62 - * @param errll linked list or pcep error 62 + * @param errll linked list or pcep error
63 - */ 63 + */
64 - public PcepErrorInfoVer1(LinkedList<PcepError> errll) { 64 + public PcepErrorInfoVer1(LinkedList<PcepError> errll) {
65 - this.errList = errll; 65 + this.errList = errll;
66 - } 66 + }
67 - 67 +
68 - @Override 68 + @Override
69 - public boolean isErrorInfoPresent() { 69 + public boolean isErrorInfoPresent() {
70 - return (!this.errList.isEmpty()) ? true : false; 70 + return (!this.errList.isEmpty()) ? true : false;
71 - } 71 + }
72 - 72 +
73 - @Override 73 + @Override
74 - public void read(ChannelBuffer cb) throws PcepParseException { 74 + public void read(ChannelBuffer cb) throws PcepParseException {
75 - PcepObjectHeader tempObjHeader; 75 + PcepObjectHeader tempObjHeader;
76 - 76 +
77 - while (0 < cb.readableBytes()) { 77 + while (0 < cb.readableBytes()) {
78 - cb.markReaderIndex(); 78 + cb.markReaderIndex();
79 - tempObjHeader = PcepObjectHeader.read(cb); 79 + tempObjHeader = PcepObjectHeader.read(cb);
80 - cb.resetReaderIndex(); 80 + cb.resetReaderIndex();
81 - byte yObjClass = tempObjHeader.getObjClass(); 81 + byte yObjClass = tempObjHeader.getObjClass();
82 - if ((yObjClass != PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjClass != PcepTEObjectVer1.TE_OBJ_CLASS) 82 + if ((yObjClass != PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjClass != PcepTEObjectVer1.TE_OBJ_CLASS)
83 - && (yObjClass != PcepErrorObjectVer1.ERROR_OBJ_CLASS)) { 83 + && (yObjClass != PcepErrorObjectVer1.ERROR_OBJ_CLASS)) {
84 - throw new PcepParseException("Unknown Object is present in PCEP-ERROR. Object Class: " + yObjClass); 84 + throw new PcepParseException("Unknown Object is present in PCEP-ERROR. Object Class: " + yObjClass);
85 - } 85 + }
86 - 86 +
87 - this.errList.add(PcepErrorVer1.read(cb)); 87 + this.errList.add(PcepErrorVer1.read(cb));
88 - } 88 + }
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public void write(ChannelBuffer cb) throws PcepParseException { 92 + public void write(ChannelBuffer cb) throws PcepParseException {
93 - //write <error> 93 + //write <error>
94 - ListIterator<PcepError> listIterator = errList.listIterator(); 94 + ListIterator<PcepError> listIterator = errList.listIterator();
95 - while (listIterator.hasNext()) { 95 + while (listIterator.hasNext()) {
96 - PcepError pcepError = listIterator.next(); 96 + PcepError pcepError = listIterator.next();
97 - 97 +
98 - //RP Object list is optional 98 + //RP Object list is optional
99 - LinkedList<PcepRPObject> llRPObjList = pcepError.getRPObjList(); 99 + LinkedList<PcepRPObject> llRPObjList = pcepError.getRPObjList();
100 - if (llRPObjList != null) { 100 + if (llRPObjList != null) {
101 - ListIterator<PcepRPObject> rpListIterator = llRPObjList.listIterator(); 101 + ListIterator<PcepRPObject> rpListIterator = llRPObjList.listIterator();
102 - while (rpListIterator.hasNext()) { 102 + while (rpListIterator.hasNext()) {
103 - rpListIterator.next().write(cb); 103 + rpListIterator.next().write(cb);
104 - } 104 + }
105 - } 105 + }
106 - 106 +
107 - //TE Object list is optional 107 + //TE Object list is optional
108 - LinkedList<PcepTEObject> llTEObjList = pcepError.getTEObjList(); 108 + LinkedList<PcepTEObject> llTEObjList = pcepError.getTEObjList();
109 - if (llTEObjList != null) { 109 + if (llTEObjList != null) {
110 - ListIterator<PcepTEObject> teListIterator = llTEObjList.listIterator(); 110 + ListIterator<PcepTEObject> teListIterator = llTEObjList.listIterator();
111 - while (teListIterator.hasNext()) { 111 + while (teListIterator.hasNext()) {
112 - teListIterator.next().write(cb); 112 + teListIterator.next().write(cb);
113 - } 113 + }
114 - } 114 + }
115 - 115 +
116 - // <error-obj-list> is mandatory 116 + // <error-obj-list> is mandatory
117 - boolean bIsErrorObjListFound = false; 117 + boolean bIsErrorObjListFound = false;
118 - 118 +
119 - LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList(); 119 + LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
120 - if (llErrObjList != null) { 120 + if (llErrObjList != null) {
121 - ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator(); 121 + ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
122 - while (errObjListIterator.hasNext()) { 122 + while (errObjListIterator.hasNext()) {
123 - errObjListIterator.next().write(cb); 123 + errObjListIterator.next().write(cb);
124 - bIsErrorObjListFound = true; 124 + bIsErrorObjListFound = true;
125 - } 125 + }
126 - } 126 + }
127 - 127 +
128 - if (!bIsErrorObjListFound) { 128 + if (!bIsErrorObjListFound) {
129 - throw new PcepParseException("<error-obj-list> is mandatory."); 129 + throw new PcepParseException("<error-obj-list> is mandatory.");
130 - } 130 + }
131 - } 131 + }
132 - } 132 + }
133 - 133 +
134 - @Override 134 + @Override
135 - public LinkedList<Integer> getErrorType() { 135 + public LinkedList<Integer> getErrorType() {
136 - LinkedList<Integer> errorType = new LinkedList<Integer>(); 136 + LinkedList<Integer> errorType = new LinkedList<Integer>();
137 - ListIterator<PcepError> listIterator = errList.listIterator(); 137 + ListIterator<PcepError> listIterator = errList.listIterator();
138 - PcepErrorObject errObj; 138 + PcepErrorObject errObj;
139 - int error; 139 + int error;
140 - while (listIterator.hasNext()) { 140 + while (listIterator.hasNext()) {
141 - PcepError pcepError = listIterator.next(); 141 + PcepError pcepError = listIterator.next();
142 - LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList(); 142 + LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
143 - if (llErrObjList != null) { 143 + if (llErrObjList != null) {
144 - ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator(); 144 + ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
145 - while (errObjListIterator.hasNext()) { 145 + while (errObjListIterator.hasNext()) {
146 - errObj = errObjListIterator.next(); 146 + errObj = errObjListIterator.next();
147 - error = errObj.getErrorType(); 147 + error = errObj.getErrorType();
148 - errorType.add(error); 148 + errorType.add(error);
149 - } 149 + }
150 - } 150 + }
151 - } 151 + }
152 - return errorType; 152 + return errorType;
153 - } 153 + }
154 - 154 +
155 - @Override 155 + @Override
156 - public LinkedList<Integer> getErrorValue() { 156 + public LinkedList<Integer> getErrorValue() {
157 - LinkedList<Integer> errorValue = new LinkedList<Integer>(); 157 + LinkedList<Integer> errorValue = new LinkedList<Integer>();
158 - ListIterator<PcepError> listIterator = errList.listIterator(); 158 + ListIterator<PcepError> listIterator = errList.listIterator();
159 - PcepErrorObject errObj; 159 + PcepErrorObject errObj;
160 - int error; 160 + int error;
161 - while (listIterator.hasNext()) { 161 + while (listIterator.hasNext()) {
162 - PcepError pcepError = listIterator.next(); 162 + PcepError pcepError = listIterator.next();
163 - LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList(); 163 + LinkedList<PcepErrorObject> llErrObjList = pcepError.getErrorObjList();
164 - if (llErrObjList != null) { 164 + if (llErrObjList != null) {
165 - ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator(); 165 + ListIterator<PcepErrorObject> errObjListIterator = llErrObjList.listIterator();
166 - while (errObjListIterator.hasNext()) { 166 + while (errObjListIterator.hasNext()) {
167 - errObj = errObjListIterator.next(); 167 + errObj = errObjListIterator.next();
168 - error = errObj.getErrorValue(); 168 + error = errObj.getErrorValue();
169 - errorValue.add(error); 169 + errorValue.add(error);
170 - } 170 + }
171 - } 171 + }
172 - } 172 + }
173 - return errorValue; 173 + return errorValue;
174 - } 174 + }
175 - 175 +
176 - /** 176 + /**
177 - * Builder class for PCEP error info. 177 + * Builder class for PCEP error info.
178 - */ 178 + */
179 - public static class Builder implements PcepErrorInfo.Builder { 179 + public static class Builder implements PcepErrorInfo.Builder {
180 - private LinkedList<PcepError> errll; 180 + private LinkedList<PcepError> errll;
181 - 181 +
182 - @Override 182 + @Override
183 - public PcepErrorInfo build() { 183 + public PcepErrorInfo build() {
184 - return new PcepErrorInfoVer1(errll); 184 + return new PcepErrorInfoVer1(errll);
185 - } 185 + }
186 - 186 +
187 - @Override 187 + @Override
188 - public LinkedList<PcepError> getPcepErrorList() { 188 + public LinkedList<PcepError> getPcepErrorList() {
189 - return this.errll; 189 + return this.errll;
190 - } 190 + }
191 - 191 +
192 - @Override 192 + @Override
193 - public Builder setPcepErrorList(LinkedList<PcepError> errll) { 193 + public Builder setPcepErrorList(LinkedList<PcepError> errll) {
194 - this.errll = errll; 194 + this.errll = errll;
195 - return this; 195 + return this;
196 - } 196 + }
197 - } 197 + }
198 - 198 +
199 - @Override 199 + @Override
200 - public String toString() { 200 + public String toString() {
201 - return MoreObjects.toStringHelper(getClass()).add("ErrorList", errList).toString(); 201 + return MoreObjects.toStringHelper(getClass()).add("ErrorList", errList).toString();
202 - } 202 + }
203 -} 203 +}
......
1 -package org.onosproject.pcepio.protocol.ver1; 1 +package org.onosproject.pcepio.protocol.ver1;
2 - 2 +
3 -import java.util.LinkedList; 3 +import java.util.LinkedList;
4 - 4 +
5 -import org.jboss.netty.buffer.ChannelBuffer; 5 +import org.jboss.netty.buffer.ChannelBuffer;
6 -import org.onosproject.pcepio.exceptions.PcepParseException; 6 +import org.onosproject.pcepio.exceptions.PcepParseException;
7 -import org.onosproject.pcepio.protocol.PcepErrorInfo; 7 +import org.onosproject.pcepio.protocol.PcepErrorInfo;
8 -import org.onosproject.pcepio.protocol.PcepErrorMsg; 8 +import org.onosproject.pcepio.protocol.PcepErrorMsg;
9 -import org.onosproject.pcepio.protocol.PcepErrorObject; 9 +import org.onosproject.pcepio.protocol.PcepErrorObject;
10 -import org.onosproject.pcepio.protocol.PcepMessageReader; 10 +import org.onosproject.pcepio.protocol.PcepMessageReader;
11 -import org.onosproject.pcepio.protocol.PcepMessageWriter; 11 +import org.onosproject.pcepio.protocol.PcepMessageWriter;
12 -import org.onosproject.pcepio.protocol.PcepOpenObject; 12 +import org.onosproject.pcepio.protocol.PcepOpenObject;
13 -import org.onosproject.pcepio.protocol.PcepType; 13 +import org.onosproject.pcepio.protocol.PcepType;
14 -import org.onosproject.pcepio.protocol.PcepVersion; 14 +import org.onosproject.pcepio.protocol.PcepVersion;
15 -import org.onosproject.pcepio.types.ErrorObjListWithOpen; 15 +import org.onosproject.pcepio.types.ErrorObjListWithOpen;
16 -import org.onosproject.pcepio.types.PcepObjectHeader; 16 +import org.onosproject.pcepio.types.PcepObjectHeader;
17 -import org.slf4j.Logger; 17 +import org.slf4j.Logger;
18 -import org.slf4j.LoggerFactory; 18 +import org.slf4j.LoggerFactory;
19 - 19 +
20 -import com.google.common.base.MoreObjects; 20 +import com.google.common.base.MoreObjects;
21 -import com.google.common.base.MoreObjects.ToStringHelper; 21 +import com.google.common.base.MoreObjects.ToStringHelper;
22 - 22 +
23 -/** 23 +/**
24 - * Provides PCEP Error Message. 24 + * Provides PCEP Error Message.
25 - */ 25 + */
26 -public class PcepErrorMsgVer1 implements PcepErrorMsg { 26 +public class PcepErrorMsgVer1 implements PcepErrorMsg {
27 - 27 +
28 - /* 28 + /*
29 - * PCE Error message format. 29 + * PCE Error message format.
30 - 30 +
31 - <PCErr Message> ::= <Common Header> 31 + <PCErr Message> ::= <Common Header>
32 - ( <error-obj-list> [<Open>] ) | <error> 32 + ( <error-obj-list> [<Open>] ) | <error>
33 - [<error-list>] 33 + [<error-list>]
34 - 34 +
35 - <error-obj-list> ::=<PCEP-ERROR>[<error-obj-list>] 35 + <error-obj-list> ::=<PCEP-ERROR>[<error-obj-list>]
36 - 36 +
37 - <error> ::=[<request-id-list> | <te-id-list>] 37 + <error> ::=[<request-id-list> | <te-id-list>]
38 - <error-obj-list> 38 + <error-obj-list>
39 - 39 +
40 - <request-id-list> ::=<RP>[<request-id-list>] 40 + <request-id-list> ::=<RP>[<request-id-list>]
41 - 41 +
42 - <te-id-list> ::=<TE>[<te-id-list>] 42 + <te-id-list> ::=<TE>[<te-id-list>]
43 - 43 +
44 - <error-list> ::=<error>[<error-list>] 44 + <error-list> ::=<error>[<error-list>]
45 - */ 45 + */
46 - 46 +
47 - protected static final Logger log = LoggerFactory.getLogger(PcepOpenMsgVer1.class); 47 + protected static final Logger log = LoggerFactory.getLogger(PcepOpenMsgVer1.class);
48 - public static final byte PACKET_VERSION = 1; 48 + public static final byte PACKET_VERSION = 1;
49 - public static final int PACKET_MINIMUM_LENGTH = 12; 49 + public static final int PACKET_MINIMUM_LENGTH = 12;
50 - public static final PcepType MSG_TYPE = PcepType.ERROR; 50 + public static final PcepType MSG_TYPE = PcepType.ERROR;
51 - 51 +
52 - //Below either one should be present. 52 + //Below either one should be present.
53 - private ErrorObjListWithOpen errObjListWithOpen; //optional ( <error-obj-list> [<Open>] ) 53 + private ErrorObjListWithOpen errObjListWithOpen; //optional ( <error-obj-list> [<Open>] )
54 - private PcepErrorInfo errInfo; //optional <error> [<error-list>] 54 + private PcepErrorInfo errInfo; //optional <error> [<error-list>]
55 - 55 +
56 - public static final PcepErrorMsgVer1.Reader READER = new Reader(); 56 + public static final PcepErrorMsgVer1.Reader READER = new Reader();
57 - 57 +
58 - /** 58 + /**
59 - * constructor to initialize variables. 59 + * constructor to initialize variables.
60 - */ 60 + */
61 - public PcepErrorMsgVer1() { 61 + public PcepErrorMsgVer1() {
62 - errObjListWithOpen = null; 62 + errObjListWithOpen = null;
63 - errInfo = null; 63 + errInfo = null;
64 - } 64 + }
65 - 65 +
66 - /** 66 + /**
67 - * Constructor to initialize variables. 67 + * Constructor to initialize variables.
68 - * 68 + *
69 - * @param errObjListWithOpen error-object-list with open object 69 + * @param errObjListWithOpen error-object-list with open object
70 - * @param errInfo error information 70 + * @param errInfo error information
71 - */ 71 + */
72 - public PcepErrorMsgVer1(ErrorObjListWithOpen errObjListWithOpen, PcepErrorInfo errInfo) { 72 + public PcepErrorMsgVer1(ErrorObjListWithOpen errObjListWithOpen, PcepErrorInfo errInfo) {
73 - this.errObjListWithOpen = errObjListWithOpen; 73 + this.errObjListWithOpen = errObjListWithOpen;
74 - this.errInfo = errInfo; 74 + this.errInfo = errInfo;
75 - } 75 + }
76 - 76 +
77 - /** 77 + /**
78 - * Reader class for reading PCEP error Message from channel buffer. 78 + * Reader class for reading PCEP error Message from channel buffer.
79 - */ 79 + */
80 - public static class Reader implements PcepMessageReader<PcepErrorMsg> { 80 + public static class Reader implements PcepMessageReader<PcepErrorMsg> {
81 - 81 +
82 - ErrorObjListWithOpen errObjListWithOpen; 82 + ErrorObjListWithOpen errObjListWithOpen;
83 - PcepErrorInfo errInfo; 83 + PcepErrorInfo errInfo;
84 - PcepObjectHeader tempObjHeader; 84 + PcepObjectHeader tempObjHeader;
85 - 85 +
86 - @Override 86 + @Override
87 - public PcepErrorMsg readFrom(ChannelBuffer cb) throws PcepParseException { 87 + public PcepErrorMsg readFrom(ChannelBuffer cb) throws PcepParseException {
88 - 88 +
89 - errObjListWithOpen = null; 89 + errObjListWithOpen = null;
90 - errInfo = null; 90 + errInfo = null;
91 - tempObjHeader = null; 91 + tempObjHeader = null;
92 - 92 +
93 - if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) { 93 + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
94 - throw new PcepParseException("Packet size is less than the minimum length."); 94 + throw new PcepParseException("Packet size is less than the minimum length.");
95 - } 95 + }
96 - 96 +
97 - byte version = cb.readByte(); 97 + byte version = cb.readByte();
98 - version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG); 98 + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
99 - if (version != PACKET_VERSION) { 99 + if (version != PACKET_VERSION) {
100 - throw new PcepParseException("Wrong version: Expected=PcepVersion.PCEP_1(1), got=" + version); 100 + throw new PcepParseException("Wrong version: Expected=PcepVersion.PCEP_1(1), got=" + version);
101 - } 101 + }
102 - // fixed value property type == 1 102 + // fixed value property type == 1
103 - byte type = cb.readByte(); 103 + byte type = cb.readByte();
104 - if (type != MSG_TYPE.getType()) { 104 + if (type != MSG_TYPE.getType()) {
105 - throw new PcepParseException("Wrong type: Expected=PcepType.ERROR(6), got=" + type); 105 + throw new PcepParseException("Wrong type: Expected=PcepType.ERROR(6), got=" + type);
106 - } 106 + }
107 - int length = cb.readShort(); 107 + int length = cb.readShort();
108 - if (length < PACKET_MINIMUM_LENGTH) { 108 + if (length < PACKET_MINIMUM_LENGTH) {
109 - throw new PcepParseException( 109 + throw new PcepParseException(
110 - "Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + length); 110 + "Wrong length: Expected to be >= " + PACKET_MINIMUM_LENGTH + ", was: " + length);
111 - } 111 + }
112 - 112 +
113 - //parse <PCErr Message> 113 + //parse <PCErr Message>
114 - parsePCErrMsg(cb); 114 + parsePCErrMsg(cb);
115 - 115 +
116 - // If other than RP or TE or PCEP-ERROR present then it is error. 116 + // If other than RP or TE or PCEP-ERROR present then it is error.
117 - if (0 < cb.readableBytes()) { 117 + if (0 < cb.readableBytes()) {
118 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 118 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
119 - throw new PcepParseException("Unexpected Object found. Object Class : " + tempObjHeader.getObjClass()); 119 + throw new PcepParseException("Unexpected Object found. Object Class : " + tempObjHeader.getObjClass());
120 - } 120 + }
121 - 121 +
122 - return new PcepErrorMsgVer1(errObjListWithOpen, errInfo); 122 + return new PcepErrorMsgVer1(errObjListWithOpen, errInfo);
123 - } 123 + }
124 - 124 +
125 - /** 125 + /**
126 - * Parsing PCErr Message. 126 + * Parsing PCErr Message.
127 - * 127 + *
128 - * @param cb channel buffer. 128 + * @param cb channel buffer.
129 - * @throws PcepParseException if mandatory fields are missing 129 + * @throws PcepParseException if mandatory fields are missing
130 - * output: this.errObjListWithOpen, this.errInfo 130 + * output: this.errObjListWithOpen, this.errInfo
131 - */ 131 + */
132 - public void parsePCErrMsg(ChannelBuffer cb) throws PcepParseException { 132 + public void parsePCErrMsg(ChannelBuffer cb) throws PcepParseException {
133 - //If PCEP-ERROR list is followed by OPEN Object then store into ErrorObjListWithOpen. 133 + //If PCEP-ERROR list is followed by OPEN Object then store into ErrorObjListWithOpen.
134 - // ( <error-obj-list> [<Open>] 134 + // ( <error-obj-list> [<Open>]
135 - //If PCEP-ERROR list is followed by RP or TE Object then store into errInfo. <error> [<error-list>] 135 + //If PCEP-ERROR list is followed by RP or TE Object then store into errInfo. <error> [<error-list>]
136 - //If only PCEP-ERROR list is present then store into ErrorObjListWithOpen. 136 + //If only PCEP-ERROR list is present then store into ErrorObjListWithOpen.
137 - PcepObjectHeader tempObjHeader; 137 + PcepObjectHeader tempObjHeader;
138 - LinkedList<PcepErrorObject> llErrObjList; 138 + LinkedList<PcepErrorObject> llErrObjList;
139 - 139 +
140 - if (0 >= cb.readableBytes()) { 140 + if (0 >= cb.readableBytes()) {
141 - throw new PcepParseException("PCEP-ERROR message came with empty objects."); 141 + throw new PcepParseException("PCEP-ERROR message came with empty objects.");
142 - } 142 + }
143 - 143 +
144 - //parse PCEP-ERROR list 144 + //parse PCEP-ERROR list
145 - llErrObjList = new LinkedList<PcepErrorObject>(); 145 + llErrObjList = new LinkedList<PcepErrorObject>();
146 - tempObjHeader = parseErrorObjectList(llErrObjList, cb); 146 + tempObjHeader = parseErrorObjectList(llErrObjList, cb);
147 - 147 +
148 - //check whether OPEN-OBJECT is present. 148 + //check whether OPEN-OBJECT is present.
149 - if ((tempObjHeader instanceof PcepObjectHeader) 149 + if ((tempObjHeader instanceof PcepObjectHeader)
150 - && (tempObjHeader.getObjClass() == PcepOpenObjectVer1.OPEN_OBJ_CLASS)) { 150 + && (tempObjHeader.getObjClass() == PcepOpenObjectVer1.OPEN_OBJ_CLASS)) {
151 - 151 +
152 - if (llErrObjList.isEmpty()) { 152 + if (llErrObjList.isEmpty()) {
153 - throw new PcepParseException("<error-obj-list> should be present if OPEN-OBJECT exists"); 153 + throw new PcepParseException("<error-obj-list> should be present if OPEN-OBJECT exists");
154 - } 154 + }
155 - 155 +
156 - PcepOpenObject pcepOpenObj = PcepOpenObjectVer1.read(cb); 156 + PcepOpenObject pcepOpenObj = PcepOpenObjectVer1.read(cb);
157 - this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList, pcepOpenObj); 157 + this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList, pcepOpenObj);
158 - 158 +
159 - } else if ((tempObjHeader instanceof PcepObjectHeader) //check whether RP or TE Object is present. 159 + } else if ((tempObjHeader instanceof PcepObjectHeader) //check whether RP or TE Object is present.
160 - && ((tempObjHeader.getObjClass() == PcepRPObjectVer1.RP_OBJ_CLASS) 160 + && ((tempObjHeader.getObjClass() == PcepRPObjectVer1.RP_OBJ_CLASS)
161 - || (tempObjHeader.getObjClass() == PcepTEObjectVer1.TE_OBJ_CLASS))) { 161 + || (tempObjHeader.getObjClass() == PcepTEObjectVer1.TE_OBJ_CLASS))) {
162 - 162 +
163 - this.errInfo = new PcepErrorInfoVer1(null, null, llErrObjList); 163 + this.errInfo = new PcepErrorInfoVer1(null, null, llErrObjList);
164 - this.errInfo.read(cb); 164 + this.errInfo.read(cb);
165 - 165 +
166 - } else if ((null != llErrObjList) && (!llErrObjList.isEmpty())) { 166 + } else if ((null != llErrObjList) && (!llErrObjList.isEmpty())) {
167 - //If only PCEP-ERROR list is present then store it in errObjListWithOpen. 167 + //If only PCEP-ERROR list is present then store it in errObjListWithOpen.
168 - this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList); 168 + this.errObjListWithOpen = new ErrorObjListWithOpen(llErrObjList);
169 - } else { 169 + } else {
170 - throw new PcepParseException("Empty PCEP-ERROR message."); 170 + throw new PcepParseException("Empty PCEP-ERROR message.");
171 - } 171 + }
172 - } 172 + }
173 - 173 +
174 - /** 174 + /**
175 - * Parse error-obj-list. 175 + * Parse error-obj-list.
176 - * 176 + *
177 - * @param llErrObjList error object list output 177 + * @param llErrObjList error object list output
178 - * @param cb channel buffer input 178 + * @param cb channel buffer input
179 - * @throws PcepParseException if mandatory fields are missing 179 + * @throws PcepParseException if mandatory fields are missing
180 - * @return error object header 180 + * @return error object header
181 - */ 181 + */
182 - public PcepObjectHeader parseErrorObjectList(LinkedList<PcepErrorObject> llErrObjList, ChannelBuffer cb) 182 + public PcepObjectHeader parseErrorObjectList(LinkedList<PcepErrorObject> llErrObjList, ChannelBuffer cb)
183 - throws PcepParseException { 183 + throws PcepParseException {
184 - PcepObjectHeader tempObjHeader = null; 184 + PcepObjectHeader tempObjHeader = null;
185 - 185 +
186 - while (0 < cb.readableBytes()) { 186 + while (0 < cb.readableBytes()) {
187 - cb.markReaderIndex(); 187 + cb.markReaderIndex();
188 - tempObjHeader = PcepObjectHeader.read(cb); 188 + tempObjHeader = PcepObjectHeader.read(cb);
189 - cb.resetReaderIndex(); 189 + cb.resetReaderIndex();
190 - if (tempObjHeader.getObjClass() == PcepErrorObjectVer1.ERROR_OBJ_CLASS) { 190 + if (tempObjHeader.getObjClass() == PcepErrorObjectVer1.ERROR_OBJ_CLASS) {
191 - llErrObjList.add(PcepErrorObjectVer1.read(cb)); 191 + llErrObjList.add(PcepErrorObjectVer1.read(cb));
192 - } else { 192 + } else {
193 - break; 193 + break;
194 - } 194 + }
195 - } 195 + }
196 - return tempObjHeader; 196 + return tempObjHeader;
197 - } 197 + }
198 - } 198 + }
199 - 199 +
200 - /** 200 + /**
201 - * Builder class for PCEP error message. 201 + * Builder class for PCEP error message.
202 - */ 202 + */
203 - public static class Builder implements PcepErrorMsg.Builder { 203 + public static class Builder implements PcepErrorMsg.Builder {
204 - // Pcep error message fields 204 + // Pcep error message fields
205 - 205 +
206 - private ErrorObjListWithOpen errObjListWithOpen = null; //optional ( <error-obj-list> [<Open>] ) 206 + private ErrorObjListWithOpen errObjListWithOpen = null; //optional ( <error-obj-list> [<Open>] )
207 - private PcepErrorInfo errInfo = null; //optional <error> [<error-list>] 207 + private PcepErrorInfo errInfo = null; //optional <error> [<error-list>]
208 - 208 +
209 - @Override 209 + @Override
210 - public PcepVersion getVersion() { 210 + public PcepVersion getVersion() {
211 - return PcepVersion.PCEP_1; 211 + return PcepVersion.PCEP_1;
212 - } 212 + }
213 - 213 +
214 - @Override 214 + @Override
215 - public PcepType getType() { 215 + public PcepType getType() {
216 - return PcepType.ERROR; 216 + return PcepType.ERROR;
217 - } 217 + }
218 - 218 +
219 - @Override 219 + @Override
220 - public PcepErrorMsg build() { 220 + public PcepErrorMsg build() {
221 - return new PcepErrorMsgVer1(this.errObjListWithOpen, this.errInfo); 221 + return new PcepErrorMsgVer1(this.errObjListWithOpen, this.errInfo);
222 - } 222 + }
223 - 223 +
224 - @Override 224 + @Override
225 - public ErrorObjListWithOpen getErrorObjListWithOpen() { 225 + public ErrorObjListWithOpen getErrorObjListWithOpen() {
226 - return this.errObjListWithOpen; 226 + return this.errObjListWithOpen;
227 - } 227 + }
228 - 228 +
229 - @Override 229 + @Override
230 - public Builder setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) { 230 + public Builder setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) {
231 - this.errObjListWithOpen = errObjListWithOpen; 231 + this.errObjListWithOpen = errObjListWithOpen;
232 - return this; 232 + return this;
233 - } 233 + }
234 - 234 +
235 - @Override 235 + @Override
236 - public PcepErrorInfo getPcepErrorInfo() { 236 + public PcepErrorInfo getPcepErrorInfo() {
237 - return this.errInfo; 237 + return this.errInfo;
238 - } 238 + }
239 - 239 +
240 - @Override 240 + @Override
241 - public Builder setPcepErrorInfo(PcepErrorInfo errInfo) { 241 + public Builder setPcepErrorInfo(PcepErrorInfo errInfo) {
242 - this.errInfo = errInfo; 242 + this.errInfo = errInfo;
243 - return this; 243 + return this;
244 - } 244 + }
245 - } 245 + }
246 - 246 +
247 - @Override 247 + @Override
248 - public void writeTo(ChannelBuffer cb) throws PcepParseException { 248 + public void writeTo(ChannelBuffer cb) throws PcepParseException {
249 - WRITER.write(cb, this); 249 + WRITER.write(cb, this);
250 - } 250 + }
251 - 251 +
252 - public static final Writer WRITER = new Writer(); 252 + public static final Writer WRITER = new Writer();
253 - 253 +
254 - /** 254 + /**
255 - * Writer class for writing PCEP error Message to channel buffer. 255 + * Writer class for writing PCEP error Message to channel buffer.
256 - */ 256 + */
257 - static class Writer implements PcepMessageWriter<PcepErrorMsgVer1> { 257 + static class Writer implements PcepMessageWriter<PcepErrorMsgVer1> {
258 - @Override 258 + @Override
259 - public void write(ChannelBuffer cb, PcepErrorMsgVer1 message) throws PcepParseException { 259 + public void write(ChannelBuffer cb, PcepErrorMsgVer1 message) throws PcepParseException {
260 - int startIndex = cb.writerIndex(); 260 + int startIndex = cb.writerIndex();
261 - // first 3 bits set to version 261 + // first 3 bits set to version
262 - cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG)); 262 + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
263 - // message type 0xC 263 + // message type 0xC
264 - cb.writeByte(MSG_TYPE.getType()); 264 + cb.writeByte(MSG_TYPE.getType());
265 - // length is length of variable message, will be updated at the end 265 + // length is length of variable message, will be updated at the end
266 - // Store the position of message 266 + // Store the position of message
267 - // length in buffer 267 + // length in buffer
268 - int msgLenIndex = cb.writerIndex(); 268 + int msgLenIndex = cb.writerIndex();
269 - cb.writeShort(0); 269 + cb.writeShort(0);
270 - ErrorObjListWithOpen errObjListWithOpen = message.getErrorObjListWithOpen(); 270 + ErrorObjListWithOpen errObjListWithOpen = message.getErrorObjListWithOpen();
271 - PcepErrorInfo errInfo = message.getPcepErrorInfo(); 271 + PcepErrorInfo errInfo = message.getPcepErrorInfo();
272 - 272 +
273 - // write ( <error-obj-list> [<Open>] ) if exists. 273 + // write ( <error-obj-list> [<Open>] ) if exists.
274 - // otherwise write <error> [<error-list>] 274 + // otherwise write <error> [<error-list>]
275 - 275 +
276 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 276 + if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
277 - && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 277 + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
278 - errObjListWithOpen.write(cb); 278 + errObjListWithOpen.write(cb);
279 - } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 279 + } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
280 - errInfo.write(cb); 280 + errInfo.write(cb);
281 - } else { 281 + } else {
282 - throw new PcepParseException("Empty PCEP-ERROR message."); 282 + throw new PcepParseException("Empty PCEP-ERROR message.");
283 - } 283 + }
284 - // PcepErrorMessage message length field 284 + // PcepErrorMessage message length field
285 - int length = cb.writerIndex() - startIndex; 285 + int length = cb.writerIndex() - startIndex;
286 - cb.setShort(msgLenIndex, (short) length); 286 + cb.setShort(msgLenIndex, (short) length);
287 - } 287 + }
288 - } 288 + }
289 - 289 +
290 - @Override 290 + @Override
291 - public PcepVersion getVersion() { 291 + public PcepVersion getVersion() {
292 - return PcepVersion.PCEP_1; 292 + return PcepVersion.PCEP_1;
293 - } 293 + }
294 - 294 +
295 - @Override 295 + @Override
296 - public PcepType getType() { 296 + public PcepType getType() {
297 - return MSG_TYPE; 297 + return MSG_TYPE;
298 - } 298 + }
299 - 299 +
300 - @Override 300 + @Override
301 - public ErrorObjListWithOpen getErrorObjListWithOpen() { 301 + public ErrorObjListWithOpen getErrorObjListWithOpen() {
302 - return this.errObjListWithOpen; 302 + return this.errObjListWithOpen;
303 - } 303 + }
304 - 304 +
305 - @Override 305 + @Override
306 - public void setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) { 306 + public void setErrorObjListWithOpen(ErrorObjListWithOpen errObjListWithOpen) {
307 - this.errObjListWithOpen = errObjListWithOpen; 307 + this.errObjListWithOpen = errObjListWithOpen;
308 - } 308 + }
309 - 309 +
310 - @Override 310 + @Override
311 - public PcepErrorInfo getPcepErrorInfo() { 311 + public PcepErrorInfo getPcepErrorInfo() {
312 - return this.errInfo; 312 + return this.errInfo;
313 - } 313 + }
314 - 314 +
315 - @Override 315 + @Override
316 - public void setPcepErrorInfo(PcepErrorInfo errInfo) { 316 + public void setPcepErrorInfo(PcepErrorInfo errInfo) {
317 - this.errInfo = errInfo; 317 + this.errInfo = errInfo;
318 - } 318 + }
319 - 319 +
320 - /** 320 + /**
321 - * Return list of Error types. 321 + * Return list of Error types.
322 - * 322 + *
323 - * @return error types list 323 + * @return error types list
324 - */ 324 + */
325 - public LinkedList<Integer> getErrorType() { 325 + public LinkedList<Integer> getErrorType() {
326 - LinkedList<Integer> llErrorType = new LinkedList<Integer>(); 326 + LinkedList<Integer> llErrorType = new LinkedList<Integer>();
327 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 327 + if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
328 - && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 328 + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
329 - llErrorType = errObjListWithOpen.getErrorType(); 329 + llErrorType = errObjListWithOpen.getErrorType();
330 - } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 330 + } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
331 - llErrorType = errInfo.getErrorType(); 331 + llErrorType = errInfo.getErrorType();
332 - } 332 + }
333 - 333 +
334 - return llErrorType; 334 + return llErrorType;
335 - } 335 + }
336 - 336 +
337 - /** 337 + /**
338 - * Return list of Error values. 338 + * Return list of Error values.
339 - * 339 + *
340 - * @return error value list 340 + * @return error value list
341 - */ 341 + */
342 - public LinkedList<Integer> getErrorValue() { 342 + public LinkedList<Integer> getErrorValue() {
343 - LinkedList<Integer> llErrorValue = new LinkedList<Integer>(); 343 + LinkedList<Integer> llErrorValue = new LinkedList<Integer>();
344 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 344 + if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
345 - && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 345 + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
346 - llErrorValue = errObjListWithOpen.getErrorValue(); 346 + llErrorValue = errObjListWithOpen.getErrorValue();
347 - } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 347 + } else if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
348 - llErrorValue = errInfo.getErrorValue(); 348 + llErrorValue = errInfo.getErrorValue();
349 - } 349 + }
350 - 350 +
351 - return llErrorValue; 351 + return llErrorValue;
352 - } 352 + }
353 - 353 +
354 - @Override 354 + @Override
355 - public String toString() { 355 + public String toString() {
356 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 356 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
357 - 357 +
358 - if ((errObjListWithOpen instanceof ErrorObjListWithOpen) 358 + if ((errObjListWithOpen instanceof ErrorObjListWithOpen)
359 - && (errObjListWithOpen.isErrorObjListWithOpenPresent())) { 359 + && (errObjListWithOpen.isErrorObjListWithOpenPresent())) {
360 - toStrHelper.add("ErrorObjectListWithOpen", errObjListWithOpen); 360 + toStrHelper.add("ErrorObjectListWithOpen", errObjListWithOpen);
361 - } 361 + }
362 - if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) { 362 + if ((errInfo instanceof PcepErrorInfo) && (errInfo.isErrorInfoPresent())) {
363 - toStrHelper.add("ErrorInfo", errInfo); 363 + toStrHelper.add("ErrorInfo", errInfo);
364 - } 364 + }
365 - 365 +
366 - return toStrHelper.toString(); 366 + return toStrHelper.toString();
367 - } 367 + }
368 -} 368 +}
......
1 -package org.onosproject.pcepio.protocol.ver1; 1 +package org.onosproject.pcepio.protocol.ver1;
2 - 2 +
3 -import java.util.LinkedList; 3 +import java.util.LinkedList;
4 -import java.util.ListIterator; 4 +import java.util.ListIterator;
5 - 5 +
6 -import org.jboss.netty.buffer.ChannelBuffer; 6 +import org.jboss.netty.buffer.ChannelBuffer;
7 -import org.onosproject.pcepio.exceptions.PcepParseException; 7 +import org.onosproject.pcepio.exceptions.PcepParseException;
8 -import org.onosproject.pcepio.protocol.PcepErrorObject; 8 +import org.onosproject.pcepio.protocol.PcepErrorObject;
9 -import org.onosproject.pcepio.types.PcepObjectHeader; 9 +import org.onosproject.pcepio.types.PcepObjectHeader;
10 -import org.onosproject.pcepio.types.PcepValueType; 10 +import org.onosproject.pcepio.types.PcepValueType;
11 -import org.slf4j.Logger; 11 +import org.slf4j.Logger;
12 -import org.slf4j.LoggerFactory; 12 +import org.slf4j.LoggerFactory;
13 - 13 +
14 -import com.google.common.base.MoreObjects; 14 +import com.google.common.base.MoreObjects;
15 - 15 +
16 -/** 16 +/**
17 - * Provides PCEP Error Object. 17 + * Provides PCEP Error Object.
18 - */ 18 + */
19 -public class PcepErrorObjectVer1 implements PcepErrorObject { 19 +public class PcepErrorObjectVer1 implements PcepErrorObject {
20 - 20 +
21 - /* 21 + /*
22 - 0 1 2 3 22 + 0 1 2 3
23 - 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 23 + 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
24 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25 - | Object-Class | OT |Res|P|I| Object Length (bytes) | 25 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
26 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 - | Reserved | Flags | Error-Type | Error-value | 27 + | Reserved | Flags | Error-Type | Error-value |
28 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 28 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
29 - | | 29 + | |
30 - // Optional TLVs // 30 + // Optional TLVs //
31 - | | 31 + | |
32 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 32 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
33 - */ 33 + */
34 - protected static final Logger log = LoggerFactory.getLogger(PcepErrorObjectVer1.class); 34 + protected static final Logger log = LoggerFactory.getLogger(PcepErrorObjectVer1.class);
35 - 35 +
36 - public static final byte ERROR_OBJ_TYPE = 1; 36 + public static final byte ERROR_OBJ_TYPE = 1;
37 - public static final byte ERROR_OBJ_CLASS = 13; 37 + public static final byte ERROR_OBJ_CLASS = 13;
38 - public static final byte ERROR_OBJECT_VERSION = 1; 38 + public static final byte ERROR_OBJECT_VERSION = 1;
39 - //ERROR_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ErrorObjectHeaderLen(4) 39 + //ERROR_OBJ_MINIMUM_LENGTH = CommonHeaderLen(4)+ErrorObjectHeaderLen(4)
40 - public static final short ERROR_OBJ_MINIMUM_LENGTH = 8; 40 + public static final short ERROR_OBJ_MINIMUM_LENGTH = 8;
41 - public static final int OBJECT_HEADER_LENGTH = 4; 41 + public static final int OBJECT_HEADER_LENGTH = 4;
42 - 42 +
43 - public static final PcepObjectHeader DEFAULT_ERROR_OBJECT_HEADER = new PcepObjectHeader(ERROR_OBJ_CLASS, 43 + public static final PcepObjectHeader DEFAULT_ERROR_OBJECT_HEADER = new PcepObjectHeader(ERROR_OBJ_CLASS,
44 - ERROR_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, 44 + ERROR_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
45 - ERROR_OBJ_MINIMUM_LENGTH); 45 + ERROR_OBJ_MINIMUM_LENGTH);
46 - 46 +
47 - private PcepObjectHeader errorObjHeader; 47 + private PcepObjectHeader errorObjHeader;
48 - private byte yErrorType; 48 + private byte yErrorType;
49 - private byte yErrorValue; 49 + private byte yErrorValue;
50 - private LinkedList<PcepValueType> llOptionalTlv; // Optional TLV 50 + private LinkedList<PcepValueType> llOptionalTlv; // Optional TLV
51 - 51 +
52 - /** 52 + /**
53 - * Constructor to initialize variables. 53 + * Constructor to initialize variables.
54 - * 54 + *
55 - * @param errorObjHeader ERROR Object header 55 + * @param errorObjHeader ERROR Object header
56 - * @param yErrorType Error Type 56 + * @param yErrorType Error Type
57 - * @param yErrorValue Error Value 57 + * @param yErrorValue Error Value
58 - * @param llOptionalTlv list of optional TLV 58 + * @param llOptionalTlv list of optional TLV
59 - */ 59 + */
60 - 60 +
61 - public PcepErrorObjectVer1(PcepObjectHeader errorObjHeader, byte yErrorType, byte yErrorValue, 61 + public PcepErrorObjectVer1(PcepObjectHeader errorObjHeader, byte yErrorType, byte yErrorValue,
62 - LinkedList<PcepValueType> llOptionalTlv) { 62 + LinkedList<PcepValueType> llOptionalTlv) {
63 - this.errorObjHeader = errorObjHeader; 63 + this.errorObjHeader = errorObjHeader;
64 - this.yErrorType = yErrorType; 64 + this.yErrorType = yErrorType;
65 - this.yErrorValue = yErrorValue; 65 + this.yErrorValue = yErrorValue;
66 - this.llOptionalTlv = llOptionalTlv; 66 + this.llOptionalTlv = llOptionalTlv;
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * sets Object Header. 70 + * sets Object Header.
71 - * 71 + *
72 - * @param obj Error-Object header 72 + * @param obj Error-Object header
73 - */ 73 + */
74 - public void setLspObjHeader(PcepObjectHeader obj) { 74 + public void setLspObjHeader(PcepObjectHeader obj) {
75 - this.errorObjHeader = obj; 75 + this.errorObjHeader = obj;
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public void setErrorType(byte yErrorType) { 79 + public void setErrorType(byte yErrorType) {
80 - this.yErrorType = yErrorType; 80 + this.yErrorType = yErrorType;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public void setErrorValue(byte yErrorValue) { 84 + public void setErrorValue(byte yErrorValue) {
85 - this.yErrorValue = yErrorValue; 85 + this.yErrorValue = yErrorValue;
86 - } 86 + }
87 - 87 +
88 - /** 88 + /**
89 - * returns object header. 89 + * returns object header.
90 - * 90 + *
91 - * @return errorObjHeader Error-Object header 91 + * @return errorObjHeader Error-Object header
92 - */ 92 + */
93 - public PcepObjectHeader getErrorObjHeader() { 93 + public PcepObjectHeader getErrorObjHeader() {
94 - return this.errorObjHeader; 94 + return this.errorObjHeader;
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public int getErrorType() { 98 + public int getErrorType() {
99 - return this.yErrorType; 99 + return this.yErrorType;
100 - } 100 + }
101 - 101 +
102 - @Override 102 + @Override
103 - public byte getErrorValue() { 103 + public byte getErrorValue() {
104 - return this.yErrorValue; 104 + return this.yErrorValue;
105 - } 105 + }
106 - 106 +
107 - @Override 107 + @Override
108 - public LinkedList<PcepValueType> getOptionalTlv() { 108 + public LinkedList<PcepValueType> getOptionalTlv() {
109 - return this.llOptionalTlv; 109 + return this.llOptionalTlv;
110 - } 110 + }
111 - 111 +
112 - @Override 112 + @Override
113 - public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 113 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
114 - this.llOptionalTlv = llOptionalTlv; 114 + this.llOptionalTlv = llOptionalTlv;
115 - } 115 + }
116 - 116 +
117 - /** 117 + /**
118 - * Reads from channel buffer and returns object of PcepErrorObject. 118 + * Reads from channel buffer and returns object of PcepErrorObject.
119 - * 119 + *
120 - * @param cb of channel buffer. 120 + * @param cb of channel buffer.
121 - * @return object of PCEP-ERROR-OBJECT 121 + * @return object of PCEP-ERROR-OBJECT
122 - */ 122 + */
123 - public static PcepErrorObject read(ChannelBuffer cb) { 123 + public static PcepErrorObject read(ChannelBuffer cb) {
124 - 124 +
125 - PcepObjectHeader errorObjHeader; 125 + PcepObjectHeader errorObjHeader;
126 - byte yErrorType; 126 + byte yErrorType;
127 - byte yErrorValue; 127 + byte yErrorValue;
128 - LinkedList<PcepValueType> llOptionalTlv; 128 + LinkedList<PcepValueType> llOptionalTlv;
129 - 129 +
130 - errorObjHeader = PcepObjectHeader.read(cb); 130 + errorObjHeader = PcepObjectHeader.read(cb);
131 - 131 +
132 - //take only ErrorObject buffer. 132 + //take only ErrorObject buffer.
133 - ChannelBuffer tempCb = cb.readBytes(errorObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); 133 + ChannelBuffer tempCb = cb.readBytes(errorObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
134 - tempCb.readByte(); //ignore Reserved 134 + tempCb.readByte(); //ignore Reserved
135 - tempCb.readByte(); //ignore Flags 135 + tempCb.readByte(); //ignore Flags
136 - yErrorType = tempCb.readByte(); 136 + yErrorType = tempCb.readByte();
137 - yErrorValue = tempCb.readByte(); 137 + yErrorValue = tempCb.readByte();
138 - 138 +
139 - llOptionalTlv = parseOptionalTlv(tempCb); 139 + llOptionalTlv = parseOptionalTlv(tempCb);
140 - 140 +
141 - return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv); 141 + return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv);
142 - } 142 + }
143 - 143 +
144 - /** 144 + /**
145 - * returns Linked list of optional tlvs. 145 + * returns Linked list of optional tlvs.
146 - * 146 + *
147 - * @param cb channel buffer. 147 + * @param cb channel buffer.
148 - * @return Linked list of optional tlvs 148 + * @return Linked list of optional tlvs
149 - */ 149 + */
150 - protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) { 150 + protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) {
151 - 151 +
152 - LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>(); 152 + LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
153 - 153 +
154 - byte[] yTemp = new byte[cb.readableBytes()]; 154 + byte[] yTemp = new byte[cb.readableBytes()];
155 - cb.readBytes(yTemp); 155 + cb.readBytes(yTemp);
156 - 156 +
157 - return llOutOptionalTlv; 157 + return llOutOptionalTlv;
158 - } 158 + }
159 - 159 +
160 - @Override 160 + @Override
161 - public int write(ChannelBuffer cb) throws PcepParseException { 161 + public int write(ChannelBuffer cb) throws PcepParseException {
162 - 162 +
163 - //write Object header 163 + //write Object header
164 - int objStartIndex = cb.writerIndex(); 164 + int objStartIndex = cb.writerIndex();
165 - 165 +
166 - int objLenIndex = errorObjHeader.write(cb); 166 + int objLenIndex = errorObjHeader.write(cb);
167 - 167 +
168 - if (objLenIndex <= 0) { 168 + if (objLenIndex <= 0) {
169 - throw new PcepParseException("While writing Error Object Header."); 169 + throw new PcepParseException("While writing Error Object Header.");
170 - } 170 + }
171 - 171 +
172 - //write Reserved 172 + //write Reserved
173 - cb.writeByte(0); 173 + cb.writeByte(0);
174 - //write Flags 174 + //write Flags
175 - cb.writeByte(0); 175 + cb.writeByte(0);
176 - //write ErrorType and ErrorValue 176 + //write ErrorType and ErrorValue
177 - cb.writeByte(this.yErrorType); 177 + cb.writeByte(this.yErrorType);
178 - cb.writeByte(this.yErrorValue); 178 + cb.writeByte(this.yErrorValue);
179 - 179 +
180 - // Add optional TLV 180 + // Add optional TLV
181 - packOptionalTlv(cb); 181 + packOptionalTlv(cb);
182 - 182 +
183 - //Update object length now 183 + //Update object length now
184 - int length = cb.writerIndex() - objStartIndex; 184 + int length = cb.writerIndex() - objStartIndex;
185 - //will be helpful during print(). 185 + //will be helpful during print().
186 - errorObjHeader.setObjLen((short) length); 186 + errorObjHeader.setObjLen((short) length);
187 - // As per RFC the length of object should be 187 + // As per RFC the length of object should be
188 - // multiples of 4 188 + // multiples of 4
189 - int pad = length % 4; 189 + int pad = length % 4;
190 - if (pad != 0) { 190 + if (pad != 0) {
191 - pad = 4 - pad; 191 + pad = 4 - pad;
192 - for (int i = 0; i < pad; i++) { 192 + for (int i = 0; i < pad; i++) {
193 - cb.writeByte((byte) 0); 193 + cb.writeByte((byte) 0);
194 - } 194 + }
195 - length = length + pad; 195 + length = length + pad;
196 - } 196 + }
197 - 197 +
198 - cb.setShort(objLenIndex, (short) length); 198 + cb.setShort(objLenIndex, (short) length);
199 - return length; 199 + return length;
200 - } 200 + }
201 - 201 +
202 - /** 202 + /**
203 - * Pack the Optional tlvs. 203 + * Pack the Optional tlvs.
204 - * 204 + *
205 - * @param cb channel buffer. 205 + * @param cb channel buffer.
206 - * @return writer index. 206 + * @return writer index.
207 - */ 207 + */
208 - protected int packOptionalTlv(ChannelBuffer cb) { 208 + protected int packOptionalTlv(ChannelBuffer cb) {
209 - 209 +
210 - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); 210 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
211 - int startIndex = cb.writerIndex(); 211 + int startIndex = cb.writerIndex();
212 - while (listIterator.hasNext()) { 212 + while (listIterator.hasNext()) {
213 - PcepValueType tlv = listIterator.next(); 213 + PcepValueType tlv = listIterator.next();
214 - 214 +
215 - if (null == tlv) { 215 + if (null == tlv) {
216 - log.debug("TLV is null from OptionalTlv list"); 216 + log.debug("TLV is null from OptionalTlv list");
217 - continue; 217 + continue;
218 - } 218 + }
219 - tlv.write(cb); 219 + tlv.write(cb);
220 - } 220 + }
221 - 221 +
222 - return cb.writerIndex() - startIndex; 222 + return cb.writerIndex() - startIndex;
223 - } 223 + }
224 - 224 +
225 - /** 225 + /**
226 - * Builder class for PCEP error object. 226 + * Builder class for PCEP error object.
227 - */ 227 + */
228 - public static class Builder implements PcepErrorObject.Builder { 228 + public static class Builder implements PcepErrorObject.Builder {
229 - 229 +
230 - private boolean bIsHeaderSet = false; 230 + private boolean bIsHeaderSet = false;
231 - 231 +
232 - private PcepObjectHeader errorObjHeader; 232 + private PcepObjectHeader errorObjHeader;
233 - private byte yErrorType; 233 + private byte yErrorType;
234 - private byte yErrorValue; 234 + private byte yErrorValue;
235 - 235 +
236 - private boolean bIsPFlagSet = false; 236 + private boolean bIsPFlagSet = false;
237 - private boolean bPFlag; 237 + private boolean bPFlag;
238 - 238 +
239 - private boolean bIsIFlagSet = false; 239 + private boolean bIsIFlagSet = false;
240 - private boolean bIFlag; 240 + private boolean bIFlag;
241 - 241 +
242 - private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 242 + private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
243 - 243 +
244 - @Override 244 + @Override
245 - public PcepErrorObject build() { 245 + public PcepErrorObject build() {
246 - 246 +
247 - PcepObjectHeader errorObjHeader = this.bIsHeaderSet ? this.errorObjHeader : DEFAULT_ERROR_OBJECT_HEADER; 247 + PcepObjectHeader errorObjHeader = this.bIsHeaderSet ? this.errorObjHeader : DEFAULT_ERROR_OBJECT_HEADER;
248 - 248 +
249 - if (bIsPFlagSet) { 249 + if (bIsPFlagSet) {
250 - errorObjHeader.setPFlag(bPFlag); 250 + errorObjHeader.setPFlag(bPFlag);
251 - } 251 + }
252 - 252 +
253 - if (bIsIFlagSet) { 253 + if (bIsIFlagSet) {
254 - errorObjHeader.setIFlag(bIFlag); 254 + errorObjHeader.setIFlag(bIFlag);
255 - } 255 + }
256 - 256 +
257 - return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv); 257 + return new PcepErrorObjectVer1(errorObjHeader, yErrorType, yErrorValue, llOptionalTlv);
258 - } 258 + }
259 - 259 +
260 - @Override 260 + @Override
261 - public PcepObjectHeader getErrorObjHeader() { 261 + public PcepObjectHeader getErrorObjHeader() {
262 - return this.errorObjHeader; 262 + return this.errorObjHeader;
263 - } 263 + }
264 - 264 +
265 - @Override 265 + @Override
266 - public Builder setErrorObjHeader(PcepObjectHeader obj) { 266 + public Builder setErrorObjHeader(PcepObjectHeader obj) {
267 - this.errorObjHeader = obj; 267 + this.errorObjHeader = obj;
268 - this.bIsHeaderSet = true; 268 + this.bIsHeaderSet = true;
269 - return this; 269 + return this;
270 - } 270 + }
271 - 271 +
272 - @Override 272 + @Override
273 - public int getErrorType() { 273 + public int getErrorType() {
274 - return this.yErrorType; 274 + return this.yErrorType;
275 - } 275 + }
276 - 276 +
277 - @Override 277 + @Override
278 - public Builder setErrorType(byte value) { 278 + public Builder setErrorType(byte value) {
279 - this.yErrorType = value; 279 + this.yErrorType = value;
280 - return this; 280 + return this;
281 - } 281 + }
282 - 282 +
283 - @Override 283 + @Override
284 - public byte getErrorValue() { 284 + public byte getErrorValue() {
285 - return this.yErrorValue; 285 + return this.yErrorValue;
286 - } 286 + }
287 - 287 +
288 - @Override 288 + @Override
289 - public Builder setErrorValue(byte value) { 289 + public Builder setErrorValue(byte value) {
290 - this.yErrorValue = value; 290 + this.yErrorValue = value;
291 - return this; 291 + return this;
292 - } 292 + }
293 - 293 +
294 - @Override 294 + @Override
295 - public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 295 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
296 - this.llOptionalTlv = llOptionalTlv; 296 + this.llOptionalTlv = llOptionalTlv;
297 - return this; 297 + return this;
298 - } 298 + }
299 - 299 +
300 - @Override 300 + @Override
301 - public LinkedList<PcepValueType> getOptionalTlv() { 301 + public LinkedList<PcepValueType> getOptionalTlv() {
302 - return this.llOptionalTlv; 302 + return this.llOptionalTlv;
303 - } 303 + }
304 - 304 +
305 - @Override 305 + @Override
306 - public Builder setPFlag(boolean value) { 306 + public Builder setPFlag(boolean value) {
307 - this.bPFlag = value; 307 + this.bPFlag = value;
308 - this.bIsPFlagSet = true; 308 + this.bIsPFlagSet = true;
309 - return this; 309 + return this;
310 - } 310 + }
311 - 311 +
312 - @Override 312 + @Override
313 - public Builder setIFlag(boolean value) { 313 + public Builder setIFlag(boolean value) {
314 - this.bIFlag = value; 314 + this.bIFlag = value;
315 - this.bIsIFlagSet = true; 315 + this.bIsIFlagSet = true;
316 - return this; 316 + return this;
317 - } 317 + }
318 - } 318 + }
319 - 319 +
320 - @Override 320 + @Override
321 - public String toString() { 321 + public String toString() {
322 - return MoreObjects.toStringHelper(getClass()).add("ObjectHeader", errorObjHeader).add("ErrorType", yErrorType) 322 + return MoreObjects.toStringHelper(getClass()).add("ObjectHeader", errorObjHeader).add("ErrorType", yErrorType)
323 - .add("ErrorValue", yErrorValue).add("OptionalTlv", llOptionalTlv).toString(); 323 + .add("ErrorValue", yErrorValue).add("OptionalTlv", llOptionalTlv).toString();
324 - } 324 + }
325 -} 325 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.protocol.ver1; 16 +package org.onosproject.pcepio.protocol.ver1;
17 - 17 +
18 -import java.util.LinkedList; 18 +import java.util.LinkedList;
19 -import java.util.ListIterator; 19 +import java.util.ListIterator;
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.exceptions.PcepParseException;
23 -import org.onosproject.pcepio.protocol.PcepError; 23 +import org.onosproject.pcepio.protocol.PcepError;
24 -import org.onosproject.pcepio.protocol.PcepErrorObject; 24 +import org.onosproject.pcepio.protocol.PcepErrorObject;
25 -import org.onosproject.pcepio.protocol.PcepRPObject; 25 +import org.onosproject.pcepio.protocol.PcepRPObject;
26 -import org.onosproject.pcepio.protocol.PcepTEObject; 26 +import org.onosproject.pcepio.protocol.PcepTEObject;
27 -import org.onosproject.pcepio.types.PcepObjectHeader; 27 +import org.onosproject.pcepio.types.PcepObjectHeader;
28 -import org.slf4j.Logger; 28 +import org.slf4j.Logger;
29 -import org.slf4j.LoggerFactory; 29 +import org.slf4j.LoggerFactory;
30 - 30 +
31 -import com.google.common.base.MoreObjects; 31 +import com.google.common.base.MoreObjects;
32 -import com.google.common.base.MoreObjects.ToStringHelper; 32 +import com.google.common.base.MoreObjects.ToStringHelper;
33 - 33 +
34 -/** 34 +/**
35 - * Provides PcepError list which contains RP or TE objects. 35 + * Provides PcepError list which contains RP or TE objects.
36 - * Reference:PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02. 36 + * Reference:PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02.
37 - */ 37 + */
38 -public class PcepErrorVer1 implements PcepError { 38 +public class PcepErrorVer1 implements PcepError {
39 - 39 +
40 - /* 40 + /*
41 - <error>::=[<request-id-list> | <te-id-list>] 41 + <error>::=[<request-id-list> | <te-id-list>]
42 - <error-obj-list> 42 + <error-obj-list>
43 - 43 +
44 - <request-id-list>::=<RP>[<request-id-list>] 44 + <request-id-list>::=<RP>[<request-id-list>]
45 - 45 +
46 - <te-id-list>::=<TE>[<te-id-list>] 46 + <te-id-list>::=<TE>[<te-id-list>]
47 - */ 47 + */
48 - 48 +
49 - protected static final Logger log = LoggerFactory.getLogger(PcepErrorVer1.class); 49 + protected static final Logger log = LoggerFactory.getLogger(PcepErrorVer1.class);
50 - 50 +
51 - private boolean isErroInfoSet; 51 + private boolean isErroInfoSet;
52 - //PcepErrorObject list 52 + //PcepErrorObject list
53 - private LinkedList<PcepErrorObject> llErrObjList; 53 + private LinkedList<PcepErrorObject> llErrObjList;
54 - //PcepRPObject list 54 + //PcepRPObject list
55 - private LinkedList<PcepRPObject> llRPObjList; 55 + private LinkedList<PcepRPObject> llRPObjList;
56 - //PcepTEObject list 56 + //PcepTEObject list
57 - private LinkedList<PcepTEObject> llTEObjList; 57 + private LinkedList<PcepTEObject> llTEObjList;
58 - private boolean isTEObjListSet; 58 + private boolean isTEObjListSet;
59 - 59 +
60 - public static final int OBJECT_HEADER_LENGTH = 4; 60 + public static final int OBJECT_HEADER_LENGTH = 4;
61 - 61 +
62 - /** 62 + /**
63 - * Constructor to initialize variable. 63 + * Constructor to initialize variable.
64 - */ 64 + */
65 - public PcepErrorVer1() { 65 + public PcepErrorVer1() {
66 - this.llRPObjList = null; 66 + this.llRPObjList = null;
67 - this.llTEObjList = null; 67 + this.llTEObjList = null;
68 - this.llErrObjList = null; 68 + this.llErrObjList = null;
69 - } 69 + }
70 - 70 +
71 - /** 71 + /**
72 - * Constructor to initialize variable. 72 + * Constructor to initialize variable.
73 - * 73 + *
74 - * @param llRPObjList list of PcepRPObject 74 + * @param llRPObjList list of PcepRPObject
75 - * @param llTEObjList list of PcepTEObject 75 + * @param llTEObjList list of PcepTEObject
76 - * @param llErrObjListObjList list of PcepErrorObject 76 + * @param llErrObjListObjList list of PcepErrorObject
77 - */ 77 + */
78 - public PcepErrorVer1(LinkedList<PcepRPObject> llRPObjList, LinkedList<PcepTEObject> llTEObjList, 78 + public PcepErrorVer1(LinkedList<PcepRPObject> llRPObjList, LinkedList<PcepTEObject> llTEObjList,
79 - LinkedList<PcepErrorObject> llErrObjListObjList) { 79 + LinkedList<PcepErrorObject> llErrObjListObjList) {
80 - this.llRPObjList = llRPObjList; 80 + this.llRPObjList = llRPObjList;
81 - this.llTEObjList = llTEObjList; 81 + this.llTEObjList = llTEObjList;
82 - this.llErrObjList = llErrObjListObjList; 82 + this.llErrObjList = llErrObjListObjList;
83 - } 83 + }
84 - 84 +
85 - /** 85 + /**
86 - * Constructor to initialize PcepError. 86 + * Constructor to initialize PcepError.
87 - * 87 + *
88 - * @param llErrObjList list of PcepErrorObject 88 + * @param llErrObjList list of PcepErrorObject
89 - */ 89 + */
90 - public PcepErrorVer1(LinkedList<PcepErrorObject> llErrObjList) { 90 + public PcepErrorVer1(LinkedList<PcepErrorObject> llErrObjList) {
91 - this.llRPObjList = null; 91 + this.llRPObjList = null;
92 - this.llTEObjList = null; 92 + this.llTEObjList = null;
93 - this.llErrObjList = llErrObjList; 93 + this.llErrObjList = llErrObjList;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public LinkedList<PcepRPObject> getRPObjList() { 97 + public LinkedList<PcepRPObject> getRPObjList() {
98 - return this.llRPObjList; 98 + return this.llRPObjList;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public LinkedList<PcepTEObject> getTEObjList() { 102 + public LinkedList<PcepTEObject> getTEObjList() {
103 - return this.llTEObjList; 103 + return this.llTEObjList;
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public LinkedList<PcepErrorObject> getErrorObjList() { 107 + public LinkedList<PcepErrorObject> getErrorObjList() {
108 - return this.llErrObjList; 108 + return this.llErrObjList;
109 - } 109 + }
110 - 110 +
111 - /** 111 + /**
112 - * Parse RP List from the channel buffer. 112 + * Parse RP List from the channel buffer.
113 - * 113 + *
114 - * @throws PcepParseException if mandatory fields are missing 114 + * @throws PcepParseException if mandatory fields are missing
115 - * @param cb of type channel buffer 115 + * @param cb of type channel buffer
116 - */ 116 + */
117 - public void parseRPList(ChannelBuffer cb) throws PcepParseException { 117 + public void parseRPList(ChannelBuffer cb) throws PcepParseException {
118 - byte yObjClass; 118 + byte yObjClass;
119 - byte yObjType; 119 + byte yObjType;
120 - 120 +
121 - llRPObjList = new LinkedList<PcepRPObject>(); 121 + llRPObjList = new LinkedList<PcepRPObject>();
122 - 122 +
123 - // caller should verify for RP object 123 + // caller should verify for RP object
124 - if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { 124 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
125 - log.debug("Unable to find RP Object"); 125 + log.debug("Unable to find RP Object");
126 - return; 126 + return;
127 - } 127 + }
128 - 128 +
129 - cb.markReaderIndex(); 129 + cb.markReaderIndex();
130 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 130 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
131 - cb.resetReaderIndex(); 131 + cb.resetReaderIndex();
132 - yObjClass = tempObjHeader.getObjClass(); 132 + yObjClass = tempObjHeader.getObjClass();
133 - yObjType = tempObjHeader.getObjType(); 133 + yObjType = tempObjHeader.getObjType();
134 - PcepRPObject rpObj; 134 + PcepRPObject rpObj;
135 - while ((yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjType == PcepRPObjectVer1.RP_OBJ_TYPE)) { 135 + while ((yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) && (yObjType == PcepRPObjectVer1.RP_OBJ_TYPE)) {
136 - rpObj = PcepRPObjectVer1.read(cb); 136 + rpObj = PcepRPObjectVer1.read(cb);
137 - llRPObjList.add(rpObj); 137 + llRPObjList.add(rpObj);
138 - 138 +
139 - if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { 139 + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
140 - cb.markReaderIndex(); 140 + cb.markReaderIndex();
141 - tempObjHeader = PcepObjectHeader.read(cb); 141 + tempObjHeader = PcepObjectHeader.read(cb);
142 - cb.resetReaderIndex(); 142 + cb.resetReaderIndex();
143 - yObjClass = tempObjHeader.getObjClass(); 143 + yObjClass = tempObjHeader.getObjClass();
144 - yObjType = tempObjHeader.getObjType(); 144 + yObjType = tempObjHeader.getObjType();
145 - } else { 145 + } else {
146 - break; 146 + break;
147 - } 147 + }
148 - } 148 + }
149 - } 149 + }
150 - 150 +
151 - /** 151 + /**
152 - * Parse TE List from the channel buffer. 152 + * Parse TE List from the channel buffer.
153 - * 153 + *
154 - * @param cb of type channel buffer 154 + * @param cb of type channel buffer
155 - * @throws PcepParseException if mandatory fields are missing 155 + * @throws PcepParseException if mandatory fields are missing
156 - */ 156 + */
157 - public void parseTEList(ChannelBuffer cb) throws PcepParseException { 157 + public void parseTEList(ChannelBuffer cb) throws PcepParseException {
158 - byte yObjClass; 158 + byte yObjClass;
159 - byte yObjType; 159 + byte yObjType;
160 - 160 +
161 - llTEObjList = new LinkedList<PcepTEObject>(); 161 + llTEObjList = new LinkedList<PcepTEObject>();
162 - 162 +
163 - // caller should verify for TE object 163 + // caller should verify for TE object
164 - if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { 164 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
165 - log.debug("Unable to find TE Object"); 165 + log.debug("Unable to find TE Object");
166 - return; 166 + return;
167 - } 167 + }
168 - 168 +
169 - cb.markReaderIndex(); 169 + cb.markReaderIndex();
170 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 170 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
171 - cb.resetReaderIndex(); 171 + cb.resetReaderIndex();
172 - yObjClass = tempObjHeader.getObjClass(); 172 + yObjClass = tempObjHeader.getObjClass();
173 - yObjType = tempObjHeader.getObjType(); 173 + yObjType = tempObjHeader.getObjType();
174 - PcepTEObject teObj; 174 + PcepTEObject teObj;
175 - while ((yObjClass == PcepTEObjectVer1.TE_OBJ_CLASS) && ((yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_NODE_VALUE) 175 + while ((yObjClass == PcepTEObjectVer1.TE_OBJ_CLASS) && ((yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_NODE_VALUE)
176 - || (yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_LINK_VALUE))) { 176 + || (yObjType == PcepTEObjectVer1.TE_OBJ_TYPE_LINK_VALUE))) {
177 - teObj = PcepTEObjectVer1.read(cb); 177 + teObj = PcepTEObjectVer1.read(cb);
178 - llTEObjList.add(teObj); 178 + llTEObjList.add(teObj);
179 - 179 +
180 - if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { 180 + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
181 - cb.markReaderIndex(); 181 + cb.markReaderIndex();
182 - tempObjHeader = PcepObjectHeader.read(cb); 182 + tempObjHeader = PcepObjectHeader.read(cb);
183 - cb.resetReaderIndex(); 183 + cb.resetReaderIndex();
184 - yObjClass = tempObjHeader.getObjClass(); 184 + yObjClass = tempObjHeader.getObjClass();
185 - yObjType = tempObjHeader.getObjType(); 185 + yObjType = tempObjHeader.getObjType();
186 - } else { 186 + } else {
187 - break; 187 + break;
188 - } 188 + }
189 - } 189 + }
190 - } 190 + }
191 - 191 +
192 - /** 192 + /**
193 - * parseErrObjList from the channel buffer. 193 + * parseErrObjList from the channel buffer.
194 - * 194 + *
195 - * @param cb of type channel buffer 195 + * @param cb of type channel buffer
196 - * @throws PcepParseException if mandatory fields are missing 196 + * @throws PcepParseException if mandatory fields are missing
197 - */ 197 + */
198 - public void parseErrObjList(ChannelBuffer cb) throws PcepParseException { 198 + public void parseErrObjList(ChannelBuffer cb) throws PcepParseException {
199 - byte yObjClass; 199 + byte yObjClass;
200 - byte yObjType; 200 + byte yObjType;
201 - boolean bIsErrorObjFound = false; 201 + boolean bIsErrorObjFound = false;
202 - 202 +
203 - llErrObjList = new LinkedList<PcepErrorObject>(); 203 + llErrObjList = new LinkedList<PcepErrorObject>();
204 - 204 +
205 - // caller should verify for RP object 205 + // caller should verify for RP object
206 - if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { 206 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
207 - throw new PcepParseException("Unable to find PCEP-ERROR Object"); 207 + throw new PcepParseException("Unable to find PCEP-ERROR Object");
208 - } 208 + }
209 - 209 +
210 - cb.markReaderIndex(); 210 + cb.markReaderIndex();
211 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 211 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
212 - cb.resetReaderIndex(); 212 + cb.resetReaderIndex();
213 - yObjClass = tempObjHeader.getObjClass(); 213 + yObjClass = tempObjHeader.getObjClass();
214 - yObjType = tempObjHeader.getObjType(); 214 + yObjType = tempObjHeader.getObjType();
215 - PcepErrorObject errorObject; 215 + PcepErrorObject errorObject;
216 - while ((yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) && (yObjType == PcepErrorObjectVer1.ERROR_OBJ_TYPE)) { 216 + while ((yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) && (yObjType == PcepErrorObjectVer1.ERROR_OBJ_TYPE)) {
217 - errorObject = PcepErrorObjectVer1.read(cb); 217 + errorObject = PcepErrorObjectVer1.read(cb);
218 - llErrObjList.add(errorObject); 218 + llErrObjList.add(errorObject);
219 - bIsErrorObjFound = true; 219 + bIsErrorObjFound = true;
220 - 220 +
221 - if (cb.readableBytes() > OBJECT_HEADER_LENGTH) { 221 + if (cb.readableBytes() > OBJECT_HEADER_LENGTH) {
222 - cb.markReaderIndex(); 222 + cb.markReaderIndex();
223 - tempObjHeader = PcepObjectHeader.read(cb); 223 + tempObjHeader = PcepObjectHeader.read(cb);
224 - cb.resetReaderIndex(); 224 + cb.resetReaderIndex();
225 - yObjClass = tempObjHeader.getObjClass(); 225 + yObjClass = tempObjHeader.getObjClass();
226 - yObjType = tempObjHeader.getObjType(); 226 + yObjType = tempObjHeader.getObjType();
227 - } else { 227 + } else {
228 - break; 228 + break;
229 - } 229 + }
230 - } 230 + }
231 - 231 +
232 - if (!bIsErrorObjFound) { 232 + if (!bIsErrorObjFound) {
233 - throw new PcepParseException("At least one PCEP-ERROR Object should be present."); 233 + throw new PcepParseException("At least one PCEP-ERROR Object should be present.");
234 - } 234 + }
235 - } 235 + }
236 - 236 +
237 - /** 237 + /**
238 - * Reads the byte stream of PcepError from channel buffer. 238 + * Reads the byte stream of PcepError from channel buffer.
239 - * 239 + *
240 - * @param cb of type channel buffer 240 + * @param cb of type channel buffer
241 - * @return PcepError error part of PCEP-ERROR 241 + * @return PcepError error part of PCEP-ERROR
242 - * @throws PcepParseException if mandatory fields are missing 242 + * @throws PcepParseException if mandatory fields are missing
243 - */ 243 + */
244 - public static PcepErrorVer1 read(ChannelBuffer cb) throws PcepParseException { 244 + public static PcepErrorVer1 read(ChannelBuffer cb) throws PcepParseException {
245 - if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { 245 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
246 - throw new PcepParseException("Unknown Object"); 246 + throw new PcepParseException("Unknown Object");
247 - } 247 + }
248 - 248 +
249 - PcepErrorVer1 pcepError = new PcepErrorVer1(); 249 + PcepErrorVer1 pcepError = new PcepErrorVer1();
250 - // check whether any PCEP Error Info is present 250 + // check whether any PCEP Error Info is present
251 - cb.markReaderIndex(); 251 + cb.markReaderIndex();
252 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 252 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
253 - cb.resetReaderIndex(); 253 + cb.resetReaderIndex();
254 - byte yObjClass = tempObjHeader.getObjClass(); 254 + byte yObjClass = tempObjHeader.getObjClass();
255 - 255 +
256 - //If RPlist present then store it.RPList and TEList are optional 256 + //If RPlist present then store it.RPList and TEList are optional
257 - if (yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) { 257 + if (yObjClass == PcepRPObjectVer1.RP_OBJ_CLASS) {
258 - log.debug("RP_LIST"); 258 + log.debug("RP_LIST");
259 - pcepError.parseRPList(cb); 259 + pcepError.parseRPList(cb);
260 - yObjClass = checkNextObject(cb); 260 + yObjClass = checkNextObject(cb);
261 - } else if (yObjClass == PcepTEObjectVer1.TE_OBJ_CLASS) { 261 + } else if (yObjClass == PcepTEObjectVer1.TE_OBJ_CLASS) {
262 - log.debug("TE_LIST"); 262 + log.debug("TE_LIST");
263 - pcepError.parseTEList(cb); 263 + pcepError.parseTEList(cb);
264 - yObjClass = checkNextObject(cb); 264 + yObjClass = checkNextObject(cb);
265 - } 265 + }
266 - 266 +
267 - if (yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) { 267 + if (yObjClass == PcepErrorObjectVer1.ERROR_OBJ_CLASS) {
268 - log.debug("PCEP-ERROR obj list"); 268 + log.debug("PCEP-ERROR obj list");
269 - pcepError.parseErrObjList(cb); 269 + pcepError.parseErrObjList(cb);
270 - yObjClass = checkNextObject(cb); 270 + yObjClass = checkNextObject(cb);
271 - } 271 + }
272 - 272 +
273 - return pcepError; 273 + return pcepError;
274 - } 274 + }
275 - 275 +
276 - /** 276 + /**
277 - * Checks Next Object. 277 + * Checks Next Object.
278 - * 278 + *
279 - * @param cb of type channel buffer. 279 + * @param cb of type channel buffer.
280 - * @return object type class. 280 + * @return object type class.
281 - */ 281 + */
282 - private static byte checkNextObject(ChannelBuffer cb) { 282 + private static byte checkNextObject(ChannelBuffer cb) {
283 - if (cb.readableBytes() < OBJECT_HEADER_LENGTH) { 283 + if (cb.readableBytes() < OBJECT_HEADER_LENGTH) {
284 - return 0; 284 + return 0;
285 - } 285 + }
286 - cb.markReaderIndex(); 286 + cb.markReaderIndex();
287 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb); 287 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(cb);
288 - cb.resetReaderIndex(); 288 + cb.resetReaderIndex();
289 - return tempObjHeader.getObjClass(); 289 + return tempObjHeader.getObjClass();
290 - } 290 + }
291 - 291 +
292 - /** 292 + /**
293 - * Writes the byte stream of PCEP error to the channel buffer. 293 + * Writes the byte stream of PCEP error to the channel buffer.
294 - * 294 + *
295 - * @param cb of type channel buffer 295 + * @param cb of type channel buffer
296 - * @return object length index 296 + * @return object length index
297 - * @throws PcepParseException if mandatory fields are missing 297 + * @throws PcepParseException if mandatory fields are missing
298 - */ 298 + */
299 - @Override 299 + @Override
300 - public int write(ChannelBuffer cb) throws PcepParseException { 300 + public int write(ChannelBuffer cb) throws PcepParseException {
301 - int iLenStartIndex = cb.writerIndex(); 301 + int iLenStartIndex = cb.writerIndex();
302 - 302 +
303 - // RPlist is optional 303 + // RPlist is optional
304 - if (this.isErroInfoSet) { 304 + if (this.isErroInfoSet) {
305 - ListIterator<PcepRPObject> rpObjlistIterator = this.llRPObjList.listIterator(); 305 + ListIterator<PcepRPObject> rpObjlistIterator = this.llRPObjList.listIterator();
306 - while (rpObjlistIterator.hasNext()) { 306 + while (rpObjlistIterator.hasNext()) {
307 - rpObjlistIterator.next().write(cb); 307 + rpObjlistIterator.next().write(cb);
308 - } 308 + }
309 - } 309 + }
310 - 310 +
311 - // TElist is optional 311 + // TElist is optional
312 - if (this.isTEObjListSet) { 312 + if (this.isTEObjListSet) {
313 - ListIterator<PcepTEObject> teObjlistIterator = this.llTEObjList.listIterator(); 313 + ListIterator<PcepTEObject> teObjlistIterator = this.llTEObjList.listIterator();
314 - while (teObjlistIterator.hasNext()) { 314 + while (teObjlistIterator.hasNext()) {
315 - teObjlistIterator.next().write(cb); 315 + teObjlistIterator.next().write(cb);
316 - } 316 + }
317 - } 317 + }
318 - //ErrList is mandatory 318 + //ErrList is mandatory
319 - ListIterator<PcepErrorObject> errlistIterator = this.llErrObjList.listIterator(); 319 + ListIterator<PcepErrorObject> errlistIterator = this.llErrObjList.listIterator();
320 - while (errlistIterator.hasNext()) { 320 + while (errlistIterator.hasNext()) {
321 - errlistIterator.next().write(cb); 321 + errlistIterator.next().write(cb);
322 - } 322 + }
323 - 323 +
324 - return cb.writerIndex() - iLenStartIndex; 324 + return cb.writerIndex() - iLenStartIndex;
325 - } 325 + }
326 - 326 +
327 - /** 327 + /**
328 - * Builder for error part of PCEP-ERROR. 328 + * Builder for error part of PCEP-ERROR.
329 - */ 329 + */
330 - public static class Builder implements PcepError.Builder { 330 + public static class Builder implements PcepError.Builder {
331 - 331 +
332 - private LinkedList<PcepRPObject> llRPObjList; 332 + private LinkedList<PcepRPObject> llRPObjList;
333 - private LinkedList<PcepTEObject> llTEObjList; 333 + private LinkedList<PcepTEObject> llTEObjList;
334 - private LinkedList<PcepErrorObject> llErrObjList; 334 + private LinkedList<PcepErrorObject> llErrObjList;
335 - 335 +
336 - @Override 336 + @Override
337 - public PcepError build() { 337 + public PcepError build() {
338 - return new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList); 338 + return new PcepErrorVer1(llRPObjList, llTEObjList, llErrObjList);
339 - } 339 + }
340 - 340 +
341 - @Override 341 + @Override
342 - public LinkedList<PcepRPObject> getRPObjList() { 342 + public LinkedList<PcepRPObject> getRPObjList() {
343 - return this.llRPObjList; 343 + return this.llRPObjList;
344 - } 344 + }
345 - 345 +
346 - @Override 346 + @Override
347 - public Builder setRPObjList(LinkedList<PcepRPObject> llRPObjList) { 347 + public Builder setRPObjList(LinkedList<PcepRPObject> llRPObjList) {
348 - this.llRPObjList = llRPObjList; 348 + this.llRPObjList = llRPObjList;
349 - return this; 349 + return this;
350 - } 350 + }
351 - 351 +
352 - @Override 352 + @Override
353 - public LinkedList<PcepTEObject> getTEObjList() { 353 + public LinkedList<PcepTEObject> getTEObjList() {
354 - return this.llTEObjList; 354 + return this.llTEObjList;
355 - } 355 + }
356 - 356 +
357 - @Override 357 + @Override
358 - public Builder setTEObjList(LinkedList<PcepTEObject> llTEObjList) { 358 + public Builder setTEObjList(LinkedList<PcepTEObject> llTEObjList) {
359 - this.llTEObjList = llTEObjList; 359 + this.llTEObjList = llTEObjList;
360 - return this; 360 + return this;
361 - } 361 + }
362 - 362 +
363 - @Override 363 + @Override
364 - public LinkedList<PcepErrorObject> getErrorObjList() { 364 + public LinkedList<PcepErrorObject> getErrorObjList() {
365 - return this.llErrObjList; 365 + return this.llErrObjList;
366 - } 366 + }
367 - 367 +
368 - @Override 368 + @Override
369 - public Builder setErrorObjList(LinkedList<PcepErrorObject> llErrObjList) { 369 + public Builder setErrorObjList(LinkedList<PcepErrorObject> llErrObjList) {
370 - this.llErrObjList = llErrObjList; 370 + this.llErrObjList = llErrObjList;
371 - return this; 371 + return this;
372 - } 372 + }
373 - 373 +
374 - } 374 + }
375 - 375 +
376 - @Override 376 + @Override
377 - public void setRPObjList(LinkedList<PcepRPObject> llRPObjList) { 377 + public void setRPObjList(LinkedList<PcepRPObject> llRPObjList) {
378 - this.llRPObjList = llRPObjList; 378 + this.llRPObjList = llRPObjList;
379 - } 379 + }
380 - 380 +
381 - @Override 381 + @Override
382 - public void setTEObjList(LinkedList<PcepTEObject> llTEObjList) { 382 + public void setTEObjList(LinkedList<PcepTEObject> llTEObjList) {
383 - this.llTEObjList = llTEObjList; 383 + this.llTEObjList = llTEObjList;
384 - } 384 + }
385 - 385 +
386 - @Override 386 + @Override
387 - public void setErrorObjList(LinkedList<PcepErrorObject> llErrObjList) { 387 + public void setErrorObjList(LinkedList<PcepErrorObject> llErrObjList) {
388 - this.llErrObjList = llErrObjList; 388 + this.llErrObjList = llErrObjList;
389 - } 389 + }
390 - 390 +
391 - @Override 391 + @Override
392 - public String toString() { 392 + public String toString() {
393 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 393 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
394 - 394 +
395 - //RP Object list is optional 395 + //RP Object list is optional
396 - if (null != llRPObjList) { 396 + if (null != llRPObjList) {
397 - toStrHelper.add("RpObjectList", llRPObjList); 397 + toStrHelper.add("RpObjectList", llRPObjList);
398 - } 398 + }
399 - 399 +
400 - //TE Object list is optional 400 + //TE Object list is optional
401 - if (null != llTEObjList) { 401 + if (null != llTEObjList) {
402 - toStrHelper.add("TeObjectList", llTEObjList); 402 + toStrHelper.add("TeObjectList", llTEObjList);
403 - } 403 + }
404 - 404 +
405 - //Error Object List is mandatory 405 + //Error Object List is mandatory
406 - return toStrHelper.add("ErrorObjectList", llErrObjList).toString(); 406 + return toStrHelper.add("ErrorObjectList", llErrObjList).toString();
407 - } 407 + }
408 -} 408 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
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.PcepFecObjectIPv4Adjacency; 21 +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.onosproject.pcepio.types.PcepObjectHeader; 23 +import org.onosproject.pcepio.types.PcepObjectHeader;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 - 28 +
29 -/** 29 +/**
30 - * Provides PCEP fec Object IPv4 Adjacency object. 30 + * Provides PCEP fec Object IPv4 Adjacency object.
31 - */ 31 + */
32 -public class PcepFecObjectIPv4AdjacencyVer1 implements PcepFecObjectIPv4Adjacency { 32 +public class PcepFecObjectIPv4AdjacencyVer1 implements PcepFecObjectIPv4Adjacency {
33 - 33 +
34 - /* 34 + /*
35 - * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 35 + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
36 - * 36 + *
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Local IPv4 address | 40 + | Local IPv4 address |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | Remote IPv4 address | 42 + | Remote IPv4 address |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - 44 +
45 - FEC Object-Type is 3 IPv4 Adjacency 45 + FEC Object-Type is 3 IPv4 Adjacency
46 - */ 46 + */
47 - protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4AdjacencyVer1.class); 47 + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4AdjacencyVer1.class);
48 - 48 +
49 - public static final byte FEC_OBJ_TYPE = 3; 49 + public static final byte FEC_OBJ_TYPE = 3;
50 - public static final byte FEC_OBJ_CLASS = 36; //to be defined 50 + public static final byte FEC_OBJ_CLASS = 36; //to be defined
51 - public static final byte FEC_OBJECT_VERSION = 1; 51 + public static final byte FEC_OBJECT_VERSION = 1;
52 - public static final short FEC_OBJ_MINIMUM_LENGTH = 12; 52 + public static final short FEC_OBJ_MINIMUM_LENGTH = 12;
53 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 53 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
54 - 54 +
55 - static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, 55 + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
56 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); 56 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
57 - 57 +
58 - private PcepObjectHeader fecObjHeader; 58 + private PcepObjectHeader fecObjHeader;
59 - private int localIPv4Address; 59 + private int localIPv4Address;
60 - private int remoteIPv4Address; 60 + private int remoteIPv4Address;
61 - 61 +
62 - /** 62 + /**
63 - * Constructor to initialize parameters for PCEP fec object . 63 + * Constructor to initialize parameters for PCEP fec object .
64 - * 64 + *
65 - * @param fecObjHeader FEC Object header 65 + * @param fecObjHeader FEC Object header
66 - * @param localIPv4Address Local IPv4 Address 66 + * @param localIPv4Address Local IPv4 Address
67 - * @param remoteIPv4Address Remote IPv4 Address 67 + * @param remoteIPv4Address Remote IPv4 Address
68 - */ 68 + */
69 - public PcepFecObjectIPv4AdjacencyVer1(PcepObjectHeader fecObjHeader, int localIPv4Address, int remoteIPv4Address) { 69 + public PcepFecObjectIPv4AdjacencyVer1(PcepObjectHeader fecObjHeader, int localIPv4Address, int remoteIPv4Address) {
70 - this.fecObjHeader = fecObjHeader; 70 + this.fecObjHeader = fecObjHeader;
71 - this.localIPv4Address = localIPv4Address; 71 + this.localIPv4Address = localIPv4Address;
72 - this.remoteIPv4Address = remoteIPv4Address; 72 + this.remoteIPv4Address = remoteIPv4Address;
73 - } 73 + }
74 - 74 +
75 - /** 75 + /**
76 - * Sets Object header. 76 + * Sets Object header.
77 - * 77 + *
78 - * @param obj Pcep fec Object Header 78 + * @param obj Pcep fec Object Header
79 - */ 79 + */
80 - public void setFecIpv4ObjHeader(PcepObjectHeader obj) { 80 + public void setFecIpv4ObjHeader(PcepObjectHeader obj) {
81 - this.fecObjHeader = obj; 81 + this.fecObjHeader = obj;
82 - } 82 + }
83 - 83 +
84 - @Override 84 + @Override
85 - public int getLocalIPv4Address() { 85 + public int getLocalIPv4Address() {
86 - return this.localIPv4Address; 86 + return this.localIPv4Address;
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public void seLocalIPv4Address(int value) { 90 + public void seLocalIPv4Address(int value) {
91 - this.localIPv4Address = value; 91 + this.localIPv4Address = value;
92 - } 92 + }
93 - 93 +
94 - @Override 94 + @Override
95 - public int getRemoteIPv4Address() { 95 + public int getRemoteIPv4Address() {
96 - return this.remoteIPv4Address; 96 + return this.remoteIPv4Address;
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public void seRemoteIPv4Address(int value) { 100 + public void seRemoteIPv4Address(int value) {
101 - this.remoteIPv4Address = value; 101 + this.remoteIPv4Address = value;
102 - } 102 + }
103 - 103 +
104 - /** 104 + /**
105 - * Reads from channel buffer and Returns object of PcepFecObjectIPv4Adjacency. 105 + * Reads from channel buffer and Returns object of PcepFecObjectIPv4Adjacency.
106 - * 106 + *
107 - * @param cb of channel buffer. 107 + * @param cb of channel buffer.
108 - * @return object of PcepFecObjectIPv4Adjacency 108 + * @return object of PcepFecObjectIPv4Adjacency
109 - * @throws PcepParseException when fails to read from channel buffer 109 + * @throws PcepParseException when fails to read from channel buffer
110 - */ 110 + */
111 - public static PcepFecObjectIPv4Adjacency read(ChannelBuffer cb) throws PcepParseException { 111 + public static PcepFecObjectIPv4Adjacency read(ChannelBuffer cb) throws PcepParseException {
112 - 112 +
113 - PcepObjectHeader fecObjHeader; 113 + PcepObjectHeader fecObjHeader;
114 - int localIPv4Address; 114 + int localIPv4Address;
115 - int remoteIPv4Address; 115 + int remoteIPv4Address;
116 - 116 +
117 - fecObjHeader = PcepObjectHeader.read(cb); 117 + fecObjHeader = PcepObjectHeader.read(cb);
118 - 118 +
119 - //take only FEC IPv4 Adjacency Object buffer. 119 + //take only FEC IPv4 Adjacency Object buffer.
120 - ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH); 120 + ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
121 - localIPv4Address = tempCb.readInt(); 121 + localIPv4Address = tempCb.readInt();
122 - remoteIPv4Address = tempCb.readInt(); 122 + remoteIPv4Address = tempCb.readInt();
123 - 123 +
124 - return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, localIPv4Address, remoteIPv4Address); 124 + return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, localIPv4Address, remoteIPv4Address);
125 - } 125 + }
126 - 126 +
127 - @Override 127 + @Override
128 - public int write(ChannelBuffer cb) throws PcepParseException { 128 + public int write(ChannelBuffer cb) throws PcepParseException {
129 - 129 +
130 - int objStartIndex = cb.writerIndex(); 130 + int objStartIndex = cb.writerIndex();
131 - 131 +
132 - //Write common header 132 + //Write common header
133 - int objLenIndex = fecObjHeader.write(cb); 133 + int objLenIndex = fecObjHeader.write(cb);
134 - cb.writeInt(localIPv4Address); 134 + cb.writeInt(localIPv4Address);
135 - cb.writeInt(remoteIPv4Address); 135 + cb.writeInt(remoteIPv4Address);
136 - 136 +
137 - //Now write FEC IPv4 Adjacency Object Length 137 + //Now write FEC IPv4 Adjacency Object Length
138 - cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); 138 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
139 - return cb.writerIndex(); 139 + return cb.writerIndex();
140 - } 140 + }
141 - 141 +
142 - /** 142 + /**
143 - * Builder class for PCEP fec object IPv4 Adjacency. 143 + * Builder class for PCEP fec object IPv4 Adjacency.
144 - */ 144 + */
145 - public static class Builder implements PcepFecObjectIPv4Adjacency.Builder { 145 + public static class Builder implements PcepFecObjectIPv4Adjacency.Builder {
146 - private boolean bIsHeaderSet = false; 146 + private boolean bIsHeaderSet = false;
147 - private boolean bIsLocalIPv4Addressset = false; 147 + private boolean bIsLocalIPv4Addressset = false;
148 - private boolean bIsRemoteIPv4Addressset = false; 148 + private boolean bIsRemoteIPv4Addressset = false;
149 - 149 +
150 - private PcepObjectHeader fecObjHeader; 150 + private PcepObjectHeader fecObjHeader;
151 - int localIPv4Address; 151 + int localIPv4Address;
152 - int remoteIPv4Address; 152 + int remoteIPv4Address;
153 - 153 +
154 - private boolean bIsPFlagSet = false; 154 + private boolean bIsPFlagSet = false;
155 - private boolean bPFlag; 155 + private boolean bPFlag;
156 - 156 +
157 - private boolean bIsIFlagSet = false; 157 + private boolean bIsIFlagSet = false;
158 - private boolean bIFlag; 158 + private boolean bIFlag;
159 - 159 +
160 - @Override 160 + @Override
161 - public PcepFecObjectIPv4Adjacency build() throws PcepParseException { 161 + public PcepFecObjectIPv4Adjacency build() throws PcepParseException {
162 - PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; 162 + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
163 - 163 +
164 - if (!this.bIsLocalIPv4Addressset) { 164 + if (!this.bIsLocalIPv4Addressset) {
165 - throw new PcepParseException( 165 + throw new PcepParseException(
166 - "Local IPv4 Address not set while building PcepFecObjectIPv4Adjacency object."); 166 + "Local IPv4 Address not set while building PcepFecObjectIPv4Adjacency object.");
167 - } 167 + }
168 - 168 +
169 - if (!this.bIsRemoteIPv4Addressset) { 169 + if (!this.bIsRemoteIPv4Addressset) {
170 - throw new PcepParseException( 170 + throw new PcepParseException(
171 - " Remote IPv4 Address not set while building PcepFecObjectIPv4Adjacency object."); 171 + " Remote IPv4 Address not set while building PcepFecObjectIPv4Adjacency object.");
172 - } 172 + }
173 - 173 +
174 - if (bIsPFlagSet) { 174 + if (bIsPFlagSet) {
175 - fecObjHeader.setPFlag(bPFlag); 175 + fecObjHeader.setPFlag(bPFlag);
176 - } 176 + }
177 - 177 +
178 - if (bIsIFlagSet) { 178 + if (bIsIFlagSet) {
179 - fecObjHeader.setIFlag(bIFlag); 179 + fecObjHeader.setIFlag(bIFlag);
180 - } 180 + }
181 - return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, this.localIPv4Address, this.remoteIPv4Address); 181 + return new PcepFecObjectIPv4AdjacencyVer1(fecObjHeader, this.localIPv4Address, this.remoteIPv4Address);
182 - } 182 + }
183 - 183 +
184 - @Override 184 + @Override
185 - public Builder setPFlag(boolean value) { 185 + public Builder setPFlag(boolean value) {
186 - this.bPFlag = value; 186 + this.bPFlag = value;
187 - this.bIsPFlagSet = true; 187 + this.bIsPFlagSet = true;
188 - return this; 188 + return this;
189 - } 189 + }
190 - 190 +
191 - @Override 191 + @Override
192 - public Builder setIFlag(boolean value) { 192 + public Builder setIFlag(boolean value) {
193 - this.bIFlag = value; 193 + this.bIFlag = value;
194 - this.bIsIFlagSet = true; 194 + this.bIsIFlagSet = true;
195 - return this; 195 + return this;
196 - } 196 + }
197 - 197 +
198 - @Override 198 + @Override
199 - public PcepObjectHeader getFecIpv4AdjacencyObjHeader() { 199 + public PcepObjectHeader getFecIpv4AdjacencyObjHeader() {
200 - return this.fecObjHeader; 200 + return this.fecObjHeader;
201 - } 201 + }
202 - 202 +
203 - @Override 203 + @Override
204 - public Builder setFecIpv4AdjacencyObjHeader(PcepObjectHeader obj) { 204 + public Builder setFecIpv4AdjacencyObjHeader(PcepObjectHeader obj) {
205 - this.fecObjHeader = obj; 205 + this.fecObjHeader = obj;
206 - this.bIsHeaderSet = true; 206 + this.bIsHeaderSet = true;
207 - return this; 207 + return this;
208 - } 208 + }
209 - 209 +
210 - @Override 210 + @Override
211 - public int getLocalIPv4Address() { 211 + public int getLocalIPv4Address() {
212 - return this.localIPv4Address; 212 + return this.localIPv4Address;
213 - } 213 + }
214 - 214 +
215 - @Override 215 + @Override
216 - public Builder seLocalIPv4Address(int value) { 216 + public Builder seLocalIPv4Address(int value) {
217 - this.localIPv4Address = value; 217 + this.localIPv4Address = value;
218 - this.bIsLocalIPv4Addressset = true; 218 + this.bIsLocalIPv4Addressset = true;
219 - return this; 219 + return this;
220 - } 220 + }
221 - 221 +
222 - @Override 222 + @Override
223 - public int getRemoteIPv4Address() { 223 + public int getRemoteIPv4Address() {
224 - return this.remoteIPv4Address; 224 + return this.remoteIPv4Address;
225 - } 225 + }
226 - 226 +
227 - @Override 227 + @Override
228 - public Builder seRemoteIPv4Address(int value) { 228 + public Builder seRemoteIPv4Address(int value) {
229 - this.remoteIPv4Address = value; 229 + this.remoteIPv4Address = value;
230 - this.bIsRemoteIPv4Addressset = true; 230 + this.bIsRemoteIPv4Addressset = true;
231 - return this; 231 + return this;
232 - } 232 + }
233 - 233 +
234 - } 234 + }
235 - 235 +
236 - @Override 236 + @Override
237 - public PcepVersion getVersion() { 237 + public PcepVersion getVersion() {
238 - return PcepVersion.PCEP_1; 238 + return PcepVersion.PCEP_1;
239 - } 239 + }
240 - 240 +
241 - @Override 241 + @Override
242 - public int getType() { 242 + public int getType() {
243 - return FEC_OBJ_TYPE; 243 + return FEC_OBJ_TYPE;
244 - } 244 + }
245 - 245 +
246 - @Override 246 + @Override
247 - public String toString() { 247 + public String toString() {
248 - return MoreObjects.toStringHelper(getClass()).add("fecObjHeader", fecObjHeader) 248 + return MoreObjects.toStringHelper(getClass()).add("fecObjHeader", fecObjHeader)
249 - .add("localIPv4Address", localIPv4Address).add("remoteIPv4Address", remoteIPv4Address).toString(); 249 + .add("localIPv4Address", localIPv4Address).add("remoteIPv4Address", remoteIPv4Address).toString();
250 - } 250 + }
251 -} 251 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
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.PcepFecObjectIPv4UnnumberedAdjacency; 21 +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4UnnumberedAdjacency;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.onosproject.pcepio.types.PcepObjectHeader; 23 +import org.onosproject.pcepio.types.PcepObjectHeader;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 - 28 +
29 -/** 29 +/**
30 - * Provides Pcep Fec Object IPv4 Unnumbered Adjacency object. 30 + * Provides Pcep Fec Object IPv4 Unnumbered Adjacency object.
31 - */ 31 + */
32 -public class PcepFecObjectIPv4UnnumberedAdjacencyVer1 implements PcepFecObjectIPv4UnnumberedAdjacency { 32 +public class PcepFecObjectIPv4UnnumberedAdjacencyVer1 implements PcepFecObjectIPv4UnnumberedAdjacency {
33 - 33 +
34 - /* 34 + /*
35 - * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 35 + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
36 - * 36 + *
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Local Node-ID | 40 + | Local Node-ID |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | Local Interface ID | 42 + | Local Interface ID |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - | Remote Node-ID | 44 + | Remote Node-ID |
45 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 - | Remote Interface ID | 46 + | Remote Interface ID |
47 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 - 48 +
49 - FEC Object-Type is 5, Unnumbered Adjacency with IPv4 NodeIDs 49 + FEC Object-Type is 5, Unnumbered Adjacency with IPv4 NodeIDs
50 - */ 50 + */
51 - protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4UnnumberedAdjacencyVer1.class); 51 + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4UnnumberedAdjacencyVer1.class);
52 - 52 +
53 - public static final byte FEC_OBJ_TYPE = 5; 53 + public static final byte FEC_OBJ_TYPE = 5;
54 - public static final byte FEC_OBJ_CLASS = 63; //to be defined 54 + public static final byte FEC_OBJ_CLASS = 63; //to be defined
55 - public static final byte FEC_OBJECT_VERSION = 1; 55 + public static final byte FEC_OBJECT_VERSION = 1;
56 - public static final short FEC_OBJ_MINIMUM_LENGTH = 20; 56 + public static final short FEC_OBJ_MINIMUM_LENGTH = 20;
57 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 57 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
58 - 58 +
59 - static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, 59 + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
60 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); 60 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
61 - 61 +
62 - private PcepObjectHeader fecObjHeader; 62 + private PcepObjectHeader fecObjHeader;
63 - private int localNodeID; 63 + private int localNodeID;
64 - private int localInterfaceID; 64 + private int localInterfaceID;
65 - private int remoteNodeID; 65 + private int remoteNodeID;
66 - private int remoteInterfaceID; 66 + private int remoteInterfaceID;
67 - 67 +
68 - /** 68 + /**
69 - * Constructor to initialize parameter for PCEP fec object. 69 + * Constructor to initialize parameter for PCEP fec object.
70 - * 70 + *
71 - * @param fecObjHeader fec object header 71 + * @param fecObjHeader fec object header
72 - * @param localNodeID local node ID 72 + * @param localNodeID local node ID
73 - * @param localInterfaceID local interface ID 73 + * @param localInterfaceID local interface ID
74 - * @param remoteNodeID remote node ID 74 + * @param remoteNodeID remote node ID
75 - * @param remoteInterfaceID remote interface ID 75 + * @param remoteInterfaceID remote interface ID
76 - */ 76 + */
77 - public PcepFecObjectIPv4UnnumberedAdjacencyVer1(PcepObjectHeader fecObjHeader, int localNodeID, 77 + public PcepFecObjectIPv4UnnumberedAdjacencyVer1(PcepObjectHeader fecObjHeader, int localNodeID,
78 - int localInterfaceID, int remoteNodeID, int remoteInterfaceID) { 78 + int localInterfaceID, int remoteNodeID, int remoteInterfaceID) {
79 - this.fecObjHeader = fecObjHeader; 79 + this.fecObjHeader = fecObjHeader;
80 - this.localNodeID = localNodeID; 80 + this.localNodeID = localNodeID;
81 - this.localInterfaceID = localInterfaceID; 81 + this.localInterfaceID = localInterfaceID;
82 - this.remoteNodeID = remoteNodeID; 82 + this.remoteNodeID = remoteNodeID;
83 - this.remoteInterfaceID = remoteInterfaceID; 83 + this.remoteInterfaceID = remoteInterfaceID;
84 - } 84 + }
85 - 85 +
86 - /** 86 + /**
87 - * Sets Object Header. 87 + * Sets Object Header.
88 - * 88 + *
89 - * @param obj object header 89 + * @param obj object header
90 - */ 90 + */
91 - public void setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) { 91 + public void setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) {
92 - this.fecObjHeader = obj; 92 + this.fecObjHeader = obj;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public void setLocalNodeID(int localNodeID) { 96 + public void setLocalNodeID(int localNodeID) {
97 - this.localNodeID = localNodeID; 97 + this.localNodeID = localNodeID;
98 - } 98 + }
99 - 99 +
100 - /** 100 + /**
101 - * Returns Object Header. 101 + * Returns Object Header.
102 - * 102 + *
103 - * @return fecObjHeader fec object header 103 + * @return fecObjHeader fec object header
104 - */ 104 + */
105 - public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() { 105 + public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() {
106 - return this.fecObjHeader; 106 + return this.fecObjHeader;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int getLocalNodeID() { 110 + public int getLocalNodeID() {
111 - return this.localNodeID; 111 + return this.localNodeID;
112 - } 112 + }
113 - 113 +
114 - @Override 114 + @Override
115 - public int getLocalInterfaceID() { 115 + public int getLocalInterfaceID() {
116 - return this.localInterfaceID; 116 + return this.localInterfaceID;
117 - } 117 + }
118 - 118 +
119 - @Override 119 + @Override
120 - public void setLocalInterfaceID(int localInterfaceID) { 120 + public void setLocalInterfaceID(int localInterfaceID) {
121 - this.localInterfaceID = localInterfaceID; 121 + this.localInterfaceID = localInterfaceID;
122 - } 122 + }
123 - 123 +
124 - @Override 124 + @Override
125 - public int getRemoteNodeID() { 125 + public int getRemoteNodeID() {
126 - return this.remoteNodeID; 126 + return this.remoteNodeID;
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public void setRemoteNodeID(int remoteNodeID) { 130 + public void setRemoteNodeID(int remoteNodeID) {
131 - this.remoteNodeID = remoteNodeID; 131 + this.remoteNodeID = remoteNodeID;
132 - } 132 + }
133 - 133 +
134 - @Override 134 + @Override
135 - public int getRemoteInterfaceID() { 135 + public int getRemoteInterfaceID() {
136 - return this.remoteInterfaceID; 136 + return this.remoteInterfaceID;
137 - } 137 + }
138 - 138 +
139 - @Override 139 + @Override
140 - public void setRemoteInterfaceID(int remoteInterfaceID) { 140 + public void setRemoteInterfaceID(int remoteInterfaceID) {
141 - this.remoteInterfaceID = remoteInterfaceID; 141 + this.remoteInterfaceID = remoteInterfaceID;
142 - } 142 + }
143 - 143 +
144 - /** 144 + /**
145 - * Reads from channel buffer and returns object of PcepFecObjectIPv4UnnumberedAdjacency. 145 + * Reads from channel buffer and returns object of PcepFecObjectIPv4UnnumberedAdjacency.
146 - * 146 + *
147 - * @param cb of channel buffer 147 + * @param cb of channel buffer
148 - * @return object of PcepFecObjectIPv4UnnumberedAdjacency 148 + * @return object of PcepFecObjectIPv4UnnumberedAdjacency
149 - * @throws PcepParseException when fails to read from channel buffer 149 + * @throws PcepParseException when fails to read from channel buffer
150 - */ 150 + */
151 - public static PcepFecObjectIPv4UnnumberedAdjacency read(ChannelBuffer cb) throws PcepParseException { 151 + public static PcepFecObjectIPv4UnnumberedAdjacency read(ChannelBuffer cb) throws PcepParseException {
152 - 152 +
153 - PcepObjectHeader fecObjHeader; 153 + PcepObjectHeader fecObjHeader;
154 - int localNodeID; 154 + int localNodeID;
155 - int localInterfaceID; 155 + int localInterfaceID;
156 - int remoteNodeID; 156 + int remoteNodeID;
157 - int remoteInterfaceID; 157 + int remoteInterfaceID;
158 - 158 +
159 - fecObjHeader = PcepObjectHeader.read(cb); 159 + fecObjHeader = PcepObjectHeader.read(cb);
160 - 160 +
161 - //take only FEC IPv4 Unnumbered Adjacency Object buffer. 161 + //take only FEC IPv4 Unnumbered Adjacency Object buffer.
162 - ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH); 162 + ChannelBuffer tempCb = cb.readBytes(fecObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
163 - localNodeID = tempCb.readInt(); 163 + localNodeID = tempCb.readInt();
164 - localInterfaceID = tempCb.readInt(); 164 + localInterfaceID = tempCb.readInt();
165 - remoteNodeID = tempCb.readInt(); 165 + remoteNodeID = tempCb.readInt();
166 - remoteInterfaceID = tempCb.readInt(); 166 + remoteInterfaceID = tempCb.readInt();
167 - 167 +
168 - return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, localNodeID, localInterfaceID, remoteNodeID, 168 + return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, localNodeID, localInterfaceID, remoteNodeID,
169 - remoteInterfaceID); 169 + remoteInterfaceID);
170 - } 170 + }
171 - 171 +
172 - @Override 172 + @Override
173 - public int write(ChannelBuffer cb) throws PcepParseException { 173 + public int write(ChannelBuffer cb) throws PcepParseException {
174 - 174 +
175 - int objStartIndex = cb.writerIndex(); 175 + int objStartIndex = cb.writerIndex();
176 - 176 +
177 - //Write common header 177 + //Write common header
178 - int objLenIndex = fecObjHeader.write(cb); 178 + int objLenIndex = fecObjHeader.write(cb);
179 - cb.writeInt(localNodeID); 179 + cb.writeInt(localNodeID);
180 - cb.writeInt(localInterfaceID); 180 + cb.writeInt(localInterfaceID);
181 - cb.writeInt(remoteNodeID); 181 + cb.writeInt(remoteNodeID);
182 - cb.writeInt(remoteInterfaceID); 182 + cb.writeInt(remoteInterfaceID);
183 - 183 +
184 - //Now write FEC IPv4 Unnumbered Adjacency Object Length 184 + //Now write FEC IPv4 Unnumbered Adjacency Object Length
185 - cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); 185 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
186 - 186 +
187 - return cb.writerIndex(); 187 + return cb.writerIndex();
188 - } 188 + }
189 - 189 +
190 - /** 190 + /**
191 - * Builder class for PCEP Fec object IPv4 unnumbered Adjacency. 191 + * Builder class for PCEP Fec object IPv4 unnumbered Adjacency.
192 - */ 192 + */
193 - public static class Builder implements PcepFecObjectIPv4UnnumberedAdjacency.Builder { 193 + public static class Builder implements PcepFecObjectIPv4UnnumberedAdjacency.Builder {
194 - private boolean bIsHeaderSet = false; 194 + private boolean bIsHeaderSet = false;
195 - private boolean bIsLocalNodeIDset = false; 195 + private boolean bIsLocalNodeIDset = false;
196 - private boolean bIsLocalInterfaceIDset = false; 196 + private boolean bIsLocalInterfaceIDset = false;
197 - private boolean bIsRemoteNodeIDset = false; 197 + private boolean bIsRemoteNodeIDset = false;
198 - private boolean bIsRemoteInterfaceIDset = false; 198 + private boolean bIsRemoteInterfaceIDset = false;
199 - 199 +
200 - private PcepObjectHeader fecObjHeader; 200 + private PcepObjectHeader fecObjHeader;
201 - private int localNodeID; 201 + private int localNodeID;
202 - private int localInterfaceID; 202 + private int localInterfaceID;
203 - private int remoteNodeID; 203 + private int remoteNodeID;
204 - private int remoteInterfaceID; 204 + private int remoteInterfaceID;
205 - 205 +
206 - private boolean bIsPFlagSet = false; 206 + private boolean bIsPFlagSet = false;
207 - private boolean bPFlag; 207 + private boolean bPFlag;
208 - 208 +
209 - private boolean bIsIFlagSet = false; 209 + private boolean bIsIFlagSet = false;
210 - private boolean bIFlag; 210 + private boolean bIFlag;
211 - 211 +
212 - @Override 212 + @Override
213 - public PcepFecObjectIPv4UnnumberedAdjacency build() throws PcepParseException { 213 + public PcepFecObjectIPv4UnnumberedAdjacency build() throws PcepParseException {
214 - PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; 214 + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
215 - 215 +
216 - if (!this.bIsLocalNodeIDset) { 216 + if (!this.bIsLocalNodeIDset) {
217 - throw new PcepParseException( 217 + throw new PcepParseException(
218 - " Local Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); 218 + " Local Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
219 - } 219 + }
220 - if (!this.bIsLocalInterfaceIDset) { 220 + if (!this.bIsLocalInterfaceIDset) {
221 - throw new PcepParseException( 221 + throw new PcepParseException(
222 - " Local Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); 222 + " Local Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
223 - } 223 + }
224 - if (!this.bIsRemoteNodeIDset) { 224 + if (!this.bIsRemoteNodeIDset) {
225 - throw new PcepParseException( 225 + throw new PcepParseException(
226 - " Remote Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); 226 + " Remote Node ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
227 - } 227 + }
228 - if (!this.bIsRemoteInterfaceIDset) { 228 + if (!this.bIsRemoteInterfaceIDset) {
229 - throw new PcepParseException( 229 + throw new PcepParseException(
230 - " Remote Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object."); 230 + " Remote Interface ID not set while building PcepFecObjectIPv4UnnumberedAdjacency object.");
231 - } 231 + }
232 - if (bIsPFlagSet) { 232 + if (bIsPFlagSet) {
233 - fecObjHeader.setPFlag(bPFlag); 233 + fecObjHeader.setPFlag(bPFlag);
234 - } 234 + }
235 - if (bIsIFlagSet) { 235 + if (bIsIFlagSet) {
236 - fecObjHeader.setIFlag(bIFlag); 236 + fecObjHeader.setIFlag(bIFlag);
237 - } 237 + }
238 - return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, this.localNodeID, this.localInterfaceID, 238 + return new PcepFecObjectIPv4UnnumberedAdjacencyVer1(fecObjHeader, this.localNodeID, this.localInterfaceID,
239 - this.remoteNodeID, this.remoteInterfaceID); 239 + this.remoteNodeID, this.remoteInterfaceID);
240 - } 240 + }
241 - 241 +
242 - @Override 242 + @Override
243 - public Builder setPFlag(boolean value) { 243 + public Builder setPFlag(boolean value) {
244 - this.bPFlag = value; 244 + this.bPFlag = value;
245 - this.bIsPFlagSet = true; 245 + this.bIsPFlagSet = true;
246 - return this; 246 + return this;
247 - } 247 + }
248 - 248 +
249 - @Override 249 + @Override
250 - public Builder setIFlag(boolean value) { 250 + public Builder setIFlag(boolean value) {
251 - this.bIFlag = value; 251 + this.bIFlag = value;
252 - this.bIsIFlagSet = true; 252 + this.bIsIFlagSet = true;
253 - return this; 253 + return this;
254 - } 254 + }
255 - 255 +
256 - @Override 256 + @Override
257 - public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() { 257 + public PcepObjectHeader getFecIpv4UnnumberedAdjacencyObjHeader() {
258 - return this.fecObjHeader; 258 + return this.fecObjHeader;
259 - } 259 + }
260 - 260 +
261 - @Override 261 + @Override
262 - public Builder setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) { 262 + public Builder setFecIpv4UnnumberedAdjacencyObjHeader(PcepObjectHeader obj) {
263 - this.fecObjHeader = obj; 263 + this.fecObjHeader = obj;
264 - this.bIsHeaderSet = true; 264 + this.bIsHeaderSet = true;
265 - return this; 265 + return this;
266 - } 266 + }
267 - 267 +
268 - @Override 268 + @Override
269 - public int getLocalNodeID() { 269 + public int getLocalNodeID() {
270 - return this.localNodeID; 270 + return this.localNodeID;
271 - } 271 + }
272 - 272 +
273 - @Override 273 + @Override
274 - public Builder setLocalNodeID(int value) { 274 + public Builder setLocalNodeID(int value) {
275 - this.localNodeID = value; 275 + this.localNodeID = value;
276 - this.bIsLocalNodeIDset = true; 276 + this.bIsLocalNodeIDset = true;
277 - return this; 277 + return this;
278 - } 278 + }
279 - 279 +
280 - @Override 280 + @Override
281 - public int getLocalInterfaceID() { 281 + public int getLocalInterfaceID() {
282 - return this.localInterfaceID; 282 + return this.localInterfaceID;
283 - } 283 + }
284 - 284 +
285 - @Override 285 + @Override
286 - public Builder setLocalInterfaceID(int value) { 286 + public Builder setLocalInterfaceID(int value) {
287 - this.localInterfaceID = value; 287 + this.localInterfaceID = value;
288 - this.bIsLocalInterfaceIDset = true; 288 + this.bIsLocalInterfaceIDset = true;
289 - return this; 289 + return this;
290 - } 290 + }
291 - 291 +
292 - @Override 292 + @Override
293 - public int getRemoteNodeID() { 293 + public int getRemoteNodeID() {
294 - return this.remoteNodeID; 294 + return this.remoteNodeID;
295 - } 295 + }
296 - 296 +
297 - @Override 297 + @Override
298 - public Builder setRemoteNodeID(int value) { 298 + public Builder setRemoteNodeID(int value) {
299 - this.remoteNodeID = value; 299 + this.remoteNodeID = value;
300 - this.bIsRemoteNodeIDset = true; 300 + this.bIsRemoteNodeIDset = true;
301 - return this; 301 + return this;
302 - } 302 + }
303 - 303 +
304 - @Override 304 + @Override
305 - public int getRemoteInterfaceID() { 305 + public int getRemoteInterfaceID() {
306 - return this.remoteInterfaceID; 306 + return this.remoteInterfaceID;
307 - } 307 + }
308 - 308 +
309 - @Override 309 + @Override
310 - public Builder setRemoteInterfaceID(int value) { 310 + public Builder setRemoteInterfaceID(int value) {
311 - this.remoteInterfaceID = value; 311 + this.remoteInterfaceID = value;
312 - this.bIsRemoteInterfaceIDset = true; 312 + this.bIsRemoteInterfaceIDset = true;
313 - return this; 313 + return this;
314 - } 314 + }
315 - } 315 + }
316 - 316 +
317 - @Override 317 + @Override
318 - public PcepVersion getVersion() { 318 + public PcepVersion getVersion() {
319 - return PcepVersion.PCEP_1; 319 + return PcepVersion.PCEP_1;
320 - } 320 + }
321 - 321 +
322 - @Override 322 + @Override
323 - public int getType() { 323 + public int getType() {
324 - return FEC_OBJ_TYPE; 324 + return FEC_OBJ_TYPE;
325 - } 325 + }
326 - 326 +
327 - @Override 327 + @Override
328 - public String toString() { 328 + public String toString() {
329 - return MoreObjects.toStringHelper(getClass()).add("LocalNodeID: ", localNodeID) 329 + return MoreObjects.toStringHelper(getClass()).add("LocalNodeID: ", localNodeID)
330 - .add("LocalInterfaceID: ", localInterfaceID).add("RemoteNodeID: ", remoteNodeID) 330 + .add("LocalInterfaceID: ", localInterfaceID).add("RemoteNodeID: ", remoteNodeID)
331 - .add("RemoteInterfaceID: ", remoteInterfaceID).toString(); 331 + .add("RemoteInterfaceID: ", remoteInterfaceID).toString();
332 - } 332 + }
333 -} 333 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
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.PcepFecObjectIPv4; 21 +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.onosproject.pcepio.types.PcepObjectHeader; 23 +import org.onosproject.pcepio.types.PcepObjectHeader;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 - 28 +
29 -/** 29 +/**
30 - * Provides Pcep Fec Object IPv4 object. 30 + * Provides Pcep Fec Object IPv4 object.
31 - */ 31 + */
32 -public class PcepFecObjectIPv4Ver1 implements PcepFecObjectIPv4 { 32 +public class PcepFecObjectIPv4Ver1 implements PcepFecObjectIPv4 {
33 - 33 +
34 - /* 34 + /*
35 - * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 35 + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
36 - * 36 + *
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | IPv4 Node ID | 40 + | IPv4 Node ID |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - 42 +
43 - FEC Object-Type is 1 IPv4 Node ID 43 + FEC Object-Type is 1 IPv4 Node ID
44 - */ 44 + */
45 - protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4Ver1.class); 45 + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv4Ver1.class);
46 - 46 +
47 - public static final byte FEC_OBJ_TYPE = 1; 47 + public static final byte FEC_OBJ_TYPE = 1;
48 - public static final byte FEC_OBJ_CLASS = 63; //to be defined 48 + public static final byte FEC_OBJ_CLASS = 63; //to be defined
49 - public static final byte FEC_OBJECT_VERSION = 1; 49 + public static final byte FEC_OBJECT_VERSION = 1;
50 - public static final short FEC_OBJ_MINIMUM_LENGTH = 8; 50 + public static final short FEC_OBJ_MINIMUM_LENGTH = 8;
51 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 51 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
52 - 52 +
53 - static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, 53 + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
54 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); 54 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
55 - 55 +
56 - private PcepObjectHeader fecObjHeader; 56 + private PcepObjectHeader fecObjHeader;
57 - private int nodeID; 57 + private int nodeID;
58 - 58 +
59 - /** 59 + /**
60 - * Constructor to initialize parameters for PCEP fec object. 60 + * Constructor to initialize parameters for PCEP fec object.
61 - * 61 + *
62 - * @param fecObjHeader fec object header 62 + * @param fecObjHeader fec object header
63 - * @param nodeID node id 63 + * @param nodeID node id
64 - */ 64 + */
65 - public PcepFecObjectIPv4Ver1(PcepObjectHeader fecObjHeader, int nodeID) { 65 + public PcepFecObjectIPv4Ver1(PcepObjectHeader fecObjHeader, int nodeID) {
66 - this.fecObjHeader = fecObjHeader; 66 + this.fecObjHeader = fecObjHeader;
67 - this.nodeID = nodeID; 67 + this.nodeID = nodeID;
68 - } 68 + }
69 - 69 +
70 - /** 70 + /**
71 - * Sets the Object Header. 71 + * Sets the Object Header.
72 - * 72 + *
73 - * @param obj object header 73 + * @param obj object header
74 - */ 74 + */
75 - public void setFecIpv4ObjHeader(PcepObjectHeader obj) { 75 + public void setFecIpv4ObjHeader(PcepObjectHeader obj) {
76 - this.fecObjHeader = obj; 76 + this.fecObjHeader = obj;
77 - } 77 + }
78 - 78 +
79 - @Override 79 + @Override
80 - public void setNodeID(int nodeID) { 80 + public void setNodeID(int nodeID) {
81 - this.nodeID = nodeID; 81 + this.nodeID = nodeID;
82 - } 82 + }
83 - 83 +
84 - /** 84 + /**
85 - * Returns Object Header. 85 + * Returns Object Header.
86 - * 86 + *
87 - * @return fecObjHeader fec object header 87 + * @return fecObjHeader fec object header
88 - */ 88 + */
89 - public PcepObjectHeader getFecIpv4ObjHeader() { 89 + public PcepObjectHeader getFecIpv4ObjHeader() {
90 - return this.fecObjHeader; 90 + return this.fecObjHeader;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public int getNodeID() { 94 + public int getNodeID() {
95 - return this.nodeID; 95 + return this.nodeID;
96 - } 96 + }
97 - 97 +
98 - /** 98 + /**
99 - * Reads from channel buffer and returns object of PcepFecObjectIPv4. 99 + * Reads from channel buffer and returns object of PcepFecObjectIPv4.
100 - * 100 + *
101 - * @param cb of channel buffer 101 + * @param cb of channel buffer
102 - * @return object of PcepFecObjectIPv4 102 + * @return object of PcepFecObjectIPv4
103 - * @throws PcepParseException when fails to read from channel buffer 103 + * @throws PcepParseException when fails to read from channel buffer
104 - */ 104 + */
105 - public static PcepFecObjectIPv4 read(ChannelBuffer cb) throws PcepParseException { 105 + public static PcepFecObjectIPv4 read(ChannelBuffer cb) throws PcepParseException {
106 - 106 +
107 - PcepObjectHeader fecObjHeader; 107 + PcepObjectHeader fecObjHeader;
108 - int nodeID; 108 + int nodeID;
109 - fecObjHeader = PcepObjectHeader.read(cb); 109 + fecObjHeader = PcepObjectHeader.read(cb);
110 - nodeID = cb.readInt(); 110 + nodeID = cb.readInt();
111 - return new PcepFecObjectIPv4Ver1(fecObjHeader, nodeID); 111 + return new PcepFecObjectIPv4Ver1(fecObjHeader, nodeID);
112 - } 112 + }
113 - 113 +
114 - @Override 114 + @Override
115 - public int write(ChannelBuffer cb) throws PcepParseException { 115 + public int write(ChannelBuffer cb) throws PcepParseException {
116 - 116 +
117 - int objStartIndex = cb.writerIndex(); 117 + int objStartIndex = cb.writerIndex();
118 - 118 +
119 - //write common header 119 + //write common header
120 - int objLenIndex = fecObjHeader.write(cb); 120 + int objLenIndex = fecObjHeader.write(cb);
121 - cb.writeInt(nodeID); 121 + cb.writeInt(nodeID);
122 - 122 +
123 - //now write FEC IPv4 Object Length 123 + //now write FEC IPv4 Object Length
124 - cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); 124 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
125 - return cb.writerIndex(); 125 + return cb.writerIndex();
126 - } 126 + }
127 - 127 +
128 - /** 128 + /**
129 - * Builder class for PCEP fec pobject IPv4. 129 + * Builder class for PCEP fec pobject IPv4.
130 - */ 130 + */
131 - public static class Builder implements PcepFecObjectIPv4.Builder { 131 + public static class Builder implements PcepFecObjectIPv4.Builder {
132 - private boolean bIsHeaderSet = false; 132 + private boolean bIsHeaderSet = false;
133 - private boolean bIsNodeIdset = false; 133 + private boolean bIsNodeIdset = false;
134 - 134 +
135 - private PcepObjectHeader fecObjHeader; 135 + private PcepObjectHeader fecObjHeader;
136 - private int nodeID; 136 + private int nodeID;
137 - 137 +
138 - private boolean bIsPFlagSet = false; 138 + private boolean bIsPFlagSet = false;
139 - private boolean bPFlag; 139 + private boolean bPFlag;
140 - 140 +
141 - private boolean bIsIFlagSet = false; 141 + private boolean bIsIFlagSet = false;
142 - private boolean bIFlag; 142 + private boolean bIFlag;
143 - 143 +
144 - @Override 144 + @Override
145 - public PcepFecObjectIPv4 build() throws PcepParseException { 145 + public PcepFecObjectIPv4 build() throws PcepParseException {
146 - PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; 146 + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
147 - 147 +
148 - if (!this.bIsNodeIdset) { 148 + if (!this.bIsNodeIdset) {
149 - throw new PcepParseException("NodeID not set while building PcepFecObjectIPv4 object."); 149 + throw new PcepParseException("NodeID not set while building PcepFecObjectIPv4 object.");
150 - } 150 + }
151 - if (bIsPFlagSet) { 151 + if (bIsPFlagSet) {
152 - fecObjHeader.setPFlag(bPFlag); 152 + fecObjHeader.setPFlag(bPFlag);
153 - } 153 + }
154 - if (bIsIFlagSet) { 154 + if (bIsIFlagSet) {
155 - fecObjHeader.setIFlag(bIFlag); 155 + fecObjHeader.setIFlag(bIFlag);
156 - } 156 + }
157 - return new PcepFecObjectIPv4Ver1(fecObjHeader, this.nodeID); 157 + return new PcepFecObjectIPv4Ver1(fecObjHeader, this.nodeID);
158 - } 158 + }
159 - 159 +
160 - @Override 160 + @Override
161 - public Builder setPFlag(boolean value) { 161 + public Builder setPFlag(boolean value) {
162 - this.bPFlag = value; 162 + this.bPFlag = value;
163 - this.bIsPFlagSet = true; 163 + this.bIsPFlagSet = true;
164 - return this; 164 + return this;
165 - } 165 + }
166 - 166 +
167 - @Override 167 + @Override
168 - public Builder setIFlag(boolean value) { 168 + public Builder setIFlag(boolean value) {
169 - this.bIFlag = value; 169 + this.bIFlag = value;
170 - this.bIsIFlagSet = true; 170 + this.bIsIFlagSet = true;
171 - return this; 171 + return this;
172 - } 172 + }
173 - 173 +
174 - @Override 174 + @Override
175 - public PcepObjectHeader getFecIpv4ObjHeader() { 175 + public PcepObjectHeader getFecIpv4ObjHeader() {
176 - return this.fecObjHeader; 176 + return this.fecObjHeader;
177 - } 177 + }
178 - 178 +
179 - @Override 179 + @Override
180 - public Builder setFecIpv4ObjHeader(PcepObjectHeader obj) { 180 + public Builder setFecIpv4ObjHeader(PcepObjectHeader obj) {
181 - this.fecObjHeader = obj; 181 + this.fecObjHeader = obj;
182 - this.bIsHeaderSet = true; 182 + this.bIsHeaderSet = true;
183 - return this; 183 + return this;
184 - } 184 + }
185 - 185 +
186 - @Override 186 + @Override
187 - public int getNodeID() { 187 + public int getNodeID() {
188 - return this.nodeID; 188 + return this.nodeID;
189 - } 189 + }
190 - 190 +
191 - @Override 191 + @Override
192 - public Builder setNodeID(int value) { 192 + public Builder setNodeID(int value) {
193 - this.nodeID = value; 193 + this.nodeID = value;
194 - this.bIsNodeIdset = true; 194 + this.bIsNodeIdset = true;
195 - return this; 195 + return this;
196 - } 196 + }
197 - 197 +
198 - } 198 + }
199 - 199 +
200 - @Override 200 + @Override
201 - public PcepVersion getVersion() { 201 + public PcepVersion getVersion() {
202 - return PcepVersion.PCEP_1; 202 + return PcepVersion.PCEP_1;
203 - } 203 + }
204 - 204 +
205 - @Override 205 + @Override
206 - public int getType() { 206 + public int getType() {
207 - return FEC_OBJ_TYPE; 207 + return FEC_OBJ_TYPE;
208 - } 208 + }
209 - 209 +
210 - @Override 210 + @Override
211 - public String toString() { 211 + public String toString() {
212 - return MoreObjects.toStringHelper(getClass()).add("fecObjHeader", fecObjHeader).add("nodeID: ", nodeID) 212 + return MoreObjects.toStringHelper(getClass()).add("fecObjHeader", fecObjHeader).add("nodeID: ", nodeID)
213 - .toString(); 213 + .toString();
214 - } 214 + }
215 -} 215 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
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.PcepFecObjectIPv6Adjacency; 21 +import org.onosproject.pcepio.protocol.PcepFecObjectIPv6Adjacency;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.onosproject.pcepio.types.PcepObjectHeader; 23 +import org.onosproject.pcepio.types.PcepObjectHeader;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 - 28 +
29 -/** 29 +/**
30 - * Provides Pcep Fec Object IPv6 Adjacency object. 30 + * Provides Pcep Fec Object IPv6 Adjacency object.
31 - */ 31 + */
32 -public class PcepFecObjectIPv6AdjacencyVer1 implements PcepFecObjectIPv6Adjacency { 32 +public class PcepFecObjectIPv6AdjacencyVer1 implements PcepFecObjectIPv6Adjacency {
33 - 33 +
34 - /* 34 + /*
35 - * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 35 + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
36 - * 36 + *
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | | 40 + | |
41 - // Local IPv6 address (16 bytes) // 41 + // Local IPv6 address (16 bytes) //
42 - | | 42 + | |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - | | 44 + | |
45 - // Remote IPv6 address (16 bytes) // 45 + // Remote IPv6 address (16 bytes) //
46 - | | 46 + | |
47 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 - 48 +
49 - FEC Object-Type is 4 IPv6 Adjacency 49 + FEC Object-Type is 4 IPv6 Adjacency
50 - */ 50 + */
51 - protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6AdjacencyVer1.class); 51 + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6AdjacencyVer1.class);
52 - 52 +
53 - public static final byte FEC_OBJ_TYPE = 4; 53 + public static final byte FEC_OBJ_TYPE = 4;
54 - public static final byte FEC_OBJ_CLASS = 63; //to be defined 54 + public static final byte FEC_OBJ_CLASS = 63; //to be defined
55 - public static final byte FEC_OBJECT_VERSION = 1; 55 + public static final byte FEC_OBJECT_VERSION = 1;
56 - public static final short FEC_OBJ_MINIMUM_LENGTH = 36; 56 + public static final short FEC_OBJ_MINIMUM_LENGTH = 36;
57 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 57 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
58 - public static final int IPV6_ADDRESS_LENGTH = 16; 58 + public static final int IPV6_ADDRESS_LENGTH = 16;
59 - 59 +
60 - static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, 60 + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
61 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); 61 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
62 - 62 +
63 - private PcepObjectHeader fecObjHeader; 63 + private PcepObjectHeader fecObjHeader;
64 - private byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; 64 + private byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
65 - private byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; 65 + private byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
66 - 66 +
67 - /** 67 + /**
68 - * Constructor to initialize parameters for PCEP fec object. 68 + * Constructor to initialize parameters for PCEP fec object.
69 - * 69 + *
70 - * @param fecObjHeader fec object header 70 + * @param fecObjHeader fec object header
71 - * @param localIPv6Address local IPv6 address 71 + * @param localIPv6Address local IPv6 address
72 - * @param remoteIPv6Address remote IPv6 address 72 + * @param remoteIPv6Address remote IPv6 address
73 - */ 73 + */
74 - public PcepFecObjectIPv6AdjacencyVer1(PcepObjectHeader fecObjHeader, byte[] localIPv6Address, 74 + public PcepFecObjectIPv6AdjacencyVer1(PcepObjectHeader fecObjHeader, byte[] localIPv6Address,
75 - byte[] remoteIPv6Address) { 75 + byte[] remoteIPv6Address) {
76 - this.fecObjHeader = fecObjHeader; 76 + this.fecObjHeader = fecObjHeader;
77 - this.localIPv6Address = localIPv6Address; 77 + this.localIPv6Address = localIPv6Address;
78 - this.remoteIPv6Address = remoteIPv6Address; 78 + this.remoteIPv6Address = remoteIPv6Address;
79 - } 79 + }
80 - 80 +
81 - /** 81 + /**
82 - * Sets Object Header. 82 + * Sets Object Header.
83 - * 83 + *
84 - * @param obj object header 84 + * @param obj object header
85 - */ 85 + */
86 - public void setFecIpv4ObjHeader(PcepObjectHeader obj) { 86 + public void setFecIpv4ObjHeader(PcepObjectHeader obj) {
87 - this.fecObjHeader = obj; 87 + this.fecObjHeader = obj;
88 - } 88 + }
89 - 89 +
90 - @Override 90 + @Override
91 - public byte[] getLocalIPv6Address() { 91 + public byte[] getLocalIPv6Address() {
92 - return this.localIPv6Address; 92 + return this.localIPv6Address;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public void seLocalIPv6Address(byte[] value) { 96 + public void seLocalIPv6Address(byte[] value) {
97 - this.localIPv6Address = value; 97 + this.localIPv6Address = value;
98 - } 98 + }
99 - 99 +
100 - @Override 100 + @Override
101 - public byte[] getRemoteIPv6Address() { 101 + public byte[] getRemoteIPv6Address() {
102 - return this.remoteIPv6Address; 102 + return this.remoteIPv6Address;
103 - } 103 + }
104 - 104 +
105 - @Override 105 + @Override
106 - public void seRemoteIPv6Address(byte[] value) { 106 + public void seRemoteIPv6Address(byte[] value) {
107 - this.remoteIPv6Address = value; 107 + this.remoteIPv6Address = value;
108 - } 108 + }
109 - 109 +
110 - /** 110 + /**
111 - * Reads channel buffer and Returns object of PcepFecObjectIPv6Adjacency. 111 + * Reads channel buffer and Returns object of PcepFecObjectIPv6Adjacency.
112 - * 112 + *
113 - * @param cb of channel buffer 113 + * @param cb of channel buffer
114 - * @return object of PcepFecObjectIPv6Adjacency 114 + * @return object of PcepFecObjectIPv6Adjacency
115 - * @throws PcepParseException when fails tp read from channel buffer 115 + * @throws PcepParseException when fails tp read from channel buffer
116 - */ 116 + */
117 - public static PcepFecObjectIPv6Adjacency read(ChannelBuffer cb) throws PcepParseException { 117 + public static PcepFecObjectIPv6Adjacency read(ChannelBuffer cb) throws PcepParseException {
118 - 118 +
119 - PcepObjectHeader fecObjHeader; 119 + PcepObjectHeader fecObjHeader;
120 - byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; 120 + byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
121 - byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; 121 + byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
122 - fecObjHeader = PcepObjectHeader.read(cb); 122 + fecObjHeader = PcepObjectHeader.read(cb);
123 - cb.readBytes(localIPv6Address, 0, IPV6_ADDRESS_LENGTH); 123 + cb.readBytes(localIPv6Address, 0, IPV6_ADDRESS_LENGTH);
124 - cb.readBytes(remoteIPv6Address, 0, IPV6_ADDRESS_LENGTH); 124 + cb.readBytes(remoteIPv6Address, 0, IPV6_ADDRESS_LENGTH);
125 - return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, localIPv6Address, remoteIPv6Address); 125 + return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, localIPv6Address, remoteIPv6Address);
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public int write(ChannelBuffer cb) throws PcepParseException { 129 + public int write(ChannelBuffer cb) throws PcepParseException {
130 - 130 +
131 - int objStartIndex = cb.writerIndex(); 131 + int objStartIndex = cb.writerIndex();
132 - 132 +
133 - //write common header 133 + //write common header
134 - int objLenIndex = fecObjHeader.write(cb); 134 + int objLenIndex = fecObjHeader.write(cb);
135 - cb.writeBytes(localIPv6Address); 135 + cb.writeBytes(localIPv6Address);
136 - cb.writeBytes(remoteIPv6Address); 136 + cb.writeBytes(remoteIPv6Address);
137 - //now write FEC IPv6 Adjacency Object Length 137 + //now write FEC IPv6 Adjacency Object Length
138 - cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); 138 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
139 - return cb.writerIndex(); 139 + return cb.writerIndex();
140 - } 140 + }
141 - 141 +
142 - /** 142 + /**
143 - * Builder class for PCEP fec object IPv6 Adjacency. 143 + * Builder class for PCEP fec object IPv6 Adjacency.
144 - */ 144 + */
145 - public static class Builder implements PcepFecObjectIPv6Adjacency.Builder { 145 + public static class Builder implements PcepFecObjectIPv6Adjacency.Builder {
146 - private boolean bIsHeaderSet = false; 146 + private boolean bIsHeaderSet = false;
147 - private boolean bIsLocalIPv6Addressset = false; 147 + private boolean bIsLocalIPv6Addressset = false;
148 - private boolean bIsRemoteIPv6Addressset = false; 148 + private boolean bIsRemoteIPv6Addressset = false;
149 - 149 +
150 - private PcepObjectHeader fecObjHeader; 150 + private PcepObjectHeader fecObjHeader;
151 - byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; 151 + byte[] localIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
152 - byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH]; 152 + byte[] remoteIPv6Address = new byte[IPV6_ADDRESS_LENGTH];
153 - 153 +
154 - private boolean bIsPFlagSet = false; 154 + private boolean bIsPFlagSet = false;
155 - private boolean bPFlag; 155 + private boolean bPFlag;
156 - 156 +
157 - private boolean bIsIFlagSet = false; 157 + private boolean bIsIFlagSet = false;
158 - private boolean bIFlag; 158 + private boolean bIFlag;
159 - 159 +
160 - @Override 160 + @Override
161 - public PcepFecObjectIPv6Adjacency build() throws PcepParseException { 161 + public PcepFecObjectIPv6Adjacency build() throws PcepParseException {
162 - PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; 162 + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
163 - 163 +
164 - if (!this.bIsLocalIPv6Addressset) { 164 + if (!this.bIsLocalIPv6Addressset) {
165 - throw new PcepParseException( 165 + throw new PcepParseException(
166 - "Local IPv6 Address not set while building PcepFecObjectIPv6Adjacency object."); 166 + "Local IPv6 Address not set while building PcepFecObjectIPv6Adjacency object.");
167 - } 167 + }
168 - if (!this.bIsRemoteIPv6Addressset) { 168 + if (!this.bIsRemoteIPv6Addressset) {
169 - throw new PcepParseException( 169 + throw new PcepParseException(
170 - "Remote IPv6 Address not set while building PcepFecObjectIPv6Adjacency object."); 170 + "Remote IPv6 Address not set while building PcepFecObjectIPv6Adjacency object.");
171 - } 171 + }
172 - if (bIsPFlagSet) { 172 + if (bIsPFlagSet) {
173 - fecObjHeader.setPFlag(bPFlag); 173 + fecObjHeader.setPFlag(bPFlag);
174 - } 174 + }
175 - if (bIsIFlagSet) { 175 + if (bIsIFlagSet) {
176 - fecObjHeader.setIFlag(bIFlag); 176 + fecObjHeader.setIFlag(bIFlag);
177 - } 177 + }
178 - return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, this.localIPv6Address, this.remoteIPv6Address); 178 + return new PcepFecObjectIPv6AdjacencyVer1(fecObjHeader, this.localIPv6Address, this.remoteIPv6Address);
179 - } 179 + }
180 - 180 +
181 - @Override 181 + @Override
182 - public Builder setPFlag(boolean value) { 182 + public Builder setPFlag(boolean value) {
183 - this.bPFlag = value; 183 + this.bPFlag = value;
184 - this.bIsPFlagSet = true; 184 + this.bIsPFlagSet = true;
185 - return this; 185 + return this;
186 - } 186 + }
187 - 187 +
188 - @Override 188 + @Override
189 - public Builder setIFlag(boolean value) { 189 + public Builder setIFlag(boolean value) {
190 - this.bIFlag = value; 190 + this.bIFlag = value;
191 - this.bIsIFlagSet = true; 191 + this.bIsIFlagSet = true;
192 - return this; 192 + return this;
193 - } 193 + }
194 - 194 +
195 - @Override 195 + @Override
196 - public PcepObjectHeader getFecIpv6AdjacencyObjHeader() { 196 + public PcepObjectHeader getFecIpv6AdjacencyObjHeader() {
197 - return this.fecObjHeader; 197 + return this.fecObjHeader;
198 - } 198 + }
199 - 199 +
200 - @Override 200 + @Override
201 - public Builder setFecIpv6AdjacencyObjHeader(PcepObjectHeader obj) { 201 + public Builder setFecIpv6AdjacencyObjHeader(PcepObjectHeader obj) {
202 - this.fecObjHeader = obj; 202 + this.fecObjHeader = obj;
203 - this.bIsHeaderSet = true; 203 + this.bIsHeaderSet = true;
204 - return this; 204 + return this;
205 - } 205 + }
206 - 206 +
207 - @Override 207 + @Override
208 - public byte[] getLocalIPv6Address() { 208 + public byte[] getLocalIPv6Address() {
209 - return this.localIPv6Address; 209 + return this.localIPv6Address;
210 - } 210 + }
211 - 211 +
212 - @Override 212 + @Override
213 - public Builder setLocalIPv6Address(byte[] value) { 213 + public Builder setLocalIPv6Address(byte[] value) {
214 - this.localIPv6Address = value; 214 + this.localIPv6Address = value;
215 - this.bIsLocalIPv6Addressset = true; 215 + this.bIsLocalIPv6Addressset = true;
216 - return this; 216 + return this;
217 - } 217 + }
218 - 218 +
219 - @Override 219 + @Override
220 - public byte[] getRemoteIPv6Address() { 220 + public byte[] getRemoteIPv6Address() {
221 - return this.remoteIPv6Address; 221 + return this.remoteIPv6Address;
222 - } 222 + }
223 - 223 +
224 - @Override 224 + @Override
225 - public Builder setRemoteIPv6Address(byte[] value) { 225 + public Builder setRemoteIPv6Address(byte[] value) {
226 - this.remoteIPv6Address = value; 226 + this.remoteIPv6Address = value;
227 - this.bIsRemoteIPv6Addressset = true; 227 + this.bIsRemoteIPv6Addressset = true;
228 - return this; 228 + return this;
229 - } 229 + }
230 - } 230 + }
231 - 231 +
232 - @Override 232 + @Override
233 - public PcepVersion getVersion() { 233 + public PcepVersion getVersion() {
234 - return PcepVersion.PCEP_1; 234 + return PcepVersion.PCEP_1;
235 - } 235 + }
236 - 236 +
237 - @Override 237 + @Override
238 - public int getType() { 238 + public int getType() {
239 - return FEC_OBJ_TYPE; 239 + return FEC_OBJ_TYPE;
240 - } 240 + }
241 - 241 +
242 - @Override 242 + @Override
243 - public String toString() { 243 + public String toString() {
244 - return MoreObjects.toStringHelper(getClass()).add("localIPv6Address", localIPv6Address) 244 + return MoreObjects.toStringHelper(getClass()).add("localIPv6Address", localIPv6Address)
245 - .add("remoteIPv6Address: ", remoteIPv6Address).toString(); 245 + .add("remoteIPv6Address: ", remoteIPv6Address).toString();
246 - } 246 + }
247 -} 247 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
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.PcepFecObjectIPv6; 21 +import org.onosproject.pcepio.protocol.PcepFecObjectIPv6;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.onosproject.pcepio.types.PcepObjectHeader; 23 +import org.onosproject.pcepio.types.PcepObjectHeader;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 - 28 +
29 -/** 29 +/**
30 - * Provides Pcep Fec Object IPv6 object. 30 + * Provides Pcep Fec Object IPv6 object.
31 - */ 31 + */
32 -public class PcepFecObjectIPv6Ver1 implements PcepFecObjectIPv6 { 32 +public class PcepFecObjectIPv6Ver1 implements PcepFecObjectIPv6 {
33 - 33 +
34 - /* 34 + /*
35 - * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5 35 + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01 , section : 7.5
36 - * 36 + *
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | | 40 + | |
41 - // IPv6 Node ID (16 bytes) // 41 + // IPv6 Node ID (16 bytes) //
42 - | | 42 + | |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - 44 +
45 - FEC Object-Type is 2 IPv6 Node ID 45 + FEC Object-Type is 2 IPv6 Node ID
46 - */ 46 + */
47 - protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6Ver1.class); 47 + protected static final Logger log = LoggerFactory.getLogger(PcepFecObjectIPv6Ver1.class);
48 - 48 +
49 - public static final byte FEC_OBJ_TYPE = 2; 49 + public static final byte FEC_OBJ_TYPE = 2;
50 - public static final byte FEC_OBJ_CLASS = 63; //to be defined 50 + public static final byte FEC_OBJ_CLASS = 63; //to be defined
51 - public static final byte FEC_OBJECT_VERSION = 1; 51 + public static final byte FEC_OBJECT_VERSION = 1;
52 - public static final short FEC_OBJ_MINIMUM_LENGTH = 20; 52 + public static final short FEC_OBJ_MINIMUM_LENGTH = 20;
53 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 53 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
54 - public static final int IPV6_ADDRESS_LENGTH = 16; 54 + public static final int IPV6_ADDRESS_LENGTH = 16;
55 - 55 +
56 - static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE, 56 + static final PcepObjectHeader DEFAULT_FEC_OBJECT_HEADER = new PcepObjectHeader(FEC_OBJ_CLASS, FEC_OBJ_TYPE,
57 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH); 57 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, FEC_OBJ_MINIMUM_LENGTH);
58 - 58 +
59 - private PcepObjectHeader fecObjHeader; 59 + private PcepObjectHeader fecObjHeader;
60 - private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH]; 60 + private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH];
61 - 61 +
62 - /** 62 + /**
63 - * Constructor to initialize parameters for PCEP fec object. 63 + * Constructor to initialize parameters for PCEP fec object.
64 - * 64 + *
65 - * @param fecObjHeader Fec object header 65 + * @param fecObjHeader Fec object header
66 - * @param nodeID node ID 66 + * @param nodeID node ID
67 - */ 67 + */
68 - public PcepFecObjectIPv6Ver1(PcepObjectHeader fecObjHeader, byte[] nodeID) { 68 + public PcepFecObjectIPv6Ver1(PcepObjectHeader fecObjHeader, byte[] nodeID) {
69 - this.fecObjHeader = fecObjHeader; 69 + this.fecObjHeader = fecObjHeader;
70 - this.nodeID = nodeID; 70 + this.nodeID = nodeID;
71 - } 71 + }
72 - 72 +
73 - /** 73 + /**
74 - * Sets the Object header. 74 + * Sets the Object header.
75 - * 75 + *
76 - * @param obj object header 76 + * @param obj object header
77 - */ 77 + */
78 - public void setFecIpv6ObjHeader(PcepObjectHeader obj) { 78 + public void setFecIpv6ObjHeader(PcepObjectHeader obj) {
79 - this.fecObjHeader = obj; 79 + this.fecObjHeader = obj;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public void setNodeID(byte[] nodeID) { 83 + public void setNodeID(byte[] nodeID) {
84 - this.nodeID = nodeID; 84 + this.nodeID = nodeID;
85 - } 85 + }
86 - 86 +
87 - /** 87 + /**
88 - * Returns object header. 88 + * Returns object header.
89 - * 89 + *
90 - * @return fec Object Header 90 + * @return fec Object Header
91 - */ 91 + */
92 - public PcepObjectHeader getFecIpv6ObjHeader() { 92 + public PcepObjectHeader getFecIpv6ObjHeader() {
93 - return this.fecObjHeader; 93 + return this.fecObjHeader;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public byte[] getNodeID() { 97 + public byte[] getNodeID() {
98 - return this.nodeID; 98 + return this.nodeID;
99 - } 99 + }
100 - 100 +
101 - /** 101 + /**
102 - * reads the channel buffer and returns object of PcepFecObjectIPv6. 102 + * reads the channel buffer and returns object of PcepFecObjectIPv6.
103 - * 103 + *
104 - * @param cb of channel buffer. 104 + * @param cb of channel buffer.
105 - * @return object of PcepFecObjectIPv6 105 + * @return object of PcepFecObjectIPv6
106 - * @throws PcepParseException when fails to read from channel buffer 106 + * @throws PcepParseException when fails to read from channel buffer
107 - */ 107 + */
108 - public static PcepFecObjectIPv6 read(ChannelBuffer cb) throws PcepParseException { 108 + public static PcepFecObjectIPv6 read(ChannelBuffer cb) throws PcepParseException {
109 - 109 +
110 - PcepObjectHeader fecObjHeader; 110 + PcepObjectHeader fecObjHeader;
111 - byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH]; 111 + byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH];
112 - fecObjHeader = PcepObjectHeader.read(cb); 112 + fecObjHeader = PcepObjectHeader.read(cb);
113 - cb.readBytes(nodeID, 0, IPV6_ADDRESS_LENGTH); 113 + cb.readBytes(nodeID, 0, IPV6_ADDRESS_LENGTH);
114 - return new PcepFecObjectIPv6Ver1(fecObjHeader, nodeID); 114 + return new PcepFecObjectIPv6Ver1(fecObjHeader, nodeID);
115 - } 115 + }
116 - 116 +
117 - @Override 117 + @Override
118 - public int write(ChannelBuffer cb) throws PcepParseException { 118 + public int write(ChannelBuffer cb) throws PcepParseException {
119 - 119 +
120 - int objStartIndex = cb.writerIndex(); 120 + int objStartIndex = cb.writerIndex();
121 - 121 +
122 - //write common header 122 + //write common header
123 - int objLenIndex = fecObjHeader.write(cb); 123 + int objLenIndex = fecObjHeader.write(cb);
124 - cb.writeBytes(nodeID); 124 + cb.writeBytes(nodeID);
125 - 125 +
126 - //now write FEC IPv4 Object Length 126 + //now write FEC IPv4 Object Length
127 - cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); 127 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
128 - return cb.writerIndex(); 128 + return cb.writerIndex();
129 - } 129 + }
130 - 130 +
131 - /** 131 + /**
132 - * Builder class for PCEP fec object IPv6. 132 + * Builder class for PCEP fec object IPv6.
133 - */ 133 + */
134 - public static class Builder implements PcepFecObjectIPv6.Builder { 134 + public static class Builder implements PcepFecObjectIPv6.Builder {
135 - private boolean bIsHeaderSet = false; 135 + private boolean bIsHeaderSet = false;
136 - private boolean bIsNodeIdset = false; 136 + private boolean bIsNodeIdset = false;
137 - 137 +
138 - private PcepObjectHeader fecObjHeader; 138 + private PcepObjectHeader fecObjHeader;
139 - private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH]; 139 + private byte[] nodeID = new byte[IPV6_ADDRESS_LENGTH];
140 - 140 +
141 - private boolean bIsPFlagSet = false; 141 + private boolean bIsPFlagSet = false;
142 - private boolean bPFlag; 142 + private boolean bPFlag;
143 - 143 +
144 - private boolean bIsIFlagSet = false; 144 + private boolean bIsIFlagSet = false;
145 - private boolean bIFlag; 145 + private boolean bIFlag;
146 - 146 +
147 - @Override 147 + @Override
148 - public PcepFecObjectIPv6 build() throws PcepParseException { 148 + public PcepFecObjectIPv6 build() throws PcepParseException {
149 - PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER; 149 + PcepObjectHeader fecObjHeader = this.bIsHeaderSet ? this.fecObjHeader : DEFAULT_FEC_OBJECT_HEADER;
150 - 150 +
151 - if (!this.bIsNodeIdset) { 151 + if (!this.bIsNodeIdset) {
152 - throw new PcepParseException(" NodeID not set while building PcepFecObjectIPv6 object."); 152 + throw new PcepParseException(" NodeID not set while building PcepFecObjectIPv6 object.");
153 - } 153 + }
154 - if (bIsPFlagSet) { 154 + if (bIsPFlagSet) {
155 - fecObjHeader.setPFlag(bPFlag); 155 + fecObjHeader.setPFlag(bPFlag);
156 - } 156 + }
157 - if (bIsIFlagSet) { 157 + if (bIsIFlagSet) {
158 - fecObjHeader.setIFlag(bIFlag); 158 + fecObjHeader.setIFlag(bIFlag);
159 - } 159 + }
160 - return new PcepFecObjectIPv6Ver1(fecObjHeader, this.nodeID); 160 + return new PcepFecObjectIPv6Ver1(fecObjHeader, this.nodeID);
161 - } 161 + }
162 - 162 +
163 - @Override 163 + @Override
164 - public Builder setPFlag(boolean value) { 164 + public Builder setPFlag(boolean value) {
165 - this.bPFlag = value; 165 + this.bPFlag = value;
166 - this.bIsPFlagSet = true; 166 + this.bIsPFlagSet = true;
167 - return this; 167 + return this;
168 - } 168 + }
169 - 169 +
170 - @Override 170 + @Override
171 - public Builder setIFlag(boolean value) { 171 + public Builder setIFlag(boolean value) {
172 - this.bIFlag = value; 172 + this.bIFlag = value;
173 - this.bIsIFlagSet = true; 173 + this.bIsIFlagSet = true;
174 - return this; 174 + return this;
175 - } 175 + }
176 - 176 +
177 - @Override 177 + @Override
178 - public PcepObjectHeader getFecIpv6ObjHeader() { 178 + public PcepObjectHeader getFecIpv6ObjHeader() {
179 - return this.fecObjHeader; 179 + return this.fecObjHeader;
180 - } 180 + }
181 - 181 +
182 - @Override 182 + @Override
183 - public Builder setFecIpv6ObjHeader(PcepObjectHeader obj) { 183 + public Builder setFecIpv6ObjHeader(PcepObjectHeader obj) {
184 - this.fecObjHeader = obj; 184 + this.fecObjHeader = obj;
185 - this.bIsHeaderSet = true; 185 + this.bIsHeaderSet = true;
186 - return this; 186 + return this;
187 - } 187 + }
188 - 188 +
189 - @Override 189 + @Override
190 - public byte[] getNodeID() { 190 + public byte[] getNodeID() {
191 - return this.nodeID; 191 + return this.nodeID;
192 - } 192 + }
193 - 193 +
194 - @Override 194 + @Override
195 - public Builder setNodeID(byte[] value) { 195 + public Builder setNodeID(byte[] value) {
196 - this.nodeID = value; 196 + this.nodeID = value;
197 - this.bIsNodeIdset = true; 197 + this.bIsNodeIdset = true;
198 - return this; 198 + return this;
199 - } 199 + }
200 - 200 +
201 - } 201 + }
202 - 202 +
203 - @Override 203 + @Override
204 - public PcepVersion getVersion() { 204 + public PcepVersion getVersion() {
205 - return PcepVersion.PCEP_1; 205 + return PcepVersion.PCEP_1;
206 - } 206 + }
207 - 207 +
208 - @Override 208 + @Override
209 - public int getType() { 209 + public int getType() {
210 - return FEC_OBJ_TYPE; 210 + return FEC_OBJ_TYPE;
211 - } 211 + }
212 - 212 +
213 - @Override 213 + @Override
214 - public String toString() { 214 + public String toString() {
215 - return MoreObjects.toStringHelper(getClass()).add("fecObjHeader", fecObjHeader).add("NodeID: ", nodeID) 215 + return MoreObjects.toStringHelper(getClass()).add("fecObjHeader", fecObjHeader).add("NodeID: ", nodeID)
216 - .toString(); 216 + .toString();
217 - } 217 + }
218 -} 218 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcInitiatedLspRequest; 24 +import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
25 -import org.onosproject.pcepio.protocol.PcepAttribute; 25 +import org.onosproject.pcepio.protocol.PcepAttribute;
26 -import org.onosproject.pcepio.protocol.PcepEndPointsObject; 26 +import org.onosproject.pcepio.protocol.PcepEndPointsObject;
27 -import org.onosproject.pcepio.protocol.PcepEroObject; 27 +import org.onosproject.pcepio.protocol.PcepEroObject;
28 -import org.onosproject.pcepio.protocol.PcepInitiateMsg; 28 +import org.onosproject.pcepio.protocol.PcepInitiateMsg;
29 -import org.onosproject.pcepio.protocol.PcepLspObject; 29 +import org.onosproject.pcepio.protocol.PcepLspObject;
30 -import org.onosproject.pcepio.protocol.PcepMessageReader; 30 +import org.onosproject.pcepio.protocol.PcepMessageReader;
31 -import org.onosproject.pcepio.protocol.PcepMessageWriter; 31 +import org.onosproject.pcepio.protocol.PcepMessageWriter;
32 -import org.onosproject.pcepio.protocol.PcepSrpObject; 32 +import org.onosproject.pcepio.protocol.PcepSrpObject;
33 -import org.onosproject.pcepio.protocol.PcepType; 33 +import org.onosproject.pcepio.protocol.PcepType;
34 -import org.onosproject.pcepio.protocol.PcepVersion; 34 +import org.onosproject.pcepio.protocol.PcepVersion;
35 -import org.slf4j.Logger; 35 +import org.slf4j.Logger;
36 -import org.slf4j.LoggerFactory; 36 +import org.slf4j.LoggerFactory;
37 - 37 +
38 -import com.google.common.base.MoreObjects; 38 +import com.google.common.base.MoreObjects;
39 - 39 +
40 -/** 40 +/**
41 - * Provides PCEP initiate message. 41 + * Provides PCEP initiate message.
42 - */ 42 + */
43 -class PcepInitiateMsgVer1 implements PcepInitiateMsg { 43 +class PcepInitiateMsgVer1 implements PcepInitiateMsg {
44 - 44 +
45 - protected static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgVer1.class); 45 + protected static final Logger log = LoggerFactory.getLogger(PcepInitiateMsgVer1.class);
46 - 46 +
47 - // Ref : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03, section 5.1 47 + // Ref : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03, section 5.1
48 - /* <PCInitiate Message> ::= <Common Header> 48 + /* <PCInitiate Message> ::= <Common Header>
49 - * <PCE-initiated-lsp-list> 49 + * <PCE-initiated-lsp-list>
50 - * Where: 50 + * Where:
51 - * <PCE-initiated-lsp-list> ::= <PCE-initiated-lsp-request>[<PCE-initiated-lsp-list>] 51 + * <PCE-initiated-lsp-list> ::= <PCE-initiated-lsp-request>[<PCE-initiated-lsp-list>]
52 - * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>) 52 + * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
53 - * <PCE-initiated-lsp-instantiation> ::= <SRP> 53 + * <PCE-initiated-lsp-instantiation> ::= <SRP>
54 - * <LSP> 54 + * <LSP>
55 - * <END-POINTS> 55 + * <END-POINTS>
56 - * <ERO> 56 + * <ERO>
57 - * [<attribute-list>] 57 + * [<attribute-list>]
58 - * <PCE-initiated-lsp-deletion> ::= <SRP> 58 + * <PCE-initiated-lsp-deletion> ::= <SRP>
59 - * <LSP> 59 + * <LSP>
60 - */ 60 + */
61 - 61 +
62 - static final byte PACKET_VERSION = 1; 62 + static final byte PACKET_VERSION = 1;
63 - /* considering LspDelete Request PcInitiate msg will contain 63 + /* considering LspDelete Request PcInitiate msg will contain
64 - * common header 64 + * common header
65 - * srp object 65 + * srp object
66 - * lsp object 66 + * lsp object
67 - * so min length for this can be 67 + * so min length for this can be
68 - * PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+SrpObjectMinLen(12)+LspObjectMinLen(8) 68 + * PACKET_MINIMUM_LENGTH = CommonHeaderLen(4)+SrpObjectMinLen(12)+LspObjectMinLen(8)
69 - */ 69 + */
70 - public static final short PACKET_MINIMUM_LENGTH = 24; 70 + public static final short PACKET_MINIMUM_LENGTH = 24;
71 - public static final short MINIMUM_COMMON_HEADER_LENGTH = 4; 71 + public static final short MINIMUM_COMMON_HEADER_LENGTH = 4;
72 - public static final PcepType MSG_TYPE = PcepType.INITIATE; 72 + public static final PcepType MSG_TYPE = PcepType.INITIATE;
73 - private LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList; 73 + private LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
74 - public static final PcepInitiateMsgVer1.Reader READER = new Reader(); 74 + public static final PcepInitiateMsgVer1.Reader READER = new Reader();
75 - 75 +
76 - /** 76 + /**
77 - * Reader class for reading of Pcep initiate message from channel buffer. 77 + * Reader class for reading of Pcep initiate message from channel buffer.
78 - */ 78 + */
79 - static class Reader implements PcepMessageReader<PcepInitiateMsg> { 79 + static class Reader implements PcepMessageReader<PcepInitiateMsg> {
80 - 80 +
81 - LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList; 81 + LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
82 - 82 +
83 - @Override 83 + @Override
84 - public PcepInitiateMsg readFrom(ChannelBuffer cb) throws PcepParseException { 84 + public PcepInitiateMsg readFrom(ChannelBuffer cb) throws PcepParseException {
85 - 85 +
86 - if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) { 86 + if (cb.readableBytes() < PACKET_MINIMUM_LENGTH) {
87 - return null; 87 + return null;
88 - } 88 + }
89 - 89 +
90 - llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>(); 90 + llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>();
91 - 91 +
92 - byte version = cb.readByte(); 92 + byte version = cb.readByte();
93 - version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG); 93 + version = (byte) (version >> PcepMessageVer1.SHIFT_FLAG);
94 - if (version != PACKET_VERSION) { 94 + if (version != PACKET_VERSION) {
95 - throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), received=" + version); 95 + throw new PcepParseException("Wrong version. Expected=PcepVersion.PCEP_1(1), received=" + version);
96 - } 96 + }
97 - byte type = cb.readByte(); 97 + byte type = cb.readByte();
98 - if (type != MSG_TYPE.getType()) { 98 + if (type != MSG_TYPE.getType()) {
99 - throw new PcepParseException("Wrong type. Expected=PcepType.INITIATE(12), recived=" + type); 99 + throw new PcepParseException("Wrong type. Expected=PcepType.INITIATE(12), recived=" + type);
100 - } 100 + }
101 - short length = cb.readShort(); 101 + short length = cb.readShort();
102 - 102 +
103 - if (length < PACKET_MINIMUM_LENGTH) { 103 + if (length < PACKET_MINIMUM_LENGTH) {
104 - throw new PcepParseException("Wrong length. Initiate message length expected to be >= " 104 + throw new PcepParseException("Wrong length. Initiate message length expected to be >= "
105 - + PACKET_MINIMUM_LENGTH + ", but received=" + length); 105 + + PACKET_MINIMUM_LENGTH + ", but received=" + length);
106 - } 106 + }
107 - 107 +
108 - log.debug("reading PcInitiate message of length " + length); 108 + log.debug("reading PcInitiate message of length " + length);
109 - 109 +
110 - // parse Start initiate/deletion list 110 + // parse Start initiate/deletion list
111 - if (!parsePcInitiatedLspRequestList(cb)) { 111 + if (!parsePcInitiatedLspRequestList(cb)) {
112 - throw new PcepParseException("Parsing PCE-initiated-lsp-Request-list failed"); 112 + throw new PcepParseException("Parsing PCE-initiated-lsp-Request-list failed");
113 - } 113 + }
114 - 114 +
115 - return new PcepInitiateMsgVer1(llPcInitiatedLspRequestList); 115 + return new PcepInitiateMsgVer1(llPcInitiatedLspRequestList);
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * To parse PcInitiatedLspRequestList from PcInitiate Message. 119 + * To parse PcInitiatedLspRequestList from PcInitiate Message.
120 - * 120 + *
121 - * @param cb of type channel buffer 121 + * @param cb of type channel buffer
122 - * @return true if parsing PcInitiatedLspRequestList is success, false otherwise 122 + * @return true if parsing PcInitiatedLspRequestList is success, false otherwise
123 - * @throws PcepParseException while parsing from channel buffer 123 + * @throws PcepParseException while parsing from channel buffer
124 - */ 124 + */
125 - public boolean parsePcInitiatedLspRequestList(ChannelBuffer cb) throws PcepParseException { 125 + public boolean parsePcInitiatedLspRequestList(ChannelBuffer cb) throws PcepParseException {
126 - 126 +
127 - boolean isDelLspRequest = false; 127 + boolean isDelLspRequest = false;
128 - 128 +
129 - if (null == cb) { 129 + if (null == cb) {
130 - throw new PcepParseException("Channel buffer is empty"); 130 + throw new PcepParseException("Channel buffer is empty");
131 - } 131 + }
132 - 132 +
133 - while (0 < cb.readableBytes()) { 133 + while (0 < cb.readableBytes()) {
134 - PcInitiatedLspRequest pceInitLspReq = new PcInitiatedLspRequestVer1(); 134 + PcInitiatedLspRequest pceInitLspReq = new PcInitiatedLspRequestVer1();
135 - 135 +
136 - //store SRP object 136 + //store SRP object
137 - PcepSrpObject srpObj; 137 + PcepSrpObject srpObj;
138 - srpObj = PcepSrpObjectVer1.read(cb); 138 + srpObj = PcepSrpObjectVer1.read(cb);
139 - pceInitLspReq.setSrpObject(srpObj); 139 + pceInitLspReq.setSrpObject(srpObj);
140 - isDelLspRequest = srpObj.getRFlag(); 140 + isDelLspRequest = srpObj.getRFlag();
141 - 141 +
142 - //store LSP object 142 + //store LSP object
143 - PcepLspObject lspObj; 143 + PcepLspObject lspObj;
144 - lspObj = PcepLspObjectVer1.read(cb); 144 + lspObj = PcepLspObjectVer1.read(cb);
145 - pceInitLspReq.setLspObject(lspObj); 145 + pceInitLspReq.setLspObject(lspObj);
146 - 146 +
147 - /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects 147 + /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects
148 - * so if R bit is not set then we should read for Ero and EndPoint objects also. 148 + * so if R bit is not set then we should read for Ero and EndPoint objects also.
149 - */ 149 + */
150 - if (!isDelLspRequest) { 150 + if (!isDelLspRequest) {
151 - 151 +
152 - //store EndPoint object 152 + //store EndPoint object
153 - PcepEndPointsObject endPointObj; 153 + PcepEndPointsObject endPointObj;
154 - endPointObj = PcepEndPointsObjectVer1.read(cb); 154 + endPointObj = PcepEndPointsObjectVer1.read(cb);
155 - pceInitLspReq.setEndPointsObject(endPointObj); 155 + pceInitLspReq.setEndPointsObject(endPointObj);
156 - 156 +
157 - //store ERO object 157 + //store ERO object
158 - PcepEroObject eroObj; 158 + PcepEroObject eroObj;
159 - eroObj = PcepEroObjectVer1.read(cb); 159 + eroObj = PcepEroObjectVer1.read(cb);
160 - pceInitLspReq.setEroObject(eroObj); 160 + pceInitLspReq.setEroObject(eroObj);
161 - 161 +
162 - if (cb.readableBytes() > MINIMUM_COMMON_HEADER_LENGTH) { 162 + if (cb.readableBytes() > MINIMUM_COMMON_HEADER_LENGTH) {
163 - pceInitLspReq.setPcepAttribute(PcepAttributeVer1.read(cb)); 163 + pceInitLspReq.setPcepAttribute(PcepAttributeVer1.read(cb));
164 - } 164 + }
165 - } 165 + }
166 - llPcInitiatedLspRequestList.add(pceInitLspReq); 166 + llPcInitiatedLspRequestList.add(pceInitLspReq);
167 - } 167 + }
168 - return true; 168 + return true;
169 - } 169 + }
170 - } 170 + }
171 - 171 +
172 - /** 172 + /**
173 - * Constructor to initialize PcInitiatedLspRequest. 173 + * Constructor to initialize PcInitiatedLspRequest.
174 - * 174 + *
175 - * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequest 175 + * @param llPcInitiatedLspRequestList list of PcInitiatedLspRequest
176 - */ 176 + */
177 - PcepInitiateMsgVer1(LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList) { 177 + PcepInitiateMsgVer1(LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList) {
178 - 178 +
179 - if (llPcInitiatedLspRequestList == null) { 179 + if (llPcInitiatedLspRequestList == null) {
180 - throw new NullPointerException("PcInitiatedLspRequestList cannot be null."); 180 + throw new NullPointerException("PcInitiatedLspRequestList cannot be null.");
181 - } 181 + }
182 - this.llPcInitiatedLspRequestList = llPcInitiatedLspRequestList; 182 + this.llPcInitiatedLspRequestList = llPcInitiatedLspRequestList;
183 - } 183 + }
184 - 184 +
185 - /** 185 + /**
186 - * Builder class for PCEP initiate message. 186 + * Builder class for PCEP initiate message.
187 - */ 187 + */
188 - static class Builder implements PcepInitiateMsg.Builder { 188 + static class Builder implements PcepInitiateMsg.Builder {
189 - 189 +
190 - // Pcep initiate message fields 190 + // Pcep initiate message fields
191 - LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList; 191 + LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList;
192 - 192 +
193 - @Override 193 + @Override
194 - public PcepVersion getVersion() { 194 + public PcepVersion getVersion() {
195 - return PcepVersion.PCEP_1; 195 + return PcepVersion.PCEP_1;
196 - } 196 + }
197 - 197 +
198 - @Override 198 + @Override
199 - public PcepType getType() { 199 + public PcepType getType() {
200 - return PcepType.INITIATE; 200 + return PcepType.INITIATE;
201 - } 201 + }
202 - 202 +
203 - @Override 203 + @Override
204 - public PcepInitiateMsg build() { 204 + public PcepInitiateMsg build() {
205 - return new PcepInitiateMsgVer1(this.llPcInitiatedLspRequestList); 205 + return new PcepInitiateMsgVer1(this.llPcInitiatedLspRequestList);
206 - } 206 + }
207 - 207 +
208 - @Override 208 + @Override
209 - public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() { 209 + public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
210 - return this.llPcInitiatedLspRequestList; 210 + return this.llPcInitiatedLspRequestList;
211 - } 211 + }
212 - 212 +
213 - @Override 213 + @Override
214 - public Builder setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) { 214 + public Builder setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) {
215 - this.llPcInitiatedLspRequestList = ll; 215 + this.llPcInitiatedLspRequestList = ll;
216 - return this; 216 + return this;
217 - } 217 + }
218 - } 218 + }
219 - 219 +
220 - @Override 220 + @Override
221 - public void writeTo(ChannelBuffer cb) throws PcepParseException { 221 + public void writeTo(ChannelBuffer cb) throws PcepParseException {
222 - WRITER.write(cb, this); 222 + WRITER.write(cb, this);
223 - } 223 + }
224 - 224 +
225 - static final Writer WRITER = new Writer(); 225 + static final Writer WRITER = new Writer();
226 - 226 +
227 - /** 227 + /**
228 - * Writer class for writing pcep initiate message to channel buffer. 228 + * Writer class for writing pcep initiate message to channel buffer.
229 - */ 229 + */
230 - static class Writer implements PcepMessageWriter<PcepInitiateMsgVer1> { 230 + static class Writer implements PcepMessageWriter<PcepInitiateMsgVer1> {
231 - 231 +
232 - @Override 232 + @Override
233 - public void write(ChannelBuffer cb, PcepInitiateMsgVer1 message) throws PcepParseException { 233 + public void write(ChannelBuffer cb, PcepInitiateMsgVer1 message) throws PcepParseException {
234 - 234 +
235 - boolean isDelLspRequest = false; 235 + boolean isDelLspRequest = false;
236 - int startIndex = cb.writerIndex(); 236 + int startIndex = cb.writerIndex();
237 - // first 3 bits set to version 237 + // first 3 bits set to version
238 - cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG)); 238 + cb.writeByte((byte) (PACKET_VERSION << PcepMessageVer1.SHIFT_FLAG));
239 - // message type 0xC 239 + // message type 0xC
240 - cb.writeByte(MSG_TYPE.getType()); 240 + cb.writeByte(MSG_TYPE.getType());
241 - // length is length of variable message, will be updated at the end 241 + // length is length of variable message, will be updated at the end
242 - // Store the position of message 242 + // Store the position of message
243 - // length in buffer 243 + // length in buffer
244 - int msgLenIndex = cb.writerIndex(); 244 + int msgLenIndex = cb.writerIndex();
245 - cb.writeShort(0); 245 + cb.writeShort(0);
246 - 246 +
247 - ListIterator<PcInitiatedLspRequest> listIterator = message.llPcInitiatedLspRequestList.listIterator(); 247 + ListIterator<PcInitiatedLspRequest> listIterator = message.llPcInitiatedLspRequestList.listIterator();
248 - 248 +
249 - while (listIterator.hasNext()) { 249 + while (listIterator.hasNext()) {
250 - 250 +
251 - PcInitiatedLspRequest listReq = listIterator.next(); 251 + PcInitiatedLspRequest listReq = listIterator.next();
252 - 252 +
253 - //Srp Object is mandatory 253 + //Srp Object is mandatory
254 - PcepSrpObject srpObj = listReq.getSrpObject(); 254 + PcepSrpObject srpObj = listReq.getSrpObject();
255 - if (srpObj instanceof PcepSrpObject) { 255 + if (srpObj instanceof PcepSrpObject) {
256 - isDelLspRequest = srpObj.getRFlag(); 256 + isDelLspRequest = srpObj.getRFlag();
257 - srpObj.write(cb); 257 + srpObj.write(cb);
258 - } else { 258 + } else {
259 - throw new PcepParseException("SRP Object is mandatory for PcInitiate message."); 259 + throw new PcepParseException("SRP Object is mandatory for PcInitiate message.");
260 - } 260 + }
261 - 261 +
262 - //LSP Object is mandatory 262 + //LSP Object is mandatory
263 - PcepLspObject lspObj = listReq.getLspObject(); 263 + PcepLspObject lspObj = listReq.getLspObject();
264 - if (lspObj instanceof PcepLspObject) { 264 + if (lspObj instanceof PcepLspObject) {
265 - lspObj.write(cb); 265 + lspObj.write(cb);
266 - } else { 266 + } else {
267 - throw new PcepParseException("LSP Object is mandatory for PcInitiate message."); 267 + throw new PcepParseException("LSP Object is mandatory for PcInitiate message.");
268 - } 268 + }
269 - 269 +
270 - /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects 270 + /* if R bit will be set then pcInitiate msg will contain only LSp and SRP objects
271 - * so if R bit is not set then we should read for Ero and EndPoint objects also. 271 + * so if R bit is not set then we should read for Ero and EndPoint objects also.
272 - */ 272 + */
273 - 273 +
274 - if (!isDelLspRequest) { 274 + if (!isDelLspRequest) {
275 - 275 +
276 - //EndPoints object is mandatory 276 + //EndPoints object is mandatory
277 - PcepEndPointsObject endPointObj = listReq.getEndPointsObject(); 277 + PcepEndPointsObject endPointObj = listReq.getEndPointsObject();
278 - if (endPointObj instanceof PcepEndPointsObject) { 278 + if (endPointObj instanceof PcepEndPointsObject) {
279 - endPointObj.write(cb); 279 + endPointObj.write(cb);
280 - } else { 280 + } else {
281 - throw new PcepParseException("End points Object is mandatory for PcInitiate message."); 281 + throw new PcepParseException("End points Object is mandatory for PcInitiate message.");
282 - } 282 + }
283 - 283 +
284 - //Ero object is mandatory 284 + //Ero object is mandatory
285 - PcepEroObject eroObj = listReq.getEroObject(); 285 + PcepEroObject eroObj = listReq.getEroObject();
286 - if (eroObj instanceof PcepEroObject) { 286 + if (eroObj instanceof PcepEroObject) {
287 - eroObj.write(cb); 287 + eroObj.write(cb);
288 - } else { 288 + } else {
289 - throw new PcepParseException("ERO Object is mandatory for PcInitiate message."); 289 + throw new PcepParseException("ERO Object is mandatory for PcInitiate message.");
290 - } 290 + }
291 - 291 +
292 - //PcepAttribute is optional 292 + //PcepAttribute is optional
293 - PcepAttribute pcepAttribute = listReq.getPcepAttribute(); 293 + PcepAttribute pcepAttribute = listReq.getPcepAttribute();
294 - if (pcepAttribute instanceof PcepAttribute) { 294 + if (pcepAttribute instanceof PcepAttribute) {
295 - pcepAttribute.write(cb); 295 + pcepAttribute.write(cb);
296 - } 296 + }
297 - } 297 + }
298 - } 298 + }
299 - 299 +
300 - // PCInitiate message length field 300 + // PCInitiate message length field
301 - int length = cb.writerIndex() - startIndex; 301 + int length = cb.writerIndex() - startIndex;
302 - cb.setShort(msgLenIndex, (short) length); 302 + cb.setShort(msgLenIndex, (short) length);
303 - } 303 + }
304 - } 304 + }
305 - 305 +
306 - @Override 306 + @Override
307 - public PcepVersion getVersion() { 307 + public PcepVersion getVersion() {
308 - return PcepVersion.PCEP_1; 308 + return PcepVersion.PCEP_1;
309 - } 309 + }
310 - 310 +
311 - @Override 311 + @Override
312 - public PcepType getType() { 312 + public PcepType getType() {
313 - return MSG_TYPE; 313 + return MSG_TYPE;
314 - } 314 + }
315 - 315 +
316 - @Override 316 + @Override
317 - public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() { 317 + public LinkedList<PcInitiatedLspRequest> getPcInitiatedLspRequestList() {
318 - return this.llPcInitiatedLspRequestList; 318 + return this.llPcInitiatedLspRequestList;
319 - } 319 + }
320 - 320 +
321 - @Override 321 + @Override
322 - public void setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) { 322 + public void setPcInitiatedLspRequestList(LinkedList<PcInitiatedLspRequest> ll) {
323 - this.llPcInitiatedLspRequestList = ll; 323 + this.llPcInitiatedLspRequestList = ll;
324 - } 324 + }
325 - 325 +
326 - @Override 326 + @Override
327 - public String toString() { 327 + public String toString() {
328 - return MoreObjects.toStringHelper(getClass()).add("PcInitiaitedLspRequestList", llPcInitiatedLspRequestList) 328 + return MoreObjects.toStringHelper(getClass()).add("PcInitiaitedLspRequestList", llPcInitiatedLspRequestList)
329 - .toString(); 329 + .toString();
330 - } 330 + }
331 -} 331 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.protocol.ver1; 16 +package org.onosproject.pcepio.protocol.ver1;
17 - 17 +
18 -import org.jboss.netty.buffer.ChannelBuffer; 18 +import org.jboss.netty.buffer.ChannelBuffer;
19 -import org.onosproject.pcepio.exceptions.PcepParseException; 19 +import org.onosproject.pcepio.exceptions.PcepParseException;
20 -import org.onosproject.pcepio.protocol.PcepInterLayerObject; 20 +import org.onosproject.pcepio.protocol.PcepInterLayerObject;
21 -import org.onosproject.pcepio.types.PcepObjectHeader; 21 +import org.onosproject.pcepio.types.PcepObjectHeader;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides PCEP inter layer object. 28 + * Provides PCEP inter layer object.
29 - */ 29 + */
30 -public class PcepInterLayerObjectVer1 implements PcepInterLayerObject { 30 +public class PcepInterLayerObjectVer1 implements PcepInterLayerObject {
31 - 31 +
32 - /* 32 + /*
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Reserved |N|I| 36 + | Reserved |N|I|
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - */ 38 + */
39 - protected static final Logger log = LoggerFactory.getLogger(PcepInterLayerObjectVer1.class); 39 + protected static final Logger log = LoggerFactory.getLogger(PcepInterLayerObjectVer1.class);
40 - 40 +
41 - public static final byte INTER_LAYER_OBJ_TYPE = 1; 41 + public static final byte INTER_LAYER_OBJ_TYPE = 1;
42 - public static final byte INTER_LAYER_OBJ_CLASS = 18; 42 + public static final byte INTER_LAYER_OBJ_CLASS = 18;
43 - public static final byte INTER_LAYER_OBJECT_VERSION = 1; 43 + public static final byte INTER_LAYER_OBJECT_VERSION = 1;
44 - public static final short INTER_LAYER_OBJ_MINIMUM_LENGTH = 8; 44 + public static final short INTER_LAYER_OBJ_MINIMUM_LENGTH = 8;
45 - public static final boolean DEFAULT_IFLAG = false; 45 + public static final boolean DEFAULT_IFLAG = false;
46 - public static final boolean DEFAULT_NFLAG = false; 46 + public static final boolean DEFAULT_NFLAG = false;
47 - public static final int OBJECT_HEADER_LENGTH = 4; 47 + public static final int OBJECT_HEADER_LENGTH = 4;
48 - public static final int NFLAG_SHIFT_VALUE = 0x02; 48 + public static final int NFLAG_SHIFT_VALUE = 0x02;
49 - public static final int IFLAG_SHIFT_VALUE = 0x01; 49 + public static final int IFLAG_SHIFT_VALUE = 0x01;
50 - public static final int FLAGS_SET_VALUE = 1; 50 + public static final int FLAGS_SET_VALUE = 1;
51 - 51 +
52 - static final PcepObjectHeader DEFAULT_INTER_LAYER_OBJECT_HEADER = new PcepObjectHeader(INTER_LAYER_OBJ_CLASS, 52 + static final PcepObjectHeader DEFAULT_INTER_LAYER_OBJECT_HEADER = new PcepObjectHeader(INTER_LAYER_OBJ_CLASS,
53 - INTER_LAYER_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, 53 + INTER_LAYER_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
54 - INTER_LAYER_OBJ_MINIMUM_LENGTH); 54 + INTER_LAYER_OBJ_MINIMUM_LENGTH);
55 - 55 +
56 - private PcepObjectHeader interLayerObjHeader; 56 + private PcepObjectHeader interLayerObjHeader;
57 - private boolean bNFlag; 57 + private boolean bNFlag;
58 - private boolean bIFlag; 58 + private boolean bIFlag;
59 - 59 +
60 - /** 60 + /**
61 - * Constructor to initialize all parameters for Pcep Inter Layer Object. 61 + * Constructor to initialize all parameters for Pcep Inter Layer Object.
62 - * 62 + *
63 - * @param interLayerObjHeader inter layer object header 63 + * @param interLayerObjHeader inter layer object header
64 - * @param bNFlag N flag 64 + * @param bNFlag N flag
65 - * @param bIFlag I flag 65 + * @param bIFlag I flag
66 - */ 66 + */
67 - public PcepInterLayerObjectVer1(PcepObjectHeader interLayerObjHeader, boolean bNFlag, boolean bIFlag) { 67 + public PcepInterLayerObjectVer1(PcepObjectHeader interLayerObjHeader, boolean bNFlag, boolean bIFlag) {
68 - 68 +
69 - this.interLayerObjHeader = interLayerObjHeader; 69 + this.interLayerObjHeader = interLayerObjHeader;
70 - this.bNFlag = bNFlag; 70 + this.bNFlag = bNFlag;
71 - this.bIFlag = bIFlag; 71 + this.bIFlag = bIFlag;
72 - } 72 + }
73 - 73 +
74 - /** 74 + /**
75 - * Sets Object Header. 75 + * Sets Object Header.
76 - * 76 + *
77 - * @param obj object header 77 + * @param obj object header
78 - */ 78 + */
79 - public void setInterLayerObjHeader(PcepObjectHeader obj) { 79 + public void setInterLayerObjHeader(PcepObjectHeader obj) {
80 - this.interLayerObjHeader = obj; 80 + this.interLayerObjHeader = obj;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public void setbNFlag(boolean bNFlag) { 84 + public void setbNFlag(boolean bNFlag) {
85 - this.bNFlag = bNFlag; 85 + this.bNFlag = bNFlag;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public void setbIFlag(boolean bIFlag) { 89 + public void setbIFlag(boolean bIFlag) {
90 - this.bIFlag = bIFlag; 90 + this.bIFlag = bIFlag;
91 - } 91 + }
92 - 92 +
93 - /** 93 + /**
94 - * Returns object header. 94 + * Returns object header.
95 - * 95 + *
96 - * @return inter Layer Object Header 96 + * @return inter Layer Object Header
97 - */ 97 + */
98 - public PcepObjectHeader getInterLayerObjHeader() { 98 + public PcepObjectHeader getInterLayerObjHeader() {
99 - return this.interLayerObjHeader; 99 + return this.interLayerObjHeader;
100 - } 100 + }
101 - 101 +
102 - @Override 102 + @Override
103 - public boolean getbNFlag() { 103 + public boolean getbNFlag() {
104 - return this.bNFlag; 104 + return this.bNFlag;
105 - } 105 + }
106 - 106 +
107 - @Override 107 + @Override
108 - public boolean getbIFlag() { 108 + public boolean getbIFlag() {
109 - return this.bIFlag; 109 + return this.bIFlag;
110 - } 110 + }
111 - 111 +
112 - /** 112 + /**
113 - * Reads channel buffer and returns object of PcepInterLayerObject. 113 + * Reads channel buffer and returns object of PcepInterLayerObject.
114 - * 114 + *
115 - * @param cb of type channel buffer 115 + * @param cb of type channel buffer
116 - * @return object of PcepInterLayerObject 116 + * @return object of PcepInterLayerObject
117 - * @throws PcepParseException when fails to read from channel buffer 117 + * @throws PcepParseException when fails to read from channel buffer
118 - */ 118 + */
119 - public static PcepInterLayerObject read(ChannelBuffer cb) throws PcepParseException { 119 + public static PcepInterLayerObject read(ChannelBuffer cb) throws PcepParseException {
120 - 120 +
121 - PcepObjectHeader interLayerObjHeader; 121 + PcepObjectHeader interLayerObjHeader;
122 - boolean bNFlag; 122 + boolean bNFlag;
123 - boolean bIFlag; 123 + boolean bIFlag;
124 - 124 +
125 - interLayerObjHeader = PcepObjectHeader.read(cb); 125 + interLayerObjHeader = PcepObjectHeader.read(cb);
126 - 126 +
127 - //take only InterLayerObject buffer. 127 + //take only InterLayerObject buffer.
128 - ChannelBuffer tempCb = cb.readBytes(interLayerObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); 128 + ChannelBuffer tempCb = cb.readBytes(interLayerObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
129 - 129 +
130 - int iTemp = tempCb.readInt(); 130 + int iTemp = tempCb.readInt();
131 - bIFlag = ((iTemp & (byte) IFLAG_SHIFT_VALUE) == FLAGS_SET_VALUE) ? true : false; 131 + bIFlag = ((iTemp & (byte) IFLAG_SHIFT_VALUE) == FLAGS_SET_VALUE) ? true : false;
132 - bNFlag = ((iTemp & (byte) NFLAG_SHIFT_VALUE) == FLAGS_SET_VALUE) ? true : false; 132 + bNFlag = ((iTemp & (byte) NFLAG_SHIFT_VALUE) == FLAGS_SET_VALUE) ? true : false;
133 - 133 +
134 - return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag); 134 + return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag);
135 - } 135 + }
136 - 136 +
137 - @Override 137 + @Override
138 - public int write(ChannelBuffer cb) throws PcepParseException { 138 + public int write(ChannelBuffer cb) throws PcepParseException {
139 - 139 +
140 - //write Object header 140 + //write Object header
141 - int objStartIndex = cb.writerIndex(); 141 + int objStartIndex = cb.writerIndex();
142 - 142 +
143 - int objLenIndex = interLayerObjHeader.write(cb); 143 + int objLenIndex = interLayerObjHeader.write(cb);
144 - 144 +
145 - if (objLenIndex <= 0) { 145 + if (objLenIndex <= 0) {
146 - throw new PcepParseException(" ObjectLength Index is " + objLenIndex); 146 + throw new PcepParseException(" ObjectLength Index is " + objLenIndex);
147 - } 147 + }
148 - 148 +
149 - int iTemp = 0; 149 + int iTemp = 0;
150 - 150 +
151 - if (bIFlag) { 151 + if (bIFlag) {
152 - iTemp = iTemp | (byte) IFLAG_SHIFT_VALUE; 152 + iTemp = iTemp | (byte) IFLAG_SHIFT_VALUE;
153 - } 153 + }
154 - if (bNFlag) { 154 + if (bNFlag) {
155 - iTemp = iTemp | (byte) NFLAG_SHIFT_VALUE; 155 + iTemp = iTemp | (byte) NFLAG_SHIFT_VALUE;
156 - } 156 + }
157 - 157 +
158 - cb.writeInt(iTemp); 158 + cb.writeInt(iTemp);
159 - 159 +
160 - //Update object length now 160 + //Update object length now
161 - int length = cb.writerIndex() - objStartIndex; 161 + int length = cb.writerIndex() - objStartIndex;
162 - //will be helpful during print(). 162 + //will be helpful during print().
163 - interLayerObjHeader.setObjLen((short) length); 163 + interLayerObjHeader.setObjLen((short) length);
164 - cb.setShort(objLenIndex, (short) length); 164 + cb.setShort(objLenIndex, (short) length);
165 - 165 +
166 - objLenIndex = cb.writerIndex(); 166 + objLenIndex = cb.writerIndex();
167 - return objLenIndex; 167 + return objLenIndex;
168 - } 168 + }
169 - 169 +
170 - /** 170 + /**
171 - * Builder class for PCEP inter layer object. 171 + * Builder class for PCEP inter layer object.
172 - */ 172 + */
173 - public static class Builder implements PcepInterLayerObject.Builder { 173 + public static class Builder implements PcepInterLayerObject.Builder {
174 - 174 +
175 - private boolean bIsHeaderSet = false; 175 + private boolean bIsHeaderSet = false;
176 - private boolean bIsNFlagset = false; 176 + private boolean bIsNFlagset = false;
177 - private boolean bIsIFlagset = false; 177 + private boolean bIsIFlagset = false;
178 - 178 +
179 - private PcepObjectHeader interLayerObjHeader; 179 + private PcepObjectHeader interLayerObjHeader;
180 - private boolean bNFlag; 180 + private boolean bNFlag;
181 - private boolean bIFlag; 181 + private boolean bIFlag;
182 - 182 +
183 - private boolean bIsPFlagSet = false; 183 + private boolean bIsPFlagSet = false;
184 - private boolean bPFalg; 184 + private boolean bPFalg;
185 - 185 +
186 - private boolean bIsIFlagSet = false; 186 + private boolean bIsIFlagSet = false;
187 - private boolean iFlag; 187 + private boolean iFlag;
188 - 188 +
189 - @Override 189 + @Override
190 - public PcepInterLayerObject build() { 190 + public PcepInterLayerObject build() {
191 - PcepObjectHeader interLayerObjHeader = this.bIsHeaderSet ? this.interLayerObjHeader 191 + PcepObjectHeader interLayerObjHeader = this.bIsHeaderSet ? this.interLayerObjHeader
192 - : DEFAULT_INTER_LAYER_OBJECT_HEADER; 192 + : DEFAULT_INTER_LAYER_OBJECT_HEADER;
193 - 193 +
194 - boolean bNFlag = this.bIsNFlagset ? this.bNFlag : DEFAULT_NFLAG; 194 + boolean bNFlag = this.bIsNFlagset ? this.bNFlag : DEFAULT_NFLAG;
195 - boolean bIFlag = this.bIsIFlagset ? this.bIFlag : DEFAULT_IFLAG; 195 + boolean bIFlag = this.bIsIFlagset ? this.bIFlag : DEFAULT_IFLAG;
196 - 196 +
197 - if (bIsPFlagSet) { 197 + if (bIsPFlagSet) {
198 - interLayerObjHeader.setPFlag(bPFalg); 198 + interLayerObjHeader.setPFlag(bPFalg);
199 - } 199 + }
200 - 200 +
201 - if (bIsIFlagSet) { 201 + if (bIsIFlagSet) {
202 - interLayerObjHeader.setIFlag(iFlag); 202 + interLayerObjHeader.setIFlag(iFlag);
203 - } 203 + }
204 - return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag); 204 + return new PcepInterLayerObjectVer1(interLayerObjHeader, bNFlag, bIFlag);
205 - } 205 + }
206 - 206 +
207 - @Override 207 + @Override
208 - public PcepObjectHeader getInterLayerObjHeader() { 208 + public PcepObjectHeader getInterLayerObjHeader() {
209 - return this.interLayerObjHeader; 209 + return this.interLayerObjHeader;
210 - } 210 + }
211 - 211 +
212 - @Override 212 + @Override
213 - public Builder setInterLayerObjHeader(PcepObjectHeader obj) { 213 + public Builder setInterLayerObjHeader(PcepObjectHeader obj) {
214 - this.interLayerObjHeader = obj; 214 + this.interLayerObjHeader = obj;
215 - this.bIsHeaderSet = true; 215 + this.bIsHeaderSet = true;
216 - return this; 216 + return this;
217 - } 217 + }
218 - 218 +
219 - @Override 219 + @Override
220 - public boolean getbNFlag() { 220 + public boolean getbNFlag() {
221 - return this.bNFlag; 221 + return this.bNFlag;
222 - } 222 + }
223 - 223 +
224 - @Override 224 + @Override
225 - public Builder setbNFlag(boolean value) { 225 + public Builder setbNFlag(boolean value) {
226 - this.bNFlag = value; 226 + this.bNFlag = value;
227 - this.bIsNFlagset = true; 227 + this.bIsNFlagset = true;
228 - return this; 228 + return this;
229 - } 229 + }
230 - 230 +
231 - @Override 231 + @Override
232 - public boolean getbIFlag() { 232 + public boolean getbIFlag() {
233 - return this.bIFlag; 233 + return this.bIFlag;
234 - } 234 + }
235 - 235 +
236 - @Override 236 + @Override
237 - public Builder setbIFlag(boolean value) { 237 + public Builder setbIFlag(boolean value) {
238 - this.bIFlag = value; 238 + this.bIFlag = value;
239 - this.bIsIFlagset = true; 239 + this.bIsIFlagset = true;
240 - return this; 240 + return this;
241 - } 241 + }
242 - 242 +
243 - @Override 243 + @Override
244 - public Builder setPFlag(boolean value) { 244 + public Builder setPFlag(boolean value) {
245 - this.bPFalg = value; 245 + this.bPFalg = value;
246 - this.bIsPFlagSet = true; 246 + this.bIsPFlagSet = true;
247 - return this; 247 + return this;
248 - } 248 + }
249 - 249 +
250 - @Override 250 + @Override
251 - public Builder setIFlag(boolean value) { 251 + public Builder setIFlag(boolean value) {
252 - this.iFlag = value; 252 + this.iFlag = value;
253 - this.bIsIFlagSet = true; 253 + this.bIsIFlagSet = true;
254 - return this; 254 + return this;
255 - } 255 + }
256 - } 256 + }
257 - 257 +
258 - @Override 258 + @Override
259 - public String toString() { 259 + public String toString() {
260 - return MoreObjects.toStringHelper(getClass()).add("IFlag", bIFlag).add("NFlag", bNFlag).toString(); 260 + return MoreObjects.toStringHelper(getClass()).add("IFlag", bIFlag).add("NFlag", bNFlag).toString();
261 - } 261 + }
262 -} 262 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepLabelRangeObject; 24 +import org.onosproject.pcepio.protocol.PcepLabelRangeObject;
25 -import org.onosproject.pcepio.types.PathSetupTypeTlv; 25 +import org.onosproject.pcepio.types.PathSetupTypeTlv;
26 -import org.onosproject.pcepio.types.PcepObjectHeader; 26 +import org.onosproject.pcepio.types.PcepObjectHeader;
27 -import org.onosproject.pcepio.types.PcepValueType; 27 +import org.onosproject.pcepio.types.PcepValueType;
28 -import org.slf4j.Logger; 28 +import org.slf4j.Logger;
29 -import org.slf4j.LoggerFactory; 29 +import org.slf4j.LoggerFactory;
30 - 30 +
31 -import com.google.common.base.MoreObjects; 31 +import com.google.common.base.MoreObjects;
32 - 32 +
33 -/** 33 +/**
34 - * Provides PCEP label range object. 34 + * Provides PCEP label range object.
35 - */ 35 + */
36 -public class PcepLabelRangeObjectVer1 implements PcepLabelRangeObject { 36 +public class PcepLabelRangeObjectVer1 implements PcepLabelRangeObject {
37 - 37 +
38 - /* 38 + /*
39 - * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01, section : 7.2 39 + * ref : draft-zhao-pce-pcep-extension-for-pce-controller-01, section : 7.2
40 - 0 1 2 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | label type | range size | 43 + | label type | range size |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | label base | 45 + | label base |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - | | 47 + | |
48 - // Optional TLVs // 48 + // Optional TLVs //
49 - | | 49 + | |
50 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 - 51 +
52 - LABEL-RANGE Object 52 + LABEL-RANGE Object
53 - */ 53 + */
54 - protected static final Logger log = LoggerFactory.getLogger(PcepLabelRangeObjectVer1.class); 54 + protected static final Logger log = LoggerFactory.getLogger(PcepLabelRangeObjectVer1.class);
55 - 55 +
56 - public static final byte LABEL_RANGE_OBJ_TYPE = 1; 56 + public static final byte LABEL_RANGE_OBJ_TYPE = 1;
57 - public static final byte LABEL_RANGE_OBJ_CLASS = 60; //to be defined 57 + public static final byte LABEL_RANGE_OBJ_CLASS = 60; //to be defined
58 - public static final byte LABEL_RANGE_OBJECT_VERSION = 1; 58 + public static final byte LABEL_RANGE_OBJECT_VERSION = 1;
59 - public static final short LABEL_RANGE_OBJ_MINIMUM_LENGTH = 12; 59 + public static final short LABEL_RANGE_OBJ_MINIMUM_LENGTH = 12;
60 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 60 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
61 - //P flag and I flag must be set to 0 61 + //P flag and I flag must be set to 0
62 - static final PcepObjectHeader DEFAULT_LABELRANGE_OBJECT_HEADER = new PcepObjectHeader(LABEL_RANGE_OBJ_CLASS, 62 + static final PcepObjectHeader DEFAULT_LABELRANGE_OBJECT_HEADER = new PcepObjectHeader(LABEL_RANGE_OBJ_CLASS,
63 - LABEL_RANGE_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, 63 + LABEL_RANGE_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED,
64 - LABEL_RANGE_OBJ_MINIMUM_LENGTH); 64 + LABEL_RANGE_OBJ_MINIMUM_LENGTH);
65 - 65 +
66 - private PcepObjectHeader labelRangeObjHeader; 66 + private PcepObjectHeader labelRangeObjHeader;
67 - private byte labelType; 67 + private byte labelType;
68 - private int rangeSize; 68 + private int rangeSize;
69 - private int labelBase; 69 + private int labelBase;
70 - //Optional TLV 70 + //Optional TLV
71 - private LinkedList<PcepValueType> llOptionalTlv; 71 + private LinkedList<PcepValueType> llOptionalTlv;
72 - 72 +
73 - /** 73 + /**
74 - * Constructor to initialize parameters for PCEP label range object. 74 + * Constructor to initialize parameters for PCEP label range object.
75 - * 75 + *
76 - * @param labelRangeObjHeader label range object header 76 + * @param labelRangeObjHeader label range object header
77 - * @param labelType label type 77 + * @param labelType label type
78 - * @param rangeSize range size 78 + * @param rangeSize range size
79 - * @param labelBase label base 79 + * @param labelBase label base
80 - * @param llOptionalTlv list of optional tlvs 80 + * @param llOptionalTlv list of optional tlvs
81 - */ 81 + */
82 - public PcepLabelRangeObjectVer1(PcepObjectHeader labelRangeObjHeader, byte labelType, int rangeSize, int labelBase, 82 + public PcepLabelRangeObjectVer1(PcepObjectHeader labelRangeObjHeader, byte labelType, int rangeSize, int labelBase,
83 - LinkedList<PcepValueType> llOptionalTlv) { 83 + LinkedList<PcepValueType> llOptionalTlv) {
84 - this.labelRangeObjHeader = labelRangeObjHeader; 84 + this.labelRangeObjHeader = labelRangeObjHeader;
85 - this.labelType = labelType; 85 + this.labelType = labelType;
86 - this.rangeSize = rangeSize; 86 + this.rangeSize = rangeSize;
87 - this.llOptionalTlv = llOptionalTlv; 87 + this.llOptionalTlv = llOptionalTlv;
88 - this.labelBase = labelBase; 88 + this.labelBase = labelBase;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public void setLabelRangeObjHeader(PcepObjectHeader obj) { 92 + public void setLabelRangeObjHeader(PcepObjectHeader obj) {
93 - this.labelRangeObjHeader = obj; 93 + this.labelRangeObjHeader = obj;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public void setLabelType(byte labelType) { 97 + public void setLabelType(byte labelType) {
98 - this.labelType = labelType; 98 + this.labelType = labelType;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public void setRangeSize(int rangeSize) { 102 + public void setRangeSize(int rangeSize) {
103 - this.rangeSize = rangeSize; 103 + this.rangeSize = rangeSize;
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public void setLabelBase(int labelBase) { 107 + public void setLabelBase(int labelBase) {
108 - this.labelBase = labelBase; 108 + this.labelBase = labelBase;
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public PcepObjectHeader getLabelRangeObjHeader() { 112 + public PcepObjectHeader getLabelRangeObjHeader() {
113 - return this.labelRangeObjHeader; 113 + return this.labelRangeObjHeader;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public byte getLabelType() { 117 + public byte getLabelType() {
118 - return this.labelType; 118 + return this.labelType;
119 - } 119 + }
120 - 120 +
121 - @Override 121 + @Override
122 - public int getRangeSize() { 122 + public int getRangeSize() {
123 - return this.rangeSize; 123 + return this.rangeSize;
124 - } 124 + }
125 - 125 +
126 - @Override 126 + @Override
127 - public int getLabelBase() { 127 + public int getLabelBase() {
128 - return this.labelBase; 128 + return this.labelBase;
129 - } 129 + }
130 - 130 +
131 - /** 131 + /**
132 - * Reads from the channel buffer and returns object of PcepLabelRangeObject. 132 + * Reads from the channel buffer and returns object of PcepLabelRangeObject.
133 - * 133 + *
134 - * @param cb of type channel buffer 134 + * @param cb of type channel buffer
135 - * @return object of PcepLabelRangeObject 135 + * @return object of PcepLabelRangeObject
136 - * @throws PcepParseException when fails to read from channel buffer 136 + * @throws PcepParseException when fails to read from channel buffer
137 - */ 137 + */
138 - public static PcepLabelRangeObject read(ChannelBuffer cb) throws PcepParseException { 138 + public static PcepLabelRangeObject read(ChannelBuffer cb) throws PcepParseException {
139 - 139 +
140 - PcepObjectHeader labelRangeObjHeader; 140 + PcepObjectHeader labelRangeObjHeader;
141 - byte labelType; 141 + byte labelType;
142 - int rangeSize; 142 + int rangeSize;
143 - int labelBase; 143 + int labelBase;
144 - 144 +
145 - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 145 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
146 - 146 +
147 - labelRangeObjHeader = PcepObjectHeader.read(cb); 147 + labelRangeObjHeader = PcepObjectHeader.read(cb);
148 - 148 +
149 - //take only LabelRangeObject buffer. 149 + //take only LabelRangeObject buffer.
150 - ChannelBuffer tempCb = cb.readBytes(labelRangeObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH); 150 + ChannelBuffer tempCb = cb.readBytes(labelRangeObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
151 - int temp = 0; 151 + int temp = 0;
152 - temp = tempCb.readInt(); 152 + temp = tempCb.readInt();
153 - rangeSize = temp & 0x00FFFFFF; 153 + rangeSize = temp & 0x00FFFFFF;
154 - labelType = (byte) (temp >> 24); 154 + labelType = (byte) (temp >> 24);
155 - labelBase = tempCb.readInt(); 155 + labelBase = tempCb.readInt();
156 - llOptionalTlv = parseOptionalTlv(tempCb); 156 + llOptionalTlv = parseOptionalTlv(tempCb);
157 - return new PcepLabelRangeObjectVer1(labelRangeObjHeader, labelType, rangeSize, labelBase, llOptionalTlv); 157 + return new PcepLabelRangeObjectVer1(labelRangeObjHeader, labelType, rangeSize, labelBase, llOptionalTlv);
158 - } 158 + }
159 - 159 +
160 - @Override 160 + @Override
161 - public int write(ChannelBuffer cb) throws PcepParseException { 161 + public int write(ChannelBuffer cb) throws PcepParseException {
162 - 162 +
163 - int objStartIndex = cb.writerIndex(); 163 + int objStartIndex = cb.writerIndex();
164 - 164 +
165 - //write common header 165 + //write common header
166 - int objLenIndex = labelRangeObjHeader.write(cb); 166 + int objLenIndex = labelRangeObjHeader.write(cb);
167 - int temp = 0; 167 + int temp = 0;
168 - temp = labelType; 168 + temp = labelType;
169 - temp = temp << 24; 169 + temp = temp << 24;
170 - temp = temp | rangeSize; 170 + temp = temp | rangeSize;
171 - cb.writeInt(temp); 171 + cb.writeInt(temp);
172 - 172 +
173 - // Add optional TLV 173 + // Add optional TLV
174 - if (!packOptionalTlv(cb)) { 174 + if (!packOptionalTlv(cb)) {
175 - throw new PcepParseException("Error while writing Optional tlv."); 175 + throw new PcepParseException("Error while writing Optional tlv.");
176 - } 176 + }
177 - 177 +
178 - //now write LabelRange Object Length 178 + //now write LabelRange Object Length
179 - cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); 179 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
180 - return cb.writerIndex() - objStartIndex; 180 + return cb.writerIndex() - objStartIndex;
181 - } 181 + }
182 - 182 +
183 - /** 183 + /**
184 - * Returns list of optional tlvs. 184 + * Returns list of optional tlvs.
185 - * 185 + *
186 - * @param cb of type channle buffer 186 + * @param cb of type channle buffer
187 - * @return list of optional tlvs 187 + * @return list of optional tlvs
188 - * @throws PcepParseException whne fails to parse list of optional tlvs 188 + * @throws PcepParseException whne fails to parse list of optional tlvs
189 - */ 189 + */
190 - public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { 190 + public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
191 - 191 +
192 - LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>(); 192 + LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
193 - 193 +
194 - while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) { 194 + while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
195 - 195 +
196 - PcepValueType tlv; 196 + PcepValueType tlv;
197 - int iValue; 197 + int iValue;
198 - short hType = cb.readShort(); 198 + short hType = cb.readShort();
199 - short hLength = cb.readShort(); 199 + short hLength = cb.readShort();
200 - 200 +
201 - switch (hType) { 201 + switch (hType) {
202 - 202 +
203 - case PathSetupTypeTlv.TYPE: 203 + case PathSetupTypeTlv.TYPE:
204 - iValue = cb.readInt(); 204 + iValue = cb.readInt();
205 - tlv = new PathSetupTypeTlv(iValue); 205 + tlv = new PathSetupTypeTlv(iValue);
206 - break; 206 + break;
207 - 207 +
208 - default: 208 + default:
209 - throw new PcepParseException("Unsupported TLV in LabelRange Object."); 209 + throw new PcepParseException("Unsupported TLV in LabelRange Object.");
210 - } 210 + }
211 - 211 +
212 - // Check for the padding 212 + // Check for the padding
213 - int pad = hLength % 4; 213 + int pad = hLength % 4;
214 - if (0 < pad) { 214 + if (0 < pad) {
215 - pad = 4 - pad; 215 + pad = 4 - pad;
216 - if (pad <= cb.readableBytes()) { 216 + if (pad <= cb.readableBytes()) {
217 - cb.skipBytes(pad); 217 + cb.skipBytes(pad);
218 - } 218 + }
219 - } 219 + }
220 - llOutOptionalTlv.add(tlv); 220 + llOutOptionalTlv.add(tlv);
221 - } 221 + }
222 - return llOutOptionalTlv; 222 + return llOutOptionalTlv;
223 - } 223 + }
224 - 224 +
225 - /** 225 + /**
226 - * Pack optional tlvs. 226 + * Pack optional tlvs.
227 - * 227 + *
228 - * @param cb of channel buffer 228 + * @param cb of channel buffer
229 - * @return true 229 + * @return true
230 - */ 230 + */
231 - protected boolean packOptionalTlv(ChannelBuffer cb) { 231 + protected boolean packOptionalTlv(ChannelBuffer cb) {
232 - 232 +
233 - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); 233 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
234 - 234 +
235 - while (listIterator.hasNext()) { 235 + while (listIterator.hasNext()) {
236 - PcepValueType tlv = listIterator.next(); 236 + PcepValueType tlv = listIterator.next();
237 - 237 +
238 - if (null == tlv) { 238 + if (null == tlv) {
239 - log.debug("tlv is null from OptionalTlv list"); 239 + log.debug("tlv is null from OptionalTlv list");
240 - continue; 240 + continue;
241 - } 241 + }
242 - tlv.write(cb); 242 + tlv.write(cb);
243 - 243 +
244 - // need to take care of padding 244 + // need to take care of padding
245 - int pad = tlv.getLength() % 4; 245 + int pad = tlv.getLength() % 4;
246 - if (0 != pad) { 246 + if (0 != pad) {
247 - pad = 4 - pad; 247 + pad = 4 - pad;
248 - for (int i = 0; i < pad; ++i) { 248 + for (int i = 0; i < pad; ++i) {
249 - cb.writeByte((byte) 0); 249 + cb.writeByte((byte) 0);
250 - } 250 + }
251 - } 251 + }
252 - } 252 + }
253 - return true; 253 + return true;
254 - } 254 + }
255 - 255 +
256 - /** 256 + /**
257 - * Builder class for PCEP label range object. 257 + * Builder class for PCEP label range object.
258 - */ 258 + */
259 - public static class Builder implements PcepLabelRangeObject.Builder { 259 + public static class Builder implements PcepLabelRangeObject.Builder {
260 - private boolean bIsHeaderSet = false; 260 + private boolean bIsHeaderSet = false;
261 - private boolean bIsLabelType = false; 261 + private boolean bIsLabelType = false;
262 - private boolean bIsRangeSize = false; 262 + private boolean bIsRangeSize = false;
263 - private boolean bIsLabelBase = false; 263 + private boolean bIsLabelBase = false;
264 - 264 +
265 - byte labelType; 265 + byte labelType;
266 - int rangeSize; 266 + int rangeSize;
267 - int labelBase; 267 + int labelBase;
268 - private boolean bIsPFlagSet = false; 268 + private boolean bIsPFlagSet = false;
269 - private boolean bPFlag; 269 + private boolean bPFlag;
270 - 270 +
271 - private boolean bIsIFlagSet = false; 271 + private boolean bIsIFlagSet = false;
272 - private boolean bIFlag; 272 + private boolean bIFlag;
273 - private PcepObjectHeader labelRangeObjHeader; 273 + private PcepObjectHeader labelRangeObjHeader;
274 - 274 +
275 - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 275 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
276 - 276 +
277 - @Override 277 + @Override
278 - public PcepLabelRangeObject build() throws PcepParseException { 278 + public PcepLabelRangeObject build() throws PcepParseException {
279 - PcepObjectHeader labelRangeObjHeader = this.bIsHeaderSet ? this.labelRangeObjHeader 279 + PcepObjectHeader labelRangeObjHeader = this.bIsHeaderSet ? this.labelRangeObjHeader
280 - : DEFAULT_LABELRANGE_OBJECT_HEADER; 280 + : DEFAULT_LABELRANGE_OBJECT_HEADER;
281 - 281 +
282 - if (!this.bIsLabelType) { 282 + if (!this.bIsLabelType) {
283 - throw new PcepParseException("LabelType NOT Set while building label range object."); 283 + throw new PcepParseException("LabelType NOT Set while building label range object.");
284 - } 284 + }
285 - 285 +
286 - if (!this.bIsRangeSize) { 286 + if (!this.bIsRangeSize) {
287 - throw new PcepParseException("RangeSize NOT Set while building label range object."); 287 + throw new PcepParseException("RangeSize NOT Set while building label range object.");
288 - } 288 + }
289 - 289 +
290 - if (!this.bIsLabelBase) { 290 + if (!this.bIsLabelBase) {
291 - throw new PcepParseException("LabelBase NOT Set while building label range object."); 291 + throw new PcepParseException("LabelBase NOT Set while building label range object.");
292 - } 292 + }
293 - 293 +
294 - if (bIsPFlagSet) { 294 + if (bIsPFlagSet) {
295 - labelRangeObjHeader.setPFlag(bPFlag); 295 + labelRangeObjHeader.setPFlag(bPFlag);
296 - } 296 + }
297 - 297 +
298 - if (bIsIFlagSet) { 298 + if (bIsIFlagSet) {
299 - labelRangeObjHeader.setIFlag(bIFlag); 299 + labelRangeObjHeader.setIFlag(bIFlag);
300 - } 300 + }
301 - return new PcepLabelRangeObjectVer1(labelRangeObjHeader, this.labelType, this.rangeSize, this.labelBase, 301 + return new PcepLabelRangeObjectVer1(labelRangeObjHeader, this.labelType, this.rangeSize, this.labelBase,
302 - this.llOptionalTlv); 302 + this.llOptionalTlv);
303 - } 303 + }
304 - 304 +
305 - @Override 305 + @Override
306 - public PcepObjectHeader getLabelRangeObjHeader() { 306 + public PcepObjectHeader getLabelRangeObjHeader() {
307 - return this.labelRangeObjHeader; 307 + return this.labelRangeObjHeader;
308 - } 308 + }
309 - 309 +
310 - @Override 310 + @Override
311 - public Builder setLabelRangeObjHeader(PcepObjectHeader obj) { 311 + public Builder setLabelRangeObjHeader(PcepObjectHeader obj) {
312 - this.labelRangeObjHeader = obj; 312 + this.labelRangeObjHeader = obj;
313 - this.bIsHeaderSet = true; 313 + this.bIsHeaderSet = true;
314 - return this; 314 + return this;
315 - } 315 + }
316 - 316 +
317 - @Override 317 + @Override
318 - public byte getLabelType() { 318 + public byte getLabelType() {
319 - return this.labelType; 319 + return this.labelType;
320 - } 320 + }
321 - 321 +
322 - @Override 322 + @Override
323 - public Builder setLabelType(byte labelType) { 323 + public Builder setLabelType(byte labelType) {
324 - this.labelType = labelType; 324 + this.labelType = labelType;
325 - this.bIsLabelType = true; 325 + this.bIsLabelType = true;
326 - return this; 326 + return this;
327 - } 327 + }
328 - 328 +
329 - @Override 329 + @Override
330 - public int getRangeSize() { 330 + public int getRangeSize() {
331 - return this.rangeSize; 331 + return this.rangeSize;
332 - } 332 + }
333 - 333 +
334 - @Override 334 + @Override
335 - public Builder setRangeSize(int rangeSize) { 335 + public Builder setRangeSize(int rangeSize) {
336 - this.rangeSize = rangeSize; 336 + this.rangeSize = rangeSize;
337 - this.bIsRangeSize = true; 337 + this.bIsRangeSize = true;
338 - return this; 338 + return this;
339 - } 339 + }
340 - 340 +
341 - @Override 341 + @Override
342 - public int getLabelBase() { 342 + public int getLabelBase() {
343 - return this.labelBase; 343 + return this.labelBase;
344 - } 344 + }
345 - 345 +
346 - @Override 346 + @Override
347 - public Builder setLabelBase(int labelBase) { 347 + public Builder setLabelBase(int labelBase) {
348 - this.labelBase = labelBase; 348 + this.labelBase = labelBase;
349 - this.bIsLabelBase = true; 349 + this.bIsLabelBase = true;
350 - return this; 350 + return this;
351 - } 351 + }
352 - 352 +
353 - @Override 353 + @Override
354 - public Builder setPFlag(boolean value) { 354 + public Builder setPFlag(boolean value) {
355 - this.bPFlag = value; 355 + this.bPFlag = value;
356 - this.bIsPFlagSet = true; 356 + this.bIsPFlagSet = true;
357 - return this; 357 + return this;
358 - } 358 + }
359 - 359 +
360 - @Override 360 + @Override
361 - public Builder setIFlag(boolean value) { 361 + public Builder setIFlag(boolean value) {
362 - this.bIFlag = value; 362 + this.bIFlag = value;
363 - this.bIsIFlagSet = true; 363 + this.bIsIFlagSet = true;
364 - return this; 364 + return this;
365 - } 365 + }
366 - } 366 + }
367 - 367 +
368 - @Override 368 + @Override
369 - public String toString() { 369 + public String toString() {
370 - return MoreObjects.toStringHelper(getClass()).add("LabelType", labelType).add("rangeSize", rangeSize) 370 + return MoreObjects.toStringHelper(getClass()).add("LabelType", labelType).add("rangeSize", rangeSize)
371 - .add("labelBase", labelBase).add("optionalTlvList", llOptionalTlv).toString(); 371 + .add("labelBase", labelBase).add("optionalTlvList", llOptionalTlv).toString();
372 - } 372 + }
373 -} 373 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepLabelRange; 24 +import org.onosproject.pcepio.protocol.PcepLabelRange;
25 -import org.onosproject.pcepio.protocol.PcepLabelRangeObject; 25 +import org.onosproject.pcepio.protocol.PcepLabelRangeObject;
26 -import org.onosproject.pcepio.protocol.PcepSrpObject; 26 +import org.onosproject.pcepio.protocol.PcepSrpObject;
27 -import org.slf4j.Logger; 27 +import org.slf4j.Logger;
28 -import org.slf4j.LoggerFactory; 28 +import org.slf4j.LoggerFactory;
29 - 29 +
30 -import com.google.common.base.MoreObjects; 30 +import com.google.common.base.MoreObjects;
31 - 31 +
32 -/** 32 +/**
33 - * Provides PCEP Label Range. 33 + * Provides PCEP Label Range.
34 - */ 34 + */
35 -public class PcepLabelRangeVer1 implements PcepLabelRange { 35 +public class PcepLabelRangeVer1 implements PcepLabelRange {
36 - 36 +
37 - protected static final Logger log = LoggerFactory.getLogger(PcepLabelRangeVer1.class); 37 + protected static final Logger log = LoggerFactory.getLogger(PcepLabelRangeVer1.class);
38 - 38 +
39 - /* 39 + /*
40 - <label-range> ::= <SRP> 40 + <label-range> ::= <SRP>
41 - <labelrange-list> 41 + <labelrange-list>
42 - Where 42 + Where
43 - <labelrange-list>::=<LABEL-RANGE>[<labelrange-list>] 43 + <labelrange-list>::=<LABEL-RANGE>[<labelrange-list>]
44 - */ 44 + */
45 - 45 +
46 - // PCEP SRP Object 46 + // PCEP SRP Object
47 - private PcepSrpObject srpObject; 47 + private PcepSrpObject srpObject;
48 - //<labelrange-list> of type PcepLabelRangeObject. 48 + //<labelrange-list> of type PcepLabelRangeObject.
49 - private LinkedList<PcepLabelRangeObject> llLabelRangeList; 49 + private LinkedList<PcepLabelRangeObject> llLabelRangeList;
50 - 50 +
51 - /** 51 + /**
52 - * Default Constructor. 52 + * Default Constructor.
53 - */ 53 + */
54 - public PcepLabelRangeVer1() { 54 + public PcepLabelRangeVer1() {
55 - srpObject = null; 55 + srpObject = null;
56 - llLabelRangeList = null; 56 + llLabelRangeList = null;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Constructor to initialize objects. 60 + * Constructor to initialize objects.
61 - * 61 + *
62 - * @param srpObj PCEP Srp object. 62 + * @param srpObj PCEP Srp object.
63 - * @param llLabelRangeList list of PcepLabelRangeObject. 63 + * @param llLabelRangeList list of PcepLabelRangeObject.
64 - */ 64 + */
65 - PcepLabelRangeVer1(PcepSrpObject srpObj, LinkedList<PcepLabelRangeObject> llLabelRangeList) { 65 + PcepLabelRangeVer1(PcepSrpObject srpObj, LinkedList<PcepLabelRangeObject> llLabelRangeList) {
66 - this.srpObject = srpObj; 66 + this.srpObject = srpObj;
67 - this.llLabelRangeList = llLabelRangeList; 67 + this.llLabelRangeList = llLabelRangeList;
68 - } 68 + }
69 - 69 +
70 - @Override 70 + @Override
71 - public PcepSrpObject getSrpObject() { 71 + public PcepSrpObject getSrpObject() {
72 - return srpObject; 72 + return srpObject;
73 - } 73 + }
74 - 74 +
75 - @Override 75 + @Override
76 - public void setSrpObject(PcepSrpObject srpObject) { 76 + public void setSrpObject(PcepSrpObject srpObject) {
77 - this.srpObject = srpObject; 77 + this.srpObject = srpObject;
78 - 78 +
79 - } 79 + }
80 - 80 +
81 - @Override 81 + @Override
82 - public LinkedList<PcepLabelRangeObject> getLabelRangeList() { 82 + public LinkedList<PcepLabelRangeObject> getLabelRangeList() {
83 - return llLabelRangeList; 83 + return llLabelRangeList;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public void setLabelRangeList(LinkedList<PcepLabelRangeObject> ll) { 87 + public void setLabelRangeList(LinkedList<PcepLabelRangeObject> ll) {
88 - this.llLabelRangeList = ll; 88 + this.llLabelRangeList = ll;
89 - } 89 + }
90 - 90 +
91 - /** 91 + /**
92 - * Reads channel buffer and returns object of PcepLabelRange. 92 + * Reads channel buffer and returns object of PcepLabelRange.
93 - * 93 + *
94 - * @param cb of type channel buffer. 94 + * @param cb of type channel buffer.
95 - * @return object of PcepLabelRange 95 + * @return object of PcepLabelRange
96 - * @throws PcepParseException when fails to read from channel buffer 96 + * @throws PcepParseException when fails to read from channel buffer
97 - */ 97 + */
98 - public static PcepLabelRange read(ChannelBuffer cb) throws PcepParseException { 98 + public static PcepLabelRange read(ChannelBuffer cb) throws PcepParseException {
99 - 99 +
100 - //parse and store SRP mandatory object 100 + //parse and store SRP mandatory object
101 - PcepSrpObject srpObj = null; 101 + PcepSrpObject srpObj = null;
102 - srpObj = PcepSrpObjectVer1.read(cb); 102 + srpObj = PcepSrpObjectVer1.read(cb);
103 - if (srpObj == null) { 103 + if (srpObj == null) {
104 - throw new PcepParseException("Exception while parsing srp object"); 104 + throw new PcepParseException("Exception while parsing srp object");
105 - } 105 + }
106 - 106 +
107 - LinkedList<PcepLabelRangeObject> llLabelRangeList = new LinkedList<PcepLabelRangeObject>(); 107 + LinkedList<PcepLabelRangeObject> llLabelRangeList = new LinkedList<PcepLabelRangeObject>();
108 - boolean bFoundLabelRangeObj = false; 108 + boolean bFoundLabelRangeObj = false;
109 - while (0 < cb.readableBytes()) { 109 + while (0 < cb.readableBytes()) {
110 - //parse and store <labelrange-list> 110 + //parse and store <labelrange-list>
111 - PcepLabelRangeObject lrObj; 111 + PcepLabelRangeObject lrObj;
112 - lrObj = PcepLabelRangeObjectVer1.read(cb); 112 + lrObj = PcepLabelRangeObjectVer1.read(cb);
113 - if (lrObj == null) { 113 + if (lrObj == null) {
114 - throw new PcepParseException("Exception while parsing label range object"); 114 + throw new PcepParseException("Exception while parsing label range object");
115 - } else { 115 + } else {
116 - llLabelRangeList.add(lrObj); 116 + llLabelRangeList.add(lrObj);
117 - bFoundLabelRangeObj = true; 117 + bFoundLabelRangeObj = true;
118 - } 118 + }
119 - } 119 + }
120 - 120 +
121 - if (!bFoundLabelRangeObj) { 121 + if (!bFoundLabelRangeObj) {
122 - throw new PcepParseException("At least one LABEL-RANGE MUST be present."); 122 + throw new PcepParseException("At least one LABEL-RANGE MUST be present.");
123 - } 123 + }
124 - return new PcepLabelRangeVer1(srpObj, llLabelRangeList); 124 + return new PcepLabelRangeVer1(srpObj, llLabelRangeList);
125 - } 125 + }
126 - 126 +
127 - @Override 127 + @Override
128 - public int write(ChannelBuffer cb) throws PcepParseException { 128 + public int write(ChannelBuffer cb) throws PcepParseException {
129 - //write Object header 129 + //write Object header
130 - int objStartIndex = cb.writerIndex(); 130 + int objStartIndex = cb.writerIndex();
131 - 131 +
132 - //write <SRP> 132 + //write <SRP>
133 - int objLenIndex = srpObject.write(cb); 133 + int objLenIndex = srpObject.write(cb);
134 - 134 +
135 - if (objLenIndex <= 0) { 135 + if (objLenIndex <= 0) {
136 - throw new PcepParseException("bjectLength is " + objLenIndex); 136 + throw new PcepParseException("bjectLength is " + objLenIndex);
137 - } 137 + }
138 - 138 +
139 - //write <labelrange-list> 139 + //write <labelrange-list>
140 - ListIterator<PcepLabelRangeObject> listIterator = llLabelRangeList.listIterator(); 140 + ListIterator<PcepLabelRangeObject> listIterator = llLabelRangeList.listIterator();
141 - while (listIterator.hasNext()) { 141 + while (listIterator.hasNext()) {
142 - listIterator.next().write(cb); 142 + listIterator.next().write(cb);
143 - } 143 + }
144 - 144 +
145 - //Update object length now 145 + //Update object length now
146 - int length = cb.writerIndex() - objStartIndex; 146 + int length = cb.writerIndex() - objStartIndex;
147 - // As per RFC the length of object should be 147 + // As per RFC the length of object should be
148 - // multiples of 4 148 + // multiples of 4
149 - int pad = length % 4; 149 + int pad = length % 4;
150 - if (pad != 0) { 150 + if (pad != 0) {
151 - pad = 4 - pad; 151 + pad = 4 - pad;
152 - for (int i = 0; i < pad; i++) { 152 + for (int i = 0; i < pad; i++) {
153 - cb.writeByte((byte) 0); 153 + cb.writeByte((byte) 0);
154 - } 154 + }
155 - length = length + pad; 155 + length = length + pad;
156 - } 156 + }
157 - cb.setShort(objLenIndex, (short) length); 157 + cb.setShort(objLenIndex, (short) length);
158 - return length; 158 + return length;
159 - } 159 + }
160 - 160 +
161 - @Override 161 + @Override
162 - public String toString() { 162 + public String toString() {
163 - return MoreObjects.toStringHelper(getClass()).add("srpObject", srpObject) 163 + return MoreObjects.toStringHelper(getClass()).add("srpObject", srpObject)
164 - .add("LabelRangeList", llLabelRangeList).toString(); 164 + .add("LabelRangeList", llLabelRangeList).toString();
165 - } 165 + }
166 -} 166 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepFecObject; 24 +import org.onosproject.pcepio.protocol.PcepFecObject;
25 -import org.onosproject.pcepio.protocol.PcepLabelObject; 25 +import org.onosproject.pcepio.protocol.PcepLabelObject;
26 -import org.onosproject.pcepio.protocol.PcepLabelUpdate; 26 +import org.onosproject.pcepio.protocol.PcepLabelUpdate;
27 -import org.onosproject.pcepio.protocol.PcepLspObject; 27 +import org.onosproject.pcepio.protocol.PcepLspObject;
28 -import org.onosproject.pcepio.protocol.PcepSrpObject; 28 +import org.onosproject.pcepio.protocol.PcepSrpObject;
29 -import org.onosproject.pcepio.types.PcepLabelDownload; 29 +import org.onosproject.pcepio.types.PcepLabelDownload;
30 -import org.onosproject.pcepio.types.PcepLabelMap; 30 +import org.onosproject.pcepio.types.PcepLabelMap;
31 -import org.onosproject.pcepio.types.PcepObjectHeader; 31 +import org.onosproject.pcepio.types.PcepObjectHeader;
32 -import org.slf4j.Logger; 32 +import org.slf4j.Logger;
33 -import org.slf4j.LoggerFactory; 33 +import org.slf4j.LoggerFactory;
34 - 34 +
35 -import com.google.common.base.MoreObjects; 35 +import com.google.common.base.MoreObjects;
36 -import com.google.common.base.MoreObjects.ToStringHelper; 36 +import com.google.common.base.MoreObjects.ToStringHelper;
37 - 37 +
38 -/** 38 +/**
39 - * Provides PCEP LABEL update . 39 + * Provides PCEP LABEL update .
40 - * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01. 40 + * Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01.
41 - */ 41 + */
42 -public class PcepLabelUpdateVer1 implements PcepLabelUpdate { 42 +public class PcepLabelUpdateVer1 implements PcepLabelUpdate {
43 - 43 +
44 - /* 44 + /*
45 - * <pce-label-update> ::= (<pce-label-download>|<pce-label-map>) 45 + * <pce-label-update> ::= (<pce-label-download>|<pce-label-map>)
46 - 46 +
47 - Where: 47 + Where:
48 - <pce-label-download> ::= <SRP> 48 + <pce-label-download> ::= <SRP>
49 - <LSP> 49 + <LSP>
50 - <label-list> 50 + <label-list>
51 - 51 +
52 - <pce-label-map> ::= <SRP> 52 + <pce-label-map> ::= <SRP>
53 - <LABEL> 53 + <LABEL>
54 - <FEC> 54 + <FEC>
55 - 55 +
56 - <label-list > ::= <LABEL> 56 + <label-list > ::= <LABEL>
57 - [<label-list>] 57 + [<label-list>]
58 - */ 58 + */
59 - protected static final Logger log = LoggerFactory.getLogger(PcepLabelUpdateVer1.class); 59 + protected static final Logger log = LoggerFactory.getLogger(PcepLabelUpdateVer1.class);
60 - 60 +
61 - //Either PceLabelDownload or PceLabelMap is mandatory. 61 + //Either PceLabelDownload or PceLabelMap is mandatory.
62 - //label Download 62 + //label Download
63 - private PcepLabelDownload labelDownload; 63 + private PcepLabelDownload labelDownload;
64 - private boolean isLabelDownloadSet; 64 + private boolean isLabelDownloadSet;
65 - //label Map 65 + //label Map
66 - private PcepLabelMap labelMap; 66 + private PcepLabelMap labelMap;
67 - private boolean isLabelMapSet; 67 + private boolean isLabelMapSet;
68 - 68 +
69 - /** 69 + /**
70 - * Constructor to reset parameters. 70 + * Constructor to reset parameters.
71 - */ 71 + */
72 - public PcepLabelUpdateVer1() { 72 + public PcepLabelUpdateVer1() {
73 - this.labelDownload = null; 73 + this.labelDownload = null;
74 - this.isLabelDownloadSet = false; 74 + this.isLabelDownloadSet = false;
75 - this.labelMap = null; 75 + this.labelMap = null;
76 - this.isLabelMapSet = false; 76 + this.isLabelMapSet = false;
77 - } 77 + }
78 - 78 +
79 - /** 79 + /**
80 - * Constructor to initialize PCEP label download. 80 + * Constructor to initialize PCEP label download.
81 - * 81 + *
82 - * @param labelDownload PCEP label download 82 + * @param labelDownload PCEP label download
83 - */ 83 + */
84 - public PcepLabelUpdateVer1(PcepLabelDownload labelDownload) { 84 + public PcepLabelUpdateVer1(PcepLabelDownload labelDownload) {
85 - this.labelDownload = labelDownload; 85 + this.labelDownload = labelDownload;
86 - this.isLabelDownloadSet = true; 86 + this.isLabelDownloadSet = true;
87 - this.labelMap = null; 87 + this.labelMap = null;
88 - this.isLabelMapSet = false; 88 + this.isLabelMapSet = false;
89 - } 89 + }
90 - 90 +
91 - /** 91 + /**
92 - * Constructor to initialize PCEP label map. 92 + * Constructor to initialize PCEP label map.
93 - * 93 + *
94 - * @param labelMap PCEP label map 94 + * @param labelMap PCEP label map
95 - */ 95 + */
96 - public PcepLabelUpdateVer1(PcepLabelMap labelMap) { 96 + public PcepLabelUpdateVer1(PcepLabelMap labelMap) {
97 - this.labelDownload = null; 97 + this.labelDownload = null;
98 - this.isLabelDownloadSet = false; 98 + this.isLabelDownloadSet = false;
99 - this.labelMap = labelMap; 99 + this.labelMap = labelMap;
100 - this.isLabelMapSet = true; 100 + this.isLabelMapSet = true;
101 - } 101 + }
102 - 102 +
103 - /** 103 + /**
104 - * builder class for PCEP label update. 104 + * builder class for PCEP label update.
105 - */ 105 + */
106 - static class Builder implements PcepLabelUpdate.Builder { 106 + static class Builder implements PcepLabelUpdate.Builder {
107 - 107 +
108 - private PcepLabelDownload labelDownload; 108 + private PcepLabelDownload labelDownload;
109 - private boolean isLabelDownloadSet; 109 + private boolean isLabelDownloadSet;
110 - private PcepLabelMap labelMap; 110 + private PcepLabelMap labelMap;
111 - private boolean isLabelMapSet; 111 + private boolean isLabelMapSet;
112 - 112 +
113 - @Override 113 + @Override
114 - public PcepLabelUpdate build() throws PcepParseException { 114 + public PcepLabelUpdate build() throws PcepParseException {
115 - 115 +
116 - if (isLabelDownloadSet) { 116 + if (isLabelDownloadSet) {
117 - return new PcepLabelUpdateVer1(labelDownload); 117 + return new PcepLabelUpdateVer1(labelDownload);
118 - } 118 + }
119 - if (isLabelMapSet) { 119 + if (isLabelMapSet) {
120 - return new PcepLabelUpdateVer1(labelMap); 120 + return new PcepLabelUpdateVer1(labelMap);
121 - } 121 + }
122 - if (!isLabelDownloadSet && !isLabelMapSet) { 122 + if (!isLabelDownloadSet && !isLabelMapSet) {
123 - throw new PcepParseException( 123 + throw new PcepParseException(
124 - "Label Download or Label Map is not set while building PcepLabelUpdate Message"); 124 + "Label Download or Label Map is not set while building PcepLabelUpdate Message");
125 - } 125 + }
126 - return new PcepLabelUpdateVer1(); 126 + return new PcepLabelUpdateVer1();
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public Builder setLabelDownload(PcepLabelDownload labelDownload) { 130 + public Builder setLabelDownload(PcepLabelDownload labelDownload) {
131 - this.labelDownload = labelDownload; 131 + this.labelDownload = labelDownload;
132 - this.isLabelDownloadSet = true; 132 + this.isLabelDownloadSet = true;
133 - return this; 133 + return this;
134 - } 134 + }
135 - 135 +
136 - @Override 136 + @Override
137 - public PcepLabelDownload getLabelDownload() { 137 + public PcepLabelDownload getLabelDownload() {
138 - return labelDownload; 138 + return labelDownload;
139 - } 139 + }
140 - 140 +
141 - @Override 141 + @Override
142 - public Builder setLabelMap(PcepLabelMap labelMap) { 142 + public Builder setLabelMap(PcepLabelMap labelMap) {
143 - this.labelMap = labelMap; 143 + this.labelMap = labelMap;
144 - this.isLabelMapSet = true; 144 + this.isLabelMapSet = true;
145 - return this; 145 + return this;
146 - } 146 + }
147 - 147 +
148 - @Override 148 + @Override
149 - public PcepLabelMap getLabelMap() { 149 + public PcepLabelMap getLabelMap() {
150 - return labelMap; 150 + return labelMap;
151 - } 151 + }
152 - } 152 + }
153 - 153 +
154 - /** 154 + /**
155 - * Reads PcepLabels from the byte stream received from channel buffer. 155 + * Reads PcepLabels from the byte stream received from channel buffer.
156 - * 156 + *
157 - * @param cb of type channel buffer. 157 + * @param cb of type channel buffer.
158 - * @return PcepLabelUpdate object. 158 + * @return PcepLabelUpdate object.
159 - * @throws PcepParseException when fails to read from channel buffer 159 + * @throws PcepParseException when fails to read from channel buffer
160 - */ 160 + */
161 - public static PcepLabelUpdate read(ChannelBuffer cb) throws PcepParseException { 161 + public static PcepLabelUpdate read(ChannelBuffer cb) throws PcepParseException {
162 - 162 +
163 - PcepLabelUpdateVer1 pceLabelUpdate = new PcepLabelUpdateVer1(); 163 + PcepLabelUpdateVer1 pceLabelUpdate = new PcepLabelUpdateVer1();
164 - 164 +
165 - PcepSrpObject srpObject; 165 + PcepSrpObject srpObject;
166 - PcepObjectHeader tempObjHeader; 166 + PcepObjectHeader tempObjHeader;
167 - 167 +
168 - //read SRP mandatory Object 168 + //read SRP mandatory Object
169 - srpObject = PcepSrpObjectVer1.read(cb); 169 + srpObject = PcepSrpObjectVer1.read(cb);
170 - 170 +
171 - //checking next object 171 + //checking next object
172 - cb.markReaderIndex(); 172 + cb.markReaderIndex();
173 - 173 +
174 - tempObjHeader = PcepObjectHeader.read(cb); 174 + tempObjHeader = PcepObjectHeader.read(cb);
175 - cb.resetReaderIndex(); 175 + cb.resetReaderIndex();
176 - 176 +
177 - if (tempObjHeader.getObjClass() == PcepLspObjectVer1.LSP_OBJ_CLASS) { 177 + if (tempObjHeader.getObjClass() == PcepLspObjectVer1.LSP_OBJ_CLASS) {
178 - 178 +
179 - //now it is belong to <pce-label-download> 179 + //now it is belong to <pce-label-download>
180 - PcepLabelDownload labelDownload = new PcepLabelDownload(); 180 + PcepLabelDownload labelDownload = new PcepLabelDownload();
181 - 181 +
182 - //set SRP 182 + //set SRP
183 - labelDownload.setSrpObject(srpObject); 183 + labelDownload.setSrpObject(srpObject);
184 - 184 +
185 - //read and set LSP 185 + //read and set LSP
186 - labelDownload.setLspObject(PcepLspObjectVer1.read(cb)); 186 + labelDownload.setLspObject(PcepLspObjectVer1.read(cb));
187 - 187 +
188 - //<label-list> 188 + //<label-list>
189 - LinkedList<PcepLabelObject> llLabelList = new LinkedList<PcepLabelObject>(); 189 + LinkedList<PcepLabelObject> llLabelList = new LinkedList<PcepLabelObject>();
190 - PcepLabelObject labelObject; 190 + PcepLabelObject labelObject;
191 - 191 +
192 - while (0 < cb.readableBytes()) { 192 + while (0 < cb.readableBytes()) {
193 - 193 +
194 - cb.markReaderIndex(); 194 + cb.markReaderIndex();
195 - tempObjHeader = PcepObjectHeader.read(cb); 195 + tempObjHeader = PcepObjectHeader.read(cb);
196 - cb.resetReaderIndex(); 196 + cb.resetReaderIndex();
197 - 197 +
198 - if (tempObjHeader.getObjClass() != PcepLabelObjectVer1.LABEL_OBJ_CLASS) { 198 + if (tempObjHeader.getObjClass() != PcepLabelObjectVer1.LABEL_OBJ_CLASS) {
199 - break; 199 + break;
200 - } 200 + }
201 - labelObject = PcepLabelObjectVer1.read(cb); 201 + labelObject = PcepLabelObjectVer1.read(cb);
202 - llLabelList.add(labelObject); 202 + llLabelList.add(labelObject);
203 - } 203 + }
204 - labelDownload.setLabelList(llLabelList); 204 + labelDownload.setLabelList(llLabelList);
205 - pceLabelUpdate.setLabelDownload(labelDownload); 205 + pceLabelUpdate.setLabelDownload(labelDownload);
206 - } else if (tempObjHeader.getObjClass() == PcepLabelObjectVer1.LABEL_OBJ_CLASS) { 206 + } else if (tempObjHeader.getObjClass() == PcepLabelObjectVer1.LABEL_OBJ_CLASS) {
207 - //belong to <pce-label-map> 207 + //belong to <pce-label-map>
208 - PcepLabelMap labelMap = new PcepLabelMap(); 208 + PcepLabelMap labelMap = new PcepLabelMap();
209 - 209 +
210 - //set SRP Object 210 + //set SRP Object
211 - labelMap.setSrpObject(srpObject); 211 + labelMap.setSrpObject(srpObject);
212 - 212 +
213 - //read and set Label Object 213 + //read and set Label Object
214 - labelMap.setLabelObject(PcepLabelObjectVer1.read(cb)); 214 + labelMap.setLabelObject(PcepLabelObjectVer1.read(cb));
215 - 215 +
216 - cb.markReaderIndex(); 216 + cb.markReaderIndex();
217 - tempObjHeader = PcepObjectHeader.read(cb); 217 + tempObjHeader = PcepObjectHeader.read(cb);
218 - cb.resetReaderIndex(); 218 + cb.resetReaderIndex();
219 - 219 +
220 - PcepFecObject fecObject = null; 220 + PcepFecObject fecObject = null;
221 - switch (tempObjHeader.getObjType()) { 221 + switch (tempObjHeader.getObjType()) {
222 - case PcepFecObjectIPv4Ver1.FEC_OBJ_TYPE: 222 + case PcepFecObjectIPv4Ver1.FEC_OBJ_TYPE:
223 - fecObject = PcepFecObjectIPv4Ver1.read(cb); 223 + fecObject = PcepFecObjectIPv4Ver1.read(cb);
224 - break; 224 + break;
225 - case PcepFecObjectIPv6Ver1.FEC_OBJ_TYPE: 225 + case PcepFecObjectIPv6Ver1.FEC_OBJ_TYPE:
226 - fecObject = PcepFecObjectIPv6Ver1.read(cb); 226 + fecObject = PcepFecObjectIPv6Ver1.read(cb);
227 - break; 227 + break;
228 - case PcepFecObjectIPv4AdjacencyVer1.FEC_OBJ_TYPE: 228 + case PcepFecObjectIPv4AdjacencyVer1.FEC_OBJ_TYPE:
229 - fecObject = PcepFecObjectIPv4AdjacencyVer1.read(cb); 229 + fecObject = PcepFecObjectIPv4AdjacencyVer1.read(cb);
230 - break; 230 + break;
231 - case PcepFecObjectIPv6AdjacencyVer1.FEC_OBJ_TYPE: 231 + case PcepFecObjectIPv6AdjacencyVer1.FEC_OBJ_TYPE:
232 - fecObject = PcepFecObjectIPv6AdjacencyVer1.read(cb); 232 + fecObject = PcepFecObjectIPv6AdjacencyVer1.read(cb);
233 - break; 233 + break;
234 - case PcepFecObjectIPv4UnnumberedAdjacencyVer1.FEC_OBJ_TYPE: 234 + case PcepFecObjectIPv4UnnumberedAdjacencyVer1.FEC_OBJ_TYPE:
235 - fecObject = PcepFecObjectIPv4UnnumberedAdjacencyVer1.read(cb); 235 + fecObject = PcepFecObjectIPv4UnnumberedAdjacencyVer1.read(cb);
236 - break; 236 + break;
237 - default: 237 + default:
238 - throw new PcepParseException("Unkown FEC object type " + tempObjHeader.getObjType()); 238 + throw new PcepParseException("Unkown FEC object type " + tempObjHeader.getObjType());
239 - } 239 + }
240 - labelMap.setFECObject(fecObject); 240 + labelMap.setFECObject(fecObject);
241 - pceLabelUpdate.setLabelMap(labelMap); 241 + pceLabelUpdate.setLabelMap(labelMap);
242 - } else { 242 + } else {
243 - throw new PcepParseException( 243 + throw new PcepParseException(
244 - "Either <pce-label-download> or <pce-label-map> should be present. Received Class: " 244 + "Either <pce-label-download> or <pce-label-map> should be present. Received Class: "
245 - + tempObjHeader.getObjClass()); 245 + + tempObjHeader.getObjClass());
246 - } 246 + }
247 - return pceLabelUpdate; 247 + return pceLabelUpdate;
248 - } 248 + }
249 - 249 +
250 - @Override 250 + @Override
251 - public void write(ChannelBuffer cb) throws PcepParseException { 251 + public void write(ChannelBuffer cb) throws PcepParseException {
252 - 252 +
253 - if ((labelDownload != null) && (labelMap != null)) { 253 + if ((labelDownload != null) && (labelMap != null)) {
254 - throw new PcepParseException("Label Download and Label Map both can't be present."); 254 + throw new PcepParseException("Label Download and Label Map both can't be present.");
255 - } 255 + }
256 - 256 +
257 - if ((labelDownload == null) && (labelMap == null)) { 257 + if ((labelDownload == null) && (labelMap == null)) {
258 - throw new PcepParseException("Either Label Download or Label Map should be present."); 258 + throw new PcepParseException("Either Label Download or Label Map should be present.");
259 - } 259 + }
260 - 260 +
261 - if (labelDownload != null) { 261 + if (labelDownload != null) {
262 - 262 +
263 - PcepLspObject lspObject; 263 + PcepLspObject lspObject;
264 - PcepSrpObject srpObject; 264 + PcepSrpObject srpObject;
265 - PcepLabelObject labelObject; 265 + PcepLabelObject labelObject;
266 - LinkedList<PcepLabelObject> llLabelList; 266 + LinkedList<PcepLabelObject> llLabelList;
267 - 267 +
268 - srpObject = labelDownload.getSrpObject(); 268 + srpObject = labelDownload.getSrpObject();
269 - if (srpObject == null) { 269 + if (srpObject == null) {
270 - throw new PcepParseException("SRP Object is mandatory object for Label Download."); 270 + throw new PcepParseException("SRP Object is mandatory object for Label Download.");
271 - } else { 271 + } else {
272 - srpObject.write(cb); 272 + srpObject.write(cb);
273 - } 273 + }
274 - 274 +
275 - lspObject = labelDownload.getLspObject(); 275 + lspObject = labelDownload.getLspObject();
276 - if (lspObject == null) { 276 + if (lspObject == null) {
277 - throw new PcepParseException("LSP Object is mandatory object for Label Download."); 277 + throw new PcepParseException("LSP Object is mandatory object for Label Download.");
278 - } else { 278 + } else {
279 - lspObject.write(cb); 279 + lspObject.write(cb);
280 - } 280 + }
281 - 281 +
282 - llLabelList = labelDownload.getLabelList(); 282 + llLabelList = labelDownload.getLabelList();
283 - if (llLabelList == null) { 283 + if (llLabelList == null) {
284 - throw new PcepParseException("Label list is mandatory object for Label Download."); 284 + throw new PcepParseException("Label list is mandatory object for Label Download.");
285 - } else { 285 + } else {
286 - ListIterator<PcepLabelObject> listIterator = llLabelList.listIterator(); 286 + ListIterator<PcepLabelObject> listIterator = llLabelList.listIterator();
287 - while (listIterator.hasNext()) { 287 + while (listIterator.hasNext()) {
288 - labelObject = listIterator.next(); 288 + labelObject = listIterator.next();
289 - labelObject.write(cb); 289 + labelObject.write(cb);
290 - } 290 + }
291 - } 291 + }
292 - } 292 + }
293 - 293 +
294 - if (labelMap != null) { 294 + if (labelMap != null) {
295 - 295 +
296 - PcepSrpObject srpObject; 296 + PcepSrpObject srpObject;
297 - PcepLabelObject labelObject; 297 + PcepLabelObject labelObject;
298 - PcepFecObject fecObject; 298 + PcepFecObject fecObject;
299 - 299 +
300 - srpObject = labelMap.getSrpObject(); 300 + srpObject = labelMap.getSrpObject();
301 - if (srpObject == null) { 301 + if (srpObject == null) {
302 - throw new PcepParseException("SRP Object is mandatory object for Label map."); 302 + throw new PcepParseException("SRP Object is mandatory object for Label map.");
303 - } else { 303 + } else {
304 - srpObject.write(cb); 304 + srpObject.write(cb);
305 - } 305 + }
306 - labelObject = labelMap.getLabelObject(); 306 + labelObject = labelMap.getLabelObject();
307 - if (labelObject == null) { 307 + if (labelObject == null) {
308 - throw new PcepParseException("label Object is mandatory object for Label map."); 308 + throw new PcepParseException("label Object is mandatory object for Label map.");
309 - } else { 309 + } else {
310 - labelObject.write(cb); 310 + labelObject.write(cb);
311 - } 311 + }
312 - fecObject = labelMap.getFECObject(); 312 + fecObject = labelMap.getFECObject();
313 - if (fecObject == null) { 313 + if (fecObject == null) {
314 - throw new PcepParseException("fec Object is mandatory object for Label map."); 314 + throw new PcepParseException("fec Object is mandatory object for Label map.");
315 - } else { 315 + } else {
316 - fecObject.write(cb); 316 + fecObject.write(cb);
317 - } 317 + }
318 - } 318 + }
319 - } 319 + }
320 - 320 +
321 - @Override 321 + @Override
322 - public void setLabelDownload(PcepLabelDownload labelDownload) { 322 + public void setLabelDownload(PcepLabelDownload labelDownload) {
323 - if (this.isLabelMapSet) { 323 + if (this.isLabelMapSet) {
324 - return; 324 + return;
325 - } 325 + }
326 - this.labelDownload = labelDownload; 326 + this.labelDownload = labelDownload;
327 - this.isLabelDownloadSet = true; 327 + this.isLabelDownloadSet = true;
328 - } 328 + }
329 - 329 +
330 - @Override 330 + @Override
331 - public PcepLabelDownload getLabelDownload() { 331 + public PcepLabelDownload getLabelDownload() {
332 - return this.labelDownload; 332 + return this.labelDownload;
333 - } 333 + }
334 - 334 +
335 - @Override 335 + @Override
336 - public void setLabelMap(PcepLabelMap labelMap) { 336 + public void setLabelMap(PcepLabelMap labelMap) {
337 - if (this.isLabelDownloadSet) { 337 + if (this.isLabelDownloadSet) {
338 - return; 338 + return;
339 - } 339 + }
340 - this.labelMap = labelMap; 340 + this.labelMap = labelMap;
341 - this.isLabelMapSet = true; 341 + this.isLabelMapSet = true;
342 - } 342 + }
343 - 343 +
344 - @Override 344 + @Override
345 - public PcepLabelMap getLabelMap() { 345 + public PcepLabelMap getLabelMap() {
346 - return this.labelMap; 346 + return this.labelMap;
347 - } 347 + }
348 - 348 +
349 - @Override 349 + @Override
350 - public String toString() { 350 + public String toString() {
351 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 351 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
352 - 352 +
353 - if (labelDownload instanceof PcepLabelDownload) { 353 + if (labelDownload instanceof PcepLabelDownload) {
354 - toStrHelper.add("LabelDownload", labelDownload); 354 + toStrHelper.add("LabelDownload", labelDownload);
355 - } 355 + }
356 - if (labelMap instanceof PcepLabelMap) { 356 + if (labelMap instanceof PcepLabelMap) {
357 - toStrHelper.add("LabelMap", labelMap); 357 + toStrHelper.add("LabelMap", labelMap);
358 - } 358 + }
359 - return toStrHelper.toString(); 359 + return toStrHelper.toString();
360 - } 360 + }
361 -} 361 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepLspaObject; 24 +import org.onosproject.pcepio.protocol.PcepLspaObject;
25 -import org.onosproject.pcepio.types.PcepObjectHeader; 25 +import org.onosproject.pcepio.types.PcepObjectHeader;
26 -import org.onosproject.pcepio.types.PcepValueType; 26 +import org.onosproject.pcepio.types.PcepValueType;
27 -import org.slf4j.Logger; 27 +import org.slf4j.Logger;
28 -import org.slf4j.LoggerFactory; 28 +import org.slf4j.LoggerFactory;
29 - 29 +
30 -import com.google.common.base.MoreObjects; 30 +import com.google.common.base.MoreObjects;
31 - 31 +
32 -/** 32 +/**
33 - * Provides PCEP label Object . 33 + * Provides PCEP label Object .
34 - */ 34 + */
35 -public class PcepLspaObjectVer1 implements PcepLspaObject { 35 +public class PcepLspaObjectVer1 implements PcepLspaObject {
36 - 36 +
37 - /* LSPA Object Body Format 37 + /* LSPA Object Body Format
38 - 38 +
39 - 0 1 2 3 39 + 0 1 2 3
40 - 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 + 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
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | Exclude-any | 42 + | Exclude-any |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - | Include-any | 44 + | Include-any |
45 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 - | Include-all | 46 + | Include-all |
47 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 - | Setup Prio | Holding Prio | Flags |L| Reserved | 48 + | Setup Prio | Holding Prio | Flags |L| Reserved |
49 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 49 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 - | | 50 + | |
51 - | Optional TLVs | 51 + | Optional TLVs |
52 - | | 52 + | |
53 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 53 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 - */ 54 + */
55 - 55 +
56 - protected static final Logger log = LoggerFactory.getLogger(PcepLspaObjectVer1.class); 56 + protected static final Logger log = LoggerFactory.getLogger(PcepLspaObjectVer1.class);
57 - 57 +
58 - public static final byte LSPA_OBJ_TYPE = 1; 58 + public static final byte LSPA_OBJ_TYPE = 1;
59 - public static final byte LSPA_OBJ_CLASS = 9; 59 + public static final byte LSPA_OBJ_CLASS = 9;
60 - public static final byte LSPA_OBJECT_VERSION = 1; 60 + public static final byte LSPA_OBJECT_VERSION = 1;
61 - public static final short LSPA_OBJ_MINIMUM_LENGTH = 20; 61 + public static final short LSPA_OBJ_MINIMUM_LENGTH = 20;
62 - public static final int OBJECT_HEADER_LENGTH = 4; 62 + public static final int OBJECT_HEADER_LENGTH = 4;
63 - 63 +
64 - static final PcepObjectHeader DEFAULT_LSPA_OBJECT_HEADER = new PcepObjectHeader(LSPA_OBJ_CLASS, LSPA_OBJ_TYPE, 64 + static final PcepObjectHeader DEFAULT_LSPA_OBJECT_HEADER = new PcepObjectHeader(LSPA_OBJ_CLASS, LSPA_OBJ_TYPE,
65 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSPA_OBJ_MINIMUM_LENGTH); 65 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, LSPA_OBJ_MINIMUM_LENGTH);
66 - 66 +
67 - public static final int SETUP_PRIORITY_SHIFT_VALUE = 24; 67 + public static final int SETUP_PRIORITY_SHIFT_VALUE = 24;
68 - public static final int HOLD_PRIORITY_SHIFT_VALUE = 16; 68 + public static final int HOLD_PRIORITY_SHIFT_VALUE = 16;
69 - public static final int BFLAG_SHIFT_VALUE = 8; 69 + public static final int BFLAG_SHIFT_VALUE = 8;
70 - public static final int LFLAG_SET = 1; 70 + public static final int LFLAG_SET = 1;
71 - public static final int LFLAG_RESET = 0; 71 + public static final int LFLAG_RESET = 0;
72 - private PcepObjectHeader lspaObjHeader; 72 + private PcepObjectHeader lspaObjHeader;
73 - private int iExcludeAny; 73 + private int iExcludeAny;
74 - private int iIncludeAny; 74 + private int iIncludeAny;
75 - private int iIncludeAll; 75 + private int iIncludeAll;
76 - private byte cSetupPriority; 76 + private byte cSetupPriority;
77 - private byte cHoldPriority; 77 + private byte cHoldPriority;
78 - private boolean bLFlag; 78 + private boolean bLFlag;
79 - private LinkedList<PcepValueType> llOptionalTlv; //Optional TLV 79 + private LinkedList<PcepValueType> llOptionalTlv; //Optional TLV
80 - 80 +
81 - /** 81 + /**
82 - * Constructor to initialize member variables. 82 + * Constructor to initialize member variables.
83 - * 83 + *
84 - * @param lspaObjHeader lspa object header 84 + * @param lspaObjHeader lspa object header
85 - * @param bLFlag b l flag 85 + * @param bLFlag b l flag
86 - * @param iExcludeAny excludeAny value 86 + * @param iExcludeAny excludeAny value
87 - * @param iIncludeAny includeAny value 87 + * @param iIncludeAny includeAny value
88 - * @param iIncludeAll includeAll value 88 + * @param iIncludeAll includeAll value
89 - * @param cSetupPriority setup priority value 89 + * @param cSetupPriority setup priority value
90 - * @param cHoldPriority hold priority value 90 + * @param cHoldPriority hold priority value
91 - * @param llOptionalTlv list of optional tlv 91 + * @param llOptionalTlv list of optional tlv
92 - */ 92 + */
93 - public PcepLspaObjectVer1(PcepObjectHeader lspaObjHeader, boolean bLFlag, int iExcludeAny, int iIncludeAny, 93 + public PcepLspaObjectVer1(PcepObjectHeader lspaObjHeader, boolean bLFlag, int iExcludeAny, int iIncludeAny,
94 - int iIncludeAll, byte cSetupPriority, byte cHoldPriority, LinkedList<PcepValueType> llOptionalTlv) { 94 + int iIncludeAll, byte cSetupPriority, byte cHoldPriority, LinkedList<PcepValueType> llOptionalTlv) {
95 - 95 +
96 - this.lspaObjHeader = lspaObjHeader; 96 + this.lspaObjHeader = lspaObjHeader;
97 - this.bLFlag = bLFlag; 97 + this.bLFlag = bLFlag;
98 - this.iExcludeAny = iExcludeAny; 98 + this.iExcludeAny = iExcludeAny;
99 - this.iIncludeAny = iIncludeAny; 99 + this.iIncludeAny = iIncludeAny;
100 - this.iIncludeAll = iIncludeAll; 100 + this.iIncludeAll = iIncludeAll;
101 - this.cSetupPriority = cSetupPriority; 101 + this.cSetupPriority = cSetupPriority;
102 - this.cHoldPriority = cHoldPriority; 102 + this.cHoldPriority = cHoldPriority;
103 - this.llOptionalTlv = llOptionalTlv; 103 + this.llOptionalTlv = llOptionalTlv;
104 - } 104 + }
105 - 105 +
106 - /** 106 + /**
107 - * Sets Object Header. 107 + * Sets Object Header.
108 - * 108 + *
109 - * @param obj lspa object header 109 + * @param obj lspa object header
110 - */ 110 + */
111 - public void setLspaObjHeader(PcepObjectHeader obj) { 111 + public void setLspaObjHeader(PcepObjectHeader obj) {
112 - this.lspaObjHeader = obj; 112 + this.lspaObjHeader = obj;
113 - } 113 + }
114 - 114 +
115 - @Override 115 + @Override
116 - public void setExcludeAny(int iExcludeAny) { 116 + public void setExcludeAny(int iExcludeAny) {
117 - this.iExcludeAny = iExcludeAny; 117 + this.iExcludeAny = iExcludeAny;
118 - } 118 + }
119 - 119 +
120 - @Override 120 + @Override
121 - public void setIncludeAny(int iIncludeAny) { 121 + public void setIncludeAny(int iIncludeAny) {
122 - this.iIncludeAny = iIncludeAny; 122 + this.iIncludeAny = iIncludeAny;
123 - } 123 + }
124 - 124 +
125 - @Override 125 + @Override
126 - public void setSetupPriority(byte cSetupPriority) { 126 + public void setSetupPriority(byte cSetupPriority) {
127 - this.cSetupPriority = cSetupPriority; 127 + this.cSetupPriority = cSetupPriority;
128 - } 128 + }
129 - 129 +
130 - @Override 130 + @Override
131 - public void setHoldPriority(byte cHoldPriority) { 131 + public void setHoldPriority(byte cHoldPriority) {
132 - this.cHoldPriority = cHoldPriority; 132 + this.cHoldPriority = cHoldPriority;
133 - } 133 + }
134 - 134 +
135 - @Override 135 + @Override
136 - public void setLFlag(boolean bLFlag) { 136 + public void setLFlag(boolean bLFlag) {
137 - this.bLFlag = bLFlag; 137 + this.bLFlag = bLFlag;
138 - } 138 + }
139 - 139 +
140 - /** 140 + /**
141 - * Returns lspa Object Header. 141 + * Returns lspa Object Header.
142 - * 142 + *
143 - * @return lspa Object Header 143 + * @return lspa Object Header
144 - */ 144 + */
145 - public PcepObjectHeader getLspaObjHeader() { 145 + public PcepObjectHeader getLspaObjHeader() {
146 - return this.lspaObjHeader; 146 + return this.lspaObjHeader;
147 - } 147 + }
148 - 148 +
149 - @Override 149 + @Override
150 - public int getExcludeAny() { 150 + public int getExcludeAny() {
151 - return this.iExcludeAny; 151 + return this.iExcludeAny;
152 - } 152 + }
153 - 153 +
154 - @Override 154 + @Override
155 - public int getIncludeAny() { 155 + public int getIncludeAny() {
156 - return this.iIncludeAny; 156 + return this.iIncludeAny;
157 - } 157 + }
158 - 158 +
159 - @Override 159 + @Override
160 - public int getIncludeAll() { 160 + public int getIncludeAll() {
161 - return this.iIncludeAll; 161 + return this.iIncludeAll;
162 - } 162 + }
163 - 163 +
164 - @Override 164 + @Override
165 - public byte getSetupPriority() { 165 + public byte getSetupPriority() {
166 - return this.cSetupPriority; 166 + return this.cSetupPriority;
167 - } 167 + }
168 - 168 +
169 - @Override 169 + @Override
170 - public byte getHoldPriority() { 170 + public byte getHoldPriority() {
171 - return this.cHoldPriority; 171 + return this.cHoldPriority;
172 - } 172 + }
173 - 173 +
174 - @Override 174 + @Override
175 - public boolean getLFlag() { 175 + public boolean getLFlag() {
176 - return this.bLFlag; 176 + return this.bLFlag;
177 - } 177 + }
178 - 178 +
179 - @Override 179 + @Override
180 - public void setIncludeAll(int value) { 180 + public void setIncludeAll(int value) {
181 - this.iIncludeAll = value; 181 + this.iIncludeAll = value;
182 - 182 +
183 - } 183 + }
184 - 184 +
185 - @Override 185 + @Override
186 - public LinkedList<PcepValueType> getOptionalTlv() { 186 + public LinkedList<PcepValueType> getOptionalTlv() {
187 - return this.llOptionalTlv; 187 + return this.llOptionalTlv;
188 - } 188 + }
189 - 189 +
190 - @Override 190 + @Override
191 - public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 191 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
192 - this.llOptionalTlv = llOptionalTlv; 192 + this.llOptionalTlv = llOptionalTlv;
193 - 193 +
194 - } 194 + }
195 - 195 +
196 - /** 196 + /**
197 - * Reads channel buffer and returns object of PcepLspaObject. 197 + * Reads channel buffer and returns object of PcepLspaObject.
198 - * 198 + *
199 - * @param cb of type channel buffer. 199 + * @param cb of type channel buffer.
200 - * @return object of PcepLspaObject 200 + * @return object of PcepLspaObject
201 - * @throws PcepParseException while parsing lspa object from channel buffer 201 + * @throws PcepParseException while parsing lspa object from channel buffer
202 - */ 202 + */
203 - public static PcepLspaObject read(ChannelBuffer cb) throws PcepParseException { 203 + public static PcepLspaObject read(ChannelBuffer cb) throws PcepParseException {
204 - 204 +
205 - log.debug("LspaObject::read"); 205 + log.debug("LspaObject::read");
206 - PcepObjectHeader lspaObjHeader; 206 + PcepObjectHeader lspaObjHeader;
207 - int iExcludeAny; 207 + int iExcludeAny;
208 - int iIncludeAny; 208 + int iIncludeAny;
209 - int iIncludeAll; 209 + int iIncludeAll;
210 - byte cSetupPriority; 210 + byte cSetupPriority;
211 - byte cHoldPriority; 211 + byte cHoldPriority;
212 - boolean bLFlag; 212 + boolean bLFlag;
213 - byte flags; 213 + byte flags;
214 - 214 +
215 - // Optional TLV 215 + // Optional TLV
216 - LinkedList<PcepValueType> llOptionalTlv; 216 + LinkedList<PcepValueType> llOptionalTlv;
217 - 217 +
218 - lspaObjHeader = PcepObjectHeader.read(cb); 218 + lspaObjHeader = PcepObjectHeader.read(cb);
219 - 219 +
220 - //take only Lspa Object buffer. 220 + //take only Lspa Object buffer.
221 - ChannelBuffer tempCb = cb.readBytes(lspaObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); 221 + ChannelBuffer tempCb = cb.readBytes(lspaObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
222 - iExcludeAny = tempCb.readInt(); 222 + iExcludeAny = tempCb.readInt();
223 - iIncludeAny = tempCb.readInt(); 223 + iIncludeAny = tempCb.readInt();
224 - iIncludeAll = tempCb.readInt(); 224 + iIncludeAll = tempCb.readInt();
225 - cSetupPriority = tempCb.readByte(); 225 + cSetupPriority = tempCb.readByte();
226 - cHoldPriority = tempCb.readByte(); 226 + cHoldPriority = tempCb.readByte();
227 - flags = tempCb.readByte(); 227 + flags = tempCb.readByte();
228 - tempCb.readByte(); 228 + tempCb.readByte();
229 - 229 +
230 - bLFlag = (flags & (byte) LFLAG_SET) == LFLAG_SET ? true : false; 230 + bLFlag = (flags & (byte) LFLAG_SET) == LFLAG_SET ? true : false;
231 - 231 +
232 - llOptionalTlv = parseOptionalTlv(tempCb); 232 + llOptionalTlv = parseOptionalTlv(tempCb);
233 - 233 +
234 - return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority, 234 + return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
235 - cHoldPriority, llOptionalTlv); 235 + cHoldPriority, llOptionalTlv);
236 - } 236 + }
237 - 237 +
238 - @Override 238 + @Override
239 - public int write(ChannelBuffer cb) throws PcepParseException { 239 + public int write(ChannelBuffer cb) throws PcepParseException {
240 - 240 +
241 - //write Object header 241 + //write Object header
242 - int objStartIndex = cb.writerIndex(); 242 + int objStartIndex = cb.writerIndex();
243 - 243 +
244 - int objLenIndex = lspaObjHeader.write(cb); 244 + int objLenIndex = lspaObjHeader.write(cb);
245 - 245 +
246 - if (objLenIndex <= 0) { 246 + if (objLenIndex <= 0) {
247 - throw new PcepParseException("Failed to write lspa object header. Index " + objLenIndex); 247 + throw new PcepParseException("Failed to write lspa object header. Index " + objLenIndex);
248 - } 248 + }
249 - 249 +
250 - cb.writeInt(iExcludeAny); 250 + cb.writeInt(iExcludeAny);
251 - cb.writeInt(iIncludeAny); 251 + cb.writeInt(iIncludeAny);
252 - cb.writeInt(iIncludeAll); 252 + cb.writeInt(iIncludeAll);
253 - 253 +
254 - int iTemp = cSetupPriority << SETUP_PRIORITY_SHIFT_VALUE; 254 + int iTemp = cSetupPriority << SETUP_PRIORITY_SHIFT_VALUE;
255 - iTemp = iTemp | (cHoldPriority << HOLD_PRIORITY_SHIFT_VALUE); 255 + iTemp = iTemp | (cHoldPriority << HOLD_PRIORITY_SHIFT_VALUE);
256 - byte bFlag; 256 + byte bFlag;
257 - bFlag = (bLFlag) ? (byte) LFLAG_SET : LFLAG_RESET; 257 + bFlag = (bLFlag) ? (byte) LFLAG_SET : LFLAG_RESET;
258 - iTemp = iTemp | (bFlag << BFLAG_SHIFT_VALUE); 258 + iTemp = iTemp | (bFlag << BFLAG_SHIFT_VALUE);
259 - cb.writeInt(iTemp); 259 + cb.writeInt(iTemp);
260 - 260 +
261 - // Add optional TLV 261 + // Add optional TLV
262 - if (!packOptionalTlv(cb)) { 262 + if (!packOptionalTlv(cb)) {
263 - throw new PcepParseException("Faild to write lspa objects tlv to channel buffer"); 263 + throw new PcepParseException("Faild to write lspa objects tlv to channel buffer");
264 - } 264 + }
265 - 265 +
266 - short length = (short) (cb.writerIndex() - objStartIndex); 266 + short length = (short) (cb.writerIndex() - objStartIndex);
267 - 267 +
268 - lspaObjHeader.setObjLen(length); //will be helpful during print(). 268 + lspaObjHeader.setObjLen(length); //will be helpful during print().
269 - 269 +
270 - //As per RFC the length of object should be multiples of 4 270 + //As per RFC the length of object should be multiples of 4
271 - short pad = (short) (length % 4); 271 + short pad = (short) (length % 4);
272 - 272 +
273 - if (pad != 0) { 273 + if (pad != 0) {
274 - pad = (short) (4 - pad); 274 + pad = (short) (4 - pad);
275 - for (int i = 0; i < pad; i++) { 275 + for (int i = 0; i < pad; i++) {
276 - cb.writeByte((byte) 0); 276 + cb.writeByte((byte) 0);
277 - } 277 + }
278 - length = (short) (length + pad); 278 + length = (short) (length + pad);
279 - } 279 + }
280 - cb.setShort(objLenIndex, length); 280 + cb.setShort(objLenIndex, length);
281 - return cb.writerIndex(); 281 + return cb.writerIndex();
282 - } 282 + }
283 - 283 +
284 - /** 284 + /**
285 - * Parse list of optional tlvs. 285 + * Parse list of optional tlvs.
286 - * 286 + *
287 - * @param cb channel buffer 287 + * @param cb channel buffer
288 - * @return list of optional tlvs. 288 + * @return list of optional tlvs.
289 - * @throws PcepParseException when fails to parse optional tlv list. 289 + * @throws PcepParseException when fails to parse optional tlv list.
290 - */ 290 + */
291 - public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { 291 + public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
292 - 292 +
293 - LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>(); 293 + LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
294 - 294 +
295 - return llOutOptionalTlv; 295 + return llOutOptionalTlv;
296 - } 296 + }
297 - 297 +
298 - /** 298 + /**
299 - * Writes optional tlvs to channel buffer. 299 + * Writes optional tlvs to channel buffer.
300 - * 300 + *
301 - * @param cb channel buffer 301 + * @param cb channel buffer
302 - * @return true 302 + * @return true
303 - */ 303 + */
304 - protected boolean packOptionalTlv(ChannelBuffer cb) { 304 + protected boolean packOptionalTlv(ChannelBuffer cb) {
305 - int hTlvType; 305 + int hTlvType;
306 - int hTlvLength; 306 + int hTlvLength;
307 - 307 +
308 - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); 308 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
309 - while (listIterator.hasNext()) { 309 + while (listIterator.hasNext()) {
310 - PcepValueType tlv = listIterator.next(); 310 + PcepValueType tlv = listIterator.next();
311 - if (null == tlv) { 311 + if (null == tlv) {
312 - log.debug("Warning: tlv is null from OptionalTlv list"); 312 + log.debug("Warning: tlv is null from OptionalTlv list");
313 - continue; 313 + continue;
314 - } 314 + }
315 - hTlvType = tlv.getType(); 315 + hTlvType = tlv.getType();
316 - hTlvLength = tlv.getLength(); 316 + hTlvLength = tlv.getLength();
317 - if (0 == hTlvLength) { 317 + if (0 == hTlvLength) {
318 - log.debug("Warning: invalid length in tlv of OptionalTlv list"); 318 + log.debug("Warning: invalid length in tlv of OptionalTlv list");
319 - continue; 319 + continue;
320 - } 320 + }
321 - 321 +
322 - cb.writeShort(hTlvType); 322 + cb.writeShort(hTlvType);
323 - cb.writeShort(hTlvLength); 323 + cb.writeShort(hTlvLength);
324 - 324 +
325 - switch (hTlvType) { 325 + switch (hTlvType) {
326 - //TODO: optional TLV for LSPA to be added 326 + //TODO: optional TLV for LSPA to be added
327 - 327 +
328 - default: 328 + default:
329 - log.debug("Warning: PcepLspaObject: unknown tlv"); 329 + log.debug("Warning: PcepLspaObject: unknown tlv");
330 - } 330 + }
331 - 331 +
332 - // As per RFC the length of object should 332 + // As per RFC the length of object should
333 - // be multiples of 4 333 + // be multiples of 4
334 - int pad = hTlvLength % 4; 334 + int pad = hTlvLength % 4;
335 - 335 +
336 - if (0 < pad) { 336 + if (0 < pad) {
337 - pad = 4 - pad; 337 + pad = 4 - pad;
338 - if (pad <= cb.readableBytes()) { 338 + if (pad <= cb.readableBytes()) {
339 - cb.skipBytes(pad); 339 + cb.skipBytes(pad);
340 - } 340 + }
341 - } 341 + }
342 - } 342 + }
343 - return true; 343 + return true;
344 - } 344 + }
345 - 345 +
346 - /** 346 + /**
347 - * Builder class for PCEP lspa object. 347 + * Builder class for PCEP lspa object.
348 - */ 348 + */
349 - public static class Builder implements PcepLspaObject.Builder { 349 + public static class Builder implements PcepLspaObject.Builder {
350 - private boolean bIsHeaderSet = false; 350 + private boolean bIsHeaderSet = false;
351 - 351 +
352 - private PcepObjectHeader lspaObjHeader; 352 + private PcepObjectHeader lspaObjHeader;
353 - 353 +
354 - private boolean bLFlag; 354 + private boolean bLFlag;
355 - private int iExcludeAny; 355 + private int iExcludeAny;
356 - private boolean bIsExcludeAnySet = false; 356 + private boolean bIsExcludeAnySet = false;
357 - private int iIncludeAny; 357 + private int iIncludeAny;
358 - private boolean bIsIncludeAnySet = false; 358 + private boolean bIsIncludeAnySet = false;
359 - private int iIncludeAll; 359 + private int iIncludeAll;
360 - private boolean bIsIncludeAllSet = false; 360 + private boolean bIsIncludeAllSet = false;
361 - private byte cSetupPriority; 361 + private byte cSetupPriority;
362 - private boolean bIsSetupPrioritySet = false; 362 + private boolean bIsSetupPrioritySet = false;
363 - private byte cHoldPriority; 363 + private byte cHoldPriority;
364 - private boolean bIsHoldPrioritySet = false; 364 + private boolean bIsHoldPrioritySet = false;
365 - private LinkedList<PcepValueType> llOptionalTlv; 365 + private LinkedList<PcepValueType> llOptionalTlv;
366 - 366 +
367 - private boolean bIsPFlagSet = false; 367 + private boolean bIsPFlagSet = false;
368 - private boolean bPFlag; 368 + private boolean bPFlag;
369 - 369 +
370 - private boolean bIsIFlagSet = false; 370 + private boolean bIsIFlagSet = false;
371 - private boolean bIFlag; 371 + private boolean bIFlag;
372 - 372 +
373 - @Override 373 + @Override
374 - public PcepLspaObject build() throws PcepParseException { 374 + public PcepLspaObject build() throws PcepParseException {
375 - 375 +
376 - PcepObjectHeader lspaObjHeader = this.bIsHeaderSet ? this.lspaObjHeader : DEFAULT_LSPA_OBJECT_HEADER; 376 + PcepObjectHeader lspaObjHeader = this.bIsHeaderSet ? this.lspaObjHeader : DEFAULT_LSPA_OBJECT_HEADER;
377 - 377 +
378 - if (!this.bIsExcludeAnySet) { 378 + if (!this.bIsExcludeAnySet) {
379 - throw new PcepParseException("ExcludeAny NOT Set while building PcepLspaObject."); 379 + throw new PcepParseException("ExcludeAny NOT Set while building PcepLspaObject.");
380 - } 380 + }
381 - if (!this.bIsIncludeAnySet) { 381 + if (!this.bIsIncludeAnySet) {
382 - throw new PcepParseException("IncludeAny NOT Set while building PcepLspaObject."); 382 + throw new PcepParseException("IncludeAny NOT Set while building PcepLspaObject.");
383 - } 383 + }
384 - if (!this.bIsIncludeAllSet) { 384 + if (!this.bIsIncludeAllSet) {
385 - throw new PcepParseException("IncludeAll NOT Set while building PcepLspaObject."); 385 + throw new PcepParseException("IncludeAll NOT Set while building PcepLspaObject.");
386 - } 386 + }
387 - if (!this.bIsSetupPrioritySet) { 387 + if (!this.bIsSetupPrioritySet) {
388 - throw new PcepParseException("Setup Priority NOT Set while building PcepLspaObject."); 388 + throw new PcepParseException("Setup Priority NOT Set while building PcepLspaObject.");
389 - } 389 + }
390 - if (!this.bIsHoldPrioritySet) { 390 + if (!this.bIsHoldPrioritySet) {
391 - throw new PcepParseException("Hold Priority NOT Set while building PcepLspaObject."); 391 + throw new PcepParseException("Hold Priority NOT Set while building PcepLspaObject.");
392 - } 392 + }
393 - 393 +
394 - if (bIsPFlagSet) { 394 + if (bIsPFlagSet) {
395 - lspaObjHeader.setPFlag(bPFlag); 395 + lspaObjHeader.setPFlag(bPFlag);
396 - } 396 + }
397 - 397 +
398 - if (bIsIFlagSet) { 398 + if (bIsIFlagSet) {
399 - lspaObjHeader.setIFlag(bIFlag); 399 + lspaObjHeader.setIFlag(bIFlag);
400 - } 400 + }
401 - 401 +
402 - return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority, 402 + return new PcepLspaObjectVer1(lspaObjHeader, bLFlag, iExcludeAny, iIncludeAny, iIncludeAll, cSetupPriority,
403 - cHoldPriority, llOptionalTlv); 403 + cHoldPriority, llOptionalTlv);
404 - } 404 + }
405 - 405 +
406 - @Override 406 + @Override
407 - public PcepObjectHeader getLspaObjHeader() { 407 + public PcepObjectHeader getLspaObjHeader() {
408 - return this.lspaObjHeader; 408 + return this.lspaObjHeader;
409 - } 409 + }
410 - 410 +
411 - @Override 411 + @Override
412 - public Builder setLspaObjHeader(PcepObjectHeader obj) { 412 + public Builder setLspaObjHeader(PcepObjectHeader obj) {
413 - this.lspaObjHeader = obj; 413 + this.lspaObjHeader = obj;
414 - this.bIsHeaderSet = true; 414 + this.bIsHeaderSet = true;
415 - return this; 415 + return this;
416 - } 416 + }
417 - 417 +
418 - @Override 418 + @Override
419 - public boolean getLFlag() { 419 + public boolean getLFlag() {
420 - return this.bLFlag; 420 + return this.bLFlag;
421 - } 421 + }
422 - 422 +
423 - @Override 423 + @Override
424 - public Builder setLFlag(boolean value) { 424 + public Builder setLFlag(boolean value) {
425 - this.bLFlag = value; 425 + this.bLFlag = value;
426 - return this; 426 + return this;
427 - } 427 + }
428 - 428 +
429 - @Override 429 + @Override
430 - public int getExcludeAny() { 430 + public int getExcludeAny() {
431 - return this.iExcludeAny; 431 + return this.iExcludeAny;
432 - } 432 + }
433 - 433 +
434 - @Override 434 + @Override
435 - public Builder setExcludeAny(int value) { 435 + public Builder setExcludeAny(int value) {
436 - this.iExcludeAny = value; 436 + this.iExcludeAny = value;
437 - this.bIsExcludeAnySet = true; 437 + this.bIsExcludeAnySet = true;
438 - return this; 438 + return this;
439 - } 439 + }
440 - 440 +
441 - @Override 441 + @Override
442 - public int getIncludeAny() { 442 + public int getIncludeAny() {
443 - return this.iIncludeAny; 443 + return this.iIncludeAny;
444 - } 444 + }
445 - 445 +
446 - @Override 446 + @Override
447 - public Builder setIncludeAny(int value) { 447 + public Builder setIncludeAny(int value) {
448 - this.iIncludeAny = value; 448 + this.iIncludeAny = value;
449 - this.bIsIncludeAnySet = true; 449 + this.bIsIncludeAnySet = true;
450 - return this; 450 + return this;
451 - } 451 + }
452 - 452 +
453 - @Override 453 + @Override
454 - public int getIncludeAll() { 454 + public int getIncludeAll() {
455 - return this.iIncludeAll; 455 + return this.iIncludeAll;
456 - } 456 + }
457 - 457 +
458 - @Override 458 + @Override
459 - public Builder setIncludeAll(int value) { 459 + public Builder setIncludeAll(int value) {
460 - this.iIncludeAll = value; 460 + this.iIncludeAll = value;
461 - this.bIsIncludeAllSet = true; 461 + this.bIsIncludeAllSet = true;
462 - return this; 462 + return this;
463 - } 463 + }
464 - 464 +
465 - @Override 465 + @Override
466 - public byte getSetupPriority() { 466 + public byte getSetupPriority() {
467 - return this.cSetupPriority; 467 + return this.cSetupPriority;
468 - } 468 + }
469 - 469 +
470 - @Override 470 + @Override
471 - public Builder setSetupPriority(byte value) { 471 + public Builder setSetupPriority(byte value) {
472 - this.cSetupPriority = value; 472 + this.cSetupPriority = value;
473 - this.bIsSetupPrioritySet = true; 473 + this.bIsSetupPrioritySet = true;
474 - return this; 474 + return this;
475 - } 475 + }
476 - 476 +
477 - @Override 477 + @Override
478 - public byte getHoldPriority() { 478 + public byte getHoldPriority() {
479 - return this.cHoldPriority; 479 + return this.cHoldPriority;
480 - } 480 + }
481 - 481 +
482 - @Override 482 + @Override
483 - public Builder setHoldPriority(byte value) { 483 + public Builder setHoldPriority(byte value) {
484 - this.cHoldPriority = value; 484 + this.cHoldPriority = value;
485 - this.bIsHoldPrioritySet = true; 485 + this.bIsHoldPrioritySet = true;
486 - return this; 486 + return this;
487 - } 487 + }
488 - 488 +
489 - @Override 489 + @Override
490 - public LinkedList<PcepValueType> getOptionalTlv() { 490 + public LinkedList<PcepValueType> getOptionalTlv() {
491 - return this.llOptionalTlv; 491 + return this.llOptionalTlv;
492 - } 492 + }
493 - 493 +
494 - @Override 494 + @Override
495 - public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 495 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
496 - this.llOptionalTlv = llOptionalTlv; 496 + this.llOptionalTlv = llOptionalTlv;
497 - 497 +
498 - return this; 498 + return this;
499 - } 499 + }
500 - 500 +
501 - @Override 501 + @Override
502 - public Builder setPFlag(boolean value) { 502 + public Builder setPFlag(boolean value) {
503 - this.bPFlag = value; 503 + this.bPFlag = value;
504 - this.bIsPFlagSet = true; 504 + this.bIsPFlagSet = true;
505 - return this; 505 + return this;
506 - } 506 + }
507 - 507 +
508 - @Override 508 + @Override
509 - public Builder setIFlag(boolean value) { 509 + public Builder setIFlag(boolean value) {
510 - this.bIFlag = value; 510 + this.bIFlag = value;
511 - this.bIsIFlagSet = true; 511 + this.bIsIFlagSet = true;
512 - return this; 512 + return this;
513 - } 513 + }
514 - 514 +
515 - } 515 + }
516 - 516 +
517 - @Override 517 + @Override
518 - public String toString() { 518 + public String toString() {
519 - return MoreObjects.toStringHelper(getClass()).add("LFlag", bLFlag).add("SetupPriority", cSetupPriority) 519 + return MoreObjects.toStringHelper(getClass()).add("LFlag", bLFlag).add("SetupPriority", cSetupPriority)
520 - .add("HoldPriority", cHoldPriority).add("IncludeAll", iIncludeAll).add("IncludeAny", iIncludeAny) 520 + .add("HoldPriority", cHoldPriority).add("IncludeAll", iIncludeAll).add("IncludeAny", iIncludeAny)
521 - .add("ExcludeAny", iExcludeAny).add("OptionalTlvList", llOptionalTlv).toString(); 521 + .add("ExcludeAny", iExcludeAny).add("OptionalTlvList", llOptionalTlv).toString();
522 - } 522 + }
523 -} 523 +}
......
1 -package org.onosproject.pcepio.protocol.ver1; 1 +package org.onosproject.pcepio.protocol.ver1;
2 - 2 +
3 -import org.jboss.netty.buffer.ChannelBuffer; 3 +import org.jboss.netty.buffer.ChannelBuffer;
4 -import org.onosproject.pcepio.exceptions.PcepParseException; 4 +import org.onosproject.pcepio.exceptions.PcepParseException;
5 -import org.onosproject.pcepio.protocol.PcepAttribute; 5 +import org.onosproject.pcepio.protocol.PcepAttribute;
6 -import org.onosproject.pcepio.protocol.PcepEroObject; 6 +import org.onosproject.pcepio.protocol.PcepEroObject;
7 -import org.onosproject.pcepio.protocol.PcepMsgPath; 7 +import org.onosproject.pcepio.protocol.PcepMsgPath;
8 -import org.slf4j.Logger; 8 +import org.slf4j.Logger;
9 -import org.slf4j.LoggerFactory; 9 +import org.slf4j.LoggerFactory;
10 - 10 +
11 -import com.google.common.base.MoreObjects; 11 +import com.google.common.base.MoreObjects;
12 - 12 +
13 -/** 13 +/**
14 - * Provides PCEP Message PAth for update message. 14 + * Provides PCEP Message PAth for update message.
15 - * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10. 15 + * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
16 - */ 16 + */
17 -public class PcepMsgPathVer1 implements PcepMsgPath { 17 +public class PcepMsgPathVer1 implements PcepMsgPath {
18 - 18 +
19 - /* 19 + /*
20 - * <path> ::= <ERO><attribute-list> 20 + * <path> ::= <ERO><attribute-list>
21 - */ 21 + */
22 - 22 +
23 - protected static final Logger log = LoggerFactory.getLogger(PcepMsgPathVer1.class); 23 + protected static final Logger log = LoggerFactory.getLogger(PcepMsgPathVer1.class);
24 - //PcepEroObject 24 + //PcepEroObject
25 - private PcepEroObject eroObj; 25 + private PcepEroObject eroObj;
26 - private boolean isEroObjectSet; 26 + private boolean isEroObjectSet;
27 - // PcepAttribute 27 + // PcepAttribute
28 - private PcepAttribute attrList; 28 + private PcepAttribute attrList;
29 - private boolean isAttributeListSet; 29 + private boolean isAttributeListSet;
30 - 30 +
31 - /** 31 + /**
32 - * constructor to initialize objects. 32 + * constructor to initialize objects.
33 - */ 33 + */
34 - public PcepMsgPathVer1() { 34 + public PcepMsgPathVer1() {
35 - eroObj = null; 35 + eroObj = null;
36 - attrList = null; 36 + attrList = null;
37 - isEroObjectSet = false; 37 + isEroObjectSet = false;
38 - isAttributeListSet = false; 38 + isAttributeListSet = false;
39 - } 39 + }
40 - 40 +
41 - @Override 41 + @Override
42 - public PcepEroObject getEroObject() { 42 + public PcepEroObject getEroObject() {
43 - return eroObj; 43 + return eroObj;
44 - } 44 + }
45 - 45 +
46 - @Override 46 + @Override
47 - public PcepAttribute getPcepAttribute() { 47 + public PcepAttribute getPcepAttribute() {
48 - return attrList; 48 + return attrList;
49 - } 49 + }
50 - 50 +
51 - @Override 51 + @Override
52 - public void setEroObject(PcepEroObject eroObj) { 52 + public void setEroObject(PcepEroObject eroObj) {
53 - this.eroObj = eroObj; 53 + this.eroObj = eroObj;
54 - } 54 + }
55 - 55 +
56 - @Override 56 + @Override
57 - public void setPcepAttribute(PcepAttribute attrList) { 57 + public void setPcepAttribute(PcepAttribute attrList) {
58 - this.attrList = attrList; 58 + this.attrList = attrList;
59 - } 59 + }
60 - 60 +
61 - /** 61 + /**
62 - * constructor to initialize member variables. 62 + * constructor to initialize member variables.
63 - * 63 + *
64 - * @param eroObj pcep ero object 64 + * @param eroObj pcep ero object
65 - * @param attrList pcep attribute 65 + * @param attrList pcep attribute
66 - */ 66 + */
67 - public PcepMsgPathVer1(PcepEroObject eroObj, PcepAttribute attrList) { 67 + public PcepMsgPathVer1(PcepEroObject eroObj, PcepAttribute attrList) {
68 - this.eroObj = eroObj; 68 + this.eroObj = eroObj;
69 - isEroObjectSet = true; 69 + isEroObjectSet = true;
70 - this.attrList = attrList; 70 + this.attrList = attrList;
71 - if (attrList == null) { 71 + if (attrList == null) {
72 - isAttributeListSet = false; 72 + isAttributeListSet = false;
73 - } else { 73 + } else {
74 - isAttributeListSet = true; 74 + isAttributeListSet = true;
75 - } 75 + }
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public PcepMsgPath read(ChannelBuffer cb) throws PcepParseException { 79 + public PcepMsgPath read(ChannelBuffer cb) throws PcepParseException {
80 - PcepEroObject eroObj; 80 + PcepEroObject eroObj;
81 - PcepAttribute attrList; 81 + PcepAttribute attrList;
82 - 82 +
83 - eroObj = PcepEroObjectVer1.read(cb); 83 + eroObj = PcepEroObjectVer1.read(cb);
84 - attrList = PcepAttributeVer1.read(cb); 84 + attrList = PcepAttributeVer1.read(cb);
85 - 85 +
86 - return new PcepMsgPathVer1(eroObj, attrList); 86 + return new PcepMsgPathVer1(eroObj, attrList);
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public int write(ChannelBuffer cb) throws PcepParseException { 90 + public int write(ChannelBuffer cb) throws PcepParseException {
91 - int iLenStartIndex = cb.writerIndex(); 91 + int iLenStartIndex = cb.writerIndex();
92 - 92 +
93 - //write Object header 93 + //write Object header
94 - if (this.isEroObjectSet) { 94 + if (this.isEroObjectSet) {
95 - this.eroObj.write(cb); 95 + this.eroObj.write(cb);
96 - } 96 + }
97 - if (this.isAttributeListSet) { 97 + if (this.isAttributeListSet) {
98 - attrList.write(cb); 98 + attrList.write(cb);
99 - } 99 + }
100 - 100 +
101 - return cb.writerIndex() - iLenStartIndex; 101 + return cb.writerIndex() - iLenStartIndex;
102 - } 102 + }
103 - 103 +
104 - /** 104 + /**
105 - * Builder class for PCEP Message path. 105 + * Builder class for PCEP Message path.
106 - */ 106 + */
107 - public static class Builder implements PcepMsgPath.Builder { 107 + public static class Builder implements PcepMsgPath.Builder {
108 - 108 +
109 - private boolean bIsEROObjectSet = false; 109 + private boolean bIsEROObjectSet = false;
110 - private boolean bIsPcepAttributeSet = false; 110 + private boolean bIsPcepAttributeSet = false;
111 - 111 +
112 - //PCEP ERO Object 112 + //PCEP ERO Object
113 - private PcepEroObject eroObject; 113 + private PcepEroObject eroObject;
114 - //PCEP Attribute list 114 + //PCEP Attribute list
115 - private PcepAttribute pcepAttribute; 115 + private PcepAttribute pcepAttribute;
116 - 116 +
117 - @Override 117 + @Override
118 - public PcepMsgPath build() throws PcepParseException { 118 + public PcepMsgPath build() throws PcepParseException {
119 - 119 +
120 - //PCEP ERO Object 120 + //PCEP ERO Object
121 - PcepEroObject eroObject = null; 121 + PcepEroObject eroObject = null;
122 - //PCEP Attribute list 122 + //PCEP Attribute list
123 - PcepAttribute pcepAttribute = null; 123 + PcepAttribute pcepAttribute = null;
124 - 124 +
125 - if (!this.bIsEROObjectSet) { 125 + if (!this.bIsEROObjectSet) {
126 - throw new PcepParseException("ERO Object NOT Set while building PcepMsgPath."); 126 + throw new PcepParseException("ERO Object NOT Set while building PcepMsgPath.");
127 - } else { 127 + } else {
128 - eroObject = this.eroObject; 128 + eroObject = this.eroObject;
129 - } 129 + }
130 - if (!this.bIsPcepAttributeSet) { 130 + if (!this.bIsPcepAttributeSet) {
131 - throw new PcepParseException("Pcep Attributes NOT Set while building PcepMsgPath."); 131 + throw new PcepParseException("Pcep Attributes NOT Set while building PcepMsgPath.");
132 - } else { 132 + } else {
133 - pcepAttribute = this.pcepAttribute; 133 + pcepAttribute = this.pcepAttribute;
134 - } 134 + }
135 - 135 +
136 - return new PcepMsgPathVer1(eroObject, pcepAttribute); 136 + return new PcepMsgPathVer1(eroObject, pcepAttribute);
137 - } 137 + }
138 - 138 +
139 - @Override 139 + @Override
140 - public PcepEroObject getEroObject() { 140 + public PcepEroObject getEroObject() {
141 - return this.eroObject; 141 + return this.eroObject;
142 - } 142 + }
143 - 143 +
144 - @Override 144 + @Override
145 - public PcepAttribute getPcepAttribute() { 145 + public PcepAttribute getPcepAttribute() {
146 - return this.pcepAttribute; 146 + return this.pcepAttribute;
147 - } 147 + }
148 - 148 +
149 - @Override 149 + @Override
150 - public Builder setEroObject(PcepEroObject eroObject) { 150 + public Builder setEroObject(PcepEroObject eroObject) {
151 - this.eroObject = eroObject; 151 + this.eroObject = eroObject;
152 - this.bIsEROObjectSet = true; 152 + this.bIsEROObjectSet = true;
153 - return this; 153 + return this;
154 - } 154 + }
155 - 155 +
156 - @Override 156 + @Override
157 - public Builder setPcepAttribute(PcepAttribute pcepAttribute) { 157 + public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
158 - this.pcepAttribute = pcepAttribute; 158 + this.pcepAttribute = pcepAttribute;
159 - this.bIsPcepAttributeSet = true; 159 + this.bIsPcepAttributeSet = true;
160 - return this; 160 + return this;
161 - } 161 + }
162 - 162 +
163 - } 163 + }
164 - 164 +
165 - @Override 165 + @Override
166 - public String toString() { 166 + public String toString() {
167 - return MoreObjects.toStringHelper(getClass()).add("EroObject", eroObj).add("AttributeList", attrList) 167 + return MoreObjects.toStringHelper(getClass()).add("EroObject", eroObj).add("AttributeList", attrList)
168 - .toString(); 168 + .toString();
169 - } 169 + }
170 } 170 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.protocol.ver1; 16 +package org.onosproject.pcepio.protocol.ver1;
17 - 17 +
18 -import java.util.LinkedList; 18 +import java.util.LinkedList;
19 -import java.util.ListIterator; 19 +import java.util.ListIterator;
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.exceptions.PcepParseException;
23 -import org.onosproject.pcepio.protocol.PcepRPObject; 23 +import org.onosproject.pcepio.protocol.PcepRPObject;
24 -import org.onosproject.pcepio.types.PcepObjectHeader; 24 +import org.onosproject.pcepio.types.PcepObjectHeader;
25 -import org.onosproject.pcepio.types.PcepValueType; 25 +import org.onosproject.pcepio.types.PcepValueType;
26 -import org.slf4j.Logger; 26 +import org.slf4j.Logger;
27 -import org.slf4j.LoggerFactory; 27 +import org.slf4j.LoggerFactory;
28 - 28 +
29 -import com.google.common.base.MoreObjects; 29 +import com.google.common.base.MoreObjects;
30 - 30 +
31 -/** 31 +/**
32 - * Provides PCEP RP object. 32 + * Provides PCEP RP object.
33 - */ 33 + */
34 -public class PcepRPObjectVer1 implements PcepRPObject { 34 +public class PcepRPObjectVer1 implements PcepRPObject {
35 - 35 +
36 - /* 36 + /*
37 - * RP Object. 37 + * RP Object.
38 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Flags |O|B|R| Pri | 41 + | Flags |O|B|R| Pri |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | Request-ID-number | 43 + | Request-ID-number |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | | 45 + | |
46 - // Optional TLVs // 46 + // Optional TLVs //
47 - | | 47 + | |
48 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 - */ 49 + */
50 - 50 +
51 - protected static final Logger log = LoggerFactory.getLogger(PcepRPObjectVer1.class); 51 + protected static final Logger log = LoggerFactory.getLogger(PcepRPObjectVer1.class);
52 - 52 +
53 - public static final byte RP_OBJ_TYPE = 1; 53 + public static final byte RP_OBJ_TYPE = 1;
54 - public static final byte RP_OBJ_CLASS = 2; 54 + public static final byte RP_OBJ_CLASS = 2;
55 - public static final byte RP_OBJECT_VERSION = 1; 55 + public static final byte RP_OBJECT_VERSION = 1;
56 - public static final short RP_OBJ_MINIMUM_LENGTH = 12; 56 + public static final short RP_OBJ_MINIMUM_LENGTH = 12;
57 - 57 +
58 - public static final int DEFAULT_REQUEST_ID_NUM = 0; 58 + public static final int DEFAULT_REQUEST_ID_NUM = 0;
59 - //Signalled , all default values to be checked. 59 + //Signalled , all default values to be checked.
60 - public static final boolean DEFAULT_OFLAG = false; 60 + public static final boolean DEFAULT_OFLAG = false;
61 - public static final boolean DEFAULT_BFLAG = false; 61 + public static final boolean DEFAULT_BFLAG = false;
62 - public static final boolean DEFAULT_RFLAG = false; 62 + public static final boolean DEFAULT_RFLAG = false;
63 - public static final byte DEFAULT_PRIFLAG = 0; 63 + public static final byte DEFAULT_PRIFLAG = 0;
64 - public static final int OBJECT_HEADER_LENGTH = 4; 64 + public static final int OBJECT_HEADER_LENGTH = 4;
65 - public static final int OFLAG_SHIFT_VALUE = 5; 65 + public static final int OFLAG_SHIFT_VALUE = 5;
66 - public static final int BFLAG_SHIFT_VALUE = 4; 66 + public static final int BFLAG_SHIFT_VALUE = 4;
67 - public static final int RFLAG_SHIFT_VALUE = 3; 67 + public static final int RFLAG_SHIFT_VALUE = 3;
68 - public static final int OFLAG_TEMP_SHIFT_VALUE = 0x20; 68 + public static final int OFLAG_TEMP_SHIFT_VALUE = 0x20;
69 - public static final int BFLAG_TEMP_SHIFT_VALUE = 0x10; 69 + public static final int BFLAG_TEMP_SHIFT_VALUE = 0x10;
70 - public static final int RFLAG_TEMP_SHIFT_VALUE = 0x08; 70 + public static final int RFLAG_TEMP_SHIFT_VALUE = 0x08;
71 - public static final int PRIFLAG_TEMP_SHIFT_VALUE = 0x07; 71 + public static final int PRIFLAG_TEMP_SHIFT_VALUE = 0x07;
72 - public static final int BIT_SET = 1; 72 + public static final int BIT_SET = 1;
73 - public static final int BIT_RESET = 0; 73 + public static final int BIT_RESET = 0;
74 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 74 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
75 - 75 +
76 - public static final PcepObjectHeader DEFAULT_RP_OBJECT_HEADER = new PcepObjectHeader(RP_OBJ_CLASS, RP_OBJ_TYPE, 76 + public static final PcepObjectHeader DEFAULT_RP_OBJECT_HEADER = new PcepObjectHeader(RP_OBJ_CLASS, RP_OBJ_TYPE,
77 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RP_OBJ_MINIMUM_LENGTH); 77 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RP_OBJ_MINIMUM_LENGTH);
78 - 78 +
79 - private PcepObjectHeader rpObjHeader; 79 + private PcepObjectHeader rpObjHeader;
80 - private int iRequestIdNum; 80 + private int iRequestIdNum;
81 - private boolean bOFlag; 81 + private boolean bOFlag;
82 - private boolean bBFlag; 82 + private boolean bBFlag;
83 - private boolean bRFlag; 83 + private boolean bRFlag;
84 - private byte yPriFlag; // 3bytes 84 + private byte yPriFlag; // 3bytes
85 - private LinkedList<PcepValueType> llOptionalTlv; 85 + private LinkedList<PcepValueType> llOptionalTlv;
86 - 86 +
87 - /** 87 + /**
88 - * Constructor to initialize variables. 88 + * Constructor to initialize variables.
89 - * 89 + *
90 - * @param rpObjHeader RP-OBJECT header 90 + * @param rpObjHeader RP-OBJECT header
91 - * @param iRequestIdNum Request-ID-number 91 + * @param iRequestIdNum Request-ID-number
92 - * @param bOFlag O-flag 92 + * @param bOFlag O-flag
93 - * @param bBFlag B-flag 93 + * @param bBFlag B-flag
94 - * @param bRFlag R-flag 94 + * @param bRFlag R-flag
95 - * @param yPriFlag Pri-flag 95 + * @param yPriFlag Pri-flag
96 - * @param llOptionalTlv linked list of Optional TLV 96 + * @param llOptionalTlv linked list of Optional TLV
97 - */ 97 + */
98 - public PcepRPObjectVer1(PcepObjectHeader rpObjHeader, int iRequestIdNum, boolean bOFlag, boolean bBFlag, 98 + public PcepRPObjectVer1(PcepObjectHeader rpObjHeader, int iRequestIdNum, boolean bOFlag, boolean bBFlag,
99 - boolean bRFlag, byte yPriFlag, LinkedList<PcepValueType> llOptionalTlv) { 99 + boolean bRFlag, byte yPriFlag, LinkedList<PcepValueType> llOptionalTlv) {
100 - this.rpObjHeader = rpObjHeader; 100 + this.rpObjHeader = rpObjHeader;
101 - this.iRequestIdNum = iRequestIdNum; 101 + this.iRequestIdNum = iRequestIdNum;
102 - this.bOFlag = bOFlag; 102 + this.bOFlag = bOFlag;
103 - this.bBFlag = bBFlag; 103 + this.bBFlag = bBFlag;
104 - this.bRFlag = bRFlag; 104 + this.bRFlag = bRFlag;
105 - this.yPriFlag = yPriFlag; 105 + this.yPriFlag = yPriFlag;
106 - this.llOptionalTlv = llOptionalTlv; 106 + this.llOptionalTlv = llOptionalTlv;
107 - } 107 + }
108 - 108 +
109 - /** 109 + /**
110 - * Sets RP Object header. 110 + * Sets RP Object header.
111 - * 111 + *
112 - * @param obj RP Object header 112 + * @param obj RP Object header
113 - */ 113 + */
114 - public void setRPObjHeader(PcepObjectHeader obj) { 114 + public void setRPObjHeader(PcepObjectHeader obj) {
115 - this.rpObjHeader = obj; 115 + this.rpObjHeader = obj;
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public void setRequestIdNum(int iRequestIdNum) { 119 + public void setRequestIdNum(int iRequestIdNum) {
120 - this.iRequestIdNum = iRequestIdNum; 120 + this.iRequestIdNum = iRequestIdNum;
121 - } 121 + }
122 - 122 +
123 - @Override 123 + @Override
124 - public void setOFlag(boolean bOFlag) { 124 + public void setOFlag(boolean bOFlag) {
125 - this.bOFlag = bOFlag; 125 + this.bOFlag = bOFlag;
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public void setBFlag(boolean bBFlag) { 129 + public void setBFlag(boolean bBFlag) {
130 - this.bBFlag = bBFlag; 130 + this.bBFlag = bBFlag;
131 - } 131 + }
132 - 132 +
133 - @Override 133 + @Override
134 - public void setRFlag(boolean bRFlag) { 134 + public void setRFlag(boolean bRFlag) {
135 - this.bRFlag = bRFlag; 135 + this.bRFlag = bRFlag;
136 - } 136 + }
137 - 137 +
138 - @Override 138 + @Override
139 - public void setPriFlag(byte yPriFlag) { 139 + public void setPriFlag(byte yPriFlag) {
140 - this.yPriFlag = yPriFlag; 140 + this.yPriFlag = yPriFlag;
141 - } 141 + }
142 - 142 +
143 - /** 143 + /**
144 - * Returns RP Object header. 144 + * Returns RP Object header.
145 - * 145 + *
146 - * @return rpObjHeader 146 + * @return rpObjHeader
147 - */ 147 + */
148 - public PcepObjectHeader getRPObjHeader() { 148 + public PcepObjectHeader getRPObjHeader() {
149 - return this.rpObjHeader; 149 + return this.rpObjHeader;
150 - } 150 + }
151 - 151 +
152 - @Override 152 + @Override
153 - public int getRequestIdNum() { 153 + public int getRequestIdNum() {
154 - return this.iRequestIdNum; 154 + return this.iRequestIdNum;
155 - } 155 + }
156 - 156 +
157 - @Override 157 + @Override
158 - public boolean getOFlag() { 158 + public boolean getOFlag() {
159 - return this.bOFlag; 159 + return this.bOFlag;
160 - } 160 + }
161 - 161 +
162 - @Override 162 + @Override
163 - public boolean getBFlag() { 163 + public boolean getBFlag() {
164 - return this.bBFlag; 164 + return this.bBFlag;
165 - } 165 + }
166 - 166 +
167 - @Override 167 + @Override
168 - public boolean getRFlag() { 168 + public boolean getRFlag() {
169 - return this.bRFlag; 169 + return this.bRFlag;
170 - } 170 + }
171 - 171 +
172 - @Override 172 + @Override
173 - public byte getPriFlag() { 173 + public byte getPriFlag() {
174 - return this.yPriFlag; 174 + return this.yPriFlag;
175 - } 175 + }
176 - 176 +
177 - /** 177 + /**
178 - * Reads the channel buffer and returns the object of PcepRPObject. 178 + * Reads the channel buffer and returns the object of PcepRPObject.
179 - * 179 + *
180 - * @param cb of type channel buffer 180 + * @param cb of type channel buffer
181 - * @return the object of PcepRPObject 181 + * @return the object of PcepRPObject
182 - * @throws PcepParseException if mandatory fields are missing 182 + * @throws PcepParseException if mandatory fields are missing
183 - */ 183 + */
184 - public static PcepRPObject read(ChannelBuffer cb) throws PcepParseException { 184 + public static PcepRPObject read(ChannelBuffer cb) throws PcepParseException {
185 - log.debug("read"); 185 + log.debug("read");
186 - PcepObjectHeader rpObjHeader; 186 + PcepObjectHeader rpObjHeader;
187 - int iRequestIdNum; 187 + int iRequestIdNum;
188 - boolean bOFlag; 188 + boolean bOFlag;
189 - boolean bBFlag; 189 + boolean bBFlag;
190 - boolean bRFlag; 190 + boolean bRFlag;
191 - byte yPriFlag; // 3bytes 191 + byte yPriFlag; // 3bytes
192 - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 192 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
193 - 193 +
194 - rpObjHeader = PcepObjectHeader.read(cb); 194 + rpObjHeader = PcepObjectHeader.read(cb);
195 - 195 +
196 - //take only LspObject buffer. 196 + //take only LspObject buffer.
197 - ChannelBuffer tempCb = cb.readBytes(rpObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); 197 + ChannelBuffer tempCb = cb.readBytes(rpObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
198 - 198 +
199 - int iTemp = tempCb.readInt(); 199 + int iTemp = tempCb.readInt();
200 - yPriFlag = (byte) (iTemp & PRIFLAG_TEMP_SHIFT_VALUE); 200 + yPriFlag = (byte) (iTemp & PRIFLAG_TEMP_SHIFT_VALUE);
201 - bOFlag = (iTemp & OFLAG_TEMP_SHIFT_VALUE) == OFLAG_TEMP_SHIFT_VALUE ? true : false; 201 + bOFlag = (iTemp & OFLAG_TEMP_SHIFT_VALUE) == OFLAG_TEMP_SHIFT_VALUE ? true : false;
202 - bBFlag = (iTemp & BFLAG_TEMP_SHIFT_VALUE) == BFLAG_TEMP_SHIFT_VALUE ? true : false; 202 + bBFlag = (iTemp & BFLAG_TEMP_SHIFT_VALUE) == BFLAG_TEMP_SHIFT_VALUE ? true : false;
203 - bRFlag = (iTemp & RFLAG_TEMP_SHIFT_VALUE) == RFLAG_TEMP_SHIFT_VALUE ? true : false; 203 + bRFlag = (iTemp & RFLAG_TEMP_SHIFT_VALUE) == RFLAG_TEMP_SHIFT_VALUE ? true : false;
204 - 204 +
205 - iRequestIdNum = tempCb.readInt(); 205 + iRequestIdNum = tempCb.readInt();
206 - 206 +
207 - // parse optional TLV 207 + // parse optional TLV
208 - llOptionalTlv = parseOptionalTlv(tempCb); 208 + llOptionalTlv = parseOptionalTlv(tempCb);
209 - 209 +
210 - return new PcepRPObjectVer1(rpObjHeader, iRequestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv); 210 + return new PcepRPObjectVer1(rpObjHeader, iRequestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv);
211 - } 211 + }
212 - 212 +
213 - @Override 213 + @Override
214 - public int write(ChannelBuffer cb) throws PcepParseException { 214 + public int write(ChannelBuffer cb) throws PcepParseException {
215 - 215 +
216 - //write Object header 216 + //write Object header
217 - int objStartIndex = cb.writerIndex(); 217 + int objStartIndex = cb.writerIndex();
218 - 218 +
219 - int objLenIndex = rpObjHeader.write(cb); 219 + int objLenIndex = rpObjHeader.write(cb);
220 - 220 +
221 - if (objLenIndex <= 0) { 221 + if (objLenIndex <= 0) {
222 - throw new PcepParseException("ObjectLength Index is " + objLenIndex); 222 + throw new PcepParseException("ObjectLength Index is " + objLenIndex);
223 - } 223 + }
224 - int iTemp; 224 + int iTemp;
225 - iTemp = (yPriFlag); 225 + iTemp = (yPriFlag);
226 - 226 +
227 - iTemp = (bOFlag) ? (iTemp | OFLAG_SHIFT_VALUE) : iTemp; 227 + iTemp = (bOFlag) ? (iTemp | OFLAG_SHIFT_VALUE) : iTemp;
228 - iTemp = (bBFlag) ? (iTemp | BFLAG_SHIFT_VALUE) : iTemp; 228 + iTemp = (bBFlag) ? (iTemp | BFLAG_SHIFT_VALUE) : iTemp;
229 - iTemp = (bRFlag) ? (iTemp | RFLAG_SHIFT_VALUE) : iTemp; 229 + iTemp = (bRFlag) ? (iTemp | RFLAG_SHIFT_VALUE) : iTemp;
230 - 230 +
231 - cb.writeInt(iTemp); 231 + cb.writeInt(iTemp);
232 - cb.writeInt(iRequestIdNum); 232 + cb.writeInt(iRequestIdNum);
233 - 233 +
234 - // Add optional TLV 234 + // Add optional TLV
235 - packOptionalTlv(cb); 235 + packOptionalTlv(cb);
236 - 236 +
237 - //Update object length now 237 + //Update object length now
238 - int length = cb.writerIndex() - objStartIndex; 238 + int length = cb.writerIndex() - objStartIndex;
239 - 239 +
240 - //will be helpful during print(). 240 + //will be helpful during print().
241 - rpObjHeader.setObjLen((short) length); 241 + rpObjHeader.setObjLen((short) length);
242 - 242 +
243 - cb.setShort(objLenIndex, (short) length); 243 + cb.setShort(objLenIndex, (short) length);
244 - return cb.writerIndex(); 244 + return cb.writerIndex();
245 - } 245 + }
246 - 246 +
247 - /** 247 + /**
248 - * Returns list of optional tlvs. 248 + * Returns list of optional tlvs.
249 - * 249 + *
250 - * @param cb of type channel buffer. 250 + * @param cb of type channel buffer.
251 - * @return llOutOptionalTlv linked list of Optional TLV 251 + * @return llOutOptionalTlv linked list of Optional TLV
252 - * @throws PcepParseException if mandatory fields are missing 252 + * @throws PcepParseException if mandatory fields are missing
253 - */ 253 + */
254 - protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { 254 + protected static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
255 - 255 +
256 - LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>(); 256 + LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
257 - //Currently no optional TLvs, will be added based on requirements. 257 + //Currently no optional TLvs, will be added based on requirements.
258 - return llOutOptionalTlv; 258 + return llOutOptionalTlv;
259 - } 259 + }
260 - 260 +
261 - /** 261 + /**
262 - * Returns optional tlvs. 262 + * Returns optional tlvs.
263 - * 263 + *
264 - * @param cb of type channel buffer 264 + * @param cb of type channel buffer
265 - * @return llOptionalTlv linked list of Optional TLV 265 + * @return llOptionalTlv linked list of Optional TLV
266 - */ 266 + */
267 - protected int packOptionalTlv(ChannelBuffer cb) { 267 + protected int packOptionalTlv(ChannelBuffer cb) {
268 - 268 +
269 - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); 269 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
270 - while (listIterator.hasNext()) { 270 + while (listIterator.hasNext()) {
271 - listIterator.next().write(cb); 271 + listIterator.next().write(cb);
272 - } 272 + }
273 - 273 +
274 - return cb.writerIndex(); 274 + return cb.writerIndex();
275 - } 275 + }
276 - 276 +
277 - /** 277 + /**
278 - * Builder class for PCEP rp object. 278 + * Builder class for PCEP rp object.
279 - */ 279 + */
280 - public static class Builder implements PcepRPObject.Builder { 280 + public static class Builder implements PcepRPObject.Builder {
281 - 281 +
282 - private boolean bIsHeaderSet = false; 282 + private boolean bIsHeaderSet = false;
283 - private boolean bIsRequestIdNumSet = false; 283 + private boolean bIsRequestIdNumSet = false;
284 - private boolean bIsOFlagSet = false; 284 + private boolean bIsOFlagSet = false;
285 - private boolean bIsRFlagset = false; 285 + private boolean bIsRFlagset = false;
286 - private boolean bIsBFlagSet = false; 286 + private boolean bIsBFlagSet = false;
287 - private boolean bIsPriFlagSet = false; 287 + private boolean bIsPriFlagSet = false;
288 - 288 +
289 - private PcepObjectHeader rpObjHeader; 289 + private PcepObjectHeader rpObjHeader;
290 - private int requestIdNum; 290 + private int requestIdNum;
291 - private boolean bOFlag; 291 + private boolean bOFlag;
292 - private boolean bBFlag; 292 + private boolean bBFlag;
293 - private boolean bRFlag; 293 + private boolean bRFlag;
294 - private byte yPriFlag; 294 + private byte yPriFlag;
295 - private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 295 + private LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
296 - 296 +
297 - private boolean bIsPFlagSet = false; 297 + private boolean bIsPFlagSet = false;
298 - private boolean bPFlag; 298 + private boolean bPFlag;
299 - 299 +
300 - private boolean bIsIFlagSet = false; 300 + private boolean bIsIFlagSet = false;
301 - private boolean bIFlag; 301 + private boolean bIFlag;
302 - 302 +
303 - @Override 303 + @Override
304 - public PcepRPObject build() { 304 + public PcepRPObject build() {
305 - PcepObjectHeader lspObjHeader = this.bIsHeaderSet ? this.rpObjHeader : DEFAULT_RP_OBJECT_HEADER; 305 + PcepObjectHeader lspObjHeader = this.bIsHeaderSet ? this.rpObjHeader : DEFAULT_RP_OBJECT_HEADER;
306 - 306 +
307 - int requestIdNum = this.bIsRequestIdNumSet ? this.requestIdNum : DEFAULT_REQUEST_ID_NUM; 307 + int requestIdNum = this.bIsRequestIdNumSet ? this.requestIdNum : DEFAULT_REQUEST_ID_NUM;
308 - boolean bOFlag = this.bIsOFlagSet ? this.bOFlag : DEFAULT_OFLAG; 308 + boolean bOFlag = this.bIsOFlagSet ? this.bOFlag : DEFAULT_OFLAG;
309 - boolean bBFlag = this.bIsBFlagSet ? this.bBFlag : DEFAULT_BFLAG; 309 + boolean bBFlag = this.bIsBFlagSet ? this.bBFlag : DEFAULT_BFLAG;
310 - boolean bRFlag = this.bIsRFlagset ? this.bRFlag : DEFAULT_RFLAG; 310 + boolean bRFlag = this.bIsRFlagset ? this.bRFlag : DEFAULT_RFLAG;
311 - byte yPriFlag = this.bIsPriFlagSet ? this.yPriFlag : DEFAULT_PRIFLAG; 311 + byte yPriFlag = this.bIsPriFlagSet ? this.yPriFlag : DEFAULT_PRIFLAG;
312 - 312 +
313 - if (bIsPFlagSet) { 313 + if (bIsPFlagSet) {
314 - lspObjHeader.setPFlag(bPFlag); 314 + lspObjHeader.setPFlag(bPFlag);
315 - } 315 + }
316 - 316 +
317 - if (bIsIFlagSet) { 317 + if (bIsIFlagSet) {
318 - lspObjHeader.setIFlag(bIFlag); 318 + lspObjHeader.setIFlag(bIFlag);
319 - } 319 + }
320 - 320 +
321 - return new PcepRPObjectVer1(lspObjHeader, requestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv); 321 + return new PcepRPObjectVer1(lspObjHeader, requestIdNum, bOFlag, bBFlag, bRFlag, yPriFlag, llOptionalTlv);
322 - } 322 + }
323 - 323 +
324 - @Override 324 + @Override
325 - public PcepObjectHeader getRPObjHeader() { 325 + public PcepObjectHeader getRPObjHeader() {
326 - return this.rpObjHeader; 326 + return this.rpObjHeader;
327 - } 327 + }
328 - 328 +
329 - @Override 329 + @Override
330 - public Builder setRPObjHeader(PcepObjectHeader obj) { 330 + public Builder setRPObjHeader(PcepObjectHeader obj) {
331 - this.rpObjHeader = obj; 331 + this.rpObjHeader = obj;
332 - this.bIsHeaderSet = true; 332 + this.bIsHeaderSet = true;
333 - return this; 333 + return this;
334 - } 334 + }
335 - 335 +
336 - @Override 336 + @Override
337 - public int getRequestIdNum() { 337 + public int getRequestIdNum() {
338 - return this.requestIdNum; 338 + return this.requestIdNum;
339 - } 339 + }
340 - 340 +
341 - @Override 341 + @Override
342 - public Builder setRequestIdNum(int value) { 342 + public Builder setRequestIdNum(int value) {
343 - this.requestIdNum = value; 343 + this.requestIdNum = value;
344 - this.bIsRequestIdNumSet = true; 344 + this.bIsRequestIdNumSet = true;
345 - return this; 345 + return this;
346 - } 346 + }
347 - 347 +
348 - @Override 348 + @Override
349 - public Builder setOFlag(boolean value) { 349 + public Builder setOFlag(boolean value) {
350 - this.bOFlag = value; 350 + this.bOFlag = value;
351 - this.bIsOFlagSet = true; 351 + this.bIsOFlagSet = true;
352 - return this; 352 + return this;
353 - } 353 + }
354 - 354 +
355 - @Override 355 + @Override
356 - public boolean getBFlag() { 356 + public boolean getBFlag() {
357 - return this.bBFlag; 357 + return this.bBFlag;
358 - } 358 + }
359 - 359 +
360 - @Override 360 + @Override
361 - public Builder setBFlag(boolean value) { 361 + public Builder setBFlag(boolean value) {
362 - this.bBFlag = value; 362 + this.bBFlag = value;
363 - this.bIsBFlagSet = true; 363 + this.bIsBFlagSet = true;
364 - return this; 364 + return this;
365 - } 365 + }
366 - 366 +
367 - @Override 367 + @Override
368 - public boolean getRFlag() { 368 + public boolean getRFlag() {
369 - return this.bRFlag; 369 + return this.bRFlag;
370 - } 370 + }
371 - 371 +
372 - @Override 372 + @Override
373 - public Builder setRFlag(boolean value) { 373 + public Builder setRFlag(boolean value) {
374 - this.bRFlag = value; 374 + this.bRFlag = value;
375 - this.bIsRFlagset = true; 375 + this.bIsRFlagset = true;
376 - return this; 376 + return this;
377 - } 377 + }
378 - 378 +
379 - @Override 379 + @Override
380 - public byte getPriFlag() { 380 + public byte getPriFlag() {
381 - return this.yPriFlag; 381 + return this.yPriFlag;
382 - } 382 + }
383 - 383 +
384 - @Override 384 + @Override
385 - public Builder setPriFlag(byte value) { 385 + public Builder setPriFlag(byte value) {
386 - this.yPriFlag = value; 386 + this.yPriFlag = value;
387 - this.bIsPriFlagSet = true; 387 + this.bIsPriFlagSet = true;
388 - return this; 388 + return this;
389 - } 389 + }
390 - 390 +
391 - @Override 391 + @Override
392 - public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 392 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
393 - this.llOptionalTlv = llOptionalTlv; 393 + this.llOptionalTlv = llOptionalTlv;
394 - return this; 394 + return this;
395 - } 395 + }
396 - 396 +
397 - @Override 397 + @Override
398 - public LinkedList<PcepValueType> getOptionalTlv() { 398 + public LinkedList<PcepValueType> getOptionalTlv() {
399 - return this.llOptionalTlv; 399 + return this.llOptionalTlv;
400 - } 400 + }
401 - 401 +
402 - @Override 402 + @Override
403 - public Builder setPFlag(boolean value) { 403 + public Builder setPFlag(boolean value) {
404 - this.bPFlag = value; 404 + this.bPFlag = value;
405 - this.bIsPFlagSet = true; 405 + this.bIsPFlagSet = true;
406 - return this; 406 + return this;
407 - } 407 + }
408 - 408 +
409 - @Override 409 + @Override
410 - public Builder setIFlag(boolean value) { 410 + public Builder setIFlag(boolean value) {
411 - this.bIFlag = value; 411 + this.bIFlag = value;
412 - this.bIsIFlagSet = true; 412 + this.bIsIFlagSet = true;
413 - return this; 413 + return this;
414 - } 414 + }
415 - 415 +
416 - @Override 416 + @Override
417 - public boolean getOFlag() { 417 + public boolean getOFlag() {
418 - return this.bOFlag; 418 + return this.bOFlag;
419 - } 419 + }
420 - 420 +
421 - } 421 + }
422 - 422 +
423 - @Override 423 + @Override
424 - public LinkedList<PcepValueType> getOptionalTlv() { 424 + public LinkedList<PcepValueType> getOptionalTlv() {
425 - return this.llOptionalTlv; 425 + return this.llOptionalTlv;
426 - } 426 + }
427 - 427 +
428 - @Override 428 + @Override
429 - public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 429 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
430 - this.llOptionalTlv = llOptionalTlv; 430 + this.llOptionalTlv = llOptionalTlv;
431 - } 431 + }
432 - 432 +
433 - @Override 433 + @Override
434 - public String toString() { 434 + public String toString() {
435 - return MoreObjects.toStringHelper(getClass()).add("ObjectHeader", rpObjHeader).add("OFlag", (bOFlag) ? 1 : 0) 435 + return MoreObjects.toStringHelper(getClass()).add("ObjectHeader", rpObjHeader).add("OFlag", (bOFlag) ? 1 : 0)
436 - .add("BFlag", (bBFlag) ? 1 : 0).add("RFlag", (bRFlag) ? 1 : 0).add("PriFlag", yPriFlag) 436 + .add("BFlag", (bBFlag) ? 1 : 0).add("RFlag", (bRFlag) ? 1 : 0).add("PriFlag", yPriFlag)
437 - .add("RequestIdNumber", iRequestIdNum).add("OptionalTlv", llOptionalTlv).toString(); 437 + .add("RequestIdNumber", iRequestIdNum).add("OptionalTlv", llOptionalTlv).toString();
438 - } 438 + }
439 -} 439 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepRroObject; 24 +import org.onosproject.pcepio.protocol.PcepRroObject;
25 -import org.onosproject.pcepio.types.IPv4SubObject; 25 +import org.onosproject.pcepio.types.IPv4SubObject;
26 -import org.onosproject.pcepio.types.IPv6SubObject; 26 +import org.onosproject.pcepio.types.IPv6SubObject;
27 -import org.onosproject.pcepio.types.LabelSubObject; 27 +import org.onosproject.pcepio.types.LabelSubObject;
28 -import org.onosproject.pcepio.types.PcepObjectHeader; 28 +import org.onosproject.pcepio.types.PcepObjectHeader;
29 -import org.onosproject.pcepio.types.PcepValueType; 29 +import org.onosproject.pcepio.types.PcepValueType;
30 -import org.slf4j.Logger; 30 +import org.slf4j.Logger;
31 -import org.slf4j.LoggerFactory; 31 +import org.slf4j.LoggerFactory;
32 - 32 +
33 -import com.google.common.base.MoreObjects; 33 +import com.google.common.base.MoreObjects;
34 - 34 +
35 -/** 35 +/**
36 - * Provides PCEP RRO object. 36 + * Provides PCEP RRO object.
37 - */ 37 + */
38 -public class PcepRroObjectVer1 implements PcepRroObject { 38 +public class PcepRroObjectVer1 implements PcepRroObject {
39 - 39 +
40 - /* 40 + /*
41 - * rfc3209 41 + * rfc3209
42 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | Object-Class | OT |Res|P|I| Object Length (bytes) | 45 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - | | 47 + | |
48 - // (Subobjects) // 48 + // (Subobjects) //
49 - | | 49 + | |
50 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 - 51 +
52 - Each subobject has its own Length 52 + Each subobject has its own Length
53 - field. The length contains the total length of the subobject in 53 + field. The length contains the total length of the subobject in
54 - bytes, including the Type and Length fields. The length MUST always 54 + bytes, including the Type and Length fields. The length MUST always
55 - be a multiple of 4, and at least 4. 55 + be a multiple of 4, and at least 4.
56 - 56 +
57 - An empty RRO with no subobjects is considered illegal. 57 + An empty RRO with no subobjects is considered illegal.
58 - Three kinds of subobjects are currently defined. 58 + Three kinds of subobjects are currently defined.
59 - 59 +
60 - Subobject 1: IPv4 address 60 + Subobject 1: IPv4 address
61 - 61 +
62 - 0 1 2 3 62 + 0 1 2 3
63 - 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 63 + 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
64 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 64 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
65 - | Type | Length | IPv4 address (4 bytes) | 65 + | Type | Length | IPv4 address (4 bytes) |
66 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 66 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
67 - | IPv4 address (continued) | Prefix Length | Flags | 67 + | IPv4 address (continued) | Prefix Length | Flags |
68 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 68 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
69 - 69 +
70 - Subobject 2: IPv6 address 70 + Subobject 2: IPv6 address
71 - 71 +
72 - 0 1 2 3 72 + 0 1 2 3
73 - 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 73 + 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
74 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 74 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
75 - | Type | Length | IPv6 address (16 bytes) | 75 + | Type | Length | IPv6 address (16 bytes) |
76 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 76 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
77 - | IPv6 address (continued) | 77 + | IPv6 address (continued) |
78 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 78 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
79 - | IPv6 address (continued) | 79 + | IPv6 address (continued) |
80 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 80 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
81 - | IPv6 address (continued) | 81 + | IPv6 address (continued) |
82 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 82 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
83 - | IPv6 address (continued) | Prefix Length | Flags | 83 + | IPv6 address (continued) | Prefix Length | Flags |
84 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 84 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
85 - 85 +
86 - Subobject 3, Label 86 + Subobject 3, Label
87 - 87 +
88 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 90 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
91 - | Type | Length | Flags | C-Type | 91 + | Type | Length | Flags | C-Type |
92 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 92 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
93 - | Contents of Label Object | 93 + | Contents of Label Object |
94 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 94 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
95 - 95 +
96 - */ 96 + */
97 - protected static final Logger log = LoggerFactory.getLogger(PcepRroObjectVer1.class); 97 + protected static final Logger log = LoggerFactory.getLogger(PcepRroObjectVer1.class);
98 - 98 +
99 - public static final byte RRO_OBJ_TYPE = 1; 99 + public static final byte RRO_OBJ_TYPE = 1;
100 - public static final byte RRO_OBJ_CLASS = 8; 100 + public static final byte RRO_OBJ_CLASS = 8;
101 - public static final byte RRO_OBJECT_VERSION = 1; 101 + public static final byte RRO_OBJECT_VERSION = 1;
102 - public static final short RRO_OBJ_MINIMUM_LENGTH = 12; 102 + public static final short RRO_OBJ_MINIMUM_LENGTH = 12;
103 - public static final int OBJECT_HEADER_LENGTH = 4; 103 + public static final int OBJECT_HEADER_LENGTH = 4;
104 - public static final int YTYPE_SHIFT_VALUE = 0x7F; 104 + public static final int YTYPE_SHIFT_VALUE = 0x7F;
105 - 105 +
106 - static final PcepObjectHeader DEFAULT_RRO_OBJECT_HEADER = new PcepObjectHeader(RRO_OBJ_CLASS, RRO_OBJ_TYPE, 106 + static final PcepObjectHeader DEFAULT_RRO_OBJECT_HEADER = new PcepObjectHeader(RRO_OBJ_CLASS, RRO_OBJ_TYPE,
107 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RRO_OBJ_MINIMUM_LENGTH); 107 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, RRO_OBJ_MINIMUM_LENGTH);
108 - 108 +
109 - private short rroObjType = 0; 109 + private short rroObjType = 0;
110 - private byte length; 110 + private byte length;
111 - private byte prefixLength; 111 + private byte prefixLength;
112 - private byte resvd; 112 + private byte resvd;
113 - PcepObjectHeader rroObjHeader; 113 + PcepObjectHeader rroObjHeader;
114 - private LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 114 + private LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
115 - 115 +
116 - /** 116 + /**
117 - * Reset variables. 117 + * Reset variables.
118 - */ 118 + */
119 - public PcepRroObjectVer1() { 119 + public PcepRroObjectVer1() {
120 - this.rroObjHeader = null; 120 + this.rroObjHeader = null;
121 - this.rroObjType = 0; 121 + this.rroObjType = 0;
122 - this.length = 0; 122 + this.length = 0;
123 - } 123 + }
124 - 124 +
125 - /** 125 + /**
126 - * constructor to initialize parameters for RRO object. 126 + * constructor to initialize parameters for RRO object.
127 - * 127 + *
128 - * @param rroObjHeader RRO object header 128 + * @param rroObjHeader RRO object header
129 - * @param llSubObjects list of sub objects 129 + * @param llSubObjects list of sub objects
130 - */ 130 + */
131 - public PcepRroObjectVer1(PcepObjectHeader rroObjHeader, LinkedList<PcepValueType> llSubObjects) { 131 + public PcepRroObjectVer1(PcepObjectHeader rroObjHeader, LinkedList<PcepValueType> llSubObjects) {
132 - this.rroObjHeader = rroObjHeader; 132 + this.rroObjHeader = rroObjHeader;
133 - this.llSubObjects = llSubObjects; 133 + this.llSubObjects = llSubObjects;
134 - } 134 + }
135 - 135 +
136 - /** 136 + /**
137 - * Returns PCEP RRO Object Header. 137 + * Returns PCEP RRO Object Header.
138 - * 138 + *
139 - * @return rroObjHeader RRO Object header 139 + * @return rroObjHeader RRO Object header
140 - */ 140 + */
141 - public PcepObjectHeader getRroObjHeader() { 141 + public PcepObjectHeader getRroObjHeader() {
142 - return this.rroObjHeader; 142 + return this.rroObjHeader;
143 - } 143 + }
144 - 144 +
145 - /** 145 + /**
146 - * Sets PCEP RRO Object Header. 146 + * Sets PCEP RRO Object Header.
147 - * 147 + *
148 - * @param obj Object header 148 + * @param obj Object header
149 - */ 149 + */
150 - public void setRroObjHeader(PcepObjectHeader obj) { 150 + public void setRroObjHeader(PcepObjectHeader obj) {
151 - this.rroObjHeader = obj; 151 + this.rroObjHeader = obj;
152 - } 152 + }
153 - 153 +
154 - @Override 154 + @Override
155 - public LinkedList<PcepValueType> getSubObjects() { 155 + public LinkedList<PcepValueType> getSubObjects() {
156 - return this.llSubObjects; 156 + return this.llSubObjects;
157 - } 157 + }
158 - 158 +
159 - @Override 159 + @Override
160 - public void setSubObjects(LinkedList<PcepValueType> llSubObjects) { 160 + public void setSubObjects(LinkedList<PcepValueType> llSubObjects) {
161 - this.llSubObjects = llSubObjects; 161 + this.llSubObjects = llSubObjects;
162 - } 162 + }
163 - 163 +
164 - /** 164 + /**
165 - * Reads the channel buffer and returns object of PcepRroObject. 165 + * Reads the channel buffer and returns object of PcepRroObject.
166 - * 166 + *
167 - * @param cb of type channel buffer 167 + * @param cb of type channel buffer
168 - * @return object of PcepRroObject 168 + * @return object of PcepRroObject
169 - * @throws PcepParseException when fails to read from channel buffer 169 + * @throws PcepParseException when fails to read from channel buffer
170 - */ 170 + */
171 - public static PcepRroObject read(ChannelBuffer cb) throws PcepParseException { 171 + public static PcepRroObject read(ChannelBuffer cb) throws PcepParseException {
172 - 172 +
173 - PcepObjectHeader rroObjHeader; 173 + PcepObjectHeader rroObjHeader;
174 - LinkedList<PcepValueType> llSubObjects; 174 + LinkedList<PcepValueType> llSubObjects;
175 - rroObjHeader = PcepObjectHeader.read(cb); 175 + rroObjHeader = PcepObjectHeader.read(cb);
176 - 176 +
177 - //take only RroObject buffer. 177 + //take only RroObject buffer.
178 - ChannelBuffer tempCb = cb.readBytes(rroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH); 178 + ChannelBuffer tempCb = cb.readBytes(rroObjHeader.getObjLen() - OBJECT_HEADER_LENGTH);
179 - llSubObjects = parseSubObjects(tempCb); 179 + llSubObjects = parseSubObjects(tempCb);
180 - 180 +
181 - return new PcepRroObjectVer1(rroObjHeader, llSubObjects); 181 + return new PcepRroObjectVer1(rroObjHeader, llSubObjects);
182 - } 182 + }
183 - 183 +
184 - /** 184 + /**
185 - * Returns list of sub objects. 185 + * Returns list of sub objects.
186 - * 186 + *
187 - * @param cb of type channel buffer 187 + * @param cb of type channel buffer
188 - * @return list of sub objects 188 + * @return list of sub objects
189 - * @throws PcepParseException when fails to parse list of sub objects 189 + * @throws PcepParseException when fails to parse list of sub objects
190 - */ 190 + */
191 - protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException { 191 + protected static LinkedList<PcepValueType> parseSubObjects(ChannelBuffer cb) throws PcepParseException {
192 - 192 +
193 - LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 193 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
194 - 194 +
195 - while (0 < cb.readableBytes()) { 195 + while (0 < cb.readableBytes()) {
196 - 196 +
197 - //check the Type of the Sub objects 197 + //check the Type of the Sub objects
198 - byte yType = cb.readByte(); 198 + byte yType = cb.readByte();
199 - yType = (byte) (yType & (YTYPE_SHIFT_VALUE)); 199 + yType = (byte) (yType & (YTYPE_SHIFT_VALUE));
200 - byte hLength = cb.readByte(); 200 + byte hLength = cb.readByte();
201 - 201 +
202 - PcepValueType subObj; 202 + PcepValueType subObj;
203 - 203 +
204 - switch (yType) { 204 + switch (yType) {
205 - 205 +
206 - case IPv4SubObject.TYPE: 206 + case IPv4SubObject.TYPE:
207 - subObj = IPv4SubObject.read(cb); 207 + subObj = IPv4SubObject.read(cb);
208 - break; 208 + break;
209 - case IPv6SubObject.TYPE: 209 + case IPv6SubObject.TYPE:
210 - byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH]; 210 + byte[] ipv6Value = new byte[IPv6SubObject.VALUE_LENGTH];
211 - cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH); 211 + cb.readBytes(ipv6Value, 0, IPv6SubObject.VALUE_LENGTH);
212 - subObj = new IPv6SubObject(ipv6Value); 212 + subObj = new IPv6SubObject(ipv6Value);
213 - break; 213 + break;
214 - case LabelSubObject.TYPE: 214 + case LabelSubObject.TYPE:
215 - subObj = LabelSubObject.read(cb); 215 + subObj = LabelSubObject.read(cb);
216 - break; 216 + break;
217 - default: 217 + default:
218 - throw new PcepParseException(" Unexpected sub object. Type: " + (int) yType); 218 + throw new PcepParseException(" Unexpected sub object. Type: " + (int) yType);
219 - } 219 + }
220 - // Check for the padding 220 + // Check for the padding
221 - int pad = hLength % 4; 221 + int pad = hLength % 4;
222 - if (0 < pad) { 222 + if (0 < pad) {
223 - pad = 4 - pad; 223 + pad = 4 - pad;
224 - if (pad <= cb.readableBytes()) { 224 + if (pad <= cb.readableBytes()) {
225 - cb.skipBytes(pad); 225 + cb.skipBytes(pad);
226 - } 226 + }
227 - } 227 + }
228 - llSubObjects.add(subObj); 228 + llSubObjects.add(subObj);
229 - } 229 + }
230 - 230 +
231 - return llSubObjects; 231 + return llSubObjects;
232 - } 232 + }
233 - 233 +
234 - @Override 234 + @Override
235 - public int write(ChannelBuffer cb) throws PcepParseException { 235 + public int write(ChannelBuffer cb) throws PcepParseException {
236 - //write Object header 236 + //write Object header
237 - int objStartIndex = cb.writerIndex(); 237 + int objStartIndex = cb.writerIndex();
238 - 238 +
239 - int objLenIndex = rroObjHeader.write(cb); 239 + int objLenIndex = rroObjHeader.write(cb);
240 - 240 +
241 - if (objLenIndex <= 0) { 241 + if (objLenIndex <= 0) {
242 - throw new PcepParseException(" object Length Index" + objLenIndex); 242 + throw new PcepParseException(" object Length Index" + objLenIndex);
243 - } 243 + }
244 - 244 +
245 - ListIterator<PcepValueType> listIterator = llSubObjects.listIterator(); 245 + ListIterator<PcepValueType> listIterator = llSubObjects.listIterator();
246 - 246 +
247 - while (listIterator.hasNext()) { 247 + while (listIterator.hasNext()) {
248 - listIterator.next().write(cb); 248 + listIterator.next().write(cb);
249 - } 249 + }
250 - 250 +
251 - //Update object length now 251 + //Update object length now
252 - int length = cb.writerIndex() - objStartIndex; 252 + int length = cb.writerIndex() - objStartIndex;
253 - cb.setShort(objLenIndex, (short) length); 253 + cb.setShort(objLenIndex, (short) length);
254 - //will be helpful during print(). 254 + //will be helpful during print().
255 - rroObjHeader.setObjLen((short) length); 255 + rroObjHeader.setObjLen((short) length);
256 - 256 +
257 - //As per RFC the length of object should be multiples of 4 257 + //As per RFC the length of object should be multiples of 4
258 - int pad = length % 4; 258 + int pad = length % 4;
259 - 259 +
260 - if (0 != pad) { 260 + if (0 != pad) {
261 - pad = 4 - pad; 261 + pad = 4 - pad;
262 - for (int i = 0; i < pad; i++) { 262 + for (int i = 0; i < pad; i++) {
263 - cb.writeByte((byte) 0); 263 + cb.writeByte((byte) 0);
264 - } 264 + }
265 - length = length + pad; 265 + length = length + pad;
266 - } 266 + }
267 - objLenIndex = cb.writerIndex(); 267 + objLenIndex = cb.writerIndex();
268 - return objLenIndex; 268 + return objLenIndex;
269 - } 269 + }
270 - 270 +
271 - /** 271 + /**
272 - * Builder class for PCEP RRO object. 272 + * Builder class for PCEP RRO object.
273 - */ 273 + */
274 - public static class Builder implements PcepRroObject.Builder { 274 + public static class Builder implements PcepRroObject.Builder {
275 - private boolean bIsHeaderSet = false; 275 + private boolean bIsHeaderSet = false;
276 - 276 +
277 - private PcepObjectHeader rroObjHeader; 277 + private PcepObjectHeader rroObjHeader;
278 - LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>(); 278 + LinkedList<PcepValueType> llSubObjects = new LinkedList<PcepValueType>();
279 - 279 +
280 - private boolean bIsPFlagSet = false; 280 + private boolean bIsPFlagSet = false;
281 - private boolean bPFlag; 281 + private boolean bPFlag;
282 - 282 +
283 - private boolean bIsIFlagSet = false; 283 + private boolean bIsIFlagSet = false;
284 - private boolean bIFlag; 284 + private boolean bIFlag;
285 - 285 +
286 - @Override 286 + @Override
287 - public PcepRroObject build() { 287 + public PcepRroObject build() {
288 - 288 +
289 - PcepObjectHeader rroObjHeader = this.bIsHeaderSet ? this.rroObjHeader : DEFAULT_RRO_OBJECT_HEADER; 289 + PcepObjectHeader rroObjHeader = this.bIsHeaderSet ? this.rroObjHeader : DEFAULT_RRO_OBJECT_HEADER;
290 - 290 +
291 - if (bIsPFlagSet) { 291 + if (bIsPFlagSet) {
292 - rroObjHeader.setPFlag(bPFlag); 292 + rroObjHeader.setPFlag(bPFlag);
293 - } 293 + }
294 - 294 +
295 - if (bIsIFlagSet) { 295 + if (bIsIFlagSet) {
296 - rroObjHeader.setIFlag(bIFlag); 296 + rroObjHeader.setIFlag(bIFlag);
297 - } 297 + }
298 - return new PcepRroObjectVer1(rroObjHeader, this.llSubObjects); 298 + return new PcepRroObjectVer1(rroObjHeader, this.llSubObjects);
299 - } 299 + }
300 - 300 +
301 - @Override 301 + @Override
302 - public PcepObjectHeader getRroObjHeader() { 302 + public PcepObjectHeader getRroObjHeader() {
303 - return this.rroObjHeader; 303 + return this.rroObjHeader;
304 - } 304 + }
305 - 305 +
306 - @Override 306 + @Override
307 - public Builder setRroObjHeader(PcepObjectHeader obj) { 307 + public Builder setRroObjHeader(PcepObjectHeader obj) {
308 - this.rroObjHeader = obj; 308 + this.rroObjHeader = obj;
309 - this.bIsHeaderSet = true; 309 + this.bIsHeaderSet = true;
310 - return this; 310 + return this;
311 - } 311 + }
312 - 312 +
313 - @Override 313 + @Override
314 - public LinkedList<PcepValueType> getSubObjects() { 314 + public LinkedList<PcepValueType> getSubObjects() {
315 - return this.llSubObjects; 315 + return this.llSubObjects;
316 - } 316 + }
317 - 317 +
318 - @Override 318 + @Override
319 - public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) { 319 + public Builder setSubObjects(LinkedList<PcepValueType> llSubObjects) {
320 - this.llSubObjects = llSubObjects; 320 + this.llSubObjects = llSubObjects;
321 - return this; 321 + return this;
322 - } 322 + }
323 - 323 +
324 - @Override 324 + @Override
325 - public Builder setPFlag(boolean value) { 325 + public Builder setPFlag(boolean value) {
326 - this.bPFlag = value; 326 + this.bPFlag = value;
327 - this.bIsPFlagSet = true; 327 + this.bIsPFlagSet = true;
328 - return this; 328 + return this;
329 - } 329 + }
330 - 330 +
331 - @Override 331 + @Override
332 - public Builder setIFlag(boolean value) { 332 + public Builder setIFlag(boolean value) {
333 - this.bIFlag = value; 333 + this.bIFlag = value;
334 - this.bIsIFlagSet = true; 334 + this.bIsIFlagSet = true;
335 - return this; 335 + return this;
336 - } 336 + }
337 - } 337 + }
338 - 338 +
339 - @Override 339 + @Override
340 - public String toString() { 340 + public String toString() {
341 - return MoreObjects.toStringHelper(getClass()).add("SubObjects", llSubObjects).toString(); 341 + return MoreObjects.toStringHelper(getClass()).add("SubObjects", llSubObjects).toString();
342 - } 342 + }
343 -} 343 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 - 21 +
22 -import org.jboss.netty.buffer.ChannelBuffer; 22 +import org.jboss.netty.buffer.ChannelBuffer;
23 -import org.onosproject.pcepio.exceptions.PcepParseException; 23 +import org.onosproject.pcepio.exceptions.PcepParseException;
24 -import org.onosproject.pcepio.protocol.PcepSrpObject; 24 +import org.onosproject.pcepio.protocol.PcepSrpObject;
25 -import org.onosproject.pcepio.types.PcepObjectHeader; 25 +import org.onosproject.pcepio.types.PcepObjectHeader;
26 -import org.onosproject.pcepio.types.PcepValueType; 26 +import org.onosproject.pcepio.types.PcepValueType;
27 -import org.onosproject.pcepio.types.SymbolicPathNameTlv; 27 +import org.onosproject.pcepio.types.SymbolicPathNameTlv;
28 -import org.slf4j.Logger; 28 +import org.slf4j.Logger;
29 -import org.slf4j.LoggerFactory; 29 +import org.slf4j.LoggerFactory;
30 - 30 +
31 -import com.google.common.base.MoreObjects; 31 +import com.google.common.base.MoreObjects;
32 - 32 +
33 -/** 33 +/**
34 - * Provides PCEP SRP obejct. 34 + * Provides PCEP SRP obejct.
35 - */ 35 + */
36 -public class PcepSrpObjectVer1 implements PcepSrpObject { 36 +public class PcepSrpObjectVer1 implements PcepSrpObject {
37 - 37 +
38 - /* 38 + /*
39 - * ref : draft-ietf-pce-stateful-pce-10, section : 7.2 39 + * ref : draft-ietf-pce-stateful-pce-10, section : 7.2
40 - 0 1 2 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | Object-Class | OT |Res|P|I| Object Length (bytes) | 43 + | Object-Class | OT |Res|P|I| Object Length (bytes) |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | Flags |R| 45 + | Flags |R|
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - | SRP-ID-number | 47 + | SRP-ID-number |
48 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 - | | 49 + | |
50 - // Optional TLVs // 50 + // Optional TLVs //
51 - | | 51 + | |
52 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 52 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
53 - 53 +
54 - */ 54 + */
55 - protected static final Logger log = LoggerFactory.getLogger(PcepSrpObjectVer1.class); 55 + protected static final Logger log = LoggerFactory.getLogger(PcepSrpObjectVer1.class);
56 - 56 +
57 - public static final byte SRP_OBJ_TYPE = 1; 57 + public static final byte SRP_OBJ_TYPE = 1;
58 - public static final byte SRP_OBJ_CLASS = 33; 58 + public static final byte SRP_OBJ_CLASS = 33;
59 - public static final byte SRP_OBJECT_VERSION = 1; 59 + public static final byte SRP_OBJECT_VERSION = 1;
60 - public static final short SRP_OBJ_MINIMUM_LENGTH = 12; 60 + public static final short SRP_OBJ_MINIMUM_LENGTH = 12;
61 - public static final int MINIMUM_COMMON_HEADER_LENGTH = 4; 61 + public static final int MINIMUM_COMMON_HEADER_LENGTH = 4;
62 - public static final boolean DEFAULT_RFLAG = false; 62 + public static final boolean DEFAULT_RFLAG = false;
63 - 63 +
64 - static final PcepObjectHeader DEFAULT_SRP_OBJECT_HEADER = new PcepObjectHeader(SRP_OBJ_CLASS, SRP_OBJ_TYPE, 64 + static final PcepObjectHeader DEFAULT_SRP_OBJECT_HEADER = new PcepObjectHeader(SRP_OBJ_CLASS, SRP_OBJ_TYPE,
65 - PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, SRP_OBJ_MINIMUM_LENGTH); 65 + PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, SRP_OBJ_MINIMUM_LENGTH);
66 - 66 +
67 - private PcepObjectHeader srpObjHeader; 67 + private PcepObjectHeader srpObjHeader;
68 - private static int flags; 68 + private static int flags;
69 - private boolean bRFlag; 69 + private boolean bRFlag;
70 - private int srpId; 70 + private int srpId;
71 - 71 +
72 - //Optional TLV 72 + //Optional TLV
73 - private LinkedList<PcepValueType> llOptionalTlv; 73 + private LinkedList<PcepValueType> llOptionalTlv;
74 - public static final byte BBIT_SET = 1; 74 + public static final byte BBIT_SET = 1;
75 - public static final byte BBIT_RESET = 0; 75 + public static final byte BBIT_RESET = 0;
76 - 76 +
77 - /** 77 + /**
78 - * Constructor to initialize member variables. 78 + * Constructor to initialize member variables.
79 - * 79 + *
80 - * @param srpObjHeader srp object header 80 + * @param srpObjHeader srp object header
81 - * @param bRFlag R flag 81 + * @param bRFlag R flag
82 - * @param srpID srp Id 82 + * @param srpID srp Id
83 - * @param llOptionalTlv list of optional tlv 83 + * @param llOptionalTlv list of optional tlv
84 - */ 84 + */
85 - public PcepSrpObjectVer1(PcepObjectHeader srpObjHeader, boolean bRFlag, int srpID, 85 + public PcepSrpObjectVer1(PcepObjectHeader srpObjHeader, boolean bRFlag, int srpID,
86 - LinkedList<PcepValueType> llOptionalTlv) { 86 + LinkedList<PcepValueType> llOptionalTlv) {
87 - 87 +
88 - this.srpObjHeader = srpObjHeader; 88 + this.srpObjHeader = srpObjHeader;
89 - this.bRFlag = bRFlag; 89 + this.bRFlag = bRFlag;
90 - this.srpId = srpID; 90 + this.srpId = srpID;
91 - this.llOptionalTlv = llOptionalTlv; 91 + this.llOptionalTlv = llOptionalTlv;
92 - } 92 + }
93 - 93 +
94 - /** 94 + /**
95 - * sets the SRP object header. 95 + * sets the SRP object header.
96 - * 96 + *
97 - * @param obj srp object header 97 + * @param obj srp object header
98 - */ 98 + */
99 - public void setSrpObjHeader(PcepObjectHeader obj) { 99 + public void setSrpObjHeader(PcepObjectHeader obj) {
100 - this.srpObjHeader = obj; 100 + this.srpObjHeader = obj;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public void setSrpID(int srpID) { 104 + public void setSrpID(int srpID) {
105 - this.srpId = srpID; 105 + this.srpId = srpID;
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public void setRFlag(boolean bRFlag) { 109 + public void setRFlag(boolean bRFlag) {
110 - this.bRFlag = bRFlag; 110 + this.bRFlag = bRFlag;
111 - } 111 + }
112 - 112 +
113 - /** 113 + /**
114 - * Returns SRP object header. 114 + * Returns SRP object header.
115 - * 115 + *
116 - * @return srpObjHeader 116 + * @return srpObjHeader
117 - */ 117 + */
118 - public PcepObjectHeader getSrpObjHeader() { 118 + public PcepObjectHeader getSrpObjHeader() {
119 - return this.srpObjHeader; 119 + return this.srpObjHeader;
120 - } 120 + }
121 - 121 +
122 - @Override 122 + @Override
123 - public int getSrpID() { 123 + public int getSrpID() {
124 - return this.srpId; 124 + return this.srpId;
125 - } 125 + }
126 - 126 +
127 - @Override 127 + @Override
128 - public boolean getRFlag() { 128 + public boolean getRFlag() {
129 - return this.bRFlag; 129 + return this.bRFlag;
130 - } 130 + }
131 - 131 +
132 - @Override 132 + @Override
133 - public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 133 + public void setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
134 - this.llOptionalTlv = llOptionalTlv; 134 + this.llOptionalTlv = llOptionalTlv;
135 - 135 +
136 - } 136 + }
137 - 137 +
138 - @Override 138 + @Override
139 - public LinkedList<PcepValueType> getOptionalTlv() { 139 + public LinkedList<PcepValueType> getOptionalTlv() {
140 - return this.llOptionalTlv; 140 + return this.llOptionalTlv;
141 - } 141 + }
142 - 142 +
143 - /** 143 + /**
144 - * Reads from channel buffer and returns instance of PCEP SRP object. 144 + * Reads from channel buffer and returns instance of PCEP SRP object.
145 - * 145 + *
146 - * @param cb of channel buffer. 146 + * @param cb of channel buffer.
147 - * @return PCEP SRP object 147 + * @return PCEP SRP object
148 - * @throws PcepParseException when srp object is not received in channel buffer 148 + * @throws PcepParseException when srp object is not received in channel buffer
149 - */ 149 + */
150 - public static PcepSrpObject read(ChannelBuffer cb) throws PcepParseException { 150 + public static PcepSrpObject read(ChannelBuffer cb) throws PcepParseException {
151 - 151 +
152 - log.debug("SrpObject::read"); 152 + log.debug("SrpObject::read");
153 - PcepObjectHeader srpObjHeader; 153 + PcepObjectHeader srpObjHeader;
154 - boolean bRFlag; 154 + boolean bRFlag;
155 - 155 +
156 - int srpID; 156 + int srpID;
157 - int flags; 157 + int flags;
158 - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 158 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
159 - 159 +
160 - srpObjHeader = PcepObjectHeader.read(cb); 160 + srpObjHeader = PcepObjectHeader.read(cb);
161 - 161 +
162 - if (SRP_OBJ_CLASS != srpObjHeader.getObjClass()) { 162 + if (SRP_OBJ_CLASS != srpObjHeader.getObjClass()) {
163 - throw new PcepParseException("SRP object expected. But received " + srpObjHeader.getObjClass()); 163 + throw new PcepParseException("SRP object expected. But received " + srpObjHeader.getObjClass());
164 - } 164 + }
165 - 165 +
166 - //take only SrpObject buffer. 166 + //take only SrpObject buffer.
167 - ChannelBuffer tempCb = cb.readBytes(srpObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH); 167 + ChannelBuffer tempCb = cb.readBytes(srpObjHeader.getObjLen() - MINIMUM_COMMON_HEADER_LENGTH);
168 - flags = tempCb.readInt(); 168 + flags = tempCb.readInt();
169 - bRFlag = (0 < flags) ? true : false; 169 + bRFlag = (0 < flags) ? true : false;
170 - srpID = tempCb.readInt(); 170 + srpID = tempCb.readInt();
171 - 171 +
172 - llOptionalTlv = parseOptionalTlv(tempCb); 172 + llOptionalTlv = parseOptionalTlv(tempCb);
173 - 173 +
174 - return new PcepSrpObjectVer1(srpObjHeader, bRFlag, srpID, llOptionalTlv); 174 + return new PcepSrpObjectVer1(srpObjHeader, bRFlag, srpID, llOptionalTlv);
175 - } 175 + }
176 - 176 +
177 - @Override 177 + @Override
178 - public int write(ChannelBuffer cb) throws PcepParseException { 178 + public int write(ChannelBuffer cb) throws PcepParseException {
179 - 179 +
180 - int objStartIndex = cb.writerIndex(); 180 + int objStartIndex = cb.writerIndex();
181 - 181 +
182 - //write common header 182 + //write common header
183 - int objLenIndex = srpObjHeader.write(cb); 183 + int objLenIndex = srpObjHeader.write(cb);
184 - 184 +
185 - //write Flags 185 + //write Flags
186 - byte bFlag; 186 + byte bFlag;
187 - 187 +
188 - bFlag = (bRFlag) ? BBIT_SET : BBIT_RESET; 188 + bFlag = (bRFlag) ? BBIT_SET : BBIT_RESET;
189 - 189 +
190 - cb.writeInt(bFlag); 190 + cb.writeInt(bFlag);
191 - 191 +
192 - //write SrpId 192 + //write SrpId
193 - cb.writeInt(srpId); 193 + cb.writeInt(srpId);
194 - 194 +
195 - // Add optional TLV 195 + // Add optional TLV
196 - if (!packOptionalTlv(cb)) { 196 + if (!packOptionalTlv(cb)) {
197 - throw new PcepParseException("Failed to write srp tlv to channel buffer."); 197 + throw new PcepParseException("Failed to write srp tlv to channel buffer.");
198 - } 198 + }
199 - 199 +
200 - //now write SRP Object Length 200 + //now write SRP Object Length
201 - cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex)); 201 + cb.setShort(objLenIndex, (short) (cb.writerIndex() - objStartIndex));
202 - 202 +
203 - return cb.writerIndex(); 203 + return cb.writerIndex();
204 - } 204 + }
205 - 205 +
206 - /** 206 + /**
207 - * Parse Optional TLvs from the channel buffer. 207 + * Parse Optional TLvs from the channel buffer.
208 - * 208 + *
209 - * @param cb of type channel buffer 209 + * @param cb of type channel buffer
210 - * @return list of optional tlvs 210 + * @return list of optional tlvs
211 - * @throws PcepParseException when unsupported tlv is received in srp object 211 + * @throws PcepParseException when unsupported tlv is received in srp object
212 - */ 212 + */
213 - public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException { 213 + public static LinkedList<PcepValueType> parseOptionalTlv(ChannelBuffer cb) throws PcepParseException {
214 - 214 +
215 - LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>(); 215 + LinkedList<PcepValueType> llOutOptionalTlv = new LinkedList<PcepValueType>();
216 - 216 +
217 - while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) { 217 + while (MINIMUM_COMMON_HEADER_LENGTH <= cb.readableBytes()) {
218 - 218 +
219 - PcepValueType tlv; 219 + PcepValueType tlv;
220 - short hType = cb.readShort(); 220 + short hType = cb.readShort();
221 - short hLength = cb.readShort(); 221 + short hLength = cb.readShort();
222 - 222 +
223 - switch (hType) { 223 + switch (hType) {
224 - 224 +
225 - case SymbolicPathNameTlv.TYPE: 225 + case SymbolicPathNameTlv.TYPE:
226 - tlv = SymbolicPathNameTlv.read(cb, hLength); 226 + tlv = SymbolicPathNameTlv.read(cb, hLength);
227 - cb.skipBytes(hLength); 227 + cb.skipBytes(hLength);
228 - break; 228 + break;
229 - 229 +
230 - default: 230 + default:
231 - throw new PcepParseException("Unsupported TLV received in SRP Object."); 231 + throw new PcepParseException("Unsupported TLV received in SRP Object.");
232 - } 232 + }
233 - 233 +
234 - // Check for the padding 234 + // Check for the padding
235 - int pad = hLength % 4; 235 + int pad = hLength % 4;
236 - if (0 < pad) { 236 + if (0 < pad) {
237 - pad = 4 - pad; 237 + pad = 4 - pad;
238 - if (pad <= cb.readableBytes()) { 238 + if (pad <= cb.readableBytes()) {
239 - cb.skipBytes(pad); 239 + cb.skipBytes(pad);
240 - } 240 + }
241 - } 241 + }
242 - llOutOptionalTlv.add(tlv); 242 + llOutOptionalTlv.add(tlv);
243 - } 243 + }
244 - 244 +
245 - return llOutOptionalTlv; 245 + return llOutOptionalTlv;
246 - } 246 + }
247 - 247 +
248 - /** 248 + /**
249 - * Writes optional tlvs to channel buffer. 249 + * Writes optional tlvs to channel buffer.
250 - * 250 + *
251 - * @param cb of type channel buffer 251 + * @param cb of type channel buffer
252 - * @return true if writing optional tlv to channel buffer is success. 252 + * @return true if writing optional tlv to channel buffer is success.
253 - */ 253 + */
254 - protected boolean packOptionalTlv(ChannelBuffer cb) { 254 + protected boolean packOptionalTlv(ChannelBuffer cb) {
255 - 255 +
256 - ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); 256 + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator();
257 - 257 +
258 - while (listIterator.hasNext()) { 258 + while (listIterator.hasNext()) {
259 - PcepValueType tlv = listIterator.next(); 259 + PcepValueType tlv = listIterator.next();
260 - 260 +
261 - if (null == tlv) { 261 + if (null == tlv) {
262 - log.debug("tlv is null from OptionalTlv list"); 262 + log.debug("tlv is null from OptionalTlv list");
263 - continue; 263 + continue;
264 - } 264 + }
265 - tlv.write(cb); 265 + tlv.write(cb);
266 - 266 +
267 - // need to take care of padding 267 + // need to take care of padding
268 - int pad = tlv.getLength() % 4; 268 + int pad = tlv.getLength() % 4;
269 - 269 +
270 - if (0 != pad) { 270 + if (0 != pad) {
271 - pad = 4 - pad; 271 + pad = 4 - pad;
272 - for (int i = 0; i < pad; ++i) { 272 + for (int i = 0; i < pad; ++i) {
273 - cb.writeByte((byte) 0); 273 + cb.writeByte((byte) 0);
274 - } 274 + }
275 - } 275 + }
276 - } 276 + }
277 - 277 +
278 - return true; 278 + return true;
279 - } 279 + }
280 - 280 +
281 - /** 281 + /**
282 - * Builder class for PCEP srp Object. 282 + * Builder class for PCEP srp Object.
283 - */ 283 + */
284 - public static class Builder implements PcepSrpObject.Builder { 284 + public static class Builder implements PcepSrpObject.Builder {
285 - private boolean bIsHeaderSet = false; 285 + private boolean bIsHeaderSet = false;
286 - private boolean bIsSrpIdset = false; 286 + private boolean bIsSrpIdset = false;
287 - private boolean bIsRFlagSet = false; 287 + private boolean bIsRFlagSet = false;
288 - 288 +
289 - private PcepObjectHeader srpObjHeader; 289 + private PcepObjectHeader srpObjHeader;
290 - private int srpId; 290 + private int srpId;
291 - private boolean bRFlag; 291 + private boolean bRFlag;
292 - LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); 292 + LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>();
293 - 293 +
294 - private boolean bIsPFlagSet = false; 294 + private boolean bIsPFlagSet = false;
295 - private boolean bPFlag; 295 + private boolean bPFlag;
296 - 296 +
297 - private boolean bIsIFlagSet = false; 297 + private boolean bIsIFlagSet = false;
298 - private boolean bIFlag; 298 + private boolean bIFlag;
299 - 299 +
300 - @Override 300 + @Override
301 - public PcepSrpObject build() throws PcepParseException { 301 + public PcepSrpObject build() throws PcepParseException {
302 - PcepObjectHeader srpObjHeader = this.bIsHeaderSet ? this.srpObjHeader : DEFAULT_SRP_OBJECT_HEADER; 302 + PcepObjectHeader srpObjHeader = this.bIsHeaderSet ? this.srpObjHeader : DEFAULT_SRP_OBJECT_HEADER;
303 - 303 +
304 - boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_RFLAG; 304 + boolean bRFlag = this.bIsRFlagSet ? this.bRFlag : DEFAULT_RFLAG;
305 - 305 +
306 - if (!this.bIsSrpIdset) { 306 + if (!this.bIsSrpIdset) {
307 - throw new PcepParseException("SrpID not set while building SRP Object."); 307 + throw new PcepParseException("SrpID not set while building SRP Object.");
308 - } 308 + }
309 - 309 +
310 - if (bIsPFlagSet) { 310 + if (bIsPFlagSet) {
311 - srpObjHeader.setPFlag(bPFlag); 311 + srpObjHeader.setPFlag(bPFlag);
312 - } 312 + }
313 - 313 +
314 - if (bIsIFlagSet) { 314 + if (bIsIFlagSet) {
315 - srpObjHeader.setIFlag(bIFlag); 315 + srpObjHeader.setIFlag(bIFlag);
316 - } 316 + }
317 - 317 +
318 - return new PcepSrpObjectVer1(srpObjHeader, bRFlag, this.srpId, this.llOptionalTlv); 318 + return new PcepSrpObjectVer1(srpObjHeader, bRFlag, this.srpId, this.llOptionalTlv);
319 - } 319 + }
320 - 320 +
321 - @Override 321 + @Override
322 - public PcepObjectHeader getSrpObjHeader() { 322 + public PcepObjectHeader getSrpObjHeader() {
323 - return this.srpObjHeader; 323 + return this.srpObjHeader;
324 - } 324 + }
325 - 325 +
326 - @Override 326 + @Override
327 - public Builder setSrpObjHeader(PcepObjectHeader obj) { 327 + public Builder setSrpObjHeader(PcepObjectHeader obj) {
328 - this.srpObjHeader = obj; 328 + this.srpObjHeader = obj;
329 - this.bIsHeaderSet = true; 329 + this.bIsHeaderSet = true;
330 - return this; 330 + return this;
331 - } 331 + }
332 - 332 +
333 - @Override 333 + @Override
334 - public int getSrpID() { 334 + public int getSrpID() {
335 - return this.srpId; 335 + return this.srpId;
336 - } 336 + }
337 - 337 +
338 - @Override 338 + @Override
339 - public Builder setSrpID(int srpID) { 339 + public Builder setSrpID(int srpID) {
340 - this.srpId = srpID; 340 + this.srpId = srpID;
341 - this.bIsSrpIdset = true; 341 + this.bIsSrpIdset = true;
342 - return this; 342 + return this;
343 - } 343 + }
344 - 344 +
345 - @Override 345 + @Override
346 - public boolean getRFlag() { 346 + public boolean getRFlag() {
347 - return this.bRFlag; 347 + return this.bRFlag;
348 - } 348 + }
349 - 349 +
350 - @Override 350 + @Override
351 - public Builder setRFlag(boolean bRFlag) { 351 + public Builder setRFlag(boolean bRFlag) {
352 - this.bRFlag = bRFlag; 352 + this.bRFlag = bRFlag;
353 - this.bIsRFlagSet = true; 353 + this.bIsRFlagSet = true;
354 - return this; 354 + return this;
355 - } 355 + }
356 - 356 +
357 - @Override 357 + @Override
358 - public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) { 358 + public Builder setOptionalTlv(LinkedList<PcepValueType> llOptionalTlv) {
359 - this.llOptionalTlv = llOptionalTlv; 359 + this.llOptionalTlv = llOptionalTlv;
360 - return this; 360 + return this;
361 - } 361 + }
362 - 362 +
363 - @Override 363 + @Override
364 - public LinkedList<PcepValueType> getOptionalTlv() { 364 + public LinkedList<PcepValueType> getOptionalTlv() {
365 - return this.llOptionalTlv; 365 + return this.llOptionalTlv;
366 - } 366 + }
367 - 367 +
368 - @Override 368 + @Override
369 - public Builder setPFlag(boolean value) { 369 + public Builder setPFlag(boolean value) {
370 - this.bPFlag = value; 370 + this.bPFlag = value;
371 - this.bIsPFlagSet = true; 371 + this.bIsPFlagSet = true;
372 - return this; 372 + return this;
373 - } 373 + }
374 - 374 +
375 - @Override 375 + @Override
376 - public Builder setIFlag(boolean value) { 376 + public Builder setIFlag(boolean value) {
377 - this.bIFlag = value; 377 + this.bIFlag = value;
378 - this.bIsIFlagSet = true; 378 + this.bIsIFlagSet = true;
379 - return this; 379 + return this;
380 - } 380 + }
381 - 381 +
382 - } 382 + }
383 - 383 +
384 - @Override 384 + @Override
385 - public String toString() { 385 + public String toString() {
386 - return MoreObjects.toStringHelper(getClass()).add("RFlag", bRFlag).add("SRPID", srpId) 386 + return MoreObjects.toStringHelper(getClass()).add("RFlag", bRFlag).add("SRPID", srpId)
387 - .add("OptionalTlvList", llOptionalTlv).toString(); 387 + .add("OptionalTlvList", llOptionalTlv).toString();
388 - } 388 + }
389 -} 389 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
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.PcepAttribute; 21 +import org.onosproject.pcepio.protocol.PcepAttribute;
22 -import org.onosproject.pcepio.protocol.PcepBandwidthObject; 22 +import org.onosproject.pcepio.protocol.PcepBandwidthObject;
23 -import org.onosproject.pcepio.protocol.PcepEroObject; 23 +import org.onosproject.pcepio.protocol.PcepEroObject;
24 -import org.onosproject.pcepio.protocol.PcepLspObject; 24 +import org.onosproject.pcepio.protocol.PcepLspObject;
25 -import org.onosproject.pcepio.protocol.PcepRroObject; 25 +import org.onosproject.pcepio.protocol.PcepRroObject;
26 -import org.onosproject.pcepio.protocol.PcepSrpObject; 26 +import org.onosproject.pcepio.protocol.PcepSrpObject;
27 -import org.onosproject.pcepio.protocol.PcepStateReport; 27 +import org.onosproject.pcepio.protocol.PcepStateReport;
28 -import org.onosproject.pcepio.types.PcepObjectHeader; 28 +import org.onosproject.pcepio.types.PcepObjectHeader;
29 -import org.slf4j.Logger; 29 +import org.slf4j.Logger;
30 -import org.slf4j.LoggerFactory; 30 +import org.slf4j.LoggerFactory;
31 - 31 +
32 -import com.google.common.base.MoreObjects; 32 +import com.google.common.base.MoreObjects;
33 -import com.google.common.base.MoreObjects.ToStringHelper; 33 +import com.google.common.base.MoreObjects.ToStringHelper;
34 - 34 +
35 -/** 35 +/**
36 - * Provide the State Report for the Pcep Report Message. 36 + * Provide the State Report for the Pcep Report Message.
37 - * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10. 37 + * Reference :PCE extensions for stateful draft-ietf-pce-stateful-pce-10.
38 - */ 38 + */
39 -public class PcepStateReportVer1 implements PcepStateReport { 39 +public class PcepStateReportVer1 implements PcepStateReport {
40 - /* 40 + /*
41 - * <state-report> ::= [<SRP>] 41 + * <state-report> ::= [<SRP>]
42 - <LSP> 42 + <LSP>
43 - <path> 43 + <path>
44 - Where: 44 + Where:
45 - <path> ::= <ERO><attribute-list>[<RRO>] 45 + <path> ::= <ERO><attribute-list>[<RRO>]
46 - */ 46 + */
47 - 47 +
48 - protected static final Logger log = LoggerFactory.getLogger(PcepStateReport.class); 48 + protected static final Logger log = LoggerFactory.getLogger(PcepStateReport.class);
49 - 49 +
50 - public static final int OBJECT_HEADER_LENGTH = 4; 50 + public static final int OBJECT_HEADER_LENGTH = 4;
51 - 51 +
52 - /** 52 + /**
53 - * Provides PCEP Message path for report message. 53 + * Provides PCEP Message path for report message.
54 - */ 54 + */
55 - public class PcepMsgPath implements PcepStateReport.PcepMsgPath { 55 + public class PcepMsgPath implements PcepStateReport.PcepMsgPath {
56 - 56 +
57 - /* 57 + /*
58 - * <path> ::= <ERO><attribute-list>[<RRO>] 58 + * <path> ::= <ERO><attribute-list>[<RRO>]
59 - */ 59 + */
60 - 60 +
61 - //PcepEroObject 61 + //PcepEroObject
62 - private PcepEroObject eroObj; 62 + private PcepEroObject eroObj;
63 - private boolean isEroObjectSet; 63 + private boolean isEroObjectSet;
64 - //PcepAttribute List 64 + //PcepAttribute List
65 - private PcepAttribute attrList; 65 + private PcepAttribute attrList;
66 - private boolean isAttributeListSet; 66 + private boolean isAttributeListSet;
67 - //PcepRroObject 67 + //PcepRroObject
68 - private PcepRroObject rroObj; 68 + private PcepRroObject rroObj;
69 - private boolean isRroObjectSet; 69 + private boolean isRroObjectSet;
70 - private PcepBandwidthObject bandwidth; 70 + private PcepBandwidthObject bandwidth;
71 - private boolean isBandwidthObjectSet; 71 + private boolean isBandwidthObjectSet;
72 - 72 +
73 - /** 73 + /**
74 - * Constructor to reset the parameters. 74 + * Constructor to reset the parameters.
75 - */ 75 + */
76 - public PcepMsgPath() { 76 + public PcepMsgPath() {
77 - eroObj = null; 77 + eroObj = null;
78 - attrList = null; 78 + attrList = null;
79 - rroObj = null; 79 + rroObj = null;
80 - this.isEroObjectSet = false; 80 + this.isEroObjectSet = false;
81 - this.isAttributeListSet = false; 81 + this.isAttributeListSet = false;
82 - this.isRroObjectSet = false; 82 + this.isRroObjectSet = false;
83 - this.isBandwidthObjectSet = false; 83 + this.isBandwidthObjectSet = false;
84 - } 84 + }
85 - 85 +
86 - /** 86 + /**
87 - * Constructor to initialize the parameters from PCEP Message path. 87 + * Constructor to initialize the parameters from PCEP Message path.
88 - * 88 + *
89 - * @param eroObj PCEP ERO Object 89 + * @param eroObj PCEP ERO Object
90 - * @param attrList PCEP Attribute 90 + * @param attrList PCEP Attribute
91 - * @param rroObj PCEP Rro Object 91 + * @param rroObj PCEP Rro Object
92 - * @param bandwidth PCEP bandwidth object 92 + * @param bandwidth PCEP bandwidth object
93 - */ 93 + */
94 - public PcepMsgPath(PcepEroObject eroObj, PcepAttribute attrList, PcepRroObject rroObj, 94 + public PcepMsgPath(PcepEroObject eroObj, PcepAttribute attrList, PcepRroObject rroObj,
95 - PcepBandwidthObject bandwidth) { 95 + PcepBandwidthObject bandwidth) {
96 - 96 +
97 - this.eroObj = eroObj; 97 + this.eroObj = eroObj;
98 - this.attrList = attrList; 98 + this.attrList = attrList;
99 - this.rroObj = rroObj; 99 + this.rroObj = rroObj;
100 - this.bandwidth = bandwidth; 100 + this.bandwidth = bandwidth;
101 - if (null == rroObj) { 101 + if (null == rroObj) {
102 - this.isRroObjectSet = false; 102 + this.isRroObjectSet = false;
103 - } else { 103 + } else {
104 - this.isRroObjectSet = true; 104 + this.isRroObjectSet = true;
105 - } 105 + }
106 - if (null == eroObj) { 106 + if (null == eroObj) {
107 - this.isEroObjectSet = false; 107 + this.isEroObjectSet = false;
108 - } else { 108 + } else {
109 - this.isEroObjectSet = true; 109 + this.isEroObjectSet = true;
110 - } 110 + }
111 - if (null == attrList) { 111 + if (null == attrList) {
112 - this.isAttributeListSet = false; 112 + this.isAttributeListSet = false;
113 - } else { 113 + } else {
114 - this.isAttributeListSet = true; 114 + this.isAttributeListSet = true;
115 - } 115 + }
116 - if (null == bandwidth) { 116 + if (null == bandwidth) {
117 - this.isBandwidthObjectSet = false; 117 + this.isBandwidthObjectSet = false;
118 - } else { 118 + } else {
119 - this.isBandwidthObjectSet = true; 119 + this.isBandwidthObjectSet = true;
120 - } 120 + }
121 - } 121 + }
122 - 122 +
123 - /** 123 + /**
124 - * Returns PcepEroObject. 124 + * Returns PcepEroObject.
125 - * 125 + *
126 - * @return eroObj PCEP ERO Object 126 + * @return eroObj PCEP ERO Object
127 - */ 127 + */
128 - @Override 128 + @Override
129 - public PcepEroObject getEroObject() { 129 + public PcepEroObject getEroObject() {
130 - return this.eroObj; 130 + return this.eroObj;
131 - } 131 + }
132 - 132 +
133 - /** 133 + /**
134 - * Returns PCEP Attribute. 134 + * Returns PCEP Attribute.
135 - * 135 + *
136 - * @return attrList Attribute list 136 + * @return attrList Attribute list
137 - */ 137 + */
138 - @Override 138 + @Override
139 - public PcepAttribute getPcepAttribute() { 139 + public PcepAttribute getPcepAttribute() {
140 - return this.attrList; 140 + return this.attrList;
141 - } 141 + }
142 - 142 +
143 - /** 143 + /**
144 - * Returns PcepRroObject. 144 + * Returns PcepRroObject.
145 - * 145 + *
146 - * @return rroObj PCEP RRO Object 146 + * @return rroObj PCEP RRO Object
147 - */ 147 + */
148 - @Override 148 + @Override
149 - public PcepRroObject getRroObject() { 149 + public PcepRroObject getRroObject() {
150 - return this.rroObj; 150 + return this.rroObj;
151 - } 151 + }
152 - 152 +
153 - @Override 153 + @Override
154 - public PcepBandwidthObject getBandwidthObject() { 154 + public PcepBandwidthObject getBandwidthObject() {
155 - return this.bandwidth; 155 + return this.bandwidth;
156 - } 156 + }
157 - 157 +
158 - @Override 158 + @Override
159 - public void setEroObject(PcepEroObject eroObj) { 159 + public void setEroObject(PcepEroObject eroObj) {
160 - this.eroObj = eroObj; 160 + this.eroObj = eroObj;
161 - } 161 + }
162 - 162 +
163 - @Override 163 + @Override
164 - public void setPcepAttribute(PcepAttribute attrList) { 164 + public void setPcepAttribute(PcepAttribute attrList) {
165 - this.attrList = attrList; 165 + this.attrList = attrList;
166 - } 166 + }
167 - 167 +
168 - @Override 168 + @Override
169 - public void setRroObject(PcepRroObject rroObj) { 169 + public void setRroObject(PcepRroObject rroObj) {
170 - this.rroObj = rroObj; 170 + this.rroObj = rroObj;
171 - } 171 + }
172 - 172 +
173 - @Override 173 + @Override
174 - public void setBandwidthObject(PcepBandwidthObject bandwidth) { 174 + public void setBandwidthObject(PcepBandwidthObject bandwidth) {
175 - this.bandwidth = bandwidth; 175 + this.bandwidth = bandwidth;
176 - } 176 + }
177 - 177 +
178 - /** 178 + /**
179 - * Reads all the Objects for PCEP Message Path. 179 + * Reads all the Objects for PCEP Message Path.
180 - * 180 + *
181 - * @param bb of type channel buffer 181 + * @param bb of type channel buffer
182 - * @return PCEP Message path 182 + * @return PCEP Message path
183 - * @throws PcepParseException when fails to read pcep message path 183 + * @throws PcepParseException when fails to read pcep message path
184 - */ 184 + */
185 - @Override 185 + @Override
186 - public PcepMsgPath read(ChannelBuffer bb) throws PcepParseException { 186 + public PcepMsgPath read(ChannelBuffer bb) throws PcepParseException {
187 - 187 +
188 - PcepEroObject eroObj; 188 + PcepEroObject eroObj;
189 - PcepAttribute attrList; 189 + PcepAttribute attrList;
190 - PcepRroObject rroObj = null; 190 + PcepRroObject rroObj = null;
191 - PcepBandwidthObject bandwidth = null; 191 + PcepBandwidthObject bandwidth = null;
192 - 192 +
193 - eroObj = PcepEroObjectVer1.read(bb); 193 + eroObj = PcepEroObjectVer1.read(bb);
194 - attrList = PcepAttributeVer1.read(bb); 194 + attrList = PcepAttributeVer1.read(bb);
195 - 195 +
196 - boolean bBreakWhile = false; 196 + boolean bBreakWhile = false;
197 - while (0 < bb.readableBytes()) { 197 + while (0 < bb.readableBytes()) {
198 - 198 +
199 - if (bb.readableBytes() < OBJECT_HEADER_LENGTH) { 199 + if (bb.readableBytes() < OBJECT_HEADER_LENGTH) {
200 - break; 200 + break;
201 - } 201 + }
202 - bb.markReaderIndex(); 202 + bb.markReaderIndex();
203 - PcepObjectHeader tempObjHeader = PcepObjectHeader.read(bb); 203 + PcepObjectHeader tempObjHeader = PcepObjectHeader.read(bb);
204 - bb.resetReaderIndex(); 204 + bb.resetReaderIndex();
205 - byte yObjClass = tempObjHeader.getObjClass(); 205 + byte yObjClass = tempObjHeader.getObjClass();
206 - 206 +
207 - switch (yObjClass) { 207 + switch (yObjClass) {
208 - case PcepRroObjectVer1.RRO_OBJ_CLASS: 208 + case PcepRroObjectVer1.RRO_OBJ_CLASS:
209 - rroObj = PcepRroObjectVer1.read(bb); 209 + rroObj = PcepRroObjectVer1.read(bb);
210 - break; 210 + break;
211 - case PcepInterLayerObjectVer1.INTER_LAYER_OBJ_CLASS: 211 + case PcepInterLayerObjectVer1.INTER_LAYER_OBJ_CLASS:
212 - bb.skipBytes(tempObjHeader.getObjLen()); 212 + bb.skipBytes(tempObjHeader.getObjLen());
213 - break; 213 + break;
214 - case PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS: 214 + case PcepBandwidthObjectVer1.BANDWIDTH_OBJ_CLASS:
215 - bandwidth = PcepBandwidthObjectVer1.read(bb); 215 + bandwidth = PcepBandwidthObjectVer1.read(bb);
216 - break; 216 + break;
217 - default: 217 + default:
218 - //Otherthan above objects handle those objects in caller. 218 + //Otherthan above objects handle those objects in caller.
219 - bBreakWhile = true; 219 + bBreakWhile = true;
220 - break; 220 + break;
221 - } 221 + }
222 - if (bBreakWhile) { 222 + if (bBreakWhile) {
223 - break; 223 + break;
224 - } 224 + }
225 - } 225 + }
226 - return new PcepMsgPath(eroObj, attrList, rroObj, bandwidth); 226 + return new PcepMsgPath(eroObj, attrList, rroObj, bandwidth);
227 - } 227 + }
228 - 228 +
229 - /** 229 + /**
230 - * Writes all the objects for PCEP message path. 230 + * Writes all the objects for PCEP message path.
231 - * 231 + *
232 - * @param bb of type channel buffer. 232 + * @param bb of type channel buffer.
233 - * @return object length index 233 + * @return object length index
234 - * @throws PcepParseException when fails to write to channel buffer 234 + * @throws PcepParseException when fails to write to channel buffer
235 - */ 235 + */
236 - @Override 236 + @Override
237 - public int write(ChannelBuffer bb) throws PcepParseException { 237 + public int write(ChannelBuffer bb) throws PcepParseException {
238 - int iLenStartIndex = bb.writerIndex(); 238 + int iLenStartIndex = bb.writerIndex();
239 - 239 +
240 - //write Object header 240 + //write Object header
241 - if (this.isEroObjectSet) { 241 + if (this.isEroObjectSet) {
242 - this.eroObj.write(bb); 242 + this.eroObj.write(bb);
243 - } else { 243 + } else {
244 - throw new PcepParseException("Ero object is not set in path"); 244 + throw new PcepParseException("Ero object is not set in path");
245 - } 245 + }
246 - 246 +
247 - if (this.isAttributeListSet) { 247 + if (this.isAttributeListSet) {
248 - this.attrList.write(bb); 248 + this.attrList.write(bb);
249 - } 249 + }
250 - 250 +
251 - // RRO is optional check and read 251 + // RRO is optional check and read
252 - if (this.isRroObjectSet) { 252 + if (this.isRroObjectSet) {
253 - this.rroObj.write(bb); 253 + this.rroObj.write(bb);
254 - // bandwidth should come along with RRO. 254 + // bandwidth should come along with RRO.
255 - if (this.isBandwidthObjectSet) { 255 + if (this.isBandwidthObjectSet) {
256 - this.bandwidth.write(bb); 256 + this.bandwidth.write(bb);
257 - } 257 + }
258 - } 258 + }
259 - return bb.writerIndex() - iLenStartIndex; 259 + return bb.writerIndex() - iLenStartIndex;
260 - } 260 + }
261 - 261 +
262 - @Override 262 + @Override
263 - public String toString() { 263 + public String toString() {
264 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 264 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
265 - 265 +
266 - if (attrList instanceof PcepAttribute) { 266 + if (attrList instanceof PcepAttribute) {
267 - toStrHelper.add("AttributeList", attrList); 267 + toStrHelper.add("AttributeList", attrList);
268 - } 268 + }
269 - if (rroObj instanceof PcepRroObjectVer1) { 269 + if (rroObj instanceof PcepRroObjectVer1) {
270 - toStrHelper.add("RroObject", rroObj); 270 + toStrHelper.add("RroObject", rroObj);
271 - } 271 + }
272 - if (bandwidth instanceof PcepBandwidthObjectVer1) { 272 + if (bandwidth instanceof PcepBandwidthObjectVer1) {
273 - toStrHelper.add("bandwidthObject", bandwidth); 273 + toStrHelper.add("bandwidthObject", bandwidth);
274 - } 274 + }
275 - return toStrHelper.toString(); 275 + return toStrHelper.toString();
276 - } 276 + }
277 - } 277 + }
278 - 278 +
279 - //SRP Object 279 + //SRP Object
280 - private PcepSrpObject srpObject; 280 + private PcepSrpObject srpObject;
281 - //LSP Object 281 + //LSP Object
282 - private PcepLspObject lspObject; 282 + private PcepLspObject lspObject;
283 - //PcepMsgPath 283 + //PcepMsgPath
284 - private PcepStateReport.PcepMsgPath msgPath; 284 + private PcepStateReport.PcepMsgPath msgPath;
285 - 285 +
286 - /** 286 + /**
287 - * Constructor to reset objects. 287 + * Constructor to reset objects.
288 - */ 288 + */
289 - public PcepStateReportVer1() { 289 + public PcepStateReportVer1() {
290 - this.srpObject = null; 290 + this.srpObject = null;
291 - this.lspObject = null; 291 + this.lspObject = null;
292 - this.msgPath = null; 292 + this.msgPath = null;
293 - } 293 + }
294 - 294 +
295 - public PcepStateReportVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepStateReport.PcepMsgPath msgPath) { 295 + public PcepStateReportVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepStateReport.PcepMsgPath msgPath) {
296 - this.srpObject = srpObject; 296 + this.srpObject = srpObject;
297 - this.lspObject = lspObject; 297 + this.lspObject = lspObject;
298 - this.msgPath = msgPath; 298 + this.msgPath = msgPath;
299 - } 299 + }
300 - 300 +
301 - @Override 301 + @Override
302 - public PcepSrpObject getSrpObject() { 302 + public PcepSrpObject getSrpObject() {
303 - return srpObject; 303 + return srpObject;
304 - } 304 + }
305 - 305 +
306 - @Override 306 + @Override
307 - public PcepLspObject getLspObject() { 307 + public PcepLspObject getLspObject() {
308 - return lspObject; 308 + return lspObject;
309 - } 309 + }
310 - 310 +
311 - @Override 311 + @Override
312 - public PcepStateReport.PcepMsgPath getMsgPath() { 312 + public PcepStateReport.PcepMsgPath getMsgPath() {
313 - return msgPath; 313 + return msgPath;
314 - } 314 + }
315 - 315 +
316 - @Override 316 + @Override
317 - public void setSrpObject(PcepSrpObject srpObj) { 317 + public void setSrpObject(PcepSrpObject srpObj) {
318 - this.srpObject = srpObj; 318 + this.srpObject = srpObj;
319 - } 319 + }
320 - 320 +
321 - @Override 321 + @Override
322 - public void setLspObject(PcepLspObject lspObject) { 322 + public void setLspObject(PcepLspObject lspObject) {
323 - this.lspObject = lspObject; 323 + this.lspObject = lspObject;
324 - } 324 + }
325 - 325 +
326 - @Override 326 + @Override
327 - public void setMsgPath(PcepStateReport.PcepMsgPath msgPath) { 327 + public void setMsgPath(PcepStateReport.PcepMsgPath msgPath) {
328 - this.msgPath = msgPath; 328 + this.msgPath = msgPath;
329 - } 329 + }
330 - 330 +
331 - /** 331 + /**
332 - * Builder class for PCEP state report. 332 + * Builder class for PCEP state report.
333 - */ 333 + */
334 - public static class Builder implements PcepStateReport.Builder { 334 + public static class Builder implements PcepStateReport.Builder {
335 - 335 +
336 - private boolean bIsSRPObjectSet = false; 336 + private boolean bIsSRPObjectSet = false;
337 - private boolean bIsLSPObjectSet = false; 337 + private boolean bIsLSPObjectSet = false;
338 - private boolean bIsPcepMsgPathSet = false; 338 + private boolean bIsPcepMsgPathSet = false;
339 - 339 +
340 - //PCEP SRP Object 340 + //PCEP SRP Object
341 - private PcepSrpObject srpObject; 341 + private PcepSrpObject srpObject;
342 - //PCEP LSP Object 342 + //PCEP LSP Object
343 - private PcepLspObject lspObject; 343 + private PcepLspObject lspObject;
344 - //PCEP Attribute list 344 + //PCEP Attribute list
345 - private PcepStateReport.PcepMsgPath msgPath; 345 + private PcepStateReport.PcepMsgPath msgPath;
346 - 346 +
347 - @Override 347 + @Override
348 - public PcepStateReport build() throws PcepParseException { 348 + public PcepStateReport build() throws PcepParseException {
349 - 349 +
350 - //PCEP SRP Object 350 + //PCEP SRP Object
351 - PcepSrpObject srpObject = null; 351 + PcepSrpObject srpObject = null;
352 - //PCEP LSP Object 352 + //PCEP LSP Object
353 - PcepLspObject lspObject = null; 353 + PcepLspObject lspObject = null;
354 - //PCEP Attribute list 354 + //PCEP Attribute list
355 - PcepStateReport.PcepMsgPath msgPath = null; 355 + PcepStateReport.PcepMsgPath msgPath = null;
356 - 356 +
357 - if (this.bIsSRPObjectSet) { 357 + if (this.bIsSRPObjectSet) {
358 - srpObject = this.srpObject; 358 + srpObject = this.srpObject;
359 - } 359 + }
360 - 360 +
361 - if (!this.bIsLSPObjectSet) { 361 + if (!this.bIsLSPObjectSet) {
362 - throw new PcepParseException(" LSP Object NOT Set while building PcepStateReport."); 362 + throw new PcepParseException(" LSP Object NOT Set while building PcepStateReport.");
363 - } else { 363 + } else {
364 - lspObject = this.lspObject; 364 + lspObject = this.lspObject;
365 - } 365 + }
366 - if (!this.bIsPcepMsgPathSet) { 366 + if (!this.bIsPcepMsgPathSet) {
367 - throw new PcepParseException(" Message Path NOT Set while building PcepStateReport."); 367 + throw new PcepParseException(" Message Path NOT Set while building PcepStateReport.");
368 - } else { 368 + } else {
369 - msgPath = this.msgPath; 369 + msgPath = this.msgPath;
370 - } 370 + }
371 - 371 +
372 - return new PcepStateReportVer1(srpObject, lspObject, msgPath); 372 + return new PcepStateReportVer1(srpObject, lspObject, msgPath);
373 - } 373 + }
374 - 374 +
375 - @Override 375 + @Override
376 - public PcepSrpObject getSrpObject() { 376 + public PcepSrpObject getSrpObject() {
377 - return this.srpObject; 377 + return this.srpObject;
378 - } 378 + }
379 - 379 +
380 - @Override 380 + @Override
381 - public PcepLspObject getLspObject() { 381 + public PcepLspObject getLspObject() {
382 - return this.lspObject; 382 + return this.lspObject;
383 - } 383 + }
384 - 384 +
385 - @Override 385 + @Override
386 - public PcepStateReport.PcepMsgPath getMsgPath() { 386 + public PcepStateReport.PcepMsgPath getMsgPath() {
387 - return this.msgPath; 387 + return this.msgPath;
388 - } 388 + }
389 - 389 +
390 - @Override 390 + @Override
391 - public Builder setSrpObject(PcepSrpObject srpobj) { 391 + public Builder setSrpObject(PcepSrpObject srpobj) {
392 - this.srpObject = srpobj; 392 + this.srpObject = srpobj;
393 - this.bIsSRPObjectSet = true; 393 + this.bIsSRPObjectSet = true;
394 - return this; 394 + return this;
395 - } 395 + }
396 - 396 +
397 - @Override 397 + @Override
398 - public Builder setLspObject(PcepLspObject lspObject) { 398 + public Builder setLspObject(PcepLspObject lspObject) {
399 - this.lspObject = lspObject; 399 + this.lspObject = lspObject;
400 - this.bIsLSPObjectSet = true; 400 + this.bIsLSPObjectSet = true;
401 - return this; 401 + return this;
402 - } 402 + }
403 - 403 +
404 - @Override 404 + @Override
405 - public Builder setMsgPath(PcepStateReport.PcepMsgPath msgPath) { 405 + public Builder setMsgPath(PcepStateReport.PcepMsgPath msgPath) {
406 - this.msgPath = msgPath; 406 + this.msgPath = msgPath;
407 - this.bIsPcepMsgPathSet = true; 407 + this.bIsPcepMsgPathSet = true;
408 - return this; 408 + return this;
409 - } 409 + }
410 - } 410 + }
411 - 411 +
412 - @Override 412 + @Override
413 - public String toString() { 413 + public String toString() {
414 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 414 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
415 - 415 +
416 - if (this.srpObject instanceof PcepSrpObject) { 416 + if (this.srpObject instanceof PcepSrpObject) {
417 - toStrHelper.add("SrpObject", srpObject); 417 + toStrHelper.add("SrpObject", srpObject);
418 - } 418 + }
419 - if (this.lspObject instanceof PcepLspObject) { 419 + if (this.lspObject instanceof PcepLspObject) {
420 - toStrHelper.add("LspObject", lspObject); 420 + toStrHelper.add("LspObject", lspObject);
421 - } 421 + }
422 - if (this.msgPath instanceof PcepStateReport.PcepMsgPath) { 422 + if (this.msgPath instanceof PcepStateReport.PcepMsgPath) {
423 - toStrHelper.add("MsgPath", msgPath); 423 + toStrHelper.add("MsgPath", msgPath);
424 - } 424 + }
425 - return toStrHelper.toString(); 425 + return toStrHelper.toString();
426 - } 426 + }
427 } 427 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.protocol.ver1; 17 +package org.onosproject.pcepio.protocol.ver1;
18 - 18 +
19 -import org.onosproject.pcepio.exceptions.PcepParseException; 19 +import org.onosproject.pcepio.exceptions.PcepParseException;
20 -import org.onosproject.pcepio.protocol.PcepLspObject; 20 +import org.onosproject.pcepio.protocol.PcepLspObject;
21 -import org.onosproject.pcepio.protocol.PcepMsgPath; 21 +import org.onosproject.pcepio.protocol.PcepMsgPath;
22 -import org.onosproject.pcepio.protocol.PcepSrpObject; 22 +import org.onosproject.pcepio.protocol.PcepSrpObject;
23 -import org.onosproject.pcepio.protocol.PcepUpdateRequest; 23 +import org.onosproject.pcepio.protocol.PcepUpdateRequest;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 - 28 +
29 -/** 29 +/**
30 - * Provides PCEP Update Request List. 30 + * Provides PCEP Update Request List.
31 - */ 31 + */
32 -public class PcepUpdateRequestVer1 implements PcepUpdateRequest { 32 +public class PcepUpdateRequestVer1 implements PcepUpdateRequest {
33 - 33 +
34 - /* <update-request-list> 34 + /* <update-request-list>
35 - * Where: 35 + * Where:
36 - * <update-request-list> ::= <update-request>[<update-request-list>] 36 + * <update-request-list> ::= <update-request>[<update-request-list>]
37 - * <update-request> ::= <SRP> 37 + * <update-request> ::= <SRP>
38 - * <LSP> 38 + * <LSP>
39 - * <path> 39 + * <path>
40 - * Where: 40 + * Where:
41 - * <path> ::= <ERO><attribute-list> 41 + * <path> ::= <ERO><attribute-list>
42 - * Where: 42 + * Where:
43 - * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions. 43 + * <attribute-list> is defined in [RFC5440] and extended by PCEP extensions.
44 - */ 44 + */
45 - 45 +
46 - protected static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class); 46 + protected static final Logger log = LoggerFactory.getLogger(PcepUpdateRequestVer1.class);
47 - 47 +
48 - //PCEP SRP Object 48 + //PCEP SRP Object
49 - private PcepSrpObject srpObject; 49 + private PcepSrpObject srpObject;
50 - //PCEP LSP Object 50 + //PCEP LSP Object
51 - private PcepLspObject lspObject; 51 + private PcepLspObject lspObject;
52 - //PCEP Message path 52 + //PCEP Message path
53 - private PcepMsgPath msgPath; 53 + private PcepMsgPath msgPath;
54 - 54 +
55 - /** 55 + /**
56 - * Default constructor. 56 + * Default constructor.
57 - */ 57 + */
58 - public PcepUpdateRequestVer1() { 58 + public PcepUpdateRequestVer1() {
59 - srpObject = null; 59 + srpObject = null;
60 - lspObject = null; 60 + lspObject = null;
61 - msgPath = null; 61 + msgPath = null;
62 - } 62 + }
63 - 63 +
64 - /** 64 + /**
65 - * Constructor to initialize all member variables. 65 + * Constructor to initialize all member variables.
66 - * 66 + *
67 - * @param srpObject srp object 67 + * @param srpObject srp object
68 - * @param lspObject lsp object 68 + * @param lspObject lsp object
69 - * @param msgPath message path object 69 + * @param msgPath message path object
70 - */ 70 + */
71 - public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) { 71 + public PcepUpdateRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject, PcepMsgPath msgPath) {
72 - this.srpObject = srpObject; 72 + this.srpObject = srpObject;
73 - this.lspObject = lspObject; 73 + this.lspObject = lspObject;
74 - this.msgPath = msgPath; 74 + this.msgPath = msgPath;
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepSrpObject getSrpObject() { 78 + public PcepSrpObject getSrpObject() {
79 - return srpObject; 79 + return srpObject;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public PcepLspObject getLspObject() { 83 + public PcepLspObject getLspObject() {
84 - return lspObject; 84 + return lspObject;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public PcepMsgPath getMsgPath() { 88 + public PcepMsgPath getMsgPath() {
89 - return msgPath; 89 + return msgPath;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public void setSrpObject(PcepSrpObject srpObject) { 93 + public void setSrpObject(PcepSrpObject srpObject) {
94 - this.srpObject = srpObject; 94 + this.srpObject = srpObject;
95 - 95 +
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public void setLspObject(PcepLspObject lspObject) { 99 + public void setLspObject(PcepLspObject lspObject) {
100 - this.lspObject = lspObject; 100 + this.lspObject = lspObject;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public void setMsgPath(PcepMsgPath msgPath) { 104 + public void setMsgPath(PcepMsgPath msgPath) {
105 - this.msgPath = msgPath; 105 + this.msgPath = msgPath;
106 - } 106 + }
107 - 107 +
108 - /** 108 + /**
109 - * Builder class for PCEP update request. 109 + * Builder class for PCEP update request.
110 - */ 110 + */
111 - public static class Builder implements PcepUpdateRequest.Builder { 111 + public static class Builder implements PcepUpdateRequest.Builder {
112 - 112 +
113 - private boolean bIsSRPObjectSet = false; 113 + private boolean bIsSRPObjectSet = false;
114 - private boolean bIsLSPObjectSet = false; 114 + private boolean bIsLSPObjectSet = false;
115 - private boolean bIsPcepMsgPathSet = false; 115 + private boolean bIsPcepMsgPathSet = false;
116 - 116 +
117 - //PCEP SRP Object 117 + //PCEP SRP Object
118 - private PcepSrpObject srpObject; 118 + private PcepSrpObject srpObject;
119 - //PCEP LSP Object 119 + //PCEP LSP Object
120 - private PcepLspObject lspObject; 120 + private PcepLspObject lspObject;
121 - //PCEP Attribute list 121 + //PCEP Attribute list
122 - private PcepMsgPath msgPath; 122 + private PcepMsgPath msgPath;
123 - 123 +
124 - @Override 124 + @Override
125 - public PcepUpdateRequest build() throws PcepParseException { 125 + public PcepUpdateRequest build() throws PcepParseException {
126 - 126 +
127 - //PCEP SRP Object 127 + //PCEP SRP Object
128 - PcepSrpObject srpObject = null; 128 + PcepSrpObject srpObject = null;
129 - //PCEP LSP Object 129 + //PCEP LSP Object
130 - PcepLspObject lspObject = null; 130 + PcepLspObject lspObject = null;
131 - //PCEP Attribute list 131 + //PCEP Attribute list
132 - PcepMsgPath msgPath = null; 132 + PcepMsgPath msgPath = null;
133 - 133 +
134 - if (!this.bIsSRPObjectSet) { 134 + if (!this.bIsSRPObjectSet) {
135 - throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest."); 135 + throw new PcepParseException(" SRP Object NOT Set while building PcepUpdateRequest.");
136 - } else { 136 + } else {
137 - srpObject = this.srpObject; 137 + srpObject = this.srpObject;
138 - } 138 + }
139 - if (!this.bIsLSPObjectSet) { 139 + if (!this.bIsLSPObjectSet) {
140 - throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest."); 140 + throw new PcepParseException(" LSP Object NOT Set while building PcepUpdateRequest.");
141 - } else { 141 + } else {
142 - lspObject = this.lspObject; 142 + lspObject = this.lspObject;
143 - } 143 + }
144 - if (!this.bIsPcepMsgPathSet) { 144 + if (!this.bIsPcepMsgPathSet) {
145 - throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest."); 145 + throw new PcepParseException(" Msg Path NOT Set while building PcepUpdateRequest.");
146 - } else { 146 + } else {
147 - msgPath = this.msgPath; 147 + msgPath = this.msgPath;
148 - } 148 + }
149 - 149 +
150 - return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath); 150 + return new PcepUpdateRequestVer1(srpObject, lspObject, msgPath);
151 - } 151 + }
152 - 152 +
153 - @Override 153 + @Override
154 - public PcepSrpObject getSrpObject() { 154 + public PcepSrpObject getSrpObject() {
155 - return this.srpObject; 155 + return this.srpObject;
156 - } 156 + }
157 - 157 +
158 - @Override 158 + @Override
159 - public PcepLspObject getLspObject() { 159 + public PcepLspObject getLspObject() {
160 - return this.lspObject; 160 + return this.lspObject;
161 - } 161 + }
162 - 162 +
163 - @Override 163 + @Override
164 - public PcepMsgPath getMsgPath() { 164 + public PcepMsgPath getMsgPath() {
165 - return this.msgPath; 165 + return this.msgPath;
166 - } 166 + }
167 - 167 +
168 - @Override 168 + @Override
169 - public Builder setSrpObject(PcepSrpObject srpobj) { 169 + public Builder setSrpObject(PcepSrpObject srpobj) {
170 - this.srpObject = srpobj; 170 + this.srpObject = srpobj;
171 - this.bIsSRPObjectSet = true; 171 + this.bIsSRPObjectSet = true;
172 - return this; 172 + return this;
173 - 173 +
174 - } 174 + }
175 - 175 +
176 - @Override 176 + @Override
177 - public Builder setLspObject(PcepLspObject lspObject) { 177 + public Builder setLspObject(PcepLspObject lspObject) {
178 - this.lspObject = lspObject; 178 + this.lspObject = lspObject;
179 - this.bIsLSPObjectSet = true; 179 + this.bIsLSPObjectSet = true;
180 - return this; 180 + return this;
181 - } 181 + }
182 - 182 +
183 - @Override 183 + @Override
184 - public Builder setMsgPath(PcepMsgPath msgPath) { 184 + public Builder setMsgPath(PcepMsgPath msgPath) {
185 - this.msgPath = msgPath; 185 + this.msgPath = msgPath;
186 - this.bIsPcepMsgPathSet = true; 186 + this.bIsPcepMsgPathSet = true;
187 - return this; 187 + return this;
188 - } 188 + }
189 - } 189 + }
190 - 190 +
191 - @Override 191 + @Override
192 - public String toString() { 192 + public String toString() {
193 - return MoreObjects.toStringHelper(getClass()).add("SrpObject", srpObject).add("LspObject", lspObject) 193 + return MoreObjects.toStringHelper(getClass()).add("SrpObject", srpObject).add("LspObject", lspObject)
194 - .add("MsgPath", msgPath).toString(); 194 + .add("MsgPath", msgPath).toString();
195 - } 195 + }
196 } 196 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides Administrative Group Tlv which contains value (32 Bit ). 28 + * Provides Administrative Group Tlv which contains value (32 Bit ).
29 - */ 29 + */
30 -public class AdministrativeGroupTlv implements PcepValueType { 30 +public class AdministrativeGroupTlv implements PcepValueType {
31 - 31 +
32 - /* REFERENCE :[RFC5305]/3.1 32 + /* REFERENCE :[RFC5305]/3.1
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TDB33] | Length=4 | 36 + | Type=[TDB33] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | value (32 Bit ) | 38 + | value (32 Bit ) |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(AdministrativeGroupTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(AdministrativeGroupTlv.class);
43 - 43 +
44 - public static final short TYPE = 3; //TDB33 44 + public static final short TYPE = 3; //TDB33
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue of Administrative-Group-Tlv. 52 + * @param rawValue of Administrative-Group-Tlv.
53 - */ 53 + */
54 - public AdministrativeGroupTlv(int rawValue) { 54 + public AdministrativeGroupTlv(int rawValue) {
55 - this.rawValue = rawValue; 55 + this.rawValue = rawValue;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Returns newly created AdministrativeGroupTlv object. 59 + * Returns newly created AdministrativeGroupTlv object.
60 - * 60 + *
61 - * @param raw value. 61 + * @param raw value.
62 - * @return object of Administrative-Group-Tlv 62 + * @return object of Administrative-Group-Tlv
63 - */ 63 + */
64 - public static AdministrativeGroupTlv of(final int raw) { 64 + public static AdministrativeGroupTlv of(final int raw) {
65 - return new AdministrativeGroupTlv(raw); 65 + return new AdministrativeGroupTlv(raw);
66 - } 66 + }
67 - 67 +
68 - /** 68 + /**
69 - * Returns raw value. 69 + * Returns raw value.
70 - * 70 + *
71 - * @return rawValue raw value 71 + * @return rawValue raw value
72 - */ 72 + */
73 - public int getInt() { 73 + public int getInt() {
74 - return rawValue; 74 + return rawValue;
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepVersion getVersion() { 78 + public PcepVersion getVersion() {
79 - return PcepVersion.PCEP_1; 79 + return PcepVersion.PCEP_1;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public short getType() { 83 + public short getType() {
84 - return TYPE; 84 + return TYPE;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public short getLength() { 88 + public short getLength() {
89 - return LENGTH; 89 + return LENGTH;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public int hashCode() { 93 + public int hashCode() {
94 - return Objects.hash(rawValue); 94 + return Objects.hash(rawValue);
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public boolean equals(Object obj) { 98 + public boolean equals(Object obj) {
99 - if (this == obj) { 99 + if (this == obj) {
100 - return true; 100 + return true;
101 - } 101 + }
102 - if (obj instanceof AdministrativeGroupTlv) { 102 + if (obj instanceof AdministrativeGroupTlv) {
103 - AdministrativeGroupTlv other = (AdministrativeGroupTlv) obj; 103 + AdministrativeGroupTlv other = (AdministrativeGroupTlv) obj;
104 - return Objects.equals(rawValue, other.rawValue); 104 + return Objects.equals(rawValue, other.rawValue);
105 - } 105 + }
106 - return false; 106 + return false;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int write(ChannelBuffer c) { 110 + public int write(ChannelBuffer c) {
111 - int iLenStartIndex = c.writerIndex(); 111 + int iLenStartIndex = c.writerIndex();
112 - c.writeShort(TYPE); 112 + c.writeShort(TYPE);
113 - c.writeShort(LENGTH); 113 + c.writeShort(LENGTH);
114 - c.writeInt(rawValue); 114 + c.writeInt(rawValue);
115 - return c.writerIndex() - iLenStartIndex; 115 + return c.writerIndex() - iLenStartIndex;
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * Reads the channel buffer and returns object of Administrative-Group-Tlv. 119 + * Reads the channel buffer and returns object of Administrative-Group-Tlv.
120 - * 120 + *
121 - * @param c input channel buffer 121 + * @param c input channel buffer
122 - * @return object of Administrative-Group-Tlv 122 + * @return object of Administrative-Group-Tlv
123 - */ 123 + */
124 - public static AdministrativeGroupTlv read(ChannelBuffer c) { 124 + public static AdministrativeGroupTlv read(ChannelBuffer c) {
125 - return AdministrativeGroupTlv.of(c.readInt()); 125 + return AdministrativeGroupTlv.of(c.readInt());
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public String toString() { 129 + public String toString() {
130 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 130 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
131 - .toString(); 131 + .toString();
132 - } 132 + }
133 -} 133 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides Autonomous-System-Tlv which contains opaque value (32 Bit AS Number). 28 + * Provides Autonomous-System-Tlv which contains opaque value (32 Bit AS Number).
29 - */ 29 + */
30 -public class AutonomousSystemTlv implements PcepValueType { 30 +public class AutonomousSystemTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :RFC3209 32 + /* Reference :RFC3209
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TBD10] | Length=4 | 36 + | Type=[TBD10] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | opaque value (32 Bit AS Number) | 38 + | opaque value (32 Bit AS Number) |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(AutonomousSystemTlv.class);
43 - 43 +
44 - public static final short TYPE = 100; //TODD:change this TBD10 44 + public static final short TYPE = 100; //TODD:change this TBD10
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue Autonomous-System-Tlv 52 + * @param rawValue Autonomous-System-Tlv
53 - */ 53 + */
54 - public AutonomousSystemTlv(int rawValue) { 54 + public AutonomousSystemTlv(int rawValue) {
55 - this.rawValue = rawValue; 55 + this.rawValue = rawValue;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Returns newly created AutonomousSystemTlv object. 59 + * Returns newly created AutonomousSystemTlv object.
60 - * 60 + *
61 - * @param raw value of opaque. 61 + * @param raw value of opaque.
62 - * @return object of Autonomous-System-Tlv 62 + * @return object of Autonomous-System-Tlv
63 - */ 63 + */
64 - public static AutonomousSystemTlv of(final int raw) { 64 + public static AutonomousSystemTlv of(final int raw) {
65 - return new AutonomousSystemTlv(raw); 65 + return new AutonomousSystemTlv(raw);
66 - } 66 + }
67 - 67 +
68 - /** 68 + /**
69 - * Returns opaque value. 69 + * Returns opaque value.
70 - * 70 + *
71 - * @return rawValue opaque value. 71 + * @return rawValue opaque value.
72 - */ 72 + */
73 - public int getInt() { 73 + public int getInt() {
74 - return rawValue; 74 + return rawValue;
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepVersion getVersion() { 78 + public PcepVersion getVersion() {
79 - return PcepVersion.PCEP_1; 79 + return PcepVersion.PCEP_1;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public short getType() { 83 + public short getType() {
84 - return TYPE; 84 + return TYPE;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public short getLength() { 88 + public short getLength() {
89 - return LENGTH; 89 + return LENGTH;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public int hashCode() { 93 + public int hashCode() {
94 - return Objects.hash(rawValue); 94 + return Objects.hash(rawValue);
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public boolean equals(Object obj) { 98 + public boolean equals(Object obj) {
99 - if (this == obj) { 99 + if (this == obj) {
100 - return true; 100 + return true;
101 - } 101 + }
102 - if (obj instanceof AutonomousSystemTlv) { 102 + if (obj instanceof AutonomousSystemTlv) {
103 - AutonomousSystemTlv other = (AutonomousSystemTlv) obj; 103 + AutonomousSystemTlv other = (AutonomousSystemTlv) obj;
104 - return Objects.equals(rawValue, other.rawValue); 104 + return Objects.equals(rawValue, other.rawValue);
105 - } 105 + }
106 - return false; 106 + return false;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int write(ChannelBuffer c) { 110 + public int write(ChannelBuffer c) {
111 - int iLenStartIndex = c.writerIndex(); 111 + int iLenStartIndex = c.writerIndex();
112 - c.writeShort(TYPE); 112 + c.writeShort(TYPE);
113 - c.writeShort(LENGTH); 113 + c.writeShort(LENGTH);
114 - c.writeInt(rawValue); 114 + c.writeInt(rawValue);
115 - return c.writerIndex() - iLenStartIndex; 115 + return c.writerIndex() - iLenStartIndex;
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * Reads the channel buffer and returns object of AutonomousSystemTlv. 119 + * Reads the channel buffer and returns object of AutonomousSystemTlv.
120 - * 120 + *
121 - * @param c input channel buffer 121 + * @param c input channel buffer
122 - * @return object of Autonomous-System-Tlv 122 + * @return object of Autonomous-System-Tlv
123 - */ 123 + */
124 - public static AutonomousSystemTlv read(ChannelBuffer c) { 124 + public static AutonomousSystemTlv read(ChannelBuffer c) {
125 - return AutonomousSystemTlv.of(c.readInt()); 125 + return AutonomousSystemTlv.of(c.readInt());
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public String toString() { 129 + public String toString() {
130 - return MoreObjects.toStringHelper(getClass()) 130 + return MoreObjects.toStringHelper(getClass())
131 - .add("TYPE", TYPE) 131 + .add("TYPE", TYPE)
132 - .add("Length", LENGTH) 132 + .add("Length", LENGTH)
133 - .add("value", rawValue) 133 + .add("value", rawValue)
134 - .toString(); 134 + .toString();
135 - } 135 + }
136 -} 136 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides BGP LS identifier which contains opaque value (32 Bit ID). 28 + * Provides BGP LS identifier which contains opaque value (32 Bit ID).
29 - */ 29 + */
30 -public class BGPLSidentifierTlv implements PcepValueType { 30 +public class BGPLSidentifierTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :draft-ietf-idr-ls-distribution-10 32 + /* Reference :draft-ietf-idr-ls-distribution-10
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TBD11] | Length=4 | 36 + | Type=[TBD11] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | opaque value (32 Bit ID). | 38 + | opaque value (32 Bit ID). |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(BGPLSidentifierTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(BGPLSidentifierTlv.class);
43 - 43 +
44 - public static final short TYPE = 17; //TODD:change this TBD11 44 + public static final short TYPE = 17; //TODD:change this TBD11
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * constructor to initialize rawValue. 50 + * constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue BGP LS identifier Tlv 52 + * @param rawValue BGP LS identifier Tlv
53 - */ 53 + */
54 - public BGPLSidentifierTlv(int rawValue) { 54 + public BGPLSidentifierTlv(int rawValue) {
55 - this.rawValue = rawValue; 55 + this.rawValue = rawValue;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Returns newly created BGPLSidentifierTlv object. 59 + * Returns newly created BGPLSidentifierTlv object.
60 - * 60 + *
61 - * @param raw value 61 + * @param raw value
62 - * @return object of BGPLSidentifierTlv 62 + * @return object of BGPLSidentifierTlv
63 - */ 63 + */
64 - public static BGPLSidentifierTlv of(final int raw) { 64 + public static BGPLSidentifierTlv of(final int raw) {
65 - return new BGPLSidentifierTlv(raw); 65 + return new BGPLSidentifierTlv(raw);
66 - } 66 + }
67 - 67 +
68 - /** 68 + /**
69 - * Returns opaque value. 69 + * Returns opaque value.
70 - * 70 + *
71 - * @return rawValue opaque value 71 + * @return rawValue opaque value
72 - */ 72 + */
73 - public int getInt() { 73 + public int getInt() {
74 - return rawValue; 74 + return rawValue;
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepVersion getVersion() { 78 + public PcepVersion getVersion() {
79 - return PcepVersion.PCEP_1; 79 + return PcepVersion.PCEP_1;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public short getType() { 83 + public short getType() {
84 - return TYPE; 84 + return TYPE;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public short getLength() { 88 + public short getLength() {
89 - return LENGTH; 89 + return LENGTH;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public int hashCode() { 93 + public int hashCode() {
94 - return Objects.hash(rawValue); 94 + return Objects.hash(rawValue);
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public boolean equals(Object obj) { 98 + public boolean equals(Object obj) {
99 - if (this == obj) { 99 + if (this == obj) {
100 - return true; 100 + return true;
101 - } 101 + }
102 - if (obj instanceof BGPLSidentifierTlv) { 102 + if (obj instanceof BGPLSidentifierTlv) {
103 - BGPLSidentifierTlv other = (BGPLSidentifierTlv) obj; 103 + BGPLSidentifierTlv other = (BGPLSidentifierTlv) obj;
104 - return Objects.equals(rawValue, other.rawValue); 104 + return Objects.equals(rawValue, other.rawValue);
105 - } 105 + }
106 - return false; 106 + return false;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int write(ChannelBuffer c) { 110 + public int write(ChannelBuffer c) {
111 - int iLenStartIndex = c.writerIndex(); 111 + int iLenStartIndex = c.writerIndex();
112 - c.writeShort(TYPE); 112 + c.writeShort(TYPE);
113 - c.writeShort(LENGTH); 113 + c.writeShort(LENGTH);
114 - c.writeInt(rawValue); 114 + c.writeInt(rawValue);
115 - return c.writerIndex() - iLenStartIndex; 115 + return c.writerIndex() - iLenStartIndex;
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * Reads the channel buffer and returns object of BGPLSidentifierTlv. 119 + * Reads the channel buffer and returns object of BGPLSidentifierTlv.
120 - * 120 + *
121 - * @param c input channel buffer 121 + * @param c input channel buffer
122 - * @return object of BGP LS identifier Tlv 122 + * @return object of BGP LS identifier Tlv
123 - */ 123 + */
124 - public static BGPLSidentifierTlv read(ChannelBuffer c) { 124 + public static BGPLSidentifierTlv read(ChannelBuffer c) {
125 - return BGPLSidentifierTlv.of(c.readInt()); 125 + return BGPLSidentifierTlv.of(c.readInt());
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public String toString() { 129 + public String toString() {
130 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 130 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
131 - .toString(); 131 + .toString();
132 - } 132 + }
133 -} 133 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Provides GMPLS Capability Tlv. 29 + * Provides GMPLS Capability Tlv.
30 - */ 30 + */
31 -public class GmplsCapabilityTlv implements PcepValueType { 31 +public class GmplsCapabilityTlv implements PcepValueType {
32 - 32 +
33 - /* 33 + /*
34 - * GMPLS-CAPABILITY TLV format 34 + * GMPLS-CAPABILITY TLV format
35 - * reference :draft-ietf-pce-gmpls-pcep-extensions -2.1.1 35 + * reference :draft-ietf-pce-gmpls-pcep-extensions -2.1.1
36 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | Type=14 | Length | 39 + | Type=14 | Length |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Flags | 41 + | Flags |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - */ 43 + */
44 - protected static final Logger log = LoggerFactory.getLogger(GmplsCapabilityTlv.class); 44 + protected static final Logger log = LoggerFactory.getLogger(GmplsCapabilityTlv.class);
45 - 45 +
46 - public static final short TYPE = 14; 46 + public static final short TYPE = 14;
47 - public static final short LENGTH = 4; 47 + public static final short LENGTH = 4;
48 - 48 +
49 - private final int rawValue; 49 + private final int rawValue;
50 - 50 +
51 - /** 51 + /**
52 - * Constructor to initialize raw value. 52 + * Constructor to initialize raw value.
53 - * 53 + *
54 - * @param rawValue of Gmpls-Capability-Tlv 54 + * @param rawValue of Gmpls-Capability-Tlv
55 - */ 55 + */
56 - public GmplsCapabilityTlv(int rawValue) { 56 + public GmplsCapabilityTlv(int rawValue) {
57 - this.rawValue = rawValue; 57 + this.rawValue = rawValue;
58 - } 58 + }
59 - 59 +
60 - /** 60 + /**
61 - * Returns newly created GmplsCapabilityTlv object. 61 + * Returns newly created GmplsCapabilityTlv object.
62 - * 62 + *
63 - * @param raw Flags value 63 + * @param raw Flags value
64 - * @return object of Gmpls-Capability-Tlv 64 + * @return object of Gmpls-Capability-Tlv
65 - */ 65 + */
66 - public static GmplsCapabilityTlv of(final int raw) { 66 + public static GmplsCapabilityTlv of(final int raw) {
67 - return new GmplsCapabilityTlv(raw); 67 + return new GmplsCapabilityTlv(raw);
68 - } 68 + }
69 - 69 +
70 - /** 70 + /**
71 - * Returns value of Flags. 71 + * Returns value of Flags.
72 - * 72 + *
73 - * @return rawValue Flags 73 + * @return rawValue Flags
74 - */ 74 + */
75 - public int getInt() { 75 + public int getInt() {
76 - return rawValue; 76 + return rawValue;
77 - } 77 + }
78 - 78 +
79 - @Override 79 + @Override
80 - public PcepVersion getVersion() { 80 + public PcepVersion getVersion() {
81 - return PcepVersion.PCEP_1; 81 + return PcepVersion.PCEP_1;
82 - } 82 + }
83 - 83 +
84 - @Override 84 + @Override
85 - public short getType() { 85 + public short getType() {
86 - return TYPE; 86 + return TYPE;
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public short getLength() { 90 + public short getLength() {
91 - return LENGTH; 91 + return LENGTH;
92 - } 92 + }
93 - 93 +
94 - @Override 94 + @Override
95 - public int hashCode() { 95 + public int hashCode() {
96 - return Objects.hash(rawValue); 96 + return Objects.hash(rawValue);
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public boolean equals(Object obj) { 100 + public boolean equals(Object obj) {
101 - if (this == obj) { 101 + if (this == obj) {
102 - return true; 102 + return true;
103 - } 103 + }
104 - if (obj instanceof GmplsCapabilityTlv) { 104 + if (obj instanceof GmplsCapabilityTlv) {
105 - GmplsCapabilityTlv other = (GmplsCapabilityTlv) obj; 105 + GmplsCapabilityTlv other = (GmplsCapabilityTlv) obj;
106 - return Objects.equals(rawValue, other.rawValue); 106 + return Objects.equals(rawValue, other.rawValue);
107 - } 107 + }
108 - return false; 108 + return false;
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public int write(ChannelBuffer c) { 112 + public int write(ChannelBuffer c) {
113 - int iLenStartIndex = c.writerIndex(); 113 + int iLenStartIndex = c.writerIndex();
114 - c.writeShort(TYPE); 114 + c.writeShort(TYPE);
115 - c.writeShort(LENGTH); 115 + c.writeShort(LENGTH);
116 - c.writeInt(rawValue); 116 + c.writeInt(rawValue);
117 - return c.writerIndex() - iLenStartIndex; 117 + return c.writerIndex() - iLenStartIndex;
118 - } 118 + }
119 - 119 +
120 - /** 120 + /**
121 - * Reads the channel buffer and returns object of Gmpls-Capability-Tlv. 121 + * Reads the channel buffer and returns object of Gmpls-Capability-Tlv.
122 - * 122 + *
123 - * @param c input channel buffer 123 + * @param c input channel buffer
124 - * @return object of Gmpls-Capability-Tlv 124 + * @return object of Gmpls-Capability-Tlv
125 - */ 125 + */
126 - public static GmplsCapabilityTlv read(ChannelBuffer c) { 126 + public static GmplsCapabilityTlv read(ChannelBuffer c) {
127 - return GmplsCapabilityTlv.of(c.readInt()); 127 + return GmplsCapabilityTlv.of(c.readInt());
128 - } 128 + }
129 - 129 +
130 - @Override 130 + @Override
131 - public String toString() { 131 + public String toString() {
132 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 132 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
133 - .toString(); 133 + .toString();
134 - } 134 + }
135 -} 135 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides IGP Link Metric . 29 + * Provides IGP Link Metric .
30 - */ 30 + */
31 -public class IGPMetricTlv implements PcepValueType { 31 +public class IGPMetricTlv implements PcepValueType {
32 - 32 +
33 - /* Reference :[I-D.ietf-idr-ls-distribution] /3.3.2.4 33 + /* Reference :[I-D.ietf-idr-ls-distribution] /3.3.2.4
34 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=TDB40 | Length | 37 + | Type=TDB40 | Length |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - // IGP Link Metric (variable length) // 39 + // IGP Link Metric (variable length) //
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - */ 41 + */
42 - 42 +
43 - protected static final Logger log = LoggerFactory.getLogger(IGPMetricTlv.class); 43 + protected static final Logger log = LoggerFactory.getLogger(IGPMetricTlv.class);
44 - 44 +
45 - public static final short TYPE = 1095; //TODO:NEED TO HANDLE TDB40 45 + public static final short TYPE = 1095; //TODO:NEED TO HANDLE TDB40
46 - private short hLength; 46 + private short hLength;
47 - 47 +
48 - private final byte[] rawValue; 48 + private final byte[] rawValue;
49 - 49 +
50 - /** 50 + /**
51 - * Constructor to initialize raw value. 51 + * Constructor to initialize raw value.
52 - * 52 + *
53 - * @param rawValue IGP Link Metric 53 + * @param rawValue IGP Link Metric
54 - * @param hLength length 54 + * @param hLength length
55 - */ 55 + */
56 - public IGPMetricTlv(byte[] rawValue, short hLength) { 56 + public IGPMetricTlv(byte[] rawValue, short hLength) {
57 - this.rawValue = rawValue; 57 + this.rawValue = rawValue;
58 - this.hLength = hLength; 58 + this.hLength = hLength;
59 - } 59 + }
60 - 60 +
61 - /** 61 + /**
62 - * Returns newly created IGPMetricTlv object. 62 + * Returns newly created IGPMetricTlv object.
63 - * 63 + *
64 - * @param raw value of IGP Link Metric 64 + * @param raw value of IGP Link Metric
65 - * @param hLength length 65 + * @param hLength length
66 - * @return object of IGPMetricTlv 66 + * @return object of IGPMetricTlv
67 - */ 67 + */
68 - public static IGPMetricTlv of(final byte[] raw, short hLength) { 68 + public static IGPMetricTlv of(final byte[] raw, short hLength) {
69 - return new IGPMetricTlv(raw, hLength); 69 + return new IGPMetricTlv(raw, hLength);
70 - } 70 + }
71 - 71 +
72 - /** 72 + /**
73 - * Returns value of IGP Link Metric. 73 + * Returns value of IGP Link Metric.
74 - * 74 + *
75 - * @return rawValue of IGP Link Metric 75 + * @return rawValue of IGP Link Metric
76 - */ 76 + */
77 - public byte[] getValue() { 77 + public byte[] getValue() {
78 - return rawValue; 78 + return rawValue;
79 - } 79 + }
80 - 80 +
81 - @Override 81 + @Override
82 - public PcepVersion getVersion() { 82 + public PcepVersion getVersion() {
83 - return PcepVersion.PCEP_1; 83 + return PcepVersion.PCEP_1;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public short getType() { 87 + public short getType() {
88 - return TYPE; 88 + return TYPE;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public short getLength() { 92 + public short getLength() {
93 - return hLength; 93 + return hLength;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public int hashCode() { 97 + public int hashCode() {
98 - return Objects.hash(rawValue); 98 + return Objects.hash(rawValue);
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public boolean equals(Object obj) { 102 + public boolean equals(Object obj) {
103 - if (this == obj) { 103 + if (this == obj) {
104 - return true; 104 + return true;
105 - } 105 + }
106 - if (obj instanceof IGPMetricTlv) { 106 + if (obj instanceof IGPMetricTlv) {
107 - IGPMetricTlv other = (IGPMetricTlv) obj; 107 + IGPMetricTlv other = (IGPMetricTlv) obj;
108 - return Objects.equals(rawValue, other.rawValue); 108 + return Objects.equals(rawValue, other.rawValue);
109 - } 109 + }
110 - return false; 110 + return false;
111 - } 111 + }
112 - 112 +
113 - @Override 113 + @Override
114 - public int write(ChannelBuffer c) { 114 + public int write(ChannelBuffer c) {
115 - int iLenStartIndex = c.writerIndex(); 115 + int iLenStartIndex = c.writerIndex();
116 - c.writeShort(TYPE); 116 + c.writeShort(TYPE);
117 - c.writeShort(hLength); 117 + c.writeShort(hLength);
118 - c.writeBytes(rawValue); 118 + c.writeBytes(rawValue);
119 - return c.writerIndex() - iLenStartIndex; 119 + return c.writerIndex() - iLenStartIndex;
120 - } 120 + }
121 - 121 +
122 - /** 122 + /**
123 - * Reads the channel buffer and returns object of IGPMetricTlv. 123 + * Reads the channel buffer and returns object of IGPMetricTlv.
124 - * 124 + *
125 - * @param c input channel buffer 125 + * @param c input channel buffer
126 - * @param hLength length 126 + * @param hLength length
127 - * @return object of IGPMetricTlv 127 + * @return object of IGPMetricTlv
128 - */ 128 + */
129 - public static PcepValueType read(ChannelBuffer c, short hLength) { 129 + public static PcepValueType read(ChannelBuffer c, short hLength) {
130 - byte[] iIGPMetric = new byte[hLength]; 130 + byte[] iIGPMetric = new byte[hLength];
131 - c.readBytes(iIGPMetric, 0, hLength); 131 + c.readBytes(iIGPMetric, 0, hLength);
132 - return new IGPMetricTlv(iIGPMetric, hLength); 132 + return new IGPMetricTlv(iIGPMetric, hLength);
133 - } 133 + }
134 - 134 +
135 - @Override 135 + @Override
136 - public String toString() { 136 + public String toString() {
137 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 137 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
138 - 138 +
139 - toStrHelper.add("Type", TYPE); 139 + toStrHelper.add("Type", TYPE);
140 - toStrHelper.add("Length", hLength); 140 + toStrHelper.add("Length", hLength);
141 - 141 +
142 - StringBuffer result = new StringBuffer(); 142 + StringBuffer result = new StringBuffer();
143 - for (byte b : rawValue) { 143 + for (byte b : rawValue) {
144 - result.append(String.format("%02X ", b)); 144 + result.append(String.format("%02X ", b));
145 - } 145 + }
146 - toStrHelper.add("Value", result); 146 + toStrHelper.add("Value", result);
147 - 147 +
148 - return toStrHelper.toString(); 148 + return toStrHelper.toString();
149 - } 149 + }
150 -} 150 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides IPv4 Interface Address . 28 + * Provides IPv4 Interface Address .
29 - */ 29 + */
30 -public class IPv4InterfaceAddressTlv implements PcepValueType { 30 +public class IPv4InterfaceAddressTlv implements PcepValueType {
31 - 31 +
32 - /* 32 + /*
33 - * reference :[RFC5305]/3.2 33 + * reference :[RFC5305]/3.2
34 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=6 | Length=4 | 37 + | Type=6 | Length=4 |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | IPv4 Interface Address | 39 + | IPv4 Interface Address |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - */ 41 + */
42 - 42 +
43 - protected static final Logger log = LoggerFactory.getLogger(IPv4InterfaceAddressTlv.class); 43 + protected static final Logger log = LoggerFactory.getLogger(IPv4InterfaceAddressTlv.class);
44 - 44 +
45 - public static final short TYPE = 6; 45 + public static final short TYPE = 6;
46 - public static final short LENGTH = 4; 46 + public static final short LENGTH = 4;
47 - 47 +
48 - private final int rawValue; 48 + private final int rawValue;
49 - 49 +
50 - /** 50 + /**
51 - * Constructor to initialize rawValue. 51 + * Constructor to initialize rawValue.
52 - * 52 + *
53 - * @param rawValue of IPv4-Interface-Address. 53 + * @param rawValue of IPv4-Interface-Address.
54 - */ 54 + */
55 - public IPv4InterfaceAddressTlv(int rawValue) { 55 + public IPv4InterfaceAddressTlv(int rawValue) {
56 - this.rawValue = rawValue; 56 + this.rawValue = rawValue;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Returns newly created IPv4InterfaceAddressTlv object. 60 + * Returns newly created IPv4InterfaceAddressTlv object.
61 - * 61 + *
62 - * @param raw value of IPv4-Interface-Address 62 + * @param raw value of IPv4-Interface-Address
63 - * @return object of IPv4-Interface-Address-Tlv 63 + * @return object of IPv4-Interface-Address-Tlv
64 - */ 64 + */
65 - public static IPv4InterfaceAddressTlv of(final int raw) { 65 + public static IPv4InterfaceAddressTlv of(final int raw) {
66 - return new IPv4InterfaceAddressTlv(raw); 66 + return new IPv4InterfaceAddressTlv(raw);
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns value of IPv4 Interface Address. 70 + * Returns value of IPv4 Interface Address.
71 - * 71 + *
72 - * @return rawValue IPv4 Interface Address 72 + * @return rawValue IPv4 Interface Address
73 - */ 73 + */
74 - public int getInt() { 74 + public int getInt() {
75 - return rawValue; 75 + return rawValue;
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public PcepVersion getVersion() { 79 + public PcepVersion getVersion() {
80 - return PcepVersion.PCEP_1; 80 + return PcepVersion.PCEP_1;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public short getType() { 84 + public short getType() {
85 - return TYPE; 85 + return TYPE;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public short getLength() { 89 + public short getLength() {
90 - return LENGTH; 90 + return LENGTH;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public int hashCode() { 94 + public int hashCode() {
95 - return Objects.hash(rawValue); 95 + return Objects.hash(rawValue);
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public boolean equals(Object obj) { 99 + public boolean equals(Object obj) {
100 - if (this == obj) { 100 + if (this == obj) {
101 - return true; 101 + return true;
102 - } 102 + }
103 - if (obj instanceof IPv4InterfaceAddressTlv) { 103 + if (obj instanceof IPv4InterfaceAddressTlv) {
104 - IPv4InterfaceAddressTlv other = (IPv4InterfaceAddressTlv) obj; 104 + IPv4InterfaceAddressTlv other = (IPv4InterfaceAddressTlv) obj;
105 - return Objects.equals(rawValue, other.rawValue); 105 + return Objects.equals(rawValue, other.rawValue);
106 - } 106 + }
107 - return false; 107 + return false;
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public int write(ChannelBuffer c) { 111 + public int write(ChannelBuffer c) {
112 - int iLenStartIndex = c.writerIndex(); 112 + int iLenStartIndex = c.writerIndex();
113 - c.writeShort(TYPE); 113 + c.writeShort(TYPE);
114 - c.writeShort(LENGTH); 114 + c.writeShort(LENGTH);
115 - c.writeInt(rawValue); 115 + c.writeInt(rawValue);
116 - return c.writerIndex() - iLenStartIndex; 116 + return c.writerIndex() - iLenStartIndex;
117 - } 117 + }
118 - 118 +
119 - /** 119 + /**
120 - * Reads the channel buffer and returns object of IPv4InterfaceAddressTlv. 120 + * Reads the channel buffer and returns object of IPv4InterfaceAddressTlv.
121 - * 121 + *
122 - * @param c input channel buffer 122 + * @param c input channel buffer
123 - * @return object of IPv4-Interface-Address-Tlv 123 + * @return object of IPv4-Interface-Address-Tlv
124 - */ 124 + */
125 - public static IPv4InterfaceAddressTlv read(ChannelBuffer c) { 125 + public static IPv4InterfaceAddressTlv read(ChannelBuffer c) {
126 - return IPv4InterfaceAddressTlv.of(c.readInt()); 126 + return IPv4InterfaceAddressTlv.of(c.readInt());
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public String toString() { 130 + public String toString() {
131 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 131 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
132 - .toString(); 132 + .toString();
133 - } 133 + }
134 } 134 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides IPv4 Neighbor Address . 28 + * Provides IPv4 Neighbor Address .
29 - */ 29 + */
30 -public class IPv4NeighborAddressTlv implements PcepValueType { 30 +public class IPv4NeighborAddressTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :[RFC5305]/3.3 32 + /* Reference :[RFC5305]/3.3
33 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=8 | Length=4 | 36 + | Type=8 | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | IPv4 Neighbor Address | 38 + | IPv4 Neighbor Address |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(IPv4NeighborAddressTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(IPv4NeighborAddressTlv.class);
43 - 43 +
44 - public static final short TYPE = 8; 44 + public static final short TYPE = 8;
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue IPv4-Neighbor-Address-Tlv 52 + * @param rawValue IPv4-Neighbor-Address-Tlv
53 - */ 53 + */
54 - public IPv4NeighborAddressTlv(int rawValue) { 54 + public IPv4NeighborAddressTlv(int rawValue) {
55 - log.debug("IPv4NeighborAddressTlv"); 55 + log.debug("IPv4NeighborAddressTlv");
56 - this.rawValue = rawValue; 56 + this.rawValue = rawValue;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Returns newly created IPv4NeighborAddressTlv object. 60 + * Returns newly created IPv4NeighborAddressTlv object.
61 - * 61 + *
62 - * @param raw value of IPv4-Neighbor-Address 62 + * @param raw value of IPv4-Neighbor-Address
63 - * @return object of IPv4NeighborAddressTlv 63 + * @return object of IPv4NeighborAddressTlv
64 - */ 64 + */
65 - public static IPv4NeighborAddressTlv of(final int raw) { 65 + public static IPv4NeighborAddressTlv of(final int raw) {
66 - return new IPv4NeighborAddressTlv(raw); 66 + return new IPv4NeighborAddressTlv(raw);
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns value of IPv4 Neighbor Address. 70 + * Returns value of IPv4 Neighbor Address.
71 - * 71 + *
72 - * @return rawValue IPv4 Neighbor Address 72 + * @return rawValue IPv4 Neighbor Address
73 - */ 73 + */
74 - public int getInt() { 74 + public int getInt() {
75 - return rawValue; 75 + return rawValue;
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public PcepVersion getVersion() { 79 + public PcepVersion getVersion() {
80 - return PcepVersion.PCEP_1; 80 + return PcepVersion.PCEP_1;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public short getType() { 84 + public short getType() {
85 - return TYPE; 85 + return TYPE;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public short getLength() { 89 + public short getLength() {
90 - return LENGTH; 90 + return LENGTH;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public int hashCode() { 94 + public int hashCode() {
95 - return Objects.hash(rawValue); 95 + return Objects.hash(rawValue);
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public boolean equals(Object obj) { 99 + public boolean equals(Object obj) {
100 - if (this == obj) { 100 + if (this == obj) {
101 - return true; 101 + return true;
102 - } 102 + }
103 - if (obj instanceof IPv4NeighborAddressTlv) { 103 + if (obj instanceof IPv4NeighborAddressTlv) {
104 - IPv4NeighborAddressTlv other = (IPv4NeighborAddressTlv) obj; 104 + IPv4NeighborAddressTlv other = (IPv4NeighborAddressTlv) obj;
105 - return Objects.equals(rawValue, other.rawValue); 105 + return Objects.equals(rawValue, other.rawValue);
106 - } 106 + }
107 - return false; 107 + return false;
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public int write(ChannelBuffer c) { 111 + public int write(ChannelBuffer c) {
112 - int iLenStartIndex = c.writerIndex(); 112 + int iLenStartIndex = c.writerIndex();
113 - c.writeShort(TYPE); 113 + c.writeShort(TYPE);
114 - c.writeShort(LENGTH); 114 + c.writeShort(LENGTH);
115 - c.writeInt(rawValue); 115 + c.writeInt(rawValue);
116 - return c.writerIndex() - iLenStartIndex; 116 + return c.writerIndex() - iLenStartIndex;
117 - } 117 + }
118 - 118 +
119 - /** 119 + /**
120 - * Reads the channel buffer and returns object of IPv4-Neighbor-Address-Tlv. 120 + * Reads the channel buffer and returns object of IPv4-Neighbor-Address-Tlv.
121 - * 121 + *
122 - * @param c input channel buffer 122 + * @param c input channel buffer
123 - * @return object of IPv4-Neighbor-Address-Tlv 123 + * @return object of IPv4-Neighbor-Address-Tlv
124 - */ 124 + */
125 - public static IPv4NeighborAddressTlv read(ChannelBuffer c) { 125 + public static IPv4NeighborAddressTlv read(ChannelBuffer c) {
126 - return IPv4NeighborAddressTlv.of(c.readInt()); 126 + return IPv4NeighborAddressTlv.of(c.readInt());
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public String toString() { 130 + public String toString() {
131 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 131 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
132 - .toString(); 132 + .toString();
133 - } 133 + }
134 } 134 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -/** 17 +/**
18 - * @author b00295750 18 + * @author b00295750
19 - * 19 + *
20 - */ 20 + */
21 -package org.onosproject.pcepio.types; 21 +package org.onosproject.pcepio.types;
22 - 22 +
23 -import java.util.Objects; 23 +import java.util.Objects;
24 - 24 +
25 -import org.jboss.netty.buffer.ChannelBuffer; 25 +import org.jboss.netty.buffer.ChannelBuffer;
26 -import org.onosproject.pcepio.protocol.PcepVersion; 26 +import org.onosproject.pcepio.protocol.PcepVersion;
27 -import org.slf4j.Logger; 27 +import org.slf4j.Logger;
28 -import org.slf4j.LoggerFactory; 28 +import org.slf4j.LoggerFactory;
29 - 29 +
30 -import com.google.common.base.MoreObjects; 30 +import com.google.common.base.MoreObjects;
31 - 31 +
32 -/** 32 +/**
33 - * Provides IPv4 Sub Object. 33 + * Provides IPv4 Sub Object.
34 - */ 34 + */
35 -public class IPv4SubObject implements PcepValueType { 35 +public class IPv4SubObject implements PcepValueType {
36 - 36 +
37 - /*Reference : RFC 4874:3.1.1 37 + /*Reference : RFC 4874:3.1.1
38 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - |L| Type | Length | IPv4 address (4 bytes) | 41 + |L| Type | Length | IPv4 address (4 bytes) |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | IPv4 address (continued) | Prefix Length | Resvd | 43 + | IPv4 address (continued) | Prefix Length | Resvd |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - */ 45 + */
46 - protected static final Logger log = LoggerFactory.getLogger(IPv4SubObject.class); 46 + protected static final Logger log = LoggerFactory.getLogger(IPv4SubObject.class);
47 - 47 +
48 - public static final byte TYPE = 0x01; 48 + public static final byte TYPE = 0x01;
49 - public static final byte LENGTH = 8; 49 + public static final byte LENGTH = 8;
50 - public static final byte VALUE_LENGTH = 6; 50 + public static final byte VALUE_LENGTH = 6;
51 - public static final byte OBJ_LENGTH = 8; 51 + public static final byte OBJ_LENGTH = 8;
52 - public static final byte LBIT = 0; 52 + public static final byte LBIT = 0;
53 - public static final int SHIFT_LBIT_POSITION = 7; 53 + public static final int SHIFT_LBIT_POSITION = 7;
54 - private int ipAddress; 54 + private int ipAddress;
55 - private byte prefixLen; 55 + private byte prefixLen;
56 - private byte resvd; 56 + private byte resvd;
57 - 57 +
58 - /** 58 + /**
59 - * Constructor to initialize ipv4 address. 59 + * Constructor to initialize ipv4 address.
60 - * 60 + *
61 - * @param ipAddr ipv4 address 61 + * @param ipAddr ipv4 address
62 - */ 62 + */
63 - public IPv4SubObject(int ipAddr) { 63 + public IPv4SubObject(int ipAddr) {
64 - this.ipAddress = ipAddr; 64 + this.ipAddress = ipAddr;
65 - } 65 + }
66 - 66 +
67 - /** 67 + /**
68 - * constructor to initialize ipAddress, prefixLen and resvd. 68 + * constructor to initialize ipAddress, prefixLen and resvd.
69 - * 69 + *
70 - * @param ipAddress ipv4 address 70 + * @param ipAddress ipv4 address
71 - * @param prefixLen prefix length 71 + * @param prefixLen prefix length
72 - * @param resvd reserved flags value 72 + * @param resvd reserved flags value
73 - */ 73 + */
74 - public IPv4SubObject(int ipAddress, byte prefixLen, byte resvd) { 74 + public IPv4SubObject(int ipAddress, byte prefixLen, byte resvd) {
75 - this.ipAddress = ipAddress; 75 + this.ipAddress = ipAddress;
76 - this.prefixLen = prefixLen; 76 + this.prefixLen = prefixLen;
77 - this.resvd = resvd; 77 + this.resvd = resvd;
78 - } 78 + }
79 - 79 +
80 - /** 80 + /**
81 - * Returns a new instance of IPv4SubObject. 81 + * Returns a new instance of IPv4SubObject.
82 - * 82 + *
83 - * @param ipAddress ipv4 address 83 + * @param ipAddress ipv4 address
84 - * @param prefixLen prefix length 84 + * @param prefixLen prefix length
85 - * @param resvd reserved flags value 85 + * @param resvd reserved flags value
86 - * @return object of IPv4SubObject 86 + * @return object of IPv4SubObject
87 - */ 87 + */
88 - public static IPv4SubObject of(int ipAddress, byte prefixLen, byte resvd) { 88 + public static IPv4SubObject of(int ipAddress, byte prefixLen, byte resvd) {
89 - return new IPv4SubObject(ipAddress, prefixLen, resvd); 89 + return new IPv4SubObject(ipAddress, prefixLen, resvd);
90 - } 90 + }
91 - 91 +
92 - /** 92 + /**
93 - * Returns prefixLen of IPv4 IP address. 93 + * Returns prefixLen of IPv4 IP address.
94 - * 94 + *
95 - * @return byte value of rawValue 95 + * @return byte value of rawValue
96 - */ 96 + */
97 - public byte getPrefixLen() { 97 + public byte getPrefixLen() {
98 - return prefixLen; 98 + return prefixLen;
99 - } 99 + }
100 - 100 +
101 - /** 101 + /**
102 - * Returns value of IPv4 IP address. 102 + * Returns value of IPv4 IP address.
103 - * 103 + *
104 - * @return int value of ipv4 address 104 + * @return int value of ipv4 address
105 - */ 105 + */
106 - public int getIpAddress() { 106 + public int getIpAddress() {
107 - return ipAddress; 107 + return ipAddress;
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public PcepVersion getVersion() { 111 + public PcepVersion getVersion() {
112 - return PcepVersion.PCEP_1; 112 + return PcepVersion.PCEP_1;
113 - } 113 + }
114 - 114 +
115 - @Override 115 + @Override
116 - public short getType() { 116 + public short getType() {
117 - return TYPE; 117 + return TYPE;
118 - } 118 + }
119 - 119 +
120 - @Override 120 + @Override
121 - public short getLength() { 121 + public short getLength() {
122 - return LENGTH; 122 + return LENGTH;
123 - } 123 + }
124 - 124 +
125 - @Override 125 + @Override
126 - public int hashCode() { 126 + public int hashCode() {
127 - return Objects.hash(ipAddress, prefixLen, resvd); 127 + return Objects.hash(ipAddress, prefixLen, resvd);
128 - } 128 + }
129 - 129 +
130 - @Override 130 + @Override
131 - public boolean equals(Object obj) { 131 + public boolean equals(Object obj) {
132 - if (this == obj) { 132 + if (this == obj) {
133 - return true; 133 + return true;
134 - } 134 + }
135 - if (obj instanceof IPv4SubObject) { 135 + if (obj instanceof IPv4SubObject) {
136 - IPv4SubObject other = (IPv4SubObject) obj; 136 + IPv4SubObject other = (IPv4SubObject) obj;
137 - return Objects.equals(this.ipAddress, other.ipAddress) && Objects.equals(this.prefixLen, other.prefixLen) 137 + return Objects.equals(this.ipAddress, other.ipAddress) && Objects.equals(this.prefixLen, other.prefixLen)
138 - && Objects.equals(this.resvd, other.resvd); 138 + && Objects.equals(this.resvd, other.resvd);
139 - } 139 + }
140 - return false; 140 + return false;
141 - } 141 + }
142 - 142 +
143 - /** 143 + /**
144 - * Reads the channel buffer and returns object of IPv4SubObject. 144 + * Reads the channel buffer and returns object of IPv4SubObject.
145 - * 145 + *
146 - * @param c type of channel buffer 146 + * @param c type of channel buffer
147 - * @return object of IPv4SubObject 147 + * @return object of IPv4SubObject
148 - */ 148 + */
149 - public static PcepValueType read(ChannelBuffer c) { 149 + public static PcepValueType read(ChannelBuffer c) {
150 - int ipAddess = c.readInt(); 150 + int ipAddess = c.readInt();
151 - byte prefixLen = c.readByte(); 151 + byte prefixLen = c.readByte();
152 - byte resvd = c.readByte(); 152 + byte resvd = c.readByte();
153 - return new IPv4SubObject(ipAddess, prefixLen, resvd); 153 + return new IPv4SubObject(ipAddess, prefixLen, resvd);
154 - } 154 + }
155 - 155 +
156 - @Override 156 + @Override
157 - public int write(ChannelBuffer c) { 157 + public int write(ChannelBuffer c) {
158 - int iLenStartIndex = c.writerIndex(); 158 + int iLenStartIndex = c.writerIndex();
159 - byte bValue = LBIT; 159 + byte bValue = LBIT;
160 - bValue = (byte) (bValue << SHIFT_LBIT_POSITION); 160 + bValue = (byte) (bValue << SHIFT_LBIT_POSITION);
161 - bValue = (byte) (bValue | TYPE); 161 + bValue = (byte) (bValue | TYPE);
162 - c.writeByte(bValue); 162 + c.writeByte(bValue);
163 - c.writeByte(OBJ_LENGTH); 163 + c.writeByte(OBJ_LENGTH);
164 - c.writeInt(ipAddress); 164 + c.writeInt(ipAddress);
165 - c.writeByte(prefixLen); 165 + c.writeByte(prefixLen);
166 - c.writeByte(resvd); 166 + c.writeByte(resvd);
167 - 167 +
168 - return c.writerIndex() - iLenStartIndex; 168 + return c.writerIndex() - iLenStartIndex;
169 - } 169 + }
170 - 170 +
171 - @Override 171 + @Override
172 - public String toString() { 172 + public String toString() {
173 - return MoreObjects.toStringHelper(getClass()) 173 + return MoreObjects.toStringHelper(getClass())
174 - .add("Type", TYPE) 174 + .add("Type", TYPE)
175 - .add("Length", LENGTH) 175 + .add("Length", LENGTH)
176 - .add("IPv4Address", ipAddress) 176 + .add("IPv4Address", ipAddress)
177 - .add("PrefixLength", prefixLen) 177 + .add("PrefixLength", prefixLen)
178 - .toString(); 178 + .toString();
179 - } 179 + }
180 -} 180 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides IPv4 TE Router Id Of Local Node. 28 + * Provides IPv4 TE Router Id Of Local Node.
29 - */ 29 + */
30 -public class IPv4TERouterIdOfLocalNodeTlv implements PcepValueType { 30 +public class IPv4TERouterIdOfLocalNodeTlv implements PcepValueType {
31 - 31 +
32 - /* Reference:[RFC5305]/4.3 32 + /* Reference:[RFC5305]/4.3
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TDB25] | Length=4 | 36 + | Type=[TDB25] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | IPv4 TE Router Id Of Local Node | 38 + | IPv4 TE Router Id Of Local Node |
39 - +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+- 39 + +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfLocalNodeTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfLocalNodeTlv.class);
43 - 43 +
44 - public static final short TYPE = 134; //TDB25 44 + public static final short TYPE = 134; //TDB25
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue IPv4-TE-RouterId-Of-Local-Node-Tlv 52 + * @param rawValue IPv4-TE-RouterId-Of-Local-Node-Tlv
53 - */ 53 + */
54 - public IPv4TERouterIdOfLocalNodeTlv(int rawValue) { 54 + public IPv4TERouterIdOfLocalNodeTlv(int rawValue) {
55 - this.rawValue = rawValue; 55 + this.rawValue = rawValue;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Returns newly created IPv4TERouterIdOfLocalNodeTlv object. 59 + * Returns newly created IPv4TERouterIdOfLocalNodeTlv object.
60 - * 60 + *
61 - * @param raw value of IPv4-TE-RouterId-Of-Local-Node 61 + * @param raw value of IPv4-TE-RouterId-Of-Local-Node
62 - * @return object of IPv4TERouterIdOfLocalNodeTlv 62 + * @return object of IPv4TERouterIdOfLocalNodeTlv
63 - */ 63 + */
64 - public static IPv4TERouterIdOfLocalNodeTlv of(final int raw) { 64 + public static IPv4TERouterIdOfLocalNodeTlv of(final int raw) {
65 - return new IPv4TERouterIdOfLocalNodeTlv(raw); 65 + return new IPv4TERouterIdOfLocalNodeTlv(raw);
66 - } 66 + }
67 - 67 +
68 - /** 68 + /**
69 - * Returns value of IPv4 TE Router Id Of Local Node. 69 + * Returns value of IPv4 TE Router Id Of Local Node.
70 - * 70 + *
71 - * @return rawValue IPv4 TE Router Id Of Local Node 71 + * @return rawValue IPv4 TE Router Id Of Local Node
72 - */ 72 + */
73 - public int getInt() { 73 + public int getInt() {
74 - return rawValue; 74 + return rawValue;
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepVersion getVersion() { 78 + public PcepVersion getVersion() {
79 - return PcepVersion.PCEP_1; 79 + return PcepVersion.PCEP_1;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public short getType() { 83 + public short getType() {
84 - return TYPE; 84 + return TYPE;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public short getLength() { 88 + public short getLength() {
89 - return LENGTH; 89 + return LENGTH;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public int hashCode() { 93 + public int hashCode() {
94 - return Objects.hash(rawValue); 94 + return Objects.hash(rawValue);
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public boolean equals(Object obj) { 98 + public boolean equals(Object obj) {
99 - if (this == obj) { 99 + if (this == obj) {
100 - return true; 100 + return true;
101 - } 101 + }
102 - if (obj instanceof IPv4TERouterIdOfLocalNodeTlv) { 102 + if (obj instanceof IPv4TERouterIdOfLocalNodeTlv) {
103 - IPv4TERouterIdOfLocalNodeTlv other = (IPv4TERouterIdOfLocalNodeTlv) obj; 103 + IPv4TERouterIdOfLocalNodeTlv other = (IPv4TERouterIdOfLocalNodeTlv) obj;
104 - return Objects.equals(rawValue, other.rawValue); 104 + return Objects.equals(rawValue, other.rawValue);
105 - } 105 + }
106 - return false; 106 + return false;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int write(ChannelBuffer c) { 110 + public int write(ChannelBuffer c) {
111 - int iLenStartIndex = c.writerIndex(); 111 + int iLenStartIndex = c.writerIndex();
112 - c.writeShort(TYPE); 112 + c.writeShort(TYPE);
113 - c.writeShort(LENGTH); 113 + c.writeShort(LENGTH);
114 - c.writeInt(rawValue); 114 + c.writeInt(rawValue);
115 - return c.writerIndex() - iLenStartIndex; 115 + return c.writerIndex() - iLenStartIndex;
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * Reads the channel buffer and returns object of IPv4TERouterIdOfLocalNodeTlv. 119 + * Reads the channel buffer and returns object of IPv4TERouterIdOfLocalNodeTlv.
120 - * 120 + *
121 - * @param c input channel buffer 121 + * @param c input channel buffer
122 - * @return object of IPv4TERouterIdOfLocalNodeTlv 122 + * @return object of IPv4TERouterIdOfLocalNodeTlv
123 - */ 123 + */
124 - public static IPv4TERouterIdOfLocalNodeTlv read(ChannelBuffer c) { 124 + public static IPv4TERouterIdOfLocalNodeTlv read(ChannelBuffer c) {
125 - return IPv4TERouterIdOfLocalNodeTlv.of(c.readInt()); 125 + return IPv4TERouterIdOfLocalNodeTlv.of(c.readInt());
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public String toString() { 129 + public String toString() {
130 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 130 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
131 - .toString(); 131 + .toString();
132 - } 132 + }
133 -} 133 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides IPv4 TE Router Id Of Remote Node. 28 + * Provides IPv4 TE Router Id Of Remote Node.
29 - */ 29 + */
30 -public class IPv4TERouterIdOfRemoteNodeTlv implements PcepValueType { 30 +public class IPv4TERouterIdOfRemoteNodeTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :[RFC5305]/4.3 32 + /* Reference :[RFC5305]/4.3
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TDB28] | Length=4 | 36 + | Type=[TDB28] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | IPv4 TE Router Id Of Remote Node | 38 + | IPv4 TE Router Id Of Remote Node |
39 - +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+- 39 + +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfRemoteNodeTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(IPv4TERouterIdOfRemoteNodeTlv.class);
43 - 43 +
44 - public static final short TYPE = 1340; //TDB28 44 + public static final short TYPE = 1340; //TDB28
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue IPv4 TE RouterId Of Remote Node Tlv 52 + * @param rawValue IPv4 TE RouterId Of Remote Node Tlv
53 - */ 53 + */
54 - public IPv4TERouterIdOfRemoteNodeTlv(int rawValue) { 54 + public IPv4TERouterIdOfRemoteNodeTlv(int rawValue) {
55 - log.debug("IPv4TERouterIdOfRemoteNodeTlv"); 55 + log.debug("IPv4TERouterIdOfRemoteNodeTlv");
56 - this.rawValue = rawValue; 56 + this.rawValue = rawValue;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Returns newly created IPv4TERouterIdOfRemoteNodeTlv object. 60 + * Returns newly created IPv4TERouterIdOfRemoteNodeTlv object.
61 - * 61 + *
62 - * @param raw IPv4 TE RouterId Of Remote Node 62 + * @param raw IPv4 TE RouterId Of Remote Node
63 - * @return object of IPv4TERouterIdOfRemoteNodeTlv 63 + * @return object of IPv4TERouterIdOfRemoteNodeTlv
64 - */ 64 + */
65 - public static IPv4TERouterIdOfRemoteNodeTlv of(final int raw) { 65 + public static IPv4TERouterIdOfRemoteNodeTlv of(final int raw) {
66 - return new IPv4TERouterIdOfRemoteNodeTlv(raw); 66 + return new IPv4TERouterIdOfRemoteNodeTlv(raw);
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns value of IPv4 TE Router Id Of Remote Node. 70 + * Returns value of IPv4 TE Router Id Of Remote Node.
71 - * 71 + *
72 - * @return rawValue IPv4 TE Router Id Of Remote Node 72 + * @return rawValue IPv4 TE Router Id Of Remote Node
73 - */ 73 + */
74 - public int getInt() { 74 + public int getInt() {
75 - return rawValue; 75 + return rawValue;
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public PcepVersion getVersion() { 79 + public PcepVersion getVersion() {
80 - return PcepVersion.PCEP_1; 80 + return PcepVersion.PCEP_1;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public short getType() { 84 + public short getType() {
85 - return TYPE; 85 + return TYPE;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public short getLength() { 89 + public short getLength() {
90 - return LENGTH; 90 + return LENGTH;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public int hashCode() { 94 + public int hashCode() {
95 - return Objects.hash(rawValue); 95 + return Objects.hash(rawValue);
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public boolean equals(Object obj) { 99 + public boolean equals(Object obj) {
100 - if (this == obj) { 100 + if (this == obj) {
101 - return true; 101 + return true;
102 - } 102 + }
103 - if (obj instanceof IPv4TERouterIdOfRemoteNodeTlv) { 103 + if (obj instanceof IPv4TERouterIdOfRemoteNodeTlv) {
104 - IPv4TERouterIdOfRemoteNodeTlv other = (IPv4TERouterIdOfRemoteNodeTlv) obj; 104 + IPv4TERouterIdOfRemoteNodeTlv other = (IPv4TERouterIdOfRemoteNodeTlv) obj;
105 - return Objects.equals(rawValue, other.rawValue); 105 + return Objects.equals(rawValue, other.rawValue);
106 - } 106 + }
107 - return false; 107 + return false;
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public int write(ChannelBuffer c) { 111 + public int write(ChannelBuffer c) {
112 - int iLenStartIndex = c.writerIndex(); 112 + int iLenStartIndex = c.writerIndex();
113 - c.writeShort(TYPE); 113 + c.writeShort(TYPE);
114 - c.writeShort(LENGTH); 114 + c.writeShort(LENGTH);
115 - c.writeInt(rawValue); 115 + c.writeInt(rawValue);
116 - return c.writerIndex() - iLenStartIndex; 116 + return c.writerIndex() - iLenStartIndex;
117 - } 117 + }
118 - 118 +
119 - /** 119 + /**
120 - * Reads the channel buffer and returns object of IPv4TERouterIdOfRemoteNodeTlv. 120 + * Reads the channel buffer and returns object of IPv4TERouterIdOfRemoteNodeTlv.
121 - * 121 + *
122 - * @param c input channel buffer 122 + * @param c input channel buffer
123 - * @return object of IPv4TERouterIdOfRemoteNodeTlv 123 + * @return object of IPv4TERouterIdOfRemoteNodeTlv
124 - */ 124 + */
125 - public static IPv4TERouterIdOfRemoteNodeTlv read(ChannelBuffer c) { 125 + public static IPv4TERouterIdOfRemoteNodeTlv read(ChannelBuffer c) {
126 - return IPv4TERouterIdOfRemoteNodeTlv.of(c.readInt()); 126 + return IPv4TERouterIdOfRemoteNodeTlv.of(c.readInt());
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public String toString() { 130 + public String toString() {
131 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 131 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
132 - .toString(); 132 + .toString();
133 - } 133 + }
134 -} 134 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides IPv6 Interface Address. REFERENCE :[RFC6119]/4.2. 29 + * Provides IPv6 Interface Address. REFERENCE :[RFC6119]/4.2.
30 - */ 30 + */
31 -public class IPv6InterfaceAddressTlv implements PcepValueType { 31 +public class IPv6InterfaceAddressTlv implements PcepValueType {
32 - 32 +
33 - protected static final Logger log = LoggerFactory.getLogger(IPv6InterfaceAddressTlv.class); 33 + protected static final Logger log = LoggerFactory.getLogger(IPv6InterfaceAddressTlv.class);
34 - 34 +
35 - public static final short TYPE = 12; //TDB18 35 + public static final short TYPE = 12; //TDB18
36 - public static final short LENGTH = 20; 36 + public static final short LENGTH = 20;
37 - public static final byte VALUE_LENGTH = 18; 37 + public static final byte VALUE_LENGTH = 18;
38 - 38 +
39 - 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}; 39 + 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};
40 - public static final IPv6InterfaceAddressTlv NONE = new IPv6InterfaceAddressTlv(NONE_VAL); 40 + public static final IPv6InterfaceAddressTlv NONE = new IPv6InterfaceAddressTlv(NONE_VAL);
41 - 41 +
42 - private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 42 + private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
43 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 43 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
44 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; 44 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
45 - public static final IPv6InterfaceAddressTlv NO_MASK = new IPv6InterfaceAddressTlv(NO_MASK_VAL); 45 + public static final IPv6InterfaceAddressTlv NO_MASK = new IPv6InterfaceAddressTlv(NO_MASK_VAL);
46 - public static final IPv6InterfaceAddressTlv FULL_MASK = NONE; 46 + public static final IPv6InterfaceAddressTlv FULL_MASK = NONE;
47 - 47 +
48 - private final byte[] rawValue; 48 + private final byte[] rawValue;
49 - 49 +
50 - /** 50 + /**
51 - * Constructor to initialize rawValue. 51 + * Constructor to initialize rawValue.
52 - * 52 + *
53 - * @param rawValue IPv6 Interface Address Tlv 53 + * @param rawValue IPv6 Interface Address Tlv
54 - */ 54 + */
55 - public IPv6InterfaceAddressTlv(byte[] rawValue) { 55 + public IPv6InterfaceAddressTlv(byte[] rawValue) {
56 - log.debug("IPv6InterfaceAddressTlv"); 56 + log.debug("IPv6InterfaceAddressTlv");
57 - this.rawValue = rawValue; 57 + this.rawValue = rawValue;
58 - } 58 + }
59 - 59 +
60 - /** 60 + /**
61 - * Returns newly created IPv6InterfaceAddressTlv object. 61 + * Returns newly created IPv6InterfaceAddressTlv object.
62 - * 62 + *
63 - * @param raw IPv6 Interface Address 63 + * @param raw IPv6 Interface Address
64 - * @return object of IPv6InterfaceAddressTlv 64 + * @return object of IPv6InterfaceAddressTlv
65 - */ 65 + */
66 - public static IPv6InterfaceAddressTlv of(final byte[] raw) { 66 + public static IPv6InterfaceAddressTlv of(final byte[] raw) {
67 - //check NONE_VAL 67 + //check NONE_VAL
68 - boolean bFoundNONE = true; 68 + boolean bFoundNONE = true;
69 - //value starts from 3rd byte. 69 + //value starts from 3rd byte.
70 - for (int i = 2; i < 20; ++i) { 70 + for (int i = 2; i < 20; ++i) {
71 - if (NONE_VAL[i] != raw[i]) { 71 + if (NONE_VAL[i] != raw[i]) {
72 - bFoundNONE = false; 72 + bFoundNONE = false;
73 - } 73 + }
74 - } 74 + }
75 - 75 +
76 - if (bFoundNONE) { 76 + if (bFoundNONE) {
77 - return NONE; 77 + return NONE;
78 - } 78 + }
79 - 79 +
80 - //check NO_MASK_VAL 80 + //check NO_MASK_VAL
81 - boolean bFoundNoMask = true; 81 + boolean bFoundNoMask = true;
82 - //value starts from 3rd byte. 82 + //value starts from 3rd byte.
83 - for (int i = 2; i < 20; ++i) { 83 + for (int i = 2; i < 20; ++i) {
84 - if (0xFF != raw[i]) { 84 + if (0xFF != raw[i]) {
85 - bFoundNoMask = false; 85 + bFoundNoMask = false;
86 - } 86 + }
87 - } 87 + }
88 - if (bFoundNoMask) { 88 + if (bFoundNoMask) {
89 - return NO_MASK; 89 + return NO_MASK;
90 - } 90 + }
91 - 91 +
92 - return new IPv6InterfaceAddressTlv(raw); 92 + return new IPv6InterfaceAddressTlv(raw);
93 - } 93 + }
94 - 94 +
95 - /** 95 + /**
96 - * Returns value of IPv6 Interface Address. 96 + * Returns value of IPv6 Interface Address.
97 - * 97 + *
98 - * @return rawValue raw value 98 + * @return rawValue raw value
99 - */ 99 + */
100 - public byte[] getBytes() { 100 + public byte[] getBytes() {
101 - return rawValue; 101 + return rawValue;
102 - } 102 + }
103 - 103 +
104 - /** 104 + /**
105 - * Returns value of IPv6 Interface Address. 105 + * Returns value of IPv6 Interface Address.
106 - * 106 + *
107 - * @return rawValue raw value 107 + * @return rawValue raw value
108 - */ 108 + */
109 - public byte[] getValue() { 109 + public byte[] getValue() {
110 - return rawValue; 110 + return rawValue;
111 - } 111 + }
112 - 112 +
113 - @Override 113 + @Override
114 - public PcepVersion getVersion() { 114 + public PcepVersion getVersion() {
115 - return PcepVersion.PCEP_1; 115 + return PcepVersion.PCEP_1;
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public short getType() { 119 + public short getType() {
120 - return TYPE; 120 + return TYPE;
121 - } 121 + }
122 - 122 +
123 - @Override 123 + @Override
124 - public short getLength() { 124 + public short getLength() {
125 - return LENGTH; 125 + return LENGTH;
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public int hashCode() { 129 + public int hashCode() {
130 - return Objects.hash(rawValue); 130 + return Objects.hash(rawValue);
131 - } 131 + }
132 - 132 +
133 - @Override 133 + @Override
134 - public boolean equals(Object obj) { 134 + public boolean equals(Object obj) {
135 - if (this == obj) { 135 + if (this == obj) {
136 - return true; 136 + return true;
137 - } 137 + }
138 - if (obj instanceof IPv6InterfaceAddressTlv) { 138 + if (obj instanceof IPv6InterfaceAddressTlv) {
139 - IPv6InterfaceAddressTlv other = (IPv6InterfaceAddressTlv) obj; 139 + IPv6InterfaceAddressTlv other = (IPv6InterfaceAddressTlv) obj;
140 - return Objects.equals(rawValue, other.rawValue); 140 + return Objects.equals(rawValue, other.rawValue);
141 - } 141 + }
142 - return false; 142 + return false;
143 - } 143 + }
144 - 144 +
145 - @Override 145 + @Override
146 - public int write(ChannelBuffer c) { 146 + public int write(ChannelBuffer c) {
147 - int iLenStartIndex = c.writerIndex(); 147 + int iLenStartIndex = c.writerIndex();
148 - c.writeShort(TYPE); 148 + c.writeShort(TYPE);
149 - c.writeShort(LENGTH); 149 + c.writeShort(LENGTH);
150 - c.writeBytes(rawValue); 150 + c.writeBytes(rawValue);
151 - return c.writerIndex() - iLenStartIndex; 151 + return c.writerIndex() - iLenStartIndex;
152 - } 152 + }
153 - 153 +
154 - /** 154 + /**
155 - * Reads the channel buffer and returns object of IPv6InterfaceAddressTlv. 155 + * Reads the channel buffer and returns object of IPv6InterfaceAddressTlv.
156 - * 156 + *
157 - * @param c input channel buffer 157 + * @param c input channel buffer
158 - * @return object of IPv6InterfaceAddressTlv 158 + * @return object of IPv6InterfaceAddressTlv
159 - */ 159 + */
160 - public static IPv6InterfaceAddressTlv read20Bytes(ChannelBuffer c) { 160 + public static IPv6InterfaceAddressTlv read20Bytes(ChannelBuffer c) {
161 - byte[] yTemp = new byte[20]; 161 + byte[] yTemp = new byte[20];
162 - c.readBytes(yTemp, 0, 20); 162 + c.readBytes(yTemp, 0, 20);
163 - return IPv6InterfaceAddressTlv.of(yTemp); 163 + return IPv6InterfaceAddressTlv.of(yTemp);
164 - } 164 + }
165 - 165 +
166 - @Override 166 + @Override
167 - public String toString() { 167 + public String toString() {
168 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 168 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
169 - 169 +
170 - toStrHelper.add("Type", TYPE); 170 + toStrHelper.add("Type", TYPE);
171 - toStrHelper.add("Length", LENGTH); 171 + toStrHelper.add("Length", LENGTH);
172 - 172 +
173 - StringBuffer result = new StringBuffer(); 173 + StringBuffer result = new StringBuffer();
174 - for (byte b : rawValue) { 174 + for (byte b : rawValue) {
175 - result.append(String.format("%02X ", b)); 175 + result.append(String.format("%02X ", b));
176 - } 176 + }
177 - toStrHelper.add("Value", result); 177 + toStrHelper.add("Value", result);
178 - 178 +
179 - return toStrHelper.toString(); 179 + return toStrHelper.toString();
180 - } 180 + }
181 -} 181 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides IPv6 Neighbor Address. Reference :[RFC6119]/4.3. 29 + * Provides IPv6 Neighbor Address. Reference :[RFC6119]/4.3.
30 - */ 30 + */
31 -public class IPv6NeighborAddressTlv implements PcepValueType { 31 +public class IPv6NeighborAddressTlv implements PcepValueType {
32 - protected static final Logger log = LoggerFactory.getLogger(IPv6NeighborAddressTlv.class); 32 + protected static final Logger log = LoggerFactory.getLogger(IPv6NeighborAddressTlv.class);
33 - 33 +
34 - public static final short TYPE = 13; // TDB19 34 + public static final short TYPE = 13; // TDB19
35 - public static final short LENGTH = 20; 35 + public static final short LENGTH = 20;
36 - public static final byte VALUE_LENGTH = 18; 36 + public static final byte VALUE_LENGTH = 18;
37 - 37 +
38 - 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}; 38 + 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};
39 - public static final IPv6NeighborAddressTlv NONE = new IPv6NeighborAddressTlv(NONE_VAL); 39 + public static final IPv6NeighborAddressTlv NONE = new IPv6NeighborAddressTlv(NONE_VAL);
40 - 40 +
41 - private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 41 + private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
42 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 42 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
43 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; 43 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
44 - public static final IPv6NeighborAddressTlv NO_MASK = new IPv6NeighborAddressTlv(NO_MASK_VAL); 44 + public static final IPv6NeighborAddressTlv NO_MASK = new IPv6NeighborAddressTlv(NO_MASK_VAL);
45 - public static final IPv6NeighborAddressTlv FULL_MASK = NONE; 45 + public static final IPv6NeighborAddressTlv FULL_MASK = NONE;
46 - 46 +
47 - private final byte[] rawValue; 47 + private final byte[] rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue IPv6 Neighbor Address Tlv 52 + * @param rawValue IPv6 Neighbor Address Tlv
53 - */ 53 + */
54 - public IPv6NeighborAddressTlv(byte[] rawValue) { 54 + public IPv6NeighborAddressTlv(byte[] rawValue) {
55 - this.rawValue = rawValue; 55 + this.rawValue = rawValue;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Returns newly created IPv6NeighborAddressTlv object. 59 + * Returns newly created IPv6NeighborAddressTlv object.
60 - * 60 + *
61 - * @param raw IPv6 Neighbor Address 61 + * @param raw IPv6 Neighbor Address
62 - * @return object of IPv6 Neighbor Address Tlv 62 + * @return object of IPv6 Neighbor Address Tlv
63 - */ 63 + */
64 - public static IPv6NeighborAddressTlv of(final byte[] raw) { 64 + public static IPv6NeighborAddressTlv of(final byte[] raw) {
65 - //check NONE_VAL 65 + //check NONE_VAL
66 - boolean bFoundNONE = true; 66 + boolean bFoundNONE = true;
67 - //value starts from 3rd byte. 67 + //value starts from 3rd byte.
68 - for (int i = 2; i < 20; ++i) { 68 + for (int i = 2; i < 20; ++i) {
69 - if (NONE_VAL[i] != raw[i]) { 69 + if (NONE_VAL[i] != raw[i]) {
70 - bFoundNONE = false; 70 + bFoundNONE = false;
71 - } 71 + }
72 - } 72 + }
73 - 73 +
74 - if (bFoundNONE) { 74 + if (bFoundNONE) {
75 - return NONE; 75 + return NONE;
76 - } 76 + }
77 - 77 +
78 - //check NO_MASK_VAL 78 + //check NO_MASK_VAL
79 - boolean bFoundNoMask = true; 79 + boolean bFoundNoMask = true;
80 - //value starts from 3rd byte. 80 + //value starts from 3rd byte.
81 - for (int i = 2; i < 20; ++i) { 81 + for (int i = 2; i < 20; ++i) {
82 - if (0xFF != raw[i]) { 82 + if (0xFF != raw[i]) {
83 - bFoundNoMask = false; 83 + bFoundNoMask = false;
84 - } 84 + }
85 - } 85 + }
86 - if (bFoundNoMask) { 86 + if (bFoundNoMask) {
87 - return NO_MASK; 87 + return NO_MASK;
88 - } 88 + }
89 - 89 +
90 - return new IPv6NeighborAddressTlv(raw); 90 + return new IPv6NeighborAddressTlv(raw);
91 - } 91 + }
92 - 92 +
93 - /** 93 + /**
94 - * Returns value of IPv6 Neighbor Address. 94 + * Returns value of IPv6 Neighbor Address.
95 - * 95 + *
96 - * @return rawValue raw value 96 + * @return rawValue raw value
97 - */ 97 + */
98 - public byte[] getBytes() { 98 + public byte[] getBytes() {
99 - return rawValue; 99 + return rawValue;
100 - } 100 + }
101 - 101 +
102 - /** 102 + /**
103 - * Returns value of IPv6 Neighbor Address. 103 + * Returns value of IPv6 Neighbor Address.
104 - * 104 + *
105 - * @return rawValue raw value 105 + * @return rawValue raw value
106 - */ 106 + */
107 - public byte[] getValue() { 107 + public byte[] getValue() {
108 - return rawValue; 108 + return rawValue;
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public PcepVersion getVersion() { 112 + public PcepVersion getVersion() {
113 - return PcepVersion.PCEP_1; 113 + return PcepVersion.PCEP_1;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public short getType() { 117 + public short getType() {
118 - return TYPE; 118 + return TYPE;
119 - } 119 + }
120 - 120 +
121 - @Override 121 + @Override
122 - public short getLength() { 122 + public short getLength() {
123 - return LENGTH; 123 + return LENGTH;
124 - } 124 + }
125 - 125 +
126 - @Override 126 + @Override
127 - public int hashCode() { 127 + public int hashCode() {
128 - return Objects.hash(rawValue); 128 + return Objects.hash(rawValue);
129 - } 129 + }
130 - 130 +
131 - @Override 131 + @Override
132 - public boolean equals(Object obj) { 132 + public boolean equals(Object obj) {
133 - if (this == obj) { 133 + if (this == obj) {
134 - return true; 134 + return true;
135 - } 135 + }
136 - if (obj instanceof IPv6NeighborAddressTlv) { 136 + if (obj instanceof IPv6NeighborAddressTlv) {
137 - IPv6NeighborAddressTlv other = (IPv6NeighborAddressTlv) obj; 137 + IPv6NeighborAddressTlv other = (IPv6NeighborAddressTlv) obj;
138 - return Objects.equals(rawValue, other.rawValue); 138 + return Objects.equals(rawValue, other.rawValue);
139 - } 139 + }
140 - return false; 140 + return false;
141 - } 141 + }
142 - 142 +
143 - @Override 143 + @Override
144 - public int write(ChannelBuffer c) { 144 + public int write(ChannelBuffer c) {
145 - int iStartIndex = c.writerIndex(); 145 + int iStartIndex = c.writerIndex();
146 - c.writeShort(TYPE); 146 + c.writeShort(TYPE);
147 - c.writeShort(LENGTH); 147 + c.writeShort(LENGTH);
148 - c.writeBytes(rawValue); 148 + c.writeBytes(rawValue);
149 - return c.writerIndex() - iStartIndex; 149 + return c.writerIndex() - iStartIndex;
150 - } 150 + }
151 - 151 +
152 - /** 152 + /**
153 - * Reads the channel buffer and returns object of IPv6NeighborAddressTlv. 153 + * Reads the channel buffer and returns object of IPv6NeighborAddressTlv.
154 - * 154 + *
155 - * @param c input channel buffer 155 + * @param c input channel buffer
156 - * @return object of IPv6NeighborAddressTlv 156 + * @return object of IPv6NeighborAddressTlv
157 - */ 157 + */
158 - public static IPv6NeighborAddressTlv read20Bytes(ChannelBuffer c) { 158 + public static IPv6NeighborAddressTlv read20Bytes(ChannelBuffer c) {
159 - byte[] yTemp = new byte[20]; 159 + byte[] yTemp = new byte[20];
160 - c.readBytes(yTemp, 0, 20); 160 + c.readBytes(yTemp, 0, 20);
161 - return IPv6NeighborAddressTlv.of(yTemp); 161 + return IPv6NeighborAddressTlv.of(yTemp);
162 - } 162 + }
163 - 163 +
164 - @Override 164 + @Override
165 - public String toString() { 165 + public String toString() {
166 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 166 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
167 - 167 +
168 - toStrHelper.add("Type", TYPE); 168 + toStrHelper.add("Type", TYPE);
169 - toStrHelper.add("Length", LENGTH); 169 + toStrHelper.add("Length", LENGTH);
170 - 170 +
171 - StringBuffer result = new StringBuffer(); 171 + StringBuffer result = new StringBuffer();
172 - for (byte b : rawValue) { 172 + for (byte b : rawValue) {
173 - result.append(String.format("%02X ", b)); 173 + result.append(String.format("%02X ", b));
174 - } 174 + }
175 - toStrHelper.add("Value", result); 175 + toStrHelper.add("Value", result);
176 - 176 +
177 - return toStrHelper.toString(); 177 + return toStrHelper.toString();
178 - } 178 + }
179 -} 179 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 -import com.google.common.base.MoreObjects.ToStringHelper; 27 +import com.google.common.base.MoreObjects.ToStringHelper;
28 - 28 +
29 -/** 29 +/**
30 - * Provides IPv6 Sub Object. 30 + * Provides IPv6 Sub Object.
31 - */ 31 + */
32 -public class IPv6SubObject implements PcepValueType { 32 +public class IPv6SubObject implements PcepValueType {
33 - 33 +
34 - /* reference :RFC 4874. 34 + /* reference :RFC 4874.
35 - Subobject : IPv6 address 35 + Subobject : IPv6 address
36 - 36 +
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Type | Length | IPv6 address (16 bytes) | 40 + | Type | Length | IPv6 address (16 bytes) |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | IPv6 address (continued) | 42 + | IPv6 address (continued) |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - | IPv6 address (continued) | 44 + | IPv6 address (continued) |
45 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 - | IPv6 address (continued) | 46 + | IPv6 address (continued) |
47 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 - | IPv6 address (continued) | Prefix Length | Flags | 48 + | IPv6 address (continued) | Prefix Length | Flags |
49 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 49 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
50 - 50 +
51 - Type 51 + Type
52 - 52 +
53 - 0x02 IPv6 address 53 + 0x02 IPv6 address
54 - 54 +
55 - Length 55 + Length
56 - 56 +
57 - The Length contains the total length of the subobject in bytes, 57 + The Length contains the total length of the subobject in bytes,
58 - including the Type and Length fields. The Length is always 20. 58 + including the Type and Length fields. The Length is always 20.
59 - 59 +
60 - IPv6 address 60 + IPv6 address
61 - 61 +
62 - A 128-bit unicast host address. 62 + A 128-bit unicast host address.
63 - 63 +
64 - Prefix length 64 + Prefix length
65 - 65 +
66 - 128 66 + 128
67 - 67 +
68 - Flags 68 + Flags
69 - 69 +
70 - 0x01 Local protection available 70 + 0x01 Local protection available
71 - 71 +
72 - Indicates that the link downstream of this node is 72 + Indicates that the link downstream of this node is
73 - protected via a local repair mechanism. This flag can 73 + protected via a local repair mechanism. This flag can
74 - only be set if the Local protection flag was set in the 74 + only be set if the Local protection flag was set in the
75 - SESSION_ATTRIBUTE object of the corresponding Path 75 + SESSION_ATTRIBUTE object of the corresponding Path
76 - message. 76 + message.
77 - 77 +
78 - 0x02 Local protection in use 78 + 0x02 Local protection in use
79 - 79 +
80 - Indicates that a local repair mechanism is in use to 80 + Indicates that a local repair mechanism is in use to
81 - maintain this tunnel (usually in the face of an outage 81 + maintain this tunnel (usually in the face of an outage
82 - of the link it was previously routed over). 82 + of the link it was previously routed over).
83 - */ 83 + */
84 - protected static final Logger log = LoggerFactory.getLogger(IPv6SubObject.class); 84 + protected static final Logger log = LoggerFactory.getLogger(IPv6SubObject.class);
85 - 85 +
86 - public static final short TYPE = 0x02; 86 + public static final short TYPE = 0x02;
87 - public static final short LENGTH = 20; 87 + public static final short LENGTH = 20;
88 - public static final byte VALUE_LENGTH = 18; 88 + public static final byte VALUE_LENGTH = 18;
89 - 89 +
90 - 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 + 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 };
91 - public static final IPv6SubObject NONE = new IPv6SubObject(NONE_VAL); 91 + public static final IPv6SubObject NONE = new IPv6SubObject(NONE_VAL);
92 - 92 +
93 - private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 93 + private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
94 - (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, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
95 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }; 95 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
96 - public static final IPv6SubObject NO_MASK = new IPv6SubObject(NO_MASK_VAL); 96 + public static final IPv6SubObject NO_MASK = new IPv6SubObject(NO_MASK_VAL);
97 - public static final IPv6SubObject FULL_MASK = NONE; 97 + public static final IPv6SubObject FULL_MASK = NONE;
98 - 98 +
99 - private final byte[] rawValue; 99 + private final byte[] rawValue;
100 - 100 +
101 - /** 101 + /**
102 - * constructor to initialize rawValue with ipv6 address. 102 + * constructor to initialize rawValue with ipv6 address.
103 - * 103 + *
104 - * @param rawValue ipv6 address 104 + * @param rawValue ipv6 address
105 - */ 105 + */
106 - public IPv6SubObject(byte[] rawValue) { 106 + public IPv6SubObject(byte[] rawValue) {
107 - this.rawValue = rawValue; 107 + this.rawValue = rawValue;
108 - } 108 + }
109 - 109 +
110 - /** 110 + /**
111 - * To create instance of IPv6SubObject. 111 + * To create instance of IPv6SubObject.
112 - * 112 + *
113 - * @param raw byte array of ipv6 address 113 + * @param raw byte array of ipv6 address
114 - * @return object of IPv6SubObject 114 + * @return object of IPv6SubObject
115 - */ 115 + */
116 - public static IPv6SubObject of(final byte[] raw) { 116 + public static IPv6SubObject of(final byte[] raw) {
117 - //check NONE_VAL 117 + //check NONE_VAL
118 - boolean bFoundNONE = true; 118 + boolean bFoundNONE = true;
119 - //value starts from 3rd byte. 119 + //value starts from 3rd byte.
120 - for (int i = 2; i < 20; ++i) { 120 + for (int i = 2; i < 20; ++i) {
121 - if (NONE_VAL[i] != raw[i]) { 121 + if (NONE_VAL[i] != raw[i]) {
122 - bFoundNONE = false; 122 + bFoundNONE = false;
123 - } 123 + }
124 - } 124 + }
125 - 125 +
126 - if (bFoundNONE) { 126 + if (bFoundNONE) {
127 - return NONE; 127 + return NONE;
128 - } 128 + }
129 - 129 +
130 - //check NO_MASK_VAL 130 + //check NO_MASK_VAL
131 - boolean bFoundNoMask = true; 131 + boolean bFoundNoMask = true;
132 - //value starts from 3rd byte. 132 + //value starts from 3rd byte.
133 - for (int i = 2; i < 20; ++i) { 133 + for (int i = 2; i < 20; ++i) {
134 - if (0xFF != raw[i]) { 134 + if (0xFF != raw[i]) {
135 - bFoundNoMask = false; 135 + bFoundNoMask = false;
136 - } 136 + }
137 - } 137 + }
138 - if (bFoundNoMask) { 138 + if (bFoundNoMask) {
139 - return NO_MASK; 139 + return NO_MASK;
140 - } 140 + }
141 - 141 +
142 - return new IPv6SubObject(raw); 142 + return new IPv6SubObject(raw);
143 - } 143 + }
144 - 144 +
145 - /** 145 + /**
146 - * Returns value of IPv6 Sub Object. 146 + * Returns value of IPv6 Sub Object.
147 - * 147 + *
148 - * @return byte array of ipv6 address 148 + * @return byte array of ipv6 address
149 - */ 149 + */
150 - public byte[] getValue() { 150 + public byte[] getValue() {
151 - return rawValue; 151 + return rawValue;
152 - } 152 + }
153 - 153 +
154 - @Override 154 + @Override
155 - public PcepVersion getVersion() { 155 + public PcepVersion getVersion() {
156 - return PcepVersion.PCEP_1; 156 + return PcepVersion.PCEP_1;
157 - } 157 + }
158 - 158 +
159 - @Override 159 + @Override
160 - public short getType() { 160 + public short getType() {
161 - return TYPE; 161 + return TYPE;
162 - } 162 + }
163 - 163 +
164 - @Override 164 + @Override
165 - public short getLength() { 165 + public short getLength() {
166 - return LENGTH; 166 + return LENGTH;
167 - } 167 + }
168 - 168 +
169 - @Override 169 + @Override
170 - public int hashCode() { 170 + public int hashCode() {
171 - return Objects.hash(rawValue); 171 + return Objects.hash(rawValue);
172 - } 172 + }
173 - 173 +
174 - @Override 174 + @Override
175 - public boolean equals(Object obj) { 175 + public boolean equals(Object obj) {
176 - if (this == obj) { 176 + if (this == obj) {
177 - return true; 177 + return true;
178 - } 178 + }
179 - if (obj instanceof IPv6SubObject) { 179 + if (obj instanceof IPv6SubObject) {
180 - IPv6SubObject other = (IPv6SubObject) obj; 180 + IPv6SubObject other = (IPv6SubObject) obj;
181 - return Objects.equals(rawValue, other.rawValue); 181 + return Objects.equals(rawValue, other.rawValue);
182 - } 182 + }
183 - return false; 183 + return false;
184 - } 184 + }
185 - 185 +
186 - @Override 186 + @Override
187 - public int write(ChannelBuffer c) { 187 + public int write(ChannelBuffer c) {
188 - int iStartIndex = c.writerIndex(); 188 + int iStartIndex = c.writerIndex();
189 - c.writeShort(TYPE); 189 + c.writeShort(TYPE);
190 - c.writeShort(LENGTH); 190 + c.writeShort(LENGTH);
191 - c.writeBytes(rawValue); 191 + c.writeBytes(rawValue);
192 - return c.writerIndex() - iStartIndex; 192 + return c.writerIndex() - iStartIndex;
193 - } 193 + }
194 - 194 +
195 - /** 195 + /**
196 - * Reads the channel buffer and returns object of IPv6SubObject. 196 + * Reads the channel buffer and returns object of IPv6SubObject.
197 - * 197 + *
198 - * @param c type of channel buffer 198 + * @param c type of channel buffer
199 - * @return object of IPv6SubObject 199 + * @return object of IPv6SubObject
200 - */ 200 + */
201 - public static IPv6SubObject read20Bytes(ChannelBuffer c) { 201 + public static IPv6SubObject read20Bytes(ChannelBuffer c) {
202 - byte[] yTemp = new byte[20]; 202 + byte[] yTemp = new byte[20];
203 - c.readBytes(yTemp, 0, 20); 203 + c.readBytes(yTemp, 0, 20);
204 - return IPv6SubObject.of(yTemp); 204 + return IPv6SubObject.of(yTemp);
205 - } 205 + }
206 - 206 +
207 - @Override 207 + @Override
208 - public String toString() { 208 + public String toString() {
209 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 209 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
210 - 210 +
211 - toStrHelper.add("Type", TYPE); 211 + toStrHelper.add("Type", TYPE);
212 - toStrHelper.add("Length", LENGTH); 212 + toStrHelper.add("Length", LENGTH);
213 - 213 +
214 - StringBuffer result = new StringBuffer(); 214 + StringBuffer result = new StringBuffer();
215 - for (byte b : rawValue) { 215 + for (byte b : rawValue) {
216 - result.append(String.format("%02X ", b)); 216 + result.append(String.format("%02X ", b));
217 - } 217 + }
218 - toStrHelper.add("Value", result); 218 + toStrHelper.add("Value", result);
219 - 219 +
220 - return toStrHelper.toString(); 220 + return toStrHelper.toString();
221 - } 221 + }
222 -} 222 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides IPv6 TE Router Id of Local Node. Reference :[RFC6119]/4.1. 29 + * Provides IPv6 TE Router Id of Local Node. Reference :[RFC6119]/4.1.
30 - */ 30 + */
31 -public class IPv6TERouterIdofLocalNodeTlv implements PcepValueType { 31 +public class IPv6TERouterIdofLocalNodeTlv implements PcepValueType {
32 - protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofLocalNodeTlv.class); 32 + protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofLocalNodeTlv.class);
33 - 33 +
34 - public static final short TYPE = 140; //TDB26 34 + public static final short TYPE = 140; //TDB26
35 - public static final short LENGTH = 20; 35 + public static final short LENGTH = 20;
36 - public static final byte VALUE_LENGTH = 18; 36 + public static final byte VALUE_LENGTH = 18;
37 - 37 +
38 - 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 }; 38 + 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 };
39 - public static final IPv6TERouterIdofLocalNodeTlv NONE = new IPv6TERouterIdofLocalNodeTlv(NONE_VAL); 39 + public static final IPv6TERouterIdofLocalNodeTlv NONE = new IPv6TERouterIdofLocalNodeTlv(NONE_VAL);
40 - 40 +
41 - private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 41 + private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
42 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 42 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
43 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }; 43 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
44 - public static final IPv6TERouterIdofLocalNodeTlv NO_MASK = new IPv6TERouterIdofLocalNodeTlv(NO_MASK_VAL); 44 + public static final IPv6TERouterIdofLocalNodeTlv NO_MASK = new IPv6TERouterIdofLocalNodeTlv(NO_MASK_VAL);
45 - public static final IPv6TERouterIdofLocalNodeTlv FULL_MASK = NONE; 45 + public static final IPv6TERouterIdofLocalNodeTlv FULL_MASK = NONE;
46 - 46 +
47 - private final byte[] rawValue; 47 + private final byte[] rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue IPv6TERouterIdofLocalNodeTlv 52 + * @param rawValue IPv6TERouterIdofLocalNodeTlv
53 - */ 53 + */
54 - public IPv6TERouterIdofLocalNodeTlv(byte[] rawValue) { 54 + public IPv6TERouterIdofLocalNodeTlv(byte[] rawValue) {
55 - this.rawValue = rawValue; 55 + this.rawValue = rawValue;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Returns newly created IPv6TERouterIdofLocalNodeTlv object. 59 + * Returns newly created IPv6TERouterIdofLocalNodeTlv object.
60 - * 60 + *
61 - * @param raw IPv6 TE Router Id of Local Node 61 + * @param raw IPv6 TE Router Id of Local Node
62 - * @return object of IPv6TERouterIdofLocalNodeTlv 62 + * @return object of IPv6TERouterIdofLocalNodeTlv
63 - */ 63 + */
64 - public static IPv6TERouterIdofLocalNodeTlv of(final byte[] raw) { 64 + public static IPv6TERouterIdofLocalNodeTlv of(final byte[] raw) {
65 - //check NONE_VAL 65 + //check NONE_VAL
66 - boolean bFoundNONE = true; 66 + boolean bFoundNONE = true;
67 - //value starts from 3rd byte. 67 + //value starts from 3rd byte.
68 - for (int i = 2; i < 20; ++i) { 68 + for (int i = 2; i < 20; ++i) {
69 - if (NONE_VAL[i] != raw[i]) { 69 + if (NONE_VAL[i] != raw[i]) {
70 - bFoundNONE = false; 70 + bFoundNONE = false;
71 - } 71 + }
72 - } 72 + }
73 - 73 +
74 - if (bFoundNONE) { 74 + if (bFoundNONE) {
75 - return NONE; 75 + return NONE;
76 - } 76 + }
77 - 77 +
78 - //check NO_MASK_VAL 78 + //check NO_MASK_VAL
79 - boolean bFoundNoMask = true; 79 + boolean bFoundNoMask = true;
80 - //value starts from 3rd byte. 80 + //value starts from 3rd byte.
81 - for (int i = 2; i < 20; ++i) { 81 + for (int i = 2; i < 20; ++i) {
82 - if (0xFF != raw[i]) { 82 + if (0xFF != raw[i]) {
83 - bFoundNoMask = false; 83 + bFoundNoMask = false;
84 - } 84 + }
85 - } 85 + }
86 - if (bFoundNoMask) { 86 + if (bFoundNoMask) {
87 - return NO_MASK; 87 + return NO_MASK;
88 - } 88 + }
89 - 89 +
90 - return new IPv6TERouterIdofLocalNodeTlv(raw); 90 + return new IPv6TERouterIdofLocalNodeTlv(raw);
91 - } 91 + }
92 - 92 +
93 - /** 93 + /**
94 - * Returns value of IPv6 TE Router Id of Local Node. 94 + * Returns value of IPv6 TE Router Id of Local Node.
95 - * 95 + *
96 - * @return byte array value of rawValue 96 + * @return byte array value of rawValue
97 - */ 97 + */
98 - public byte[] getBytes() { 98 + public byte[] getBytes() {
99 - return rawValue; 99 + return rawValue;
100 - } 100 + }
101 - 101 +
102 - /** 102 + /**
103 - * Returns value of IPv6 TE Router Id of Local Node. 103 + * Returns value of IPv6 TE Router Id of Local Node.
104 - * 104 + *
105 - * @return byte array value of rawValue 105 + * @return byte array value of rawValue
106 - */ 106 + */
107 - public byte[] getValue() { 107 + public byte[] getValue() {
108 - return rawValue; 108 + return rawValue;
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public PcepVersion getVersion() { 112 + public PcepVersion getVersion() {
113 - return PcepVersion.PCEP_1; 113 + return PcepVersion.PCEP_1;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public short getType() { 117 + public short getType() {
118 - return TYPE; 118 + return TYPE;
119 - } 119 + }
120 - 120 +
121 - @Override 121 + @Override
122 - public short getLength() { 122 + public short getLength() {
123 - return LENGTH; 123 + return LENGTH;
124 - } 124 + }
125 - 125 +
126 - @Override 126 + @Override
127 - public int hashCode() { 127 + public int hashCode() {
128 - return Objects.hash(rawValue); 128 + return Objects.hash(rawValue);
129 - } 129 + }
130 - 130 +
131 - @Override 131 + @Override
132 - public boolean equals(Object obj) { 132 + public boolean equals(Object obj) {
133 - if (this == obj) { 133 + if (this == obj) {
134 - return true; 134 + return true;
135 - } 135 + }
136 - if (obj instanceof IPv6TERouterIdofLocalNodeTlv) { 136 + if (obj instanceof IPv6TERouterIdofLocalNodeTlv) {
137 - IPv6TERouterIdofLocalNodeTlv other = (IPv6TERouterIdofLocalNodeTlv) obj; 137 + IPv6TERouterIdofLocalNodeTlv other = (IPv6TERouterIdofLocalNodeTlv) obj;
138 - return Objects.equals(rawValue, other.rawValue); 138 + return Objects.equals(rawValue, other.rawValue);
139 - } 139 + }
140 - return false; 140 + return false;
141 - } 141 + }
142 - 142 +
143 - @Override 143 + @Override
144 - public int write(ChannelBuffer c) { 144 + public int write(ChannelBuffer c) {
145 - int iStartIndex = c.writerIndex(); 145 + int iStartIndex = c.writerIndex();
146 - c.writeShort(TYPE); 146 + c.writeShort(TYPE);
147 - c.writeShort(LENGTH); 147 + c.writeShort(LENGTH);
148 - c.writeBytes(rawValue); 148 + c.writeBytes(rawValue);
149 - return c.writerIndex() - iStartIndex; 149 + return c.writerIndex() - iStartIndex;
150 - } 150 + }
151 - 151 +
152 - /** 152 + /**
153 - * Reads the channel buffer and returns object of IPv6TERouterIdofLocalNodeTlv. 153 + * Reads the channel buffer and returns object of IPv6TERouterIdofLocalNodeTlv.
154 - * 154 + *
155 - * @param c input channel buffer 155 + * @param c input channel buffer
156 - * @return object of IPv6TERouterIdofLocalNodeTlv 156 + * @return object of IPv6TERouterIdofLocalNodeTlv
157 - */ 157 + */
158 - public static IPv6TERouterIdofLocalNodeTlv read20Bytes(ChannelBuffer c) { 158 + public static IPv6TERouterIdofLocalNodeTlv read20Bytes(ChannelBuffer c) {
159 - byte[] yTemp = new byte[20]; 159 + byte[] yTemp = new byte[20];
160 - c.readBytes(yTemp, 0, 20); 160 + c.readBytes(yTemp, 0, 20);
161 - return IPv6TERouterIdofLocalNodeTlv.of(yTemp); 161 + return IPv6TERouterIdofLocalNodeTlv.of(yTemp);
162 - } 162 + }
163 - 163 +
164 - @Override 164 + @Override
165 - public String toString() { 165 + public String toString() {
166 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 166 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
167 - 167 +
168 - toStrHelper.add("Type", TYPE); 168 + toStrHelper.add("Type", TYPE);
169 - toStrHelper.add("Length", LENGTH); 169 + toStrHelper.add("Length", LENGTH);
170 - 170 +
171 - StringBuffer result = new StringBuffer(); 171 + StringBuffer result = new StringBuffer();
172 - for (byte b : rawValue) { 172 + for (byte b : rawValue) {
173 - result.append(String.format("%02X ", b)); 173 + result.append(String.format("%02X ", b));
174 - } 174 + }
175 - toStrHelper.add("Value", result); 175 + toStrHelper.add("Value", result);
176 - 176 +
177 - return toStrHelper.toString(); 177 + return toStrHelper.toString();
178 - } 178 + }
179 -} 179 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides IPv6 TE Router Id of Remote Node. Reference :[RFC6119]/4.1. 29 + * Provides IPv6 TE Router Id of Remote Node. Reference :[RFC6119]/4.1.
30 - */ 30 + */
31 -public class IPv6TERouterIdofRemoteNodeTlv implements PcepValueType { 31 +public class IPv6TERouterIdofRemoteNodeTlv implements PcepValueType {
32 - protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofRemoteNodeTlv.class); 32 + protected static final Logger log = LoggerFactory.getLogger(IPv6TERouterIdofRemoteNodeTlv.class);
33 - 33 +
34 - public static final short TYPE = 1400; //TDB29 34 + public static final short TYPE = 1400; //TDB29
35 - public static final short LENGTH = 20; 35 + public static final short LENGTH = 20;
36 - public static final byte VALUE_LENGTH = 18; 36 + public static final byte VALUE_LENGTH = 18;
37 - 37 +
38 - 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}; 38 + 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};
39 - public static final IPv6TERouterIdofRemoteNodeTlv NONE = new IPv6TERouterIdofRemoteNodeTlv(NONE_VAL); 39 + public static final IPv6TERouterIdofRemoteNodeTlv NONE = new IPv6TERouterIdofRemoteNodeTlv(NONE_VAL);
40 - 40 +
41 - private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 41 + private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
42 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 42 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
43 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF}; 43 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF};
44 - public static final IPv6TERouterIdofRemoteNodeTlv NO_MASK = new IPv6TERouterIdofRemoteNodeTlv(NO_MASK_VAL); 44 + public static final IPv6TERouterIdofRemoteNodeTlv NO_MASK = new IPv6TERouterIdofRemoteNodeTlv(NO_MASK_VAL);
45 - public static final IPv6TERouterIdofRemoteNodeTlv FULL_MASK = NONE; 45 + public static final IPv6TERouterIdofRemoteNodeTlv FULL_MASK = NONE;
46 - 46 +
47 - private final byte[] rawValue; 47 + private final byte[] rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * constructor to initialize rawValue. 50 + * constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue IPv6TERouterIdofRemoteNodeTlv 52 + * @param rawValue IPv6TERouterIdofRemoteNodeTlv
53 - */ 53 + */
54 - public IPv6TERouterIdofRemoteNodeTlv(byte[] rawValue) { 54 + public IPv6TERouterIdofRemoteNodeTlv(byte[] rawValue) {
55 - log.debug("IPv6TERouterIdofRemoteNodeTlv"); 55 + log.debug("IPv6TERouterIdofRemoteNodeTlv");
56 - this.rawValue = rawValue; 56 + this.rawValue = rawValue;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Returns newly created IPv6TERouterIdofRemoteNodeTlv object. 60 + * Returns newly created IPv6TERouterIdofRemoteNodeTlv object.
61 - * 61 + *
62 - * @param raw IPv6 TE Router Id of RemoteNode 62 + * @param raw IPv6 TE Router Id of RemoteNode
63 - * @return object of IPv6TERouterIdofRemoteNodeTlv 63 + * @return object of IPv6TERouterIdofRemoteNodeTlv
64 - */ 64 + */
65 - public static IPv6TERouterIdofRemoteNodeTlv of(final byte[] raw) { 65 + public static IPv6TERouterIdofRemoteNodeTlv of(final byte[] raw) {
66 - //check NONE_VAL 66 + //check NONE_VAL
67 - boolean bFoundNONE = true; 67 + boolean bFoundNONE = true;
68 - //value starts from 3rd byte. 68 + //value starts from 3rd byte.
69 - for (int i = 2; i < 20; ++i) { 69 + for (int i = 2; i < 20; ++i) {
70 - if (NONE_VAL[i] != raw[i]) { 70 + if (NONE_VAL[i] != raw[i]) {
71 - bFoundNONE = false; 71 + bFoundNONE = false;
72 - } 72 + }
73 - } 73 + }
74 - 74 +
75 - if (bFoundNONE) { 75 + if (bFoundNONE) {
76 - return NONE; 76 + return NONE;
77 - } 77 + }
78 - 78 +
79 - //check NO_MASK_VAL 79 + //check NO_MASK_VAL
80 - boolean bFoundNoMask = true; 80 + boolean bFoundNoMask = true;
81 - //value starts from 3rd byte. 81 + //value starts from 3rd byte.
82 - for (int i = 2; i < 20; ++i) { 82 + for (int i = 2; i < 20; ++i) {
83 - if (0xFF != raw[i]) { 83 + if (0xFF != raw[i]) {
84 - bFoundNoMask = false; 84 + bFoundNoMask = false;
85 - } 85 + }
86 - } 86 + }
87 - if (bFoundNoMask) { 87 + if (bFoundNoMask) {
88 - return NO_MASK; 88 + return NO_MASK;
89 - } 89 + }
90 - 90 +
91 - return new IPv6TERouterIdofRemoteNodeTlv(raw); 91 + return new IPv6TERouterIdofRemoteNodeTlv(raw);
92 - } 92 + }
93 - 93 +
94 - /** 94 + /**
95 - * Returns value of IPv6 TE Router Id of Remote Node. 95 + * Returns value of IPv6 TE Router Id of Remote Node.
96 - * 96 + *
97 - * @return byte array value of rawValue 97 + * @return byte array value of rawValue
98 - */ 98 + */
99 - public byte[] getBytes() { 99 + public byte[] getBytes() {
100 - return rawValue; 100 + return rawValue;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public PcepVersion getVersion() { 104 + public PcepVersion getVersion() {
105 - return PcepVersion.PCEP_1; 105 + return PcepVersion.PCEP_1;
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public short getType() { 109 + public short getType() {
110 - return TYPE; 110 + return TYPE;
111 - } 111 + }
112 - 112 +
113 - @Override 113 + @Override
114 - public short getLength() { 114 + public short getLength() {
115 - return LENGTH; 115 + return LENGTH;
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public int hashCode() { 119 + public int hashCode() {
120 - return Objects.hash(rawValue); 120 + return Objects.hash(rawValue);
121 - } 121 + }
122 - 122 +
123 - @Override 123 + @Override
124 - public boolean equals(Object obj) { 124 + public boolean equals(Object obj) {
125 - if (this == obj) { 125 + if (this == obj) {
126 - return true; 126 + return true;
127 - } 127 + }
128 - if (obj instanceof IPv6TERouterIdofRemoteNodeTlv) { 128 + if (obj instanceof IPv6TERouterIdofRemoteNodeTlv) {
129 - IPv6TERouterIdofRemoteNodeTlv other = (IPv6TERouterIdofRemoteNodeTlv) obj; 129 + IPv6TERouterIdofRemoteNodeTlv other = (IPv6TERouterIdofRemoteNodeTlv) obj;
130 - return Objects.equals(rawValue, other.rawValue); 130 + return Objects.equals(rawValue, other.rawValue);
131 - } 131 + }
132 - return false; 132 + return false;
133 - } 133 + }
134 - 134 +
135 - @Override 135 + @Override
136 - public int write(ChannelBuffer c) { 136 + public int write(ChannelBuffer c) {
137 - int iStartIndex = c.writerIndex(); 137 + int iStartIndex = c.writerIndex();
138 - c.writeShort(TYPE); 138 + c.writeShort(TYPE);
139 - c.writeShort(LENGTH); 139 + c.writeShort(LENGTH);
140 - c.writeBytes(rawValue); 140 + c.writeBytes(rawValue);
141 - return c.writerIndex() - iStartIndex; 141 + return c.writerIndex() - iStartIndex;
142 - } 142 + }
143 - 143 +
144 - /** 144 + /**
145 - * Reads the channel buffer and returns object of IPv6TERouterIdofRemoteNodeTlv. 145 + * Reads the channel buffer and returns object of IPv6TERouterIdofRemoteNodeTlv.
146 - * 146 + *
147 - * @param c input channel buffer 147 + * @param c input channel buffer
148 - * @return object of IPv6TERouterIdofRemoteNodeTlv 148 + * @return object of IPv6TERouterIdofRemoteNodeTlv
149 - */ 149 + */
150 - public static IPv6TERouterIdofRemoteNodeTlv read20Bytes(ChannelBuffer c) { 150 + public static IPv6TERouterIdofRemoteNodeTlv read20Bytes(ChannelBuffer c) {
151 - byte[] yTemp = new byte[20]; 151 + byte[] yTemp = new byte[20];
152 - c.readBytes(yTemp, 0, 20); 152 + c.readBytes(yTemp, 0, 20);
153 - return IPv6TERouterIdofRemoteNodeTlv.of(yTemp); 153 + return IPv6TERouterIdofRemoteNodeTlv.of(yTemp);
154 - } 154 + }
155 - 155 +
156 - @Override 156 + @Override
157 - public String toString() { 157 + public String toString() {
158 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 158 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
159 - 159 +
160 - toStrHelper.add("Type", TYPE); 160 + toStrHelper.add("Type", TYPE);
161 - toStrHelper.add("Length", LENGTH); 161 + toStrHelper.add("Length", LENGTH);
162 - 162 +
163 - StringBuffer result = new StringBuffer(); 163 + StringBuffer result = new StringBuffer();
164 - for (byte b : rawValue) { 164 + for (byte b : rawValue) {
165 - result.append(String.format("%02X ", b)); 165 + result.append(String.format("%02X ", b));
166 - } 166 + }
167 - toStrHelper.add("Value", result); 167 + toStrHelper.add("Value", result);
168 - 168 +
169 - return toStrHelper.toString(); 169 + return toStrHelper.toString();
170 - } 170 + }
171 -} 171 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides ISIS Area Identifier. 29 + * Provides ISIS Area Identifier.
30 - */ 30 + */
31 -public class ISISAreaIdentifierTlv implements PcepValueType { 31 +public class ISISAreaIdentifierTlv implements PcepValueType {
32 - 32 +
33 - /* Reference :[I-D.ietf-idr- ls-distribution]/3.3.1.2 33 + /* Reference :[I-D.ietf-idr- ls-distribution]/3.3.1.2
34 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=[TBD24] | Length | 37 + | Type=[TBD24] | Length |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - // Area Identifier (variable) // 39 + // Area Identifier (variable) //
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - */ 41 + */
42 - 42 +
43 - protected static final Logger log = LoggerFactory.getLogger(ISISAreaIdentifierTlv.class); 43 + protected static final Logger log = LoggerFactory.getLogger(ISISAreaIdentifierTlv.class);
44 - 44 +
45 - public static final short TYPE = 107; //TODO:NEED TO HANDLE TBD24 45 + public static final short TYPE = 107; //TODO:NEED TO HANDLE TBD24
46 - private short hLength; 46 + private short hLength;
47 - 47 +
48 - private final byte[] rawValue; 48 + private final byte[] rawValue;
49 - 49 +
50 - /** 50 + /**
51 - * Constructor to initialize rawValue. 51 + * Constructor to initialize rawValue.
52 - * 52 + *
53 - * @param rawValue ISIS-Area-Identifier 53 + * @param rawValue ISIS-Area-Identifier
54 - * @param hLength length 54 + * @param hLength length
55 - */ 55 + */
56 - public ISISAreaIdentifierTlv(byte[] rawValue, short hLength) { 56 + public ISISAreaIdentifierTlv(byte[] rawValue, short hLength) {
57 - log.debug("ISISAreaIdentifierTlv"); 57 + log.debug("ISISAreaIdentifierTlv");
58 - this.rawValue = rawValue; 58 + this.rawValue = rawValue;
59 - if (0 == hLength) { 59 + if (0 == hLength) {
60 - this.hLength = (short) rawValue.length; 60 + this.hLength = (short) rawValue.length;
61 - } else { 61 + } else {
62 - this.hLength = hLength; 62 + this.hLength = hLength;
63 - } 63 + }
64 - } 64 + }
65 - 65 +
66 - /** 66 + /**
67 - * Returns newly created ISISAreaIdentifierTlv object. 67 + * Returns newly created ISISAreaIdentifierTlv object.
68 - * 68 + *
69 - * @param raw ISIS-Area-Identifier 69 + * @param raw ISIS-Area-Identifier
70 - * @param hLength length 70 + * @param hLength length
71 - * @return object of ISISAreaIdentifierTlv 71 + * @return object of ISISAreaIdentifierTlv
72 - */ 72 + */
73 - public static ISISAreaIdentifierTlv of(final byte[] raw, short hLength) { 73 + public static ISISAreaIdentifierTlv of(final byte[] raw, short hLength) {
74 - return new ISISAreaIdentifierTlv(raw, hLength); 74 + return new ISISAreaIdentifierTlv(raw, hLength);
75 - } 75 + }
76 - 76 +
77 - /** 77 + /**
78 - * Returns value of ISIS-Area-Identifier. 78 + * Returns value of ISIS-Area-Identifier.
79 - * 79 + *
80 - * @return byte array of rawValue 80 + * @return byte array of rawValue
81 - */ 81 + */
82 - public byte[] getValue() { 82 + public byte[] getValue() {
83 - return rawValue; 83 + return rawValue;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public PcepVersion getVersion() { 87 + public PcepVersion getVersion() {
88 - return PcepVersion.PCEP_1; 88 + return PcepVersion.PCEP_1;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public short getType() { 92 + public short getType() {
93 - return TYPE; 93 + return TYPE;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public short getLength() { 97 + public short getLength() {
98 - return hLength; 98 + return hLength;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public int hashCode() { 102 + public int hashCode() {
103 - return Objects.hash(rawValue); 103 + return Objects.hash(rawValue);
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public boolean equals(Object obj) { 107 + public boolean equals(Object obj) {
108 - if (this == obj) { 108 + if (this == obj) {
109 - return true; 109 + return true;
110 - } 110 + }
111 - if (obj instanceof ISISAreaIdentifierTlv) { 111 + if (obj instanceof ISISAreaIdentifierTlv) {
112 - ISISAreaIdentifierTlv other = (ISISAreaIdentifierTlv) obj; 112 + ISISAreaIdentifierTlv other = (ISISAreaIdentifierTlv) obj;
113 - return Objects.equals(hLength, other.hLength) && Objects.equals(rawValue, other.rawValue); 113 + return Objects.equals(hLength, other.hLength) && Objects.equals(rawValue, other.rawValue);
114 - } 114 + }
115 - return false; 115 + return false;
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public int write(ChannelBuffer c) { 119 + public int write(ChannelBuffer c) {
120 - int iLenStartIndex = c.writerIndex(); 120 + int iLenStartIndex = c.writerIndex();
121 - c.writeShort(TYPE); 121 + c.writeShort(TYPE);
122 - c.writeShort(hLength); 122 + c.writeShort(hLength);
123 - c.writeBytes(rawValue); 123 + c.writeBytes(rawValue);
124 - return c.writerIndex() - iLenStartIndex; 124 + return c.writerIndex() - iLenStartIndex;
125 - } 125 + }
126 - 126 +
127 - /** 127 + /**
128 - * Reads the channel buffer and returns object of ISISAreaIdentifierTlv. 128 + * Reads the channel buffer and returns object of ISISAreaIdentifierTlv.
129 - * 129 + *
130 - * @param c input channel buffer 130 + * @param c input channel buffer
131 - * @param hLength length 131 + * @param hLength length
132 - * @return object of ISISAreaIdentifierTlv 132 + * @return object of ISISAreaIdentifierTlv
133 - */ 133 + */
134 - public static PcepValueType read(ChannelBuffer c, short hLength) { 134 + public static PcepValueType read(ChannelBuffer c, short hLength) {
135 - byte[] iISISAreaIdentifier = new byte[hLength]; 135 + byte[] iISISAreaIdentifier = new byte[hLength];
136 - c.readBytes(iISISAreaIdentifier, 0, hLength); 136 + c.readBytes(iISISAreaIdentifier, 0, hLength);
137 - return new ISISAreaIdentifierTlv(iISISAreaIdentifier, hLength); 137 + return new ISISAreaIdentifierTlv(iISISAreaIdentifier, hLength);
138 - } 138 + }
139 - 139 +
140 - @Override 140 + @Override
141 - public String toString() { 141 + public String toString() {
142 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 142 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
143 - 143 +
144 - toStrHelper.add("Type", TYPE); 144 + toStrHelper.add("Type", TYPE);
145 - toStrHelper.add("Length", hLength); 145 + toStrHelper.add("Length", hLength);
146 - 146 +
147 - StringBuffer result = new StringBuffer(); 147 + StringBuffer result = new StringBuffer();
148 - for (byte b : rawValue) { 148 + for (byte b : rawValue) {
149 - result.append(String.format("%02X ", b)); 149 + result.append(String.format("%02X ", b));
150 - } 150 + }
151 - toStrHelper.add("Value", result); 151 + toStrHelper.add("Value", result);
152 - 152 +
153 - return toStrHelper.toString(); 153 + return toStrHelper.toString();
154 - } 154 + }
155 -} 155 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * LabelSubObject: Provides a LabelSubObject. 29 + * LabelSubObject: Provides a LabelSubObject.
30 - */ 30 + */
31 -public class LabelSubObject implements PcepValueType { 31 +public class LabelSubObject implements PcepValueType {
32 - 32 +
33 - /* Reference : RFC 3209 33 + /* Reference : RFC 3209
34 - * LABEL Sub Object 34 + * LABEL Sub Object
35 - * 35 + *
36 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | Type | Length | Flags | C-Type | 39 + | Type | Length | Flags | C-Type |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Contents of Label Object | 41 + | Contents of Label Object |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - */ 43 + */
44 - protected static final Logger log = LoggerFactory.getLogger(LabelSubObject.class); 44 + protected static final Logger log = LoggerFactory.getLogger(LabelSubObject.class);
45 - 45 +
46 - public static final short TYPE = 0x03; 46 + public static final short TYPE = 0x03;
47 - public static final short LENGTH = 8; 47 + public static final short LENGTH = 8;
48 - private final byte flags; 48 + private final byte flags;
49 - private final byte cType; 49 + private final byte cType;
50 - private final int contents; 50 + private final int contents;
51 - 51 +
52 - /** 52 + /**
53 - * constructor to initialize parameters for LabelSubObject. 53 + * constructor to initialize parameters for LabelSubObject.
54 - * 54 + *
55 - * @param flags flags 55 + * @param flags flags
56 - * @param cType C-Type 56 + * @param cType C-Type
57 - * @param contents Contents of label object 57 + * @param contents Contents of label object
58 - */ 58 + */
59 - public LabelSubObject(byte flags, byte cType, int contents) { 59 + public LabelSubObject(byte flags, byte cType, int contents) {
60 - this.flags = flags; 60 + this.flags = flags;
61 - this.cType = cType; 61 + this.cType = cType;
62 - this.contents = contents; 62 + this.contents = contents;
63 - } 63 + }
64 - 64 +
65 - /** 65 + /**
66 - * Return an object of LabelSubObject. 66 + * Return an object of LabelSubObject.
67 - * 67 + *
68 - * @param flags flags 68 + * @param flags flags
69 - * @param cType C-type 69 + * @param cType C-type
70 - * @param contents contents of label objects 70 + * @param contents contents of label objects
71 - * @return object of LabelSubObject 71 + * @return object of LabelSubObject
72 - */ 72 + */
73 - public static LabelSubObject of(byte flags, byte cType, int contents) { 73 + public static LabelSubObject of(byte flags, byte cType, int contents) {
74 - return new LabelSubObject(flags, cType, contents); 74 + return new LabelSubObject(flags, cType, contents);
75 - } 75 + }
76 - 76 +
77 - /** 77 + /**
78 - * Returns Flags. 78 + * Returns Flags.
79 - * 79 + *
80 - * @return flags 80 + * @return flags
81 - */ 81 + */
82 - public byte getFlags() { 82 + public byte getFlags() {
83 - return flags; 83 + return flags;
84 - } 84 + }
85 - 85 +
86 - /** 86 + /**
87 - * Returns cType. 87 + * Returns cType.
88 - * 88 + *
89 - * @return cType 89 + * @return cType
90 - */ 90 + */
91 - public byte getCtype() { 91 + public byte getCtype() {
92 - return cType; 92 + return cType;
93 - } 93 + }
94 - 94 +
95 - /** 95 + /**
96 - * Returns contents. 96 + * Returns contents.
97 - * 97 + *
98 - * @return contents 98 + * @return contents
99 - */ 99 + */
100 - public int getContents() { 100 + public int getContents() {
101 - return contents; 101 + return contents;
102 - } 102 + }
103 - 103 +
104 - @Override 104 + @Override
105 - public PcepVersion getVersion() { 105 + public PcepVersion getVersion() {
106 - return PcepVersion.PCEP_1; 106 + return PcepVersion.PCEP_1;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public short getType() { 110 + public short getType() {
111 - return TYPE; 111 + return TYPE;
112 - } 112 + }
113 - 113 +
114 - @Override 114 + @Override
115 - public short getLength() { 115 + public short getLength() {
116 - return LENGTH; 116 + return LENGTH;
117 - } 117 + }
118 - 118 +
119 - @Override 119 + @Override
120 - public int hashCode() { 120 + public int hashCode() {
121 - return Objects.hash(flags, cType, contents); 121 + return Objects.hash(flags, cType, contents);
122 - } 122 + }
123 - 123 +
124 - @Override 124 + @Override
125 - public boolean equals(Object obj) { 125 + public boolean equals(Object obj) {
126 - if (this == obj) { 126 + if (this == obj) {
127 - return true; 127 + return true;
128 - } 128 + }
129 - if (obj instanceof LabelSubObject) { 129 + if (obj instanceof LabelSubObject) {
130 - LabelSubObject other = (LabelSubObject) obj; 130 + LabelSubObject other = (LabelSubObject) obj;
131 - return Objects.equals(this.flags, other.flags) && Objects.equals(this.cType, other.cType) 131 + return Objects.equals(this.flags, other.flags) && Objects.equals(this.cType, other.cType)
132 - && Objects.equals(this.contents, other.contents); 132 + && Objects.equals(this.contents, other.contents);
133 - } 133 + }
134 - return false; 134 + return false;
135 - } 135 + }
136 - 136 +
137 - @Override 137 + @Override
138 - public int write(ChannelBuffer c) { 138 + public int write(ChannelBuffer c) {
139 - int iStartIndex = c.writerIndex(); 139 + int iStartIndex = c.writerIndex();
140 - c.writeShort(TYPE); 140 + c.writeShort(TYPE);
141 - c.writeShort(LENGTH); 141 + c.writeShort(LENGTH);
142 - c.writeByte(flags); 142 + c.writeByte(flags);
143 - c.writeByte(cType); 143 + c.writeByte(cType);
144 - c.writeByte(contents); 144 + c.writeByte(contents);
145 - return c.writerIndex() - iStartIndex; 145 + return c.writerIndex() - iStartIndex;
146 - } 146 + }
147 - 147 +
148 - /** 148 + /**
149 - * Reads the channel buffer and returns object of LabelSubObject. 149 + * Reads the channel buffer and returns object of LabelSubObject.
150 - * 150 + *
151 - * @param c type of channel buffer 151 + * @param c type of channel buffer
152 - * @return object of LabelSubObject 152 + * @return object of LabelSubObject
153 - */ 153 + */
154 - public static PcepValueType read(ChannelBuffer c) { 154 + public static PcepValueType read(ChannelBuffer c) {
155 - byte flags = c.readByte(); 155 + byte flags = c.readByte();
156 - byte cType = c.readByte(); 156 + byte cType = c.readByte();
157 - int contents = c.readInt(); 157 + int contents = c.readInt();
158 - return new LabelSubObject(flags, cType, contents); 158 + return new LabelSubObject(flags, cType, contents);
159 - } 159 + }
160 - 160 +
161 - @Override 161 + @Override
162 - public String toString() { 162 + public String toString() {
163 - return MoreObjects.toStringHelper(getClass()).add("type", TYPE).add("Length", LENGTH).add("flags", flags) 163 + return MoreObjects.toStringHelper(getClass()).add("type", TYPE).add("Length", LENGTH).add("flags", flags)
164 - .add("C-type", cType).add("contents", contents).toString(); 164 + .add("C-type", cType).add("contents", contents).toString();
165 - } 165 + }
166 -} 166 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides Local and remote Link Identifiers. 28 + * Provides Local and remote Link Identifiers.
29 - */ 29 + */
30 -public class LinkLocalRemoteIdentifiersTlv implements PcepValueType { 30 +public class LinkLocalRemoteIdentifiersTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :RFC5307 32 + /* Reference :RFC5307
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=4 | Length=8 | 36 + | Type=4 | Length=8 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | Link Local Identifier | 38 + | Link Local Identifier |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Link Remote Identifier | 40 + | Link Remote Identifier |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - 42 +
43 - */ 43 + */
44 - protected static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class); 44 + protected static final Logger log = LoggerFactory.getLogger(LinkLocalRemoteIdentifiersTlv.class);
45 - 45 +
46 - public static final short TYPE = 4; 46 + public static final short TYPE = 4;
47 - public static final short LENGTH = 8; 47 + public static final short LENGTH = 8;
48 - private final int iLinkLocalIdentifier; 48 + private final int iLinkLocalIdentifier;
49 - private final int iLinkRemoteIdentifier; 49 + private final int iLinkRemoteIdentifier;
50 - 50 +
51 - /** 51 + /**
52 - * Constructor to initialize iLinkLocalIdentifier , iLinkRemoteIdentifier. 52 + * Constructor to initialize iLinkLocalIdentifier , iLinkRemoteIdentifier.
53 - * 53 + *
54 - * @param iLinkLocalIdentifier Link Local identifier 54 + * @param iLinkLocalIdentifier Link Local identifier
55 - * @param iLinkRemoteIdentifier Link Remote identifier 55 + * @param iLinkRemoteIdentifier Link Remote identifier
56 - */ 56 + */
57 - public LinkLocalRemoteIdentifiersTlv(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) { 57 + public LinkLocalRemoteIdentifiersTlv(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
58 - this.iLinkLocalIdentifier = iLinkLocalIdentifier; 58 + this.iLinkLocalIdentifier = iLinkLocalIdentifier;
59 - this.iLinkRemoteIdentifier = iLinkRemoteIdentifier; 59 + this.iLinkRemoteIdentifier = iLinkRemoteIdentifier;
60 - } 60 + }
61 - 61 +
62 - /** 62 + /**
63 - * Retruns an object of Link Local Remote Identifiers Tlv. 63 + * Retruns an object of Link Local Remote Identifiers Tlv.
64 - * 64 + *
65 - * @param iLinkLocalIdentifier Link Local identifier 65 + * @param iLinkLocalIdentifier Link Local identifier
66 - * @param iLinkRemoteIdentifier Link Remote identifier 66 + * @param iLinkRemoteIdentifier Link Remote identifier
67 - * @return object of LinkLocalRemoteIdentifiersTlv 67 + * @return object of LinkLocalRemoteIdentifiersTlv
68 - */ 68 + */
69 - public static LinkLocalRemoteIdentifiersTlv of(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) { 69 + public static LinkLocalRemoteIdentifiersTlv of(int iLinkLocalIdentifier, int iLinkRemoteIdentifier) {
70 - return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier); 70 + return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
71 - } 71 + }
72 - 72 +
73 - /** 73 + /**
74 - * Returns Link-Local-Identifier. 74 + * Returns Link-Local-Identifier.
75 - * 75 + *
76 - * @return iLinkLocalIdentifier Link Local Identifier 76 + * @return iLinkLocalIdentifier Link Local Identifier
77 - */ 77 + */
78 - public int getLinkLocalIdentifier() { 78 + public int getLinkLocalIdentifier() {
79 - return iLinkLocalIdentifier; 79 + return iLinkLocalIdentifier;
80 - } 80 + }
81 - 81 +
82 - /** 82 + /**
83 - * Returns Link-Remote-Identifier. 83 + * Returns Link-Remote-Identifier.
84 - * 84 + *
85 - * @return iLinkRemoteIdentifier Link Remote Identifier. 85 + * @return iLinkRemoteIdentifier Link Remote Identifier.
86 - */ 86 + */
87 - public int getLinkRemoteIdentifier() { 87 + public int getLinkRemoteIdentifier() {
88 - return iLinkRemoteIdentifier; 88 + return iLinkRemoteIdentifier;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public PcepVersion getVersion() { 92 + public PcepVersion getVersion() {
93 - return PcepVersion.PCEP_1; 93 + return PcepVersion.PCEP_1;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public short getLength() { 97 + public short getLength() {
98 - return LENGTH; 98 + return LENGTH;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public short getType() { 102 + public short getType() {
103 - return TYPE; 103 + return TYPE;
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public int hashCode() { 107 + public int hashCode() {
108 - return Objects.hash(iLinkLocalIdentifier, iLinkRemoteIdentifier); 108 + return Objects.hash(iLinkLocalIdentifier, iLinkRemoteIdentifier);
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public boolean equals(Object obj) { 112 + public boolean equals(Object obj) {
113 - if (this == obj) { 113 + if (this == obj) {
114 - return true; 114 + return true;
115 - } 115 + }
116 - if (obj instanceof LinkLocalRemoteIdentifiersTlv) { 116 + if (obj instanceof LinkLocalRemoteIdentifiersTlv) {
117 - LinkLocalRemoteIdentifiersTlv other = (LinkLocalRemoteIdentifiersTlv) obj; 117 + LinkLocalRemoteIdentifiersTlv other = (LinkLocalRemoteIdentifiersTlv) obj;
118 - return Objects.equals(iLinkLocalIdentifier, other.iLinkLocalIdentifier) 118 + return Objects.equals(iLinkLocalIdentifier, other.iLinkLocalIdentifier)
119 - && Objects.equals(iLinkRemoteIdentifier, other.iLinkRemoteIdentifier); 119 + && Objects.equals(iLinkRemoteIdentifier, other.iLinkRemoteIdentifier);
120 - } 120 + }
121 - return false; 121 + return false;
122 - } 122 + }
123 - 123 +
124 - @Override 124 + @Override
125 - public int write(ChannelBuffer c) { 125 + public int write(ChannelBuffer c) {
126 - int iStartIndex = c.writerIndex(); 126 + int iStartIndex = c.writerIndex();
127 - c.writeShort(TYPE); 127 + c.writeShort(TYPE);
128 - c.writeShort(LENGTH); 128 + c.writeShort(LENGTH);
129 - c.writeInt(iLinkLocalIdentifier); 129 + c.writeInt(iLinkLocalIdentifier);
130 - c.writeInt(iLinkRemoteIdentifier); 130 + c.writeInt(iLinkRemoteIdentifier);
131 - return c.writerIndex() - iStartIndex; 131 + return c.writerIndex() - iStartIndex;
132 - } 132 + }
133 - 133 +
134 - /** 134 + /**
135 - * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv. 135 + * Reads the channel buffer and returns object of LinkLocalRemoteIdentifiersTlv.
136 - * 136 + *
137 - * @param c input channel buffer 137 + * @param c input channel buffer
138 - * @return object of LinkLocalRemoteIdentifiersTlv 138 + * @return object of LinkLocalRemoteIdentifiersTlv
139 - */ 139 + */
140 - public static PcepValueType read(ChannelBuffer c) { 140 + public static PcepValueType read(ChannelBuffer c) {
141 - int iLinkLocalIdentifier = c.readInt(); 141 + int iLinkLocalIdentifier = c.readInt();
142 - int iLinkRemoteIdentifier = c.readInt(); 142 + int iLinkRemoteIdentifier = c.readInt();
143 - return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier); 143 + return new LinkLocalRemoteIdentifiersTlv(iLinkLocalIdentifier, iLinkRemoteIdentifier);
144 - } 144 + }
145 - 145 +
146 - @Override 146 + @Override
147 - public String toString() { 147 + public String toString() {
148 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH) 148 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
149 - .add("LinkLocalIdentifier", iLinkLocalIdentifier).add("LinkRemoteIdentifier", iLinkRemoteIdentifier) 149 + .add("LinkLocalIdentifier", iLinkLocalIdentifier).add("LinkRemoteIdentifier", iLinkRemoteIdentifier)
150 - .toString(); 150 + .toString();
151 - } 151 + }
152 -} 152 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides the Link Name. 29 + * Provides the Link Name.
30 - */ 30 + */
31 -public class LinkNameTlv implements PcepValueType { 31 +public class LinkNameTlv implements PcepValueType {
32 - 32 +
33 - /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.2.7 33 + /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.2.7
34 - * Link name tlv format. 34 + * Link name tlv format.
35 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | Type=TDB43 | Length | 38 + | Type=TDB43 | Length |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - // Link Name (variable) // 40 + // Link Name (variable) //
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - */ 42 + */
43 - 43 +
44 - protected static final Logger log = LoggerFactory.getLogger(LinkNameTlv.class); 44 + protected static final Logger log = LoggerFactory.getLogger(LinkNameTlv.class);
45 - 45 +
46 - public static final short TYPE = 1098; //TODO:NEED TO HANDLE TDB43 46 + public static final short TYPE = 1098; //TODO:NEED TO HANDLE TDB43
47 - private short hLength; 47 + private short hLength;
48 - 48 +
49 - private final byte[] rawValue; 49 + private final byte[] rawValue;
50 - 50 +
51 - /** 51 + /**
52 - * Constructor to initialize rawValue. 52 + * Constructor to initialize rawValue.
53 - * 53 + *
54 - * @param rawValue Link-Name 54 + * @param rawValue Link-Name
55 - * @param hLength length 55 + * @param hLength length
56 - */ 56 + */
57 - public LinkNameTlv(byte[] rawValue, short hLength) { 57 + public LinkNameTlv(byte[] rawValue, short hLength) {
58 - this.rawValue = rawValue; 58 + this.rawValue = rawValue;
59 - if (0 == hLength) { 59 + if (0 == hLength) {
60 - this.hLength = (short) rawValue.length; 60 + this.hLength = (short) rawValue.length;
61 - } else { 61 + } else {
62 - this.hLength = hLength; 62 + this.hLength = hLength;
63 - } 63 + }
64 - } 64 + }
65 - 65 +
66 - /** 66 + /**
67 - * Returns newly created LinkNameTlv object. 67 + * Returns newly created LinkNameTlv object.
68 - * 68 + *
69 - * @param raw Link-Name 69 + * @param raw Link-Name
70 - * @param hLength length 70 + * @param hLength length
71 - * @return object of LinkNameTlv 71 + * @return object of LinkNameTlv
72 - */ 72 + */
73 - public static LinkNameTlv of(final byte[] raw, short hLength) { 73 + public static LinkNameTlv of(final byte[] raw, short hLength) {
74 - return new LinkNameTlv(raw, hLength); 74 + return new LinkNameTlv(raw, hLength);
75 - } 75 + }
76 - 76 +
77 - /** 77 + /**
78 - * Returns value of Link-Name. 78 + * Returns value of Link-Name.
79 - * 79 + *
80 - * @return raw value 80 + * @return raw value
81 - */ 81 + */
82 - public byte[] getValue() { 82 + public byte[] getValue() {
83 - return rawValue; 83 + return rawValue;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public PcepVersion getVersion() { 87 + public PcepVersion getVersion() {
88 - return PcepVersion.PCEP_1; 88 + return PcepVersion.PCEP_1;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public short getType() { 92 + public short getType() {
93 - return TYPE; 93 + return TYPE;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public short getLength() { 97 + public short getLength() {
98 - return hLength; 98 + return hLength;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public int hashCode() { 102 + public int hashCode() {
103 - return Objects.hash(rawValue); 103 + return Objects.hash(rawValue);
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public boolean equals(Object obj) { 107 + public boolean equals(Object obj) {
108 - if (this == obj) { 108 + if (this == obj) {
109 - return true; 109 + return true;
110 - } 110 + }
111 - if (obj instanceof LinkNameTlv) { 111 + if (obj instanceof LinkNameTlv) {
112 - LinkNameTlv other = (LinkNameTlv) obj; 112 + LinkNameTlv other = (LinkNameTlv) obj;
113 - return Objects.equals(rawValue, other.rawValue); 113 + return Objects.equals(rawValue, other.rawValue);
114 - } 114 + }
115 - return false; 115 + return false;
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public int write(ChannelBuffer c) { 119 + public int write(ChannelBuffer c) {
120 - int iLenStartIndex = c.writerIndex(); 120 + int iLenStartIndex = c.writerIndex();
121 - c.writeShort(TYPE); 121 + c.writeShort(TYPE);
122 - c.writeShort(hLength); 122 + c.writeShort(hLength);
123 - c.writeBytes(rawValue); 123 + c.writeBytes(rawValue);
124 - return c.writerIndex() - iLenStartIndex; 124 + return c.writerIndex() - iLenStartIndex;
125 - } 125 + }
126 - 126 +
127 - /** 127 + /**
128 - * Reads the channel buffer and returns object of LinkNameTlv. 128 + * Reads the channel buffer and returns object of LinkNameTlv.
129 - * 129 + *
130 - * @param c input channel buffer 130 + * @param c input channel buffer
131 - * @param hLength length 131 + * @param hLength length
132 - * @return object of LinkNameTlv 132 + * @return object of LinkNameTlv
133 - */ 133 + */
134 - public static PcepValueType read(ChannelBuffer c, short hLength) { 134 + public static PcepValueType read(ChannelBuffer c, short hLength) {
135 - byte[] linkName = new byte[hLength]; 135 + byte[] linkName = new byte[hLength];
136 - c.readBytes(linkName, 0, hLength); 136 + c.readBytes(linkName, 0, hLength);
137 - return new LinkNameTlv(linkName, hLength); 137 + return new LinkNameTlv(linkName, hLength);
138 - } 138 + }
139 - 139 +
140 - @Override 140 + @Override
141 - public String toString() { 141 + public String toString() {
142 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 142 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
143 - 143 +
144 - toStrHelper.add("Type", TYPE); 144 + toStrHelper.add("Type", TYPE);
145 - toStrHelper.add("Length", hLength); 145 + toStrHelper.add("Length", hLength);
146 - 146 +
147 - StringBuffer result = new StringBuffer(); 147 + StringBuffer result = new StringBuffer();
148 - for (byte b : rawValue) { 148 + for (byte b : rawValue) {
149 - result.append(String.format("%02X ", b)); 149 + result.append(String.format("%02X ", b));
150 - } 150 + }
151 - toStrHelper.add("Value", result); 151 + toStrHelper.add("Value", result);
152 - 152 +
153 - return toStrHelper.toString(); 153 + return toStrHelper.toString();
154 - } 154 + }
155 -} 155 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provide Link Protection Type. 28 + * Provide Link Protection Type.
29 - */ 29 + */
30 - 30 +
31 -public class LinkProtectionTypeTlv implements PcepValueType { 31 +public class LinkProtectionTypeTlv implements PcepValueType {
32 - 32 +
33 - /* Reference :[RFC5307]/1.2 33 + /* Reference :[RFC5307]/1.2
34 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=[TDB38] | Length=2 | 37 + | Type=[TDB38] | Length=2 |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - |Protection Cap | Reserved | 39 + |Protection Cap | Reserved |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - */ 41 + */
42 - protected static final Logger log = LoggerFactory.getLogger(LinkProtectionTypeTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(LinkProtectionTypeTlv.class);
43 - 43 +
44 - public static final short TYPE = 20; //TDB38 44 + public static final short TYPE = 20; //TDB38
45 - public static final short LENGTH = 2; 45 + public static final short LENGTH = 2;
46 - private final byte protectionCap; 46 + private final byte protectionCap;
47 - private final byte reserved; 47 + private final byte reserved;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize protectionCap. 50 + * Constructor to initialize protectionCap.
51 - * 51 + *
52 - * @param protectionCap Protection Cap 52 + * @param protectionCap Protection Cap
53 - */ 53 + */
54 - public LinkProtectionTypeTlv(byte protectionCap) { 54 + public LinkProtectionTypeTlv(byte protectionCap) {
55 - this.protectionCap = protectionCap; 55 + this.protectionCap = protectionCap;
56 - this.reserved = 0; 56 + this.reserved = 0;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Constructor to initialize protectionCap, reserved. 60 + * Constructor to initialize protectionCap, reserved.
61 - * 61 + *
62 - * @param protectionCap Protection Cap 62 + * @param protectionCap Protection Cap
63 - * @param reserved Reserved value 63 + * @param reserved Reserved value
64 - */ 64 + */
65 - public LinkProtectionTypeTlv(byte protectionCap, byte reserved) { 65 + public LinkProtectionTypeTlv(byte protectionCap, byte reserved) {
66 - this.protectionCap = protectionCap; 66 + this.protectionCap = protectionCap;
67 - this.reserved = reserved; 67 + this.reserved = reserved;
68 - } 68 + }
69 - 69 +
70 - /** 70 + /**
71 - * Returns Protection Cap. 71 + * Returns Protection Cap.
72 - * 72 + *
73 - * @return protectionCap Protection Cap 73 + * @return protectionCap Protection Cap
74 - */ 74 + */
75 - public byte getProtectionCap() { 75 + public byte getProtectionCap() {
76 - return protectionCap; 76 + return protectionCap;
77 - } 77 + }
78 - 78 +
79 - @Override 79 + @Override
80 - public PcepVersion getVersion() { 80 + public PcepVersion getVersion() {
81 - return PcepVersion.PCEP_1; 81 + return PcepVersion.PCEP_1;
82 - } 82 + }
83 - 83 +
84 - @Override 84 + @Override
85 - public short getType() { 85 + public short getType() {
86 - return TYPE; 86 + return TYPE;
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public short getLength() { 90 + public short getLength() {
91 - return LENGTH; 91 + return LENGTH;
92 - } 92 + }
93 - 93 +
94 - @Override 94 + @Override
95 - public int hashCode() { 95 + public int hashCode() {
96 - return Objects.hash(protectionCap, reserved); 96 + return Objects.hash(protectionCap, reserved);
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public boolean equals(Object obj) { 100 + public boolean equals(Object obj) {
101 - if (this == obj) { 101 + if (this == obj) {
102 - return true; 102 + return true;
103 - } 103 + }
104 - if (obj instanceof LinkProtectionTypeTlv) { 104 + if (obj instanceof LinkProtectionTypeTlv) {
105 - LinkProtectionTypeTlv other = (LinkProtectionTypeTlv) obj; 105 + LinkProtectionTypeTlv other = (LinkProtectionTypeTlv) obj;
106 - return Objects.equals(protectionCap, other.protectionCap) && Objects.equals(reserved, other.reserved); 106 + return Objects.equals(protectionCap, other.protectionCap) && Objects.equals(reserved, other.reserved);
107 - } 107 + }
108 - 108 +
109 - return false; 109 + return false;
110 - } 110 + }
111 - 111 +
112 - @Override 112 + @Override
113 - public int write(ChannelBuffer c) { 113 + public int write(ChannelBuffer c) {
114 - int iLenStartIndex = c.writerIndex(); 114 + int iLenStartIndex = c.writerIndex();
115 - c.writeShort(TYPE); 115 + c.writeShort(TYPE);
116 - c.writeShort(LENGTH); 116 + c.writeShort(LENGTH);
117 - c.writeByte(protectionCap); 117 + c.writeByte(protectionCap);
118 - c.writeByte(reserved); 118 + c.writeByte(reserved);
119 - return c.writerIndex() - iLenStartIndex; 119 + return c.writerIndex() - iLenStartIndex;
120 - } 120 + }
121 - 121 +
122 - /** 122 + /**
123 - * Reads the channel buffer and returns object of LinkProtectionTypeTlv. 123 + * Reads the channel buffer and returns object of LinkProtectionTypeTlv.
124 - * 124 + *
125 - * @param c input channel buffer 125 + * @param c input channel buffer
126 - * @return object of LinkProtectionTypeTlv 126 + * @return object of LinkProtectionTypeTlv
127 - */ 127 + */
128 - public static PcepValueType read(ChannelBuffer c) { 128 + public static PcepValueType read(ChannelBuffer c) {
129 - byte protectionCap = c.readByte(); 129 + byte protectionCap = c.readByte();
130 - byte reserved = c.readByte(); 130 + byte reserved = c.readByte();
131 - return new LinkProtectionTypeTlv(protectionCap, reserved); 131 + return new LinkProtectionTypeTlv(protectionCap, reserved);
132 - } 132 + }
133 - 133 +
134 - @Override 134 + @Override
135 - public String toString() { 135 + public String toString() {
136 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH) 136 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
137 - .add("ProtectionCap", protectionCap).toString(); 137 + .add("ProtectionCap", protectionCap).toString();
138 - } 138 + }
139 } 139 }
...\ No newline at end of file ...\ No newline at end of file
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Iterator; 18 +import java.util.Iterator;
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 -import java.util.Objects; 21 +import java.util.Objects;
22 - 22 +
23 -import org.jboss.netty.buffer.ChannelBuffer; 23 +import org.jboss.netty.buffer.ChannelBuffer;
24 -import org.onosproject.pcepio.exceptions.PcepParseException; 24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 -import org.onosproject.pcepio.protocol.PcepVersion; 25 +import org.onosproject.pcepio.protocol.PcepVersion;
26 -import org.slf4j.Logger; 26 +import org.slf4j.Logger;
27 -import org.slf4j.LoggerFactory; 27 +import org.slf4j.LoggerFactory;
28 - 28 +
29 -import com.google.common.base.MoreObjects; 29 +import com.google.common.base.MoreObjects;
30 - 30 +
31 -/** 31 +/**
32 - * Provides Local TE Node Descriptors TLV which contains Node Descriptor Sub-TLVs. 32 + * Provides Local TE Node Descriptors TLV which contains Node Descriptor Sub-TLVs.
33 - */ 33 + */
34 -public class LocalTENodeDescriptorsTLV implements PcepValueType { 34 +public class LocalTENodeDescriptorsTLV implements PcepValueType {
35 - 35 +
36 - /* REFERENCE :draft-ietf-idr-ls-distribution-10 36 + /* REFERENCE :draft-ietf-idr-ls-distribution-10
37 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Type=[TBD8] | Length | 40 + | Type=[TBD8] | Length |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | | 42 + | |
43 - // Node Descriptor Sub-TLVs (variable) // 43 + // Node Descriptor Sub-TLVs (variable) //
44 - | | 44 + | |
45 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 - Note: Length is including header here. Refer Routing Universe TLV. 46 + Note: Length is including header here. Refer Routing Universe TLV.
47 - */ 47 + */
48 - 48 +
49 - protected static final Logger log = LoggerFactory.getLogger(LocalTENodeDescriptorsTLV.class); 49 + protected static final Logger log = LoggerFactory.getLogger(LocalTENodeDescriptorsTLV.class);
50 - 50 +
51 - public static final short TYPE = 1637; //TODD:change this TBD8 51 + public static final short TYPE = 1637; //TODD:change this TBD8
52 - public short hLength; 52 + public short hLength;
53 - 53 +
54 - public static final int TLV_HEADER_LENGTH = 4; 54 + public static final int TLV_HEADER_LENGTH = 4;
55 - // Node Descriptor Sub-TLVs (variable) 55 + // Node Descriptor Sub-TLVs (variable)
56 - private LinkedList<PcepValueType> llNodeDescriptorSubTLVs; 56 + private LinkedList<PcepValueType> llNodeDescriptorSubTLVs;
57 - 57 +
58 - /** 58 + /**
59 - * Constructor to initialize llNodeDescriptorSubTLVs. 59 + * Constructor to initialize llNodeDescriptorSubTLVs.
60 - * 60 + *
61 - * @param llNodeDescriptorSubTLVs LinkedList of PcepValueType 61 + * @param llNodeDescriptorSubTLVs LinkedList of PcepValueType
62 - */ 62 + */
63 - public LocalTENodeDescriptorsTLV(LinkedList<PcepValueType> llNodeDescriptorSubTLVs) { 63 + public LocalTENodeDescriptorsTLV(LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
64 - this.llNodeDescriptorSubTLVs = llNodeDescriptorSubTLVs; 64 + this.llNodeDescriptorSubTLVs = llNodeDescriptorSubTLVs;
65 - } 65 + }
66 - 66 +
67 - /** 67 + /**
68 - * Returns a new object of LocalTENodeDescriptorsTLV. 68 + * Returns a new object of LocalTENodeDescriptorsTLV.
69 - * 69 + *
70 - * @param llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLVs 70 + * @param llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLVs
71 - * @return object of LocalTENodeDescriptorsTLV 71 + * @return object of LocalTENodeDescriptorsTLV
72 - */ 72 + */
73 - public static LocalTENodeDescriptorsTLV of(final LinkedList<PcepValueType> llNodeDescriptorSubTLVs) { 73 + public static LocalTENodeDescriptorsTLV of(final LinkedList<PcepValueType> llNodeDescriptorSubTLVs) {
74 - return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs); 74 + return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs);
75 - } 75 + }
76 - 76 +
77 - /** 77 + /**
78 - * Returns Linked List of tlvs. 78 + * Returns Linked List of tlvs.
79 - * 79 + *
80 - * @return llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLV 80 + * @return llNodeDescriptorSubTLVs linked list of Node Descriptor Sub TLV
81 - */ 81 + */
82 - public LinkedList<PcepValueType> getllNodeDescriptorSubTLVs() { 82 + public LinkedList<PcepValueType> getllNodeDescriptorSubTLVs() {
83 - return llNodeDescriptorSubTLVs; 83 + return llNodeDescriptorSubTLVs;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public PcepVersion getVersion() { 87 + public PcepVersion getVersion() {
88 - return PcepVersion.PCEP_1; 88 + return PcepVersion.PCEP_1;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public short getType() { 92 + public short getType() {
93 - return TYPE; 93 + return TYPE;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public short getLength() { 97 + public short getLength() {
98 - return hLength; 98 + return hLength;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public int hashCode() { 102 + public int hashCode() {
103 - return Objects.hash(llNodeDescriptorSubTLVs.hashCode()); 103 + return Objects.hash(llNodeDescriptorSubTLVs.hashCode());
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public boolean equals(Object obj) { 107 + public boolean equals(Object obj) {
108 - if (this == obj) { 108 + if (this == obj) {
109 - return true; 109 + return true;
110 - } 110 + }
111 - 111 +
112 - /* 112 + /*
113 - * Here we have a list of Tlv so to compare each sub tlv between the object 113 + * Here we have a list of Tlv so to compare each sub tlv between the object
114 - * we have to take a list iterator so one by one we can get each sub tlv object 114 + * we have to take a list iterator so one by one we can get each sub tlv object
115 - * and can compare them. 115 + * and can compare them.
116 - * it may be possible that the size of 2 lists is not equal so we have to first check 116 + * it may be possible that the size of 2 lists is not equal so we have to first check
117 - * the size, if both are same then we should check for the subtlv objects otherwise 117 + * the size, if both are same then we should check for the subtlv objects otherwise
118 - * we should return false. 118 + * we should return false.
119 - */ 119 + */
120 - if (obj instanceof LocalTENodeDescriptorsTLV) { 120 + if (obj instanceof LocalTENodeDescriptorsTLV) {
121 - int countObjSubTlv = 0; 121 + int countObjSubTlv = 0;
122 - int countOtherSubTlv = 0; 122 + int countOtherSubTlv = 0;
123 - boolean isCommonSubTlv = true; 123 + boolean isCommonSubTlv = true;
124 - LocalTENodeDescriptorsTLV other = (LocalTENodeDescriptorsTLV) obj; 124 + LocalTENodeDescriptorsTLV other = (LocalTENodeDescriptorsTLV) obj;
125 - Iterator<PcepValueType> objListIterator = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs 125 + Iterator<PcepValueType> objListIterator = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs
126 - .iterator(); 126 + .iterator();
127 - countObjSubTlv = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs.size(); 127 + countObjSubTlv = ((LocalTENodeDescriptorsTLV) obj).llNodeDescriptorSubTLVs.size();
128 - countOtherSubTlv = other.llNodeDescriptorSubTLVs.size(); 128 + countOtherSubTlv = other.llNodeDescriptorSubTLVs.size();
129 - if (countObjSubTlv != countOtherSubTlv) { 129 + if (countObjSubTlv != countOtherSubTlv) {
130 - return false; 130 + return false;
131 - } else { 131 + } else {
132 - while (objListIterator.hasNext() && isCommonSubTlv) { 132 + while (objListIterator.hasNext() && isCommonSubTlv) {
133 - PcepValueType subTlv = objListIterator.next(); 133 + PcepValueType subTlv = objListIterator.next();
134 - isCommonSubTlv = Objects.equals(llNodeDescriptorSubTLVs.contains(subTlv), 134 + isCommonSubTlv = Objects.equals(llNodeDescriptorSubTLVs.contains(subTlv),
135 - other.llNodeDescriptorSubTLVs.contains(subTlv)); 135 + other.llNodeDescriptorSubTLVs.contains(subTlv));
136 - } 136 + }
137 - return isCommonSubTlv; 137 + return isCommonSubTlv;
138 - } 138 + }
139 - } 139 + }
140 - return false; 140 + return false;
141 - } 141 + }
142 - 142 +
143 - @Override 143 + @Override
144 - public int write(ChannelBuffer c) { 144 + public int write(ChannelBuffer c) {
145 - int tlvStartIndex = c.writerIndex(); 145 + int tlvStartIndex = c.writerIndex();
146 - c.writeShort(TYPE); 146 + c.writeShort(TYPE);
147 - int tlvLenIndex = c.writerIndex(); 147 + int tlvLenIndex = c.writerIndex();
148 - hLength = 0; 148 + hLength = 0;
149 - c.writeShort(0); 149 + c.writeShort(0);
150 - 150 +
151 - ListIterator<PcepValueType> listIterator = llNodeDescriptorSubTLVs.listIterator(); 151 + ListIterator<PcepValueType> listIterator = llNodeDescriptorSubTLVs.listIterator();
152 - 152 +
153 - while (listIterator.hasNext()) { 153 + while (listIterator.hasNext()) {
154 - PcepValueType tlv = listIterator.next(); 154 + PcepValueType tlv = listIterator.next();
155 - if (null == tlv) { 155 + if (null == tlv) {
156 - log.debug("TLV is null from subTlv list"); 156 + log.debug("TLV is null from subTlv list");
157 - continue; 157 + continue;
158 - } 158 + }
159 - tlv.write(c); 159 + tlv.write(c);
160 - 160 +
161 - // need to take care of padding 161 + // need to take care of padding
162 - int pad = tlv.getLength() % 4; 162 + int pad = tlv.getLength() % 4;
163 - 163 +
164 - if (0 != pad) { 164 + if (0 != pad) {
165 - pad = 4 - pad; 165 + pad = 4 - pad;
166 - for (int i = 0; i < pad; ++i) { 166 + for (int i = 0; i < pad; ++i) {
167 - c.writeByte((byte) 0); 167 + c.writeByte((byte) 0);
168 - } 168 + }
169 - } 169 + }
170 - } 170 + }
171 - hLength = (short) (c.writerIndex() - tlvStartIndex); 171 + hLength = (short) (c.writerIndex() - tlvStartIndex);
172 - c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH)); 172 + c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
173 - return c.writerIndex() - tlvStartIndex; 173 + return c.writerIndex() - tlvStartIndex;
174 - } 174 + }
175 - 175 +
176 - /** 176 + /**
177 - * Reads the channel buffer and returns object of AutonomousSystemTlv. 177 + * Reads the channel buffer and returns object of AutonomousSystemTlv.
178 - * 178 + *
179 - * @param c input channel buffer 179 + * @param c input channel buffer
180 - * @param hLength length of subtlvs. 180 + * @param hLength length of subtlvs.
181 - * @return object of AutonomousSystemTlv 181 + * @return object of AutonomousSystemTlv
182 - * @throws PcepParseException if mandatory fields are missing 182 + * @throws PcepParseException if mandatory fields are missing
183 - */ 183 + */
184 - public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException { 184 + public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
185 - 185 +
186 - // Node Descriptor Sub-TLVs (variable) 186 + // Node Descriptor Sub-TLVs (variable)
187 - LinkedList<PcepValueType> llNodeDescriptorSubTLVs = new LinkedList<PcepValueType>(); 187 + LinkedList<PcepValueType> llNodeDescriptorSubTLVs = new LinkedList<PcepValueType>();
188 - 188 +
189 - ChannelBuffer tempCb = c.readBytes(hLength); 189 + ChannelBuffer tempCb = c.readBytes(hLength);
190 - 190 +
191 - while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) { 191 + while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
192 - 192 +
193 - PcepValueType tlv; 193 + PcepValueType tlv;
194 - short hType = tempCb.readShort(); 194 + short hType = tempCb.readShort();
195 - int iValue = 0; 195 + int iValue = 0;
196 - short length = tempCb.readShort(); 196 + short length = tempCb.readShort();
197 - 197 +
198 - switch (hType) { 198 + switch (hType) {
199 - 199 +
200 - case AutonomousSystemTlv.TYPE: 200 + case AutonomousSystemTlv.TYPE:
201 - iValue = tempCb.readInt(); 201 + iValue = tempCb.readInt();
202 - tlv = new AutonomousSystemTlv(iValue); 202 + tlv = new AutonomousSystemTlv(iValue);
203 - break; 203 + break;
204 - case BGPLSidentifierTlv.TYPE: 204 + case BGPLSidentifierTlv.TYPE:
205 - iValue = tempCb.readInt(); 205 + iValue = tempCb.readInt();
206 - tlv = new BGPLSidentifierTlv(iValue); 206 + tlv = new BGPLSidentifierTlv(iValue);
207 - break; 207 + break;
208 - case OSPFareaIDsubTlv.TYPE: 208 + case OSPFareaIDsubTlv.TYPE:
209 - iValue = tempCb.readInt(); 209 + iValue = tempCb.readInt();
210 - tlv = new OSPFareaIDsubTlv(iValue); 210 + tlv = new OSPFareaIDsubTlv(iValue);
211 - break; 211 + break;
212 - case RouterIDSubTlv.TYPE: 212 + case RouterIDSubTlv.TYPE:
213 - tlv = RouterIDSubTlv.read(tempCb, length); 213 + tlv = RouterIDSubTlv.read(tempCb, length);
214 - break; 214 + break;
215 - 215 +
216 - default: 216 + default:
217 - throw new PcepParseException("Unsupported Sub TLV type :" + hType); 217 + throw new PcepParseException("Unsupported Sub TLV type :" + hType);
218 - } 218 + }
219 - 219 +
220 - // Check for the padding 220 + // Check for the padding
221 - int pad = length % 4; 221 + int pad = length % 4;
222 - if (0 < pad) { 222 + if (0 < pad) {
223 - pad = 4 - pad; 223 + pad = 4 - pad;
224 - if (pad <= tempCb.readableBytes()) { 224 + if (pad <= tempCb.readableBytes()) {
225 - tempCb.skipBytes(pad); 225 + tempCb.skipBytes(pad);
226 - } 226 + }
227 - } 227 + }
228 - 228 +
229 - llNodeDescriptorSubTLVs.add(tlv); 229 + llNodeDescriptorSubTLVs.add(tlv);
230 - } 230 + }
231 - 231 +
232 - if (0 < tempCb.readableBytes()) { 232 + if (0 < tempCb.readableBytes()) {
233 - throw new PcepParseException("Sub Tlv parsing error. Extra bytes received."); 233 + throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
234 - } 234 + }
235 - return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs); 235 + return new LocalTENodeDescriptorsTLV(llNodeDescriptorSubTLVs);
236 - } 236 + }
237 - 237 +
238 - @Override 238 + @Override
239 - public String toString() { 239 + public String toString() {
240 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength) 240 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
241 - .add("NodeDescriptorSubTLVs", llNodeDescriptorSubTLVs).toString(); 241 + .add("NodeDescriptorSubTLVs", llNodeDescriptorSubTLVs).toString();
242 - } 242 + }
243 -} 243 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides MPLS Protocol Mask. 28 + * Provides MPLS Protocol Mask.
29 - */ 29 + */
30 -public class MPLSProtocolMaskTlv implements PcepValueType { 30 +public class MPLSProtocolMaskTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :[I-D.ietf-idr-ls-distribution]/3.3.2.2 32 + /* Reference :[I-D.ietf-idr-ls-distribution]/3.3.2.2
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=TDB39 | Length =1 | 36 + | Type=TDB39 | Length =1 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - |L|R| Reserved | 38 + |L|R| Reserved |
39 - +-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - protected static final Logger log = LoggerFactory.getLogger(MPLSProtocolMaskTlv.class); 41 + protected static final Logger log = LoggerFactory.getLogger(MPLSProtocolMaskTlv.class);
42 - 42 +
43 - public static final short TYPE = 1094; //TDB39 43 + public static final short TYPE = 1094; //TDB39
44 - public static final short LENGTH = 1; 44 + public static final short LENGTH = 1;
45 - public static final int SET = 1; 45 + public static final int SET = 1;
46 - public static final byte LFLAG_SET = (byte) 0x80; 46 + public static final byte LFLAG_SET = (byte) 0x80;
47 - public static final byte RFLAG_SET = 0x40; 47 + public static final byte RFLAG_SET = 0x40;
48 - 48 +
49 - private final byte rawValue; 49 + private final byte rawValue;
50 - private final boolean bLFlag; 50 + private final boolean bLFlag;
51 - private final boolean bRFlag; 51 + private final boolean bRFlag;
52 - private final boolean isRawValueSet; 52 + private final boolean isRawValueSet;
53 - 53 +
54 - /** 54 + /**
55 - * constructor to initialize rawValue. 55 + * constructor to initialize rawValue.
56 - * 56 + *
57 - * @param rawValue MPLS Protocol Mask Flag Bits 57 + * @param rawValue MPLS Protocol Mask Flag Bits
58 - */ 58 + */
59 - public MPLSProtocolMaskTlv(byte rawValue) { 59 + public MPLSProtocolMaskTlv(byte rawValue) {
60 - this.rawValue = rawValue; 60 + this.rawValue = rawValue;
61 - isRawValueSet = true; 61 + isRawValueSet = true;
62 - byte temp = rawValue; 62 + byte temp = rawValue;
63 - if ((temp & LFLAG_SET) == SET) { 63 + if ((temp & LFLAG_SET) == SET) {
64 - this.bLFlag = true; 64 + this.bLFlag = true;
65 - 65 +
66 - } else { 66 + } else {
67 - this.bLFlag = false; 67 + this.bLFlag = false;
68 - } 68 + }
69 - if ((temp & RFLAG_SET) == SET) { 69 + if ((temp & RFLAG_SET) == SET) {
70 - this.bRFlag = true; 70 + this.bRFlag = true;
71 - } else { 71 + } else {
72 - this.bRFlag = false; 72 + this.bRFlag = false;
73 - } 73 + }
74 - } 74 + }
75 - 75 +
76 - /** 76 + /**
77 - * constructor to initialize different Flags. 77 + * constructor to initialize different Flags.
78 - * 78 + *
79 - * @param bLFlag L-flag 79 + * @param bLFlag L-flag
80 - * @param bRFlag R-flag 80 + * @param bRFlag R-flag
81 - */ 81 + */
82 - public MPLSProtocolMaskTlv(boolean bLFlag, boolean bRFlag) { 82 + public MPLSProtocolMaskTlv(boolean bLFlag, boolean bRFlag) {
83 - this.bLFlag = bLFlag; 83 + this.bLFlag = bLFlag;
84 - this.bRFlag = bRFlag; 84 + this.bRFlag = bRFlag;
85 - this.rawValue = 0; 85 + this.rawValue = 0;
86 - isRawValueSet = false; 86 + isRawValueSet = false;
87 - } 87 + }
88 - 88 +
89 - /** 89 + /**
90 - * Returns newly created MPLSProtocolMaskTlv object. 90 + * Returns newly created MPLSProtocolMaskTlv object.
91 - * 91 + *
92 - * @param raw MPLS Protocol Mask Tlv 92 + * @param raw MPLS Protocol Mask Tlv
93 - * @return new object of MPLS Protocol Mask Tlv 93 + * @return new object of MPLS Protocol Mask Tlv
94 - */ 94 + */
95 - public static MPLSProtocolMaskTlv of(final byte raw) { 95 + public static MPLSProtocolMaskTlv of(final byte raw) {
96 - return new MPLSProtocolMaskTlv(raw); 96 + return new MPLSProtocolMaskTlv(raw);
97 - } 97 + }
98 - 98 +
99 - /** 99 + /**
100 - * Returns L-flag. 100 + * Returns L-flag.
101 - * 101 + *
102 - * @return bLFlag L-flag 102 + * @return bLFlag L-flag
103 - */ 103 + */
104 - public boolean getbLFlag() { 104 + public boolean getbLFlag() {
105 - return bLFlag; 105 + return bLFlag;
106 - } 106 + }
107 - 107 +
108 - /** 108 + /**
109 - * Returns R-flag. 109 + * Returns R-flag.
110 - * 110 + *
111 - * @return bRFlag R-flag 111 + * @return bRFlag R-flag
112 - */ 112 + */
113 - public boolean getbRFlag() { 113 + public boolean getbRFlag() {
114 - return bRFlag; 114 + return bRFlag;
115 - } 115 + }
116 - 116 +
117 - /** 117 + /**
118 - * Returns raw value. 118 + * Returns raw value.
119 - * 119 + *
120 - * @return rawValue raw value 120 + * @return rawValue raw value
121 - */ 121 + */
122 - public byte getByte() { 122 + public byte getByte() {
123 - return rawValue; 123 + return rawValue;
124 - } 124 + }
125 - 125 +
126 - @Override 126 + @Override
127 - public PcepVersion getVersion() { 127 + public PcepVersion getVersion() {
128 - return PcepVersion.PCEP_1; 128 + return PcepVersion.PCEP_1;
129 - } 129 + }
130 - 130 +
131 - @Override 131 + @Override
132 - public short getType() { 132 + public short getType() {
133 - return TYPE; 133 + return TYPE;
134 - } 134 + }
135 - 135 +
136 - @Override 136 + @Override
137 - public short getLength() { 137 + public short getLength() {
138 - return LENGTH; 138 + return LENGTH;
139 - } 139 + }
140 - 140 +
141 - @Override 141 + @Override
142 - public int hashCode() { 142 + public int hashCode() {
143 - if (isRawValueSet) { 143 + if (isRawValueSet) {
144 - return Objects.hash(rawValue); 144 + return Objects.hash(rawValue);
145 - } else { 145 + } else {
146 - return Objects.hash(bLFlag, bRFlag); 146 + return Objects.hash(bLFlag, bRFlag);
147 - } 147 + }
148 - } 148 + }
149 - 149 +
150 - @Override 150 + @Override
151 - public boolean equals(Object obj) { 151 + public boolean equals(Object obj) {
152 - if (this == obj) { 152 + if (this == obj) {
153 - return true; 153 + return true;
154 - } 154 + }
155 - if (obj instanceof MPLSProtocolMaskTlv) { 155 + if (obj instanceof MPLSProtocolMaskTlv) {
156 - MPLSProtocolMaskTlv other = (MPLSProtocolMaskTlv) obj; 156 + MPLSProtocolMaskTlv other = (MPLSProtocolMaskTlv) obj;
157 - if (isRawValueSet) { 157 + if (isRawValueSet) {
158 - return Objects.equals(this.rawValue, other.rawValue); 158 + return Objects.equals(this.rawValue, other.rawValue);
159 - } else { 159 + } else {
160 - return Objects.equals(this.bLFlag, other.bLFlag) && Objects.equals(this.bRFlag, other.bRFlag); 160 + return Objects.equals(this.bLFlag, other.bLFlag) && Objects.equals(this.bRFlag, other.bRFlag);
161 - } 161 + }
162 - } 162 + }
163 - return false; 163 + return false;
164 - } 164 + }
165 - 165 +
166 - @Override 166 + @Override
167 - public int write(ChannelBuffer c) { 167 + public int write(ChannelBuffer c) {
168 - int iLenStartIndex = c.writerIndex(); 168 + int iLenStartIndex = c.writerIndex();
169 - c.writeShort(TYPE); 169 + c.writeShort(TYPE);
170 - c.writeShort(LENGTH); 170 + c.writeShort(LENGTH);
171 - if (isRawValueSet) { 171 + if (isRawValueSet) {
172 - c.writeByte(rawValue); 172 + c.writeByte(rawValue);
173 - } else { 173 + } else {
174 - byte temp = 0; 174 + byte temp = 0;
175 - if (bLFlag) { 175 + if (bLFlag) {
176 - temp = (byte) (temp | LFLAG_SET); 176 + temp = (byte) (temp | LFLAG_SET);
177 - } 177 + }
178 - if (bRFlag) { 178 + if (bRFlag) {
179 - temp = (byte) (temp | RFLAG_SET); 179 + temp = (byte) (temp | RFLAG_SET);
180 - } 180 + }
181 - c.writeByte(temp); 181 + c.writeByte(temp);
182 - } 182 + }
183 - return c.writerIndex() - iLenStartIndex; 183 + return c.writerIndex() - iLenStartIndex;
184 - } 184 + }
185 - 185 +
186 - /** 186 + /**
187 - * Reads the channel buffer and returns object of MPLS Protocol Mask Tlv. 187 + * Reads the channel buffer and returns object of MPLS Protocol Mask Tlv.
188 - * 188 + *
189 - * @param c input channel buffer 189 + * @param c input channel buffer
190 - * @return object of MPLS Protocol Mask Tlv 190 + * @return object of MPLS Protocol Mask Tlv
191 - */ 191 + */
192 - public static PcepValueType read(ChannelBuffer c) { 192 + public static PcepValueType read(ChannelBuffer c) {
193 - byte temp = c.readByte(); 193 + byte temp = c.readByte();
194 - boolean bLFlag; 194 + boolean bLFlag;
195 - boolean bRFlag; 195 + boolean bRFlag;
196 - 196 +
197 - if ((temp & LFLAG_SET) == SET) { 197 + if ((temp & LFLAG_SET) == SET) {
198 - bLFlag = true; 198 + bLFlag = true;
199 - } else { 199 + } else {
200 - bLFlag = false; 200 + bLFlag = false;
201 - } 201 + }
202 - if ((temp & RFLAG_SET) == SET) { 202 + if ((temp & RFLAG_SET) == SET) {
203 - bRFlag = true; 203 + bRFlag = true;
204 - } else { 204 + } else {
205 - bRFlag = false; 205 + bRFlag = false;
206 - } 206 + }
207 - return new MPLSProtocolMaskTlv(bLFlag, bRFlag); 207 + return new MPLSProtocolMaskTlv(bLFlag, bRFlag);
208 - } 208 + }
209 - 209 +
210 - @Override 210 + @Override
211 - public String toString() { 211 + public String toString() {
212 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 212 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
213 - .toString(); 213 + .toString();
214 - } 214 + }
215 -} 215 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provide the Maximum Link Bandwidth. 28 + * Provide the Maximum Link Bandwidth.
29 - */ 29 + */
30 -public class MaximumLinkBandwidthTlv implements PcepValueType { 30 +public class MaximumLinkBandwidthTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :[RFC5305]/3.3. 32 + /* Reference :[RFC5305]/3.3.
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TDB34] | Length=4 | 36 + | Type=[TDB34] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | Maximum Link Bandwidth | 38 + | Maximum Link Bandwidth |
39 - +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+- 39 + +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(MaximumLinkBandwidthTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(MaximumLinkBandwidthTlv.class);
43 - 43 +
44 - public static final short TYPE = 9; //TDB34 44 + public static final short TYPE = 9; //TDB34
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue Maximum-Link-Bandwidth 52 + * @param rawValue Maximum-Link-Bandwidth
53 - */ 53 + */
54 - 54 +
55 - public MaximumLinkBandwidthTlv(int rawValue) { 55 + public MaximumLinkBandwidthTlv(int rawValue) {
56 - this.rawValue = rawValue; 56 + this.rawValue = rawValue;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Returns newly created MaximumLinkBandwidthTlv object. 60 + * Returns newly created MaximumLinkBandwidthTlv object.
61 - * 61 + *
62 - * @param raw value of Maximum-Link-Bandwidth 62 + * @param raw value of Maximum-Link-Bandwidth
63 - * @return object of MaximumLinkBandwidthTlv 63 + * @return object of MaximumLinkBandwidthTlv
64 - */ 64 + */
65 - public static MaximumLinkBandwidthTlv of(final int raw) { 65 + public static MaximumLinkBandwidthTlv of(final int raw) {
66 - return new MaximumLinkBandwidthTlv(raw); 66 + return new MaximumLinkBandwidthTlv(raw);
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns value of Maximum Link Bandwidth. 70 + * Returns value of Maximum Link Bandwidth.
71 - * 71 + *
72 - * @return rawValue Maximum Link Bandwidth 72 + * @return rawValue Maximum Link Bandwidth
73 - */ 73 + */
74 - public int getInt() { 74 + public int getInt() {
75 - return rawValue; 75 + return rawValue;
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public PcepVersion getVersion() { 79 + public PcepVersion getVersion() {
80 - return PcepVersion.PCEP_1; 80 + return PcepVersion.PCEP_1;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public short getType() { 84 + public short getType() {
85 - return TYPE; 85 + return TYPE;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public short getLength() { 89 + public short getLength() {
90 - return LENGTH; 90 + return LENGTH;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public int hashCode() { 94 + public int hashCode() {
95 - return Objects.hash(rawValue); 95 + return Objects.hash(rawValue);
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public boolean equals(Object obj) { 99 + public boolean equals(Object obj) {
100 - if (this == obj) { 100 + if (this == obj) {
101 - return true; 101 + return true;
102 - } 102 + }
103 - if (obj instanceof MaximumLinkBandwidthTlv) { 103 + if (obj instanceof MaximumLinkBandwidthTlv) {
104 - MaximumLinkBandwidthTlv other = (MaximumLinkBandwidthTlv) obj; 104 + MaximumLinkBandwidthTlv other = (MaximumLinkBandwidthTlv) obj;
105 - return Objects.equals(rawValue, other.rawValue); 105 + return Objects.equals(rawValue, other.rawValue);
106 - } 106 + }
107 - return false; 107 + return false;
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public int write(ChannelBuffer c) { 111 + public int write(ChannelBuffer c) {
112 - int iLenStartIndex = c.writerIndex(); 112 + int iLenStartIndex = c.writerIndex();
113 - c.writeShort(TYPE); 113 + c.writeShort(TYPE);
114 - c.writeShort(LENGTH); 114 + c.writeShort(LENGTH);
115 - c.writeInt(rawValue); 115 + c.writeInt(rawValue);
116 - return c.writerIndex() - iLenStartIndex; 116 + return c.writerIndex() - iLenStartIndex;
117 - } 117 + }
118 - 118 +
119 - /** 119 + /**
120 - * Reads the channel buffer and returns object of MaximumLinkBandwidthTlv. 120 + * Reads the channel buffer and returns object of MaximumLinkBandwidthTlv.
121 - * 121 + *
122 - * @param c input channel buffer 122 + * @param c input channel buffer
123 - * @return object of MaximumLinkBandwidthTlv 123 + * @return object of MaximumLinkBandwidthTlv
124 - */ 124 + */
125 - public static MaximumLinkBandwidthTlv read(ChannelBuffer c) { 125 + public static MaximumLinkBandwidthTlv read(ChannelBuffer c) {
126 - return MaximumLinkBandwidthTlv.of(c.readInt()); 126 + return MaximumLinkBandwidthTlv.of(c.readInt());
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public String toString() { 130 + public String toString() {
131 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 131 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
132 - .toString(); 132 + .toString();
133 - } 133 + }
134 -} 134 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provide the Maximum Reservable Link Bandwidth. 28 + * Provide the Maximum Reservable Link Bandwidth.
29 - */ 29 + */
30 -public class MaximumReservableLinkBandwidthTlv implements PcepValueType { 30 +public class MaximumReservableLinkBandwidthTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :[RFC5305]/3.5. 32 + /* Reference :[RFC5305]/3.5.
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TDB35] | Length=4 | 36 + | Type=[TDB35] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | Maximum Reservable Link Bandwidth | 38 + | Maximum Reservable Link Bandwidth |
39 - +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+- 39 + +-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-+-+-+-+-+-++-+-+-+-
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(MaximumReservableLinkBandwidthTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(MaximumReservableLinkBandwidthTlv.class);
43 - 43 +
44 - public static final short TYPE = 10; // TDB35 44 + public static final short TYPE = 10; // TDB35
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * constructor to initialize rawValue. 50 + * constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue MaximumReservableLinkBandwidth 52 + * @param rawValue MaximumReservableLinkBandwidth
53 - */ 53 + */
54 - public MaximumReservableLinkBandwidthTlv(int rawValue) { 54 + public MaximumReservableLinkBandwidthTlv(int rawValue) {
55 - log.debug("MaximumReservableLinkBandwidthTlv"); 55 + log.debug("MaximumReservableLinkBandwidthTlv");
56 - this.rawValue = rawValue; 56 + this.rawValue = rawValue;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Returns newly created MaximumReservableLinkBandwidth object. 60 + * Returns newly created MaximumReservableLinkBandwidth object.
61 - * 61 + *
62 - * @param raw MaximumReservableLinkBandwidth 62 + * @param raw MaximumReservableLinkBandwidth
63 - * @return object of MaximumReservableLinkBandwidthTlv 63 + * @return object of MaximumReservableLinkBandwidthTlv
64 - */ 64 + */
65 - public static MaximumReservableLinkBandwidthTlv of(final int raw) { 65 + public static MaximumReservableLinkBandwidthTlv of(final int raw) {
66 - return new MaximumReservableLinkBandwidthTlv(raw); 66 + return new MaximumReservableLinkBandwidthTlv(raw);
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns value of Maximum Reservable Link Bandwidth. 70 + * Returns value of Maximum Reservable Link Bandwidth.
71 - * @return rawValue Maximum Reservable Link Bandwidth 71 + * @return rawValue Maximum Reservable Link Bandwidth
72 - */ 72 + */
73 - public int getInt() { 73 + public int getInt() {
74 - return rawValue; 74 + return rawValue;
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepVersion getVersion() { 78 + public PcepVersion getVersion() {
79 - return PcepVersion.PCEP_1; 79 + return PcepVersion.PCEP_1;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public short getType() { 83 + public short getType() {
84 - return TYPE; 84 + return TYPE;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public short getLength() { 88 + public short getLength() {
89 - return LENGTH; 89 + return LENGTH;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public int hashCode() { 93 + public int hashCode() {
94 - return Objects.hash(rawValue); 94 + return Objects.hash(rawValue);
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public boolean equals(Object obj) { 98 + public boolean equals(Object obj) {
99 - if (this == obj) { 99 + if (this == obj) {
100 - return true; 100 + return true;
101 - } 101 + }
102 - if (obj instanceof MaximumReservableLinkBandwidthTlv) { 102 + if (obj instanceof MaximumReservableLinkBandwidthTlv) {
103 - MaximumReservableLinkBandwidthTlv other = (MaximumReservableLinkBandwidthTlv) obj; 103 + MaximumReservableLinkBandwidthTlv other = (MaximumReservableLinkBandwidthTlv) obj;
104 - return Objects.equals(this.rawValue, other.rawValue); 104 + return Objects.equals(this.rawValue, other.rawValue);
105 - } 105 + }
106 - return false; 106 + return false;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int write(ChannelBuffer c) { 110 + public int write(ChannelBuffer c) {
111 - int iLenStartIndex = c.writerIndex(); 111 + int iLenStartIndex = c.writerIndex();
112 - c.writeShort(TYPE); 112 + c.writeShort(TYPE);
113 - c.writeShort(LENGTH); 113 + c.writeShort(LENGTH);
114 - c.writeInt(rawValue); 114 + c.writeInt(rawValue);
115 - return c.writerIndex() - iLenStartIndex; 115 + return c.writerIndex() - iLenStartIndex;
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * Reads the channel buffer and returns object of MaximumReservableLinkBandwidthTlv. 119 + * Reads the channel buffer and returns object of MaximumReservableLinkBandwidthTlv.
120 - * 120 + *
121 - * @param c input channel buffer 121 + * @param c input channel buffer
122 - * @return object of MaximumReservableLinkBandwidthTlv 122 + * @return object of MaximumReservableLinkBandwidthTlv
123 - */ 123 + */
124 - public static MaximumReservableLinkBandwidthTlv read(ChannelBuffer c) { 124 + public static MaximumReservableLinkBandwidthTlv read(ChannelBuffer c) {
125 - return MaximumReservableLinkBandwidthTlv.of(c.readInt()); 125 + return MaximumReservableLinkBandwidthTlv.of(c.readInt());
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public String toString() { 129 + public String toString() {
130 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 130 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
131 - .toString(); 131 + .toString();
132 - } 132 + }
133 -} 133 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * NexthopIPv6addressTlv provides Ipv4 address of next hop. 29 + * NexthopIPv6addressTlv provides Ipv4 address of next hop.
30 - */ 30 + */
31 -public class NexthopIPv4addressTlv implements PcepValueType { 31 +public class NexthopIPv4addressTlv implements PcepValueType {
32 - 32 +
33 - /* 33 + /*
34 - Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01 34 + Reference :draft-zhao-pce-pcep-extension-for-pce-controller-01
35 - 35 +
36 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | Type=TBD | Length = 8 | 39 + | Type=TBD | Length = 8 |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | nexthop IPv4 address | 41 + | nexthop IPv4 address |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - 43 +
44 - NEXTHOP-IPV4-ADDRESS TLV 44 + NEXTHOP-IPV4-ADDRESS TLV
45 - 45 +
46 - */ 46 + */
47 - protected static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class); 47 + protected static final Logger log = LoggerFactory.getLogger(NexthopIPv4addressTlv.class);
48 - 48 +
49 - public static final short TYPE = 2; //to be defined 49 + public static final short TYPE = 2; //to be defined
50 - //Length is header + value 50 + //Length is header + value
51 - public static final short LENGTH = 8; 51 + public static final short LENGTH = 8;
52 - public static final short VALUE_LENGTH = 4; 52 + public static final short VALUE_LENGTH = 4;
53 - 53 +
54 - private final int rawValue; 54 + private final int rawValue;
55 - 55 +
56 - /** 56 + /**
57 - * Constructor to initialize next hop IPv4 address. 57 + * Constructor to initialize next hop IPv4 address.
58 - * 58 + *
59 - * @param rawValue next hop IPv4 address 59 + * @param rawValue next hop IPv4 address
60 - */ 60 + */
61 - public NexthopIPv4addressTlv(int rawValue) { 61 + public NexthopIPv4addressTlv(int rawValue) {
62 - this.rawValue = rawValue; 62 + this.rawValue = rawValue;
63 - } 63 + }
64 - 64 +
65 - /** 65 + /**
66 - * Return next hop IPv4 address tlv. 66 + * Return next hop IPv4 address tlv.
67 - * 67 + *
68 - * @param raw of next hop IPv4 address 68 + * @param raw of next hop IPv4 address
69 - * @return object of NexthopIPv4addressTlv 69 + * @return object of NexthopIPv4addressTlv
70 - */ 70 + */
71 - public static NexthopIPv4addressTlv of(final int raw) { 71 + public static NexthopIPv4addressTlv of(final int raw) {
72 - return new NexthopIPv4addressTlv(raw); 72 + return new NexthopIPv4addressTlv(raw);
73 - } 73 + }
74 - 74 +
75 - /** 75 + /**
76 - * Returns next hop IPv4 address. 76 + * Returns next hop IPv4 address.
77 - * 77 + *
78 - * @return next hop IPv4 address 78 + * @return next hop IPv4 address
79 - */ 79 + */
80 - public int getInt() { 80 + public int getInt() {
81 - return rawValue; 81 + return rawValue;
82 - } 82 + }
83 - 83 +
84 - @Override 84 + @Override
85 - public PcepVersion getVersion() { 85 + public PcepVersion getVersion() {
86 - return PcepVersion.PCEP_1; 86 + return PcepVersion.PCEP_1;
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public short getType() { 90 + public short getType() {
91 - return TYPE; 91 + return TYPE;
92 - } 92 + }
93 - 93 +
94 - @Override 94 + @Override
95 - public short getLength() { 95 + public short getLength() {
96 - return LENGTH; 96 + return LENGTH;
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public int hashCode() { 100 + public int hashCode() {
101 - return Objects.hash(rawValue); 101 + return Objects.hash(rawValue);
102 - } 102 + }
103 - 103 +
104 - @Override 104 + @Override
105 - public boolean equals(Object obj) { 105 + public boolean equals(Object obj) {
106 - if (this == obj) { 106 + if (this == obj) {
107 - return true; 107 + return true;
108 - } 108 + }
109 - if (obj instanceof NexthopIPv4addressTlv) { 109 + if (obj instanceof NexthopIPv4addressTlv) {
110 - NexthopIPv4addressTlv other = (NexthopIPv4addressTlv) obj; 110 + NexthopIPv4addressTlv other = (NexthopIPv4addressTlv) obj;
111 - return Objects.equals(this.rawValue, other.rawValue); 111 + return Objects.equals(this.rawValue, other.rawValue);
112 - } 112 + }
113 - return false; 113 + return false;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public int write(ChannelBuffer c) { 117 + public int write(ChannelBuffer c) {
118 - int iStartIndex = c.writerIndex(); 118 + int iStartIndex = c.writerIndex();
119 - c.writeShort(TYPE); 119 + c.writeShort(TYPE);
120 - c.writeShort(LENGTH); 120 + c.writeShort(LENGTH);
121 - c.writeInt(rawValue); 121 + c.writeInt(rawValue);
122 - return c.writerIndex() - iStartIndex; 122 + return c.writerIndex() - iStartIndex;
123 - } 123 + }
124 - 124 +
125 - /** 125 + /**
126 - * Reads the channel buffer and returns object of NexthopIPv4addressTlv. 126 + * Reads the channel buffer and returns object of NexthopIPv4addressTlv.
127 - * 127 + *
128 - * @param c type of channel buffer 128 + * @param c type of channel buffer
129 - * @return object of NexthopIPv4addressTlv 129 + * @return object of NexthopIPv4addressTlv
130 - */ 130 + */
131 - public static NexthopIPv4addressTlv read(ChannelBuffer c) { 131 + public static NexthopIPv4addressTlv read(ChannelBuffer c) {
132 - return NexthopIPv4addressTlv.of(c.readInt()); 132 + return NexthopIPv4addressTlv.of(c.readInt());
133 - } 133 + }
134 - 134 +
135 - @Override 135 + @Override
136 - public String toString() { 136 + public String toString() {
137 - return MoreObjects.toStringHelper(getClass()) 137 + return MoreObjects.toStringHelper(getClass())
138 - .add("Type", TYPE) 138 + .add("Type", TYPE)
139 - .add("Length", LENGTH) 139 + .add("Length", LENGTH)
140 - .add("Ipv4Address ", rawValue) 140 + .add("Ipv4Address ", rawValue)
141 - .toString(); 141 + .toString();
142 - } 142 + }
143 -} 143 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 -import com.google.common.base.MoreObjects.ToStringHelper; 27 +import com.google.common.base.MoreObjects.ToStringHelper;
28 - 28 +
29 -/** 29 +/**
30 - * NexthopIPv6addressTlv provides Ipv6 address of next hop. 30 + * NexthopIPv6addressTlv provides Ipv6 address of next hop.
31 - */ 31 + */
32 -public class NexthopIPv6addressTlv implements PcepValueType { 32 +public class NexthopIPv6addressTlv implements PcepValueType {
33 - 33 +
34 - /* 34 + /*
35 - Reference: draft-zhao-pce-pcep-extension-for-pce-controller-01. 35 + Reference: draft-zhao-pce-pcep-extension-for-pce-controller-01.
36 - 36 +
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Type=TBD | Length = 20 | 40 + | Type=TBD | Length = 20 |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | | 42 + | |
43 - // nexthop IPv6 address (16 bytes) // 43 + // nexthop IPv6 address (16 bytes) //
44 - | | 44 + | |
45 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 - 46 +
47 - NEXTHOP-IPV6-ADDRESS TLV: 47 + NEXTHOP-IPV6-ADDRESS TLV:
48 - 48 +
49 - */ 49 + */
50 - protected static final Logger log = LoggerFactory.getLogger(NexthopIPv6addressTlv.class); 50 + protected static final Logger log = LoggerFactory.getLogger(NexthopIPv6addressTlv.class);
51 - 51 +
52 - public static final short TYPE = 100; //to be defined 52 + public static final short TYPE = 100; //to be defined
53 - //Length is header + value 53 + //Length is header + value
54 - public static final short LENGTH = 20; 54 + public static final short LENGTH = 20;
55 - public static final short VALUE_LENGTH = 16; 55 + public static final short VALUE_LENGTH = 16;
56 - 56 +
57 - 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 }; 57 + 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 };
58 - public static final NexthopIPv6addressTlv NONE = new NexthopIPv6addressTlv(NONE_VAL); 58 + public static final NexthopIPv6addressTlv NONE = new NexthopIPv6addressTlv(NONE_VAL);
59 - 59 +
60 - private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 60 + private static final byte[] NO_MASK_VAL = {(byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
61 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, 61 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF,
62 - (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF }; 62 + (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF, (byte) 0xFF };
63 - public static final NexthopIPv6addressTlv NO_MASK = new NexthopIPv6addressTlv(NO_MASK_VAL); 63 + public static final NexthopIPv6addressTlv NO_MASK = new NexthopIPv6addressTlv(NO_MASK_VAL);
64 - public static final NexthopIPv6addressTlv FULL_MASK = NONE; 64 + public static final NexthopIPv6addressTlv FULL_MASK = NONE;
65 - 65 +
66 - private final byte[] rawValue; 66 + private final byte[] rawValue;
67 - 67 +
68 - /** 68 + /**
69 - * Constructor to initialize IP address for next hop IPv6 address tlv. 69 + * Constructor to initialize IP address for next hop IPv6 address tlv.
70 - * 70 + *
71 - * @param rawValue value of Next hop ipAddress 71 + * @param rawValue value of Next hop ipAddress
72 - */ 72 + */
73 - public NexthopIPv6addressTlv(byte[] rawValue) { 73 + public NexthopIPv6addressTlv(byte[] rawValue) {
74 - log.debug("NexthopIPv6addressTlv"); 74 + log.debug("NexthopIPv6addressTlv");
75 - this.rawValue = rawValue; 75 + this.rawValue = rawValue;
76 - } 76 + }
77 - 77 +
78 - /** 78 + /**
79 - * Creates next hop IPv6 address tlv. 79 + * Creates next hop IPv6 address tlv.
80 - * 80 + *
81 - * @param raw value of Next hop ipAddress 81 + * @param raw value of Next hop ipAddress
82 - * @return object of NexthopIPv6addressTlv 82 + * @return object of NexthopIPv6addressTlv
83 - */ 83 + */
84 - //logic to be checked 84 + //logic to be checked
85 - public static NexthopIPv6addressTlv of(final byte[] raw) { 85 + public static NexthopIPv6addressTlv of(final byte[] raw) {
86 - //check NONE_VAL 86 + //check NONE_VAL
87 - boolean bFoundNONE = true; 87 + boolean bFoundNONE = true;
88 - //value starts from 3rd byte. 88 + //value starts from 3rd byte.
89 - for (int i = 5; i < 20; ++i) { 89 + for (int i = 5; i < 20; ++i) {
90 - if (NONE_VAL[i] != raw[i]) { 90 + if (NONE_VAL[i] != raw[i]) {
91 - bFoundNONE = false; 91 + bFoundNONE = false;
92 - } 92 + }
93 - } 93 + }
94 - 94 +
95 - if (bFoundNONE) { 95 + if (bFoundNONE) {
96 - return NONE; 96 + return NONE;
97 - } 97 + }
98 - 98 +
99 - //check NO_MASK_VAL 99 + //check NO_MASK_VAL
100 - boolean bFoundNoMask = true; 100 + boolean bFoundNoMask = true;
101 - //value starts from 3rd byte. 101 + //value starts from 3rd byte.
102 - for (int i = 5; i < 20; ++i) { 102 + for (int i = 5; i < 20; ++i) {
103 - if (0xFF != raw[i]) { 103 + if (0xFF != raw[i]) {
104 - bFoundNoMask = false; 104 + bFoundNoMask = false;
105 - } 105 + }
106 - } 106 + }
107 - if (bFoundNoMask) { 107 + if (bFoundNoMask) {
108 - return NO_MASK; 108 + return NO_MASK;
109 - } 109 + }
110 - return new NexthopIPv6addressTlv(raw); 110 + return new NexthopIPv6addressTlv(raw);
111 - } 111 + }
112 - 112 +
113 - /** 113 + /**
114 - * Returns next hop IPv6 address. 114 + * Returns next hop IPv6 address.
115 - * 115 + *
116 - * @return next hop IPv6 address 116 + * @return next hop IPv6 address
117 - */ 117 + */
118 - public byte[] getBytes() { 118 + public byte[] getBytes() {
119 - return rawValue; 119 + return rawValue;
120 - } 120 + }
121 - 121 +
122 - @Override 122 + @Override
123 - public PcepVersion getVersion() { 123 + public PcepVersion getVersion() {
124 - return PcepVersion.PCEP_1; 124 + return PcepVersion.PCEP_1;
125 - } 125 + }
126 - 126 +
127 - @Override 127 + @Override
128 - public short getType() { 128 + public short getType() {
129 - return TYPE; 129 + return TYPE;
130 - } 130 + }
131 - 131 +
132 - @Override 132 + @Override
133 - public short getLength() { 133 + public short getLength() {
134 - return LENGTH; 134 + return LENGTH;
135 - } 135 + }
136 - 136 +
137 - @Override 137 + @Override
138 - public int hashCode() { 138 + public int hashCode() {
139 - return Objects.hash(rawValue); 139 + return Objects.hash(rawValue);
140 - } 140 + }
141 - 141 +
142 - @Override 142 + @Override
143 - public boolean equals(Object obj) { 143 + public boolean equals(Object obj) {
144 - if (this == obj) { 144 + if (this == obj) {
145 - return true; 145 + return true;
146 - } 146 + }
147 - if (obj instanceof NexthopIPv6addressTlv) { 147 + if (obj instanceof NexthopIPv6addressTlv) {
148 - NexthopIPv6addressTlv other = (NexthopIPv6addressTlv) obj; 148 + NexthopIPv6addressTlv other = (NexthopIPv6addressTlv) obj;
149 - return Objects.equals(this.rawValue, other.rawValue); 149 + return Objects.equals(this.rawValue, other.rawValue);
150 - } 150 + }
151 - return false; 151 + return false;
152 - } 152 + }
153 - 153 +
154 - @Override 154 + @Override
155 - public int write(ChannelBuffer c) { 155 + public int write(ChannelBuffer c) {
156 - int iStartIndex = c.writerIndex(); 156 + int iStartIndex = c.writerIndex();
157 - c.writeShort(TYPE); 157 + c.writeShort(TYPE);
158 - c.writeShort(LENGTH); 158 + c.writeShort(LENGTH);
159 - c.writeBytes(rawValue); 159 + c.writeBytes(rawValue);
160 - return c.writerIndex() - iStartIndex; 160 + return c.writerIndex() - iStartIndex;
161 - } 161 + }
162 - 162 +
163 - /** 163 + /**
164 - * Reads the channel buffer and returns object of NexthopIPv6addressTlv. 164 + * Reads the channel buffer and returns object of NexthopIPv6addressTlv.
165 - * 165 + *
166 - * @param c type of channel buffer 166 + * @param c type of channel buffer
167 - * @return object of NexthopIPv6addressTlv 167 + * @return object of NexthopIPv6addressTlv
168 - */ 168 + */
169 - public static NexthopIPv6addressTlv read(ChannelBuffer c) { 169 + public static NexthopIPv6addressTlv read(ChannelBuffer c) {
170 - byte[] yTemp = new byte[20]; 170 + byte[] yTemp = new byte[20];
171 - c.readBytes(yTemp, 0, 20); 171 + c.readBytes(yTemp, 0, 20);
172 - return NexthopIPv6addressTlv.of(yTemp); 172 + return NexthopIPv6addressTlv.of(yTemp);
173 - } 173 + }
174 - 174 +
175 - @Override 175 + @Override
176 - public String toString() { 176 + public String toString() {
177 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 177 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
178 - 178 +
179 - toStrHelper.add("Type", TYPE); 179 + toStrHelper.add("Type", TYPE);
180 - toStrHelper.add("Length", LENGTH); 180 + toStrHelper.add("Length", LENGTH);
181 - 181 +
182 - StringBuffer result = new StringBuffer(); 182 + StringBuffer result = new StringBuffer();
183 - for (byte b : rawValue) { 183 + for (byte b : rawValue) {
184 - result.append(String.format("%02X ", b)); 184 + result.append(String.format("%02X ", b));
185 - } 185 + }
186 - toStrHelper.add("IpAddress", result); 186 + toStrHelper.add("IpAddress", result);
187 - 187 +
188 - return toStrHelper.toString(); 188 + return toStrHelper.toString();
189 - } 189 + }
190 -} 190 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * NexthopUnnumberedIPv4IDTlv provides the next node's ID and Interface ID. 29 + * NexthopUnnumberedIPv4IDTlv provides the next node's ID and Interface ID.
30 - */ 30 + */
31 -public class NexthopUnnumberedIPv4IDTlv implements PcepValueType { 31 +public class NexthopUnnumberedIPv4IDTlv implements PcepValueType {
32 - 32 +
33 - /* 33 + /*
34 - Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01. 34 + Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01.
35 - 35 +
36 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | Type=TBD | Length = 12 | 39 + | Type=TBD | Length = 12 |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Node-ID | 41 + | Node-ID |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | Interface ID | 43 + | Interface ID |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - 45 +
46 - NEXTHOP-UNNUMBERED-IPV4-ID TLV 46 + NEXTHOP-UNNUMBERED-IPV4-ID TLV
47 - 47 +
48 - */ 48 + */
49 - protected static final Logger log = LoggerFactory.getLogger(NexthopUnnumberedIPv4IDTlv.class); 49 + protected static final Logger log = LoggerFactory.getLogger(NexthopUnnumberedIPv4IDTlv.class);
50 - 50 +
51 - public static final short TYPE = 1; //to be defined 51 + public static final short TYPE = 1; //to be defined
52 - //Length is header + value 52 + //Length is header + value
53 - public static final short LENGTH = 12; 53 + public static final short LENGTH = 12;
54 - 54 +
55 - private final int nodeID; 55 + private final int nodeID;
56 - private final int interfaceID; 56 + private final int interfaceID;
57 - 57 +
58 - /** 58 + /**
59 - * constructor to initialize nodeID and interfaceID. 59 + * constructor to initialize nodeID and interfaceID.
60 - * 60 + *
61 - * @param nodeID node ID 61 + * @param nodeID node ID
62 - * @param interfaceID interface ID 62 + * @param interfaceID interface ID
63 - */ 63 + */
64 - public NexthopUnnumberedIPv4IDTlv(int nodeID, int interfaceID) { 64 + public NexthopUnnumberedIPv4IDTlv(int nodeID, int interfaceID) {
65 - this.nodeID = nodeID; 65 + this.nodeID = nodeID;
66 - this.interfaceID = interfaceID; 66 + this.interfaceID = interfaceID;
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns new object of NexthopUnnumberedIPv4IDTlv. 70 + * Returns new object of NexthopUnnumberedIPv4IDTlv.
71 - * 71 + *
72 - * @param nodeID node ID 72 + * @param nodeID node ID
73 - * @param interfaceID interface ID 73 + * @param interfaceID interface ID
74 - * @return NexthopUnnumberedIPv4IDTlv 74 + * @return NexthopUnnumberedIPv4IDTlv
75 - */ 75 + */
76 - public static NexthopUnnumberedIPv4IDTlv of(int nodeID, int interfaceID) { 76 + public static NexthopUnnumberedIPv4IDTlv of(int nodeID, int interfaceID) {
77 - return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID); 77 + return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
78 - } 78 + }
79 - 79 +
80 - /** 80 + /**
81 - * Returns Node Id. 81 + * Returns Node Id.
82 - * 82 + *
83 - * @return node ID 83 + * @return node ID
84 - */ 84 + */
85 - public int getNodeID() { 85 + public int getNodeID() {
86 - return nodeID; 86 + return nodeID;
87 - } 87 + }
88 - 88 +
89 - /** 89 + /**
90 - * Returns Interface Id. 90 + * Returns Interface Id.
91 - * 91 + *
92 - * @return interface ID 92 + * @return interface ID
93 - */ 93 + */
94 - public int getInterfaceID() { 94 + public int getInterfaceID() {
95 - return interfaceID; 95 + return interfaceID;
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public PcepVersion getVersion() { 99 + public PcepVersion getVersion() {
100 - return PcepVersion.PCEP_1; 100 + return PcepVersion.PCEP_1;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public short getType() { 104 + public short getType() {
105 - return TYPE; 105 + return TYPE;
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public short getLength() { 109 + public short getLength() {
110 - return LENGTH; 110 + return LENGTH;
111 - } 111 + }
112 - 112 +
113 - @Override 113 + @Override
114 - public int hashCode() { 114 + public int hashCode() {
115 - return Objects.hash(nodeID, interfaceID); 115 + return Objects.hash(nodeID, interfaceID);
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public boolean equals(Object obj) { 119 + public boolean equals(Object obj) {
120 - if (this == obj) { 120 + if (this == obj) {
121 - return true; 121 + return true;
122 - } 122 + }
123 - if (obj instanceof NexthopUnnumberedIPv4IDTlv) { 123 + if (obj instanceof NexthopUnnumberedIPv4IDTlv) {
124 - NexthopUnnumberedIPv4IDTlv other = (NexthopUnnumberedIPv4IDTlv) obj; 124 + NexthopUnnumberedIPv4IDTlv other = (NexthopUnnumberedIPv4IDTlv) obj;
125 - return Objects.equals(this.nodeID, other.nodeID) && Objects.equals(this.interfaceID, other.interfaceID); 125 + return Objects.equals(this.nodeID, other.nodeID) && Objects.equals(this.interfaceID, other.interfaceID);
126 - } 126 + }
127 - return false; 127 + return false;
128 - } 128 + }
129 - 129 +
130 - @Override 130 + @Override
131 - public int write(ChannelBuffer c) { 131 + public int write(ChannelBuffer c) {
132 - int iLenStartIndex = c.writerIndex(); 132 + int iLenStartIndex = c.writerIndex();
133 - c.writeShort(TYPE); 133 + c.writeShort(TYPE);
134 - c.writeShort(LENGTH); 134 + c.writeShort(LENGTH);
135 - 135 +
136 - c.writeInt(nodeID); 136 + c.writeInt(nodeID);
137 - c.writeInt(interfaceID); 137 + c.writeInt(interfaceID);
138 - 138 +
139 - return c.writerIndex() - iLenStartIndex; 139 + return c.writerIndex() - iLenStartIndex;
140 - } 140 + }
141 - 141 +
142 - /** 142 + /**
143 - * Reads the channel buffer and returns object of NexthopUnnumberedIPv4IDTlv. 143 + * Reads the channel buffer and returns object of NexthopUnnumberedIPv4IDTlv.
144 - * 144 + *
145 - * @param cb type of channel buffer 145 + * @param cb type of channel buffer
146 - * @return object of NexthopUnnumberedIPv4IDTlv 146 + * @return object of NexthopUnnumberedIPv4IDTlv
147 - */ 147 + */
148 - public static NexthopUnnumberedIPv4IDTlv read(ChannelBuffer cb) { 148 + public static NexthopUnnumberedIPv4IDTlv read(ChannelBuffer cb) {
149 - int nodeID = cb.readInt(); 149 + int nodeID = cb.readInt();
150 - int interfaceID = cb.readInt(); 150 + int interfaceID = cb.readInt();
151 - return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID); 151 + return new NexthopUnnumberedIPv4IDTlv(nodeID, interfaceID);
152 - } 152 + }
153 - 153 +
154 - @Override 154 + @Override
155 - public String toString() { 155 + public String toString() {
156 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("NodeId", nodeID) 156 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("NodeId", nodeID)
157 - .add("InterfaceId", interfaceID).toString(); 157 + .add("InterfaceId", interfaceID).toString();
158 - } 158 + }
159 -} 159 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 -import org.jboss.netty.buffer.ChannelBuffer; 19 +import org.jboss.netty.buffer.ChannelBuffer;
20 -import org.onosproject.pcepio.protocol.PcepVersion; 20 +import org.onosproject.pcepio.protocol.PcepVersion;
21 -import org.slf4j.Logger; 21 +import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory; 22 +import org.slf4j.LoggerFactory;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 - 25 +
26 -/** 26 +/**
27 - * Provide node Flags bits. 27 + * Provide node Flags bits.
28 - */ 28 + */
29 -public class NodeFlagBitsTlv implements PcepValueType { 29 +public class NodeFlagBitsTlv implements PcepValueType {
30 - 30 +
31 - /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.1.1 31 + /* Reference :[I-D.ietf-idr- ls-distribution] /3.3.1.1
32 - * 0 1 2 3 32 + * 0 1 2 3
33 - 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 + 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
34 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 - | Type=[TBD21] | Length=1 | 35 + | Type=[TBD21] | Length=1 |
36 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - |O|T|E|B| Reserved| 37 + |O|T|E|B| Reserved|
38 - +-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+
39 - */ 39 + */
40 - 40 +
41 - protected static final Logger log = LoggerFactory.getLogger(NodeFlagBitsTlv.class); 41 + protected static final Logger log = LoggerFactory.getLogger(NodeFlagBitsTlv.class);
42 - 42 +
43 - public static final short TYPE = 14; 43 + public static final short TYPE = 14;
44 - public static final short LENGTH = 1; 44 + public static final short LENGTH = 1;
45 - public static final int SET = 1; 45 + public static final int SET = 1;
46 - public static final byte OFLAG_SET = (byte) 0x80; 46 + public static final byte OFLAG_SET = (byte) 0x80;
47 - public static final byte TFLAG_SET = 0x40; 47 + public static final byte TFLAG_SET = 0x40;
48 - public static final byte EFLAG_SET = 0x20; 48 + public static final byte EFLAG_SET = 0x20;
49 - public static final byte BFLAG_SET = 0x10; 49 + public static final byte BFLAG_SET = 0x10;
50 - 50 +
51 - private final byte rawValue; 51 + private final byte rawValue;
52 - private final boolean bOFlag; 52 + private final boolean bOFlag;
53 - private final boolean bTFlag; 53 + private final boolean bTFlag;
54 - private final boolean bEFlag; 54 + private final boolean bEFlag;
55 - private final boolean bBFlag; 55 + private final boolean bBFlag;
56 - private final boolean isRawValueSet; 56 + private final boolean isRawValueSet;
57 - 57 +
58 - /** 58 + /**
59 - * constructor to initialize rawValue. 59 + * constructor to initialize rawValue.
60 - * 60 + *
61 - * @param rawValue of Node Flag Bits TLV 61 + * @param rawValue of Node Flag Bits TLV
62 - */ 62 + */
63 - public NodeFlagBitsTlv(byte rawValue) { 63 + public NodeFlagBitsTlv(byte rawValue) {
64 - this.rawValue = rawValue; 64 + this.rawValue = rawValue;
65 - isRawValueSet = true; 65 + isRawValueSet = true;
66 - byte temp = rawValue; 66 + byte temp = rawValue;
67 - this.bOFlag = (temp & OFLAG_SET) == OFLAG_SET ? true : false; 67 + this.bOFlag = (temp & OFLAG_SET) == OFLAG_SET ? true : false;
68 - this.bTFlag = (temp & TFLAG_SET) == TFLAG_SET ? true : false; 68 + this.bTFlag = (temp & TFLAG_SET) == TFLAG_SET ? true : false;
69 - this.bEFlag = (temp & EFLAG_SET) == EFLAG_SET ? true : false; 69 + this.bEFlag = (temp & EFLAG_SET) == EFLAG_SET ? true : false;
70 - this.bBFlag = (temp & BFLAG_SET) == BFLAG_SET ? true : false; 70 + this.bBFlag = (temp & BFLAG_SET) == BFLAG_SET ? true : false;
71 - } 71 + }
72 - 72 +
73 - /** 73 + /**
74 - * constructor to initialize different Flags. 74 + * constructor to initialize different Flags.
75 - * 75 + *
76 - * @param bOFlag O-flag 76 + * @param bOFlag O-flag
77 - * @param bTFlag T-flag 77 + * @param bTFlag T-flag
78 - * @param bEFlag E-flag 78 + * @param bEFlag E-flag
79 - * @param bBFlag B-flag 79 + * @param bBFlag B-flag
80 - */ 80 + */
81 - public NodeFlagBitsTlv(boolean bOFlag, boolean bTFlag, boolean bEFlag, boolean bBFlag) { 81 + public NodeFlagBitsTlv(boolean bOFlag, boolean bTFlag, boolean bEFlag, boolean bBFlag) {
82 - this.bOFlag = bOFlag; 82 + this.bOFlag = bOFlag;
83 - this.bTFlag = bTFlag; 83 + this.bTFlag = bTFlag;
84 - this.bEFlag = bEFlag; 84 + this.bEFlag = bEFlag;
85 - this.bBFlag = bBFlag; 85 + this.bBFlag = bBFlag;
86 - this.rawValue = 0; 86 + this.rawValue = 0;
87 - this.isRawValueSet = false; 87 + this.isRawValueSet = false;
88 - } 88 + }
89 - 89 +
90 - /** 90 + /**
91 - * Returns newly created NodeFlagBitsTlv object. 91 + * Returns newly created NodeFlagBitsTlv object.
92 - * 92 + *
93 - * @param raw of Node Flag Bits TLV 93 + * @param raw of Node Flag Bits TLV
94 - * @return new object of NodeFlagBitsTlv 94 + * @return new object of NodeFlagBitsTlv
95 - */ 95 + */
96 - public static NodeFlagBitsTlv of(final byte raw) { 96 + public static NodeFlagBitsTlv of(final byte raw) {
97 - return new NodeFlagBitsTlv(raw); 97 + return new NodeFlagBitsTlv(raw);
98 - } 98 + }
99 - 99 +
100 - /** 100 + /**
101 - * Returns raw value of NodeFlagBitsTlv. 101 + * Returns raw value of NodeFlagBitsTlv.
102 - * 102 + *
103 - * @return rawValue raw value 103 + * @return rawValue raw value
104 - */ 104 + */
105 - public byte getbyte() { 105 + public byte getbyte() {
106 - return rawValue; 106 + return rawValue;
107 - } 107 + }
108 - 108 +
109 - /** 109 + /**
110 - * Returns O-flag. 110 + * Returns O-flag.
111 - * 111 + *
112 - * @return bOFlag O-flag 112 + * @return bOFlag O-flag
113 - */ 113 + */
114 - public boolean getOFlag() { 114 + public boolean getOFlag() {
115 - return bOFlag; 115 + return bOFlag;
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * Returns T-flag. 119 + * Returns T-flag.
120 - * 120 + *
121 - * @return bTFlag T-flag 121 + * @return bTFlag T-flag
122 - */ 122 + */
123 - public boolean getTFlag() { 123 + public boolean getTFlag() {
124 - return bTFlag; 124 + return bTFlag;
125 - } 125 + }
126 - 126 +
127 - /** 127 + /**
128 - * Returns E-flag. 128 + * Returns E-flag.
129 - * 129 + *
130 - * @return bEFlag E-flag 130 + * @return bEFlag E-flag
131 - */ 131 + */
132 - public boolean getEFlag() { 132 + public boolean getEFlag() {
133 - return bEFlag; 133 + return bEFlag;
134 - } 134 + }
135 - 135 +
136 - /** 136 + /**
137 - * Returns B-flag. 137 + * Returns B-flag.
138 - * 138 + *
139 - * @return bBFlag B-flag 139 + * @return bBFlag B-flag
140 - */ 140 + */
141 - public boolean getBFlag() { 141 + public boolean getBFlag() {
142 - return bBFlag; 142 + return bBFlag;
143 - } 143 + }
144 - 144 +
145 - @Override 145 + @Override
146 - public PcepVersion getVersion() { 146 + public PcepVersion getVersion() {
147 - return PcepVersion.PCEP_1; 147 + return PcepVersion.PCEP_1;
148 - } 148 + }
149 - 149 +
150 - @Override 150 + @Override
151 - public short getType() { 151 + public short getType() {
152 - return TYPE; 152 + return TYPE;
153 - } 153 + }
154 - 154 +
155 - @Override 155 + @Override
156 - public short getLength() { 156 + public short getLength() {
157 - return LENGTH; 157 + return LENGTH;
158 - } 158 + }
159 - 159 +
160 - @Override 160 + @Override
161 - public int hashCode() { 161 + public int hashCode() {
162 - if (isRawValueSet) { 162 + if (isRawValueSet) {
163 - return Objects.hash(rawValue); 163 + return Objects.hash(rawValue);
164 - } else { 164 + } else {
165 - return Objects.hash(bOFlag, bTFlag, bEFlag, bBFlag); 165 + return Objects.hash(bOFlag, bTFlag, bEFlag, bBFlag);
166 - } 166 + }
167 - } 167 + }
168 - 168 +
169 - @Override 169 + @Override
170 - public boolean equals(Object obj) { 170 + public boolean equals(Object obj) {
171 - if (this == obj) { 171 + if (this == obj) {
172 - return true; 172 + return true;
173 - } 173 + }
174 - if (obj instanceof NodeFlagBitsTlv) { 174 + if (obj instanceof NodeFlagBitsTlv) {
175 - NodeFlagBitsTlv other = (NodeFlagBitsTlv) obj; 175 + NodeFlagBitsTlv other = (NodeFlagBitsTlv) obj;
176 - if (isRawValueSet) { 176 + if (isRawValueSet) {
177 - return Objects.equals(this.rawValue, other.rawValue); 177 + return Objects.equals(this.rawValue, other.rawValue);
178 - } else { 178 + } else {
179 - return Objects.equals(this.bOFlag, other.bOFlag) && Objects.equals(this.bTFlag, other.bTFlag) 179 + return Objects.equals(this.bOFlag, other.bOFlag) && Objects.equals(this.bTFlag, other.bTFlag)
180 - && Objects.equals(this.bEFlag, other.bEFlag) && Objects.equals(this.bBFlag, other.bBFlag); 180 + && Objects.equals(this.bEFlag, other.bEFlag) && Objects.equals(this.bBFlag, other.bBFlag);
181 - } 181 + }
182 - } 182 + }
183 - return false; 183 + return false;
184 - } 184 + }
185 - 185 +
186 - @Override 186 + @Override
187 - public int write(ChannelBuffer c) { 187 + public int write(ChannelBuffer c) {
188 - int iLenStartIndex = c.writerIndex(); 188 + int iLenStartIndex = c.writerIndex();
189 - c.writeShort(TYPE); 189 + c.writeShort(TYPE);
190 - c.writeShort(LENGTH); 190 + c.writeShort(LENGTH);
191 - if (isRawValueSet) { 191 + if (isRawValueSet) {
192 - c.writeByte(rawValue); 192 + c.writeByte(rawValue);
193 - } else { 193 + } else {
194 - byte temp = 0; 194 + byte temp = 0;
195 - if (bOFlag) { 195 + if (bOFlag) {
196 - temp = (byte) (temp | OFLAG_SET); 196 + temp = (byte) (temp | OFLAG_SET);
197 - } 197 + }
198 - if (bTFlag) { 198 + if (bTFlag) {
199 - temp = (byte) (temp | TFLAG_SET); 199 + temp = (byte) (temp | TFLAG_SET);
200 - } 200 + }
201 - if (bEFlag) { 201 + if (bEFlag) {
202 - temp = (byte) (temp | EFLAG_SET); 202 + temp = (byte) (temp | EFLAG_SET);
203 - } 203 + }
204 - if (bBFlag) { 204 + if (bBFlag) {
205 - temp = (byte) (temp | BFLAG_SET); 205 + temp = (byte) (temp | BFLAG_SET);
206 - } 206 + }
207 - c.writeByte(temp); 207 + c.writeByte(temp);
208 - } 208 + }
209 - return c.writerIndex() - iLenStartIndex; 209 + return c.writerIndex() - iLenStartIndex;
210 - } 210 + }
211 - 211 +
212 - /** 212 + /**
213 - * Reads the channel buffer and returns object of NodeFlagBitsTlv. 213 + * Reads the channel buffer and returns object of NodeFlagBitsTlv.
214 - * 214 + *
215 - * @param c input channel buffer 215 + * @param c input channel buffer
216 - * @return object of NodeFlagBitsTlv 216 + * @return object of NodeFlagBitsTlv
217 - */ 217 + */
218 - public static PcepValueType read(ChannelBuffer c) { 218 + public static PcepValueType read(ChannelBuffer c) {
219 - 219 +
220 - return NodeFlagBitsTlv.of(c.readByte()); 220 + return NodeFlagBitsTlv.of(c.readByte());
221 - } 221 + }
222 - 222 +
223 - @Override 223 + @Override
224 - public String toString() { 224 + public String toString() {
225 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH) 225 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH)
226 - .add("OFlag", (bOFlag) ? 1 : 0).add("TFlag", (bTFlag) ? 1 : 0).add("EFlag", (bEFlag) ? 1 : 0) 226 + .add("OFlag", (bOFlag) ? 1 : 0).add("TFlag", (bTFlag) ? 1 : 0).add("EFlag", (bEFlag) ? 1 : 0)
227 - .add("BFlag", (bBFlag) ? 1 : 0).toString(); 227 + .add("BFlag", (bBFlag) ? 1 : 0).toString();
228 - } 228 + }
229 -} 229 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 -import org.jboss.netty.buffer.ChannelBuffer; 19 +import org.jboss.netty.buffer.ChannelBuffer;
20 -import org.onosproject.pcepio.protocol.PcepVersion; 20 +import org.onosproject.pcepio.protocol.PcepVersion;
21 -import org.slf4j.Logger; 21 +import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory; 22 +import org.slf4j.LoggerFactory;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 -import com.google.common.base.MoreObjects.ToStringHelper; 25 +import com.google.common.base.MoreObjects.ToStringHelper;
26 - 26 +
27 -/** 27 +/**
28 - * Provide the name for the node. 28 + * Provide the name for the node.
29 - */ 29 + */
30 -public class NodeNameTlv implements PcepValueType { 30 +public class NodeNameTlv implements PcepValueType {
31 - 31 +
32 - /* reference :[I-D.ietf-idr-ls-distribution]/3.3.1.3 32 + /* reference :[I-D.ietf-idr-ls-distribution]/3.3.1.3
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TBD23] | Length | 36 + | Type=[TBD23] | Length |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - // Node Name (variable) // 38 + // Node Name (variable) //
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(NodeNameTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(NodeNameTlv.class);
43 - 43 +
44 - public static final short TYPE = 1007; //TODO:check and change TBD23 44 + public static final short TYPE = 1007; //TODO:check and change TBD23
45 - public final short hLength; 45 + public final short hLength;
46 - 46 +
47 - private final byte[] rawValue; 47 + private final byte[] rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * constructor to initialize rawValue. 50 + * constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue of Node Name 52 + * @param rawValue of Node Name
53 - * @param hLength length 53 + * @param hLength length
54 - */ 54 + */
55 - public NodeNameTlv(byte[] rawValue, short hLength) { 55 + public NodeNameTlv(byte[] rawValue, short hLength) {
56 - log.debug("NodeNameTlv"); 56 + log.debug("NodeNameTlv");
57 - this.rawValue = rawValue; 57 + this.rawValue = rawValue;
58 - if (0 == hLength) { 58 + if (0 == hLength) {
59 - this.hLength = (short) rawValue.length; 59 + this.hLength = (short) rawValue.length;
60 - } else { 60 + } else {
61 - this.hLength = hLength; 61 + this.hLength = hLength;
62 - } 62 + }
63 - } 63 + }
64 - 64 +
65 - /** 65 + /**
66 - * Returns newly created NodeNameTlv object. 66 + * Returns newly created NodeNameTlv object.
67 - * 67 + *
68 - * @param raw of NodeName 68 + * @param raw of NodeName
69 - * @param hLength length 69 + * @param hLength length
70 - * @return new object of Node Name Tlv 70 + * @return new object of Node Name Tlv
71 - */ 71 + */
72 - public static NodeNameTlv of(final byte[] raw, short hLength) { 72 + public static NodeNameTlv of(final byte[] raw, short hLength) {
73 - return new NodeNameTlv(raw, hLength); 73 + return new NodeNameTlv(raw, hLength);
74 - } 74 + }
75 - 75 +
76 - /** 76 + /**
77 - * Returns RawValue for NodeName. 77 + * Returns RawValue for NodeName.
78 - * 78 + *
79 - * @return rawValue raw value 79 + * @return rawValue raw value
80 - */ 80 + */
81 - public byte[] getValue() { 81 + public byte[] getValue() {
82 - return rawValue; 82 + return rawValue;
83 - } 83 + }
84 - 84 +
85 - @Override 85 + @Override
86 - public PcepVersion getVersion() { 86 + public PcepVersion getVersion() {
87 - return PcepVersion.PCEP_1; 87 + return PcepVersion.PCEP_1;
88 - } 88 + }
89 - 89 +
90 - @Override 90 + @Override
91 - public short getType() { 91 + public short getType() {
92 - return TYPE; 92 + return TYPE;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public short getLength() { 96 + public short getLength() {
97 - return hLength; 97 + return hLength;
98 - } 98 + }
99 - 99 +
100 - @Override 100 + @Override
101 - public int hashCode() { 101 + public int hashCode() {
102 - return Objects.hash(rawValue); 102 + return Objects.hash(rawValue);
103 - } 103 + }
104 - 104 +
105 - @Override 105 + @Override
106 - public boolean equals(Object obj) { 106 + public boolean equals(Object obj) {
107 - if (this == obj) { 107 + if (this == obj) {
108 - return true; 108 + return true;
109 - } 109 + }
110 - if (obj instanceof NodeNameTlv) { 110 + if (obj instanceof NodeNameTlv) {
111 - NodeNameTlv other = (NodeNameTlv) obj; 111 + NodeNameTlv other = (NodeNameTlv) obj;
112 - return Objects.equals(this.rawValue, other.rawValue); 112 + return Objects.equals(this.rawValue, other.rawValue);
113 - } 113 + }
114 - return false; 114 + return false;
115 - } 115 + }
116 - 116 +
117 - @Override 117 + @Override
118 - public int write(ChannelBuffer c) { 118 + public int write(ChannelBuffer c) {
119 - int iLenStartIndex = c.writerIndex(); 119 + int iLenStartIndex = c.writerIndex();
120 - c.writeShort(TYPE); 120 + c.writeShort(TYPE);
121 - c.writeShort(hLength); 121 + c.writeShort(hLength);
122 - c.writeBytes(rawValue); 122 + c.writeBytes(rawValue);
123 - return c.writerIndex() - iLenStartIndex; 123 + return c.writerIndex() - iLenStartIndex;
124 - } 124 + }
125 - 125 +
126 - /** 126 + /**
127 - * Reads the channel buffer and returns object of NodeNameTlv. 127 + * Reads the channel buffer and returns object of NodeNameTlv.
128 - * 128 + *
129 - * @param c input channel buffer 129 + * @param c input channel buffer
130 - * @param hLength length 130 + * @param hLength length
131 - * @return object of Node Name TLV 131 + * @return object of Node Name TLV
132 - */ 132 + */
133 - public static PcepValueType read(ChannelBuffer c, short hLength) { 133 + public static PcepValueType read(ChannelBuffer c, short hLength) {
134 - byte[] iNodeName = new byte[hLength]; 134 + byte[] iNodeName = new byte[hLength];
135 - c.readBytes(iNodeName, 0, hLength); 135 + c.readBytes(iNodeName, 0, hLength);
136 - return new NodeNameTlv(iNodeName, hLength); 136 + return new NodeNameTlv(iNodeName, hLength);
137 - } 137 + }
138 - 138 +
139 - @Override 139 + @Override
140 - public String toString() { 140 + public String toString() {
141 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 141 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
142 - 142 +
143 - toStrHelper.add("Type", TYPE); 143 + toStrHelper.add("Type", TYPE);
144 - toStrHelper.add("Length", hLength); 144 + toStrHelper.add("Length", hLength);
145 - 145 +
146 - StringBuffer result = new StringBuffer(); 146 + StringBuffer result = new StringBuffer();
147 - for (byte b : rawValue) { 147 + for (byte b : rawValue) {
148 - result.append(String.format("%02X ", b)); 148 + result.append(String.format("%02X ", b));
149 - } 149 + }
150 - toStrHelper.add("Value", result); 150 + toStrHelper.add("Value", result);
151 - 151 +
152 - return toStrHelper.toString(); 152 + return toStrHelper.toString();
153 - } 153 + }
154 -} 154 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 -import org.jboss.netty.buffer.ChannelBuffer; 19 +import org.jboss.netty.buffer.ChannelBuffer;
20 -import org.onosproject.pcepio.protocol.PcepVersion; 20 +import org.onosproject.pcepio.protocol.PcepVersion;
21 -import org.slf4j.Logger; 21 +import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory; 22 +import org.slf4j.LoggerFactory;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 - 25 +
26 -/** 26 +/**
27 - * Provides area ID for OSPF area. 27 + * Provides area ID for OSPF area.
28 - */ 28 + */
29 -public class OSPFareaIDsubTlv implements PcepValueType { 29 +public class OSPFareaIDsubTlv implements PcepValueType {
30 - 30 +
31 - /* Reference :draft-ietf-idr-ls-distribution-10. 31 + /* Reference :draft-ietf-idr-ls-distribution-10.
32 - * 0 1 2 3 32 + * 0 1 2 3
33 - 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 + 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
34 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 34 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
35 - | Type=[TBD12] | Length=4 | 35 + | Type=[TBD12] | Length=4 |
36 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | opaque value (32 Bit AS Number) | 37 + | opaque value (32 Bit AS Number) |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - */ 39 + */
40 - 40 +
41 - protected static final Logger log = LoggerFactory.getLogger(OSPFareaIDsubTlv.class); 41 + protected static final Logger log = LoggerFactory.getLogger(OSPFareaIDsubTlv.class);
42 - 42 +
43 - public static final short TYPE = 600; //TODD:change this TBD12 43 + public static final short TYPE = 600; //TODD:change this TBD12
44 - public static final short LENGTH = 4; 44 + public static final short LENGTH = 4;
45 - 45 +
46 - private final int rawValue; 46 + private final int rawValue;
47 - 47 +
48 - /** 48 + /**
49 - * constructor to initialize rawValue. 49 + * constructor to initialize rawValue.
50 - * 50 + *
51 - * @param rawValue area ID for OSPF area. 51 + * @param rawValue area ID for OSPF area.
52 - */ 52 + */
53 - public OSPFareaIDsubTlv(int rawValue) { 53 + public OSPFareaIDsubTlv(int rawValue) {
54 - this.rawValue = rawValue; 54 + this.rawValue = rawValue;
55 - } 55 + }
56 - 56 +
57 - /** 57 + /**
58 - * Returns newly created OSPFareaIDsubTlv object. 58 + * Returns newly created OSPFareaIDsubTlv object.
59 - * 59 + *
60 - * @param raw opaque value of AreaID 60 + * @param raw opaque value of AreaID
61 - * @return new object of OSPF area ID sub TLV 61 + * @return new object of OSPF area ID sub TLV
62 - */ 62 + */
63 - public static OSPFareaIDsubTlv of(final int raw) { 63 + public static OSPFareaIDsubTlv of(final int raw) {
64 - return new OSPFareaIDsubTlv(raw); 64 + return new OSPFareaIDsubTlv(raw);
65 - } 65 + }
66 - 66 +
67 - /** 67 + /**
68 - * Returns RawValue opaque value of AreaID. 68 + * Returns RawValue opaque value of AreaID.
69 - * 69 + *
70 - * @return rawValue Area ID 70 + * @return rawValue Area ID
71 - */ 71 + */
72 - public int getInt() { 72 + public int getInt() {
73 - return rawValue; 73 + return rawValue;
74 - } 74 + }
75 - 75 +
76 - @Override 76 + @Override
77 - public PcepVersion getVersion() { 77 + public PcepVersion getVersion() {
78 - return PcepVersion.PCEP_1; 78 + return PcepVersion.PCEP_1;
79 - } 79 + }
80 - 80 +
81 - @Override 81 + @Override
82 - public short getType() { 82 + public short getType() {
83 - return TYPE; 83 + return TYPE;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public short getLength() { 87 + public short getLength() {
88 - return LENGTH; 88 + return LENGTH;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public int hashCode() { 92 + public int hashCode() {
93 - return Objects.hash(rawValue); 93 + return Objects.hash(rawValue);
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public boolean equals(Object obj) { 97 + public boolean equals(Object obj) {
98 - if (this == obj) { 98 + if (this == obj) {
99 - return true; 99 + return true;
100 - } 100 + }
101 - if (obj instanceof OSPFareaIDsubTlv) { 101 + if (obj instanceof OSPFareaIDsubTlv) {
102 - OSPFareaIDsubTlv other = (OSPFareaIDsubTlv) obj; 102 + OSPFareaIDsubTlv other = (OSPFareaIDsubTlv) obj;
103 - return Objects.equals(this.rawValue, other.rawValue); 103 + return Objects.equals(this.rawValue, other.rawValue);
104 - } 104 + }
105 - return false; 105 + return false;
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public int write(ChannelBuffer c) { 109 + public int write(ChannelBuffer c) {
110 - int iLenStartIndex = c.writerIndex(); 110 + int iLenStartIndex = c.writerIndex();
111 - c.writeShort(TYPE); 111 + c.writeShort(TYPE);
112 - c.writeShort(LENGTH); 112 + c.writeShort(LENGTH);
113 - c.writeInt(rawValue); 113 + c.writeInt(rawValue);
114 - return c.writerIndex() - iLenStartIndex; 114 + return c.writerIndex() - iLenStartIndex;
115 - } 115 + }
116 - 116 +
117 - /** 117 + /**
118 - * Reads the channel buffer and returns object of OSPFAreaIdSubTlv. 118 + * Reads the channel buffer and returns object of OSPFAreaIdSubTlv.
119 - * 119 + *
120 - * @param c input channel buffer 120 + * @param c input channel buffer
121 - * @return object of OSPFAreaIdSubTlv 121 + * @return object of OSPFAreaIdSubTlv
122 - */ 122 + */
123 - public static OSPFareaIDsubTlv read(ChannelBuffer c) { 123 + public static OSPFareaIDsubTlv read(ChannelBuffer c) {
124 - return OSPFareaIDsubTlv.of(c.readInt()); 124 + return OSPFareaIDsubTlv.of(c.readInt());
125 - } 125 + }
126 - 126 +
127 - @Override 127 + @Override
128 - public String toString() { 128 + public String toString() {
129 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 129 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
130 - .toString(); 130 + .toString();
131 - } 131 + }
132 -} 132 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 -import org.jboss.netty.buffer.ChannelBuffer; 19 +import org.jboss.netty.buffer.ChannelBuffer;
20 -import org.onosproject.pcepio.protocol.PcepVersion; 20 +import org.onosproject.pcepio.protocol.PcepVersion;
21 -import org.slf4j.Logger; 21 +import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory; 22 +import org.slf4j.LoggerFactory;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 -import com.google.common.base.MoreObjects.ToStringHelper; 25 +import com.google.common.base.MoreObjects.ToStringHelper;
26 - 26 +
27 -/** 27 +/**
28 - * Provides Opaque Link Attribute. 28 + * Provides Opaque Link Attribute.
29 - */ 29 + */
30 -public class OpaqueLinkAttributeTlv implements PcepValueType { 30 +public class OpaqueLinkAttributeTlv implements PcepValueType {
31 - 31 +
32 - /* 32 + /*
33 - * TLV format. 33 + * TLV format.
34 - * Reference :[I-D.ietf-idr-attributesls-distribution] /3.3.2.6 34 + * Reference :[I-D.ietf-idr-attributesls-distribution] /3.3.2.6
35 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | Type=TBD42 | Length | 38 + | Type=TBD42 | Length |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - // Opaque link attributes (variable) // 40 + // Opaque link attributes (variable) //
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - */ 42 + */
43 - 43 +
44 - protected static final Logger log = LoggerFactory.getLogger(OpaqueLinkAttributeTlv.class); 44 + protected static final Logger log = LoggerFactory.getLogger(OpaqueLinkAttributeTlv.class);
45 - 45 +
46 - public static final short TYPE = 1097; //TODO:NEED TO HANDLE TDB42 46 + public static final short TYPE = 1097; //TODO:NEED TO HANDLE TDB42
47 - private final short hLength; 47 + private final short hLength;
48 - 48 +
49 - private final byte[] rawValue; 49 + private final byte[] rawValue;
50 - 50 +
51 - /** 51 + /**
52 - * constructor to initialize rawValue. 52 + * constructor to initialize rawValue.
53 - * 53 + *
54 - * @param rawValue of Opaque Link Attribute 54 + * @param rawValue of Opaque Link Attribute
55 - * @param hLength length 55 + * @param hLength length
56 - */ 56 + */
57 - public OpaqueLinkAttributeTlv(byte[] rawValue, short hLength) { 57 + public OpaqueLinkAttributeTlv(byte[] rawValue, short hLength) {
58 - log.debug("OpaqueLinkAttributeTlv"); 58 + log.debug("OpaqueLinkAttributeTlv");
59 - this.rawValue = rawValue; 59 + this.rawValue = rawValue;
60 - if (0 == hLength) { 60 + if (0 == hLength) {
61 - this.hLength = (short) rawValue.length; 61 + this.hLength = (short) rawValue.length;
62 - } else { 62 + } else {
63 - this.hLength = hLength; 63 + this.hLength = hLength;
64 - } 64 + }
65 - } 65 + }
66 - 66 +
67 - /** 67 + /**
68 - * Returns newly created OpaqueLinkAttributeTlv object. 68 + * Returns newly created OpaqueLinkAttributeTlv object.
69 - * 69 + *
70 - * @param raw of Opaque Link Attribute 70 + * @param raw of Opaque Link Attribute
71 - * @param hLength length 71 + * @param hLength length
72 - * @return new object of OpaqueLinkAttributeTlv 72 + * @return new object of OpaqueLinkAttributeTlv
73 - */ 73 + */
74 - public static OpaqueLinkAttributeTlv of(final byte[] raw, short hLength) { 74 + public static OpaqueLinkAttributeTlv of(final byte[] raw, short hLength) {
75 - return new OpaqueLinkAttributeTlv(raw, hLength); 75 + return new OpaqueLinkAttributeTlv(raw, hLength);
76 - } 76 + }
77 - 77 +
78 - /** 78 + /**
79 - * Returns raw value of Opaque Link Attribute Tlv. 79 + * Returns raw value of Opaque Link Attribute Tlv.
80 - * @return rawValue raw value 80 + * @return rawValue raw value
81 - */ 81 + */
82 - public byte[] getValue() { 82 + public byte[] getValue() {
83 - return rawValue; 83 + return rawValue;
84 - } 84 + }
85 - 85 +
86 - @Override 86 + @Override
87 - public PcepVersion getVersion() { 87 + public PcepVersion getVersion() {
88 - return PcepVersion.PCEP_1; 88 + return PcepVersion.PCEP_1;
89 - } 89 + }
90 - 90 +
91 - @Override 91 + @Override
92 - public short getType() { 92 + public short getType() {
93 - return TYPE; 93 + return TYPE;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public short getLength() { 97 + public short getLength() {
98 - return hLength; 98 + return hLength;
99 - } 99 + }
100 - 100 +
101 - @Override 101 + @Override
102 - public int hashCode() { 102 + public int hashCode() {
103 - return Objects.hash(rawValue); 103 + return Objects.hash(rawValue);
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public boolean equals(Object obj) { 107 + public boolean equals(Object obj) {
108 - if (this == obj) { 108 + if (this == obj) {
109 - return true; 109 + return true;
110 - } 110 + }
111 - if (obj instanceof OpaqueLinkAttributeTlv) { 111 + if (obj instanceof OpaqueLinkAttributeTlv) {
112 - OpaqueLinkAttributeTlv other = (OpaqueLinkAttributeTlv) obj; 112 + OpaqueLinkAttributeTlv other = (OpaqueLinkAttributeTlv) obj;
113 - return Objects.equals(this.rawValue, other.rawValue); 113 + return Objects.equals(this.rawValue, other.rawValue);
114 - } 114 + }
115 - return false; 115 + return false;
116 - } 116 + }
117 - 117 +
118 - @Override 118 + @Override
119 - public int write(ChannelBuffer c) { 119 + public int write(ChannelBuffer c) {
120 - int iLenStartIndex = c.writerIndex(); 120 + int iLenStartIndex = c.writerIndex();
121 - c.writeShort(TYPE); 121 + c.writeShort(TYPE);
122 - c.writeShort(hLength); 122 + c.writeShort(hLength);
123 - c.writeBytes(rawValue); 123 + c.writeBytes(rawValue);
124 - return c.writerIndex() - iLenStartIndex; 124 + return c.writerIndex() - iLenStartIndex;
125 - } 125 + }
126 - 126 +
127 - /** 127 + /**
128 - * Reads the channel buffer and returns object of OpaqueLinkAttributeTlv. 128 + * Reads the channel buffer and returns object of OpaqueLinkAttributeTlv.
129 - * 129 + *
130 - * @param c input channel buffer 130 + * @param c input channel buffer
131 - * @param hLength length 131 + * @param hLength length
132 - * @return object of Opaque Link Attribute Tlv 132 + * @return object of Opaque Link Attribute Tlv
133 - */ 133 + */
134 - public static PcepValueType read(ChannelBuffer c, short hLength) { 134 + public static PcepValueType read(ChannelBuffer c, short hLength) {
135 - byte[] iOpaqueValue = new byte[hLength]; 135 + byte[] iOpaqueValue = new byte[hLength];
136 - c.readBytes(iOpaqueValue, 0, hLength); 136 + c.readBytes(iOpaqueValue, 0, hLength);
137 - return new OpaqueLinkAttributeTlv(iOpaqueValue, hLength); 137 + return new OpaqueLinkAttributeTlv(iOpaqueValue, hLength);
138 - } 138 + }
139 - 139 +
140 - @Override 140 + @Override
141 - public String toString() { 141 + public String toString() {
142 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 142 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
143 - 143 +
144 - toStrHelper.add("Type", TYPE); 144 + toStrHelper.add("Type", TYPE);
145 - toStrHelper.add("Length", hLength); 145 + toStrHelper.add("Length", hLength);
146 - 146 +
147 - StringBuffer result = new StringBuffer(); 147 + StringBuffer result = new StringBuffer();
148 - for (byte b : rawValue) { 148 + for (byte b : rawValue) {
149 - result.append(String.format("%02X ", b)); 149 + result.append(String.format("%02X ", b));
150 - } 150 + }
151 - toStrHelper.add("Value", result); 151 + toStrHelper.add("Value", result);
152 - 152 +
153 - return toStrHelper.toString(); 153 + return toStrHelper.toString();
154 - } 154 + }
155 -} 155 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 -import org.jboss.netty.buffer.ChannelBuffer; 19 +import org.jboss.netty.buffer.ChannelBuffer;
20 -import org.onosproject.pcepio.protocol.PcepVersion; 20 +import org.onosproject.pcepio.protocol.PcepVersion;
21 -import org.slf4j.Logger; 21 +import org.slf4j.Logger;
22 -import org.slf4j.LoggerFactory; 22 +import org.slf4j.LoggerFactory;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 -import com.google.common.base.MoreObjects.ToStringHelper; 25 +import com.google.common.base.MoreObjects.ToStringHelper;
26 - 26 +
27 -/** 27 +/**
28 - * Provides Opaque node attributes. 28 + * Provides Opaque node attributes.
29 - */ 29 + */
30 -public class OpaqueNodeAttributeTlv implements PcepValueType { 30 +public class OpaqueNodeAttributeTlv implements PcepValueType {
31 - /* 31 + /*
32 - * Reference [I-D.ietf-idr-Properties ls-distribution] /3.3.1.5 32 + * Reference [I-D.ietf-idr-Properties ls-distribution] /3.3.1.5
33 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TBD22] | Length | 36 + | Type=[TBD22] | Length |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - // Opaque node attributes (variable) // 38 + // Opaque node attributes (variable) //
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(OpaqueNodeAttributeTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(OpaqueNodeAttributeTlv.class);
43 - 43 +
44 - public static final short TYPE = 1001; 44 + public static final short TYPE = 1001;
45 - private final short hLength; 45 + private final short hLength;
46 - 46 +
47 - private final byte[] rawValue; 47 + private final byte[] rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * constructor to initialize rawValue. 50 + * constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue Opaque Node Attribute 52 + * @param rawValue Opaque Node Attribute
53 - * @param hLength length 53 + * @param hLength length
54 - */ 54 + */
55 - public OpaqueNodeAttributeTlv(byte[] rawValue, short hLength) { 55 + public OpaqueNodeAttributeTlv(byte[] rawValue, short hLength) {
56 - 56 +
57 - this.rawValue = rawValue; 57 + this.rawValue = rawValue;
58 - if (0 == hLength) { 58 + if (0 == hLength) {
59 - this.hLength = (short) rawValue.length; 59 + this.hLength = (short) rawValue.length;
60 - } else { 60 + } else {
61 - this.hLength = hLength; 61 + this.hLength = hLength;
62 - } 62 + }
63 - } 63 + }
64 - 64 +
65 - /** 65 + /**
66 - * Returns newly created OpaqueNodeAttributeTlv object. 66 + * Returns newly created OpaqueNodeAttributeTlv object.
67 - * 67 + *
68 - * @param raw value of Opaque Node Attribute 68 + * @param raw value of Opaque Node Attribute
69 - * @param hLength length 69 + * @param hLength length
70 - * @return new object of Opaque Node Attribute Tlv 70 + * @return new object of Opaque Node Attribute Tlv
71 - */ 71 + */
72 - public static OpaqueNodeAttributeTlv of(final byte[] raw, short hLength) { 72 + public static OpaqueNodeAttributeTlv of(final byte[] raw, short hLength) {
73 - return new OpaqueNodeAttributeTlv(raw, hLength); 73 + return new OpaqueNodeAttributeTlv(raw, hLength);
74 - } 74 + }
75 - 75 +
76 - /** 76 + /**
77 - * Returns raw value of Opaque Node Attribute Tlv. 77 + * Returns raw value of Opaque Node Attribute Tlv.
78 - * 78 + *
79 - * @return rawValue of Opaque Node Attribute 79 + * @return rawValue of Opaque Node Attribute
80 - */ 80 + */
81 - public byte[] getValue() { 81 + public byte[] getValue() {
82 - return rawValue; 82 + return rawValue;
83 - } 83 + }
84 - 84 +
85 - @Override 85 + @Override
86 - public PcepVersion getVersion() { 86 + public PcepVersion getVersion() {
87 - return PcepVersion.PCEP_1; 87 + return PcepVersion.PCEP_1;
88 - } 88 + }
89 - 89 +
90 - @Override 90 + @Override
91 - public short getType() { 91 + public short getType() {
92 - return TYPE; 92 + return TYPE;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public short getLength() { 96 + public short getLength() {
97 - return hLength; 97 + return hLength;
98 - } 98 + }
99 - 99 +
100 - @Override 100 + @Override
101 - public int hashCode() { 101 + public int hashCode() {
102 - return Objects.hash(rawValue); 102 + return Objects.hash(rawValue);
103 - } 103 + }
104 - 104 +
105 - @Override 105 + @Override
106 - public boolean equals(Object obj) { 106 + public boolean equals(Object obj) {
107 - if (this == obj) { 107 + if (this == obj) {
108 - return true; 108 + return true;
109 - } 109 + }
110 - if (obj instanceof OpaqueLinkAttributeTlv) { 110 + if (obj instanceof OpaqueLinkAttributeTlv) {
111 - OpaqueNodeAttributeTlv other = (OpaqueNodeAttributeTlv) obj; 111 + OpaqueNodeAttributeTlv other = (OpaqueNodeAttributeTlv) obj;
112 - return Objects.equals(this.rawValue, other.rawValue); 112 + return Objects.equals(this.rawValue, other.rawValue);
113 - } 113 + }
114 - return false; 114 + return false;
115 - } 115 + }
116 - 116 +
117 - @Override 117 + @Override
118 - public int write(ChannelBuffer c) { 118 + public int write(ChannelBuffer c) {
119 - int iLenStartIndex = c.writerIndex(); 119 + int iLenStartIndex = c.writerIndex();
120 - c.writeShort(TYPE); 120 + c.writeShort(TYPE);
121 - c.writeShort(hLength); 121 + c.writeShort(hLength);
122 - c.writeBytes(rawValue); 122 + c.writeBytes(rawValue);
123 - return c.writerIndex() - iLenStartIndex; 123 + return c.writerIndex() - iLenStartIndex;
124 - } 124 + }
125 - 125 +
126 - /** 126 + /**
127 - * Reads the channel buffer and returns object of Opaque Node Attribute Tlv. 127 + * Reads the channel buffer and returns object of Opaque Node Attribute Tlv.
128 - * 128 + *
129 - * @param c input channel buffer 129 + * @param c input channel buffer
130 - * @param hLength length 130 + * @param hLength length
131 - * @return object of OpaqueNodeAttributeTlv 131 + * @return object of OpaqueNodeAttributeTlv
132 - */ 132 + */
133 - public static PcepValueType read(ChannelBuffer c, short hLength) { 133 + public static PcepValueType read(ChannelBuffer c, short hLength) {
134 - byte[] iOpaqueValue = new byte[hLength]; 134 + byte[] iOpaqueValue = new byte[hLength];
135 - c.readBytes(iOpaqueValue, 0, hLength); 135 + c.readBytes(iOpaqueValue, 0, hLength);
136 - return new OpaqueNodeAttributeTlv(iOpaqueValue, hLength); 136 + return new OpaqueNodeAttributeTlv(iOpaqueValue, hLength);
137 - } 137 + }
138 - 138 +
139 - @Override 139 + @Override
140 - public String toString() { 140 + public String toString() {
141 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 141 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
142 - 142 +
143 - toStrHelper.add("Type", TYPE); 143 + toStrHelper.add("Type", TYPE);
144 - toStrHelper.add("Length", hLength); 144 + toStrHelper.add("Length", hLength);
145 - 145 +
146 - StringBuffer result = new StringBuffer(); 146 + StringBuffer result = new StringBuffer();
147 - for (byte b : rawValue) { 147 + for (byte b : rawValue) {
148 - result.append(String.format("%02X ", b)); 148 + result.append(String.format("%02X ", b));
149 - } 149 + }
150 - toStrHelper.add("Value", result); 150 + toStrHelper.add("Value", result);
151 - 151 +
152 - return toStrHelper.toString(); 152 + return toStrHelper.toString();
153 - } 153 + }
154 -} 154 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Path Key SubObject: When a PCC needs to expand a path-key in order to expand a CPS, it 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 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 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. 32 + * the PKS to be expanded in a PATH-KEY SubObject in the PCReq message.
33 - */ 33 + */
34 -public class PathKeySubObject implements PcepValueType { 34 +public class PathKeySubObject implements PcepValueType {
35 - 35 +
36 - /* 36 + /*
37 - Pathkey subobject(RFC 5520): 37 + Pathkey subobject(RFC 5520):
38 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - |L| Type | Length | Path-Key | 41 + |L| Type | Length | Path-Key |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | PCE ID (4 bytes) | 43 + | PCE ID (4 bytes) |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - */ 45 + */
46 - 46 +
47 - protected static final Logger log = LoggerFactory.getLogger(PathKeySubObject.class); 47 + protected static final Logger log = LoggerFactory.getLogger(PathKeySubObject.class);
48 - 48 +
49 - public static final byte TYPE = 0x40; 49 + public static final byte TYPE = 0x40;
50 - public static final byte LENGTH = 8; 50 + public static final byte LENGTH = 8;
51 - private final short pathKey; 51 + private final short pathKey;
52 - private final int pceID; 52 + private final int pceID;
53 - 53 +
54 - /** 54 + /**
55 - * Constructor for Path Key sub Object which initializes pathKey and pceId. 55 + * Constructor for Path Key sub Object which initializes pathKey and pceId.
56 - * 56 + *
57 - * @param pathKey path key provided by PCC 57 + * @param pathKey path key provided by PCC
58 - * @param pceID ID for the PCE 58 + * @param pceID ID for the PCE
59 - */ 59 + */
60 - public PathKeySubObject(short pathKey, int pceID) { 60 + public PathKeySubObject(short pathKey, int pceID) {
61 - this.pathKey = pathKey; 61 + this.pathKey = pathKey;
62 - this.pceID = pceID; 62 + this.pceID = pceID;
63 - } 63 + }
64 - 64 +
65 - /** 65 + /**
66 - * Creates Path Key sub Object which initializes pathKey and pceId. 66 + * Creates Path Key sub Object which initializes pathKey and pceId.
67 - * 67 + *
68 - * @param pathKey path key provided by PCC 68 + * @param pathKey path key provided by PCC
69 - * @param pceID PCE id 69 + * @param pceID PCE id
70 - * @return new object of type path key sub object 70 + * @return new object of type path key sub object
71 - */ 71 + */
72 - public static PathKeySubObject of(short pathKey, int pceID) { 72 + public static PathKeySubObject of(short pathKey, int pceID) {
73 - return new PathKeySubObject(pathKey, pceID); 73 + return new PathKeySubObject(pathKey, pceID);
74 - } 74 + }
75 - 75 +
76 - /** 76 + /**
77 - * Returns Path Key. 77 + * Returns Path Key.
78 - * 78 + *
79 - * @return pathKey 79 + * @return pathKey
80 - */ 80 + */
81 - public short getPathKey() { 81 + public short getPathKey() {
82 - return pathKey; 82 + return pathKey;
83 - } 83 + }
84 - 84 +
85 - /** 85 + /**
86 - * Returns pceID. 86 + * Returns pceID.
87 - * 87 + *
88 - * @return pceID 88 + * @return pceID
89 - */ 89 + */
90 - public int getPceId() { 90 + public int getPceId() {
91 - return pceID; 91 + return pceID;
92 - } 92 + }
93 - 93 +
94 - @Override 94 + @Override
95 - public PcepVersion getVersion() { 95 + public PcepVersion getVersion() {
96 - return PcepVersion.PCEP_1; 96 + return PcepVersion.PCEP_1;
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public short getType() { 100 + public short getType() {
101 - return TYPE; 101 + return TYPE;
102 - } 102 + }
103 - 103 +
104 - @Override 104 + @Override
105 - public short getLength() { 105 + public short getLength() {
106 - return LENGTH; 106 + return LENGTH;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int hashCode() { 110 + public int hashCode() {
111 - return Objects.hash(pathKey, pceID); 111 + return Objects.hash(pathKey, pceID);
112 - } 112 + }
113 - 113 +
114 - @Override 114 + @Override
115 - public boolean equals(Object obj) { 115 + public boolean equals(Object obj) {
116 - if (this == obj) { 116 + if (this == obj) {
117 - return true; 117 + return true;
118 - } 118 + }
119 - if (obj instanceof PathKeySubObject) { 119 + if (obj instanceof PathKeySubObject) {
120 - PathKeySubObject other = (PathKeySubObject) obj; 120 + PathKeySubObject other = (PathKeySubObject) obj;
121 - return Objects.equals(this.pathKey, other.pathKey) && Objects.equals(this.pceID, other.pceID); 121 + return Objects.equals(this.pathKey, other.pathKey) && Objects.equals(this.pceID, other.pceID);
122 - } 122 + }
123 - return false; 123 + return false;
124 - } 124 + }
125 - 125 +
126 - @Override 126 + @Override
127 - public int write(ChannelBuffer c) { 127 + public int write(ChannelBuffer c) {
128 - int iLenStartIndex = c.writerIndex(); 128 + int iLenStartIndex = c.writerIndex();
129 - c.writeShort(TYPE); 129 + c.writeShort(TYPE);
130 - c.writeShort(LENGTH); 130 + c.writeShort(LENGTH);
131 - 131 +
132 - c.writeShort(pathKey); 132 + c.writeShort(pathKey);
133 - c.writeInt(pceID); 133 + c.writeInt(pceID);
134 - 134 +
135 - return c.writerIndex() - iLenStartIndex; 135 + return c.writerIndex() - iLenStartIndex;
136 - } 136 + }
137 - 137 +
138 - /** 138 + /**
139 - * Reads the channel buffer and returns new path key sub objects. 139 + * Reads the channel buffer and returns new path key sub objects.
140 - * 140 + *
141 - * @param c of type channel buffer 141 + * @param c of type channel buffer
142 - * @return object of type path key sub object 142 + * @return object of type path key sub object
143 - */ 143 + */
144 - public static PcepValueType read(ChannelBuffer c) { 144 + public static PcepValueType read(ChannelBuffer c) {
145 - Short pathKey = c.readShort(); 145 + Short pathKey = c.readShort();
146 - int pceID = c.readInt(); 146 + int pceID = c.readInt();
147 - return new PathKeySubObject(pathKey, pceID); 147 + return new PathKeySubObject(pathKey, pceID);
148 - } 148 + }
149 - 149 +
150 - @Override 150 + @Override
151 - public String toString() { 151 + public String toString() {
152 - return MoreObjects.toStringHelper(getClass()) 152 + return MoreObjects.toStringHelper(getClass())
153 - .add("Type", TYPE) 153 + .add("Type", TYPE)
154 - .add("Length", LENGTH) 154 + .add("Length", LENGTH)
155 - .add("PathKey", pathKey) 155 + .add("PathKey", pathKey)
156 - .add("PceID", pceID) 156 + .add("PceID", pceID)
157 - .toString(); 157 + .toString();
158 - } 158 + }
159 -} 159 +}
......
1 -package org.onosproject.pcepio.types; 1 +package org.onosproject.pcepio.types;
2 - 2 +
3 -import java.util.Objects; 3 +import java.util.Objects;
4 - 4 +
5 -import org.jboss.netty.buffer.ChannelBuffer; 5 +import org.jboss.netty.buffer.ChannelBuffer;
6 -import org.onosproject.pcepio.protocol.PcepVersion; 6 +import org.onosproject.pcepio.protocol.PcepVersion;
7 -import org.slf4j.Logger; 7 +import org.slf4j.Logger;
8 -import org.slf4j.LoggerFactory; 8 +import org.slf4j.LoggerFactory;
9 - 9 +
10 -import com.google.common.base.MoreObjects; 10 +import com.google.common.base.MoreObjects;
11 - 11 +
12 -/** 12 +/**
13 - * Provides PcepSetup type tlv. 13 + * Provides PcepSetup type tlv.
14 - */ 14 + */
15 -public class PathSetupTypeTlv implements PcepValueType { 15 +public class PathSetupTypeTlv implements PcepValueType {
16 - 16 +
17 - /* 17 + /*
18 - Reference : draft-sivabalan-pce-lsp-setup-type-02. 18 + Reference : draft-sivabalan-pce-lsp-setup-type-02.
19 - 19 +
20 - 0 1 2 3 20 + 0 1 2 3
21 - 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 21 + 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
22 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 22 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
23 - | Type | Length | 23 + | Type | Length |
24 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 24 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
25 - | Reserved | PST | 25 + | Reserved | PST |
26 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 - 27 +
28 - Figure 1: PATH-SETUP-TYPE TLV 28 + Figure 1: PATH-SETUP-TYPE TLV
29 - 29 +
30 - */ 30 + */
31 - protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class); 31 + protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class);
32 - 32 +
33 - public static final short TYPE = 0; //TODO : need to reassign the value as per RFC 33 + public static final short TYPE = 0; //TODO : need to reassign the value as per RFC
34 - public static final short LENGTH = 4; 34 + public static final short LENGTH = 4;
35 - 35 +
36 - private final byte pst; 36 + private final byte pst;
37 - private final int rawValue; 37 + private final int rawValue;
38 - private final boolean isRawValueSet; 38 + private final boolean isRawValueSet;
39 - 39 +
40 - /** 40 + /**
41 - * Constructor to initialize parameters for path setup type tlv. 41 + * Constructor to initialize parameters for path setup type tlv.
42 - * 42 + *
43 - * @param rawValue parameter for path setup type tlv 43 + * @param rawValue parameter for path setup type tlv
44 - */ 44 + */
45 - public PathSetupTypeTlv(final int rawValue) { 45 + public PathSetupTypeTlv(final int rawValue) {
46 - this.rawValue = rawValue; 46 + this.rawValue = rawValue;
47 - this.isRawValueSet = true; 47 + this.isRawValueSet = true;
48 - this.pst = (byte) rawValue; 48 + this.pst = (byte) rawValue;
49 - } 49 + }
50 - 50 +
51 - /** 51 + /**
52 - * Constructor to initialize pst. 52 + * Constructor to initialize pst.
53 - * 53 + *
54 - * @param pst PST 54 + * @param pst PST
55 - */ 55 + */
56 - public PathSetupTypeTlv(byte pst) { 56 + public PathSetupTypeTlv(byte pst) {
57 - this.pst = pst; 57 + this.pst = pst;
58 - this.rawValue = 0; 58 + this.rawValue = 0;
59 - this.isRawValueSet = false; 59 + this.isRawValueSet = false;
60 - } 60 + }
61 - 61 +
62 - /** 62 + /**
63 - * Returns Object of path setup type tlv. 63 + * Returns Object of path setup type tlv.
64 - * 64 + *
65 - * @param raw parameter for path setup type tlv 65 + * @param raw parameter for path setup type tlv
66 - * @return object of PathSetupTypeTlv 66 + * @return object of PathSetupTypeTlv
67 - */ 67 + */
68 - public static PathSetupTypeTlv of(final int raw) { 68 + public static PathSetupTypeTlv of(final int raw) {
69 - return new PathSetupTypeTlv(raw); 69 + return new PathSetupTypeTlv(raw);
70 - } 70 + }
71 - 71 +
72 - @Override 72 + @Override
73 - public PcepVersion getVersion() { 73 + public PcepVersion getVersion() {
74 - return PcepVersion.PCEP_1; 74 + return PcepVersion.PCEP_1;
75 - } 75 + }
76 - 76 +
77 - /** 77 + /**
78 - * Returns parameters for path setup type tlv. 78 + * Returns parameters for path setup type tlv.
79 - * 79 + *
80 - * @return parameters for path setup type tlv 80 + * @return parameters for path setup type tlv
81 - */ 81 + */
82 - public int getInt() { 82 + public int getInt() {
83 - return rawValue; 83 + return rawValue;
84 - } 84 + }
85 - 85 +
86 - /** 86 + /**
87 - * Returns the pst value. 87 + * Returns the pst value.
88 - * 88 + *
89 - * @return pst value 89 + * @return pst value
90 - */ 90 + */
91 - public byte getPst() { 91 + public byte getPst() {
92 - return pst; 92 + return pst;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public short getType() { 96 + public short getType() {
97 - return TYPE; 97 + return TYPE;
98 - } 98 + }
99 - 99 +
100 - @Override 100 + @Override
101 - public short getLength() { 101 + public short getLength() {
102 - return LENGTH; 102 + return LENGTH;
103 - } 103 + }
104 - 104 +
105 - @Override 105 + @Override
106 - public int hashCode() { 106 + public int hashCode() {
107 - return Objects.hash(pst); 107 + return Objects.hash(pst);
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public boolean equals(Object obj) { 111 + public boolean equals(Object obj) {
112 - if (this == obj) { 112 + if (this == obj) {
113 - return true; 113 + return true;
114 - } 114 + }
115 - if (obj instanceof PathSetupTypeTlv) { 115 + if (obj instanceof PathSetupTypeTlv) {
116 - PathSetupTypeTlv other = (PathSetupTypeTlv) obj; 116 + PathSetupTypeTlv other = (PathSetupTypeTlv) obj;
117 - return Objects.equals(this.pst, other.pst); 117 + return Objects.equals(this.pst, other.pst);
118 - } 118 + }
119 - return false; 119 + return false;
120 - } 120 + }
121 - 121 +
122 - @Override 122 + @Override
123 - public int write(ChannelBuffer c) { 123 + public int write(ChannelBuffer c) {
124 - int iLenStartIndex = c.writerIndex(); 124 + int iLenStartIndex = c.writerIndex();
125 - c.writeShort(TYPE); 125 + c.writeShort(TYPE);
126 - c.writeShort(LENGTH); 126 + c.writeShort(LENGTH);
127 - c.writeInt(pst); 127 + c.writeInt(pst);
128 - return c.writerIndex() - iLenStartIndex; 128 + return c.writerIndex() - iLenStartIndex;
129 - } 129 + }
130 - 130 +
131 - /** 131 + /**
132 - * Returns the object of type PathSetupTypeTlv. 132 + * Returns the object of type PathSetupTypeTlv.
133 - * 133 + *
134 - * @param c is type Channel buffer 134 + * @param c is type Channel buffer
135 - * @return object of PathSetupTypeTlv 135 + * @return object of PathSetupTypeTlv
136 - */ 136 + */
137 - public static PathSetupTypeTlv read(ChannelBuffer c) { 137 + public static PathSetupTypeTlv read(ChannelBuffer c) {
138 - return PathSetupTypeTlv.of(c.readInt()); 138 + return PathSetupTypeTlv.of(c.readInt());
139 - } 139 + }
140 - 140 +
141 - @Override 141 + @Override
142 - public String toString() { 142 + public String toString() {
143 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("PST", pst) 143 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("PST", pst)
144 - .toString(); 144 + .toString();
145 - } 145 + }
146 -} 146 +}
......
1 -package org.onosproject.pcepio.types; 1 +package org.onosproject.pcepio.types;
2 - 2 +
3 -import java.util.Objects; 3 +import java.util.Objects;
4 -import org.jboss.netty.buffer.ChannelBuffer; 4 +import org.jboss.netty.buffer.ChannelBuffer;
5 -import org.onosproject.pcepio.protocol.PcepVersion; 5 +import org.onosproject.pcepio.protocol.PcepVersion;
6 -import org.slf4j.Logger; 6 +import org.slf4j.Logger;
7 -import org.slf4j.LoggerFactory; 7 +import org.slf4j.LoggerFactory;
8 - 8 +
9 -import com.google.common.base.MoreObjects; 9 +import com.google.common.base.MoreObjects;
10 - 10 +
11 -/** 11 +/**
12 - * Provides PceccCapabilityTlv. 12 + * Provides PceccCapabilityTlv.
13 - */ 13 + */
14 -public class PceccCapabilityTlv implements PcepValueType { 14 +public class PceccCapabilityTlv implements PcepValueType {
15 - 15 +
16 - /* PCECC CAPABILITY TLV 16 + /* PCECC CAPABILITY TLV
17 - * Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01, section-7.1.1 17 + * Reference : draft-zhao-pce-pcep-extension-for-pce-controller-01, section-7.1.1
18 - 18 +
19 - 0 1 2 3 19 + 0 1 2 3
20 - 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 20 + 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
21 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 21 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
22 - | Type=32 | Length=4 | 22 + | Type=32 | Length=4 |
23 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 23 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24 - | Flags |G|L| 24 + | Flags |G|L|
25 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 25 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
26 - 26 +
27 - */ 27 + */
28 - protected static final Logger log = LoggerFactory.getLogger(PceccCapabilityTlv.class); 28 + protected static final Logger log = LoggerFactory.getLogger(PceccCapabilityTlv.class);
29 - 29 +
30 - public static final short TYPE = 32; 30 + public static final short TYPE = 32;
31 - public static final short LENGTH = 4; 31 + public static final short LENGTH = 4;
32 - public static final int SET = 1; 32 + public static final int SET = 1;
33 - public static final byte LFLAG_CHECK = 0x01; 33 + public static final byte LFLAG_CHECK = 0x01;
34 - public static final byte GFLAG_CHECK = 0x02; 34 + public static final byte GFLAG_CHECK = 0x02;
35 - 35 +
36 - private final boolean bGFlag; 36 + private final boolean bGFlag;
37 - private final boolean bLFlag; 37 + private final boolean bLFlag;
38 - 38 +
39 - private final int rawValue; 39 + private final int rawValue;
40 - private final boolean isRawValueSet; 40 + private final boolean isRawValueSet;
41 - 41 +
42 - /** 42 + /**
43 - * Constructor to initialize raw Value. 43 + * Constructor to initialize raw Value.
44 - * 44 + *
45 - * @param rawValue raw value 45 + * @param rawValue raw value
46 - */ 46 + */
47 - public PceccCapabilityTlv(final int rawValue) { 47 + public PceccCapabilityTlv(final int rawValue) {
48 - this.rawValue = rawValue; 48 + this.rawValue = rawValue;
49 - this.isRawValueSet = true; 49 + this.isRawValueSet = true;
50 - 50 +
51 - bLFlag = (rawValue & LFLAG_CHECK) == LFLAG_CHECK ? true : false; 51 + bLFlag = (rawValue & LFLAG_CHECK) == LFLAG_CHECK ? true : false;
52 - bGFlag = (rawValue & GFLAG_CHECK) == GFLAG_CHECK ? true : false; 52 + bGFlag = (rawValue & GFLAG_CHECK) == GFLAG_CHECK ? true : false;
53 - } 53 + }
54 - 54 +
55 - /** 55 + /**
56 - * Constructor to initialize G-flag L-flag. 56 + * Constructor to initialize G-flag L-flag.
57 - * @param bGFlag G-flag 57 + * @param bGFlag G-flag
58 - * @param bLFlag L-flag 58 + * @param bLFlag L-flag
59 - */ 59 + */
60 - public PceccCapabilityTlv(boolean bGFlag, boolean bLFlag) { 60 + public PceccCapabilityTlv(boolean bGFlag, boolean bLFlag) {
61 - this.bGFlag = bGFlag; 61 + this.bGFlag = bGFlag;
62 - this.bLFlag = bLFlag; 62 + this.bLFlag = bLFlag;
63 - this.rawValue = 0; 63 + this.rawValue = 0;
64 - this.isRawValueSet = false; 64 + this.isRawValueSet = false;
65 - } 65 + }
66 - 66 +
67 - /** 67 + /**
68 - * Returns newly created PceccCapabilityTlv object. 68 + * Returns newly created PceccCapabilityTlv object.
69 - * 69 + *
70 - * @param raw value 70 + * @param raw value
71 - * @return object of Pcecc Capability Tlv 71 + * @return object of Pcecc Capability Tlv
72 - */ 72 + */
73 - public static PceccCapabilityTlv of(final int raw) { 73 + public static PceccCapabilityTlv of(final int raw) {
74 - return new PceccCapabilityTlv(raw); 74 + return new PceccCapabilityTlv(raw);
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepVersion getVersion() { 78 + public PcepVersion getVersion() {
79 - return PcepVersion.PCEP_1; 79 + return PcepVersion.PCEP_1;
80 - } 80 + }
81 - 81 +
82 - /** 82 + /**
83 - * Returns G-flag. 83 + * Returns G-flag.
84 - * @return bGFlag G-flag 84 + * @return bGFlag G-flag
85 - */ 85 + */
86 - public boolean getGFlag() { 86 + public boolean getGFlag() {
87 - return bGFlag; 87 + return bGFlag;
88 - } 88 + }
89 - 89 +
90 - /** 90 + /**
91 - * Returns L-flag. 91 + * Returns L-flag.
92 - * @return bLFlag L-flag 92 + * @return bLFlag L-flag
93 - */ 93 + */
94 - public boolean getLFlag() { 94 + public boolean getLFlag() {
95 - return bLFlag; 95 + return bLFlag;
96 - } 96 + }
97 - 97 +
98 - /** 98 + /**
99 - * Returns the raw value. 99 + * Returns the raw value.
100 - * @return rawValue Flags 100 + * @return rawValue Flags
101 - */ 101 + */
102 - public int getInt() { 102 + public int getInt() {
103 - return rawValue; 103 + return rawValue;
104 - } 104 + }
105 - 105 +
106 - @Override 106 + @Override
107 - public short getType() { 107 + public short getType() {
108 - return TYPE; 108 + return TYPE;
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public short getLength() { 112 + public short getLength() {
113 - return LENGTH; 113 + return LENGTH;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public int hashCode() { 117 + public int hashCode() {
118 - if (isRawValueSet) { 118 + if (isRawValueSet) {
119 - return Objects.hash(rawValue); 119 + return Objects.hash(rawValue);
120 - } else { 120 + } else {
121 - return Objects.hash(bLFlag, bGFlag); 121 + return Objects.hash(bLFlag, bGFlag);
122 - } 122 + }
123 - } 123 + }
124 - 124 +
125 - @Override 125 + @Override
126 - public boolean equals(Object obj) { 126 + public boolean equals(Object obj) {
127 - if (this == obj) { 127 + if (this == obj) {
128 - return true; 128 + return true;
129 - } 129 + }
130 - if (obj instanceof PceccCapabilityTlv) { 130 + if (obj instanceof PceccCapabilityTlv) {
131 - PceccCapabilityTlv other = (PceccCapabilityTlv) obj; 131 + PceccCapabilityTlv other = (PceccCapabilityTlv) obj;
132 - if (isRawValueSet) { 132 + if (isRawValueSet) {
133 - return Objects.equals(this.rawValue, other.rawValue); 133 + return Objects.equals(this.rawValue, other.rawValue);
134 - } else { 134 + } else {
135 - return Objects.equals(this.bGFlag, other.bGFlag) && Objects.equals(this.bLFlag, other.bLFlag); 135 + return Objects.equals(this.bGFlag, other.bGFlag) && Objects.equals(this.bLFlag, other.bLFlag);
136 - } 136 + }
137 - } 137 + }
138 - return false; 138 + return false;
139 - } 139 + }
140 - 140 +
141 - @Override 141 + @Override
142 - public int write(ChannelBuffer c) { 142 + public int write(ChannelBuffer c) {
143 - int iLenStartIndex = c.writerIndex(); 143 + int iLenStartIndex = c.writerIndex();
144 - int temp = 0; 144 + int temp = 0;
145 - c.writeShort(TYPE); 145 + c.writeShort(TYPE);
146 - c.writeShort(LENGTH); 146 + c.writeShort(LENGTH);
147 - if (isRawValueSet) { 147 + if (isRawValueSet) {
148 - c.writeInt(rawValue); 148 + c.writeInt(rawValue);
149 - } else { 149 + } else {
150 - if (bGFlag) { 150 + if (bGFlag) {
151 - temp = temp | GFLAG_CHECK; 151 + temp = temp | GFLAG_CHECK;
152 - } 152 + }
153 - if (bLFlag) { 153 + if (bLFlag) {
154 - temp = temp | LFLAG_CHECK; 154 + temp = temp | LFLAG_CHECK;
155 - } 155 + }
156 - c.writeInt(temp); 156 + c.writeInt(temp);
157 - } 157 + }
158 - return c.writerIndex() - iLenStartIndex; 158 + return c.writerIndex() - iLenStartIndex;
159 - } 159 + }
160 - 160 +
161 - /** 161 + /**
162 - * Reads channel buffer and returns object of PceccCapabilityTlv. 162 + * Reads channel buffer and returns object of PceccCapabilityTlv.
163 - * 163 + *
164 - * @param c input channel buffer 164 + * @param c input channel buffer
165 - * @return object of PceccCapabilityTlv 165 + * @return object of PceccCapabilityTlv
166 - */ 166 + */
167 - public static PceccCapabilityTlv read(ChannelBuffer c) { 167 + public static PceccCapabilityTlv read(ChannelBuffer c) {
168 - return PceccCapabilityTlv.of(c.readInt()); 168 + return PceccCapabilityTlv.of(c.readInt());
169 - } 169 + }
170 - 170 +
171 - @Override 171 + @Override
172 - public String toString() { 172 + public String toString() {
173 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 173 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
174 - .toString(); 174 + .toString();
175 - } 175 + }
176 -} 176 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -/** 19 +/**
20 - * Provide the PCEP Error Info Details. 20 + * Provide the PCEP Error Info Details.
21 - */ 21 + */
22 -public final class PcepErrorDetailInfo { 22 +public final class PcepErrorDetailInfo {
23 - 23 +
24 - private PcepErrorDetailInfo() { 24 + private PcepErrorDetailInfo() {
25 - } 25 + }
26 - 26 +
27 - // Error Types 27 + // Error Types
28 - /** 28 + /**
29 - Error- Meaning Reference:RFC 5440 29 + Error- Meaning Reference:RFC 5440
30 - Type 30 + Type
31 - 1 PCEP session establishment failure 31 + 1 PCEP session establishment failure
32 - Error-value=1: reception of an invalid Open message or a non Open message. 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 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 34 + Error-value=3: unacceptable and non-negotiable session characteristics
35 - Error-value=4: unacceptable but 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 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 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 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 39 + Error-value=8: PCEP version not supported
40 - 2 Capability not supported 40 + 2 Capability not supported
41 - 3 Unknown Object 41 + 3 Unknown Object
42 - Error-value=1: Unrecognized object class 42 + Error-value=1: Unrecognized object class
43 - Error-value=2: Unrecognized object Type 43 + Error-value=2: Unrecognized object Type
44 - 4 Not supported object 44 + 4 Not supported object
45 - Error-value=1: Not supported object class 45 + Error-value=1: Not supported object class
46 - Error-value=2: Not supported object Type 46 + Error-value=2: Not supported object Type
47 - 5 Policy violation 47 + 5 Policy violation
48 - Error-value=1: C bit of the METRIC object set (request rejected) 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) 49 + Error-value=2: O bit of the RP object cleared (request rejected)
50 - 6 Mandatory Object missing 50 + 6 Mandatory Object missing
51 - Error-value=1: RP 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) 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 53 + Error-value=3: END-POINTS object missing
54 - 7 Synchronized path computation request missing 54 + 7 Synchronized path computation request missing
55 - 8 Unknown request reference 55 + 8 Unknown request reference
56 - 9 Attempt to establish a second PCEP session 56 + 9 Attempt to establish a second PCEP session
57 - 10 Reception of an invalid object 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 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. 59 + set according to this specification.
60 - */ 60 + */
61 - public static final byte ERROR_TYPE_1 = 1; 61 + public static final byte ERROR_TYPE_1 = 1;
62 - public static final byte ERROR_TYPE_2 = 2; 62 + public static final byte ERROR_TYPE_2 = 2;
63 - public static final byte ERROR_TYPE_3 = 3; 63 + public static final byte ERROR_TYPE_3 = 3;
64 - public static final byte ERROR_TYPE_4 = 4; 64 + public static final byte ERROR_TYPE_4 = 4;
65 - public static final byte ERROR_TYPE_5 = 5; 65 + public static final byte ERROR_TYPE_5 = 5;
66 - public static final byte ERROR_TYPE_6 = 6; 66 + public static final byte ERROR_TYPE_6 = 6;
67 - public static final byte ERROR_TYPE_7 = 7; 67 + public static final byte ERROR_TYPE_7 = 7;
68 - public static final byte ERROR_TYPE_8 = 8; 68 + public static final byte ERROR_TYPE_8 = 8;
69 - public static final byte ERROR_TYPE_9 = 9; 69 + public static final byte ERROR_TYPE_9 = 9;
70 - public static final byte ERROR_TYPE_10 = 10; 70 + public static final byte ERROR_TYPE_10 = 10;
71 - 71 +
72 - // Error Values 72 + // Error Values
73 - public static final byte ERROR_VALUE_1 = 1; 73 + public static final byte ERROR_VALUE_1 = 1;
74 - public static final byte ERROR_VALUE_2 = 2; 74 + public static final byte ERROR_VALUE_2 = 2;
75 - public static final byte ERROR_VALUE_3 = 3; 75 + public static final byte ERROR_VALUE_3 = 3;
76 - public static final byte ERROR_VALUE_4 = 4; 76 + public static final byte ERROR_VALUE_4 = 4;
77 - public static final byte ERROR_VALUE_5 = 5; 77 + public static final byte ERROR_VALUE_5 = 5;
78 - public static final byte ERROR_VALUE_6 = 6; 78 + public static final byte ERROR_VALUE_6 = 6;
79 - public static final byte ERROR_VALUE_7 = 7; 79 + public static final byte ERROR_VALUE_7 = 7;
80 - public static final byte ERROR_VALUE_8 = 8; 80 + public static final byte ERROR_VALUE_8 = 8;
81 - public static final byte ERROR_VALUE_9 = 9; 81 + public static final byte ERROR_VALUE_9 = 9;
82 - public static final byte ERROR_VALUE_10 = 10; 82 + public static final byte ERROR_VALUE_10 = 10;
83 -} 83 +}
......
1 -package org.onosproject.pcepio.types; 1 +package org.onosproject.pcepio.types;
2 - 2 +
3 -import java.util.Objects; 3 +import java.util.Objects;
4 -import org.jboss.netty.buffer.ChannelBuffer; 4 +import org.jboss.netty.buffer.ChannelBuffer;
5 -import org.onosproject.pcepio.protocol.PcepVersion; 5 +import org.onosproject.pcepio.protocol.PcepVersion;
6 -import org.slf4j.Logger; 6 +import org.slf4j.Logger;
7 -import org.slf4j.LoggerFactory; 7 +import org.slf4j.LoggerFactory;
8 - 8 +
9 -import com.google.common.base.MoreObjects; 9 +import com.google.common.base.MoreObjects;
10 - 10 +
11 -/** 11 +/**
12 - * Provides CEP LABEL DB VERSION TLV which contains LSP State DB Version (32 Bit ). 12 + * Provides CEP LABEL DB VERSION TLV which contains LSP State DB Version (32 Bit ).
13 - */ 13 + */
14 -public class PcepLabelDbVerTlv implements PcepValueType { 14 +public class PcepLabelDbVerTlv implements PcepValueType {
15 - 15 +
16 - /* PCEP LABEL DB VERSION TLV format 16 + /* PCEP LABEL DB VERSION TLV format
17 - 17 +
18 - Reference : draft-ietf-pce-stateful-sync-optimizations-02, section 3.3.1 18 + Reference : draft-ietf-pce-stateful-sync-optimizations-02, section 3.3.1
19 - 0 1 2 3 19 + 0 1 2 3
20 - 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 20 + 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
21 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 21 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
22 - | Type=23 | Length=8 | 22 + | Type=23 | Length=8 |
23 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 23 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
24 - | LSP State DB Version | 24 + | LSP State DB Version |
25 - | | 25 + | |
26 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 26 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
27 - 27 +
28 - */ 28 + */
29 - protected static final Logger log = LoggerFactory.getLogger(PcepLabelDbVerTlv.class); 29 + protected static final Logger log = LoggerFactory.getLogger(PcepLabelDbVerTlv.class);
30 - 30 +
31 - public static final short TYPE = 34; 31 + public static final short TYPE = 34;
32 - public static final short LENGTH = 8; 32 + public static final short LENGTH = 8;
33 - private final long rawValue; 33 + private final long rawValue;
34 - 34 +
35 - /** 35 + /**
36 - * constructor to initialize rawValue. 36 + * constructor to initialize rawValue.
37 - * 37 + *
38 - * @param rawValue of Pcep Label Db Version Tlv 38 + * @param rawValue of Pcep Label Db Version Tlv
39 - */ 39 + */
40 - public PcepLabelDbVerTlv(final long rawValue) { 40 + public PcepLabelDbVerTlv(final long rawValue) {
41 - log.debug("PcepLabelDbVerTlv"); 41 + log.debug("PcepLabelDbVerTlv");
42 - this.rawValue = rawValue; 42 + this.rawValue = rawValue;
43 - } 43 + }
44 - 44 +
45 - /** 45 + /**
46 - * Returns newly created PcepLabelDbVerTlv object. 46 + * Returns newly created PcepLabelDbVerTlv object.
47 - * 47 + *
48 - * @param raw LSP State DB Version 48 + * @param raw LSP State DB Version
49 - * @return object of PcepLabelDbVerTlv 49 + * @return object of PcepLabelDbVerTlv
50 - */ 50 + */
51 - public static PcepLabelDbVerTlv of(final long raw) { 51 + public static PcepLabelDbVerTlv of(final long raw) {
52 - return new PcepLabelDbVerTlv(raw); 52 + return new PcepLabelDbVerTlv(raw);
53 - } 53 + }
54 - 54 +
55 - @Override 55 + @Override
56 - public PcepVersion getVersion() { 56 + public PcepVersion getVersion() {
57 - return PcepVersion.PCEP_1; 57 + return PcepVersion.PCEP_1;
58 - } 58 + }
59 - 59 +
60 - /** 60 + /**
61 - * Returns LSP State DB Version. 61 + * Returns LSP State DB Version.
62 - * @return raw value 62 + * @return raw value
63 - */ 63 + */
64 - public long getLong() { 64 + public long getLong() {
65 - return rawValue; 65 + return rawValue;
66 - } 66 + }
67 - 67 +
68 - @Override 68 + @Override
69 - public short getLength() { 69 + public short getLength() {
70 - return LENGTH; 70 + return LENGTH;
71 - } 71 + }
72 - 72 +
73 - @Override 73 + @Override
74 - public short getType() { 74 + public short getType() {
75 - return TYPE; 75 + return TYPE;
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public int hashCode() { 79 + public int hashCode() {
80 - return Objects.hash(rawValue); 80 + return Objects.hash(rawValue);
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public boolean equals(Object obj) { 84 + public boolean equals(Object obj) {
85 - if (this == obj) { 85 + if (this == obj) {
86 - return true; 86 + return true;
87 - } 87 + }
88 - if (obj instanceof PceccCapabilityTlv) { 88 + if (obj instanceof PceccCapabilityTlv) {
89 - PcepLabelDbVerTlv other = (PcepLabelDbVerTlv) obj; 89 + PcepLabelDbVerTlv other = (PcepLabelDbVerTlv) obj;
90 - return Objects.equals(this.rawValue, other.rawValue); 90 + return Objects.equals(this.rawValue, other.rawValue);
91 - } 91 + }
92 - return false; 92 + return false;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public int write(ChannelBuffer c) { 96 + public int write(ChannelBuffer c) {
97 - int iLenStartIndex = c.writerIndex(); 97 + int iLenStartIndex = c.writerIndex();
98 - c.writeShort(TYPE); 98 + c.writeShort(TYPE);
99 - c.writeShort(LENGTH); 99 + c.writeShort(LENGTH);
100 - c.writeLong(rawValue); 100 + c.writeLong(rawValue);
101 - return c.writerIndex() - iLenStartIndex; 101 + return c.writerIndex() - iLenStartIndex;
102 - } 102 + }
103 - 103 +
104 - /** 104 + /**
105 - * Reads the channel buffer and returns object of PcepLabelDbVerTlv. 105 + * Reads the channel buffer and returns object of PcepLabelDbVerTlv.
106 - * 106 + *
107 - * @param c input channel buffer 107 + * @param c input channel buffer
108 - * @return object of PcepLabelDbVerTlv 108 + * @return object of PcepLabelDbVerTlv
109 - */ 109 + */
110 - public static PcepLabelDbVerTlv read(ChannelBuffer c) { 110 + public static PcepLabelDbVerTlv read(ChannelBuffer c) {
111 - return PcepLabelDbVerTlv.of(c.readLong()); 111 + return PcepLabelDbVerTlv.of(c.readLong());
112 - } 112 + }
113 - 113 +
114 - @Override 114 + @Override
115 - public String toString() { 115 + public String toString() {
116 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 116 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
117 - .toString(); 117 + .toString();
118 - } 118 + }
119 -} 119 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepNai; 22 +import org.onosproject.pcepio.protocol.PcepNai;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 - 25 +
26 -/** 26 +/**
27 - * Provides Pcep Nai Ipv4 Adjacency. 27 + * Provides Pcep Nai Ipv4 Adjacency.
28 - */ 28 + */
29 -public class PcepNaiIpv4Adjacency implements PcepNai { 29 +public class PcepNaiIpv4Adjacency implements PcepNai {
30 - 30 +
31 - public static final byte ST_TYPE = 0x03; 31 + public static final byte ST_TYPE = 0x03;
32 - private final int localIpv4Addr; 32 + private final int localIpv4Addr;
33 - private final int remoteIpv4Addr; 33 + private final int remoteIpv4Addr;
34 - 34 +
35 - /** 35 + /**
36 - * Constructor to initialize variables. 36 + * Constructor to initialize variables.
37 - * 37 + *
38 - * @param localIpv4 local ipv4 address 38 + * @param localIpv4 local ipv4 address
39 - * @param remoteIpv4 remote ipv4 address 39 + * @param remoteIpv4 remote ipv4 address
40 - */ 40 + */
41 - public PcepNaiIpv4Adjacency(int localIpv4, int remoteIpv4) { 41 + public PcepNaiIpv4Adjacency(int localIpv4, int remoteIpv4) {
42 - this.localIpv4Addr = localIpv4; 42 + this.localIpv4Addr = localIpv4;
43 - this.remoteIpv4Addr = remoteIpv4; 43 + this.remoteIpv4Addr = remoteIpv4;
44 - } 44 + }
45 - 45 +
46 - /** 46 + /**
47 - * Returns Object of Pcep nai Ipv4 Adjacency. 47 + * Returns Object of Pcep nai Ipv4 Adjacency.
48 - * 48 + *
49 - * @param localIpv4Addr local ipv4 address 49 + * @param localIpv4Addr local ipv4 address
50 - * @param remoteIpv4Addr remote ipv4 address 50 + * @param remoteIpv4Addr remote ipv4 address
51 - * @return Object of Pcep nai Ipv4 Adjacency 51 + * @return Object of Pcep nai Ipv4 Adjacency
52 - */ 52 + */
53 - public static PcepNaiIpv4Adjacency of(int localIpv4Addr, int remoteIpv4Addr) { 53 + public static PcepNaiIpv4Adjacency of(int localIpv4Addr, int remoteIpv4Addr) {
54 - return new PcepNaiIpv4Adjacency(localIpv4Addr, remoteIpv4Addr); 54 + return new PcepNaiIpv4Adjacency(localIpv4Addr, remoteIpv4Addr);
55 - } 55 + }
56 - 56 +
57 - @Override 57 + @Override
58 - public byte getType() { 58 + public byte getType() {
59 - return ST_TYPE; 59 + return ST_TYPE;
60 - } 60 + }
61 - 61 +
62 - @Override 62 + @Override
63 - public int write(ChannelBuffer bb) { 63 + public int write(ChannelBuffer bb) {
64 - int iLenStartIndex = bb.writerIndex(); 64 + int iLenStartIndex = bb.writerIndex();
65 - bb.writeInt(localIpv4Addr); 65 + bb.writeInt(localIpv4Addr);
66 - bb.writeInt(remoteIpv4Addr); 66 + bb.writeInt(remoteIpv4Addr);
67 - return bb.writerIndex() - iLenStartIndex; 67 + return bb.writerIndex() - iLenStartIndex;
68 - } 68 + }
69 - 69 +
70 - /** 70 + /**
71 - * Reads the channel buffer and returns object of PcepNAIIpv4AdjacencyVer1. 71 + * Reads the channel buffer and returns object of PcepNAIIpv4AdjacencyVer1.
72 - * 72 + *
73 - * @param cb of channel buffer 73 + * @param cb of channel buffer
74 - * @return object of PcepNAIIpv4Adjacency 74 + * @return object of PcepNAIIpv4Adjacency
75 - */ 75 + */
76 - public static PcepNaiIpv4Adjacency read(ChannelBuffer cb) { 76 + public static PcepNaiIpv4Adjacency read(ChannelBuffer cb) {
77 - int localIpv4 = cb.readInt(); 77 + int localIpv4 = cb.readInt();
78 - int remoteIpv4 = cb.readInt(); 78 + int remoteIpv4 = cb.readInt();
79 - return new PcepNaiIpv4Adjacency(localIpv4, remoteIpv4); 79 + return new PcepNaiIpv4Adjacency(localIpv4, remoteIpv4);
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public int hashCode() { 83 + public int hashCode() {
84 - return Objects.hash(localIpv4Addr, remoteIpv4Addr); 84 + return Objects.hash(localIpv4Addr, remoteIpv4Addr);
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public boolean equals(Object obj) { 88 + public boolean equals(Object obj) {
89 - if (this == obj) { 89 + if (this == obj) {
90 - return true; 90 + return true;
91 - } 91 + }
92 - if (obj instanceof PcepNaiIpv4Adjacency) { 92 + if (obj instanceof PcepNaiIpv4Adjacency) {
93 - PcepNaiIpv4Adjacency other = (PcepNaiIpv4Adjacency) obj; 93 + PcepNaiIpv4Adjacency other = (PcepNaiIpv4Adjacency) obj;
94 - return Objects.equals(this.localIpv4Addr, other.localIpv4Addr) 94 + return Objects.equals(this.localIpv4Addr, other.localIpv4Addr)
95 - && Objects.equals(this.remoteIpv4Addr, other.remoteIpv4Addr); 95 + && Objects.equals(this.remoteIpv4Addr, other.remoteIpv4Addr);
96 - } 96 + }
97 - return false; 97 + return false;
98 - } 98 + }
99 - 99 +
100 - @Override 100 + @Override
101 - public String toString() { 101 + public String toString() {
102 - return MoreObjects.toStringHelper(getClass()) 102 + return MoreObjects.toStringHelper(getClass())
103 - .add("localIPv4Address", localIpv4Addr) 103 + .add("localIPv4Address", localIpv4Addr)
104 - .add("remoteIPv4Address", remoteIpv4Addr) 104 + .add("remoteIPv4Address", remoteIpv4Addr)
105 - .toString(); 105 + .toString();
106 - } 106 + }
107 -} 107 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepNai; 22 +import org.onosproject.pcepio.protocol.PcepNai;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 - 25 +
26 -/** 26 +/**
27 - * Provides Pcep Nai Ipv4 Node Id. 27 + * Provides Pcep Nai Ipv4 Node Id.
28 - */ 28 + */
29 -public class PcepNaiIpv4NodeId implements PcepNai { 29 +public class PcepNaiIpv4NodeId implements PcepNai {
30 - 30 +
31 - public static final byte ST_TYPE = 0x01; 31 + public static final byte ST_TYPE = 0x01;
32 - 32 +
33 - private final int ipv4NodeId; 33 + private final int ipv4NodeId;
34 - 34 +
35 - /** 35 + /**
36 - * Constructor to initialize ipv4NodeId. 36 + * Constructor to initialize ipv4NodeId.
37 - * 37 + *
38 - * @param value ipv4 node id 38 + * @param value ipv4 node id
39 - */ 39 + */
40 - public PcepNaiIpv4NodeId(int value) { 40 + public PcepNaiIpv4NodeId(int value) {
41 - this.ipv4NodeId = value; 41 + this.ipv4NodeId = value;
42 - } 42 + }
43 - 43 +
44 - /** 44 + /**
45 - * Returns an object of PcepNaiIpv4NodeId. 45 + * Returns an object of PcepNaiIpv4NodeId.
46 - * 46 + *
47 - * @param value ipv4 node id 47 + * @param value ipv4 node id
48 - * @return object of PcepNaiIpv4NodeId 48 + * @return object of PcepNaiIpv4NodeId
49 - */ 49 + */
50 - public static PcepNaiIpv4NodeId of(int value) { 50 + public static PcepNaiIpv4NodeId of(int value) {
51 - return new PcepNaiIpv4NodeId(value); 51 + return new PcepNaiIpv4NodeId(value);
52 - } 52 + }
53 - 53 +
54 - @Override 54 + @Override
55 - public byte getType() { 55 + public byte getType() {
56 - return ST_TYPE; 56 + return ST_TYPE;
57 - } 57 + }
58 - 58 +
59 - @Override 59 + @Override
60 - public int write(ChannelBuffer bb) { 60 + public int write(ChannelBuffer bb) {
61 - int iLenStartIndex = bb.writerIndex(); 61 + int iLenStartIndex = bb.writerIndex();
62 - bb.writeInt(ipv4NodeId); 62 + bb.writeInt(ipv4NodeId);
63 - return bb.writerIndex() - iLenStartIndex; 63 + return bb.writerIndex() - iLenStartIndex;
64 - } 64 + }
65 - 65 +
66 - /** 66 + /**
67 - * Reads from the channel buffer and returns object of PcepNAIIpv4NodeIdVer1. 67 + * Reads from the channel buffer and returns object of PcepNAIIpv4NodeIdVer1.
68 - * 68 + *
69 - * @param bb of channel buffer. 69 + * @param bb of channel buffer.
70 - * @return object of PcepNAIIpv4NodeIdVer1 70 + * @return object of PcepNAIIpv4NodeIdVer1
71 - */ 71 + */
72 - public static PcepNaiIpv4NodeId read(ChannelBuffer bb) { 72 + public static PcepNaiIpv4NodeId read(ChannelBuffer bb) {
73 - return new PcepNaiIpv4NodeId(bb.readInt()); 73 + return new PcepNaiIpv4NodeId(bb.readInt());
74 - } 74 + }
75 - 75 +
76 - @Override 76 + @Override
77 - public int hashCode() { 77 + public int hashCode() {
78 - return Objects.hash(ipv4NodeId); 78 + return Objects.hash(ipv4NodeId);
79 - } 79 + }
80 - 80 +
81 - @Override 81 + @Override
82 - public boolean equals(Object obj) { 82 + public boolean equals(Object obj) {
83 - if (this == obj) { 83 + if (this == obj) {
84 - return true; 84 + return true;
85 - } 85 + }
86 - if (obj instanceof PcepNaiIpv4NodeId) { 86 + if (obj instanceof PcepNaiIpv4NodeId) {
87 - PcepNaiIpv4NodeId other = (PcepNaiIpv4NodeId) obj; 87 + PcepNaiIpv4NodeId other = (PcepNaiIpv4NodeId) obj;
88 - return Objects.equals(this.ipv4NodeId, other.ipv4NodeId); 88 + return Objects.equals(this.ipv4NodeId, other.ipv4NodeId);
89 - } 89 + }
90 - return false; 90 + return false;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public String toString() { 94 + public String toString() {
95 - return MoreObjects.toStringHelper(getClass()).add("IPv4NodeId", ipv4NodeId).toString(); 95 + return MoreObjects.toStringHelper(getClass()).add("IPv4NodeId", ipv4NodeId).toString();
96 - } 96 + }
97 -} 97 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepNai; 22 +import org.onosproject.pcepio.protocol.PcepNai;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 - 25 +
26 -/** 26 +/**
27 - * Provides Pcep Nai Ipv6 Adjacency. 27 + * Provides Pcep Nai Ipv6 Adjacency.
28 - */ 28 + */
29 -public class PcepNaiIpv6Adjacency implements PcepNai { 29 +public class PcepNaiIpv6Adjacency implements PcepNai {
30 - 30 +
31 - public static final byte ST_TYPE = 0x04; 31 + public static final byte ST_TYPE = 0x04;
32 - public static final byte IPV6_LEN = 0x10; 32 + public static final byte IPV6_LEN = 0x10;
33 - 33 +
34 - private final byte[] localIpv6Addr; 34 + private final byte[] localIpv6Addr;
35 - private final byte[] remoteIpv6Addr; 35 + private final byte[] remoteIpv6Addr;
36 - 36 +
37 - /** 37 + /**
38 - * Constructor to initialize local ipv6 and remote ipv6. 38 + * Constructor to initialize local ipv6 and remote ipv6.
39 - * 39 + *
40 - * @param localIpv6 local ipv6 address 40 + * @param localIpv6 local ipv6 address
41 - * @param remoteIpv6 remote ipv6 address 41 + * @param remoteIpv6 remote ipv6 address
42 - */ 42 + */
43 - public PcepNaiIpv6Adjacency(byte[] localIpv6, byte[] remoteIpv6) { 43 + public PcepNaiIpv6Adjacency(byte[] localIpv6, byte[] remoteIpv6) {
44 - this.localIpv6Addr = localIpv6; 44 + this.localIpv6Addr = localIpv6;
45 - this.remoteIpv6Addr = remoteIpv6; 45 + this.remoteIpv6Addr = remoteIpv6;
46 - } 46 + }
47 - 47 +
48 - @Override 48 + @Override
49 - public byte getType() { 49 + public byte getType() {
50 - return ST_TYPE; 50 + return ST_TYPE;
51 - } 51 + }
52 - 52 +
53 - @Override 53 + @Override
54 - public int write(ChannelBuffer bb) { 54 + public int write(ChannelBuffer bb) {
55 - int iLenStartIndex = bb.writerIndex(); 55 + int iLenStartIndex = bb.writerIndex();
56 - bb.writeBytes(localIpv6Addr); 56 + bb.writeBytes(localIpv6Addr);
57 - bb.writeBytes(remoteIpv6Addr); 57 + bb.writeBytes(remoteIpv6Addr);
58 - return bb.writerIndex() - iLenStartIndex; 58 + return bb.writerIndex() - iLenStartIndex;
59 - } 59 + }
60 - 60 +
61 - /** 61 + /**
62 - * Reads from channel buffer and returns object of PcepNAIIpv6AdjacencyVer1. 62 + * Reads from channel buffer and returns object of PcepNAIIpv6AdjacencyVer1.
63 - * 63 + *
64 - * @param bb of type channel buffer 64 + * @param bb of type channel buffer
65 - * @return object of PcepNAIIpv6AdjacencyVer1 65 + * @return object of PcepNAIIpv6AdjacencyVer1
66 - */ 66 + */
67 - public static PcepNaiIpv6Adjacency read(ChannelBuffer bb) { 67 + public static PcepNaiIpv6Adjacency read(ChannelBuffer bb) {
68 - byte[] localIpv6 = new byte[IPV6_LEN]; 68 + byte[] localIpv6 = new byte[IPV6_LEN];
69 - bb.readBytes(localIpv6, 0, IPV6_LEN); 69 + bb.readBytes(localIpv6, 0, IPV6_LEN);
70 - byte[] remoteIpv6 = new byte[IPV6_LEN]; 70 + byte[] remoteIpv6 = new byte[IPV6_LEN];
71 - bb.readBytes(remoteIpv6, 0, IPV6_LEN); 71 + bb.readBytes(remoteIpv6, 0, IPV6_LEN);
72 - return new PcepNaiIpv6Adjacency(localIpv6, remoteIpv6); 72 + return new PcepNaiIpv6Adjacency(localIpv6, remoteIpv6);
73 - } 73 + }
74 - 74 +
75 - @Override 75 + @Override
76 - public int hashCode() { 76 + public int hashCode() {
77 - return Objects.hash(localIpv6Addr, remoteIpv6Addr); 77 + return Objects.hash(localIpv6Addr, remoteIpv6Addr);
78 - } 78 + }
79 - 79 +
80 - @Override 80 + @Override
81 - public boolean equals(Object obj) { 81 + public boolean equals(Object obj) {
82 - if (this == obj) { 82 + if (this == obj) {
83 - return true; 83 + return true;
84 - } 84 + }
85 - if (obj instanceof PcepNaiIpv6Adjacency) { 85 + if (obj instanceof PcepNaiIpv6Adjacency) {
86 - PcepNaiIpv6Adjacency other = (PcepNaiIpv6Adjacency) obj; 86 + PcepNaiIpv6Adjacency other = (PcepNaiIpv6Adjacency) obj;
87 - return Objects.equals(this.localIpv6Addr, other.localIpv6Addr) 87 + return Objects.equals(this.localIpv6Addr, other.localIpv6Addr)
88 - && Objects.equals(this.remoteIpv6Addr, other.remoteIpv6Addr); 88 + && Objects.equals(this.remoteIpv6Addr, other.remoteIpv6Addr);
89 - } 89 + }
90 - return false; 90 + return false;
91 - } 91 + }
92 - 92 +
93 - /** 93 + /**
94 - * Creates object of PcepNaiIpv6Adjacency with local ipv6 address and remote ipv6 address. 94 + * Creates object of PcepNaiIpv6Adjacency with local ipv6 address and remote ipv6 address.
95 - * 95 + *
96 - * @param localIpv6Addr local ipv6 address 96 + * @param localIpv6Addr local ipv6 address
97 - * @param remoteIpv6Addr remote ipv6 address 97 + * @param remoteIpv6Addr remote ipv6 address
98 - * @return object of PcepNaiIpv6Adjacency 98 + * @return object of PcepNaiIpv6Adjacency
99 - */ 99 + */
100 - 100 +
101 - public static PcepNaiIpv6Adjacency of(final byte[] localIpv6Addr, final byte[] remoteIpv6Addr) { 101 + public static PcepNaiIpv6Adjacency of(final byte[] localIpv6Addr, final byte[] remoteIpv6Addr) {
102 - return new PcepNaiIpv6Adjacency(localIpv6Addr, remoteIpv6Addr); 102 + return new PcepNaiIpv6Adjacency(localIpv6Addr, remoteIpv6Addr);
103 - } 103 + }
104 - 104 +
105 - @Override 105 + @Override
106 - public String toString() { 106 + public String toString() {
107 - return MoreObjects.toStringHelper(getClass()) 107 + return MoreObjects.toStringHelper(getClass())
108 - .add("localIPV6Address", localIpv6Addr) 108 + .add("localIPV6Address", localIpv6Addr)
109 - .add("remoteIPV6Address", remoteIpv6Addr) 109 + .add("remoteIPV6Address", remoteIpv6Addr)
110 - .toString(); 110 + .toString();
111 - } 111 + }
112 - 112 +
113 -} 113 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepNai; 22 +import org.onosproject.pcepio.protocol.PcepNai;
23 - 23 +
24 -import com.google.common.base.MoreObjects; 24 +import com.google.common.base.MoreObjects;
25 - 25 +
26 -/** 26 +/**
27 - * Provides Pcep Nai Ipv6 Node Id. 27 + * Provides Pcep Nai Ipv6 Node Id.
28 - */ 28 + */
29 -public class PcepNaiIpv6NodeId implements PcepNai { 29 +public class PcepNaiIpv6NodeId implements PcepNai {
30 - 30 +
31 - public static final byte ST_TYPE = 0x02; 31 + public static final byte ST_TYPE = 0x02;
32 - public static final byte IPV6_LEN = 0x10; 32 + public static final byte IPV6_LEN = 0x10;
33 - 33 +
34 - private final byte[] ipv6NodeId; 34 + private final byte[] ipv6NodeId;
35 - 35 +
36 - /** 36 + /**
37 - * Constructor to initialize ipv6NodeId. 37 + * Constructor to initialize ipv6NodeId.
38 - * 38 + *
39 - * @param value ipv6 node id 39 + * @param value ipv6 node id
40 - */ 40 + */
41 - public PcepNaiIpv6NodeId(byte[] value) { 41 + public PcepNaiIpv6NodeId(byte[] value) {
42 - this.ipv6NodeId = value; 42 + this.ipv6NodeId = value;
43 - } 43 + }
44 - 44 +
45 - /** 45 + /**
46 - * Return object of Pcep Nai Ipv6 Node ID. 46 + * Return object of Pcep Nai Ipv6 Node ID.
47 - * 47 + *
48 - * @param ipv6NodeId Ipv6 node ID. 48 + * @param ipv6NodeId Ipv6 node ID.
49 - * @return object of Pcep Nai Ipv6 Node ID. 49 + * @return object of Pcep Nai Ipv6 Node ID.
50 - */ 50 + */
51 - public static PcepNaiIpv6NodeId of(byte[] ipv6NodeId) { 51 + public static PcepNaiIpv6NodeId of(byte[] ipv6NodeId) {
52 - return new PcepNaiIpv6NodeId(ipv6NodeId); 52 + return new PcepNaiIpv6NodeId(ipv6NodeId);
53 - } 53 + }
54 - 54 +
55 - @Override 55 + @Override
56 - public byte getType() { 56 + public byte getType() {
57 - return ST_TYPE; 57 + return ST_TYPE;
58 - } 58 + }
59 - 59 +
60 - @Override 60 + @Override
61 - public int write(ChannelBuffer cb) { 61 + public int write(ChannelBuffer cb) {
62 - int iLenStartIndex = cb.writerIndex(); 62 + int iLenStartIndex = cb.writerIndex();
63 - cb.writeBytes(ipv6NodeId); 63 + cb.writeBytes(ipv6NodeId);
64 - return cb.writerIndex() - iLenStartIndex; 64 + return cb.writerIndex() - iLenStartIndex;
65 - } 65 + }
66 - 66 +
67 - /** 67 + /**
68 - * Reads from the channel buffer and returns object of PcepNAIIpv6NodeId. 68 + * Reads from the channel buffer and returns object of PcepNAIIpv6NodeId.
69 - * 69 + *
70 - * @param cb of type channel buffer. 70 + * @param cb of type channel buffer.
71 - * @return object of PcepNAIIpv6NodeId 71 + * @return object of PcepNAIIpv6NodeId
72 - */ 72 + */
73 - public static PcepNaiIpv6NodeId read(ChannelBuffer cb) { 73 + public static PcepNaiIpv6NodeId read(ChannelBuffer cb) {
74 - byte[] ipv6NodeId = new byte[IPV6_LEN]; 74 + byte[] ipv6NodeId = new byte[IPV6_LEN];
75 - cb.readBytes(ipv6NodeId, 0, IPV6_LEN); 75 + cb.readBytes(ipv6NodeId, 0, IPV6_LEN);
76 - return new PcepNaiIpv6NodeId(ipv6NodeId); 76 + return new PcepNaiIpv6NodeId(ipv6NodeId);
77 - } 77 + }
78 - 78 +
79 - @Override 79 + @Override
80 - public int hashCode() { 80 + public int hashCode() {
81 - return Objects.hash(ipv6NodeId); 81 + return Objects.hash(ipv6NodeId);
82 - } 82 + }
83 - 83 +
84 - @Override 84 + @Override
85 - public boolean equals(Object obj) { 85 + public boolean equals(Object obj) {
86 - if (this == obj) { 86 + if (this == obj) {
87 - return true; 87 + return true;
88 - } 88 + }
89 - if (obj instanceof PcepNaiIpv6NodeId) { 89 + if (obj instanceof PcepNaiIpv6NodeId) {
90 - PcepNaiIpv6NodeId other = (PcepNaiIpv6NodeId) obj; 90 + PcepNaiIpv6NodeId other = (PcepNaiIpv6NodeId) obj;
91 - return Objects.equals(this.ipv6NodeId, other.ipv6NodeId); 91 + return Objects.equals(this.ipv6NodeId, other.ipv6NodeId);
92 - } 92 + }
93 - return false; 93 + return false;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public String toString() { 97 + public String toString() {
98 - return MoreObjects.toStringHelper(getClass()).add("IPV6NodeID", ipv6NodeId).toString(); 98 + return MoreObjects.toStringHelper(getClass()).add("IPV6NodeID", ipv6NodeId).toString();
99 - } 99 + }
100 -} 100 +}
......
1 -package org.onosproject.pcepio.types; 1 +package org.onosproject.pcepio.types;
2 - 2 +
3 -import java.util.Objects; 3 +import java.util.Objects;
4 - 4 +
5 -import org.jboss.netty.buffer.ChannelBuffer; 5 +import org.jboss.netty.buffer.ChannelBuffer;
6 -import org.onosproject.pcepio.protocol.PcepNai; 6 +import org.onosproject.pcepio.protocol.PcepNai;
7 - 7 +
8 -import com.google.common.base.MoreObjects; 8 +import com.google.common.base.MoreObjects;
9 - 9 +
10 -/** 10 +/**
11 - * Provides Pcep Nai Unnumbered Adjacency Ipv4. 11 + * Provides Pcep Nai Unnumbered Adjacency Ipv4.
12 - */ 12 + */
13 -public class PcepNaiUnnumberedAdjacencyIpv4 implements PcepNai { 13 +public class PcepNaiUnnumberedAdjacencyIpv4 implements PcepNai {
14 - /** 14 + /**
15 - * draft-ietf-pce-segment-routing-03 section 5.3.2. 15 + * draft-ietf-pce-segment-routing-03 section 5.3.2.
16 - */ 16 + */
17 - public static final byte ST_TYPE = 0x05; 17 + public static final byte ST_TYPE = 0x05;
18 - 18 +
19 - private final int localNodeId; 19 + private final int localNodeId;
20 - private final int localInterfaceId; 20 + private final int localInterfaceId;
21 - private final int remoteNodeId; 21 + private final int remoteNodeId;
22 - private final int remoteInterfaceId; 22 + private final int remoteInterfaceId;
23 - 23 +
24 - /** 24 + /**
25 - * Constructor to initialize all the member variables. 25 + * Constructor to initialize all the member variables.
26 - * 26 + *
27 - * @param localNodeId local node id 27 + * @param localNodeId local node id
28 - * @param localInterfaceId local interface id 28 + * @param localInterfaceId local interface id
29 - * @param remoteNodeId remote node id 29 + * @param remoteNodeId remote node id
30 - * @param remoteInterfaceId remote interface id 30 + * @param remoteInterfaceId remote interface id
31 - */ 31 + */
32 - public PcepNaiUnnumberedAdjacencyIpv4(int localNodeId, int localInterfaceId, int remoteNodeId, 32 + public PcepNaiUnnumberedAdjacencyIpv4(int localNodeId, int localInterfaceId, int remoteNodeId,
33 - int remoteInterfaceId) { 33 + int remoteInterfaceId) {
34 - this.localNodeId = localNodeId; 34 + this.localNodeId = localNodeId;
35 - this.localInterfaceId = localInterfaceId; 35 + this.localInterfaceId = localInterfaceId;
36 - this.remoteNodeId = remoteNodeId; 36 + this.remoteNodeId = remoteNodeId;
37 - this.remoteInterfaceId = remoteInterfaceId; 37 + this.remoteInterfaceId = remoteInterfaceId;
38 - } 38 + }
39 - 39 +
40 - /** 40 + /**
41 - * Returns PCEP Nai Unnumbered Adjacency Ipv4 object. 41 + * Returns PCEP Nai Unnumbered Adjacency Ipv4 object.
42 - * 42 + *
43 - * @param localNodeId local node id 43 + * @param localNodeId local node id
44 - * @param localInterfaceId local interface if 44 + * @param localInterfaceId local interface if
45 - * @param remoteNodeId remote node id 45 + * @param remoteNodeId remote node id
46 - * @param remoteInterfaceId remote interface id 46 + * @param remoteInterfaceId remote interface id
47 - * @return PCEP Nai Unnumbered Adjacency Ipv4 object 47 + * @return PCEP Nai Unnumbered Adjacency Ipv4 object
48 - */ 48 + */
49 - public static PcepNaiUnnumberedAdjacencyIpv4 of(int localNodeId, int localInterfaceId, int remoteNodeId, 49 + public static PcepNaiUnnumberedAdjacencyIpv4 of(int localNodeId, int localInterfaceId, int remoteNodeId,
50 - int remoteInterfaceId) { 50 + int remoteInterfaceId) {
51 - return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId); 51 + return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
52 - } 52 + }
53 - 53 +
54 - @Override 54 + @Override
55 - public byte getType() { 55 + public byte getType() {
56 - return ST_TYPE; 56 + return ST_TYPE;
57 - } 57 + }
58 - 58 +
59 - @Override 59 + @Override
60 - public int write(ChannelBuffer bb) { 60 + public int write(ChannelBuffer bb) {
61 - int iLenStartIndex = bb.writerIndex(); 61 + int iLenStartIndex = bb.writerIndex();
62 - bb.writeInt(localNodeId); 62 + bb.writeInt(localNodeId);
63 - bb.writeInt(localInterfaceId); 63 + bb.writeInt(localInterfaceId);
64 - bb.writeInt(remoteNodeId); 64 + bb.writeInt(remoteNodeId);
65 - bb.writeInt(remoteInterfaceId); 65 + bb.writeInt(remoteInterfaceId);
66 - return bb.writerIndex() - iLenStartIndex; 66 + return bb.writerIndex() - iLenStartIndex;
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Reads from channel buffer and return object of PcepNAIUnnumberedAdjacencyIpv4. 70 + * Reads from channel buffer and return object of PcepNAIUnnumberedAdjacencyIpv4.
71 - * 71 + *
72 - * @param bb of type channel buffer 72 + * @param bb of type channel buffer
73 - * @return object of PcepNAIUnnumberedAdjacencyIpv4 73 + * @return object of PcepNAIUnnumberedAdjacencyIpv4
74 - */ 74 + */
75 - public static PcepNaiUnnumberedAdjacencyIpv4 read(ChannelBuffer bb) { 75 + public static PcepNaiUnnumberedAdjacencyIpv4 read(ChannelBuffer bb) {
76 - int localNodeId; 76 + int localNodeId;
77 - int localInterfaceId; 77 + int localInterfaceId;
78 - int remoteNodeId; 78 + int remoteNodeId;
79 - int remoteInterfaceId; 79 + int remoteInterfaceId;
80 - localNodeId = bb.readInt(); 80 + localNodeId = bb.readInt();
81 - localInterfaceId = bb.readInt(); 81 + localInterfaceId = bb.readInt();
82 - remoteNodeId = bb.readInt(); 82 + remoteNodeId = bb.readInt();
83 - remoteInterfaceId = bb.readInt(); 83 + remoteInterfaceId = bb.readInt();
84 - return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId); 84 + return new PcepNaiUnnumberedAdjacencyIpv4(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public int hashCode() { 88 + public int hashCode() {
89 - return Objects.hash(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId); 89 + return Objects.hash(localNodeId, localInterfaceId, remoteNodeId, remoteInterfaceId);
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public boolean equals(Object obj) { 93 + public boolean equals(Object obj) {
94 - if (this == obj) { 94 + if (this == obj) {
95 - return true; 95 + return true;
96 - } 96 + }
97 - if (obj instanceof PcepNaiUnnumberedAdjacencyIpv4) { 97 + if (obj instanceof PcepNaiUnnumberedAdjacencyIpv4) {
98 - PcepNaiUnnumberedAdjacencyIpv4 other = (PcepNaiUnnumberedAdjacencyIpv4) obj; 98 + PcepNaiUnnumberedAdjacencyIpv4 other = (PcepNaiUnnumberedAdjacencyIpv4) obj;
99 - return Objects.equals(this.localNodeId, other.localNodeId) 99 + return Objects.equals(this.localNodeId, other.localNodeId)
100 - && Objects.equals(this.localInterfaceId, other.localInterfaceId) 100 + && Objects.equals(this.localInterfaceId, other.localInterfaceId)
101 - && Objects.equals(this.remoteNodeId, other.remoteNodeId) 101 + && Objects.equals(this.remoteNodeId, other.remoteNodeId)
102 - && Objects.equals(this.remoteInterfaceId, other.remoteInterfaceId); 102 + && Objects.equals(this.remoteInterfaceId, other.remoteInterfaceId);
103 - } 103 + }
104 - return false; 104 + return false;
105 - } 105 + }
106 - 106 +
107 - @Override 107 + @Override
108 - public String toString() { 108 + public String toString() {
109 - return MoreObjects.toStringHelper(getClass()) 109 + return MoreObjects.toStringHelper(getClass())
110 - .add("localNodeId", localNodeId) 110 + .add("localNodeId", localNodeId)
111 - .add("localInterfaceId", localInterfaceId) 111 + .add("localInterfaceId", localInterfaceId)
112 - .add("remoteNodeId", remoteNodeId) 112 + .add("remoteNodeId", remoteNodeId)
113 - .add("remoteInterfaceId:", remoteInterfaceId) 113 + .add("remoteInterfaceId:", remoteInterfaceId)
114 - .toString(); 114 + .toString();
115 - } 115 + }
116 -} 116 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import org.jboss.netty.buffer.ChannelBuffer; 18 +import org.jboss.netty.buffer.ChannelBuffer;
19 - 19 +
20 -/** 20 +/**
21 - * Abstraction of an entity which provides PCPE RSVP error spec. 21 + * Abstraction of an entity which provides PCPE RSVP error spec.
22 - */ 22 + */
23 -public interface PcepRsvpErrorSpec extends PcepValueType { 23 +public interface PcepRsvpErrorSpec extends PcepValueType {
24 - 24 +
25 - /** 25 + /**
26 - * To write the object information to channelBuffer. 26 + * To write the object information to channelBuffer.
27 - * 27 + *
28 - * @param cb of type channel buffer 28 + * @param cb of type channel buffer
29 - */ 29 + */
30 - @Override 30 + @Override
31 - int write(ChannelBuffer cb); 31 + int write(ChannelBuffer cb);
32 - 32 +
33 - /** 33 + /**
34 - * Returns class number. 34 + * Returns class number.
35 - * 35 + *
36 - * @return class number 36 + * @return class number
37 - */ 37 + */
38 - byte getClassNum(); 38 + byte getClassNum();
39 - 39 +
40 - /** 40 + /**
41 - * Returns class type. 41 + * Returns class type.
42 - * 42 + *
43 - * @return class type 43 + * @return class type
44 - */ 44 + */
45 - byte getClassType(); 45 + byte getClassType();
46 -} 46 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import org.jboss.netty.buffer.ChannelBuffer; 18 +import org.jboss.netty.buffer.ChannelBuffer;
19 -import org.onosproject.pcepio.protocol.PcepVersion; 19 +import org.onosproject.pcepio.protocol.PcepVersion;
20 - 20 +
21 -import com.google.common.base.MoreObjects; 21 +import com.google.common.base.MoreObjects;
22 - 22 +
23 -/** 23 +/**
24 - * Provides Pcep Rsvp Ipv4 Error Spec. 24 + * Provides Pcep Rsvp Ipv4 Error Spec.
25 - */ 25 + */
26 -public class PcepRsvpIpv4ErrorSpec implements PcepRsvpErrorSpec { 26 +public class PcepRsvpIpv4ErrorSpec implements PcepRsvpErrorSpec {
27 - 27 +
28 - /* 28 + /*
29 - RSVP error spec object header. 29 + RSVP error spec object header.
30 - 0 1 2 3 30 + 0 1 2 3
31 - +-------------+-------------+-------------+-------------+ 31 + +-------------+-------------+-------------+-------------+
32 - | Length (bytes) | Class-Num | C-Type | 32 + | Length (bytes) | Class-Num | C-Type |
33 - +-------------+-------------+-------------+-------------+ 33 + +-------------+-------------+-------------+-------------+
34 - | | 34 + | |
35 - // (Object contents) // 35 + // (Object contents) //
36 - | | 36 + | |
37 - +-------------+-------------+-------------+-------------+ 37 + +-------------+-------------+-------------+-------------+
38 - 38 +
39 - Ref : ERROR_SPEC @ RFC2205 39 + Ref : ERROR_SPEC @ RFC2205
40 - 40 +
41 - IPv4 ERROR_SPEC object: Class = 6, C-Type = 1 41 + IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
42 - +-------------+-------------+-------------+-------------+ 42 + +-------------+-------------+-------------+-------------+
43 - | IPv4 Error Node Address (4 bytes) | 43 + | IPv4 Error Node Address (4 bytes) |
44 - +-------------+-------------+-------------+-------------+ 44 + +-------------+-------------+-------------+-------------+
45 - | Flags | Error Code | Error Value | 45 + | Flags | Error Code | Error Value |
46 - +-------------+-------------+-------------+-------------+ 46 + +-------------+-------------+-------------+-------------+
47 - 47 +
48 - */ 48 + */
49 - 49 +
50 - PcepRsvpSpecObjHeader objHeader; 50 + PcepRsvpSpecObjHeader objHeader;
51 - public static final byte CLASS_NUM = 0x06; 51 + public static final byte CLASS_NUM = 0x06;
52 - public static final byte CLASS_TYPE = 0x01; 52 + public static final byte CLASS_TYPE = 0x01;
53 - public static final byte CLASS_LENGTH = 0x0c; 53 + public static final byte CLASS_LENGTH = 0x0c;
54 - private int ipv4Addr; 54 + private int ipv4Addr;
55 - private byte flags; 55 + private byte flags;
56 - private byte errCode; 56 + private byte errCode;
57 - private short errValue; 57 + private short errValue;
58 - 58 +
59 - /** 59 + /**
60 - * Constructor to initialize obj header, ipv4 addr, flags, err code and err value. 60 + * Constructor to initialize obj header, ipv4 addr, flags, err code and err value.
61 - * 61 + *
62 - * @param objHeader rsvp ipv4 error spec object header 62 + * @param objHeader rsvp ipv4 error spec object header
63 - * @param ipv4Addr ipv4 address 63 + * @param ipv4Addr ipv4 address
64 - * @param flags flags value 64 + * @param flags flags value
65 - * @param errCode error code value 65 + * @param errCode error code value
66 - * @param errValue error value 66 + * @param errValue error value
67 - */ 67 + */
68 - public PcepRsvpIpv4ErrorSpec(PcepRsvpSpecObjHeader objHeader, int ipv4Addr, byte flags, byte errCode, 68 + public PcepRsvpIpv4ErrorSpec(PcepRsvpSpecObjHeader objHeader, int ipv4Addr, byte flags, byte errCode,
69 - short errValue) { 69 + short errValue) {
70 - this.objHeader = objHeader; 70 + this.objHeader = objHeader;
71 - this.ipv4Addr = ipv4Addr; 71 + this.ipv4Addr = ipv4Addr;
72 - this.flags = flags; 72 + this.flags = flags;
73 - this.errCode = errCode; 73 + this.errCode = errCode;
74 - this.errValue = errValue; 74 + this.errValue = errValue;
75 - } 75 + }
76 - 76 +
77 - /** 77 + /**
78 - * Constructor to initialize ipv4 address, flags, err code and err value. 78 + * Constructor to initialize ipv4 address, flags, err code and err value.
79 - * 79 + *
80 - * @param ipv4Addr ipv4 address 80 + * @param ipv4Addr ipv4 address
81 - * @param flags flags value 81 + * @param flags flags value
82 - * @param errCode error code 82 + * @param errCode error code
83 - * @param errValue error value 83 + * @param errValue error value
84 - */ 84 + */
85 - public PcepRsvpIpv4ErrorSpec(int ipv4Addr, byte flags, byte errCode, short errValue) { 85 + public PcepRsvpIpv4ErrorSpec(int ipv4Addr, byte flags, byte errCode, short errValue) {
86 - this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE); 86 + this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
87 - this.ipv4Addr = ipv4Addr; 87 + this.ipv4Addr = ipv4Addr;
88 - this.flags = flags; 88 + this.flags = flags;
89 - this.errCode = errCode; 89 + this.errCode = errCode;
90 - this.errValue = errValue; 90 + this.errValue = errValue;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public int write(ChannelBuffer cb) { 94 + public int write(ChannelBuffer cb) {
95 - int objLenIndex = objHeader.write(cb); 95 + int objLenIndex = objHeader.write(cb);
96 - cb.writeInt(ipv4Addr); 96 + cb.writeInt(ipv4Addr);
97 - cb.writeByte(flags); 97 + cb.writeByte(flags);
98 - cb.writeByte(errCode); 98 + cb.writeByte(errCode);
99 - cb.writeShort(errValue); 99 + cb.writeShort(errValue);
100 - short objLen = (short) (cb.writerIndex() - objLenIndex); 100 + short objLen = (short) (cb.writerIndex() - objLenIndex);
101 - cb.setShort(objLenIndex, objLen); 101 + cb.setShort(objLenIndex, objLen);
102 - return objLen; 102 + return objLen;
103 - } 103 + }
104 - 104 +
105 - /** 105 + /**
106 - * Reads PCPE RSVP error spec from channel buffer and returns PCEP rsvp IPv4 error spec object. 106 + * Reads PCPE RSVP error spec from channel buffer and returns PCEP rsvp IPv4 error spec object.
107 - * 107 + *
108 - * @param cb channel buffer 108 + * @param cb channel buffer
109 - * @return PCEP rsvp IPv4 error spec object 109 + * @return PCEP rsvp IPv4 error spec object
110 - */ 110 + */
111 - public static PcepRsvpErrorSpec read(ChannelBuffer cb) { 111 + public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
112 - PcepRsvpSpecObjHeader objHeader; 112 + PcepRsvpSpecObjHeader objHeader;
113 - int ipv4Addr; 113 + int ipv4Addr;
114 - byte flags; 114 + byte flags;
115 - byte errCode; 115 + byte errCode;
116 - short errValue; 116 + short errValue;
117 - 117 +
118 - objHeader = PcepRsvpSpecObjHeader.read(cb); 118 + objHeader = PcepRsvpSpecObjHeader.read(cb);
119 - ipv4Addr = cb.readInt(); 119 + ipv4Addr = cb.readInt();
120 - flags = cb.readByte(); 120 + flags = cb.readByte();
121 - errCode = cb.readByte(); 121 + errCode = cb.readByte();
122 - errValue = cb.readShort(); 122 + errValue = cb.readShort();
123 - return new PcepRsvpIpv4ErrorSpec(objHeader, ipv4Addr, flags, errCode, errValue); 123 + return new PcepRsvpIpv4ErrorSpec(objHeader, ipv4Addr, flags, errCode, errValue);
124 - } 124 + }
125 - 125 +
126 - @Override 126 + @Override
127 - public PcepVersion getVersion() { 127 + public PcepVersion getVersion() {
128 - return PcepVersion.PCEP_1; 128 + return PcepVersion.PCEP_1;
129 - } 129 + }
130 - 130 +
131 - @Override 131 + @Override
132 - public short getType() { 132 + public short getType() {
133 - return StatefulRsvpErrorSpecTlv.TYPE; 133 + return StatefulRsvpErrorSpecTlv.TYPE;
134 - } 134 + }
135 - 135 +
136 - @Override 136 + @Override
137 - public short getLength() { 137 + public short getLength() {
138 - return CLASS_LENGTH; 138 + return CLASS_LENGTH;
139 - } 139 + }
140 - 140 +
141 - @Override 141 + @Override
142 - public byte getClassNum() { 142 + public byte getClassNum() {
143 - return CLASS_NUM; 143 + return CLASS_NUM;
144 - } 144 + }
145 - 145 +
146 - @Override 146 + @Override
147 - public byte getClassType() { 147 + public byte getClassType() {
148 - return CLASS_TYPE; 148 + return CLASS_TYPE;
149 - } 149 + }
150 - 150 +
151 - @Override 151 + @Override
152 - public String toString() { 152 + public String toString() {
153 - return MoreObjects.toStringHelper(getClass()) 153 + return MoreObjects.toStringHelper(getClass())
154 - .add("IPv4Address:", ipv4Addr) 154 + .add("IPv4Address:", ipv4Addr)
155 - .add("flags:", flags) 155 + .add("flags:", flags)
156 - .add("errorCode:", errCode) 156 + .add("errorCode:", errCode)
157 - .add("errorValue:", errValue) 157 + .add("errorValue:", errValue)
158 - .toString(); 158 + .toString();
159 - } 159 + }
160 -} 160 +}
......
1 -package org.onosproject.pcepio.types; 1 +package org.onosproject.pcepio.types;
2 - 2 +
3 -import org.jboss.netty.buffer.ChannelBuffer; 3 +import org.jboss.netty.buffer.ChannelBuffer;
4 -import org.onosproject.pcepio.protocol.PcepVersion; 4 +import org.onosproject.pcepio.protocol.PcepVersion;
5 - 5 +
6 -import com.google.common.base.MoreObjects; 6 +import com.google.common.base.MoreObjects;
7 - 7 +
8 -/** 8 +/**
9 - * Provides Pcep Rsvp Ipv6 Error Spec. 9 + * Provides Pcep Rsvp Ipv6 Error Spec.
10 - */ 10 + */
11 -public class PcepRsvpIpv6ErrorSpec implements PcepRsvpErrorSpec { 11 +public class PcepRsvpIpv6ErrorSpec implements PcepRsvpErrorSpec {
12 - 12 +
13 - /* 13 + /*
14 - 0 1 2 3 14 + 0 1 2 3
15 - +-------------+-------------+-------------+-------------+ 15 + +-------------+-------------+-------------+-------------+
16 - | Length (bytes) | Class-Num | C-Type | 16 + | Length (bytes) | Class-Num | C-Type |
17 - +-------------+-------------+-------------+-------------+ 17 + +-------------+-------------+-------------+-------------+
18 - | | 18 + | |
19 - // (Object contents) // 19 + // (Object contents) //
20 - | | 20 + | |
21 - +-------------+-------------+-------------+-------------+ 21 + +-------------+-------------+-------------+-------------+
22 - 22 +
23 - Ref : ERROR_SPEC @ RFC2205 23 + Ref : ERROR_SPEC @ RFC2205
24 - 24 +
25 - IPv6 ERROR_SPEC object: Class = 6, C-Type = 2 25 + IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
26 - +-------------+-------------+-------------+-------------+ 26 + +-------------+-------------+-------------+-------------+
27 - | | 27 + | |
28 - + + 28 + + +
29 - | | 29 + | |
30 - + IPv6 Error Node Address (16 bytes) + 30 + + IPv6 Error Node Address (16 bytes) +
31 - | | 31 + | |
32 - + + 32 + + +
33 - | | 33 + | |
34 - +-------------+-------------+-------------+-------------+ 34 + +-------------+-------------+-------------+-------------+
35 - | Flags | Error Code | Error Value | 35 + | Flags | Error Code | Error Value |
36 - +-------------+-------------+-------------+-------------+ */ 36 + +-------------+-------------+-------------+-------------+ */
37 - 37 +
38 - PcepRsvpSpecObjHeader objHeader; 38 + PcepRsvpSpecObjHeader objHeader;
39 - public static final byte CLASS_NUM = 0x06; 39 + public static final byte CLASS_NUM = 0x06;
40 - public static final byte CLASS_TYPE = 0x02; 40 + public static final byte CLASS_TYPE = 0x02;
41 - public static final byte CLASS_LENGTH = 0x18; 41 + public static final byte CLASS_LENGTH = 0x18;
42 - public static final byte IPV6_LEN = 0x10; 42 + public static final byte IPV6_LEN = 0x10;
43 - 43 +
44 - private byte[] ipv6Addr; 44 + private byte[] ipv6Addr;
45 - private byte flags; 45 + private byte flags;
46 - private byte errCode; 46 + private byte errCode;
47 - private short errValue; 47 + private short errValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize obj header, ipv6 addr, flags, err code and err value. 50 + * Constructor to initialize obj header, ipv6 addr, flags, err code and err value.
51 - * 51 + *
52 - * @param objHeader rsvp ipv6 error spec object header 52 + * @param objHeader rsvp ipv6 error spec object header
53 - * @param ipv6Addr ipv6 address 53 + * @param ipv6Addr ipv6 address
54 - * @param flags flags value 54 + * @param flags flags value
55 - * @param errCode error code 55 + * @param errCode error code
56 - * @param errValue error value 56 + * @param errValue error value
57 - */ 57 + */
58 - public PcepRsvpIpv6ErrorSpec(PcepRsvpSpecObjHeader objHeader, byte[] ipv6Addr, byte flags, byte errCode, 58 + public PcepRsvpIpv6ErrorSpec(PcepRsvpSpecObjHeader objHeader, byte[] ipv6Addr, byte flags, byte errCode,
59 - short errValue) { 59 + short errValue) {
60 - this.objHeader = objHeader; 60 + this.objHeader = objHeader;
61 - this.ipv6Addr = ipv6Addr; 61 + this.ipv6Addr = ipv6Addr;
62 - this.flags = flags; 62 + this.flags = flags;
63 - this.errCode = errCode; 63 + this.errCode = errCode;
64 - this.errValue = errValue; 64 + this.errValue = errValue;
65 - } 65 + }
66 - 66 +
67 - /** 67 + /**
68 - * Constructor to initialize ipv6 addr, flags, err code and err value. 68 + * Constructor to initialize ipv6 addr, flags, err code and err value.
69 - * 69 + *
70 - * @param ipv6Addr ipv6 address 70 + * @param ipv6Addr ipv6 address
71 - * @param flags flags value 71 + * @param flags flags value
72 - * @param errCode error code 72 + * @param errCode error code
73 - * @param errValue error value 73 + * @param errValue error value
74 - */ 74 + */
75 - public PcepRsvpIpv6ErrorSpec(byte[] ipv6Addr, byte flags, byte errCode, short errValue) { 75 + public PcepRsvpIpv6ErrorSpec(byte[] ipv6Addr, byte flags, byte errCode, short errValue) {
76 - this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE); 76 + this.objHeader = new PcepRsvpSpecObjHeader(CLASS_LENGTH, CLASS_NUM, CLASS_TYPE);
77 - this.ipv6Addr = ipv6Addr; 77 + this.ipv6Addr = ipv6Addr;
78 - this.flags = flags; 78 + this.flags = flags;
79 - this.errCode = errCode; 79 + this.errCode = errCode;
80 - this.errValue = errValue; 80 + this.errValue = errValue;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public int write(ChannelBuffer cb) { 84 + public int write(ChannelBuffer cb) {
85 - int objLenIndex = objHeader.write(cb); 85 + int objLenIndex = objHeader.write(cb);
86 - cb.writeBytes(ipv6Addr); 86 + cb.writeBytes(ipv6Addr);
87 - cb.writeByte(flags); 87 + cb.writeByte(flags);
88 - cb.writeByte(errCode); 88 + cb.writeByte(errCode);
89 - cb.writeShort(errValue); 89 + cb.writeShort(errValue);
90 - short objLen = (short) (cb.writerIndex() - objLenIndex); 90 + short objLen = (short) (cb.writerIndex() - objLenIndex);
91 - cb.setShort(objLenIndex, objLen); 91 + cb.setShort(objLenIndex, objLen);
92 - return objLen; 92 + return objLen;
93 - } 93 + }
94 - 94 +
95 - /** 95 + /**
96 - * Returns PCEP rsvp IPv6 error spce object. 96 + * Returns PCEP rsvp IPv6 error spce object.
97 - * 97 + *
98 - * @param cb channel buffer 98 + * @param cb channel buffer
99 - * @return PCEP rsvp IPv6 error spce object 99 + * @return PCEP rsvp IPv6 error spce object
100 - */ 100 + */
101 - public static PcepRsvpErrorSpec read(ChannelBuffer cb) { 101 + public static PcepRsvpErrorSpec read(ChannelBuffer cb) {
102 - PcepRsvpSpecObjHeader objHeader; 102 + PcepRsvpSpecObjHeader objHeader;
103 - byte[] ipv6Addr = new byte[IPV6_LEN]; 103 + byte[] ipv6Addr = new byte[IPV6_LEN];
104 - byte flags; 104 + byte flags;
105 - byte errCode; 105 + byte errCode;
106 - short errValue; 106 + short errValue;
107 - 107 +
108 - objHeader = PcepRsvpSpecObjHeader.read(cb); 108 + objHeader = PcepRsvpSpecObjHeader.read(cb);
109 - cb.readBytes(ipv6Addr, 0, IPV6_LEN); 109 + cb.readBytes(ipv6Addr, 0, IPV6_LEN);
110 - flags = cb.readByte(); 110 + flags = cb.readByte();
111 - errCode = cb.readByte(); 111 + errCode = cb.readByte();
112 - errValue = cb.readShort(); 112 + errValue = cb.readShort();
113 - return new PcepRsvpIpv6ErrorSpec(objHeader, ipv6Addr, flags, errCode, errValue); 113 + return new PcepRsvpIpv6ErrorSpec(objHeader, ipv6Addr, flags, errCode, errValue);
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public PcepVersion getVersion() { 117 + public PcepVersion getVersion() {
118 - return PcepVersion.PCEP_1; 118 + return PcepVersion.PCEP_1;
119 - } 119 + }
120 - 120 +
121 - @Override 121 + @Override
122 - public short getType() { 122 + public short getType() {
123 - return StatefulRsvpErrorSpecTlv.TYPE; 123 + return StatefulRsvpErrorSpecTlv.TYPE;
124 - } 124 + }
125 - 125 +
126 - @Override 126 + @Override
127 - public short getLength() { 127 + public short getLength() {
128 - return CLASS_LENGTH; 128 + return CLASS_LENGTH;
129 - } 129 + }
130 - 130 +
131 - @Override 131 + @Override
132 - public byte getClassNum() { 132 + public byte getClassNum() {
133 - return CLASS_NUM; 133 + return CLASS_NUM;
134 - } 134 + }
135 - 135 +
136 - @Override 136 + @Override
137 - public byte getClassType() { 137 + public byte getClassType() {
138 - return CLASS_TYPE; 138 + return CLASS_TYPE;
139 - } 139 + }
140 - 140 +
141 - @Override 141 + @Override
142 - public String toString() { 142 + public String toString() {
143 - return MoreObjects.toStringHelper(getClass()) 143 + return MoreObjects.toStringHelper(getClass())
144 - .add("IPv6Address:", ipv6Addr) 144 + .add("IPv6Address:", ipv6Addr)
145 - .add("flags:", flags) 145 + .add("flags:", flags)
146 - .add("errorCode:", errCode) 146 + .add("errorCode:", errCode)
147 - .add("errorValue:", errValue) 147 + .add("errorValue:", errValue)
148 - .toString(); 148 + .toString();
149 - } 149 + }
150 -} 150 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.LinkedList; 18 +import java.util.LinkedList;
19 -import java.util.ListIterator; 19 +import java.util.ListIterator;
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.exceptions.PcepParseException;
23 -import org.onosproject.pcepio.protocol.PcepVersion; 23 +import org.onosproject.pcepio.protocol.PcepVersion;
24 - 24 +
25 -import com.google.common.base.MoreObjects; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides Pcep Rsvp User Error Spec. 28 + * Provides Pcep Rsvp User Error Spec.
29 - */ 29 + */
30 -public class PcepRsvpUserErrorSpec implements PcepRsvpErrorSpec { 30 +public class PcepRsvpUserErrorSpec implements PcepRsvpErrorSpec {
31 - 31 +
32 - /* 32 + /*
33 - RSVP error spec object header. 33 + RSVP error spec object header.
34 - 0 1 2 3 34 + 0 1 2 3
35 - +-------------+-------------+-------------+-------------+ 35 + +-------------+-------------+-------------+-------------+
36 - | Length (bytes) | Class-Num | C-Type | 36 + | Length (bytes) | Class-Num | C-Type |
37 - +-------------+-------------+-------------+-------------+ 37 + +-------------+-------------+-------------+-------------+
38 - | | 38 + | |
39 - // (Object contents) // 39 + // (Object contents) //
40 - | | 40 + | |
41 - +-------------+-------------+-------------+-------------+ 41 + +-------------+-------------+-------------+-------------+
42 - 42 +
43 - Ref : USER_ERROR_SPEC @ RFC5284. 43 + Ref : USER_ERROR_SPEC @ RFC5284.
44 - USER_ERROR_SPEC object: Class = 194, C-Type = 1 44 + USER_ERROR_SPEC object: Class = 194, C-Type = 1
45 - 45 +
46 - 0 1 2 3 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 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 - +---------------+---------------+---------------+---------------+ 48 + +---------------+---------------+---------------+---------------+
49 - | Enterprise Number | 49 + | Enterprise Number |
50 - +---------------+---------------+---------------+---------------+ 50 + +---------------+---------------+---------------+---------------+
51 - | Sub Org | Err Desc Len | User Error Value | 51 + | Sub Org | Err Desc Len | User Error Value |
52 - +---------------+---------------+---------------+---------------+ 52 + +---------------+---------------+---------------+---------------+
53 - | | 53 + | |
54 - ~ Error Description ~ 54 + ~ Error Description ~
55 - | | 55 + | |
56 - +---------------+---------------+---------------+---------------+ 56 + +---------------+---------------+---------------+---------------+
57 - | | 57 + | |
58 - ~ User-Defined Subobjects ~ 58 + ~ User-Defined Subobjects ~
59 - | | 59 + | |
60 - +---------------+---------------+---------------+---------------+ 60 + +---------------+---------------+---------------+---------------+
61 - */ 61 + */
62 - 62 +
63 - public static final byte CLASS_NUM = (byte) 0xc2; 63 + public static final byte CLASS_NUM = (byte) 0xc2;
64 - public static final byte CLASS_TYPE = 0x01; 64 + public static final byte CLASS_TYPE = 0x01;
65 - 65 +
66 - private PcepRsvpSpecObjHeader objHeader; 66 + private PcepRsvpSpecObjHeader objHeader;
67 - private int enterpriseNum; 67 + private int enterpriseNum;
68 - private byte subOrg; 68 + private byte subOrg;
69 - private byte errDescLen; 69 + private byte errDescLen;
70 - private short userErrorValue; 70 + private short userErrorValue;
71 - private byte[] errDesc; 71 + private byte[] errDesc;
72 - private LinkedList<PcepValueType> llRsvpUserSpecSubObj; 72 + private LinkedList<PcepValueType> llRsvpUserSpecSubObj;
73 - 73 +
74 - /** 74 + /**
75 - * Default constructor. 75 + * Default constructor.
76 - * 76 + *
77 - * @param objHeader pcep rsvp spec object header 77 + * @param objHeader pcep rsvp spec object header
78 - * @param enterpriseNum enterprise number 78 + * @param enterpriseNum enterprise number
79 - * @param subOrg organization identifier value 79 + * @param subOrg organization identifier value
80 - * @param errDescLen error description length 80 + * @param errDescLen error description length
81 - * @param userErrorValue user error value 81 + * @param userErrorValue user error value
82 - * @param errDesc error description 82 + * @param errDesc error description
83 - * @param llRsvpUserSpecSubObj list of subobjects 83 + * @param llRsvpUserSpecSubObj list of subobjects
84 - */ 84 + */
85 - public PcepRsvpUserErrorSpec(PcepRsvpSpecObjHeader objHeader, int enterpriseNum, byte subOrg, byte errDescLen, 85 + public PcepRsvpUserErrorSpec(PcepRsvpSpecObjHeader objHeader, int enterpriseNum, byte subOrg, byte errDescLen,
86 - short userErrorValue, byte[] errDesc, LinkedList<PcepValueType> llRsvpUserSpecSubObj) { 86 + short userErrorValue, byte[] errDesc, LinkedList<PcepValueType> llRsvpUserSpecSubObj) {
87 - this.objHeader = objHeader; 87 + this.objHeader = objHeader;
88 - this.enterpriseNum = enterpriseNum; 88 + this.enterpriseNum = enterpriseNum;
89 - this.subOrg = subOrg; 89 + this.subOrg = subOrg;
90 - this.errDescLen = errDescLen; 90 + this.errDescLen = errDescLen;
91 - this.userErrorValue = userErrorValue; 91 + this.userErrorValue = userErrorValue;
92 - this.errDesc = errDesc; 92 + this.errDesc = errDesc;
93 - this.llRsvpUserSpecSubObj = llRsvpUserSpecSubObj; 93 + this.llRsvpUserSpecSubObj = llRsvpUserSpecSubObj;
94 - } 94 + }
95 - 95 +
96 - @Override 96 + @Override
97 - public int write(ChannelBuffer cb) { 97 + public int write(ChannelBuffer cb) {
98 - int objLenIndex = objHeader.write(cb); 98 + int objLenIndex = objHeader.write(cb);
99 - cb.writeInt(enterpriseNum); 99 + cb.writeInt(enterpriseNum);
100 - cb.writeByte(subOrg); 100 + cb.writeByte(subOrg);
101 - cb.writeByte(errDescLen); 101 + cb.writeByte(errDescLen);
102 - cb.writeShort(userErrorValue); 102 + cb.writeShort(userErrorValue);
103 - cb.writeBytes(errDesc); 103 + cb.writeBytes(errDesc);
104 - 104 +
105 - if (null != llRsvpUserSpecSubObj) { 105 + if (null != llRsvpUserSpecSubObj) {
106 - 106 +
107 - ListIterator<PcepValueType> listIterator = llRsvpUserSpecSubObj.listIterator(); 107 + ListIterator<PcepValueType> listIterator = llRsvpUserSpecSubObj.listIterator();
108 - 108 +
109 - while (listIterator.hasNext()) { 109 + while (listIterator.hasNext()) {
110 - PcepValueType tlv = listIterator.next(); 110 + PcepValueType tlv = listIterator.next();
111 - if (null == tlv) { 111 + if (null == tlv) {
112 - continue; 112 + continue;
113 - } 113 + }
114 - tlv.write(cb); 114 + tlv.write(cb);
115 - // need to take care of padding 115 + // need to take care of padding
116 - int pad = tlv.getLength() % 4; 116 + int pad = tlv.getLength() % 4;
117 - if (0 != pad) { 117 + if (0 != pad) {
118 - pad = 4 - pad; 118 + pad = 4 - pad;
119 - for (int i = 0; i < pad; ++i) { 119 + for (int i = 0; i < pad; ++i) {
120 - cb.writeByte((byte) 0); 120 + cb.writeByte((byte) 0);
121 - } 121 + }
122 - } 122 + }
123 - } 123 + }
124 - } 124 + }
125 - short objLen = (short) (cb.writerIndex() - objLenIndex); 125 + short objLen = (short) (cb.writerIndex() - objLenIndex);
126 - cb.setShort(objLenIndex, objLen); 126 + cb.setShort(objLenIndex, objLen);
127 - return objLen; 127 + return objLen;
128 - } 128 + }
129 - 129 +
130 - /** 130 + /**
131 - * Reads the channel buffer and returns object of PcepRsvpErrorSpec. 131 + * Reads the channel buffer and returns object of PcepRsvpErrorSpec.
132 - * 132 + *
133 - * @param cb of type channel buffer 133 + * @param cb of type channel buffer
134 - * @return object of PcepRsvpErrorSpec 134 + * @return object of PcepRsvpErrorSpec
135 - * @throws PcepParseException when expected object is not received 135 + * @throws PcepParseException when expected object is not received
136 - */ 136 + */
137 - public static PcepRsvpErrorSpec read(ChannelBuffer cb) throws PcepParseException { 137 + public static PcepRsvpErrorSpec read(ChannelBuffer cb) throws PcepParseException {
138 - PcepRsvpSpecObjHeader objHeader; 138 + PcepRsvpSpecObjHeader objHeader;
139 - int enterpriseNum; 139 + int enterpriseNum;
140 - byte subOrg; 140 + byte subOrg;
141 - byte errDescLen; 141 + byte errDescLen;
142 - short userErrorValue; 142 + short userErrorValue;
143 - byte[] errDesc; 143 + byte[] errDesc;
144 - LinkedList<PcepValueType> llRsvpUserSpecSubObj = null; 144 + LinkedList<PcepValueType> llRsvpUserSpecSubObj = null;
145 - 145 +
146 - objHeader = PcepRsvpSpecObjHeader.read(cb); 146 + objHeader = PcepRsvpSpecObjHeader.read(cb);
147 - 147 +
148 - if (CLASS_NUM != objHeader.getObjClassNum() || CLASS_TYPE != objHeader.getObjClassType()) { 148 + if (CLASS_NUM != objHeader.getObjClassNum() || CLASS_TYPE != objHeader.getObjClassType()) {
149 - throw new PcepParseException("Expected PcepRsvpUserErrorSpec object."); 149 + throw new PcepParseException("Expected PcepRsvpUserErrorSpec object.");
150 - } 150 + }
151 - enterpriseNum = cb.readInt(); 151 + enterpriseNum = cb.readInt();
152 - subOrg = cb.readByte(); 152 + subOrg = cb.readByte();
153 - errDescLen = cb.readByte(); 153 + errDescLen = cb.readByte();
154 - userErrorValue = cb.readShort(); 154 + userErrorValue = cb.readShort();
155 - errDesc = new byte[errDescLen]; 155 + errDesc = new byte[errDescLen];
156 - cb.readBytes(errDesc, 0, errDescLen); 156 + cb.readBytes(errDesc, 0, errDescLen);
157 - 157 +
158 - llRsvpUserSpecSubObj = parseErrSpecSubObj(cb); 158 + llRsvpUserSpecSubObj = parseErrSpecSubObj(cb);
159 - 159 +
160 - return new PcepRsvpUserErrorSpec(objHeader, enterpriseNum, subOrg, errDescLen, userErrorValue, errDesc, 160 + return new PcepRsvpUserErrorSpec(objHeader, enterpriseNum, subOrg, errDescLen, userErrorValue, errDesc,
161 - llRsvpUserSpecSubObj); 161 + llRsvpUserSpecSubObj);
162 - } 162 + }
163 - 163 +
164 - private static LinkedList<PcepValueType> parseErrSpecSubObj(ChannelBuffer cb) throws PcepParseException { 164 + private static LinkedList<PcepValueType> parseErrSpecSubObj(ChannelBuffer cb) throws PcepParseException {
165 - LinkedList<PcepValueType> llRsvpUserSpecSubObj = new LinkedList<PcepValueType>(); 165 + LinkedList<PcepValueType> llRsvpUserSpecSubObj = new LinkedList<PcepValueType>();
166 - while (0 < cb.readableBytes()) { 166 + while (0 < cb.readableBytes()) {
167 - PcepValueType tlv = null; 167 + PcepValueType tlv = null;
168 - short hType = cb.readShort(); 168 + short hType = cb.readShort();
169 - int iValue = 0; 169 + int iValue = 0;
170 - //short hLength = cb.readShort(); 170 + //short hLength = cb.readShort();
171 - switch (hType) { 171 + switch (hType) {
172 - case AutonomousSystemTlv.TYPE: 172 + case AutonomousSystemTlv.TYPE:
173 - iValue = cb.readInt(); 173 + iValue = cb.readInt();
174 - tlv = new AutonomousSystemTlv(iValue); 174 + tlv = new AutonomousSystemTlv(iValue);
175 - break; 175 + break;
176 - default: 176 + default:
177 - throw new PcepParseException("Unsupported Sub TLV type :" + hType); 177 + throw new PcepParseException("Unsupported Sub TLV type :" + hType);
178 - } 178 + }
179 - llRsvpUserSpecSubObj.add(tlv); 179 + llRsvpUserSpecSubObj.add(tlv);
180 - } 180 + }
181 - return llRsvpUserSpecSubObj; 181 + return llRsvpUserSpecSubObj;
182 - } 182 + }
183 - 183 +
184 - @Override 184 + @Override
185 - public PcepVersion getVersion() { 185 + public PcepVersion getVersion() {
186 - return PcepVersion.PCEP_1; 186 + return PcepVersion.PCEP_1;
187 - } 187 + }
188 - 188 +
189 - @Override 189 + @Override
190 - public short getType() { 190 + public short getType() {
191 - return StatefulRsvpErrorSpecTlv.TYPE; 191 + return StatefulRsvpErrorSpecTlv.TYPE;
192 - } 192 + }
193 - 193 +
194 - @Override 194 + @Override
195 - public short getLength() { 195 + public short getLength() {
196 - return objHeader.getObjLen(); 196 + return objHeader.getObjLen();
197 - } 197 + }
198 - 198 +
199 - @Override 199 + @Override
200 - public byte getClassNum() { 200 + public byte getClassNum() {
201 - return CLASS_NUM; 201 + return CLASS_NUM;
202 - } 202 + }
203 - 203 +
204 - @Override 204 + @Override
205 - public byte getClassType() { 205 + public byte getClassType() {
206 - return CLASS_TYPE; 206 + return CLASS_TYPE;
207 - } 207 + }
208 - 208 +
209 - @Override 209 + @Override
210 - public String toString() { 210 + public String toString() {
211 - return MoreObjects.toStringHelper(getClass()) 211 + return MoreObjects.toStringHelper(getClass())
212 - .add("enterpriseNumber:", enterpriseNum) 212 + .add("enterpriseNumber:", enterpriseNum)
213 - .add("subOrganization:", subOrg) 213 + .add("subOrganization:", subOrg)
214 - .add("errDescLength:", errDescLen) 214 + .add("errDescLength:", errDescLen)
215 - .add("userErrorValue:", userErrorValue) 215 + .add("userErrorValue:", userErrorValue)
216 - .add("errDesc:", errDesc) 216 + .add("errDesc:", errDesc)
217 - .add("RsvpUserSpecSubObject:", llRsvpUserSpecSubObj) 217 + .add("RsvpUserSpecSubObject:", llRsvpUserSpecSubObj)
218 - .toString(); 218 + .toString();
219 - } 219 + }
220 -} 220 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Iterator; 18 +import java.util.Iterator;
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 -import java.util.Objects; 21 +import java.util.Objects;
22 - 22 +
23 -import org.jboss.netty.buffer.ChannelBuffer; 23 +import org.jboss.netty.buffer.ChannelBuffer;
24 -import org.onosproject.pcepio.exceptions.PcepParseException; 24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 -import org.onosproject.pcepio.protocol.PcepVersion; 25 +import org.onosproject.pcepio.protocol.PcepVersion;
26 -import org.slf4j.Logger; 26 +import org.slf4j.Logger;
27 -import org.slf4j.LoggerFactory; 27 +import org.slf4j.LoggerFactory;
28 - 28 +
29 -import com.google.common.base.MoreObjects; 29 +import com.google.common.base.MoreObjects;
30 - 30 +
31 -/** 31 +/**
32 - * Provides Remote TE Node Descriptors TLV. 32 + * Provides Remote TE Node Descriptors TLV.
33 - */ 33 + */
34 -public class RemoteTENodeDescriptorsTLV implements PcepValueType { 34 +public class RemoteTENodeDescriptorsTLV implements PcepValueType {
35 - 35 +
36 - /* Reference :PCEP Extension for Transporting TE Data 36 + /* Reference :PCEP Extension for Transporting TE Data
37 - draft-dhodylee-pce-pcep-te-data-extn-02 37 + draft-dhodylee-pce-pcep-te-data-extn-02
38 - * 38 + *
39 - 0 1 2 3 39 + 0 1 2 3
40 - 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 + 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
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | Type=[TBD9] | Length | 42 + | Type=[TBD9] | Length |
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - | | 44 + | |
45 - // Node Descriptor Sub-TLVs (variable) // 45 + // Node Descriptor Sub-TLVs (variable) //
46 - | | 46 + | |
47 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 - */ 48 + */
49 - 49 +
50 - protected static final Logger log = LoggerFactory.getLogger(RemoteTENodeDescriptorsTLV.class); 50 + protected static final Logger log = LoggerFactory.getLogger(RemoteTENodeDescriptorsTLV.class);
51 - 51 +
52 - public static final short TYPE = 1003; //TODD:change this TBD9 52 + public static final short TYPE = 1003; //TODD:change this TBD9
53 - public short hLength; 53 + public short hLength;
54 - 54 +
55 - public static final int TLV_HEADER_LENGTH = 4; 55 + public static final int TLV_HEADER_LENGTH = 4;
56 - // Node Descriptor Sub-TLVs (variable) 56 + // Node Descriptor Sub-TLVs (variable)
57 - private LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs; 57 + private LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs;
58 - 58 +
59 - /** 59 + /**
60 - * Constructor to initialize llRemoteTENodeDescriptorSubTLVs. 60 + * Constructor to initialize llRemoteTENodeDescriptorSubTLVs.
61 - * 61 + *
62 - * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType 62 + * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType
63 - */ 63 + */
64 - public RemoteTENodeDescriptorsTLV(LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) { 64 + public RemoteTENodeDescriptorsTLV(LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
65 - this.llRemoteTENodeDescriptorSubTLVs = llRemoteTENodeDescriptorSubTLVs; 65 + this.llRemoteTENodeDescriptorSubTLVs = llRemoteTENodeDescriptorSubTLVs;
66 - } 66 + }
67 - 67 +
68 - /** 68 + /**
69 - * Returns object of Remote TE Node Descriptors TLV. 69 + * Returns object of Remote TE Node Descriptors TLV.
70 - * 70 + *
71 - * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType 71 + * @param llRemoteTENodeDescriptorSubTLVs LinkedList of PcepValueType
72 - * @return object of RemoteTENodeDescriptorsTLV 72 + * @return object of RemoteTENodeDescriptorsTLV
73 - */ 73 + */
74 - public static RemoteTENodeDescriptorsTLV of(final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) { 74 + public static RemoteTENodeDescriptorsTLV of(final LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs) {
75 - return new RemoteTENodeDescriptorsTLV(llRemoteTENodeDescriptorSubTLVs); 75 + return new RemoteTENodeDescriptorsTLV(llRemoteTENodeDescriptorSubTLVs);
76 - } 76 + }
77 - 77 +
78 - /** 78 + /**
79 - * Returns Remote TE Node Descriptor Sub TLVs. 79 + * Returns Remote TE Node Descriptor Sub TLVs.
80 - * 80 + *
81 - * @return llRemoteTENodeDescriptorSubTLVs 81 + * @return llRemoteTENodeDescriptorSubTLVs
82 - */ 82 + */
83 - public LinkedList<PcepValueType> getllRemoteTENodeDescriptorSubTLVs() { 83 + public LinkedList<PcepValueType> getllRemoteTENodeDescriptorSubTLVs() {
84 - return llRemoteTENodeDescriptorSubTLVs; 84 + return llRemoteTENodeDescriptorSubTLVs;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public PcepVersion getVersion() { 88 + public PcepVersion getVersion() {
89 - return PcepVersion.PCEP_1; 89 + return PcepVersion.PCEP_1;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public short getType() { 93 + public short getType() {
94 - return TYPE; 94 + return TYPE;
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public short getLength() { 98 + public short getLength() {
99 - return hLength; 99 + return hLength;
100 - } 100 + }
101 - 101 +
102 - @Override 102 + @Override
103 - public int hashCode() { 103 + public int hashCode() {
104 - return Objects.hash(llRemoteTENodeDescriptorSubTLVs.hashCode()); 104 + return Objects.hash(llRemoteTENodeDescriptorSubTLVs.hashCode());
105 - } 105 + }
106 - 106 +
107 - @Override 107 + @Override
108 - public boolean equals(Object obj) { 108 + public boolean equals(Object obj) {
109 - if (this == obj) { 109 + if (this == obj) {
110 - return true; 110 + return true;
111 - } 111 + }
112 - /* 112 + /*
113 - * Here we have a list of Tlv so to compare each sub tlv between the object 113 + * Here we have a list of Tlv so to compare each sub tlv between the object
114 - * we have to take a list iterator so one by one we can get each sub tlv object 114 + * we have to take a list iterator so one by one we can get each sub tlv object
115 - * and can compare them. 115 + * and can compare them.
116 - * it may be possible that the size of 2 lists is not equal so we have to first check 116 + * it may be possible that the size of 2 lists is not equal so we have to first check
117 - * the size, if both are same then we should check for the subtlv objects otherwise 117 + * the size, if both are same then we should check for the subtlv objects otherwise
118 - * we should return false. 118 + * we should return false.
119 - */ 119 + */
120 - if (obj instanceof RemoteTENodeDescriptorsTLV) { 120 + if (obj instanceof RemoteTENodeDescriptorsTLV) {
121 - int countObjSubTlv = 0; 121 + int countObjSubTlv = 0;
122 - int countOtherSubTlv = 0; 122 + int countOtherSubTlv = 0;
123 - boolean isCommonSubTlv = true; 123 + boolean isCommonSubTlv = true;
124 - RemoteTENodeDescriptorsTLV other = (RemoteTENodeDescriptorsTLV) obj; 124 + RemoteTENodeDescriptorsTLV other = (RemoteTENodeDescriptorsTLV) obj;
125 - Iterator<PcepValueType> objListIterator = ((RemoteTENodeDescriptorsTLV) obj).llRemoteTENodeDescriptorSubTLVs 125 + Iterator<PcepValueType> objListIterator = ((RemoteTENodeDescriptorsTLV) obj).llRemoteTENodeDescriptorSubTLVs
126 - .iterator(); 126 + .iterator();
127 - countObjSubTlv = ((RemoteTENodeDescriptorsTLV) obj).llRemoteTENodeDescriptorSubTLVs.size(); 127 + countObjSubTlv = ((RemoteTENodeDescriptorsTLV) obj).llRemoteTENodeDescriptorSubTLVs.size();
128 - countOtherSubTlv = other.llRemoteTENodeDescriptorSubTLVs.size(); 128 + countOtherSubTlv = other.llRemoteTENodeDescriptorSubTLVs.size();
129 - if (countObjSubTlv != countOtherSubTlv) { 129 + if (countObjSubTlv != countOtherSubTlv) {
130 - return false; 130 + return false;
131 - } else { 131 + } else {
132 - while (objListIterator.hasNext() && isCommonSubTlv) { 132 + while (objListIterator.hasNext() && isCommonSubTlv) {
133 - PcepValueType subTlv = objListIterator.next(); 133 + PcepValueType subTlv = objListIterator.next();
134 - isCommonSubTlv = Objects.equals(llRemoteTENodeDescriptorSubTLVs.contains(subTlv), 134 + isCommonSubTlv = Objects.equals(llRemoteTENodeDescriptorSubTLVs.contains(subTlv),
135 - other.llRemoteTENodeDescriptorSubTLVs.contains(subTlv)); 135 + other.llRemoteTENodeDescriptorSubTLVs.contains(subTlv));
136 - } 136 + }
137 - return isCommonSubTlv; 137 + return isCommonSubTlv;
138 - } 138 + }
139 - } 139 + }
140 - return false; 140 + return false;
141 - } 141 + }
142 - 142 +
143 - @Override 143 + @Override
144 - public int write(ChannelBuffer c) { 144 + public int write(ChannelBuffer c) {
145 - 145 +
146 - int tlvStartIndex = c.writerIndex(); 146 + int tlvStartIndex = c.writerIndex();
147 - c.writeShort(TYPE); 147 + c.writeShort(TYPE);
148 - int tlvLenIndex = c.writerIndex(); 148 + int tlvLenIndex = c.writerIndex();
149 - hLength = 0; 149 + hLength = 0;
150 - c.writeShort(hLength); 150 + c.writeShort(hLength);
151 - 151 +
152 - ListIterator<PcepValueType> listIterator = llRemoteTENodeDescriptorSubTLVs.listIterator(); 152 + ListIterator<PcepValueType> listIterator = llRemoteTENodeDescriptorSubTLVs.listIterator();
153 - 153 +
154 - while (listIterator.hasNext()) { 154 + while (listIterator.hasNext()) {
155 - PcepValueType tlv = listIterator.next(); 155 + PcepValueType tlv = listIterator.next();
156 - 156 +
157 - if (null == tlv) { 157 + if (null == tlv) {
158 - log.debug("TLV is null from subTlv list"); 158 + log.debug("TLV is null from subTlv list");
159 - continue; 159 + continue;
160 - } 160 + }
161 - tlv.write(c); 161 + tlv.write(c);
162 - 162 +
163 - // need to take care of padding 163 + // need to take care of padding
164 - int pad = tlv.getLength() % 4; 164 + int pad = tlv.getLength() % 4;
165 - 165 +
166 - if (0 != pad) { 166 + if (0 != pad) {
167 - pad = 4 - pad; 167 + pad = 4 - pad;
168 - for (int i = 0; i < pad; ++i) { 168 + for (int i = 0; i < pad; ++i) {
169 - c.writeByte((byte) 0); 169 + c.writeByte((byte) 0);
170 - } 170 + }
171 - } 171 + }
172 - } 172 + }
173 - 173 +
174 - hLength = (short) (c.writerIndex() - tlvStartIndex); 174 + hLength = (short) (c.writerIndex() - tlvStartIndex);
175 - c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH)); 175 + c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
176 - 176 +
177 - return c.writerIndex() - tlvStartIndex; 177 + return c.writerIndex() - tlvStartIndex;
178 - } 178 + }
179 - 179 +
180 - /** 180 + /**
181 - * Reads channel buffer and returns object of Remote TE Node Descriptors TLV. 181 + * Reads channel buffer and returns object of Remote TE Node Descriptors TLV.
182 - * 182 + *
183 - * @param c input channel buffer 183 + * @param c input channel buffer
184 - * @return object of RemoteTENodeDescriptorsTLV 184 + * @return object of RemoteTENodeDescriptorsTLV
185 - * @throws PcepParseException if mandatory fields are missing 185 + * @throws PcepParseException if mandatory fields are missing
186 - */ 186 + */
187 - public static PcepValueType read(ChannelBuffer c , short length) throws PcepParseException { 187 + public static PcepValueType read(ChannelBuffer c , short length) throws PcepParseException {
188 - 188 +
189 - // Node Descriptor Sub-TLVs (variable) 189 + // Node Descriptor Sub-TLVs (variable)
190 - LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs = new LinkedList<PcepValueType>(); 190 + LinkedList<PcepValueType> llRemoteTENodeDescriptorSubTLVs = new LinkedList<PcepValueType>();
191 - 191 +
192 - ChannelBuffer tempCb = c.readBytes(length); 192 + ChannelBuffer tempCb = c.readBytes(length);
193 - 193 +
194 - while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) { 194 + while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
195 - 195 +
196 - PcepValueType tlv; 196 + PcepValueType tlv;
197 - short hType = tempCb.readShort(); 197 + short hType = tempCb.readShort();
198 - int iValue = 0; 198 + int iValue = 0;
199 - short hLength = tempCb.readShort(); 199 + short hLength = tempCb.readShort();
200 - switch (hType) { 200 + switch (hType) {
201 - 201 +
202 - case AutonomousSystemTlv.TYPE: 202 + case AutonomousSystemTlv.TYPE:
203 - iValue = tempCb.readInt(); 203 + iValue = tempCb.readInt();
204 - tlv = new AutonomousSystemTlv(iValue); 204 + tlv = new AutonomousSystemTlv(iValue);
205 - break; 205 + break;
206 - case BGPLSidentifierTlv.TYPE: 206 + case BGPLSidentifierTlv.TYPE:
207 - iValue = tempCb.readInt(); 207 + iValue = tempCb.readInt();
208 - tlv = new BGPLSidentifierTlv(iValue); 208 + tlv = new BGPLSidentifierTlv(iValue);
209 - break; 209 + break;
210 - case OSPFareaIDsubTlv.TYPE: 210 + case OSPFareaIDsubTlv.TYPE:
211 - iValue = tempCb.readInt(); 211 + iValue = tempCb.readInt();
212 - tlv = new OSPFareaIDsubTlv(iValue); 212 + tlv = new OSPFareaIDsubTlv(iValue);
213 - break; 213 + break;
214 - case RouterIDSubTlv.TYPE: 214 + case RouterIDSubTlv.TYPE:
215 - tlv = RouterIDSubTlv.read(tempCb, hLength); 215 + tlv = RouterIDSubTlv.read(tempCb, hLength);
216 - break; 216 + break;
217 - 217 +
218 - default: 218 + default:
219 - throw new PcepParseException("Unsupported Sub TLV type :" + hType); 219 + throw new PcepParseException("Unsupported Sub TLV type :" + hType);
220 - } 220 + }
221 - 221 +
222 - // Check for the padding 222 + // Check for the padding
223 - int pad = hLength % 4; 223 + int pad = hLength % 4;
224 - if (0 < pad) { 224 + if (0 < pad) {
225 - pad = 4 - pad; 225 + pad = 4 - pad;
226 - if (pad <= tempCb.readableBytes()) { 226 + if (pad <= tempCb.readableBytes()) {
227 - tempCb.skipBytes(pad); 227 + tempCb.skipBytes(pad);
228 - } 228 + }
229 - } 229 + }
230 - 230 +
231 - llRemoteTENodeDescriptorSubTLVs.add(tlv); 231 + llRemoteTENodeDescriptorSubTLVs.add(tlv);
232 - } 232 + }
233 - 233 +
234 - if (0 < tempCb.readableBytes()) { 234 + if (0 < tempCb.readableBytes()) {
235 - 235 +
236 - throw new PcepParseException("Sub Tlv parsing error. Extra bytes received."); 236 + throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
237 - } 237 + }
238 - return new RemoteTENodeDescriptorsTLV(llRemoteTENodeDescriptorSubTLVs); 238 + return new RemoteTENodeDescriptorsTLV(llRemoteTENodeDescriptorSubTLVs);
239 - } 239 + }
240 - 240 +
241 - @Override 241 + @Override
242 - public String toString() { 242 + public String toString() {
243 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength) 243 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
244 - .add("RemoteTeNodeDescriptorSubTLVs", llRemoteTENodeDescriptorSubTLVs).toString(); 244 + .add("RemoteTeNodeDescriptorSubTLVs", llRemoteTENodeDescriptorSubTLVs).toString();
245 - } 245 + }
246 -} 246 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides router id. 29 + * Provides router id.
30 - */ 30 + */
31 -public class RouterIDSubTlv implements PcepValueType { 31 +public class RouterIDSubTlv implements PcepValueType {
32 - 32 +
33 - /* reference :I-D.ietf-idr-ls-distribution. 33 + /* reference :I-D.ietf-idr-ls-distribution.
34 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=[TBD13] | Length | 37 + | Type=[TBD13] | Length |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | opaque value | 39 + | opaque value |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - */ 41 + */
42 - 42 +
43 - protected static final Logger log = LoggerFactory.getLogger(RouterIDSubTlv.class); 43 + protected static final Logger log = LoggerFactory.getLogger(RouterIDSubTlv.class);
44 - 44 +
45 - public static final short TYPE = 1000; //TODD:change this TBD13 45 + public static final short TYPE = 1000; //TODD:change this TBD13
46 - private final short hLength; 46 + private final short hLength;
47 - 47 +
48 - private final byte[] rawValue; 48 + private final byte[] rawValue;
49 - 49 +
50 - /** 50 + /**
51 - * constructor to initialize rawValue. 51 + * constructor to initialize rawValue.
52 - * 52 + *
53 - * @param rawValue raw value 53 + * @param rawValue raw value
54 - * @param hLength length 54 + * @param hLength length
55 - */ 55 + */
56 - public RouterIDSubTlv(byte[] rawValue, short hLength) { 56 + public RouterIDSubTlv(byte[] rawValue, short hLength) {
57 - this.rawValue = rawValue; 57 + this.rawValue = rawValue;
58 - if (0 == hLength) { 58 + if (0 == hLength) {
59 - this.hLength = (short) rawValue.length; 59 + this.hLength = (short) rawValue.length;
60 - } else { 60 + } else {
61 - this.hLength = hLength; 61 + this.hLength = hLength;
62 - } 62 + }
63 - } 63 + }
64 - 64 +
65 - /** 65 + /**
66 - * Returns object of Router ID Sub Tlv. 66 + * Returns object of Router ID Sub Tlv.
67 - * 67 + *
68 - * @param raw value 68 + * @param raw value
69 - * @param hLength length 69 + * @param hLength length
70 - * @return object of Router ID Sub Tlv 70 + * @return object of Router ID Sub Tlv
71 - */ 71 + */
72 - public static RouterIDSubTlv of(final byte[] raw, short hLength) { 72 + public static RouterIDSubTlv of(final byte[] raw, short hLength) {
73 - return new RouterIDSubTlv(raw, hLength); 73 + return new RouterIDSubTlv(raw, hLength);
74 - } 74 + }
75 - 75 +
76 - /** 76 + /**
77 - * Returns raw value. 77 + * Returns raw value.
78 - * 78 + *
79 - * @return rawValue value 79 + * @return rawValue value
80 - */ 80 + */
81 - public byte[] getValue() { 81 + public byte[] getValue() {
82 - return rawValue; 82 + return rawValue;
83 - } 83 + }
84 - 84 +
85 - @Override 85 + @Override
86 - public PcepVersion getVersion() { 86 + public PcepVersion getVersion() {
87 - return PcepVersion.PCEP_1; 87 + return PcepVersion.PCEP_1;
88 - } 88 + }
89 - 89 +
90 - @Override 90 + @Override
91 - public short getType() { 91 + public short getType() {
92 - return TYPE; 92 + return TYPE;
93 - } 93 + }
94 - 94 +
95 - @Override 95 + @Override
96 - public short getLength() { 96 + public short getLength() {
97 - return hLength; 97 + return hLength;
98 - } 98 + }
99 - 99 +
100 - @Override 100 + @Override
101 - public int hashCode() { 101 + public int hashCode() {
102 - return Objects.hash(rawValue); 102 + return Objects.hash(rawValue);
103 - } 103 + }
104 - 104 +
105 - @Override 105 + @Override
106 - public boolean equals(Object obj) { 106 + public boolean equals(Object obj) {
107 - if (this == obj) { 107 + if (this == obj) {
108 - return true; 108 + return true;
109 - } 109 + }
110 - if (obj instanceof RouterIDSubTlv) { 110 + if (obj instanceof RouterIDSubTlv) {
111 - RouterIDSubTlv other = (RouterIDSubTlv) obj; 111 + RouterIDSubTlv other = (RouterIDSubTlv) obj;
112 - return Objects.equals(this.rawValue, other.rawValue); 112 + return Objects.equals(this.rawValue, other.rawValue);
113 - } 113 + }
114 - return false; 114 + return false;
115 - } 115 + }
116 - 116 +
117 - @Override 117 + @Override
118 - public int write(ChannelBuffer c) { 118 + public int write(ChannelBuffer c) {
119 - int iLenStartIndex = c.writerIndex(); 119 + int iLenStartIndex = c.writerIndex();
120 - c.writeShort(TYPE); 120 + c.writeShort(TYPE);
121 - c.writeShort(hLength); 121 + c.writeShort(hLength);
122 - c.writeBytes(rawValue); 122 + c.writeBytes(rawValue);
123 - return c.writerIndex() - iLenStartIndex; 123 + return c.writerIndex() - iLenStartIndex;
124 - } 124 + }
125 - 125 +
126 - /** 126 + /**
127 - * Reads channel buffer and returns object of RouterIDSubTlv. 127 + * Reads channel buffer and returns object of RouterIDSubTlv.
128 - * 128 + *
129 - * @param c input channel buffer 129 + * @param c input channel buffer
130 - * @param hLength length 130 + * @param hLength length
131 - * @return object of RouterIDSubTlv 131 + * @return object of RouterIDSubTlv
132 - */ 132 + */
133 - public static PcepValueType read(ChannelBuffer c, short hLength) { 133 + public static PcepValueType read(ChannelBuffer c, short hLength) {
134 - byte[] iOpaqueValue = new byte[hLength]; 134 + byte[] iOpaqueValue = new byte[hLength];
135 - c.readBytes(iOpaqueValue, 0, hLength); 135 + c.readBytes(iOpaqueValue, 0, hLength);
136 - return new RouterIDSubTlv(iOpaqueValue, hLength); 136 + return new RouterIDSubTlv(iOpaqueValue, hLength);
137 - } 137 + }
138 - 138 +
139 - @Override 139 + @Override
140 - public String toString() { 140 + public String toString() {
141 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 141 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
142 - 142 +
143 - toStrHelper.add("Type", TYPE); 143 + toStrHelper.add("Type", TYPE);
144 - toStrHelper.add("Length", hLength); 144 + toStrHelper.add("Length", hLength);
145 - 145 +
146 - StringBuffer result = new StringBuffer(); 146 + StringBuffer result = new StringBuffer();
147 - for (byte b : rawValue) { 147 + for (byte b : rawValue) {
148 - result.append(String.format("%02X ", b)); 148 + result.append(String.format("%02X ", b));
149 - } 149 + }
150 - toStrHelper.add("Value", result); 150 + toStrHelper.add("Value", result);
151 - 151 +
152 - return toStrHelper.toString(); 152 + return toStrHelper.toString();
153 - } 153 + }
154 -} 154 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides RoutingUniverseTLV identifiers. 28 + * Provides RoutingUniverseTLV identifiers.
29 - */ 29 + */
30 -public class RoutingUniverseTLV implements PcepValueType { 30 +public class RoutingUniverseTLV implements PcepValueType {
31 - 31 +
32 - /* 32 + /*
33 - * Reference : draft-dhodylee-pce-pcep-te-data-extn-02, section 9.2.1. 33 + * Reference : draft-dhodylee-pce-pcep-te-data-extn-02, section 9.2.1.
34 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=[TBD7] | Length=8 | 37 + | Type=[TBD7] | Length=8 |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | Identifier | 39 + | Identifier |
40 - | | 40 + | |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - 42 +
43 - * 43 + *
44 - * 44 + *
45 - * +------------+---------------------+ 45 + * +------------+---------------------+
46 - | Identifier | Routing Universe | 46 + | Identifier | Routing Universe |
47 - +------------+---------------------+ 47 + +------------+---------------------+
48 - | 0 | L3 packet topology | 48 + | 0 | L3 packet topology |
49 - | 1 | L1 optical topology | 49 + | 1 | L1 optical topology |
50 - +------------+---------------------+ 50 + +------------+---------------------+
51 - */ 51 + */
52 - 52 +
53 - protected static final Logger log = LoggerFactory.getLogger(RoutingUniverseTLV.class); 53 + protected static final Logger log = LoggerFactory.getLogger(RoutingUniverseTLV.class);
54 - 54 +
55 - public static final short TYPE = 14; // TODO:need to change TBD7 55 + public static final short TYPE = 14; // TODO:need to change TBD7
56 - public static final short LENGTH = 8; 56 + public static final short LENGTH = 8;
57 - 57 +
58 - private final long rawValue; 58 + private final long rawValue;
59 - 59 +
60 - /** 60 + /**
61 - * Constructor to initialize raw value. 61 + * Constructor to initialize raw value.
62 - * 62 + *
63 - * @param rawValue raw value 63 + * @param rawValue raw value
64 - */ 64 + */
65 - public RoutingUniverseTLV(long rawValue) { 65 + public RoutingUniverseTLV(long rawValue) {
66 - this.rawValue = rawValue; 66 + this.rawValue = rawValue;
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns object of RoutingUniverseTLV. 70 + * Returns object of RoutingUniverseTLV.
71 - * 71 + *
72 - * @param raw value 72 + * @param raw value
73 - * @return object of RoutingUniverseTLV 73 + * @return object of RoutingUniverseTLV
74 - */ 74 + */
75 - public static RoutingUniverseTLV of(final long raw) { 75 + public static RoutingUniverseTLV of(final long raw) {
76 - return new RoutingUniverseTLV(raw); 76 + return new RoutingUniverseTLV(raw);
77 - } 77 + }
78 - 78 +
79 - /** 79 + /**
80 - * Returns raw value as Identifier. 80 + * Returns raw value as Identifier.
81 - * 81 + *
82 - * @return rawValue Identifier 82 + * @return rawValue Identifier
83 - */ 83 + */
84 - public long getLong() { 84 + public long getLong() {
85 - return rawValue; 85 + return rawValue;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public PcepVersion getVersion() { 89 + public PcepVersion getVersion() {
90 - return PcepVersion.PCEP_1; 90 + return PcepVersion.PCEP_1;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public short getType() { 94 + public short getType() {
95 - return TYPE; 95 + return TYPE;
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public short getLength() { 99 + public short getLength() {
100 - return LENGTH; 100 + return LENGTH;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public int hashCode() { 104 + public int hashCode() {
105 - return Objects.hash(rawValue); 105 + return Objects.hash(rawValue);
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public boolean equals(Object obj) { 109 + public boolean equals(Object obj) {
110 - if (this == obj) { 110 + if (this == obj) {
111 - return true; 111 + return true;
112 - } 112 + }
113 - if (obj instanceof RoutingUniverseTLV) { 113 + if (obj instanceof RoutingUniverseTLV) {
114 - RoutingUniverseTLV other = (RoutingUniverseTLV) obj; 114 + RoutingUniverseTLV other = (RoutingUniverseTLV) obj;
115 - return Objects.equals(this.rawValue, other.rawValue); 115 + return Objects.equals(this.rawValue, other.rawValue);
116 - } 116 + }
117 - return false; 117 + return false;
118 - } 118 + }
119 - 119 +
120 - @Override 120 + @Override
121 - public int write(ChannelBuffer c) { 121 + public int write(ChannelBuffer c) {
122 - int iLenStartIndex = c.writerIndex(); 122 + int iLenStartIndex = c.writerIndex();
123 - c.writeShort(TYPE); 123 + c.writeShort(TYPE);
124 - c.writeShort(LENGTH); 124 + c.writeShort(LENGTH);
125 - c.writeLong(rawValue); 125 + c.writeLong(rawValue);
126 - return c.writerIndex() - iLenStartIndex; 126 + return c.writerIndex() - iLenStartIndex;
127 - } 127 + }
128 - 128 +
129 - /** 129 + /**
130 - * Reads from channel buffer and returns object of RoutingUniverseTLV. 130 + * Reads from channel buffer and returns object of RoutingUniverseTLV.
131 - * 131 + *
132 - * @param c input channel buffer 132 + * @param c input channel buffer
133 - * @return object of RoutingUniverseTLV 133 + * @return object of RoutingUniverseTLV
134 - */ 134 + */
135 - public static RoutingUniverseTLV read(ChannelBuffer c) { 135 + public static RoutingUniverseTLV read(ChannelBuffer c) {
136 - return RoutingUniverseTLV.of(c.readLong()); 136 + return RoutingUniverseTLV.of(c.readLong());
137 - } 137 + }
138 - 138 +
139 - @Override 139 + @Override
140 - public String toString() { 140 + public String toString() {
141 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 141 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
142 - .toString(); 142 + .toString();
143 - } 143 + }
144 -} 144 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 -import com.google.common.base.MoreObjects.ToStringHelper; 26 +import com.google.common.base.MoreObjects.ToStringHelper;
27 - 27 +
28 -/** 28 +/**
29 - * Provides SharedRiskLinkGroupTlv. 29 + * Provides SharedRiskLinkGroupTlv.
30 - */ 30 + */
31 -public class SharedRiskLinkGroupTlv implements PcepValueType { 31 +public class SharedRiskLinkGroupTlv implements PcepValueType {
32 - 32 +
33 - /* 33 + /*
34 - * Reference :[I-D.ietf-idr- Group ls-distribution] /3.3.2.5 34 + * Reference :[I-D.ietf-idr- Group ls-distribution] /3.3.2.5
35 - * 35 + *
36 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | Type =TDB41 | Length | 39 + | Type =TDB41 | Length |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Shared Risk Link Group Value | 41 + | Shared Risk Link Group Value |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - // ............ // 43 + // ............ //
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | Shared Risk Link Group Value | 45 + | Shared Risk Link Group Value |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - */ 47 + */
48 - 48 +
49 - protected static final Logger log = LoggerFactory.getLogger(SharedRiskLinkGroupTlv.class); 49 + protected static final Logger log = LoggerFactory.getLogger(SharedRiskLinkGroupTlv.class);
50 - 50 +
51 - public static final short TYPE = 1096; //TODO:NEED TO HANDLE TDB41 51 + public static final short TYPE = 1096; //TODO:NEED TO HANDLE TDB41
52 - 52 +
53 - private final short hLength; 53 + private final short hLength;
54 - 54 +
55 - private final int[] srlgValue; 55 + private final int[] srlgValue;
56 - 56 +
57 - /** 57 + /**
58 - * Constructor to initialize SRLG value. 58 + * Constructor to initialize SRLG value.
59 - * 59 + *
60 - * @param srlgValue Shared Risk Link Group Value 60 + * @param srlgValue Shared Risk Link Group Value
61 - * @param hLength length 61 + * @param hLength length
62 - */ 62 + */
63 - public SharedRiskLinkGroupTlv(int[] srlgValue, short hLength) { 63 + public SharedRiskLinkGroupTlv(int[] srlgValue, short hLength) {
64 - this.srlgValue = srlgValue; 64 + this.srlgValue = srlgValue;
65 - if (0 == hLength) { 65 + if (0 == hLength) {
66 - this.hLength = (short) ((srlgValue.length) * 4); 66 + this.hLength = (short) ((srlgValue.length) * 4);
67 - } else { 67 + } else {
68 - this.hLength = hLength; 68 + this.hLength = hLength;
69 - } 69 + }
70 - } 70 + }
71 - 71 +
72 - /** 72 + /**
73 - * Returns object of SharedRiskLinkGroupTlv. 73 + * Returns object of SharedRiskLinkGroupTlv.
74 - * 74 + *
75 - * @param raw value 75 + * @param raw value
76 - * @param hLength length 76 + * @param hLength length
77 - * @return object of SharedRiskLinkGroupTlv 77 + * @return object of SharedRiskLinkGroupTlv
78 - */ 78 + */
79 - public static SharedRiskLinkGroupTlv of(final int[] raw, short hLength) { 79 + public static SharedRiskLinkGroupTlv of(final int[] raw, short hLength) {
80 - return new SharedRiskLinkGroupTlv(raw, hLength); 80 + return new SharedRiskLinkGroupTlv(raw, hLength);
81 - } 81 + }
82 - 82 +
83 - /** 83 + /**
84 - * Returns SRLG Value. 84 + * Returns SRLG Value.
85 - * 85 + *
86 - * @return srlgValue 86 + * @return srlgValue
87 - */ 87 + */
88 - public int[] getValue() { 88 + public int[] getValue() {
89 - return srlgValue; 89 + return srlgValue;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public PcepVersion getVersion() { 93 + public PcepVersion getVersion() {
94 - return PcepVersion.PCEP_1; 94 + return PcepVersion.PCEP_1;
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public short getType() { 98 + public short getType() {
99 - return TYPE; 99 + return TYPE;
100 - } 100 + }
101 - 101 +
102 - @Override 102 + @Override
103 - public short getLength() { 103 + public short getLength() {
104 - return hLength; 104 + return hLength;
105 - } 105 + }
106 - 106 +
107 - @Override 107 + @Override
108 - public int hashCode() { 108 + public int hashCode() {
109 - return Objects.hash(srlgValue); 109 + return Objects.hash(srlgValue);
110 - } 110 + }
111 - 111 +
112 - @Override 112 + @Override
113 - public boolean equals(Object obj) { 113 + public boolean equals(Object obj) {
114 - if (this == obj) { 114 + if (this == obj) {
115 - return true; 115 + return true;
116 - } 116 + }
117 - if (obj instanceof SharedRiskLinkGroupTlv) { 117 + if (obj instanceof SharedRiskLinkGroupTlv) {
118 - SharedRiskLinkGroupTlv other = (SharedRiskLinkGroupTlv) obj; 118 + SharedRiskLinkGroupTlv other = (SharedRiskLinkGroupTlv) obj;
119 - return Objects.equals(this.srlgValue, other.srlgValue); 119 + return Objects.equals(this.srlgValue, other.srlgValue);
120 - } 120 + }
121 - return false; 121 + return false;
122 - } 122 + }
123 - 123 +
124 - @Override 124 + @Override
125 - public int write(ChannelBuffer c) { 125 + public int write(ChannelBuffer c) {
126 - int iLenStartIndex = c.writerIndex(); 126 + int iLenStartIndex = c.writerIndex();
127 - c.writeShort(TYPE); 127 + c.writeShort(TYPE);
128 - c.writeShort(hLength); 128 + c.writeShort(hLength);
129 - for (int b : srlgValue) { 129 + for (int b : srlgValue) {
130 - c.writeInt(b); 130 + c.writeInt(b);
131 - } 131 + }
132 - return c.writerIndex() - iLenStartIndex; 132 + return c.writerIndex() - iLenStartIndex;
133 - } 133 + }
134 - 134 +
135 - /** 135 + /**
136 - * Reads from channel buffer and returns object of SharedRiskLinkGroupTlv. 136 + * Reads from channel buffer and returns object of SharedRiskLinkGroupTlv.
137 - * 137 + *
138 - * @param c input channel buffer 138 + * @param c input channel buffer
139 - * @param hLength length 139 + * @param hLength length
140 - * @return object of SharedRiskLinkGroupTlv 140 + * @return object of SharedRiskLinkGroupTlv
141 - */ 141 + */
142 - public static PcepValueType read(ChannelBuffer c, short hLength) { 142 + public static PcepValueType read(ChannelBuffer c, short hLength) {
143 - int iLength = hLength / 4; 143 + int iLength = hLength / 4;
144 - int[] iSharedRiskLinkGroup = new int[iLength]; 144 + int[] iSharedRiskLinkGroup = new int[iLength];
145 - for (int i = 0; i < iLength; i++) { 145 + for (int i = 0; i < iLength; i++) {
146 - iSharedRiskLinkGroup[i] = c.readInt(); 146 + iSharedRiskLinkGroup[i] = c.readInt();
147 - } 147 + }
148 - return new SharedRiskLinkGroupTlv(iSharedRiskLinkGroup, hLength); 148 + return new SharedRiskLinkGroupTlv(iSharedRiskLinkGroup, hLength);
149 - } 149 + }
150 - 150 +
151 - 151 +
152 - @Override 152 + @Override
153 - public String toString() { 153 + public String toString() {
154 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 154 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
155 - 155 +
156 - toStrHelper.add("Type", TYPE); 156 + toStrHelper.add("Type", TYPE);
157 - toStrHelper.add("Length", hLength); 157 + toStrHelper.add("Length", hLength);
158 - 158 +
159 - StringBuffer result = new StringBuffer(); 159 + StringBuffer result = new StringBuffer();
160 - for (int b : srlgValue) { 160 + for (int b : srlgValue) {
161 - result.append(String.format("%02X ", b)); 161 + result.append(String.format("%02X ", b));
162 - } 162 + }
163 - toStrHelper.add("Value", result); 163 + toStrHelper.add("Value", result);
164 - 164 +
165 - return toStrHelper.toString(); 165 + return toStrHelper.toString();
166 - } 166 + }
167 -} 167 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepNai; 22 +import org.onosproject.pcepio.protocol.PcepNai;
23 -import org.onosproject.pcepio.protocol.PcepVersion; 23 +import org.onosproject.pcepio.protocol.PcepVersion;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 - 28 +
29 -/** 29 +/**
30 - * Provides SrEroSubObject. 30 + * Provides SrEroSubObject.
31 - */ 31 + */
32 -public class SrEroSubObject implements PcepValueType { 32 +public class SrEroSubObject implements PcepValueType {
33 - /* 33 + /*
34 - SR-ERO subobject: (draft-ietf-pce-segment-routing-00) 34 + SR-ERO subobject: (draft-ietf-pce-segment-routing-00)
35 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - |L| Type | Length | ST | Flags |F|S|C|M| 38 + |L| Type | Length | ST | Flags |F|S|C|M|
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | SID | 40 + | SID |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - // NAI (variable) // 42 + // NAI (variable) //
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - 44 +
45 - 45 +
46 - 46 +
47 - NAI 47 + NAI
48 - 48 +
49 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 51 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
52 - | Local IPv4 address | 52 + | Local IPv4 address |
53 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 53 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
54 - | Remote IPv4 address | 54 + | Remote IPv4 address |
55 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 55 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
56 - 56 +
57 - NAI for IPv4 Adjacency 57 + NAI for IPv4 Adjacency
58 - 58 +
59 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 61 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
62 - // Local IPv6 address (16 bytes) // 62 + // Local IPv6 address (16 bytes) //
63 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 63 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 - // Remote IPv6 address (16 bytes) // 64 + // Remote IPv6 address (16 bytes) //
65 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 65 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
66 - 66 +
67 - NAI for IPv6 adjacency 67 + NAI for IPv6 adjacency
68 - 68 +
69 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 71 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
72 - | Local Node-ID | 72 + | Local Node-ID |
73 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 73 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
74 - | Local Interface ID | 74 + | Local Interface ID |
75 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 75 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
76 - | Remote Node-ID | 76 + | Remote Node-ID |
77 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 77 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
78 - | Remote Interface ID | 78 + | Remote Interface ID |
79 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 79 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
80 - 80 +
81 - NAI for Unnumbered adjacency with IPv4 Node IDs 81 + NAI for Unnumbered adjacency with IPv4 Node IDs
82 - 82 +
83 - */ 83 + */
84 - protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class); 84 + protected static final Logger log = LoggerFactory.getLogger(SrEroSubObject.class);
85 - 85 +
86 - public static final short TYPE = 0x60; //TODO : type to be defined 86 + public static final short TYPE = 0x60; //TODO : type to be defined
87 - public static final short LENGTH = 12; 87 + public static final short LENGTH = 12;
88 - public static final short VALUE_LENGTH = 10; 88 + public static final short VALUE_LENGTH = 10;
89 - public static final int SET = 1; 89 + public static final int SET = 1;
90 - public static final byte MFLAG_SET = 0x01; 90 + public static final byte MFLAG_SET = 0x01;
91 - public static final byte CFLAG_SET = 0x02; 91 + public static final byte CFLAG_SET = 0x02;
92 - public static final byte SFLAG_SET = 0x04; 92 + public static final byte SFLAG_SET = 0x04;
93 - public static final byte FFLAG_SET = 0x08; 93 + public static final byte FFLAG_SET = 0x08;
94 - public static final byte SHIFT_ST = 12; 94 + public static final byte SHIFT_ST = 12;
95 - 95 +
96 - private final boolean bFFlag; 96 + private final boolean bFFlag;
97 - private final boolean bSFlag; 97 + private final boolean bSFlag;
98 - private final boolean bCFlag; 98 + private final boolean bCFlag;
99 - private final boolean bMFlag; 99 + private final boolean bMFlag;
100 - private final byte st; 100 + private final byte st;
101 - 101 +
102 - private final int sID; 102 + private final int sID;
103 - private final PcepNai nai; 103 + private final PcepNai nai;
104 - 104 +
105 - /** 105 + /**
106 - * Constructor to initialize member variables. 106 + * Constructor to initialize member variables.
107 - * 107 + *
108 - * @param st SID type 108 + * @param st SID type
109 - * @param bFFlag F flag 109 + * @param bFFlag F flag
110 - * @param bSFlag S flag 110 + * @param bSFlag S flag
111 - * @param bCFlag C flag 111 + * @param bCFlag C flag
112 - * @param bMFlag M flag 112 + * @param bMFlag M flag
113 - * @param sID segment identifier value 113 + * @param sID segment identifier value
114 - * @param nai NAI associated with SID 114 + * @param nai NAI associated with SID
115 - */ 115 + */
116 - public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID, 116 + public SrEroSubObject(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
117 - PcepNai nai) { 117 + PcepNai nai) {
118 - this.st = st; 118 + this.st = st;
119 - this.bFFlag = bFFlag; 119 + this.bFFlag = bFFlag;
120 - this.bSFlag = bSFlag; 120 + this.bSFlag = bSFlag;
121 - this.bCFlag = bCFlag; 121 + this.bCFlag = bCFlag;
122 - this.bMFlag = bMFlag; 122 + this.bMFlag = bMFlag;
123 - this.sID = sID; 123 + this.sID = sID;
124 - this.nai = nai; 124 + this.nai = nai;
125 - } 125 + }
126 - 126 +
127 - /** 127 + /**
128 - * Creates object of SrEroSubObject. 128 + * Creates object of SrEroSubObject.
129 - * 129 + *
130 - * @param st SID type 130 + * @param st SID type
131 - * @param bFFlag F flag 131 + * @param bFFlag F flag
132 - * @param bSFlag S flag 132 + * @param bSFlag S flag
133 - * @param bCFlag C flag 133 + * @param bCFlag C flag
134 - * @param bMFlag M flag 134 + * @param bMFlag M flag
135 - * @param sID segment identifier value 135 + * @param sID segment identifier value
136 - * @param nai NAI associated with SID 136 + * @param nai NAI associated with SID
137 - * @return object of SrEroSubObject 137 + * @return object of SrEroSubObject
138 - */ 138 + */
139 - public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID, 139 + public static SrEroSubObject of(byte st, boolean bFFlag, boolean bSFlag, boolean bCFlag, boolean bMFlag, int sID,
140 - PcepNai nai) { 140 + PcepNai nai) {
141 - return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai); 141 + return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
142 - } 142 + }
143 - 143 +
144 - /** 144 + /**
145 - * Returns SID type. 145 + * Returns SID type.
146 - * @return st sid type 146 + * @return st sid type
147 - */ 147 + */
148 - public byte getSt() { 148 + public byte getSt() {
149 - return st; 149 + return st;
150 - } 150 + }
151 - 151 +
152 - /** 152 + /**
153 - * Returns bFFlag. 153 + * Returns bFFlag.
154 - * @return bFFlag 154 + * @return bFFlag
155 - */ 155 + */
156 - public boolean getFFlag() { 156 + public boolean getFFlag() {
157 - return bFFlag; 157 + return bFFlag;
158 - } 158 + }
159 - 159 +
160 - /** 160 + /**
161 - * Returns bSFlag. 161 + * Returns bSFlag.
162 - * @return bSFlag 162 + * @return bSFlag
163 - */ 163 + */
164 - public boolean getSFlag() { 164 + public boolean getSFlag() {
165 - return bSFlag; 165 + return bSFlag;
166 - } 166 + }
167 - 167 +
168 - /** 168 + /**
169 - * Returns bCFlag. 169 + * Returns bCFlag.
170 - * @return bCFlag 170 + * @return bCFlag
171 - */ 171 + */
172 - public boolean getCFlag() { 172 + public boolean getCFlag() {
173 - return bCFlag; 173 + return bCFlag;
174 - } 174 + }
175 - 175 +
176 - /** 176 + /**
177 - * Returns bMFlag. 177 + * Returns bMFlag.
178 - * @return bMFlag 178 + * @return bMFlag
179 - */ 179 + */
180 - public boolean getMFlag() { 180 + public boolean getMFlag() {
181 - return bMFlag; 181 + return bMFlag;
182 - } 182 + }
183 - 183 +
184 - /** 184 + /**
185 - * Returns sID. 185 + * Returns sID.
186 - * @return sID 186 + * @return sID
187 - */ 187 + */
188 - public int getSID() { 188 + public int getSID() {
189 - return sID; 189 + return sID;
190 - } 190 + }
191 - 191 +
192 - /** 192 + /**
193 - * Returns nai. 193 + * Returns nai.
194 - * @return nai 194 + * @return nai
195 - */ 195 + */
196 - public PcepNai getNai() { 196 + public PcepNai getNai() {
197 - return nai; 197 + return nai;
198 - } 198 + }
199 - 199 +
200 - @Override 200 + @Override
201 - public PcepVersion getVersion() { 201 + public PcepVersion getVersion() {
202 - return PcepVersion.PCEP_1; 202 + return PcepVersion.PCEP_1;
203 - } 203 + }
204 - 204 +
205 - @Override 205 + @Override
206 - public short getType() { 206 + public short getType() {
207 - return TYPE; 207 + return TYPE;
208 - } 208 + }
209 - 209 +
210 - @Override 210 + @Override
211 - public short getLength() { 211 + public short getLength() {
212 - return LENGTH; 212 + return LENGTH;
213 - } 213 + }
214 - 214 +
215 - @Override 215 + @Override
216 - public int hashCode() { 216 + public int hashCode() {
217 - return Objects.hash(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai); 217 + return Objects.hash(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
218 - } 218 + }
219 - 219 +
220 - @Override 220 + @Override
221 - public boolean equals(Object obj) { 221 + public boolean equals(Object obj) {
222 - if (this == obj) { 222 + if (this == obj) {
223 - return true; 223 + return true;
224 - } 224 + }
225 - if (obj instanceof SrEroSubObject) { 225 + if (obj instanceof SrEroSubObject) {
226 - SrEroSubObject other = (SrEroSubObject) obj; 226 + SrEroSubObject other = (SrEroSubObject) obj;
227 - return Objects.equals(this.st, other.st) && Objects.equals(this.bFFlag, other.bFFlag) 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) 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) 229 + && Objects.equals(this.bMFlag, other.bMFlag) && Objects.equals(this.sID, other.sID)
230 - && Objects.equals(this.nai, other.nai); 230 + && Objects.equals(this.nai, other.nai);
231 - } 231 + }
232 - return false; 232 + return false;
233 - } 233 + }
234 - 234 +
235 - @Override 235 + @Override
236 - public int write(ChannelBuffer c) { 236 + public int write(ChannelBuffer c) {
237 - int iLenStartIndex = c.writerIndex(); 237 + int iLenStartIndex = c.writerIndex();
238 - 238 +
239 - c.writeShort(TYPE); 239 + c.writeShort(TYPE);
240 - c.writeShort(LENGTH); 240 + c.writeShort(LENGTH);
241 - 241 +
242 - short temp = 0; 242 + short temp = 0;
243 - if (bMFlag) { 243 + if (bMFlag) {
244 - temp = (short) (temp | MFLAG_SET); 244 + temp = (short) (temp | MFLAG_SET);
245 - } 245 + }
246 - if (bCFlag) { 246 + if (bCFlag) {
247 - temp = (short) (temp | CFLAG_SET); 247 + temp = (short) (temp | CFLAG_SET);
248 - } 248 + }
249 - if (bSFlag) { 249 + if (bSFlag) {
250 - temp = (short) (temp | SFLAG_SET); 250 + temp = (short) (temp | SFLAG_SET);
251 - } 251 + }
252 - if (bFFlag) { 252 + if (bFFlag) {
253 - temp = (short) (temp | FFLAG_SET); 253 + temp = (short) (temp | FFLAG_SET);
254 - } 254 + }
255 - short tempST = (short) (st << SHIFT_ST); 255 + short tempST = (short) (st << SHIFT_ST);
256 - temp = (short) (temp | tempST); 256 + temp = (short) (temp | tempST);
257 - c.writeShort(temp); 257 + c.writeShort(temp);
258 - c.writeInt(sID); 258 + c.writeInt(sID);
259 - nai.write(c); 259 + nai.write(c);
260 - 260 +
261 - return c.writerIndex() - iLenStartIndex; 261 + return c.writerIndex() - iLenStartIndex;
262 - } 262 + }
263 - 263 +
264 - /** 264 + /**
265 - * Reads the channel buffer and returns object of SrEroSubObject. 265 + * Reads the channel buffer and returns object of SrEroSubObject.
266 - * @param c of type channel buffer 266 + * @param c of type channel buffer
267 - * @return object of SrEroSubObject 267 + * @return object of SrEroSubObject
268 - */ 268 + */
269 - public static PcepValueType read(ChannelBuffer c) { 269 + public static PcepValueType read(ChannelBuffer c) {
270 - short temp = c.readShort(); 270 + short temp = c.readShort();
271 - boolean bMFlag; 271 + boolean bMFlag;
272 - boolean bCFlag; 272 + boolean bCFlag;
273 - boolean bSFlag; 273 + boolean bSFlag;
274 - boolean bFFlag; 274 + boolean bFFlag;
275 - byte st; 275 + byte st;
276 - PcepNai nai = null; 276 + PcepNai nai = null;
277 - 277 +
278 - bMFlag = (temp & MFLAG_SET) == MFLAG_SET ? true : false; 278 + bMFlag = (temp & MFLAG_SET) == MFLAG_SET ? true : false;
279 - bCFlag = (temp & CFLAG_SET) == CFLAG_SET ? true : false; 279 + bCFlag = (temp & CFLAG_SET) == CFLAG_SET ? true : false;
280 - bSFlag = (temp & SFLAG_SET) == SFLAG_SET ? true : false; 280 + bSFlag = (temp & SFLAG_SET) == SFLAG_SET ? true : false;
281 - bFFlag = (temp & FFLAG_SET) == FFLAG_SET ? true : false; 281 + bFFlag = (temp & FFLAG_SET) == FFLAG_SET ? true : false;
282 - 282 +
283 - st = (byte) (temp >> SHIFT_ST); 283 + st = (byte) (temp >> SHIFT_ST);
284 - 284 +
285 - int sID = c.readInt(); 285 + int sID = c.readInt();
286 - switch (st) { 286 + switch (st) {
287 - case 0x01: 287 + case 0x01:
288 - nai = PcepNaiIpv4NodeId.read(c); 288 + nai = PcepNaiIpv4NodeId.read(c);
289 - break; 289 + break;
290 - case 0x02: 290 + case 0x02:
291 - nai = PcepNaiIpv6NodeId.read(c); 291 + nai = PcepNaiIpv6NodeId.read(c);
292 - break; 292 + break;
293 - case 0x03: 293 + case 0x03:
294 - nai = PcepNaiIpv4Adjacency.read(c); 294 + nai = PcepNaiIpv4Adjacency.read(c);
295 - break; 295 + break;
296 - case 0x04: 296 + case 0x04:
297 - nai = PcepNaiIpv6Adjacency.read(c); 297 + nai = PcepNaiIpv6Adjacency.read(c);
298 - break; 298 + break;
299 - case 0x05: 299 + case 0x05:
300 - nai = PcepNaiUnnumberedAdjacencyIpv4.read(c); 300 + nai = PcepNaiUnnumberedAdjacencyIpv4.read(c);
301 - break; 301 + break;
302 - default: 302 + default:
303 - nai = null; 303 + nai = null;
304 - break; 304 + break;
305 - } 305 + }
306 - 306 +
307 - return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai); 307 + return new SrEroSubObject(st, bFFlag, bSFlag, bCFlag, bMFlag, sID, nai);
308 - } 308 + }
309 - 309 +
310 - @Override 310 + @Override
311 - public String toString() { 311 + public String toString() {
312 - return MoreObjects.toStringHelper(getClass()) 312 + return MoreObjects.toStringHelper(getClass())
313 - .add("Type", TYPE) 313 + .add("Type", TYPE)
314 - .add("Length", LENGTH) 314 + .add("Length", LENGTH)
315 - .add("st", st) 315 + .add("st", st)
316 - .add("bFflag", bFFlag) 316 + .add("bFflag", bFFlag)
317 - .add("bSFlag", bSFlag) 317 + .add("bSFlag", bSFlag)
318 - .add("bCFlag", bCFlag) 318 + .add("bCFlag", bCFlag)
319 - .add("bMFlag", bMFlag) 319 + .add("bMFlag", bMFlag)
320 - .add("sID", sID) 320 + .add("sID", sID)
321 - .add("nAI", nai) 321 + .add("nAI", nai)
322 - .toString(); 322 + .toString();
323 - } 323 + }
324 -} 324 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Provides StatefulIPv4LspIdentidiersTlv. 29 + * Provides StatefulIPv4LspIdentidiersTlv.
30 - */ 30 + */
31 -public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { 31 +public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
32 - 32 +
33 - /* IPV4-LSP-IDENTIFIERS TLV format 33 + /* IPV4-LSP-IDENTIFIERS TLV format
34 - * 34 + *
35 - * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10 35 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
36 - * 36 + *
37 - 37 +
38 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Type=18 | Length=16 | 41 + | Type=18 | Length=16 |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | IPv4 Tunnel Sender Address | 43 + | IPv4 Tunnel Sender Address |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | LSP ID | Tunnel ID | 45 + | LSP ID | Tunnel ID |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - | Extended Tunnel ID | 47 + | Extended Tunnel ID |
48 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 48 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
49 - | IPv4 Tunnel Endpoint Address | 49 + | IPv4 Tunnel Endpoint Address |
50 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 - 51 +
52 - */ 52 + */
53 - protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class); 53 + protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class);
54 - 54 +
55 - public static final short TYPE = 18; 55 + public static final short TYPE = 18;
56 - public static final short LENGTH = 16; 56 + public static final short LENGTH = 16;
57 - public static final int VALUE_LENGTH = 16; 57 + public static final int VALUE_LENGTH = 16;
58 - private final int ipv4IngressAddress; 58 + private final int ipv4IngressAddress;
59 - private final short lspId; 59 + private final short lspId;
60 - private final short tunnelId; 60 + private final short tunnelId;
61 - private final int extendedTunnelId; 61 + private final int extendedTunnelId;
62 - private final int ipv4EgressAddress; 62 + private final int ipv4EgressAddress;
63 - 63 +
64 - /** 64 + /**
65 - * Constructor to initialize member variables. 65 + * Constructor to initialize member variables.
66 - * 66 + *
67 - * @param ipv4IngressAddress ingress ipv4 address 67 + * @param ipv4IngressAddress ingress ipv4 address
68 - * @param lspId lsp id 68 + * @param lspId lsp id
69 - * @param tunnelId tunnel id 69 + * @param tunnelId tunnel id
70 - * @param extendedTunnelId extended tunnel id 70 + * @param extendedTunnelId extended tunnel id
71 - * @param ipv4EgressAddress egress ipv4 address 71 + * @param ipv4EgressAddress egress ipv4 address
72 - */ 72 + */
73 - public StatefulIPv4LspIdentidiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId, 73 + public StatefulIPv4LspIdentidiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
74 - int ipv4EgressAddress) { 74 + int ipv4EgressAddress) {
75 - 75 +
76 - this.ipv4IngressAddress = ipv4IngressAddress; 76 + this.ipv4IngressAddress = ipv4IngressAddress;
77 - this.lspId = lspId; 77 + this.lspId = lspId;
78 - this.tunnelId = tunnelId; 78 + this.tunnelId = tunnelId;
79 - this.extendedTunnelId = extendedTunnelId; 79 + this.extendedTunnelId = extendedTunnelId;
80 - this.ipv4EgressAddress = ipv4EgressAddress; 80 + this.ipv4EgressAddress = ipv4EgressAddress;
81 - } 81 + }
82 - 82 +
83 - /** 83 + /**
84 - * Creates object of StatefulIPv4LspIdentidiersTlv. 84 + * Creates object of StatefulIPv4LspIdentidiersTlv.
85 - * 85 + *
86 - * @param ipv4IngressAddress ingress ipv4 address 86 + * @param ipv4IngressAddress ingress ipv4 address
87 - * @param lspId lsp id 87 + * @param lspId lsp id
88 - * @param tunnelId tunnel id 88 + * @param tunnelId tunnel id
89 - * @param extendedTunnelId extended tunnel id 89 + * @param extendedTunnelId extended tunnel id
90 - * @param ipv4EgressAddress egress ipv4 address 90 + * @param ipv4EgressAddress egress ipv4 address
91 - * @return object of StatefulIPv4LspIdentidiersTlv 91 + * @return object of StatefulIPv4LspIdentidiersTlv
92 - */ 92 + */
93 - public static StatefulIPv4LspIdentidiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId, 93 + public static StatefulIPv4LspIdentidiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
94 - int extendedTunnelId, int ipv4EgressAddress) { 94 + int extendedTunnelId, int ipv4EgressAddress) {
95 - return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, 95 + return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
96 - ipv4EgressAddress); 96 + ipv4EgressAddress);
97 - } 97 + }
98 - 98 +
99 - /** 99 + /**
100 - * Returns tunnel id. 100 + * Returns tunnel id.
101 - * 101 + *
102 - * @return tunnelId 102 + * @return tunnelId
103 - */ 103 + */
104 - public short getTunnelId() { 104 + public short getTunnelId() {
105 - return this.tunnelId; 105 + return this.tunnelId;
106 - } 106 + }
107 - 107 +
108 - /** 108 + /**
109 - * Returns extendedTunnelId. 109 + * Returns extendedTunnelId.
110 - * 110 + *
111 - * @return extendedTunnelId 111 + * @return extendedTunnelId
112 - */ 112 + */
113 - public int getextendedTunnelId() { 113 + public int getextendedTunnelId() {
114 - return this.extendedTunnelId; 114 + return this.extendedTunnelId;
115 - } 115 + }
116 - 116 +
117 - @Override 117 + @Override
118 - public PcepVersion getVersion() { 118 + public PcepVersion getVersion() {
119 - return PcepVersion.PCEP_1; 119 + return PcepVersion.PCEP_1;
120 - } 120 + }
121 - 121 +
122 - /** 122 + /**
123 - * Returns ipv4IngressAddress. 123 + * Returns ipv4IngressAddress.
124 - * 124 + *
125 - * @return ipv4IngressAddress 125 + * @return ipv4IngressAddress
126 - */ 126 + */
127 - public int getIpv4IngressAddress() { 127 + public int getIpv4IngressAddress() {
128 - return ipv4IngressAddress; 128 + return ipv4IngressAddress;
129 - } 129 + }
130 - 130 +
131 - /** 131 + /**
132 - * Returns ipv4EgressAddress. 132 + * Returns ipv4EgressAddress.
133 - * 133 + *
134 - * @return ipv4EgressAddress 134 + * @return ipv4EgressAddress
135 - */ 135 + */
136 - public int getIpv4EgressAddress() { 136 + public int getIpv4EgressAddress() {
137 - return ipv4EgressAddress; 137 + return ipv4EgressAddress;
138 - } 138 + }
139 - 139 +
140 - @Override 140 + @Override
141 - public short getType() { 141 + public short getType() {
142 - return TYPE; 142 + return TYPE;
143 - } 143 + }
144 - 144 +
145 - @Override 145 + @Override
146 - public short getLength() { 146 + public short getLength() {
147 - return LENGTH; 147 + return LENGTH;
148 - } 148 + }
149 - 149 +
150 - @Override 150 + @Override
151 - public int hashCode() { 151 + public int hashCode() {
152 - return Objects.hash(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, ipv4EgressAddress); 152 + return Objects.hash(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, ipv4EgressAddress);
153 - } 153 + }
154 - 154 +
155 - @Override 155 + @Override
156 - public boolean equals(Object obj) { 156 + public boolean equals(Object obj) {
157 - if (this == obj) { 157 + if (this == obj) {
158 - return true; 158 + return true;
159 - } 159 + }
160 - if (obj instanceof StatefulIPv4LspIdentidiersTlv) { 160 + if (obj instanceof StatefulIPv4LspIdentidiersTlv) {
161 - StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj; 161 + StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj;
162 - return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress) 162 + return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
163 - && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId) 163 + && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
164 - && Objects.equals(this.extendedTunnelId, other.extendedTunnelId) 164 + && Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
165 - && Objects.equals(this.ipv4EgressAddress, other.ipv4EgressAddress); 165 + && Objects.equals(this.ipv4EgressAddress, other.ipv4EgressAddress);
166 - } 166 + }
167 - return false; 167 + return false;
168 - } 168 + }
169 - 169 +
170 - @Override 170 + @Override
171 - public int write(ChannelBuffer c) { 171 + public int write(ChannelBuffer c) {
172 - int iLenStartIndex = c.writerIndex(); 172 + int iLenStartIndex = c.writerIndex();
173 - c.writeShort(TYPE); 173 + c.writeShort(TYPE);
174 - c.writeShort(LENGTH); 174 + c.writeShort(LENGTH);
175 - c.writeInt(ipv4IngressAddress); 175 + c.writeInt(ipv4IngressAddress);
176 - c.writeShort(lspId); 176 + c.writeShort(lspId);
177 - c.writeShort(tunnelId); 177 + c.writeShort(tunnelId);
178 - c.writeInt(extendedTunnelId); 178 + c.writeInt(extendedTunnelId);
179 - c.writeInt(ipv4EgressAddress); 179 + c.writeInt(ipv4EgressAddress);
180 - 180 +
181 - return c.writerIndex() - iLenStartIndex; 181 + return c.writerIndex() - iLenStartIndex;
182 - } 182 + }
183 - 183 +
184 - /** 184 + /**
185 - * Reads the channel buffer and returns object of StatefulIPv4LspIdentidiersTlv. 185 + * Reads the channel buffer and returns object of StatefulIPv4LspIdentidiersTlv.
186 - * 186 + *
187 - * @param c of type channel buffer 187 + * @param c of type channel buffer
188 - * @return object of StatefulIPv4LspIdentidiersTlv 188 + * @return object of StatefulIPv4LspIdentidiersTlv
189 - */ 189 + */
190 - public static PcepValueType read(ChannelBuffer c) { 190 + public static PcepValueType read(ChannelBuffer c) {
191 - int ipv4IngressAddress = c.readInt(); 191 + int ipv4IngressAddress = c.readInt();
192 - short lspId = c.readShort(); 192 + short lspId = c.readShort();
193 - short tunnelId = c.readShort(); 193 + short tunnelId = c.readShort();
194 - int extendedTunnelId = c.readInt(); 194 + int extendedTunnelId = c.readInt();
195 - int ipv4EgressAddress = c.readInt(); 195 + int ipv4EgressAddress = c.readInt();
196 - return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, 196 + return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
197 - ipv4EgressAddress); 197 + ipv4EgressAddress);
198 - } 198 + }
199 - 199 +
200 - @Override 200 + @Override
201 - public String toString() { 201 + public String toString() {
202 - return MoreObjects.toStringHelper(getClass()) 202 + return MoreObjects.toStringHelper(getClass())
203 - .add("Type:", TYPE) 203 + .add("Type:", TYPE)
204 - .add("Length:", LENGTH) 204 + .add("Length:", LENGTH)
205 - .add("Ipv4IngressAddress:", ipv4IngressAddress) 205 + .add("Ipv4IngressAddress:", ipv4IngressAddress)
206 - .add("LspId:", lspId).add("TunnelId:", tunnelId) 206 + .add("LspId:", lspId).add("TunnelId:", tunnelId)
207 - .add("ExtendedTunnelId:", extendedTunnelId) 207 + .add("ExtendedTunnelId:", extendedTunnelId)
208 - .add("Ipv4EgressAddress:", ipv4EgressAddress).toString(); 208 + .add("Ipv4EgressAddress:", ipv4EgressAddress).toString();
209 - } 209 + }
210 -} 210 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Provides StatefulLspDbVerTlv. 29 + * Provides StatefulLspDbVerTlv.
30 - */ 30 + */
31 -public class StatefulLspDbVerTlv implements PcepValueType { 31 +public class StatefulLspDbVerTlv implements PcepValueType {
32 - 32 +
33 - /* LSP-DB-VERSION TLV format 33 + /* LSP-DB-VERSION TLV format
34 - * 34 + *
35 - * Reference : Optimizations of Label Switched Path State Synchronization Procedures 35 + * Reference : Optimizations of Label Switched Path State Synchronization Procedures
36 - for a Stateful PCE draft-ietf-pce-stateful-sync-optimizations-02 36 + for a Stateful PCE draft-ietf-pce-stateful-sync-optimizations-02
37 - * 37 + *
38 - * 38 + *
39 - 39 +
40 - 0 1 2 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | Type=23 | Length=8 | 43 + | Type=23 | Length=8 |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | LSP State DB Version | 45 + | LSP State DB Version |
46 - | | 46 + | |
47 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 47 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
48 - 48 +
49 - */ 49 + */
50 - protected static final Logger log = LoggerFactory.getLogger(StatefulLspDbVerTlv.class); 50 + protected static final Logger log = LoggerFactory.getLogger(StatefulLspDbVerTlv.class);
51 - 51 +
52 - public static final short TYPE = 23; 52 + public static final short TYPE = 23;
53 - public static final short LENGTH = 8; 53 + public static final short LENGTH = 8;
54 - private final long rawValue; 54 + private final long rawValue;
55 - 55 +
56 - /** 56 + /**
57 - * Constructor to initialize rawValue. 57 + * Constructor to initialize rawValue.
58 - * 58 + *
59 - * @param rawValue value 59 + * @param rawValue value
60 - */ 60 + */
61 - public StatefulLspDbVerTlv(final long rawValue) { 61 + public StatefulLspDbVerTlv(final long rawValue) {
62 - this.rawValue = rawValue; 62 + this.rawValue = rawValue;
63 - } 63 + }
64 - 64 +
65 - /** 65 + /**
66 - * Returns object of StatefulLspDbVerTlv. 66 + * Returns object of StatefulLspDbVerTlv.
67 - * 67 + *
68 - * @param raw is LSP State DB Version 68 + * @param raw is LSP State DB Version
69 - * @return object of StatefulLspDbVerTlv 69 + * @return object of StatefulLspDbVerTlv
70 - */ 70 + */
71 - public static StatefulLspDbVerTlv of(final long raw) { 71 + public static StatefulLspDbVerTlv of(final long raw) {
72 - return new StatefulLspDbVerTlv(raw); 72 + return new StatefulLspDbVerTlv(raw);
73 - } 73 + }
74 - 74 +
75 - @Override 75 + @Override
76 - public PcepVersion getVersion() { 76 + public PcepVersion getVersion() {
77 - return PcepVersion.PCEP_1; 77 + return PcepVersion.PCEP_1;
78 - } 78 + }
79 - 79 +
80 - /** 80 + /**
81 - * Returns LSP State DB Version. 81 + * Returns LSP State DB Version.
82 - * 82 + *
83 - * @return rawValue value 83 + * @return rawValue value
84 - */ 84 + */
85 - public long getLong() { 85 + public long getLong() {
86 - return rawValue; 86 + return rawValue;
87 - } 87 + }
88 - 88 +
89 - @Override 89 + @Override
90 - public short getLength() { 90 + public short getLength() {
91 - return LENGTH; 91 + return LENGTH;
92 - } 92 + }
93 - 93 +
94 - @Override 94 + @Override
95 - public short getType() { 95 + public short getType() {
96 - return TYPE; 96 + return TYPE;
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public int hashCode() { 100 + public int hashCode() {
101 - return Objects.hash(rawValue); 101 + return Objects.hash(rawValue);
102 - } 102 + }
103 - 103 +
104 - @Override 104 + @Override
105 - public boolean equals(Object obj) { 105 + public boolean equals(Object obj) {
106 - if (this == obj) { 106 + if (this == obj) {
107 - return true; 107 + return true;
108 - } 108 + }
109 - if (obj instanceof StatefulLspDbVerTlv) { 109 + if (obj instanceof StatefulLspDbVerTlv) {
110 - StatefulLspDbVerTlv other = (StatefulLspDbVerTlv) obj; 110 + StatefulLspDbVerTlv other = (StatefulLspDbVerTlv) obj;
111 - return Objects.equals(this.rawValue, other.rawValue); 111 + return Objects.equals(this.rawValue, other.rawValue);
112 - } 112 + }
113 - return false; 113 + return false;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public int write(ChannelBuffer c) { 117 + public int write(ChannelBuffer c) {
118 - c.writeShort(TYPE); 118 + c.writeShort(TYPE);
119 - c.writeShort(LENGTH); 119 + c.writeShort(LENGTH);
120 - c.writeLong(rawValue); 120 + c.writeLong(rawValue);
121 - return c.writerIndex(); 121 + return c.writerIndex();
122 - } 122 + }
123 - 123 +
124 - /** 124 + /**
125 - * Reads the channel buffer and returns object of StatefulLspDbVerTlv. 125 + * Reads the channel buffer and returns object of StatefulLspDbVerTlv.
126 - * 126 + *
127 - * @param c input channel buffer 127 + * @param c input channel buffer
128 - * @return object of StatefulLspDbVerTlv 128 + * @return object of StatefulLspDbVerTlv
129 - */ 129 + */
130 - public static StatefulLspDbVerTlv read(ChannelBuffer c) { 130 + public static StatefulLspDbVerTlv read(ChannelBuffer c) {
131 - return StatefulLspDbVerTlv.of(c.readLong()); 131 + return StatefulLspDbVerTlv.of(c.readLong());
132 - } 132 + }
133 - 133 +
134 - @Override 134 + @Override
135 - public String toString() { 135 + public String toString() {
136 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 136 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
137 - .toString(); 137 + .toString();
138 - } 138 + }
139 -} 139 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Provides StatefulLspErrorCodeTlv. 29 + * Provides StatefulLspErrorCodeTlv.
30 - */ 30 + */
31 -public class StatefulLspErrorCodeTlv implements PcepValueType { 31 +public class StatefulLspErrorCodeTlv implements PcepValueType {
32 - 32 +
33 - /* LSP-ERROR-CODE TLV format 33 + /* LSP-ERROR-CODE TLV format
34 - * 34 + *
35 - * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10 35 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
36 - * 36 + *
37 - 37 +
38 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Type=20 | Length=4 | 41 + | Type=20 | Length=4 |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | LSP Error Code | 43 + | LSP Error Code |
44 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - 45 +
46 - */ 46 + */
47 - 47 +
48 - protected static final Logger log = LoggerFactory.getLogger(StatefulLspErrorCodeTlv.class); 48 + protected static final Logger log = LoggerFactory.getLogger(StatefulLspErrorCodeTlv.class);
49 - 49 +
50 - public static final short TYPE = 20; 50 + public static final short TYPE = 20;
51 - public static final short LENGTH = 4; 51 + public static final short LENGTH = 4;
52 - private final int rawValue; 52 + private final int rawValue;
53 - 53 +
54 - /** 54 + /**
55 - * Constructor to initialize raw Value. 55 + * Constructor to initialize raw Value.
56 - * 56 + *
57 - * @param rawValue lsp error code value 57 + * @param rawValue lsp error code value
58 - */ 58 + */
59 - public StatefulLspErrorCodeTlv(int rawValue) { 59 + public StatefulLspErrorCodeTlv(int rawValue) {
60 - this.rawValue = rawValue; 60 + this.rawValue = rawValue;
61 - } 61 + }
62 - 62 +
63 - /** 63 + /**
64 - * Creates object of StatefulLspErrorCodeTlv. 64 + * Creates object of StatefulLspErrorCodeTlv.
65 - * 65 + *
66 - * @param raw lsp error code value 66 + * @param raw lsp error code value
67 - * @return object of StatefulLspErrorCodeTlv 67 + * @return object of StatefulLspErrorCodeTlv
68 - */ 68 + */
69 - public static StatefulLspErrorCodeTlv of(int raw) { 69 + public static StatefulLspErrorCodeTlv of(int raw) {
70 - return new StatefulLspErrorCodeTlv(raw); 70 + return new StatefulLspErrorCodeTlv(raw);
71 - } 71 + }
72 - 72 +
73 - @Override 73 + @Override
74 - public PcepVersion getVersion() { 74 + public PcepVersion getVersion() {
75 - return PcepVersion.PCEP_1; 75 + return PcepVersion.PCEP_1;
76 - } 76 + }
77 - 77 +
78 - /** 78 + /**
79 - * Returns lsp error code value. 79 + * Returns lsp error code value.
80 - * 80 + *
81 - * @return lsp error code value 81 + * @return lsp error code value
82 - */ 82 + */
83 - public int getInt() { 83 + public int getInt() {
84 - return rawValue; 84 + return rawValue;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public short getLength() { 88 + public short getLength() {
89 - return LENGTH; 89 + return LENGTH;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public short getType() { 93 + public short getType() {
94 - return TYPE; 94 + return TYPE;
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public int hashCode() { 98 + public int hashCode() {
99 - return Objects.hash(rawValue); 99 + return Objects.hash(rawValue);
100 - } 100 + }
101 - 101 +
102 - @Override 102 + @Override
103 - public boolean equals(Object obj) { 103 + public boolean equals(Object obj) {
104 - if (this == obj) { 104 + if (this == obj) {
105 - return true; 105 + return true;
106 - } 106 + }
107 - if (obj instanceof StatefulLspErrorCodeTlv) { 107 + if (obj instanceof StatefulLspErrorCodeTlv) {
108 - StatefulLspErrorCodeTlv other = (StatefulLspErrorCodeTlv) obj; 108 + StatefulLspErrorCodeTlv other = (StatefulLspErrorCodeTlv) obj;
109 - return Objects.equals(this.rawValue, other.rawValue); 109 + return Objects.equals(this.rawValue, other.rawValue);
110 - } 110 + }
111 - return false; 111 + return false;
112 - } 112 + }
113 - 113 +
114 - @Override 114 + @Override
115 - public int write(ChannelBuffer c) { 115 + public int write(ChannelBuffer c) {
116 - int iLenStartIndex = c.writerIndex(); 116 + int iLenStartIndex = c.writerIndex();
117 - c.writeShort(TYPE); 117 + c.writeShort(TYPE);
118 - c.writeShort(LENGTH); 118 + c.writeShort(LENGTH);
119 - c.writeInt(rawValue); 119 + c.writeInt(rawValue);
120 - return c.writerIndex() - iLenStartIndex; 120 + return c.writerIndex() - iLenStartIndex;
121 - } 121 + }
122 - 122 +
123 - /** 123 + /**
124 - * Reads the channel buffer and returns object of StatefulLspErrorCodeTlv. 124 + * Reads the channel buffer and returns object of StatefulLspErrorCodeTlv.
125 - * 125 + *
126 - * @param c of type channel buffer 126 + * @param c of type channel buffer
127 - * @return object of StatefulLspErrorCodeTlv 127 + * @return object of StatefulLspErrorCodeTlv
128 - */ 128 + */
129 - public static StatefulLspErrorCodeTlv read(ChannelBuffer c) { 129 + public static StatefulLspErrorCodeTlv read(ChannelBuffer c) {
130 - return StatefulLspErrorCodeTlv.of(c.readInt()); 130 + return StatefulLspErrorCodeTlv.of(c.readInt());
131 - } 131 + }
132 - 132 +
133 - @Override 133 + @Override
134 - public String toString() { 134 + public String toString() {
135 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 135 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
136 - .toString(); 136 + .toString();
137 - } 137 + }
138 - 138 +
139 -} 139 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Provides StatefulPceCapabilityTlv. 29 + * Provides StatefulPceCapabilityTlv.
30 - */ 30 + */
31 -public class StatefulPceCapabilityTlv implements PcepValueType { 31 +public class StatefulPceCapabilityTlv implements PcepValueType {
32 - 32 +
33 - /* STATEFUL-PCE-CAPABILITY TLV format 33 + /* STATEFUL-PCE-CAPABILITY TLV format
34 - * 34 + *
35 - * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10 35 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
36 - 36 +
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Type=16 | Length=4 | 40 + | Type=16 | Length=4 |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | Flags |D|T|I|S|U| 42 + | Flags |D|T|I|S|U|
43 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 43 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
44 - 44 +
45 - */ 45 + */
46 - protected static final Logger log = LoggerFactory.getLogger(StatefulPceCapabilityTlv.class); 46 + protected static final Logger log = LoggerFactory.getLogger(StatefulPceCapabilityTlv.class);
47 - 47 +
48 - public static final short TYPE = 16; 48 + public static final short TYPE = 16;
49 - public static final short LENGTH = 4; 49 + public static final short LENGTH = 4;
50 - public static final byte UFLAG_SET = 0x01; 50 + public static final byte UFLAG_SET = 0x01;
51 - public static final byte SFLAG_SET = 0x02; 51 + public static final byte SFLAG_SET = 0x02;
52 - public static final byte IFLAG_SET = 0x04; 52 + public static final byte IFLAG_SET = 0x04;
53 - public static final byte TFLAG_SET = 0x08; 53 + public static final byte TFLAG_SET = 0x08;
54 - public static final byte DFLAG_SET = 0x10; 54 + public static final byte DFLAG_SET = 0x10;
55 - public static final int SET = 1; 55 + public static final int SET = 1;
56 - 56 +
57 - private final int rawValue; 57 + private final int rawValue;
58 - private final boolean bDFlag; 58 + private final boolean bDFlag;
59 - private final boolean bTFlag; 59 + private final boolean bTFlag;
60 - private final boolean bIFlag; 60 + private final boolean bIFlag;
61 - private final boolean bSFlag; 61 + private final boolean bSFlag;
62 - private final boolean bUFlag; 62 + private final boolean bUFlag;
63 - private final boolean isRawValueSet; 63 + private final boolean isRawValueSet;
64 - 64 +
65 - /** 65 + /**
66 - * Constructor to initialize variables. 66 + * Constructor to initialize variables.
67 - * 67 + *
68 - * @param rawValue Flags 68 + * @param rawValue Flags
69 - */ 69 + */
70 - public StatefulPceCapabilityTlv(int rawValue) { 70 + public StatefulPceCapabilityTlv(int rawValue) {
71 - this.rawValue = rawValue; 71 + this.rawValue = rawValue;
72 - isRawValueSet = true; 72 + isRawValueSet = true;
73 - this.bUFlag = (rawValue & UFLAG_SET) == UFLAG_SET ? true : false; 73 + this.bUFlag = (rawValue & UFLAG_SET) == UFLAG_SET ? true : false;
74 - this.bSFlag = (rawValue & SFLAG_SET) == SFLAG_SET ? true : false; 74 + this.bSFlag = (rawValue & SFLAG_SET) == SFLAG_SET ? true : false;
75 - this.bIFlag = (rawValue & IFLAG_SET) == IFLAG_SET ? true : false; 75 + this.bIFlag = (rawValue & IFLAG_SET) == IFLAG_SET ? true : false;
76 - this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET ? true : false; 76 + this.bTFlag = (rawValue & TFLAG_SET) == TFLAG_SET ? true : false;
77 - this.bDFlag = (rawValue & DFLAG_SET) == DFLAG_SET ? true : false; 77 + this.bDFlag = (rawValue & DFLAG_SET) == DFLAG_SET ? true : false;
78 - } 78 + }
79 - 79 +
80 - /** 80 + /**
81 - * Constructor to initialize variables. 81 + * Constructor to initialize variables.
82 - * 82 + *
83 - * @param bDFlag D-flag 83 + * @param bDFlag D-flag
84 - * @param bTFlag T-flag 84 + * @param bTFlag T-flag
85 - * @param bIFlag I-flag 85 + * @param bIFlag I-flag
86 - * @param bSFlag S-flag 86 + * @param bSFlag S-flag
87 - * @param bUFlag U-flag 87 + * @param bUFlag U-flag
88 - */ 88 + */
89 - public StatefulPceCapabilityTlv(boolean bDFlag, boolean bTFlag, boolean bIFlag, boolean bSFlag, boolean bUFlag) { 89 + public StatefulPceCapabilityTlv(boolean bDFlag, boolean bTFlag, boolean bIFlag, boolean bSFlag, boolean bUFlag) {
90 - this.bDFlag = bDFlag; 90 + this.bDFlag = bDFlag;
91 - this.bTFlag = bTFlag; 91 + this.bTFlag = bTFlag;
92 - this.bIFlag = bIFlag; 92 + this.bIFlag = bIFlag;
93 - this.bSFlag = bSFlag; 93 + this.bSFlag = bSFlag;
94 - this.bUFlag = bUFlag; 94 + this.bUFlag = bUFlag;
95 - this.rawValue = 0; 95 + this.rawValue = 0;
96 - isRawValueSet = false; 96 + isRawValueSet = false;
97 - } 97 + }
98 - 98 +
99 - /** 99 + /**
100 - * Returns object of StatefulPceCapabilityTlv. 100 + * Returns object of StatefulPceCapabilityTlv.
101 - * 101 + *
102 - * @param raw value Flags 102 + * @param raw value Flags
103 - * @return object of StatefulPceCapabilityTlv 103 + * @return object of StatefulPceCapabilityTlv
104 - */ 104 + */
105 - public static StatefulPceCapabilityTlv of(final int raw) { 105 + public static StatefulPceCapabilityTlv of(final int raw) {
106 - return new StatefulPceCapabilityTlv(raw); 106 + return new StatefulPceCapabilityTlv(raw);
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public PcepVersion getVersion() { 110 + public PcepVersion getVersion() {
111 - return PcepVersion.PCEP_1; 111 + return PcepVersion.PCEP_1;
112 - } 112 + }
113 - 113 +
114 - /** 114 + /**
115 - * Returns D-flag. 115 + * Returns D-flag.
116 - * 116 + *
117 - * @return bDFlag D-flag 117 + * @return bDFlag D-flag
118 - */ 118 + */
119 - public boolean getDFlag() { 119 + public boolean getDFlag() {
120 - return bDFlag; 120 + return bDFlag;
121 - } 121 + }
122 - 122 +
123 - /** 123 + /**
124 - * Returns T-flag. 124 + * Returns T-flag.
125 - * 125 + *
126 - * @return bTFlag T-flag 126 + * @return bTFlag T-flag
127 - */ 127 + */
128 - public boolean getTFlag() { 128 + public boolean getTFlag() {
129 - return bTFlag; 129 + return bTFlag;
130 - } 130 + }
131 - 131 +
132 - /** 132 + /**
133 - * Returns I-flag. 133 + * Returns I-flag.
134 - * 134 + *
135 - * @return bIFlag I-flag 135 + * @return bIFlag I-flag
136 - */ 136 + */
137 - public boolean getIFlag() { 137 + public boolean getIFlag() {
138 - return bIFlag; 138 + return bIFlag;
139 - } 139 + }
140 - 140 +
141 - /** 141 + /**
142 - * Returns S-flag. 142 + * Returns S-flag.
143 - * 143 + *
144 - * @return bSFlag S-flag 144 + * @return bSFlag S-flag
145 - */ 145 + */
146 - public boolean getSFlag() { 146 + public boolean getSFlag() {
147 - return bSFlag; 147 + return bSFlag;
148 - } 148 + }
149 - 149 +
150 - /** 150 + /**
151 - * Returns U-flag. 151 + * Returns U-flag.
152 - * 152 + *
153 - * @return bUFlag U-flag 153 + * @return bUFlag U-flag
154 - */ 154 + */
155 - public boolean getUFlag() { 155 + public boolean getUFlag() {
156 - return bUFlag; 156 + return bUFlag;
157 - } 157 + }
158 - 158 +
159 - /** 159 + /**
160 - * Returns raw value Flags. 160 + * Returns raw value Flags.
161 - * 161 + *
162 - * @return rawValue Flags 162 + * @return rawValue Flags
163 - */ 163 + */
164 - public int getInt() { 164 + public int getInt() {
165 - return rawValue; 165 + return rawValue;
166 - } 166 + }
167 - 167 +
168 - @Override 168 + @Override
169 - public short getType() { 169 + public short getType() {
170 - return TYPE; 170 + return TYPE;
171 - } 171 + }
172 - 172 +
173 - @Override 173 + @Override
174 - public short getLength() { 174 + public short getLength() {
175 - return LENGTH; 175 + return LENGTH;
176 - } 176 + }
177 - 177 +
178 - @Override 178 + @Override
179 - public int hashCode() { 179 + public int hashCode() {
180 - if (isRawValueSet) { 180 + if (isRawValueSet) {
181 - return Objects.hash(rawValue); 181 + return Objects.hash(rawValue);
182 - } else { 182 + } else {
183 - return Objects.hash(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag); 183 + return Objects.hash(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
184 - } 184 + }
185 - } 185 + }
186 - 186 +
187 - @Override 187 + @Override
188 - public boolean equals(Object obj) { 188 + public boolean equals(Object obj) {
189 - if (this == obj) { 189 + if (this == obj) {
190 - return true; 190 + return true;
191 - } 191 + }
192 - if (obj instanceof StatefulPceCapabilityTlv) { 192 + if (obj instanceof StatefulPceCapabilityTlv) {
193 - StatefulPceCapabilityTlv other = (StatefulPceCapabilityTlv) obj; 193 + StatefulPceCapabilityTlv other = (StatefulPceCapabilityTlv) obj;
194 - if (isRawValueSet) { 194 + if (isRawValueSet) {
195 - return Objects.equals(this.rawValue, other.rawValue); 195 + return Objects.equals(this.rawValue, other.rawValue);
196 - } else { 196 + } else {
197 - return Objects.equals(this.bDFlag, other.bDFlag) && Objects.equals(this.bTFlag, other.bTFlag) 197 + return Objects.equals(this.bDFlag, other.bDFlag) && Objects.equals(this.bTFlag, other.bTFlag)
198 - && Objects.equals(this.bIFlag, other.bIFlag) && Objects.equals(this.bSFlag, other.bSFlag) 198 + && Objects.equals(this.bIFlag, other.bIFlag) && Objects.equals(this.bSFlag, other.bSFlag)
199 - && Objects.equals(this.bUFlag, other.bUFlag); 199 + && Objects.equals(this.bUFlag, other.bUFlag);
200 - } 200 + }
201 - } 201 + }
202 - return false; 202 + return false;
203 - } 203 + }
204 - 204 +
205 - @Override 205 + @Override
206 - public int write(ChannelBuffer c) { 206 + public int write(ChannelBuffer c) {
207 - int iLenStartIndex = c.writerIndex(); 207 + int iLenStartIndex = c.writerIndex();
208 - c.writeShort(TYPE); 208 + c.writeShort(TYPE);
209 - c.writeShort(LENGTH); 209 + c.writeShort(LENGTH);
210 - if (isRawValueSet) { 210 + if (isRawValueSet) {
211 - c.writeInt(rawValue); 211 + c.writeInt(rawValue);
212 - } else { 212 + } else {
213 - int temp = 0; 213 + int temp = 0;
214 - if (bUFlag) { 214 + if (bUFlag) {
215 - temp = temp | UFLAG_SET; 215 + temp = temp | UFLAG_SET;
216 - } 216 + }
217 - if (bSFlag) { 217 + if (bSFlag) {
218 - temp = temp | SFLAG_SET; 218 + temp = temp | SFLAG_SET;
219 - } 219 + }
220 - if (bIFlag) { 220 + if (bIFlag) {
221 - temp = temp | IFLAG_SET; 221 + temp = temp | IFLAG_SET;
222 - } 222 + }
223 - if (bTFlag) { 223 + if (bTFlag) {
224 - temp = temp | TFLAG_SET; 224 + temp = temp | TFLAG_SET;
225 - } 225 + }
226 - if (bDFlag) { 226 + if (bDFlag) {
227 - temp = temp | DFLAG_SET; 227 + temp = temp | DFLAG_SET;
228 - } 228 + }
229 - c.writeInt(temp); 229 + c.writeInt(temp);
230 - } 230 + }
231 - return c.writerIndex() - iLenStartIndex; 231 + return c.writerIndex() - iLenStartIndex;
232 - } 232 + }
233 - 233 +
234 - /** 234 + /**
235 - * Reads from channel buffer and returns object of StatefulPceCapabilityTlv. 235 + * Reads from channel buffer and returns object of StatefulPceCapabilityTlv.
236 - * 236 + *
237 - * @param c input channel buffer 237 + * @param c input channel buffer
238 - * @return object of StatefulPceCapabilityTlv 238 + * @return object of StatefulPceCapabilityTlv
239 - */ 239 + */
240 - public static PcepValueType read(ChannelBuffer c) { 240 + public static PcepValueType read(ChannelBuffer c) {
241 - int temp = c.readInt(); 241 + int temp = c.readInt();
242 - boolean bDFlag; 242 + boolean bDFlag;
243 - boolean bTFlag; 243 + boolean bTFlag;
244 - boolean bIFlag; 244 + boolean bIFlag;
245 - boolean bSFlag; 245 + boolean bSFlag;
246 - boolean bUFlag; 246 + boolean bUFlag;
247 - 247 +
248 - bUFlag = (temp & UFLAG_SET) == UFLAG_SET ? true : false; 248 + bUFlag = (temp & UFLAG_SET) == UFLAG_SET ? true : false;
249 - bSFlag = (temp & SFLAG_SET) == SFLAG_SET ? true : false; 249 + bSFlag = (temp & SFLAG_SET) == SFLAG_SET ? true : false;
250 - bIFlag = (temp & IFLAG_SET) == IFLAG_SET ? true : false; 250 + bIFlag = (temp & IFLAG_SET) == IFLAG_SET ? true : false;
251 - bTFlag = (temp & TFLAG_SET) == TFLAG_SET ? true : false; 251 + bTFlag = (temp & TFLAG_SET) == TFLAG_SET ? true : false;
252 - bDFlag = (temp & DFLAG_SET) == DFLAG_SET ? true : false; 252 + bDFlag = (temp & DFLAG_SET) == DFLAG_SET ? true : false;
253 - 253 +
254 - return new StatefulPceCapabilityTlv(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag); 254 + return new StatefulPceCapabilityTlv(bDFlag, bTFlag, bIFlag, bSFlag, bUFlag);
255 - } 255 + }
256 - 256 +
257 - @Override 257 + @Override
258 - public String toString() { 258 + public String toString() {
259 - return MoreObjects.toStringHelper(getClass()).add("type", TYPE).add("Length", LENGTH).add("DFlag", bDFlag) 259 + return MoreObjects.toStringHelper(getClass()).add("type", TYPE).add("Length", LENGTH).add("DFlag", bDFlag)
260 - .add("TFlag", bTFlag).add("IFlag", bIFlag).add("SFlag", bSFlag).add("UFlag", bUFlag).toString(); 260 + .add("TFlag", bTFlag).add("IFlag", bIFlag).add("SFlag", bSFlag).add("UFlag", bUFlag).toString();
261 - } 261 + }
262 -} 262 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
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.exceptions.PcepParseException;
23 -import org.onosproject.pcepio.protocol.PcepVersion; 23 +import org.onosproject.pcepio.protocol.PcepVersion;
24 -import org.slf4j.Logger; 24 +import org.slf4j.Logger;
25 -import org.slf4j.LoggerFactory; 25 +import org.slf4j.LoggerFactory;
26 - 26 +
27 -import com.google.common.base.MoreObjects; 27 +import com.google.common.base.MoreObjects;
28 -import com.google.common.base.MoreObjects.ToStringHelper; 28 +import com.google.common.base.MoreObjects.ToStringHelper;
29 - 29 +
30 -/** 30 +/**
31 - * Provides StatefulRsvpErrorSpecTlv. 31 + * Provides StatefulRsvpErrorSpecTlv.
32 - */ 32 + */
33 -public class StatefulRsvpErrorSpecTlv implements PcepValueType { 33 +public class StatefulRsvpErrorSpecTlv implements PcepValueType {
34 - 34 +
35 - protected static final Logger log = LoggerFactory.getLogger(StatefulRsvpErrorSpecTlv.class); 35 + protected static final Logger log = LoggerFactory.getLogger(StatefulRsvpErrorSpecTlv.class);
36 - 36 +
37 - /* RSVP-ERROR-SPEC TLV format 37 + /* RSVP-ERROR-SPEC TLV format
38 - * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10 38 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
39 - * 39 + *
40 - * 40 + *
41 - 41 +
42 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 44 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
45 - | Type=21 | Length (variable) | 45 + | Type=21 | Length (variable) |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - | | 47 + | |
48 - + RSVP ERROR_SPEC or USER_ERROR_SPEC Object + 48 + + RSVP ERROR_SPEC or USER_ERROR_SPEC Object +
49 - | | 49 + | |
50 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 50 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 - 51 +
52 - 0 1 2 3 52 + 0 1 2 3
53 - +-------------+-------------+-------------+-------------+ 53 + +-------------+-------------+-------------+-------------+
54 - | Length (bytes) | Class-Num | C-Type | 54 + | Length (bytes) | Class-Num | C-Type |
55 - +-------------+-------------+-------------+-------------+ 55 + +-------------+-------------+-------------+-------------+
56 - | | 56 + | |
57 - // (Object contents) // 57 + // (Object contents) //
58 - | | 58 + | |
59 - +-------------+-------------+-------------+-------------+ 59 + +-------------+-------------+-------------+-------------+
60 - 60 +
61 - Ref : ERROR_SPEC @ RFC2205 61 + Ref : ERROR_SPEC @ RFC2205
62 - 62 +
63 - IPv4 ERROR_SPEC object: Class = 6, C-Type = 1 63 + IPv4 ERROR_SPEC object: Class = 6, C-Type = 1
64 - +-------------+-------------+-------------+-------------+ 64 + +-------------+-------------+-------------+-------------+
65 - | IPv4 Error Node Address (4 bytes) | 65 + | IPv4 Error Node Address (4 bytes) |
66 - +-------------+-------------+-------------+-------------+ 66 + +-------------+-------------+-------------+-------------+
67 - | Flags | Error Code | Error Value | 67 + | Flags | Error Code | Error Value |
68 - +-------------+-------------+-------------+-------------+ 68 + +-------------+-------------+-------------+-------------+
69 - 69 +
70 - 70 +
71 - IPv6 ERROR_SPEC object: Class = 6, C-Type = 2 71 + IPv6 ERROR_SPEC object: Class = 6, C-Type = 2
72 - +-------------+-------------+-------------+-------------+ 72 + +-------------+-------------+-------------+-------------+
73 - | | 73 + | |
74 - + + 74 + + +
75 - | | 75 + | |
76 - + IPv6 Error Node Address (16 bytes) + 76 + + IPv6 Error Node Address (16 bytes) +
77 - | | 77 + | |
78 - + + 78 + + +
79 - | | 79 + | |
80 - +-------------+-------------+-------------+-------------+ 80 + +-------------+-------------+-------------+-------------+
81 - | Flags | Error Code | Error Value | 81 + | Flags | Error Code | Error Value |
82 - +-------------+-------------+-------------+-------------+ 82 + +-------------+-------------+-------------+-------------+
83 - 83 +
84 - 84 +
85 - Ref : USER_ERROR_SPEC @ RFC5284 85 + Ref : USER_ERROR_SPEC @ RFC5284
86 - USER_ERROR_SPEC object: Class = 194, C-Type = 1 86 + USER_ERROR_SPEC object: Class = 194, C-Type = 1
87 - 0 1 2 3 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 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 - +---------------+---------------+---------------+---------------+ 89 + +---------------+---------------+---------------+---------------+
90 - | Enterprise Number | 90 + | Enterprise Number |
91 - +---------------+---------------+---------------+---------------+ 91 + +---------------+---------------+---------------+---------------+
92 - | Sub Org | Err Desc Len | User Error Value | 92 + | Sub Org | Err Desc Len | User Error Value |
93 - +---------------+---------------+---------------+---------------+ 93 + +---------------+---------------+---------------+---------------+
94 - | | 94 + | |
95 - ~ Error Description ~ 95 + ~ Error Description ~
96 - | | 96 + | |
97 - +---------------+---------------+---------------+---------------+ 97 + +---------------+---------------+---------------+---------------+
98 - | | 98 + | |
99 - ~ User-Defined Subobjects ~ 99 + ~ User-Defined Subobjects ~
100 - | | 100 + | |
101 - +---------------+---------------+---------------+---------------+ 101 + +---------------+---------------+---------------+---------------+
102 - 102 +
103 - */ 103 + */
104 - 104 +
105 - public static final short TYPE = 21; 105 + public static final short TYPE = 21;
106 - public static final int OBJECT_HEADER_LENGTH = 4; 106 + public static final int OBJECT_HEADER_LENGTH = 4;
107 - private short hLength; 107 + private short hLength;
108 - 108 +
109 - private final PcepRsvpErrorSpec rsvpErrSpecObj; 109 + private final PcepRsvpErrorSpec rsvpErrSpecObj;
110 - private final boolean isErrSpceObjSet; 110 + private final boolean isErrSpceObjSet;
111 - 111 +
112 - /** 112 + /**
113 - * Constructor to initialize errSpecObj. 113 + * Constructor to initialize errSpecObj.
114 - * 114 + *
115 - * @param rsvpErrSpecObj Rsvp error spec object 115 + * @param rsvpErrSpecObj Rsvp error spec object
116 - */ 116 + */
117 - public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj) { 117 + public StatefulRsvpErrorSpecTlv(PcepRsvpErrorSpec rsvpErrSpecObj) {
118 - this.rsvpErrSpecObj = rsvpErrSpecObj; 118 + this.rsvpErrSpecObj = rsvpErrSpecObj;
119 - this.isErrSpceObjSet = true; 119 + this.isErrSpceObjSet = true;
120 - } 120 + }
121 - 121 +
122 - /** 122 + /**
123 - * Returns PcepRsvpErrorSpecObject. 123 + * Returns PcepRsvpErrorSpecObject.
124 - * 124 + *
125 - * @return rsvpErrSpecObj 125 + * @return rsvpErrSpecObj
126 - */ 126 + */
127 - public PcepRsvpErrorSpec getPcepRsvpErrorSpec() { 127 + public PcepRsvpErrorSpec getPcepRsvpErrorSpec() {
128 - return this.rsvpErrSpecObj; 128 + return this.rsvpErrSpecObj;
129 - } 129 + }
130 - 130 +
131 - @Override 131 + @Override
132 - public PcepVersion getVersion() { 132 + public PcepVersion getVersion() {
133 - return PcepVersion.PCEP_1; 133 + return PcepVersion.PCEP_1;
134 - } 134 + }
135 - 135 +
136 - @Override 136 + @Override
137 - public short getType() { 137 + public short getType() {
138 - return TYPE; 138 + return TYPE;
139 - } 139 + }
140 - 140 +
141 - @Override 141 + @Override
142 - public short getLength() { 142 + public short getLength() {
143 - return hLength; 143 + return hLength;
144 - } 144 + }
145 - 145 +
146 - /** 146 + /**
147 - * Reads channel buffer and returns object of StatefulRsvpErrorSpecTlv. 147 + * Reads channel buffer and returns object of StatefulRsvpErrorSpecTlv.
148 - * 148 + *
149 - * @param cb of type channel buffer 149 + * @param cb of type channel buffer
150 - * @return object of StatefulRsvpErrorSpecTlv 150 + * @return object of StatefulRsvpErrorSpecTlv
151 - * @throws PcepParseException while parsing this tlv from channel buffer 151 + * @throws PcepParseException while parsing this tlv from channel buffer
152 - */ 152 + */
153 - public static PcepValueType read(ChannelBuffer cb) throws PcepParseException { 153 + public static PcepValueType read(ChannelBuffer cb) throws PcepParseException {
154 - 154 +
155 - PcepRsvpErrorSpec rsvpErrSpecObj = null; 155 + PcepRsvpErrorSpec rsvpErrSpecObj = null;
156 - PcepRsvpSpecObjHeader rsvpErrSpecObjHeader; 156 + PcepRsvpSpecObjHeader rsvpErrSpecObjHeader;
157 - 157 +
158 - cb.markReaderIndex(); 158 + cb.markReaderIndex();
159 - rsvpErrSpecObjHeader = PcepRsvpSpecObjHeader.read(cb); 159 + rsvpErrSpecObjHeader = PcepRsvpSpecObjHeader.read(cb);
160 - cb.resetReaderIndex(); 160 + cb.resetReaderIndex();
161 - 161 +
162 - if (PcepRsvpIpv4ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum() 162 + if (PcepRsvpIpv4ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
163 - && PcepRsvpIpv4ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) { 163 + && PcepRsvpIpv4ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
164 - rsvpErrSpecObj = PcepRsvpIpv4ErrorSpec.read(cb); 164 + rsvpErrSpecObj = PcepRsvpIpv4ErrorSpec.read(cb);
165 - } else if (PcepRsvpIpv6ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum() 165 + } else if (PcepRsvpIpv6ErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
166 - && PcepRsvpIpv6ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) { 166 + && PcepRsvpIpv6ErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
167 - rsvpErrSpecObj = PcepRsvpIpv6ErrorSpec.read(cb); 167 + rsvpErrSpecObj = PcepRsvpIpv6ErrorSpec.read(cb);
168 - } else if (PcepRsvpUserErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum() 168 + } else if (PcepRsvpUserErrorSpec.CLASS_NUM == rsvpErrSpecObjHeader.getObjClassNum()
169 - && PcepRsvpUserErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) { 169 + && PcepRsvpUserErrorSpec.CLASS_TYPE == rsvpErrSpecObjHeader.getObjClassType()) {
170 - rsvpErrSpecObj = PcepRsvpUserErrorSpec.read(cb); 170 + rsvpErrSpecObj = PcepRsvpUserErrorSpec.read(cb);
171 - } 171 + }
172 - return new StatefulRsvpErrorSpecTlv(rsvpErrSpecObj); 172 + return new StatefulRsvpErrorSpecTlv(rsvpErrSpecObj);
173 - } 173 + }
174 - 174 +
175 - @Override 175 + @Override
176 - public int hashCode() { 176 + public int hashCode() {
177 - return Objects.hash(rsvpErrSpecObj.hashCode()); 177 + return Objects.hash(rsvpErrSpecObj.hashCode());
178 - } 178 + }
179 - 179 +
180 - @Override 180 + @Override
181 - public boolean equals(Object obj) { 181 + public boolean equals(Object obj) {
182 - if (this == obj) { 182 + if (this == obj) {
183 - return true; 183 + return true;
184 - } 184 + }
185 - if (obj instanceof StatefulRsvpErrorSpecTlv) { 185 + if (obj instanceof StatefulRsvpErrorSpecTlv) {
186 - StatefulRsvpErrorSpecTlv other = (StatefulRsvpErrorSpecTlv) obj; 186 + StatefulRsvpErrorSpecTlv other = (StatefulRsvpErrorSpecTlv) obj;
187 - return Objects.equals(this.rsvpErrSpecObj, other.rsvpErrSpecObj); 187 + return Objects.equals(this.rsvpErrSpecObj, other.rsvpErrSpecObj);
188 - } 188 + }
189 - return false; 189 + return false;
190 - } 190 + }
191 - 191 +
192 - @Override 192 + @Override
193 - public int write(ChannelBuffer c) { 193 + public int write(ChannelBuffer c) {
194 - int iStartIndex = c.writerIndex(); 194 + int iStartIndex = c.writerIndex();
195 - c.writeShort(TYPE); 195 + c.writeShort(TYPE);
196 - int tlvLenIndex = c.writerIndex(); 196 + int tlvLenIndex = c.writerIndex();
197 - hLength = 0; 197 + hLength = 0;
198 - c.writeShort(hLength); 198 + c.writeShort(hLength);
199 - if (isErrSpceObjSet) { 199 + if (isErrSpceObjSet) {
200 - rsvpErrSpecObj.write(c); 200 + rsvpErrSpecObj.write(c);
201 - } 201 + }
202 - hLength = (short) (c.writerIndex() - iStartIndex); 202 + hLength = (short) (c.writerIndex() - iStartIndex);
203 - c.setShort(tlvLenIndex, (hLength - OBJECT_HEADER_LENGTH)); 203 + c.setShort(tlvLenIndex, (hLength - OBJECT_HEADER_LENGTH));
204 - 204 +
205 - return c.writerIndex() - iStartIndex; 205 + return c.writerIndex() - iStartIndex;
206 - } 206 + }
207 - 207 +
208 - @Override 208 + @Override
209 - public String toString() { 209 + public String toString() {
210 - ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass()); 210 + ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
211 - 211 +
212 - if (!isErrSpceObjSet) { 212 + if (!isErrSpceObjSet) {
213 - toStrHelper.add("Type", TYPE).add("Length", hLength); 213 + toStrHelper.add("Type", TYPE).add("Length", hLength);
214 - } else { 214 + } else {
215 - toStrHelper.add("Type", TYPE).add("Length", hLength).add("RSVPErrorSpecObject", rsvpErrSpecObj); 215 + toStrHelper.add("Type", TYPE).add("Length", hLength).add("RSVPErrorSpecObject", rsvpErrSpecObj);
216 - } 216 + }
217 - return toStrHelper.toString(); 217 + return toStrHelper.toString();
218 - } 218 + }
219 -} 219 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 - 16 +
17 -package org.onosproject.pcepio.types; 17 +package org.onosproject.pcepio.types;
18 - 18 +
19 -import java.util.Objects; 19 +import java.util.Objects;
20 - 20 +
21 -import org.jboss.netty.buffer.ChannelBuffer; 21 +import org.jboss.netty.buffer.ChannelBuffer;
22 -import org.onosproject.pcepio.protocol.PcepVersion; 22 +import org.onosproject.pcepio.protocol.PcepVersion;
23 -import org.slf4j.Logger; 23 +import org.slf4j.Logger;
24 -import org.slf4j.LoggerFactory; 24 +import org.slf4j.LoggerFactory;
25 - 25 +
26 -import com.google.common.base.MoreObjects; 26 +import com.google.common.base.MoreObjects;
27 - 27 +
28 -/** 28 +/**
29 - * Provides SymbolicPathNameTlv. 29 + * Provides SymbolicPathNameTlv.
30 - */ 30 + */
31 -public class SymbolicPathNameTlv implements PcepValueType { 31 +public class SymbolicPathNameTlv implements PcepValueType {
32 - 32 +
33 - /* 33 + /*
34 - * SYMBOLIC-PATH-NAME TLV format 34 + * SYMBOLIC-PATH-NAME TLV format
35 - * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10 35 + * Reference :PCEP Extensions for Stateful PCE draft-ietf-pce-stateful-pce-10
36 - * 36 + *
37 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - | Type=17 | Length (variable) | 40 + | Type=17 | Length (variable) |
41 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 41 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
42 - | | 42 + | |
43 - // Symbolic Path Name // 43 + // Symbolic Path Name //
44 - | | 44 + | |
45 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 45 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
46 - */ 46 + */
47 - protected static final Logger log = LoggerFactory.getLogger(SymbolicPathNameTlv.class); 47 + protected static final Logger log = LoggerFactory.getLogger(SymbolicPathNameTlv.class);
48 - 48 +
49 - public static final short TYPE = 17; 49 + public static final short TYPE = 17;
50 - private short hLength; 50 + private short hLength;
51 - 51 +
52 - private final byte[] rawValue; 52 + private final byte[] rawValue;
53 - 53 +
54 - /** 54 + /**
55 - * Constructor to initialize raw Value. 55 + * Constructor to initialize raw Value.
56 - * 56 + *
57 - * @param rawValue Symbolic path name 57 + * @param rawValue Symbolic path name
58 - */ 58 + */
59 - public SymbolicPathNameTlv(byte[] rawValue) { 59 + public SymbolicPathNameTlv(byte[] rawValue) {
60 - this.rawValue = rawValue; 60 + this.rawValue = rawValue;
61 - this.hLength = (short) rawValue.length; 61 + this.hLength = (short) rawValue.length;
62 - } 62 + }
63 - 63 +
64 - /** 64 + /**
65 - * Constructor to initialize raw Value. 65 + * Constructor to initialize raw Value.
66 - * 66 + *
67 - * @param rawValue Symbolic path name 67 + * @param rawValue Symbolic path name
68 - * @param hLength length of Symbolic path name 68 + * @param hLength length of Symbolic path name
69 - */ 69 + */
70 - public SymbolicPathNameTlv(byte[] rawValue, short hLength) { 70 + public SymbolicPathNameTlv(byte[] rawValue, short hLength) {
71 - this.rawValue = rawValue; 71 + this.rawValue = rawValue;
72 - if (0 == hLength) { 72 + if (0 == hLength) {
73 - this.hLength = (short) rawValue.length; 73 + this.hLength = (short) rawValue.length;
74 - } else { 74 + } else {
75 - this.hLength = hLength; 75 + this.hLength = hLength;
76 - } 76 + }
77 - } 77 + }
78 - 78 +
79 - /** 79 + /**
80 - * Creates an object of SymbolicPathNameTlv. 80 + * Creates an object of SymbolicPathNameTlv.
81 - * 81 + *
82 - * @param raw Symbolic path name 82 + * @param raw Symbolic path name
83 - * @param hLength length of Symbolic path name 83 + * @param hLength length of Symbolic path name
84 - * @return object of SymbolicPathNameTlv 84 + * @return object of SymbolicPathNameTlv
85 - */ 85 + */
86 - public static SymbolicPathNameTlv of(final byte[] raw, short hLength) { 86 + public static SymbolicPathNameTlv of(final byte[] raw, short hLength) {
87 - return new SymbolicPathNameTlv(raw, hLength); 87 + return new SymbolicPathNameTlv(raw, hLength);
88 - } 88 + }
89 - 89 +
90 - /** 90 + /**
91 - * Returns Symbolic path name. 91 + * Returns Symbolic path name.
92 - * 92 + *
93 - * @return Symbolic path name byte array 93 + * @return Symbolic path name byte array
94 - */ 94 + */
95 - public byte[] getValue() { 95 + public byte[] getValue() {
96 - return rawValue; 96 + return rawValue;
97 - } 97 + }
98 - 98 +
99 - @Override 99 + @Override
100 - public PcepVersion getVersion() { 100 + public PcepVersion getVersion() {
101 - return PcepVersion.PCEP_1; 101 + return PcepVersion.PCEP_1;
102 - } 102 + }
103 - 103 +
104 - @Override 104 + @Override
105 - public short getType() { 105 + public short getType() {
106 - return TYPE; 106 + return TYPE;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public short getLength() { 110 + public short getLength() {
111 - return hLength; 111 + return hLength;
112 - } 112 + }
113 - 113 +
114 - @Override 114 + @Override
115 - public int hashCode() { 115 + public int hashCode() {
116 - return Objects.hash(rawValue); 116 + return Objects.hash(rawValue);
117 - } 117 + }
118 - 118 +
119 - @Override 119 + @Override
120 - public boolean equals(Object obj) { 120 + public boolean equals(Object obj) {
121 - if (this == obj) { 121 + if (this == obj) {
122 - return true; 122 + return true;
123 - } 123 + }
124 - if (obj instanceof SymbolicPathNameTlv) { 124 + if (obj instanceof SymbolicPathNameTlv) {
125 - SymbolicPathNameTlv other = (SymbolicPathNameTlv) obj; 125 + SymbolicPathNameTlv other = (SymbolicPathNameTlv) obj;
126 - return Objects.equals(this.rawValue, other.rawValue); 126 + return Objects.equals(this.rawValue, other.rawValue);
127 - } 127 + }
128 - return false; 128 + return false;
129 - } 129 + }
130 - 130 +
131 - @Override 131 + @Override
132 - public int write(ChannelBuffer c) { 132 + public int write(ChannelBuffer c) {
133 - int iLenStartIndex = c.writerIndex(); 133 + int iLenStartIndex = c.writerIndex();
134 - c.writeShort(TYPE); 134 + c.writeShort(TYPE);
135 - c.writeShort(hLength); 135 + c.writeShort(hLength);
136 - c.writeBytes(rawValue); 136 + c.writeBytes(rawValue);
137 - return c.writerIndex() - iLenStartIndex; 137 + return c.writerIndex() - iLenStartIndex;
138 - } 138 + }
139 - 139 +
140 - /** 140 + /**
141 - * Reads channel buffer and returns object of SymbolicPathNameTlv. 141 + * Reads channel buffer and returns object of SymbolicPathNameTlv.
142 - * 142 + *
143 - * @param c of type channel buffer 143 + * @param c of type channel buffer
144 - * @param hLength length of bytes to read 144 + * @param hLength length of bytes to read
145 - * @return object of SymbolicPathNameTlv 145 + * @return object of SymbolicPathNameTlv
146 - */ 146 + */
147 - public static SymbolicPathNameTlv read(ChannelBuffer c, short hLength) { 147 + public static SymbolicPathNameTlv read(ChannelBuffer c, short hLength) {
148 - byte[] symbolicPathName = new byte[hLength]; 148 + byte[] symbolicPathName = new byte[hLength];
149 - c.readBytes(symbolicPathName, 0, hLength); 149 + c.readBytes(symbolicPathName, 0, hLength);
150 - return new SymbolicPathNameTlv(symbolicPathName, hLength); 150 + return new SymbolicPathNameTlv(symbolicPathName, hLength);
151 - } 151 + }
152 - 152 +
153 - @Override 153 + @Override
154 - public String toString() { 154 + public String toString() {
155 - return MoreObjects.toStringHelper(getClass()).add("SymbolicPathName ", rawValue).toString(); 155 + return MoreObjects.toStringHelper(getClass()).add("SymbolicPathName ", rawValue).toString();
156 - } 156 + }
157 -} 157 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides TEDefaultMetricTlv. 28 + * Provides TEDefaultMetricTlv.
29 - */ 29 + */
30 -public class TEDefaultMetricTlv implements PcepValueType { 30 +public class TEDefaultMetricTlv implements PcepValueType {
31 - 31 +
32 - /* 32 + /*
33 - * Reference :| [I-D.ietf-idr- ls-distribution] /3.3.2.3 33 + * Reference :| [I-D.ietf-idr- ls-distribution] /3.3.2.3
34 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=TDB37 | Length=4 | 37 + | Type=TDB37 | Length=4 |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | TE Default Link Metric | 39 + | TE Default Link Metric |
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - 41 +
42 - */ 42 + */
43 - protected static final Logger log = LoggerFactory.getLogger(TEDefaultMetricTlv.class); 43 + protected static final Logger log = LoggerFactory.getLogger(TEDefaultMetricTlv.class);
44 - 44 +
45 - public static final short TYPE = 13400; //TDB37 45 + public static final short TYPE = 13400; //TDB37
46 - public static final short LENGTH = 4; 46 + public static final short LENGTH = 4;
47 - 47 +
48 - private final int rawValue; 48 + private final int rawValue;
49 - 49 +
50 - /** 50 + /**
51 - * Constructor to initialize rawValue. 51 + * Constructor to initialize rawValue.
52 - * 52 + *
53 - * @param rawValue TE Default Link Metric 53 + * @param rawValue TE Default Link Metric
54 - */ 54 + */
55 - public TEDefaultMetricTlv(int rawValue) { 55 + public TEDefaultMetricTlv(int rawValue) {
56 - this.rawValue = rawValue; 56 + this.rawValue = rawValue;
57 - } 57 + }
58 - 58 +
59 - /** 59 + /**
60 - * Returns newly created TEDefaultMetricTlv object. 60 + * Returns newly created TEDefaultMetricTlv object.
61 - * 61 + *
62 - * @param raw raw value 62 + * @param raw raw value
63 - * @return object of TEDefaultMetricTlv. 63 + * @return object of TEDefaultMetricTlv.
64 - */ 64 + */
65 - public static TEDefaultMetricTlv of(final int raw) { 65 + public static TEDefaultMetricTlv of(final int raw) {
66 - return new TEDefaultMetricTlv(raw); 66 + return new TEDefaultMetricTlv(raw);
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns raw value. 70 + * Returns raw value.
71 - * 71 + *
72 - * @return rawValue TE Default Link Metric 72 + * @return rawValue TE Default Link Metric
73 - */ 73 + */
74 - public int getInt() { 74 + public int getInt() {
75 - return rawValue; 75 + return rawValue;
76 - } 76 + }
77 - 77 +
78 - @Override 78 + @Override
79 - public PcepVersion getVersion() { 79 + public PcepVersion getVersion() {
80 - return PcepVersion.PCEP_1; 80 + return PcepVersion.PCEP_1;
81 - } 81 + }
82 - 82 +
83 - @Override 83 + @Override
84 - public short getType() { 84 + public short getType() {
85 - return TYPE; 85 + return TYPE;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public short getLength() { 89 + public short getLength() {
90 - return LENGTH; 90 + return LENGTH;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public int hashCode() { 94 + public int hashCode() {
95 - return Objects.hash(rawValue); 95 + return Objects.hash(rawValue);
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public boolean equals(Object obj) { 99 + public boolean equals(Object obj) {
100 - if (this == obj) { 100 + if (this == obj) {
101 - return true; 101 + return true;
102 - } 102 + }
103 - if (obj instanceof TEDefaultMetricTlv) { 103 + if (obj instanceof TEDefaultMetricTlv) {
104 - TEDefaultMetricTlv other = (TEDefaultMetricTlv) obj; 104 + TEDefaultMetricTlv other = (TEDefaultMetricTlv) obj;
105 - return Objects.equals(this.rawValue, other.rawValue); 105 + return Objects.equals(this.rawValue, other.rawValue);
106 - } 106 + }
107 - return false; 107 + return false;
108 - } 108 + }
109 - 109 +
110 - @Override 110 + @Override
111 - public int write(ChannelBuffer c) { 111 + public int write(ChannelBuffer c) {
112 - int iLenStartIndex = c.writerIndex(); 112 + int iLenStartIndex = c.writerIndex();
113 - c.writeShort(TYPE); 113 + c.writeShort(TYPE);
114 - c.writeShort(LENGTH); 114 + c.writeShort(LENGTH);
115 - c.writeInt(rawValue); 115 + c.writeInt(rawValue);
116 - return c.writerIndex() - iLenStartIndex; 116 + return c.writerIndex() - iLenStartIndex;
117 - } 117 + }
118 - 118 +
119 - /** 119 + /**
120 - * Reads channel buffer and returns object of TEDefaultMetricTlv. 120 + * Reads channel buffer and returns object of TEDefaultMetricTlv.
121 - * 121 + *
122 - * @param c input channel buffer 122 + * @param c input channel buffer
123 - * @return object of TEDefaultMetricTlv 123 + * @return object of TEDefaultMetricTlv
124 - */ 124 + */
125 - public static TEDefaultMetricTlv read(ChannelBuffer c) { 125 + public static TEDefaultMetricTlv read(ChannelBuffer c) {
126 - return TEDefaultMetricTlv.of(c.readInt()); 126 + return TEDefaultMetricTlv.of(c.readInt());
127 - } 127 + }
128 - 128 +
129 - @Override 129 + @Override
130 - public String toString() { 130 + public String toString() {
131 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 131 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
132 - .toString(); 132 + .toString();
133 - } 133 + }
134 -} 134 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Iterator; 18 +import java.util.Iterator;
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 -import java.util.Objects; 21 +import java.util.Objects;
22 - 22 +
23 -import org.jboss.netty.buffer.ChannelBuffer; 23 +import org.jboss.netty.buffer.ChannelBuffer;
24 -import org.onosproject.pcepio.exceptions.PcepParseException; 24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 -import org.onosproject.pcepio.protocol.PcepVersion; 25 +import org.onosproject.pcepio.protocol.PcepVersion;
26 -import org.slf4j.Logger; 26 +import org.slf4j.Logger;
27 -import org.slf4j.LoggerFactory; 27 +import org.slf4j.LoggerFactory;
28 - 28 +
29 -import com.google.common.base.MoreObjects; 29 +import com.google.common.base.MoreObjects;
30 - 30 +
31 -/** 31 +/**
32 - * Provides TELinkAttributesTlv. 32 + * Provides TELinkAttributesTlv.
33 - */ 33 + */
34 -public class TELinkAttributesTlv implements PcepValueType { 34 +public class TELinkAttributesTlv implements PcepValueType {
35 - 35 +
36 - /* 36 + /*
37 - * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02 37 + * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
38 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Type=[TBD27] | Length | 41 + | Type=[TBD27] | Length |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | | 43 + | |
44 - // Link Attributes Sub-TLVs (variable) // 44 + // Link Attributes Sub-TLVs (variable) //
45 - | | 45 + | |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - */ 47 + */
48 - 48 +
49 - protected static final Logger log = LoggerFactory.getLogger(TELinkAttributesTlv.class); 49 + protected static final Logger log = LoggerFactory.getLogger(TELinkAttributesTlv.class);
50 - 50 +
51 - public static final short TYPE = 1897; //TODD:change this TBD27 51 + public static final short TYPE = 1897; //TODD:change this TBD27
52 - public short hLength; 52 + public short hLength;
53 - 53 +
54 - public static final int TLV_HEADER_LENGTH = 4; 54 + public static final int TLV_HEADER_LENGTH = 4;
55 - 55 +
56 - // LinkDescriptors Sub-TLVs (variable) 56 + // LinkDescriptors Sub-TLVs (variable)
57 - private LinkedList<PcepValueType> llLinkAttributesSubTLVs; 57 + private LinkedList<PcepValueType> llLinkAttributesSubTLVs;
58 - 58 +
59 - /** 59 + /**
60 - * Constructor to initialize Link Attributes Sub TLVs. 60 + * Constructor to initialize Link Attributes Sub TLVs.
61 - * 61 + *
62 - * @param llLinkAttributesSubTLVs linked list of PcepValueType 62 + * @param llLinkAttributesSubTLVs linked list of PcepValueType
63 - */ 63 + */
64 - public TELinkAttributesTlv(LinkedList<PcepValueType> llLinkAttributesSubTLVs) { 64 + public TELinkAttributesTlv(LinkedList<PcepValueType> llLinkAttributesSubTLVs) {
65 - this.llLinkAttributesSubTLVs = llLinkAttributesSubTLVs; 65 + this.llLinkAttributesSubTLVs = llLinkAttributesSubTLVs;
66 - } 66 + }
67 - 67 +
68 - /** 68 + /**
69 - * Returns object of TE Link Attributes TLV. 69 + * Returns object of TE Link Attributes TLV.
70 - * 70 + *
71 - * @param llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV 71 + * @param llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
72 - * @return object of TELinkAttributesTlv 72 + * @return object of TELinkAttributesTlv
73 - */ 73 + */
74 - public static TELinkAttributesTlv of(final LinkedList<PcepValueType> llLinkAttributesSubTLVs) { 74 + public static TELinkAttributesTlv of(final LinkedList<PcepValueType> llLinkAttributesSubTLVs) {
75 - return new TELinkAttributesTlv(llLinkAttributesSubTLVs); 75 + return new TELinkAttributesTlv(llLinkAttributesSubTLVs);
76 - } 76 + }
77 - 77 +
78 - /** 78 + /**
79 - * Returns linked list of Link Attribute of Sub TLV. 79 + * Returns linked list of Link Attribute of Sub TLV.
80 - * 80 + *
81 - * @return llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV 81 + * @return llLinkAttributesSubTLVs linked list of Link Attribute of Sub TLV
82 - */ 82 + */
83 - public LinkedList<PcepValueType> getllLinkAttributesSubTLVs() { 83 + public LinkedList<PcepValueType> getllLinkAttributesSubTLVs() {
84 - return llLinkAttributesSubTLVs; 84 + return llLinkAttributesSubTLVs;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public PcepVersion getVersion() { 88 + public PcepVersion getVersion() {
89 - return PcepVersion.PCEP_1; 89 + return PcepVersion.PCEP_1;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public short getType() { 93 + public short getType() {
94 - return TYPE; 94 + return TYPE;
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public short getLength() { 98 + public short getLength() {
99 - return hLength; 99 + return hLength;
100 - } 100 + }
101 - 101 +
102 - @Override 102 + @Override
103 - public int hashCode() { 103 + public int hashCode() {
104 - return Objects.hash(llLinkAttributesSubTLVs.hashCode()); 104 + return Objects.hash(llLinkAttributesSubTLVs.hashCode());
105 - } 105 + }
106 - 106 +
107 - @Override 107 + @Override
108 - public boolean equals(Object obj) { 108 + public boolean equals(Object obj) {
109 - if (this == obj) { 109 + if (this == obj) {
110 - return true; 110 + return true;
111 - } 111 + }
112 - /* 112 + /*
113 - * Here we have a list of Tlv so to compare each sub tlv between the object 113 + * Here we have a list of Tlv so to compare each sub tlv between the object
114 - * we have to take a list iterator so one by one we can get each sub tlv object 114 + * we have to take a list iterator so one by one we can get each sub tlv object
115 - * and can compare them. 115 + * and can compare them.
116 - * it may be possible that the size of 2 lists is not equal so we have to first check 116 + * it may be possible that the size of 2 lists is not equal so we have to first check
117 - * the size, if both are same then we should check for the subtlv objects otherwise 117 + * the size, if both are same then we should check for the subtlv objects otherwise
118 - * we should return false. 118 + * we should return false.
119 - */ 119 + */
120 - if (obj instanceof TELinkAttributesTlv) { 120 + if (obj instanceof TELinkAttributesTlv) {
121 - int countObjSubTlv = 0; 121 + int countObjSubTlv = 0;
122 - int countOtherSubTlv = 0; 122 + int countOtherSubTlv = 0;
123 - boolean isCommonSubTlv = true; 123 + boolean isCommonSubTlv = true;
124 - TELinkAttributesTlv other = (TELinkAttributesTlv) obj; 124 + TELinkAttributesTlv other = (TELinkAttributesTlv) obj;
125 - Iterator<PcepValueType> objListIterator = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.iterator(); 125 + Iterator<PcepValueType> objListIterator = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.iterator();
126 - countObjSubTlv = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.size(); 126 + countObjSubTlv = ((TELinkAttributesTlv) obj).llLinkAttributesSubTLVs.size();
127 - countOtherSubTlv = other.llLinkAttributesSubTLVs.size(); 127 + countOtherSubTlv = other.llLinkAttributesSubTLVs.size();
128 - if (countObjSubTlv != countOtherSubTlv) { 128 + if (countObjSubTlv != countOtherSubTlv) {
129 - return false; 129 + return false;
130 - } else { 130 + } else {
131 - while (objListIterator.hasNext() && isCommonSubTlv) { 131 + while (objListIterator.hasNext() && isCommonSubTlv) {
132 - PcepValueType subTlv = objListIterator.next(); 132 + PcepValueType subTlv = objListIterator.next();
133 - isCommonSubTlv = Objects.equals(llLinkAttributesSubTLVs.contains(subTlv), 133 + isCommonSubTlv = Objects.equals(llLinkAttributesSubTLVs.contains(subTlv),
134 - other.llLinkAttributesSubTLVs.contains(subTlv)); 134 + other.llLinkAttributesSubTLVs.contains(subTlv));
135 - } 135 + }
136 - return isCommonSubTlv; 136 + return isCommonSubTlv;
137 - } 137 + }
138 - } 138 + }
139 - return false; 139 + return false;
140 - } 140 + }
141 - 141 +
142 - @Override 142 + @Override
143 - public int write(ChannelBuffer c) { 143 + public int write(ChannelBuffer c) {
144 - int tlvStartIndex = c.writerIndex(); 144 + int tlvStartIndex = c.writerIndex();
145 - c.writeShort(TYPE); 145 + c.writeShort(TYPE);
146 - int tlvLenIndex = c.writerIndex(); 146 + int tlvLenIndex = c.writerIndex();
147 - hLength = 0; 147 + hLength = 0;
148 - c.writeShort(hLength); 148 + c.writeShort(hLength);
149 - 149 +
150 - ListIterator<PcepValueType> listIterator = llLinkAttributesSubTLVs.listIterator(); 150 + ListIterator<PcepValueType> listIterator = llLinkAttributesSubTLVs.listIterator();
151 - 151 +
152 - while (listIterator.hasNext()) { 152 + while (listIterator.hasNext()) {
153 - PcepValueType tlv = listIterator.next(); 153 + PcepValueType tlv = listIterator.next();
154 - 154 +
155 - if (null == tlv) { 155 + if (null == tlv) {
156 - log.debug("TLV is null from subTlv list"); 156 + log.debug("TLV is null from subTlv list");
157 - continue; 157 + continue;
158 - } 158 + }
159 - tlv.write(c); 159 + tlv.write(c);
160 - 160 +
161 - // need to take care of padding 161 + // need to take care of padding
162 - int pad = tlv.getLength() % 4; 162 + int pad = tlv.getLength() % 4;
163 - 163 +
164 - if (0 != pad) { 164 + if (0 != pad) {
165 - pad = 4 - pad; 165 + pad = 4 - pad;
166 - for (int i = 0; i < pad; ++i) { 166 + for (int i = 0; i < pad; ++i) {
167 - c.writeByte((byte) 0); 167 + c.writeByte((byte) 0);
168 - } 168 + }
169 - } 169 + }
170 - } 170 + }
171 - 171 +
172 - hLength = (short) (c.writerIndex() - tlvStartIndex); 172 + hLength = (short) (c.writerIndex() - tlvStartIndex);
173 - c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH)); 173 + c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
174 - 174 +
175 - return c.writerIndex() - tlvStartIndex; 175 + return c.writerIndex() - tlvStartIndex;
176 - } 176 + }
177 - 177 +
178 - /** 178 + /**
179 - * Reads channel buffer and returns object of TE Link Attributes TLV. 179 + * Reads channel buffer and returns object of TE Link Attributes TLV.
180 - * 180 + *
181 - * @param c input channel buffer 181 + * @param c input channel buffer
182 - * @param hLength length 182 + * @param hLength length
183 - * @return object of TELinkAttributesTlv 183 + * @return object of TELinkAttributesTlv
184 - * @throws PcepParseException if mandatory fields are missing 184 + * @throws PcepParseException if mandatory fields are missing
185 - */ 185 + */
186 - public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException { 186 + public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
187 - 187 +
188 - // Node Descriptor Sub-TLVs (variable) 188 + // Node Descriptor Sub-TLVs (variable)
189 - LinkedList<PcepValueType> llLinkAttributesSubTLVs = new LinkedList<PcepValueType>(); 189 + LinkedList<PcepValueType> llLinkAttributesSubTLVs = new LinkedList<PcepValueType>();
190 - 190 +
191 - ChannelBuffer tempCb = c.readBytes(hLength); 191 + ChannelBuffer tempCb = c.readBytes(hLength);
192 - 192 +
193 - while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) { 193 + while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
194 - 194 +
195 - PcepValueType tlv; 195 + PcepValueType tlv;
196 - short hType = tempCb.readShort(); 196 + short hType = tempCb.readShort();
197 - int iValue = 0; 197 + int iValue = 0;
198 - short length = tempCb.readShort(); 198 + short length = tempCb.readShort();
199 - switch (hType) { 199 + switch (hType) {
200 - 200 +
201 - case IPv4TERouterIdOfLocalNodeTlv.TYPE: 201 + case IPv4TERouterIdOfLocalNodeTlv.TYPE:
202 - iValue = tempCb.readInt(); 202 + iValue = tempCb.readInt();
203 - tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue); 203 + tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue);
204 - break; 204 + break;
205 - case IPv6TERouterIdofLocalNodeTlv.TYPE: 205 + case IPv6TERouterIdofLocalNodeTlv.TYPE:
206 - byte[] ipv6LValue = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH]; 206 + byte[] ipv6LValue = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH];
207 - tempCb.readBytes(ipv6LValue, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH); 207 + tempCb.readBytes(ipv6LValue, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH);
208 - tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6LValue); 208 + tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6LValue);
209 - break; 209 + break;
210 - case IPv4TERouterIdOfRemoteNodeTlv.TYPE: 210 + case IPv4TERouterIdOfRemoteNodeTlv.TYPE:
211 - iValue = tempCb.readInt(); 211 + iValue = tempCb.readInt();
212 - tlv = new IPv4TERouterIdOfRemoteNodeTlv(iValue); 212 + tlv = new IPv4TERouterIdOfRemoteNodeTlv(iValue);
213 - break; 213 + break;
214 - case IPv6TERouterIdofRemoteNodeTlv.TYPE: 214 + case IPv6TERouterIdofRemoteNodeTlv.TYPE:
215 - byte[] ipv6RValue = new byte[IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH]; 215 + byte[] ipv6RValue = new byte[IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH];
216 - tempCb.readBytes(ipv6RValue, 0, IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH); 216 + tempCb.readBytes(ipv6RValue, 0, IPv6TERouterIdofRemoteNodeTlv.VALUE_LENGTH);
217 - tlv = new IPv6TERouterIdofRemoteNodeTlv(ipv6RValue); 217 + tlv = new IPv6TERouterIdofRemoteNodeTlv(ipv6RValue);
218 - break; 218 + break;
219 - case LinkLocalRemoteIdentifiersTlv.TYPE: 219 + case LinkLocalRemoteIdentifiersTlv.TYPE:
220 - tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb); 220 + tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
221 - break; 221 + break;
222 - case AdministrativeGroupTlv.TYPE: 222 + case AdministrativeGroupTlv.TYPE:
223 - iValue = tempCb.readInt(); 223 + iValue = tempCb.readInt();
224 - tlv = new AdministrativeGroupTlv(iValue); 224 + tlv = new AdministrativeGroupTlv(iValue);
225 - break; 225 + break;
226 - case MaximumLinkBandwidthTlv.TYPE: 226 + case MaximumLinkBandwidthTlv.TYPE:
227 - iValue = tempCb.readInt(); 227 + iValue = tempCb.readInt();
228 - tlv = new MaximumLinkBandwidthTlv(iValue); 228 + tlv = new MaximumLinkBandwidthTlv(iValue);
229 - break; 229 + break;
230 - case MaximumReservableLinkBandwidthTlv.TYPE: 230 + case MaximumReservableLinkBandwidthTlv.TYPE:
231 - iValue = tempCb.readInt(); 231 + iValue = tempCb.readInt();
232 - tlv = new MaximumReservableLinkBandwidthTlv(iValue); 232 + tlv = new MaximumReservableLinkBandwidthTlv(iValue);
233 - break; 233 + break;
234 - case UnreservedBandwidthTlv.TYPE: 234 + case UnreservedBandwidthTlv.TYPE:
235 - iValue = tempCb.readInt(); 235 + iValue = tempCb.readInt();
236 - tlv = new UnreservedBandwidthTlv(iValue); 236 + tlv = new UnreservedBandwidthTlv(iValue);
237 - break; 237 + break;
238 - case TEDefaultMetricTlv.TYPE: 238 + case TEDefaultMetricTlv.TYPE:
239 - iValue = tempCb.readInt(); 239 + iValue = tempCb.readInt();
240 - tlv = new TEDefaultMetricTlv(iValue); 240 + tlv = new TEDefaultMetricTlv(iValue);
241 - break; 241 + break;
242 - case LinkProtectionTypeTlv.TYPE: 242 + case LinkProtectionTypeTlv.TYPE:
243 - tlv = LinkProtectionTypeTlv.read(tempCb); 243 + tlv = LinkProtectionTypeTlv.read(tempCb);
244 - break; 244 + break;
245 - case MPLSProtocolMaskTlv.TYPE: 245 + case MPLSProtocolMaskTlv.TYPE:
246 - byte cValue = tempCb.readByte(); 246 + byte cValue = tempCb.readByte();
247 - tlv = new MPLSProtocolMaskTlv(cValue); 247 + tlv = new MPLSProtocolMaskTlv(cValue);
248 - break; 248 + break;
249 - case IGPMetricTlv.TYPE: 249 + case IGPMetricTlv.TYPE:
250 - tlv = IGPMetricTlv.read(tempCb, length); 250 + tlv = IGPMetricTlv.read(tempCb, length);
251 - break; 251 + break;
252 - case SharedRiskLinkGroupTlv.TYPE: 252 + case SharedRiskLinkGroupTlv.TYPE:
253 - tlv = SharedRiskLinkGroupTlv.read(tempCb, length); 253 + tlv = SharedRiskLinkGroupTlv.read(tempCb, length);
254 - break; 254 + break;
255 - case OpaqueLinkAttributeTlv.TYPE: 255 + case OpaqueLinkAttributeTlv.TYPE:
256 - tlv = OpaqueLinkAttributeTlv.read(tempCb, length); 256 + tlv = OpaqueLinkAttributeTlv.read(tempCb, length);
257 - break; 257 + break;
258 - case LinkNameTlv.TYPE: 258 + case LinkNameTlv.TYPE:
259 - tlv = LinkNameTlv.read(tempCb, length); 259 + tlv = LinkNameTlv.read(tempCb, length);
260 - break; 260 + break;
261 - default: 261 + default:
262 - throw new PcepParseException("Unsupported Sub TLV type :" + hType); 262 + throw new PcepParseException("Unsupported Sub TLV type :" + hType);
263 - } 263 + }
264 - 264 +
265 - // Check for the padding 265 + // Check for the padding
266 - int pad = length % 4; 266 + int pad = length % 4;
267 - if (0 < pad) { 267 + if (0 < pad) {
268 - pad = 4 - pad; 268 + pad = 4 - pad;
269 - if (pad <= tempCb.readableBytes()) { 269 + if (pad <= tempCb.readableBytes()) {
270 - tempCb.skipBytes(pad); 270 + tempCb.skipBytes(pad);
271 - } 271 + }
272 - } 272 + }
273 - llLinkAttributesSubTLVs.add(tlv); 273 + llLinkAttributesSubTLVs.add(tlv);
274 - } 274 + }
275 - 275 +
276 - if (0 < tempCb.readableBytes()) { 276 + if (0 < tempCb.readableBytes()) {
277 - 277 +
278 - throw new PcepParseException("Sub Tlv parsing error. Extra bytes received."); 278 + throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
279 - } 279 + }
280 - 280 +
281 - return new TELinkAttributesTlv(llLinkAttributesSubTLVs); 281 + return new TELinkAttributesTlv(llLinkAttributesSubTLVs);
282 - } 282 + }
283 - 283 +
284 - @Override 284 + @Override
285 - public String toString() { 285 + public String toString() {
286 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength) 286 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
287 - .add("LinkAttributesSubTLVs", llLinkAttributesSubTLVs).toString(); 287 + .add("LinkAttributesSubTLVs", llLinkAttributesSubTLVs).toString();
288 - } 288 + }
289 -} 289 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Iterator; 18 +import java.util.Iterator;
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 -import java.util.Objects; 21 +import java.util.Objects;
22 - 22 +
23 -import org.jboss.netty.buffer.ChannelBuffer; 23 +import org.jboss.netty.buffer.ChannelBuffer;
24 -import org.onosproject.pcepio.exceptions.PcepParseException; 24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 -import org.onosproject.pcepio.protocol.PcepVersion; 25 +import org.onosproject.pcepio.protocol.PcepVersion;
26 -import org.slf4j.Logger; 26 +import org.slf4j.Logger;
27 -import org.slf4j.LoggerFactory; 27 +import org.slf4j.LoggerFactory;
28 - 28 +
29 -import com.google.common.base.MoreObjects; 29 +import com.google.common.base.MoreObjects;
30 - 30 +
31 -/** 31 +/**
32 - * Provides TE Link Descriptors TLV. 32 + * Provides TE Link Descriptors TLV.
33 - */ 33 + */
34 -public class TELinkDescriptorsTLV implements PcepValueType { 34 +public class TELinkDescriptorsTLV implements PcepValueType {
35 - 35 +
36 - /* 36 + /*
37 - * Reference: PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02 37 + * Reference: PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
38 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Type=[TBD14] | Length | 41 + | Type=[TBD14] | Length |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | | 43 + | |
44 - // Link Descriptor Sub-TLVs (variable) // 44 + // Link Descriptor Sub-TLVs (variable) //
45 - | | 45 + | |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - 47 +
48 - */ 48 + */
49 - 49 +
50 - protected static final Logger log = LoggerFactory.getLogger(TELinkDescriptorsTLV.class); 50 + protected static final Logger log = LoggerFactory.getLogger(TELinkDescriptorsTLV.class);
51 - 51 +
52 - public static final short TYPE = 1070; //TODD:change this TBD14 52 + public static final short TYPE = 1070; //TODD:change this TBD14
53 - public short hLength; 53 + public short hLength;
54 - 54 +
55 - public static final int TLV_HEADER_LENGTH = 4; 55 + public static final int TLV_HEADER_LENGTH = 4;
56 - 56 +
57 - // LinkDescriptors Sub-TLVs (variable) 57 + // LinkDescriptors Sub-TLVs (variable)
58 - private LinkedList<PcepValueType> llLinkDescriptorsSubTLVs; 58 + private LinkedList<PcepValueType> llLinkDescriptorsSubTLVs;
59 - 59 +
60 - /** 60 + /**
61 - * Constructor to initialize llLinkDescriptorsSubTLVs. 61 + * Constructor to initialize llLinkDescriptorsSubTLVs.
62 - * 62 + *
63 - * @param llLinkDescriptorsSubTLVs of PcepValueType 63 + * @param llLinkDescriptorsSubTLVs of PcepValueType
64 - */ 64 + */
65 - public TELinkDescriptorsTLV(LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) { 65 + public TELinkDescriptorsTLV(LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) {
66 - this.llLinkDescriptorsSubTLVs = llLinkDescriptorsSubTLVs; 66 + this.llLinkDescriptorsSubTLVs = llLinkDescriptorsSubTLVs;
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns object of TELinkDescriptorsTLV. 70 + * Returns object of TELinkDescriptorsTLV.
71 - * 71 + *
72 - * @param llLinkDescriptorsSubTLVs of PcepValueType 72 + * @param llLinkDescriptorsSubTLVs of PcepValueType
73 - * @return object of TELinkDescriptorsTLV 73 + * @return object of TELinkDescriptorsTLV
74 - */ 74 + */
75 - public static TELinkDescriptorsTLV of(final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) { 75 + public static TELinkDescriptorsTLV of(final LinkedList<PcepValueType> llLinkDescriptorsSubTLVs) {
76 - return new TELinkDescriptorsTLV(llLinkDescriptorsSubTLVs); 76 + return new TELinkDescriptorsTLV(llLinkDescriptorsSubTLVs);
77 - } 77 + }
78 - 78 +
79 - /** 79 + /**
80 - * Returns linked list of Link Attribute of Sub TLV. 80 + * Returns linked list of Link Attribute of Sub TLV.
81 - * 81 + *
82 - * @return llLinkDescriptorsSubTLVs linked list of Link Attribute of Sub TLV 82 + * @return llLinkDescriptorsSubTLVs linked list of Link Attribute of Sub TLV
83 - */ 83 + */
84 - public LinkedList<PcepValueType> getllLinkDescriptorsSubTLVs() { 84 + public LinkedList<PcepValueType> getllLinkDescriptorsSubTLVs() {
85 - return llLinkDescriptorsSubTLVs; 85 + return llLinkDescriptorsSubTLVs;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public PcepVersion getVersion() { 89 + public PcepVersion getVersion() {
90 - return PcepVersion.PCEP_1; 90 + return PcepVersion.PCEP_1;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public short getType() { 94 + public short getType() {
95 - return TYPE; 95 + return TYPE;
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public short getLength() { 99 + public short getLength() {
100 - return hLength; 100 + return hLength;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public int hashCode() { 104 + public int hashCode() {
105 - return Objects.hash(llLinkDescriptorsSubTLVs.hashCode()); 105 + return Objects.hash(llLinkDescriptorsSubTLVs.hashCode());
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public boolean equals(Object obj) { 109 + public boolean equals(Object obj) {
110 - if (this == obj) { 110 + if (this == obj) {
111 - return true; 111 + return true;
112 - } 112 + }
113 - /* 113 + /*
114 - * Here we have a list of Tlv so to compare each sub tlv between the object 114 + * Here we have a list of Tlv so to compare each sub tlv between the object
115 - * we have to take a list iterator so one by one we can get each sub tlv object 115 + * we have to take a list iterator so one by one we can get each sub tlv object
116 - * and can compare them. 116 + * and can compare them.
117 - * it may be possible that the size of 2 lists is not equal so we have to first check 117 + * it may be possible that the size of 2 lists is not equal so we have to first check
118 - * the size, if both are same then we should check for the subtlv objects otherwise 118 + * the size, if both are same then we should check for the subtlv objects otherwise
119 - * we should return false. 119 + * we should return false.
120 - */ 120 + */
121 - if (obj instanceof TELinkDescriptorsTLV) { 121 + if (obj instanceof TELinkDescriptorsTLV) {
122 - int countObjSubTlv = 0; 122 + int countObjSubTlv = 0;
123 - int countOtherSubTlv = 0; 123 + int countOtherSubTlv = 0;
124 - boolean isCommonSubTlv = true; 124 + boolean isCommonSubTlv = true;
125 - TELinkDescriptorsTLV other = (TELinkDescriptorsTLV) obj; 125 + TELinkDescriptorsTLV other = (TELinkDescriptorsTLV) obj;
126 - Iterator<PcepValueType> objListIterator = ((TELinkDescriptorsTLV) obj).llLinkDescriptorsSubTLVs.iterator(); 126 + Iterator<PcepValueType> objListIterator = ((TELinkDescriptorsTLV) obj).llLinkDescriptorsSubTLVs.iterator();
127 - countObjSubTlv = ((TELinkDescriptorsTLV) obj).llLinkDescriptorsSubTLVs.size(); 127 + countObjSubTlv = ((TELinkDescriptorsTLV) obj).llLinkDescriptorsSubTLVs.size();
128 - countOtherSubTlv = other.llLinkDescriptorsSubTLVs.size(); 128 + countOtherSubTlv = other.llLinkDescriptorsSubTLVs.size();
129 - if (countObjSubTlv != countOtherSubTlv) { 129 + if (countObjSubTlv != countOtherSubTlv) {
130 - return false; 130 + return false;
131 - } else { 131 + } else {
132 - while (objListIterator.hasNext() && isCommonSubTlv) { 132 + while (objListIterator.hasNext() && isCommonSubTlv) {
133 - PcepValueType subTlv = objListIterator.next(); 133 + PcepValueType subTlv = objListIterator.next();
134 - isCommonSubTlv = Objects.equals(llLinkDescriptorsSubTLVs.contains(subTlv), 134 + isCommonSubTlv = Objects.equals(llLinkDescriptorsSubTLVs.contains(subTlv),
135 - other.llLinkDescriptorsSubTLVs.contains(subTlv)); 135 + other.llLinkDescriptorsSubTLVs.contains(subTlv));
136 - } 136 + }
137 - return isCommonSubTlv; 137 + return isCommonSubTlv;
138 - } 138 + }
139 - } 139 + }
140 - return false; 140 + return false;
141 - } 141 + }
142 - 142 +
143 - @Override 143 + @Override
144 - public int write(ChannelBuffer c) { 144 + public int write(ChannelBuffer c) {
145 - int tlvStartIndex = c.writerIndex(); 145 + int tlvStartIndex = c.writerIndex();
146 - c.writeShort(TYPE); 146 + c.writeShort(TYPE);
147 - int tlvLenIndex = c.writerIndex(); 147 + int tlvLenIndex = c.writerIndex();
148 - hLength = 0; 148 + hLength = 0;
149 - c.writeShort(hLength); 149 + c.writeShort(hLength);
150 - 150 +
151 - ListIterator<PcepValueType> listIterator = llLinkDescriptorsSubTLVs.listIterator(); 151 + ListIterator<PcepValueType> listIterator = llLinkDescriptorsSubTLVs.listIterator();
152 - 152 +
153 - while (listIterator.hasNext()) { 153 + while (listIterator.hasNext()) {
154 - PcepValueType tlv = listIterator.next(); 154 + PcepValueType tlv = listIterator.next();
155 - 155 +
156 - tlv.write(c); 156 + tlv.write(c);
157 - 157 +
158 - // need to take care of padding 158 + // need to take care of padding
159 - int pad = tlv.getLength() % 4; 159 + int pad = tlv.getLength() % 4;
160 - 160 +
161 - if (0 != pad) { 161 + if (0 != pad) {
162 - pad = 4 - pad; 162 + pad = 4 - pad;
163 - for (int i = 0; i < pad; ++i) { 163 + for (int i = 0; i < pad; ++i) {
164 - c.writeByte((byte) 0); 164 + c.writeByte((byte) 0);
165 - } 165 + }
166 - } 166 + }
167 - } 167 + }
168 - 168 +
169 - hLength = (short) (c.writerIndex() - tlvStartIndex); 169 + hLength = (short) (c.writerIndex() - tlvStartIndex);
170 - c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH)); 170 + c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
171 - 171 +
172 - return c.writerIndex() - tlvStartIndex; 172 + return c.writerIndex() - tlvStartIndex;
173 - } 173 + }
174 - 174 +
175 - /** 175 + /**
176 - * Reads channel buffer and returns object of TELinkDescriptorsTLV. 176 + * Reads channel buffer and returns object of TELinkDescriptorsTLV.
177 - * 177 + *
178 - * @param c input channel buffer 178 + * @param c input channel buffer
179 - * @param length length 179 + * @param length length
180 - * @return object of TELinkDescriptorsTLV 180 + * @return object of TELinkDescriptorsTLV
181 - * @throws PcepParseException if mandatory fields are missing 181 + * @throws PcepParseException if mandatory fields are missing
182 - */ 182 + */
183 - public static PcepValueType read(ChannelBuffer c, short length) throws PcepParseException { 183 + public static PcepValueType read(ChannelBuffer c, short length) throws PcepParseException {
184 - 184 +
185 - // Node Descriptor Sub-TLVs (variable) 185 + // Node Descriptor Sub-TLVs (variable)
186 - LinkedList<PcepValueType> llLinkDescriptorsSubTLVs = new LinkedList<PcepValueType>(); 186 + LinkedList<PcepValueType> llLinkDescriptorsSubTLVs = new LinkedList<PcepValueType>();
187 - 187 +
188 - ChannelBuffer tempCb = c.readBytes(length); 188 + ChannelBuffer tempCb = c.readBytes(length);
189 - 189 +
190 - while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) { 190 + while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
191 - 191 +
192 - PcepValueType tlv; 192 + PcepValueType tlv;
193 - short hType = tempCb.readShort(); 193 + short hType = tempCb.readShort();
194 - int iValue = 0; 194 + int iValue = 0;
195 - short hLength = tempCb.readShort(); 195 + short hLength = tempCb.readShort();
196 - log.debug("sub Tlv Length" + hLength); 196 + log.debug("sub Tlv Length" + hLength);
197 - switch (hType) { 197 + switch (hType) {
198 - 198 +
199 - case LinkLocalRemoteIdentifiersTlv.TYPE: 199 + case LinkLocalRemoteIdentifiersTlv.TYPE:
200 - tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb); 200 + tlv = LinkLocalRemoteIdentifiersTlv.read(tempCb);
201 - break; 201 + break;
202 - case IPv4InterfaceAddressTlv.TYPE: 202 + case IPv4InterfaceAddressTlv.TYPE:
203 - iValue = tempCb.readInt(); 203 + iValue = tempCb.readInt();
204 - tlv = new IPv4InterfaceAddressTlv(iValue); 204 + tlv = new IPv4InterfaceAddressTlv(iValue);
205 - break; 205 + break;
206 - case IPv4NeighborAddressTlv.TYPE: 206 + case IPv4NeighborAddressTlv.TYPE:
207 - iValue = tempCb.readInt(); 207 + iValue = tempCb.readInt();
208 - tlv = new IPv4NeighborAddressTlv(iValue); 208 + tlv = new IPv4NeighborAddressTlv(iValue);
209 - break; 209 + break;
210 - case IPv6InterfaceAddressTlv.TYPE: 210 + case IPv6InterfaceAddressTlv.TYPE:
211 - byte[] ipv6Value = new byte[IPv6InterfaceAddressTlv.VALUE_LENGTH]; 211 + byte[] ipv6Value = new byte[IPv6InterfaceAddressTlv.VALUE_LENGTH];
212 - tempCb.readBytes(ipv6Value, 0, IPv6InterfaceAddressTlv.VALUE_LENGTH); 212 + tempCb.readBytes(ipv6Value, 0, IPv6InterfaceAddressTlv.VALUE_LENGTH);
213 - tlv = new IPv6InterfaceAddressTlv(ipv6Value); 213 + tlv = new IPv6InterfaceAddressTlv(ipv6Value);
214 - break; 214 + break;
215 - case IPv6NeighborAddressTlv.TYPE: 215 + case IPv6NeighborAddressTlv.TYPE:
216 - byte[] ipv6NeighborAdd = new byte[IPv6NeighborAddressTlv.VALUE_LENGTH]; 216 + byte[] ipv6NeighborAdd = new byte[IPv6NeighborAddressTlv.VALUE_LENGTH];
217 - tempCb.readBytes(ipv6NeighborAdd, 0, IPv6NeighborAddressTlv.VALUE_LENGTH); 217 + tempCb.readBytes(ipv6NeighborAdd, 0, IPv6NeighborAddressTlv.VALUE_LENGTH);
218 - tlv = new IPv6NeighborAddressTlv(ipv6NeighborAdd); 218 + tlv = new IPv6NeighborAddressTlv(ipv6NeighborAdd);
219 - break; 219 + break;
220 - default: 220 + default:
221 - throw new PcepParseException("Unsupported Sub TLV type:" + hType); 221 + throw new PcepParseException("Unsupported Sub TLV type:" + hType);
222 - } 222 + }
223 - 223 +
224 - // Check for the padding 224 + // Check for the padding
225 - int pad = hLength % 4; 225 + int pad = hLength % 4;
226 - if (0 < pad) { 226 + if (0 < pad) {
227 - pad = 4 - pad; 227 + pad = 4 - pad;
228 - if (pad <= tempCb.readableBytes()) { 228 + if (pad <= tempCb.readableBytes()) {
229 - tempCb.skipBytes(pad); 229 + tempCb.skipBytes(pad);
230 - } 230 + }
231 - } 231 + }
232 - llLinkDescriptorsSubTLVs.add(tlv); 232 + llLinkDescriptorsSubTLVs.add(tlv);
233 - 233 +
234 - } 234 + }
235 - 235 +
236 - if (0 < tempCb.readableBytes()) { 236 + if (0 < tempCb.readableBytes()) {
237 - 237 +
238 - throw new PcepParseException("Sub Tlv parsing error. Extra bytes received."); 238 + throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
239 - } 239 + }
240 - return new TELinkDescriptorsTLV(llLinkDescriptorsSubTLVs); 240 + return new TELinkDescriptorsTLV(llLinkDescriptorsSubTLVs);
241 - } 241 + }
242 - 242 +
243 - @Override 243 + @Override
244 - public String toString() { 244 + public String toString() {
245 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength) 245 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
246 - .add("LinkDescriptorsSubTLVs", llLinkDescriptorsSubTLVs).toString(); 246 + .add("LinkDescriptorsSubTLVs", llLinkDescriptorsSubTLVs).toString();
247 - } 247 + }
248 -} 248 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Iterator; 18 +import java.util.Iterator;
19 -import java.util.LinkedList; 19 +import java.util.LinkedList;
20 -import java.util.ListIterator; 20 +import java.util.ListIterator;
21 -import java.util.Objects; 21 +import java.util.Objects;
22 - 22 +
23 -import org.jboss.netty.buffer.ChannelBuffer; 23 +import org.jboss.netty.buffer.ChannelBuffer;
24 -import org.onosproject.pcepio.exceptions.PcepParseException; 24 +import org.onosproject.pcepio.exceptions.PcepParseException;
25 -import org.onosproject.pcepio.protocol.PcepVersion; 25 +import org.onosproject.pcepio.protocol.PcepVersion;
26 -import org.slf4j.Logger; 26 +import org.slf4j.Logger;
27 -import org.slf4j.LoggerFactory; 27 +import org.slf4j.LoggerFactory;
28 - 28 +
29 -import com.google.common.base.MoreObjects; 29 +import com.google.common.base.MoreObjects;
30 - 30 +
31 -/** 31 +/**
32 - * Provides TE Node Attributes Tlv. 32 + * Provides TE Node Attributes Tlv.
33 - */ 33 + */
34 -public class TENodeAttributesTlv implements PcepValueType { 34 +public class TENodeAttributesTlv implements PcepValueType {
35 - /* 35 + /*
36 - * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02 36 + * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
37 - * 37 + *
38 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - | Type=[TBD20] | Length | 41 + | Type=[TBD20] | Length |
42 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 42 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
43 - | | 43 + | |
44 - // Node Attributes Sub-TLVs (variable) // 44 + // Node Attributes Sub-TLVs (variable) //
45 - | | 45 + | |
46 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 46 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
47 - 47 +
48 - 48 +
49 - */ 49 + */
50 - 50 +
51 - protected static final Logger log = LoggerFactory.getLogger(TENodeAttributesTlv.class); 51 + protected static final Logger log = LoggerFactory.getLogger(TENodeAttributesTlv.class);
52 - 52 +
53 - public static final short TYPE = 1267; //TODD:change this TBD20 53 + public static final short TYPE = 1267; //TODD:change this TBD20
54 - public short hLength; 54 + public short hLength;
55 - 55 +
56 - public static final int TLV_HEADER_LENGTH = 4; 56 + public static final int TLV_HEADER_LENGTH = 4;
57 - // LinkDescriptors Sub-TLVs (variable) 57 + // LinkDescriptors Sub-TLVs (variable)
58 - private LinkedList<PcepValueType> llNodeAttributesSubTLVs; 58 + private LinkedList<PcepValueType> llNodeAttributesSubTLVs;
59 - 59 +
60 - /** 60 + /**
61 - * Constructor to initialize llNodeAttributesSubTLVs. 61 + * Constructor to initialize llNodeAttributesSubTLVs.
62 - * 62 + *
63 - * @param llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs 63 + * @param llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
64 - */ 64 + */
65 - public TENodeAttributesTlv(LinkedList<PcepValueType> llNodeAttributesSubTLVs) { 65 + public TENodeAttributesTlv(LinkedList<PcepValueType> llNodeAttributesSubTLVs) {
66 - this.llNodeAttributesSubTLVs = llNodeAttributesSubTLVs; 66 + this.llNodeAttributesSubTLVs = llNodeAttributesSubTLVs;
67 - } 67 + }
68 - 68 +
69 - /** 69 + /**
70 - * Returns object of TENodeAttributesTlv. 70 + * Returns object of TENodeAttributesTlv.
71 - * 71 + *
72 - * @param llNodeAttributesSubTLVs LinkedList of PcepValueType 72 + * @param llNodeAttributesSubTLVs LinkedList of PcepValueType
73 - * @return object of TENodeAttributesTlv 73 + * @return object of TENodeAttributesTlv
74 - */ 74 + */
75 - public static TENodeAttributesTlv of(LinkedList<PcepValueType> llNodeAttributesSubTLVs) { 75 + public static TENodeAttributesTlv of(LinkedList<PcepValueType> llNodeAttributesSubTLVs) {
76 - return new TENodeAttributesTlv(llNodeAttributesSubTLVs); 76 + return new TENodeAttributesTlv(llNodeAttributesSubTLVs);
77 - } 77 + }
78 - 78 +
79 - /** 79 + /**
80 - * Returns Node Attributes Sub-TLVs. 80 + * Returns Node Attributes Sub-TLVs.
81 - * 81 + *
82 - * @return llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs 82 + * @return llNodeAttributesSubTLVs linked list of Node Attributes Sub-TLVs
83 - */ 83 + */
84 - public LinkedList<PcepValueType> getllNodeAttributesSubTLVs() { 84 + public LinkedList<PcepValueType> getllNodeAttributesSubTLVs() {
85 - return llNodeAttributesSubTLVs; 85 + return llNodeAttributesSubTLVs;
86 - } 86 + }
87 - 87 +
88 - @Override 88 + @Override
89 - public PcepVersion getVersion() { 89 + public PcepVersion getVersion() {
90 - return PcepVersion.PCEP_1; 90 + return PcepVersion.PCEP_1;
91 - } 91 + }
92 - 92 +
93 - @Override 93 + @Override
94 - public short getType() { 94 + public short getType() {
95 - return TYPE; 95 + return TYPE;
96 - } 96 + }
97 - 97 +
98 - @Override 98 + @Override
99 - public short getLength() { 99 + public short getLength() {
100 - return hLength; 100 + return hLength;
101 - } 101 + }
102 - 102 +
103 - @Override 103 + @Override
104 - public int hashCode() { 104 + public int hashCode() {
105 - return Objects.hash(llNodeAttributesSubTLVs.hashCode()); 105 + return Objects.hash(llNodeAttributesSubTLVs.hashCode());
106 - } 106 + }
107 - 107 +
108 - @Override 108 + @Override
109 - public boolean equals(Object obj) { 109 + public boolean equals(Object obj) {
110 - if (this == obj) { 110 + if (this == obj) {
111 - return true; 111 + return true;
112 - } 112 + }
113 - /* 113 + /*
114 - * Here we have a list of Tlv so to compare each sub tlv between the object 114 + * Here we have a list of Tlv so to compare each sub tlv between the object
115 - * we have to take a list iterator so one by one we can get each sub tlv object 115 + * we have to take a list iterator so one by one we can get each sub tlv object
116 - * and can compare them. 116 + * and can compare them.
117 - * it may be possible that the size of 2 lists is not equal so we have to first check 117 + * it may be possible that the size of 2 lists is not equal so we have to first check
118 - * the size, if both are same then we should check for the subtlv objects otherwise 118 + * the size, if both are same then we should check for the subtlv objects otherwise
119 - * we should return false. 119 + * we should return false.
120 - */ 120 + */
121 - if (obj instanceof TENodeAttributesTlv) { 121 + if (obj instanceof TENodeAttributesTlv) {
122 - int countObjSubTlv = 0; 122 + int countObjSubTlv = 0;
123 - int countOtherSubTlv = 0; 123 + int countOtherSubTlv = 0;
124 - boolean isCommonSubTlv = true; 124 + boolean isCommonSubTlv = true;
125 - TENodeAttributesTlv other = (TENodeAttributesTlv) obj; 125 + TENodeAttributesTlv other = (TENodeAttributesTlv) obj;
126 - Iterator<PcepValueType> objListIterator = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.iterator(); 126 + Iterator<PcepValueType> objListIterator = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.iterator();
127 - countObjSubTlv = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.size(); 127 + countObjSubTlv = ((TENodeAttributesTlv) obj).llNodeAttributesSubTLVs.size();
128 - countOtherSubTlv = other.llNodeAttributesSubTLVs.size(); 128 + countOtherSubTlv = other.llNodeAttributesSubTLVs.size();
129 - if (countObjSubTlv != countOtherSubTlv) { 129 + if (countObjSubTlv != countOtherSubTlv) {
130 - return false; 130 + return false;
131 - } else { 131 + } else {
132 - while (objListIterator.hasNext() && isCommonSubTlv) { 132 + while (objListIterator.hasNext() && isCommonSubTlv) {
133 - PcepValueType subTlv = objListIterator.next(); 133 + PcepValueType subTlv = objListIterator.next();
134 - isCommonSubTlv = Objects.equals(llNodeAttributesSubTLVs.contains(subTlv), 134 + isCommonSubTlv = Objects.equals(llNodeAttributesSubTLVs.contains(subTlv),
135 - other.llNodeAttributesSubTLVs.contains(subTlv)); 135 + other.llNodeAttributesSubTLVs.contains(subTlv));
136 - } 136 + }
137 - return isCommonSubTlv; 137 + return isCommonSubTlv;
138 - } 138 + }
139 - } 139 + }
140 - return false; 140 + return false;
141 - } 141 + }
142 - 142 +
143 - @Override 143 + @Override
144 - public int write(ChannelBuffer c) { 144 + public int write(ChannelBuffer c) {
145 - int tlvStartIndex = c.writerIndex(); 145 + int tlvStartIndex = c.writerIndex();
146 - c.writeShort(TYPE); 146 + c.writeShort(TYPE);
147 - int tlvLenIndex = c.writerIndex(); 147 + int tlvLenIndex = c.writerIndex();
148 - hLength = 0; 148 + hLength = 0;
149 - c.writeShort(hLength); 149 + c.writeShort(hLength);
150 - 150 +
151 - ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator(); 151 + ListIterator<PcepValueType> listIterator = llNodeAttributesSubTLVs.listIterator();
152 - 152 +
153 - while (listIterator.hasNext()) { 153 + while (listIterator.hasNext()) {
154 - PcepValueType tlv = listIterator.next(); 154 + PcepValueType tlv = listIterator.next();
155 - 155 +
156 - tlv.write(c); 156 + tlv.write(c);
157 - 157 +
158 - // need to take care of padding 158 + // need to take care of padding
159 - int pad = tlv.getLength() % 4; 159 + int pad = tlv.getLength() % 4;
160 - 160 +
161 - if (0 != pad) { 161 + if (0 != pad) {
162 - pad = 4 - pad; 162 + pad = 4 - pad;
163 - for (int i = 0; i < pad; ++i) { 163 + for (int i = 0; i < pad; ++i) {
164 - c.writeByte((byte) 0); 164 + c.writeByte((byte) 0);
165 - } 165 + }
166 - } 166 + }
167 - } 167 + }
168 - 168 +
169 - hLength = (short) (c.writerIndex() - tlvStartIndex); 169 + hLength = (short) (c.writerIndex() - tlvStartIndex);
170 - c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH)); 170 + c.setShort(tlvLenIndex, (hLength - TLV_HEADER_LENGTH));
171 - 171 +
172 - return c.writerIndex() - tlvStartIndex; 172 + return c.writerIndex() - tlvStartIndex;
173 - } 173 + }
174 - 174 +
175 - /** 175 + /**
176 - * Reads the channel buffer and returns object of TENodeAttributesTlv. 176 + * Reads the channel buffer and returns object of TENodeAttributesTlv.
177 - * 177 + *
178 - * @param c input channel buffer 178 + * @param c input channel buffer
179 - * @param hLength length 179 + * @param hLength length
180 - * @return object of TENodeAttributesTlv 180 + * @return object of TENodeAttributesTlv
181 - * @throws PcepParseException if mandatory fields are missing 181 + * @throws PcepParseException if mandatory fields are missing
182 - */ 182 + */
183 - public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException { 183 + public static PcepValueType read(ChannelBuffer c, short hLength) throws PcepParseException {
184 - 184 +
185 - // Node Descriptor Sub-TLVs (variable) 185 + // Node Descriptor Sub-TLVs (variable)
186 - LinkedList<PcepValueType> llNodeAttributesSubTLVs = new LinkedList<PcepValueType>(); 186 + LinkedList<PcepValueType> llNodeAttributesSubTLVs = new LinkedList<PcepValueType>();
187 - 187 +
188 - ChannelBuffer tempCb = c.readBytes(hLength); 188 + ChannelBuffer tempCb = c.readBytes(hLength);
189 - 189 +
190 - while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) { 190 + while (TLV_HEADER_LENGTH <= tempCb.readableBytes()) {
191 - PcepValueType tlv; 191 + PcepValueType tlv;
192 - short hType = tempCb.readShort(); 192 + short hType = tempCb.readShort();
193 - int iValue = 0; 193 + int iValue = 0;
194 - short length = tempCb.readShort(); 194 + short length = tempCb.readShort();
195 - switch (hType) { 195 + switch (hType) {
196 - 196 +
197 - case NodeFlagBitsTlv.TYPE: 197 + case NodeFlagBitsTlv.TYPE:
198 - byte cValue = tempCb.readByte(); 198 + byte cValue = tempCb.readByte();
199 - tlv = new NodeFlagBitsTlv(cValue); 199 + tlv = new NodeFlagBitsTlv(cValue);
200 - break; 200 + break;
201 - case OpaqueNodeAttributeTlv.TYPE: 201 + case OpaqueNodeAttributeTlv.TYPE:
202 - tlv = OpaqueNodeAttributeTlv.read(tempCb, length); 202 + tlv = OpaqueNodeAttributeTlv.read(tempCb, length);
203 - break; 203 + break;
204 - case NodeNameTlv.TYPE: 204 + case NodeNameTlv.TYPE:
205 - tlv = NodeNameTlv.read(tempCb, length); 205 + tlv = NodeNameTlv.read(tempCb, length);
206 - break; 206 + break;
207 - case ISISAreaIdentifierTlv.TYPE: 207 + case ISISAreaIdentifierTlv.TYPE:
208 - tlv = ISISAreaIdentifierTlv.read(tempCb, length); 208 + tlv = ISISAreaIdentifierTlv.read(tempCb, length);
209 - break; 209 + break;
210 - case IPv4TERouterIdOfLocalNodeTlv.TYPE: 210 + case IPv4TERouterIdOfLocalNodeTlv.TYPE:
211 - iValue = tempCb.readInt(); 211 + iValue = tempCb.readInt();
212 - tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue); 212 + tlv = new IPv4TERouterIdOfLocalNodeTlv(iValue);
213 - break; 213 + break;
214 - case IPv6TERouterIdofLocalNodeTlv.TYPE: 214 + case IPv6TERouterIdofLocalNodeTlv.TYPE:
215 - byte[] ipv6Value = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH]; 215 + byte[] ipv6Value = new byte[IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH];
216 - tempCb.readBytes(ipv6Value, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH); 216 + tempCb.readBytes(ipv6Value, 0, IPv6TERouterIdofLocalNodeTlv.VALUE_LENGTH);
217 - tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6Value); 217 + tlv = new IPv6TERouterIdofLocalNodeTlv(ipv6Value);
218 - break; 218 + break;
219 - default: 219 + default:
220 - throw new PcepParseException("Unsupported Sub TLV type :" + hType); 220 + throw new PcepParseException("Unsupported Sub TLV type :" + hType);
221 - } 221 + }
222 - 222 +
223 - // Check for the padding 223 + // Check for the padding
224 - int pad = length % 4; 224 + int pad = length % 4;
225 - if (0 < pad) { 225 + if (0 < pad) {
226 - pad = 4 - pad; 226 + pad = 4 - pad;
227 - if (pad <= tempCb.readableBytes()) { 227 + if (pad <= tempCb.readableBytes()) {
228 - tempCb.skipBytes(pad); 228 + tempCb.skipBytes(pad);
229 - } 229 + }
230 - } 230 + }
231 - 231 +
232 - llNodeAttributesSubTLVs.add(tlv); 232 + llNodeAttributesSubTLVs.add(tlv);
233 - } 233 + }
234 - 234 +
235 - if (0 < tempCb.readableBytes()) { 235 + if (0 < tempCb.readableBytes()) {
236 - 236 +
237 - throw new PcepParseException("Sub Tlv parsing error. Extra bytes received."); 237 + throw new PcepParseException("Sub Tlv parsing error. Extra bytes received.");
238 - } 238 + }
239 - return new TENodeAttributesTlv(llNodeAttributesSubTLVs); 239 + return new TENodeAttributesTlv(llNodeAttributesSubTLVs);
240 - } 240 + }
241 - 241 +
242 - @Override 242 + @Override
243 - public String toString() { 243 + public String toString() {
244 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength) 244 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", hLength)
245 - .add("NodeAttributesSubTLVs", llNodeAttributesSubTLVs).toString(); 245 + .add("NodeAttributesSubTLVs", llNodeAttributesSubTLVs).toString();
246 - } 246 + }
247 -} 247 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides TED Capability Tlv. 28 + * Provides TED Capability Tlv.
29 - */ 29 + */
30 -public class TedCapabilityTlv implements PcepValueType { 30 +public class TedCapabilityTlv implements PcepValueType {
31 - 31 +
32 - /* 32 + /*
33 - * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02 33 + * Reference :PCEP Extension for Transporting TE Data draft-dhodylee-pce-pcep-te-data-extn-02
34 - * 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 36 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
37 - | Type=[TBD5] | Length=4 | 37 + | Type=[TBD5] | Length=4 |
38 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 38 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
39 - | Flags |R| 39 + | Flags |R|
40 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 40 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
41 - */ 41 + */
42 - 42 +
43 - protected static final Logger log = LoggerFactory.getLogger(TedCapabilityTlv.class); 43 + protected static final Logger log = LoggerFactory.getLogger(TedCapabilityTlv.class);
44 - 44 +
45 - public static final short TYPE = 132; //TODO: need to change this TBD5 45 + public static final short TYPE = 132; //TODO: need to change this TBD5
46 - public static final short LENGTH = 4; 46 + public static final short LENGTH = 4;
47 - public static final int SET = 1; 47 + public static final int SET = 1;
48 - public static final byte RFLAG_CHECK = 0x01; 48 + public static final byte RFLAG_CHECK = 0x01;
49 - 49 +
50 - private final boolean bRFlag; 50 + private final boolean bRFlag;
51 - private final int rawValue; 51 + private final int rawValue;
52 - private final boolean isRawValueSet; 52 + private final boolean isRawValueSet;
53 - 53 +
54 - /** 54 + /**
55 - * Constructor to initialize raw Value. 55 + * Constructor to initialize raw Value.
56 - * 56 + *
57 - * @param rawValue Flags 57 + * @param rawValue Flags
58 - */ 58 + */
59 - public TedCapabilityTlv(final int rawValue) { 59 + public TedCapabilityTlv(final int rawValue) {
60 - this.rawValue = rawValue; 60 + this.rawValue = rawValue;
61 - this.isRawValueSet = true; 61 + this.isRawValueSet = true;
62 - int temp = rawValue; 62 + int temp = rawValue;
63 - temp = temp & RFLAG_CHECK; 63 + temp = temp & RFLAG_CHECK;
64 - if (temp == SET) { 64 + if (temp == SET) {
65 - this.bRFlag = true; 65 + this.bRFlag = true;
66 - } else { 66 + } else {
67 - this.bRFlag = false; 67 + this.bRFlag = false;
68 - } 68 + }
69 - 69 +
70 - } 70 + }
71 - 71 +
72 - /** 72 + /**
73 - * Constructor to initialize bRFlag. 73 + * Constructor to initialize bRFlag.
74 - * 74 + *
75 - * @param bRFlag R-flag 75 + * @param bRFlag R-flag
76 - */ 76 + */
77 - public TedCapabilityTlv(boolean bRFlag) { 77 + public TedCapabilityTlv(boolean bRFlag) {
78 - this.bRFlag = bRFlag; 78 + this.bRFlag = bRFlag;
79 - this.rawValue = 0; 79 + this.rawValue = 0;
80 - this.isRawValueSet = false; 80 + this.isRawValueSet = false;
81 - } 81 + }
82 - 82 +
83 - /** 83 + /**
84 - * Returns R-flag. 84 + * Returns R-flag.
85 - * 85 + *
86 - * @return bRFlag 86 + * @return bRFlag
87 - */ 87 + */
88 - public boolean getbRFlag() { 88 + public boolean getbRFlag() {
89 - return bRFlag; 89 + return bRFlag;
90 - } 90 + }
91 - 91 +
92 - /** 92 + /**
93 - * Returns an object of TedCapabilityTlv. 93 + * Returns an object of TedCapabilityTlv.
94 - * 94 + *
95 - * @param raw value Flags 95 + * @param raw value Flags
96 - * @return object of TedCapabilityTlv 96 + * @return object of TedCapabilityTlv
97 - */ 97 + */
98 - public static TedCapabilityTlv of(final int raw) { 98 + public static TedCapabilityTlv of(final int raw) {
99 - return new TedCapabilityTlv(raw); 99 + return new TedCapabilityTlv(raw);
100 - } 100 + }
101 - 101 +
102 - @Override 102 + @Override
103 - public PcepVersion getVersion() { 103 + public PcepVersion getVersion() {
104 - return PcepVersion.PCEP_1; 104 + return PcepVersion.PCEP_1;
105 - } 105 + }
106 - 106 +
107 - public int getInt() { 107 + public int getInt() {
108 - return rawValue; 108 + return rawValue;
109 - } 109 + }
110 - 110 +
111 - @Override 111 + @Override
112 - public short getType() { 112 + public short getType() {
113 - return TYPE; 113 + return TYPE;
114 - } 114 + }
115 - 115 +
116 - @Override 116 + @Override
117 - public short getLength() { 117 + public short getLength() {
118 - return LENGTH; 118 + return LENGTH;
119 - } 119 + }
120 - 120 +
121 - @Override 121 + @Override
122 - public int hashCode() { 122 + public int hashCode() {
123 - if (isRawValueSet) { 123 + if (isRawValueSet) {
124 - return Objects.hash(rawValue); 124 + return Objects.hash(rawValue);
125 - } else { 125 + } else {
126 - return Objects.hash(bRFlag); 126 + return Objects.hash(bRFlag);
127 - } 127 + }
128 - } 128 + }
129 - 129 +
130 - @Override 130 + @Override
131 - public boolean equals(Object obj) { 131 + public boolean equals(Object obj) {
132 - if (this == obj) { 132 + if (this == obj) {
133 - return true; 133 + return true;
134 - } 134 + }
135 - if (obj instanceof TedCapabilityTlv) { 135 + if (obj instanceof TedCapabilityTlv) {
136 - TedCapabilityTlv other = (TedCapabilityTlv) obj; 136 + TedCapabilityTlv other = (TedCapabilityTlv) obj;
137 - if (isRawValueSet) { 137 + if (isRawValueSet) {
138 - return Objects.equals(this.rawValue, other.rawValue); 138 + return Objects.equals(this.rawValue, other.rawValue);
139 - } else { 139 + } else {
140 - return Objects.equals(this.bRFlag, other.bRFlag); 140 + return Objects.equals(this.bRFlag, other.bRFlag);
141 - } 141 + }
142 - } 142 + }
143 - return false; 143 + return false;
144 - } 144 + }
145 - 145 +
146 - @Override 146 + @Override
147 - public int write(ChannelBuffer c) { 147 + public int write(ChannelBuffer c) {
148 - int iStartIndex = c.writerIndex(); 148 + int iStartIndex = c.writerIndex();
149 - int temp = 0; 149 + int temp = 0;
150 - c.writeShort(TYPE); 150 + c.writeShort(TYPE);
151 - c.writeShort(LENGTH); 151 + c.writeShort(LENGTH);
152 - if (isRawValueSet) { 152 + if (isRawValueSet) {
153 - c.writeInt(rawValue); 153 + c.writeInt(rawValue);
154 - } else { 154 + } else {
155 - if (bRFlag) { 155 + if (bRFlag) {
156 - temp = temp | RFLAG_CHECK; 156 + temp = temp | RFLAG_CHECK;
157 - } 157 + }
158 - c.writeInt(temp); 158 + c.writeInt(temp);
159 - } 159 + }
160 - return c.writerIndex() - iStartIndex; 160 + return c.writerIndex() - iStartIndex;
161 - } 161 + }
162 - 162 +
163 - /** 163 + /**
164 - * Reads channel buffer and returns object of TedCapabilityTlv. 164 + * Reads channel buffer and returns object of TedCapabilityTlv.
165 - * 165 + *
166 - * @param c input channel buffer 166 + * @param c input channel buffer
167 - * @return object of TedCapabilityTlv 167 + * @return object of TedCapabilityTlv
168 - */ 168 + */
169 - public static TedCapabilityTlv read(ChannelBuffer c) { 169 + public static TedCapabilityTlv read(ChannelBuffer c) {
170 - return TedCapabilityTlv.of(c.readInt()); 170 + return TedCapabilityTlv.of(c.readInt());
171 - } 171 + }
172 - 172 +
173 - @Override 173 + @Override
174 - public String toString() { 174 + public String toString() {
175 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 175 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
176 - .toString(); 176 + .toString();
177 - } 177 + }
178 -} 178 +}
......
1 -/* 1 +/*
2 - * Copyright 2015 Open Networking Laboratory 2 + * Copyright 2015 Open Networking Laboratory
3 - * 3 + *
4 - * Licensed under the Apache License, Version 2.0 (the "License"); 4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 - * you may not use this file except in compliance with 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 6 + * You may obtain a copy of the License at
7 - * 7 + *
8 - * http://www.apache.org/licenses/LICENSE-2.0 8 + * http://www.apache.org/licenses/LICENSE-2.0
9 - * 9 + *
10 - * Unless required by applicable law or agreed to in writing, software 10 + * Unless required by applicable law or agreed to in writing, software
11 - * distributed under the License is distributed on an "AS IS" BASIS, 11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 - * See the License for the specific language governing permissions and 13 + * See the License for the specific language governing permissions and
14 - * limitations under the License. 14 + * limitations under the License.
15 - */ 15 + */
16 -package org.onosproject.pcepio.types; 16 +package org.onosproject.pcepio.types;
17 - 17 +
18 -import java.util.Objects; 18 +import java.util.Objects;
19 - 19 +
20 -import org.jboss.netty.buffer.ChannelBuffer; 20 +import org.jboss.netty.buffer.ChannelBuffer;
21 -import org.onosproject.pcepio.protocol.PcepVersion; 21 +import org.onosproject.pcepio.protocol.PcepVersion;
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; 25 +import com.google.common.base.MoreObjects;
26 - 26 +
27 -/** 27 +/**
28 - * Provides Unreserved Bandwidth Tlv. 28 + * Provides Unreserved Bandwidth Tlv.
29 - */ 29 + */
30 -public class UnreservedBandwidthTlv implements PcepValueType { 30 +public class UnreservedBandwidthTlv implements PcepValueType {
31 - 31 +
32 - /* Reference :[RFC5305]/3.6 32 + /* Reference :[RFC5305]/3.6
33 - 0 1 2 3 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 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 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 35 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
36 - | Type=[TDB36] | Length=4 | 36 + | Type=[TDB36] | Length=4 |
37 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 37 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
38 - | Unreserved Bandwidth | 38 + | Unreserved Bandwidth |
39 - +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 39 + +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
40 - */ 40 + */
41 - 41 +
42 - protected static final Logger log = LoggerFactory.getLogger(UnreservedBandwidthTlv.class); 42 + protected static final Logger log = LoggerFactory.getLogger(UnreservedBandwidthTlv.class);
43 - 43 +
44 - public static final short TYPE = 11; //TDB36 44 + public static final short TYPE = 11; //TDB36
45 - public static final short LENGTH = 4; 45 + public static final short LENGTH = 4;
46 - 46 +
47 - private final int rawValue; 47 + private final int rawValue;
48 - 48 +
49 - /** 49 + /**
50 - * Constructor to initialize rawValue. 50 + * Constructor to initialize rawValue.
51 - * 51 + *
52 - * @param rawValue Unreserved Bandwidth 52 + * @param rawValue Unreserved Bandwidth
53 - */ 53 + */
54 - public UnreservedBandwidthTlv(int rawValue) { 54 + public UnreservedBandwidthTlv(int rawValue) {
55 - this.rawValue = rawValue; 55 + this.rawValue = rawValue;
56 - } 56 + }
57 - 57 +
58 - /** 58 + /**
59 - * Returns newly created UnreservedBandwidthTlv object. 59 + * Returns newly created UnreservedBandwidthTlv object.
60 - * 60 + *
61 - * @param raw as Unreserved Bandwidth 61 + * @param raw as Unreserved Bandwidth
62 - * @return object of UnreservedBandwidthTlv 62 + * @return object of UnreservedBandwidthTlv
63 - */ 63 + */
64 - public static UnreservedBandwidthTlv of(final int raw) { 64 + public static UnreservedBandwidthTlv of(final int raw) {
65 - return new UnreservedBandwidthTlv(raw); 65 + return new UnreservedBandwidthTlv(raw);
66 - } 66 + }
67 - 67 +
68 - /** 68 + /**
69 - * Returns Unreserved Bandwidth. 69 + * Returns Unreserved Bandwidth.
70 - * 70 + *
71 - * @return rawValue Unreserved Bandwidth 71 + * @return rawValue Unreserved Bandwidth
72 - */ 72 + */
73 - public int getInt() { 73 + public int getInt() {
74 - return rawValue; 74 + return rawValue;
75 - } 75 + }
76 - 76 +
77 - @Override 77 + @Override
78 - public PcepVersion getVersion() { 78 + public PcepVersion getVersion() {
79 - return PcepVersion.PCEP_1; 79 + return PcepVersion.PCEP_1;
80 - } 80 + }
81 - 81 +
82 - @Override 82 + @Override
83 - public short getType() { 83 + public short getType() {
84 - return TYPE; 84 + return TYPE;
85 - } 85 + }
86 - 86 +
87 - @Override 87 + @Override
88 - public short getLength() { 88 + public short getLength() {
89 - return LENGTH; 89 + return LENGTH;
90 - } 90 + }
91 - 91 +
92 - @Override 92 + @Override
93 - public int hashCode() { 93 + public int hashCode() {
94 - return Objects.hash(rawValue); 94 + return Objects.hash(rawValue);
95 - } 95 + }
96 - 96 +
97 - @Override 97 + @Override
98 - public boolean equals(Object obj) { 98 + public boolean equals(Object obj) {
99 - if (this == obj) { 99 + if (this == obj) {
100 - return true; 100 + return true;
101 - } 101 + }
102 - if (obj instanceof UnreservedBandwidthTlv) { 102 + if (obj instanceof UnreservedBandwidthTlv) {
103 - UnreservedBandwidthTlv other = (UnreservedBandwidthTlv) obj; 103 + UnreservedBandwidthTlv other = (UnreservedBandwidthTlv) obj;
104 - return Objects.equals(this.rawValue, other.rawValue); 104 + return Objects.equals(this.rawValue, other.rawValue);
105 - } 105 + }
106 - return false; 106 + return false;
107 - } 107 + }
108 - 108 +
109 - @Override 109 + @Override
110 - public int write(ChannelBuffer c) { 110 + public int write(ChannelBuffer c) {
111 - int iLenStartIndex = c.writerIndex(); 111 + int iLenStartIndex = c.writerIndex();
112 - c.writeShort(TYPE); 112 + c.writeShort(TYPE);
113 - c.writeShort(LENGTH); 113 + c.writeShort(LENGTH);
114 - c.writeInt(rawValue); 114 + c.writeInt(rawValue);
115 - return c.writerIndex() - iLenStartIndex; 115 + return c.writerIndex() - iLenStartIndex;
116 - } 116 + }
117 - 117 +
118 - /** 118 + /**
119 - * Reads byte stream from channel buffer and returns object of UnreservedBandwidthTlv. 119 + * Reads byte stream from channel buffer and returns object of UnreservedBandwidthTlv.
120 - * 120 + *
121 - * @param c input channel buffer 121 + * @param c input channel buffer
122 - * @return object of UnreservedBandwidthTlv 122 + * @return object of UnreservedBandwidthTlv
123 - */ 123 + */
124 - public static UnreservedBandwidthTlv read(ChannelBuffer c) { 124 + public static UnreservedBandwidthTlv read(ChannelBuffer c) {
125 - return UnreservedBandwidthTlv.of(c.readInt()); 125 + return UnreservedBandwidthTlv.of(c.readInt());
126 - } 126 + }
127 - 127 +
128 - @Override 128 + @Override
129 - public String toString() { 129 + public String toString() {
130 - return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue) 130 + return MoreObjects.toStringHelper(getClass()).add("Type", TYPE).add("Length", LENGTH).add("Value", rawValue)
131 - .toString(); 131 + .toString();
132 - } 132 + }
133 -} 133 +}
......
1 -package org.onosproject.pcepio.util; 1 +package org.onosproject.pcepio.util;
2 - 2 +
3 -import org.jboss.netty.buffer.ChannelBuffer; 3 +import org.jboss.netty.buffer.ChannelBuffer;
4 -import org.slf4j.Logger; 4 +import org.slf4j.Logger;
5 -import org.slf4j.LoggerFactory; 5 +import org.slf4j.LoggerFactory;
6 - 6 +
7 -/** 7 +/**
8 - * Provides Hex Dump for debugging. 8 + * Provides Hex Dump for debugging.
9 - */ 9 + */
10 -public final class HexDump { 10 +public final class HexDump {
11 - protected static final Logger log = LoggerFactory.getLogger(HexDump.class); 11 + protected static final Logger log = LoggerFactory.getLogger(HexDump.class);
12 - 12 +
13 - private HexDump() { 13 + private HexDump() {
14 - } 14 + }
15 - 15 +
16 - public static void pcepHexDump(ChannelBuffer buff) { 16 + public static void pcepHexDump(ChannelBuffer buff) {
17 - 17 +
18 - log.debug("==================== HEX DUMP ======================"); 18 + log.debug("==================== HEX DUMP ======================");
19 - try { 19 + try {
20 - byte[] yTemp; 20 + byte[] yTemp;
21 - yTemp = buff.array(); 21 + yTemp = buff.array();
22 - 22 +
23 - int iStartIndex = buff.readerIndex(); 23 + int iStartIndex = buff.readerIndex();
24 - int iEndIndex = buff.writerIndex(); 24 + int iEndIndex = buff.writerIndex();
25 - do { 25 + do {
26 - StringBuilder sb = new StringBuilder(); 26 + StringBuilder sb = new StringBuilder();
27 - for (int k = 0; (k < 16) && (iStartIndex < iEndIndex); ++k) { 27 + for (int k = 0; (k < 16) && (iStartIndex < iEndIndex); ++k) {
28 - if (0 == k % 4) { 28 + if (0 == k % 4) {
29 - sb.append(String.format(" ")); //blank after 4 bytes 29 + sb.append(String.format(" ")); //blank after 4 bytes
30 - } 30 + }
31 - sb.append(String.format("%02X ", yTemp[iStartIndex++])); 31 + sb.append(String.format("%02X ", yTemp[iStartIndex++]));
32 - } 32 + }
33 - log.debug(sb.toString()); 33 + log.debug(sb.toString());
34 - } while (iStartIndex < iEndIndex); 34 + } while (iStartIndex < iEndIndex);
35 - } catch (Exception e) { 35 + } catch (Exception e) {
36 - log.error("[HexDump] Invalid buffer: " + e.toString()); 36 + log.error("[HexDump] Invalid buffer: " + e.toString());
37 - } 37 + }
38 - 38 +
39 - log.debug("==================================================="); 39 + log.debug("===================================================");
40 - } 40 + }
41 -} 41 +}
......