Phanendra Manda
Committed by Gerrit Code Review

[ONOS-2287,ONOS-2288]Pcep TunnelProvider implementation

Change-Id: I4184336c200f1060e93be5dc28076ba35f6b98f4
...@@ -85,6 +85,23 @@ public class ConnectPoint { ...@@ -85,6 +85,23 @@ public class ConnectPoint {
85 } 85 }
86 86
87 /** 87 /**
88 + * Returns the identifier of the infrastructure device if the connection
89 + * point belongs to a network element which is indeed an ip of pcc
90 + * client identifier.
91 + *
92 + * @return network element identifier as a pcc client identifier
93 + * @throws java.lang.IllegalStateException if connection point is not
94 + * associated with a pcc client
95 + */
96 + public IpElementId ipElementId() {
97 + if (elementId instanceof IpElementId) {
98 + return (IpElementId) elementId;
99 + }
100 + throw new IllegalStateException("Connection point not associated " +
101 + "with an pcc client");
102 + }
103 +
104 + /**
88 * Returns the connection port number. 105 * Returns the connection port number.
89 * 106 *
90 * @return port number 107 * @return port number
......
1 +package org.onosproject.net;
2 +
3 +import java.util.Objects;
4 +import org.onlab.packet.IpAddress;
5 +import com.google.common.base.MoreObjects;
6 +
7 +/**
8 + * Represent for a Element ID using ip address.
9 + */
10 +public final class IpElementId extends ElementId {
11 +
12 + private final IpAddress ipAddress;
13 +
14 + /**
15 + * Public construction is prohibited.
16 + * @param ipAddress ip address
17 + */
18 + private IpElementId(IpAddress ipAddress) {
19 + this.ipAddress = ipAddress;
20 + }
21 +
22 + /**
23 + * Create a IP Element ID.
24 + * @param ipAddress IP address
25 + * @return IpElementId
26 + */
27 + public static IpElementId ipElement(IpAddress ipAddress) {
28 + return new IpElementId(ipAddress);
29 + }
30 +
31 + /**
32 + * Returns the ip address.
33 + *
34 + * @return ipAddress
35 + */
36 + public IpAddress ipAddress() {
37 + return ipAddress;
38 + }
39 +
40 + @Override
41 + public int hashCode() {
42 + return Objects.hash(ipAddress);
43 + }
44 +
45 + @Override
46 + public boolean equals(Object obj) {
47 + if (this == obj) {
48 + return true;
49 + }
50 + if (obj instanceof IpElementId) {
51 + final IpElementId other = (IpElementId) obj;
52 + return Objects.equals(this.ipAddress, other.ipAddress);
53 + }
54 + return false;
55 + }
56 +
57 + @Override
58 + public String toString() {
59 + return MoreObjects.toStringHelper(getClass()).add("ipAddress", ipAddress).toString();
60 + }
61 +}
...@@ -220,5 +220,4 @@ public class PcepFactoryVer1 implements PcepFactory { ...@@ -220,5 +220,4 @@ public class PcepFactoryVer1 implements PcepFactory {
220 public PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg() { 220 public PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg() {
221 return new PcepLabelRangeResvMsgVer1.Builder(); 221 return new PcepLabelRangeResvMsgVer1.Builder();
222 } 222 }
223 -
224 } 223 }
......
1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2 - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 2 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3 - <modelVersion>4.0.0</modelVersion> 3 + <modelVersion>4.0.0</modelVersion>
4 - <parent> 4 + <parent>
5 - <groupId>org.onosproject</groupId> 5 + <groupId>org.onosproject</groupId>
6 - <artifactId>onos-pcep-providers</artifactId> 6 + <artifactId>onos-pcep-providers</artifactId>
7 - <version>1.3.0-SNAPSHOT</version> 7 + <version>1.3.0-SNAPSHOT</version>
8 - <relativePath>../pom.xml</relativePath> 8 + <relativePath>../pom.xml</relativePath>
9 - </parent> 9 + </parent>
10 - <artifactId>onos-pcep-provider-tunnel</artifactId> 10 + <artifactId>onos-pcep-provider-tunnel</artifactId>
11 - <packaging>bundle</packaging> 11 + <packaging>bundle</packaging>
12 <description>PCEP-based tunnel provider</description> 12 <description>PCEP-based tunnel provider</description>
13 - <dependencies> 13 + <dependencies>
14 - <dependency> 14 + <dependency>
15 - <groupId>org.onosproject</groupId> 15 + <groupId>org.onosproject</groupId>
16 - <artifactId>onos-app-pcep-api</artifactId> 16 + <artifactId>onos-app-pcep-api</artifactId>
17 - </dependency> 17 + </dependency>
18 - </dependencies> 18 + <dependency>
19 + <groupId>org.onosproject</groupId>
20 + <artifactId>onos-pcep-controller-api</artifactId>
21 + </dependency>
22 + </dependencies>
19 </project> 23 </project>
...\ No newline at end of file ...\ No newline at end of file
......
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.provider.pcep.tunnel.impl;
17 +
18 +import java.util.HashMap;
19 +import java.util.Map;
20 +
21 +import org.apache.commons.collections.map.MultiKeyMap;
22 +import org.onosproject.incubator.net.tunnel.TunnelId;
23 +import org.onosproject.incubator.net.tunnel.TunnelProviderService;
24 +import org.slf4j.Logger;
25 +import org.slf4j.LoggerFactory;
26 +
27 +/**
28 + * Entity to provide tunnel DB and mapping for request/response between CORE to PCEP
29 + * and PCEP to PCC.
30 + */
31 +public class PcepTunnelApiMapper {
32 + protected static final Logger log = LoggerFactory.getLogger(PcepTunnelApiMapper.class);
33 +
34 + static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep";
35 + // Map to store all the tunnel requests.
36 + private Map<Integer, PcepTunnelData> tunnelRequestQueue;
37 + //Map to store all core related tunnel requests.
38 + private Map<TunnelId, PcepTunnelData> coreTunnelRequestQueue;
39 + //Map to store all the created tunnels.
40 + private Map<Integer, PcepTunnelData> tunnelDB;
41 + // Map to store the tunnel ids, given by core and given by pcc.
42 + private Map<TunnelId, Integer> tunnelIdMap;
43 + //Map to store all the learnt tunnels.
44 + private MultiKeyMap pccTunnelDB = new MultiKeyMap();
45 +
46 + TunnelProviderService tunnelApiMapperservice;
47 +
48 + /**
49 + * Default constructor.
50 + */
51 + public PcepTunnelApiMapper() {
52 + //TODO check if the map need to initialize
53 + tunnelRequestQueue = new HashMap<Integer, PcepTunnelData>();
54 + coreTunnelRequestQueue = new HashMap<TunnelId, PcepTunnelData>();
55 + tunnelDB = new HashMap<Integer, PcepTunnelData>();
56 + tunnelIdMap = new HashMap<TunnelId, Integer>();
57 + }
58 +
59 + /**
60 + * Add tunnels to tunnel Request queues.
61 + *
62 + * @param srpId srp id
63 + * @param pcepTunnelData pcep tunnel data
64 + */
65 + public void addToTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
66 + tunnelRequestQueue.put(new Integer(srpId), pcepTunnelData);
67 + log.debug("Tunnel Added to TunnelRequestQueue");
68 + }
69 +
70 + /**
71 + * Map between Tunnel ID and pcc provided Tunnel ID.
72 + *
73 + * @param pcepTunnelData pcep tunnel data
74 + */
75 + public void addToTunnelIdMap(PcepTunnelData pcepTunnelData) {
76 + int value = pcepTunnelData.statefulIpv4IndentifierTlv().getTunnelId() & 0xFFFF;
77 + tunnelIdMap.put(pcepTunnelData.tunnel().tunnelId(), (new Integer(value)));
78 + log.debug("Tunnel ID Added to tunnelIdMap");
79 + }
80 +
81 + /**
82 + * Add tunnels to core tunnel request queue.
83 + *
84 + * @param pcepTunnelData pcep tunnel data
85 + */
86 + public void addToCoreTunnelRequestQueue(PcepTunnelData pcepTunnelData) {
87 + coreTunnelRequestQueue.put(pcepTunnelData.tunnel().tunnelId(), pcepTunnelData);
88 + log.debug("Tunnel Added to CoreTunnelRequestQueue");
89 + }
90 +
91 + /**
92 + * Removes tunnels from the core tunnel request queue.
93 + *
94 + * @param tunnelId tunnel id
95 + */
96 + public void removeFromCoreTunnelRequestQueue(TunnelId tunnelId) {
97 + coreTunnelRequestQueue.remove(tunnelId);
98 + log.debug("Tunnnel create response sent to core and removed from CoreTunnelRequestQueue");
99 + }
100 +
101 + /**
102 + * Handle the report which comes after initiate message.
103 + *
104 + * @param srpId srp id
105 + * @param pcepTunnelData pcep tunnel data
106 + */
107 + public void handleCreateTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
108 +
109 + int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId());
110 + tunnelDB.put(new Integer(value), pcepTunnelData);
111 + tunnelRequestQueue.remove(new Integer(srpId), pcepTunnelData);
112 + log.debug("Tunnel Added to TunnelDBQueue and removed from TunnelRequestQueue. tunnel id {}"
113 + + (new Integer(value)).toString());
114 + }
115 +
116 + /**
117 + * Handle report which comes for update message.
118 + *
119 + * @param srpId srp id
120 + * @param pcepTunnelData pcep tunnel data
121 + */
122 + public void handleUpdateTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
123 + if (pcepTunnelData.rptFlag()) {
124 + pcepTunnelData.setRptFlag(false);
125 + int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId());
126 + tunnelDB.put(new Integer(value), pcepTunnelData);
127 + tunnelRequestQueue.remove(new Integer(srpId), pcepTunnelData);
128 + log.debug("Tunnel Added to TunnelDBQueue and removed from TunnelRequestQueue. tunnel id {}" ,
129 + (new Integer(value)).toString());
130 + } else {
131 + pcepTunnelData.setRptFlag(true);
132 + tunnelRequestQueue.put(new Integer(srpId), pcepTunnelData);
133 + log.debug("Tunnel updated in TunnelRequestQueue");
134 + }
135 + }
136 +
137 + /**
138 + * Handle report for tunnel Release request.
139 + *
140 + * @param srpId srp id
141 + * @param pcepTunnelData pcep tunnel data
142 + */
143 + public void handleRemoveFromTunnelRequestQueue(int srpId, PcepTunnelData pcepTunnelData) {
144 +
145 + int value = tunnelIdMap.get(pcepTunnelData.tunnel().tunnelId());
146 + tunnelIdMap.remove(pcepTunnelData.tunnel().tunnelId());
147 + tunnelDB.remove(new Integer(value));
148 + tunnelRequestQueue.remove(srpId);
149 + log.debug("Tunnel removed from TunnelDBQueue and TunnelRequestQueue");
150 + }
151 +
152 + /**
153 + * Returns PcepTunnelData from the tunnel request queue.
154 + *
155 + * @param srpId srp id
156 + * @return PcepTunnelData pcep tunnel data
157 + */
158 + public PcepTunnelData getDataFromTunnelRequestQueue(int srpId) {
159 + return tunnelRequestQueue.get(new Integer(srpId));
160 +
161 + }
162 +
163 + /**
164 + * Returns PcepTunnelData from the tunnel DB.
165 + *
166 + * @param tunnelId tunnel id
167 + * @return PcepTunnelData pcep tunnel data
168 + */
169 + public PcepTunnelData getDataFromTunnelDBQueue(TunnelId tunnelId) {
170 + int value = tunnelIdMap.get(tunnelId);
171 + return tunnelDB.get((new Integer(value)));
172 + }
173 +
174 + /**
175 + * Checks whether the tunnel exist in tunnel request queue.
176 + *
177 + * @param srpId srp id
178 + * @return true if tunnel exist in reuest queue, false otherwise
179 + */
180 + public boolean checkFromTunnelRequestQueue(int srpId) {
181 + boolean retValue = tunnelRequestQueue.containsKey(srpId);
182 + return retValue;
183 + }
184 +
185 + /**
186 + * Returns whether tunnel exist in tunnel db.
187 + *
188 + * @param tunnelId
189 + * @return true/false
190 + */
191 + public boolean checkFromTunnelDBQueue(TunnelId tunnelId) {
192 + int value = tunnelIdMap.get(tunnelId);
193 + boolean retValue = tunnelDB.containsKey((new Integer(value)));
194 + return retValue;
195 + }
196 +
197 + /**
198 + * Add Learnt tunnels to pcc tunnel DB.
199 + *
200 + * @param pcepTunnelData pcep tunnel data
201 + */
202 + public void addPccTunnelDB(PcepTunnelData pcepTunnelData) {
203 + pccTunnelDB.put(pcepTunnelData.statefulIpv4IndentifierTlv().getTunnelId() & 0xFFFFL,
204 + pcepTunnelData.statefulIpv4IndentifierTlv().getIpv4IngressAddress(), pcepTunnelData);
205 + }
206 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.provider.pcep.tunnel.impl;
17 +
18 +import java.util.Objects;
19 +
20 +import org.onosproject.incubator.net.tunnel.Tunnel;
21 +import org.onosproject.net.ElementId;
22 +import org.onosproject.net.Path;
23 +import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
24 +
25 +import com.google.common.base.MoreObjects;
26 +
27 +/**
28 + * To store all tunnel related information from Core and Path computation client.
29 + */
30 +public class PcepTunnelData {
31 +
32 + private Tunnel tunnel;
33 + private Path path;
34 + private int plspId;
35 + private ElementId elementId;
36 + private RequestType requestType;
37 + private boolean rptFlag;
38 +
39 + // data need to store from LSP object
40 + private boolean lspAFlag;
41 + private boolean lspDFlag;
42 + private byte lspOFlag;
43 + private short tunnelId;
44 + private int extTunnelId;
45 + private short lspId;
46 + private StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv;
47 +
48 + /**
49 + * Default constructor.
50 + */
51 + public PcepTunnelData() {
52 + this.elementId = null;
53 + this.tunnel = null;
54 + this.path = null;
55 + this.requestType = null;
56 + this.rptFlag = false;
57 + this.plspId = 0;
58 + }
59 +
60 + /**
61 + * Constructor to initialize Tunnel, Path and Request type.
62 + *
63 + * @param tunnel mpls tunnel
64 + * @param path Path in network
65 + * @param requestType request type for tunnel
66 + */
67 + public PcepTunnelData(Tunnel tunnel, Path path, RequestType requestType) {
68 + this.tunnel = tunnel;
69 + this.path = path;
70 + this.requestType = requestType;
71 + }
72 +
73 + /**
74 + * Constructor to initialize ElemendId, Tunnel, Path and Request type.
75 + *
76 + * @param elementId Ip element id
77 + * @param tunnel mpls tunnel
78 + * @param path Path in network
79 + * @param requestType request type for tunnel
80 + */
81 + public PcepTunnelData(ElementId elementId, Tunnel tunnel, Path path, RequestType requestType) {
82 + this.elementId = elementId;
83 + this.tunnel = tunnel;
84 + this.path = path;
85 + this.requestType = requestType;
86 + }
87 +
88 + /**
89 + * Constructor to initialize Tunnel and Request type.
90 + *
91 + * @param tunnel Tunnel from core
92 + * @param requestType request type for tunnel
93 + */
94 + public PcepTunnelData(Tunnel tunnel, RequestType requestType) {
95 + this.tunnel = tunnel;
96 + this.requestType = requestType;
97 + }
98 +
99 + /**
100 + * Constructor to initialize ElementId, Tunnel and Request type.
101 + *
102 + * @param elementId Ip element id
103 + * @param tunnel mpls tunnel
104 + * @param requestType request type for tunnel
105 + */
106 + public PcepTunnelData(ElementId elementId, Tunnel tunnel, RequestType requestType) {
107 + this.elementId = elementId;
108 + this.tunnel = tunnel;
109 + this.requestType = requestType;
110 + }
111 +
112 + /**
113 + * Sets ip element id.
114 + *
115 + * @param elementId Ip element id
116 + */
117 + public void setElementId(ElementId elementId) {
118 + this.elementId = elementId;
119 + }
120 +
121 + /**
122 + * Sets tunnel.
123 + *
124 + * @param tunnel mpls tunnel
125 + */
126 + public void setTunnel(Tunnel tunnel) {
127 + this.tunnel = tunnel;
128 + }
129 +
130 + /**
131 + * Sets Path.
132 + *
133 + * @param path Path in network
134 + */
135 + public void setPath(Path path) {
136 + this.path = path;
137 + }
138 +
139 + /**
140 + * Request type for tunnel.
141 + *
142 + * @param requestType request type for tunnel
143 + */
144 + public void setRequestType(RequestType requestType) {
145 + this.requestType = requestType;
146 + }
147 +
148 + /**
149 + * Sets plspid generated from pcc.
150 + *
151 + * @param plspId plsp identifier
152 + */
153 + public void setPlspId(int plspId) {
154 + this.plspId = plspId;
155 + }
156 +
157 + /**
158 + * Sets A flag from lsp object.
159 + *
160 + * @param value A flag value
161 + */
162 + public void setLspAFlag(boolean value) {
163 + this.lspAFlag = value;
164 + }
165 +
166 + /**
167 + * Sets OF flag from lsp object.
168 + *
169 + * @param value OF flag value
170 + */
171 + public void setLspOFlag(byte value) {
172 + this.lspOFlag = value;
173 + }
174 +
175 + /**
176 + * Sets tunnel id from PCC.
177 + *
178 + * @param value tunnel id value
179 + */
180 + public void setTunnelId(short value) {
181 + this.tunnelId = value;
182 + }
183 +
184 + /**
185 + * Sets extended tunnel id from PCC.
186 + *
187 + * @param value extended tunnel id value
188 + */
189 + public void setExtTunnelId(int value) {
190 + this.extTunnelId = value;
191 + }
192 +
193 + /**
194 + * Sets lsp id from pcc.
195 + *
196 + * @param value lsp id
197 + */
198 + public void setLspId(short value) {
199 + this.lspId = value;
200 + }
201 +
202 + /**
203 + * Sets statefulIpv4Identifiers tlv.
204 + * @param value statefulIpv4Identifiers tlv
205 + */
206 + public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentidiersTlv value) {
207 + this.statefulIpv4IndentifierTlv = value;
208 + }
209 +
210 + /**
211 + * Sets report flag.
212 + *
213 + * @param rptFlag report flag
214 + */
215 + public void setRptFlag(boolean rptFlag) {
216 + this.rptFlag = rptFlag;
217 + }
218 +
219 + /**
220 + * Sets D flag from lsp object.
221 + *
222 + * @param value D flag value
223 + */
224 + public void setLspDFlag(boolean value) {
225 + this.lspDFlag = value;
226 + }
227 +
228 + /**
229 + * To get Ip element id.
230 + *
231 + * @return Ip elemend id
232 + */
233 + public ElementId elementId() {
234 + return this.elementId;
235 + }
236 +
237 + /**
238 + * To get Tunnel.
239 + *
240 + * @return tunnel
241 + */
242 + public Tunnel tunnel() {
243 + return this.tunnel;
244 + }
245 +
246 + /**
247 + * To get Path.
248 + *
249 + * @return path
250 + */
251 + public Path path() {
252 + return this.path;
253 + }
254 +
255 + /**
256 + * To get request type.
257 + *
258 + * @return request type
259 + */
260 + public RequestType requestType() {
261 + return this.requestType;
262 + }
263 +
264 + /**
265 + * To get pLspId.
266 + *
267 + * @return pLspId
268 + */
269 + public int plspId() {
270 + return this.plspId;
271 + }
272 +
273 + /**
274 + * To get A flag.
275 + *
276 + * @return A flag
277 + */
278 + public boolean lspAFlag() {
279 + return this.lspAFlag;
280 + }
281 +
282 + /**
283 + * To get OF flag.
284 + *
285 + * @return OF flag
286 + */
287 + public byte lspOFlag() {
288 + return this.lspOFlag;
289 + }
290 +
291 + /**
292 + * To get tunnel id.
293 + *
294 + * @return tunnel id
295 + */
296 + public short tunnelId() {
297 + return this.tunnelId;
298 + }
299 +
300 + /**
301 + * To get extended tunnel id.
302 + *
303 + * @return extended tunnel id
304 + */
305 + public int extTunnelId() {
306 + return this.extTunnelId;
307 + }
308 +
309 + /**
310 + * To get pLspId.
311 + *
312 + * @return pLspId
313 + */
314 + public short lspId() {
315 + return this.lspId;
316 + }
317 +
318 + /**
319 + * To get D Flag.
320 + *
321 + * @return d flag
322 + */
323 + public boolean lspDFlag() {
324 + return this.lspDFlag;
325 + }
326 +
327 + /**
328 + * To get statefulIpv4Indentifier tlv.
329 + *
330 + * @return statefulIpv4Indentifier tlv
331 + */
332 + public StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv() {
333 + return this.statefulIpv4IndentifierTlv;
334 + }
335 +
336 + /**
337 + * To get report flag.
338 + *
339 + * @return report flag
340 + */
341 + public boolean rptFlag() {
342 + return this.rptFlag;
343 + }
344 +
345 + @Override
346 + public boolean equals(Object obj) {
347 + if (this == obj) {
348 + return true;
349 + }
350 +
351 + if (obj instanceof PcepTunnelData) {
352 + PcepTunnelData other = (PcepTunnelData) obj;
353 + return Objects.equals(tunnel, other.tunnel)
354 + && Objects.equals(path, other.path)
355 + && Objects.equals(plspId, other.plspId)
356 + && Objects.equals(elementId, other.elementId)
357 + && Objects.equals(requestType, other.requestType)
358 + && Objects.equals(rptFlag, other.rptFlag)
359 + && Objects.equals(lspAFlag, other.lspAFlag)
360 + && Objects.equals(lspDFlag, other.lspDFlag)
361 + && Objects.equals(lspOFlag, other.lspOFlag)
362 + && Objects.equals(tunnelId, other.tunnelId)
363 + && Objects.equals(extTunnelId, other.extTunnelId)
364 + && Objects.equals(lspId, other.lspId)
365 + && Objects.equals(statefulIpv4IndentifierTlv, other.statefulIpv4IndentifierTlv);
366 + }
367 +
368 + return false;
369 + }
370 +
371 + @Override
372 + public int hashCode() {
373 + return Objects.hash(tunnel, path, plspId, elementId, requestType, rptFlag, lspAFlag,
374 + lspDFlag, lspOFlag, tunnelId, extTunnelId, lspId, statefulIpv4IndentifierTlv);
375 + }
376 +
377 + @Override
378 + public String toString() {
379 + return MoreObjects.toStringHelper(getClass()).add("Tunnel", tunnel)
380 + .add("Path", path).add("PlspId", plspId).add("ElementId", elementId)
381 + .add("RequestType", requestType).add("RptFlag", rptFlag).add("LspAFlag", lspAFlag)
382 + .add("LspDFlag", lspDFlag).add("LspOFlag", lspOFlag).add("TunnelId", tunnelId)
383 + .add("ExtTunnelid", extTunnelId).add("LspId", lspId)
384 + .add("StatefulIpv4IndentifierTlv", statefulIpv4IndentifierTlv).toString();
385 + }
386 +}
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.provider.pcep.tunnel.impl;
17 +
18 +/**
19 + * Enum of request types between pcc and pcep.
20 + */
21 +public enum RequestType {
22 + /**
23 + * Specifies the request type for PCC is to create new tunnel.
24 + */
25 + CREATE,
26 +
27 + /**
28 + * Specifies the request type for PCC is to update existing tunnel.
29 + */
30 + UPDATE,
31 +
32 + /**
33 + * Specifies the request type for PCC is to delete existing tunnel.
34 + */
35 + DELETE,
36 +
37 + /**
38 + * Specifies the request type for PCC to report existing tunnel.
39 + */
40 + LSP_STATE_RPT;
41 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/*
2 + * Copyright 2015 Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +package org.onosproject.provider.pcep.tunnel.impl;
17 +
18 +import static org.slf4j.LoggerFactory.getLogger;
19 +
20 +import java.util.concurrent.atomic.AtomicInteger;
21 +
22 +import org.slf4j.Logger;
23 +
24 +/**
25 + * Unique Srp Id generator for pcep messages.
26 + */
27 +public final class SrpIdGenerators {
28 +
29 + private static final Logger log = getLogger(SrpIdGenerators.class);
30 + private static final AtomicInteger SRP_ID_GEN = new AtomicInteger();
31 + private static final int MAX_SRP_ID = 0x7FFFFFFF;
32 + private static int srpId;
33 +
34 + /**
35 + * Default constructor.
36 + */
37 + private SrpIdGenerators() {
38 + }
39 +
40 + /**
41 + * Get the next srp id.
42 + *
43 + * @return srp id
44 + */
45 + public static int create() {
46 + do {
47 + if (srpId >= MAX_SRP_ID) {
48 + if (SRP_ID_GEN.get() >= MAX_SRP_ID) {
49 + SRP_ID_GEN.set(0);
50 + }
51 + }
52 + srpId = SRP_ID_GEN.incrementAndGet();
53 + } while (srpId > MAX_SRP_ID);
54 + return srpId;
55 + }
56 +}