Committed by
Gerrit Code Review
[ONOS-4163] Provider side changes to support stateful PCE and PCECC
Change-Id: I0a57ed1d1e505a2e94921fd5f5d92426a105ad12
Showing
20 changed files
with
1404 additions
and
158 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(); | ... | ... |
providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/LspType.java
0 → 100644
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 | +} |
providers/pcep/tunnel/src/main/java/org/onosproject/provider/pcep/tunnel/impl/PcepLspStatus.java
0 → 100644
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 | ... | ... |
... | @@ -16,6 +16,7 @@ | ... | @@ -16,6 +16,7 @@ |
16 | package org.onosproject.provider.pcep.tunnel.impl; | 16 | package org.onosproject.provider.pcep.tunnel.impl; |
17 | 17 | ||
18 | import com.google.common.collect.Maps; | 18 | import com.google.common.collect.Maps; |
19 | + | ||
19 | import org.apache.felix.scr.annotations.Activate; | 20 | import org.apache.felix.scr.annotations.Activate; |
20 | import org.apache.felix.scr.annotations.Component; | 21 | import org.apache.felix.scr.annotations.Component; |
21 | import org.apache.felix.scr.annotations.Deactivate; | 22 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -34,6 +35,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | ... | @@ -34,6 +35,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
34 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; | 35 | import org.onosproject.incubator.net.tunnel.OpticalLogicId; |
35 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; | 36 | import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint; |
36 | import org.onosproject.incubator.net.tunnel.Tunnel; | 37 | import org.onosproject.incubator.net.tunnel.Tunnel; |
38 | +import org.onosproject.incubator.net.tunnel.Tunnel.State; | ||
37 | import org.onosproject.incubator.net.tunnel.TunnelDescription; | 39 | import org.onosproject.incubator.net.tunnel.TunnelDescription; |
38 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | 40 | import org.onosproject.incubator.net.tunnel.TunnelEndPoint; |
39 | import org.onosproject.incubator.net.tunnel.TunnelId; | 41 | import org.onosproject.incubator.net.tunnel.TunnelId; |
... | @@ -45,6 +47,7 @@ import org.onosproject.incubator.net.tunnel.TunnelService; | ... | @@ -45,6 +47,7 @@ import org.onosproject.incubator.net.tunnel.TunnelService; |
45 | import org.onosproject.incubator.net.tunnel.TunnelStatistics; | 47 | import org.onosproject.incubator.net.tunnel.TunnelStatistics; |
46 | import org.onosproject.net.ConnectPoint; | 48 | import org.onosproject.net.ConnectPoint; |
47 | import org.onosproject.net.DefaultAnnotations; | 49 | import org.onosproject.net.DefaultAnnotations; |
50 | +import org.onosproject.net.DefaultAnnotations.Builder; | ||
48 | import org.onosproject.net.DefaultLink; | 51 | import org.onosproject.net.DefaultLink; |
49 | import org.onosproject.net.DefaultPath; | 52 | import org.onosproject.net.DefaultPath; |
50 | import org.onosproject.net.DeviceId; | 53 | import org.onosproject.net.DeviceId; |
... | @@ -81,20 +84,21 @@ import org.onosproject.pcepio.protocol.PcepLspObject; | ... | @@ -81,20 +84,21 @@ import org.onosproject.pcepio.protocol.PcepLspObject; |
81 | import org.onosproject.pcepio.protocol.PcepMessage; | 84 | import org.onosproject.pcepio.protocol.PcepMessage; |
82 | import org.onosproject.pcepio.protocol.PcepMsgPath; | 85 | import org.onosproject.pcepio.protocol.PcepMsgPath; |
83 | import org.onosproject.pcepio.protocol.PcepReportMsg; | 86 | import org.onosproject.pcepio.protocol.PcepReportMsg; |
84 | -import org.onosproject.pcepio.protocol.PcepRroObject; | ||
85 | import org.onosproject.pcepio.protocol.PcepSrpObject; | 87 | import org.onosproject.pcepio.protocol.PcepSrpObject; |
86 | import org.onosproject.pcepio.protocol.PcepStateReport; | 88 | import org.onosproject.pcepio.protocol.PcepStateReport; |
87 | import org.onosproject.pcepio.protocol.PcepUpdateMsg; | 89 | import org.onosproject.pcepio.protocol.PcepUpdateMsg; |
88 | import org.onosproject.pcepio.protocol.PcepUpdateRequest; | 90 | import org.onosproject.pcepio.protocol.PcepUpdateRequest; |
89 | import org.onosproject.pcepio.types.IPv4SubObject; | 91 | import org.onosproject.pcepio.types.IPv4SubObject; |
92 | +import org.onosproject.pcepio.types.PathSetupTypeTlv; | ||
90 | import org.onosproject.pcepio.types.PcepValueType; | 93 | import org.onosproject.pcepio.types.PcepValueType; |
91 | -import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; | 94 | +import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
92 | import org.onosproject.pcepio.types.SymbolicPathNameTlv; | 95 | import org.onosproject.pcepio.types.SymbolicPathNameTlv; |
93 | import org.osgi.service.component.ComponentContext; | 96 | import org.osgi.service.component.ComponentContext; |
94 | import org.osgi.service.component.annotations.Modified; | 97 | import org.osgi.service.component.annotations.Modified; |
95 | import org.slf4j.Logger; | 98 | import org.slf4j.Logger; |
96 | 99 | ||
97 | import java.util.ArrayList; | 100 | import java.util.ArrayList; |
101 | +import java.util.Collection; | ||
98 | import java.util.Collections; | 102 | import java.util.Collections; |
99 | import java.util.Dictionary; | 103 | import java.util.Dictionary; |
100 | import java.util.HashMap; | 104 | import java.util.HashMap; |
... | @@ -106,10 +110,21 @@ import java.util.Optional; | ... | @@ -106,10 +110,21 @@ import java.util.Optional; |
106 | import static com.google.common.base.Preconditions.checkNotNull; | 110 | import static com.google.common.base.Preconditions.checkNotNull; |
107 | import static com.google.common.base.Strings.isNullOrEmpty; | 111 | import static com.google.common.base.Strings.isNullOrEmpty; |
108 | import static org.onlab.util.Tools.get; | 112 | import static org.onlab.util.Tools.get; |
113 | +import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | ||
109 | import static org.onosproject.net.DefaultAnnotations.EMPTY; | 114 | import static org.onosproject.net.DefaultAnnotations.EMPTY; |
110 | import static org.onosproject.net.DeviceId.deviceId; | 115 | import static org.onosproject.net.DeviceId.deviceId; |
111 | import static org.onosproject.net.PortNumber.portNumber; | 116 | import static org.onosproject.net.PortNumber.portNumber; |
112 | import static org.onosproject.pcep.api.PcepDpid.uri; | 117 | import static org.onosproject.pcep.api.PcepDpid.uri; |
118 | +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | ||
119 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH; | ||
120 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID; | ||
121 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE; | ||
122 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID; | ||
123 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID; | ||
124 | +import static org.onosproject.provider.pcep.tunnel.impl.RequestType.CREATE; | ||
125 | +import static org.onosproject.provider.pcep.tunnel.impl.RequestType.DELETE; | ||
126 | +import static org.onosproject.provider.pcep.tunnel.impl.RequestType.LSP_STATE_RPT; | ||
127 | +import static org.onosproject.provider.pcep.tunnel.impl.RequestType.UPDATE; | ||
113 | import static org.slf4j.LoggerFactory.getLogger; | 128 | import static org.slf4j.LoggerFactory.getLogger; |
114 | 129 | ||
115 | /** | 130 | /** |
... | @@ -215,7 +230,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -215,7 +230,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
215 | 230 | ||
216 | @Override | 231 | @Override |
217 | public void setupTunnel(Tunnel tunnel, Path path) { | 232 | public void setupTunnel(Tunnel tunnel, Path path) { |
218 | - if (tunnel.type() != Tunnel.Type.MPLS) { | 233 | + if (tunnel.type() != MPLS) { |
219 | log.error("Tunnel Type MPLS is only supported"); | 234 | log.error("Tunnel Type MPLS is only supported"); |
220 | return; | 235 | return; |
221 | } | 236 | } |
... | @@ -244,7 +259,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -244,7 +259,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
244 | @Override | 259 | @Override |
245 | public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) { | 260 | public void setupTunnel(ElementId srcElement, Tunnel tunnel, Path path) { |
246 | 261 | ||
247 | - if (tunnel.type() != Tunnel.Type.MPLS) { | 262 | + if (tunnel.annotations().value(PLSP_ID) != null) { |
263 | + updateTunnel(tunnel, path); | ||
264 | + return; | ||
265 | + } | ||
266 | + | ||
267 | + if (tunnel.type() != MPLS) { | ||
248 | log.error("Tunnel Type MPLS is only supported"); | 268 | log.error("Tunnel Type MPLS is only supported"); |
249 | return; | 269 | return; |
250 | } | 270 | } |
... | @@ -276,7 +296,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -276,7 +296,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
276 | @Override | 296 | @Override |
277 | public void releaseTunnel(Tunnel tunnel) { | 297 | public void releaseTunnel(Tunnel tunnel) { |
278 | 298 | ||
279 | - if (tunnel.type() != Tunnel.Type.MPLS) { | 299 | + if (tunnel.type() != MPLS) { |
280 | log.error("Tunnel Type MPLS is only supported"); | 300 | log.error("Tunnel Type MPLS is only supported"); |
281 | return; | 301 | return; |
282 | } | 302 | } |
... | @@ -302,7 +322,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -302,7 +322,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
302 | 322 | ||
303 | @Override | 323 | @Override |
304 | public void releaseTunnel(ElementId srcElement, Tunnel tunnel) { | 324 | public void releaseTunnel(ElementId srcElement, Tunnel tunnel) { |
305 | - if (tunnel.type() != Tunnel.Type.MPLS) { | 325 | + if (tunnel.type() != MPLS) { |
306 | log.error("Tunnel Type MPLS is only supported"); | 326 | log.error("Tunnel Type MPLS is only supported"); |
307 | return; | 327 | return; |
308 | } | 328 | } |
... | @@ -333,7 +353,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -333,7 +353,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
333 | 353 | ||
334 | @Override | 354 | @Override |
335 | public void updateTunnel(Tunnel tunnel, Path path) { | 355 | public void updateTunnel(Tunnel tunnel, Path path) { |
336 | - if (tunnel.type() != Tunnel.Type.MPLS) { | 356 | + if (tunnel.type() != MPLS) { |
337 | log.error("Tunnel Type MPLS is only supported"); | 357 | log.error("Tunnel Type MPLS is only supported"); |
338 | return; | 358 | return; |
339 | } | 359 | } |
... | @@ -360,7 +380,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -360,7 +380,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
360 | @Override | 380 | @Override |
361 | public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) { | 381 | public void updateTunnel(ElementId srcElement, Tunnel tunnel, Path path) { |
362 | 382 | ||
363 | - if (tunnel.type() != Tunnel.Type.MPLS) { | 383 | + if (tunnel.type() != MPLS) { |
364 | log.error("Tunnel Type MPLS is only supported"); | 384 | log.error("Tunnel Type MPLS is only supported"); |
365 | return; | 385 | return; |
366 | } | 386 | } |
... | @@ -391,13 +411,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -391,13 +411,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
391 | 411 | ||
392 | @Override | 412 | @Override |
393 | public TunnelId tunnelAdded(TunnelDescription tunnel) { | 413 | public TunnelId tunnelAdded(TunnelDescription tunnel) { |
394 | - if (tunnel.type() == Tunnel.Type.MPLS) { | 414 | + return handleTunnelAdded(tunnel, null); |
415 | + } | ||
416 | + | ||
417 | + public TunnelId tunnelAdded(TunnelDescription tunnel, State tunnelState) { | ||
418 | + return handleTunnelAdded(tunnel, tunnelState); | ||
419 | + } | ||
420 | + | ||
421 | + private TunnelId handleTunnelAdded(TunnelDescription tunnel, State tunnelState) { | ||
422 | + | ||
423 | + if (tunnel.type() == MPLS) { | ||
395 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); | 424 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); |
396 | - return service.tunnelAdded(tunnel); | 425 | + |
426 | + if (tunnelState == null) { | ||
427 | + return service.tunnelAdded(tunnel); | ||
428 | + } else { | ||
429 | + return service.tunnelAdded(tunnel, tunnelState); | ||
430 | + } | ||
397 | } | 431 | } |
398 | 432 | ||
399 | - long bandwidth = Long | 433 | + long bandwidth = Long.parseLong(tunnel.annotations().value(BANDWIDTH)); |
400 | - .parseLong(tunnel.annotations().value("bandwidth")); | ||
401 | 434 | ||
402 | if (bandwidth < MIN_BANDWIDTH || bandwidth > MAX_BANDWIDTH) { | 435 | if (bandwidth < MIN_BANDWIDTH || bandwidth > MAX_BANDWIDTH) { |
403 | error("Update failed, invalid bandwidth."); | 436 | error("Update failed, invalid bandwidth."); |
... | @@ -437,7 +470,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -437,7 +470,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
437 | 470 | ||
438 | @Override | 471 | @Override |
439 | public void tunnelRemoved(TunnelDescription tunnel) { | 472 | public void tunnelRemoved(TunnelDescription tunnel) { |
440 | - if (tunnel.type() == Tunnel.Type.MPLS) { | 473 | + if (tunnel.type() == MPLS) { |
441 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); | 474 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); |
442 | service.tunnelRemoved(tunnel); | 475 | service.tunnelRemoved(tunnel); |
443 | } | 476 | } |
... | @@ -460,9 +493,23 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -460,9 +493,23 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
460 | 493 | ||
461 | @Override | 494 | @Override |
462 | public void tunnelUpdated(TunnelDescription tunnel) { | 495 | public void tunnelUpdated(TunnelDescription tunnel) { |
463 | - if (tunnel.type() == Tunnel.Type.MPLS) { | 496 | + handleTunnelUpdate(tunnel, null); |
497 | + } | ||
498 | + | ||
499 | + public void tunnelUpdated(TunnelDescription tunnel, State tunnelState) { | ||
500 | + handleTunnelUpdate(tunnel, tunnelState); | ||
501 | + } | ||
502 | + | ||
503 | + private void handleTunnelUpdate(TunnelDescription tunnel, State tunnelState) { | ||
504 | + if (tunnel.type() == MPLS) { | ||
464 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); | 505 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); |
465 | - service.tunnelUpdated(tunnel); | 506 | + |
507 | + if (tunnelState == null) { | ||
508 | + service.tunnelUpdated(tunnel); | ||
509 | + } else { | ||
510 | + service.tunnelUpdated(tunnel, tunnelState); | ||
511 | + } | ||
512 | + return; | ||
466 | } | 513 | } |
467 | 514 | ||
468 | Tunnel tunnelOld = tunnelQueryById(tunnel.id()); | 515 | Tunnel tunnelOld = tunnelQueryById(tunnel.id()); |
... | @@ -724,15 +771,31 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -724,15 +771,31 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
724 | return null; | 771 | return null; |
725 | } | 772 | } |
726 | 773 | ||
727 | - //build SRP object | ||
728 | - PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false).build(); | ||
729 | - | ||
730 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); | 774 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); |
775 | + | ||
776 | + // set PathSetupTypeTlv of SRP object | ||
777 | + tlv = new PathSetupTypeTlv(LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)).type()); | ||
778 | + llOptionalTlv.add(tlv); | ||
779 | + | ||
780 | + // build SRP object | ||
781 | + PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false) | ||
782 | + .setOptionalTlv(llOptionalTlv).build(); | ||
783 | + | ||
784 | + llOptionalTlv = new LinkedList<PcepValueType>(); | ||
731 | LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>(); | 785 | LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>(); |
786 | + | ||
732 | // set LSP identifiers TLV | 787 | // set LSP identifiers TLV |
733 | - tlv = new StatefulIPv4LspIdentidiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), | 788 | + short localLspId = 0; |
734 | - (short) 0, (short) 0, 0, | 789 | + if (LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) != WITH_SIGNALLING) { |
735 | - (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())); | 790 | + String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID); |
791 | + if (localLspIdString != null) { | ||
792 | + localLspId = Short.valueOf(localLspIdString); | ||
793 | + } | ||
794 | + } | ||
795 | + | ||
796 | + tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), | ||
797 | + localLspId, (short) 0, 0, (((IpTunnelEndPoint) tunnel.dst()).ip() | ||
798 | + .getIp4Address().toInt())); | ||
736 | llOptionalTlv.add(tlv); | 799 | llOptionalTlv.add(tlv); |
737 | //set SymbolicPathNameTlv of LSP object | 800 | //set SymbolicPathNameTlv of LSP object |
738 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); | 801 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); |
... | @@ -752,8 +815,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -752,8 +815,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
752 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); | 815 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); |
753 | 816 | ||
754 | int iBandwidth = DEFAULT_BANDWIDTH_VALUE; | 817 | int iBandwidth = DEFAULT_BANDWIDTH_VALUE; |
755 | - if (tunnel.annotations().value("bandwidth") != null) { | 818 | + if (tunnel.annotations().value(BANDWIDTH) != null) { |
756 | - iBandwidth = Integer.parseInt(tunnel.annotations().value("bandwidth")); | 819 | + iBandwidth = Integer.parseInt(tunnel.annotations().value(BANDWIDTH)); |
757 | } | 820 | } |
758 | // build bandwidth object | 821 | // build bandwidth object |
759 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); | 822 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); |
... | @@ -777,7 +840,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -777,7 +840,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
777 | private void pcepSetupTunnel(Tunnel tunnel, Path path, PcepClient pc) { | 840 | private void pcepSetupTunnel(Tunnel tunnel, Path path, PcepClient pc) { |
778 | try { | 841 | try { |
779 | int srpId = SrpIdGenerators.create(); | 842 | int srpId = SrpIdGenerators.create(); |
780 | - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.CREATE); | 843 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, CREATE); |
781 | 844 | ||
782 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); | 845 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); |
783 | 846 | ||
... | @@ -809,12 +872,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -809,12 +872,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
809 | */ | 872 | */ |
810 | private void pcepReleaseTunnel(Tunnel tunnel, PcepClient pc) { | 873 | private void pcepReleaseTunnel(Tunnel tunnel, PcepClient pc) { |
811 | try { | 874 | try { |
812 | - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, RequestType.DELETE); | 875 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, DELETE); |
813 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); | 876 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); |
814 | int srpId = SrpIdGenerators.create(); | 877 | int srpId = SrpIdGenerators.create(); |
815 | TunnelId tunnelId = tunnel.tunnelId(); | 878 | TunnelId tunnelId = tunnel.tunnelId(); |
816 | int plspId = 0; | 879 | int plspId = 0; |
817 | - StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv = null; | ||
818 | 880 | ||
819 | if (!(pcepTunnelApiMapper.checkFromTunnelDBQueue(tunnelId))) { | 881 | if (!(pcepTunnelApiMapper.checkFromTunnelDBQueue(tunnelId))) { |
820 | log.error("Tunnel doesnot exists. Tunnel id {}" + tunnelId.toString()); | 882 | log.error("Tunnel doesnot exists. Tunnel id {}" + tunnelId.toString()); |
... | @@ -822,24 +884,23 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -822,24 +884,23 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
822 | } else { | 884 | } else { |
823 | PcepTunnelData pcepTunnelDbData = pcepTunnelApiMapper.getDataFromTunnelDBQueue(tunnelId); | 885 | PcepTunnelData pcepTunnelDbData = pcepTunnelApiMapper.getDataFromTunnelDBQueue(tunnelId); |
824 | plspId = pcepTunnelDbData.plspId(); | 886 | plspId = pcepTunnelDbData.plspId(); |
825 | - statefulIpv4IndentifierTlv = pcepTunnelDbData.statefulIpv4IndentifierTlv(); | ||
826 | } | 887 | } |
827 | - // build srp object | ||
828 | - PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(true).build(); | ||
829 | 888 | ||
830 | PcepValueType tlv; | 889 | PcepValueType tlv; |
831 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); | 890 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); |
832 | - LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>(); | ||
833 | 891 | ||
834 | - if (statefulIpv4IndentifierTlv != null) { | 892 | + // set PathSetupTypeTlv of SRP object |
835 | - tlv = statefulIpv4IndentifierTlv; | 893 | + tlv = new PathSetupTypeTlv(LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)) |
836 | - } else { | 894 | + .type()); |
837 | - tlv = new StatefulIPv4LspIdentidiersTlv(( | ||
838 | - ((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), | ||
839 | - (short) 0, (short) 0, 0, | ||
840 | - (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())); | ||
841 | - } | ||
842 | llOptionalTlv.add(tlv); | 895 | llOptionalTlv.add(tlv); |
896 | + | ||
897 | + // build SRP object | ||
898 | + PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(true) | ||
899 | + .setOptionalTlv(llOptionalTlv).build(); | ||
900 | + | ||
901 | + llOptionalTlv = new LinkedList<PcepValueType>(); | ||
902 | + LinkedList<PcInitiatedLspRequest> llPcInitiatedLspRequestList = new LinkedList<PcInitiatedLspRequest>(); | ||
903 | + | ||
843 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); | 904 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); |
844 | llOptionalTlv.add(tlv); | 905 | llOptionalTlv.add(tlv); |
845 | // build lsp object, set r flag as false to delete the tunnel | 906 | // build lsp object, set r flag as false to delete the tunnel |
... | @@ -871,7 +932,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -871,7 +932,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
871 | */ | 932 | */ |
872 | private void pcepUpdateTunnel(Tunnel tunnel, Path path, PcepClient pc) { | 933 | private void pcepUpdateTunnel(Tunnel tunnel, Path path, PcepClient pc) { |
873 | try { | 934 | try { |
874 | - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE); | 935 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, UPDATE); |
875 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); | 936 | pcepTunnelApiMapper.addToCoreTunnelRequestQueue(pcepTunnelData); |
876 | int srpId = SrpIdGenerators.create(); | 937 | int srpId = SrpIdGenerators.create(); |
877 | TunnelId tunnelId = tunnel.tunnelId(); | 938 | TunnelId tunnelId = tunnel.tunnelId(); |
... | @@ -882,8 +943,16 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -882,8 +943,16 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
882 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); | 943 | LinkedList<PcepValueType> llOptionalTlv = new LinkedList<PcepValueType>(); |
883 | LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>(); | 944 | LinkedList<PcepUpdateRequest> llUpdateRequestList = new LinkedList<PcepUpdateRequest>(); |
884 | 945 | ||
885 | - //build SRP object | 946 | + // set PathSetupTypeTlv of SRP object |
886 | - PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false).build(); | 947 | + LspType lspSigType = LspType.valueOf(tunnel.annotations().value(LSP_SIG_TYPE)); |
948 | + tlv = new PathSetupTypeTlv(lspSigType.type()); | ||
949 | + llOptionalTlv.add(tlv); | ||
950 | + | ||
951 | + // build SRP object | ||
952 | + PcepSrpObject srpobj = pc.factory().buildSrpObject().setSrpID(srpId).setRFlag(false) | ||
953 | + .setOptionalTlv(llOptionalTlv).build(); | ||
954 | + | ||
955 | + llOptionalTlv = new LinkedList<PcepValueType>(); | ||
887 | 956 | ||
888 | if (!(pcepTunnelApiMapper.checkFromTunnelDBQueue(tunnelId))) { | 957 | if (!(pcepTunnelApiMapper.checkFromTunnelDBQueue(tunnelId))) { |
889 | log.error("Tunnel doesnot exists in DB"); | 958 | log.error("Tunnel doesnot exists in DB"); |
... | @@ -893,10 +962,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -893,10 +962,26 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
893 | plspId = pcepTunnelDBData.plspId(); | 962 | plspId = pcepTunnelDBData.plspId(); |
894 | } | 963 | } |
895 | 964 | ||
896 | - tlv = new StatefulIPv4LspIdentidiersTlv((((IpTunnelEndPoint) tunnel.src()).ip().getIp4Address().toInt()), | 965 | + if (lspSigType != WITH_SIGNALLING) { |
897 | - (short) 0, (short) 0, 0, | 966 | + String localLspIdString = tunnel.annotations().value(LOCAL_LSP_ID); |
898 | - (((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt())); | 967 | + String pccTunnelIdString = tunnel.annotations().value(PCC_TUNNEL_ID); |
899 | - llOptionalTlv.add(tlv); | 968 | + short localLspId = 0; |
969 | + short pccTunnelId = 0; | ||
970 | + | ||
971 | + if (localLspIdString != null) { | ||
972 | + localLspId = Short.valueOf(localLspIdString); | ||
973 | + } | ||
974 | + | ||
975 | + if (pccTunnelIdString != null) { | ||
976 | + pccTunnelId = Short.valueOf(pccTunnelIdString); | ||
977 | + } | ||
978 | + | ||
979 | + tlv = new StatefulIPv4LspIdentifiersTlv((((IpTunnelEndPoint) tunnel.src()) | ||
980 | + .ip().getIp4Address().toInt()), | ||
981 | + localLspId, pccTunnelId, 0, (((IpTunnelEndPoint) tunnel.dst()).ip() | ||
982 | + .getIp4Address().toInt())); | ||
983 | + llOptionalTlv.add(tlv); | ||
984 | + } | ||
900 | 985 | ||
901 | if (tunnel.tunnelName().value() != null) { | 986 | if (tunnel.tunnelName().value() != null) { |
902 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); | 987 | tlv = new SymbolicPathNameTlv(tunnel.tunnelName().value().getBytes()); |
... | @@ -910,8 +995,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -910,8 +995,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
910 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); | 995 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); |
911 | 996 | ||
912 | int iBandwidth = DEFAULT_BANDWIDTH_VALUE; | 997 | int iBandwidth = DEFAULT_BANDWIDTH_VALUE; |
913 | - if (tunnel.annotations().value("bandwidth") != null) { | 998 | + if (tunnel.annotations().value(BANDWIDTH) != null) { |
914 | - iBandwidth = Integer.parseInt(tunnel.annotations().value("bandwidth")); | 999 | + iBandwidth = Integer.parseInt(tunnel.annotations().value(BANDWIDTH)); |
915 | } | 1000 | } |
916 | // build bandwidth object | 1001 | // build bandwidth object |
917 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); | 1002 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); |
... | @@ -1005,14 +1090,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1005,14 +1090,15 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1005 | // Check the sync status | 1090 | // Check the sync status |
1006 | if (lspObj.getSFlag()) { | 1091 | if (lspObj.getSFlag()) { |
1007 | handleSyncReport(stateRpt); | 1092 | handleSyncReport(stateRpt); |
1093 | + continue; | ||
1008 | } else if (!pcepClientController.getClient(pccId).isSyncComplete()) { | 1094 | } else if (!pcepClientController.getClient(pccId).isSyncComplete()) { |
1009 | // sync is done | 1095 | // sync is done |
1010 | pcepClientController.getClient(pccId).setIsSyncComplete(true); | 1096 | pcepClientController.getClient(pccId).setIsSyncComplete(true); |
1097 | + continue; | ||
1011 | } | 1098 | } |
1012 | - continue; | ||
1013 | } | 1099 | } |
1014 | 1100 | ||
1015 | - handleReportMessage(srpId, lspObj); | 1101 | + handleReportMessage(srpId, lspObj, stateRpt); |
1016 | } | 1102 | } |
1017 | break; | 1103 | break; |
1018 | 1104 | ||
... | @@ -1027,13 +1113,18 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1027,13 +1113,18 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1027 | /** | 1113 | /** |
1028 | * Handles report message for setup/update/delete tunnel request. | 1114 | * Handles report message for setup/update/delete tunnel request. |
1029 | * | 1115 | * |
1030 | - * @param srpId unique identifier for pcep message | 1116 | + * @param srpId unique identifier for PCEP message |
1031 | - * @param lspObj lsp object | 1117 | + * @param lspObj LSP object |
1118 | + * @param stateRpt parsed PCEP report msg. | ||
1032 | */ | 1119 | */ |
1033 | - private void handleReportMessage(int srpId, PcepLspObject lspObj) { | 1120 | + private void handleReportMessage(int srpId, PcepLspObject lspObj, PcepStateReport stateRpt) { |
1034 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); | 1121 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); |
1035 | PcepTunnelData pcepTunnelData = pcepTunnelApiMapper.getDataFromTunnelRequestQueue(srpId); | 1122 | PcepTunnelData pcepTunnelData = pcepTunnelApiMapper.getDataFromTunnelRequestQueue(srpId); |
1036 | - SparseAnnotations annotations = (SparseAnnotations) pcepTunnelData.tunnel().annotations(); | 1123 | + |
1124 | + if (pcepTunnelData == null) { | ||
1125 | + handleRptWithoutSrpId(stateRpt); | ||
1126 | + return; | ||
1127 | + } | ||
1037 | 1128 | ||
1038 | // store the values required from report message | 1129 | // store the values required from report message |
1039 | pcepTunnelData.setPlspId(lspObj.getPlspId()); | 1130 | pcepTunnelData.setPlspId(lspObj.getPlspId()); |
... | @@ -1041,12 +1132,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1041,12 +1132,12 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1041 | pcepTunnelData.setLspOFlag(lspObj.getOFlag()); | 1132 | pcepTunnelData.setLspOFlag(lspObj.getOFlag()); |
1042 | pcepTunnelData.setLspDFlag(lspObj.getDFlag()); | 1133 | pcepTunnelData.setLspDFlag(lspObj.getDFlag()); |
1043 | 1134 | ||
1044 | - StatefulIPv4LspIdentidiersTlv ipv4LspTlv = null; | 1135 | + StatefulIPv4LspIdentifiersTlv ipv4LspTlv = null; |
1045 | ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); | 1136 | ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); |
1046 | while (listTlvIterator.hasNext()) { | 1137 | while (listTlvIterator.hasNext()) { |
1047 | PcepValueType tlv = listTlvIterator.next(); | 1138 | PcepValueType tlv = listTlvIterator.next(); |
1048 | - if (tlv.getType() == StatefulIPv4LspIdentidiersTlv.TYPE) { | 1139 | + if (tlv.getType() == StatefulIPv4LspIdentifiersTlv.TYPE) { |
1049 | - ipv4LspTlv = (StatefulIPv4LspIdentidiersTlv) tlv; | 1140 | + ipv4LspTlv = (StatefulIPv4LspIdentifiersTlv) tlv; |
1050 | break; | 1141 | break; |
1051 | } | 1142 | } |
1052 | } | 1143 | } |
... | @@ -1056,38 +1147,113 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1056,38 +1147,113 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1056 | 1147 | ||
1057 | Path path = pcepTunnelData.path(); | 1148 | Path path = pcepTunnelData.path(); |
1058 | Tunnel tunnel = pcepTunnelData.tunnel(); | 1149 | Tunnel tunnel = pcepTunnelData.tunnel(); |
1150 | + Builder annotationBuilder = DefaultAnnotations.builder(); | ||
1151 | + annotationBuilder.putAll(pcepTunnelData.tunnel().annotations()); | ||
1152 | + | ||
1153 | + // PCRpt in response to PCInitate msg will carry PLSP id allocated by PCC. | ||
1154 | + if (tunnel.annotations().value(PLSP_ID) == null) { | ||
1155 | + annotationBuilder.set(PLSP_ID, String.valueOf(lspObj.getPlspId())); | ||
1156 | + } | ||
1157 | + | ||
1158 | + // Signalled LSPs will carry local LSP id allocated by signalling protocol(PCC). | ||
1159 | + if (tunnel.annotations().value(LOCAL_LSP_ID) == null) { | ||
1160 | + annotationBuilder.set(LOCAL_LSP_ID, String.valueOf(ipv4LspTlv.getLspId())); | ||
1161 | + } | ||
1162 | + | ||
1163 | + SparseAnnotations annotations = annotationBuilder.build(); | ||
1059 | DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), | 1164 | DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), |
1060 | tunnel.dst(), tunnel.type(), tunnel.groupId(), | 1165 | tunnel.dst(), tunnel.type(), tunnel.groupId(), |
1061 | providerId, tunnel.tunnelName(), path, | 1166 | providerId, tunnel.tunnelName(), path, |
1062 | annotations); | 1167 | annotations); |
1063 | 1168 | ||
1064 | - if (RequestType.CREATE == pcepTunnelData.requestType()) { | 1169 | + if (CREATE == pcepTunnelData.requestType()) { |
1065 | - log.debug("Report received for create request"); | ||
1066 | - | ||
1067 | pcepTunnelApiMapper.handleCreateTunnelRequestQueue(srpId, pcepTunnelData); | 1170 | pcepTunnelApiMapper.handleCreateTunnelRequestQueue(srpId, pcepTunnelData); |
1068 | - if (0 == lspObj.getOFlag()) { | 1171 | + } else if (DELETE == pcepTunnelData.requestType()) { |
1069 | - log.warn("The tunnel is in down state"); | ||
1070 | - } | ||
1071 | - tunnelAdded(td); | ||
1072 | - } | ||
1073 | - if (RequestType.DELETE == pcepTunnelData.requestType()) { | ||
1074 | - log.debug("Report received for delete request"); | ||
1075 | pcepTunnelApiMapper.handleRemoveFromTunnelRequestQueue(srpId, pcepTunnelData); | 1172 | pcepTunnelApiMapper.handleRemoveFromTunnelRequestQueue(srpId, pcepTunnelData); |
1076 | - tunnelRemoved(td); | 1173 | + } else if (UPDATE == pcepTunnelData.requestType()) { |
1077 | - } | ||
1078 | - | ||
1079 | - if (RequestType.UPDATE == pcepTunnelData.requestType()) { | ||
1080 | - log.debug("Report received for update request"); | ||
1081 | pcepTunnelData.setRptFlag(true); | 1174 | pcepTunnelData.setRptFlag(true); |
1082 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 1175 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
1083 | pcepTunnelApiMapper.handleUpdateTunnelRequestQueue(srpId, pcepTunnelData); | 1176 | pcepTunnelApiMapper.handleUpdateTunnelRequestQueue(srpId, pcepTunnelData); |
1177 | + } | ||
1178 | + | ||
1179 | + if (lspObj.getRFlag()) { | ||
1180 | + tunnelRemoved(td); | ||
1181 | + } else { | ||
1182 | + State tunnelState = PcepLspStatus | ||
1183 | + .getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); | ||
1184 | + tunnelUpdated(td, tunnelState); | ||
1185 | + } | ||
1186 | + } | ||
1187 | + | ||
1188 | + /** | ||
1189 | + * Handles asynchronous report messages from PCC when LSPDB sync is not in progress. | ||
1190 | + * | ||
1191 | + * @param stateRpt parsed PCEP report msg. | ||
1192 | + */ | ||
1193 | + private void handleRptWithoutSrpId(PcepStateReport stateRpt) { | ||
1194 | + ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); | ||
1195 | + StatefulIPv4LspIdentifiersTlv ipv4LspTlv = null; | ||
1084 | 1196 | ||
1085 | - if (0 == lspObj.getOFlag()) { | 1197 | + PcepLspObject lspObj = stateRpt.getLspObject(); |
1086 | - log.warn("The tunnel is in down state"); | 1198 | + ListIterator<PcepValueType> listTlvIterator = lspObj.getOptionalTlv().listIterator(); |
1199 | + | ||
1200 | + while (listTlvIterator.hasNext()) { | ||
1201 | + PcepValueType tlv = listTlvIterator.next(); | ||
1202 | + if (tlv.getType() == StatefulIPv4LspIdentifiersTlv.TYPE) { | ||
1203 | + ipv4LspTlv = (StatefulIPv4LspIdentifiersTlv) tlv; | ||
1204 | + break; | ||
1205 | + } | ||
1206 | + } | ||
1207 | + | ||
1208 | + checkNotNull(ipv4LspTlv); | ||
1209 | + | ||
1210 | + IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(ipv4LspTlv | ||
1211 | + .getIpv4IngressAddress())); | ||
1212 | + IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(ipv4LspTlv | ||
1213 | + .getIpv4EgressAddress())); | ||
1214 | + | ||
1215 | + Collection<Tunnel> tunnelQueryResult = tunnelService.queryTunnel(tunnelEndPointSrc, tunnelEndPointDst); | ||
1216 | + | ||
1217 | + Tunnel tunnel = null; | ||
1218 | + // Asynchronous status change message from PCC for LSP reported earlier. | ||
1219 | + for (Tunnel tunnelObj : tunnelQueryResult) { | ||
1220 | + if ((tunnelObj.annotations().value(PLSP_ID) == null) | ||
1221 | + || (tunnelObj.annotations().value(LOCAL_LSP_ID) == null)) { | ||
1222 | + /* | ||
1223 | + * Can skip this tunnel as this is one for which PCE has | ||
1224 | + * sent PCInit/PCUpd msg and waiting for a PCRpt. | ||
1225 | + */ | ||
1226 | + continue; | ||
1227 | + } | ||
1228 | + | ||
1229 | + if ((Integer.valueOf(tunnelObj.annotations().value(PLSP_ID)) == lspObj.getPlspId()) | ||
1230 | + && (Integer.valueOf(tunnelObj.annotations().value(LOCAL_LSP_ID)) | ||
1231 | + == ipv4LspTlv.getLspId())) { | ||
1232 | + tunnel = tunnelObj; | ||
1233 | + break; | ||
1087 | } | 1234 | } |
1088 | - if (!(pcepTunnelApiMapper.checkFromTunnelRequestQueue(srpId))) { | 1235 | + } |
1089 | - tunnelUpdated(td); | 1236 | + |
1237 | + // Status report for a new LSP when LSPDB sync was already completed sometime. | ||
1238 | + // No need to add the tunnel if msg is for remove but store doesn't have an entry. | ||
1239 | + if (tunnel == null) { | ||
1240 | + if (!lspObj.getRFlag()) { | ||
1241 | + handleSyncReport(stateRpt); | ||
1090 | } | 1242 | } |
1243 | + return; | ||
1244 | + } | ||
1245 | + | ||
1246 | + DefaultTunnelDescription td = new DefaultTunnelDescription(tunnel.tunnelId(), tunnel.src(), | ||
1247 | + tunnel.dst(), tunnel.type(), tunnel.groupId(), | ||
1248 | + providerId, tunnel.tunnelName(), tunnel.path(), | ||
1249 | + (SparseAnnotations) tunnel.annotations()); | ||
1250 | + | ||
1251 | + if (lspObj.getRFlag()) { | ||
1252 | + tunnelRemoved(td); // This will happen only for PCC initiated tunnels. | ||
1253 | + } else { | ||
1254 | + State tunnelState = PcepLspStatus | ||
1255 | + .getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); | ||
1256 | + tunnelUpdated(td, tunnelState); | ||
1091 | } | 1257 | } |
1092 | } | 1258 | } |
1093 | 1259 | ||
... | @@ -1100,9 +1266,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1100,9 +1266,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1100 | PcepLspObject lspObj = stateRpt.getLspObject(); | 1266 | PcepLspObject lspObj = stateRpt.getLspObject(); |
1101 | PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath(); | 1267 | PcepStateReport.PcepMsgPath msgPath = stateRpt.getMsgPath(); |
1102 | checkNotNull(msgPath); | 1268 | checkNotNull(msgPath); |
1103 | - PcepRroObject rroObj = msgPath.getRroObject(); | 1269 | + PcepEroObject eroObj = msgPath.getEroObject(); |
1104 | - if (rroObj == null) { | 1270 | + if (eroObj == null) { |
1105 | - log.debug("RRO object is null in sate report"); | 1271 | + log.debug("ERO object is null in sate report"); |
1106 | return; | 1272 | return; |
1107 | } | 1273 | } |
1108 | int bandwidth = 0; | 1274 | int bandwidth = 0; |
... | @@ -1118,20 +1284,44 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1118,20 +1284,44 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1118 | bandwidth = msgPath.getBandwidthObject().getBandwidth(); | 1284 | bandwidth = msgPath.getBandwidthObject().getBandwidth(); |
1119 | } | 1285 | } |
1120 | 1286 | ||
1121 | - buildAndStorePcepTunnelData(lspObj, rroObj, bandwidth); | 1287 | + // To carry PST TLV, SRP object can be present with value 0 even |
1288 | + // when PCRpt is | ||
1289 | + // not in response to any action from PCE. | ||
1290 | + PcepSrpObject srpObj = stateRpt.getSrpObject(); | ||
1291 | + LspType lspType = WITH_SIGNALLING; | ||
1292 | + | ||
1293 | + if (null != srpObj) { | ||
1294 | + LinkedList<PcepValueType> llOptionalTlv = srpObj.getOptionalTlv(); | ||
1295 | + ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); | ||
1296 | + | ||
1297 | + while (listIterator.hasNext()) { | ||
1298 | + PcepValueType tlv = listIterator.next(); | ||
1299 | + | ||
1300 | + switch (tlv.getType()) { | ||
1301 | + case PathSetupTypeTlv.TYPE: | ||
1302 | + lspType = LspType.values()[Integer.valueOf(((PathSetupTypeTlv) tlv).getPst())]; | ||
1303 | + break; | ||
1304 | + | ||
1305 | + default: | ||
1306 | + break; | ||
1307 | + } | ||
1308 | + } | ||
1309 | + } | ||
1310 | + | ||
1311 | + buildAndStorePcepTunnelData(lspObj, eroObj, bandwidth, lspType); | ||
1122 | } | 1312 | } |
1123 | 1313 | ||
1124 | /** | 1314 | /** |
1125 | - * To build Path in network from RRO object. | 1315 | + * To build Path in network from ERO object. |
1126 | * | 1316 | * |
1127 | - * @param rroObj rro object | 1317 | + * @param eroObj ERO object |
1128 | * @param providerId provider id | 1318 | * @param providerId provider id |
1129 | * @return path object | 1319 | * @return path object |
1130 | */ | 1320 | */ |
1131 | - private Path buildPathFromRroObj(PcepRroObject rroObj, ProviderId providerId) { | 1321 | + private Path buildPathFromEroObj(PcepEroObject eroObj, ProviderId providerId) { |
1132 | - checkNotNull(rroObj); | 1322 | + checkNotNull(eroObj); |
1133 | List<Link> links = new ArrayList<Link>(); | 1323 | List<Link> links = new ArrayList<Link>(); |
1134 | - LinkedList<PcepValueType> llSubObj = rroObj.getSubObjects(); | 1324 | + LinkedList<PcepValueType> llSubObj = eroObj.getSubObjects(); |
1135 | if (0 == llSubObj.size()) { | 1325 | if (0 == llSubObj.size()) { |
1136 | log.error("RRO in report message does not have hop information"); | 1326 | log.error("RRO in report message does not have hop information"); |
1137 | } | 1327 | } |
... | @@ -1172,27 +1362,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1172,27 +1362,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1172 | } | 1362 | } |
1173 | 1363 | ||
1174 | /** | 1364 | /** |
1175 | - * To build pcepTunnelData and informs core about the pcc reported tunnel. | 1365 | + * To build pcepTunnelData and informs core about the PCC reported |
1366 | + * tunnel. | ||
1176 | * | 1367 | * |
1177 | - * @param lspObj pcep lsp object | 1368 | + * @param lspObj PCEP LSP object |
1178 | - * @param rroObj pcep rro object | 1369 | + * @param eroObj PCEP ERO object |
1179 | * @param bandwidth bandwidth of tunnel | 1370 | * @param bandwidth bandwidth of tunnel |
1371 | + * @param lspType path setup type/signaling type of the LSP. | ||
1180 | */ | 1372 | */ |
1181 | - private void buildAndStorePcepTunnelData(PcepLspObject lspObj, PcepRroObject rroObj, | 1373 | + private void buildAndStorePcepTunnelData(PcepLspObject lspObj, PcepEroObject eroObj, int bandwidth, |
1182 | - int bandwidth) { | 1374 | + LspType lspType) { |
1183 | 1375 | ||
1184 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); | 1376 | ProviderId providerId = new ProviderId("pcep", PROVIDER_ID); |
1185 | 1377 | ||
1186 | // StatefulIPv4LspIdentidiersTlv in LSP object will have the source and destination address. | 1378 | // StatefulIPv4LspIdentidiersTlv in LSP object will have the source and destination address. |
1187 | - StatefulIPv4LspIdentidiersTlv lspIdenTlv = null; | 1379 | + StatefulIPv4LspIdentifiersTlv lspIdenTlv = null; |
1188 | SymbolicPathNameTlv pathNameTlv = null; | 1380 | SymbolicPathNameTlv pathNameTlv = null; |
1189 | LinkedList<PcepValueType> llOptionalTlv = lspObj.getOptionalTlv(); | 1381 | LinkedList<PcepValueType> llOptionalTlv = lspObj.getOptionalTlv(); |
1190 | ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); | 1382 | ListIterator<PcepValueType> listIterator = llOptionalTlv.listIterator(); |
1191 | while (listIterator.hasNext()) { | 1383 | while (listIterator.hasNext()) { |
1192 | PcepValueType tlv = listIterator.next(); | 1384 | PcepValueType tlv = listIterator.next(); |
1193 | switch (tlv.getType()) { | 1385 | switch (tlv.getType()) { |
1194 | - case StatefulIPv4LspIdentidiersTlv.TYPE: | 1386 | + case StatefulIPv4LspIdentifiersTlv.TYPE: |
1195 | - lspIdenTlv = (StatefulIPv4LspIdentidiersTlv) tlv; | 1387 | + lspIdenTlv = (StatefulIPv4LspIdentifiersTlv) tlv; |
1196 | break; | 1388 | break; |
1197 | case SymbolicPathNameTlv.TYPE: | 1389 | case SymbolicPathNameTlv.TYPE: |
1198 | pathNameTlv = (SymbolicPathNameTlv) tlv; | 1390 | pathNameTlv = (SymbolicPathNameTlv) tlv; |
... | @@ -1207,24 +1399,28 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1207,24 +1399,28 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1207 | IpTunnelEndPoint tunnelEndPointDst; | 1399 | IpTunnelEndPoint tunnelEndPointDst; |
1208 | tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(lspIdenTlv.getIpv4EgressAddress())); | 1400 | tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(lspIdenTlv.getIpv4EgressAddress())); |
1209 | 1401 | ||
1210 | - Path path = buildPathFromRroObj(rroObj, providerId); | 1402 | + Path path = buildPathFromEroObj(eroObj, providerId); |
1211 | 1403 | ||
1212 | SparseAnnotations annotations = DefaultAnnotations.builder() | 1404 | SparseAnnotations annotations = DefaultAnnotations.builder() |
1213 | - .set("bandwidth", (new Integer(bandwidth)).toString()) | 1405 | + .set(BANDWIDTH, (new Integer(bandwidth)).toString()) |
1214 | - .build(); | 1406 | + .set(LSP_SIG_TYPE, lspType.name()) |
1407 | + .set(PCC_TUNNEL_ID, String.valueOf(lspIdenTlv.getTunnelId())) | ||
1408 | + .set(PLSP_ID, String.valueOf(lspObj.getPlspId())) | ||
1409 | + .set(LOCAL_LSP_ID, String.valueOf(lspIdenTlv.getLspId())).build(); | ||
1215 | 1410 | ||
1216 | DefaultTunnelDescription td = new DefaultTunnelDescription(null, tunnelEndPointSrc, | 1411 | DefaultTunnelDescription td = new DefaultTunnelDescription(null, tunnelEndPointSrc, |
1217 | - tunnelEndPointDst, Tunnel.Type.MPLS, | 1412 | + tunnelEndPointDst, MPLS, |
1218 | new DefaultGroupId(0), providerId, | 1413 | new DefaultGroupId(0), providerId, |
1219 | TunnelName.tunnelName(pathNameTlv.toString()), | 1414 | TunnelName.tunnelName(pathNameTlv.toString()), |
1220 | path, annotations); | 1415 | path, annotations); |
1221 | - TunnelId tId = tunnelAdded(td); | 1416 | + State tunnelState = PcepLspStatus.getTunnelStatusFromLspStatus(PcepLspStatus.values()[lspObj.getOFlag()]); |
1417 | + TunnelId tId = tunnelAdded(td, tunnelState); | ||
1222 | 1418 | ||
1223 | - Tunnel tunnel = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, Tunnel.Type.MPLS, | 1419 | + Tunnel tunnel = new DefaultTunnel(providerId, tunnelEndPointSrc, tunnelEndPointDst, MPLS, |
1224 | new DefaultGroupId(0), tId, | 1420 | new DefaultGroupId(0), tId, |
1225 | TunnelName.tunnelName(pathNameTlv.toString()), path, annotations); | 1421 | TunnelName.tunnelName(pathNameTlv.toString()), path, annotations); |
1226 | 1422 | ||
1227 | - PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.LSP_STATE_RPT); | 1423 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, LSP_STATE_RPT); |
1228 | pcepTunnelData.setStatefulIpv4IndentifierTlv(lspIdenTlv); | 1424 | pcepTunnelData.setStatefulIpv4IndentifierTlv(lspIdenTlv); |
1229 | pcepTunnelApiMapper.addPccTunnelDB(pcepTunnelData); | 1425 | pcepTunnelApiMapper.addPccTunnelDB(pcepTunnelData); |
1230 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 1426 | pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
... | @@ -1240,8 +1436,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1240,8 +1436,6 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1240 | // TODO | 1436 | // TODO |
1241 | } | 1437 | } |
1242 | 1438 | ||
1243 | - | ||
1244 | - | ||
1245 | @Override | 1439 | @Override |
1246 | public void handlePcepTunnelStatistics(PcepTunnelStatistics pcepTunnelStatistics) { | 1440 | public void handlePcepTunnelStatistics(PcepTunnelStatistics pcepTunnelStatistics) { |
1247 | TunnelId id = getTunnelId(String.valueOf(pcepTunnelStatistics.id())); | 1441 | TunnelId id = getTunnelId(String.valueOf(pcepTunnelStatistics.id())); | ... | ... |
providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java
... | @@ -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(); | ... | ... |
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 static org.hamcrest.MatcherAssert.assertThat; | ||
19 | +import static org.hamcrest.core.Is.is; | ||
20 | +import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | ||
21 | +import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; | ||
22 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.BANDWIDTH; | ||
23 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LOCAL_LSP_ID; | ||
24 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE; | ||
25 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PCC_TUNNEL_ID; | ||
26 | +import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.PLSP_ID; | ||
27 | +import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | ||
28 | + | ||
29 | +import java.io.IOException; | ||
30 | +import java.util.Collection; | ||
31 | +import java.util.Collections; | ||
32 | +import java.util.HashMap; | ||
33 | +import java.util.HashSet; | ||
34 | + | ||
35 | +import org.jboss.netty.buffer.ChannelBuffer; | ||
36 | +import org.jboss.netty.buffer.ChannelBuffers; | ||
37 | +import org.junit.After; | ||
38 | +import org.junit.Before; | ||
39 | +import org.junit.Test; | ||
40 | +import org.onlab.packet.IpAddress; | ||
41 | +import org.onosproject.cfg.ComponentConfigAdapter; | ||
42 | +import org.onosproject.core.ApplicationId; | ||
43 | +import org.onosproject.incubator.net.tunnel.DefaultTunnel; | ||
44 | +import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | ||
45 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
46 | +import org.onosproject.incubator.net.tunnel.TunnelDescription; | ||
47 | +import org.onosproject.incubator.net.tunnel.TunnelEndPoint; | ||
48 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
49 | +import org.onosproject.incubator.net.tunnel.TunnelName; | ||
50 | +import org.onosproject.incubator.net.tunnel.TunnelProvider; | ||
51 | +import org.onosproject.incubator.net.tunnel.TunnelProviderService; | ||
52 | +import org.onosproject.incubator.net.tunnel.Tunnel.State; | ||
53 | +import org.onosproject.net.DefaultAnnotations; | ||
54 | +import org.onosproject.net.ElementId; | ||
55 | +import org.onosproject.net.Path; | ||
56 | +import org.onosproject.net.SparseAnnotations; | ||
57 | +import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException; | ||
58 | +import org.onosproject.pcepio.exceptions.PcepParseException; | ||
59 | +import org.onosproject.pcepio.protocol.PcepFactories; | ||
60 | +import org.onosproject.pcepio.protocol.PcepMessage; | ||
61 | +import org.onosproject.pcepio.protocol.PcepMessageReader; | ||
62 | +import org.onosproject.pcep.controller.ClientCapability; | ||
63 | +import org.onosproject.pcep.controller.PccId; | ||
64 | + | ||
65 | +import com.google.common.collect.ImmutableSet; | ||
66 | + | ||
67 | +/** | ||
68 | + * Tests handling of PCEP report message. | ||
69 | + */ | ||
70 | +public class PcepTunnelAddedTest { | ||
71 | + | ||
72 | + static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; | ||
73 | + PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); | ||
74 | + private final MockTunnelProviderRegistryAdapter registry = new MockTunnelProviderRegistryAdapter(); | ||
75 | + private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); | ||
76 | + private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | ||
77 | + private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); | ||
78 | + private final MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter(); | ||
79 | + | ||
80 | + private class MockTunnelProviderRegistryAdapter extends TunnelProviderRegistryAdapter { | ||
81 | + public long tunnelIdCounter; | ||
82 | + | ||
83 | + @Override | ||
84 | + public TunnelProviderService register(TunnelProvider provider) { | ||
85 | + this.provider = provider; | ||
86 | + return new TestProviderService(); | ||
87 | + } | ||
88 | + | ||
89 | + private class TestProviderService implements TunnelProviderService { | ||
90 | + | ||
91 | + @Override | ||
92 | + public TunnelProvider provider() { | ||
93 | + return null; | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public TunnelId tunnelAdded(TunnelDescription tunnel) { | ||
98 | + return TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public TunnelId tunnelAdded(TunnelDescription tunnel, State state) { | ||
103 | + return TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public void tunnelRemoved(TunnelDescription tunnel) { | ||
108 | + } | ||
109 | + | ||
110 | + @Override | ||
111 | + public void tunnelUpdated(TunnelDescription tunnel) { | ||
112 | + } | ||
113 | + | ||
114 | + @Override | ||
115 | + public void tunnelUpdated(TunnelDescription tunnel, State state) { | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public Tunnel tunnelQueryById(TunnelId tunnelId) { | ||
120 | + return null; | ||
121 | + } | ||
122 | + } | ||
123 | + } | ||
124 | + | ||
125 | + private class MockTunnelServiceAdapter extends TunnelServiceAdapter { | ||
126 | + private HashMap<TunnelId, Tunnel> tunnelIdAsKeyStore = new HashMap<>(); | ||
127 | + private int tunnelIdCounter = 0; | ||
128 | + | ||
129 | + @Override | ||
130 | + public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) { | ||
131 | + TunnelId tunnelId = TunnelId.valueOf(String.valueOf(++tunnelIdCounter)); | ||
132 | + tunnelIdAsKeyStore.put(tunnelId, tunnel); | ||
133 | + return tunnelId; | ||
134 | + } | ||
135 | + | ||
136 | + @Override | ||
137 | + public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) { | ||
138 | + Collection<Tunnel> result = new HashSet<>(); | ||
139 | + Tunnel tunnel = null; | ||
140 | + for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) { | ||
141 | + tunnel = tunnelIdAsKeyStore.get(tunnelId); | ||
142 | + | ||
143 | + if ((null != tunnel) && (src.equals(tunnel.src())) && (dst.equals(tunnel.dst()))) { | ||
144 | + result.add(tunnel); | ||
145 | + } | ||
146 | + } | ||
147 | + | ||
148 | + return result.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(result); | ||
149 | + } | ||
150 | + | ||
151 | + @Override | ||
152 | + public Collection<Tunnel> queryAllTunnels() { | ||
153 | + Collection<Tunnel> result = new HashSet<>(); | ||
154 | + | ||
155 | + for (TunnelId tunnelId : tunnelIdAsKeyStore.keySet()) { | ||
156 | + result.add(tunnelIdAsKeyStore.get(tunnelId)); | ||
157 | + } | ||
158 | + | ||
159 | + return result.isEmpty() ? Collections.emptySet() : ImmutableSet.copyOf(result); | ||
160 | + | ||
161 | + } | ||
162 | + } | ||
163 | + | ||
164 | + @Before | ||
165 | + public void preSetup() { | ||
166 | + tunnelProvider.tunnelProviderRegistry = registry; | ||
167 | + tunnelProvider.pcepClientController = controller; | ||
168 | + tunnelProvider.controller = ctl; | ||
169 | + tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper; | ||
170 | + tunnelProvider.cfgService = new ComponentConfigAdapter(); | ||
171 | + tunnelProvider.tunnelService = tunnelService; | ||
172 | + tunnelProvider.service = registry.register(tunnelProvider); | ||
173 | + tunnelProvider.activate(); | ||
174 | + } | ||
175 | + | ||
176 | + /** | ||
177 | + * Tests PCRpt msg with sync flag set. | ||
178 | + */ | ||
179 | + @Test | ||
180 | + public void tunnelProviderAddedTest1() throws PcepParseException, PcepOutOfBoundMessageException { | ||
181 | + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
182 | + 0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object | ||
183 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
184 | + 0x00, 0x00, 0x00, 0x02, | ||
185 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x03, //LSP object | ||
186 | + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv | ||
187 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
188 | + 0x01, 0x01, 0x01, 0x01, | ||
189 | + 0x00, 0x01, 0x00, 0x01, | ||
190 | + 0x01, 0x01, 0x01, 0x01, | ||
191 | + 0x05, 0x05, 0x05, 0x05, | ||
192 | + | ||
193 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
194 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
195 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
196 | + | ||
197 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
198 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
199 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
200 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
201 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
202 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
203 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
204 | + }; | ||
205 | + | ||
206 | + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); | ||
207 | + buffer.writeBytes(reportMsg); | ||
208 | + | ||
209 | + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | ||
210 | + PcepMessage message = reader.readFrom(buffer); | ||
211 | + controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); | ||
212 | + | ||
213 | + assertThat(registry.tunnelIdCounter, is((long) 1)); | ||
214 | + } | ||
215 | + | ||
216 | + /** | ||
217 | + * Tests updating an existing tunnel on receiving asynchronous PCRpt msg, | ||
218 | + * i.e. without any SRP id. | ||
219 | + */ | ||
220 | + @Test | ||
221 | + public void tunnelProviderAddedTest2() throws PcepParseException, PcepOutOfBoundMessageException { | ||
222 | + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x50, | ||
223 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
224 | + 0x00, 0x00, 0x00, 0x00, | ||
225 | + 0x00, 0x00, 0x00, 0x00, | ||
226 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
227 | + 0x00, 0x00, 0x00, 0x02, | ||
228 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, //LSP object | ||
229 | + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path TLV | ||
230 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
231 | + 0x4e, 0x1f, 0x04, 0x00, | ||
232 | + 0x00, 0x01, 0x00, 0x01, | ||
233 | + 0x4e, 0x1f, 0x04, 0x00, | ||
234 | + 0x4e, 0x20, 0x04, 0x00, | ||
235 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
236 | + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, // ERO IPv4 sub objects | ||
237 | + 0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00, | ||
238 | + }; | ||
239 | + | ||
240 | + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); | ||
241 | + buffer.writeBytes(reportMsg); | ||
242 | + | ||
243 | + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | ||
244 | + PcepMessage message = reader.readFrom(buffer); | ||
245 | + | ||
246 | + // create an existing tunnel. | ||
247 | + IpTunnelEndPoint tunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e1f0400)); | ||
248 | + IpTunnelEndPoint tunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(0x4e200400)); | ||
249 | + | ||
250 | + SparseAnnotations annotations = DefaultAnnotations.builder() | ||
251 | + .set(BANDWIDTH, (new Integer(1)).toString()) | ||
252 | + .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name()) | ||
253 | + .set(PCC_TUNNEL_ID, String.valueOf(1)) | ||
254 | + .set(PLSP_ID, String.valueOf(1)) | ||
255 | + .set(LOCAL_LSP_ID, String.valueOf(1)).build(); | ||
256 | + | ||
257 | + Tunnel tunnel = new DefaultTunnel(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, INIT, null, null, | ||
258 | + TunnelName.tunnelName("T123"), null, annotations); | ||
259 | + tunnelService.setupTunnel(null, null, tunnel, null); | ||
260 | + | ||
261 | + PccId pccId = PccId.pccId(IpAddress.valueOf(0x4e1f0400)); | ||
262 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); | ||
263 | + controller.getClient(pccId).setIsSyncComplete(true); | ||
264 | + | ||
265 | + // Process update message. | ||
266 | + controller.processClientMessage(pccId, message); | ||
267 | + assertThat(tunnelService.queryAllTunnels().size(), is(1)); | ||
268 | + } | ||
269 | + | ||
270 | + /** | ||
271 | + * Tests adding a new tunnel on receiving asynchronous PCRpt msg, | ||
272 | + * i.e. without any SRP id. | ||
273 | + */ | ||
274 | + @Test | ||
275 | + public void tunnelProviderAddedTest3() throws PcepParseException, PcepOutOfBoundMessageException { | ||
276 | + byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x84, | ||
277 | + 0x21, 0x10, 0x00, 0x14, //SRP object | ||
278 | + 0x00, 0x00, 0x00, 0x00, | ||
279 | + 0x00, 0x00, 0x00, 0x00, | ||
280 | + 0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV | ||
281 | + 0x00, 0x00, 0x00, 0x02, | ||
282 | + 0x20, 0x10, 0x00, 0x24, 0x00, 0x00, 0x10, 0x19, // LSP object | ||
283 | + 0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, // symbolic path TLV | ||
284 | + 0x00, 0x12, 0x00, 0x10, // IPv4-LSP-IDENTIFIER-TLV | ||
285 | + 0x01, 0x01, 0x01, 0x01, | ||
286 | + 0x00, 0x01, 0x00, 0x01, | ||
287 | + 0x01, 0x01, 0x01, 0x01, | ||
288 | + 0x05, 0x05, 0x05, 0x05, | ||
289 | + | ||
290 | + 0x07, 0x10, 0x00, 0x14, //ERO object | ||
291 | + 0x01, 0x08, (byte) 0x01, 0x01, 0x01, 0x01, 0x04, 0x00, // ERO IPv4 sub objects | ||
292 | + 0x01, 0x08, (byte) 0x05, 0x05, 0x05, 0x05, 0x04, 0x00, | ||
293 | + | ||
294 | + 0x08, 0x10, 0x00, 0x34, //RRO object | ||
295 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x01, 0x04, 0x00, // RRO IPv4 sub objects | ||
296 | + 0x01, 0x08, 0x11, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
297 | + 0x01, 0x08, 0x06, 0x06, 0x06, 0x06, 0x04, 0x00, | ||
298 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x02, 0x04, 0x00, | ||
299 | + 0x01, 0x08, 0x12, 0x01, 0x01, 0x01, 0x04, 0x00, | ||
300 | + 0x01, 0x08, 0x05, 0x05, 0x05, 0x05, 0x04, 0x00 | ||
301 | + }; | ||
302 | + | ||
303 | + ChannelBuffer buffer = ChannelBuffers.dynamicBuffer(); | ||
304 | + buffer.writeBytes(reportMsg); | ||
305 | + | ||
306 | + PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader(); | ||
307 | + PcepMessage message = reader.readFrom(buffer); | ||
308 | + | ||
309 | + PccId pccId = PccId.pccId(IpAddress.valueOf("1.1.1.1")); | ||
310 | + controller.getClient(pccId).setIsSyncComplete(true); | ||
311 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true)); | ||
312 | + controller.processClientMessage(pccId, message); | ||
313 | + | ||
314 | + assertThat(registry.tunnelIdCounter, is((long) 1)); | ||
315 | + } | ||
316 | + | ||
317 | + @After | ||
318 | + public void tearDown() throws IOException { | ||
319 | + tunnelProvider.deactivate(); | ||
320 | + tunnelProvider.controller = null; | ||
321 | + tunnelProvider.pcepClientController = null; | ||
322 | + tunnelProvider.tunnelProviderRegistry = null; | ||
323 | + | ||
324 | + tunnelProvider.pcepTunnelApiMapper = null; | ||
325 | + tunnelProvider.cfgService = null; | ||
326 | + tunnelProvider.tunnelService = null; | ||
327 | + tunnelProvider.service = null; | ||
328 | + } | ||
329 | +} |
... | @@ -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 | ... | ... |
-
Please register or login to post a comment