1#!/bin/sh /etc/rc.common
2START=20
3. /lib/cfgmgr/cfgmgr.sh
4. /lib/cfgmgr/opmode.sh
5
6vlan_iptv_wl_enable()
7{
8	local i
9	local value
10	local wl
11
12	local vlan_iptv_enable=$($CONFIG get i_opmode)
13
14	case $vlan_iptv_enable in
15	vlan)
16		for i in 1 2 3 4 5 6 7 8 9 10; do
17			value=$($CONFIG get vlan_tag_$i)
18			if [ "x$value" = "x" ] ;then
19				break
20			fi
21			wl=`echo $value|awk '{print $6}'`
22			[ "x$wl" != "x0" ] && return 0
23		done
24		;;
25	iptv)
26		[ "$($CONFIG get wan_brig_ssid1)" = "1" ] && return 0
27		[ "$($CONFIG get wan_brig_ssid2)" = "1" ] && return 0
28		[ "$($CONFIG get wan_brig_guest_ssid1)" = "1" ] && return 0
29		[ "$($CONFIG get wan_brig_guest_ssid2)" = "1" ] && return 0
30
31	;;
32	*) return 1 ;;
33	esac
34	return 1
35}
36
37bridge_stop_nss()
38{
39	case "$($CONFIG get i_opmode)" in
40	apmode|extmode)
41		return 0
42		;;
43	*)
44		return 1
45		;;
46	esac
47}
48
49start_stage0() # $1: boot/start
50{
51	op_set_induced_configs
52	op_create_brs_and_vifs
53
54	#For AP mode and Bridge mode turn off access control
55	local opmode=$($CONFIG get i_opmode)
56	if [ "$opmode" = "apmode"  -o "$opmode" = "brmode" ]; then
57		$CONFIG set enable_block_device=0
58	else
59		[ "x$($CONFIG get old_enable_acl_status)" != "x" ] && $CONFIG set enable_block_device=$($CONFIG get old_enable_acl_status)
60	fi
61	/etc/init.d/acl restart
62
63
64	case "$($CONFIG get i_opmode)" in
65	normal|iptv|vlan)
66		if [ "$1" = "start" ]; then
67			/sbin/cmd_traffic_meter restart
68		fi
69		/etc/init.d/net-lan $1 mode
70		/etc/init.d/net-wan $1 mode
71		;;
72	*)
73		/etc/init.d/net-br $1
74		;;
75	esac
76
77	if vlan_iptv_wl_enable || bridge_stop_nss; then
78		/etc/init.d/qca-nss-ecm stop &
79	fi
80}
81
82stop0()
83{
84	case "$($CONFIG get i_opmode)" in
85	normal|iptv|vlan)
86		/etc/init.d/init6 stop
87		/etc/init.d/net-wan stop
88		/etc/init.d/net-lan stop
89		;;
90	*)
91		/etc/init.d/net-br stop
92		;;
93	esac
94	op_del_all_brs_vifs
95}
96
97start()
98{
99	start_stage0 start
100}
101
102stop()
103{
104	/etc/init.d/wlan-common stop
105	stop0
106}
107
108restart()
109{
110	stop
111	start
112}
113
114boot()
115{
116	op_create_br0_brwan
117	start_stage0 boot
118}
119
120