summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/networking
diff options
context:
space:
mode:
Diffstat (limited to 'usr.sbin/bsdconfig/networking')
-rwxr-xr-xusr.sbin/bsdconfig/networking/devices3
-rw-r--r--usr.sbin/bsdconfig/networking/include/Makefile2
-rw-r--r--usr.sbin/bsdconfig/networking/include/tcp.hlp33
-rw-r--r--usr.sbin/bsdconfig/networking/share/common.subr13
-rw-r--r--usr.sbin/bsdconfig/networking/share/device.subr133
-rw-r--r--usr.sbin/bsdconfig/networking/share/hostname.subr59
-rw-r--r--usr.sbin/bsdconfig/networking/share/ipaddr.subr204
-rw-r--r--usr.sbin/bsdconfig/networking/share/netmask.subr83
-rw-r--r--usr.sbin/bsdconfig/networking/share/resolv.subr27
-rw-r--r--usr.sbin/bsdconfig/networking/share/routing.subr22
10 files changed, 15 insertions, 564 deletions
diff --git a/usr.sbin/bsdconfig/networking/devices b/usr.sbin/bsdconfig/networking/devices
index 443294f..f9c27b4 100755
--- a/usr.sbin/bsdconfig/networking/devices
+++ b/usr.sbin/bsdconfig/networking/devices
@@ -1,6 +1,6 @@
#!/bin/sh
#-
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -34,6 +34,7 @@ f_dprintf "%s: loading includes..." "$0"
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/mustberoot.subr
f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
f_include $BSDCFG_SHARE/networking/device.subr
f_include $BSDCFG_SHARE/networking/ipaddr.subr
f_include $BSDCFG_SHARE/networking/media.subr
diff --git a/usr.sbin/bsdconfig/networking/include/Makefile b/usr.sbin/bsdconfig/networking/include/Makefile
index be6cacb..c93d486 100644
--- a/usr.sbin/bsdconfig/networking/include/Makefile
+++ b/usr.sbin/bsdconfig/networking/include/Makefile
@@ -3,7 +3,7 @@
NO_OBJ=
FILESDIR= ${LIBEXECDIR}/bsdconfig/120.networking/include
-FILES= messages.subr tcp.hlp
+FILES= messages.subr
beforeinstall:
mkdir -p ${DESTDIR}${FILESDIR}
diff --git a/usr.sbin/bsdconfig/networking/include/tcp.hlp b/usr.sbin/bsdconfig/networking/include/tcp.hlp
deleted file mode 100644
index 6d0ba10..0000000
--- a/usr.sbin/bsdconfig/networking/include/tcp.hlp
+++ /dev/null
@@ -1,33 +0,0 @@
-This screen allows you to set up your general network parameters
-(hostname, domain name, DNS server, etc) as well as the settings for a
-given interface (which was selected from the menu before this screen).
-
-PLIP/SLIP users - please read through to the end of this doc!
-
-The "options" field is kind of special (read: a hack :-):
-
-Any valid options to ifconfig can be specified here, so if you need
-to do something "special" to get your interface working, then here
-is the place to do it.
-
-If you're running SLIP or PLIP, you also need to use it for specifying
-the remote end of the link (simply type the foreign IP address in).
-In the specific case where you're running PLIP with a Linux host peer
-rather than a FreeBSD one, you also must add the "-link0" flag after the
-foreign address.
-
-If you're dealing with an ethernet adaptor with multiple media
-connectors (e.g. AUI, 10BT, 10B2, etc), you can use this field to
-specify which one to use. Examples of valid strings include:
-
- "media 10base5/AUI" - Select the AUI port.
- "media 10baseT/UTP" - Select the twisted pair port.
- "media 10base2/BNC" - Select the BNC connector.
- "media 100baseTX" - Select 100BaseT on a 100/10 dual adaptor.
-
-If you have a wireless interface and must specify arguments such as a
-WEP key here, you may use something like:
-
- "wepmode on wepkey 0xFEEDFACE"
-
-When you're done with this form, select OK.
diff --git a/usr.sbin/bsdconfig/networking/share/common.subr b/usr.sbin/bsdconfig/networking/share/common.subr
index e501a9c..1a37a9c 100644
--- a/usr.sbin/bsdconfig/networking/share/common.subr
+++ b/usr.sbin/bsdconfig/networking/share/common.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_COMMON_SUBR" ]; then _NETWORKING_COMMON_SUBR=1
#
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,17 +33,6 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
############################################################ FUNCTIONS
-# f_mounted $local_directory
-#
-# Return success if a filesystem is mounted on a particular directory.
-#
-f_mounted()
-{
- local dir="$1"
- [ -d "$dir" ] || return $FAILURE
- mount | grep -Eq " on $dir \([^)]+\)$"
-}
-
# f_jailed
#
# Returns true if the current process is jail(8)ed.
diff --git a/usr.sbin/bsdconfig/networking/share/device.subr b/usr.sbin/bsdconfig/networking/share/device.subr
index 23ac83b..cac8ef5 100644
--- a/usr.sbin/bsdconfig/networking/share/device.subr
+++ b/usr.sbin/bsdconfig/networking/share/device.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1
#
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -31,8 +31,10 @@ if [ ! "$_NETWORKING_DEVICE_SUBR" ]; then _NETWORKING_DEVICE_SUBR=1
BSDCFG_SHARE="/usr/share/bsdconfig"
. $BSDCFG_SHARE/common.subr || exit 1
f_dprintf "%s: loading includes..." networking/device.subr
+f_include $BSDCFG_SHARE/device.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/sysrc.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
f_include $BSDCFG_SHARE/networking/common.subr
f_include $BSDCFG_SHARE/networking/ipaddr.subr
f_include $BSDCFG_SHARE/networking/media.subr
@@ -43,8 +45,6 @@ f_include $BSDCFG_SHARE/networking/routing.subr
BSDCFG_LIBE="/usr/libexec/bsdconfig" APP_DIR="120.networking"
f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
-TCP_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/tcp.hlp
-
############################################################ GLOBALS
#
@@ -55,133 +55,6 @@ TCP_HELPFILE=$BSDCFG_LIBE/$APP_DIR/include/tcp.hlp
############################################################ FUNCTIONS
-# f_device_desc $device_name
-#
-# Print a description for a device name (eg., `fxp0').
-#
-f_device_desc()
-{
- local device="$1" d="[1234567890]" desc=""
-
- # Check variables
- [ "$device" ] || return $SUCCESS
-
- #
- # Return sysctl MIB dev.NAME.UNIT.%desc if it exists,
- # otherwise fall through to below static list.
- #
- if f_have sysctl; then
- local devname devunit
- devname="${device%%$d*}"
- devunit="${device#$devname}"
- devunit="${devunit%%[a-zA-Z_]*}"
- sysctl -n "dev.$devname.$devunit.%desc" 2> /dev/null &&
- return $SUCCESS
- fi
-
- case "$device" in
- # Network devices
- ae$d) desc="Attansic/Atheros L2 Fast Ethernet";;
- age$d) desc="Attansic/Atheros L1 Gigabit Ethernet";;
- alc$d) desc="Atheros AR8131/AR8132 PCIe Ethernet";;
- ale$d) desc="Atheros AR8121/AR8113/AR8114 PCIe Ethernet";;
- an$d) desc="Aironet 4500/4800 802.11 wireless adapter";;
- ath$d) desc="Atheros IEEE 802.11 wireless adapter";;
- aue$d) desc="ADMtek USB Ethernet adapter";;
- axe$d) desc="ASIX Electronics USB Ethernet adapter";;
- bce$d) desc="Broadcom NetXtreme II Gigabit Ethernet card";;
- bfe$d) desc="Broadcom BCM440x PCI Ethernet card";;
- bge$d) desc="Broadcom BCM570x PCI Gigabit Ethernet card";;
- bm$d) desc="Apple BMAC Built-in Ethernet";;
- bwn$d) desc="Broadcom BCM43xx IEEE 802.11 wireless adapter";;
- cas$d) desc="Sun Cassini/Cassini+ or NS DP83065 Saturn Ethernet";;
- cc3i$d) desc="SDL HSSI sync serial PCI card";;
- cue$d) desc="CATC USB Ethernet adapter";;
- cxgb$d) desc="Chelsio T3 10Gb Ethernet card";;
- dc$d) desc="DEC/Intel 21143 (and clones) PCI Fast Ethernet card";;
- de$d) desc="DEC DE435 PCI NIC or other DC21040-AA based card";;
- disc$d) desc="Software discard network interface";;
- ed$d) desc="Novell NE1000/2000; 3C503; NE2000-compatible PCMCIA";;
- el$d) desc="3Com 3C501 Ethernet card";;
- em$d) desc="Intel(R) PRO/1000 Ethernet card";;
- en$d) desc="Efficient Networks ATM PCI card";;
- ep$d) desc="3Com 3C509 Ethernet card/3C589 PCMCIA";;
- et$d) desc="Agere ET1310 based PCI Express Gigabit Ethernet card";;
- ex$d) desc="Intel EtherExpress Pro/10 Ethernet card";;
- fe$d) desc="Fujitsu MB86960A/MB86965A Ethernet card";;
- fpa$d) desc="DEC DEFPA PCI FDDI card";;
- fwe$d) desc="FireWire Ethernet emulation";;
- fwip$d) desc="IP over FireWire";;
- fxp$d) desc="Intel EtherExpress Pro/100B PCI Fast Ethernet card";;
- gem$d) desc="Apple GMAC or Sun ERI/GEM Ethernet adapter";;
- hme$d) desc="Sun HME (Happy Meal Ethernet) Ethernet adapter";;
- ie$d) desc="AT&T StarLAN 10 and EN100; 3Com 3C507; NI5210";;
- igb$d) desc="Intel(R) PRO/1000 PCI Express Gigabit Ethernet card";;
- ipw$d) desc="Intel PRO/Wireless 2100 IEEE 802.11 adapter";;
- iwi$d) desc="Intel PRO/Wireless 2200BG/2225BG/2915ABG adapter";;
- iwn$d) desc="Intel Wireless WiFi Link 4965AGN IEEE 802.11n adapter";;
- ix$d) desc="Intel Etherexpress Ethernet card";;
- ixgb$d) desc="Intel(R) PRO/10Gb Ethernet card";;
- ixgbe$d) desc="Intel(R) PRO/10Gb Ethernet card";;
- jme$d) desc="JMicron JMC250 Gigabit/JMC260 Fast Ethernet";;
- kue$d) desc="Kawasaki LSI USB Ethernet adapter";;
- le$d) desc="AMD Am7900 LANCE or Am79C9xx PCnet Ethernet adapter";;
- lge$d) desc="Level 1 LXT1001 Gigabit Ethernet card";;
- lnc$d) desc="Lance/PCnet (Isolan/Novell NE2100/NE32-VL) Ethernet";;
- lp$d) desc="Parallel Port IP (PLIP) peer connection";;
- lo$d) desc="Loop-back (local) network interface";;
- malo$d) desc="Marvell Libertas 88W8335 802.11 wireless adapter";;
- msk$d) desc="Marvell/SysKonnect Yukon II Gigabit Ethernet";;
- mxge$d) desc="Myricom Myri10GE 10Gb Ethernet card";;
- nfe$d) desc="NVIDIA nForce MCP Ethernet";;
- ng${d}_*|ng$d${d}_*|ng$d$d${d}_*|ng$d$d$d${d}_*|ng$d$d$d$d${d}_*)
- desc="Vimage netgraph(4) bridged Ethernet device";;
- nge$d) desc="NatSemi PCI Gigabit Ethernet card";;
- nve$d) desc="NVIDIA nForce MCP Ethernet";;
- nxge$d) desc="Neterion Xframe 10GbE Server/Storage adapter";;
- pcn$d) desc="AMD Am79c79x PCI Ethernet card";;
- plip$d) desc="Parallel Port IP (PLIP) peer connection";;
- ral$d) desc="Ralink Technology IEEE 802.11 wireless adapter";;
- ray$d) desc="Raytheon Raylink 802.11 wireless adapter";;
- re$d) desc="RealTek 8139C+/8169/8169S/8110S PCI Ethernet adapter";;
- rl$d) desc="RealTek 8129/8139 PCI Ethernet card";;
- rue$d) desc="RealTek USB Ethernet card";;
- rum$d) desc="Ralink Technology USB IEEE 802.11 wireless adapter";;
- sf$d) desc="Adaptec AIC-6915 PCI Ethernet card";;
- sge$d) desc="Silicon Integrated Systems SiS190/191 Ethernet";;
- sis$d) desc="SiS 900/SiS 7016 PCI Ethernet card";;
- sk$d) desc="SysKonnect PCI Gigabit Ethernet card";;
- sn$d) desc="SMC/Megahertz Ethernet card";;
- snc$d) desc="SONIC Ethernet card";;
- sr$d) desc="SDL T1/E1 sync serial PCI card";;
- ste$d) desc="Sundance ST201 PCI Ethernet card";;
- stge$d) desc="Sundance/Tamarack TC9021 Gigabit Ethernet";;
- ti$d) desc="Alteon Networks PCI Gigabit Ethernet card";;
- tl$d) desc="Texas Instruments ThunderLAN PCI Ethernet card";;
- tx$d) desc="SMC 9432TX Ethernet card";;
- txp$d) desc="3Com 3cR990 Ethernet card";;
- uath$d) desc="Atheros AR5005UG and AR5005UX USB wireless adapter";;
- upgt$d) desc="Conexant/Intersil PrismGT USB wireless adapter";;
- ural$d) desc="Ralink Technology RT2500USB 802.11 wireless adapter";;
- urtw$d) desc="Realtek 8187L USB wireless adapter";;
- vge$d) desc="VIA VT612x PCI Gigabit Ethernet card";;
- vlan$d|vlan$d$d|vlan$d$d$d|vlan$d$d$d$d|vlan$d$d$d$d$d)
- desc="IEEE 802.1Q VLAN network interface";;
- vr$d) desc="VIA VT3043/VT86C100A Rhine PCI Ethernet card";;
- vx$d) desc="3COM 3c590 / 3c595 Ethernet card";;
- wb$d) desc="Winbond W89C840F PCI Ethernet card";;
- wi$d) desc="Lucent WaveLAN/IEEE 802.11 wireless adapter";;
- wpi$d) desc="Intel 3945ABG IEEE 802.11 wireless adapter";;
- wx$d) desc="Intel Gigabit Ethernet (82452) card";;
- xe$d) desc="Xircom/Intel EtherExpress Pro100/16 Ethernet card";;
- xl$d) desc="3COM 3c90x / 3c90xB PCI Ethernet card";;
- zyd$d) desc="ZyDAS ZD1211/ZD1211B USB 802.11 wireless adapter";;
- # Unknown device
- *) desc="<unknown network interface type>";;
- esac
- printf "%s\n" "$desc"
-}
-
# f_dialog_menu_netdev
#
# Display a list of network devices with descriptions.
diff --git a/usr.sbin/bsdconfig/networking/share/hostname.subr b/usr.sbin/bsdconfig/networking/share/hostname.subr
index b276059..61df2b4 100644
--- a/usr.sbin/bsdconfig/networking/share/hostname.subr
+++ b/usr.sbin/bsdconfig/networking/share/hostname.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_HOSTNAME_SUBR" ]; then _NETWORKING_HOSTNAME_SUBR=1
#
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -41,63 +41,6 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
############################################################ FUNCTIONS
-# f_validate_hostname $hostname
-#
-# Returns zero if the given argument (a fully-qualified hostname) is compliant
-# with standards set-forth in RFC's 952 and 1123 of the Network Working Group:
-#
-# RFC 952 - DoD Internet host table specification
-# http://tools.ietf.org/html/rfc952
-#
-# RFC 1123 - Requirements for Internet Hosts - Application and Support
-# http://tools.ietf.org/html/rfc1123
-#
-# See http://en.wikipedia.org/wiki/Hostname for a brief overview.
-#
-# The return status for invalid hostnames is one of:
-# 255 Entire hostname exceeds the maximum length of 255 characters.
-# 63 One or more individual labels within the hostname (separated by
-# dots) exceeds the maximum of 63 characters.
-# 1 One or more individual labels within the hostname contains one
-# or more invalid characters.
-# 2 One or more individual labels within the hostname starts or
-# ends with a hyphen (hyphens are allowed, but a label cannot
-# begin or end with a hyphen).
-# 3 One or more individual labels within the hostname are null.
-#
-# If the hostname is determined to be invalid, the appropriate error will be
-# displayed using the f_show_msg function.
-#
-f_validate_hostname()
-{
- local fqhn="$1"
-
- ( # Operate within a sub-shell to protect the parent environment
-
- # Return error if the hostname exceeds 255 characters
- [ ${#fqhn} -gt 255 ] && exit 255
-
- IFS="." # Split on `dot'
- for label in $fqhn; do
-
- # Return error if the label exceeds 63 characters
- [ ${#label} -gt 63 ] && exit 63
-
- # Return error if the label is null
- [ "$label" ] || exit 3
-
- # Return error if label begins/ends with dash
- case "$label" in
- -*|*-) exit 2
- esac
-
- # Return error if the label contains any invalid chars
- echo "$label" | grep -q '^[[:alnum:]-]*$' || exit 1
-
- done
- )
-}
-
# f_dialog_hnerror $error $hostname
#
# Display a msgbox with the appropriate error message for an error returned by
diff --git a/usr.sbin/bsdconfig/networking/share/ipaddr.subr b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
index d5398e5..4b39dd2 100644
--- a/usr.sbin/bsdconfig/networking/share/ipaddr.subr
+++ b/usr.sbin/bsdconfig/networking/share/ipaddr.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_IPADDR_SUBR" ]; then _NETWORKING_IPADDR_SUBR=1
#
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -40,75 +40,10 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
############################################################ FUNCTIONS
-# f_ifconfig_inet $interface
-#
-# Returns the IPv4 address associated with $interface.
-#
-f_ifconfig_inet()
-{
- local interface="$1"
- ifconfig "$interface" 2> /dev/null | awk \
- '
- BEGIN { found = 0 }
- ( $1 == "inet" ) \
- {
- print $2
- found = 1
- exit
- }
- END { exit ! found }
- '
-}
-
-# f_validate_ipaddr $ipaddr
-#
-# Returns zero if the given argument (an IP address) is of the proper format.
-#
-# The return status for invalid IP address is one of:
-# 1 One or more individual octets within the IP address (separated
-# by dots) contains one or more invalid characters.
-# 2 One or more individual octets within the IP address are null
-# and/or missing.
-# 3 One or more individual octets within the IP address exceeds the
-# maximum of 255 (or 2^8, being an octet comprised of 8 bits).
-# 4 The IP address has either too few or too many octets.
-#
-f_validate_ipaddr()
-{
- local ip="$1"
-
- ( # Operate within a sub-shell to protect the parent environment
-
- # Track number of octets for error checking
- noctets=0
-
- IFS="." # Split on `dot'
- for octet in $ip; do
-
- # Return error if the octet is null
- [ "$octet" ] || exit 2
-
- # Return error if not a whole integer
- f_isinteger "$octet" || exit 1
-
- # Return error if not a positive integer
- [ $octet -ge 0 ] || exit 1
-
- # Return error if the octet exceeds 255
- [ $octet -gt 255 ] && exit 3
-
- noctets=$(( $noctets + 1 ))
-
- done
-
- [ $noctets -eq 4 ] || exit 4
- )
-}
-
# f_dialog_iperror $error $ipaddr
#
# Display a msgbox with the appropriate error message for an error returned by
-# the f_validate_ipaddr function above.
+# the f_validate_ipaddr function.
#
f_dialog_iperror()
{
@@ -144,141 +79,6 @@ f_dialog_validate_ipaddr()
return $retval
}
-# f_validate_ipaddr6 $ipv6_addr
-#
-# Returns zero if the given argument (an IPv6 address) is of the proper format.
-#
-# The return status for invalid IP address is one of:
-# 1 One or more individual segments within the IP address
-# (separated by colons) contains one or more invalid characters.
-# Segments must contain only combinations of the characters 0-9,
-# A-F, or a-f.
-# 2 Too many/incorrect null segments. A single null segment is
-# allowed within the IP address (separated by colons) but not
-# allowed at the beginning or end (unless a double-null segment;
-# i.e., "::*" or "*::").
-# 3 One or more individual segments within the IP address
-# (separated by colons) exceeds the length of 4 hex-digits.
-# 4 The IP address entered has either too few (less than 3), too
-# many (more than 8), or not enough segments, separated by
-# colons.
-# 5* The IPv4 address at the end of the IPv6 address is invalid.
-# * When there is an error with the dotted-quad IPv4 address at the
-# end of the IPv6 address, the return value of 5 is OR'd with a
-# bit-shifted (<< 4) return of f_validate_ipaddr.
-#
-f_validate_ipaddr6()
-{
- local ip="$1"
-
- ( # Operate within a sub-shell to protect the parent environment
-
- IFS=":" # Split on `colon'
- set -- $ip:
-
- # Return error if too many or too few segments
- # Using 9 as max in case of leading or trailing null spanner
- [ $# -gt 9 -o $# -lt 3 ] && exit 4
-
- h="[0-9A-Fa-f]"
- nulls=0
- nsegments=$#
- contains_ipv4_segment=
-
- while [ $# -gt 0 ]; do
-
- segment="${1%:}"
- shift
-
- #
- # Return error if this segment makes one null too-many.
- # A single null segment is allowed anywhere in the
- # middle as well as double null segments are allowed at
- # the beginning or end (but not both).
- #
- if [ ! "$segment" ]; then
- nulls=$(( $nulls + 1 ))
- if [ $nulls -eq 3 ]; then
- # Only valid syntax for 3 nulls is `::'
- [ "$ip" = "::" ] || exit 2
- elif [ $nulls -eq 2 ]; then
- # Only valid if begins/ends with `::'
- case "$ip" in
- ::*|*::) : fall thru ;;
- *) exit 2
- esac
- fi
- continue
- fi
-
- #
- # Return error if not a valid hexadecimal short
- #
- case "$segment" in
- $h|$h$h|$h$h$h|$h$h$h$h)
- : valid segment of 1-4 hexadecimal digits
- ;;
- *[!0-9A-Fa-f]*)
- # Segment contains at least one invalid char
-
- # Return error immediately if not last segment
- [ $# -eq 0 ] || exit 1
-
- # Otherwise, check for legacy IPv4 notation
- case "$segment" in
- *[!0-9.]*)
- # Segment contains at least one invalid
- # character even for an IPv4 address
- exit 1
- esac
-
- # Return error if not enough segments
- if [ $nulls -eq 0 ]; then
- [ $nsegments -eq 7 ] || exit 4
- fi
-
- contains_ipv4_segment=1
-
- # Validate the IPv4 address
- f_validate_ipaddr "$segment" ||
- exit $(( 5 | $? << 4 ))
- ;;
- *)
- # Segment characters are all valid but too many
- exit 3
- esac
-
- done
-
- if [ $nulls -eq 1 ]; then
- # Single null segment cannot be at beginning/end
- case "$ip" in
- :*|*:) exit 2
- esac
- fi
-
- #
- # A legacy IPv4 address can span the last two 16-bit segments,
- # reducing the amount of maximum allowable segments by-one.
- #
- maxsegments=8
- if [ "$contains_ipv4_segment" ]; then
- maxsegments=7
- fi
-
- case $nulls in
- # Return error if missing segments with no null spanner
- 0) [ $nsegments -eq $maxsegments ] || exit 4 ;;
- # Return error if null spanner with too many segments
- 1) [ $nsegments -le $maxsegments ] || exit 4 ;;
- # Return error if leading/trailing `::' with too many segments
- 2) [ $nsegments -le $(( $maxsegments + 1 )) ] || exit 4 ;;
- esac
-
- exit $SUCCESS
- )
-}
-
# f_dialog_ip6error $error $ipv6_addr
#
# Display a msgbox with the appropriate error message for an error returned by
diff --git a/usr.sbin/bsdconfig/networking/share/netmask.subr b/usr.sbin/bsdconfig/networking/share/netmask.subr
index 3a8665d..e6838e5 100644
--- a/usr.sbin/bsdconfig/networking/share/netmask.subr
+++ b/usr.sbin/bsdconfig/networking/share/netmask.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_NETMASK_SUBR" ]; then _NETWORKING_NETMASK_SUBR=1
#
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -40,87 +40,6 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
############################################################ FUNCTIONS
-# f_ifconfig_netmask $interface
-#
-# Returns the IPv4 subnet mask associated with $interface.
-#
-f_ifconfig_netmask()
-{
- local interface="$1" octets
- octets=$( ifconfig "$interface" 2> /dev/null | awk \
- '
- BEGIN { found = 0 }
- ( $1 == "inet" ) \
- {
- printf "%s %s %s %s\n",
- substr($4,3,2),
- substr($4,5,2),
- substr($4,7,2),
- substr($4,9,2)
- found = 1
- exit
- }
- END { exit ! found }
- ' ) || return $FAILURE
-
- local octet netmask=
- for octet in $octets; do
- netmask="$netmask${netmask:+.}$( printf "%u" "0x$octet" )"
- done
- echo $netmask
-}
-
-# f_validate_netmask $netmask
-#
-# Returns zero if the given argument (a subnet mask) is of the proper format.
-#
-# The return status for invalid IP address is one of:
-# 1 One or more individual fields within the subnet mask (separated
-# by dots) contains one or more invalid characters.
-# 2 One or more individual fields within the subnet mask are null
-# and/or missing.
-# 3 One or more individual fields within the subnet mask exceeds
-# the maximum of 255 (a full 8-bit register).
-# 4 The subnet mask has either too few or too many fields.
-# 5 One or more individual fields within the subnet mask is an
-# invalid integer (only 0,128,192,224,240,248,252,254,255 are
-# valid integers).
-#
-f_validate_netmask()
-{
- local mask="$1"
-
- ( # Operate within a sub-shell to protect the parent environment
-
- # Track number of fields for error checking
- nfields=0
-
- IFS="." # Split on `dot'
- for field in $mask; do
-
- # Return error if the field is null
- [ "$field" ] || exit 2
-
- # Return error if not a whole positive integer
- f_isinteger "$field" || exit 1
-
- # Return error if the field exceeds 255
- [ $field -gt 255 ] && exit 3
-
- # Return error if the field is an invalid integer
- case "$field" in
- 0|128|192|224|240|248|252|254|255) :;;
- *) exit 5;;
- esac
-
- nfields=$(( $nfields + 1 ))
-
- done
-
- [ $nfields -eq 4 ] || exit 4
- )
-}
-
# f_dialog_maskerror $error $netmask
#
# Display a msgbox with the appropriate error message for an error returned by
diff --git a/usr.sbin/bsdconfig/networking/share/resolv.subr b/usr.sbin/bsdconfig/networking/share/resolv.subr
index 7d9af3b..b525a4d 100644
--- a/usr.sbin/bsdconfig/networking/share/resolv.subr
+++ b/usr.sbin/bsdconfig/networking/share/resolv.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_RESOLV_SUBR" ]; then _NETWORKING_RESOLV_SUBR=1
#
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
f_dprintf "%s: loading includes..." networking/resolv.subr
f_include $BSDCFG_SHARE/dialog.subr
f_include $BSDCFG_SHARE/strings.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
f_include $BSDCFG_SHARE/networking/common.subr
f_include $BSDCFG_SHARE/networking/ipaddr.subr
@@ -42,11 +43,6 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
############################################################ CONFIGURATION
#
-# Path to resolv.conf(5).
-#
-: ${RESOLV_CONF:="/etc/resolv.conf"}
-
-#
# When updating resolv.conf(5), should we populate the `search' directive with
# all possible sub-domains? In example, if the domain is "sub.domain.com", when
# the below option is set to 1, include both "sub.domain.com" and "domain.com"
@@ -103,25 +99,6 @@ f_resolv_conf_search()
'
}
-# f_resolv_conf_nameservers
-#
-# Returns nameserver(s) configured in resolv.conf(5).
-#
-f_resolv_conf_nameservers()
-{
- awk \
- '
- BEGIN { found = 0 }
- ( $1 == "nameserver" ) \
- {
- print $2
- found = 1
- }
- END { exit ! found }
- ' \
- "$RESOLV_CONF" 2> /dev/null
-}
-
# f_dialog_resolv_conf_update $hostname
#
# Updates the search/domain directives in resolv.conf(5) given a valid fully-
diff --git a/usr.sbin/bsdconfig/networking/share/routing.subr b/usr.sbin/bsdconfig/networking/share/routing.subr
index 4207ab2..2d8cafc 100644
--- a/usr.sbin/bsdconfig/networking/share/routing.subr
+++ b/usr.sbin/bsdconfig/networking/share/routing.subr
@@ -1,6 +1,6 @@
if [ ! "$_NETWORKING_ROUTING_SUBR" ]; then _NETWORKING_ROUTING_SUBR=1
#
-# Copyright (c) 2006-2012 Devin Teske
+# Copyright (c) 2006-2013 Devin Teske
# All Rights Reserved.
#
# Redistribution and use in source and binary forms, with or without
@@ -33,6 +33,7 @@ BSDCFG_SHARE="/usr/share/bsdconfig"
f_dprintf "%s: loading includes..." networking/routing.subr
f_include $BSDCFG_SHARE/sysrc.subr
f_include $BSDCFG_SHARE/dialog.subr
+f_include $BSDCFG_SHARE/media/tcpip.subr
f_include $BSDCFG_SHARE/networking/common.subr
f_include $BSDCFG_SHARE/networking/ipaddr.subr
@@ -41,25 +42,6 @@ f_include_lang $BSDCFG_LIBE/$APP_DIR/include/messages.subr
############################################################ FUNCTIONS
-# f_route_get_default
-#
-# Returns the IP address of the currently active default router.
-#
-f_route_get_default()
-{
- route -n get default 2> /dev/null | awk \
- '
- BEGIN { found = 0 }
- ( $1 == "gateway:" ) \
- {
- print $2
- found = 1
- exit
- }
- END { exit ! found }
- '
-}
-
# f_dialog_input_defaultrouter
#
# Edits the default router.
OpenPOWER on IntegriCloud