Avantika-Huawei
Committed by Gerrit Code Review

[ONOS-4163] Provider side changes to support stateful PCE and PCECC

Change-Id: I0a57ed1d1e505a2e94921fd5f5d92426a105ad12
Showing 20 changed files with 780 additions and 57 deletions
...@@ -52,6 +52,8 @@ import org.onosproject.pcepio.protocol.PcepOpenMsg; ...@@ -52,6 +52,8 @@ import org.onosproject.pcepio.protocol.PcepOpenMsg;
52 import org.onosproject.pcepio.protocol.PcepOpenObject; 52 import org.onosproject.pcepio.protocol.PcepOpenObject;
53 import org.onosproject.pcepio.protocol.PcepType; 53 import org.onosproject.pcepio.protocol.PcepType;
54 import org.onosproject.pcepio.protocol.PcepVersion; 54 import org.onosproject.pcepio.protocol.PcepVersion;
55 +import org.onosproject.pcepio.types.IPv4RouterIdOfLocalNodeSubTlv;
56 +import org.onosproject.pcepio.types.NodeAttributesTlv;
55 import org.onosproject.pcepio.types.PceccCapabilityTlv; 57 import org.onosproject.pcepio.types.PceccCapabilityTlv;
56 import org.onosproject.pcepio.types.StatefulPceCapabilityTlv; 58 import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
57 import org.onosproject.pcepio.types.PcepErrorDetailInfo; 59 import org.onosproject.pcepio.types.PcepErrorDetailInfo;
...@@ -136,7 +138,7 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { ...@@ -136,7 +138,7 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
136 @Override 138 @Override
137 void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException { 139 void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
138 140
139 - log.debug("Message received in OPEN WAIT State"); 141 + log.info("Message received in OPEN WAIT State");
140 142
141 //check for open message 143 //check for open message
142 if (m.getType() != PcepType.OPEN) { 144 if (m.getType() != PcepType.OPEN) {
...@@ -166,6 +168,33 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { ...@@ -166,6 +168,33 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
166 h.deadTime = DEADTIMER_MAXIMUM_VALUE; 168 h.deadTime = DEADTIMER_MAXIMUM_VALUE;
167 } 169 }
168 } 170 }
171 +
172 + LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv();
173 + for (PcepValueType optionalTlv : optionalTlvs) {
174 + if (optionalTlv instanceof NodeAttributesTlv) {
175 + List<PcepValueType> subTlvs = ((NodeAttributesTlv) optionalTlv)
176 + .getllNodeAttributesSubTLVs();
177 + for (PcepValueType subTlv : subTlvs) {
178 + if (subTlv instanceof IPv4RouterIdOfLocalNodeSubTlv) {
179 + h.thispccId = PccId.pccId(IpAddress
180 + .valueOf(((IPv4RouterIdOfLocalNodeSubTlv) subTlv).getInt()));
181 + break;
182 + }
183 + }
184 + break;
185 + }
186 + }
187 +
188 + if (h.thispccId == null) {
189 + final SocketAddress address = h.channel.getRemoteAddress();
190 + if (!(address instanceof InetSocketAddress)) {
191 + throw new IOException("Invalid client connection. Pcc is indentifed based on IP");
192 + }
193 +
194 + final InetSocketAddress inetAddress = (InetSocketAddress) address;
195 + h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress()));
196 + }
197 +
169 h.sendHandshakeOpenMessage(); 198 h.sendHandshakeOpenMessage();
170 h.pcepPacketStats.addOutPacket(); 199 h.pcepPacketStats.addOutPacket();
171 h.setState(KEEPWAIT); 200 h.setState(KEEPWAIT);
...@@ -178,23 +207,16 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { ...@@ -178,23 +207,16 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
178 KEEPWAIT(false) { 207 KEEPWAIT(false) {
179 @Override 208 @Override
180 void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException { 209 void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
181 - log.debug("message received in KEEPWAIT state"); 210 + log.info("message received in KEEPWAIT state");
182 //check for keep alive message 211 //check for keep alive message
183 if (m.getType() != PcepType.KEEP_ALIVE) { 212 if (m.getType() != PcepType.KEEP_ALIVE) {
184 // When the message type is not keep alive message increment the wrong packet statistics 213 // When the message type is not keep alive message increment the wrong packet statistics
185 h.processUnknownMsg(); 214 h.processUnknownMsg();
186 - log.debug("message is not KEEPALIVE message"); 215 + log.error("message is not KEEPALIVE message");
187 } else { 216 } else {
188 // Set the client connected status 217 // Set the client connected status
189 h.pcepPacketStats.addInPacket(); 218 h.pcepPacketStats.addInPacket();
190 - final SocketAddress address = h.channel.getRemoteAddress();
191 - if (!(address instanceof InetSocketAddress)) {
192 - throw new IOException("Invalid client connection. Pcc is indentifed based on IP");
193 - }
194 log.debug("sending keep alive message in KEEPWAIT state"); 219 log.debug("sending keep alive message in KEEPWAIT state");
195 -
196 - final InetSocketAddress inetAddress = (InetSocketAddress) address;
197 - h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress()));
198 h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion, 220 h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion,
199 h.pcepPacketStats); 221 h.pcepPacketStats);
200 //Get pc instance and set capabilities 222 //Get pc instance and set capabilities
......
...@@ -25,7 +25,7 @@ import org.onosproject.pcepio.protocol.PcepLspObject; ...@@ -25,7 +25,7 @@ import org.onosproject.pcepio.protocol.PcepLspObject;
25 import org.onosproject.pcepio.types.PcepErrorDetailInfo; 25 import org.onosproject.pcepio.types.PcepErrorDetailInfo;
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.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; 28 +import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
29 import org.onosproject.pcepio.types.StatefulLspDbVerTlv; 29 import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
30 import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv; 30 import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
31 import org.onosproject.pcepio.types.StatefulRsvpErrorSpecTlv; 31 import org.onosproject.pcepio.types.StatefulRsvpErrorSpecTlv;
...@@ -325,8 +325,8 @@ public class PcepLspObjectVer1 implements PcepLspObject { ...@@ -325,8 +325,8 @@ public class PcepLspObjectVer1 implements PcepLspObject {
325 325
326 switch (hType) { 326 switch (hType) {
327 327
328 - case StatefulIPv4LspIdentidiersTlv.TYPE: 328 + case StatefulIPv4LspIdentifiersTlv.TYPE:
329 - tlv = StatefulIPv4LspIdentidiersTlv.read(cb); 329 + tlv = StatefulIPv4LspIdentifiersTlv.read(cb);
330 break; 330 break;
331 case StatefulLspErrorCodeTlv.TYPE: 331 case StatefulLspErrorCodeTlv.TYPE:
332 iValue = cb.readInt(); 332 iValue = cb.readInt();
......
...@@ -45,7 +45,7 @@ public class PathSetupTypeTlv implements PcepValueType { ...@@ -45,7 +45,7 @@ public class PathSetupTypeTlv implements PcepValueType {
45 */ 45 */
46 protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class); 46 protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class);
47 47
48 - public static final short TYPE = 0; //TODO : need to reassign the value as per RFC 48 + public static final short TYPE = 28;
49 public static final short LENGTH = 4; 49 public static final short LENGTH = 4;
50 50
51 private final byte pst; 51 private final byte pst;
......
...@@ -28,7 +28,7 @@ import com.google.common.base.MoreObjects; ...@@ -28,7 +28,7 @@ import com.google.common.base.MoreObjects;
28 /** 28 /**
29 * Provides StatefulIPv4LspIdentidiersTlv. 29 * Provides StatefulIPv4LspIdentidiersTlv.
30 */ 30 */
31 -public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { 31 +public class StatefulIPv4LspIdentifiersTlv implements PcepValueType {
32 32
33 /* IPV4-LSP-IDENTIFIERS TLV format 33 /* IPV4-LSP-IDENTIFIERS TLV format
34 * 34 *
...@@ -50,7 +50,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { ...@@ -50,7 +50,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
50 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 50 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
51 51
52 */ 52 */
53 - protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class); 53 + protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentifiersTlv.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;
...@@ -70,7 +70,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { ...@@ -70,7 +70,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
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 StatefulIPv4LspIdentifiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
74 int ipv4EgressAddress) { 74 int ipv4EgressAddress) {
75 75
76 this.ipv4IngressAddress = ipv4IngressAddress; 76 this.ipv4IngressAddress = ipv4IngressAddress;
...@@ -90,9 +90,9 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { ...@@ -90,9 +90,9 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
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 StatefulIPv4LspIdentifiersTlv 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 StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
96 ipv4EgressAddress); 96 ipv4EgressAddress);
97 } 97 }
98 98
...@@ -106,6 +106,15 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { ...@@ -106,6 +106,15 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
106 } 106 }
107 107
108 /** 108 /**
109 + * Returns LSP id.
110 + *
111 + * @return lspId
112 + */
113 + public short getLspId() {
114 + return this.lspId;
115 + }
116 +
117 + /**
109 * Returns extendedTunnelId. 118 * Returns extendedTunnelId.
110 * 119 *
111 * @return extendedTunnelId 120 * @return extendedTunnelId
...@@ -157,8 +166,8 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { ...@@ -157,8 +166,8 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
157 if (this == obj) { 166 if (this == obj) {
158 return true; 167 return true;
159 } 168 }
160 - if (obj instanceof StatefulIPv4LspIdentidiersTlv) { 169 + if (obj instanceof StatefulIPv4LspIdentifiersTlv) {
161 - StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj; 170 + StatefulIPv4LspIdentifiersTlv other = (StatefulIPv4LspIdentifiersTlv) obj;
162 return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress) 171 return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
163 && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId) 172 && Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
164 && Objects.equals(this.extendedTunnelId, other.extendedTunnelId) 173 && Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
...@@ -193,7 +202,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType { ...@@ -193,7 +202,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
193 short tunnelId = c.readShort(); 202 short tunnelId = c.readShort();
194 int extendedTunnelId = c.readInt(); 203 int extendedTunnelId = c.readInt();
195 int ipv4EgressAddress = c.readInt(); 204 int ipv4EgressAddress = c.readInt();
196 - return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId, 205 + return new StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
197 ipv4EgressAddress); 206 ipv4EgressAddress);
198 } 207 }
199 208
......
...@@ -555,4 +555,40 @@ public class PcepOpenMsgTest { ...@@ -555,4 +555,40 @@ public class PcepOpenMsgTest {
555 assertThat(testOpenMsg, is(openMsg)); 555 assertThat(testOpenMsg, is(openMsg));
556 556
557 } 557 }
558 +
559 + /**
560 + * This test case checks open object with LSR id encoded.
561 + */
562 + @Test
563 + public void openMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
564 +
565 + byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, // common header
566 + 0x01, 0x10, 0x00, 0x14, // common object header
567 + 0x20, 0x05, 0x1E, 0x01, // OPEN object
568 + (byte) 0xFF, 0x05, 0x00, 0x08, // Node attribute TLV
569 + 0x00, 0x11, 0x00, 0x04, // PCEP-LS-IPv4-ROUTER-ID sub tlv
570 + 0x02, 0x02, 0x02, 0x02
571 + };
572 +
573 + byte[] testOpenMsg = {0};
574 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
575 + buffer.writeBytes(openMsg);
576 +
577 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
578 + PcepMessage message = null;
579 +
580 + message = reader.readFrom(buffer);
581 +
582 + assertThat(message, instanceOf(PcepOpenMsg.class));
583 +
584 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
585 + message.writeTo(buf);
586 + testOpenMsg = buf.array();
587 +
588 + int readLen = buf.writerIndex() - 0;
589 + testOpenMsg = new byte[readLen];
590 + buf.readBytes(testOpenMsg, 0, readLen);
591 + assertThat(testOpenMsg, is(openMsg));
592 +
593 + }
558 } 594 }
......
...@@ -184,14 +184,14 @@ public class PcepReportMsgExtTest { ...@@ -184,14 +184,14 @@ public class PcepReportMsgExtTest {
184 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object 184 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
185 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv 185 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
186 0x07, 0x10, 0x00, 0x14, //ERO object 186 0x07, 0x10, 0x00, 0x14, //ERO object
187 - 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, 187 + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
188 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, 188 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
189 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object 189 0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 190 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
191 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object 191 0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
192 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object 192 0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
193 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object 193 0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
194 - 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, 194 + 0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, //RRO IPv4 subobjects
195 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06, 195 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
196 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 196 0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
197 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01, 197 0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
...@@ -216,4 +216,83 @@ public class PcepReportMsgExtTest { ...@@ -216,4 +216,83 @@ public class PcepReportMsgExtTest {
216 216
217 assertThat(testReportMsg, is(reportMsg)); 217 assertThat(testReportMsg, is(reportMsg));
218 } 218 }
219 +
220 + /**
221 + * Tests PCRpt msg with Path-Setup-Type TLV as SR.
222 + *
223 + * @throws PcepParseException
224 + * @throws PcepOutOfBoundMessageException
225 + */
226 + @Test
227 + public void reportMessageTest43() throws PcepParseException, PcepOutOfBoundMessageException {
228 +
229 + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
230 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
231 + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
232 + 0x00, 0x00, 0x00, 0x01,
233 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
234 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
235 + 0x07, 0x10, 0x00, 0x14, //ERO object
236 + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
237 + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
238 + };
239 +
240 + byte[] testReportMsg = {0};
241 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
242 + buffer.writeBytes(reportMsg);
243 +
244 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
245 + PcepMessage message = null;
246 +
247 + message = reader.readFrom(buffer);
248 + assertThat(message, instanceOf(PcepReportMsg.class));
249 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
250 + message.writeTo(buf);
251 +
252 + int readLen = buf.writerIndex();
253 + testReportMsg = new byte[readLen];
254 + buf.readBytes(testReportMsg, 0, readLen);
255 +
256 + assertThat(testReportMsg, is(reportMsg));
257 + }
258 +
259 + /**
260 + * Tests PCRpt msg with Path-Setup-Type TLV as "without SR and without signalling".
261 + *
262 + * @throws PcepParseException
263 + * @throws PcepOutOfBoundMessageException
264 + */
265 + @Test
266 + public void reportMessageTest44() throws PcepParseException, PcepOutOfBoundMessageException {
267 +
268 + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
269 + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
270 + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
271 + 0x00, 0x00, 0x00, 0x02,
272 + 0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
273 + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
274 + 0x07, 0x10, 0x00, 0x14, //ERO object
275 + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
276 + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
277 + };
278 +
279 + byte[] testReportMsg = {0};
280 + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
281 + buffer.writeBytes(reportMsg);
282 +
283 + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
284 + PcepMessage message = null;
285 +
286 + message = reader.readFrom(buffer);
287 + assertThat(message, instanceOf(PcepReportMsg.class));
288 + ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
289 + message.writeTo(buf);
290 +
291 + int readLen = buf.writerIndex();
292 + testReportMsg = new byte[readLen];
293 + buf.readBytes(testReportMsg, 0, readLen);
294 +
295 + assertThat(testReportMsg, is(reportMsg));
296 + }
297 +
219 } 298 }
......
...@@ -18,7 +18,10 @@ package org.onosproject.pcepio.types; ...@@ -18,7 +18,10 @@ package org.onosproject.pcepio.types;
18 import com.google.common.testing.EqualsTester; 18 import com.google.common.testing.EqualsTester;
19 import org.junit.Test; 19 import org.junit.Test;
20 20
21 -public class StatefulIPv4LspIdentidiersTlvTest { 21 +/**
22 + * Tests class StatefulIPv4LspIdentifiersTlv.
23 + */
24 +public class StatefulIPv4LspIdentifiersTlvTest {
22 25
23 private final int ipv4IngressAddress = 1; 26 private final int ipv4IngressAddress = 1;
24 private final short lspId = 1; 27 private final short lspId = 1;
...@@ -26,7 +29,7 @@ public class StatefulIPv4LspIdentidiersTlvTest { ...@@ -26,7 +29,7 @@ public class StatefulIPv4LspIdentidiersTlvTest {
26 private final int extendedTunnelId = 1; 29 private final int extendedTunnelId = 1;
27 private final int ipv4EgressAddress = 1; 30 private final int ipv4EgressAddress = 1;
28 31
29 - private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId, 32 + private final StatefulIPv4LspIdentifiersTlv tlv1 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress, lspId,
30 tunnelId, extendedTunnelId, ipv4EgressAddress); 33 tunnelId, extendedTunnelId, ipv4EgressAddress);
31 34
32 private final int ipv4IngressAddress1 = 1; 35 private final int ipv4IngressAddress1 = 1;
...@@ -35,7 +38,7 @@ public class StatefulIPv4LspIdentidiersTlvTest { ...@@ -35,7 +38,7 @@ public class StatefulIPv4LspIdentidiersTlvTest {
35 private final int extendedTunnelId1 = 1; 38 private final int extendedTunnelId1 = 1;
36 private final int ipv4EgressAddress1 = 1; 39 private final int ipv4EgressAddress1 = 1;
37 40
38 - private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1, 41 + private final StatefulIPv4LspIdentifiersTlv tlv2 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress1, lspId1,
39 tunnelId1, extendedTunnelId1, ipv4EgressAddress1); 42 tunnelId1, extendedTunnelId1, ipv4EgressAddress1);
40 43
41 private final int ipv4IngressAddress2 = 2; 44 private final int ipv4IngressAddress2 = 2;
...@@ -44,9 +47,12 @@ public class StatefulIPv4LspIdentidiersTlvTest { ...@@ -44,9 +47,12 @@ public class StatefulIPv4LspIdentidiersTlvTest {
44 private final int extendedTunnelId2 = 2; 47 private final int extendedTunnelId2 = 2;
45 private final int ipv4EgressAddress2 = 2; 48 private final int ipv4EgressAddress2 = 2;
46 49
47 - private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2, 50 + private final StatefulIPv4LspIdentifiersTlv tlv3 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress2, lspId2,
48 tunnelId2, extendedTunnelId2, ipv4EgressAddress2); 51 tunnelId2, extendedTunnelId2, ipv4EgressAddress2);
49 52
53 + /**
54 + * Tests equality of objects of class StatefulIPv4LspIdentifiersTlv.
55 + */
50 @Test 56 @Test
51 public void basics() { 57 public void basics() {
52 new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals(); 58 new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
......
1 +/*
2 + * Copyright 2016-present 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.provider.pcep.tunnel.impl;
18 +
19 +/**
20 + * Representation of LSP type.
21 + */
22 +public enum LspType {
23 + /**
24 + * Signifies that path is created via signaling mode.
25 + */
26 + WITH_SIGNALLING(0),
27 +
28 + /**
29 + * Signifies that path is created via SR mode.
30 + */
31 + SR_WITHOUT_SIGNALLING(1),
32 +
33 + /**
34 + * Signifies that path is created via without signaling and without SR mode.
35 + */
36 + WITHOUT_SIGNALLING_AND_WITHOUT_SR(2);
37 +
38 + int value;
39 +
40 + /**
41 + * Assign val with the value as the LSP type.
42 + *
43 + * @param val LSP type
44 + */
45 + LspType(int val) {
46 + value = val;
47 + }
48 +
49 + /**
50 + * Returns value of LSP type.
51 + *
52 + * @return LSP type
53 + */
54 + public byte type() {
55 + return (byte) value;
56 + }
57 +}
1 +/*
2 + * Copyright 2016-present 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 + * Collection of keys for annotation for PCEP tunnels.
20 + */
21 +public final class PcepAnnotationKeys {
22 +
23 + /**
24 + * Prohibits instantiation.
25 + */
26 + private PcepAnnotationKeys() {
27 + }
28 +
29 + /**
30 + * Annotation key for bandwidth.
31 + * The value for this key is interpreted as Mbps.
32 + */
33 + public static final String BANDWIDTH = "bandwidth";
34 +
35 + /**
36 + * Annotation key for the LSP signaling type.
37 + */
38 + public static final String LSP_SIG_TYPE = "lspSigType";
39 +
40 + /**
41 + * Annotation key for the PCC tunnel id.
42 + */
43 + public static final String PCC_TUNNEL_ID = "PccTunnelId";
44 +
45 + /**
46 + * Annotation key for the LSP id assigned per tunnel per session.
47 + */
48 + public static final String PLSP_ID = "PLspId";
49 +
50 + /**
51 + * Annotation key for the LSP id assigned per tunnel.
52 + */
53 + public static final String LOCAL_LSP_ID = "localLspId";
54 +}
1 +/*
2 + * Copyright 2016-present 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 org.onosproject.incubator.net.tunnel.Tunnel.State;
19 +
20 +/**
21 + * Representation of the PCEP LSP state.
22 + */
23 +public enum PcepLspStatus {
24 +
25 + /**
26 + * Signifies that the LSP is not active.
27 + */
28 + DOWN,
29 +
30 + /**
31 + * Signifies that the LSP is signalled.
32 + */
33 + UP,
34 +
35 + /**
36 + * Signifies that the LSP is up and carrying traffic.
37 + */
38 + ACTIVE,
39 +
40 + /**
41 + * Signifies that the LSP is being torn down, resources are being released.
42 + */
43 + GOING_DOWN,
44 +
45 + /**
46 + * Signifies that the LSP is being signalled.
47 + */
48 + GOING_UP;
49 +
50 + /**
51 + * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state.
52 + *
53 + * @param tunnelState ONOS tunnel state
54 + */
55 + public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) {
56 +
57 + switch (tunnelState) {
58 +
59 + case INIT:
60 + return PcepLspStatus.DOWN;
61 +
62 + case ESTABLISHED:
63 + return PcepLspStatus.GOING_UP;
64 +
65 + case ACTIVE:
66 + return PcepLspStatus.UP;
67 +
68 + case FAILED: // fall through
69 + case INACTIVE: // LSP is administratively down.
70 + default:
71 + return PcepLspStatus.DOWN;
72 + }
73 + }
74 +
75 + /**
76 + * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status.
77 + *
78 + * @param lspState PCEP LSP status
79 + */
80 + public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) {
81 +
82 + switch (lspState) {
83 +
84 + case DOWN:
85 + return State.FAILED;
86 +
87 + case UP: // fall through
88 + case ACTIVE:
89 + return State.ACTIVE;
90 +
91 + case GOING_DOWN:
92 + return State.FAILED;
93 +
94 + case GOING_UP:
95 + return State.ESTABLISHED;
96 +
97 + default:
98 + return State.FAILED;
99 + }
100 + }
101 +}
...@@ -20,7 +20,7 @@ import java.util.Objects; ...@@ -20,7 +20,7 @@ import java.util.Objects;
20 import org.onosproject.incubator.net.tunnel.Tunnel; 20 import org.onosproject.incubator.net.tunnel.Tunnel;
21 import org.onosproject.net.ElementId; 21 import org.onosproject.net.ElementId;
22 import org.onosproject.net.Path; 22 import org.onosproject.net.Path;
23 -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; 23 +import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
24 24
25 import com.google.common.base.MoreObjects; 25 import com.google.common.base.MoreObjects;
26 26
...@@ -43,7 +43,7 @@ public class PcepTunnelData { ...@@ -43,7 +43,7 @@ public class PcepTunnelData {
43 private short tunnelId; 43 private short tunnelId;
44 private int extTunnelId; 44 private int extTunnelId;
45 private short lspId; 45 private short lspId;
46 - private StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv; 46 + private StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv;
47 47
48 /** 48 /**
49 * Default constructor. 49 * Default constructor.
...@@ -203,7 +203,7 @@ public class PcepTunnelData { ...@@ -203,7 +203,7 @@ public class PcepTunnelData {
203 * Sets statefulIpv4Identifiers tlv. 203 * Sets statefulIpv4Identifiers tlv.
204 * @param value statefulIpv4Identifiers tlv 204 * @param value statefulIpv4Identifiers tlv
205 */ 205 */
206 - public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentidiersTlv value) { 206 + public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentifiersTlv value) {
207 this.statefulIpv4IndentifierTlv = value; 207 this.statefulIpv4IndentifierTlv = value;
208 } 208 }
209 209
...@@ -329,7 +329,7 @@ public class PcepTunnelData { ...@@ -329,7 +329,7 @@ public class PcepTunnelData {
329 * 329 *
330 * @return statefulIpv4Indentifier tlv 330 * @return statefulIpv4Indentifier tlv
331 */ 331 */
332 - public StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv() { 332 + public StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv() {
333 return this.statefulIpv4IndentifierTlv; 333 return this.statefulIpv4IndentifierTlv;
334 } 334 }
335 335
......
...@@ -42,6 +42,7 @@ public class PcepClientAdapter implements PcepClient { ...@@ -42,6 +42,7 @@ public class PcepClientAdapter implements PcepClient {
42 private ClientCapability capability; 42 private ClientCapability capability;
43 43
44 private PcepVersion pcepVersion; 44 private PcepVersion pcepVersion;
45 + private boolean syncCompleted;
45 46
46 /** 47 /**
47 * Initialize instance with specified parameters. 48 * Initialize instance with specified parameters.
...@@ -109,11 +110,12 @@ public class PcepClientAdapter implements PcepClient { ...@@ -109,11 +110,12 @@ public class PcepClientAdapter implements PcepClient {
109 110
110 @Override 111 @Override
111 public final boolean isSyncComplete() { 112 public final boolean isSyncComplete() {
112 - return false; 113 + return syncCompleted;
113 } 114 }
114 115
115 @Override 116 @Override
116 public final void setIsSyncComplete(boolean value) { 117 public final void setIsSyncComplete(boolean value) {
118 + syncCompleted = value;
117 } 119 }
118 120
119 @Override 121 @Override
......
...@@ -73,6 +73,9 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -73,6 +73,9 @@ public class PcepClientControllerAdapter implements PcepClientController {
73 73
74 @Override 74 @Override
75 public PcepClient getClient(PccId pccId) { 75 public PcepClient getClient(PccId pccId) {
76 + if (null != connectedClients.get(pccId)) {
77 + return connectedClients.get(pccId);
78 + }
76 PcepClientAdapter pc = new PcepClientAdapter(); 79 PcepClientAdapter pc = new PcepClientAdapter();
77 if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103)) 80 if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103))
78 || pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) { 81 || pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) {
...@@ -81,6 +84,7 @@ public class PcepClientControllerAdapter implements PcepClientController { ...@@ -81,6 +84,7 @@ public class PcepClientControllerAdapter implements PcepClientController {
81 pc.setCapability(new ClientCapability(true, true, true)); 84 pc.setCapability(new ClientCapability(true, true, true));
82 } 85 }
83 pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1); 86 pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1);
87 + connectedClients.put(pccId, pc);
84 return pc; 88 return pc;
85 } 89 }
86 90
......
...@@ -20,6 +20,10 @@ import static org.hamcrest.Matchers.nullValue; ...@@ -20,6 +20,10 @@ import static org.hamcrest.Matchers.nullValue;
20 import static org.hamcrest.core.Is.is; 20 import static org.hamcrest.core.Is.is;
21 import static org.hamcrest.core.IsNot.not; 21 import static org.hamcrest.core.IsNot.not;
22 import static org.onosproject.net.DefaultAnnotations.EMPTY; 22 import static org.onosproject.net.DefaultAnnotations.EMPTY;
23 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
24 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
25 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
26 +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
23 27
24 import java.io.IOException; 28 import java.io.IOException;
25 import java.util.ArrayList; 29 import java.util.ArrayList;
...@@ -36,7 +40,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; ...@@ -36,7 +40,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
36 import org.onosproject.incubator.net.tunnel.Tunnel; 40 import org.onosproject.incubator.net.tunnel.Tunnel;
37 import org.onosproject.incubator.net.tunnel.TunnelId; 41 import org.onosproject.incubator.net.tunnel.TunnelId;
38 import org.onosproject.incubator.net.tunnel.TunnelName; 42 import org.onosproject.incubator.net.tunnel.TunnelName;
43 +import org.onosproject.net.Annotations;
39 import org.onosproject.net.ConnectPoint; 44 import org.onosproject.net.ConnectPoint;
45 +import org.onosproject.net.DefaultAnnotations;
40 import org.onosproject.net.DefaultLink; 46 import org.onosproject.net.DefaultLink;
41 import org.onosproject.net.DefaultPath; 47 import org.onosproject.net.DefaultPath;
42 import org.onosproject.net.IpElementId; 48 import org.onosproject.net.IpElementId;
...@@ -44,7 +50,7 @@ import org.onosproject.net.Link; ...@@ -44,7 +50,7 @@ import org.onosproject.net.Link;
44 import org.onosproject.net.Path; 50 import org.onosproject.net.Path;
45 import org.onosproject.net.PortNumber; 51 import org.onosproject.net.PortNumber;
46 import org.onosproject.net.provider.ProviderId; 52 import org.onosproject.net.provider.ProviderId;
47 -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; 53 +import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
48 54
49 /** 55 /**
50 * Test for PCEP release tunnel. 56 * Test for PCEP release tunnel.
...@@ -77,7 +83,7 @@ public class PcepReleaseTunnelProviderTest { ...@@ -77,7 +83,7 @@ public class PcepReleaseTunnelProviderTest {
77 public void testCasePcepReleaseTunnel() { 83 public void testCasePcepReleaseTunnel() {
78 Tunnel tunnel; 84 Tunnel tunnel;
79 Path path; 85 Path path;
80 - List<Link> links = new ArrayList<Link>(); 86 + List<Link> links = new ArrayList<>();
81 87
82 ProviderId pid = new ProviderId("pcep", PROVIDER_ID); 88 ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
83 89
...@@ -103,14 +109,18 @@ public class PcepReleaseTunnelProviderTest { ...@@ -103,14 +109,18 @@ public class PcepReleaseTunnelProviderTest {
103 109
104 path = new DefaultPath(pid, links, 20, EMPTY); 110 path = new DefaultPath(pid, links, 20, EMPTY);
105 111
112 + Annotations annotations = DefaultAnnotations.builder()
113 + .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
114 + .build();
115 +
106 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, 116 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
107 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), 117 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
108 - path, EMPTY); 118 + path, annotations);
109 119
110 // for releasing tunnel tunnel should exist in db 120 // for releasing tunnel tunnel should exist in db
111 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); 121 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
112 pcepTunnelData.setPlspId(1); 122 pcepTunnelData.setPlspId(1);
113 - StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); 123 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
114 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); 124 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
115 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); 125 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
116 126
...@@ -127,7 +137,7 @@ public class PcepReleaseTunnelProviderTest { ...@@ -127,7 +137,7 @@ public class PcepReleaseTunnelProviderTest {
127 public void testCasePcepReleaseTunnel2() { 137 public void testCasePcepReleaseTunnel2() {
128 Tunnel tunnel; 138 Tunnel tunnel;
129 Path path; 139 Path path;
130 - List<Link> links = new ArrayList<Link>(); 140 + List<Link> links = new ArrayList<>();
131 141
132 ProviderId pid = new ProviderId("pcep", PROVIDER_ID); 142 ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
133 143
...@@ -153,14 +163,18 @@ public class PcepReleaseTunnelProviderTest { ...@@ -153,14 +163,18 @@ public class PcepReleaseTunnelProviderTest {
153 163
154 path = new DefaultPath(pid, links, 20, EMPTY); 164 path = new DefaultPath(pid, links, 20, EMPTY);
155 165
166 + Annotations annotations = DefaultAnnotations.builder()
167 + .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
168 + .build();
169 +
156 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, 170 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
157 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), 171 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
158 - path, EMPTY); 172 + path, annotations);
159 173
160 // for releasing tunnel tunnel should exist in db 174 // for releasing tunnel tunnel should exist in db
161 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); 175 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
162 pcepTunnelData.setPlspId(1); 176 pcepTunnelData.setPlspId(1);
163 - StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); 177 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
164 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); 178 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
165 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); 179 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
166 180
...@@ -170,6 +184,114 @@ public class PcepReleaseTunnelProviderTest { ...@@ -170,6 +184,114 @@ public class PcepReleaseTunnelProviderTest {
170 assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); 184 assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
171 } 185 }
172 186
187 + /**
188 + * Tests releasing SR based tunnel.
189 + */
190 + @Test
191 + public void testCasePcepReleaseSrTunnel() {
192 + Tunnel tunnel;
193 + Path path;
194 + List<Link> links = new ArrayList<>();
195 +
196 + ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
197 +
198 + IpAddress srcIp = IpAddress.valueOf(0xB6024E20);
199 + IpElementId srcElementId = IpElementId.ipElement(srcIp);
200 +
201 + IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
202 + IpElementId dstElementId = IpElementId.ipElement(dstIp);
203 +
204 + IpTunnelEndPoint ipTunnelEndPointSrc;
205 + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
206 +
207 + IpTunnelEndPoint ipTunnelEndPointDst;
208 + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
209 +
210 + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
211 +
212 + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
213 +
214 + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
215 + .type(Link.Type.DIRECT).build();
216 + links.add(link);
217 +
218 + path = new DefaultPath(pid, links, 20, EMPTY);
219 +
220 + Annotations annotations = DefaultAnnotations.builder()
221 + .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
222 + .build();
223 +
224 + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
225 + new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
226 + path, annotations);
227 +
228 + // for releasing tunnel tunnel should exist in db
229 + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
230 + pcepTunnelData.setPlspId(1);
231 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
232 + pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
233 + tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
234 +
235 + tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
236 +
237 + tunnelProvider.releaseTunnel(tunnel);
238 + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
239 + }
240 +
241 + /**
242 + * Tests releasing tunnel without SR and without signalling.
243 + */
244 + @Test
245 + public void testCasePcepReleaseTunnelWithoutSigSr() {
246 + Tunnel tunnel;
247 + Path path;
248 + List<Link> links = new ArrayList<>();
249 +
250 + ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
251 +
252 + IpAddress srcIp = IpAddress.valueOf(0xB6024E20);
253 + IpElementId srcElementId = IpElementId.ipElement(srcIp);
254 +
255 + IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
256 + IpElementId dstElementId = IpElementId.ipElement(dstIp);
257 +
258 + IpTunnelEndPoint ipTunnelEndPointSrc;
259 + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
260 +
261 + IpTunnelEndPoint ipTunnelEndPointDst;
262 + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
263 +
264 + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
265 +
266 + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
267 +
268 + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
269 + .type(Link.Type.DIRECT).build();
270 + links.add(link);
271 +
272 + path = new DefaultPath(pid, links, 20, EMPTY);
273 +
274 + Annotations annotations = DefaultAnnotations.builder()
275 + .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
276 + .build();
277 +
278 + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
279 + new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
280 + path, annotations);
281 +
282 + // for releasing tunnel tunnel should exist in db
283 + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
284 + pcepTunnelData.setPlspId(1);
285 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
286 + pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
287 + tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
288 +
289 + tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
290 +
291 + tunnelProvider.releaseTunnel(tunnel);
292 + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
293 + }
294 +
173 @After 295 @After
174 public void tearDown() throws IOException { 296 public void tearDown() throws IOException {
175 tunnelProvider.deactivate(); 297 tunnelProvider.deactivate();
......
...@@ -20,6 +20,10 @@ import static org.hamcrest.MatcherAssert.assertThat; ...@@ -20,6 +20,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
20 import static org.hamcrest.core.Is.is; 20 import static org.hamcrest.core.Is.is;
21 import static org.hamcrest.core.IsNot.not; 21 import static org.hamcrest.core.IsNot.not;
22 import static org.hamcrest.Matchers.nullValue; 22 import static org.hamcrest.Matchers.nullValue;
23 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
24 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
25 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
26 +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
23 27
24 import java.io.IOException; 28 import java.io.IOException;
25 import java.util.ArrayList; 29 import java.util.ArrayList;
...@@ -36,7 +40,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; ...@@ -36,7 +40,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
36 import org.onosproject.incubator.net.tunnel.Tunnel; 40 import org.onosproject.incubator.net.tunnel.Tunnel;
37 import org.onosproject.incubator.net.tunnel.TunnelId; 41 import org.onosproject.incubator.net.tunnel.TunnelId;
38 import org.onosproject.incubator.net.tunnel.TunnelName; 42 import org.onosproject.incubator.net.tunnel.TunnelName;
43 +import org.onosproject.net.Annotations;
39 import org.onosproject.net.ConnectPoint; 44 import org.onosproject.net.ConnectPoint;
45 +import org.onosproject.net.DefaultAnnotations;
40 import org.onosproject.net.DefaultLink; 46 import org.onosproject.net.DefaultLink;
41 import org.onosproject.net.DefaultPath; 47 import org.onosproject.net.DefaultPath;
42 import org.onosproject.net.IpElementId; 48 import org.onosproject.net.IpElementId;
...@@ -75,7 +81,7 @@ public class PcepSetupTunnelProviderTest { ...@@ -75,7 +81,7 @@ public class PcepSetupTunnelProviderTest {
75 Tunnel tunnel; 81 Tunnel tunnel;
76 Path path; 82 Path path;
77 ProviderId pid = new ProviderId("pcep", PROVIDER_ID); 83 ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
78 - List<Link> links = new ArrayList<Link>(); 84 + List<Link> links = new ArrayList<>();
79 IpAddress srcIp = IpAddress.valueOf(0xC010101); 85 IpAddress srcIp = IpAddress.valueOf(0xC010101);
80 IpElementId srcElementId = IpElementId.ipElement(srcIp); 86 IpElementId srcElementId = IpElementId.ipElement(srcIp);
81 87
...@@ -98,9 +104,13 @@ public class PcepSetupTunnelProviderTest { ...@@ -98,9 +104,13 @@ public class PcepSetupTunnelProviderTest {
98 104
99 path = new DefaultPath(pid, links, 10, EMPTY); 105 path = new DefaultPath(pid, links, 10, EMPTY);
100 106
107 + Annotations annotations = DefaultAnnotations.builder()
108 + .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
109 + .build();
110 +
101 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, 111 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
102 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), 112 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
103 - path, EMPTY); 113 + path, annotations);
104 114
105 tunnelProvider.setupTunnel(tunnel, path); 115 tunnelProvider.setupTunnel(tunnel, path);
106 assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); 116 assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
...@@ -114,7 +124,7 @@ public class PcepSetupTunnelProviderTest { ...@@ -114,7 +124,7 @@ public class PcepSetupTunnelProviderTest {
114 Tunnel tunnel; 124 Tunnel tunnel;
115 Path path; 125 Path path;
116 ProviderId pid = new ProviderId("pcep", PROVIDER_ID); 126 ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
117 - List<Link> links = new ArrayList<Link>(); 127 + List<Link> links = new ArrayList<>();
118 IpAddress srcIp = IpAddress.valueOf(0xC010103); 128 IpAddress srcIp = IpAddress.valueOf(0xC010103);
119 IpElementId srcElementId = IpElementId.ipElement(srcIp); 129 IpElementId srcElementId = IpElementId.ipElement(srcIp);
120 130
...@@ -137,14 +147,104 @@ public class PcepSetupTunnelProviderTest { ...@@ -137,14 +147,104 @@ public class PcepSetupTunnelProviderTest {
137 147
138 path = new DefaultPath(pid, links, 10, EMPTY); 148 path = new DefaultPath(pid, links, 10, EMPTY);
139 149
150 + Annotations annotations = DefaultAnnotations.builder()
151 + .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
152 + .build();
153 +
140 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, 154 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
141 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), 155 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
142 - path, EMPTY); 156 + path, annotations);
143 157
144 tunnelProvider.setupTunnel(tunnel, path); 158 tunnelProvider.setupTunnel(tunnel, path);
145 assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); 159 assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
146 } 160 }
147 161
162 + /**
163 + * Sends PCInitiate msg to setup a SR based tunnel.
164 + */
165 + @Test
166 + public void testCasePcepSetupSrTunnel() {
167 + Tunnel tunnel;
168 + Path path;
169 + ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
170 + List<Link> links = new ArrayList<>();
171 + IpAddress srcIp = IpAddress.valueOf(0xC010101);
172 + IpElementId srcElementId = IpElementId.ipElement(srcIp);
173 +
174 + IpAddress dstIp = IpAddress.valueOf(0xC010102);
175 + IpElementId dstElementId = IpElementId.ipElement(dstIp);
176 +
177 + IpTunnelEndPoint ipTunnelEndPointSrc;
178 + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
179 +
180 + IpTunnelEndPoint ipTunnelEndPointDst;
181 + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
182 +
183 + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
184 +
185 + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
186 +
187 + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
188 + .type(Link.Type.DIRECT).build();
189 + links.add(link);
190 +
191 + path = new DefaultPath(pid, links, 10, EMPTY);
192 +
193 + Annotations annotations = DefaultAnnotations.builder()
194 + .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
195 + .build();
196 +
197 + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
198 + new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
199 + path, annotations);
200 +
201 + tunnelProvider.setupTunnel(tunnel, path);
202 + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
203 + }
204 +
205 + /**
206 + * Sends PCInitiate msg to setup a tunnel without signalling and without SR.
207 + */
208 + @Test
209 + public void testCasePcepSetupTunnelWithoutSigSr() {
210 + Tunnel tunnel;
211 + Path path;
212 + ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
213 + List<Link> links = new ArrayList<>();
214 + IpAddress srcIp = IpAddress.valueOf(0xC010101);
215 + IpElementId srcElementId = IpElementId.ipElement(srcIp);
216 +
217 + IpAddress dstIp = IpAddress.valueOf(0xC010102);
218 + IpElementId dstElementId = IpElementId.ipElement(dstIp);
219 +
220 + IpTunnelEndPoint ipTunnelEndPointSrc;
221 + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
222 +
223 + IpTunnelEndPoint ipTunnelEndPointDst;
224 + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
225 +
226 + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
227 +
228 + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
229 +
230 + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
231 + .type(Link.Type.DIRECT).build();
232 + links.add(link);
233 +
234 + path = new DefaultPath(pid, links, 10, EMPTY);
235 +
236 + Annotations annotations = DefaultAnnotations.builder()
237 + .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
238 + .build();
239 +
240 + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
241 + new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
242 + path, annotations);
243 +
244 + tunnelProvider.setupTunnel(tunnel, path);
245 + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
246 + }
247 +
148 @After 248 @After
149 public void tearDown() throws IOException { 249 public void tearDown() throws IOException {
150 tunnelProvider.deactivate(); 250 tunnelProvider.deactivate();
......
...@@ -15,7 +15,12 @@ ...@@ -15,7 +15,12 @@
15 */ 15 */
16 package org.onosproject.provider.pcep.tunnel.impl; 16 package org.onosproject.provider.pcep.tunnel.impl;
17 17
18 +import static org.hamcrest.MatcherAssert.assertThat;
19 +import static org.hamcrest.Matchers.nullValue;
20 +import static org.hamcrest.core.IsNot.not;
18 import static org.onosproject.net.DefaultAnnotations.EMPTY; 21 import static org.onosproject.net.DefaultAnnotations.EMPTY;
22 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
23 +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
19 24
20 import java.io.IOException; 25 import java.io.IOException;
21 import java.util.ArrayList; 26 import java.util.ArrayList;
...@@ -30,7 +35,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; ...@@ -30,7 +35,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
30 import org.onosproject.incubator.net.tunnel.Tunnel; 35 import org.onosproject.incubator.net.tunnel.Tunnel;
31 import org.onosproject.incubator.net.tunnel.TunnelId; 36 import org.onosproject.incubator.net.tunnel.TunnelId;
32 import org.onosproject.incubator.net.tunnel.TunnelName; 37 import org.onosproject.incubator.net.tunnel.TunnelName;
38 +import org.onosproject.net.Annotations;
33 import org.onosproject.net.ConnectPoint; 39 import org.onosproject.net.ConnectPoint;
40 +import org.onosproject.net.DefaultAnnotations;
34 import org.onosproject.net.DefaultLink; 41 import org.onosproject.net.DefaultLink;
35 import org.onosproject.net.DefaultPath; 42 import org.onosproject.net.DefaultPath;
36 import org.onosproject.net.IpElementId; 43 import org.onosproject.net.IpElementId;
...@@ -62,7 +69,7 @@ public class PcepTunnelProviderTest { ...@@ -62,7 +69,7 @@ public class PcepTunnelProviderTest {
62 Tunnel tunnel; 69 Tunnel tunnel;
63 Path path; 70 Path path;
64 ProviderId pid = new ProviderId("pcep", PROVIDER_ID); 71 ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
65 - List<Link> links = new ArrayList<Link>(); 72 + List<Link> links = new ArrayList<>();
66 IpAddress srcIp = IpAddress.valueOf(0xC010101); 73 IpAddress srcIp = IpAddress.valueOf(0xC010101);
67 IpElementId srcElementId = IpElementId.ipElement(srcIp); 74 IpElementId srcElementId = IpElementId.ipElement(srcIp);
68 75
...@@ -85,11 +92,17 @@ public class PcepTunnelProviderTest { ...@@ -85,11 +92,17 @@ public class PcepTunnelProviderTest {
85 92
86 path = new DefaultPath(pid, links, 10, EMPTY); 93 path = new DefaultPath(pid, links, 10, EMPTY);
87 94
95 + Annotations annotations = DefaultAnnotations.builder()
96 + .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
97 + .build();
98 +
88 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, 99 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
89 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), 100 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
90 - path, EMPTY); 101 + path, annotations);
91 102
92 tunnelProvider.setupTunnel(tunnel, path); 103 tunnelProvider.setupTunnel(tunnel, path);
104 +
105 + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
93 } 106 }
94 107
95 @After 108 @After
...@@ -99,4 +112,4 @@ public class PcepTunnelProviderTest { ...@@ -99,4 +112,4 @@ public class PcepTunnelProviderTest {
99 tunnelProvider.pcepClientController = null; 112 tunnelProvider.pcepClientController = null;
100 tunnelProvider.tunnelProviderRegistry = null; 113 tunnelProvider.tunnelProviderRegistry = null;
101 } 114 }
102 -} 115 +}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.nullValue; ...@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.nullValue;
20 import static org.hamcrest.core.Is.is; 20 import static org.hamcrest.core.Is.is;
21 import static org.hamcrest.core.IsNot.not; 21 import static org.hamcrest.core.IsNot.not;
22 import static org.onosproject.net.DefaultAnnotations.EMPTY; 22 import static org.onosproject.net.DefaultAnnotations.EMPTY;
23 +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
23 24
24 import java.io.IOException; 25 import java.io.IOException;
25 import java.util.ArrayList; 26 import java.util.ArrayList;
...@@ -36,7 +37,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; ...@@ -36,7 +37,9 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
36 import org.onosproject.incubator.net.tunnel.Tunnel; 37 import org.onosproject.incubator.net.tunnel.Tunnel;
37 import org.onosproject.incubator.net.tunnel.TunnelId; 38 import org.onosproject.incubator.net.tunnel.TunnelId;
38 import org.onosproject.incubator.net.tunnel.TunnelName; 39 import org.onosproject.incubator.net.tunnel.TunnelName;
40 +import org.onosproject.net.Annotations;
39 import org.onosproject.net.ConnectPoint; 41 import org.onosproject.net.ConnectPoint;
42 +import org.onosproject.net.DefaultAnnotations;
40 import org.onosproject.net.DefaultLink; 43 import org.onosproject.net.DefaultLink;
41 import org.onosproject.net.DefaultPath; 44 import org.onosproject.net.DefaultPath;
42 import org.onosproject.net.IpElementId; 45 import org.onosproject.net.IpElementId;
...@@ -44,8 +47,11 @@ import org.onosproject.net.Link; ...@@ -44,8 +47,11 @@ import org.onosproject.net.Link;
44 import org.onosproject.net.Path; 47 import org.onosproject.net.Path;
45 import org.onosproject.net.PortNumber; 48 import org.onosproject.net.PortNumber;
46 import org.onosproject.net.provider.ProviderId; 49 import org.onosproject.net.provider.ProviderId;
47 -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; 50 +import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
48 51
52 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
53 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
54 +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
49 /** 55 /**
50 * Test for PCEP update tunnel. 56 * Test for PCEP update tunnel.
51 */ 57 */
...@@ -78,7 +84,7 @@ public class PcepUpdateTunnelProviderTest { ...@@ -78,7 +84,7 @@ public class PcepUpdateTunnelProviderTest {
78 Tunnel tunnel; 84 Tunnel tunnel;
79 Path path; 85 Path path;
80 ProviderId pid = new ProviderId("pcep", PROVIDER_ID); 86 ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
81 - List<Link> links = new ArrayList<Link>(); 87 + List<Link> links = new ArrayList<>();
82 IpAddress srcIp = IpAddress.valueOf(0xD010101); 88 IpAddress srcIp = IpAddress.valueOf(0xD010101);
83 IpElementId srcElementId = IpElementId.ipElement(srcIp); 89 IpElementId srcElementId = IpElementId.ipElement(srcIp);
84 90
...@@ -101,14 +107,18 @@ public class PcepUpdateTunnelProviderTest { ...@@ -101,14 +107,18 @@ public class PcepUpdateTunnelProviderTest {
101 107
102 path = new DefaultPath(pid, links, 20, EMPTY); 108 path = new DefaultPath(pid, links, 20, EMPTY);
103 109
110 + Annotations annotations = DefaultAnnotations.builder()
111 + .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
112 + .build();
113 +
104 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, 114 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
105 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), 115 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
106 - path, EMPTY); 116 + path, annotations);
107 117
108 // for updating tunnel tunnel should exist in db 118 // for updating tunnel tunnel should exist in db
109 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE); 119 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
110 pcepTunnelData.setPlspId(1); 120 pcepTunnelData.setPlspId(1);
111 - StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); 121 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
112 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); 122 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
113 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); 123 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
114 124
...@@ -126,7 +136,7 @@ public class PcepUpdateTunnelProviderTest { ...@@ -126,7 +136,7 @@ public class PcepUpdateTunnelProviderTest {
126 Tunnel tunnel; 136 Tunnel tunnel;
127 Path path; 137 Path path;
128 ProviderId pid = new ProviderId("pcep", PROVIDER_ID); 138 ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
129 - List<Link> links = new ArrayList<Link>(); 139 + List<Link> links = new ArrayList<>();
130 IpAddress srcIp = IpAddress.valueOf(0xC010103); 140 IpAddress srcIp = IpAddress.valueOf(0xC010103);
131 IpElementId srcElementId = IpElementId.ipElement(srcIp); 141 IpElementId srcElementId = IpElementId.ipElement(srcIp);
132 142
...@@ -149,14 +159,18 @@ public class PcepUpdateTunnelProviderTest { ...@@ -149,14 +159,18 @@ public class PcepUpdateTunnelProviderTest {
149 159
150 path = new DefaultPath(pid, links, 20, EMPTY); 160 path = new DefaultPath(pid, links, 20, EMPTY);
151 161
162 + Annotations annotations = DefaultAnnotations.builder()
163 + .set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
164 + .build();
165 +
152 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, 166 tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
153 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), 167 new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
154 - path, EMPTY); 168 + path, annotations);
155 169
156 // for updating tunnel tunnel should exist in db 170 // for updating tunnel tunnel should exist in db
157 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE); 171 PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
158 pcepTunnelData.setPlspId(1); 172 pcepTunnelData.setPlspId(1);
159 - StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); 173 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
160 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); 174 pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
161 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); 175 tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
162 176
...@@ -166,6 +180,110 @@ public class PcepUpdateTunnelProviderTest { ...@@ -166,6 +180,110 @@ public class PcepUpdateTunnelProviderTest {
166 assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); 180 assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
167 } 181 }
168 182
183 + /**
184 + * Sends update message to PCC for SR based tunnel.
185 + */
186 + @Test
187 + public void testCasePcepUpdateSrTunnel() {
188 + Tunnel tunnel;
189 + Path path;
190 + ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
191 + List<Link> links = new ArrayList<>();
192 + IpAddress srcIp = IpAddress.valueOf(0xD010101);
193 + IpElementId srcElementId = IpElementId.ipElement(srcIp);
194 +
195 + IpAddress dstIp = IpAddress.valueOf(0xD010102);
196 + IpElementId dstElementId = IpElementId.ipElement(dstIp);
197 +
198 + IpTunnelEndPoint ipTunnelEndPointSrc;
199 + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
200 +
201 + IpTunnelEndPoint ipTunnelEndPointDst;
202 + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
203 +
204 + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
205 +
206 + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
207 +
208 + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
209 + .type(Link.Type.DIRECT).build();
210 + links.add(link);
211 +
212 + path = new DefaultPath(pid, links, 20, EMPTY);
213 +
214 + Annotations annotations = DefaultAnnotations.builder()
215 + .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
216 + .build();
217 +
218 + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
219 + new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
220 + path, annotations);
221 +
222 + // for updating tunnel tunnel should exist in db
223 + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
224 + pcepTunnelData.setPlspId(1);
225 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
226 + pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
227 + tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
228 +
229 + tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
230 +
231 + tunnelProvider.updateTunnel(tunnel, path);
232 + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
233 + }
234 +
235 + /**
236 + * Sends update message to PCC for tunnel without signalling and without SR.
237 + */
238 + @Test
239 + public void testCasePcepUpdateTunnelWithoutSigSr() {
240 + Tunnel tunnel;
241 + Path path;
242 + ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
243 + List<Link> links = new ArrayList<>();
244 + IpAddress srcIp = IpAddress.valueOf(0xD010101);
245 + IpElementId srcElementId = IpElementId.ipElement(srcIp);
246 +
247 + IpAddress dstIp = IpAddress.valueOf(0xD010102);
248 + IpElementId dstElementId = IpElementId.ipElement(dstIp);
249 +
250 + IpTunnelEndPoint ipTunnelEndPointSrc;
251 + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
252 +
253 + IpTunnelEndPoint ipTunnelEndPointDst;
254 + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
255 +
256 + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
257 +
258 + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
259 +
260 + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
261 + .type(Link.Type.DIRECT).build();
262 + links.add(link);
263 +
264 + path = new DefaultPath(pid, links, 20, EMPTY);
265 +
266 + Annotations annotations = DefaultAnnotations.builder()
267 + .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
268 + .build();
269 +
270 + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
271 + new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
272 + path, annotations);
273 +
274 + // for updating tunnel tunnel should exist in db
275 + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
276 + pcepTunnelData.setPlspId(1);
277 + StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
278 + pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
279 + tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
280 +
281 + tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
282 +
283 + tunnelProvider.updateTunnel(tunnel, path);
284 + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
285 + }
286 +
169 @After 287 @After
170 public void tearDown() throws IOException { 288 public void tearDown() throws IOException {
171 tunnelProvider.deactivate(); 289 tunnelProvider.deactivate();
......
...@@ -94,17 +94,17 @@ public class TunnelServiceAdapter implements TunnelService { ...@@ -94,17 +94,17 @@ public class TunnelServiceAdapter implements TunnelService {
94 94
95 @Override 95 @Override
96 public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) { 96 public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) {
97 - return null; 97 + return Collections.emptySet();
98 } 98 }
99 99
100 @Override 100 @Override
101 public Collection<Tunnel> queryTunnel(Tunnel.Type type) { 101 public Collection<Tunnel> queryTunnel(Tunnel.Type type) {
102 - return null; 102 + return Collections.emptySet();
103 } 103 }
104 104
105 @Override 105 @Override
106 public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { 106 public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
107 - return null; 107 + return Collections.emptySet();
108 } 108 }
109 109
110 @Override 110 @Override
......