bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 1 | /*
|
| 2 | * Copyright 2015 Open Networking Laboratory
|
| 3 | *
|
| 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
| 5 | * you may not use this file except in compliance with the License.
|
| 6 | * You may obtain a copy of the License at
|
| 7 | *
|
| 8 | * http://www.apache.org/licenses/LICENSE-2.0
|
| 9 | *
|
| 10 | * Unless required by applicable law or agreed to in writing, software
|
| 11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| 13 | * See the License for the specific language governing permissions and
|
| 14 | * limitations under the License.
|
| 15 | */
|
| 16 |
|
| 17 | package org.onosproject.pcepio.protocol.ver1;
|
| 18 |
|
| 19 | import org.onosproject.pcepio.exceptions.PcepParseException;
|
| 20 | import org.onosproject.pcepio.protocol.PcInitiatedLspRequest;
|
| 21 | import org.onosproject.pcepio.protocol.PcepAttribute;
|
| 22 | import org.onosproject.pcepio.protocol.PcepEndPointsObject;
|
| 23 | import org.onosproject.pcepio.protocol.PcepEroObject;
|
| 24 | import org.onosproject.pcepio.protocol.PcepLspObject;
|
| 25 | import org.onosproject.pcepio.protocol.PcepSrpObject;
|
| 26 | import org.slf4j.Logger;
|
| 27 | import org.slf4j.LoggerFactory;
|
| 28 |
|
| 29 | import com.google.common.base.MoreObjects;
|
| 30 | import com.google.common.base.MoreObjects.ToStringHelper;
|
| 31 |
|
| 32 | /**
|
| 33 | * Provides PcInitiatedLspRequest for PCEP Initiate message.
|
| 34 | * Reference : PCE initiated tunnel setup draft-ietf-pce-pce-initiated-lsp-03.
|
| 35 | */
|
| 36 | public class PcInitiatedLspRequestVer1 implements PcInitiatedLspRequest {
|
| 37 |
|
| 38 | /*
|
| 39 | * <PCE-initiated-lsp-request> ::= (<PCE-initiated-lsp-instantiation>|<PCE-initiated-lsp-deletion>)
|
| 40 | <PCE-initiated-lsp-instantiation> ::= <SRP>
|
| 41 | <LSP>
|
| 42 | <END-POINTS>
|
| 43 | <ERO>
|
| 44 | [<attribute-list>]
|
| 45 | <PCE-initiated-lsp-deletion> ::= <SRP>
|
| 46 | <LSP>
|
| 47 | */
|
| 48 |
|
| 49 | protected static final Logger log = LoggerFactory.getLogger(PcInitiatedLspRequestVer1.class);
|
| 50 |
|
| 51 | //PCEP SRP Object
|
| 52 | private PcepSrpObject srpObject;
|
| 53 | //PCEP LSP Object
|
| 54 | private PcepLspObject lspObject;
|
| 55 | //PCEP End Point Object
|
| 56 | private PcepEndPointsObject endPointsObject;
|
| 57 | //PCEP ERO Object
|
| 58 | private PcepEroObject eroObject;
|
| 59 | //PCEP Attribute list
|
| 60 | private PcepAttribute pcepAttribute;
|
| 61 |
|
| 62 | /**
|
| 63 | * Default constructor.
|
| 64 | */
|
| 65 | public PcInitiatedLspRequestVer1() {
|
| 66 | srpObject = null;
|
| 67 | lspObject = null;
|
| 68 | endPointsObject = null;
|
| 69 | eroObject = null;
|
| 70 | pcepAttribute = null;
|
| 71 |
|
| 72 | }
|
| 73 |
|
| 74 | /**
|
| 75 | * Constructor to initialize all parameters of PC initiated lsp request.
|
| 76 | *
|
| 77 | * @param srpObject PCEP srp Object
|
| 78 | * @param lspObject PCEP lsp object
|
| 79 | * @param endPointsObject PCPE endpoints object
|
| 80 | * @param eroObject PCEP ero object
|
| 81 | * @param pcepAttribute PCEP attribute
|
| 82 | */
|
| 83 | public PcInitiatedLspRequestVer1(PcepSrpObject srpObject, PcepLspObject lspObject,
|
| 84 | PcepEndPointsObject endPointsObject, PcepEroObject eroObject, PcepAttribute pcepAttribute) {
|
| 85 | this.srpObject = srpObject;
|
| 86 | this.lspObject = lspObject;
|
| 87 | this.endPointsObject = endPointsObject;
|
| 88 | this.eroObject = eroObject;
|
| 89 | this.pcepAttribute = pcepAttribute;
|
| 90 |
|
| 91 | }
|
| 92 |
|
| 93 | @Override
|
| 94 | public PcepSrpObject getSrpObject() {
|
| 95 | return srpObject;
|
| 96 | }
|
| 97 |
|
| 98 | @Override
|
| 99 | public PcepLspObject getLspObject() {
|
| 100 | return lspObject;
|
| 101 | }
|
| 102 |
|
| 103 | @Override
|
| 104 | public PcepEndPointsObject getEndPointsObject() {
|
| 105 | return endPointsObject;
|
| 106 | }
|
| 107 |
|
| 108 | @Override
|
| 109 | public PcepEroObject getEroObject() {
|
| 110 | return eroObject;
|
| 111 | }
|
| 112 |
|
| 113 | @Override
|
| 114 | public PcepAttribute getPcepAttribute() {
|
| 115 | return pcepAttribute;
|
| 116 | }
|
| 117 |
|
| 118 | @Override
|
| 119 | public void setSrpObject(PcepSrpObject srpobj) {
|
| 120 | this.srpObject = srpobj;
|
| 121 |
|
| 122 | }
|
| 123 |
|
| 124 | @Override
|
| 125 | public void setLspObject(PcepLspObject lspObject) {
|
| 126 | this.lspObject = lspObject;
|
| 127 | }
|
| 128 |
|
| 129 | @Override
|
| 130 | public void setEndPointsObject(PcepEndPointsObject endPointsObject) {
|
| 131 | this.endPointsObject = endPointsObject;
|
| 132 | }
|
| 133 |
|
| 134 | @Override
|
| 135 | public void setEroObject(PcepEroObject eroObject) {
|
| 136 | this.eroObject = eroObject;
|
| 137 | }
|
| 138 |
|
| 139 | @Override
|
| 140 | public void setPcepAttribute(PcepAttribute pcepAttribute) {
|
| 141 | this.pcepAttribute = pcepAttribute;
|
| 142 | }
|
| 143 |
|
| 144 | /**
|
| 145 | * Builder class for PC initiated lsp reuqest.
|
| 146 | */
|
| 147 | public static class Builder implements PcInitiatedLspRequest.Builder {
|
| 148 |
|
| 149 | private boolean bIsSRPObjectSet = false;
|
| 150 | private boolean bIsLSPObjectSet = false;
|
| 151 | private boolean bIsEndPointsObjectSet = false;
|
| 152 | private boolean bIsEROObjectSet = false;
|
| 153 | private boolean bIsPcepAttributeSet = false;
|
| 154 | private boolean bIsbRFlagSet = false;
|
| 155 |
|
| 156 | //PCEP SRP Object
|
| 157 | private PcepSrpObject srpObject;
|
| 158 | //PCEP LSP Object
|
| 159 | private PcepLspObject lspObject;
|
| 160 | //PCEP End Point Object
|
| 161 | private PcepEndPointsObject endPointsObject;
|
| 162 | //PCEP ERO Object
|
| 163 | private PcepEroObject eroObject;
|
| 164 | //PCEP Attribute list
|
| 165 | private PcepAttribute pcepAttribute;
|
| 166 |
|
| 167 | @Override
|
| 168 | public PcInitiatedLspRequest build() throws PcepParseException {
|
| 169 |
|
| 170 | //PCEP SRP Object
|
| 171 | PcepSrpObject srpObject = null;
|
| 172 | //PCEP LSP Object
|
| 173 | PcepLspObject lspObject = null;
|
| 174 | //PCEP End Point Object
|
| 175 | PcepEndPointsObject endPointsObject = null;
|
| 176 | //PCEP ERO Object
|
| 177 | PcepEroObject eroObject = null;
|
| 178 | //PCEP Attribute list
|
| 179 | PcepAttribute pcepAttribute = null;
|
| 180 | boolean bRFlag = false;
|
| 181 |
|
| 182 | if (!this.bIsSRPObjectSet) {
|
| 183 | throw new PcepParseException("Srp object NOT Set while building PcInitiatedLspRequest");
|
| 184 | } else {
|
| 185 | srpObject = this.srpObject;
|
| 186 | bRFlag = srpObject.getRFlag();
|
| 187 | }
|
| 188 |
|
| 189 | if (bRFlag) {
|
| 190 | this.bIsbRFlagSet = true;
|
| 191 | } else {
|
| 192 | this.bIsbRFlagSet = false;
|
| 193 | }
|
| 194 |
|
| 195 | if (!this.bIsLSPObjectSet) {
|
| 196 | throw new PcepParseException("LSP Object NOT Set while building PcInitiatedLspRequest");
|
| 197 | } else {
|
| 198 | lspObject = this.lspObject;
|
| 199 | }
|
| 200 | if (!this.bIsbRFlagSet) {
|
| 201 |
|
| 202 | if (!this.bIsEndPointsObjectSet) {
|
| 203 | throw new PcepParseException("EndPoints Object NOT Set while building PcInitiatedLspRequest");
|
| 204 | } else {
|
| 205 | endPointsObject = this.endPointsObject;
|
| 206 | }
|
| 207 | if (!this.bIsEROObjectSet) {
|
| 208 | throw new PcepParseException("ERO Object NOT Set while building PcInitiatedLspRequest");
|
| 209 | } else {
|
| 210 | eroObject = this.eroObject;
|
| 211 | }
|
| 212 | if (bIsPcepAttributeSet) {
|
| 213 | pcepAttribute = this.pcepAttribute;
|
| 214 | }
|
| 215 | }
|
| 216 | return new PcInitiatedLspRequestVer1(srpObject, lspObject, endPointsObject, eroObject, pcepAttribute);
|
| 217 | }
|
| 218 |
|
| 219 | @Override
|
| 220 | public PcepSrpObject getSrpObject() {
|
| 221 | return this.srpObject;
|
| 222 | }
|
| 223 |
|
| 224 | @Override
|
| 225 | public PcepLspObject getLspObject() {
|
| 226 | return this.lspObject;
|
| 227 | }
|
| 228 |
|
| 229 | @Override
|
| 230 | public PcepEndPointsObject getEndPointsObject() {
|
| 231 | return this.endPointsObject;
|
| 232 | }
|
| 233 |
|
| 234 | @Override
|
| 235 | public PcepEroObject getEroObject() {
|
| 236 | return this.eroObject;
|
| 237 | }
|
| 238 |
|
| 239 | @Override
|
| 240 | public PcepAttribute getPcepAttribute() {
|
| 241 | return this.pcepAttribute;
|
| 242 | }
|
| 243 |
|
| 244 | @Override
|
| 245 | public Builder setSrpObject(PcepSrpObject srpobj) {
|
| 246 | this.srpObject = srpobj;
|
| 247 | this.bIsSRPObjectSet = true;
|
| 248 | return this;
|
| 249 |
|
| 250 | }
|
| 251 |
|
| 252 | @Override
|
| 253 | public Builder setLspObject(PcepLspObject lspObject) {
|
| 254 | this.lspObject = lspObject;
|
| 255 | this.bIsLSPObjectSet = true;
|
| 256 | return this;
|
| 257 | }
|
| 258 |
|
| 259 | @Override
|
| 260 | public Builder setEndPointsObject(PcepEndPointsObject endPointsObject) {
|
| 261 | this.endPointsObject = endPointsObject;
|
| 262 | this.bIsEndPointsObjectSet = true;
|
| 263 | return this;
|
| 264 | }
|
| 265 |
|
| 266 | @Override
|
| 267 | public Builder setEroObject(PcepEroObject eroObject) {
|
| 268 | this.eroObject = eroObject;
|
| 269 | this.bIsEROObjectSet = true;
|
| 270 | return this;
|
| 271 | }
|
| 272 |
|
| 273 | @Override
|
| 274 | public Builder setPcepAttribute(PcepAttribute pcepAttribute) {
|
| 275 | this.pcepAttribute = pcepAttribute;
|
| 276 | this.bIsPcepAttributeSet = true;
|
| 277 | return this;
|
| 278 | }
|
bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 279 | }
|
| 280 |
|
| 281 | @Override
|
| 282 | public String toString() {
|
| 283 | ToStringHelper toStrHelper = MoreObjects.toStringHelper(getClass());
|
bharat saraswal | e180630 | 2015-08-21 12:16:46 +0530 | [diff] [blame] | 284 | toStrHelper.add("SrpObject", srpObject).add("LspObject", lspObject);
|
bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 285 |
|
| 286 | if (endPointsObject instanceof PcepEndPointsObject) {
|
bharat saraswal | e180630 | 2015-08-21 12:16:46 +0530 | [diff] [blame] | 287 | toStrHelper.add("EndPointObject", endPointsObject);
|
bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 288 | }
|
| 289 | if (eroObject instanceof PcepEroObject) {
|
bharat saraswal | e180630 | 2015-08-21 12:16:46 +0530 | [diff] [blame] | 290 | toStrHelper.add("EroObject", eroObject);
|
bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 291 | }
|
| 292 | if (pcepAttribute instanceof PcepAttribute) {
|
bharat saraswal | e180630 | 2015-08-21 12:16:46 +0530 | [diff] [blame] | 293 | toStrHelper.add("PcepAttribute", pcepAttribute);
|
bharat saraswal | f7364db | 2015-08-11 13:39:31 +0530 | [diff] [blame] | 294 | }
|
| 295 | return toStrHelper.toString();
|
| 296 | }
|
| 297 | }
|