2 * Copyright 2015 Open Networking Laboratory
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org.onosproject.pcepio.protocol.ver1;
19 import org.onosproject.pcepio.exceptions.PcepParseException;
20 import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
21 import org.onosproject.pcepio.protocol.PcepAttribute;
22 import org.onosproject.pcepio.protocol.PcepEndPointsObject;
23 import org.onosproject.pcepio.protocol.PcepEroObject;
24 import org.onosproject.pcepio.protocol.PcepLspObject;
25 import org.onosproject.pcepio.protocol.PcepSrpObject;
26 import org.slf4j.Logger;
27 import org.slf4j.LoggerFactory;
29 import com.google.common.base.MoreObjects;
32 * Provides PcInitiatedLspRequest for PCEP Initiate message.
33 * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03.
35 public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest {
38 * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
39 <PCE-initiated-lsp-instantiation> ::= <SRP>
44 <PCE-initiated-lsp-deletion> ::= <SRP>
48 protected static final Logger log = LoggerFactory.getLogger(PcInitiatedLspRequestVer1.class);
51 private PcepSrpObject srpObject;
53 private PcepLspObject lspObject;
54 //PCEP End Point Object
55 private PcepEndPointsObject endPointsObject;
57 private PcepEroObject eroObject;
59 private PcepAttribute pcepAttribute;
62 * Default constructor.
64 public PcInitiatedLspRequestVer1() {
67 endPointsObject = null;
74 * Constructor to initialize all parameters of PC initiated lsp request.
76 * @param srpObject PCEP srp Object
77 * @param lspObject PCEP lsp object
78 * @param endPointsObject PCPE endpoints object
79 * @param eroObject PCEP ero object
80 * @param pcepAttribute PCEP attribute
82 public PcInitiatedLspRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject,
83 PcepEndPointsObject endPointsObject, PcepEroObject eroObject, PcepAttribute pcepAttribute) {
84 this.srpObject = srpObject;
85 this.lspObject = lspObject;
86 this.endPointsObject = endPointsObject;
87 this.eroObject = eroObject;
88 this.pcepAttribute = pcepAttribute;
93 public PcepSrpObject getSrpObject() {
98 public PcepLspObject getLspObject() {
103 public PcepEndPointsObject getEndPointsObject() {
104 return endPointsObject;
108 public PcepEroObject getEroObject() {
113 public PcepAttribute getPcepAttribute() {
114 return pcepAttribute;
118 public void setSrpObject(PcepSrpObject srpobj) {
119 this.srpObject = srpobj;
124 public void setLspObject(PcepLspObject lspObject) {
125 this.lspObject = lspObject;
129 public void setEndPointsObject(PcepEndPointsObject endPointsObject) {
130 this.endPointsObject = endPointsObject;
134 public void setEroObject(PcepEroObject eroObject) {
135 this.eroObject = eroObject;
139 public void setPcepAttribute(PcepAttribute pcepAttribute) {
140 this.pcepAttribute = pcepAttribute;
144 * Builder class for PC initiated lsp reuqest.
146 public static class Builder implements PcInitiatedLspRequest.Builder {
148 private boolean bIsSRPObjectSet = false;
149 private boolean bIsLSPObjectSet = false;
150 private boolean bIsEndPointsObjectSet = false;
151 private boolean bIsEROObjectSet = false;
152 private boolean bIsPcepAttributeSet = false;
153 private boolean bIsbRFlagSet = false;
156 private PcepSrpObject srpObject;
158 private PcepLspObject lspObject;
159 //PCEP End Point Object
160 private PcepEndPointsObject endPointsObject;
162 private PcepEroObject eroObject;
163 //PCEP Attribute list
164 private PcepAttribute pcepAttribute;
167 public PcInitiatedLspRequest build() throws PcepParseException {
170 PcepSrpObject srpObject = null;
172 PcepLspObject lspObject = null;
173 //PCEP End Point Object
174 PcepEndPointsObject endPointsObject = null;
176 PcepEroObject eroObject = null;
177 //PCEP Attribute list
178 PcepAttribute pcepAttribute = null;
179 boolean bRFlag = false;
181 if (!this.bIsSRPObjectSet) {
182 throw new PcepParseException("Srp object NOT Set while building PcInitiatedLspRequest");
184 srpObject = this.srpObject;
185 bRFlag = srpObject.getRFlag();
189 this.bIsbRFlagSet = true;
191 this.bIsbRFlagSet = false;
194 if (!this.bIsLSPObjectSet) {
195 throw new PcepParseException("LSP Object NOT Set while building PcInitiatedLspRequest");
197 lspObject = this.lspObject;
199 if (!this.bIsbRFlagSet) {
201 if (!this.bIsEndPointsObjectSet) {
202 throw new PcepParseException("EndPoints Object NOT Set while building PcInitiatedLspRequest");
204 endPointsObject = this.endPointsObject;
206 if (!this.bIsEROObjectSet) {
207 throw new PcepParseException("ERO Object NOT Set while building PcInitiatedLspRequest");
209 eroObject = this.eroObject;
211 if (bIsPcepAttributeSet) {
212 pcepAttribute = this.pcepAttribute;
215 return new PcInitiatedLspRequestVer1(srpObject, lspObject, endPointsObject, eroObject, pcepAttribute);
219 public PcepSrpObject getSrpObject() {
220 return this.srpObject;
224 public PcepLspObject getLspObject() {
225 return this.lspObject;
229 public PcepEndPointsObject getEndPointsObject() {
230 return this.endPointsObject;
234 public PcepEroObject getEroObject() {
235 return this.eroObject;
239 public PcepAttribute getPcepAttribute() {
240 return this.pcepAttribute;
244 public Builder setSrpObject(PcepSrpObject srpobj) {
245 this.srpObject = srpobj;
246 this.bIsSRPObjectSet = true;
252 public Builder setLspObject(PcepLspObject lspObject) {
253 this.lspObject = lspObject;
254 this.bIsLSPObjectSet = true;
259 public Builder setEndPointsObject(PcepEndPointsObject endPointsObject) {
260 this.endPointsObject = endPointsObject;
261 this.bIsEndPointsObjectSet = true;
266 public Builder setEroObject(PcepEroObject eroObject) {
267 this.eroObject = eroObject;
268 this.bIsEROObjectSet = true;
273 public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
274 this.pcepAttribute = pcepAttribute;
275 this.bIsPcepAttributeSet = true;
281 public String toString() {
282 return MoreObjects.toStringHelper(getClass())
284 .add("SrpObject", srpObject)
285 .add("LspObject", lspObject)
286 .add("EndPointObject", endPointsObject)
287 .add("EroObject", eroObject)
288 .add("PcepAttribute", pcepAttribute)