Committed by
Priyankab-Huawei
[ONOS] Cherry picked from master 1.7
Change-Id: I74a0c1634f9c425af2bcb646edc3d9170b3c087c
Showing
73 changed files
with
1925 additions
and
61 deletions
... | @@ -22,6 +22,7 @@ | ... | @@ -22,6 +22,7 @@ |
22 | <groupId>org.onosproject</groupId> | 22 | <groupId>org.onosproject</groupId> |
23 | <artifactId>onos-pce</artifactId> | 23 | <artifactId>onos-pce</artifactId> |
24 | <version>1.6.0-SNAPSHOT</version> | 24 | <version>1.6.0-SNAPSHOT</version> |
25 | + <relativePath>../pom.xml</relativePath> | ||
25 | </parent> | 26 | </parent> |
26 | <artifactId>onos-app-pce</artifactId> | 27 | <artifactId>onos-app-pce</artifactId> |
27 | <packaging>bundle</packaging> | 28 | <packaging>bundle</packaging> | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -19,7 +19,6 @@ import static org.hamcrest.MatcherAssert.assertThat; | ... | @@ -19,7 +19,6 @@ import static org.hamcrest.MatcherAssert.assertThat; |
19 | import static org.hamcrest.Matchers.is; | 19 | import static org.hamcrest.Matchers.is; |
20 | import static org.hamcrest.Matchers.notNullValue; | 20 | import static org.hamcrest.Matchers.notNullValue; |
21 | import static org.hamcrest.Matchers.nullValue; | 21 | import static org.hamcrest.Matchers.nullValue; |
22 | - | ||
23 | import static org.onosproject.net.Link.Type.DIRECT; | 22 | import static org.onosproject.net.Link.Type.DIRECT; |
24 | 23 | ||
25 | import java.util.Iterator; | 24 | import java.util.Iterator; |
... | @@ -29,7 +28,6 @@ import java.util.LinkedList; | ... | @@ -29,7 +28,6 @@ import java.util.LinkedList; |
29 | import org.junit.After; | 28 | import org.junit.After; |
30 | import org.junit.Before; | 29 | import org.junit.Before; |
31 | import org.junit.Test; | 30 | import org.junit.Test; |
32 | - | ||
33 | import org.onlab.packet.IpAddress; | 31 | import org.onlab.packet.IpAddress; |
34 | import org.onosproject.core.ApplicationId; | 32 | import org.onosproject.core.ApplicationId; |
35 | import org.onosproject.core.CoreService; | 33 | import org.onosproject.core.CoreService; |
... | @@ -165,6 +163,7 @@ public class BasicPceccHandlerTest { | ... | @@ -165,6 +163,7 @@ public class BasicPceccHandlerTest { |
165 | 163 | ||
166 | @After | 164 | @After |
167 | public void tearDown() throws Exception { | 165 | public void tearDown() throws Exception { |
166 | + PceManagerTest.flowsDownloaded = 0; | ||
168 | } | 167 | } |
169 | 168 | ||
170 | /** | 169 | /** | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -158,6 +158,7 @@ public class PceccSrTeBeHandlerTest { | ... | @@ -158,6 +158,7 @@ public class PceccSrTeBeHandlerTest { |
158 | 158 | ||
159 | @After | 159 | @After |
160 | public void tearDown() throws Exception { | 160 | public void tearDown() throws Exception { |
161 | + PceManagerTest.flowsDownloaded = 0; | ||
161 | } | 162 | } |
162 | 163 | ||
163 | /** | 164 | /** | ... | ... |
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | <groupId>org.onosproject</groupId> | 23 | <groupId>org.onosproject</groupId> |
24 | <artifactId>onos-pce</artifactId> | 24 | <artifactId>onos-pce</artifactId> |
25 | <version>1.6.0-SNAPSHOT</version> | 25 | <version>1.6.0-SNAPSHOT</version> |
26 | + <relativePath>../pom.xml</relativePath> | ||
26 | </parent> | 27 | </parent> |
27 | 28 | ||
28 | <artifactId>onos-app-pceweb</artifactId> | 29 | <artifactId>onos-app-pceweb</artifactId> |
... | @@ -42,6 +43,11 @@ | ... | @@ -42,6 +43,11 @@ |
42 | <artifactId>onos-cli</artifactId> | 43 | <artifactId>onos-cli</artifactId> |
43 | <version>${project.version}</version> | 44 | <version>${project.version}</version> |
44 | </dependency> | 45 | </dependency> |
46 | + <dependency> | ||
47 | + <groupId>org.onosproject</groupId> | ||
48 | + <artifactId>onos-app-pce</artifactId> | ||
49 | + <version>${project.version}</version> | ||
50 | + </dependency> | ||
45 | </dependencies> | 51 | </dependencies> |
46 | 52 | ||
47 | <properties> | 53 | <properties> | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -63,7 +63,6 @@ public class PceWebTopovOverlay extends UiTopoOverlay { | ... | @@ -63,7 +63,6 @@ public class PceWebTopovOverlay extends UiTopoOverlay { |
63 | public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { | 63 | public void modifyDeviceDetails(PropertyPanel pp, DeviceId deviceId) { |
64 | 64 | ||
65 | pp.title(MY_TITLE); | 65 | pp.title(MY_TITLE); |
66 | - log.info("Modify device details called."); | ||
67 | 66 | ||
68 | DeviceService deviceService = AbstractShellCommand.get(DeviceService.class); | 67 | DeviceService deviceService = AbstractShellCommand.get(DeviceService.class); |
69 | 68 | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -34,7 +34,6 @@ | ... | @@ -34,7 +34,6 @@ |
34 | glyphId: 'topo', | 34 | glyphId: 'topo', |
35 | tooltip: 'PCE web Topo Overlay', | 35 | tooltip: 'PCE web Topo Overlay', |
36 | 36 | ||
37 | - | ||
38 | activate: function () { | 37 | activate: function () { |
39 | $log.debug("PCE web topology overlay ACTIVATED"); | 38 | $log.debug("PCE web topology overlay ACTIVATED"); |
40 | }, | 39 | }, |
... | @@ -112,11 +111,32 @@ | ... | @@ -112,11 +111,32 @@ |
112 | }, | 111 | }, |
113 | 1: { | 112 | 1: { |
114 | cb: function () { | 113 | cb: function () { |
115 | - pps.setMode("shortest"); | 114 | + pps.setMode(); |
115 | + }, | ||
116 | + tt: 'Setup path', | ||
117 | + gid: 'plus' | ||
118 | + }, | ||
119 | + 2: { | ||
120 | + cb: function () { | ||
121 | + pps.updatePath(selection); | ||
116 | }, | 122 | }, |
117 | - tt: 'Select constraints for LSP', | 123 | + tt: 'Update path', |
118 | gid: '*jp' | 124 | gid: '*jp' |
119 | }, | 125 | }, |
126 | + 3: { | ||
127 | + cb: function () { | ||
128 | + pps.remPath(selection); | ||
129 | + }, | ||
130 | + tt: 'Remove path', | ||
131 | + gid: 'minus' | ||
132 | + }, | ||
133 | + 4: { | ||
134 | + cb: function () { | ||
135 | + pps.queryTunnelDisplay(); | ||
136 | + }, | ||
137 | + tt: 'Show Tunnels', | ||
138 | + gid: 'checkMark' | ||
139 | + }, | ||
120 | 0: { | 140 | 0: { |
121 | cb: function () { | 141 | cb: function () { |
122 | pps.clear(); | 142 | pps.clear(); |
... | @@ -126,7 +146,7 @@ | ... | @@ -126,7 +146,7 @@ |
126 | }, | 146 | }, |
127 | 147 | ||
128 | _keyOrder: [ | 148 | _keyOrder: [ |
129 | - 'openBracket', 'closeBracket', '1', '0' | 149 | + 'openBracket', 'closeBracket', '1', '2', '3', '4', '0' |
130 | ] | 150 | ] |
131 | }, | 151 | }, |
132 | hooks: { | 152 | hooks: { |
... | @@ -145,6 +165,9 @@ | ... | @@ -145,6 +165,9 @@ |
145 | }, | 165 | }, |
146 | single: function (data) { | 166 | single: function (data) { |
147 | selectionCallback(data); | 167 | selectionCallback(data); |
168 | + }, | ||
169 | + multi: function (selectOrder) { | ||
170 | + selectionCallback(selectOrder); | ||
148 | } | 171 | } |
149 | } | 172 | } |
150 | }; | 173 | }; | ... | ... |
... | @@ -21,6 +21,7 @@ | ... | @@ -21,6 +21,7 @@ |
21 | <groupId>org.onosproject</groupId> | 21 | <groupId>org.onosproject</groupId> |
22 | <artifactId>onos-apps</artifactId> | 22 | <artifactId>onos-apps</artifactId> |
23 | <version>1.6.0-SNAPSHOT</version> | 23 | <version>1.6.0-SNAPSHOT</version> |
24 | + <relativePath>../pom.xml</relativePath> | ||
24 | </parent> | 25 | </parent> |
25 | <modelVersion>4.0.0</modelVersion> | 26 | <modelVersion>4.0.0</modelVersion> |
26 | 27 | ... | ... |
protocols/bgp/api/pom.xml
100755 → 100644
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | <groupId>org.onosproject</groupId> | 23 | <groupId>org.onosproject</groupId> |
24 | <artifactId>onos-bgp</artifactId> | 24 | <artifactId>onos-bgp</artifactId> |
25 | <version>1.6.0-SNAPSHOT</version> | 25 | <version>1.6.0-SNAPSHOT</version> |
26 | + <relativePath>../pom.xml</relativePath> | ||
26 | </parent> | 27 | </parent> |
27 | 28 | ||
28 | <artifactId>onos-bgp-api</artifactId> | 29 | <artifactId>onos-bgp-api</artifactId> | ... | ... |
protocols/bgp/bgpio/pom.xml
100755 → 100644
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | <groupId>org.onosproject</groupId> | 23 | <groupId>org.onosproject</groupId> |
24 | <artifactId>onos-bgp</artifactId> | 24 | <artifactId>onos-bgp</artifactId> |
25 | <version>1.6.0-SNAPSHOT</version> | 25 | <version>1.6.0-SNAPSHOT</version> |
26 | + <relativePath>../pom.xml</relativePath> | ||
26 | </parent> | 27 | </parent> |
27 | 28 | ||
28 | <artifactId>onos-bgpio</artifactId> | 29 | <artifactId>onos-bgpio</artifactId> | ... | ... |
... | @@ -241,13 +241,12 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg { | ... | @@ -241,13 +241,12 @@ public class BgpUpdateMsgVer4 implements BgpUpdateMsg { |
241 | afi = mpUnReach.afi(); | 241 | afi = mpUnReach.afi(); |
242 | safi = mpUnReach.safi(); | 242 | safi = mpUnReach.safi(); |
243 | } | 243 | } |
244 | + } | ||
244 | 245 | ||
245 | - if ((afi == Constants.AFI_FLOWSPEC_VALUE) && ((safi == Constants.SAFI_FLOWSPEC_VALUE) | 246 | + if ((afi == Constants.AFI_FLOWSPEC_VALUE) || (afi == Constants.AFI_VALUE)) { |
246 | - || (safi == Constants.VPN_SAFI_FLOWSPEC_VALUE))) { | ||
247 | //unfeasible route length | 247 | //unfeasible route length |
248 | cb.writeShort(0); | 248 | cb.writeShort(0); |
249 | } | 249 | } |
250 | - } | ||
251 | 250 | ||
252 | } | 251 | } |
253 | 252 | ... | ... |
... | @@ -171,6 +171,7 @@ public class As4Path implements BgpValueType { | ... | @@ -171,6 +171,7 @@ public class As4Path implements BgpValueType { |
171 | if ((as4pathSet != null) && (as4pathSeq != null)) { | 171 | if ((as4pathSet != null) && (as4pathSeq != null)) { |
172 | int iAsLenIndex = cb.writerIndex(); | 172 | int iAsLenIndex = cb.writerIndex(); |
173 | cb.writeByte(0); | 173 | cb.writeByte(0); |
174 | + if (as4pathSeq.size() != 0) { | ||
174 | cb.writeByte(AsPath.ASPATH_SEQ_TYPE); | 175 | cb.writeByte(AsPath.ASPATH_SEQ_TYPE); |
175 | cb.writeByte(as4pathSeq.size()); | 176 | cb.writeByte(as4pathSeq.size()); |
176 | 177 | ||
... | @@ -180,6 +181,7 @@ public class As4Path implements BgpValueType { | ... | @@ -180,6 +181,7 @@ public class As4Path implements BgpValueType { |
180 | 181 | ||
181 | int asLen = cb.writerIndex() - iAsLenIndex; | 182 | int asLen = cb.writerIndex() - iAsLenIndex; |
182 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); | 183 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); |
184 | + } | ||
183 | } else { | 185 | } else { |
184 | cb.writeByte(0); | 186 | cb.writeByte(0); |
185 | } | 187 | } | ... | ... |
... | @@ -208,15 +208,16 @@ public class AsPath implements BgpValueType { | ... | @@ -208,15 +208,16 @@ public class AsPath implements BgpValueType { |
208 | if (isaspathSet()) { | 208 | if (isaspathSet()) { |
209 | int iAsLenIndex = cb.writerIndex(); | 209 | int iAsLenIndex = cb.writerIndex(); |
210 | cb.writeByte(0); | 210 | cb.writeByte(0); |
211 | + if (aspathSeq.size() != 0) { | ||
211 | cb.writeByte(ASPATH_SEQ_TYPE); | 212 | cb.writeByte(ASPATH_SEQ_TYPE); |
212 | cb.writeByte(aspathSeq.size()); | 213 | cb.writeByte(aspathSeq.size()); |
213 | 214 | ||
214 | for (int j = 0; j < aspathSeq.size(); j++) { | 215 | for (int j = 0; j < aspathSeq.size(); j++) { |
215 | cb.writeShort(aspathSeq.get(j)); | 216 | cb.writeShort(aspathSeq.get(j)); |
216 | } | 217 | } |
217 | - | ||
218 | int asLen = cb.writerIndex() - iAsLenIndex; | 218 | int asLen = cb.writerIndex() - iAsLenIndex; |
219 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); | 219 | cb.setByte(iAsLenIndex, (byte) (asLen - 1)); |
220 | + } | ||
220 | } else { | 221 | } else { |
221 | cb.writeByte(0); | 222 | cb.writeByte(0); |
222 | } | 223 | } | ... | ... |
... | @@ -106,7 +106,7 @@ public class LinkStateAttributes implements BgpValueType { | ... | @@ -106,7 +106,7 @@ public class LinkStateAttributes implements BgpValueType { |
106 | * | 106 | * |
107 | * @param linkStateAttribList Linked list of Link, Node and Prefix TLVs | 107 | * @param linkStateAttribList Linked list of Link, Node and Prefix TLVs |
108 | */ | 108 | */ |
109 | - LinkStateAttributes(List<BgpValueType> linkStateAttribList) { | 109 | + public LinkStateAttributes(List<BgpValueType> linkStateAttribList) { |
110 | this.linkStateAttribList = linkStateAttribList; | 110 | this.linkStateAttribList = linkStateAttribList; |
111 | this.isLinkStateAttribute = true; | 111 | this.isLinkStateAttribute = true; |
112 | } | 112 | } | ... | ... |
... | @@ -163,7 +163,6 @@ public class WideCommunityAttrHeader implements BgpValueType { | ... | @@ -163,7 +163,6 @@ public class WideCommunityAttrHeader implements BgpValueType { |
163 | c.writeShort(TYPE); | 163 | c.writeShort(TYPE); |
164 | c.writeByte(flag); | 164 | c.writeByte(flag); |
165 | c.writeByte(hopCount); | 165 | c.writeByte(hopCount); |
166 | - c.writeShort(length); | ||
167 | return c.writerIndex() - iLenStartIndex; | 166 | return c.writerIndex() - iLenStartIndex; |
168 | } | 167 | } |
169 | 168 | ... | ... |
... | @@ -97,8 +97,8 @@ public class WideCommunityIpV4Neighbour implements BgpValueType { | ... | @@ -97,8 +97,8 @@ public class WideCommunityIpV4Neighbour implements BgpValueType { |
97 | while (listIterator.hasNext()) { | 97 | while (listIterator.hasNext()) { |
98 | IpV4Neighbour speaker = listIterator.next(); | 98 | IpV4Neighbour speaker = listIterator.next(); |
99 | if (speaker instanceof IpV4Neighbour) { | 99 | if (speaker instanceof IpV4Neighbour) { |
100 | - c.writeInt(Integer.valueOf(speaker.localSpeaker.toString())); | 100 | + c.writeBytes(speaker.localSpeaker().toOctets()); |
101 | - c.writeInt(Integer.valueOf(speaker.remoteSpeaker.toString())); | 101 | + c.writeBytes(speaker.remoteSpeaker().toOctets()); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ... | ... |
... | @@ -96,7 +96,7 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType { | ... | @@ -96,7 +96,7 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType { |
96 | * | 96 | * |
97 | * @return Maximum link bandwidth | 97 | * @return Maximum link bandwidth |
98 | */ | 98 | */ |
99 | - float linkAttrMaxLinkBandwidth() { | 99 | + public float linkAttrMaxLinkBandwidth() { |
100 | return maxBandwidth; | 100 | return maxBandwidth; |
101 | } | 101 | } |
102 | 102 | ... | ... |
... | @@ -43,10 +43,10 @@ import java.util.Objects; | ... | @@ -43,10 +43,10 @@ import java.util.Objects; |
43 | public class WideCommunity implements BgpValueType { | 43 | public class WideCommunity implements BgpValueType { |
44 | 44 | ||
45 | private static final Logger log = LoggerFactory.getLogger(WideCommunity.class); | 45 | private static final Logger log = LoggerFactory.getLogger(WideCommunity.class); |
46 | - public static final byte TYPE = (byte) 254; /* TODO: IANA Assigned */ | 46 | + public static final byte TYPE = (byte) 129; |
47 | public static final short LENGTH = 4; | 47 | public static final short LENGTH = 4; |
48 | public static final byte TYPE_LENGTH_SIZE = 3; | 48 | public static final byte TYPE_LENGTH_SIZE = 3; |
49 | - public static final byte FLAGS = (byte) 0x40; | 49 | + public static final byte FLAGS = (byte) 0x90; |
50 | private WideCommunityAttrHeader wideCommunityHeader; | 50 | private WideCommunityAttrHeader wideCommunityHeader; |
51 | private int community; | 51 | private int community; |
52 | private int localAsn; | 52 | private int localAsn; |
... | @@ -238,6 +238,9 @@ public class WideCommunity implements BgpValueType { | ... | @@ -238,6 +238,9 @@ public class WideCommunity implements BgpValueType { |
238 | 238 | ||
239 | wideCommunityHeader.write(c); | 239 | wideCommunityHeader.write(c); |
240 | 240 | ||
241 | + int iComLengthIndex = c.writerIndex(); | ||
242 | + c.writeShort(0); | ||
243 | + | ||
241 | c.writeInt(community); | 244 | c.writeInt(community); |
242 | c.writeInt(localAsn); | 245 | c.writeInt(localAsn); |
243 | c.writeInt(contextAsn); | 246 | c.writeInt(contextAsn); |
... | @@ -275,6 +278,9 @@ public class WideCommunity implements BgpValueType { | ... | @@ -275,6 +278,9 @@ public class WideCommunity implements BgpValueType { |
275 | c.setShort(iTargetLenIndex, (short) (length - 2)); | 278 | c.setShort(iTargetLenIndex, (short) (length - 2)); |
276 | } | 279 | } |
277 | 280 | ||
281 | + length = c.writerIndex() - iComLengthIndex; | ||
282 | + c.setShort(iComLengthIndex, (short) (length - 2)); | ||
283 | + | ||
278 | length = c.writerIndex() - iLengthIndex; | 284 | length = c.writerIndex() - iLengthIndex; |
279 | c.setShort(iLengthIndex, (short) (length - 2)); | 285 | c.setShort(iLengthIndex, (short) (length - 2)); |
280 | 286 | ... | ... |
protocols/bgp/ctl/pom.xml
100755 → 100644
... | @@ -46,6 +46,11 @@ | ... | @@ -46,6 +46,11 @@ |
46 | <groupId>org.osgi</groupId> | 46 | <groupId>org.osgi</groupId> |
47 | <artifactId>org.osgi.compendium</artifactId> | 47 | <artifactId>org.osgi.compendium</artifactId> |
48 | </dependency> | 48 | </dependency> |
49 | + <dependency> | ||
50 | + <groupId>io.netty</groupId> | ||
51 | + <artifactId>netty-common</artifactId> | ||
52 | + <version>4.0.36.Final</version> | ||
53 | + </dependency> | ||
49 | </dependencies> | 54 | </dependencies> |
50 | 55 | ||
51 | <build> | 56 | <build> | ... | ... |
... | @@ -205,7 +205,7 @@ public class BgpConfig implements BgpCfg { | ... | @@ -205,7 +205,7 @@ public class BgpConfig implements BgpCfg { |
205 | lspeer.setSelfInnitConnection(true); | 205 | lspeer.setSelfInnitConnection(true); |
206 | 206 | ||
207 | if (lspeer.connectPeer() == null) { | 207 | if (lspeer.connectPeer() == null) { |
208 | - connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.getBgpPortNum()); | 208 | + connectPeer = new BgpConnectPeerImpl(bgpController, routerid, Controller.BGP_PORT_NUM); |
209 | lspeer.setConnectPeer(connectPeer); | 209 | lspeer.setConnectPeer(connectPeer); |
210 | connectPeer.connectPeer(); | 210 | connectPeer.connectPeer(); |
211 | } | 211 | } | ... | ... |
protocols/bgp/ctl/src/main/java/org/onosproject/bgp/controller/impl/BgpLocalRibImpl.java
100755 → 100644
... | @@ -135,7 +135,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { | ... | @@ -135,7 +135,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { |
135 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); | 135 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); |
136 | // Compare local RIB entry with the current attribute | 136 | // Compare local RIB entry with the current attribute |
137 | decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib); | 137 | decisionResult = selectionAlgo.compare(nodeTree.get(nodeLsIdentifier), detailsLocRib); |
138 | - if (decisionResult < 0) { | 138 | + if (decisionResult <= 0) { |
139 | for (BgpNodeListener l : bgpController.listener()) { | 139 | for (BgpNodeListener l : bgpController.listener()) { |
140 | l.addNode((BgpNodeLSNlriVer4) nlri, details); | 140 | l.addNode((BgpNodeLSNlriVer4) nlri, details); |
141 | } | 141 | } |
... | @@ -155,7 +155,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { | ... | @@ -155,7 +155,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { |
155 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); | 155 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); |
156 | // Compare local RIB entry with the current attribute | 156 | // Compare local RIB entry with the current attribute |
157 | decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib); | 157 | decisionResult = selectionAlgo.compare(linkTree.get(linkLsIdentifier), detailsLocRib); |
158 | - if (decisionResult < 0) { | 158 | + if (decisionResult <= 0) { |
159 | linkTree.replace(linkLsIdentifier, detailsLocRib); | 159 | linkTree.replace(linkLsIdentifier, detailsLocRib); |
160 | for (BgpLinkListener l : bgpController.linkListener()) { | 160 | for (BgpLinkListener l : bgpController.linkListener()) { |
161 | l.addLink((BgpLinkLsNlriVer4) nlri, details); | 161 | l.addLink((BgpLinkLsNlriVer4) nlri, details); |
... | @@ -175,7 +175,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { | ... | @@ -175,7 +175,7 @@ public class BgpLocalRibImpl implements BgpLocalRib { |
175 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); | 175 | BgpSelectionAlgo selectionAlgo = new BgpSelectionAlgo(); |
176 | // Compare local RIB entry with the current attribute | 176 | // Compare local RIB entry with the current attribute |
177 | decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib); | 177 | decisionResult = selectionAlgo.compare(prefixTree.get(prefixIdentifier), detailsLocRib); |
178 | - if (decisionResult < 0) { | 178 | + if (decisionResult <= 0) { |
179 | prefixTree.replace(prefixIdentifier, detailsLocRib); | 179 | prefixTree.replace(prefixIdentifier, detailsLocRib); |
180 | log.debug("Local RIB update prefix: {}", detailsLocRib.toString()); | 180 | log.debug("Local RIB update prefix: {}", detailsLocRib.toString()); |
181 | } | 181 | } | ... | ... |
... | @@ -159,6 +159,7 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -159,6 +159,7 @@ public class BgpPeerImpl implements BgpPeer { |
159 | * Send flow specification update message to peer. | 159 | * Send flow specification update message to peer. |
160 | * | 160 | * |
161 | * @param operType operation type | 161 | * @param operType operation type |
162 | + * @param routeKey flow rule key | ||
162 | * @param flowSpec flow specification details | 163 | * @param flowSpec flow specification details |
163 | * @param wideCommunity for route policy | 164 | * @param wideCommunity for route policy |
164 | */ | 165 | */ |
... | @@ -167,7 +168,7 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -167,7 +168,7 @@ public class BgpPeerImpl implements BgpPeer { |
167 | 168 | ||
168 | List<BgpValueType> attributesList = new LinkedList<>(); | 169 | List<BgpValueType> attributesList = new LinkedList<>(); |
169 | byte sessionType = sessionInfo.isIbgpSession() ? (byte) 0 : (byte) 1; | 170 | byte sessionType = sessionInfo.isIbgpSession() ? (byte) 0 : (byte) 1; |
170 | - byte sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE; | 171 | + byte sAfi = Constants.SAFI_FLOWSPEC_VALUE; |
171 | 172 | ||
172 | boolean isFsCapabilitySet = isCapabilitySupported(MultiProtocolExtnCapabilityTlv.TYPE, | 173 | boolean isFsCapabilitySet = isCapabilitySupported(MultiProtocolExtnCapabilityTlv.TYPE, |
173 | Constants.AFI_FLOWSPEC_VALUE, | 174 | Constants.AFI_FLOWSPEC_VALUE, |
... | @@ -190,10 +191,10 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -190,10 +191,10 @@ public class BgpPeerImpl implements BgpPeer { |
190 | return; | 191 | return; |
191 | } | 192 | } |
192 | 193 | ||
193 | - if ((wideCommunity != null) && (isVpnRpdCapabilitySet)) { | 194 | + if (isVpnFsCapabilitySet) { |
194 | - sAfi = Constants.VPN_SAFI_FLOWSPEC_RDP_VALUE; | ||
195 | - } else if (isVpnFsCapabilitySet) { | ||
196 | sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE; | 195 | sAfi = Constants.VPN_SAFI_FLOWSPEC_VALUE; |
196 | + } else if (isVpnRpdCapabilitySet) { | ||
197 | + sAfi = Constants.VPN_SAFI_FLOWSPEC_RDP_VALUE; | ||
197 | } | 198 | } |
198 | attributesList.add(new Origin((byte) 0)); | 199 | attributesList.add(new Origin((byte) 0)); |
199 | 200 | ||
... | @@ -222,7 +223,9 @@ public class BgpPeerImpl implements BgpPeer { | ... | @@ -222,7 +223,9 @@ public class BgpPeerImpl implements BgpPeer { |
222 | } | 223 | } |
223 | 224 | ||
224 | attributesList.add(new BgpExtendedCommunity(flowSpec.fsActionTlv())); | 225 | attributesList.add(new BgpExtendedCommunity(flowSpec.fsActionTlv())); |
226 | + if (wideCommunity != null) { | ||
225 | attributesList.add(wideCommunity); | 227 | attributesList.add(wideCommunity); |
228 | + } | ||
226 | 229 | ||
227 | if (operType == FlowSpecOperation.ADD) { | 230 | if (operType == FlowSpecOperation.ADD) { |
228 | attributesList.add(new MpReachNlri(flowSpec, Constants.AFI_FLOWSPEC_VALUE, sAfi)); | 231 | attributesList.add(new MpReachNlri(flowSpec, Constants.AFI_FLOWSPEC_VALUE, sAfi)); | ... | ... |
... | @@ -16,7 +16,7 @@ | ... | @@ -16,7 +16,7 @@ |
16 | package org.onosproject.bgp.controller.impl; | 16 | package org.onosproject.bgp.controller.impl; |
17 | 17 | ||
18 | import static org.onlab.util.Tools.groupedThreads; | 18 | import static org.onlab.util.Tools.groupedThreads; |
19 | - | 19 | +import io.netty.util.internal.PlatformDependent; |
20 | import java.lang.management.ManagementFactory; | 20 | import java.lang.management.ManagementFactory; |
21 | import java.lang.management.RuntimeMXBean; | 21 | import java.lang.management.RuntimeMXBean; |
22 | import java.net.InetSocketAddress; | 22 | import java.net.InetSocketAddress; |
... | @@ -53,9 +53,11 @@ public class Controller { | ... | @@ -53,9 +53,11 @@ public class Controller { |
53 | public Channel serverChannel; | 53 | public Channel serverChannel; |
54 | 54 | ||
55 | // Configuration options | 55 | // Configuration options |
56 | - private static final short BGP_PORT_NUM = 179; | 56 | + protected static final short BGP_PORT_NUM = 179; |
57 | + private static final short BGP_PRIVILEGED_PORT = 1790; // server port used for non root users in linux | ||
57 | private static final short PORT_NUM_ZERO = 0; | 58 | private static final short PORT_NUM_ZERO = 0; |
58 | private static boolean isPortNumSet = false; | 59 | private static boolean isPortNumSet = false; |
60 | + private static short portNumber = BGP_PORT_NUM; | ||
59 | private final int workerThreads = 16; | 61 | private final int workerThreads = 16; |
60 | private final int peerWorkerThreads = 16; | 62 | private final int peerWorkerThreads = 16; |
61 | 63 | ||
... | @@ -219,6 +221,11 @@ public class Controller { | ... | @@ -219,6 +221,11 @@ public class Controller { |
219 | */ | 221 | */ |
220 | public void start() { | 222 | public void start() { |
221 | log.info("Started"); | 223 | log.info("Started"); |
224 | + if (!PlatformDependent.isWindows() && !PlatformDependent.isRoot()) { | ||
225 | + portNumber = BGP_PRIVILEGED_PORT; | ||
226 | + } else { | ||
227 | + portNumber = BGP_PORT_NUM; | ||
228 | + } | ||
222 | this.init(); | 229 | this.init(); |
223 | this.run(); | 230 | this.run(); |
224 | } | 231 | } |
... | @@ -242,7 +249,8 @@ public class Controller { | ... | @@ -242,7 +249,8 @@ public class Controller { |
242 | if (isPortNumSet) { | 249 | if (isPortNumSet) { |
243 | return PORT_NUM_ZERO; | 250 | return PORT_NUM_ZERO; |
244 | } | 251 | } |
245 | - return BGP_PORT_NUM; | 252 | + |
253 | + return portNumber; | ||
246 | } | 254 | } |
247 | 255 | ||
248 | /** | 256 | /** | ... | ... |
1 | COMPILE_DEPS = [ | 1 | COMPILE_DEPS = [ |
2 | '//lib:CORE_DEPS', | 2 | '//lib:CORE_DEPS', |
3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', | 3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', |
4 | + '//apps/pcep-api:onos-apps-pcep-api', | ||
5 | + '//incubator/api:onos-incubator-api', | ||
4 | ] | 6 | ] |
5 | 7 | ||
6 | osgi_jar_with_tests ( | 8 | osgi_jar_with_tests ( | ... | ... |
... | @@ -23,6 +23,7 @@ | ... | @@ -23,6 +23,7 @@ |
23 | <groupId>org.onosproject</groupId> | 23 | <groupId>org.onosproject</groupId> |
24 | <artifactId>onos-pcep-controller</artifactId> | 24 | <artifactId>onos-pcep-controller</artifactId> |
25 | <version>1.6.0-SNAPSHOT</version> | 25 | <version>1.6.0-SNAPSHOT</version> |
26 | + <relativePath>../pom.xml</relativePath> | ||
26 | </parent> | 27 | </parent> |
27 | 28 | ||
28 | <artifactId>onos-pcep-controller-api</artifactId> | 29 | <artifactId>onos-pcep-controller-api</artifactId> |
... | @@ -51,5 +52,9 @@ | ... | @@ -51,5 +52,9 @@ |
51 | <groupId>org.onosproject</groupId> | 52 | <groupId>org.onosproject</groupId> |
52 | <artifactId>onlab-misc</artifactId> | 53 | <artifactId>onlab-misc</artifactId> |
53 | </dependency> | 54 | </dependency> |
55 | + <dependency> | ||
56 | + <groupId>org.onosproject</groupId> | ||
57 | + <artifactId>onos-incubator-api</artifactId> | ||
58 | + </dependency> | ||
54 | </dependencies> | 59 | </dependencies> |
55 | </project> | 60 | </project> | ... | ... |
... | @@ -26,6 +26,8 @@ public class ClientCapability { | ... | @@ -26,6 +26,8 @@ public class ClientCapability { |
26 | private boolean pceccCapability; | 26 | private boolean pceccCapability; |
27 | private boolean statefulPceCapability; | 27 | private boolean statefulPceCapability; |
28 | private boolean pcInstantiationCapability; | 28 | private boolean pcInstantiationCapability; |
29 | + private boolean labelStackCapability; | ||
30 | + private boolean srCapability; | ||
29 | 31 | ||
30 | /** | 32 | /** |
31 | * Creates new instance of client capability. | 33 | * Creates new instance of client capability. |
... | @@ -33,11 +35,34 @@ public class ClientCapability { | ... | @@ -33,11 +35,34 @@ public class ClientCapability { |
33 | * @param pceccCapability represents PCECC capability | 35 | * @param pceccCapability represents PCECC capability |
34 | * @param statefulPceCapability represents stateful PCE capability | 36 | * @param statefulPceCapability represents stateful PCE capability |
35 | * @param pcInstantiationCapability represents PC initiation capability | 37 | * @param pcInstantiationCapability represents PC initiation capability |
38 | + * @param labelStackCapability represents S bit is set in PCECC capability | ||
39 | + * @param srCapability represents SR capability | ||
36 | */ | 40 | */ |
37 | - public ClientCapability(boolean pceccCapability, boolean statefulPceCapability, boolean pcInstantiationCapability) { | 41 | + public ClientCapability(boolean pceccCapability, boolean statefulPceCapability, boolean pcInstantiationCapability, |
42 | + boolean labelStackCapability, boolean srCapability) { | ||
38 | this.pceccCapability = pceccCapability; | 43 | this.pceccCapability = pceccCapability; |
39 | this.statefulPceCapability = statefulPceCapability; | 44 | this.statefulPceCapability = statefulPceCapability; |
40 | this.pcInstantiationCapability = pcInstantiationCapability; | 45 | this.pcInstantiationCapability = pcInstantiationCapability; |
46 | + this.labelStackCapability = labelStackCapability; | ||
47 | + this.srCapability = srCapability; | ||
48 | + } | ||
49 | + | ||
50 | + /** | ||
51 | + * Obtains label stack capability. | ||
52 | + * | ||
53 | + * @return true if client supports PCECC capability with S bit set otherwise false | ||
54 | + */ | ||
55 | + public boolean labelStackCapability() { | ||
56 | + return labelStackCapability; | ||
57 | + } | ||
58 | + | ||
59 | + /** | ||
60 | + * Obtains segment routing capability. | ||
61 | + * | ||
62 | + * @return true if client supports SR capability otherwise false | ||
63 | + */ | ||
64 | + public boolean srCapability() { | ||
65 | + return srCapability; | ||
41 | } | 66 | } |
42 | 67 | ||
43 | /** | 68 | /** |
... | @@ -69,7 +94,8 @@ public class ClientCapability { | ... | @@ -69,7 +94,8 @@ public class ClientCapability { |
69 | 94 | ||
70 | @Override | 95 | @Override |
71 | public int hashCode() { | 96 | public int hashCode() { |
72 | - return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability); | 97 | + return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability, labelStackCapability, |
98 | + srCapability); | ||
73 | } | 99 | } |
74 | 100 | ||
75 | @Override | 101 | @Override |
... | @@ -81,7 +107,9 @@ public class ClientCapability { | ... | @@ -81,7 +107,9 @@ public class ClientCapability { |
81 | ClientCapability other = (ClientCapability) obj; | 107 | ClientCapability other = (ClientCapability) obj; |
82 | return Objects.equals(pceccCapability, other.pceccCapability) | 108 | return Objects.equals(pceccCapability, other.pceccCapability) |
83 | && Objects.equals(statefulPceCapability, other.statefulPceCapability) | 109 | && Objects.equals(statefulPceCapability, other.statefulPceCapability) |
84 | - && Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability); | 110 | + && Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability) |
111 | + && Objects.equals(labelStackCapability, other.labelStackCapability) | ||
112 | + && Objects.equals(srCapability, other.srCapability); | ||
85 | } | 113 | } |
86 | return false; | 114 | return false; |
87 | } | 115 | } |
... | @@ -92,6 +120,8 @@ public class ClientCapability { | ... | @@ -92,6 +120,8 @@ public class ClientCapability { |
92 | .add("pceccCapability", pceccCapability) | 120 | .add("pceccCapability", pceccCapability) |
93 | .add("statefulPceCapability", statefulPceCapability) | 121 | .add("statefulPceCapability", statefulPceCapability) |
94 | .add("pcInstantiationCapability", pcInstantiationCapability) | 122 | .add("pcInstantiationCapability", pcInstantiationCapability) |
123 | + .add("labelStackCapability", labelStackCapability) | ||
124 | + .add("srCapability", srCapability) | ||
95 | .toString(); | 125 | .toString(); |
96 | } | 126 | } |
97 | } | 127 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
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.pcep.controller; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import com.google.common.base.MoreObjects; | ||
21 | + | ||
22 | +/** | ||
23 | + * Representation of LSP info, it will be unique for each LSP. | ||
24 | + */ | ||
25 | +public class LspKey { | ||
26 | + private int plspId; | ||
27 | + private short localLspId; | ||
28 | + | ||
29 | + /** | ||
30 | + * Creates new instance of LspInfo. | ||
31 | + * | ||
32 | + * @param plspId LSP id assigned per tunnel per session | ||
33 | + * @param localLspId LSP id assigned per tunnel | ||
34 | + */ | ||
35 | + public LspKey(int plspId, short localLspId) { | ||
36 | + this.plspId = plspId; | ||
37 | + this.localLspId = localLspId; | ||
38 | + } | ||
39 | + | ||
40 | + /** | ||
41 | + * Obtains PLSP id. | ||
42 | + * | ||
43 | + * @return LSP id assigned per tunnel per session | ||
44 | + */ | ||
45 | + public int plspId() { | ||
46 | + return plspId; | ||
47 | + } | ||
48 | + | ||
49 | + /** | ||
50 | + * Obtains local LSP id. | ||
51 | + * | ||
52 | + * @return LSP id assigned per tunnel | ||
53 | + */ | ||
54 | + public short localLspId() { | ||
55 | + return localLspId; | ||
56 | + } | ||
57 | + | ||
58 | + @Override | ||
59 | + public int hashCode() { | ||
60 | + return Objects.hash(plspId, localLspId); | ||
61 | + } | ||
62 | + | ||
63 | + @Override | ||
64 | + public boolean equals(Object obj) { | ||
65 | + if (this == obj) { | ||
66 | + return true; | ||
67 | + } | ||
68 | + | ||
69 | + if (obj instanceof LspKey) { | ||
70 | + LspKey other = (LspKey) obj; | ||
71 | + return Objects.equals(plspId, other.plspId) | ||
72 | + && Objects.equals(localLspId, other.localLspId); | ||
73 | + } | ||
74 | + | ||
75 | + return false; | ||
76 | + } | ||
77 | + | ||
78 | + @Override | ||
79 | + public String toString() { | ||
80 | + return MoreObjects.toStringHelper(getClass()) | ||
81 | + .add("plspId", plspId) | ||
82 | + .add("localLspId", localLspId) | ||
83 | + .toString(); | ||
84 | + } | ||
85 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -19,6 +19,7 @@ import java.util.List; | ... | @@ -19,6 +19,7 @@ import java.util.List; |
19 | 19 | ||
20 | import org.onosproject.pcepio.protocol.PcepFactory; | 20 | import org.onosproject.pcepio.protocol.PcepFactory; |
21 | import org.onosproject.pcepio.protocol.PcepMessage; | 21 | import org.onosproject.pcepio.protocol.PcepMessage; |
22 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
22 | 23 | ||
23 | /** | 24 | /** |
24 | * Represents to provider facing side of a path computation client(pcc). | 25 | * Represents to provider facing side of a path computation client(pcc). |
... | @@ -135,4 +136,64 @@ public interface PcepClient { | ... | @@ -135,4 +136,64 @@ public interface PcepClient { |
135 | * @return capability supported by client | 136 | * @return capability supported by client |
136 | */ | 137 | */ |
137 | ClientCapability capability(); | 138 | ClientCapability capability(); |
139 | + | ||
140 | + /** | ||
141 | + * Adds PCEP device when session is successfully established. | ||
142 | + * | ||
143 | + * @param pc PCEP client details | ||
144 | + */ | ||
145 | + void addNode(PcepClient pc); | ||
146 | + | ||
147 | + /** | ||
148 | + * Removes PCEP device when session is disconnected. | ||
149 | + * | ||
150 | + * @param pccId PCEP client ID | ||
151 | + */ | ||
152 | + void deleteNode(PccId pccId); | ||
153 | + | ||
154 | + /** | ||
155 | + * Sets D flag for the given LSP and its LSP info. | ||
156 | + * | ||
157 | + * @param lspKey contains LSP info | ||
158 | + * @param dFlag delegation flag in LSP object | ||
159 | + */ | ||
160 | + void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag); | ||
161 | + | ||
162 | + /** | ||
163 | + * Returns delegation flag for the given LSP info. | ||
164 | + * | ||
165 | + * @param lspKey contains LSP info | ||
166 | + * @return delegation flag | ||
167 | + */ | ||
168 | + Boolean delegationInfo(LspKey lspKey); | ||
169 | + | ||
170 | + /** | ||
171 | + * Creates a temporary cache to hold report messages received during LSPDB sync. | ||
172 | + * | ||
173 | + * @param pccId PCC id which is the key to store report messages | ||
174 | + */ | ||
175 | + void initializeSyncMsgList(PccId pccId); | ||
176 | + | ||
177 | + /** | ||
178 | + * Returns the list of report messages received during LSPDB sync. | ||
179 | + * | ||
180 | + * @param pccId PCC id which is the key for all the report messages | ||
181 | + * @return list of report messages received during LSPDB sync | ||
182 | + */ | ||
183 | + List<PcepStateReport> getSyncMsgList(PccId pccId); | ||
184 | + | ||
185 | + /** | ||
186 | + * Removes the list of report messages received during LSPDB sync. | ||
187 | + * | ||
188 | + * @param pccId PCC id which is the key for all the report messages | ||
189 | + */ | ||
190 | + void removeSyncMsgList(PccId pccId); | ||
191 | + | ||
192 | + /** | ||
193 | + * Adds report message received during LSPDB sync into temporary cache. | ||
194 | + * | ||
195 | + * @param pccId PCC id which is the key to store report messages | ||
196 | + * @param rptMsg the report message to be stored | ||
197 | + */ | ||
198 | + void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg); | ||
138 | } | 199 | } | ... | ... |
... | @@ -57,7 +57,7 @@ public interface PcepClientController { | ... | @@ -57,7 +57,7 @@ public interface PcepClientController { |
57 | void removeListener(PcepClientListener listener); | 57 | void removeListener(PcepClientListener listener); |
58 | 58 | ||
59 | /** | 59 | /** |
60 | - * Register a listener for OF msg events. | 60 | + * Register a listener for PCEP msg events. |
61 | * | 61 | * |
62 | * @param listener the listener to notify | 62 | * @param listener the listener to notify |
63 | */ | 63 | */ |
... | @@ -71,6 +71,34 @@ public interface PcepClientController { | ... | @@ -71,6 +71,34 @@ public interface PcepClientController { |
71 | void removeEventListener(PcepEventListener listener); | 71 | void removeEventListener(PcepEventListener listener); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | + * Register a listener for PCEP msg events[carrying node descriptor details]. | ||
75 | + * | ||
76 | + * @param listener the listener to notify | ||
77 | + */ | ||
78 | + void addNodeListener(PcepNodeListener listener); | ||
79 | + | ||
80 | + /** | ||
81 | + * Unregister a listener. | ||
82 | + * | ||
83 | + * @param listener the listener to be unregistered | ||
84 | + */ | ||
85 | + void removeNodeListener(PcepNodeListener listener); | ||
86 | + | ||
87 | + /** | ||
88 | + * Register a listener for packet events. | ||
89 | + * | ||
90 | + * @param listener the listener to notify | ||
91 | + */ | ||
92 | + void addPacketListener(PcepPacketListener listener); | ||
93 | + | ||
94 | + /** | ||
95 | + * Unregister a packet listener. | ||
96 | + * | ||
97 | + * @param listener the listener to unregister | ||
98 | + */ | ||
99 | + void removePacketListener(PcepPacketListener listener); | ||
100 | + | ||
101 | + /** | ||
74 | * Send a message to a particular pcc client. | 102 | * Send a message to a particular pcc client. |
75 | * | 103 | * |
76 | * @param pccId the id of the client to send message. | 104 | * @param pccId the id of the client to send message. | ... | ... |
... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.pcep.controller; | 16 | package org.onosproject.pcep.controller; |
17 | 17 | ||
18 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
18 | import org.onosproject.pcepio.protocol.PcepMessage; | 19 | import org.onosproject.pcepio.protocol.PcepMessage; |
19 | /** | 20 | /** |
20 | * Notifies providers about PCEP message events. | 21 | * Notifies providers about PCEP message events. |
... | @@ -28,4 +29,21 @@ public interface PcepEventListener { | ... | @@ -28,4 +29,21 @@ public interface PcepEventListener { |
28 | * @param msg the message | 29 | * @param msg the message |
29 | */ | 30 | */ |
30 | void handleMessage(PccId pccId, PcepMessage msg); | 31 | void handleMessage(PccId pccId, PcepMessage msg); |
32 | + | ||
33 | + /** | ||
34 | + * Handles end of LSPDB sync actions. | ||
35 | + * | ||
36 | + * @param tunnel the tunnel on which action needs to be taken | ||
37 | + * @param endOfSyncAction the action that needs to be taken for the tunnel | ||
38 | + */ | ||
39 | + void handleEndOfSyncAction(Tunnel tunnel, PcepLspSyncAction endOfSyncAction); | ||
40 | + | ||
41 | + /** | ||
42 | + * Handles sending PCEP message to client on end of LSPDB sync. | ||
43 | + * | ||
44 | + * @param pccId id of the pcc | ||
45 | + * @param msg the message to be sent | ||
46 | + * @param endOfSyncAction the action that needs to be taken in the message | ||
47 | + */ | ||
48 | + void handleEndOfSyncAction(PccId pccId, PcepMessage msg, PcepLspSyncAction endOfSyncAction); | ||
31 | } | 49 | } | ... | ... |
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.pcep.controller; | ||
17 | + | ||
18 | +/** | ||
19 | + * Representation of actions to be taken for LSPs on end of LSP-DB sync. | ||
20 | + */ | ||
21 | +public enum PcepLspSyncAction { | ||
22 | + | ||
23 | + /** | ||
24 | + * Specifies that delete message for PCE intiiated tunnel should be sent. | ||
25 | + */ | ||
26 | + SEND_DELETE(0), | ||
27 | + | ||
28 | + /** | ||
29 | + * Specifies that update message should be sent. | ||
30 | + */ | ||
31 | + SEND_UPDATE(1), | ||
32 | + | ||
33 | + /** | ||
34 | + * Specifies that the tunnel should be removed from PCE. | ||
35 | + */ | ||
36 | + REMOVE(2), | ||
37 | + | ||
38 | + /** | ||
39 | + * Specifies that the status of the tunnel should be set as unstable. | ||
40 | + */ | ||
41 | + UNSTABLE(3); | ||
42 | + | ||
43 | + int value; | ||
44 | + | ||
45 | + /** | ||
46 | + * Assigns val with the value for actions to be taken for LSPs on end of LSP-DB sync. | ||
47 | + * | ||
48 | + * @param val sync status | ||
49 | + */ | ||
50 | + PcepLspSyncAction(int val) { | ||
51 | + value = val; | ||
52 | + } | ||
53 | +} |
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.pcep.controller; | ||
17 | + | ||
18 | +/** | ||
19 | + * Notifies providers about PCEP node events. | ||
20 | + */ | ||
21 | +public interface PcepNodeListener { | ||
22 | + | ||
23 | + /** | ||
24 | + * Notifies that the node was added. | ||
25 | + * | ||
26 | + * @param pc PCEP client details | ||
27 | + */ | ||
28 | + void addNode(PcepClient pc); | ||
29 | + | ||
30 | + /** | ||
31 | + * Notifies that the node was removed. | ||
32 | + * | ||
33 | + * @param pccId PCEP client ID | ||
34 | + */ | ||
35 | + void deleteNode(PccId pccId); | ||
36 | +} |
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.pcep.controller; | ||
17 | + | ||
18 | +public interface PcepPacketListener { | ||
19 | + | ||
20 | + void sendPacketIn(PccId pccId); | ||
21 | + | ||
22 | +} |
protocols/pcep/api/src/main/java/org/onosproject/pcep/controller/driver/PcepAgent.java
100755 → 100644
... | @@ -60,4 +60,25 @@ public interface PcepAgent { | ... | @@ -60,4 +60,25 @@ public interface PcepAgent { |
60 | */ | 60 | */ |
61 | void processPcepMessage(PccId pccId, PcepMessage m); | 61 | void processPcepMessage(PccId pccId, PcepMessage m); |
62 | 62 | ||
63 | + /** | ||
64 | + * Adds PCEP device when session is successfully established. | ||
65 | + * | ||
66 | + * @param pc PCEP client details | ||
67 | + */ | ||
68 | + void addNode(PcepClient pc); | ||
69 | + | ||
70 | + /** | ||
71 | + * Removes PCEP device when session is disconnected. | ||
72 | + * | ||
73 | + * @param pccId PCEP client ID | ||
74 | + */ | ||
75 | + void deleteNode(PccId pccId); | ||
76 | + | ||
77 | + /** | ||
78 | + * Analyzes report messages received during LSP DB sync again tunnel store and takes necessary actions. | ||
79 | + * | ||
80 | + * @param pccId the id of pcc client | ||
81 | + * @return success or failure | ||
82 | + */ | ||
83 | + boolean analyzeSyncMsgList(PccId pccId); | ||
63 | } | 84 | } | ... | ... |
... | @@ -2,6 +2,7 @@ COMPILE_DEPS = [ | ... | @@ -2,6 +2,7 @@ COMPILE_DEPS = [ |
2 | '//lib:CORE_DEPS', | 2 | '//lib:CORE_DEPS', |
3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', | 3 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', |
4 | '//protocols/pcep/api:onos-protocols-pcep-api', | 4 | '//protocols/pcep/api:onos-protocols-pcep-api', |
5 | + '//incubator/api:onos-incubator-api', | ||
5 | ] | 6 | ] |
6 | 7 | ||
7 | osgi_jar_with_tests ( | 8 | osgi_jar_with_tests ( | ... | ... |
... | @@ -55,6 +55,7 @@ import org.onosproject.pcepio.protocol.PcepVersion; | ... | @@ -55,6 +55,7 @@ import org.onosproject.pcepio.protocol.PcepVersion; |
55 | import org.onosproject.pcepio.types.IPv4RouterIdOfLocalNodeSubTlv; | 55 | import org.onosproject.pcepio.types.IPv4RouterIdOfLocalNodeSubTlv; |
56 | import org.onosproject.pcepio.types.NodeAttributesTlv; | 56 | import org.onosproject.pcepio.types.NodeAttributesTlv; |
57 | import org.onosproject.pcepio.types.PceccCapabilityTlv; | 57 | import org.onosproject.pcepio.types.PceccCapabilityTlv; |
58 | +import org.onosproject.pcepio.types.SrPceCapabilityTlv; | ||
58 | import org.onosproject.pcepio.types.StatefulPceCapabilityTlv; | 59 | import org.onosproject.pcepio.types.StatefulPceCapabilityTlv; |
59 | import org.onosproject.pcepio.types.PcepErrorDetailInfo; | 60 | import org.onosproject.pcepio.types.PcepErrorDetailInfo; |
60 | import org.onosproject.pcepio.types.PcepValueType; | 61 | import org.onosproject.pcepio.types.PcepValueType; |
... | @@ -260,6 +261,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -260,6 +261,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
260 | disconnectDuplicate(h); | 261 | disconnectDuplicate(h); |
261 | } else { | 262 | } else { |
262 | h.setState(ESTABLISHED); | 263 | h.setState(ESTABLISHED); |
264 | + //Session is established, add a PCEP device | ||
265 | + h.addNode(); | ||
263 | } | 266 | } |
264 | } | 267 | } |
265 | } | 268 | } |
... | @@ -469,6 +472,20 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -469,6 +472,20 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
469 | } | 472 | } |
470 | 473 | ||
471 | /** | 474 | /** |
475 | + * Adds PCEP device once session is established. | ||
476 | + */ | ||
477 | + private void addNode() { | ||
478 | + pc.addNode(pc); | ||
479 | + } | ||
480 | + | ||
481 | + /** | ||
482 | + * Deletes PCEP device when session is disconnected. | ||
483 | + */ | ||
484 | + private void deleteNode() { | ||
485 | + pc.deleteNode(pc.getPccId()); | ||
486 | + } | ||
487 | + | ||
488 | + /** | ||
472 | * Return a string describing this client based on the already available | 489 | * Return a string describing this client based on the already available |
473 | * information (ip address and/or remote socket). | 490 | * information (ip address and/or remote socket). |
474 | * | 491 | * |
... | @@ -523,6 +540,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -523,6 +540,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
523 | boolean pceccCapability = false; | 540 | boolean pceccCapability = false; |
524 | boolean statefulPceCapability = false; | 541 | boolean statefulPceCapability = false; |
525 | boolean pcInstantiationCapability = false; | 542 | boolean pcInstantiationCapability = false; |
543 | + boolean labelStackCapability = false; | ||
544 | + boolean srCapability = false; | ||
526 | 545 | ||
527 | ListIterator<PcepValueType> listIterator = tlvList.listIterator(); | 546 | ListIterator<PcepValueType> listIterator = tlvList.listIterator(); |
528 | while (listIterator.hasNext()) { | 547 | while (listIterator.hasNext()) { |
... | @@ -531,6 +550,9 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -531,6 +550,9 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
531 | switch (tlv.getType()) { | 550 | switch (tlv.getType()) { |
532 | case PceccCapabilityTlv.TYPE: | 551 | case PceccCapabilityTlv.TYPE: |
533 | pceccCapability = true; | 552 | pceccCapability = true; |
553 | + if (((PceccCapabilityTlv) tlv).sBit()) { | ||
554 | + labelStackCapability = true; | ||
555 | + } | ||
534 | break; | 556 | break; |
535 | case StatefulPceCapabilityTlv.TYPE: | 557 | case StatefulPceCapabilityTlv.TYPE: |
536 | statefulPceCapability = true; | 558 | statefulPceCapability = true; |
... | @@ -539,11 +561,15 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -539,11 +561,15 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
539 | pcInstantiationCapability = true; | 561 | pcInstantiationCapability = true; |
540 | } | 562 | } |
541 | break; | 563 | break; |
564 | + case SrPceCapabilityTlv.TYPE: | ||
565 | + srCapability = true; | ||
566 | + break; | ||
542 | default: | 567 | default: |
543 | continue; | 568 | continue; |
544 | } | 569 | } |
545 | } | 570 | } |
546 | - this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability); | 571 | + this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability, |
572 | + labelStackCapability, srCapability); | ||
547 | } | 573 | } |
548 | 574 | ||
549 | /** | 575 | /** |
... | @@ -563,6 +589,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -563,6 +589,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
563 | */ | 589 | */ |
564 | private void sendErrMsgAndCloseChannel() { | 590 | private void sendErrMsgAndCloseChannel() { |
565 | // TODO send error message | 591 | // TODO send error message |
592 | + //Remove PCEP device from topology | ||
593 | + deleteNode(); | ||
566 | channel.close(); | 594 | channel.close(); |
567 | } | 595 | } |
568 | 596 | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -19,13 +19,18 @@ package org.onosproject.pcep.controller.impl; | ... | @@ -19,13 +19,18 @@ package org.onosproject.pcep.controller.impl; |
19 | import java.net.InetSocketAddress; | 19 | import java.net.InetSocketAddress; |
20 | import java.net.SocketAddress; | 20 | import java.net.SocketAddress; |
21 | import java.util.Collections; | 21 | import java.util.Collections; |
22 | +import java.util.HashMap; | ||
23 | +import java.util.LinkedList; | ||
22 | import java.util.List; | 24 | import java.util.List; |
25 | +import java.util.Map; | ||
23 | import java.util.concurrent.RejectedExecutionException; | 26 | import java.util.concurrent.RejectedExecutionException; |
24 | 27 | ||
25 | import org.jboss.netty.channel.Channel; | 28 | import org.jboss.netty.channel.Channel; |
26 | import org.onlab.packet.IpAddress; | 29 | import org.onlab.packet.IpAddress; |
27 | import org.onosproject.pcep.controller.ClientCapability; | 30 | import org.onosproject.pcep.controller.ClientCapability; |
31 | +import org.onosproject.pcep.controller.LspKey; | ||
28 | import org.onosproject.pcep.controller.PccId; | 32 | import org.onosproject.pcep.controller.PccId; |
33 | +import org.onosproject.pcep.controller.PcepClient; | ||
29 | import org.onosproject.pcep.controller.PcepPacketStats; | 34 | import org.onosproject.pcep.controller.PcepPacketStats; |
30 | import org.onosproject.pcep.controller.PcepSyncStatus; | 35 | import org.onosproject.pcep.controller.PcepSyncStatus; |
31 | import org.onosproject.pcep.controller.driver.PcepAgent; | 36 | import org.onosproject.pcep.controller.driver.PcepAgent; |
... | @@ -33,6 +38,7 @@ import org.onosproject.pcep.controller.driver.PcepClientDriver; | ... | @@ -33,6 +38,7 @@ import org.onosproject.pcep.controller.driver.PcepClientDriver; |
33 | import org.onosproject.pcepio.protocol.PcepFactories; | 38 | import org.onosproject.pcepio.protocol.PcepFactories; |
34 | import org.onosproject.pcepio.protocol.PcepFactory; | 39 | import org.onosproject.pcepio.protocol.PcepFactory; |
35 | import org.onosproject.pcepio.protocol.PcepMessage; | 40 | import org.onosproject.pcepio.protocol.PcepMessage; |
41 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
36 | import org.onosproject.pcepio.protocol.PcepVersion; | 42 | import org.onosproject.pcepio.protocol.PcepVersion; |
37 | import org.slf4j.Logger; | 43 | import org.slf4j.Logger; |
38 | import org.slf4j.LoggerFactory; | 44 | import org.slf4j.LoggerFactory; |
... | @@ -66,6 +72,8 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -66,6 +72,8 @@ public class PcepClientImpl implements PcepClientDriver { |
66 | private byte deadTime; | 72 | private byte deadTime; |
67 | private byte sessionId; | 73 | private byte sessionId; |
68 | private PcepPacketStatsImpl pktStats; | 74 | private PcepPacketStatsImpl pktStats; |
75 | + private Map<LspKey, Boolean> lspDelegationInfo; | ||
76 | + private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>(); | ||
69 | 77 | ||
70 | @Override | 78 | @Override |
71 | public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) { | 79 | public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) { |
... | @@ -188,7 +196,14 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -188,7 +196,14 @@ public class PcepClientImpl implements PcepClientDriver { |
188 | 196 | ||
189 | @Override | 197 | @Override |
190 | public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { | 198 | public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { |
199 | + | ||
200 | + PcepSyncStatus syncOldStatus = labelDbSyncStatus(); | ||
191 | this.labelDbSyncStatus = syncStatus; | 201 | this.labelDbSyncStatus = syncStatus; |
202 | + | ||
203 | + if ((syncOldStatus == PcepSyncStatus.IN_SYNC) && (syncStatus == PcepSyncStatus.SYNCED)) { | ||
204 | + // Perform end of LSP DB sync actions. | ||
205 | + this.agent.analyzeSyncMsgList(pccId); | ||
206 | + } | ||
192 | } | 207 | } |
193 | 208 | ||
194 | @Override | 209 | @Override |
... | @@ -203,6 +218,16 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -203,6 +218,16 @@ public class PcepClientImpl implements PcepClientDriver { |
203 | } | 218 | } |
204 | 219 | ||
205 | @Override | 220 | @Override |
221 | + public void addNode(PcepClient pc) { | ||
222 | + this.agent.addNode(pc); | ||
223 | + } | ||
224 | + | ||
225 | + @Override | ||
226 | + public void deleteNode(PccId pccId) { | ||
227 | + this.agent.deleteNode(pccId); | ||
228 | + } | ||
229 | + | ||
230 | + @Override | ||
206 | public final boolean connectClient() { | 231 | public final boolean connectClient() { |
207 | return this.agent.addConnectedClient(pccId, this); | 232 | return this.agent.addConnectedClient(pccId, this); |
208 | } | 233 | } |
... | @@ -230,6 +255,39 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -230,6 +255,39 @@ public class PcepClientImpl implements PcepClientDriver { |
230 | } | 255 | } |
231 | 256 | ||
232 | @Override | 257 | @Override |
258 | + public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) { | ||
259 | + lspDelegationInfo.put(lspKey, dFlag); | ||
260 | + } | ||
261 | + | ||
262 | + @Override | ||
263 | + public Boolean delegationInfo(LspKey lspKey) { | ||
264 | + return lspDelegationInfo.get(lspKey); | ||
265 | + } | ||
266 | + | ||
267 | + @Override | ||
268 | + public void initializeSyncMsgList(PccId pccId) { | ||
269 | + List<PcepStateReport> rptMsgList = new LinkedList<>(); | ||
270 | + sycRptCache.put(pccId, rptMsgList); | ||
271 | + } | ||
272 | + | ||
273 | + @Override | ||
274 | + public List<PcepStateReport> getSyncMsgList(PccId pccId) { | ||
275 | + return sycRptCache.get(pccId); | ||
276 | + } | ||
277 | + | ||
278 | + @Override | ||
279 | + public void removeSyncMsgList(PccId pccId) { | ||
280 | + sycRptCache.remove(pccId); | ||
281 | + } | ||
282 | + | ||
283 | + @Override | ||
284 | + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) { | ||
285 | + List<PcepStateReport> rptMsgList = sycRptCache.get(pccId); | ||
286 | + rptMsgList.add(rptMsg); | ||
287 | + sycRptCache.put(pccId, rptMsgList); | ||
288 | + } | ||
289 | + | ||
290 | + @Override | ||
233 | public boolean isOptical() { | 291 | public boolean isOptical() { |
234 | return false; | 292 | return false; |
235 | } | 293 | } | ... | ... |
... | @@ -13,7 +13,7 @@ | ... | @@ -13,7 +13,7 @@ |
13 | * See the License for the specific language governing permissions and | 13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. | 14 | * limitations under the License. |
15 | */ | 15 | */ |
16 | -package org.onosproject.provider.pcep.tunnel.impl; | 16 | +package org.onosproject.pcep.controller.impl; |
17 | 17 | ||
18 | import org.onosproject.incubator.net.tunnel.Tunnel.State; | 18 | import org.onosproject.incubator.net.tunnel.Tunnel.State; |
19 | 19 | ||
... | @@ -51,6 +51,7 @@ public enum PcepLspStatus { | ... | @@ -51,6 +51,7 @@ public enum PcepLspStatus { |
51 | * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state. | 51 | * Returns the applicable PCEP LSP status corresponding to ONOS tunnel state. |
52 | * | 52 | * |
53 | * @param tunnelState ONOS tunnel state | 53 | * @param tunnelState ONOS tunnel state |
54 | + * @return LSP status as per protocol | ||
54 | */ | 55 | */ |
55 | public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) { | 56 | public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) { |
56 | 57 | ||
... | @@ -76,6 +77,7 @@ public enum PcepLspStatus { | ... | @@ -76,6 +77,7 @@ public enum PcepLspStatus { |
76 | * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status. | 77 | * Returns the applicable ONOS tunnel state corresponding to PCEP LSP status. |
77 | * | 78 | * |
78 | * @param lspState PCEP LSP status | 79 | * @param lspState PCEP LSP status |
80 | + * @return tunnel state | ||
79 | */ | 81 | */ |
80 | public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) { | 82 | public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) { |
81 | 83 | ... | ... |
protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepBandwidthObject.java
100755 → 100644
... | @@ -29,14 +29,14 @@ public interface PcepBandwidthObject { | ... | @@ -29,14 +29,14 @@ public interface PcepBandwidthObject { |
29 | * | 29 | * |
30 | * @return bandwidth value | 30 | * @return bandwidth value |
31 | */ | 31 | */ |
32 | - int getBandwidth(); | 32 | + float getBandwidth(); |
33 | 33 | ||
34 | /** | 34 | /** |
35 | * Sets bandwidth with specified value. | 35 | * Sets bandwidth with specified value. |
36 | * | 36 | * |
37 | * @param iBandwidth Bandwidth's value | 37 | * @param iBandwidth Bandwidth's value |
38 | */ | 38 | */ |
39 | - void setBandwidth(int iBandwidth); | 39 | + void setBandwidth(float iBandwidth); |
40 | 40 | ||
41 | /** | 41 | /** |
42 | * Writes the BandwidthObject into channel buffer. | 42 | * Writes the BandwidthObject into channel buffer. | ... | ... |
... | @@ -51,6 +51,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -51,6 +51,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
51 | public static final byte BANDWIDTH_OBJ_TYPE = 1; | 51 | public static final byte BANDWIDTH_OBJ_TYPE = 1; |
52 | public static final byte BANDWIDTH_OBJ_CLASS = 5; | 52 | public static final byte BANDWIDTH_OBJ_CLASS = 5; |
53 | public static final byte BANDWIDTH_OBJECT_VERSION = 1; | 53 | public static final byte BANDWIDTH_OBJECT_VERSION = 1; |
54 | + public static final int NO_OF_BITS = 8; | ||
54 | public static final short BANDWIDTH_OBJ_MINIMUM_LENGTH = 8; | 55 | public static final short BANDWIDTH_OBJ_MINIMUM_LENGTH = 8; |
55 | 56 | ||
56 | static final PcepObjectHeader DEFAULT_BANDWIDTH_OBJECT_HEADER = new PcepObjectHeader(BANDWIDTH_OBJ_CLASS, | 57 | static final PcepObjectHeader DEFAULT_BANDWIDTH_OBJECT_HEADER = new PcepObjectHeader(BANDWIDTH_OBJ_CLASS, |
... | @@ -58,7 +59,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -58,7 +59,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
58 | BANDWIDTH_OBJ_MINIMUM_LENGTH); | 59 | BANDWIDTH_OBJ_MINIMUM_LENGTH); |
59 | 60 | ||
60 | private PcepObjectHeader bandwidthObjHeader; | 61 | private PcepObjectHeader bandwidthObjHeader; |
61 | - private int iBandwidth; | 62 | + private float iBandwidth; |
62 | 63 | ||
63 | /** | 64 | /** |
64 | * Constructor to bandwidth object header and bandwidth. | 65 | * Constructor to bandwidth object header and bandwidth. |
... | @@ -66,7 +67,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -66,7 +67,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
66 | * @param bandwidthObjHeader bandwidth object header | 67 | * @param bandwidthObjHeader bandwidth object header |
67 | * @param iBandwidth bandwidth value | 68 | * @param iBandwidth bandwidth value |
68 | */ | 69 | */ |
69 | - public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, int iBandwidth) { | 70 | + public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, float iBandwidth) { |
70 | this.bandwidthObjHeader = bandwidthObjHeader; | 71 | this.bandwidthObjHeader = bandwidthObjHeader; |
71 | this.iBandwidth = iBandwidth; | 72 | this.iBandwidth = iBandwidth; |
72 | } | 73 | } |
... | @@ -76,7 +77,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -76,7 +77,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
76 | * | 77 | * |
77 | * @param iBandwidth bandwidth value | 78 | * @param iBandwidth bandwidth value |
78 | */ | 79 | */ |
79 | - public PcepBandwidthObjectVer1(int iBandwidth) { | 80 | + public PcepBandwidthObjectVer1(float iBandwidth) { |
80 | this.bandwidthObjHeader = DEFAULT_BANDWIDTH_OBJECT_HEADER; | 81 | this.bandwidthObjHeader = DEFAULT_BANDWIDTH_OBJECT_HEADER; |
81 | this.iBandwidth = iBandwidth; | 82 | this.iBandwidth = iBandwidth; |
82 | } | 83 | } |
... | @@ -100,12 +101,12 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -100,12 +101,12 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
100 | } | 101 | } |
101 | 102 | ||
102 | @Override | 103 | @Override |
103 | - public int getBandwidth() { | 104 | + public float getBandwidth() { |
104 | return this.iBandwidth; | 105 | return this.iBandwidth; |
105 | } | 106 | } |
106 | 107 | ||
107 | @Override | 108 | @Override |
108 | - public void setBandwidth(int iBandwidth) { | 109 | + public void setBandwidth(float iBandwidth) { |
109 | this.iBandwidth = iBandwidth; | 110 | this.iBandwidth = iBandwidth; |
110 | } | 111 | } |
111 | 112 | ||
... | @@ -119,12 +120,25 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -119,12 +120,25 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
119 | public static PcepBandwidthObject read(ChannelBuffer cb) throws PcepParseException { | 120 | public static PcepBandwidthObject read(ChannelBuffer cb) throws PcepParseException { |
120 | 121 | ||
121 | PcepObjectHeader bandwidthObjHeader; | 122 | PcepObjectHeader bandwidthObjHeader; |
122 | - int iBandwidth; | 123 | + float bandwidth; |
123 | 124 | ||
124 | bandwidthObjHeader = PcepObjectHeader.read(cb); | 125 | bandwidthObjHeader = PcepObjectHeader.read(cb); |
125 | - iBandwidth = cb.readInt(); | 126 | + bandwidth = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS; |
126 | 127 | ||
127 | - return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth); | 128 | + return new PcepBandwidthObjectVer1(bandwidthObjHeader, bandwidth); |
129 | + } | ||
130 | + | ||
131 | + /** | ||
132 | + * Parse the IEEE floating point notation and returns it in normal float. | ||
133 | + * | ||
134 | + * @param iVal IEEE floating point number | ||
135 | + * @return normal float | ||
136 | + */ | ||
137 | + public static float ieeeToFloatRead(int iVal) { | ||
138 | + iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8) | ||
139 | + | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF)); | ||
140 | + | ||
141 | + return Float.intBitsToFloat(iVal); | ||
128 | } | 142 | } |
129 | 143 | ||
130 | @Override | 144 | @Override |
... | @@ -138,7 +152,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -138,7 +152,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
138 | throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex); | 152 | throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex); |
139 | } | 153 | } |
140 | 154 | ||
141 | - cb.writeInt(iBandwidth); | 155 | + cb.writeInt(Float.floatToIntBits(iBandwidth)); |
142 | short hLength = (short) (cb.writerIndex() - objStartIndex); | 156 | short hLength = (short) (cb.writerIndex() - objStartIndex); |
143 | cb.setShort(objLenIndex, hLength); | 157 | cb.setShort(objLenIndex, hLength); |
144 | //will be helpful during print(). | 158 | //will be helpful during print(). | ... | ... |
... | @@ -16,8 +16,10 @@ | ... | @@ -16,8 +16,10 @@ |
16 | 16 | ||
17 | package org.onosproject.pcepio.protocol.ver1; | 17 | package org.onosproject.pcepio.protocol.ver1; |
18 | 18 | ||
19 | +import java.util.Iterator; | ||
19 | import java.util.LinkedList; | 20 | import java.util.LinkedList; |
20 | import java.util.ListIterator; | 21 | import java.util.ListIterator; |
22 | +import java.util.Objects; | ||
21 | 23 | ||
22 | import org.jboss.netty.buffer.ChannelBuffer; | 24 | import org.jboss.netty.buffer.ChannelBuffer; |
23 | import org.onosproject.pcepio.exceptions.PcepParseException; | 25 | import org.onosproject.pcepio.exceptions.PcepParseException; |
... | @@ -399,10 +401,47 @@ public class PcepEroObjectVer1 implements PcepEroObject { | ... | @@ -399,10 +401,47 @@ public class PcepEroObjectVer1 implements PcepEroObject { |
399 | } | 401 | } |
400 | 402 | ||
401 | @Override | 403 | @Override |
404 | + public int hashCode() { | ||
405 | + return Objects.hash(eroObjHeader, subObjectList); | ||
406 | + } | ||
407 | + | ||
408 | + @Override | ||
402 | public String toString() { | 409 | public String toString() { |
403 | return MoreObjects.toStringHelper(getClass()).omitNullValues() | 410 | return MoreObjects.toStringHelper(getClass()).omitNullValues() |
404 | .add("EroObjHeader", eroObjHeader) | 411 | .add("EroObjHeader", eroObjHeader) |
405 | .add("SubObjects", subObjectList) | 412 | .add("SubObjects", subObjectList) |
406 | .toString(); | 413 | .toString(); |
407 | } | 414 | } |
415 | + | ||
416 | + @Override | ||
417 | + public boolean equals(Object obj) { | ||
418 | + if (this == obj) { | ||
419 | + return true; | ||
420 | + } | ||
421 | + | ||
422 | + if (obj instanceof PcepEroObjectVer1) { | ||
423 | + int countObjSubTlv = 0; | ||
424 | + int countOtherSubTlv = 0; | ||
425 | + boolean isCommonSubTlv = true; | ||
426 | + PcepEroObjectVer1 other = (PcepEroObjectVer1) obj; | ||
427 | + Iterator<PcepValueType> objListIterator = other.subObjectList.iterator(); | ||
428 | + countOtherSubTlv = other.subObjectList.size(); | ||
429 | + countObjSubTlv = subObjectList.size(); | ||
430 | + if (countObjSubTlv != countOtherSubTlv) { | ||
431 | + return false; | ||
432 | + } else { | ||
433 | + while (objListIterator.hasNext() && isCommonSubTlv) { | ||
434 | + PcepValueType subTlv = objListIterator.next(); | ||
435 | + if (subObjectList.contains(subTlv)) { | ||
436 | + isCommonSubTlv = Objects.equals(subObjectList.get(subObjectList.indexOf(subTlv)), | ||
437 | + other.subObjectList.get(other.subObjectList.indexOf(subTlv))); | ||
438 | + } else { | ||
439 | + isCommonSubTlv = false; | ||
440 | + } | ||
441 | + } | ||
442 | + return isCommonSubTlv && Objects.equals(eroObjHeader, other.eroObjHeader); | ||
443 | + } | ||
444 | + } | ||
445 | + return false; | ||
446 | + } | ||
408 | } | 447 | } | ... | ... |
... | @@ -57,6 +57,10 @@ public class PcepMetricObjectVer1 implements PcepMetricObject { | ... | @@ -57,6 +57,10 @@ public class PcepMetricObjectVer1 implements PcepMetricObject { |
57 | public static final int BFLAG_RESET = 0; | 57 | public static final int BFLAG_RESET = 0; |
58 | public static final byte CFLAG_CHECK = 0x02; | 58 | public static final byte CFLAG_CHECK = 0x02; |
59 | 59 | ||
60 | + public static final byte IGP_METRIC = 0x01; | ||
61 | + public static final byte TE_METRIC = 0x02; | ||
62 | + public static final byte HOP_COUNT_METRIC = 0x03; | ||
63 | + | ||
60 | static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS, | 64 | static final PcepObjectHeader DEFAULT_METRIC_OBJECT_HEADER = new PcepObjectHeader(METRIC_OBJ_CLASS, |
61 | METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, | 65 | METRIC_OBJ_TYPE, PcepObjectHeader.REQ_OBJ_OPTIONAL_PROCESS, PcepObjectHeader.RSP_OBJ_PROCESSED, |
62 | METRIC_OBJ_MINIMUM_LENGTH); | 66 | METRIC_OBJ_MINIMUM_LENGTH); | ... | ... |
... | @@ -16,6 +16,8 @@ | ... | @@ -16,6 +16,8 @@ |
16 | 16 | ||
17 | package org.onosproject.pcepio.types; | 17 | package org.onosproject.pcepio.types; |
18 | 18 | ||
19 | +import java.util.Objects; | ||
20 | + | ||
19 | import org.jboss.netty.buffer.ChannelBuffer; | 21 | import org.jboss.netty.buffer.ChannelBuffer; |
20 | import org.slf4j.Logger; | 22 | import org.slf4j.Logger; |
21 | import org.slf4j.LoggerFactory; | 23 | import org.slf4j.LoggerFactory; |
... | @@ -212,6 +214,27 @@ public class PcepObjectHeader { | ... | @@ -212,6 +214,27 @@ public class PcepObjectHeader { |
212 | } | 214 | } |
213 | 215 | ||
214 | @Override | 216 | @Override |
217 | + public int hashCode() { | ||
218 | + return Objects.hash(objClass, objType, bPFlag, bIFlag, objLen); | ||
219 | + } | ||
220 | + | ||
221 | + @Override | ||
222 | + public boolean equals(Object obj) { | ||
223 | + if (this == obj) { | ||
224 | + return true; | ||
225 | + } | ||
226 | + if (obj instanceof PcepObjectHeader) { | ||
227 | + PcepObjectHeader other = (PcepObjectHeader) obj; | ||
228 | + return Objects.equals(objClass, other.objClass) | ||
229 | + && Objects.equals(objType, other.objType) | ||
230 | + && Objects.equals(bPFlag, other.bPFlag) | ||
231 | + && Objects.equals(bIFlag, other.bIFlag) | ||
232 | + && Objects.equals(objLen, other.objLen); | ||
233 | + } | ||
234 | + return false; | ||
235 | + } | ||
236 | + | ||
237 | + @Override | ||
215 | public String toString() { | 238 | public String toString() { |
216 | return MoreObjects.toStringHelper(getClass()) | 239 | return MoreObjects.toStringHelper(getClass()) |
217 | .add("ObjectClass", objClass) | 240 | .add("ObjectClass", objClass) | ... | ... |
providers/bgp/pom.xml
100755 → 100644
... | @@ -40,6 +40,11 @@ | ... | @@ -40,6 +40,11 @@ |
40 | </dependency> | 40 | </dependency> |
41 | <dependency> | 41 | <dependency> |
42 | <groupId>org.onosproject</groupId> | 42 | <groupId>org.onosproject</groupId> |
43 | + <artifactId>onos-incubator-api</artifactId> | ||
44 | + <version>${project.version}</version> | ||
45 | + </dependency> | ||
46 | + <dependency> | ||
47 | + <groupId>org.onosproject</groupId> | ||
43 | <artifactId>onos-api</artifactId> | 48 | <artifactId>onos-api</artifactId> |
44 | <classifier>tests</classifier> | 49 | <classifier>tests</classifier> |
45 | <scope>test</scope> | 50 | <scope>test</scope> | ... | ... |
... | @@ -3,6 +3,7 @@ COMPILE_DEPS = [ | ... | @@ -3,6 +3,7 @@ COMPILE_DEPS = [ |
3 | '//protocols/bgp/api:onos-protocols-bgp-api', | 3 | '//protocols/bgp/api:onos-protocols-bgp-api', |
4 | '//protocols/bgp/bgpio:onos-protocols-bgp-bgpio', | 4 | '//protocols/bgp/bgpio:onos-protocols-bgp-bgpio', |
5 | '//incubator/store:onos-incubator-store', | 5 | '//incubator/store:onos-incubator-store', |
6 | + '//incubator/api:onos-incubator-api', | ||
6 | ] | 7 | ] |
7 | 8 | ||
8 | TEST_DEPS = [ | 9 | TEST_DEPS = [ | ... | ... |
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
providers/pcep/packet/pom.xml
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 | +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
17 | + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
18 | + <modelVersion>4.0.0</modelVersion> | ||
19 | + <parent> | ||
20 | + <groupId>org.onosproject</groupId> | ||
21 | + <artifactId>onos-pcep-providers</artifactId> | ||
22 | + <version>1.6.0-SNAPSHOT</version> | ||
23 | + </parent> | ||
24 | + <artifactId>onos-pcep-provider-packet</artifactId> | ||
25 | + <packaging>bundle</packaging> | ||
26 | + <description>PCEP packet provider</description> | ||
27 | + <dependencies> | ||
28 | + <dependency> | ||
29 | + <groupId>org.onosproject</groupId> | ||
30 | + <artifactId>onos-pcep-controller-api</artifactId> | ||
31 | + </dependency> | ||
32 | + </dependencies> | ||
33 | +</project> |
1 | +package org.onosproject.provider.pcep.packet.impl; | ||
2 | + | ||
3 | +import static org.slf4j.LoggerFactory.getLogger; | ||
4 | + | ||
5 | +import org.apache.felix.scr.annotations.Activate; | ||
6 | +import org.apache.felix.scr.annotations.Component; | ||
7 | +import org.apache.felix.scr.annotations.Deactivate; | ||
8 | +import org.apache.felix.scr.annotations.Reference; | ||
9 | +import org.apache.felix.scr.annotations.ReferenceCardinality; | ||
10 | +import org.apache.felix.scr.annotations.Service; | ||
11 | +import org.onlab.packet.Ethernet; | ||
12 | +import org.onlab.packet.IPv4; | ||
13 | +import org.onlab.packet.TCP; | ||
14 | +import org.onosproject.net.AnnotationKeys; | ||
15 | +import org.onosproject.net.ConnectPoint; | ||
16 | +import org.onosproject.net.Device; | ||
17 | +import org.onosproject.net.DeviceId; | ||
18 | +import org.onosproject.net.PortNumber; | ||
19 | +import org.onosproject.net.device.DeviceService; | ||
20 | +import org.onosproject.net.packet.DefaultInboundPacket; | ||
21 | +import org.onosproject.net.packet.DefaultPacketContext; | ||
22 | +import org.onosproject.net.packet.InboundPacket; | ||
23 | +import org.onosproject.net.packet.OutboundPacket; | ||
24 | +import org.onosproject.net.packet.PacketProvider; | ||
25 | +import org.onosproject.net.packet.PacketProviderRegistry; | ||
26 | +import org.onosproject.net.packet.PacketProviderService; | ||
27 | +import org.onosproject.net.provider.AbstractProvider; | ||
28 | +import org.onosproject.net.provider.ProviderId; | ||
29 | +import org.onosproject.pcep.controller.PccId; | ||
30 | +import org.onosproject.pcep.controller.PcepClientController; | ||
31 | +import org.onosproject.pcep.controller.PcepPacketListener; | ||
32 | +import org.slf4j.Logger; | ||
33 | + | ||
34 | +/** | ||
35 | + * Provider which uses an PCEP controller to process packets. | ||
36 | + */ | ||
37 | +@Component(immediate = true) | ||
38 | +@Service | ||
39 | +public class PcepPacketProvider extends AbstractProvider implements PacketProvider { | ||
40 | + | ||
41 | + private static final Logger log = getLogger(PcepPacketProvider.class); | ||
42 | + static final String PROVIDER_ID = "org.onosproject.provider.packet.pcep"; | ||
43 | + | ||
44 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
45 | + protected PacketProviderRegistry packetProviderRegistry; | ||
46 | + | ||
47 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
48 | + protected PcepClientController pcepClientController; | ||
49 | + | ||
50 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
51 | + protected DeviceService deviceService; | ||
52 | + | ||
53 | + PacketProviderService packetProviderService; | ||
54 | + | ||
55 | + private InnerPacketProvider listener = new InnerPacketProvider(); | ||
56 | + public static final String LSRID = "lsrId"; | ||
57 | + public static final int PCEP_PORT = 4189; | ||
58 | + | ||
59 | + /** | ||
60 | + * Creates a Packet provider. | ||
61 | + */ | ||
62 | + public PcepPacketProvider() { | ||
63 | + super(new ProviderId("pcep", PROVIDER_ID)); | ||
64 | + } | ||
65 | + | ||
66 | + @Activate | ||
67 | + public void activate() { | ||
68 | + packetProviderService = packetProviderRegistry.register(this); | ||
69 | + pcepClientController.addPacketListener(listener); | ||
70 | + log.info("Started"); | ||
71 | + } | ||
72 | + | ||
73 | + @Deactivate | ||
74 | + public void deactivate() { | ||
75 | + packetProviderRegistry.unregister(this); | ||
76 | + pcepClientController.removePacketListener(listener); | ||
77 | + log.info("Stopped"); | ||
78 | + } | ||
79 | + | ||
80 | + private class InnerPacketProvider implements PcepPacketListener { | ||
81 | + @Override | ||
82 | + public void sendPacketIn(PccId pccId) { | ||
83 | + TCP tcp = new TCP(); | ||
84 | + // Set the well known PCEP port. To be used to decide to process/discard the packet while processing. | ||
85 | + tcp.setDestinationPort(PCEP_PORT); | ||
86 | + | ||
87 | + IPv4 ipv4 = new IPv4(); | ||
88 | + ipv4.setProtocol(IPv4.PROTOCOL_TCP); | ||
89 | + ipv4.setPayload(tcp); | ||
90 | + | ||
91 | + Ethernet eth = new Ethernet(); | ||
92 | + eth.setEtherType(Ethernet.TYPE_IPV4); | ||
93 | + eth.setPayload(ipv4); | ||
94 | + | ||
95 | + // Get lsrId of the PCEP client from the PCC ID. Session info is based on lsrID. | ||
96 | + String lsrId = String.valueOf(pccId.ipAddress()); | ||
97 | + DeviceId pccDeviceId = null; | ||
98 | + | ||
99 | + // Find PCC deviceID from lsrId stored as annotations | ||
100 | + Iterable<Device> devices = deviceService.getAvailableDevices(); | ||
101 | + for (Device dev : devices) { | ||
102 | + if ("L3".equals(dev.annotations().value(AnnotationKeys.TYPE)) | ||
103 | + && lsrId.equals(dev.annotations().value(LSRID))) { | ||
104 | + pccDeviceId = dev.id(); | ||
105 | + break; | ||
106 | + } | ||
107 | + } | ||
108 | + | ||
109 | + if (pccDeviceId == null) { | ||
110 | + return; | ||
111 | + } | ||
112 | + | ||
113 | + InboundPacket inPkt = new DefaultInboundPacket(new ConnectPoint(pccDeviceId, | ||
114 | + PortNumber.portNumber(PCEP_PORT)), | ||
115 | + eth, null); | ||
116 | + | ||
117 | + packetProviderService.processPacket(new PcepPacketContext(inPkt, null)); | ||
118 | + } | ||
119 | + } | ||
120 | + | ||
121 | + // Minimal PacketContext to make core and applications happy. | ||
122 | + private final class PcepPacketContext extends DefaultPacketContext { | ||
123 | + private PcepPacketContext(InboundPacket inPkt, OutboundPacket outPkt) { | ||
124 | + super(System.currentTimeMillis(), inPkt, outPkt, false); | ||
125 | + } | ||
126 | + | ||
127 | + @Override | ||
128 | + public void send() { | ||
129 | + // We don't send anything out. | ||
130 | + return; | ||
131 | + } | ||
132 | + } | ||
133 | + | ||
134 | + @Override | ||
135 | + public void emit(OutboundPacket packet) { | ||
136 | + // Nothing to emit | ||
137 | + return; | ||
138 | + | ||
139 | + } | ||
140 | +} |
providers/pcep/packet/src/main/java/org/onosproject/provider/pcep/packet/impl/package-info.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 | + *Provider that uses PCEP controller as a means to send packets. | ||
18 | + */ | ||
19 | +package org.onosproject.provider.pcep.packet.impl; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -27,5 +27,6 @@ | ... | @@ -27,5 +27,6 @@ |
27 | <module>topology</module> | 27 | <module>topology</module> |
28 | <module>tunnel</module> | 28 | <module>tunnel</module> |
29 | <module>app</module> | 29 | <module>app</module> |
30 | + <module>packet</module> | ||
30 | </modules> | 31 | </modules> |
31 | </project> | 32 | </project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -3,6 +3,9 @@ COMPILE_DEPS = [ | ... | @@ -3,6 +3,9 @@ COMPILE_DEPS = [ |
3 | '//protocols/ovsdb/api:onos-protocols-ovsdb-api', | 3 | '//protocols/ovsdb/api:onos-protocols-ovsdb-api', |
4 | '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc', | 4 | '//protocols/ovsdb/rfc:onos-protocols-ovsdb-rfc', |
5 | '//apps/pcep-api:onos-apps-pcep-api', | 5 | '//apps/pcep-api:onos-apps-pcep-api', |
6 | + '//protocols/pcep/api:onos-protocols-pcep-api', | ||
7 | + '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', | ||
8 | + '//core/api:onos-api-tests', | ||
6 | ] | 9 | ] |
7 | 10 | ||
8 | osgi_jar_with_tests ( | 11 | osgi_jar_with_tests ( | ... | ... |
... | @@ -28,5 +28,15 @@ | ... | @@ -28,5 +28,15 @@ |
28 | <groupId>org.onosproject</groupId> | 28 | <groupId>org.onosproject</groupId> |
29 | <artifactId>onos-app-pcep-api</artifactId> | 29 | <artifactId>onos-app-pcep-api</artifactId> |
30 | </dependency> | 30 | </dependency> |
31 | + <dependency> | ||
32 | + <groupId>org.onosproject</groupId> | ||
33 | + <artifactId>onos-pcep-controller-api</artifactId> | ||
34 | + </dependency> | ||
35 | + <dependency> | ||
36 | + <groupId>org.onosproject</groupId> | ||
37 | + <artifactId>onos-api</artifactId> | ||
38 | + <classifier>tests</classifier> | ||
39 | + <scope>test</scope> | ||
40 | + </dependency> | ||
31 | </dependencies> | 41 | </dependencies> |
32 | </project> | 42 | </project> |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -62,6 +62,10 @@ import org.onosproject.pcep.api.PcepLinkListener; | ... | @@ -62,6 +62,10 @@ import org.onosproject.pcep.api.PcepLinkListener; |
62 | import org.onosproject.pcep.api.PcepOperator.OperationType; | 62 | import org.onosproject.pcep.api.PcepOperator.OperationType; |
63 | import org.onosproject.pcep.api.PcepSwitch; | 63 | import org.onosproject.pcep.api.PcepSwitch; |
64 | import org.onosproject.pcep.api.PcepSwitchListener; | 64 | import org.onosproject.pcep.api.PcepSwitchListener; |
65 | +import org.onosproject.pcep.controller.PccId; | ||
66 | +import org.onosproject.pcep.controller.PcepClient; | ||
67 | +import org.onosproject.pcep.controller.PcepClientController; | ||
68 | +import org.onosproject.pcep.controller.PcepNodeListener; | ||
65 | import org.slf4j.Logger; | 69 | import org.slf4j.Logger; |
66 | import org.slf4j.LoggerFactory; | 70 | import org.slf4j.LoggerFactory; |
67 | 71 | ||
... | @@ -115,18 +119,40 @@ public class PcepTopologyProvider extends AbstractProvider | ... | @@ -115,18 +119,40 @@ public class PcepTopologyProvider extends AbstractProvider |
115 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 119 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
116 | protected ClusterService clusterService; | 120 | protected ClusterService clusterService; |
117 | 121 | ||
122 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
123 | + protected PcepClientController pcepClientController; | ||
124 | + | ||
118 | private DeviceProviderService deviceProviderService; | 125 | private DeviceProviderService deviceProviderService; |
119 | private LinkProviderService linkProviderService; | 126 | private LinkProviderService linkProviderService; |
120 | 127 | ||
121 | private HashMap<Long, List<PortDescription>> portMap = new HashMap<>(); | 128 | private HashMap<Long, List<PortDescription>> portMap = new HashMap<>(); |
122 | private InternalLinkProvider listener = new InternalLinkProvider(); | 129 | private InternalLinkProvider listener = new InternalLinkProvider(); |
123 | 130 | ||
131 | + /* | ||
132 | + * For the client supporting SR capability. | ||
133 | + */ | ||
134 | + public static final String SR_CAPABILITY = "srCapability"; | ||
135 | + | ||
136 | + /* | ||
137 | + * For the client supporting PCECC capability. | ||
138 | + */ | ||
139 | + public static final String PCECC_CAPABILITY = "pceccCapability"; | ||
140 | + | ||
141 | + /* | ||
142 | + * For the client supporting label stack capability. | ||
143 | + */ | ||
144 | + public static final String LABEL_STACK_CAPABILITY = "labelStackCapability"; | ||
145 | + | ||
146 | + public static final String LSRID = "lsrId"; | ||
147 | + private static final String UNKNOWN = "unknown"; | ||
148 | + | ||
124 | @Activate | 149 | @Activate |
125 | public void activate() { | 150 | public void activate() { |
126 | linkProviderService = linkProviderRegistry.register(this); | 151 | linkProviderService = linkProviderRegistry.register(this); |
127 | deviceProviderService = deviceProviderRegistry.register(this); | 152 | deviceProviderService = deviceProviderRegistry.register(this); |
128 | controller.addListener(listener); | 153 | controller.addListener(listener); |
129 | controller.addLinkListener(listener); | 154 | controller.addLinkListener(listener); |
155 | + pcepClientController.addNodeListener(listener); | ||
130 | } | 156 | } |
131 | 157 | ||
132 | @Deactivate | 158 | @Deactivate |
... | @@ -135,6 +161,7 @@ public class PcepTopologyProvider extends AbstractProvider | ... | @@ -135,6 +161,7 @@ public class PcepTopologyProvider extends AbstractProvider |
135 | linkProviderService = null; | 161 | linkProviderService = null; |
136 | controller.removeListener(listener); | 162 | controller.removeListener(listener); |
137 | controller.removeLinkListener(listener); | 163 | controller.removeLinkListener(listener); |
164 | + pcepClientController.removeNodeListener(listener); | ||
138 | } | 165 | } |
139 | 166 | ||
140 | private List<PortDescription> buildPortDescriptions(PcepDpid dpid, | 167 | private List<PortDescription> buildPortDescriptions(PcepDpid dpid, |
... | @@ -225,7 +252,7 @@ public class PcepTopologyProvider extends AbstractProvider | ... | @@ -225,7 +252,7 @@ public class PcepTopologyProvider extends AbstractProvider |
225 | } | 252 | } |
226 | 253 | ||
227 | private class InternalLinkProvider | 254 | private class InternalLinkProvider |
228 | - implements PcepSwitchListener, PcepLinkListener { | 255 | + implements PcepSwitchListener, PcepLinkListener, PcepNodeListener { |
229 | 256 | ||
230 | @Override | 257 | @Override |
231 | public void switchAdded(PcepDpid dpid) { | 258 | public void switchAdded(PcepDpid dpid) { |
... | @@ -306,6 +333,51 @@ public class PcepTopologyProvider extends AbstractProvider | ... | @@ -306,6 +333,51 @@ public class PcepTopologyProvider extends AbstractProvider |
306 | } | 333 | } |
307 | } | 334 | } |
308 | 335 | ||
336 | + @Override | ||
337 | + public void addNode(PcepClient pc) { | ||
338 | + if (deviceProviderService == null) { | ||
339 | + return; | ||
340 | + } | ||
341 | + | ||
342 | + //Right now device URI for PCEP devices is their LSRID | ||
343 | + DeviceId deviceId = deviceId(uri(new PcepDpid(pc.getPccId().id().getIp4Address().toInt()))); | ||
344 | + ChassisId cId = new ChassisId(); | ||
345 | + | ||
346 | + Device.Type deviceType = Device.Type.ROUTER; | ||
347 | + | ||
348 | + DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder(); | ||
349 | + //PCC capabilities (SR, PCECC and PCECC-SR) | ||
350 | + annotationBuilder.set(SR_CAPABILITY, String.valueOf(pc.capability().srCapability())); | ||
351 | + annotationBuilder.set(PCECC_CAPABILITY, String.valueOf(pc.capability().pceccCapability())); | ||
352 | + annotationBuilder.set(LABEL_STACK_CAPABILITY, String.valueOf(pc.capability().labelStackCapability())); | ||
353 | + //PccId is the lsrId contained in openMsg, if not present it will be the socket address | ||
354 | + annotationBuilder.set(LSRID, String.valueOf(pc.getPccId().id())); | ||
355 | + | ||
356 | + DeviceDescription description = new DefaultDeviceDescription( | ||
357 | + deviceId.uri(), | ||
358 | + deviceType, | ||
359 | + UNKNOWN, | ||
360 | + UNKNOWN, | ||
361 | + UNKNOWN, | ||
362 | + UNKNOWN, | ||
363 | + cId, | ||
364 | + annotationBuilder.build()); | ||
365 | + | ||
366 | + deviceProviderService.deviceConnected(deviceId, description); | ||
367 | + } | ||
368 | + | ||
369 | + @Override | ||
370 | + public void deleteNode(PccId pccId) { | ||
371 | + if (deviceProviderService == null || deviceService == null) { | ||
372 | + return; | ||
373 | + } | ||
374 | + //TODO: In device manager, in deviceDisconnected() method, get the device but null check is not validated | ||
375 | + if (deviceService.getDevice(DeviceId.deviceId(uri(new PcepDpid(pccId.id() | ||
376 | + .getIp4Address().toInt())))) == null) { | ||
377 | + return; | ||
378 | + } | ||
379 | + deviceProviderService.deviceDisconnected(deviceId(uri(new PcepDpid(pccId.id().getIp4Address().toInt())))); | ||
380 | + } | ||
309 | } | 381 | } |
310 | 382 | ||
311 | @Override | 383 | @Override | ... | ... |
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.topology.impl; | ||
17 | + | ||
18 | +import static org.junit.Assert.assertNotNull; | ||
19 | + | ||
20 | +import java.util.HashMap; | ||
21 | +import java.util.List; | ||
22 | +import java.util.Map; | ||
23 | +import java.util.concurrent.RejectedExecutionException; | ||
24 | + | ||
25 | +import org.jboss.netty.channel.Channel; | ||
26 | +import org.onosproject.pcep.controller.ClientCapability; | ||
27 | +import org.onosproject.pcep.controller.PccId; | ||
28 | +import org.onosproject.pcep.controller.LspKey; | ||
29 | +import org.onosproject.pcep.controller.PcepClient; | ||
30 | +import org.onosproject.pcep.controller.PcepSyncStatus; | ||
31 | +import org.onosproject.pcepio.protocol.PcepFactories; | ||
32 | +import org.onosproject.pcepio.protocol.PcepFactory; | ||
33 | +import org.onosproject.pcepio.protocol.PcepMessage; | ||
34 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
35 | +import org.onosproject.pcepio.protocol.PcepVersion; | ||
36 | + | ||
37 | +/** | ||
38 | + * Representation of PCEP client adapter. | ||
39 | + */ | ||
40 | +public class PcepClientAdapter implements PcepClient { | ||
41 | + | ||
42 | + private Channel channel; | ||
43 | + protected String channelId; | ||
44 | + | ||
45 | + private boolean connected; | ||
46 | + private PccId pccId; | ||
47 | + private ClientCapability capability; | ||
48 | + | ||
49 | + private PcepVersion pcepVersion; | ||
50 | + private PcepSyncStatus lspDbSyncStatus; | ||
51 | + private PcepSyncStatus labelDbSyncStatus; | ||
52 | + private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>(); | ||
53 | + | ||
54 | + /** | ||
55 | + * Initialize instance with specified parameters. | ||
56 | + * | ||
57 | + * @param pccId PCC id | ||
58 | + * @param pcepVersion PCEP message version | ||
59 | + */ | ||
60 | + public void init(PccId pccId, PcepVersion pcepVersion) { | ||
61 | + this.pccId = pccId; | ||
62 | + this.pcepVersion = pcepVersion; | ||
63 | + } | ||
64 | + | ||
65 | + @Override | ||
66 | + public final void disconnectClient() { | ||
67 | + this.channel.close(); | ||
68 | + } | ||
69 | + | ||
70 | + @Override | ||
71 | + public final void sendMessage(PcepMessage m) { | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public final void sendMessage(List<PcepMessage> msgs) { | ||
76 | + try { | ||
77 | + PcepMessage pcepMsg = msgs.get(0); | ||
78 | + assertNotNull("PCEP MSG should be created.", pcepMsg); | ||
79 | + } catch (RejectedExecutionException e) { | ||
80 | + throw e; | ||
81 | + } | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public final boolean isConnected() { | ||
86 | + return this.connected; | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public String channelId() { | ||
91 | + return channelId; | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public final PccId getPccId() { | ||
96 | + return this.pccId; | ||
97 | + }; | ||
98 | + | ||
99 | + @Override | ||
100 | + public final String getStringId() { | ||
101 | + return this.pccId.toString(); | ||
102 | + } | ||
103 | + | ||
104 | + @Override | ||
105 | + public final void handleMessage(PcepMessage m) { | ||
106 | + } | ||
107 | + | ||
108 | + @Override | ||
109 | + public boolean isOptical() { | ||
110 | + return false; | ||
111 | + } | ||
112 | + | ||
113 | + @Override | ||
114 | + public PcepFactory factory() { | ||
115 | + return PcepFactories.getFactory(pcepVersion); | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public void setLspDbSyncStatus(PcepSyncStatus syncStatus) { | ||
120 | + this.lspDbSyncStatus = syncStatus; | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public PcepSyncStatus lspDbSyncStatus() { | ||
125 | + return lspDbSyncStatus; | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
129 | + public void setLabelDbSyncStatus(PcepSyncStatus syncStatus) { | ||
130 | + this.labelDbSyncStatus = syncStatus; | ||
131 | + } | ||
132 | + | ||
133 | + @Override | ||
134 | + public PcepSyncStatus labelDbSyncStatus() { | ||
135 | + return labelDbSyncStatus; | ||
136 | + } | ||
137 | + | ||
138 | + @Override | ||
139 | + public void setCapability(ClientCapability capability) { | ||
140 | + this.capability = capability; | ||
141 | + } | ||
142 | + | ||
143 | + @Override | ||
144 | + public ClientCapability capability() { | ||
145 | + return capability; | ||
146 | + } | ||
147 | + | ||
148 | + @Override | ||
149 | + public void addNode(PcepClient pc) { | ||
150 | + } | ||
151 | + | ||
152 | + @Override | ||
153 | + public void deleteNode(PccId pccId) { | ||
154 | + } | ||
155 | + | ||
156 | + @Override | ||
157 | + public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) { | ||
158 | + lspDelegationInfo.put(lspKey, dFlag); | ||
159 | + } | ||
160 | + | ||
161 | + @Override | ||
162 | + public Boolean delegationInfo(LspKey lspKey) { | ||
163 | + return lspDelegationInfo.get(lspKey); | ||
164 | + } | ||
165 | + | ||
166 | + @Override | ||
167 | + public void initializeSyncMsgList(PccId pccId) { | ||
168 | + // TODO Auto-generated method stub | ||
169 | + | ||
170 | + } | ||
171 | + | ||
172 | + @Override | ||
173 | + public List<PcepStateReport> getSyncMsgList(PccId pccId) { | ||
174 | + // TODO Auto-generated method stub | ||
175 | + return null; | ||
176 | + } | ||
177 | + | ||
178 | + @Override | ||
179 | + public void removeSyncMsgList(PccId pccId) { | ||
180 | + // TODO Auto-generated method stub | ||
181 | + | ||
182 | + } | ||
183 | + | ||
184 | + @Override | ||
185 | + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) { | ||
186 | + // TODO Auto-generated method stub | ||
187 | + | ||
188 | + } | ||
189 | +} |
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.topology.impl; | ||
17 | + | ||
18 | +import java.util.Collection; | ||
19 | +import java.util.Collections; | ||
20 | +import java.util.HashSet; | ||
21 | +import java.util.LinkedList; | ||
22 | +import java.util.Set; | ||
23 | +import java.util.concurrent.ConcurrentHashMap; | ||
24 | + | ||
25 | +import org.apache.felix.scr.annotations.Activate; | ||
26 | +import org.apache.felix.scr.annotations.Deactivate; | ||
27 | +import org.onlab.packet.IpAddress; | ||
28 | +import org.onosproject.pcep.controller.ClientCapability; | ||
29 | +import org.onosproject.pcep.controller.PccId; | ||
30 | +import org.onosproject.pcep.controller.PcepClient; | ||
31 | +import org.onosproject.pcep.controller.PcepClientController; | ||
32 | +import org.onosproject.pcep.controller.PcepClientListener; | ||
33 | +import org.onosproject.pcep.controller.PcepEventListener; | ||
34 | +import org.onosproject.pcep.controller.PcepNodeListener; | ||
35 | +import org.onosproject.pcep.controller.PcepPacketListener; | ||
36 | +import org.onosproject.pcep.controller.driver.PcepAgent; | ||
37 | +import org.onosproject.pcepio.protocol.PcepError; | ||
38 | +import org.onosproject.pcepio.protocol.PcepErrorInfo; | ||
39 | +import org.onosproject.pcepio.protocol.PcepErrorMsg; | ||
40 | +import org.onosproject.pcepio.protocol.PcepErrorObject; | ||
41 | +import org.onosproject.pcepio.protocol.PcepFactory; | ||
42 | +import org.onosproject.pcepio.protocol.PcepMessage; | ||
43 | +import org.onosproject.pcepio.protocol.PcepVersion; | ||
44 | + | ||
45 | +import com.google.common.collect.Sets; | ||
46 | + | ||
47 | +import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19; | ||
48 | +import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5; | ||
49 | + | ||
50 | +/** | ||
51 | + * Representation of PCEP client controller adapter. | ||
52 | + */ | ||
53 | +public class PcepClientControllerAdapter implements PcepClientController { | ||
54 | + | ||
55 | + protected ConcurrentHashMap<PccId, PcepClient> connectedClients = | ||
56 | + new ConcurrentHashMap<PccId, PcepClient>(); | ||
57 | + | ||
58 | + protected PcepClientAgent agent = new PcepClientAgent(); | ||
59 | + protected Set<PcepClientListener> pcepClientListener = new HashSet<>(); | ||
60 | + | ||
61 | + protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); | ||
62 | + public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet(); | ||
63 | + | ||
64 | + @Activate | ||
65 | + public void activate() { | ||
66 | + } | ||
67 | + | ||
68 | + @Deactivate | ||
69 | + public void deactivate() { | ||
70 | + } | ||
71 | + | ||
72 | + @Override | ||
73 | + public Collection<PcepClient> getClients() { | ||
74 | + return connectedClients.values(); | ||
75 | + } | ||
76 | + | ||
77 | + @Override | ||
78 | + public PcepClient getClient(PccId pccId) { | ||
79 | + if (null != connectedClients.get(pccId)) { | ||
80 | + return connectedClients.get(pccId); | ||
81 | + } | ||
82 | + PcepClientAdapter pc = new PcepClientAdapter(); | ||
83 | + if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103)) | ||
84 | + || pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) { | ||
85 | + pc.setCapability(new ClientCapability(true, false, false, false, false)); | ||
86 | + } else { | ||
87 | + pc.setCapability(new ClientCapability(true, true, true, false, false)); | ||
88 | + } | ||
89 | + pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1); | ||
90 | + connectedClients.put(pccId, pc); | ||
91 | + return pc; | ||
92 | + } | ||
93 | + | ||
94 | + @Override | ||
95 | + public void addListener(PcepClientListener listener) { | ||
96 | + if (!pcepClientListener.contains(listener)) { | ||
97 | + this.pcepClientListener.add(listener); | ||
98 | + } | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public void addNodeListener(PcepNodeListener listener) { | ||
103 | + pcepNodeListener.add(listener); | ||
104 | + } | ||
105 | + | ||
106 | + @Override | ||
107 | + public void removeNodeListener(PcepNodeListener listener) { | ||
108 | + pcepNodeListener.remove(listener); | ||
109 | + } | ||
110 | + | ||
111 | + @Override | ||
112 | + public void removeListener(PcepClientListener listener) { | ||
113 | + this.pcepClientListener.remove(listener); | ||
114 | + } | ||
115 | + | ||
116 | + @Override | ||
117 | + public void addEventListener(PcepEventListener listener) { | ||
118 | + pcepEventListener.add(listener); | ||
119 | + } | ||
120 | + | ||
121 | + @Override | ||
122 | + public void removeEventListener(PcepEventListener listener) { | ||
123 | + pcepEventListener.remove(listener); | ||
124 | + } | ||
125 | + | ||
126 | + @Override | ||
127 | + public void writeMessage(PccId pccId, PcepMessage msg) { | ||
128 | + this.getClient(pccId).sendMessage(msg); | ||
129 | + } | ||
130 | + | ||
131 | + @Override | ||
132 | + public void processClientMessage(PccId pccId, PcepMessage msg) { | ||
133 | + | ||
134 | + PcepClient pc = getClient(pccId); | ||
135 | + | ||
136 | + switch (msg.getType()) { | ||
137 | + case NONE: | ||
138 | + break; | ||
139 | + case OPEN: | ||
140 | + break; | ||
141 | + case KEEP_ALIVE: | ||
142 | + //log.debug("Sending Keep Alive Message to {" + pccIpAddress.toString() + "}"); | ||
143 | + pc.sendMessage(Collections.singletonList(pc.factory().buildKeepaliveMsg().build())); | ||
144 | + break; | ||
145 | + case PATH_COMPUTATION_REQUEST: | ||
146 | + break; | ||
147 | + case PATH_COMPUTATION_REPLY: | ||
148 | + break; | ||
149 | + case NOTIFICATION: | ||
150 | + break; | ||
151 | + case ERROR: | ||
152 | + break; | ||
153 | + case CLOSE: | ||
154 | + //log.debug("Sending Close Message to { }", pccIpAddress.toString()); | ||
155 | + pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build())); | ||
156 | + break; | ||
157 | + case INITIATE: | ||
158 | + if (!pc.capability().pcInstantiationCapability()) { | ||
159 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), | ||
160 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
161 | + } | ||
162 | + break; | ||
163 | + case REPORT: | ||
164 | + //Only update the listener if respective capability is supported else send PCEP-ERR msg | ||
165 | + if (pc.capability().statefulPceCapability()) { | ||
166 | + for (PcepEventListener l : pcepEventListener) { | ||
167 | + l.handleMessage(pccId, msg); | ||
168 | + } | ||
169 | + } else { | ||
170 | + // Send PCEP-ERROR message. | ||
171 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), | ||
172 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
173 | + } | ||
174 | + break; | ||
175 | + case UPDATE: | ||
176 | + if (!pc.capability().statefulPceCapability()) { | ||
177 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), | ||
178 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
179 | + } | ||
180 | + break; | ||
181 | + case LABEL_UPDATE: | ||
182 | + if (!pc.capability().pceccCapability()) { | ||
183 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), | ||
184 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
185 | + } | ||
186 | + break; | ||
187 | + case MAX: | ||
188 | + break; | ||
189 | + case END: | ||
190 | + break; | ||
191 | + default: | ||
192 | + break; | ||
193 | + } | ||
194 | + } | ||
195 | + | ||
196 | + @Override | ||
197 | + public void closeConnectedClients() { | ||
198 | + PcepClient pc; | ||
199 | + for (PccId id : connectedClients.keySet()) { | ||
200 | + pc = getClient(id); | ||
201 | + pc.disconnectClient(); | ||
202 | + } | ||
203 | + } | ||
204 | + | ||
205 | + private PcepErrorMsg getErrMsg(PcepFactory factory, byte errorType, byte errorValue) { | ||
206 | + LinkedList<PcepError> llPcepErr = new LinkedList<>(); | ||
207 | + | ||
208 | + LinkedList<PcepErrorObject> llerrObj = new LinkedList<>(); | ||
209 | + PcepErrorMsg errMsg; | ||
210 | + | ||
211 | + PcepErrorObject errObj = factory.buildPcepErrorObject().setErrorValue(errorValue).setErrorType(errorType) | ||
212 | + .build(); | ||
213 | + | ||
214 | + llerrObj.add(errObj); | ||
215 | + PcepError pcepErr = factory.buildPcepError().setErrorObjList(llerrObj).build(); | ||
216 | + | ||
217 | + llPcepErr.add(pcepErr); | ||
218 | + | ||
219 | + PcepErrorInfo errInfo = factory.buildPcepErrorInfo().setPcepErrorList(llPcepErr).build(); | ||
220 | + | ||
221 | + errMsg = factory.buildPcepErrorMsg().setPcepErrorInfo(errInfo).build(); | ||
222 | + return errMsg; | ||
223 | + } | ||
224 | + | ||
225 | + /** | ||
226 | + * Implementation of an Pcep Agent which is responsible for | ||
227 | + * keeping track of connected clients and the state in which | ||
228 | + * they are. | ||
229 | + */ | ||
230 | + public class PcepClientAgent implements PcepAgent { | ||
231 | + | ||
232 | + @Override | ||
233 | + public boolean addConnectedClient(PccId pccId, PcepClient pc) { | ||
234 | + | ||
235 | + if (connectedClients.get(pccId) != null) { | ||
236 | + return false; | ||
237 | + } else { | ||
238 | + connectedClients.put(pccId, pc); | ||
239 | + for (PcepClientListener l : pcepClientListener) { | ||
240 | + l.clientConnected(pccId); | ||
241 | + } | ||
242 | + return true; | ||
243 | + } | ||
244 | + } | ||
245 | + | ||
246 | + @Override | ||
247 | + public boolean validActivation(PccId pccId) { | ||
248 | + if (connectedClients.get(pccId) == null) { | ||
249 | + //log.error("Trying to activate client but is not in " | ||
250 | + // + "connected switches: pccIp {}. Aborting ..", pccIpAddress.toString()); | ||
251 | + return false; | ||
252 | + } | ||
253 | + | ||
254 | + return true; | ||
255 | + } | ||
256 | + | ||
257 | + @Override | ||
258 | + public void removeConnectedClient(PccId pccId) { | ||
259 | + connectedClients.remove(pccId); | ||
260 | + for (PcepClientListener l : pcepClientListener) { | ||
261 | + //log.warn("removal for {}", pccIpAddress.toString()); | ||
262 | + l.clientDisconnected(pccId); | ||
263 | + } | ||
264 | + } | ||
265 | + | ||
266 | + @Override | ||
267 | + public void processPcepMessage(PccId pccId, PcepMessage m) { | ||
268 | + processClientMessage(pccId, m); | ||
269 | + } | ||
270 | + | ||
271 | + @Override | ||
272 | + public void addNode(PcepClient pc) { | ||
273 | + for (PcepNodeListener l : pcepNodeListener) { | ||
274 | + l.addNode(pc); | ||
275 | + } | ||
276 | + } | ||
277 | + | ||
278 | + @Override | ||
279 | + public void deleteNode(PccId pccId) { | ||
280 | + for (PcepNodeListener l : pcepNodeListener) { | ||
281 | + l.deleteNode(pccId); | ||
282 | + } | ||
283 | + } | ||
284 | + | ||
285 | + @Override | ||
286 | + public boolean analyzeSyncMsgList(PccId pccId) { | ||
287 | + // TODO Auto-generated method stub | ||
288 | + return false; | ||
289 | + } | ||
290 | + } | ||
291 | + | ||
292 | + @Override | ||
293 | + public void addPacketListener(PcepPacketListener listener) { | ||
294 | + // TODO Auto-generated method stub | ||
295 | + | ||
296 | + } | ||
297 | + | ||
298 | + @Override | ||
299 | + public void removePacketListener(PcepPacketListener listener) { | ||
300 | + // TODO Auto-generated method stub | ||
301 | + | ||
302 | + } | ||
303 | +} |
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.topology.impl; | ||
18 | + | ||
19 | +import org.onosproject.net.DeviceId; | ||
20 | +import org.onosproject.pcep.api.PcepController; | ||
21 | +import org.onosproject.pcep.api.PcepDpid; | ||
22 | +import org.onosproject.pcep.api.PcepLinkListener; | ||
23 | +import org.onosproject.pcep.api.PcepSwitch; | ||
24 | +import org.onosproject.pcep.api.PcepSwitchListener; | ||
25 | +import org.onosproject.pcep.api.PcepTunnel; | ||
26 | +import org.onosproject.pcep.api.PcepTunnelListener; | ||
27 | + | ||
28 | +/** | ||
29 | + * Implementation of PCEP controller. | ||
30 | + */ | ||
31 | +public class PcepControllerAdapter implements PcepController { | ||
32 | + | ||
33 | + @Override | ||
34 | + public Iterable<PcepSwitch> getSwitches() { | ||
35 | + return null; | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public PcepSwitch getSwitch(PcepDpid did) { | ||
40 | + return null; | ||
41 | + } | ||
42 | + | ||
43 | + @Override | ||
44 | + public void addListener(PcepSwitchListener listener) { | ||
45 | + | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public void removeListener(PcepSwitchListener listener) { | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public void addLinkListener(PcepLinkListener listener) { | ||
54 | + } | ||
55 | + | ||
56 | + @Override | ||
57 | + public void removeLinkListener(PcepLinkListener listener) { | ||
58 | + } | ||
59 | + | ||
60 | + @Override | ||
61 | + public void addTunnelListener(PcepTunnelListener listener) { | ||
62 | + } | ||
63 | + | ||
64 | + @Override | ||
65 | + public void removeTunnelListener(PcepTunnelListener listener) { | ||
66 | + } | ||
67 | + | ||
68 | + @Override | ||
69 | + public PcepTunnel applyTunnel(DeviceId srcDid, DeviceId dstDid, long srcPort, long dstPort, long bandwidth, | ||
70 | + String name) { | ||
71 | + return null; | ||
72 | + } | ||
73 | + | ||
74 | + @Override | ||
75 | + public Boolean deleteTunnel(String id) { | ||
76 | + return null; | ||
77 | + } | ||
78 | + | ||
79 | + @Override | ||
80 | + public Boolean updateTunnelBandwidth(String id, long bandwidth) { | ||
81 | + return null; | ||
82 | + } | ||
83 | + | ||
84 | + @Override | ||
85 | + public void getTunnelStatistics(String pcepTunnelId) { | ||
86 | + | ||
87 | + } | ||
88 | +} |
1 | +/* | ||
2 | + * Copyright 2016-present Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with | ||
5 | + * the License. You may obtain a copy of the License at | ||
6 | + * | ||
7 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
8 | + * | ||
9 | + * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on | ||
10 | + * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
11 | + * specific language governing permissions and limitations under the License. | ||
12 | + */ | ||
13 | +package org.onosproject.provider.pcep.topology.impl; | ||
14 | + | ||
15 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
16 | +import static org.hamcrest.core.Is.is; | ||
17 | +import static org.onosproject.net.Link.State.ACTIVE; | ||
18 | +import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.LABEL_STACK_CAPABILITY; | ||
19 | +import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.LSRID; | ||
20 | +import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.PCECC_CAPABILITY; | ||
21 | +import static org.onosproject.provider.pcep.topology.impl.PcepTopologyProvider.SR_CAPABILITY; | ||
22 | + | ||
23 | +import java.util.Collection; | ||
24 | +import java.util.HashMap; | ||
25 | +import java.util.HashSet; | ||
26 | +import java.util.List; | ||
27 | +import java.util.Map; | ||
28 | +import java.util.Set; | ||
29 | + | ||
30 | +import org.junit.After; | ||
31 | +import org.junit.Before; | ||
32 | +import org.junit.Test; | ||
33 | +import org.onlab.packet.ChassisId; | ||
34 | +import org.onlab.packet.IpAddress; | ||
35 | +import org.onosproject.net.ConnectPoint; | ||
36 | +import org.onosproject.net.DefaultDevice; | ||
37 | +import org.onosproject.net.DefaultLink; | ||
38 | +import org.onosproject.net.Device; | ||
39 | +import org.onosproject.net.DeviceId; | ||
40 | +import org.onosproject.net.Link; | ||
41 | +import org.onosproject.net.MastershipRole; | ||
42 | +import org.onosproject.net.device.DeviceDescription; | ||
43 | +import org.onosproject.net.device.DeviceProvider; | ||
44 | +import org.onosproject.net.device.DeviceProviderRegistry; | ||
45 | +import org.onosproject.net.device.DeviceProviderService; | ||
46 | +import org.onosproject.net.device.DeviceServiceAdapter; | ||
47 | +import org.onosproject.net.device.PortDescription; | ||
48 | +import org.onosproject.net.device.PortStatistics; | ||
49 | +import org.onosproject.net.link.LinkDescription; | ||
50 | +import org.onosproject.net.link.LinkProvider; | ||
51 | +import org.onosproject.net.link.LinkProviderRegistry; | ||
52 | +import org.onosproject.net.link.LinkProviderService; | ||
53 | +import org.onosproject.net.provider.ProviderId; | ||
54 | +import org.onosproject.pcep.controller.ClientCapability; | ||
55 | +import org.onosproject.pcep.controller.PccId; | ||
56 | +import org.onosproject.pcep.controller.PcepClient; | ||
57 | +import org.onosproject.pcep.controller.PcepNodeListener; | ||
58 | + | ||
59 | +/** | ||
60 | + * Test for PCEP topology provider. | ||
61 | + */ | ||
62 | +public class PcepTopologyProviderTest { | ||
63 | + private static final String UNKNOWN = new String("unknown"); | ||
64 | + public static ProviderId providerId = new ProviderId("l3", "foo"); | ||
65 | + private final PcepClientControllerAdapter clientController = new PcepClientControllerAdapter(); | ||
66 | + private final PcepTopologyProvider provider = new PcepTopologyProvider(); | ||
67 | + private final MockDeviceRegistry nodeRegistry = new MockDeviceRegistry(); | ||
68 | + private final PcepControllerAdapter controller = new PcepControllerAdapter(); | ||
69 | + private final MockLinkRegistry linkRegistry = new MockLinkRegistry(); | ||
70 | + private final MockDeviceService deviceService = new MockDeviceService(); | ||
71 | + private Map<DeviceId, Device> deviceMap = new HashMap<>(); | ||
72 | + | ||
73 | + @Before | ||
74 | + public void startUp() { | ||
75 | + provider.pcepClientController = clientController; | ||
76 | + provider.deviceProviderRegistry = nodeRegistry; | ||
77 | + provider.linkProviderRegistry = linkRegistry; | ||
78 | + provider.controller = controller; | ||
79 | + provider.deviceService = deviceService; | ||
80 | + provider.activate(); | ||
81 | + } | ||
82 | + | ||
83 | + @After | ||
84 | + public void tearDown() { | ||
85 | + provider.deactivate(); | ||
86 | + provider.deviceProviderRegistry = null; | ||
87 | + provider.pcepClientController = null; | ||
88 | + provider.linkProviderRegistry = null; | ||
89 | + provider.controller = null; | ||
90 | + provider.deviceService = null; | ||
91 | + } | ||
92 | + | ||
93 | + /* Class implement device test registry */ | ||
94 | + private class MockLinkRegistry implements LinkProviderRegistry { | ||
95 | + LinkProvider linkProvider; | ||
96 | + Set<Link> links = new HashSet<>(); | ||
97 | + | ||
98 | + @Override | ||
99 | + public LinkProviderService register(LinkProvider provider) { | ||
100 | + this.linkProvider = provider; | ||
101 | + return new MockProviderService(); | ||
102 | + } | ||
103 | + | ||
104 | + @Override | ||
105 | + public void unregister(LinkProvider provider) { | ||
106 | + // TODO Auto-generated method stub | ||
107 | + } | ||
108 | + | ||
109 | + @Override | ||
110 | + public Set<ProviderId> getProviders() { | ||
111 | + return null; | ||
112 | + } | ||
113 | + | ||
114 | + private class MockProviderService implements LinkProviderService { | ||
115 | + | ||
116 | + @Override | ||
117 | + public void linkDetected(LinkDescription linkDescription) { | ||
118 | + links.add(DefaultLink.builder().src(linkDescription.src()) | ||
119 | + .dst(linkDescription.dst()).state(ACTIVE).type(linkDescription.type()) | ||
120 | + .providerId(ProviderId.NONE).build()); | ||
121 | + } | ||
122 | + | ||
123 | + @Override | ||
124 | + public void linkVanished(LinkDescription linkDescription) { | ||
125 | + links.remove(DefaultLink.builder().src(linkDescription.src()) | ||
126 | + .dst(linkDescription.dst()).state(ACTIVE).type(linkDescription.type()) | ||
127 | + .providerId(ProviderId.NONE).build()); | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
131 | + public void linksVanished(ConnectPoint connectPoint) { | ||
132 | + // TODO Auto-generated method stub | ||
133 | + } | ||
134 | + | ||
135 | + @Override | ||
136 | + public void linksVanished(DeviceId deviceId) { | ||
137 | + // TODO Auto-generated method stub | ||
138 | + } | ||
139 | + | ||
140 | + @Override | ||
141 | + public LinkProvider provider() { | ||
142 | + // TODO Auto-generated method stub | ||
143 | + return null; | ||
144 | + } | ||
145 | + } | ||
146 | + } | ||
147 | + | ||
148 | + /* Class implement device test registry */ | ||
149 | + private class MockDeviceRegistry implements DeviceProviderRegistry { | ||
150 | + DeviceProvider provider; | ||
151 | + | ||
152 | + Set<DeviceId> connected = new HashSet<>(); | ||
153 | + | ||
154 | + @Override | ||
155 | + public DeviceProviderService register(DeviceProvider provider) { | ||
156 | + this.provider = provider; | ||
157 | + return new MockProviderService(); | ||
158 | + } | ||
159 | + | ||
160 | + @Override | ||
161 | + public void unregister(DeviceProvider provider) { | ||
162 | + } | ||
163 | + | ||
164 | + @Override | ||
165 | + public Set<ProviderId> getProviders() { | ||
166 | + return null; | ||
167 | + } | ||
168 | + | ||
169 | + private class MockProviderService implements DeviceProviderService { | ||
170 | + | ||
171 | + @Override | ||
172 | + public DeviceProvider provider() { | ||
173 | + return null; | ||
174 | + } | ||
175 | + | ||
176 | + @Override | ||
177 | + public void deviceConnected(DeviceId deviceId, DeviceDescription deviceDescription) { | ||
178 | + connected.add(deviceId); | ||
179 | + Device device = new DefaultDevice(ProviderId.NONE, deviceId, Device.Type.ROUTER, UNKNOWN, UNKNOWN, | ||
180 | + UNKNOWN, UNKNOWN, new ChassisId(), deviceDescription.annotations()); | ||
181 | + deviceMap.put(deviceId, device); | ||
182 | + } | ||
183 | + | ||
184 | + @Override | ||
185 | + public void deviceDisconnected(DeviceId deviceId) { | ||
186 | + connected.remove(deviceId); | ||
187 | + deviceMap.remove(deviceId); | ||
188 | + } | ||
189 | + | ||
190 | + @Override | ||
191 | + public void updatePorts(DeviceId deviceId, List<PortDescription> portDescriptions) { | ||
192 | + // TODO Auto-generated method stub | ||
193 | + } | ||
194 | + | ||
195 | + @Override | ||
196 | + public void portStatusChanged(DeviceId deviceId, PortDescription portDescription) { | ||
197 | + // TODO Auto-generated method stub | ||
198 | + } | ||
199 | + | ||
200 | + @Override | ||
201 | + public void receivedRoleReply(DeviceId deviceId, MastershipRole requested, MastershipRole response) { | ||
202 | + // TODO Auto-generated method stub | ||
203 | + } | ||
204 | + | ||
205 | + @Override | ||
206 | + public void updatePortStatistics(DeviceId deviceId, Collection<PortStatistics> portStatistics) { | ||
207 | + // TODO Auto-generated method stub | ||
208 | + } | ||
209 | + } | ||
210 | + } | ||
211 | + | ||
212 | + /* Mock test for device service */ | ||
213 | + private class MockDeviceService extends DeviceServiceAdapter { | ||
214 | + @Override | ||
215 | + public Device getDevice(DeviceId deviceId) { | ||
216 | + return deviceMap.get(deviceId); | ||
217 | + } | ||
218 | + } | ||
219 | + | ||
220 | + /** | ||
221 | + * Adds the PCEP device and removes it. | ||
222 | + */ | ||
223 | + @Test | ||
224 | + public void testPcepTopologyProviderTestAddDevice1() { | ||
225 | + PcepClient pc = clientController.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))); | ||
226 | + for (PcepNodeListener l : clientController.pcepNodeListener) { | ||
227 | + pc.setCapability(new ClientCapability(true, true, false, true, true)); | ||
228 | + l.addNode(pc); | ||
229 | + assertThat(nodeRegistry.connected.size(), is(1)); | ||
230 | + assertThat(deviceMap.keySet().iterator().next(), is(DeviceId.deviceId("l3:1.1.1.1"))); | ||
231 | + assertThat(deviceMap.values().iterator().next().annotations().value(LABEL_STACK_CAPABILITY), is("true")); | ||
232 | + assertThat(deviceMap.values().iterator().next().annotations().value(LSRID), is("1.1.1.1")); | ||
233 | + assertThat(deviceMap.values().iterator().next().annotations().value(PCECC_CAPABILITY), is("true")); | ||
234 | + assertThat(deviceMap.values().iterator().next().annotations().value(SR_CAPABILITY), is("true")); | ||
235 | + | ||
236 | + l.deleteNode(pc.getPccId()); | ||
237 | + assertThat(nodeRegistry.connected.size(), is(0)); | ||
238 | + } | ||
239 | + } | ||
240 | +} |
... | @@ -6,6 +6,7 @@ COMPILE_DEPS = [ | ... | @@ -6,6 +6,7 @@ COMPILE_DEPS = [ |
6 | '//incubator/api:onos-incubator-api', | 6 | '//incubator/api:onos-incubator-api', |
7 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', | 7 | '//protocols/pcep/pcepio:onos-protocols-pcep-pcepio', |
8 | '//protocols/pcep/api:onos-protocols-pcep-api', | 8 | '//protocols/pcep/api:onos-protocols-pcep-api', |
9 | + '//protocols/pcep/ctl:onos-protocols-pcep-ctl', | ||
9 | ] | 10 | ] |
10 | 11 | ||
11 | TEST_DEPS = [ | 12 | TEST_DEPS = [ | ... | ... |
... | @@ -49,5 +49,10 @@ | ... | @@ -49,5 +49,10 @@ |
49 | <version>${project.version} </version> | 49 | <version>${project.version} </version> |
50 | <scope>test</scope> | 50 | <scope>test</scope> |
51 | </dependency> | 51 | </dependency> |
52 | + <dependency> | ||
53 | + <groupId>org.onosproject</groupId> | ||
54 | + <artifactId>onos-pcep-controller-impl</artifactId> | ||
55 | + <version>${project.version} </version> | ||
56 | + </dependency> | ||
52 | </dependencies> | 57 | </dependencies> |
53 | </project> | 58 | </project> | ... | ... |
This diff is collapsed. Click to expand it.
providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java
... | @@ -17,17 +17,22 @@ package org.onosproject.provider.pcep.tunnel.impl; | ... | @@ -17,17 +17,22 @@ package org.onosproject.provider.pcep.tunnel.impl; |
17 | 17 | ||
18 | import static org.junit.Assert.assertNotNull; | 18 | import static org.junit.Assert.assertNotNull; |
19 | 19 | ||
20 | +import java.util.HashMap; | ||
21 | +import java.util.LinkedList; | ||
20 | import java.util.List; | 22 | import java.util.List; |
23 | +import java.util.Map; | ||
21 | import java.util.concurrent.RejectedExecutionException; | 24 | import java.util.concurrent.RejectedExecutionException; |
22 | 25 | ||
23 | import org.jboss.netty.channel.Channel; | 26 | import org.jboss.netty.channel.Channel; |
24 | import org.onosproject.pcep.controller.ClientCapability; | 27 | import org.onosproject.pcep.controller.ClientCapability; |
28 | +import org.onosproject.pcep.controller.LspKey; | ||
25 | import org.onosproject.pcep.controller.PccId; | 29 | import org.onosproject.pcep.controller.PccId; |
26 | import org.onosproject.pcep.controller.PcepClient; | 30 | import org.onosproject.pcep.controller.PcepClient; |
27 | import org.onosproject.pcep.controller.PcepSyncStatus; | 31 | import org.onosproject.pcep.controller.PcepSyncStatus; |
28 | import org.onosproject.pcepio.protocol.PcepFactories; | 32 | import org.onosproject.pcepio.protocol.PcepFactories; |
29 | import org.onosproject.pcepio.protocol.PcepFactory; | 33 | import org.onosproject.pcepio.protocol.PcepFactory; |
30 | import org.onosproject.pcepio.protocol.PcepMessage; | 34 | import org.onosproject.pcepio.protocol.PcepMessage; |
35 | +import org.onosproject.pcepio.protocol.PcepStateReport; | ||
31 | import org.onosproject.pcepio.protocol.PcepVersion; | 36 | import org.onosproject.pcepio.protocol.PcepVersion; |
32 | 37 | ||
33 | /** | 38 | /** |
... | @@ -45,6 +50,8 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -45,6 +50,8 @@ public class PcepClientAdapter implements PcepClient { |
45 | private PcepVersion pcepVersion; | 50 | private PcepVersion pcepVersion; |
46 | private PcepSyncStatus lspDbSyncStatus; | 51 | private PcepSyncStatus lspDbSyncStatus; |
47 | private PcepSyncStatus labelDbSyncStatus; | 52 | private PcepSyncStatus labelDbSyncStatus; |
53 | + private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>(); | ||
54 | + private Map<PccId, List<PcepStateReport>> sycRptCache = new HashMap<>(); | ||
48 | 55 | ||
49 | /** | 56 | /** |
50 | * Initialize instance with specified parameters. | 57 | * Initialize instance with specified parameters. |
... | @@ -139,4 +146,45 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -139,4 +146,45 @@ public class PcepClientAdapter implements PcepClient { |
139 | public ClientCapability capability() { | 146 | public ClientCapability capability() { |
140 | return capability; | 147 | return capability; |
141 | } | 148 | } |
149 | + | ||
150 | + @Override | ||
151 | + public void addNode(PcepClient pc) { | ||
152 | + } | ||
153 | + | ||
154 | + @Override | ||
155 | + public void deleteNode(PccId pccId) { | ||
156 | + } | ||
157 | + | ||
158 | + @Override | ||
159 | + public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) { | ||
160 | + lspDelegationInfo.put(lspKey, dFlag); | ||
161 | + } | ||
162 | + | ||
163 | + @Override | ||
164 | + public Boolean delegationInfo(LspKey lspKey) { | ||
165 | + return lspDelegationInfo.get(lspKey); | ||
166 | + } | ||
167 | + | ||
168 | + @Override | ||
169 | + public void initializeSyncMsgList(PccId pccId) { | ||
170 | + List<PcepStateReport> rptMsgList = new LinkedList<>(); | ||
171 | + sycRptCache.put(pccId, rptMsgList); | ||
172 | + } | ||
173 | + | ||
174 | + @Override | ||
175 | + public List<PcepStateReport> getSyncMsgList(PccId pccId) { | ||
176 | + return sycRptCache.get(pccId); | ||
177 | + } | ||
178 | + | ||
179 | + @Override | ||
180 | + public void removeSyncMsgList(PccId pccId) { | ||
181 | + sycRptCache.remove(pccId); | ||
182 | + } | ||
183 | + | ||
184 | + @Override | ||
185 | + public void addSyncMsgToList(PccId pccId, PcepStateReport rptMsg) { | ||
186 | + List<PcepStateReport> rptMsgList = sycRptCache.get(pccId); | ||
187 | + rptMsgList.add(rptMsg); | ||
188 | + sycRptCache.put(pccId, rptMsgList); | ||
189 | + } | ||
142 | } | 190 | } | ... | ... |
... | @@ -24,13 +24,13 @@ import java.util.concurrent.ConcurrentHashMap; | ... | @@ -24,13 +24,13 @@ import java.util.concurrent.ConcurrentHashMap; |
24 | 24 | ||
25 | import org.apache.felix.scr.annotations.Activate; | 25 | import org.apache.felix.scr.annotations.Activate; |
26 | import org.apache.felix.scr.annotations.Deactivate; | 26 | import org.apache.felix.scr.annotations.Deactivate; |
27 | -import org.onlab.packet.IpAddress; | ||
28 | -import org.onosproject.pcep.controller.ClientCapability; | ||
29 | import org.onosproject.pcep.controller.PccId; | 27 | import org.onosproject.pcep.controller.PccId; |
30 | import org.onosproject.pcep.controller.PcepClient; | 28 | import org.onosproject.pcep.controller.PcepClient; |
31 | import org.onosproject.pcep.controller.PcepClientController; | 29 | import org.onosproject.pcep.controller.PcepClientController; |
32 | import org.onosproject.pcep.controller.PcepClientListener; | 30 | import org.onosproject.pcep.controller.PcepClientListener; |
33 | import org.onosproject.pcep.controller.PcepEventListener; | 31 | import org.onosproject.pcep.controller.PcepEventListener; |
32 | +import org.onosproject.pcep.controller.PcepNodeListener; | ||
33 | +import org.onosproject.pcep.controller.PcepPacketListener; | ||
34 | import org.onosproject.pcep.controller.driver.PcepAgent; | 34 | import org.onosproject.pcep.controller.driver.PcepAgent; |
35 | import org.onosproject.pcepio.protocol.PcepError; | 35 | import org.onosproject.pcepio.protocol.PcepError; |
36 | import org.onosproject.pcepio.protocol.PcepErrorInfo; | 36 | import org.onosproject.pcepio.protocol.PcepErrorInfo; |
... | @@ -57,6 +57,8 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -57,6 +57,8 @@ public class PcepClientControllerAdapter implements PcepClientController { |
57 | protected Set<PcepClientListener> pcepClientListener = new HashSet<>(); | 57 | protected Set<PcepClientListener> pcepClientListener = new HashSet<>(); |
58 | 58 | ||
59 | protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); | 59 | protected Set<PcepEventListener> pcepEventListener = Sets.newHashSet(); |
60 | + public Set<PcepNodeListener> pcepNodeListener = Sets.newHashSet(); | ||
61 | + protected Set<PcepPacketListener> pcepPacketListener = Sets.newHashSet(); | ||
60 | 62 | ||
61 | @Activate | 63 | @Activate |
62 | public void activate() { | 64 | public void activate() { |
... | @@ -73,16 +75,11 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -73,16 +75,11 @@ public class PcepClientControllerAdapter implements PcepClientController { |
73 | 75 | ||
74 | @Override | 76 | @Override |
75 | public PcepClient getClient(PccId pccId) { | 77 | public PcepClient getClient(PccId pccId) { |
76 | - if (null != connectedClients.get(pccId)) { | 78 | + if (connectedClients.get(pccId) != null) { |
77 | return connectedClients.get(pccId); | 79 | return connectedClients.get(pccId); |
78 | } | 80 | } |
79 | PcepClientAdapter pc = new PcepClientAdapter(); | 81 | PcepClientAdapter pc = new PcepClientAdapter(); |
80 | - if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103)) | 82 | + |
81 | - || pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) { | ||
82 | - pc.setCapability(new ClientCapability(true, false, false)); | ||
83 | - } else { | ||
84 | - pc.setCapability(new ClientCapability(true, true, true)); | ||
85 | - } | ||
86 | pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1); | 83 | pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1); |
87 | connectedClients.put(pccId, pc); | 84 | connectedClients.put(pccId, pc); |
88 | return pc; | 85 | return pc; |
... | @@ -96,6 +93,16 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -96,6 +93,16 @@ public class PcepClientControllerAdapter implements PcepClientController { |
96 | } | 93 | } |
97 | 94 | ||
98 | @Override | 95 | @Override |
96 | + public void addNodeListener(PcepNodeListener listener) { | ||
97 | + pcepNodeListener.add(listener); | ||
98 | + } | ||
99 | + | ||
100 | + @Override | ||
101 | + public void removeNodeListener(PcepNodeListener listener) { | ||
102 | + pcepNodeListener.remove(listener); | ||
103 | + } | ||
104 | + | ||
105 | + @Override | ||
99 | public void removeListener(PcepClientListener listener) { | 106 | public void removeListener(PcepClientListener listener) { |
100 | this.pcepClientListener.remove(listener); | 107 | this.pcepClientListener.remove(listener); |
101 | } | 108 | } |
... | @@ -111,6 +118,16 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -111,6 +118,16 @@ public class PcepClientControllerAdapter implements PcepClientController { |
111 | } | 118 | } |
112 | 119 | ||
113 | @Override | 120 | @Override |
121 | + public void addPacketListener(PcepPacketListener listener) { | ||
122 | + pcepPacketListener.add(listener); | ||
123 | + } | ||
124 | + | ||
125 | + @Override | ||
126 | + public void removePacketListener(PcepPacketListener listener) { | ||
127 | + pcepPacketListener.remove(listener); | ||
128 | + } | ||
129 | + | ||
130 | + @Override | ||
114 | public void writeMessage(PccId pccId, PcepMessage msg) { | 131 | public void writeMessage(PccId pccId, PcepMessage msg) { |
115 | this.getClient(pccId).sendMessage(msg); | 132 | this.getClient(pccId).sendMessage(msg); |
116 | } | 133 | } |
... | @@ -254,5 +271,25 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -254,5 +271,25 @@ public class PcepClientControllerAdapter implements PcepClientController { |
254 | public void processPcepMessage(PccId pccId, PcepMessage m) { | 271 | public void processPcepMessage(PccId pccId, PcepMessage m) { |
255 | processClientMessage(pccId, m); | 272 | processClientMessage(pccId, m); |
256 | } | 273 | } |
274 | + | ||
275 | + @Override | ||
276 | + public void addNode(PcepClient pc) { | ||
277 | + for (PcepNodeListener l : pcepNodeListener) { | ||
278 | + l.addNode(pc); | ||
279 | + } | ||
280 | + } | ||
281 | + | ||
282 | + @Override | ||
283 | + public void deleteNode(PccId pccId) { | ||
284 | + for (PcepNodeListener l : pcepNodeListener) { | ||
285 | + l.deleteNode(pccId); | ||
286 | + } | ||
287 | + } | ||
288 | + | ||
289 | + @Override | ||
290 | + public boolean analyzeSyncMsgList(PccId pccId) { | ||
291 | + // TODO Auto-generated method stub | ||
292 | + return false; | ||
293 | + } | ||
257 | } | 294 | } |
258 | } | 295 | } | ... | ... |
... | @@ -40,6 +40,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | ... | @@ -40,6 +40,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
40 | import org.onosproject.incubator.net.tunnel.Tunnel; | 40 | import org.onosproject.incubator.net.tunnel.Tunnel; |
41 | import org.onosproject.incubator.net.tunnel.TunnelId; | 41 | import org.onosproject.incubator.net.tunnel.TunnelId; |
42 | import org.onosproject.incubator.net.tunnel.TunnelName; | 42 | import org.onosproject.incubator.net.tunnel.TunnelName; |
43 | +import org.onosproject.mastership.MastershipServiceAdapter; | ||
43 | import org.onosproject.net.Annotations; | 44 | import org.onosproject.net.Annotations; |
44 | import org.onosproject.net.ConnectPoint; | 45 | import org.onosproject.net.ConnectPoint; |
45 | import org.onosproject.net.DefaultAnnotations; | 46 | import org.onosproject.net.DefaultAnnotations; |
... | @@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId; | ... | @@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId; |
49 | import org.onosproject.net.Link; | 50 | import org.onosproject.net.Link; |
50 | import org.onosproject.net.Path; | 51 | import org.onosproject.net.Path; |
51 | import org.onosproject.net.PortNumber; | 52 | import org.onosproject.net.PortNumber; |
53 | +import org.onosproject.net.device.DeviceServiceAdapter; | ||
52 | import org.onosproject.net.provider.ProviderId; | 54 | import org.onosproject.net.provider.ProviderId; |
55 | +import org.onosproject.pcep.controller.ClientCapability; | ||
56 | +import org.onosproject.pcep.controller.PccId; | ||
53 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | 57 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
54 | 58 | ||
55 | /** | 59 | /** |
... | @@ -64,12 +68,16 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -64,12 +68,16 @@ public class PcepReleaseTunnelProviderTest { |
64 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | 68 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
65 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); | 69 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); |
66 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); | 70 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); |
71 | + private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter(); | ||
72 | + private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter(); | ||
67 | 73 | ||
68 | @Before | 74 | @Before |
69 | public void setUp() throws IOException { | 75 | public void setUp() throws IOException { |
70 | tunnelProvider.tunnelProviderRegistry = registry; | 76 | tunnelProvider.tunnelProviderRegistry = registry; |
71 | tunnelProvider.pcepClientController = controller; | 77 | tunnelProvider.pcepClientController = controller; |
72 | tunnelProvider.controller = ctl; | 78 | tunnelProvider.controller = ctl; |
79 | + tunnelProvider.deviceService = deviceService; | ||
80 | + tunnelProvider.mastershipService = mastershipService; | ||
73 | tunnelProvider.tunnelService = tunnelService; | 81 | tunnelProvider.tunnelService = tunnelService; |
74 | tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper; | 82 | tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper; |
75 | tunnelProvider.cfgService = new ComponentConfigAdapter(); | 83 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
... | @@ -125,6 +133,8 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -125,6 +133,8 @@ public class PcepReleaseTunnelProviderTest { |
125 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 133 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
126 | 134 | ||
127 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 135 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
136 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability( | ||
137 | + new ClientCapability(true, true, true, true, true)); | ||
128 | 138 | ||
129 | tunnelProvider.releaseTunnel(tunnel); | 139 | tunnelProvider.releaseTunnel(tunnel); |
130 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 140 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
... | @@ -179,6 +189,8 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -179,6 +189,8 @@ public class PcepReleaseTunnelProviderTest { |
179 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 189 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
180 | 190 | ||
181 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 191 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
192 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E22))).setCapability( | ||
193 | + new ClientCapability(true, false, false, true, true)); | ||
182 | 194 | ||
183 | tunnelProvider.releaseTunnel(tunnel); | 195 | tunnelProvider.releaseTunnel(tunnel); |
184 | assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); | 196 | assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); |
... | @@ -233,6 +245,8 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -233,6 +245,8 @@ public class PcepReleaseTunnelProviderTest { |
233 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 245 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
234 | 246 | ||
235 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 247 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
248 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability( | ||
249 | + new ClientCapability(true, true, true, true, true)); | ||
236 | 250 | ||
237 | tunnelProvider.releaseTunnel(tunnel); | 251 | tunnelProvider.releaseTunnel(tunnel); |
238 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 252 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
... | @@ -287,6 +301,8 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -287,6 +301,8 @@ public class PcepReleaseTunnelProviderTest { |
287 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | 301 | tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); |
288 | 302 | ||
289 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 303 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
304 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability( | ||
305 | + new ClientCapability(true, true, true, true, true)); | ||
290 | 306 | ||
291 | tunnelProvider.releaseTunnel(tunnel); | 307 | tunnelProvider.releaseTunnel(tunnel); |
292 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 308 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
... | @@ -298,5 +314,7 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -298,5 +314,7 @@ public class PcepReleaseTunnelProviderTest { |
298 | tunnelProvider.controller = null; | 314 | tunnelProvider.controller = null; |
299 | tunnelProvider.pcepClientController = null; | 315 | tunnelProvider.pcepClientController = null; |
300 | tunnelProvider.tunnelProviderRegistry = null; | 316 | tunnelProvider.tunnelProviderRegistry = null; |
317 | + tunnelProvider.deviceService = null; | ||
318 | + tunnelProvider.mastershipService = null; | ||
301 | } | 319 | } |
302 | } | 320 | } | ... | ... |
... | @@ -40,6 +40,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | ... | @@ -40,6 +40,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
40 | import org.onosproject.incubator.net.tunnel.Tunnel; | 40 | import org.onosproject.incubator.net.tunnel.Tunnel; |
41 | import org.onosproject.incubator.net.tunnel.TunnelId; | 41 | import org.onosproject.incubator.net.tunnel.TunnelId; |
42 | import org.onosproject.incubator.net.tunnel.TunnelName; | 42 | import org.onosproject.incubator.net.tunnel.TunnelName; |
43 | +import org.onosproject.mastership.MastershipServiceAdapter; | ||
43 | import org.onosproject.net.Annotations; | 44 | import org.onosproject.net.Annotations; |
44 | import org.onosproject.net.ConnectPoint; | 45 | import org.onosproject.net.ConnectPoint; |
45 | import org.onosproject.net.DefaultAnnotations; | 46 | import org.onosproject.net.DefaultAnnotations; |
... | @@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId; | ... | @@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId; |
49 | import org.onosproject.net.Link; | 50 | import org.onosproject.net.Link; |
50 | import org.onosproject.net.Path; | 51 | import org.onosproject.net.Path; |
51 | import org.onosproject.net.PortNumber; | 52 | import org.onosproject.net.PortNumber; |
53 | +import org.onosproject.net.device.DeviceServiceAdapter; | ||
52 | import org.onosproject.net.provider.ProviderId; | 54 | import org.onosproject.net.provider.ProviderId; |
55 | +import org.onosproject.pcep.controller.ClientCapability; | ||
56 | +import org.onosproject.pcep.controller.PccId; | ||
53 | 57 | ||
54 | /** | 58 | /** |
55 | * Test for PCEP setup tunnel. | 59 | * Test for PCEP setup tunnel. |
... | @@ -62,12 +66,16 @@ public class PcepSetupTunnelProviderTest { | ... | @@ -62,12 +66,16 @@ public class PcepSetupTunnelProviderTest { |
62 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); | 66 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
63 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | 67 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
64 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); | 68 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); |
69 | + private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter(); | ||
70 | + private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter(); | ||
65 | 71 | ||
66 | @Before | 72 | @Before |
67 | public void setUp() throws IOException { | 73 | public void setUp() throws IOException { |
68 | tunnelProvider.tunnelProviderRegistry = registry; | 74 | tunnelProvider.tunnelProviderRegistry = registry; |
69 | tunnelProvider.pcepClientController = controller; | 75 | tunnelProvider.pcepClientController = controller; |
70 | tunnelProvider.controller = ctl; | 76 | tunnelProvider.controller = ctl; |
77 | + tunnelProvider.deviceService = deviceService; | ||
78 | + tunnelProvider.mastershipService = mastershipService; | ||
71 | tunnelProvider.cfgService = new ComponentConfigAdapter(); | 79 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
72 | tunnelProvider.tunnelService = tunnelService; | 80 | tunnelProvider.tunnelService = tunnelService; |
73 | tunnelProvider.activate(); | 81 | tunnelProvider.activate(); |
... | @@ -111,6 +119,8 @@ public class PcepSetupTunnelProviderTest { | ... | @@ -111,6 +119,8 @@ public class PcepSetupTunnelProviderTest { |
111 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 119 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
112 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), | 120 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
113 | path, annotations); | 121 | path, annotations); |
122 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability( | ||
123 | + new ClientCapability(true, true, true, true, true)); | ||
114 | 124 | ||
115 | tunnelProvider.setupTunnel(tunnel, path); | 125 | tunnelProvider.setupTunnel(tunnel, path); |
116 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 126 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
... | @@ -154,6 +164,8 @@ public class PcepSetupTunnelProviderTest { | ... | @@ -154,6 +164,8 @@ public class PcepSetupTunnelProviderTest { |
154 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 164 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
155 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), | 165 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
156 | path, annotations); | 166 | path, annotations); |
167 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010103))).setCapability( | ||
168 | + new ClientCapability(true, true, true, true, true)); | ||
157 | 169 | ||
158 | tunnelProvider.setupTunnel(tunnel, path); | 170 | tunnelProvider.setupTunnel(tunnel, path); |
159 | assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); | 171 | assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); |
... | @@ -197,6 +209,8 @@ public class PcepSetupTunnelProviderTest { | ... | @@ -197,6 +209,8 @@ public class PcepSetupTunnelProviderTest { |
197 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 209 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
198 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), | 210 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
199 | path, annotations); | 211 | path, annotations); |
212 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability( | ||
213 | + new ClientCapability(true, true, true, true, true)); | ||
200 | 214 | ||
201 | tunnelProvider.setupTunnel(tunnel, path); | 215 | tunnelProvider.setupTunnel(tunnel, path); |
202 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 216 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
... | @@ -240,6 +254,8 @@ public class PcepSetupTunnelProviderTest { | ... | @@ -240,6 +254,8 @@ public class PcepSetupTunnelProviderTest { |
240 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 254 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
241 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), | 255 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
242 | path, annotations); | 256 | path, annotations); |
257 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability( | ||
258 | + new ClientCapability(true, true, true, true, true)); | ||
243 | 259 | ||
244 | tunnelProvider.setupTunnel(tunnel, path); | 260 | tunnelProvider.setupTunnel(tunnel, path); |
245 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 261 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
... | @@ -251,5 +267,7 @@ public class PcepSetupTunnelProviderTest { | ... | @@ -251,5 +267,7 @@ public class PcepSetupTunnelProviderTest { |
251 | tunnelProvider.controller = null; | 267 | tunnelProvider.controller = null; |
252 | tunnelProvider.pcepClientController = null; | 268 | tunnelProvider.pcepClientController = null; |
253 | tunnelProvider.tunnelProviderRegistry = null; | 269 | tunnelProvider.tunnelProviderRegistry = null; |
270 | + tunnelProvider.deviceService = null; | ||
271 | + tunnelProvider.mastershipService = null; | ||
254 | } | 272 | } |
255 | } | 273 | } | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -35,6 +35,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | ... | @@ -35,6 +35,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; |
35 | import org.onosproject.incubator.net.tunnel.Tunnel; | 35 | import org.onosproject.incubator.net.tunnel.Tunnel; |
36 | import org.onosproject.incubator.net.tunnel.TunnelId; | 36 | import org.onosproject.incubator.net.tunnel.TunnelId; |
37 | import org.onosproject.incubator.net.tunnel.TunnelName; | 37 | import org.onosproject.incubator.net.tunnel.TunnelName; |
38 | +import org.onosproject.mastership.MastershipServiceAdapter; | ||
38 | import org.onosproject.net.Annotations; | 39 | import org.onosproject.net.Annotations; |
39 | import org.onosproject.net.ConnectPoint; | 40 | import org.onosproject.net.ConnectPoint; |
40 | import org.onosproject.net.DefaultAnnotations; | 41 | import org.onosproject.net.DefaultAnnotations; |
... | @@ -44,7 +45,10 @@ import org.onosproject.net.IpElementId; | ... | @@ -44,7 +45,10 @@ import org.onosproject.net.IpElementId; |
44 | import org.onosproject.net.Link; | 45 | import org.onosproject.net.Link; |
45 | import org.onosproject.net.Path; | 46 | import org.onosproject.net.Path; |
46 | import org.onosproject.net.PortNumber; | 47 | import org.onosproject.net.PortNumber; |
48 | +import org.onosproject.net.device.DeviceServiceAdapter; | ||
47 | import org.onosproject.net.provider.ProviderId; | 49 | import org.onosproject.net.provider.ProviderId; |
50 | +import org.onosproject.pcep.controller.ClientCapability; | ||
51 | +import org.onosproject.pcep.controller.PccId; | ||
48 | import org.onosproject.cfg.ComponentConfigAdapter; | 52 | import org.onosproject.cfg.ComponentConfigAdapter; |
49 | 53 | ||
50 | public class PcepTunnelProviderTest { | 54 | public class PcepTunnelProviderTest { |
... | @@ -55,6 +59,8 @@ public class PcepTunnelProviderTest { | ... | @@ -55,6 +59,8 @@ public class PcepTunnelProviderTest { |
55 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); | 59 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
56 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | 60 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
57 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); | 61 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); |
62 | + private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter(); | ||
63 | + private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter(); | ||
58 | 64 | ||
59 | @Test | 65 | @Test |
60 | public void testCasePcepSetupTunnel() { | 66 | public void testCasePcepSetupTunnel() { |
... | @@ -62,6 +68,8 @@ public class PcepTunnelProviderTest { | ... | @@ -62,6 +68,8 @@ public class PcepTunnelProviderTest { |
62 | tunnelProvider.tunnelProviderRegistry = registry; | 68 | tunnelProvider.tunnelProviderRegistry = registry; |
63 | tunnelProvider.pcepClientController = controller; | 69 | tunnelProvider.pcepClientController = controller; |
64 | tunnelProvider.controller = ctl; | 70 | tunnelProvider.controller = ctl; |
71 | + tunnelProvider.deviceService = deviceService; | ||
72 | + tunnelProvider.mastershipService = mastershipService; | ||
65 | tunnelProvider.cfgService = new ComponentConfigAdapter(); | 73 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
66 | tunnelProvider.tunnelService = tunnelService; | 74 | tunnelProvider.tunnelService = tunnelService; |
67 | tunnelProvider.activate(); | 75 | tunnelProvider.activate(); |
... | @@ -99,6 +107,8 @@ public class PcepTunnelProviderTest { | ... | @@ -99,6 +107,8 @@ public class PcepTunnelProviderTest { |
99 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 107 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
100 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), | 108 | new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"), |
101 | path, annotations); | 109 | path, annotations); |
110 | + controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability( | ||
111 | + new ClientCapability(true, true, true, true, true)); | ||
102 | 112 | ||
103 | tunnelProvider.setupTunnel(tunnel, path); | 113 | tunnelProvider.setupTunnel(tunnel, path); |
104 | 114 | ||
... | @@ -109,6 +119,8 @@ public class PcepTunnelProviderTest { | ... | @@ -109,6 +119,8 @@ public class PcepTunnelProviderTest { |
109 | public void tearDown() throws IOException { | 119 | public void tearDown() throws IOException { |
110 | tunnelProvider.deactivate(); | 120 | tunnelProvider.deactivate(); |
111 | tunnelProvider.controller = null; | 121 | tunnelProvider.controller = null; |
122 | + tunnelProvider.deviceService = null; | ||
123 | + tunnelProvider.mastershipService = null; | ||
112 | tunnelProvider.pcepClientController = null; | 124 | tunnelProvider.pcepClientController = null; |
113 | tunnelProvider.tunnelProviderRegistry = null; | 125 | tunnelProvider.tunnelProviderRegistry = null; |
114 | } | 126 | } | ... | ... |
... | @@ -47,6 +47,10 @@ import org.onosproject.net.Link; | ... | @@ -47,6 +47,10 @@ import org.onosproject.net.Link; |
47 | import org.onosproject.net.Path; | 47 | import org.onosproject.net.Path; |
48 | import org.onosproject.net.PortNumber; | 48 | import org.onosproject.net.PortNumber; |
49 | import org.onosproject.net.provider.ProviderId; | 49 | import org.onosproject.net.provider.ProviderId; |
50 | +import org.onosproject.pcep.controller.ClientCapability; | ||
51 | +import org.onosproject.pcep.controller.LspKey; | ||
52 | +import org.onosproject.pcep.controller.PccId; | ||
53 | +import org.onosproject.pcepio.protocol.PcepVersion; | ||
50 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | 54 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
51 | 55 | ||
52 | import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; | 56 | import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING; |
... | @@ -99,7 +103,7 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -99,7 +103,7 @@ public class PcepUpdateTunnelProviderTest { |
99 | 103 | ||
100 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); | 104 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
101 | 105 | ||
102 | - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); | 106 | + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024)); |
103 | 107 | ||
104 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) | 108 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
105 | .type(Link.Type.DIRECT).build(); | 109 | .type(Link.Type.DIRECT).build(); |
... | @@ -108,6 +112,8 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -108,6 +112,8 @@ public class PcepUpdateTunnelProviderTest { |
108 | path = new DefaultPath(pid, links, 20, EMPTY); | 112 | path = new DefaultPath(pid, links, 20, EMPTY); |
109 | 113 | ||
110 | Annotations annotations = DefaultAnnotations.builder() | 114 | Annotations annotations = DefaultAnnotations.builder() |
115 | + .set(PcepAnnotationKeys.PLSP_ID, "1") | ||
116 | + .set(PcepAnnotationKeys.LOCAL_LSP_ID, "1") | ||
111 | .set(LSP_SIG_TYPE, WITH_SIGNALLING.name()) | 117 | .set(LSP_SIG_TYPE, WITH_SIGNALLING.name()) |
112 | .build(); | 118 | .build(); |
113 | 119 | ||
... | @@ -124,6 +130,12 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -124,6 +130,12 @@ public class PcepUpdateTunnelProviderTest { |
124 | 130 | ||
125 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 131 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
126 | 132 | ||
133 | + PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101)); | ||
134 | + PcepClientAdapter pc = new PcepClientAdapter(); | ||
135 | + pc.init(pccId, PcepVersion.PCEP_1); | ||
136 | + controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); | ||
137 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); | ||
138 | + | ||
127 | tunnelProvider.updateTunnel(tunnel, path); | 139 | tunnelProvider.updateTunnel(tunnel, path); |
128 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 140 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
129 | } | 141 | } |
... | @@ -137,7 +149,7 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -137,7 +149,7 @@ public class PcepUpdateTunnelProviderTest { |
137 | Path path; | 149 | Path path; |
138 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); | 150 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); |
139 | List<Link> links = new ArrayList<>(); | 151 | List<Link> links = new ArrayList<>(); |
140 | - IpAddress srcIp = IpAddress.valueOf(0xC010103); | 152 | + IpAddress srcIp = IpAddress.valueOf(0xD010101); |
141 | IpElementId srcElementId = IpElementId.ipElement(srcIp); | 153 | IpElementId srcElementId = IpElementId.ipElement(srcIp); |
142 | 154 | ||
143 | IpAddress dstIp = IpAddress.valueOf(0xD010102); | 155 | IpAddress dstIp = IpAddress.valueOf(0xD010102); |
... | @@ -151,7 +163,7 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -151,7 +163,7 @@ public class PcepUpdateTunnelProviderTest { |
151 | 163 | ||
152 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); | 164 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
153 | 165 | ||
154 | - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); | 166 | + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024)); |
155 | 167 | ||
156 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) | 168 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
157 | .type(Link.Type.DIRECT).build(); | 169 | .type(Link.Type.DIRECT).build(); |
... | @@ -161,6 +173,8 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -161,6 +173,8 @@ public class PcepUpdateTunnelProviderTest { |
161 | 173 | ||
162 | Annotations annotations = DefaultAnnotations.builder() | 174 | Annotations annotations = DefaultAnnotations.builder() |
163 | .set(LSP_SIG_TYPE, WITH_SIGNALLING.name()) | 175 | .set(LSP_SIG_TYPE, WITH_SIGNALLING.name()) |
176 | + .set(PcepAnnotationKeys.PLSP_ID, "1") | ||
177 | + .set(PcepAnnotationKeys.LOCAL_LSP_ID, "1") | ||
164 | .build(); | 178 | .build(); |
165 | 179 | ||
166 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 180 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
... | @@ -176,6 +190,12 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -176,6 +190,12 @@ public class PcepUpdateTunnelProviderTest { |
176 | 190 | ||
177 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 191 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
178 | 192 | ||
193 | + PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101)); | ||
194 | + PcepClientAdapter pc = new PcepClientAdapter(); | ||
195 | + pc.init(pccId, PcepVersion.PCEP_1); | ||
196 | + controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); | ||
197 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); | ||
198 | + | ||
179 | tunnelProvider.updateTunnel(tunnel, path); | 199 | tunnelProvider.updateTunnel(tunnel, path); |
180 | assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); | 200 | assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); |
181 | } | 201 | } |
... | @@ -203,7 +223,7 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -203,7 +223,7 @@ public class PcepUpdateTunnelProviderTest { |
203 | 223 | ||
204 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); | 224 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
205 | 225 | ||
206 | - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); | 226 | + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024)); |
207 | 227 | ||
208 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) | 228 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
209 | .type(Link.Type.DIRECT).build(); | 229 | .type(Link.Type.DIRECT).build(); |
... | @@ -213,6 +233,8 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -213,6 +233,8 @@ public class PcepUpdateTunnelProviderTest { |
213 | 233 | ||
214 | Annotations annotations = DefaultAnnotations.builder() | 234 | Annotations annotations = DefaultAnnotations.builder() |
215 | .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name()) | 235 | .set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name()) |
236 | + .set(PcepAnnotationKeys.PLSP_ID, "1") | ||
237 | + .set(PcepAnnotationKeys.LOCAL_LSP_ID, "1") | ||
216 | .build(); | 238 | .build(); |
217 | 239 | ||
218 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 240 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
... | @@ -228,6 +250,12 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -228,6 +250,12 @@ public class PcepUpdateTunnelProviderTest { |
228 | 250 | ||
229 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 251 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
230 | 252 | ||
253 | + PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101)); | ||
254 | + PcepClientAdapter pc = new PcepClientAdapter(); | ||
255 | + pc.init(pccId, PcepVersion.PCEP_1); | ||
256 | + controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); | ||
257 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); | ||
258 | + | ||
231 | tunnelProvider.updateTunnel(tunnel, path); | 259 | tunnelProvider.updateTunnel(tunnel, path); |
232 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 260 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
233 | } | 261 | } |
... | @@ -255,7 +283,7 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -255,7 +283,7 @@ public class PcepUpdateTunnelProviderTest { |
255 | 283 | ||
256 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); | 284 | ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); |
257 | 285 | ||
258 | - ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); | 286 | + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024)); |
259 | 287 | ||
260 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) | 288 | Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) |
261 | .type(Link.Type.DIRECT).build(); | 289 | .type(Link.Type.DIRECT).build(); |
... | @@ -265,6 +293,8 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -265,6 +293,8 @@ public class PcepUpdateTunnelProviderTest { |
265 | 293 | ||
266 | Annotations annotations = DefaultAnnotations.builder() | 294 | Annotations annotations = DefaultAnnotations.builder() |
267 | .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name()) | 295 | .set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name()) |
296 | + .set(PcepAnnotationKeys.PLSP_ID, "1") | ||
297 | + .set(PcepAnnotationKeys.LOCAL_LSP_ID, "1") | ||
268 | .build(); | 298 | .build(); |
269 | 299 | ||
270 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | 300 | tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, |
... | @@ -280,6 +310,12 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -280,6 +310,12 @@ public class PcepUpdateTunnelProviderTest { |
280 | 310 | ||
281 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 311 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
282 | 312 | ||
313 | + PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101)); | ||
314 | + PcepClientAdapter pc = new PcepClientAdapter(); | ||
315 | + pc.init(pccId, PcepVersion.PCEP_1); | ||
316 | + controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); | ||
317 | + controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); | ||
318 | + | ||
283 | tunnelProvider.updateTunnel(tunnel, path); | 319 | tunnelProvider.updateTunnel(tunnel, path); |
284 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | 320 | assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); |
285 | } | 321 | } | ... | ... |
-
Please register or login to post a comment