From: Ben Pfaff <blp@nicira.com>
Date: Thu, 3 Apr 2008 16:27:40 +0000 (-0700)
Subject: Make vconn log all incoming and outgoing OpenFlow packets at debug level.
X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=8240e9cdc74088c795e5bdb5025b38188f5c608e;p=sliver-openvswitch.git

Make vconn log all incoming and outgoing OpenFlow packets at debug level.
---

diff --git a/lib/vconn.c b/lib/vconn.c
index a3314c575..84c3bbc6e 100644
--- a/lib/vconn.c
+++ b/lib/vconn.c
@@ -40,6 +40,7 @@
 #include <string.h>
 #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;
 }