[ovs-dev] [packet_in v2 08/18] ofp-print: Print checksum in ofp_packet_to_string().
Ethan Jackson
ethan at nicira.com
Sat Jan 7 19:11:49 UTC 2012
This will improve the unit tests of future patches.
Signed-off-by: Ethan Jackson <ethan at nicira.com>
---
lib/ofp-print.c | 13 +++++++++++++
tests/ofp-print.at | 2 +-
2 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/lib/ofp-print.c b/lib/ofp-print.c
index fe4af4c..20b6537 100644
--- a/lib/ofp-print.c
+++ b/lib/ofp-print.c
@@ -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);
diff --git a/tests/ofp-print.at b/tests/ofp-print.at
index 5734174..aa3a218 100644
--- a/tests/ofp-print.at
+++ b/tests/ofp-print.at
@@ -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
--
1.7.7.1
More information about the dev
mailing list