openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/libnl/1_3.4.0-r0/libnl-3.4.0/lib/socket.c
int nl_socket_add_memberships(struct nl_sock* sk, int group, ...)
{
    int err;
    va_list ap;

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

    va_start(ap, group);

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

        err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group,
                         sizeof(group));
        if (err < 0)
        {
            va_end(ap);
            NL_DBG(4,
                   "nl_socket_add_memberships(%p): setsockopt() failed with %d "
                   "(%s)\n",
                   sk, errno, nl_strerror_l(errno));
            return -nl_syserr2nlerr(errno);
        }

        group = va_arg(ap, int);
    }

    va_end(ap);

    return 0;
}
/**
 * Join groups
 * @arg sk		Netlink socket
 * @arg 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.
 *
 * @return 0 on sucess or a negative error code.
 */
Join groups
@arg sk              Netlink socket
@arg 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.

@return 0 on sucess or a negative error code.
Join groups @arg sk Netlink socket @arg 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 . @return 0 on sucess or a negative error code .
int nl_socket_add_memberships(struct nl_sock* sk, int group, ...)
{
    int err;
    va_list ap;
    if (sk->s_fd == -1)
        return -NLE_BAD_SOCK;
    va_start(ap, group);
    while (group != 0)
    {
        if (group < 0)
        {
            va_end(ap);
            return -NLE_INVAL;
        }
        err = setsockopt(sk->s_fd, SOL_NETLINK, NETLINK_ADD_MEMBERSHIP, &group,
                         sizeof(group));
        if (err < 0)
        {
            va_end(ap);
            NL_DBG(4,
                   "nl_socket_add_memberships(%p): setsockopt() failed with %d "
                   "(%s)\n",
                   sk, errno, nl_strerror_l(errno));
            return -nl_syserr2nlerr(errno);
        }
        group = va_arg(ap, int);
    }
    va_end(ap);
    return 0;
}
int nl_socket_add_memberships ( struct nl_sock * sk , int group , ... ) { int err ; va_list ap ; if ( sk -> s_fd == -1 ) return - NLE_BAD_SOCK ; va_start ( ap , group ) ; while ( group != 0 ) { if ( group < 0 ) { va_end ( ap ) ; return - NLE_INVAL ; } err = setsockopt ( sk -> s_fd , SOL_NETLINK , NETLINK_ADD_MEMBERSHIP , & group , sizeof ( group ) ) ; if ( err < 0 ) { va_end ( ap ) ; NL_DBG ( 4 , " " " \n " , sk , errno , nl_strerror_l ( errno ) ) ; return - nl_syserr2nlerr ( errno ) ; } group = va_arg ( ap , int ) ; } va_end ( ap ) ; return 0 ; }
Join groups
 @arg sk              Netlink socket
 @arg group           Group identifier
Join groups @arg sk Netlink socket @arg group Group identifier