Back to index

glibc  2.9
Defines | Functions | Variables
getsourcefilter.c File Reference
#include <alloca.h>
#include <assert.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <netatalk/at.h>
#include <netax25/ax25.h>
#include <netinet/in.h>
#include <netipx/ipx.h>
#include <netpacket/packet.h>
#include <netrose/rose.h>
#include <sys/param.h>
#include <sys/socket.h>

Go to the source code of this file.


#define NSOL_MAP   (sizeof (sol_map) / sizeof (sol_map[0]))


int __get_sol (int af, socklen_t len)
int getsourcefilter (int s, uint32_t interface, const struct sockaddr *group, socklen_t grouplen, uint32_t *fmode, uint32_t *numsrc, struct sockaddr_storage *slist)


struct {
int sol
int af
socklen_t size
sol_map []

Define Documentation

#define NSOL_MAP   (sizeof (sol_map) / sizeof (sol_map[0]))

Definition at line 53 of file getsourcefilter.c.

Function Documentation

int __get_sol ( int  af,
socklen_t  len 

Definition at line 61 of file getsourcefilter.c.

  int first_size_sol = -1;

  for (size_t cnt = 0; cnt < NSOL_MAP; ++cnt)
      /* Just a test so that we make sure the special value used to
        signal the "we have so far no socket level value" is OK.  */
      assert (sol_map[cnt].sol != -1);

      if (len == sol_map[cnt].size)
         /* The size matches, which is a requirement.  If the family
            matches, too, we have a winner.  Otherwise we remember the
            socket level value for this protocol if it is the first
            match.  */
         if (af == sol_map[cnt].af)
           /* Bingo!  */
           return sol_map[cnt].sol;

         if (first_size_sol == -1)
           first_size_sol = sol_map[cnt].sol;

  return first_size_sol;

Here is the caller graph for this function:

int getsourcefilter ( int  s,
uint32_t  interface,
const struct sockaddr group,
socklen_t  grouplen,
uint32_t fmode,
uint32_t numsrc,
struct sockaddr_storage slist 

Definition at line 91 of file getsourcefilter.c.

  /* We have to create an struct ip_msfilter object which we can pass
     to the kernel.  */
  socklen_t needed = GROUP_FILTER_SIZE (*numsrc);
  int use_alloca = __libc_use_alloca (needed);

  struct group_filter *gf;
  if (use_alloca)
    gf = (struct group_filter *) alloca (needed);
      gf = (struct group_filter *) malloc (needed);
      if (gf == NULL)
       return -1;

  gf->gf_interface = interface;
  memcpy (&gf->gf_group, group, grouplen);
  gf->gf_numsrc = *numsrc;

  /* We need to provide the appropriate socket level value.  */
  int result;
  int sol = __get_sol (group->sa_family, grouplen);
  if (sol == -1)
      __set_errno (EINVAL);
      result = -1;
      result = __getsockopt (s, sol, MCAST_MSFILTER, gf, &needed);

      /* If successful, copy the results to the places the caller wants
        them in.  */
      if (result == 0)
         *fmode = gf->gf_fmode;
         memcpy (slist, gf->gf_slist,
                MIN (*numsrc, gf->gf_numsrc)
                * sizeof (struct sockaddr_storage));
         *numsrc = gf->gf_numsrc;

  if (! use_alloca)
      int save_errno = errno;
      free (gf);
      __set_errno (save_errno);

  return result;

Here is the call graph for this function:

Variable Documentation

struct { ... } sol_map[] [static]