10Sigor@sysoev.ru 20Sigor@sysoev.ru# Copyright (C) Igor Sysoev 30Sigor@sysoev.ru# Copyright (C) NGINX, Inc. 40Sigor@sysoev.ru 50Sigor@sysoev.ru 60Sigor@sysoev.ruif [ $NXT_INET6 = YES ]; then 70Sigor@sysoev.ru 80Sigor@sysoev.ru nxt_feature="AF_INET6" 90Sigor@sysoev.ru nxt_feature_name=NXT_INET6 100Sigor@sysoev.ru nxt_feature_run= 110Sigor@sysoev.ru nxt_feature_incs= 120Sigor@sysoev.ru nxt_feature_libs= 130Sigor@sysoev.ru nxt_feature_test="#include <stdio.h> 140Sigor@sysoev.ru #include <sys/socket.h> 150Sigor@sysoev.ru #include <sys/types.h> 160Sigor@sysoev.ru #include <netinet/in.h> 170Sigor@sysoev.ru 180Sigor@sysoev.ru int main() { 190Sigor@sysoev.ru struct sockaddr_in6 sin6; 200Sigor@sysoev.ru 210Sigor@sysoev.ru sin6.sin6_family = AF_INET6; 220Sigor@sysoev.ru printf(\"%d\", sin6.sin6_family); 230Sigor@sysoev.ru return 0; 240Sigor@sysoev.ru }" 250Sigor@sysoev.ru . auto/feature 260Sigor@sysoev.rufi 270Sigor@sysoev.ru 280Sigor@sysoev.ru 290Sigor@sysoev.ru# FreeBSD, MacOSX, NetBSD, OpenBSD. 300Sigor@sysoev.ru 310Sigor@sysoev.runxt_feature="sockaddr.sa_len" 320Sigor@sysoev.runxt_feature_name=NXT_SOCKADDR_SA_LEN 330Sigor@sysoev.runxt_feature_run= 340Sigor@sysoev.runxt_feature_incs= 350Sigor@sysoev.runxt_feature_libs= 360Sigor@sysoev.runxt_feature_test="#include <stdio.h> 370Sigor@sysoev.ru #include <sys/socket.h> 380Sigor@sysoev.ru 390Sigor@sysoev.ru int main() { 400Sigor@sysoev.ru struct sockaddr sa; 410Sigor@sysoev.ru 420Sigor@sysoev.ru sa.sa_len = 0; 430Sigor@sysoev.ru printf(\"%d\", sa.sa_len); 440Sigor@sysoev.ru return 0; 450Sigor@sysoev.ru }" 460Sigor@sysoev.ru. auto/feature 470Sigor@sysoev.ru 480Sigor@sysoev.ru 490Sigor@sysoev.runxt_feature="struct sockaddr size" 500Sigor@sysoev.runxt_feature_name=NXT_HAVE_SOCKADDR 510Sigor@sysoev.runxt_feature_run=value 520Sigor@sysoev.runxt_feature_incs= 530Sigor@sysoev.runxt_feature_libs= 540Sigor@sysoev.runxt_feature_test="#include <stdio.h> 550Sigor@sysoev.ru #include <sys/socket.h> 560Sigor@sysoev.ru 570Sigor@sysoev.ru int main() { 580Sigor@sysoev.ru printf(\"%d\", (int) sizeof(struct sockaddr)); 590Sigor@sysoev.ru return 0; 600Sigor@sysoev.ru }" 610Sigor@sysoev.ru. auto/feature 620Sigor@sysoev.ru 630Sigor@sysoev.ru 640Sigor@sysoev.runxt_feature="struct sockaddr_in size" 650Sigor@sysoev.runxt_feature_name=NXT_HAVE_SOCKADDR_IN 660Sigor@sysoev.runxt_feature_run=value 670Sigor@sysoev.runxt_feature_incs= 680Sigor@sysoev.runxt_feature_libs= 690Sigor@sysoev.runxt_feature_test="#include <stdio.h> 700Sigor@sysoev.ru #include <sys/types.h> 710Sigor@sysoev.ru #include <netinet/in.h> 720Sigor@sysoev.ru 730Sigor@sysoev.ru int main() { 740Sigor@sysoev.ru printf(\"%d\", (int) sizeof(struct sockaddr_in)); 750Sigor@sysoev.ru return 0; 760Sigor@sysoev.ru }" 770Sigor@sysoev.ru. auto/feature 780Sigor@sysoev.ru 790Sigor@sysoev.ru 800Sigor@sysoev.runxt_feature="struct sockaddr_in6 size" 810Sigor@sysoev.runxt_feature_name=NXT_HAVE_SOCKADDR_IN6 820Sigor@sysoev.runxt_feature_run=value 830Sigor@sysoev.runxt_feature_incs= 840Sigor@sysoev.runxt_feature_libs= 850Sigor@sysoev.runxt_feature_test="#include <stdio.h> 860Sigor@sysoev.ru #include <sys/types.h> 870Sigor@sysoev.ru #include <netinet/in.h> 880Sigor@sysoev.ru 890Sigor@sysoev.ru int main() { 900Sigor@sysoev.ru printf(\"%d\", (int) sizeof(struct sockaddr_in6)); 910Sigor@sysoev.ru return 0; 920Sigor@sysoev.ru }" 930Sigor@sysoev.ru. auto/feature 940Sigor@sysoev.ru 950Sigor@sysoev.ru 960Sigor@sysoev.runxt_feature="struct sockaddr_un size" 970Sigor@sysoev.runxt_feature_name=NXT_HAVE_SOCKADDR_UN 980Sigor@sysoev.runxt_feature_run=value 990Sigor@sysoev.runxt_feature_incs= 1000Sigor@sysoev.runxt_feature_libs= 1010Sigor@sysoev.runxt_feature_test="#include <stdio.h> 1020Sigor@sysoev.ru #include <sys/types.h> 1030Sigor@sysoev.ru #include <sys/un.h> 1040Sigor@sysoev.ru 1050Sigor@sysoev.ru int main() { 1060Sigor@sysoev.ru printf(\"%d\", (int) sizeof(struct sockaddr_un)); 1070Sigor@sysoev.ru return 0; 1080Sigor@sysoev.ru }" 1090Sigor@sysoev.ru. auto/feature 1100Sigor@sysoev.ru 1110Sigor@sysoev.ru 1120Sigor@sysoev.runxt_feature="struct sockaddr_storage size" 1130Sigor@sysoev.runxt_feature_name=NXT_HAVE_SOCKADDR_STORAGE 1140Sigor@sysoev.runxt_feature_run=value 1150Sigor@sysoev.runxt_feature_incs= 1160Sigor@sysoev.runxt_feature_libs= 1170Sigor@sysoev.runxt_feature_test="#include <stdio.h> 1180Sigor@sysoev.ru #include <sys/socket.h> 1190Sigor@sysoev.ru 1200Sigor@sysoev.ru int main() { 1210Sigor@sysoev.ru printf(\"%d\", (int) sizeof(struct sockaddr_storage)); 1220Sigor@sysoev.ru return 0; 1230Sigor@sysoev.ru }" 1240Sigor@sysoev.ru. auto/feature 1250Sigor@sysoev.ru 1260Sigor@sysoev.ru 1270Sigor@sysoev.runxt_feature="socketpair(AF_UNIX, SOCK_SEQPACKET)" 1280Sigor@sysoev.runxt_feature_name=NXT_HAVE_AF_UNIX_SOCK_SEQPACKET 1290Sigor@sysoev.runxt_feature_run=yes 1300Sigor@sysoev.runxt_feature_incs= 1310Sigor@sysoev.runxt_feature_libs= 1320Sigor@sysoev.runxt_feature_test="#include <stdio.h> 1330Sigor@sysoev.ru #include <sys/socket.h> 1340Sigor@sysoev.ru 1350Sigor@sysoev.ru int main() { 1360Sigor@sysoev.ru int pair[2]; 1370Sigor@sysoev.ru 1380Sigor@sysoev.ru if (socketpair(AF_UNIX, SOCK_SEQPACKET, 0, pair) != 0) 1390Sigor@sysoev.ru return 1; 1400Sigor@sysoev.ru return 0; 1410Sigor@sysoev.ru }" 1420Sigor@sysoev.ru. auto/feature 1430Sigor@sysoev.ru 1440Sigor@sysoev.ru 1450Sigor@sysoev.runxt_feature="struct msghdr.msg_control" 1460Sigor@sysoev.runxt_feature_name=NXT_HAVE_MSGHDR_MSG_CONTROL 1470Sigor@sysoev.runxt_feature_run= 1480Sigor@sysoev.runxt_feature_incs= 1490Sigor@sysoev.runxt_feature_libs= 1500Sigor@sysoev.runxt_feature_test="#include <stdio.h> 1510Sigor@sysoev.ru #include <sys/socket.h> 1520Sigor@sysoev.ru 1530Sigor@sysoev.ru int main() { 1540Sigor@sysoev.ru struct msghdr msg; 1550Sigor@sysoev.ru 1560Sigor@sysoev.ru printf(\"%d\", (int) sizeof(msg.msg_control)); 1570Sigor@sysoev.ru return 0; 1580Sigor@sysoev.ru }" 1590Sigor@sysoev.ru. auto/feature 1600Sigor@sysoev.ru 161*1996St.nateldemoura@f5.comif [ $nxt_found = no ]; then 162*1996St.nateldemoura@f5.com $echo 163*1996St.nateldemoura@f5.com $echo $0: error: no msghdr.msg_control struct member. 164*1996St.nateldemoura@f5.com $echo 165*1996St.nateldemoura@f5.com exit 1; 166*1996St.nateldemoura@f5.comfi 167*1996St.nateldemoura@f5.com 168*1996St.nateldemoura@f5.com 169*1996St.nateldemoura@f5.comnxt_feature="sockopt SO_PASSCRED" 170*1996St.nateldemoura@f5.comnxt_feature_name=NXT_HAVE_SOCKOPT_SO_PASSCRED 171*1996St.nateldemoura@f5.comnxt_feature_run= 172*1996St.nateldemoura@f5.comnxt_feature_incs= 173*1996St.nateldemoura@f5.comnxt_feature_libs= 174*1996St.nateldemoura@f5.comnxt_feature_test="#define _GNU_SOURCE 175*1996St.nateldemoura@f5.com #include <sys/socket.h> 176*1996St.nateldemoura@f5.com 177*1996St.nateldemoura@f5.com int main() { 178*1996St.nateldemoura@f5.com return SO_PASSCRED == 0; 179*1996St.nateldemoura@f5.com }" 180*1996St.nateldemoura@f5.com. auto/feature 181*1996St.nateldemoura@f5.com 182*1996St.nateldemoura@f5.com 183*1996St.nateldemoura@f5.comif [ $nxt_found = yes ]; then 184*1996St.nateldemoura@f5.com nxt_feature="struct ucred" 185*1996St.nateldemoura@f5.com nxt_feature_name=NXT_HAVE_UCRED 186*1996St.nateldemoura@f5.com nxt_feature_run= 187*1996St.nateldemoura@f5.com nxt_feature_incs= 188*1996St.nateldemoura@f5.com nxt_feature_libs= 189*1996St.nateldemoura@f5.com nxt_feature_test="#define _GNU_SOURCE 190*1996St.nateldemoura@f5.com #include <sys/socket.h> 191*1996St.nateldemoura@f5.com #include <sys/un.h> 192*1996St.nateldemoura@f5.com 193*1996St.nateldemoura@f5.com int main() { 194*1996St.nateldemoura@f5.com return sizeof(struct ucred); 195*1996St.nateldemoura@f5.com }" 196*1996St.nateldemoura@f5.com . auto/feature 197*1996St.nateldemoura@f5.comfi 198*1996St.nateldemoura@f5.com 199*1996St.nateldemoura@f5.com 200*1996St.nateldemoura@f5.comnxt_feature="struct cmsgcred" 201*1996St.nateldemoura@f5.comnxt_feature_name=NXT_HAVE_MSGHDR_CMSGCRED 202*1996St.nateldemoura@f5.comnxt_feature_run= 203*1996St.nateldemoura@f5.comnxt_feature_incs= 204*1996St.nateldemoura@f5.comnxt_feature_libs= 205*1996St.nateldemoura@f5.comnxt_feature_test="#define _GNU_SOURCE 206*1996St.nateldemoura@f5.com #include <sys/socket.h> 207*1996St.nateldemoura@f5.com 208*1996St.nateldemoura@f5.com int main() { 209*1996St.nateldemoura@f5.com return sizeof(struct cmsgcred); 210*1996St.nateldemoura@f5.com }" 211*1996St.nateldemoura@f5.com. auto/feature 212*1996St.nateldemoura@f5.com 2130Sigor@sysoev.ru 2140Sigor@sysoev.runxt_feature="sys/filio.h" 2150Sigor@sysoev.runxt_feature_name=NXT_HAVE_SYS_FILIO_H 2160Sigor@sysoev.runxt_feature_run= 2170Sigor@sysoev.runxt_feature_incs= 2180Sigor@sysoev.runxt_feature_libs= 2190Sigor@sysoev.runxt_feature_test="#include <sys/filio.h> 2200Sigor@sysoev.ru 2210Sigor@sysoev.ru int main() { 2220Sigor@sysoev.ru return 0; 2230Sigor@sysoev.ru }" 2240Sigor@sysoev.ru. auto/feature 2250Sigor@sysoev.ru 2260Sigor@sysoev.ruif [ $nxt_found = yes ]; then 2270Sigor@sysoev.ru NXT_SYS_FILIO_H="#include <sys/filio.h>" 2280Sigor@sysoev.ruelse 2290Sigor@sysoev.ru NXT_SYS_FILIO_H= 2300Sigor@sysoev.rufi 2310Sigor@sysoev.ru 2320Sigor@sysoev.ru 2330Sigor@sysoev.runxt_feature="ioctl(FIONBIO)" 2340Sigor@sysoev.runxt_feature_name=NXT_HAVE_FIONBIO 2350Sigor@sysoev.runxt_feature_run= 2360Sigor@sysoev.runxt_feature_incs= 2370Sigor@sysoev.runxt_feature_libs= 2380Sigor@sysoev.runxt_feature_test="#include <unistd.h> 2390Sigor@sysoev.ru #include <sys/socket.h> 2400Sigor@sysoev.ru $NXT_SYS_FILIO_H 2410Sigor@sysoev.ru #include <sys/ioctl.h> 2420Sigor@sysoev.ru 2430Sigor@sysoev.ru int main() { 2440Sigor@sysoev.ru int nb; 2450Sigor@sysoev.ru 2460Sigor@sysoev.ru nb = 0; 2470Sigor@sysoev.ru ioctl(-1, FIONBIO, &nb); 2480Sigor@sysoev.ru return 0; 2490Sigor@sysoev.ru }" 2500Sigor@sysoev.ru. auto/feature 2510Sigor@sysoev.ru 2520Sigor@sysoev.ru 2530Sigor@sysoev.ru# socket(SOCK_NONBLOCK), Linux 2.6.27/glibc 2.10, NetBSD 6.0, FreeBSD 9.2. 2540Sigor@sysoev.ru 2550Sigor@sysoev.runxt_feature="socket(SOCK_NONBLOCK)" 2560Sigor@sysoev.runxt_feature_name=NXT_HAVE_SOCK_NONBLOCK 2570Sigor@sysoev.runxt_feature_run= 2580Sigor@sysoev.runxt_feature_incs= 2590Sigor@sysoev.runxt_feature_libs= 2600Sigor@sysoev.runxt_feature_test="#define _GNU_SOURCE 2610Sigor@sysoev.ru #include <sys/socket.h> 2620Sigor@sysoev.ru 2630Sigor@sysoev.ru int main() { 2640Sigor@sysoev.ru socket(AF_INET, SOCK_STREAM | SOCK_NONBLOCK, 0); 2650Sigor@sysoev.ru return 0; 2660Sigor@sysoev.ru }" 2670Sigor@sysoev.ru. auto/feature 2680Sigor@sysoev.ru 2690Sigor@sysoev.ru 2700Sigor@sysoev.ru# accept4(), Linux 2.6.28/glibc 2.10, NetBSD 6.0, FreeBSD 9.2. 2710Sigor@sysoev.ru 2720Sigor@sysoev.runxt_feature="accept4()" 2730Sigor@sysoev.runxt_feature_name=NXT_HAVE_ACCEPT4 2740Sigor@sysoev.runxt_feature_run= 2750Sigor@sysoev.runxt_feature_incs= 2760Sigor@sysoev.runxt_feature_libs= 2770Sigor@sysoev.runxt_feature_test="#define _GNU_SOURCE 2780Sigor@sysoev.ru #include <stdlib.h> 2790Sigor@sysoev.ru #include <sys/socket.h> 2800Sigor@sysoev.ru 2810Sigor@sysoev.ru int main() { 2820Sigor@sysoev.ru accept4(0, NULL, NULL, SOCK_NONBLOCK); 2830Sigor@sysoev.ru return 0; 2840Sigor@sysoev.ru }" 2850Sigor@sysoev.ru. auto/feature 286