summaryrefslogtreecommitdiffstats
path: root/usr.sbin/bsdconfig/networking/share/netmask.subr
diff options
context:
space:
mode:
authordteske <dteske@FreeBSD.org>2013-02-25 19:55:32 +0000
committerdteske <dteske@FreeBSD.org>2013-02-25 19:55:32 +0000
commit1f658c88bed0f72839a6caee6fdc9731cfd3a516 (patch)
treecd0ba840ab0526258652c2740f9e0c046edb8374 /usr.sbin/bsdconfig/networking/share/netmask.subr
parent66bd226a8bcd9c32e76c9a7c414af10c393e50d8 (diff)
downloadFreeBSD-src-1f658c88bed0f72839a6caee6fdc9731cfd3a516.zip
FreeBSD-src-1f658c88bed0f72839a6caee6fdc9731cfd3a516.tar.gz
Import media selection/preparation framework (sysinstall inspired). Makes
accessing files from various types of media nice and abstracted away from the wet-work involved in preparing, validating, and initializing those types of media. This will be used for the package management system module and other modules that need access to files and want to allow the user to decide where those files come from (either in a scripted fashion, prompted fashion, or any combination thereof). Heavily inspired by sysinstall and even uses the same reserved words so that scripts are portable. Coded over months, tested continuously through- out, and reviewed several times. Some notes about the changes: - Move network-setting acquisition/validation routines to media/tcpip.subr - The options screen from sysinstall has been converted to a dialog menu - The "UFS" media choice is renamed to "Directory" to reflect how sysinstall treats the choice and a new [true] "UFS" media choice has been added that acts on real UFS partitions (such as external disks with disklabels). - Many more help files have been resurrected from sysinstall (I noticed that some of the content seems a bit dated; I gave them a once-over but they could really use an update). - A total of 10 media choices are presented (via mediaGetType) including: CD/DVD, FTP, FTP Passive, HTTP Proxy, Directory, NFS, DOS, UFS, Floppy, USB - Novel struct/device management layer for managing the issue of passing more information than can comfortably fit in an argument list.
Diffstat (limited to 'usr.sbin/bsdconfig/networking/share/netmask.subr')
-rw-r--r--usr.sbin/bsdconfig/networking/share/netmask.subr83
1 files changed, 1 insertions, 82 deletions
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
OpenPOWER on IntegriCloud