1 /* Helper for SA_LEN macro.
2 Copyright (C) 2013 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
19 #include <sys/socket.h>
21 /* If _HAVE_SA_LEN is defined, then SA_LEN just uses sockaddr.sa_len
22 and there is no need for a helper function. */
26 /* All configurations have at least these two headers
27 and their associated address families. */
29 # include <netinet/in.h>
32 /* More-specific sa_len.c files #define these various HAVE_*_H
33 macros and then #include this file. */
35 # ifdef HAVE_NETASH_ASH_H
36 # include <netash/ash.h>
38 # ifdef HAVE_NETATALK_AT_H
39 # include <netatalk/at.h>
41 # ifdef HAVE_NETAX25_AX25_H
42 # include <netax25/ax25.h>
44 # ifdef HAVE_NETECONET_EC_H
45 # include <neteconet/ec.h>
47 # ifdef HAVE_NETIPX_IPX_H
48 # include <netipx/ipx.h>
50 # ifdef HAVE_NETPACKET_PACKET_H
51 # include <netpacket/packet.h>
53 # ifdef HAVE_NETROSE_ROSE_H
54 # include <netrose/rose.h>
56 # ifdef HAVE_NETIUCV_IUCV_H
57 # include <netiucv/iucv.h>
61 __libc_sa_len (sa_family_t af
)
65 # ifdef HAVE_NETATALK_AT_H
67 return sizeof (struct sockaddr_at
);
69 # ifdef HAVE_NETASH_ASH_H
71 return sizeof (struct sockaddr_ash
);
73 # ifdef HAVE_NETAX25_AX25_H
75 return sizeof (struct sockaddr_ax25
);
77 # ifdef HAVE_NETECONET_EC_H
79 return sizeof (struct sockaddr_ec
);
82 return sizeof (struct sockaddr_in
);
84 return sizeof (struct sockaddr_in6
);
85 # ifdef HAVE_NETIPX_IPX_H
87 return sizeof (struct sockaddr_ipx
);
89 # ifdef HAVE_NETIUCV_IUCV_H
91 return sizeof (struct sockaddr_iucv
);
94 return sizeof (struct sockaddr_un
);
95 # ifdef HAVE_NETPACKET_PACKET_H
97 return sizeof (struct sockaddr_ll
);
99 # ifdef HAVE_NETROSE_ROSE_H
101 return sizeof (struct sockaddr_rose
);
106 libc_hidden_def (__libc_sa_len
)
108 #endif /* Not _HAVE_SA_LEN. */