1ab2043b8SDevin Teskeif [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1 2ab2043b8SDevin Teske# 3*55620f43SDevin Teske# Copyright (c) 2006-2016 Devin Teske 4f8ea072aSDevin Teske# All rights reserved. 5ab2043b8SDevin Teske# 6ab2043b8SDevin Teske# Redistribution and use in source and binary forms, with or without 7ab2043b8SDevin Teske# modification, are permitted provided that the following conditions 8ab2043b8SDevin Teske# are met: 9ab2043b8SDevin Teske# 1. Redistributions of source code must retain the above copyright 10ab2043b8SDevin Teske# notice, this list of conditions and the following disclaimer. 11ab2043b8SDevin Teske# 2. Redistributions in binary form must reproduce the above copyright 12ab2043b8SDevin Teske# notice, this list of conditions and the following disclaimer in the 13ab2043b8SDevin Teske# documentation and/or other materials provided with the distribution. 14ab2043b8SDevin Teske# 15ab2043b8SDevin Teske# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 168e37a7c8SDevin Teske# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17ab2043b8SDevin Teske# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18ab2043b8SDevin Teske# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19ab2043b8SDevin Teske# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 208e37a7c8SDevin Teske# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21ab2043b8SDevin Teske# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22ab2043b8SDevin Teske# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23ab2043b8SDevin Teske# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24ab2043b8SDevin Teske# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25ab2043b8SDevin Teske# SUCH DAMAGE. 26ab2043b8SDevin Teske# 27ab2043b8SDevin Teske# 28ab2043b8SDevin Teske############################################################ INCLUDES 29ab2043b8SDevin Teske 30ab2043b8SDevin TeskeBSDCFG_SHARE="/usr/share/bsdconfig" 31ab2043b8SDevin Teske. $BSDCFG_SHARE/common.subr || exit 1 3256961fd7SDevin Teskef_dprintf "%s: loading includes..." networking/device.subr 337323adacSDevin Teskef_include $BSDCFG_SHARE/device.subr 34ab2043b8SDevin Teskef_include $BSDCFG_SHARE/dialog.subr 357323adacSDevin Teskef_include $BSDCFG_SHARE/media/tcpip.subr 36*55620f43SDevin Teskef_include $BSDCFG_SHARE/media/wlan.subr 37ab2043b8SDevin Teskef_include $BSDCFG_SHARE/networking/common.subr 38ab2043b8SDevin Teskef_include $BSDCFG_SHARE/networking/ipaddr.subr 39ab2043b8SDevin Teskef_include $BSDCFG_SHARE/networking/media.subr 40ab2043b8SDevin Teskef_include $BSDCFG_SHARE/networking/netmask.subr 41ab2043b8SDevin Teskef_include $BSDCFG_SHARE/networking/resolv.subr 42ab2043b8SDevin Teskef_include $BSDCFG_SHARE/networking/routing.subr 43d4ae33f0SDevin Teskef_include $BSDCFG_SHARE/strings.subr 441de60ff0SDevin Teskef_include $BSDCFG_SHARE/sysrc.subr 45ab2043b8SDevin Teske 46ab2043b8SDevin TeskeBSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking" 47ab2043b8SDevin Teskef_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr 48ab2043b8SDevin Teske 49ab2043b8SDevin Teske############################################################ GLOBALS 50ab2043b8SDevin Teske 51ab2043b8SDevin Teske# 52ab2043b8SDevin Teske# Settings used while interacting with various dialog(1) menus 53ab2043b8SDevin Teske# 54ab2043b8SDevin Teske: ${DIALOG_MENU_NETDEV_KICK_INTERFACES=1} 55ab2043b8SDevin Teske: ${DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK=3} 56ab2043b8SDevin Teske 57ab2043b8SDevin Teske############################################################ FUNCTIONS 58ab2043b8SDevin Teske 59d3a0f918SDevin Teske# f_dialog_menu_netdev [$default] 60ab2043b8SDevin Teske# 61d3a0f918SDevin Teske# Display a list of network devices with descriptions. Optionally, if present 62d3a0f918SDevin Teske# and non-NULL, initially highlight $default interface. 63ab2043b8SDevin Teske# 64ab2043b8SDevin Teskef_dialog_menu_netdev() 65ab2043b8SDevin Teske{ 66721819beSDevin Teske local menu_list # Calculated below 674c9e27bdSTom Rhodes local defaultitem="${1%\*}" # Trim trailing asterisk if present 68d3a0f918SDevin Teske 69ab2043b8SDevin Teske # 70ab2043b8SDevin Teske # Display a message to let the user know we're working... 71ab2043b8SDevin Teske # (message will remain until we throw up the next dialog) 72ab2043b8SDevin Teske # 73ab2043b8SDevin Teske f_dialog_info "$msg_probing_network_interfaces" 74ab2043b8SDevin Teske 75ab2043b8SDevin Teske # 76ab2043b8SDevin Teske # Get list of usable network interfaces 77ab2043b8SDevin Teske # 789ecd54f2SDevin Teske local dev devs if iflist= # Calculated below 792cc6c69dSDevin Teske f_device_rescan_network 802cc6c69dSDevin Teske f_device_find "" $DEVICE_TYPE_NETWORK devs 819ecd54f2SDevin Teske for dev in $devs; do 829ecd54f2SDevin Teske f_struct "$dev" get name if || continue 83721819beSDevin Teske # Skip unsavory interfaces 84721819beSDevin Teske case "$if" in 85603eaf79SAlexander V. Chernikov lo[0-9]*|ppp[0-9]*|sl[0-9]*) continue ;; 86721819beSDevin Teske esac 87721819beSDevin Teske iflist="$iflist $if" 88721819beSDevin Teske done 89721819beSDevin Teske iflist="${iflist# }" 90ab2043b8SDevin Teske 91ab2043b8SDevin Teske # 92ab2043b8SDevin Teske # Optionally kick interfaces in the head to get them to accurately 93ab2043b8SDevin Teske # track the carrier status in realtime (required on FreeBSD). 94ab2043b8SDevin Teske # 95ab2043b8SDevin Teske if [ "$DIALOG_MENU_NETDEV_KICK_INTERFACES" ]; then 96ab2043b8SDevin Teske DIALOG_MENU_NETDEV_KICK_INTERFACES= 97ab2043b8SDevin Teske 982cc6c69dSDevin Teske for if in $iflist; do 992cc6c69dSDevin Teske f_quietly ifconfig $if up 100ab2043b8SDevin Teske done 101ab2043b8SDevin Teske 102ab2043b8SDevin Teske if [ "$DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK" ]; then 103ab2043b8SDevin Teske # interfaces need time to update carrier status 104ab2043b8SDevin Teske sleep $DIALOG_MENU_NETDEV_SLEEP_AFTER_KICK 105ab2043b8SDevin Teske fi 106ab2043b8SDevin Teske fi 107ab2043b8SDevin Teske 108ab2043b8SDevin Teske # 109ab2043b8SDevin Teske # Mark any "active" interfaces with an asterisk (*) 110ab2043b8SDevin Teske # to the right of the device name. 111ab2043b8SDevin Teske # 112721819beSDevin Teske menu_list=$( 1132cc6c69dSDevin Teske for if in $iflist; do 1142cc6c69dSDevin Teske f_device_desc $if $DEVICE_TYPE_NETWORK desc 1152cc6c69dSDevin Teske f_shell_escape "$desc" desc 1162cc6c69dSDevin Teske if f_device_is_active $if; then 1172cc6c69dSDevin Teske printf "'%s\*' '%s'\n" $if "$desc" 1182cc6c69dSDevin Teske else 1192cc6c69dSDevin Teske printf "'%s' '%s'\n" $if "$desc" 1202cc6c69dSDevin Teske fi 121ab2043b8SDevin Teske done 122ab2043b8SDevin Teske ) 123721819beSDevin Teske if [ ! "$menu_list" ]; then 1247079fc4eSDevin Teske f_show_msg "$msg_no_network_interfaces" 125f677a9e2SDevin Teske return $DIALOG_CANCEL 126ab2043b8SDevin Teske fi 127ab2043b8SDevin Teske 128d3a0f918SDevin Teske # Maybe the default item was marked as active 1292cc6c69dSDevin Teske f_device_is_active "$defaultitem" && defaultitem="$defaultitem*" 130ab2043b8SDevin Teske 131ab2043b8SDevin Teske # 132ab2043b8SDevin Teske # Ask user to select an interface 133ab2043b8SDevin Teske # 134c01472c1SDevin Teske local prompt="$msg_select_network_interface" 1352cc6c69dSDevin Teske local hline="$hline_arrows_tab_enter" 13674036c4dSDevin Teske local height width rows 13774036c4dSDevin Teske eval f_dialog_menu_size height width rows \ 138ab2043b8SDevin Teske \"\$DIALOG_TITLE\" \ 139ab2043b8SDevin Teske \"\$DIALOG_BACKTITLE\" \ 140ab2043b8SDevin Teske \"\$prompt\" \ 141ab2043b8SDevin Teske \"\$hline\" \ 142721819beSDevin Teske $menu_list 143fd962ac6SDevin Teske local menu_choice 144fd962ac6SDevin Teske menu_choice=$( eval $DIALOG \ 145d3a0f918SDevin Teske --title \"\$DIALOG_TITLE\" \ 146ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 147ab2043b8SDevin Teske --hline \"\$hline\" \ 148ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 149ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 150d3a0f918SDevin Teske --default-item \"\$defaultitem\" \ 15174036c4dSDevin Teske --menu \"\$prompt\" \ 15274036c4dSDevin Teske $height $width $rows \ 153721819beSDevin Teske $menu_list \ 15489498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 15589498fdfSDevin Teske ) 15689498fdfSDevin Teske local retval=$? 157fd962ac6SDevin Teske f_dialog_menutag_store -s "$menu_choice" 15889498fdfSDevin Teske return $retval 159ab2043b8SDevin Teske} 160ab2043b8SDevin Teske 161ab2043b8SDevin Teske# f_dialog_menu_netdev_edit $interface $ipaddr $netmask $options $dhcp 162ab2043b8SDevin Teske# 163ab2043b8SDevin Teske# Allow a user to edit network interface settings. Current values are not 164ab2043b8SDevin Teske# probed but rather taken from the positional arguments. 165ab2043b8SDevin Teske# 166ab2043b8SDevin Teskef_dialog_menu_netdev_edit() 167ab2043b8SDevin Teske{ 168d4ae33f0SDevin Teske local funcname=f_dialog_menu_netdev_edit 169ab2043b8SDevin Teske local interface="$1" ipaddr="$2" netmask="$3" options="$4" dhcp="$5" 17074036c4dSDevin Teske local prompt menu_list height width rows 171ab2043b8SDevin Teske 172ab2043b8SDevin Teske # 173ab2043b8SDevin Teske # Create a duplicate set of variables for change-tracking... 174ab2043b8SDevin Teske # 175ab2043b8SDevin Teske local ipaddr_orig="$2" \ 176ab2043b8SDevin Teske netmask_orig="$3" \ 177ab2043b8SDevin Teske options_orig="$4" \ 178ab2043b8SDevin Teske dhcp_orig="$5" 179ab2043b8SDevin Teske 180ab2043b8SDevin Teske local hline="$hline_arrows_tab_enter" 181d4ae33f0SDevin Teske f_sprintf prompt "$msg_network_configuration" "$interface" 182ab2043b8SDevin Teske 183ab2043b8SDevin Teske # 184ab2043b8SDevin Teske # Loop forever until the user has finished configuring the different 185ab2043b8SDevin Teske # components of the network interface. 186ab2043b8SDevin Teske # 187ab2043b8SDevin Teske # To apply the settings, we need to know each of the following: 188ab2043b8SDevin Teske # - IP Address 189ab2043b8SDevin Teske # - Network subnet mask 190ab2043b8SDevin Teske # - Additional ifconfig(8) options 191ab2043b8SDevin Teske # 192ab2043b8SDevin Teske # It is only when we have all of the above values that we can make the 193ab2043b8SDevin Teske # changes effective because all three options must be specified at-once 194ab2043b8SDevin Teske # to ifconfig(8). 195ab2043b8SDevin Teske # 196d3a0f918SDevin Teske local defaultitem= 197*55620f43SDevin Teske local wlans wlan_status 198ab2043b8SDevin Teske while :; do 199ab2043b8SDevin Teske local dhcp_status="$msg_disabled" 200ab2043b8SDevin Teske [ "$dhcp" ] && dhcp_status="$msg_enabled" 201ab2043b8SDevin Teske 202*55620f43SDevin Teske if f_device_is_wireless "$interface"; then 203*55620f43SDevin Teske wlans=$( f_sysrc_get "wlans_$interface" ) 204*55620f43SDevin Teske wlan_status="$msg_unconfigured" 205*55620f43SDevin Teske [ -e "$( f_sysrc_get wpa_supplicant_conf_file )" ] && 206*55620f43SDevin Teske wlan_status="$msg_configured" 207*55620f43SDevin Teske fi 208*55620f43SDevin Teske 209ab2043b8SDevin Teske # 210ab2043b8SDevin Teske # Display configuration-edit menu 211ab2043b8SDevin Teske # 212ab2043b8SDevin Teske menu_list=" 213ab2043b8SDevin Teske 'X $msg_save_exit' '$msg_return_to_previous_menu' 214*55620f43SDevin Teske " # END-QUOTE 215*55620f43SDevin Teske f_device_is_wireless "$interface" && menu_list="$menu_list 216*55620f43SDevin Teske 'W $msg_wireless_networks' '$wlan_status' 217*55620f43SDevin Teske '1 $msg_wlans' '$wlans' 218*55620f43SDevin Teske " # END-QUOTE 219*55620f43SDevin Teske menu_list="$menu_list 220ab2043b8SDevin Teske '2 $msg_dhcp' '$dhcp_status' 221ab2043b8SDevin Teske '3 $msg_ipaddr4' '$ipaddr' 222ab2043b8SDevin Teske '4 $msg_netmask' '$netmask' 223ab2043b8SDevin Teske '5 $msg_options' '$options' 224ec273ebfSDevin Teske " # END-QUOTE 22574036c4dSDevin Teske eval f_dialog_menu_size height width rows \ 226ab2043b8SDevin Teske \"\$DIALOG_TITLE\" \ 227ab2043b8SDevin Teske \"\$DIALOG_BACKTITLE\" \ 228ab2043b8SDevin Teske \"\$prompt\" \ 229ab2043b8SDevin Teske \"\$hline\" \ 23074036c4dSDevin Teske $menu_list 231fd962ac6SDevin Teske local tag 232fd962ac6SDevin Teske tag=$( eval $DIALOG \ 233d3a0f918SDevin Teske --title \"\$DIALOG_TITLE\" \ 234ab2043b8SDevin Teske --backtitle \"\$DIALOG_BACKTITLE\" \ 235ab2043b8SDevin Teske --hline \"\$hline\" \ 236ab2043b8SDevin Teske --ok-label \"\$msg_ok\" \ 237ab2043b8SDevin Teske --cancel-label \"\$msg_cancel\" \ 238198a44b5SDevin Teske --help-button \ 2393c91c65aSDevin Teske --help-label \"\$msg_help\" \ 240198a44b5SDevin Teske ${USE_XDIALOG:+--help \"\"} \ 241d3a0f918SDevin Teske --default-item \"\$defaultitem\" \ 24274036c4dSDevin Teske --menu \"\$prompt\" \ 24374036c4dSDevin Teske $height $width $rows \ 244ab2043b8SDevin Teske $menu_list \ 24589498fdfSDevin Teske 2>&1 >&$DIALOG_TERMINAL_PASSTHRU_FD 24689498fdfSDevin Teske ) 247ab2043b8SDevin Teske local retval=$? 248fd962ac6SDevin Teske f_dialog_data_sanitize tag 249ab2043b8SDevin Teske 250f677a9e2SDevin Teske if [ $retval -eq $DIALOG_HELP ]; then 251198a44b5SDevin Teske f_show_help "$TCP_HELPFILE" 252198a44b5SDevin Teske continue 253f677a9e2SDevin Teske elif [ $retval -ne $DIALOG_OK ]; then 254198a44b5SDevin Teske return $retval 255d3a0f918SDevin Teske else 256d3a0f918SDevin Teske # Only update default-item on success 257d3a0f918SDevin Teske defaultitem="$tag" 258198a44b5SDevin Teske fi 259ab2043b8SDevin Teske 260ab2043b8SDevin Teske # 261ab2043b8SDevin Teske # Call the below ``modifier functions'' whose job it is to take 262ab2043b8SDevin Teske # input from the user and assign the newly-acquired values back 263ab2043b8SDevin Teske # to the ipaddr, netmask, and options variables for us to re- 264ab2043b8SDevin Teske # read and display in the summary dialog. 265ab2043b8SDevin Teske # 266ab2043b8SDevin Teske case "$tag" in 267ab2043b8SDevin Teske X\ *) break ;; 268*55620f43SDevin Teske W\ *) f_dialog_menu_wireless_edit ;; 269*55620f43SDevin Teske 1\ *) f_dialog_menu_wlandev_edit \ 270*55620f43SDevin Teske "$interface" "${wlans%%[$IFS]*}" ;; 271ab2043b8SDevin Teske 2\ *) # 27239c22926SDevin Teske # Proceed cautiously (confirm with the user) if/when NFS- 27339c22926SDevin Teske # mounts are active. If the network on which these mounts 27439c22926SDevin Teske # are made is changed parts of the system may hang. 275ab2043b8SDevin Teske # 276ab2043b8SDevin Teske if f_nfs_mounted && ! f_jailed; then 277d4ae33f0SDevin Teske local setting 278d4ae33f0SDevin Teske f_sprintf setting "$msg_current_dhcp_status" \ 279d4ae33f0SDevin Teske "$interface" "$dhcp_status" 28039c22926SDevin Teske f_noyes "$msg_nfs_mounts_may_cause_hang" "$setting" || 281ab2043b8SDevin Teske continue 282ab2043b8SDevin Teske fi 283ab2043b8SDevin Teske 284ab2043b8SDevin Teske # 285ab2043b8SDevin Teske # Toggle DHCP status 286ab2043b8SDevin Teske # 287ab2043b8SDevin Teske if [ "$dhcp_status" = "$msg_enabled" ]; then 288ab2043b8SDevin Teske dhcp= 289ab2043b8SDevin Teske else 290ab2043b8SDevin Teske trap - SIGINT 291ab2043b8SDevin Teske ( # Execute within sub-shell to allow/catch Ctrl-C 292ab2043b8SDevin Teske trap 'exit $FAILURE' SIGINT 293d4ae33f0SDevin Teske f_sprintf msg "$msg_scanning_for_dhcp" "$interface" 294ab2043b8SDevin Teske if [ "$USE_XDIALOG" ]; then 295ab2043b8SDevin Teske ( 2964128cd31SDevin Teske f_quietly ifconfig "$interface" delete 2974128cd31SDevin Teske f_quietly dhclient "$interface" 298ab2043b8SDevin Teske ) | 299ab2043b8SDevin Teske f_xdialog_info "$msg" 300ab2043b8SDevin Teske else 301ab2043b8SDevin Teske f_dialog_info "$msg" 3024128cd31SDevin Teske f_quietly ifconfig "$interface" delete 3034128cd31SDevin Teske f_quietly dhclient "$interface" 304ab2043b8SDevin Teske fi 305ab2043b8SDevin Teske ) 306ab2043b8SDevin Teske retval=$? 307ab2043b8SDevin Teske trap 'interrupt' SIGINT 308f677a9e2SDevin Teske if [ $retval -eq $DIALOG_OK ]; then 309ab2043b8SDevin Teske dhcp=1 3104128cd31SDevin Teske f_ifconfig_inet "$interface" ipaddr 3114128cd31SDevin Teske f_ifconfig_inet6 "$interface" ipaddr6 3124128cd31SDevin Teske f_ifconfig_netmask "$interface" netmask 313ab2043b8SDevin Teske options= 314ab2043b8SDevin Teske 315ab2043b8SDevin Teske # Fixup search/domain in resolv.conf(5) 316ab2043b8SDevin Teske hostname=$( f_sysrc_get \ 317ab2043b8SDevin Teske 'hostname:-$(hostname)' ) 318ab2043b8SDevin Teske f_dialog_resolv_conf_update "$hostname" 319ab2043b8SDevin Teske fi 320ab2043b8SDevin Teske fi 321ab2043b8SDevin Teske ;; 322ab2043b8SDevin Teske 3\ *) f_dialog_input_ipaddr "$interface" "$ipaddr" 323f677a9e2SDevin Teske [ $? -eq $DIALOG_OK ] && dhcp= ;; 324ab2043b8SDevin Teske 4\ *) f_dialog_input_netmask "$interface" "$netmask" 325f677a9e2SDevin Teske [ $? -eq $DIALOG_OK -a "$_netmask" ] && dhcp= ;; 326ab2043b8SDevin Teske 5\ *) f_dialog_menu_media_options "$interface" "$options" 327f677a9e2SDevin Teske [ $? -eq $DIALOG_OK ] && dhcp= ;; 328ab2043b8SDevin Teske esac 329ab2043b8SDevin Teske done 330ab2043b8SDevin Teske 331ab2043b8SDevin Teske # 332ab2043b8SDevin Teske # Save only if the user changed at least one feature of the interface 333ab2043b8SDevin Teske # 334ab2043b8SDevin Teske if [ "$ipaddr" != "$ipaddr_orig" -o \ 335ab2043b8SDevin Teske "$netmask" != "$netmask_orig" -o \ 336ab2043b8SDevin Teske "$options" != "$options_orig" -o \ 337ab2043b8SDevin Teske "$dhcp" != "$dhcp_orig" ] 338ab2043b8SDevin Teske then 33913aadd84SDevin Teske f_show_info "$msg_saving_network_interface" "$interface" 340ab2043b8SDevin Teske 341ab2043b8SDevin Teske local value= 342ab2043b8SDevin Teske if [ "$dhcp" ]; then 343d4ae33f0SDevin Teske f_eval_catch $funcname f_sysrc_delete \ 344d4ae33f0SDevin Teske 'f_sysrc_delete defaultrouter' 345ab2043b8SDevin Teske value=DHCP 346ab2043b8SDevin Teske else 347ab2043b8SDevin Teske value="inet $ipaddr netmask $netmask" 348ab2043b8SDevin Teske value="$value${options:+ }$options" 349ab2043b8SDevin Teske fi 350ab2043b8SDevin Teske 351d4ae33f0SDevin Teske f_eval_catch $funcname f_sysrc_set \ 352d4ae33f0SDevin Teske 'f_sysrc_set "ifconfig_%s" "%s"' "$interface" "$value" 353ab2043b8SDevin Teske fi 354ab2043b8SDevin Teske 355ab2043b8SDevin Teske # 356ab2043b8SDevin Teske # Re/Apply the settings if desired 357ab2043b8SDevin Teske # 358ab2043b8SDevin Teske if [ ! "$dhcp" ]; then 35927ff90aaSDevin Teske if f_yesno "$msg_bring_interface_up" "$interface" 36027ff90aaSDevin Teske then 36113aadd84SDevin Teske f_show_info "$msg_bring_interface_up" "$interface" 362ab2043b8SDevin Teske 363d4ae33f0SDevin Teske local dr="$( f_sysrc_get defaultrouter )" 364ab2043b8SDevin Teske if [ "$dr" = "NO" -o ! "$dr" ]; then 365d4ae33f0SDevin Teske f_route_get_default dr 366d4ae33f0SDevin Teske [ "$dr" ] && f_eval_catch \ 367d4ae33f0SDevin Teske $funcname f_sysrc_set \ 368d4ae33f0SDevin Teske 'f_sysrc_set defaultrouter "%s"' "$dr" 369ab2043b8SDevin Teske fi 370ab2043b8SDevin Teske # 371ab2043b8SDevin Teske # Make a backup of resolv.conf(5) before using 372ab2043b8SDevin Teske # ifconfig(8) and then restore it afterward. This 373ab2043b8SDevin Teske # allows preservation of nameservers acquired via 374ab2043b8SDevin Teske # DHCP on FreeBSD-8.x (normally lost as ifconfig(8) 375ab2043b8SDevin Teske # usage causes dhclient(8) to exit which scrubs 376ab2043b8SDevin Teske # resolv.conf(5) by-default upon termination). 377ab2043b8SDevin Teske # 378ab2043b8SDevin Teske f_quietly cp -fp "$RESOLV_CONF" "$RESOLV_CONF.$$" 379d4ae33f0SDevin Teske if f_eval_catch $funcname ifconfig \ 380d4ae33f0SDevin Teske 'ifconfig "%s" inet "%s" netmask "%s" %s' \ 381d4ae33f0SDevin Teske "$interface" "$ipaddr" "$netmask" "$options" 382d4ae33f0SDevin Teske then 383d4ae33f0SDevin Teske [ "$dr" -a "$dr" != "NO" ] && 384d4ae33f0SDevin Teske f_eval_catch $funcname route \ 385d4ae33f0SDevin Teske 'route add default "%s"' "$dr" 386ab2043b8SDevin Teske fi 387ab2043b8SDevin Teske if cmp -s "$RESOLV_CONF" "$RESOLV_CONF.$$"; then 388ab2043b8SDevin Teske f_quietly rm -f "$RESOLV_CONF.$$" 389ab2043b8SDevin Teske else 390ab2043b8SDevin Teske f_quietly mv -f "$RESOLV_CONF.$$" "$RESOLV_CONF" 391ab2043b8SDevin Teske fi 392ab2043b8SDevin Teske fi 393ab2043b8SDevin Teske fi 394ab2043b8SDevin Teske 395f677a9e2SDevin Teske return $DIALOG_OK 396ab2043b8SDevin Teske} 397ab2043b8SDevin Teske 39856961fd7SDevin Teske############################################################ MAIN 39956961fd7SDevin Teske 40056961fd7SDevin Teskef_dprintf "%s: Successfully loaded." networking/device.subr 40156961fd7SDevin Teske 402ab2043b8SDevin Teskefi # ! $_NETWORKING_DEVICE_SUBR 403