~ubuntu-branches/ubuntu/feisty/apache2/feisty

« back to all changes in this revision

Viewing changes to srclib/apr/build/apr_network.m4

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Barth
  • Date: 2006-12-09 21:05:45 UTC
  • mfrom: (0.6.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20061209210545-h70s0xaqc2v8vqr2
Tags: 2.2.3-3.2
* Non-maintainer upload.
* 043_ajp_connection_reuse: Patch from upstream Bugzilla, fixing a critical
  issue with regard to connection reuse in mod_proxy_ajp.
  Closes: #396265

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
dnl -------------------------------------------------------- -*- autoconf -*-
 
2
dnl Copyright 2000-2005 The Apache Software Foundation
 
3
dnl
 
4
dnl Licensed under the Apache License, Version 2.0 (the "License");
 
5
dnl you may not use this file except in compliance with the License.
 
6
dnl You may obtain a copy of the License at
 
7
dnl
 
8
dnl     http://www.apache.org/licenses/LICENSE-2.0
 
9
dnl
 
10
dnl Unless required by applicable law or agreed to in writing, software
 
11
dnl distributed under the License is distributed on an "AS IS" BASIS,
 
12
dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
13
dnl See the License for the specific language governing permissions and
 
14
dnl limitations under the License.
 
15
 
 
16
dnl -----------------------------------------------------------------
 
17
dnl apr_network.m4: APR's autoconf macros for testing network support
 
18
dnl
 
19
 
 
20
dnl
 
21
dnl check for working getaddrinfo()
 
22
dnl
 
23
dnl Note that if the system doesn't have gai_strerror(), we
 
24
dnl can't use getaddrinfo() because we can't get strings
 
25
dnl describing the error codes.
 
26
dnl
 
27
AC_DEFUN(APR_CHECK_WORKING_GETADDRINFO,[
 
28
  AC_CACHE_CHECK(for working getaddrinfo, ac_cv_working_getaddrinfo,[
 
29
  AC_TRY_RUN( [
 
30
#ifdef HAVE_NETDB_H
 
31
#include <netdb.h>
 
32
#endif
 
33
#ifdef HAVE_STRING_H
 
34
#include <string.h>
 
35
#endif
 
36
#ifdef HAVE_SYS_TYPES_H
 
37
#include <sys/types.h>
 
38
#endif
 
39
#ifdef HAVE_SYS_SOCKET_H
 
40
#include <sys/socket.h>
 
41
#endif
 
42
 
 
43
void main(void) {
 
44
    struct addrinfo hints, *ai;
 
45
    int error;
 
46
 
 
47
    memset(&hints, 0, sizeof(hints));
 
48
    hints.ai_family = AF_UNSPEC;
 
49
    hints.ai_socktype = SOCK_STREAM;
 
50
    error = getaddrinfo("127.0.0.1", NULL, &hints, &ai);
 
51
    if (error) {
 
52
        exit(1);
 
53
    }
 
54
    if (ai->ai_addr->sa_family != AF_INET) {
 
55
        exit(1);
 
56
    }
 
57
    exit(0);
 
58
}
 
59
],[
 
60
  ac_cv_working_getaddrinfo="yes"
 
61
],[
 
62
  ac_cv_working_getaddrinfo="no"
 
63
],[
 
64
  ac_cv_working_getaddrinfo="yes"
 
65
])])
 
66
if test "$ac_cv_working_getaddrinfo" = "yes"; then
 
67
  if test "$ac_cv_func_gai_strerror" != "yes"; then
 
68
    ac_cv_working_getaddrinfo="no"
 
69
  else
 
70
    AC_DEFINE(HAVE_GETADDRINFO, 1, [Define if getaddrinfo exists and works well enough for APR])
 
71
  fi
 
72
fi
 
73
])
 
74
 
 
75
dnl Check whether the AI_ADDRCONFIG flag can be used with getaddrinfo
 
76
AC_DEFUN(APR_CHECK_GETADDRINFO_ADDRCONFIG, [
 
77
  AC_CACHE_CHECK(for working AI_ADDRCONFIG, apr_cv_gai_addrconfig, [
 
78
  AC_TRY_RUN([
 
79
#ifdef HAVE_NETDB_H
 
80
#include <netdb.h>
 
81
#endif
 
82
#ifdef HAVE_STRING_H
 
83
#include <string.h>
 
84
#endif
 
85
#ifdef HAVE_SYS_TYPES_H
 
86
#include <sys/types.h>
 
87
#endif
 
88
#ifdef HAVE_SYS_SOCKET_H
 
89
#include <sys/socket.h>
 
90
#endif
 
91
 
 
92
int main(int argc, char **argv) {
 
93
    struct addrinfo hints, *ai;
 
94
 
 
95
    memset(&hints, 0, sizeof(hints));
 
96
    hints.ai_family = AF_UNSPEC;
 
97
    hints.ai_socktype = SOCK_STREAM;
 
98
    hints.ai_flags = AI_ADDRCONFIG;
 
99
    return getaddrinfo("localhost", NULL, &hints, &ai) != 0;
 
100
}], [apr_cv_gai_addrconfig=yes], 
 
101
    [apr_cv_gai_addrconfig=no],
 
102
    [apr_cv_gai_addrconfig=no])])
 
103
 
 
104
if test $apr_cv_gai_addrconfig = yes; then
 
105
   AC_DEFINE(HAVE_GAI_ADDRCONFIG, 1, [Define if getaddrinfo accepts the AI_ADDRCONFIG flag])
 
106
fi
 
107
])
 
108
 
 
109
dnl
 
110
dnl check for working getnameinfo()
 
111
dnl
 
112
AC_DEFUN(APR_CHECK_WORKING_GETNAMEINFO,[
 
113
  AC_CACHE_CHECK(for working getnameinfo, ac_cv_working_getnameinfo,[
 
114
  AC_TRY_RUN( [
 
115
#ifdef HAVE_NETDB_H
 
116
#include <netdb.h>
 
117
#endif
 
118
#ifdef HAVE_STRING_H
 
119
#include <string.h>
 
120
#endif
 
121
#ifdef HAVE_SYS_TYPES_H
 
122
#include <sys/types.h>
 
123
#endif
 
124
#ifdef HAVE_SYS_SOCKET_H
 
125
#include <sys/socket.h>
 
126
#endif
 
127
#ifdef HAVE_NETINET_IN_H
 
128
#include <netinet/in.h>
 
129
#endif
 
130
 
 
131
void main(void) {
 
132
    struct sockaddr_in sa;
 
133
    char hbuf[256];
 
134
    int error;
 
135
 
 
136
    sa.sin_family = AF_INET;
 
137
    sa.sin_port = 0;
 
138
    sa.sin_addr.s_addr = inet_addr("127.0.0.1");
 
139
#ifdef SIN6_LEN
 
140
    sa.sin_len = sizeof(sa);
 
141
#endif
 
142
 
 
143
    error = getnameinfo((const struct sockaddr *)&sa, sizeof(sa),
 
144
                        hbuf, 256, NULL, 0,
 
145
                        NI_NUMERICHOST);
 
146
    if (error) {
 
147
        exit(1);
 
148
    } else {
 
149
        exit(0);
 
150
    }
 
151
}
 
152
],[
 
153
  ac_cv_working_getnameinfo="yes"
 
154
],[
 
155
  ac_cv_working_getnameinfo="no"
 
156
],[
 
157
  ac_cv_working_getnameinfo="yes"
 
158
])])
 
159
if test "$ac_cv_working_getnameinfo" = "yes"; then
 
160
  AC_DEFINE(HAVE_GETNAMEINFO, 1, [Define if getnameinfo exists])
 
161
fi
 
162
])
 
163
 
 
164
dnl
 
165
dnl check for negative error codes for getaddrinfo()
 
166
dnl
 
167
AC_DEFUN(APR_CHECK_NEGATIVE_EAI,[
 
168
  AC_CACHE_CHECK(for negative error codes for getaddrinfo, ac_cv_negative_eai,[
 
169
  AC_TRY_RUN( [
 
170
#ifdef HAVE_NETDB_H
 
171
#include <netdb.h>
 
172
#endif
 
173
 
 
174
void main(void) {
 
175
    if (EAI_ADDRFAMILY < 0) {
 
176
        exit(0);
 
177
    }
 
178
    exit(1);
 
179
}
 
180
],[
 
181
  ac_cv_negative_eai="yes"
 
182
],[
 
183
  ac_cv_negative_eai="no"
 
184
],[
 
185
  ac_cv_negative_eai="no"
 
186
])])
 
187
if test "$ac_cv_negative_eai" = "yes"; then
 
188
  AC_DEFINE(NEGATIVE_EAI, 1, [Define if EAI_ error codes from getaddrinfo are negative])
 
189
fi
 
190
])
 
191
 
 
192
dnl
 
193
dnl Checks the definition of gethostbyname_r and gethostbyaddr_r
 
194
dnl which are different for glibc, solaris and assorted other operating
 
195
dnl systems
 
196
dnl
 
197
dnl Note that this test is executed too early to see if we have all of
 
198
dnl the headers.
 
199
AC_DEFUN(APR_CHECK_GETHOSTBYNAME_R_STYLE,[
 
200
 
 
201
dnl Try and compile a glibc2 gethostbyname_r piece of code, and set the
 
202
dnl style of the routines to glibc2 on success
 
203
AC_CACHE_CHECK([style of gethostbyname_r routine], ac_cv_gethostbyname_r_style,
 
204
APR_TRY_COMPILE_NO_WARNING([
 
205
#ifdef HAVE_SYS_TYPES_H
 
206
#include <sys/types.h>
 
207
#endif
 
208
#ifdef HAVE_NETINET_IN_H
 
209
#include <netinet/in.h>
 
210
#endif
 
211
#ifdef HAVE_ARPA_INET_H
 
212
#include <arpa/inet.h>
 
213
#endif
 
214
#ifdef HAVE_NETDB_H
 
215
#include <netdb.h>
 
216
#endif
 
217
#ifdef HAVE_STDLIB_H
 
218
#include <stdlib.h>
 
219
#endif
 
220
],[
 
221
int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, 
 
222
                          (char *) 0, 0, (struct hostent **) 0, &tmp);
 
223
], ac_cv_gethostbyname_r_style=glibc2, ac_cv_gethostbyname_r_style=none))
 
224
 
 
225
if test "$ac_cv_gethostbyname_r_style" = "glibc2"; then
 
226
    AC_DEFINE(GETHOSTBYNAME_R_GLIBC2, 1, [Define if gethostbyname_r has the glibc style])
 
227
fi
 
228
 
 
229
AC_CACHE_CHECK([3rd argument to the gethostbyname_r routines], ac_cv_gethostbyname_r_arg,
 
230
APR_TRY_COMPILE_NO_WARNING([
 
231
#ifdef HAVE_SYS_TYPES_H
 
232
#include <sys/types.h>
 
233
#endif
 
234
#ifdef HAVE_NETINET_IN_H
 
235
#include <netinet/in.h>
 
236
#endif
 
237
#ifdef HAVE_ARPA_INET_H
 
238
#include <arpa/inet.h>
 
239
#endif
 
240
#ifdef HAVE_NETDB_H
 
241
#include <netdb.h>
 
242
#endif
 
243
#ifdef HAVE_STDLIB_H
 
244
#include <stdlib.h>
 
245
#endif
 
246
],[
 
247
int tmp = gethostbyname_r((const char *) 0, (struct hostent *) 0, 
 
248
                          (struct hostent_data *) 0);],
 
249
ac_cv_gethostbyname_r_arg=hostent_data, ac_cv_gethostbyname_r_arg=char))
 
250
 
 
251
if test "$ac_cv_gethostbyname_r_arg" = "hostent_data"; then
 
252
    AC_DEFINE(GETHOSTBYNAME_R_HOSTENT_DATA, 1, [Define if gethostbyname_r has the hostent_data for the third argument])
 
253
fi
 
254
])
 
255
 
 
256
dnl
 
257
dnl see if TCP_NODELAY setting is inherited from listening sockets
 
258
dnl
 
259
AC_DEFUN(APR_CHECK_TCP_NODELAY_INHERITED,[
 
260
  AC_CACHE_CHECK(if TCP_NODELAY setting is inherited from listening sockets, ac_cv_tcp_nodelay_inherited,[
 
261
  AC_TRY_RUN( [
 
262
#include <stdio.h>
 
263
#ifdef HAVE_SYS_TYPES_H
 
264
#include <sys/types.h>
 
265
#endif
 
266
#ifdef HAVE_SYS_SOCKET_H
 
267
#include <sys/socket.h>
 
268
#endif
 
269
#ifdef HAVE_NETINET_IN_H
 
270
#include <netinet/in.h>
 
271
#endif
 
272
#ifdef HAVE_NETINET_TCP_H
 
273
#include <netinet/tcp.h>
 
274
#endif
 
275
#ifndef HAVE_SOCKLEN_T
 
276
typedef int socklen_t;
 
277
#endif
 
278
int main(void) {
 
279
    int listen_s, connected_s, client_s;
 
280
    int listen_port, rc;
 
281
    struct sockaddr_in sa;
 
282
    socklen_t sa_len;
 
283
    socklen_t option_len;
 
284
    int option;
 
285
 
 
286
    listen_s = socket(AF_INET, SOCK_STREAM, 0);
 
287
    if (listen_s < 0) {
 
288
        perror("socket");
 
289
        exit(1);
 
290
    }
 
291
    option = 1;
 
292
    rc = setsockopt(listen_s, IPPROTO_TCP, TCP_NODELAY, &option, sizeof option);
 
293
    if (rc < 0) {
 
294
        perror("setsockopt TCP_NODELAY");
 
295
        exit(1);
 
296
    }
 
297
    memset(&sa, 0, sizeof sa);
 
298
    sa.sin_family = AF_INET;
 
299
#ifdef BEOS
 
300
    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
301
#endif
 
302
    /* leave port 0 to get ephemeral */
 
303
    rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa);
 
304
    if (rc < 0) {
 
305
        perror("bind for ephemeral port");
 
306
        exit(1);
 
307
    }
 
308
    /* find ephemeral port */
 
309
    sa_len = sizeof(sa);
 
310
    rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len);
 
311
    if (rc < 0) {
 
312
        perror("getsockname");
 
313
        exit(1);
 
314
    }
 
315
    listen_port = sa.sin_port;
 
316
    rc = listen(listen_s, 5);
 
317
    if (rc < 0) {
 
318
        perror("listen");
 
319
        exit(1);
 
320
    }
 
321
    client_s = socket(AF_INET, SOCK_STREAM, 0);
 
322
    if (client_s < 0) {
 
323
        perror("socket");
 
324
        exit(1);
 
325
    }
 
326
    memset(&sa, 0, sizeof sa);
 
327
    sa.sin_family = AF_INET;
 
328
    sa.sin_port   = listen_port;
 
329
#ifdef BEOS
 
330
    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
331
#endif
 
332
    /* leave sin_addr all zeros to use loopback */
 
333
    rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa);
 
334
    if (rc < 0) {
 
335
        perror("connect");
 
336
        exit(1);
 
337
    }
 
338
    sa_len = sizeof sa;
 
339
    connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len);
 
340
    if (connected_s < 0) {
 
341
        perror("accept");
 
342
        exit(1);
 
343
    }
 
344
    option_len = sizeof option;
 
345
    rc = getsockopt(connected_s, IPPROTO_TCP, TCP_NODELAY, &option, &option_len);
 
346
    if (rc < 0) {
 
347
        perror("getsockopt");
 
348
        exit(1);
 
349
    }
 
350
    if (!option) {
 
351
        fprintf(stderr, "TCP_NODELAY is not set in the child.\n");
 
352
        exit(1);
 
353
    }
 
354
    return 0;
 
355
}
 
356
],[
 
357
    ac_cv_tcp_nodelay_inherited="yes"
 
358
],[
 
359
    ac_cv_tcp_nodelay_inherited="no"
 
360
],[
 
361
    ac_cv_tcp_nodelay_inherited="yes"
 
362
])])
 
363
if test "$ac_cv_tcp_nodelay_inherited" = "yes"; then
 
364
    tcp_nodelay_inherited=1
 
365
else
 
366
    tcp_nodelay_inherited=0
 
367
fi
 
368
])
 
369
 
 
370
dnl
 
371
dnl Determine whether TCP_NODELAY and TCP_CORK can both be set
 
372
dnl on a TCP socket.
 
373
dnl
 
374
AC_DEFUN([APR_CHECK_TCP_NODELAY_WITH_CORK], [
 
375
AC_CACHE_CHECK([whether TCP_NODELAY and TCP_CORK can both be enabled],
 
376
[apr_cv_tcp_nodelay_with_cork],
 
377
[AC_RUN_IFELSE([AC_LANG_PROGRAM([[
 
378
#ifdef HAVE_SYS_TYPES_H
 
379
#include <sys/types.h>
 
380
#endif
 
381
#ifdef HAVE_SYS_SOCKET_H
 
382
#include <sys/socket.h>
 
383
#endif
 
384
#ifdef HAVE_NETINET_IN_H
 
385
#include <netinet/in.h>
 
386
#endif
 
387
#ifdef HAVE_NETINET_TCP_H
 
388
#include <netinet/tcp.h>
 
389
#endif
 
390
#include <stdio.h>
 
391
#include <stdlib.h>
 
392
]], [[
 
393
    int fd, flag, rc;
 
394
 
 
395
    fd = socket(AF_INET, SOCK_STREAM, 0);
 
396
    if (fd < 0) {
 
397
       exit(1);
 
398
    }
 
399
 
 
400
    flag = 1;
 
401
    rc = setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, &flag, sizeof flag);
 
402
    if (rc < 0) {
 
403
        perror("setsockopt TCP_NODELAY");
 
404
        exit(2);
 
405
    }
 
406
 
 
407
    flag = 1;
 
408
    rc = setsockopt(fd, IPPROTO_TCP, TCP_CORK, &flag, sizeof flag);
 
409
    if (rc < 0) {
 
410
        perror("setsockopt TCP_CORK");
 
411
        exit(3);
 
412
    }
 
413
 
 
414
    exit(0);
 
415
]])], [apr_cv_tcp_nodelay_with_cork=yes], [apr_cv_tcp_nodelay_with_cork=no])])
 
416
 
 
417
if test "$apr_cv_tcp_nodelay_with_cork" = "yes"; then
 
418
  AC_DEFINE([HAVE_TCP_NODELAY_WITH_CORK], 1,
 
419
            [Define if TCP_NODELAY and TCP_CORK can be enabled at the same time])
 
420
fi
 
421
])
 
422
 
 
423
 
 
424
dnl
 
425
dnl see if O_NONBLOCK setting is inherited from listening sockets
 
426
dnl
 
427
AC_DEFUN(APR_CHECK_O_NONBLOCK_INHERITED,[
 
428
  AC_CACHE_CHECK(if O_NONBLOCK setting is inherited from listening sockets, ac_cv_o_nonblock_inherited,[
 
429
  AC_TRY_RUN( [
 
430
#include <stdio.h>
 
431
#ifdef HAVE_SYS_TYPES_H
 
432
#include <sys/types.h>
 
433
#endif
 
434
#ifdef HAVE_SYS_SOCKET_H
 
435
#include <sys/socket.h>
 
436
#endif
 
437
#ifdef HAVE_NETINET_IN_H
 
438
#include <netinet/in.h>
 
439
#endif
 
440
#ifdef HAVE_NETINET_TCP_H
 
441
#include <netinet/tcp.h>
 
442
#endif
 
443
#ifndef HAVE_SOCKLEN_T
 
444
typedef int socklen_t;
 
445
#endif
 
446
#ifdef HAVE_FCNTL_H
 
447
#include <fcntl.h>
 
448
#endif
 
449
int main(void) {
 
450
    int listen_s, connected_s, client_s;
 
451
    int listen_port, rc;
 
452
    struct sockaddr_in sa;
 
453
    socklen_t sa_len;
 
454
 
 
455
    listen_s = socket(AF_INET, SOCK_STREAM, 0);
 
456
    if (listen_s < 0) {
 
457
        perror("socket");
 
458
        exit(1);
 
459
    }
 
460
    memset(&sa, 0, sizeof sa);
 
461
    sa.sin_family = AF_INET;
 
462
#ifdef BEOS
 
463
    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
464
#endif
 
465
    /* leave port 0 to get ephemeral */
 
466
    rc = bind(listen_s, (struct sockaddr *)&sa, sizeof sa);
 
467
    if (rc < 0) {
 
468
        perror("bind for ephemeral port");
 
469
        exit(1);
 
470
    }
 
471
    /* find ephemeral port */
 
472
    sa_len = sizeof(sa);
 
473
    rc = getsockname(listen_s, (struct sockaddr *)&sa, &sa_len);
 
474
    if (rc < 0) {
 
475
        perror("getsockname");
 
476
        exit(1);
 
477
    }
 
478
    listen_port = sa.sin_port;
 
479
    rc = listen(listen_s, 5);
 
480
    if (rc < 0) {
 
481
        perror("listen");
 
482
        exit(1);
 
483
    }
 
484
    rc = fcntl(listen_s, F_SETFL, O_NONBLOCK);
 
485
    if (rc < 0) {
 
486
        perror("fcntl(F_SETFL)");
 
487
        exit(1);
 
488
    }
 
489
    client_s = socket(AF_INET, SOCK_STREAM, 0);
 
490
    if (client_s < 0) {
 
491
        perror("socket");
 
492
        exit(1);
 
493
    }
 
494
    memset(&sa, 0, sizeof sa);
 
495
    sa.sin_family = AF_INET;
 
496
    sa.sin_port   = listen_port;
 
497
#ifdef BEOS
 
498
    sa.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
 
499
#endif
 
500
    /* leave sin_addr all zeros to use loopback */
 
501
    rc = connect(client_s, (struct sockaddr *)&sa, sizeof sa);
 
502
    if (rc < 0) {
 
503
        perror("connect");
 
504
        exit(1);
 
505
    }
 
506
    sa_len = sizeof sa;
 
507
    connected_s = accept(listen_s, (struct sockaddr *)&sa, &sa_len);
 
508
    if (connected_s < 0) {
 
509
        perror("accept");
 
510
        exit(1);
 
511
    }
 
512
    rc = fcntl(connected_s, F_GETFL, 0);
 
513
    if (rc < 0) {
 
514
        perror("fcntl(F_GETFL)");
 
515
        exit(1);
 
516
    }
 
517
    if (!(rc & O_NONBLOCK)) {
 
518
        fprintf(stderr, "O_NONBLOCK is not set in the child.\n");
 
519
        exit(1);
 
520
    }
 
521
    return 0;
 
522
}
 
523
],[
 
524
    ac_cv_o_nonblock_inherited="yes"
 
525
],[
 
526
    ac_cv_o_nonblock_inherited="no"
 
527
],[
 
528
    ac_cv_o_nonblock_inherited="yes"
 
529
])])
 
530
if test "$ac_cv_o_nonblock_inherited" = "yes"; then
 
531
    o_nonblock_inherited=1
 
532
else
 
533
    o_nonblock_inherited=0
 
534
fi
 
535
])
 
536
 
 
537
dnl 
 
538
dnl check for socklen_t, fall back to unsigned int
 
539
dnl
 
540
AC_DEFUN(APR_CHECK_SOCKLEN_T,[
 
541
AC_CACHE_CHECK(for socklen_t, ac_cv_socklen_t,[
 
542
AC_TRY_COMPILE([
 
543
#ifdef HAVE_SYS_TYPES_H
 
544
#include <sys/types.h>
 
545
#endif
 
546
#ifdef HAVE_SYS_SOCKET_H
 
547
#include <sys/socket.h>
 
548
#endif
 
549
],[
 
550
socklen_t foo = (socklen_t) 0;
 
551
],[
 
552
    ac_cv_socklen_t=yes
 
553
],[
 
554
    ac_cv_socklen_t=no
 
555
])
 
556
])
 
557
 
 
558
if test "$ac_cv_socklen_t" = "yes"; then
 
559
  AC_DEFINE(HAVE_SOCKLEN_T, 1, [Whether you have socklen_t])
 
560
fi
 
561
])
 
562
 
 
563
 
 
564
AC_DEFUN(APR_CHECK_INET_ADDR,[
 
565
AC_CACHE_CHECK(for inet_addr, ac_cv_func_inet_addr,[
 
566
AC_TRY_COMPILE([
 
567
#ifdef HAVE_SYS_TYPES_H
 
568
#include <sys/types.h>
 
569
#endif
 
570
#ifdef HAVE_ARPA_INET_H
 
571
#include <arpa/inet.h>
 
572
#endif
 
573
],[
 
574
inet_addr("127.0.0.1");
 
575
],[
 
576
    ac_cv_func_inet_addr=yes
 
577
],[
 
578
    ac_cv_func_inet_addr=no
 
579
])
 
580
])
 
581
 
 
582
if test "$ac_cv_func_inet_addr" = "yes"; then
 
583
  have_inet_addr=1
 
584
else
 
585
  have_inet_addr=0
 
586
fi
 
587
])
 
588
 
 
589
 
 
590
AC_DEFUN(APR_CHECK_INET_NETWORK,[
 
591
AC_CACHE_CHECK(for inet_network, ac_cv_func_inet_network,[
 
592
AC_TRY_COMPILE([
 
593
#ifdef HAVE_SYS_TYPES_H
 
594
#include <sys/types.h>
 
595
#endif
 
596
#ifdef HAVE_ARPA_INET_H
 
597
#include <arpa/inet.h>
 
598
#endif
 
599
],[
 
600
inet_network("127.0.0.1");
 
601
],[
 
602
    ac_cv_func_inet_network=yes
 
603
],[
 
604
    ac_cv_func_inet_network=no
 
605
])
 
606
])
 
607
 
 
608
if test "$ac_cv_func_inet_network" = "yes"; then
 
609
  have_inet_network=1
 
610
else
 
611
  have_inet_network=0
 
612
fi
 
613
])
 
614
 
 
615
dnl Check for presence of struct sockaddr_storage.
 
616
AC_DEFUN(APR_CHECK_SOCKADDR_STORAGE,[
 
617
AC_CACHE_CHECK(for sockaddr_storage, apr_cv_define_sockaddr_storage,[
 
618
AC_TRY_COMPILE([
 
619
#ifdef HAVE_SYS_TYPES_H
 
620
#include <sys/types.h>
 
621
#endif
 
622
#ifdef HAVE_NETINET_IN_H
 
623
#include <netinet/in.h>
 
624
#endif
 
625
],[struct sockaddr_storage sa;],
 
626
[apr_cv_define_sockaddr_storage=yes],
 
627
[apr_cv_define_sockaddr_storage=no])])
 
628
 
 
629
if test "$apr_cv_define_sockaddr_storage" = "yes"; then
 
630
  have_sa_storage=1
 
631
else
 
632
  have_sa_storage=0
 
633
fi
 
634
AC_SUBST(have_sa_storage)
 
635
])
 
636
 
 
637
dnl Check for presence of struct sockaddr_in6.
 
638
AC_DEFUN(APR_CHECK_SOCKADDR_IN6,[
 
639
AC_CACHE_CHECK(for sockaddr_in6, ac_cv_define_sockaddr_in6,[
 
640
AC_TRY_COMPILE([
 
641
#ifdef HAVE_SYS_TYPES_H
 
642
#include <sys/types.h>
 
643
#endif
 
644
#ifdef HAVE_NETINET_IN_H
 
645
#include <netinet/in.h>
 
646
#endif
 
647
],[
 
648
struct sockaddr_in6 sa;
 
649
],[
 
650
    ac_cv_define_sockaddr_in6=yes
 
651
],[
 
652
    ac_cv_define_sockaddr_in6=no
 
653
])
 
654
])
 
655
 
 
656
if test "$ac_cv_define_sockaddr_in6" = "yes"; then
 
657
  have_sockaddr_in6=1
 
658
else
 
659
  have_sockaddr_in6=0
 
660
fi
 
661
])
 
662
 
 
663
dnl
 
664
dnl APR_H_ERRNO_COMPILE_CHECK
 
665
dnl
 
666
AC_DEFUN(APR_H_ERRNO_COMPILE_CHECK,[
 
667
  if test x$1 != x; then
 
668
    CPPFLAGS="-D$1 $CPPFLAGS"
 
669
  fi
 
670
  AC_TRY_COMPILE([
 
671
#ifdef HAVE_SYS_TYPES_H
 
672
#include <sys/types.h>
 
673
#endif
 
674
#ifdef HAVE_NETDB_H
 
675
#include <netdb.h>
 
676
#endif
 
677
],[
 
678
int h_e = h_errno;
 
679
],[
 
680
  if test x$1 != x; then
 
681
    ac_cv_h_errno_cppflags="$1"
 
682
  else
 
683
    ac_cv_h_errno_cppflags=yes
 
684
  fi
 
685
],[
 
686
  ac_cv_h_errno_cppflags=no
 
687
])])
 
688
 
 
689
 
 
690
dnl
 
691
dnl APR_CHECK_SCTP
 
692
dnl
 
693
dnl check for presence of SCTP protocol support
 
694
dnl
 
695
AC_DEFUN([APR_CHECK_SCTP],
 
696
[
 
697
  AC_CACHE_CHECK([whether SCTP is supported], [apr_cv_sctp], [
 
698
  AC_TRY_RUN([
 
699
#ifdef HAVE_SYS_TYPES_H
 
700
#include <sys/types.h>
 
701
#endif
 
702
#ifdef HAVE_SYS_SOCKET_H
 
703
#include <sys/socket.h>
 
704
#endif
 
705
#ifdef HAVE_NETINET_IN_H
 
706
#include <netinet/in.h>
 
707
#endif
 
708
#ifdef HAVE_NETINET_SCTP_H
 
709
#include <netinet/sctp.h>
 
710
#endif
 
711
#ifdef HAVE_NETINET_SCTP_UIO_H
 
712
#include <netinet/sctp_uio.h>
 
713
#endif
 
714
#include <stdlib.h>
 
715
int main(void) {
 
716
    int s, opt = 1;
 
717
    if ((s = socket(AF_INET, SOCK_STREAM, IPPROTO_SCTP)) < 0)
 
718
       exit(1);
 
719
    if (setsockopt(s, IPPROTO_SCTP, SCTP_NODELAY, &opt, sizeof(int)) < 0)
 
720
       exit(2);
 
721
    exit(0);
 
722
}], [apr_cv_sctp=yes], [apr_cv_sctp=no], [apr_cv_sctp=no])])
 
723
 
 
724
if test "$apr_cv_sctp" = "yes"; then
 
725
    have_sctp=1
 
726
else
 
727
    have_sctp=0
 
728
fi
 
729
])
 
730
 
 
731
dnl APR_CHECK_MCAST: check for multicast interfaces
 
732
AC_DEFUN([APR_CHECK_MCAST], [
 
733
AC_CACHE_CHECK([for struct ip_mreq], [apr_cv_struct_ipmreq], [
 
734
AC_TRY_COMPILE([
 
735
#include <sys/types.h>
 
736
#include <netinet/in.h>
 
737
], [
 
738
    struct ip_mreq mip;
 
739
    mip.imr_interface.s_addr = INADDR_ANY;
 
740
], [apr_cv_struct_ipmreq=yes], [apr_cv_struct_ipmreq=no], [apr_cv_struct_ipmreq=yes])])
 
741
 
 
742
if test $apr_cv_struct_ipmreq = yes; then
 
743
   AC_DEFINE([HAVE_STRUCT_IPMREQ], 1, [Define if struct impreq was found])
 
744
fi
 
745
])
 
746
 
 
747
dnl
 
748
dnl APR_CHECK_H_ERRNO_FLAG
 
749
dnl
 
750
dnl checks which flags are necessary for <netdb.h> to define h_errno
 
751
dnl
 
752
AC_DEFUN(APR_CHECK_H_ERRNO_FLAG,[
 
753
  AC_MSG_CHECKING([for h_errno in netdb.h])
 
754
  AC_CACHE_VAL(ac_cv_h_errno_cppflags,[
 
755
    APR_H_ERRNO_COMPILE_CHECK
 
756
    if test "$ac_cv_h_errno_cppflags" = "no"; then
 
757
      ac_save="$CPPFLAGS"
 
758
      for flag in _XOPEN_SOURCE_EXTENDED; do
 
759
        APR_H_ERRNO_COMPILE_CHECK($flag)
 
760
        if test "$ac_cv_h_errno_cppflags" != "no"; then
 
761
          break
 
762
        fi
 
763
      done
 
764
      CPPFLAGS="$ac_save"
 
765
    fi
 
766
  ])
 
767
  if test "$ac_cv_h_errno_cppflags" != "no"; then
 
768
    if test "$ac_cv_h_errno_cppflags" != "yes"; then
 
769
      CPPFLAGS="-D$ac_cv_h_errno_cppflags $CPPFLAGS"
 
770
      AC_MSG_RESULT([yes, with -D$ac_cv_h_errno_cppflags])
 
771
    else
 
772
      AC_MSG_RESULT([$ac_cv_h_errno_cppflags])
 
773
    fi
 
774
  else
 
775
    AC_MSG_RESULT([$ac_cv_h_errno_cppflags])
 
776
  fi
 
777
])
 
778
 
 
779
 
 
780
AC_DEFUN(APR_EBCDIC,[
 
781
  AC_CACHE_CHECK([whether system uses EBCDIC],ac_cv_ebcdic,[
 
782
  AC_TRY_RUN( [
 
783
int main(void) { 
 
784
  return (unsigned char)'A' != (unsigned char)0xC1; 
 
785
 
786
],[
 
787
  ac_cv_ebcdic="yes"
 
788
],[
 
789
  ac_cv_ebcdic="no"
 
790
],[
 
791
  ac_cv_ebcdic="no"
 
792
])])
 
793
  if test "$ac_cv_ebcdic" = "yes"; then
 
794
    apr_charset_ebcdic=1
 
795
  else
 
796
    apr_charset_ebcdic=0
 
797
  fi
 
798
  AC_SUBST(apr_charset_ebcdic)
 
799
])
 
800