<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>sal</artifactId>
- <version>0.5.1-SNAPSHOT</version>
+ <version>0.6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6FlowMod;
import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match;
import org.opendaylight.controller.sal.action.ActionType;
import org.opendaylight.controller.sal.action.Controller;
import org.opendaylight.controller.sal.action.Drop;
+import org.opendaylight.controller.sal.action.Enqueue;
import org.opendaylight.controller.sal.action.Flood;
import org.opendaylight.controller.sal.action.FloodAll;
import org.opendaylight.controller.sal.action.HwPath;
return flow;
}
+ private static final Map<Integer, Class<? extends Action>> actionMap = new HashMap<Integer, Class<? extends Action>>() {
+ private static final long serialVersionUID = 1L;
+ {
+ put(1 << 0, Output.class);
+ put(1 << 1, SetVlanId.class);
+ put(1 << 2, SetVlanPcp.class);
+ put(1 << 3, PopVlan.class);
+ put(1 << 4, SetDlSrc.class);
+ put(1 << 5, SetDlDst.class);
+ put(1 << 6, SetNwSrc.class);
+ put(1 << 7, SetNwDst.class);
+ put(1 << 8, SetNwTos.class);
+ put(1 << 9, SetTpSrc.class);
+ put(1 << 10, SetTpDst.class);
+ put(1 << 11, Enqueue.class);
+ }
+ };
+
+ /**
+ * Returns the supported flow actions for the netwrok node given the bitmask
+ * representing the actions the Openflow 1.0 switch supports
+ *
+ * @param ofActionBitmask
+ * OF 1.0 action bitmask
+ * @return The correspondent list of SAL Action classes
+ */
+ public static List<Class<? extends Action>> getFlowActions(int ofActionBitmask) {
+ List<Class<? extends Action>> list = new ArrayList<Class<? extends Action>>();
+
+ for (int i = 0; i < Integer.SIZE; i++) {
+ int index = 1 << i;
+ if ((index & ofActionBitmask) > 0) {
+ if (actionMap.containsKey(index)) {
+ list.add(actionMap.get(index));
+ }
+ }
+ }
+ // Add implicit SAL actions
+ list.add(Controller.class);
+ list.add(SwPath.class);
+ list.add(HwPath.class);
+ list.add(Drop.class);
+
+ return list;
+ }
+
}
import org.opendaylight.controller.protocol_plugin.openflow.core.IMessageListener;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitch;
import org.opendaylight.controller.protocol_plugin.openflow.core.ISwitchStateListener;
+import org.opendaylight.controller.sal.action.SupportedFlowActions;
import org.opendaylight.controller.sal.connection.ConnectionLocality;
import org.opendaylight.controller.sal.connection.IPluginOutConnectionService;
-import org.opendaylight.controller.sal.core.Actions;
import org.opendaylight.controller.sal.core.Buffers;
import org.opendaylight.controller.sal.core.Capabilities;
import org.opendaylight.controller.sal.core.ContainerFlow;
props.add(c);
}
int act = sw.getActions();
- Actions a = new Actions(act);
+ SupportedFlowActions a = new SupportedFlowActions(FlowConverter.getFlowActions(act));
if (a != null) {
props.add(a);
}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.sal.action;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+
+import org.opendaylight.controller.sal.core.NodeConnector;
+
+@XmlRootElement
+@XmlAccessorType(XmlAccessType.NONE)
+public class Enqueue extends Action {
+ private static final long serialVersionUID = 1L;
+ @XmlElement
+ private NodeConnector port;
+
+ /* Dummy constructor for JAXB */
+ @SuppressWarnings("unused")
+ private Enqueue() {
+ }
+
+ public Enqueue(NodeConnector port) {
+ type = ActionType.ENQUEUE;
+ this.port = port;
+ }
+
+ public NodeConnector getPort() {
+ return port;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2013 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.controller.sal.action;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.opendaylight.controller.sal.core.Property;
+
+/**
+ * @file SupportedFlowActions.java
+ *
+ * @brief Class representing the supported flow actions
+ *
+ * Describes the supported flow actions
+ */
+
+@XmlAccessorType(XmlAccessType.NONE)
+public class SupportedFlowActions extends Property {
+ private static final long serialVersionUID = 1L;
+ public static final String SupportedFlowActionsPropName = "supportedFlowActions";
+ private List<Class<? extends Action>> actions;
+
+ private SupportedFlowActions() {
+ super(SupportedFlowActionsPropName);
+ this.actions = new ArrayList<Class<? extends Action>>();
+ }
+
+ public SupportedFlowActions(List<Class<? extends Action>> actions) {
+ super(SupportedFlowActionsPropName);
+ this.actions = new ArrayList<Class<? extends Action>>(actions);
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((actions == null) ? 0 : actions.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ SupportedFlowActions other = (SupportedFlowActions) obj;
+ if (actions == null) {
+ if (other.actions != null) {
+ return false;
+ }
+ } else if (!actions.equals(other.actions)) {
+ return false;
+ }
+ return true;
+ }
+
+ public List<Class<? extends Action>> getActions() {
+ return new ArrayList<Class<? extends Action>>(this.actions);
+ }
+
+ @XmlElement(name = "value")
+ @Override
+ public String getStringValue() {
+ List<String> nameList = new ArrayList<String>();
+ for (Class<? extends Action> clazz : actions) {
+ nameList.add(clazz.getSimpleName());
+ }
+ Collections.sort(nameList);
+ return nameList.toString();
+ }
+
+ @Override
+ public Property clone() {
+ return new SupportedFlowActions(this.actions);
+ }
+
+ @Override
+ public String toString() {
+ return this.getStringValue();
+ }
+}
* @brief Class representing actions
*
* Describes supported actions
+ * @Deprecated This class is OF 1.0 specific. Use SupportedFlowActions instead.
*/
-
+@Deprecated
@XmlRootElement
@XmlAccessorType(XmlAccessType.NONE)
public class Actions extends Property {
@Override
public boolean equals(Object obj) {
- if (this == obj)
+ if (this == obj) {
return true;
- if (!super.equals(obj))
+ }
+ if (!super.equals(obj)) {
return false;
- if (getClass() != obj.getClass())
+ }
+ if (getClass() != obj.getClass()) {
return false;
+ }
Actions other = (Actions) obj;
- if (actionsValue != other.actionsValue)
+ if (actionsValue != other.actionsValue) {
return false;
+ }
return true;
}