1if [ ! "$_MEDIA_HTTP_SUBR" ]; then _MEDIA_HTTP_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: head/usr.sbin/bsdconfig/share/media/http.subr 264840 2014-04-23 22:04:04Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/http.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/dialog.subr
--- 174 unchanged lines hidden (view full) ---
210 # Set the name of the HTTP device to the URL
211 f_struct_new DEVICE device_http
212 device_http set name "$url"
213
214 if ! f_struct device_network ||
215 ! f_dialog_yesno "$msg_youve_already_done_the_network_configuration"
216 then
217 f_struct device_network &&
218 f_device_shutdown device_network
219 if ! f_device_select_tcp; then
220 unset $VAR_HTTP_PATH
221 return $FAILURE
222 fi
223 local dev if
224 f_getvar $VAR_NETWORK_DEVICE if
225 f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
226 f_struct_copy "$dev" device_network
227 fi
228 if ! f_device_init device_network; then
229 f_dprintf "f_media_set_http: %s" "$msg_net_device_init_failed"
230 unset $VAR_HTTP_PATH
231 return $FAILURE
232 fi
233
234 local hostname="${url#*://}" port=80 dir=/
235 case "$hostname" in
236 #
--- 66 unchanged lines hidden (view full) ---
303 f_validate_ipaddr6 "$hostname"
304 }; then
305 f_show_info "$msg_looking_up_host" "$hostname"
306 f_dprintf "%s: Looking up hostname, %s, using host(1)" \
307 "f_media_set_http" "$hostname"
308 if ! f_quietly f_host_lookup "$hostname"; then
309 f_show_msg "$msg_cannot_resolve_hostname" "$hostname"
310 f_struct device_network &&
311 f_device_shutdown device_network
312 f_struct_free device_network
313 unset $VAR_HTTP_PATH
314 return $FAILURE
315 fi
316 f_dprintf "Found DNS entry for %s successfully." "$hostname"
317 fi
318
319 setvar $VAR_HTTP_HOST "$hostname"
320 setvar $VAR_HTTP_PORT "$port"
321 setvar $VAR_HTTP_DIR "$dir"
322
323 device_http set type $DEVICE_TYPE_HTTP
324 device_http set init f_media_init_http
325 device_http set get f_media_get_http
326 device_http set shutdown f_media_shutdown_http
327 device_http set private device_network
328 f_struct_copy device_http device_media
329 f_struct_free device_http
330
331 return $SUCCESS
332}
333
334# f_http_check_access [$connect_only]
335#
--- 225 unchanged lines hidden (view full) ---
561#
562# Example usage:
563# f_media_set_http
564# f_media_get_http media $file
565#
566f_media_get_http()
567{
568 local dev="$1" file="$2" probe_type="$3" hosts=
569 local name
570
571 $dev get name name
572 f_dprintf "f_media_get_http: dev=[%s] file=[%s] probe_type=%s" \
573 "$name" "$file" "$probe_type"
574
575 local http_host http_port
576 f_getvar $VAR_HTTP_HOST http_host
577 f_getvar $VAR_HTTP_PORT http_port
578
579 if [ ! "$HTTP_INITIALIZED" ]; then
580 f_dprintf "No HTTP connection open, can't get file %s" "$file"
581 return $FAILURE
--- 112 unchanged lines hidden ---
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: head/usr.sbin/bsdconfig/share/media/http.subr 264840 2014-04-23 22:04:04Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." media/http.subr
34f_include $BSDCFG_SHARE/device.subr
35f_include $BSDCFG_SHARE/dialog.subr
--- 174 unchanged lines hidden (view full) ---
210 # Set the name of the HTTP device to the URL
211 f_struct_new DEVICE device_http
212 device_http set name "$url"
213
214 if ! f_struct device_network ||
215 ! f_dialog_yesno "$msg_youve_already_done_the_network_configuration"
216 then
217 f_struct device_network &&
218 f_device_shutdown device_network
219 if ! f_device_select_tcp; then
220 unset $VAR_HTTP_PATH
221 return $FAILURE
222 fi
223 local dev if
224 f_getvar $VAR_NETWORK_DEVICE if
225 f_device_find -1 "$if" $DEVICE_TYPE_NETWORK dev
226 f_struct_copy "$dev" device_network
227 fi
228 if ! f_device_init device_network; then
229 f_dprintf "f_media_set_http: %s" "$msg_net_device_init_failed"
230 unset $VAR_HTTP_PATH
231 return $FAILURE
232 fi
233
234 local hostname="${url#*://}" port=80 dir=/
235 case "$hostname" in
236 #
--- 66 unchanged lines hidden (view full) ---
303 f_validate_ipaddr6 "$hostname"
304 }; then
305 f_show_info "$msg_looking_up_host" "$hostname"
306 f_dprintf "%s: Looking up hostname, %s, using host(1)" \
307 "f_media_set_http" "$hostname"
308 if ! f_quietly f_host_lookup "$hostname"; then
309 f_show_msg "$msg_cannot_resolve_hostname" "$hostname"
310 f_struct device_network &&
311 f_device_shutdown device_network
312 f_struct_free device_network
313 unset $VAR_HTTP_PATH
314 return $FAILURE
315 fi
316 f_dprintf "Found DNS entry for %s successfully." "$hostname"
317 fi
318
319 setvar $VAR_HTTP_HOST "$hostname"
320 setvar $VAR_HTTP_PORT "$port"
321 setvar $VAR_HTTP_DIR "$dir"
322
323 device_http set type $DEVICE_TYPE_HTTP
324 device_http set init f_media_init_http
325 device_http set get f_media_get_http
326 device_http set shutdown f_media_shutdown_http
327 device_http set private device_network
328 f_struct_copy device_http device_media
329 f_struct_free device_http
330
331 return $SUCCESS
332}
333
334# f_http_check_access [$connect_only]
335#
--- 225 unchanged lines hidden (view full) ---
561#
562# Example usage:
563# f_media_set_http
564# f_media_get_http media $file
565#
566f_media_get_http()
567{
568 local dev="$1" file="$2" probe_type="$3" hosts=
569 local name
570
571 $dev get name name
572 f_dprintf "f_media_get_http: dev=[%s] file=[%s] probe_type=%s" \
573 "$name" "$file" "$probe_type"
574
575 local http_host http_port
576 f_getvar $VAR_HTTP_HOST http_host
577 f_getvar $VAR_HTTP_PORT http_port
578
579 if [ ! "$HTTP_INITIALIZED" ]; then
580 f_dprintf "No HTTP connection open, can't get file %s" "$file"
581 return $FAILURE
--- 112 unchanged lines hidden ---