summaryrefslogtreecommitdiff
blob: a4bf06ca734ff5c9db6c68664354968a381ecd04 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/sbin/runscript

source_config() {
	if [ -f /etc/wlan/shared ]
	then
		source /etc/wlan/shared
	else
		return 1
	fi
	return 0
}

start() {
	ebegin "Starting WLAN devices"
	if ! source_config
	then
		eerror "Error loading /etc/wlan/shared"
		eend 1
		return 1
	fi

	# NOTE: We don't explicitly insmod the card driver here.  The
	#  best thing to do is to specify an alias in /etc/modules.conf.
	#  Then, the first time we call wlanctl with the named device,
	#  the kernel module autoload stuff will take over.

	for DEVICE in $WLAN_DEVICES; do
	#=======ENABLE========================================
	# Do we want to init the card at all?
		eval 'WLAN_ENABLE=$ENABLE_'$DEVICE
		if ! is_true $WLAN_ENABLE ; then
			continue
		fi

		if is_true $WLAN_DOWNLOAD; then
			wlan_download $DEVICE
		fi

		wlan_enable $DEVICE

	#=======MAC STARTUP=========================================
		wlan_supports_scan $DEVICE

		if [ $? = 0 ] ; then
			wlan_scan $DEVICE
			if [ $? = 0 ] ; then
				wlan_source_config_for_ssid "$ssid" "$bssid"
		
				wlan_user_mibs $DEVICE
				# make it quiet
				error=`eval wlan_wep $DEVICE`
		
				grep 'autojoin' /proc/net/p80211/$DEVICE/wlandev > /dev/null
					if [ $? = 0 ]; then
						wlan_infra $DEVICE
					else
						wlan_dot11_join $DEVICE
					fi
			else
				echo "network not found.  maybe start IBSS?"
			fi
		else
			wlan_source_config $DEVICE
	
			wlan_user_mibs $DEVICE
			# make it quiet
			error=`eval wlan_wep $DEVICE`
	
			if is_true $IS_ADHOC ; then
				wlan_adhoc $DEVICE
			else
				wlan_infra $DEVICE
			fi
		fi
	done

	eend 0
}

stop() {
	ebegin "Shutting Down WLAN Devices"
	if ! source_config
	then
		eerror "Error loading /etc/wlan/shared"
		eend 1
		return 1
	fi

	# Do a reset on each device to make sure none of them are still
	#  trying to generate interrupts.
	for DEVICE in $WLAN_DEVICES; do
		# This just makes it quiet...
		error="$(eval wlan_disable $DEVICE)"
	done

	eend 0
}