X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fprotocol_plugins%2Fopenflow%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fprotocol_plugin%2Fopenflow%2Finternal%2FFlowConverter.java;h=8d3a1be20339b866b4165ad305f20aef2629d371;hb=6341181f02c8ebd4a2b77716d310c5a151eb556a;hp=6379b5d74e15980b18bab06d06f1e8793cbcbf0e;hpb=11837100975c9ad113e12668c09ecd78f9433f73;p=controller.git diff --git a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java index 6379b5d74e..8d3a1be203 100644 --- a/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java +++ b/opendaylight/protocol_plugins/openflow/src/main/java/org/opendaylight/controller/protocol_plugin/openflow/internal/FlowConverter.java @@ -16,29 +16,6 @@ import java.util.List; import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6FlowMod; import org.opendaylight.controller.protocol_plugin.openflow.vendorextension.v6extension.V6Match; -import org.openflow.protocol.OFFlowMod; -import org.openflow.protocol.OFMatch; -import org.openflow.protocol.OFMessage; -import org.openflow.protocol.OFPacketOut; -import org.openflow.protocol.OFPort; -import org.openflow.protocol.OFVendor; -import org.openflow.protocol.action.OFAction; -import org.openflow.protocol.action.OFActionDataLayerDestination; -import org.openflow.protocol.action.OFActionDataLayerSource; -import org.openflow.protocol.action.OFActionNetworkLayerAddress; -import org.openflow.protocol.action.OFActionNetworkLayerDestination; -import org.openflow.protocol.action.OFActionNetworkLayerSource; -import org.openflow.protocol.action.OFActionNetworkTypeOfService; -import org.openflow.protocol.action.OFActionOutput; -import org.openflow.protocol.action.OFActionStripVirtualLan; -import org.openflow.protocol.action.OFActionTransportLayer; -import org.openflow.protocol.action.OFActionTransportLayerDestination; -import org.openflow.protocol.action.OFActionTransportLayerSource; -import org.openflow.protocol.action.OFActionVirtualLanIdentifier; -import org.openflow.protocol.action.OFActionVirtualLanPriorityCodePoint; -import org.openflow.util.U16; -import org.openflow.util.U32; - import org.opendaylight.controller.sal.action.Action; import org.opendaylight.controller.sal.action.ActionType; import org.opendaylight.controller.sal.action.Controller; @@ -67,6 +44,28 @@ import org.opendaylight.controller.sal.match.MatchField; import org.opendaylight.controller.sal.match.MatchType; import org.opendaylight.controller.sal.utils.NetUtils; import org.opendaylight.controller.sal.utils.NodeConnectorCreator; +import org.openflow.protocol.OFFlowMod; +import org.openflow.protocol.OFMatch; +import org.openflow.protocol.OFMessage; +import org.openflow.protocol.OFPacketOut; +import org.openflow.protocol.OFPort; +import org.openflow.protocol.OFVendor; +import org.openflow.protocol.action.OFAction; +import org.openflow.protocol.action.OFActionDataLayerDestination; +import org.openflow.protocol.action.OFActionDataLayerSource; +import org.openflow.protocol.action.OFActionNetworkLayerAddress; +import org.openflow.protocol.action.OFActionNetworkLayerDestination; +import org.openflow.protocol.action.OFActionNetworkLayerSource; +import org.openflow.protocol.action.OFActionNetworkTypeOfService; +import org.openflow.protocol.action.OFActionOutput; +import org.openflow.protocol.action.OFActionStripVirtualLan; +import org.openflow.protocol.action.OFActionTransportLayer; +import org.openflow.protocol.action.OFActionTransportLayerDestination; +import org.openflow.protocol.action.OFActionTransportLayerSource; +import org.openflow.protocol.action.OFActionVirtualLanIdentifier; +import org.openflow.protocol.action.OFActionVirtualLanPriorityCodePoint; +import org.openflow.util.U16; +import org.openflow.util.U32; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -75,7 +74,7 @@ import org.slf4j.LoggerFactory; */ public class FlowConverter { protected static final Logger logger = LoggerFactory - .getLogger(FlowConverter.class); + .getLogger(FlowConverter.class); private Flow flow; // SAL Flow private OFMatch ofMatch; // OF 1.0 match or OF 1.0 + IPv6 extension match private List actionsList; // OF 1.0 actions @@ -101,7 +100,7 @@ public class FlowConverter { /** * Returns the match in OF 1.0 (OFMatch) form or OF 1.0 + IPv6 extensions * form (V6Match) - * + * * @return */ public OFMatch getOFMatch() { @@ -178,7 +177,7 @@ public class FlowConverter { * actually the DSCP field followed by a zero ECN */ byte tos = (Byte) match.getField(MatchType.NW_TOS).getValue(); - byte dscp = (byte) ((int) tos << 2); + byte dscp = (byte) (tos << 2); if (!isIPv6) { ofMatch.setNetworkTypeOfService(dscp); wildcards &= ~OFMatch.OFPFW_NW_TOS; @@ -256,13 +255,14 @@ public class FlowConverter { ofMatch.setWildcards(U32.t(Long.valueOf(wildcards))); } } - + logger.trace("SAL Match: {} Openflow Match: {}", flow.getMatch(), + ofMatch); return ofMatch; } /** * Returns the list of actions in OF 1.0 form - * + * * @return */ public List getOFActions() { @@ -411,18 +411,20 @@ public class FlowConverter { continue; } if (action.getType() == ActionType.SET_NEXT_HOP) { - // TODO + logger.info("Unsupported action: {}", action); continue; } } } + logger.trace("SAL Actions: {} Openflow Actions: {}", flow.getActions(), + actionsList); return actionsList; } /** * Utility to convert a SAL flow to an OF 1.0 (OFFlowMod) or to an OF 1.0 + * IPv6 extension (V6FlowMod) Flow modifier Message - * + * * @param sw * @param command * @param port @@ -483,6 +485,9 @@ public class FlowConverter { } } } + logger.trace("Openflow Match: {} Openflow Actions: {}", ofMatch, + actionsList); + logger.trace("Openflow Mod Message: {}", fm); return fm; } @@ -500,7 +505,7 @@ public class FlowConverter { if (ofMatch.getInputPort() != 0) { salMatch.setField(new MatchField(MatchType.IN_PORT, NodeConnectorCreator.createNodeConnector( - (Short) ofMatch.getInputPort(), node))); + ofMatch.getInputPort(), node))); } if (ofMatch.getDataLayerSource() != null && !NetUtils @@ -555,11 +560,11 @@ public class FlowConverter { } if (ofMatch.getTransportSource() != 0) { salMatch.setField(MatchType.TP_SRC, - ((Short) ofMatch.getTransportSource())); + ofMatch.getTransportSource()); } if (ofMatch.getTransportDestination() != 0) { salMatch.setField(MatchType.TP_DST, - ((Short) ofMatch.getTransportDestination())); + ofMatch.getTransportDestination()); } } else { // Compute OF1.0 + IPv6 extensions Match @@ -568,7 +573,7 @@ public class FlowConverter { // Mask on input port is not defined salMatch.setField(new MatchField(MatchType.IN_PORT, NodeConnectorCreator.createOFNodeConnector( - (Short) v6Match.getInputPort(), node))); + v6Match.getInputPort(), node))); } if (v6Match.getDataLayerSource() != null && !NetUtils @@ -618,11 +623,11 @@ public class FlowConverter { } if (v6Match.getTransportSource() != 0) { salMatch.setField(MatchType.TP_SRC, - ((Short) v6Match.getTransportSource())); + (v6Match.getTransportSource())); } if (v6Match.getTransportDestination() != 0) { salMatch.setField(MatchType.TP_DST, - ((Short) v6Match.getTransportDestination())); + (v6Match.getTransportDestination())); } } } @@ -684,7 +689,7 @@ public class FlowConverter { try { ip = InetAddress.getByAddress(addr); } catch (UnknownHostException e) { - logger.error("",e); + logger.error("", e); } salAction = new SetNwSrc(ip); } else if (ofAction instanceof OFActionNetworkLayerDestination) { @@ -695,7 +700,7 @@ public class FlowConverter { try { ip = InetAddress.getByAddress(addr); } catch (UnknownHostException e) { - logger.error("",e); + logger.error("", e); } salAction = new SetNwDst(ip); } else if (ofAction instanceof OFActionNetworkTypeOfService) { @@ -719,6 +724,9 @@ public class FlowConverter { // Create Flow flow = new Flow(salMatch, salActionList); } + logger.trace("Openflow Match: {} Openflow Actions: {}", ofMatch, + actionsList); + logger.trace("SAL Flow: {}", flow); return flow; }