Committed by
Gerrit Code Review
[ONOS] SBI part of label flow.
Change-Id: Id3af26cbf0dd7d02febfe4c13ce6fe496641e043
Showing
4 changed files
with
374 additions
and
27 deletions
protocols/pcep/pcepio/src/main/java/org/onosproject/pcepio/protocol/PcepFactory.java
100755 → 100644
... | @@ -18,117 +18,116 @@ package org.onosproject.pcepio.protocol; | ... | @@ -18,117 +18,116 @@ package org.onosproject.pcepio.protocol; |
18 | 18 | ||
19 | /** | 19 | /** |
20 | * Abstraction of an Message factory providing Builder functions to PCEP Messages and Objects. | 20 | * Abstraction of an Message factory providing Builder functions to PCEP Messages and Objects. |
21 | - * | ||
22 | */ | 21 | */ |
23 | public interface PcepFactory { | 22 | public interface PcepFactory { |
24 | 23 | ||
25 | /** | 24 | /** |
26 | - * To get Builder Object for Open Message. | 25 | + * Returns Builder Object for Open Message. |
27 | * | 26 | * |
28 | * @return Builder Object for Open Message | 27 | * @return Builder Object for Open Message |
29 | */ | 28 | */ |
30 | PcepOpenMsg.Builder buildOpenMsg(); | 29 | PcepOpenMsg.Builder buildOpenMsg(); |
31 | 30 | ||
32 | /** | 31 | /** |
33 | - * To get Builder Object for Open Object. | 32 | + * Returns Builder Object for Open Object. |
34 | * | 33 | * |
35 | * @return Builder Object for Open Object | 34 | * @return Builder Object for Open Object |
36 | */ | 35 | */ |
37 | PcepOpenObject.Builder buildOpenObject(); | 36 | PcepOpenObject.Builder buildOpenObject(); |
38 | 37 | ||
39 | /** | 38 | /** |
40 | - * To get Builder Object for Keepalive Message. | 39 | + * Returns Builder Object for Keepalive Message. |
41 | * | 40 | * |
42 | * @return Builder Object for Keepalive Message | 41 | * @return Builder Object for Keepalive Message |
43 | */ | 42 | */ |
44 | PcepKeepaliveMsg.Builder buildKeepaliveMsg(); | 43 | PcepKeepaliveMsg.Builder buildKeepaliveMsg(); |
45 | 44 | ||
46 | /** | 45 | /** |
47 | - * To get Builder Object for Close Message. | 46 | + * Returns Builder Object for Close Message. |
48 | * | 47 | * |
49 | * @return Builder Object for Close Message | 48 | * @return Builder Object for Close Message |
50 | */ | 49 | */ |
51 | PcepCloseMsg.Builder buildCloseMsg(); | 50 | PcepCloseMsg.Builder buildCloseMsg(); |
52 | 51 | ||
53 | /** | 52 | /** |
54 | - * To get Builder Object for Report Message. | 53 | + * Returns Builder Object for Report Message. |
55 | * | 54 | * |
56 | * @return Builder Object for Report Message | 55 | * @return Builder Object for Report Message |
57 | */ | 56 | */ |
58 | PcepReportMsg.Builder buildReportMsg(); | 57 | PcepReportMsg.Builder buildReportMsg(); |
59 | 58 | ||
60 | /** | 59 | /** |
61 | - * To get Builder Object for Update Message. | 60 | + * Returns Builder Object for Update Message. |
62 | * | 61 | * |
63 | * @return Builder Object for Update Message | 62 | * @return Builder Object for Update Message |
64 | */ | 63 | */ |
65 | PcepUpdateMsg.Builder buildUpdateMsg(); | 64 | PcepUpdateMsg.Builder buildUpdateMsg(); |
66 | 65 | ||
67 | /** | 66 | /** |
68 | - * To get Builder Object for Initiate Message. | 67 | + * Returns Builder Object for Initiate Message. |
69 | * | 68 | * |
70 | * @return Builder Object for Initiate Message | 69 | * @return Builder Object for Initiate Message |
71 | */ | 70 | */ |
72 | PcepInitiateMsg.Builder buildPcepInitiateMsg(); | 71 | PcepInitiateMsg.Builder buildPcepInitiateMsg(); |
73 | 72 | ||
74 | /** | 73 | /** |
75 | - * To get Builder Object for LSP Object. | 74 | + * Returns Builder Object for LSP Object. |
76 | * | 75 | * |
77 | * @return Builder Object for LSP Object | 76 | * @return Builder Object for LSP Object |
78 | */ | 77 | */ |
79 | PcepLspObject.Builder buildLspObject(); | 78 | PcepLspObject.Builder buildLspObject(); |
80 | 79 | ||
81 | /** | 80 | /** |
82 | - * To get Builder Object for SRP Object. | 81 | + * Returns Builder Object for SRP Object. |
83 | * | 82 | * |
84 | * @return Builder Object for SRP Object | 83 | * @return Builder Object for SRP Object |
85 | */ | 84 | */ |
86 | PcepSrpObject.Builder buildSrpObject(); | 85 | PcepSrpObject.Builder buildSrpObject(); |
87 | 86 | ||
88 | /** | 87 | /** |
89 | - * To get Builder Object for EndPoints Object. | 88 | + * Returns Builder Object for EndPoints Object. |
90 | * | 89 | * |
91 | * @return Builder Object for EndPoints Object | 90 | * @return Builder Object for EndPoints Object |
92 | */ | 91 | */ |
93 | PcepEndPointsObject.Builder buildEndPointsObject(); | 92 | PcepEndPointsObject.Builder buildEndPointsObject(); |
94 | 93 | ||
95 | /** | 94 | /** |
96 | - * To get Builder Object for ERO Object. | 95 | + * Returns Builder Object for ERO Object. |
97 | * | 96 | * |
98 | * @return Builder Object for ERO Object | 97 | * @return Builder Object for ERO Object |
99 | */ | 98 | */ |
100 | PcepEroObject.Builder buildEroObject(); | 99 | PcepEroObject.Builder buildEroObject(); |
101 | 100 | ||
102 | /** | 101 | /** |
103 | - * To get Builder Object for RRO Object. | 102 | + * Returns Builder Object for RRO Object. |
104 | * | 103 | * |
105 | * @return Builder Object for RRO Object | 104 | * @return Builder Object for RRO Object |
106 | */ | 105 | */ |
107 | PcepRroObject.Builder buildRroObject(); | 106 | PcepRroObject.Builder buildRroObject(); |
108 | 107 | ||
109 | /** | 108 | /** |
110 | - * To get Builder Object for LSPA Object. | 109 | + * Returns Builder Object for LSPA Object. |
111 | * | 110 | * |
112 | * @return Builder Object for LSPA Object | 111 | * @return Builder Object for LSPA Object |
113 | */ | 112 | */ |
114 | PcepLspaObject.Builder buildLspaObject(); | 113 | PcepLspaObject.Builder buildLspaObject(); |
115 | 114 | ||
116 | /** | 115 | /** |
117 | - * To get Builder Object for IRO Object. | 116 | + * Returns Builder Object for IRO Object. |
118 | * | 117 | * |
119 | * @return Builder Object for IRO Object | 118 | * @return Builder Object for IRO Object |
120 | */ | 119 | */ |
121 | PcepIroObject.Builder buildIroObject(); | 120 | PcepIroObject.Builder buildIroObject(); |
122 | 121 | ||
123 | /** | 122 | /** |
124 | - * To get Builder Object for METRIC Object. | 123 | + * Returns Builder Object for METRIC Object. |
125 | * | 124 | * |
126 | * @return Builder Object for METRIC Object | 125 | * @return Builder Object for METRIC Object |
127 | */ | 126 | */ |
128 | PcepMetricObject.Builder buildMetricObject(); | 127 | PcepMetricObject.Builder buildMetricObject(); |
129 | 128 | ||
130 | /** | 129 | /** |
131 | - * To get Builder Object for Bandwidth Object. | 130 | + * Returns Builder Object for Bandwidth Object. |
132 | * | 131 | * |
133 | * @return Builder Object for Bandwidth Object | 132 | * @return Builder Object for Bandwidth Object |
134 | */ | 133 | */ |
... | @@ -184,70 +183,77 @@ public interface PcepFactory { | ... | @@ -184,70 +183,77 @@ public interface PcepFactory { |
184 | PcepAttribute.Builder buildPcepAttribute(); | 183 | PcepAttribute.Builder buildPcepAttribute(); |
185 | 184 | ||
186 | /** | 185 | /** |
187 | - * To get Builder Object for LabelUpdate message. | 186 | + * Returns Builder Object for LabelUpdate message. |
188 | * | 187 | * |
189 | * @return Builder Object for LabelUpdate message | 188 | * @return Builder Object for LabelUpdate message |
190 | */ | 189 | */ |
191 | PcepLabelUpdateMsg.Builder buildPcepLabelUpdateMsg(); | 190 | PcepLabelUpdateMsg.Builder buildPcepLabelUpdateMsg(); |
192 | 191 | ||
193 | /** | 192 | /** |
194 | - * To get Builder Object for PcepLabelUpdate Object. | 193 | + * Returns Builder Object for PcepLabelUpdate Object. |
195 | * | 194 | * |
196 | * @return Builder Object for PcepLabelUpdate Object | 195 | * @return Builder Object for PcepLabelUpdate Object |
197 | */ | 196 | */ |
198 | PcepLabelUpdate.Builder buildPcepLabelUpdateObject(); | 197 | PcepLabelUpdate.Builder buildPcepLabelUpdateObject(); |
199 | 198 | ||
200 | /** | 199 | /** |
201 | - * To get Builder Object for PcepLabel Object. | 200 | + * Returns Builder Object for PcepLabel Object. |
202 | * | 201 | * |
203 | * @return Builder Object for PcepLabel Object | 202 | * @return Builder Object for PcepLabel Object |
204 | */ | 203 | */ |
205 | PcepLabelObject.Builder buildLabelObject(); | 204 | PcepLabelObject.Builder buildLabelObject(); |
206 | 205 | ||
207 | /** | 206 | /** |
208 | - * To get Builder Object for Error Message. | 207 | + * Returns Builder Object for Error Message. |
209 | * | 208 | * |
210 | * @return Builder Object for Error Message | 209 | * @return Builder Object for Error Message |
211 | */ | 210 | */ |
212 | PcepErrorMsg.Builder buildPcepErrorMsg(); | 211 | PcepErrorMsg.Builder buildPcepErrorMsg(); |
213 | 212 | ||
214 | /** | 213 | /** |
215 | - * To get Builder Object for Error Object. | 214 | + * Returns Builder Object for Error Object. |
216 | * | 215 | * |
217 | * @return Builder Object for Error Object | 216 | * @return Builder Object for Error Object |
218 | */ | 217 | */ |
219 | PcepErrorObject.Builder buildPcepErrorObject(); | 218 | PcepErrorObject.Builder buildPcepErrorObject(); |
220 | 219 | ||
221 | /** | 220 | /** |
222 | - * To get Builder Object for FecIpv4Adjacency. | 221 | + * Returns Builder Object for FecIpv4Adjacency. |
223 | * | 222 | * |
224 | * @return Builder Object for FecIpv4Adjacency | 223 | * @return Builder Object for FecIpv4Adjacency |
225 | */ | 224 | */ |
226 | PcepFecObjectIPv4Adjacency.Builder buildFecIpv4Adjacency(); | 225 | PcepFecObjectIPv4Adjacency.Builder buildFecIpv4Adjacency(); |
227 | 226 | ||
228 | /** | 227 | /** |
229 | - * To get Builder Object for ErrorInfo. | 228 | + * Returns Builder Object for FecObjectIPv4. |
229 | + * | ||
230 | + * @return Builder Object for FecObjectIPv4 | ||
231 | + */ | ||
232 | + PcepFecObjectIPv4.Builder buildFecObjectIpv4(); | ||
233 | + | ||
234 | + /** | ||
235 | + * Returns Builder Object for ErrorInfo. | ||
230 | * | 236 | * |
231 | * @return Builder Object for ErrorInfo | 237 | * @return Builder Object for ErrorInfo |
232 | */ | 238 | */ |
233 | PcepErrorInfo.Builder buildPcepErrorInfo(); | 239 | PcepErrorInfo.Builder buildPcepErrorInfo(); |
234 | 240 | ||
235 | /** | 241 | /** |
236 | - * To get Builder Object for PcepError. | 242 | + * Returns Builder Object for PcepError. |
237 | * | 243 | * |
238 | * @return Builder Object for PcepError | 244 | * @return Builder Object for PcepError |
239 | */ | 245 | */ |
240 | PcepError.Builder buildPcepError(); | 246 | PcepError.Builder buildPcepError(); |
241 | 247 | ||
242 | /** | 248 | /** |
243 | - * To get Builder Object for PcepLabelRangeObject. | 249 | + * Returns Builder Object for PcepLabelRangeObject. |
244 | * | 250 | * |
245 | * @return Builder Object for PcepLabelRangeObject | 251 | * @return Builder Object for PcepLabelRangeObject |
246 | */ | 252 | */ |
247 | PcepLabelRangeObject.Builder buildPcepLabelRangeObject(); | 253 | PcepLabelRangeObject.Builder buildPcepLabelRangeObject(); |
248 | 254 | ||
249 | /** | 255 | /** |
250 | - * To get Builder Object for PcepLabelRangeResvMsg. | 256 | + * Returns Builder Object for PcepLabelRangeResvMsg. |
251 | * | 257 | * |
252 | * @return Builder Object for PcepLabelRangeResvMsg | 258 | * @return Builder Object for PcepLabelRangeResvMsg |
253 | */ | 259 | */ | ... | ... |
... | @@ -27,6 +27,7 @@ import org.onosproject.pcepio.protocol.PcepError; | ... | @@ -27,6 +27,7 @@ import org.onosproject.pcepio.protocol.PcepError; |
27 | import org.onosproject.pcepio.protocol.PcepErrorMsg; | 27 | import org.onosproject.pcepio.protocol.PcepErrorMsg; |
28 | import org.onosproject.pcepio.protocol.PcepErrorObject; | 28 | import org.onosproject.pcepio.protocol.PcepErrorObject; |
29 | import org.onosproject.pcepio.protocol.PcepFactory; | 29 | import org.onosproject.pcepio.protocol.PcepFactory; |
30 | +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4.Builder; | ||
30 | import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency; | 31 | import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency; |
31 | import org.onosproject.pcepio.protocol.PcepInitiateMsg; | 32 | import org.onosproject.pcepio.protocol.PcepInitiateMsg; |
32 | import org.onosproject.pcepio.protocol.PcepIroObject; | 33 | import org.onosproject.pcepio.protocol.PcepIroObject; |
... | @@ -223,4 +224,9 @@ public class PcepFactoryVer1 implements PcepFactory { | ... | @@ -223,4 +224,9 @@ public class PcepFactoryVer1 implements PcepFactory { |
223 | public PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg() { | 224 | public PcepLabelRangeResvMsg.Builder buildPcepLabelRangeResvMsg() { |
224 | return new PcepLabelRangeResvMsgVer1.Builder(); | 225 | return new PcepLabelRangeResvMsgVer1.Builder(); |
225 | } | 226 | } |
227 | + | ||
228 | + @Override | ||
229 | + public Builder buildFecObjectIpv4() { | ||
230 | + return new PcepFecObjectIPv4Ver1.Builder(); | ||
231 | + } | ||
226 | } | 232 | } | ... | ... |
... | @@ -15,25 +15,62 @@ | ... | @@ -15,25 +15,62 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.provider.bgpcep.flow.impl; | 16 | package org.onosproject.provider.bgpcep.flow.impl; |
17 | 17 | ||
18 | +import java.util.LinkedList; | ||
19 | +import java.util.List; | ||
20 | + | ||
18 | import org.apache.felix.scr.annotations.Activate; | 21 | import org.apache.felix.scr.annotations.Activate; |
19 | import org.apache.felix.scr.annotations.Component; | 22 | import org.apache.felix.scr.annotations.Component; |
20 | import org.apache.felix.scr.annotations.Deactivate; | 23 | import org.apache.felix.scr.annotations.Deactivate; |
21 | import org.apache.felix.scr.annotations.Reference; | 24 | import org.apache.felix.scr.annotations.Reference; |
22 | import org.apache.felix.scr.annotations.ReferenceCardinality; | 25 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
26 | +import org.onlab.packet.Ip4Address; | ||
27 | +import org.onlab.packet.IpAddress; | ||
28 | +import org.onlab.packet.IpPrefix; | ||
23 | import org.onosproject.bgp.controller.BgpController; | 29 | import org.onosproject.bgp.controller.BgpController; |
24 | import org.onosproject.cfg.ComponentConfigService; | 30 | import org.onosproject.cfg.ComponentConfigService; |
25 | import org.onosproject.core.ApplicationId; | 31 | import org.onosproject.core.ApplicationId; |
32 | +import org.onosproject.incubator.net.resource.label.LabelResourceId; | ||
33 | +import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint; | ||
34 | +import org.onosproject.incubator.net.tunnel.Tunnel; | ||
35 | +import org.onosproject.incubator.net.tunnel.TunnelId; | ||
36 | +import org.onosproject.incubator.net.tunnel.TunnelService; | ||
37 | +import org.onosproject.net.ConnectPoint; | ||
38 | +import org.onosproject.net.DeviceId; | ||
39 | +import org.onosproject.net.Link; | ||
40 | +import org.onosproject.net.Path; | ||
41 | +import org.onosproject.net.PortNumber; | ||
26 | import org.onosproject.net.flow.FlowRule; | 42 | import org.onosproject.net.flow.FlowRule; |
27 | import org.onosproject.net.flow.FlowRuleBatchOperation; | 43 | import org.onosproject.net.flow.FlowRuleBatchOperation; |
28 | import org.onosproject.net.flow.FlowRuleProvider; | 44 | import org.onosproject.net.flow.FlowRuleProvider; |
29 | import org.onosproject.net.flow.FlowRuleProviderRegistry; | 45 | import org.onosproject.net.flow.FlowRuleProviderRegistry; |
30 | import org.onosproject.net.flow.FlowRuleProviderService; | 46 | import org.onosproject.net.flow.FlowRuleProviderService; |
31 | import org.onosproject.net.flow.criteria.Criterion; | 47 | import org.onosproject.net.flow.criteria.Criterion; |
48 | +import org.onosproject.net.flowobjective.Objective; | ||
32 | import org.onosproject.net.provider.AbstractProvider; | 49 | import org.onosproject.net.provider.AbstractProvider; |
33 | import org.onosproject.net.provider.ProviderId; | 50 | import org.onosproject.net.provider.ProviderId; |
34 | import org.onosproject.net.resource.ResourceService; | 51 | import org.onosproject.net.resource.ResourceService; |
35 | import org.onosproject.pcep.controller.PcepClient; | 52 | import org.onosproject.pcep.controller.PcepClient; |
36 | import org.onosproject.pcep.controller.PcepClientController; | 53 | import org.onosproject.pcep.controller.PcepClientController; |
54 | +import org.onosproject.pcepio.exceptions.PcepParseException; | ||
55 | +import org.onosproject.pcepio.protocol.PcepEroObject; | ||
56 | +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4; | ||
57 | +import org.onosproject.pcepio.protocol.PcepFecObjectIPv4Adjacency; | ||
58 | +import org.onosproject.pcepio.protocol.PcepLabelObject; | ||
59 | +import org.onosproject.pcepio.protocol.PcepLabelUpdate; | ||
60 | +import org.onosproject.pcepio.protocol.PcepLabelUpdateMsg; | ||
61 | +import org.onosproject.pcepio.protocol.PcepLspObject; | ||
62 | +import org.onosproject.pcepio.protocol.PcepMsgPath; | ||
63 | +import org.onosproject.pcepio.protocol.PcepSrpObject; | ||
64 | +import org.onosproject.pcepio.protocol.PcepUpdateMsg; | ||
65 | +import org.onosproject.pcepio.protocol.PcepUpdateRequest; | ||
66 | +import org.onosproject.pcepio.types.IPv4SubObject; | ||
67 | +import org.onosproject.pcepio.types.NexthopIPv4addressTlv; | ||
68 | +import org.onosproject.pcepio.types.PcepLabelDownload; | ||
69 | +import org.onosproject.pcepio.types.PcepLabelMap; | ||
70 | +import org.onosproject.pcepio.types.PcepValueType; | ||
71 | +import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | ||
72 | +import org.onosproject.provider.pcep.tunnel.impl.SrpIdGenerators; | ||
73 | +import org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys; | ||
37 | import org.osgi.service.component.ComponentContext; | 74 | import org.osgi.service.component.ComponentContext; |
38 | import org.slf4j.Logger; | 75 | import org.slf4j.Logger; |
39 | 76 | ||
... | @@ -63,7 +100,15 @@ public class BgpcepFlowRuleProvider extends AbstractProvider | ... | @@ -63,7 +100,15 @@ public class BgpcepFlowRuleProvider extends AbstractProvider |
63 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 100 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
64 | protected ResourceService resourceService; | 101 | protected ResourceService resourceService; |
65 | 102 | ||
103 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
104 | + protected TunnelService tunnelService; | ||
105 | + | ||
66 | private FlowRuleProviderService providerService; | 106 | private FlowRuleProviderService providerService; |
107 | + private PcepLabelObject labelObj; | ||
108 | + public static final int OUT_LABEL_TYPE = 0; | ||
109 | + public static final int IN_LABEL_TYPE = 1; | ||
110 | + public static final long IDENTIFIER_SET = 0x100000000L; | ||
111 | + public static final long SET = 0xFFFFFFFFL; | ||
67 | 112 | ||
68 | /** | 113 | /** |
69 | * Creates a BgpFlow host provider. | 114 | * Creates a BgpFlow host provider. |
... | @@ -120,6 +165,286 @@ public class BgpcepFlowRuleProvider extends AbstractProvider | ... | @@ -120,6 +165,286 @@ public class BgpcepFlowRuleProvider extends AbstractProvider |
120 | }); | 165 | }); |
121 | } | 166 | } |
122 | 167 | ||
168 | + /** | ||
169 | + * Returns PCEP client. | ||
170 | + * | ||
171 | + * @return PCEP client | ||
172 | + */ | ||
173 | + private PcepClient getPcepClient(DeviceId deviceId) { | ||
174 | + PcepClient pcc; | ||
175 | + //TODO: commented code has dependency | ||
176 | + /* Set<TeRouterId> lrsIds = resourceService.getAvailableResourceValues(Resources | ||
177 | + .discrete(deviceId()).id(), TeRouterId.class); | ||
178 | + | ||
179 | + lrsIds.forEach(lsrId -> | ||
180 | + { | ||
181 | + if (pcepController.getClient(PccId.pccId(lsrId)) != null) { | ||
182 | + pcc = pcepController.getClient(PccId.pccId(lsrId)); | ||
183 | + return pcc | ||
184 | + } | ||
185 | + });*/ | ||
186 | + return null; | ||
187 | + } | ||
188 | + | ||
189 | + //Pushes node labels to the specified device. | ||
190 | + private void pushGlobalNodeLabel(DeviceId deviceId, LabelResourceId labelId, | ||
191 | + IpPrefix ipPrefix, Objective.Operation type) throws PcepParseException { | ||
192 | + PcepClient pc = getPcepClient(deviceId); | ||
193 | + if (pc == null) { | ||
194 | + log.error("PCEP client not found"); | ||
195 | + return; | ||
196 | + } | ||
197 | + | ||
198 | + LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>(); | ||
199 | + | ||
200 | + PcepFecObjectIPv4 fecObject = pc.factory().buildFecObjectIpv4() | ||
201 | + .setNodeID(ipPrefix.address().getIp4Address().toInt()) | ||
202 | + .build(); | ||
203 | + | ||
204 | + PcepSrpObject srpObj = getSrpObject(pc, type); | ||
205 | + | ||
206 | + //Global NODE-SID as label object | ||
207 | + PcepLabelObject labelObject = pc.factory().buildLabelObject() | ||
208 | + .setLabel((int) labelId.labelId()) | ||
209 | + .build(); | ||
210 | + | ||
211 | + PcepLabelMap labelMap = new PcepLabelMap(); | ||
212 | + labelMap.setFecObject(fecObject); | ||
213 | + labelMap.setLabelObject(labelObject); | ||
214 | + labelMap.setSrpObject(srpObj); | ||
215 | + | ||
216 | + labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject() | ||
217 | + .setLabelMap(labelMap) | ||
218 | + .build()); | ||
219 | + | ||
220 | + PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg() | ||
221 | + .setPcLabelUpdateList(labelUpdateList) | ||
222 | + .build(); | ||
223 | + | ||
224 | + pc.sendMessage(labelMsg); | ||
225 | + } | ||
226 | + | ||
227 | + private PcepSrpObject getSrpObject(PcepClient pc, Objective.Operation type) throws PcepParseException { | ||
228 | + PcepSrpObject srpObj; | ||
229 | + if (type.equals(Objective.Operation.ADD)) { | ||
230 | + srpObj = pc.factory().buildSrpObject() | ||
231 | + .setRFlag(false) | ||
232 | + .setSrpID(SrpIdGenerators.create()) | ||
233 | + .build(); | ||
234 | + } else { | ||
235 | + //To cleanup labels, R bit is set | ||
236 | + srpObj = pc.factory().buildSrpObject() | ||
237 | + .setRFlag(true) | ||
238 | + .setSrpID(SrpIdGenerators.create()) | ||
239 | + .build(); | ||
240 | + } | ||
241 | + return srpObj; | ||
242 | + } | ||
243 | + | ||
244 | + //Pushes adjacency labels to the specified device. | ||
245 | + private void pushAdjacencyLabel(DeviceId deviceId, LabelResourceId labelId, | ||
246 | + PortNumber srcPortNum, PortNumber dstPortNum, Objective.Operation type) throws PcepParseException { | ||
247 | + PcepClient pc = getPcepClient(deviceId); | ||
248 | + if (pc == null) { | ||
249 | + log.error("PCEP client not found"); | ||
250 | + return; | ||
251 | + } | ||
252 | + | ||
253 | + LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>(); | ||
254 | + | ||
255 | + long srcPortNo = srcPortNum.toLong(); | ||
256 | + long dstPortNo = dstPortNum.toLong(); | ||
257 | + srcPortNo = ((srcPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? srcPortNo & SET : srcPortNo; | ||
258 | + dstPortNo = ((dstPortNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? dstPortNo & SET : dstPortNo; | ||
259 | + | ||
260 | + PcepFecObjectIPv4Adjacency fecAdjObject = pc.factory().buildFecIpv4Adjacency() | ||
261 | + .seRemoteIPv4Address((int) dstPortNo) | ||
262 | + .seLocalIPv4Address((int) srcPortNo) | ||
263 | + .build(); | ||
264 | + | ||
265 | + PcepSrpObject srpObj = getSrpObject(pc, type); | ||
266 | + | ||
267 | + //Adjacency label object | ||
268 | + PcepLabelObject labelObject = pc.factory().buildLabelObject() | ||
269 | + .setLabel((int) labelId.labelId()) | ||
270 | + .build(); | ||
271 | + | ||
272 | + PcepLabelMap labelMap = new PcepLabelMap(); | ||
273 | + labelMap.setFecObject(fecAdjObject); | ||
274 | + labelMap.setLabelObject(labelObject); | ||
275 | + labelMap.setSrpObject(srpObj); | ||
276 | + | ||
277 | + labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject() | ||
278 | + .setLabelMap(labelMap) | ||
279 | + .build()); | ||
280 | + | ||
281 | + PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg() | ||
282 | + .setPcLabelUpdateList(labelUpdateList) | ||
283 | + .build(); | ||
284 | + | ||
285 | + pc.sendMessage(labelMsg); | ||
286 | + } | ||
287 | + | ||
288 | + //Pushes local labels to the device which is specific to path [CR-case]. | ||
289 | + private void pushLocalLabels(DeviceId deviceId, LabelResourceId labelId, | ||
290 | + PortNumber portNum, TunnelId tunnelId, | ||
291 | + Boolean isBos, Long labelType, Objective.Operation type) throws PcepParseException { | ||
292 | + | ||
293 | + PcepClient pc = getPcepClient(deviceId); | ||
294 | + if (pc == null) { | ||
295 | + log.error("PCEP client not found"); | ||
296 | + return; | ||
297 | + } | ||
298 | + | ||
299 | + PcepLspObject lspObj; | ||
300 | + LinkedList<PcepLabelUpdate> labelUpdateList = new LinkedList<>(); | ||
301 | + LinkedList<PcepLabelObject> labelObjects = new LinkedList<>(); | ||
302 | + PcepSrpObject srpObj; | ||
303 | + PcepLabelDownload labelDownload = new PcepLabelDownload(); | ||
304 | + LinkedList<PcepValueType> optionalTlv = new LinkedList<>(); | ||
305 | + | ||
306 | + long portNo = portNum.toLong(); | ||
307 | + portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; | ||
308 | + | ||
309 | + optionalTlv.add(NexthopIPv4addressTlv.of((int) portNo)); | ||
310 | + | ||
311 | + Tunnel tunnel = tunnelService.queryTunnel(tunnelId); | ||
312 | + | ||
313 | + PcepLabelObject labelObj = pc.factory().buildLabelObject() | ||
314 | + .setOFlag(labelType == OUT_LABEL_TYPE ? true : false) | ||
315 | + .setOptionalTlv(optionalTlv) | ||
316 | + .setLabel((int) labelId.labelId()) | ||
317 | + .build(); | ||
318 | + | ||
319 | + /** | ||
320 | + * Check whether transit node or not. For transit node, label update message should include IN and OUT labels. | ||
321 | + * Hence store IN label object and next when out label comes add IN and OUT label objects and encode label | ||
322 | + * update message and send to specified client. | ||
323 | + */ | ||
324 | + if (!deviceId.equals(tunnel.path().src().deviceId()) && !deviceId.equals(tunnel.path().dst().deviceId())) { | ||
325 | + //Device is transit node | ||
326 | + if (labelType == IN_LABEL_TYPE) { | ||
327 | + //Store label object having IN label value | ||
328 | + this.labelObj = labelObj; | ||
329 | + return; | ||
330 | + } | ||
331 | + //Add IN label object | ||
332 | + labelObjects.add(this.labelObj); | ||
333 | + } | ||
334 | + | ||
335 | + //Add OUT label object in case of transit node | ||
336 | + labelObjects.add(labelObj); | ||
337 | + | ||
338 | + srpObj = getSrpObject(pc, type); | ||
339 | + | ||
340 | + String lspId = tunnel.annotations().value(PcepAnnotationKeys.PLSP_ID); | ||
341 | + String plspId = tunnel.annotations().value(PcepAnnotationKeys.LOCAL_LSP_ID); | ||
342 | + String tunnelIdentifier = tunnel.annotations().value(PcepAnnotationKeys.PCC_TUNNEL_ID); | ||
343 | + | ||
344 | + LinkedList<PcepValueType> tlvs = new LinkedList<>(); | ||
345 | + StatefulIPv4LspIdentifiersTlv lspIdTlv = new StatefulIPv4LspIdentifiersTlv(((IpTunnelEndPoint) tunnel.src()) | ||
346 | + .ip().getIp4Address().toInt(), Short.valueOf(lspId), Short.valueOf(tunnelIdentifier), 0, | ||
347 | + ((IpTunnelEndPoint) tunnel.dst()).ip().getIp4Address().toInt()); | ||
348 | + tlvs.add(lspIdTlv); | ||
349 | + | ||
350 | + lspObj = pc.factory().buildLspObject() | ||
351 | + .setRFlag(false) | ||
352 | + .setAFlag(true) | ||
353 | + .setDFlag(true) | ||
354 | + .setPlspId(Integer.valueOf(plspId)) | ||
355 | + .setOptionalTlv(tlvs) | ||
356 | + .build(); | ||
357 | + | ||
358 | + labelDownload.setLabelList(labelObjects); | ||
359 | + labelDownload.setLspObject(lspObj); | ||
360 | + labelDownload.setSrpObject(srpObj); | ||
361 | + | ||
362 | + labelUpdateList.add(pc.factory().buildPcepLabelUpdateObject() | ||
363 | + .setLabelDownload(labelDownload) | ||
364 | + .build()); | ||
365 | + | ||
366 | + PcepLabelUpdateMsg labelMsg = pc.factory().buildPcepLabelUpdateMsg() | ||
367 | + .setPcLabelUpdateList(labelUpdateList) | ||
368 | + .build(); | ||
369 | + | ||
370 | + pc.sendMessage(labelMsg); | ||
371 | + | ||
372 | + //If isBos is true, label download is done along the LSP, send PCEP update message. | ||
373 | + if (isBos) { | ||
374 | + sendPcepUpdateMsg(pc, lspObj, tunnel); | ||
375 | + } | ||
376 | + } | ||
377 | + | ||
378 | + //Sends PCEP update message. | ||
379 | + private void sendPcepUpdateMsg(PcepClient pc, PcepLspObject lspObj, Tunnel tunnel) throws PcepParseException { | ||
380 | + LinkedList<PcepUpdateRequest> updateRequestList = new LinkedList<>(); | ||
381 | + LinkedList<PcepValueType> subObjects = createEroSubObj(tunnel.path()); | ||
382 | + | ||
383 | + if (subObjects == null) { | ||
384 | + log.error("ERO subjects not present"); | ||
385 | + return; | ||
386 | + } | ||
387 | + | ||
388 | + PcepSrpObject srpObj = pc.factory().buildSrpObject() | ||
389 | + .setRFlag(false) | ||
390 | + .setSrpID(SrpIdGenerators.create()) | ||
391 | + .build(); | ||
392 | + | ||
393 | + PcepEroObject eroObj = pc.factory().buildEroObject() | ||
394 | + .setSubObjects(subObjects) | ||
395 | + .build(); | ||
396 | + | ||
397 | + PcepMsgPath msgPath = pc.factory().buildPcepMsgPath() | ||
398 | + .setEroObject(eroObj) | ||
399 | + .build(); | ||
400 | + | ||
401 | + PcepUpdateRequest updateReq = pc.factory().buildPcepUpdateRequest() | ||
402 | + .setSrpObject(srpObj) | ||
403 | + .setMsgPath(msgPath) | ||
404 | + .setLspObject(lspObj) | ||
405 | + .build(); | ||
406 | + | ||
407 | + updateRequestList.add(updateReq); | ||
408 | + | ||
409 | + //TODO: P = 1 is it P flag in PCEP obj header | ||
410 | + PcepUpdateMsg updateMsg = pc.factory().buildUpdateMsg() | ||
411 | + .setUpdateRequestList(updateRequestList) | ||
412 | + .build(); | ||
413 | + | ||
414 | + pc.sendMessage(updateMsg); | ||
415 | + } | ||
416 | + | ||
417 | + private LinkedList<PcepValueType> createEroSubObj(Path path) { | ||
418 | + LinkedList<PcepValueType> subObjects = new LinkedList<>(); | ||
419 | + List<Link> links = path.links(); | ||
420 | + ConnectPoint source = null; | ||
421 | + ConnectPoint destination = null; | ||
422 | + IpAddress ipDstAddress = null; | ||
423 | + IpAddress ipSrcAddress = null; | ||
424 | + PcepValueType subObj = null; | ||
425 | + long portNo; | ||
426 | + | ||
427 | + for (Link link : links) { | ||
428 | + source = link.src(); | ||
429 | + if (!(source.equals(destination))) { | ||
430 | + //set IPv4SubObject for ERO object | ||
431 | + portNo = source.port().toLong(); | ||
432 | + portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; | ||
433 | + ipSrcAddress = Ip4Address.valueOf((int) portNo); | ||
434 | + subObj = new IPv4SubObject(ipSrcAddress.getIp4Address().toInt()); | ||
435 | + subObjects.add(subObj); | ||
436 | + } | ||
437 | + | ||
438 | + destination = link.dst(); | ||
439 | + portNo = destination.port().toLong(); | ||
440 | + portNo = ((portNo & IDENTIFIER_SET) == IDENTIFIER_SET) ? portNo & SET : portNo; | ||
441 | + ipDstAddress = Ip4Address.valueOf((int) portNo); | ||
442 | + subObj = new IPv4SubObject(ipDstAddress.getIp4Address().toInt()); | ||
443 | + subObjects.add(subObj); | ||
444 | + } | ||
445 | + return subObjects; | ||
446 | + } | ||
447 | + | ||
123 | @Override | 448 | @Override |
124 | public void removeFlowRule(FlowRule... flowRules) { | 449 | public void removeFlowRule(FlowRule... flowRules) { |
125 | for (FlowRule flowRule : flowRules) { | 450 | for (FlowRule flowRule : flowRules) { | ... | ... |
... | @@ -42,6 +42,16 @@ | ... | @@ -42,6 +42,16 @@ |
42 | <artifactId>onos-bgp-api</artifactId> | 42 | <artifactId>onos-bgp-api</artifactId> |
43 | <version>${project.version}</version> | 43 | <version>${project.version}</version> |
44 | </dependency> | 44 | </dependency> |
45 | + <dependency> | ||
46 | + <groupId>org.onosproject</groupId> | ||
47 | + <artifactId>onos-pcep-provider-tunnel</artifactId> | ||
48 | + <version>${project.version}</version> | ||
49 | + </dependency> | ||
50 | + <dependency> | ||
51 | + <groupId>org.onosproject</groupId> | ||
52 | + <artifactId>onos-pcepio</artifactId> | ||
53 | + <version>${project.version}</version> | ||
54 | + </dependency> | ||
45 | </dependencies> | 55 | </dependencies> |
46 | 56 | ||
47 | </project> | 57 | </project> | ... | ... |
-
Please register or login to post a comment