OpenWrt – Diff between revs 2 and 3

Subversion Repositories:
Rev:
Show entire fileIgnore whitespace
Rev 2 Rev 3
Line 20... Line 20...
20 proto_config_add_string pdptype 20 proto_config_add_string pdptype
21 proto_config_add_int profile 21 proto_config_add_int profile
22 proto_config_add_boolean dhcpv6 22 proto_config_add_boolean dhcpv6
23 proto_config_add_boolean autoconnect 23 proto_config_add_boolean autoconnect
24 proto_config_add_int plmn 24 proto_config_add_int plmn
25 proto_config_add_int timeout -  
26 proto_config_add_defaults 25 proto_config_add_defaults
27 } 26 }
Line 28... Line 27...
28   27  
29 proto_qmi_setup() { 28 proto_qmi_setup() {
30 local interface="$1" 29 local interface="$1"
31 local dataformat connstat 30 local dataformat connstat
32 local device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn timeout $PROTO_DEFAULT_OPTIONS -  
33 local ip4table ip6table 31 local device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn $PROTO_DEFAULT_OPTIONS
34 local cid_4 pdh_4 cid_6 pdh_6 32 local cid_4 pdh_4 cid_6 pdh_6
35 local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6 33 local ip_6 ip_prefix_length gateway_6 dns1_6 dns2_6
36 json_get_vars device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn ip4table ip6table timeout $PROTO_DEFAULT_OPTIONS -  
37   -  
Line 38... Line 34...
38 [ "$timeout" = "" ] && timeout="10" 34 json_get_vars device apn auth username password pincode delay modes pdptype profile dhcpv6 autoconnect plmn $PROTO_DEFAULT_OPTIONS
Line 39... Line 35...
39   35  
Line 46... Line 42...
46 proto_notify_error "$interface" NO_DEVICE 42 proto_notify_error "$interface" NO_DEVICE
47 proto_set_available "$interface" 0 43 proto_set_available "$interface" 0
48 return 1 44 return 1
49 } 45 }
Line 50... Line -...
50   -  
51 [ -n "$delay" ] && sleep "$delay" -  
52   46  
53 device="$(readlink -f $device)" 47 device="$(readlink -f $device)"
54 [ -c "$device" ] || { 48 [ -c "$device" ] || {
55 echo "The specified control device does not exist" 49 echo "The specified control device does not exist"
56 proto_notify_error "$interface" NO_DEVICE 50 proto_notify_error "$interface" NO_DEVICE
Line 66... Line 60...
66 proto_notify_error "$interface" NO_IFACE 60 proto_notify_error "$interface" NO_IFACE
67 proto_set_available "$interface" 0 61 proto_set_available "$interface" 0
68 return 1 62 return 1
69 } 63 }
Line 70... Line 64...
70   64  
71 echo "Waiting for SIM initialization" -  
-   65 [ -n "$delay" ] && sleep "$delay"
72 local uninitialized_timeout=0 66  
73 while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do 67 while uqmi -s -d "$device" --get-pin-status | grep '"UIM uninitialized"' > /dev/null; do
74 [ -e "$device" ] || return 1 -  
75 if [ "$uninitialized_timeout" -lt "$timeout" ]; then -  
76 let uninitialized_timeout++ 68 [ -e "$device" ] || return 1
77 sleep 1; -  
78 else -  
79 echo "SIM not initialized" -  
80 proto_notify_error "$interface" SIM_NOT_INITIALIZED -  
81 proto_block_restart "$interface" -  
82 return 1 -  
83 fi 69 sleep 1;
Line 84... Line -...
84 done -  
85   70 done
86 if uqmi -s -d "$device" --get-pin-status | grep '"Not supported"\|"Invalid QMI command"' > /dev/null; then 71  
87 [ -n "$pincode" ] && { 72 [ -n "$pincode" ] && {
88 uqmi -s -d "$device" --verify-pin1 "$pincode" > /dev/null || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null || { 73 uqmi -s -d "$device" --verify-pin1 "$pincode" > /dev/null || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null || {
89 echo "Unable to verify PIN" 74 echo "Unable to verify PIN"
90 proto_notify_error "$interface" PIN_FAILED 75 proto_notify_error "$interface" PIN_FAILED
91 proto_block_restart "$interface" -  
92 return 1 76 proto_block_restart "$interface"
93 } -  
94 } -  
95 else -  
96 . /usr/share/libubox/jshn.sh -  
97 json_load "$(uqmi -s -d "$device" --get-pin-status)" -  
98 json_get_var pin1_status pin1_status -  
99 json_get_var pin1_verify_tries pin1_verify_tries -  
100   -  
101 case "$pin1_status" in -  
102 disabled) -  
103 echo "PIN verification is disabled" -  
104 ;; -  
105 blocked) -  
106 echo "SIM locked PUK required" -  
107 proto_notify_error "$interface" PUK_NEEDED -  
108 proto_block_restart "$interface" -  
109 return 1 -  
110 ;; -  
111 not_verified) -  
112 [ "$pin1_verify_tries" -lt "3" ] && { -  
113 echo "PIN verify count value is $pin1_verify_tries this is below the limit of 3" -  
114 proto_notify_error "$interface" PIN_TRIES_BELOW_LIMIT -  
115 proto_block_restart "$interface" -  
116 return 1 -  
117 } -  
118 if [ -n "$pincode" ]; then -  
119 uqmi -s -d "$device" --verify-pin1 "$pincode" > /dev/null 2>&1 || uqmi -s -d "$device" --uim-verify-pin1 "$pincode" > /dev/null 2>&1 || { -  
120 echo "Unable to verify PIN" -  
121 proto_notify_error "$interface" PIN_FAILED -  
122 proto_block_restart "$interface" -  
123 return 1 -  
124 } -  
125 else -  
126 echo "PIN not specified but required" -  
127 proto_notify_error "$interface" PIN_NOT_SPECIFIED -  
128 proto_block_restart "$interface" -  
129 return 1 -  
130 fi -  
131 ;; -  
132 verified) -  
133 echo "PIN already verified" -  
134 ;; -  
135 *) -  
136 echo "PIN status failed ($pin1_status)" -  
137 proto_notify_error "$interface" PIN_STATUS_FAILED -  
138 proto_block_restart "$interface" -  
139 return 1 -  
140 ;; 77 return 1
Line 141... Line 78...
141 esac 78 }
142 fi 79 }
143   80  
144 [ -n "$plmn" ] && { 81 [ -n "$plmn" ] && {
Line 150... Line 87...
150 else 87 else
151 mcc=${plmn:0:3} 88 mcc=${plmn:0:3}
152 mnc=${plmn:3} 89 mnc=${plmn:3}
153 echo "Setting PLMN to $plmn" 90 echo "Setting PLMN to $plmn"
154 fi 91 fi
155 uqmi -s -d "$device" --set-plmn --mcc "$mcc" --mnc "$mnc" > /dev/null 2>&1 || { 92 uqmi -s -d "$device" --set-plmn --mcc "$mcc" --mnc "$mnc" || {
156 echo "Unable to set PLMN" 93 echo "Unable to set PLMN"
157 proto_notify_error "$interface" PLMN_FAILED 94 proto_notify_error "$interface" PLMN_FAILED
158 proto_block_restart "$interface" 95 proto_block_restart "$interface"
159 return 1 96 return 1
160 } 97 }
161 } 98 }
Line 162... Line 99...
162   99  
163 # Cleanup current state if any 100 # Cleanup current state if any
Line 164... Line 101...
164 uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect > /dev/null 2>&1 101 uqmi -s -d "$device" --stop-network 0xffffffff --autoconnect
165   102  
166 # Set IP format 103 # Set IP format
167 uqmi -s -d "$device" --set-data-format 802.3 > /dev/null 2>&1 104 uqmi -s -d "$device" --set-data-format 802.3
Line 168... Line 105...
168 uqmi -s -d "$device" --wda-set-data-format 802.3 > /dev/null 2>&1 105 uqmi -s -d "$device" --wda-set-data-format 802.3
Line 169... Line 106...
169 dataformat="$(uqmi -s -d "$device" --wda-get-data-format)" 106 dataformat="$(uqmi -s -d "$device" --wda-get-data-format)"
Line 177... Line 114...
177   114  
178 echo "Device does not support 802.3 mode. Informing driver of raw-ip only for $ifname .." 115 echo "Device does not support 802.3 mode. Informing driver of raw-ip only for $ifname .."
179 echo "Y" > /sys/class/net/$ifname/qmi/raw_ip 116 echo "Y" > /sys/class/net/$ifname/qmi/raw_ip
Line 180... Line 117...
180 fi 117 fi
Line 181... Line 118...
181   118  
182 uqmi -s -d "$device" --sync > /dev/null 2>&1 -  
183   119 uqmi -s -d "$device" --sync
184 echo "Waiting for network registration" 120  
185 local registration_timeout=0 -  
186 while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do -  
187 [ -e "$device" ] || return 1 121 echo "Waiting for network registration"
188 if [ "$registration_timeout" -lt "$timeout" ]; then -  
189 let registration_timeout++ -  
190 sleep 1; -  
191 else -  
192 echo "Network registration failed" -  
193 proto_notify_error "$interface" NETWORK_REGISTRATION_FAILED -  
194 proto_block_restart "$interface" 122 while uqmi -s -d "$device" --get-serving-system | grep '"searching"' > /dev/null; do
Line 195... Line 123...
195 return 1 123 [ -e "$device" ] || return 1
Line 196... Line 124...
196 fi 124 sleep 5;
Line 197... Line 125...
197 done 125 done
198   126  
Line 216... Line 144...
216 echo "Unable to obtain client ID" 144 echo "Unable to obtain client ID"
217 proto_notify_error "$interface" NO_CID 145 proto_notify_error "$interface" NO_CID
218 return 1 146 return 1
219 fi 147 fi
Line 220... Line 148...
220   148  
Line 221... Line 149...
221 uqmi -s -d "$device" --set-client-id wds,"$cid_4" --set-ip-family ipv4 > /dev/null 2>&1 149 uqmi -s -d "$device" --set-client-id wds,"$cid_4" --set-ip-family ipv4 > /dev/null
222   150  
223 pdh_4=$(uqmi -s -d "$device" --set-client-id wds,"$cid_4" \ 151 pdh_4=$(uqmi -s -d "$device" --set-client-id wds,"$cid_4" \
224 --start-network \ 152 --start-network \
225 ${apn:+--apn $apn} \ 153 ${apn:+--apn $apn} \
226 ${profile:+--profile $profile} \ 154 ${profile:+--profile $profile} \
227 ${auth:+--auth-type $auth} \ 155 ${auth:+--auth-type $auth} \
228 ${username:+--username $username} \ 156 ${username:+--username $username} \
Line 229... Line 157...
229 ${password:+--password $password} \ 157 ${password:+--password $password} \
230 ${autoconnect:+--autoconnect}) 158 ${autoconnect:+--autoconnect})
231   159  
232 # pdh_4 is a numeric value on success 160 # pdh_4 is a numeric value on success
233 if ! [ "$pdh_4" -eq "$pdh_4" ] 2> /dev/null; then 161 if ! [ "$pdh_4" -eq "$pdh_4" ] 2> /dev/null; then
234 echo "Unable to connect IPv4" 162 echo "Unable to connect IPv4"
235 uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds > /dev/null 2>&1 163 uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds
Line 236... Line 164...
236 proto_notify_error "$interface" CALL_FAILED 164 proto_notify_error "$interface" CALL_FAILED
237 return 1 165 return 1
238 fi 166 fi
239   167  
240 # Check data connection state 168 # Check data connection state
241 connstat=$(uqmi -s -d "$device" --get-data-status) 169 connstat=$(uqmi -s -d "$device" --get-data-status)
242 [ "$connstat" == '"connected"' ] || { 170 [ "$connstat" == '"connected"' ] || {
243 echo "No data link!" 171 echo "No data link!"
244 uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds > /dev/null 2>&1 172 uqmi -s -d "$device" --set-client-id wds,"$cid_4" --release-client-id wds
Line 245... Line 173...
245 proto_notify_error "$interface" CALL_FAILED 173 proto_notify_error "$interface" CALL_FAILED
246 return 1 174 return 1
247 } 175 }
248 } 176 }
249   177  
250 [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && { 178 [ "$pdptype" = "ipv6" -o "$pdptype" = "ipv4v6" ] && {
251 cid_6=$(uqmi -s -d "$device" --get-client-id wds) 179 cid_6=$(uqmi -s -d "$device" --get-client-id wds)
Line 252... Line 180...
252 if ! [ "$cid_6" -eq "$cid_6" ] 2> /dev/null; then 180 if ! [ "$cid_6" -eq "$cid_6" ] 2> /dev/null; then
Line 253... Line 181...
253 echo "Unable to obtain client ID" 181 echo "Unable to obtain client ID"
254 proto_notify_error "$interface" NO_CID 182 proto_notify_error "$interface" NO_CID
255 return 1 183 return 1
256 fi 184 fi
257   185  
258 uqmi -s -d "$device" --set-client-id wds,"$cid_6" --set-ip-family ipv6 > /dev/null 2>&1 186 uqmi -s -d "$device" --set-client-id wds,"$cid_6" --set-ip-family ipv6 > /dev/null
259   187  
260 pdh_6=$(uqmi -s -d "$device" --set-client-id wds,"$cid_6" \ 188 pdh_6=$(uqmi -s -d "$device" --set-client-id wds,"$cid_6" \
Line 261... Line 189...
261 --start-network \ 189 --start-network \
262 ${apn:+--apn $apn} \ 190 ${apn:+--apn $apn} \
263 ${profile:+--profile $profile} \ 191 ${profile:+--profile $profile} \
264 ${auth:+--auth-type $auth} \ 192 ${auth:+--auth-type $auth} \
265 ${username:+--username $username} \ 193 ${username:+--username $username} \
266 ${password:+--password $password} \ 194 ${password:+--password $password} \
267 ${autoconnect:+--autoconnect}) 195 ${autoconnect:+--autoconnect})
Line 268... Line 196...
268   196  
269 # pdh_6 is a numeric value on success 197 # pdh_6 is a numeric value on success
270 if ! [ "$pdh_6" -eq "$pdh_6" ] 2> /dev/null; then 198 if ! [ "$pdh_6" -eq "$pdh_6" ] 2> /dev/null; then
271 echo "Unable to connect IPv6" 199 echo "Unable to connect IPv6"
272 uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds > /dev/null 2>&1 200 uqmi -s -d "$device" --set-client-id wds,"$cid_6" --release-client-id wds
273 proto_notify_error "$interface" CALL_FAILED 201 proto_notify_error "$interface" CALL_FAILED
274 return 1 202 return 1
275 fi 203 fi
276   204  
Line 277... Line 205...
277 # Check data connection state 205 # Check data connection state
278 connstat=$(uqmi -s -d "$device" --get-data-status) 206 connstat=$(uqmi -s -d "$device" --get-data-status)
279 [ "$connstat" == '"connected"' ] || { 207 [ "$connstat" == '"connected"' ] || {
Line 322... Line 250...
322 else 250 else
323 json_init 251 json_init
324 json_add_string name "${interface}_6" 252 json_add_string name "${interface}_6"
325 json_add_string ifname "@$interface" 253 json_add_string ifname "@$interface"
326 json_add_string proto "dhcpv6" 254 json_add_string proto "dhcpv6"
327 [ -n "$ip6table" ] && json_add_string ip6table "$ip6table" -  
328 proto_add_dynamic_defaults 255 proto_add_dynamic_defaults
329 # RFC 7278: Extend an IPv6 /64 Prefix to LAN 256 # RFC 7278: Extend an IPv6 /64 Prefix to LAN
330 json_add_string extendprefix 1 257 json_add_string extendprefix 1
331 json_close_object 258 json_close_object
332 ubus call network add_dynamic "$(json_dump)" 259 ubus call network add_dynamic "$(json_dump)"
Line 336... Line 263...
336 [ -n "$pdh_4" ] && { 263 [ -n "$pdh_4" ] && {
337 json_init 264 json_init
338 json_add_string name "${interface}_4" 265 json_add_string name "${interface}_4"
339 json_add_string ifname "@$interface" 266 json_add_string ifname "@$interface"
340 json_add_string proto "dhcp" 267 json_add_string proto "dhcp"
341 [ -n "$ip4table" ] && json_add_string ip4table "$ip4table" -  
342 proto_add_dynamic_defaults 268 proto_add_dynamic_defaults
343 json_close_object 269 json_close_object
344 ubus call network add_dynamic "$(json_dump)" 270 ubus call network add_dynamic "$(json_dump)"
345 } 271 }
346 } 272 }