Add serial number to description status message.
authorJustin Pettit <jpettit@nicira.com>
Thu, 4 Sep 2008 00:51:42 +0000 (17:51 -0700)
committerJustin Pettit <jpettit@nicira.com>
Thu, 4 Sep 2008 00:51:42 +0000 (17:51 -0700)
datapath/datapath.c
ext [deleted submodule]
include/openflow.h
lib/ofp-print.c
switch/datapath.c
switch/switch.c
utilities/dpctl.c

index d68151d..d405fc1 100644 (file)
 
 
 /* Strings to describe the manufacturer, hardware, and software.  This data 
- * is queriable through the version stats message. */
-static char mfr_desc[VERSION_STR_LEN] = "Nicira Networks";
-static char hw_desc[VERSION_STR_LEN] = "Reference Linux Kernel Module";
-static char sw_desc[VERSION_STR_LEN] = VERSION;
+ * is queriable through the switch description stats message. */
+static char mfr_desc[DESC_STR_LEN] = "Nicira Networks";
+static char hw_desc[DESC_STR_LEN] = "Reference Linux Kernel Module";
+static char sw_desc[DESC_STR_LEN] = VERSION;
+static char serial_num[SERIAL_NUM_LEN] = "None";
 
 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,0)
 module_param_string(mfr_desc, mfr_desc, sizeof mfr_desc, 0444);
 module_param_string(hw_desc, hw_desc, sizeof hw_desc, 0444);
 module_param_string(sw_desc, sw_desc, sizeof sw_desc, 0444);
+module_param_string(serial_num, serial_num, sizeof serial_num, 0444);
 #else
 MODULE_PARM(mfr_desc, "s");
 MODULE_PARM(hw_desc, "s");
 MODULE_PARM(sw_desc, "s");
+MODULE_PARM(serial_num, "s");
 #endif
 
 
@@ -1218,20 +1221,21 @@ static struct nla_policy dp_genl_openflow_policy[DP_GENL_A_MAX + 1] = {
        [DP_GENL_A_DP_IDX] = { .type = NLA_U32 },
 };
 
-static int version_stats_dump(struct datapath *dp, void *state,
+static int desc_stats_dump(struct datapath *dp, void *state,
                            void *body, int *body_len)
 {
-       struct ofp_version_stats *ovs = body;
-       int n_bytes = sizeof *ovs;
+       struct ofp_desc_stats *ods = body;
+       int n_bytes = sizeof *ods;
 
        if (n_bytes > *body_len) {
                return -ENOBUFS;
        }
        *body_len = n_bytes;
 
-       strncpy(ovs->mfr_desc, mfr_desc, sizeof ovs->mfr_desc);
-       strncpy(ovs->hw_desc, hw_desc, sizeof ovs->hw_desc);
-       strncpy(ovs->sw_desc, sw_desc, sizeof ovs->sw_desc);
+       strncpy(ods->mfr_desc, mfr_desc, sizeof ods->mfr_desc);
+       strncpy(ods->hw_desc, hw_desc, sizeof ods->hw_desc);
+       strncpy(ods->sw_desc, sw_desc, sizeof ods->sw_desc);
+       strncpy(ods->serial_num, serial_num, sizeof ods->serial_num);
 
        return 0;
 }
@@ -1507,11 +1511,11 @@ struct stats_type {
 };
 
 static const struct stats_type stats[] = {
-       [OFPST_VERSION] = {
+       [OFPST_DESC] = {
                0,
                0,
                NULL,
-               version_stats_dump,
+               desc_stats_dump,
                NULL
        },
        [OFPST_FLOW] = {
diff --git a/ext b/ext
deleted file mode 160000 (submodule)
index 4cf18a5..0000000
--- a/ext
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 4cf18a517a2663e945529a16e5d18e3b676c2687
index 7456a6e..1ad8227 100644 (file)
@@ -446,8 +446,8 @@ OFP_ASSERT(sizeof(struct ofp_error_msg) == 12);
 enum ofp_stats_types {
     /* Description of this OpenFlow switch. 
      * The request body is empty.
-     * The reply body is struct ofp_version_stats. */
-    OFPST_VERSION,
+     * The reply body is struct ofp_desc_stats. */
+    OFPST_DESC,
 
     /* Individual flow statistics.
      * The request body is struct ofp_flow_stats_request.
@@ -498,15 +498,17 @@ struct ofp_stats_reply {
 };
 OFP_ASSERT(sizeof(struct ofp_stats_reply) == 12);
 
-#define VERSION_STR_LEN 256
-/* Body of reply to OFPST_VERSION request.  Each entry is a NULL-terminated 
+#define DESC_STR_LEN   256
+#define SERIAL_NUM_LEN 32
+/* Body of reply to OFPST_DESC request.  Each entry is a NULL-terminated 
  * ASCII string. */
-struct ofp_version_stats {
-    char mfr_desc[VERSION_STR_LEN];  /* Manufacturer description. */
-    char hw_desc[VERSION_STR_LEN];   /* Hardware description. */
-    char sw_desc[VERSION_STR_LEN];   /* Software description. */
+struct ofp_desc_stats {
+    char mfr_desc[DESC_STR_LEN];       /* Manufacturer description. */
+    char hw_desc[DESC_STR_LEN];        /* Hardware description. */
+    char sw_desc[DESC_STR_LEN];        /* Software description. */
+    char serial_num[SERIAL_NUM_LEN];   /* Serial number. */
 };
-OFP_ASSERT(sizeof(struct ofp_version_stats) == 768);
+OFP_ASSERT(sizeof(struct ofp_desc_stats) == 800);
 
 /* Body for ofp_stats_request of type OFPST_FLOW. */
 struct ofp_flow_stats_request {
index d758680..7cfe0a3 100644 (file)
@@ -633,14 +633,15 @@ ofp_print_port_status(struct ds *string, const void *oh, size_t len,
 }
 
 static void
-ofp_version_stats_reply(struct ds *string, const void *body, size_t len,
+ofp_desc_stats_reply(struct ds *string, const void *body, size_t len,
                      int verbosity)
 {
-    const struct ofp_version_stats *vs = body;
+    const struct ofp_desc_stats *ods = body;
 
-    ds_put_format(string, "Manufacturer: %s\n", vs->mfr_desc);
-    ds_put_format(string, "Hardware: %s\n", vs->hw_desc);
-    ds_put_format(string, "Software: %s\n", vs->sw_desc);
+    ds_put_format(string, "Manufacturer: %s\n", ods->mfr_desc);
+    ds_put_format(string, "Hardware: %s\n", ods->hw_desc);
+    ds_put_format(string, "Software: %s\n", ods->sw_desc);
+    ds_put_format(string, "Serial Num: %s\n", ods->serial_num);
 }
 
 static void
@@ -852,10 +853,10 @@ print_stats(struct ds *string, int type, const void *body, size_t body_len,
     };
 
     static const struct stats_type stats_types[] = {
-        [OFPST_VERSION] = {
-            "version",
+        [OFPST_DESC] = {
+            "description",
             { 0, 0, NULL },
-            { 0, SIZE_MAX, ofp_version_stats_reply },
+            { 0, SIZE_MAX, ofp_desc_stats_reply },
         },
         [OFPST_FLOW] = {
             "flow",
index 4776c61..c25bc3e 100644 (file)
@@ -66,6 +66,7 @@ enum br_port_status {
 extern char mfr_desc;
 extern char hw_desc;
 extern char sw_desc;
+extern char serial_num;
 
 /* Capabilities supported by this implementation. */
 #define OFP_SUPPORTED_CAPABILITIES ( OFPC_FLOW_STATS \
@@ -1239,14 +1240,15 @@ recv_flow(struct datapath *dp, const struct sender *sender UNUSED,
     }
 }
 
-static int version_stats_dump(struct datapath *dp, void *state,
+static int desc_stats_dump(struct datapath *dp, void *state,
                               struct buffer *buffer)
 {
-    struct ofp_version_stats *ovs = buffer_put_uninit(buffer, sizeof *ovs);
+    struct ofp_desc_stats *ods = buffer_put_uninit(buffer, sizeof *ods);
 
-    strncpy(ovs->mfr_desc, &mfr_desc, sizeof ovs->mfr_desc);
-    strncpy(ovs->hw_desc, &hw_desc, sizeof ovs->hw_desc);
-    strncpy(ovs->sw_desc, &sw_desc, sizeof ovs->sw_desc);
+    strncpy(ods->mfr_desc, &mfr_desc, sizeof ods->mfr_desc);
+    strncpy(ods->hw_desc, &hw_desc, sizeof ods->hw_desc);
+    strncpy(ods->sw_desc, &sw_desc, sizeof ods->sw_desc);
+    strncpy(ods->serial_num, &serial_num, sizeof ods->serial_num);
 
     return 0;
 }
@@ -1470,11 +1472,11 @@ struct stats_type {
 };
 
 static const struct stats_type stats[] = {
-    [OFPST_VERSION] = {
+    [OFPST_DESC] = {
         0,
         0,
         NULL,
-        version_stats_dump,
+        desc_stats_dump,
         NULL
     },
     [OFPST_FLOW] = {
index 28a6b42..9d307db 100644 (file)
 
 
 /* Strings to describe the manufacturer, hardware, and software.  This data 
- * is queriable through the version stats message. */
-char mfr_desc[VERSION_STR_LEN] = "Nicira Networks";
-char hw_desc[VERSION_STR_LEN] = "Reference User-Space Switch";
-char sw_desc[VERSION_STR_LEN] = VERSION;
+ * is queriable through the switch description stats message. */
+char mfr_desc[DESC_STR_LEN] = "Nicira Networks";
+char hw_desc[DESC_STR_LEN] = "Reference User-Space Switch";
+char sw_desc[DESC_STR_LEN] = VERSION;
+char serial_num[SERIAL_NUM_LEN] = "None";
 
 static void parse_options(int argc, char *argv[]);
 static void usage(void) NO_RETURN;
@@ -163,7 +164,8 @@ parse_options(int argc, char *argv[])
         OPT_MAX_BACKOFF = UCHAR_MAX + 1,
         OPT_MFR_DESC,
         OPT_HW_DESC,
-        OPT_SW_DESC
+        OPT_SW_DESC,
+        OPT_SERIAL_NUM
     };
 
     static struct option long_options[] = {
@@ -180,6 +182,7 @@ parse_options(int argc, char *argv[])
         {"mfr-desc",    required_argument, 0, OPT_MFR_DESC},
         {"hw-desc",     required_argument, 0, OPT_HW_DESC},
         {"sw-desc",     required_argument, 0, OPT_SW_DESC},
+        {"serial_num",  required_argument, 0, OPT_SERIAL_NUM},
         VCONN_SSL_LONG_OPTIONS
         {0, 0, 0, 0},
     };
@@ -259,6 +262,10 @@ parse_options(int argc, char *argv[])
             strncpy(sw_desc, optarg, sizeof sw_desc);
             break;
 
+        case OPT_SERIAL_NUM:
+            strncpy(serial_num, optarg, sizeof serial_num);
+            break;
+
         case 'l':
             if (listen_vconn_name) {
                 fatal(0, "-l or --listen may be only specified once");
index 381a1c7..62c93c6 100644 (file)
@@ -194,7 +194,7 @@ usage(void)
            "\nFor local datapaths and remote switches:\n"
            "  show SWITCH                 show basic information\n"
            "  status SWITCH [KEY]         report statistics (about KEY)\n"
-           "  dump-version SWITCH         print version information\n"
+           "  dump-desc SWITCH            print switch description\n"
            "  dump-tables SWITCH          print table stats\n"
            "  mod-port SWITCH IFACE ACT   modify port behavior\n"
            "  dump-ports SWITCH           print port statistics\n"
@@ -436,9 +436,9 @@ do_status(int argc, char *argv[])
 }
 
 static void
-do_dump_version(int argc, char *argv[])
+do_dump_desc(int argc, char *argv[])
 {
-    dump_trivial_stats_transaction(argv[1], OFPST_VERSION);
+    dump_trivial_stats_transaction(argv[1], OFPST_DESC);
 }
 
 static void
@@ -1096,7 +1096,7 @@ static struct command all_commands[] = {
 
     { "help", 0, INT_MAX, do_help },
     { "monitor", 1, 1, do_monitor },
-    { "dump-version", 1, 1, do_dump_version },
+    { "dump-desc", 1, 1, do_dump_desc },
     { "dump-tables", 1, 1, do_dump_tables },
     { "dump-flows", 1, 2, do_dump_flows },
     { "dump-aggregate", 1, 2, do_dump_aggregate },