Lambdas are reinterpreted before being sent to Linc-OE switches. This includes
adding ability to intercept messages at the switch driver for modification before
being sent down.
Reference: ONOS-1980
Change-Id: I405b89a0fc3844555c9efa0cd9fc887a90d00280
diff --git a/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java b/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java
index 49ca5a8..0d2dc3a 100644
--- a/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java
+++ b/openflow/api/src/main/java/org/onosproject/openflow/controller/OpenFlowSwitch.java
@@ -148,4 +148,16 @@
* @return string representation of the connection to the device
*/
String channelId();
+
+ /**
+ * Prepares a message to be sent, if necessary. Default is to do nothing,
+ * since most Devices do not need to pre-process a message that's about to
+ * be sent.
+ *
+ * @param msg The message to prepare for sending
+ * @return the prepared OFMessage
+ */
+ default OFMessage prepareMessage(OFMessage msg) {
+ return msg;
+ }
}
diff --git a/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java b/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
index 50c0351..94e82a2 100644
--- a/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
+++ b/openflow/api/src/main/java/org/onosproject/openflow/controller/driver/AbstractOpenFlowSwitch.java
@@ -97,7 +97,7 @@
@Override
public final void sendMsg(OFMessage m) {
if (role == RoleState.MASTER && channel.isWritable()) {
- channel.write(Collections.singletonList(m));
+ channel.write(Collections.singletonList(prepareMessage(m)));
}
}
@@ -119,6 +119,7 @@
"a non role request message");
}
+ @Override
public final void sendHandshakeMessage(OFMessage message) {
if (!this.isDriverHandshakeComplete()) {
channel.write(Collections.singletonList(message));
@@ -155,7 +156,6 @@
return channelId;
}
-
//************************
// Switch features related
//************************