ofp-print: Print checksum in ofp_packet_to_string().
authorEthan Jackson <ethan@nicira.com>
Wed, 21 Dec 2011 03:56:43 +0000 (19:56 -0800)
committerEthan Jackson <ethan@nicira.com>
Tue, 10 Jan 2012 22:30:14 +0000 (14:30 -0800)
This will improve the unit tests of future patches.

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

index fe4af4c800edd3619c39bc129cdbae5dce171272..20b653776e614f7b2b873662858cfa30f9616eab 100644 (file)
@@ -60,6 +60,19 @@ ofp_packet_to_string(const void *data, size_t len)
     ofpbuf_use_const(&buf, data, len);
     flow_extract(&buf, 0, 0, 0, &flow);
     flow_format(&ds, &flow);
+
+    if (buf.l7) {
+        if (flow.nw_proto == IPPROTO_TCP) {
+            struct tcp_header *th = buf.l4;
+            ds_put_format(&ds, " tcp_csum:%"PRIx16,
+                          ntohs(th->tcp_csum));
+        } else if (flow.nw_proto == IPPROTO_UDP) {
+            struct udp_header *uh = buf.l4;
+            ds_put_format(&ds, " udp_csum:%"PRIx16,
+                          ntohs(uh->udp_csum));
+        }
+    }
+
     ds_put_char(&ds, '\n');
 
     return ds_cstr(&ds);
index 5734174d50521c2ade25f0a36d1789c6667e52b3..aa3a2186b237a566ef3a6c628f07c88e58f9a247 100644 (file)
@@ -233,7 +233,7 @@ c0 a8 00 02 27 2f 00 00 78 50 cc 5b 57 af 42 1e \
 50 00 02 00 26 e8 00 00 00 00 00 00 00 00 \
 "], [0], [dnl
 OFPT_PACKET_IN (xid=0x0): total_len=60 in_port=3 data_len=60 buffer=0x00000111
-priority:0,tunnel:0,in_port:0000,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)
+priority:0,tunnel:0,in_port:0000,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) tcp_csum:26e8
 ])
 AT_CLEANUP