From 1aa7f822edcf809b12d51ee74328b91aaa5895e7 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Fri, 8 Aug 2008 14:05:09 -0700 Subject: [PATCH] Make ofp_packet_in() print the flow corresponding to the buffer also. --- lib/ofp-print.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/lib/ofp-print.c b/lib/ofp-print.c index 8329e304..c8d8ad31 100644 --- a/lib/ofp-print.c +++ b/lib/ofp-print.c @@ -43,13 +43,17 @@ #include #include +#include "buffer.h" #include "compiler.h" #include "dynamic-string.h" +#include "flow.h" #include "util.h" #include "openflow.h" #include "packets.h" static void ofp_print_port_name(struct ds *string, uint16_t port); +static void ofp_print_match(struct ds *, const struct ofp_match *, + int verbosity); /* Returns a string that represents the contents of the Ethernet frame in the * 'len' bytes starting at 'data' to 'stream' as output by tcpdump. @@ -175,6 +179,28 @@ ofp_packet_in(struct ds *string, const void *oh, size_t len, int verbosity) ds_put_char(string, '\n'); if (verbosity > 0) { + struct flow flow; + struct buffer packet; + struct ofp_match match; + packet.data = (void *) op->data; + packet.size = data_len; + flow_extract(&packet, ntohs(op->in_port), &flow); + match.wildcards = 0; + match.in_port = flow.in_port; + memcpy(match.dl_src, flow.dl_src, ETH_ADDR_LEN); + memcpy(match.dl_dst, flow.dl_dst, ETH_ADDR_LEN); + match.dl_vlan = flow.dl_vlan; + match.dl_type = flow.dl_type; + match.nw_proto = flow.nw_proto; + match.pad = 0; + match.nw_src = flow.nw_src; + match.nw_dst = flow.nw_dst; + match.tp_src = flow.tp_src; + match.tp_dst = flow.tp_dst; + ofp_print_match(string, &match, verbosity); + ds_put_char(string, '\n'); + } + if (verbosity > 1) { char *packet = ofp_packet_to_string(op->data, data_len, ntohs(op->total_len)); ds_put_cstr(string, packet); -- 2.30.2