source: web/old/remctl-2.14/m4/socket.m4 @ f6f3e91

web
Last change on this file since f6f3e91 was f6f3e91, checked in by Jessica B. Hamrick <jhamrick@…>, 15 years ago

Preserve directory hierarchy (not sure what happened to it)

  • Property mode set to 100644
File size: 3.6 KB
Line 
1dnl Various checks for socket support and macros.
2dnl
3dnl This is a collection of various Autoconf macros for checking networking
4dnl and socket properties.  The macros provided are:
5dnl
6dnl     RRA_FUNC_GETADDRINFO_ADDRCONFIG
7dnl     RRA_MACRO_IN6_ARE_ADDR_EQUAL
8dnl     RRA_MACRO_SA_LEN
9dnl
10dnl They use a separate internal source macro to make the code easier to read.
11dnl
12dnl Copyright 2008, 2009 Board of Trustees, Leland Stanford Jr. University
13dnl Copyright (c) 2004, 2005, 2006, 2007, 2008, 2009
14dnl     by Internet Systems Consortium, Inc. ("ISC")
15dnl Copyright (c) 1991, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
16dnl     2002, 2003 by The Internet Software Consortium and Rich Salz
17dnl
18dnl See LICENSE for licensing terms.
19
20dnl Source used by RRA_FUNC_GETADDRINFO_ADDRCONFIG.
21AC_DEFUN([_RRA_FUNC_GETADDRINFO_ADDRCONFIG_SOURCE], [[
22#include <netdb.h>
23#include <stdio.h>
24#include <sys/socket.h>
25
26int
27main(void) {
28    struct addrinfo hints, *ai;
29
30    memset(&hints, 0, sizeof(hints));
31    hints.ai_family = AF_UNSPEC;
32    hints.ai_socktype = SOCK_STREAM;
33    hints.ai_flags = AI_ADDRCONFIG;
34    return (getaddrinfo("localhost", NULL, &hints, &ai) != 0);
35}
36]])
37
38dnl Check whether the AI_ADDRCONFIG flag works properly with getaddrinfo.
39dnl If so, set HAVE_GETADDRINFO_ADDRCONFIG.
40AC_DEFUN([RRA_FUNC_GETADDRINFO_ADDRCONFIG],
41[AC_CACHE_CHECK([for working AI_ADDRCONFIG flag],
42    [rra_cv_func_getaddrinfo_addrconfig_works],
43    [AC_RUN_IFELSE(AC_LANG_SOURCE([_RRA_FUNC_GETADDRINFO_ADDRCONFIG_SOURCE]),
44        [rra_cv_func_getaddrinfo_addrconfig_works=yes],
45        [rra_cv_func_getaddrinfo_addrconfig_works=no],
46        [rra_cv_func_getaddrinfo_addrconfig_works=no])])
47 AS_IF([test x"$rra_cv_func_getaddrinfo_addrconfig_works" = xyes],
48    [AC_DEFINE([HAVE_GETADDRINFO_ADDRCONFIG], 1,
49        [Define if the AI_ADDRCONFIG flag works with getaddrinfo.])])])
50
51dnl Source used by INN_IN6_EQ_BROKEN.  Test borrowed from a bug report by
52dnl tmoestl@gmx.net for glibc.
53AC_DEFUN([_RRA_MACRO_IN6_ARE_ADDR_EQUAL_SOURCE], [[
54#include <sys/types.h>
55#include <sys/socket.h>
56#include <netinet/in.h>
57#include <arpa/inet.h>
58
59int
60main (void)
61{
62    struct in6_addr a;
63    struct in6_addr b;
64
65    inet_pton(AF_INET6, "fe80::1234:5678:abcd", &a);
66    inet_pton(AF_INET6, "fe80::1234:5678:abcd", &b);
67    return IN6_ARE_ADDR_EQUAL(&a, &b) ? 0 : 1;
68}
69]])
70
71dnl Check whether the IN6_ARE_ADDR_EQUAL macro is broken (like glibc 2.1.3) or
72dnl missing.
73AC_DEFUN([RRA_MACRO_IN6_ARE_ADDR_EQUAL],
74[AC_CACHE_CHECK([whether IN6_ARE_ADDR_EQUAL macro is broken],
75    [rra_cv_in6_are_addr_equal_broken],
76    [AC_RUN_IFELSE([AC_LANG_SOURCE([_RRA_MACRO_IN6_ARE_ADDR_EQUAL_SOURCE])],
77        [rra_cv_in6_are_addr_equal_broken=no],
78        [rra_cv_in6_are_addr_equal_broken=yes],
79        [rra_cv_in6_are_addr_equal_broken=yes])])
80 AS_IF([test x"$rra_cv_in6_are_addr_equal_broken" = xyes],
81    [AC_DEFINE([HAVE_BROKEN_IN6_ARE_ADDR_EQUAL], 1,
82        [Define if your IN6_ARE_ADDR_EQUAL macro is broken.])])])
83
84dnl Source used by RRA_MACRO_SA_LEN.
85AC_DEFUN([_RRA_MACRO_SA_LEN_SOURCE], [[
86#include <sys/types.h>
87#include <sys/socket.h>
88
89int
90main(void)
91{
92    struct sockaddr sa;
93    int x = SA_LEN(&sa);
94}
95]])
96
97dnl Check whether the SA_LEN macro is available.  This should give the length
98dnl of a struct sockaddr regardless of type.
99AC_DEFUN([RRA_MACRO_SA_LEN],
100[AC_CACHE_CHECK([for SA_LEN macro], [rra_cv_sa_len_macro],
101    [AC_LINK_IFELSE([AC_LANG_SOURCE([_RRA_MACRO_SA_LEN_SOURCE])],
102        [rra_cv_sa_len_macro=yes],
103        [rra_cv_sa_len_macro=no])])
104 AS_IF([test "$rra_cv_sa_len_macro" = yes],
105    [AC_DEFINE([HAVE_SA_LEN], 1,
106        [Define if <sys/socket.h> defines the SA_LEN macro])])])
Note: See TracBrowser for help on using the repository browser.