blob: 4ae5121ca29fbbda70a839db86a5fb7e16b68ded [file] [log] [blame]
Pingping Linffa27d32015-04-30 14:41:03 -07001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2015-present Open Networking Foundation
Pingping Linffa27d32015-04-30 14:41:03 -07003 *
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 */
16package org.onosproject.virtualbng;
17
Pingping Lin53ae34f2015-06-09 10:07:08 -070018import com.fasterxml.jackson.databind.JsonNode;
19import com.fasterxml.jackson.databind.node.ArrayNode;
20import com.fasterxml.jackson.databind.node.ObjectNode;
Pingping Linffa27d32015-04-30 14:41:03 -070021import org.onlab.packet.Ethernet;
22import org.onlab.packet.IpAddress;
23import org.onlab.packet.IpPrefix;
24import org.onlab.packet.MacAddress;
25import org.onosproject.core.ApplicationId;
26import org.onosproject.core.CoreService;
27import org.onosproject.net.ConnectPoint;
Pingping Lindead2052015-06-08 16:07:23 -070028import org.onosproject.net.DeviceId;
Ray Milkeya2cf3a12018-02-15 16:13:56 -080029import org.onosproject.net.FilteredConnectPoint;
Pingping Linffa27d32015-04-30 14:41:03 -070030import org.onosproject.net.Host;
31import org.onosproject.net.flow.DefaultTrafficSelector;
32import org.onosproject.net.flow.DefaultTrafficTreatment;
33import org.onosproject.net.flow.TrafficSelector;
34import org.onosproject.net.flow.TrafficTreatment;
Pingping Lin4e0c73d2015-05-06 15:41:10 -070035import org.onosproject.net.host.HostEvent;
36import org.onosproject.net.host.HostListener;
Pingping Linffa27d32015-04-30 14:41:03 -070037import org.onosproject.net.host.HostService;
38import org.onosproject.net.intent.IntentService;
39import org.onosproject.net.intent.Key;
40import org.onosproject.net.intent.PointToPointIntent;
Ray Milkeyd84f89b2018-08-17 14:54:17 -070041import org.osgi.service.component.annotations.Activate;
42import org.osgi.service.component.annotations.Component;
43import org.osgi.service.component.annotations.Deactivate;
44import org.osgi.service.component.annotations.Reference;
45import org.osgi.service.component.annotations.ReferenceCardinality;
Pingping Linffa27d32015-04-30 14:41:03 -070046import org.slf4j.Logger;
47import org.slf4j.LoggerFactory;
48
Jonathan Hartbbc352f2015-10-27 19:24:36 -070049import java.util.Iterator;
50import java.util.Map;
51import java.util.Map.Entry;
52import java.util.concurrent.ConcurrentHashMap;
53
54import static com.google.common.base.Preconditions.checkNotNull;
55
Pingping Linffa27d32015-04-30 14:41:03 -070056/**
57 * This is a virtual Broadband Network Gateway (BNG) application. It mainly
58 * has 3 functions:
59 * (1) assigns and replies a public IP address to a REST request with a private
60 * IP address
61 * (2) maintains the mapping from the private IP address to the public IP address
62 * (3) installs point to point intents for the host configured with private IP
63 * address to access Internet
64 */
Ray Milkeyd84f89b2018-08-17 14:54:17 -070065@Component(immediate = true, service = VbngService.class)
Pingping Linffa27d32015-04-30 14:41:03 -070066public class VbngManager implements VbngService {
67
68 private static final String APP_NAME = "org.onosproject.virtualbng";
Pingping Lin53ae34f2015-06-09 10:07:08 -070069 private static final String VBNG_MAP_NAME = "vbng_mapping";
Pingping Linffa27d32015-04-30 14:41:03 -070070
71 private final Logger log = LoggerFactory.getLogger(getClass());
72
Ray Milkeyd84f89b2018-08-17 14:54:17 -070073 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Pingping Linffa27d32015-04-30 14:41:03 -070074 protected CoreService coreService;
75
Ray Milkeyd84f89b2018-08-17 14:54:17 -070076 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Pingping Linffa27d32015-04-30 14:41:03 -070077 protected HostService hostService;
78
Ray Milkeyd84f89b2018-08-17 14:54:17 -070079 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Pingping Linffa27d32015-04-30 14:41:03 -070080 protected IntentService intentService;
81
Ray Milkeyd84f89b2018-08-17 14:54:17 -070082 @Reference(cardinality = ReferenceCardinality.MANDATORY)
Pingping Linffa27d32015-04-30 14:41:03 -070083 protected VbngConfigurationService vbngConfigurationService;
84
85 private ApplicationId appId;
86 private Map<IpAddress, PointToPointIntent> p2pIntentsFromHost;
87 private Map<IpAddress, PointToPointIntent> p2pIntentsToHost;
88
Pingping Lindead2052015-06-08 16:07:23 -070089 // This map stores the mapping from the private IP addresses to VcpeHost.
90 // The IP addresses in this map are all the private IP addresses we failed
91 // to create vBNGs due to the next hop host was not in ONOS.
92 private Map<IpAddress, VcpeHost> privateIpAddressMap;
93
94 // Store the mapping from hostname to connect point
95 private Map<String, ConnectPoint> nodeToPort;
Pingping Lin4e0c73d2015-05-06 15:41:10 -070096
97 private HostListener hostListener;
98 private IpAddress nextHopIpAddress;
99
Pingping Lindead2052015-06-08 16:07:23 -0700100 private static final DeviceId FABRIC_DEVICE_ID =
101 DeviceId.deviceId("of:8f0e486e73000187");
102
Pingping Linffa27d32015-04-30 14:41:03 -0700103 @Activate
104 public void activate() {
105 appId = coreService.registerApplication(APP_NAME);
106 p2pIntentsFromHost = new ConcurrentHashMap<>();
107 p2pIntentsToHost = new ConcurrentHashMap<>();
Pingping Lindead2052015-06-08 16:07:23 -0700108 privateIpAddressMap = new ConcurrentHashMap<>();
109
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700110 nextHopIpAddress = vbngConfigurationService.getNextHopIpAddress();
Jonathan Hartbbc352f2015-10-27 19:24:36 -0700111 nodeToPort = vbngConfigurationService.getNodeToPort();
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700112 hostListener = new InternalHostListener();
113 hostService.addListener(hostListener);
114
Pingping Linffa27d32015-04-30 14:41:03 -0700115 log.info("vBNG Started");
Pingping Lin53ae34f2015-06-09 10:07:08 -0700116
117 // Recover the status before vBNG restarts
118 statusRecovery();
Pingping Linffa27d32015-04-30 14:41:03 -0700119 }
120
121 @Deactivate
122 public void deactivate() {
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700123 hostService.removeListener(hostListener);
Pingping Linffa27d32015-04-30 14:41:03 -0700124 log.info("vBNG Stopped");
125 }
126
Pingping Lindead2052015-06-08 16:07:23 -0700127 /**
Pingping Lin53ae34f2015-06-09 10:07:08 -0700128 * Recovers from XOS record. Re-sets up the mapping between private IP
129 * address and public IP address, re-calculates intents and re-installs
130 * those intents.
131 */
132 private void statusRecovery() {
133 log.info("vBNG starts to recover from XOS record......");
Jonathan Hartbbc352f2015-10-27 19:24:36 -0700134 ObjectNode map;
135 try {
136 RestClient restClient =
137 new RestClient(vbngConfigurationService.getXosIpAddress(),
138 vbngConfigurationService.getXosRestPort());
139 map = restClient.getRest();
140 } catch (Exception e) {
Ray Milkey6ee38b82019-02-07 08:08:26 -0800141 log.warn("Could not contact XOS {}", e.getMessage());
Jonathan Hartbbc352f2015-10-27 19:24:36 -0700142 return;
143 }
Pingping Lin53ae34f2015-06-09 10:07:08 -0700144 if (map == null) {
145 log.info("Stop to recover vBNG status due to the vBNG map "
146 + "is null!");
147 return;
148 }
149
150 log.info("Get record from XOS: {}", map);
151
152 ArrayNode array = (ArrayNode) map.get(VBNG_MAP_NAME);
153 Iterator<JsonNode> entries = array.elements();
154 while (entries.hasNext()) {
155 ObjectNode entry = (ObjectNode) entries.next();
156
157 IpAddress hostIpAdddress =
158 IpAddress.valueOf(entry.get("private_ip").asText());
159 IpAddress publicIpAddress =
160 IpAddress.valueOf(entry.get("routeable_subnet").asText());
161 MacAddress macAddress =
162 MacAddress.valueOf(entry.get("mac").asText());
163 String hostName = entry.get("hostname").asText();
164
165 // Create vBNG
166 createVbng(hostIpAdddress, publicIpAddress, macAddress, hostName);
167
168 }
169 }
170
171 /**
Pingping Lin53ae34f2015-06-09 10:07:08 -0700172 * Creates a new vBNG.
173 *
174 * @param privateIpAddress a private IP address
175 * @param publicIpAddress the public IP address for the private IP address
176 * @param hostMacAddress the MAC address for the private IP address
177 * @param hostName the host name for the private IP address
178 */
179 private void createVbng(IpAddress privateIpAddress,
180 IpAddress publicIpAddress,
181 MacAddress hostMacAddress,
182 String hostName) {
183 boolean result = vbngConfigurationService
184 .assignSpecifiedPublicIp(publicIpAddress, privateIpAddress);
185 if (!result) {
186 log.info("Assign public IP address {} for private IP address {} "
187 + "failed!", publicIpAddress, privateIpAddress);
188 log.info("Failed to create vBNG for private IP address {}",
189 privateIpAddress);
190 return;
191 }
192 log.info("[ADD] Private IP to Public IP mapping: {} --> {}",
193 privateIpAddress, publicIpAddress);
194
195 // Setup paths between the host configured with private IP and
196 // next hop
197 if (!setupForwardingPaths(privateIpAddress, publicIpAddress,
198 hostMacAddress, hostName)) {
199 privateIpAddressMap.put(privateIpAddress,
200 new VcpeHost(hostMacAddress, hostName));
201 }
202 }
203
Pingping Linffa27d32015-04-30 14:41:03 -0700204 @Override
Pingping Lindead2052015-06-08 16:07:23 -0700205 public IpAddress createVbng(IpAddress privateIpAddress,
206 MacAddress hostMacAddress,
207 String hostName) {
Pingping Linffa27d32015-04-30 14:41:03 -0700208
Pingping Linffa27d32015-04-30 14:41:03 -0700209 IpAddress publicIpAddress =
210 vbngConfigurationService.getAvailablePublicIpAddress(
211 privateIpAddress);
212 if (publicIpAddress == null) {
213 log.info("Did not find an available public IP address to use.");
214 return null;
215 }
Pingping Linde77ee52015-06-03 17:16:07 -0700216 log.info("[ADD] Private IP to Public IP mapping: {} --> {}",
Pingping Linffa27d32015-04-30 14:41:03 -0700217 privateIpAddress, publicIpAddress);
218
219 // Setup paths between the host configured with private IP and
220 // next hop
Pingping Lindead2052015-06-08 16:07:23 -0700221 if (!setupForwardingPaths(privateIpAddress, publicIpAddress,
222 hostMacAddress, hostName)) {
223 privateIpAddressMap.put(privateIpAddress,
224 new VcpeHost(hostMacAddress, hostName));
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700225 }
Pingping Linffa27d32015-04-30 14:41:03 -0700226 return publicIpAddress;
227 }
228
Pingping Lind2afaf22015-06-02 10:46:29 -0700229 @Override
230 public IpAddress deleteVbng(IpAddress privateIpAddress) {
231 // Recycle the public IP address assigned to this private IP address.
232 // Recycling will also delete the mapping entry from the private IP
233 // address to public IP address.
234 IpAddress assignedPublicIpAddress = vbngConfigurationService
235 .recycleAssignedPublicIpAddress(privateIpAddress);
236 if (assignedPublicIpAddress == null) {
237 return null;
238 }
239
Pingping Lindead2052015-06-08 16:07:23 -0700240 // Remove the private IP address from privateIpAddressMap
241 privateIpAddressMap.remove(privateIpAddress);
Pingping Lind2afaf22015-06-02 10:46:29 -0700242
243 // Remove intents
244 removeForwardingPaths(privateIpAddress);
245
246 return assignedPublicIpAddress;
247 }
248
249 /**
250 * Removes the forwarding paths in both two directions between host
251 * configured with private IP and next hop.
252 *
253 * @param privateIp the private IP address of a local host
254 */
255 private void removeForwardingPaths(IpAddress privateIp) {
256 PointToPointIntent toNextHopIntent =
257 p2pIntentsFromHost.remove(privateIp);
258 if (toNextHopIntent != null) {
259 intentService.withdraw(toNextHopIntent);
260 //intentService.purge(toNextHopIntent);
261 }
262 PointToPointIntent toLocalHostIntent =
263 p2pIntentsToHost.remove(privateIp);
264 if (toLocalHostIntent != null) {
265 intentService.withdraw(toLocalHostIntent);
266 //intentService.purge(toLocalHostIntent);
267 }
268 }
269
Pingping Linffa27d32015-04-30 14:41:03 -0700270 /**
271 * Sets up forwarding paths in both two directions between host configured
272 * with private IP and next hop.
273 *
274 * @param privateIp the private IP address of a local host
275 * @param publicIp the public IP address assigned for the private IP address
Pingping Lindead2052015-06-08 16:07:23 -0700276 * @param hostMacAddress the MAC address for the IP address
277 * @param hostName the host name for the IP address
Pingping Linffa27d32015-04-30 14:41:03 -0700278 */
Pingping Lindead2052015-06-08 16:07:23 -0700279 private boolean setupForwardingPaths(IpAddress privateIp,
280 IpAddress publicIp,
281 MacAddress hostMacAddress,
282 String hostName) {
Pingping Linffa27d32015-04-30 14:41:03 -0700283 checkNotNull(privateIp);
284 checkNotNull(publicIp);
Pingping Lindead2052015-06-08 16:07:23 -0700285 checkNotNull(hostMacAddress);
286 checkNotNull(hostName);
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700287
288 if (nextHopIpAddress == null) {
289 log.warn("Did not find next hop IP address");
290 return false;
291 }
Pingping Linffa27d32015-04-30 14:41:03 -0700292
293 // If there are already intents for private IP address in the system,
294 // we will do nothing and directly return.
295 if (p2pIntentsFromHost.containsKey(privateIp)
296 && p2pIntentsToHost.containsKey(privateIp)) {
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700297 return true;
Pingping Linffa27d32015-04-30 14:41:03 -0700298 }
299
Pingping Linffa27d32015-04-30 14:41:03 -0700300 Host nextHopHost = null;
301 if (!hostService.getHostsByIp(nextHopIpAddress).isEmpty()) {
302 nextHopHost = hostService.getHostsByIp(nextHopIpAddress)
303 .iterator().next();
304 } else {
Pingping Linffa27d32015-04-30 14:41:03 -0700305 hostService.startMonitoringIp(nextHopIpAddress);
306 if (hostService.getHostsByIp(privateIp).isEmpty()) {
307 hostService.startMonitoringIp(privateIp);
308 }
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700309 return false;
Pingping Linffa27d32015-04-30 14:41:03 -0700310 }
311
Pingping Linffa27d32015-04-30 14:41:03 -0700312 ConnectPoint nextHopConnectPoint =
313 new ConnectPoint(nextHopHost.location().elementId(),
314 nextHopHost.location().port());
Pingping Lindead2052015-06-08 16:07:23 -0700315 ConnectPoint localHostConnectPoint = nodeToPort.get(hostName);
Pingping Linffa27d32015-04-30 14:41:03 -0700316
317 // Generate and install intent for traffic from host configured with
318 // private IP
319 if (!p2pIntentsFromHost.containsKey(privateIp)) {
320 PointToPointIntent toNextHopIntent
321 = srcMatchIntentGenerator(privateIp,
322 publicIp,
323 nextHopHost.mac(),
324 nextHopConnectPoint,
325 localHostConnectPoint
326 );
327 p2pIntentsFromHost.put(privateIp, toNextHopIntent);
328 intentService.submit(toNextHopIntent);
329 }
330
331 // Generate and install intent for traffic to host configured with
332 // private IP
333 if (!p2pIntentsToHost.containsKey(privateIp)) {
334 PointToPointIntent toLocalHostIntent
335 = dstMatchIntentGenerator(publicIp,
336 privateIp,
Pingping Lindead2052015-06-08 16:07:23 -0700337 hostMacAddress,
Pingping Linffa27d32015-04-30 14:41:03 -0700338 localHostConnectPoint,
339 nextHopConnectPoint);
Pingping Lind2afaf22015-06-02 10:46:29 -0700340 p2pIntentsToHost.put(privateIp, toLocalHostIntent);
Pingping Linffa27d32015-04-30 14:41:03 -0700341 intentService.submit(toLocalHostIntent);
342 }
343
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700344 return true;
345 }
346
347 /**
348 * Listener for host events.
349 */
350 private class InternalHostListener implements HostListener {
351 @Override
352 public void event(HostEvent event) {
353 log.debug("Received HostEvent {}", event);
354
355 Host host = event.subject();
356 if (event.type() != HostEvent.Type.HOST_ADDED) {
357 return;
358 }
359
360 for (IpAddress ipAddress: host.ipAddresses()) {
Pingping Lindead2052015-06-08 16:07:23 -0700361 // The POST method from XOS gives us MAC and host name, so we
362 // do not need to do anything after receive a vCPE host event
363 // for now.
364 /*if (privateIpAddressSet.contains(ipAddress)) {
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700365 createVbngAgain(ipAddress);
Pingping Lindead2052015-06-08 16:07:23 -0700366 }*/
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700367
368 if (nextHopIpAddress != null &&
369 ipAddress.equals(nextHopIpAddress)) {
Pingping Lindead2052015-06-08 16:07:23 -0700370
371 for (Entry<IpAddress, VcpeHost> entry:
372 privateIpAddressMap.entrySet()) {
373 createVbngAgain(entry.getKey());
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700374 }
Pingping Lindead2052015-06-08 16:07:23 -0700375
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700376 }
377 }
378 }
379 }
380
381 /**
382 * Tries to create vBNG again after receiving a host event if the IP
Pingping Lindead2052015-06-08 16:07:23 -0700383 * address of the host is the next hop IP address.
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700384 *
385 * @param privateIpAddress the private IP address
386 */
387 private void createVbngAgain(IpAddress privateIpAddress) {
388 IpAddress publicIpAddress = vbngConfigurationService
389 .getAssignedPublicIpAddress(privateIpAddress);
390 if (publicIpAddress == null) {
391 // We only need to handle the private IP addresses for which we
392 // already returned the REST replies with assigned public IP
393 // addresses. If a private IP addresses does not have an assigned
394 // public IP address, we should not get it an available public IP
395 // address here, and we should delete it in the unhandled private
Pingping Lindead2052015-06-08 16:07:23 -0700396 // IP address map.
397 privateIpAddressMap.remove(privateIpAddress);
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700398 return;
399 }
Pingping Lindead2052015-06-08 16:07:23 -0700400 VcpeHost vcpeHost = privateIpAddressMap.get(privateIpAddress);
401 if (setupForwardingPaths(privateIpAddress, publicIpAddress,
402 vcpeHost.macAddress, vcpeHost.hostName)) {
403 privateIpAddressMap.remove(privateIpAddress);
Pingping Lin4e0c73d2015-05-06 15:41:10 -0700404 }
Pingping Linffa27d32015-04-30 14:41:03 -0700405 }
406
407 /**
408 * PointToPointIntent Generator.
409 * <p>
410 * The intent will match the source IP address in packet, rewrite the
411 * source IP address, and rewrite the destination MAC address.
412 * </p>
413 *
414 * @param srcIpAddress the source IP address in packet to match
415 * @param newSrcIpAddress the new source IP address to set
416 * @param dstMacAddress the destination MAC address to set
417 * @param dstConnectPoint the egress point
418 * @param srcConnectPoint the ingress point
419 * @return a PointToPointIntent
420 */
421 private PointToPointIntent srcMatchIntentGenerator(
422 IpAddress srcIpAddress,
423 IpAddress newSrcIpAddress,
424 MacAddress dstMacAddress,
425 ConnectPoint dstConnectPoint,
426 ConnectPoint srcConnectPoint) {
427 checkNotNull(srcIpAddress);
428 checkNotNull(newSrcIpAddress);
429 checkNotNull(dstMacAddress);
430 checkNotNull(dstConnectPoint);
431 checkNotNull(srcConnectPoint);
432
433 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
434 selector.matchEthType(Ethernet.TYPE_IPV4);
435 selector.matchIPSrc(IpPrefix.valueOf(srcIpAddress,
436 IpPrefix.MAX_INET_MASK_LENGTH));
437
438 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
439 treatment.setEthDst(dstMacAddress);
440 treatment.setIpSrc(newSrcIpAddress);
441
442 Key key = Key.of(srcIpAddress.toString() + "MatchSrc", appId);
443 PointToPointIntent intent = PointToPointIntent.builder()
444 .appId(appId)
445 .key(key)
446 .selector(selector.build())
447 .treatment(treatment.build())
Ray Milkeya2cf3a12018-02-15 16:13:56 -0800448 .filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint))
449 .filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint))
Pingping Linffa27d32015-04-30 14:41:03 -0700450 .build();
451
452 log.info("Generated a PointToPointIntent for traffic from local host "
453 + ": {}", intent);
454 return intent;
455 }
456
457 /**
458 * PointToPointIntent Generator.
459 * <p>
460 * The intent will match the destination IP address in packet, rewrite the
461 * destination IP address, and rewrite the destination MAC address.
462 * </p>
463 *
464 * @param dstIpAddress the destination IP address in packet to match
465 * @param newDstIpAddress the new destination IP address to set
466 * @param dstMacAddress the destination MAC address to set
467 * @param dstConnectPoint the egress point
468 * @param srcConnectPoint the ingress point
469 * @return a PointToPointIntent
470 */
471 private PointToPointIntent dstMatchIntentGenerator(
472 IpAddress dstIpAddress,
473 IpAddress newDstIpAddress,
474 MacAddress dstMacAddress,
475 ConnectPoint dstConnectPoint,
476 ConnectPoint srcConnectPoint) {
477 checkNotNull(dstIpAddress);
478 checkNotNull(newDstIpAddress);
479 checkNotNull(dstMacAddress);
480 checkNotNull(dstConnectPoint);
481 checkNotNull(srcConnectPoint);
482
483 TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
484 selector.matchEthType(Ethernet.TYPE_IPV4);
485 selector.matchIPDst(IpPrefix.valueOf(dstIpAddress,
486 IpPrefix.MAX_INET_MASK_LENGTH));
487
488 TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder();
489 treatment.setEthDst(dstMacAddress);
490 treatment.setIpDst(newDstIpAddress);
491
492 Key key = Key.of(newDstIpAddress.toString() + "MatchDst", appId);
493 PointToPointIntent intent = PointToPointIntent.builder()
494 .appId(appId)
495 .key(key)
496 .selector(selector.build())
497 .treatment(treatment.build())
Ray Milkeya2cf3a12018-02-15 16:13:56 -0800498 .filteredEgressPoint(new FilteredConnectPoint(dstConnectPoint))
499 .filteredIngressPoint(new FilteredConnectPoint(srcConnectPoint))
Pingping Linffa27d32015-04-30 14:41:03 -0700500 .build();
501 log.info("Generated a PointToPointIntent for traffic to local host "
502 + ": {}", intent);
503
504 return intent;
505 }
Pingping Lindead2052015-06-08 16:07:23 -0700506
507 /**
508 * Constructor to store the a vCPE host info.
509 */
510 private class VcpeHost {
511 MacAddress macAddress;
512 String hostName;
513 public VcpeHost(MacAddress macAddress, String hostName) {
514 this.macAddress = macAddress;
515 this.hostName = hostName;
516 }
517 }
Pingping Linffa27d32015-04-30 14:41:03 -0700518}