#define NL_NO_AUTO_ACK (1<<4)
struct nl_cb;
+
+typedef void (*nl_debug_cb)(void *priv, const void *data, size_t len);
struct nl_sock
{
struct sockaddr_nl s_local;
unsigned int s_seq_expect;
int s_flags;
struct nl_cb * s_cb;
+
+ nl_debug_cb s_debug_tx_cb;
+ nl_debug_cb s_debug_rx_cb;
+ void * s_debug_tx_priv;
+ void * s_debug_rx_priv;
};
extern int nl_socket_set_nonblocking(struct nl_sock *);
+static inline void nl_socket_set_tx_debug_cb(struct nl_sock *sk, nl_debug_cb cb, void *priv)
+{
+ sk->s_debug_tx_cb = cb;
+ sk->s_debug_tx_priv = priv;
+}
+
+static inline void nl_socket_set_rx_debug_cb(struct nl_sock *sk, nl_debug_cb cb, void *priv)
+{
+ sk->s_debug_rx_cb = cb;
+ sk->s_debug_rx_priv = priv;
+}
+
/**
* Use next sequence number
* @arg sk Netlink socket.
{
int ret;
+ if (sk->s_debug_tx_cb)
+ sk->s_debug_tx_cb(sk->s_debug_tx_priv, buf, size);
+
ret = sendto(sk->s_fd, buf, size, 0, (struct sockaddr *)
&sk->s_peer, sizeof(sk->s_peer));
if (ret < 0)
if (nl_cb_call(cb, NL_CB_MSG_OUT, msg) != NL_OK)
return 0;
+ if (sk->s_debug_tx_cb)
+ sk->s_debug_tx_cb(sk->s_debug_tx_priv, iov.iov_base, iov.iov_len);
+
ret = sendmsg(sk->s_fd, hdr, 0);
if (ret < 0)
return -nl_syserr2nlerr(errno);
}
}
+ if (sk->s_debug_rx_cb)
+ sk->s_debug_rx_cb(sk->s_debug_rx_priv, *buf, n);
+
free(msg.msg_control);
return n;