socket: change debug callbacks to pass struct nl_msg
[project/libnl-tiny.git] / nl.c
diff --git a/nl.c b/nl.c
index 32d26a3f763525f525b66e4e6a5b7923935a3051..7ab882238e577955e4eb37695c635549fe7360ab 100644 (file)
--- a/nl.c
+++ b/nl.c
@@ -227,6 +227,11 @@ int nl_sendmsg(struct nl_sock *sk, struct nl_msg *msg, struct msghdr *hdr)
                if (nl_cb_call(cb, NL_CB_MSG_OUT, msg) != NL_OK)
                        return 0;
 
+       if (sk->s_debug_tx_cb) {
+               nlmsg_set_proto(msg, sk->s_proto);
+               sk->s_debug_tx_cb(sk->s_debug_tx_priv, msg);
+       }
+
        ret = sendmsg(sk->s_fd, hdr, 0);
        if (ret < 0)
                return -nl_syserr2nlerr(errno);
@@ -532,6 +537,9 @@ continue_reading:
                if (creds)
                        nlmsg_set_creds(msg, creds);
 
+               if (sk->s_debug_rx_cb)
+                       sk->s_debug_rx_cb(sk->s_debug_rx_priv, msg);
+
                /* Raw callback is the first, it gives the most control
                 * to the user and he can do his very own parsing. */
                if (cb->cb_set[NL_CB_MSG_IN])