flow: Improve flow_format() output.
authorEthan Jackson <ethan@nicira.com>
Tue, 20 Dec 2011 20:57:04 +0000 (12:57 -0800)
committerEthan Jackson <ethan@nicira.com>
Tue, 10 Jan 2012 22:29:17 +0000 (14:29 -0800)
I find this significantly easier to read.

Signed-off-by: Ethan Jackson <ethan@nicira.com>
lib/flow.c
tests/ofp-print.at

index fa7ae4f178327fa681b05c5e37832037f313e5fd..5d18212f7cbae03eca3a2c9a42a9006f816bc430 100644 (file)
@@ -518,41 +518,41 @@ flow_to_string(const struct flow *flow)
 void
 flow_format(struct ds *ds, const struct flow *flow)
 {
-    ds_put_format(ds, "priority%"PRIu32
-                      ":tunnel%#"PRIx64
-                      ":in_port%04"PRIx16,
+    ds_put_format(ds, "priority:%"PRIu32
+                      ",tunnel:%#"PRIx64
+                      ",in_port:%04"PRIx16,
                       flow->skb_priority,
                       ntohll(flow->tun_id),
                       flow->in_port);
 
-    ds_put_format(ds, ":tci(");
+    ds_put_format(ds, ",tci(");
     if (flow->vlan_tci) {
-        ds_put_format(ds, "vlan%"PRIu16",pcp%d",
+        ds_put_format(ds, "vlan:%"PRIu16",pcp:%d",
                       vlan_tci_to_vid(flow->vlan_tci),
                       vlan_tci_to_pcp(flow->vlan_tci));
     } else {
         ds_put_char(ds, '0');
     }
-    ds_put_format(ds, ") mac"ETH_ADDR_FMT"->"ETH_ADDR_FMT
-                      " type%04"PRIx16,
+    ds_put_format(ds, ") mac("ETH_ADDR_FMT"->"ETH_ADDR_FMT
+                      ") type:%04"PRIx16,
                   ETH_ADDR_ARGS(flow->dl_src),
                   ETH_ADDR_ARGS(flow->dl_dst),
                   ntohs(flow->dl_type));
 
     if (flow->dl_type == htons(ETH_TYPE_IPV6)) {
-        ds_put_format(ds, " label%#"PRIx32" proto%"PRIu8" tos%#"PRIx8
-                          " ttl%"PRIu8" ipv6",
+        ds_put_format(ds, " label:%#"PRIx32" proto:%"PRIu8" tos:%#"PRIx8
+                          " ttl:%"PRIu8" ipv6(",
                       ntohl(flow->ipv6_label), flow->nw_proto,
                       flow->nw_tos, flow->nw_ttl);
         print_ipv6_addr(ds, &flow->ipv6_src);
         ds_put_cstr(ds, "->");
         print_ipv6_addr(ds, &flow->ipv6_dst);
-
+        ds_put_char(ds, ')');
     } else {
-        ds_put_format(ds, " proto%"PRIu8" tos%#"PRIx8" ttl%"PRIu8
-                          " ip"IP_FMT"->"IP_FMT,
-                      flow->nw_proto, flow->nw_tos, flow->nw_ttl,
-                      IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst));
+        ds_put_format(ds, " proto:%"PRIu8" tos:%#"PRIx8" ttl:%"PRIu8
+                          " ip("IP_FMT"->"IP_FMT")",
+                          flow->nw_proto, flow->nw_tos, flow->nw_ttl,
+                          IP_ARGS(&flow->nw_src), IP_ARGS(&flow->nw_dst));
     }
     if (flow->nw_frag) {
         ds_put_format(ds, " frag(%s)",
@@ -561,11 +561,11 @@ flow_format(struct ds *ds, const struct flow *flow)
                       ? "later" : "<error>");
     }
     if (flow->tp_src || flow->tp_dst) {
-        ds_put_format(ds, " port%"PRIu16"->%"PRIu16,
+        ds_put_format(ds, " port(%"PRIu16"->%"PRIu16")",
                 ntohs(flow->tp_src), ntohs(flow->tp_dst));
     }
     if (!eth_addr_is_zero(flow->arp_sha) || !eth_addr_is_zero(flow->arp_tha)) {
-        ds_put_format(ds, " arp_ha"ETH_ADDR_FMT"->"ETH_ADDR_FMT,
+        ds_put_format(ds, " arp_ha("ETH_ADDR_FMT"->"ETH_ADDR_FMT")",
                 ETH_ADDR_ARGS(flow->arp_sha),
                 ETH_ADDR_ARGS(flow->arp_tha));
     }
index df5dc9bfa204b587b30cb2f74a4af2c533eff3c8..09b785bcf3e8dfb771b3b029e235a6755fdad5ff 100644 (file)
@@ -237,7 +237,7 @@ dnl The tcpdump output format differs slightly from one version to another,
 dnl so trim off the end of the line where differences appear.
 AT_CHECK([sed 's/\(length 60:\).*/\1 .../' stdout], [0], [dnl
 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=3 data_len=60 buffer=0x00000111
-priority0:tunnel0:in_port0003:tci(0) mac50:54:00:00:00:05->50:54:00:00:00:06 type0800 proto6 tos0 ttl64 ip192.168.0.1->192.168.0.2 port10031->0
+priority:0,tunnel:0,in_port:0003,tci(0) mac(50:54:00:00:00:05->50:54:00:00:00:06) type:0800 proto:6 tos:0 ttl:64 ip(192.168.0.1->192.168.0.2) port(10031->0)
 50:54:00:00:00:05 > 50:54:00:00:00:06, ethertype IPv4 (0x0800), length 60: ...
 ])
 AT_CLEANUP