tcpip.subr (256281) | tcpip.subr (258420) |
---|---|
1if [ ! "$_MEDIA_TCPIP_SUBR" ]; then _MEDIA_TCPIP_SUBR=1 2# 3# Copyright (c) 2012-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# | 1if [ ! "$_MEDIA_TCPIP_SUBR" ]; then _MEDIA_TCPIP_SUBR=1 2# 3# Copyright (c) 2012-2013 Devin Teske 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: stable/10/usr.sbin/bsdconfig/share/media/tcpip.subr 256181 2013-10-09 08:12:26Z dteske $ | 27# $FreeBSD: stable/10/usr.sbin/bsdconfig/share/media/tcpip.subr 258420 2013-11-21 03:38:47Z dteske $ |
28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." media/tcpip.subr 34f_include $BSDCFG_SHARE/device.subr 35f_include $BSDCFG_SHARE/dialog.subr --- 979 unchanged lines hidden (view full) --- 1015 return $SUCCESS 1016 fi 1017 fi 1018 1019 # 1020 # Fall back to host(1) -- which is further governed by nsswitch.conf(5) 1021 # 1022 | 28# 29############################################################ INCLUDES 30 31BSDCFG_SHARE="/usr/share/bsdconfig" 32. $BSDCFG_SHARE/common.subr || exit 1 33f_dprintf "%s: loading includes..." media/tcpip.subr 34f_include $BSDCFG_SHARE/device.subr 35f_include $BSDCFG_SHARE/dialog.subr --- 979 unchanged lines hidden (view full) --- 1015 return $SUCCESS 1016 fi 1017 fi 1018 1019 # 1020 # Fall back to host(1) -- which is further governed by nsswitch.conf(5) 1021 # 1022 |
1023 local __output __ip6 __addrs="" __wait="" 1024 f_getvar $VAR_MEDIA_TIMEOUT __wait 1025 [ "$__wait" ] && __wait="-W $(( $__wait / 2 ))" | 1023 local __output __ip6 __addrs= |
1026 f_getvar $VAR_IPV6_ENABLE __ip6 | 1024 f_getvar $VAR_IPV6_ENABLE __ip6 |
1025 1026 # If we have a TCP media type configured, check for an SRV record 1027 local __srvtypes= 1028 { f_quietly f_getvar $VAR_HTTP_PATH || 1029 f_quietly f_getvar $VAR_HTTP_PROXY_PATH 1030 } && __srvtypes="$__srvtypes _http._tcp" 1031 f_quietly f_getvar $VAR_FTP_PATH && __srvtypes="$__srvtypes _ftp._tcp" 1032 f_quietly f_getvar $VAR_NFS_PATH && 1033 __srvtypes="$__srvtypes _nfs._tcp _nfs._udp" 1034 1035 # Calculate wait time as dividend of total time and host(1) invocations 1036 local __host_runs __wait |
|
1027 if [ "$__ip6" = "YES" ]; then | 1037 if [ "$__ip6" = "YES" ]; then |
1038 __host_runs=$(( 2 + $( set -- $__srvtypes; echo $# ) )) 1039 else 1040 __host_runs=$(( 1 + $( set -- $__srvtypes; echo $# ) )) 1041 fi 1042 f_getvar $VAR_MEDIA_TIMEOUT __wait 1043 [ "$__wait" ] && __wait="-W $(( $__wait / $__host_runs ))" 1044 1045 # Query SRV types first (1st host response taken as new host to query) 1046 for __type in $__srvtypes; do 1047 if __output=$( 1048 host -t SRV $__wait -- "$__type.$__host" \ 1049 2> /dev/null 1050 ); then 1051 __host=$( echo "$__output" | 1052 awk '/ SRV /{print $NF;exit}' ) 1053 break 1054 fi 1055 done 1056 1057 # Try IPv6 first (if enabled) 1058 if [ "$__ip6" = "YES" ]; then |
|
1028 if ! __output=$( host -t AAAA $__wait -- "$__host" 2>&1 ); then 1029 # An error occurred, display in-full and return error 1030 [ "$__var_to_set" ] && 1031 setvar "$__var_to_set" "$__output" 1032 return $FAILURE 1033 fi | 1059 if ! __output=$( host -t AAAA $__wait -- "$__host" 2>&1 ); then 1060 # An error occurred, display in-full and return error 1061 [ "$__var_to_set" ] && 1062 setvar "$__var_to_set" "$__output" 1063 return $FAILURE 1064 fi |
1065 # Add the IPv6 addresses and fall-through to collect IPv4 too |
|
1034 __addrs=$( echo "$__output" | awk '/ address /{print $NF}' ) 1035 fi | 1066 __addrs=$( echo "$__output" | awk '/ address /{print $NF}' ) 1067 fi |
1068 1069 # Good ol' IPv4 |
|
1036 if ! __output=$( host -t A $__wait -- "$__host" 2>&1 ); then 1037 # An error occurred, display it in-full and return error 1038 [ "$__var_to_set" ] && setvar "$__var_to_set" "$__output" 1039 return $FAILURE 1040 fi | 1070 if ! __output=$( host -t A $__wait -- "$__host" 2>&1 ); then 1071 # An error occurred, display it in-full and return error 1072 [ "$__var_to_set" ] && setvar "$__var_to_set" "$__output" 1073 return $FAILURE 1074 fi |
1075 |
|
1041 __addrs="$__addrs${__addrs:+ }$( 1042 echo "$__output" | awk '/ address /{print $NF}' )" 1043 if [ "$__var_to_set" ]; then 1044 setvar "$__var_to_set" "$__addrs" 1045 else 1046 echo $__addrs 1047 fi 1048} --- 634 unchanged lines hidden --- | 1076 __addrs="$__addrs${__addrs:+ }$( 1077 echo "$__output" | awk '/ address /{print $NF}' )" 1078 if [ "$__var_to_set" ]; then 1079 setvar "$__var_to_set" "$__addrs" 1080 else 1081 echo $__addrs 1082 fi 1083} --- 634 unchanged lines hidden --- |