Logo Search packages:      
Sourcecode: libnl2 version File versions  Download package

int nl_socket_add_memberships ( struct nl_sock *  sk,
int  group,
  ... 
)

Join groups

  • sk Netlink socket
  • group Group identifier
Joins the specified groups using the modern socket option which is available since kernel version 2.6.14. It allows joining an almost arbitary number of groups without limitation. The list of groups has to be terminated by 0 (NFNLGRP_NONE).

Make sure to use the correct group definitions as the older bitmask definitions for nl_join_groups() are likely to still be present for backward compatibility reasons.

Returns:
0 on sucess or a negative error code.

Definition at line 292 of file socket.c.

{
      int err;
      va_list ap;

      if (sk->s_fd == -1)
            return -NLE_BAD_SOCK;

      va_start(ap, group);

      while (group != 0) {
            if (group < 0)
                  return -NLE_INVAL;

            err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP,
                                     &group, sizeof(group));
            if (err < 0)
                  return -nl_syserr2nlerr(errno);

            group = va_arg(ap, int);
      }

      va_end(ap);

      return 0;
}


Generated by  Doxygen 1.6.0   Back to index