Verified Commit 8ce45ae7 authored by Martin Prudek's avatar Martin Prudek
Browse files

mbim: Replace "ifconfig" by iproute2

parent 0dfbc7c0
#!/bin/sh
mask="0"
[ -n "$INCLUDE_ONLY" ] || {
. /lib/functions.sh
. ../netifd-proto.sh
......@@ -21,19 +19,9 @@ proto_mbim_init_config() {
proto_config_add_string password
}
# https://stackoverflow.com/questions/20762575
cdr2mask ()
{
# Number of args to shift, 255..255, first non-255 byte, zeroes
set -- $(( 5 - ($1 / 8) )) 255 255 255 255 $(( (255 << (8 - ($1 % 8))) & 255 )) 0 0 0
[ $1 -gt 1 ] && shift $1 || shift
# echo "MASK: ${1-0}.${2-0}.${3-0}.${4-0}"
mask=${1-0}.${2-0}.${3-0}.${4-0}
}
parse_config ()
{
IP=$(cat /tmp/ip |grep ipv4address |grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
NM=$(cat /tmp/ip |grep ipv4address |grep -o '.\{2\}$')
IP=$(cat /tmp/ip |grep ipv4address |grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/([0-9]|[1-2][0-9]|3[0-2])")
GW=$(cat /tmp/ip |grep ipv4gateway |grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)")
DNS=$(cat /tmp/ip |grep ipv4dnsserver |grep -E -o "(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)" |head -1)
}
......@@ -129,15 +117,13 @@ _proto_mbim_setup() {
echo "$CONFIG" > /tmp/ip
parse_config
cdr2mask $NM
echo "mbim[$$]" "Connected, setting IP"
proto_init_update "$ifname" 1
proto_send_update "$interface"
ifconfig wwan0 $IP netmask $mask
ip address add $IP dev wwan0
ip route add default dev wwan0
# ifup wwan0
echo "nameserver $DNS" >> /tmp/resolv.conf.auto
echo "nameserver $DNS" >> /etc/resolv.conf
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment