This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
mesh_setip.sh
executable file
·279 lines (232 loc) · 9.26 KB
/
mesh_setip.sh
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
#!/bin/sh
######################################################################################
# If not stated otherwise in this file or this component's LICENSE file the
# following copyright and licenses apply:
# Copyright 2018 RDK Management
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#######################################################################################
MODEL_NUM=`grep MODEL_NUM /etc/device.properties | cut -d "=" -f2`
IF_MESHBR24=`wifi_api wifi_getApBridgeInfo 12 "" "" "" | head -n 1`
IF_MESHBR50=`wifi_api wifi_getApBridgeInfo 13 "" "" "" | head -n 1`
MESHBR24_IP="169.254.0.1 netmask 255.255.255.0"
MESHBR50_IP="169.254.1.1 netmask 255.255.255.0"
IF_MESHEB="brebhaul"
MESHEB_IP="169.254.85.1 netmask 255.255.255.0"
BRIDGE_MTU=1600
MESH_EXTENDER_BRIDGE="br-home"
if [ "$MODEL_NUM" == "WNXL11BWL" ]; then
echo "Extender mode bridge configuration"
ovs-vsctl add-br $MESH_EXTENDER_BRIDGE
ifconfig $MESH_EXTENDER_BRIDGE up
exit 0
fi
ovs_enable=false
if [ -d "/sys/module/openvswitch/" ];then
ovs_enable=true
fi
bridgeUtilEnable=`syscfg get bridge_util_enable`
USE_BRIDGEUTILS=0
if [ "x$ovs_enable" = "xtrue" ] || [ "x$bridgeUtilEnable" = "xtrue" ] ; then
if [ "$MODEL_NUM" == "CGM4331COM" ] || [ "$MODEL_NUM" == "CGM4981COM" ] || [ "$MODEL_NUM" == "SR300" ] || [ "$MODEL_NUM" == "SE501" ] || [ "$MODEL_NUM" == "WNXL11BWL" ] || [ "$MODEL_NUM" == "SR213" ] || [ "$MODEL_NUM" == "SR203" ]; then
USE_BRIDGEUTILS=1
fi
fi
#XF3 & CommScope XB7 specific changes
if [ "$MODEL_NUM" == "PX5001" ] || [ "$MODEL_NUM" == "CGM4331COM" ] || [ "$MODEL_NUM" == "CGM4981COM" ] || [ "$MODEL_NUM" == "TG4482A" ]; then
IF_MESHBR24="brlan112"
IF_MESHBR50="brlan113"
if [ "$MODEL_NUM" == "TG4482A" ]; then
IF_MESHVAP24="wlan0.6"
IF_MESHVAP50="wlan2.6"
else
IF_MESHVAP24="wl0.6"
IF_MESHVAP50="wl1.6"
fi
PLUME_BH1_NAME="brlan112"
PLUME_BH2_NAME="brlan113"
PLUME_BHAUL_NAME="br403"
DEFAULT_MESHBHUAL_IPV4_ADDR="192.168.245.1"
DEFAULT_PLUME_BH1_IPV4_ADDR="169.254.0.1"
DEFAULT_PLUME_BH2_IPV4_ADDR="169.254.1.1"
DEFAULT_PLUME_BH_NETMASK="255.255.255.0"
fi
#SKYHUB4 specific changes
if [ "$MODEL_NUM" == "SR201" ] || [ "$MODEL_NUM" == "SR203" ] || [ "$MODEL_NUM" == "SR300" ] || [ "$MODEL_NUM" == "SE501" ] || [ "$MODEL_NUM" == "SR213" ] || [ "$MODEL_NUM" == "WNXL11BWL" ]; then
IF_MESHBR24="brlan6"
IF_MESHBR50="brlan7"
IF_MESHVAP24="wl0.6"
IF_MESHVAP50="wl1.6"
PLUME_BH1_NAME="brlan6"
PLUME_BH2_NAME="brlan7"
PLUME_BHAUL_NAME="br403"
DEFAULT_MESHBHUAL_IPV4_ADDR="192.168.245.1"
DEFAULT_PLUME_BH1_IPV4_ADDR="169.254.0.1"
DEFAULT_PLUME_BH2_IPV4_ADDR="169.254.1.1"
DEFAULT_PLUME_BH_NETMASK="255.255.255.0"
fi
if [ "$MODEL_NUM" == "PX5001" ]; then
IF_ETH_IFACE="eth0 eth1 eth2 eth3"
fi
mesh_bridges()
{
echo "ADD wifi interfaces to the Bridge $PLUME_BH1_NAME" > /dev/console
for WIFI_IFACE in $IF_MESHVAP24
do
/sbin/ifconfig $WIFI_IFACE down
done
for WIFI_IFACE in $IF_MESHVAP24
do
brctl addif $PLUME_BH1_NAME $WIFI_IFACE
/sbin/ifconfig $WIFI_IFACE 0.0.0.0 up
done
echo inf add wl0.6 > /proc/driver/flowmgr/cmd
echo 1 > /sys/class/net/$PLUME_BH1_NAME/bridge/nf_call_iptables
echo 1 > /sys/class/net/$PLUME_BH1_NAME/bridge/nf_call_arptables
/sbin/ifconfig $PLUME_BH1_NAME $DEFAULT_PLUME_BH1_IPV4_ADDR netmask $DEFAULT_PLUME_BH_NETMASK up
echo "ADD wifi interfaces to the Bridge $PLUME_BH2_NAME" > /dev/console
for WIFI_IFACE in $IF_MESHVAP50
do
/sbin/ifconfig $WIFI_IFACE down
done
for WIFI_IFACE in $IF_MESHVAP50
do
brctl addif $PLUME_BH2_NAME $WIFI_IFACE
/sbin/ifconfig $WIFI_IFACE 0.0.0.0 up
done
echo inf add wl1.6 > /proc/driver/flowmgr/cmd
echo 1 > /sys/class/net/$PLUME_BH2_NAME/bridge/nf_call_iptables
echo 1 > /sys/class/net/$PLUME_BH2_NAME/bridge/nf_call_arptables
/sbin/ifconfig $PLUME_BH2_NAME $DEFAULT_PLUME_BH2_IPV4_ADDR netmask $DEFAULT_PLUME_BH_NETMASK up
}
mesh_bhaul()
{
brctl addbr $PLUME_BHAUL_NAME
echo 1 > /sys/class/net/$PLUME_BHAUL_NAME/bridge/nf_call_iptables
echo 1 > /sys/class/net/$PLUME_BHAUL_NAME/bridge/nf_call_arptables
/sbin/ifconfig $PLUME_BHAUL_NAME $DEFAULT_MESHBHUAL_IPV4_ADDR netmask $DEFAULT_PLUME_BH_NETMASK up
ifconfig $PLUME_BHAUL_NAME up
}
is_vlan() {
ifn="$1"
[ -z "$ifn" ] && return 1
ip -d link show $ifn | grep vlan > /dev/null
return $?
}
vlan_root() {
echo "$1" | cut -d '.' -f 1
}
bridge_interfaces() {
br_ifn="$1"
[ -z "$br_ifn" ] && return
brctl show $br_ifn | grep -v STP | while read a b c d; do
[ ${#d} -eq 0 ] && echo $a || echo $d
done
}
bridge_set_mtu() {
br_ifn="$1"
br_mtu="$2"
[ -z "$br_ifn" -o -z "$br_mtu" ] && return
echo "...Setting bridge $br_ifn MTU to $br_mtu"
for ifn in $(bridge_interfaces $br_ifn); do
echo "......Setting $(vlan_root $ifn) MTU to $br_mtu"
ifconfig $ifn mtu $br_mtu
done
ifconfig $br_ifn $br_mtu
}
mesh_bridge_setup() {
brctl addbr $PLUME_BH1_NAME
brctl addbr $PLUME_BH2_NAME
/sbin/ifconfig $PLUME_BH1_NAME $DEFAULT_PLUME_BH1_IPV4_ADDR netmask $DEFAULT_PLUME_BH_NETMASK up
/sbin/ifconfig $PLUME_BH2_NAME $DEFAULT_PLUME_BH2_IPV4_ADDR netmask $DEFAULT_PLUME_BH_NETMASK up
if [ "$MODEL_NUM" == "TG4482A" ]; then
ifconfig $IF_MESHBR24 mtu $BRIDGE_MTU
ifconfig $IF_MESHVAP24 mtu $BRIDGE_MTU
ifconfig $IF_MESHBR50 mtu $BRIDGE_MTU
ifconfig $IF_MESHVAP50 mtu $BRIDGE_MTU
fi
brctl delif brlan0 $IF_MESHVAP24
brctl delif brlan0 $IF_MESHVAP50
brctl addif $PLUME_BH1_NAME $IF_MESHVAP24
brctl addif $PLUME_BH2_NAME $IF_MESHVAP50
}
#Setup backhaul bridge for Ethernet Pod connection
if [ "$1" == "set_eb" ];then
if [ "$2" == "1" ];then
brctl addbr $IF_MESHEB
/sbin/ifconfig $IF_MESHEB $MESHEB_IP up
for iface in $IF_ETH_IFACE;do
vconfig add $iface 123
ifconfig $iface.123 up
brctl addif $IF_MESHEB $iface.123
done
echo e 0 > /proc/driver/ethsw/vlan
else
for iface in $IF_ETH_IFACE;do
ip link del $iface.123
done
fi
exit 0
fi
if [ "$MODEL_NUM" == "SR201" ] || [ "$MODEL_NUM" == "SR203" ] || [ "$MODEL_NUM" == "SR300" ] || [ "$MODEL_NUM" == "SE501" ] || [ "$MODEL_NUM" == "WNXL11BWL" ] || [ "$MODEL_NUM" == "CGM4981COM" ] || [ "$MODEL_NUM" == "CGM4331COM" ] || [ "$MODEL_NUM" == "TG4482A" ] || [ "$MODEL_NUM" == "SR213" ]; then
VLAN_PUMA7_ENABLE=`grep VLAN_PUMA7_ENABLE /etc/device.properties | cut -d "=" -f2`
if [ $USE_BRIDGEUTILS -eq 1 ] || [ "$VLAN_PUMA7_ENABLE" == "true" ]; then
sysevent set multinet-up 13
sysevent set multinet-up 14
else
mesh_bridge_setup
fi
fi
if [ -n "${IF_MESHBR24}" ] && [ $USE_BRIDGEUTILS -eq 0 ]; then
echo "Configuring $IF_MESHBR24"
bridge_set_mtu $IF_MESHBR24 $BRIDGE_MTU
ifconfig $IF_MESHBR24 $MESHBR24_IP
if [ "$MODEL_NUM" == "PX5001" ] || [ "$MODEL_NUM" == "CGM4331COM" ] || [ "$MODEL_NUM" == "CGM4981COM" ] || [ "$MODEL_NUM" == "SR201" ] || [ "$MODEL_NUM" == "SR203" ] || [ "$MODEL_NUM" == "SR300" ] || [ "$MODEL_NUM" == "SE501" ] || [ "$MODEL_NUM" == "WNXL11BWL" ] || [ "$MODEL_NUM" == "SR213" ]; then
ifconfig $IF_MESHBR24 mtu $BRIDGE_MTU
ifconfig $IF_MESHVAP24 mtu $BRIDGE_MTU
fi
fi
if [ -n "${IF_MESHBR50}" ] && [ $USE_BRIDGEUTILS -eq 0 ]; then
echo "Configuring $IF_MESHBR50"
bridge_set_mtu $IF_MESHBR50 $BRIDGE_MTU
ifconfig $IF_MESHBR50 $MESHBR50_IP
if [ "$MODEL_NUM" == "PX5001" ] || [ "$MODEL_NUM" == "CGM4331COM" ] || [ "$MODEL_NUM" == "CGM4981COM" ] || [ "$MODEL_NUM" == "SR201" ] || [ "$MODEL_NUM" == "SR203" ] || [ "$MODEL_NUM" == "SR300" ] || [ "$MODEL_NUM" == "SE501" ] || [ "$MODEL_NUM" == "WNXL11BWL" ] || [ "$MODEL_NUM" == "SR213" ]; then
ifconfig $IF_MESHBR50 mtu $BRIDGE_MTU
ifconfig $IF_MESHVAP50 mtu $BRIDGE_MTU
fi
fi
if [ "$MODEL_NUM" == "PX5001" ] || [ "$MODEL_NUM" == "CGM4331COM" ] || [ "$MODEL_NUM" == "CGM4981COM" ] || [ "$MODEL_NUM" == "SR201" ] || [ "$MODEL_NUM" == "SR203" ] || [ "$MODEL_NUM" == "SR300" ] || [ "$MODEL_NUM" == "SE501" ] || [ "$MODEL_NUM" == "WNXL11BWL" ] || [ "$MODEL_NUM" == "SR213" ]; then
if [ "$MODEL_NUM" == "TG4482A" ]; then
brctl112=`brctl show | grep wlan0.6`
brctl113=`brctl show | grep wlan2.6`
else
brctl113=`brctl show | grep wl1.6`
brctl112=`brctl show | grep wl0.6`
fi
if [ "$brctl113" == "" ] || [ "$brctl112" == "" ] && [ "$MODEL_NUM" == "PX5001" ]; then
mesh_bridges
fi
#RDKB-15951- Xf3 & Sky specific change: Moving over bhaul to br403 Prash
if [ "x$ovs_enable" = "xtrue" ];then
if [ "x$ovs_enable" = "xtrue" ]; then
ifbr403=`ovs-vsctl show | grep br403`
else
ifbr403=`brctl show | grep br403`
fi
if [ "$ifbr403" == "" ]; then
sysevent set meshbhaul-setup 10
fi
else
brctl403=`brctl show | grep br403`
if [ "$brctl403" == "" ]; then
mesh_bhaul
fi
fi
fi