From 8240e9cdc74088c795e5bdb5025b38188f5c608e Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Thu, 3 Apr 2008 09:27:40 -0700 Subject: [PATCH] Make vconn log all incoming and outgoing OpenFlow packets at debug level. --- lib/vconn.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/vconn.c b/lib/vconn.c index a3314c57..84c3bbc6 100644 --- a/lib/vconn.c +++ b/lib/vconn.c @@ -40,6 +40,7 @@ #include #include "buffer.h" #include "flow.h" +#include "ofp-print.h" #include "openflow.h" #include "poll-loop.h" #include "util.h" @@ -209,6 +210,11 @@ vconn_recv(struct vconn *vconn, struct buffer **msgp) int retval = vconn_connect(vconn); if (!retval) { retval = (vconn->class->recv)(vconn, msgp); + if (VLOG_IS_DBG_ENABLED() && !retval) { + char *s = ofp_to_string((*msgp)->data, (*msgp)->size, 1); + VLOG_DBG("received: %s", s); + free(s); + } } if (retval) { *msgp = NULL; @@ -232,7 +238,16 @@ vconn_send(struct vconn *vconn, struct buffer *msg) { int retval = vconn_connect(vconn); if (!retval) { - retval = (vconn->class->send)(vconn, msg); + if (!VLOG_IS_DBG_ENABLED()) { + retval = (vconn->class->send)(vconn, msg); + } else { + char *s = ofp_to_string(msg->data, msg->size, 1); + retval = (vconn->class->send)(vconn, msg); + if (retval != EAGAIN) { + VLOG_DBG("sent (%s): %s", strerror(retval), s); + } + free(s); + } } return retval; } -- 2.30.2