Search code examples
linuxudpsystem-callsstracesendto

sendto pid and groups


I'm trying to understand this line from an strace on linux:

sendto(10, "\24\0\0\0\26\0\1\3\233\274\362O\0\0\0\0\0\0\0\0", 20, 0, {sa_family=AF_NETLINK, pid=0, groups=00000000}, 12) = 20

I have looked on the net and in man pages about sendto, but I see no reference of pid and groups. event AF_NETLINK is not mentioned.

What do the pid and groups arguments mean? Where can I find the right doc about this function?

Thanks


Solution

  • That argument is a struct sockaddr *, as per the sendto manual page. When used with netlink sockets, it's actually a struct sockaddr_nl:

    struct sockaddr_nl {
           sa_family_t     nl_family;  /* AF_NETLINK */
           unsigned short  nl_pad;     /* Zero. */
           pid_t           nl_pid;     /* Process ID. */
           __u32           nl_groups;  /* Multicast groups mask. */
    };
    

    So that's where the pid and groups must be coming from (the "Address Formats" section of the manual explains those fields).