0

Hi Linux kernel/net guru,

I'm looking for a way how to hook and print out NL(netlink) messages between wpa_supplicant and kernel. As of now I just inserted several printk messages to print those but it's very painful I think.

Please let me know if you have a better idea.

Thanks.

windrg00
  • 457
  • 3
  • 9

1 Answers1

1

This is not a good answer given the OP is using wpa_supplicant specifically but might help people drawn here by accident.

If somebody is using libnl (wpa_supplicant doesn't), all you have to do is, in userspace, once the socket has been initialized,

error = nl_socket_modify_cb(sk, NL_CB_MSG_IN, NL_CB_DEBUG, NULL, NULL);
if (error < 0)
    log_err("Could not register debug cb for incoming packets.");
error = nl_socket_modify_cb(sk, NL_CB_MSG_OUT, NL_CB_DEBUG, NULL, NULL);
if (error < 0)
    log_err("Could not register debug cb for outgoing packets.");

The userspace client will print all messages whenever it sends or receives them.

(Also, you can alternatively call nl_msg_dump(msg, stderr) whenever you want.)

For stuff that doesn't use libnl, you can always copy the relevant functions from libnl and call them. See nl_msg_dump() in libnl's source code (libnl/lib/msg.c).

Yd Ahhrk
  • 1,088
  • 12
  • 24