ofp-util: Add version bitmap support to hello messages.
[openvswitch] / lib / ofp-print.c
index cafc665d7b10a8104e348e23bbb50e4060d932ee..c1b50e2c142ae7cf67883148a5b783ad9263ac05 100644 (file)
@@ -903,6 +903,23 @@ ofp_print_error(struct ds *string, enum ofperr error)
     ds_put_format(string, "***decode error: %s***\n", ofperr_get_name(error));
 }
 
+static void
+ofp_print_hello(struct ds *string, const struct ofp_header *oh)
+{
+    uint32_t allowed_versions;
+    bool ok;
+
+    ok = ofputil_decode_hello(oh, &allowed_versions);
+
+    ds_put_cstr(string, "\n version bitmap: ");
+    ofputil_format_version_bitmap(string, allowed_versions);
+
+    if (!ok) {
+        ds_put_cstr(string, "\n unknown data in hello:\n");
+        ds_put_hex_dump(string, oh, ntohs(oh->length), 0, true);
+    }
+}
+
 static void
 ofp_print_error_msg(struct ds *string, const struct ofp_header *oh)
 {
@@ -1729,9 +1746,7 @@ ofp_to_string__(const struct ofp_header *oh, enum ofpraw raw,
     ofp_header_to_string__(oh, raw, string);
     switch (ofptype_from_ofpraw(raw)) {
     case OFPTYPE_HELLO:
-        ds_put_char(string, '\n');
-        ds_put_hex_dump(string, oh + 1, ntohs(oh->length) - sizeof *oh,
-                        0, true);
+        ofp_print_hello(string, oh);
         break;
 
     case OFPTYPE_ERROR: