Blame socket/sa_len.c

Packit 6c4009
/* Helper for SA_LEN macro.
Packit 6c4009
   Copyright (C) 2013-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library; if not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sys/socket.h>
Packit 6c4009
Packit 6c4009
/* If _HAVE_SA_LEN is defined, then SA_LEN just uses sockaddr.sa_len
Packit 6c4009
   and there is no need for a helper function.  */
Packit 6c4009
Packit 6c4009
#ifndef _HAVE_SA_LEN
Packit 6c4009
Packit 6c4009
/* All configurations have at least these two headers
Packit 6c4009
   and their associated address families.  */
Packit 6c4009
Packit 6c4009
# include <netinet/in.h>
Packit 6c4009
# include <sys/un.h>
Packit 6c4009
Packit 6c4009
/* More-specific sa_len.c files #define these various HAVE_*_H
Packit 6c4009
   macros and then #include this file.  */
Packit 6c4009
Packit 6c4009
# ifdef HAVE_NETASH_ASH_H
Packit 6c4009
#  include <netash/ash.h>
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETATALK_AT_H
Packit 6c4009
#  include <netatalk/at.h>
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETAX25_AX25_H
Packit 6c4009
#  include <netax25/ax25.h>
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETECONET_EC_H
Packit 6c4009
#  include <neteconet/ec.h>
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETIPX_IPX_H
Packit 6c4009
#  include <netipx/ipx.h>
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETPACKET_PACKET_H
Packit 6c4009
#  include <netpacket/packet.h>
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETROSE_ROSE_H
Packit 6c4009
#  include <netrose/rose.h>
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETIUCV_IUCV_H
Packit 6c4009
#  include <netiucv/iucv.h>
Packit 6c4009
# endif
Packit 6c4009
Packit 6c4009
int
Packit 6c4009
__libc_sa_len (sa_family_t af)
Packit 6c4009
{
Packit 6c4009
  switch (af)
Packit 6c4009
    {
Packit 6c4009
# ifdef HAVE_NETATALK_AT_H
Packit 6c4009
    case AF_APPLETALK:
Packit 6c4009
      return sizeof (struct sockaddr_at);
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETASH_ASH_H
Packit 6c4009
    case AF_ASH:
Packit 6c4009
      return sizeof (struct sockaddr_ash);
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETAX25_AX25_H
Packit 6c4009
    case AF_AX25:
Packit 6c4009
      return sizeof (struct sockaddr_ax25);
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETECONET_EC_H
Packit 6c4009
    case AF_ECONET:
Packit 6c4009
      return sizeof (struct sockaddr_ec);
Packit 6c4009
# endif
Packit 6c4009
    case AF_INET:
Packit 6c4009
      return sizeof (struct sockaddr_in);
Packit 6c4009
    case AF_INET6:
Packit 6c4009
      return sizeof (struct sockaddr_in6);
Packit 6c4009
# ifdef HAVE_NETIPX_IPX_H
Packit 6c4009
    case AF_IPX:
Packit 6c4009
      return sizeof (struct sockaddr_ipx);
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETIUCV_IUCV_H
Packit 6c4009
    case AF_IUCV:
Packit 6c4009
      return sizeof (struct sockaddr_iucv);
Packit 6c4009
# endif
Packit 6c4009
    case AF_LOCAL:
Packit 6c4009
      return sizeof (struct sockaddr_un);
Packit 6c4009
# ifdef HAVE_NETPACKET_PACKET_H
Packit 6c4009
    case AF_PACKET:
Packit 6c4009
      return sizeof (struct sockaddr_ll);
Packit 6c4009
# endif
Packit 6c4009
# ifdef HAVE_NETROSE_ROSE_H
Packit 6c4009
    case AF_ROSE:
Packit 6c4009
      return sizeof (struct sockaddr_rose);
Packit 6c4009
# endif
Packit 6c4009
    }
Packit 6c4009
  return 0;
Packit 6c4009
}
Packit 6c4009
libc_hidden_def (__libc_sa_len)
Packit 6c4009
Packit 6c4009
#endif  /* Not _HAVE_SA_LEN.  */