Use MAC address documentation range in filter examples
[metze/wireshark/wip.git] / epan / dissectors / packet-openflow_v1.c
index 40600ece0e3137bc327de22b65239aee7c8362d2..437b3261e15577b1788993eded5fa3708814cd55 100644 (file)
 
 #include "config.h"
 
-#include <glib.h>
-
 #include <epan/packet.h>
 #include <epan/expert.h>
 
 void proto_register_openflow_v1(void);
-void proto_reg_handoff_openflow_v1(void);
 
 static dissector_handle_t eth_withoutfcs_handle;
 
@@ -49,7 +46,6 @@ static int hf_openflow_datapath_impl = -1;
 static int hf_openflow_n_buffers = -1;
 static int hf_openflow_n_tables = -1;
 /* static int hf_openflow_auxiliary_id = -1; */
-/* static int hf_openflow_pad3 = -1; */
 static int hf_openflow_capabilities = -1;
 static int hf_openflow_actions = -1;
 /* static int hf_openflow_reserved32 = -1; */
@@ -116,12 +112,11 @@ static int hf_openflow_buffer_id = -1;
 static int hf_openflow_total_len = -1;
 static int hf_openflow_in_port = -1;
 static int hf_openflow_reason = -1;
+static int hf_openflow_pkt_in_pad = -1;
 /* static int hf_openflow_table_id = -1; */
 static int hf_openflow_cookie = -1;
 /* static int hf_openflow_cookie_mask = -1; */
-static int hf_openflow_padd8 = -1;
-/* static int hf_openflow_padd16 = -1; */
-/* static int hf_openflow_padd48 = -1; */
+static int hf_openflow_features_reply_pad = -1;
 static int hf_openflow_actions_len = -1;
 static int hf_openflow_action_type = -1;
 static int hf_openflow_action_len = -1;
@@ -133,6 +128,7 @@ static int hf_openflow_eth_src = -1;
 static int hf_openflow_eth_dst = -1;
 static int hf_openflow_dl_vlan = -1;
 static int hf_openflow_dl_vlan_pcp = -1;
+static int hf_openflow_ofp_match_pad = -1;
 static int hf_openflow_idle_timeout = -1;
 static int hf_openflow_hard_timeout = -1;
 static int hf_openflow_priority = -1;
@@ -193,19 +189,17 @@ static const value_string openflow_version_values[] = {
 
 static const value_string openflow_1_0_type_values[] = {
 /* Immutable messages. */
-
-/* Immutable messages. */
-    { 0, "OFPT_HELLO" },              /* Symmetric message */
-    { 1, "OFPT_ERROR" },              /* Symmetric message */
-    { 2, "OFPT_ECHO_REQUEST" },       /* Symmetric message */
-    { 3, "OFPT_ECHO_REPLY" },         /* Symmetric message */
-    { 4, "OFPT_VENDOR" },             /* Symmetric message */
+    { 0, "OFPT_HELLO" },                     /* Symmetric message */
+    { 1, "OFPT_ERROR" },                     /* Symmetric message */
+    { 2, "OFPT_ECHO_REQUEST" },              /* Symmetric message */
+    { 3, "OFPT_ECHO_REPLY" },                /* Symmetric message */
+    { 4, "OFPT_VENDOR" },                    /* Symmetric message */
 /* Switch configuration messages. */
-    { 5, "OFPT_FEATURES_REQUEST" },   /* Controller/switch message */
-    { 6, "OFPT_FEATURES_REPLY" },     /* Controller/switch message */
-    { 7, "OFPT_GET_CONFIG_REQUEST" }, /* Controller/switch message */
-    { 8, "OFPT_GET_CONFIG_REPLY" },   /* Controller/switch message */
-    { 9, "OFPT_SET_CONFIG" },         /* Controller/switch message */
+    { 5, "OFPT_FEATURES_REQUEST" },          /* Controller/switch message */
+    { 6, "OFPT_FEATURES_REPLY" },            /* Controller/switch message */
+    { 7, "OFPT_GET_CONFIG_REQUEST" },        /* Controller/switch message */
+    { 8, "OFPT_GET_CONFIG_REPLY" },          /* Controller/switch message */
+    { 9, "OFPT_SET_CONFIG" },                /* Controller/switch message */
 /* Asynchronous messages. */
     { 10, "OFPT_PACKET_IN" },                /* Async message */
     { 11, "OFPT_FLOW_REMOVED" },             /* Async message */
@@ -225,7 +219,7 @@ static const value_string openflow_1_0_type_values[] = {
     { 21, "OFPT_QUEUE_GET_CONFIG_REPLY" },   /* Controller/switch message */
     { 0, NULL }
 };
-
+static value_string_ext openflow_1_0_type_values_ext = VALUE_STRING_EXT_INIT(openflow_1_0_type_values);
 
 #define OFPC_FLOW_STATS   1<<0  /* Flow statistics. */
 #define OFPC_TABLE_STATS  1<<1  /* Table statistics. */
@@ -266,16 +260,16 @@ static const value_string openflow_1_0_type_values[] = {
 #define OFPPS_STP_MASK     3<<8 /* Bit mask for OFPPS_STP_* values. */
 
 
-#define OFPPF_10MB_HD      1<<0 /* 10 Mb half-duplex rate support. */
-#define OFPPF_10MB_FD      1<<1 /* 10 Mb full-duplex rate support. */
-#define OFPPF_100MB_HD     1<<2 /* 100 Mb half-duplex rate support. */
-#define OFPPF_100MB_FD     1<<3 /* 100 Mb full-duplex rate support. */
-#define OFPPF_1GB_HD       1<<4 /* 1 Gb half-duplex rate support. */
-#define OFPPF_1GB_FD       1<<5 /* 1 Gb full-duplex rate support. */
-#define OFPPF_10GB_FD      1<<6 /* 10 Gb full-duplex rate support. */
-#define OFPPF_COPPER       1<<7 /* Copper medium. */
-#define OFPPF_FIBER        1<<8 /* Fiber medium. */
-#define OFPPF_AUTONEG      1<<9 /* Auto-negotiation. */
+#define OFPPF_10MB_HD      1<<0  /* 10 Mb half-duplex rate support. */
+#define OFPPF_10MB_FD      1<<1  /* 10 Mb full-duplex rate support. */
+#define OFPPF_100MB_HD     1<<2  /* 100 Mb half-duplex rate support. */
+#define OFPPF_100MB_FD     1<<3  /* 100 Mb full-duplex rate support. */
+#define OFPPF_1GB_HD       1<<4  /* 1 Gb half-duplex rate support. */
+#define OFPPF_1GB_FD       1<<5  /* 1 Gb full-duplex rate support. */
+#define OFPPF_10GB_FD      1<<6  /* 10 Gb full-duplex rate support. */
+#define OFPPF_COPPER       1<<7  /* Copper medium. */
+#define OFPPF_FIBER        1<<8  /* Fiber medium. */
+#define OFPPF_AUTONEG      1<<9  /* Auto-negotiation. */
 #define OFPPF_PAUSE        1<<10 /* Pause. */
 #define OFPPF_PAUSE_ASYM   1<<11 /* Asymmetric pause. */
 
@@ -316,7 +310,7 @@ dissect_openflow_ofp_match_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tre
     proto_tree_add_item(tree, hf_openflow_dl_vlan_pcp, tvb, offset, 1, ENC_BIG_ENDIAN);
     offset++;
     /* uint8_t pad1[1]; Align to 64-bits */
-    proto_tree_add_item(tree, hf_openflow_padd8, tvb, offset, 1, ENC_BIG_ENDIAN);
+    proto_tree_add_item(tree, hf_openflow_ofp_match_pad, tvb, offset, 1, ENC_NA);
     offset++;
     /* uint16_t dl_type; Ethernet frame type. */
     /* uint8_t nw_tos; IP ToS (actually DSCP field, 6 bits). */
@@ -513,6 +507,9 @@ dissect_openflow_features_reply_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree
     proto_tree_add_item(tree, hf_openflow_n_tables, tvb, offset, 1, ENC_BIG_ENDIAN);
     offset++;
 
+    proto_tree_add_item(tree, hf_openflow_features_reply_pad, tvb, offset, 3, ENC_NA);
+    offset+=3;
+
     ti = proto_tree_add_item(tree, hf_openflow_capabilities, tvb, offset, 4, ENC_BIG_ENDIAN);
     cap_tree = proto_item_add_subtree(ti, ett_openflow_cap);
 
@@ -547,7 +544,7 @@ dissect_openflow_features_reply_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree
     if(length_remaining > 0){
         guint16 num_ports = length_remaining/48;
         int i;
-        if ((length_remaining&0x003f) != 0){
+        if((length_remaining&0x003f) != 0){
             /* protocol_error */
         }
         for(i=0; i<num_ports ;i++){
@@ -606,7 +603,7 @@ dissect_openflow_pkt_in(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *tree,
     proto_tree_add_item(tree, hf_openflow_reason, tvb, offset, 1, ENC_BIG_ENDIAN);
     offset++;
 
-    proto_tree_add_item(tree, hf_openflow_padd8, tvb, offset, 1, ENC_BIG_ENDIAN);
+    proto_tree_add_item(tree, hf_openflow_pkt_in_pad, tvb, offset, 1, ENC_NA);
     offset+=1;
 
     next_tvb = tvb_new_subset_length(tvb, offset, length-offset);
@@ -713,7 +710,7 @@ dissect_openflow_v1(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *d
     type    = tvb_get_guint8(tvb, 1);
 
     col_append_fstr(pinfo->cinfo, COL_INFO, "Type: %s",
-                  val_to_str_const(type, openflow_1_0_type_values, "Unknown message type"));
+                  val_to_str_ext_const(type, &openflow_1_0_type_values_ext, "Unknown message type"));
 
     /* Stop the Ethernet frame from overwriting the columns */
     if((type == OFPT_1_0_PACKET_IN) || (type == OFPT_1_0_PACKET_OUT)){
@@ -802,7 +799,7 @@ proto_register_openflow_v1(void)
         },
         { &hf_openflow_1_0_type,
             { "Type", "openflow_1_0.type",
-               FT_UINT8, BASE_DEC, VALS(openflow_1_0_type_values), 0x0,
+               FT_UINT8, BASE_DEC | BASE_EXT_STRING, &openflow_1_0_type_values_ext, 0x0,
                NULL, HFILL }
         },
         { &hf_openflow_xid,
@@ -846,13 +843,6 @@ proto_register_openflow_v1(void)
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
         },
-#endif
-#if 0
-        { &hf_openflow_pad3,
-            { "Padding", "openflow.pad3",
-               FT_UINT24, BASE_DEC, NULL, 0x0,
-               NULL, HFILL }
-        },
 #endif
         { &hf_openflow_capabilities,
             { "capabilities", "openflow.capabilities",
@@ -977,7 +967,7 @@ proto_register_openflow_v1(void)
                NULL, HFILL }
         },
         { &hf_openflow_port_name,
-            { "Name", "openflow.hw_add",
+            { "Port Name", "openflow.port_name",
                FT_STRING, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
         },
@@ -1027,7 +1017,7 @@ proto_register_openflow_v1(void)
                NULL, HFILL }
         },
         { &hf_openflow_no_recv_stp,
-            { "Drop received 802.1D STP packets", "openflow.no_recv",
+            { "Drop received 802.1D STP packets", "openflow.no_recv_stp",
                FT_BOOLEAN, 32, NULL, OFPPC_NO_RECV_STP,
                NULL, HFILL }
         },
@@ -1141,6 +1131,12 @@ proto_register_openflow_v1(void)
                FT_UINT8, BASE_DEC, VALS(openflow_reason_values), 0x0,
                NULL, HFILL }
         },
+
+        { &hf_openflow_pkt_in_pad,
+            { "Pad", "openflow.pkt_in.pad",
+               FT_BYTES, BASE_NONE, NULL, 0x0,
+               NULL, HFILL }
+        },
 #if 0
         { &hf_openflow_table_id,
             { "Table Id", "openflow.table_id",
@@ -1155,30 +1151,16 @@ proto_register_openflow_v1(void)
         },
 #if 0
         { &hf_openflow_cookie_mask,
-            { "Cookie mask", "openflow.cookie",
+            { "Cookie mask", "openflow.cookie_mask",
                FT_UINT64, BASE_HEX, NULL, 0x0,
                NULL, HFILL }
         },
 #endif
-        { &hf_openflow_padd8,
-            { "Padding", "openflow.padding8",
-               FT_UINT8, BASE_DEC, NULL, 0x0,
-               NULL, HFILL }
-        },
-#if 0
-        { &hf_openflow_padd16,
-            { "Padding", "openflow.padding16",
-               FT_UINT16, BASE_DEC, NULL, 0x0,
-               NULL, HFILL }
-        },
-#endif
-#if 0
-        { &hf_openflow_padd48,
-            { "Padding", "openflow.padding48",
-               FT_UINT64, BASE_DEC, NULL, 0x0,
+        { &hf_openflow_features_reply_pad,
+            { "Pad", "openflow.features_reply.pad",
+               FT_BYTES, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
         },
-#endif
         { &hf_openflow_actions_len,
             { "Actions length", "openflow.actions_len",
                FT_UINT16, BASE_DEC, NULL, 0x0,
@@ -1220,7 +1202,7 @@ proto_register_openflow_v1(void)
                NULL, HFILL }
         },
         { &hf_openflow_eth_dst,
-            { "Ethernet destination address", "openflow.eth_src",
+            { "Ethernet destination address", "openflow.eth_dst",
                FT_ETHER, BASE_NONE, NULL, 0x0,
                NULL, HFILL }
         },
@@ -1234,6 +1216,11 @@ proto_register_openflow_v1(void)
                FT_UINT8, BASE_DEC, NULL, 0x0,
                NULL, HFILL }
         },
+        { &hf_openflow_ofp_match_pad,
+            { "Pad", "openflow.ofp_match.pad",
+              FT_BYTES, BASE_NONE, NULL, 0x0,
+               NULL, HFILL }
+        },
         { &hf_openflow_idle_timeout,
             { "Idle time-out", "openflow.idle_timeout",
                FT_UINT16, BASE_DEC, NULL, 0x0,