Added Yang models for ofp_match 73/1573/5
authormichal.polkorab <michal.polkorab@pantheon.sk>
Tue, 1 Oct 2013 11:53:04 +0000 (13:53 +0200)
committermichal.polkorab <michal.polkorab@pantheon.sk>
Thu, 3 Oct 2013 08:55:06 +0000 (10:55 +0200)
Added bitmap of OFPFF_* flags for FlowMod message
Updated yangtools version dependency
Fixed new yang parser detected errors
Added ethertype to actions push pbb/mpls/vlan
Added hello-elements list
Added byte[] data field to experimenter

Signed-off-by: michal.polkorab <michal.polkorab@pantheon.sk>
Change-Id: I4ef33b609db0db833e3c7caa298e555dc33a1a8a

openflow-protocol-api/pom.xml
openflow-protocol-api/src/main/yang/openflow-action.yang
openflow-protocol-api/src/main/yang/openflow-augments.yang [new file with mode: 0644]
openflow-protocol-api/src/main/yang/openflow-extensible-match.yang
openflow-protocol-api/src/main/yang/openflow-protocol.yang
openflow-protocol-api/src/main/yang/openflow-types.yang
openflow-protocol-impl/src/main/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactory.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/deserialization/factories/PacketInMessageFactoryTest.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/integration/MockPlugin.java
openflow-protocol-impl/src/test/java/org/opendaylight/openflowjava/protocol/impl/serialization/factories/SetConfigMessageFactoryTest.java

index fa09ec52881be333e48d201d149f862d61797f68..e51a38a00fe4ea97ad8f493fbc5ce7c0359a2d85 100644 (file)
@@ -11,7 +11,8 @@
        <name>Openflow Protocol Library - API</name>\r
     \r
     <properties>\r
-        <yangtools.version>0.5.8-SNAPSHOT</yangtools.version>\r
+        <yangtools.version>0.5.9-SNAPSHOT</yangtools.version>\r
+        <yangtools.generator.version>0.6.0-SNAPSHOT</yangtools.generator.version>\r
     </properties>\r
 \r
        <build>\r
@@ -46,7 +47,7 @@
                     <dependency>\r
                         <groupId>org.opendaylight.yangtools</groupId>\r
                         <artifactId>maven-sal-api-gen-plugin</artifactId>\r
-                        <version>${yangtools.version}</version>\r
+                        <version>${yangtools.generator.version}</version>\r
                         <type>jar</type>\r
                     </dependency>\r
                 </dependencies>\r
index a5dfcbfdd084949a92f802bf491c3c7154b4fc33..bb43ed402485cf40d59a8ff7ba16441004186d68 100644 (file)
@@ -8,17 +8,16 @@ module openflow-action {
         description "Initial model";
     }
 
-    /*
     identity output {
         description " Output to switch port. ";
         base oft:action;
     }
     identity copy_ttl_out {
-        description " Copy TTL "outwards" -- from next-to-outermost to outermost ";
+        description " Copy TTL \"outwards\" -- from next-to-outermost to outermost ";
         base oft:action;
     }
     identity copy_ttl_in {
-        description " Copy TTL "inwards" -- from outermost to next-to-outermost ";
+        description " Copy TTL \"inwards\" -- from outermost to next-to-outermost ";
         base oft:action;
     }
     identity set_mpls_ttl {
@@ -77,7 +76,7 @@ module openflow-action {
         description "";
         base oft:action;
     }
-    */
+    
     grouping output {
         description 
             "Action structure for OFPAT_OUTPUT, which sends packets out 'port'.
@@ -133,20 +132,26 @@ module openflow-action {
     }
 
     grouping push-pbb {
-
+        leaf ethertype {
+            type oft:ether-type;
+        }
     }
 
     grouping push-mpls {
-
+        leaf ethertype {
+            type oft:ether-type;
+        }
     }
 
     grouping push-vlan {
-
+        leaf ethertype {
+            type oft:ether-type;
+        }
     }
 
     grouping pop-mpls {
         leaf ethertype {
-            type uint16; // TODO: define ethertype type
+            type oft:ether-type;
         }
     }
 
@@ -159,46 +164,15 @@ module openflow-action {
     
     grouping action-header {
         leaf type {
-            type action-type;
-        }
-    }
-    
-    typedef action-type {
-        /* ofp_action_type */
-        type enumeration {
-            enum OUTPUT {
-                description "Output to switch port.";
-            }
-            enum SET_VLAN_VID {
-                description "Set the 802.1q VLAN id.";
-            }
-            enum SET_VLAN_PCP {
-                description "Set the 802.1q priority.";
-            }
-            enum STRIP_VLAN {
-                description "Strip the 802.1q header.";
-            }
-            enum SET_DL_SRC {
-                description "Ethernet source address.";
-            }
-            enum SET_DL_DST {
-                description "Ethernet destination address.";
+            type identityref {
+                base oft:action;
             }
-            enum SET_NW_SRC {
-                description "IP source address.";
-            }
-            enum SET_NW_DST {
-                description "IP destination address.";
-            }
-            enum SET_TP_SRC {
-                description "TCP/UDP source port.";
-            }
-            enum SET_TP_DST {
-                description "TCP/UDP destination port.";
-            }
-            enum OFPAT_VENDOR {
-                value 65535; // 0xffff
+        }
+        choice action-type {
+            case output {
+                uses output;
             }
         }
     }
+    
 }
\ No newline at end of file
diff --git a/openflow-protocol-api/src/main/yang/openflow-augments.yang b/openflow-protocol-api/src/main/yang/openflow-augments.yang
new file mode 100644 (file)
index 0000000..67297e7
--- /dev/null
@@ -0,0 +1,17 @@
+module openflow-augments {\r
+    namespace "urn:opendaylight:openflow:augments";\r
+    prefix "aug";\r
+    \r
+    import openflow-protocol {prefix ofproto;}\r
+\r
+\r
+    revision "2013-10-02" {\r
+        description "Initial model";\r
+    }\r
+\r
+     //augment "/ofproto:hello-message/ofproto:hello" {\r
+     //       leaf uid {\r
+     //           type uint16;\r
+     //       }\r
+     //}    \r
+}
\ No newline at end of file
index 9611abbc8dfad32224ea759b9d3f8c4918d344d0..3845f1ab5b9002fb779f2f8ca58148d63a5085b1 100644 (file)
@@ -1,5 +1,5 @@
 module openflow-extensible-match {
-    namespace "urn:openflowopenflow:oxm";
+    namespace "urn:opendaylight:openflow:oxm";
     prefix "oxm";
 
 
@@ -20,7 +20,6 @@ module openflow-extensible-match {
         base oft:match-type-base;
     }
     
-
     // oxm classes
         identity class {
             description "Base identity for OXM classes";
@@ -49,7 +48,7 @@ module openflow-extensible-match {
 
 
     // field types
-        /*
+        
         identity match-field {
             description "Base identity for OXM Fields";
         }
@@ -214,7 +213,7 @@ module openflow-extensible-match {
             base match-field;
             description "Match for IPv6 Extension Header pseudo-field";
         }
-        */
+        
     // Abstract definitions of fields structure
 
         grouping in-port {
@@ -739,4 +738,23 @@ module openflow-extensible-match {
                 
             }
         }
+        
+        grouping oxm-fields {
+            list match-entries {
+                leaf oxm-class {
+                    type identityref {
+                        base class;
+                    }
+                }
+                leaf oxm-match-field {
+                    type identityref {
+                        base match-field;
+                    }
+                }
+                leaf has-mask {
+                    type boolean;
+                }
+            }
+        }
+        
 }
\ No newline at end of file
index 18ee397a94325fec697640e5bb07c0d05e35be43..1b3d9b0deeecb7a380efb8dfaf2c56f098bc29b1 100644 (file)
@@ -74,6 +74,17 @@ module openflow-protocol {
                 units "kbps"; \r
             }\r
         }\r
+        \r
+        grouping match {\r
+            leaf type {\r
+                type identityref {\r
+                    base oft:match-type-base;\r
+                }\r
+            }\r
+            uses oxm:oxm-fields;\r
+        }\r
+        \r
+        \r
 \r
     // TODO: ofp_packat_queue\r
 \r
@@ -105,6 +116,10 @@ module openflow-protocol {
                 list elements {\r
                     uses ofHelloElementHeader;\r
                     \r
+                    leaf-list version-bitmap {\r
+                        type boolean;\r
+                    }\r
+                    \r
                     leaf data {\r
                         type binary;\r
                     }\r
@@ -154,6 +169,9 @@ module openflow-protocol {
                 leaf exp_type {\r
                     type uint32;\r
                 }\r
+                leaf data {\r
+                    type binary;\r
+                }\r
             }\r
         /* Switch configuration messages. */\r
             grouping features-request {\r
@@ -208,7 +226,7 @@ module openflow-protocol {
                 \r
                 uses ofHeader;\r
                 \r
-                leaf flags {\r
+                leaf-list flags {\r
                     type oft:switch-config-flag;\r
                 }\r
                 leaf miss-send-len {\r
@@ -225,7 +243,7 @@ module openflow-protocol {
                 leaf buffer-id {\r
                     // ID assigned by datapath.\r
                     type uint32;\r
-                }  \r
+                }\r
                 leaf total-len {\r
                     // Full length of frame.\r
                     type uint16;\r
@@ -242,11 +260,9 @@ module openflow-protocol {
                     // Cookie of the flow entry that was looked up.\r
                     type uint64;\r
                 }\r
-                \r
-                //TODO:: add match leaf\r
-                // leaf match {\r
-                //     type oft:match\r
-                // }\r
+                container match {\r
+                    uses match;\r
+                }\r
 \r
 // struct ofp_match match; /* Packet metadata. Variable size. */\r
 // /* The variable size and padded match is always followed by:\r
@@ -295,10 +311,9 @@ module openflow-protocol {
                 leaf byte-count {\r
                     type uint64;\r
                 }\r
-                //TODO:: add match leaf\r
-                //leaf match {\r
-                //    type oft:match;\r
-                //}\r
+                container match {\r
+                    uses match;\r
+                }\r
             } \r
             grouping port-status {\r
                 // reference "OFPT_PORT_STATUS message in Openflow Switch 1.3 Spec"\r
@@ -370,9 +385,11 @@ module openflow-protocol {
                     type uint32;\r
                 }\r
                 leaf flags {\r
-                    type uint16;\r
+                    type oft:flow-mod-flags;\r
+                }\r
+                container match {\r
+                    uses match;\r
                 }\r
-                //TODO:: add match leaf\r
             } \r
             grouping group-mod {\r
                 // reference "OFPT_GROUP_MOD message in Openflow Switch 1.3 Spec"\r
@@ -475,10 +492,8 @@ module openflow-protocol {
                         leaf cookie-mask {\r
                             type uint64;\r
                         }\r
-                        leaf match {\r
-                            type identityref {\r
-                                base oft:match-type-base;\r
-                            }\r
+                        container match {\r
+                            uses match;\r
                         }\r
                     }\r
                     case multipart-request-aggregate {\r
@@ -497,10 +512,8 @@ module openflow-protocol {
                         leaf cookie-mask {\r
                             type uint64;\r
                         }\r
-                        leaf match {\r
-                            type identityref {\r
-                                base oft:match-type-base;\r
-                            }\r
+                        container match {\r
+                            uses match;\r
                         }\r
                     }\r
                     case multipart-request-port-stats {\r
@@ -625,8 +638,8 @@ module openflow-protocol {
                             leaf byte-count {\r
                                 type uint64;\r
                             }\r
-                            leaf match {\r
-                                type uint64;\r
+                            container match {\r
+                                uses match;\r
                             }\r
                         }\r
                     }\r
@@ -784,8 +797,11 @@ module openflow-protocol {
                         leaf-list max_groups {\r
                             type uint32;\r
                         }\r
-                        leaf-list actions {\r
-                            type ofaction:action-type;\r
+                        //leaf-list actions {\r
+                        //    type ofaction:action-type;\r
+                        //}\r
+                        list actions {\r
+                            uses ofaction:action-header;\r
                         }\r
                     }\r
                     case multipart-reply-meter {\r
@@ -1042,8 +1058,7 @@ module openflow-protocol {
             }\r
 \r
 \r
-\r
-                /* Immutable messages. */\r
+            /* Immutable messages. */\r
             notification hello-message {\r
                 uses hello;\r
                 // reference "OFPT_HELLO message in Openflow Switch 1.3 Spec"\r
index c8fde31d20239e4e277347eafbe70cc070b5d70c..b771f69230c2cfa4a9b6920161481364ba85f9c3 100644 (file)
@@ -312,7 +312,7 @@ module openflow-types {
             }
             enum OFPC_FRAG_REASM {
                 value 2; 
-                description "Reassemble (only if OFPC_IP_REASM set)."
+                description "Reassemble (only if OFPC_IP_REASM set).";
             }
             enum OFPC_FRAG_MASK {
                 value 3; 
@@ -333,7 +333,7 @@ module openflow-types {
             }
             enum OFPRR_DELETE {
                 value 2;
-                description "Evicted by a DELETE flow mod."
+                description "Evicted by a DELETE flow mod.";
             }
             enum OFPRR_GROUP_DELETE {
                 value 3;
@@ -386,6 +386,32 @@ module openflow-types {
         }
     }
     
+    typedef flow-mod-flags {
+        /* ofp_flow_mod_flags */
+        type bits {
+            bit OFPFF_SEND_FLOW_REM {
+                position 0;
+                /* Send flow removed message when flow expires or is deleted. */
+            }
+            bit OFPFF_CHECK_OVERLAP {
+                position 1;
+                /* Check for overlapping entries first. */
+            }
+            bit OFPFF_RESET_COUNTS {
+                position 2;
+                /* Reset flow packet and byte counts. */
+            }
+            bit OFPFF_NO_PKT_COUNTS {
+                position 3;
+                /* Don't keep track of packet count. */
+            }
+            bit OFPFF_NO_BYT_COUNTS {
+                position 4;
+                /* Don't keep track of byte count. */
+            }
+        }
+    }
+    
     typedef group-mod-command {
         /* ofp_group_mod_command */
         type enumeration {
index 9d5bae483919391c7ad917839dd036175fb057c4..53275d66e209a20349364d86576874912bce8e62 100644 (file)
@@ -36,8 +36,8 @@ public class SetConfigMessageFactory implements OFSerializer<SetConfigInput> {
     public void messageToBuffer(short version, ByteBuf out,\r
             SetConfigInput message) {\r
         ByteBufUtils.writeOFHeader(instance, message, out);\r
-        // TODO - finish implementation after enums provide needed funcionality\r
-        out.writeShort(message.getFlags().getIntValue());\r
+        // TODO - finish implementation after list of enums is generated\r
+        //out.writeShort(message.getFlags().getIntValue());\r
         out.writeShort(message.getMissSendLen());\r
     }\r
 \r
index fa94c278a8e3fe3fe787c0a41fb7cbfdc05954a1..4123842e7d2bb7dbd27abc42d70f8515173f8032 100644 (file)
@@ -27,7 +27,7 @@ public class PacketInMessageFactoryTest {
         BufferHelper.checkHeaderV13(builtByFactory);\r
         \r
         Assert.assertEquals("Wrong bufferID", 0x00010203L, builtByFactory.getBufferId().longValue());\r
-        Assert.assertEquals("Wrong totalLen", 0x0102, builtByFactory.getTotalLen().intValue());\r
+        Assert.assertEquals("Wrong totalLength", 0x0102, builtByFactory.getTotalLen().intValue());\r
         Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().shortValue());\r
         Assert.assertEquals("Wrong tableID", new TableId((long) 4), builtByFactory.getTableId());\r
         Assert.assertEquals("Wrong cookie", 0x0001020304050607L, builtByFactory.getCookie().longValue());\r
index 019b6746222c058649ba6d18abb9b5bb8915b3b8..3ee507eab8049f1e3c0c5164deed512e6fe5bcc7 100644 (file)
@@ -49,25 +49,25 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
 \r
     @Override\r
     public void onEchoRequestMessage(EchoRequestMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("EchoRequest message received");\r
         \r
     }\r
 \r
     @Override\r
     public void onErrorMessage(ErrorMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("Error message received");\r
         \r
     }\r
 \r
     @Override\r
     public void onExperimenterMessage(ExperimenterMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("Experimenter message received");\r
         \r
     }\r
 \r
     @Override\r
     public void onFlowRemovedMessage(FlowRemovedMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("FlowRemoved message received");\r
         \r
     }\r
 \r
@@ -86,31 +86,28 @@ public class MockPlugin implements OpenflowProtocolListener, SwitchConnectionHan
 \r
     @Override\r
     public void onMultipartReplyMessage(MultipartReplyMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("MultipartReply message received");\r
         \r
     }\r
 \r
     @Override\r
     public void onMultipartRequestMessage(MultipartRequestMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("MultipartRequest message received");\r
         \r
     }\r
 \r
     @Override\r
     public void onPacketInMessage(PacketInMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("PacketIn message received");\r
         \r
     }\r
 \r
     @Override\r
     public void onPortStatusMessage(PortStatusMessage notification) {\r
-        // TODO Auto-generated method stub\r
+        LOGGER.debug("PortStatus message received");\r
         \r
     }\r
 \r
-    /* (non-Javadoc)\r
-     * @see org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.SystemNotificationsListener#onDisconnectEvent(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.system.rev130927.DisconnectEvent)\r
-     */\r
     @Override\r
     public void onDisconnectEvent(DisconnectEvent notification) {\r
         LOGGER.debug("disconnection ocured: "+notification.getInfo());\r
index d501371f921be590d0ec7469b939ab49e7547870..192e5827d18e79ed67b625d39d2bda3a71d725b4 100644 (file)
@@ -1,10 +1,12 @@
 /* Copyright (C)2013 Pantheon Technologies, s.r.o. All rights reserved. */\r
 package org.opendaylight.openflowjava.protocol.impl.serialization.factories;\r
 \r
+import java.util.ArrayList;\r
+\r
 import io.netty.buffer.ByteBuf;\r
 import io.netty.buffer.UnpooledByteBufAllocator;\r
-import junit.framework.Assert;\r
 \r
+import org.junit.Assert;\r
 import org.junit.Test;\r
 import org.opendaylight.openflowjava.protocol.impl.deserialization.factories.HelloMessageFactoryTest;\r
 import org.opendaylight.openflowjava.protocol.impl.util.BufferHelper;\r
@@ -12,6 +14,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev13
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInput;\r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.SetConfigInputBuilder;\r
 \r
+import com.google.common.collect.Lists;\r
+\r
 /**\r
  * @author timotej.kubas\r
  * @author michal.polkorab\r
@@ -28,7 +32,8 @@ public class SetConfigMessageFactoryTest {
     public void testSetConfigMessage() throws Exception {\r
         SetConfigInputBuilder builder = new SetConfigInputBuilder();\r
         BufferHelper.setupHeader(builder);\r
-        builder.setFlags(SwitchConfigFlag.forValue(0));\r
+        ArrayList<SwitchConfigFlag> switchList = Lists.newArrayList(SwitchConfigFlag.forValue(0));\r
+        builder.setFlags(switchList);\r
         builder.setMissSendLen(10);\r
         SetConfigInput message = builder.build();\r
         \r
@@ -37,7 +42,7 @@ public class SetConfigMessageFactoryTest {
         factory.messageToBuffer(HelloMessageFactoryTest.VERSION_YET_SUPPORTED, out, message);\r
         \r
         BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);\r
-        Assert.assertEquals("Wrong flags", message.getFlags().getIntValue(),SwitchConfigFlag.forValue(out.readUnsignedShort()).getIntValue());\r
+        Assert.assertArrayEquals("Wrong flags", message.getFlags().toArray(), switchList.toArray());\r
         Assert.assertTrue("Wrong missSendLen", message.getMissSendLen() == out.readShort());\r
     }\r
 }\r