1dnl look for available socket options 2 3unset ALLSOCKOPTS 4unset SOCKOPTS 5#socket level 6L_CHECKSOCKOPT(SOL_SOCKET, SO_BINDANY) #test requires root 7L_CHECKSOCKOPT(SOL_SOCKET, SO_BROADCAST) 8L_CHECKSOCKOPT(SOL_SOCKET, SO_DEBUG) 9L_CHECKSOCKOPT(SOL_SOCKET, SO_DONTROUTE) 10L_CHECKSOCKOPT(SOL_SOCKET, SO_JUMBO) 11L_CHECKSOCKOPT(SOL_SOCKET, SO_KEEPALIVE) 12L_CHECKSOCKOPT(SOL_SOCKET, SO_LINGER) #linger arg 13L_CHECKSOCKOPT(SOL_SOCKET, SO_OOBINLINE) 14L_CHECKSOCKOPT(SOL_SOCKET, SO_PRIORITY) 15L_CHECKSOCKOPT(SOL_SOCKET, SO_RCVBUF) 16L_CHECKSOCKOPT(SOL_SOCKET, SO_RCVBUFFORCE) 17L_CHECKSOCKOPT(SOL_SOCKET, SO_RCVLOWAT) 18L_CHECKSOCKOPT(SOL_SOCKET, SO_RCVTIMEO) #timeval arg 19L_CHECKSOCKOPT(SOL_SOCKET, SO_SNDBUF) 20L_CHECKSOCKOPT(SOL_SOCKET, SO_SNDBUFFORCE) 21L_CHECKSOCKOPT(SOL_SOCKET, SO_SNDLOWAT) 22L_CHECKSOCKOPT(SOL_SOCKET, SO_SNDTIMEO) #timeval arg 23L_CHECKSOCKOPT(SOL_SOCKET, SO_TIMESTAMP) #XXX requires additional code 24L_CHECKSOCKOPT(SOL_SOCKET, SO_USELOOPBACK) 25L_CHECKSOCKOPT(SOL_SOCKET, SO_AUDIT) 26L_CHECKSOCKOPT(SOL_SOCKET, SO_CKSUMRECV) 27L_CHECKSOCKOPT(SOL_SOCKET, SO_NOMULTIPATH) 28L_CHECKSOCKOPT(SOL_SOCKET, SO_NOREUSEADDR) #XXX usable? 29 30#tcp level 31L_CHECKSOCKOPT(IPPROTO_TCP, TCP_CORK) 32L_CHECKSOCKOPT(IPPROTO_TCP, TCP_CWND) #Google patch 33L_CHECKSOCKOPT(IPPROTO_TCP, TCP_INIT_CWND) #Solaris 34L_CHECKSOCKOPT(IPPROTO_TCP, TCP_KEEPCNT) 35L_CHECKSOCKOPT(IPPROTO_TCP, TCP_KEEPIDLE) 36L_CHECKSOCKOPT(IPPROTO_TCP, TCP_KEEPINTVL) 37L_CHECKSOCKOPT(IPPROTO_TCP, TCP_LINGER2) 38L_CHECKSOCKOPT(IPPROTO_TCP, TCP_MAXRT) 39L_CHECKSOCKOPT(IPPROTO_TCP, TCP_MAXSEG) 40L_CHECKSOCKOPT(IPPROTO_TCP, TCP_MD5SIG) 41L_CHECKSOCKOPT(IPPROTO_TCP, TCP_NODELAY) 42L_CHECKSOCKOPT(IPPROTO_TCP, TCP_NOOPT) 43L_CHECKSOCKOPT(IPPROTO_TCP, TCP_NOPUSH) 44#L_CHECKSOCKOPT(IPPROTO_TCP, TCP_QUICKACK) #only transient? 45L_CHECKSOCKOPT(IPPROTO_TCP, TCP_SACK_ENABLE) 46L_CHECKSOCKOPT(IPPROTO_TCP, TCP_STDURG) 47L_CHECKSOCKOPT(IPPROTO_TCP, TCP_SYNCNT) 48L_CHECKSOCKOPT(IPPROTO_TCP, TCP_WINDOW_CLAMP) 49L_CHECKSOCKOPT(IPPROTO_TCP, TCP_RFC1323) 50L_CHECKSOCKOPT(IPPROTO_TCP, TCP_NODELAYACK) 51L_CHECKSOCKOPT(IPPROTO_TCP, TCP_CWND_IF) 52L_CHECKSOCKOPT(IPPROTO_TCP, TCP_CWND_DF) 53L_CHECKSOCKOPT(IPPROTO_TCP, TCP_NOTENTER_SSTART) 54L_CHECKSOCKOPT(IPPROTO_TCP, TCP_NOREDUCE_CWND_IN_FRXMT) 55L_CHECKSOCKOPT(IPPROTO_TCP, TCP_NOREDUCE_CWND_EXIT_FRXMT) 56 57#udp level 58L_CHECKSOCKOPT(IPPROTO_UDP, UDP_CORK) 59 60#ipv4 level 61L_CHECKSOCKOPT(IPPROTO_IP, IP_AUTH_LEVEL) 62L_CHECKSOCKOPT(IPPROTO_IP, IP_DONTFRAG) 63L_CHECKSOCKOPT(IPPROTO_IP, IP_ESP_NETWORK_LEVEL) 64L_CHECKSOCKOPT(IPPROTO_IP, IP_ESP_TRANS_LEVEL) 65L_CHECKSOCKOPT(IPPROTO_IP, IP_FREEBIND) 66L_CHECKSOCKOPT(IPPROTO_IP, IP_IPCOMP_LEVEL) 67L_CHECKSOCKOPT(IPPROTO_IP, IP_MINTTL) 68L_CHECKSOCKOPT(IPPROTO_IP, IP_MTU_DISCOVER) 69L_CHECKSOCKOPT(IPPROTO_IP, IP_PORTRANGE) 70L_CHECKSOCKOPT(IPPROTO_IP, IP_TOS) 71L_CHECKSOCKOPT(IPPROTO_IP, IP_TTL) 72L_CHECKSOCKOPT(IPPROTO_IP, IP_TRANSPARENT) 73L_CHECKSOCKOPT(IPPROTO_IP, IP_UNICAST_HOPS) 74L_CHECKSOCKOPT(IPPROTO_IP, IP_BROADCAST_IF) 75 76#ipv6 level 77L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ADDRFORM) 78L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_UNICAST_HOPS) 79L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_2292DSTOPTS) 80L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_2292HOPLIMIT) 81L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_2292HOPOPTS) 82L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_2292PKTINFO) 83L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_2292PKTOPTIONS) 84L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_2292RTHDR) 85L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ADDRFORM) 86L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ADDR_PREFERENCES) 87L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_AUTHHDR) 88L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_AUTH_LEVEL) 89L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_AUTOFLOWLABEL) 90L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_CHECKSUM) 91L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_DONTFRAG) 92L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_DSTOPTS) 93L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_DSTOPTS) 94L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ESP_NETWORK_LEVEL) 95L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ESP_TRANS_LEVEL) 96L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_FLOWINFO) 97L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_FLOWINFO_SEND) 98L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_FLOWLABEL_MGR) 99L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_HOPLIMIT) 100L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_HOPLIMIT) 101L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_HOPOPTS) 102L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_HOPOPTS) 103L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_IPCOMP_LEVEL) 104L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_IPSEC_POLICY) 105L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_JOIN_ANYCAST) 106L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_JOIN_GROUP) 107L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_LEAVE_ANYCAST) 108L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_LEAVE_GROUP) 109L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_MINHOPCOUNT) 110L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_MTU) 111L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_MTU_DISCOVER) 112L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_NEXTHOP) 113L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ORIGDSTADDR) 114L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_PATHMTU) 115L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_PIPEX) 116L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_PKTINFO) 117L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_PORTRANGE) 118L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RETOPTS) 119L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ROUTER_ALERT) 120L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RTHDR) 121L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RTHDRDSTOPTS) 122L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_TCLASS) 123L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_TRANSPARENT) 124L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_UNICAST_HOPS) 125L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_USE_MIN_MTU) 126L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_V6ONLY) 127L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_XFRM_POLICY) 128L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_MIPDSTOPTS) 129L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_AIXRAWSOCKET) 130 131OKSOCKOPTS="$SOCKOPTS" #user-settable socket options 132 133ALLSOCKOPTS="$SOCKOPTS" 134 135unset SOCKOPTS #default to no TCP_IPA support 136AC_CHECK_HEADER(linux/bbkernel.h, 137[#found TCP_IPA header, cannot include headers during build 138 #so determine values of expected defines. 139 SOCKOPTS="TCP_IPA" 140 L_GETDEFINEDINT(IPA_VERSION, [ 141#include <linux/bbkernel.h> 142], SOCKS_HOSTID_VERSION) 143 L_GETDEFINEDINT(MAX_IPA, [ 144#include <linux/bbkernel.h> 145], HAVE_MAX_HOSTIDS) 146 L_GETDEFINEDINT(TCP_IPA, [ 147#include <linux/tcp.h> 148], TCP_IPA) 149 AC_DEFINE(HAVE_TCP_IPA, 1, [TCP_IPA supported])dnl 150 AC_DEFINE(SOCKS_TCP_IPA_LVL, IPPROTO_TCP, [TCP_IPA protocol level])dnl 151 AC_DEFINE(SOCKS_TCP_IPA_NAME, "tcp_ipa", [TCP_IPA symbolic name])dnl 152 AC_DEFINE(SOCKS_TCP_IPA_IPV4, 1, [TCP_IPA IPv4 usability])dnl 153 AC_DEFINE(SOCKS_TCP_IPA_IPV6, 0, [TCP_IPA IPv6 usability])]) 154 155HOSTIDSOCKOPTS="$SOCKOPTS" 156 157ALLSOCKOPTS="$ALLSOCKOPTS $SOCKOPTS" 158 159#options that are not settable by users 160unset SOCKOPTS 161#socket level 162L_CHECKSOCKOPT(SOL_SOCKET, SO_ERROR) #not usable 163L_CHECKSOCKOPT(SOL_SOCKET, SO_REUSEADDR) #not usable 164L_CHECKSOCKOPT(SOL_SOCKET, SO_REUSEPORT) #not usable 165L_CHECKSOCKOPT(SOL_SOCKET, SO_ACCEPTCONN) #not usable 166L_CHECKSOCKOPT(SOL_SOCKET, SO_KERNACCEPT) #likely not usable 167L_CHECKSOCKOPT(SOL_SOCKET, SO_PEERID) #likely not usable 168L_CHECKSOCKOPT(SOL_SOCKET, SO_TYPE) #likely not usable 169L_CHECKSOCKOPT(SOL_SOCKET, SO_USE_IFBUFS) #likely not usable 170 171#ipv4 level 172L_CHECKSOCKOPT(IPPROTO_IP, IP_ADDRFORM) #not usable 173L_CHECKSOCKOPT(IPPROTO_IP, IP_ADD_MEMBERSHIP) #likely not usable 174L_CHECKSOCKOPT(IPPROTO_IP, IP_ADD_SOURCE_MEMBERSHIP) #not usable 175L_CHECKSOCKOPT(IPPROTO_IP, IP_BLOCK_SOURCE) #not usable 176L_CHECKSOCKOPT(IPPROTO_IP, IP_DHCPMODE) #likely not usable 177L_CHECKSOCKOPT(IPPROTO_IP, IP_DROP_MEMBERSHIP) #likely not usable 178L_CHECKSOCKOPT(IPPROTO_IP, IP_DROP_MEMBERSHIP) #not usable 179L_CHECKSOCKOPT(IPPROTO_IP, IP_DROP_SOURCE_MEMBERSHIP) #not usable 180L_CHECKSOCKOPT(IPPROTO_IP, IP_DROP_SOURCE_MEMBERSHIP) #not usable 181L_CHECKSOCKOPT(IPPROTO_IP, IP_FINDPMTU) #likely not usable 182L_CHECKSOCKOPT(IPPROTO_IP, IP_HDRINCL) #not usable 183L_CHECKSOCKOPT(IPPROTO_IP, IP_HDRINCL) #not usable 184L_CHECKSOCKOPT(IPPROTO_IP, IP_MULTICAST_HOPS) #not usable 185L_CHECKSOCKOPT(IPPROTO_IP, IP_MULTICAST_IF) #not usable 186L_CHECKSOCKOPT(IPPROTO_IP, IP_MULTICAST_LOOP) #not usable 187L_CHECKSOCKOPT(IPPROTO_IP, IP_MULTICAST_TTL) #not usable 188L_CHECKSOCKOPT(IPPROTO_IP, IP_OPTIONS) #likely not usable/unsupported type 189L_CHECKSOCKOPT(IPPROTO_IP, IP_PMTUAGE) #likely not usable 190L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVDSTADDR) #not usable 191L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVIF) #not usable 192L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVIFINFO) #not usable 193L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVINTERFACE) #likely not usable 194L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVMACHDR) #not usable 195L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVTOS) #not usable 196L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVTTL) #likely not usable 197L_CHECKSOCKOPT(IPPROTO_IP, IP_RECVTTL) #not usable 198L_CHECKSOCKOPT(IPPROTO_IP, IP_SOURCE_FILTER) #not usable 199L_CHECKSOCKOPT(IPPROTO_IP, IP_UNBLOCK_SOURCE) #not usable 200 201#ipv6 level (XXX likely more) 202L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_MULTICAST_HOPS) 203L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_MULTICAST_IF) 204L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_MULTICAST_LOOP) 205L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_AIXRAWSOCKET) #not usable 206L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_NOPROBE) #not usable 207L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_PKTOPTIONS) #not usable 208L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVHOPS) #not usable 209L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVIF) #not usable 210L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVSRCRT) #not usable 211L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_SENDIF) #not usable 212L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_ADD_MEMBERSHIP) 213L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_DROP_MEMBERSHIP) 214L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVDSTADDR) 215L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVDSTOPTS) 216L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVERR) 217L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVHOPLIMIT) 218L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVHOPOPTS) 219L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVOPTS) 220L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVORIGDSTADDR) 221L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVPATHMTU) 222L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVPKTINFO) 223L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVRETOPTS) 224L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVRTHDR) 225L_CHECKSOCKOPT(IPPROTO_IPV6, IPV6_RECVTCLASS) 226 227INVALIDSOCKOPTS="$SOCKOPTS" #not user-settable options 228 229ALLSOCKOPTS="$ALLSOCKOPTS $SOCKOPTS" 230 231#add symbolic values for options 232unset SOCKOPTVALSYMS 233for opt in $OKSOCKOPTS; do 234 case $opt in 235 IP_PORTRANGE) 236 L_CHECKSOCKOPTVALSYM(IPPROTO_IP, IP_PORTRANGE, IP_PORTRANGE_DEFAULT) 237 L_CHECKSOCKOPTVALSYM(IPPROTO_IP, IP_PORTRANGE, IP_PORTRANGE_HIGH) 238 L_CHECKSOCKOPTVALSYM(IPPROTO_IP, IP_PORTRANGE, IP_PORTRANGE_LOW) 239 ;; 240 esac 241done 242 243#define socket option behavior. 244# the default is integer values that can only be set before bind()/connect(), 245# exceptions are specified here. 246 247#postonly: only settable after bind()/connect() 248SOCKOPTS_POSTONLY="TCP_CWND" 249 250#anytime: always settable 251SOCKOPTS_ANYTIME="SO_DEBUG IP_TOS" #XXX verify/expand 252 253#dup: options for which values should be duplicated across connections 254SOCKOPTSDUP_IP="IP_HDRINCL IP_MULTICAST_IF IP_MULTICAST_LOOP IP_MULTICAST_TTL 255 IP_OPTIONS IP_RECVDSTADDR IP_RECVIF IP_TOS IP_TTL" 256SOCKOPTSDUP_SOL="SO_BROADCAST SO_DEBUG SO_DONTROUTE SO_KEEPALIVE SO_LINGER 257 SO_OOBINLINE SO_RCVBUF SO_RCVLOWAT SO_RCVTIMEO SO_REUSEADDR 258 SO_REUSEPORT SO_SNDBUF SO_SNDLOWAT SO_SNDTIMEO SO_TIMESTAMP 259 SO_USELOOPBACK" 260SOCKOPTSDUP_TCP="TCP_KEEPALIVE TCP_MAXRT TCP_MAXSEG TCP_NODELAY TCP_STDURG" 261 262IPTOS_DSCP="AF11 AF12 AF13 AF21 AF22 AF23 AF31 AF32 AF33 AF41 AF42 AF43 263 CS0 CS1 CS2 CS3 CS4 CS5 CS6 CS7 EF" 264IPTOS_PREC="NETCONTROL INTERNETCONTROL CRITIC_ECP FLASHOVERRIDE FLASH 265 IMMEDIATE PRIORITY ROUTINE" 266IPTOS_TOS="LOWDELAY THROUGHPUT RELIABILITY" 267 268sockopt2argtype() 269{ 270 _opt=$1 271 272 case ${_opt} in 273 SO_LINGER) 274 _argtype="linger_val" 275 ;; 276 SO_SNDTIMEO | SO_RCVTIMEO) 277 _argtype="timeval_val" 278 ;; 279 TCP_IPA) 280 _argtype="option28_val" 281 ;; 282 *) 283 _argtype="int_val" 284 ;; 285 esac 286 287 echo ${_argtype} 288} 289 290optargmatch () 291{ 292 _list="$1" 293 _opt="$2" 294 295 for _val in ${_list}; do 296 if test x"${_val}" = x"${_opt}"; then 297 return 0 298 fi 299 done 300 301 return 1 302} 303 304#priv: options that require privileges to set 305SOCKOPTS_PRIV="SO_BINDANY SO_RCVBUFFORCE SO_SNDBUFFORCE IP_TRANSPARENT IP_FREEBIND" 306case $host in 307 *-*-linux-*) 308 SOCKOPTS_PRIV="$SOCKOPTS_PRIV${SOCKOPTS_PRIV:+ }SO_DEBUG" 309 ;; 310esac 311 312OPTSRCTMP0=_sockopttmp0.c #for options to be duplicated 313OPTSRCTMP1=_sockopttmp1.c #for options definitions 314OPTSRCTMP2=_sockopttmp2.c #for option argument symbols 315cp /dev/null $OPTSRCTMP0 316cp /dev/null $OPTSRCTMP1 317cp /dev/null $OPTSRCTMP2 318 319DUPSOCKOPTCNT=0 320for opt in $ALLSOCKOPTS; do 321 if optargmatch "${SOCKOPTSDUP_IP}" $opt; then 322 echo " { IPPROTO_IP, $opt, \"$opt\" }," >> $OPTSRCTMP0 323 DUPSOCKOPTCNT=`expr $DUPSOCKOPTCNT + 1` 324 fi 325 if optargmatch "${SOCKOPTSDUP_SOL}" $opt; then 326 echo " { SOL_SOCKET, $opt, \"$opt\" }," >> $OPTSRCTMP0 327 DUPSOCKOPTCNT=`expr $DUPSOCKOPTCNT + 1` 328 fi 329 if optargmatch "${SOCKOPTSDUP_TCP}" $opt; then 330 echo " { IPPROTO_TCP, $opt, \"$opt\" }," >> $OPTSRCTMP0 331 DUPSOCKOPTCNT=`expr $DUPSOCKOPTCNT + 1` 332 fi 333done 334 335SOCKOPTCNT=0 336SOCKOPTSYMCNT=0 337unset OKSOCKOPTVALSYMS 338for opt in $OKSOCKOPTS; do 339 argtype=`sockopt2argtype $opt` 340 341 calltype="preonly" #default 342 if optargmatch "${SOCKOPTS_POSTONLY}" $opt; then 343 calltype="postonly" 344 fi 345 if optargmatch "${SOCKOPTS_ANYTIME}" $opt; then 346 calltype="anytime" 347 fi 348 349 optshift=0 350 optmask=0 351 352 if optargmatch "${SOCKOPTS_DUP}" $opt; then 353 dup=1 354 else 355 dup=0 356 fi 357 358 priv=0 359 360 if optargmatch "${SOCKOPTS_PRIV}" $opt; then 361 priv=1 362 else 363 priv=0 364 fi 365 366 optid=$SOCKOPTCNT 367 368 echo " { $optid, $argtype, ${opt}, SOCKS_${opt}_LVL, SOCKS_${opt}_IPV4, SOCKS_${opt}_IPV6, $calltype, $optshift, $optmask, $dup, $priv, SOCKS_${opt}_NAME }," >> $OPTSRCTMP1 369 SOCKOPTCNT=`expr $SOCKOPTCNT + 1` 370 371 #add subfields 372 case $opt in 373 IP_PORTRANGE) 374 unset SOCKOPTVALSYMS 375 L_CHECKSOCKOPTVALSYM(IPPROTO_IP, IP_PORTRANGE, IP_PORTRANGE_DEFAULT) 376 L_CHECKSOCKOPTVALSYM(IPPROTO_IP, IP_PORTRANGE, IP_PORTRANGE_HIGH) 377 L_CHECKSOCKOPTVALSYM(IPPROTO_IP, IP_PORTRANGE, IP_PORTRANGE_LOW) 378 unset symlist 379 for sym in $SOCKOPTVALSYMS; do 380 echo " { $optid, { .int_val = $sym }, SOCKS_${sym}_SYMNAME }," >> $OPTSRCTMP2 381 lcsym=`echo $sym | ucase` 382 symlist="$symlist${symlist:+ }$lcsym" 383 SOCKOPTSYMCNT=`expr $SOCKOPTSYMCNT + 1` 384 done 385 if test x"$symlist" != x; then 386 OKSOCKOPTVALSYMS="$OKSOCKOPTVALSYMS${OKSOCKOPTVALSYMS:+ }$opt($symlist)" 387 fi 388 ;; 389 390 IP_TOS) 391 #DSCP (rfc2474), 6 bits (2-7) 392 optshift=2 393 optmask=0x3F 394 optid=$SOCKOPTCNT 395 subfield="ip_tos.dscp" 396 AC_DEFINE_UNQUOTED(SOCKS_IP_TOS_DSCP_NAME, ["$subfield"], [IP_TOS subfield]) 397 echo " { $optid, $argtype, ${opt}, SOCKS_${opt}_LVL, SOCKS_${opt}_IPV4, SOCKS_${opt}_IPV6, $calltype, $optshift, $optmask, $dup, $priv, SOCKS_IP_TOS_DSCP_NAME }," >> $OPTSRCTMP1 398 SOCKOPTCNT=`expr $SOCKOPTCNT + 1` 399 400 unset symlist 401 for sym in $IPTOS_DSCP; do 402 echo " { $optid, { .int_val = SOCKS_IP_TOS_DSCP_${sym} }, SOCKS_IP_TOS_DSCP_${sym}_SYMNAME }," >> $OPTSRCTMP2 403 lcsym=`echo $sym | ucase` 404 symlist="$symlist${symlist:+ }$lcsym" 405 SOCKOPTSYMCNT=`expr $SOCKOPTSYMCNT + 1` 406 done 407 if test x"$symlist" != x; then 408 OKSOCKOPTVALSYMS="$OKSOCKOPTVALSYMS${OKSOCKOPTVALSYMS:+ }$subfield($symlist)" 409 fi 410 411 #Precedence 412 optshift=5 413 optmask=0x7 414 optid=$SOCKOPTCNT 415 subfield="ip_tos.prec" 416 AC_DEFINE_UNQUOTED(SOCKS_IP_TOS_PREC_NAME, ["$subfield"], [IP_TOS subfield]) 417 echo " { $optid, $argtype, ${opt}, SOCKS_${opt}_LVL, SOCKS_${opt}_IPV4, SOCKS_${opt}_IPV6, $calltype, $optshift, $optmask, $dup, $priv, SOCKS_IP_TOS_PREC_NAME }," >> $OPTSRCTMP1 418 SOCKOPTCNT=`expr $SOCKOPTCNT + 1` 419 420 unset symlist 421 for sym in $IPTOS_PREC; do 422 echo " { $optid, { .int_val = SOCKS_IP_TOS_PREC_${sym} }, SOCKS_IP_TOS_PREC_${sym}_SYMNAME }," >> $OPTSRCTMP2 423 lcsym=`echo $sym | ucase` 424 symlist="$symlist${symlist:+ }$lcsym" 425 SOCKOPTSYMCNT=`expr $SOCKOPTSYMCNT + 1` 426 done 427 if test x"$symlist" != x; then 428 OKSOCKOPTVALSYMS="$OKSOCKOPTVALSYMS${OKSOCKOPTVALSYMS:+ }$subfield($symlist)" 429 fi 430 431 #TOS (bits 1-4) 432 optshift=1 433 optmask=0xf 434 optid=$SOCKOPTCNT 435 subfield="ip_tos.tos" 436 AC_DEFINE_UNQUOTED(SOCKS_IP_TOS_TOS_NAME, ["$subfield"], [IP_TOS subfield]) 437 echo " { $optid, $argtype, ${opt}, SOCKS_${opt}_LVL, SOCKS_${opt}_IPV4, SOCKS_${opt}_IPV6, $calltype, $optshift, $optmask, $dup, $priv, SOCKS_IP_TOS_TOS_NAME }," >> $OPTSRCTMP1 438 SOCKOPTCNT=`expr $SOCKOPTCNT + 1` 439 440 unset symlist 441 for sym in $IPTOS_TOS; do 442 echo " { $optid, { .int_val = SOCKS_IP_TOS_TOS_${sym} }, SOCKS_IP_TOS_TOS_${sym}_SYMNAME }," >> $OPTSRCTMP2 443 lcsym=`echo $sym | ucase` 444 symlist="$symlist${symlist:+ }$lcsym" 445 SOCKOPTSYMCNT=`expr $SOCKOPTSYMCNT + 1` 446 done 447 if test x"$symlist" != x; then 448 OKSOCKOPTVALSYMS="$OKSOCKOPTVALSYMS${OKSOCKOPTVALSYMS:+ }$subfield($symlist)" 449 fi 450 ;; 451 esac 452done 453 454#hostid options (only set first) 455unset HOSTIDTYPE 456AC_MSG_CHECKING([for supported hostid type]) 457for opt in $HOSTIDSOCKOPTS; do 458 argtype=`sockopt2argtype $opt` 459 460 calltype="preonly" #default 461 if optargmatch "${SOCKOPTS_POSTONLY}" $opt; then 462 calltype="postonly" 463 fi 464 if optargmatch "${SOCKOPTS_ANYTIME}" $opt; then 465 calltype="anytime" 466 fi 467 468 optshift=0 469 optmask=0 470 471 if optargmatch "${SOCKOPTS_DUP}" $opt; then 472 dup=1 473 else 474 dup=0 475 fi 476 477 priv=0 478 479 if optargmatch "${SOCKOPTS_PRIV}" $opt; then 480 priv=1 481 else 482 priv=0 483 fi 484 485 optid=$SOCKOPTCNT 486 487 AC_DEFINE_UNQUOTED(SOCKS_HOSTID_NAME, ["hostid"], [hostid option type]) 488 echo " { $optid, $argtype, ${opt}, SOCKS_${opt}_LVL, SOCKS_${opt}_IPV4, SOCKS_${opt}_IPV6, $calltype, $optshift, $optmask, $dup, $priv, SOCKS_HOSTID_NAME }," >> $OPTSRCTMP1 489 AC_DEFINE_UNQUOTED(SOCKS_HOSTID_TYPE, [SOCKS_HOSTID_TYPE_${opt}], [hostid option type]) 490 SOCKOPTCNT=`expr $SOCKOPTCNT + 1` 491 HOSTIDTYPE=$opt 492 493 #add supported arguments 494 unset symlist 495 for sym in NONE PASS ADDCLIENT SETCLIENT; do 496 echo " { $optid, { .int_val = SOCKS_HOSTID_$sym }, SOCKS_HOSTID_${sym}_SYMNAME }," >> $OPTSRCTMP2 497 SOCKOPTSYMCNT=`expr $SOCKOPTSYMCNT + 1` 498 done 499 OKSOCKOPTVALSYMS="$OKSOCKOPTVALSYMS${OKSOCKOPTVALSYMS:+ }hostid(none pass add-client set-client)" 500 OKSOCKOPTS="$OKSOCKOPTS${OKSOCKOPTS:+ }hostid($opt)" 501 502 break #end after first entry 503done 504if test x"$HOSTIDTYPE" = x; then 505 AC_MSG_RESULT([no]) 506 AC_DEFINE(SOCKS_HOSTID_TYPE, [SOCKS_HOSTID_TYPE_NONE], [no hostid support]) 507else 508 AC_MSG_RESULT([$HOSTIDTYPE]) 509 FEAT="$FEAT${FEAT:+ }hostid" 510fi 511 512#options that are not settable by users 513for opt in $INVALIDSOCKOPTS; do 514 calltype="invalid" 515 argtype=`sockopt2argtype $opt` 516 optshift=0 517 optmask=0 518 priv=0 519 optid=$SOCKOPTCNT 520 521 echo " { $optid, $argtype, ${opt}, SOCKS_${opt}_LVL, SOCKS_${opt}_IPV4, SOCKS_${opt}_IPV6, $calltype, $optshift, $optmask, $dup, $priv, SOCKS_${opt}_NAME }," >> $OPTSRCTMP1 522 SOCKOPTCNT=`expr $SOCKOPTCNT + 1` 523done 524 525OPTNAMEMAXLEN=0 526for opt in $ALLSOCKOPTS $INVALIDSOCKOPTS; do 527 namelen=`echo $opt | wc -c` #should include newline 528 if test $namelen -gt $OPTNAMEMAXLEN; then 529 OPTNAMEMAXLEN=$namelen 530 fi 531done 532AC_DEFINE_UNQUOTED(SOCKOPTNAME_MAXLEN, [$OPTNAMEMAXLEN], [longest name + 1]) 533 534#generate source file 535case $APP in 536 dante) 537 SOCKOPTSRC="lib/sockopt_gen.c" 538 ;; 539 *) 540 SOCKOPTSRC="src/sockopt_gen.c" 541 ;; 542esac 543cp /dev/null $SOCKOPTSRC 544echo "/* NOTICE: $SOCKOPTSRC Generated by configure */" >>$SOCKOPTSRC 545echo "" >> $SOCKOPTSRC 546 547#quotes around argument added to avoid [] in text from disappearing 548echo ['static const struct option option[] = {'] >> $SOCKOPTSRC 549cat $OPTSRCTMP0 >> $SOCKOPTSRC 550echo '};' >> $SOCKOPTSRC 551echo '' >> $SOCKOPTSRC 552AC_DEFINE_UNQUOTED(HAVE_DUPSOCKOPT_MAX, $DUPSOCKOPTCNT, [option count])dnl 553 554#quotes around argument added to avoid [] in text from disappearing 555echo ['static const sockopt_t sockopts[] = {'] >> $SOCKOPTSRC 556#list of options that can be set also after connection has been established 557cat $OPTSRCTMP1 >> $SOCKOPTSRC 558echo '};' >> $SOCKOPTSRC 559AC_DEFINE_UNQUOTED(HAVE_SOCKOPTVAL_MAX, $SOCKOPTCNT, [socket option count])dnl 560 561#add symbolic values for options 562echo '' >> $SOCKOPTSRC 563#quotes around argument added to avoid [] in text from disappearing 564echo ['static const sockoptvalsym_t sockoptvalsyms[] = {'] >> $SOCKOPTSRC 565cat $OPTSRCTMP2 >> $SOCKOPTSRC 566echo '};' >> $SOCKOPTSRC 567AC_DEFINE_UNQUOTED(HAVE_SOCKOPTVALSYM_MAX, $SOCKOPTSYMCNT, [symbol count])dnl 568 569rm -f "$OPTSRCTMP0" "$OPTSRCTMP1" "$OPTSRCTMP2" 570 571#set value for server -v option 572UCOKSOCKOPTS_SO=`echo $OKSOCKOPTS | ucase | xargs -n1 | egrep 'SO_' | xargs` 573AC_DEFINE_UNQUOTED(DANTE_SOCKOPTS_SO, "${UCOKSOCKOPTS_SO}", [Socket level socket options enabled in build]) 574UCOKSOCKOPTS_IPV4=`echo $OKSOCKOPTS | ucase | xargs -n1 | egrep 'IP_' | xargs` 575AC_DEFINE_UNQUOTED(DANTE_SOCKOPTS_IPV4, "${UCOKSOCKOPTS_IPV4}", [IPV4 level socket options enabled in build]) 576UCOKSOCKOPTS_IPV6=`echo $OKSOCKOPTS | ucase | xargs -n1 | egrep 'IPV6_' | xargs` 577AC_DEFINE_UNQUOTED(DANTE_SOCKOPTS_IPV6, "${UCOKSOCKOPTS_IPV6}", [IPV6 level socket options enabled in build]) 578UCOKSOCKOPTS_TCP=`echo $OKSOCKOPTS | ucase | xargs -n1 | egrep 'TCP_' | xargs` 579AC_DEFINE_UNQUOTED(DANTE_SOCKOPTS_TCP, "${UCOKSOCKOPTS_TCP}", [TCP level socket options enabled in build]) 580UCOKSOCKOPTS_UDP=`echo $OKSOCKOPTS | ucase | xargs -n1 | egrep 'UDP_' | xargs` 581AC_DEFINE_UNQUOTED(DANTE_SOCKOPTS_UDP, "${UCOKSOCKOPTS_UDP}", [UDP level socket options enabled in build]) 582