Updating Reactive forwarding to output unicast packet and added intents to wipe-out command
diff --git a/apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java b/apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
index 21d07cb..b2f9529 100644
--- a/apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
+++ b/apps/ifwd/src/main/java/org/onlab/onos/ifwd/IntentReactiveForwarding.java
@@ -1,5 +1,7 @@
package org.onlab.onos.ifwd;
+import static org.slf4j.LoggerFactory.getLogger;
+
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -17,7 +19,9 @@
import org.onlab.onos.net.intent.HostToHostIntent;
import org.onlab.onos.net.intent.IntentId;
import org.onlab.onos.net.intent.IntentService;
+import org.onlab.onos.net.packet.DefaultOutboundPacket;
import org.onlab.onos.net.packet.InboundPacket;
+import org.onlab.onos.net.packet.OutboundPacket;
import org.onlab.onos.net.packet.PacketContext;
import org.onlab.onos.net.packet.PacketProcessor;
import org.onlab.onos.net.packet.PacketService;
@@ -25,17 +29,12 @@
import org.onlab.packet.Ethernet;
import org.slf4j.Logger;
-import static org.slf4j.LoggerFactory.getLogger;
-
/**
* WORK-IN-PROGRESS: Sample reactive forwarding application using intent framework.
*/
@Component(immediate = true)
public class IntentReactiveForwarding {
- private static final int TIMEOUT = 10;
- private static final int PRIORITY = 10;
-
private final Logger log = getLogger(getClass());
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
@@ -98,6 +97,7 @@
// Otherwise forward and be done with it.
setUpConnectivity(context, srcId, dstId);
+ forwardPacketToDst(context, dst);
}
}
@@ -117,6 +117,14 @@
context.send();
}
+ private void forwardPacketToDst(PacketContext context, Host dst) {
+ TrafficTreatment treatment = DefaultTrafficTreatment.builder().setOutput(dst.location().port()).build();
+ OutboundPacket packet = new DefaultOutboundPacket(dst.location().deviceId(),
+ treatment, context.inPacket().unparsed());
+ packetService.emit(packet);
+ log.info("sending packet: {}", packet);
+ }
+
// Install a rule forwarding the packet to the specified port.
private void setUpConnectivity(PacketContext context, HostId srcId, HostId dstId) {
TrafficSelector selector = DefaultTrafficSelector.builder().build();
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
index d0e6a70..3f90f2a 100644
--- a/cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
+++ b/cli/src/main/java/org/onlab/onos/cli/net/WipeOutCommand.java
@@ -7,6 +7,9 @@
import org.onlab.onos.net.device.DeviceService;
import org.onlab.onos.net.host.HostAdminService;
import org.onlab.onos.net.host.HostService;
+import org.onlab.onos.net.intent.Intent;
+import org.onlab.onos.net.intent.IntentService;
+import org.onlab.onos.net.intent.IntentState;
/**
* Wipes-out the entire network information base, i.e. devices, links, hosts.
@@ -28,7 +31,12 @@
for (Host host : hostService.getHosts()) {
hostAdminService.removeHost(host.id());
}
+
+ IntentService intentService = get(IntentService.class);
+ for (Intent intent : intentService.getIntents()) {
+ if (intentService.getIntentState(intent.getId()) == IntentState.INSTALLED) {
+ intentService.withdraw(intent);
+ }
+ }
}
-
-
}