components/isc-dhcp/isc-dhcp
changeset 893 f9f75acab23a
parent 722 db6c773d591a
child 898 1b10a9e1d78c
equal deleted inserted replaced
892:fe7f5469cc2d 893:f9f75acab23a
    76 
    76 
    77 	export OPTIONS="$OPTIONS $DEBUG"
    77 	export OPTIONS="$OPTIONS $DEBUG"
    78 	return 0
    78 	return 0
    79 }
    79 }
    80 
    80 
       
    81 #
       
    82 # expand_prop "prop_name" "var_name" [ argflag ]
       
    83 #
       
    84 #     prop_name		FMRI property name
       
    85 #     var_name		variable where result is stored; initialized
       
    86 #			to ""
       
    87 #     argflag		The flag to be prepended to each property
       
    88 #			value; optional argument
       
    89 #
       
    90 # This function will retrieve the properties for "prop_name" via a call
       
    91 # to get_prop(). It will split-up the property values; it assumes that
       
    92 # the delimiter is whitespace. It will then prepend "argflag" to each
       
    93 # property value. The results will be stored in "var_name" which is
       
    94 # passed by reference.
       
    95 #
       
    96 # Return values:
       
    97 #
       
    98 #     0			Success
       
    99 #     1			Failure
       
   100 #
       
   101 expand_prop() {
       
   102 	if [ $# -lt 2 ] || [ -z $2 ]; then
       
   103 		errlog "Internal error - expand_prop() has incorrect arguments"
       
   104 		return 1
       
   105 	fi
       
   106 
       
   107 	prop_name=$1
       
   108 	typeset -n var_name=$2
       
   109 	argflag="$3"
       
   110 
       
   111 	prop_values="`get_prop $prop_name`"
       
   112 	if [  -z "$prop_values" ]; then
       
   113 		errlog "The property, \"${prop_name}\", is empty"
       
   114 		return 1
       
   115 	fi
       
   116 
       
   117 	var_name=""
       
   118 	for item in `IFS= ; set -- $prop_values; echo $@`; do
       
   119 		var_name="$var_name $argflag $item"
       
   120 	done
       
   121 
       
   122 	return 0
       
   123 }
       
   124 
       
   125 
    81 get_dhcpd_options() {
   126 get_dhcpd_options() {
    82 	# get listen_ifname property value.
   127 	# get listen_ifname property value.
    83 	LISTENIFNAMES="`get_prop listen_ifnames`"
   128 	LISTENIFNAMES="`get_prop listen_ifnames`"
    84 
   129 
    85 	#
   130 	#
   125 	#
   170 	#
   126 	# get listen_ifname property value and modify it.  
   171 	# get listen_ifname property value and modify it.  
   127 	# If listen_ifnames property value is "e1000g01 iprb0" then the
   172 	# If listen_ifnames property value is "e1000g01 iprb0" then the
   128 	# command line option will look like  "-i e1000g0 -i iprb0"
   173 	# command line option will look like  "-i e1000g0 -i iprb0"
   129 	#
   174 	#
   130 	LISTENIFNAMES="`get_prop listen_ifnames`"
   175 	IIFLIST=
   131 	IIFLIST=""
   176 	expand_prop listen_ifnames IIFLIST -i || return $?
   132 	if [ ! -z "$LISTENIFNAMES" ]; then
       
   133 		IIFLIST="-i `echo $LISTENIFNAMES | sed -e 's/[ \t]/ -i /g'`"
       
   134 	fi
       
   135 
   177 
   136 	#
   178 	#
   137 	# Get servers  V4 property value - command line option will look
   179 	# Get servers  V4 property value - command line option will look
   138 	# like  "1.2.3.5 4.5.6.7".
   180 	# like  "1.2.3.5" "4.5.6.7".
   139 	#
   181 	#
   140 	# NOTE: By default server property value is empty. User must
   182 	# NOTE: By default server property value is empty. User must
   141 	# first specify a server using svccfg/setprop command
   183 	# first specify a server using svccfg/setprop command
   142 	# before enabling service.
   184 	# before enabling service.
   143 	#
   185 	#
   160 	#
   202 	#
   161 	# NOTE: By default receivelinks value is empty. User must
   203 	# NOTE: By default receivelinks value is empty. User must
   162 	# first specify a server using svccfg/setprop command
   204 	# first specify a server using svccfg/setprop command
   163 	# before enabling service.
   205 	# before enabling service.
   164 	#
   206 	#
   165 	RECVLINKS=`get_prop receive_query_links`
   207 	IRECVLINKS=
   166 	if [  -z "$RECVLINKS" ]; then
   208 	expand_prop receive_query_links IRECVLINKS -l || return $?
   167         	errlog 'Must specify at least one "receive_query_links" property value'
       
   168 		errlog "Exiting."
       
   169 		return 1
       
   170 	fi
       
   171 	IRECVLINKS=""
       
   172 	if [ ! -z "$RECVLINKS" ]; then
       
   173 		IRECVLINKS="-l `echo $RECVLINKS | sed -e 's/[ \t]/ -l /g'`"
       
   174 	fi
       
   175 	#
   209 	#
   176 	# Get forwardlinks V6 property value and modify it:
   210 	# Get forwardlinks V6 property value and modify it:
   177 	# Given forward_query_links property value is "1.2.3.4%bge0 bge2,"
   211 	# Given forward_query_links property value is "1.2.3.4%bge0 bge2,"
   178 	# then the command line option will look like  "-u 1.2.3.4%bge0 -u
   212 	# then the command line option will look like  "-u 1.2.3.4%bge0 -u
   179 	# bge2"
   213 	# bge2"
   180 	#
   214 	#
   181 	# NOTE: By default forwardlinks value is empty. User must
   215 	# NOTE: By default forwardlinks value is empty. User must
   182 	# first specify a server using svccfg/setprop command
   216 	# first specify a server using svccfg/setprop command
   183 	# before enabling service.
   217 	# before enabling service.
   184 	#
   218 	#
   185 	FWDLINKS=`get_prop forward_query_links`
   219 	IFWDLINKS=
   186 	if [ -z "$FWDLINKS" ]; then
   220 	expand_prop forward_query_links IFWDLINKS -u || return $?
   187         	errlog 'Must specify at least one "forward_query_links" property value'
       
   188 		errlog "Exiting"
       
   189 		return 1
       
   190 	fi
       
   191 	IFWDLINKS=""
       
   192 	if [ ! -z "$FWDLINKS" ]; then
       
   193 		IFWDLINKS="-u `echo $FWDLINKS | sed -e 's/[ \t]/ -u /g'`"
       
   194 	fi
       
   195 
   221 
   196 	export OPTIONS="$OPTIONS -6 $IRECVLINKS $IFWDLINKS"
   222 	export OPTIONS="$OPTIONS -6 $IRECVLINKS $IFWDLINKS"
   197 }
   223 }
   198 
   224 
   199 export OPTIONS="--no-pid"
   225 export OPTIONS="--no-pid"