summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2016-06-30 10:00:40 +0200
committerAleksander Morgado <aleksander@aleksander.es>2016-06-30 10:10:37 +0200
commit9eaf56e87ecd715ab9922e17b700dd5804884263 (patch)
treea30324f1a7dddb5378ebdcd6e4c261107975a65a
parent506052b608c0ee55b27cb69028b7606de3fb5927 (diff)
downloadlibmbim-9eaf56e87ecd715ab9922e17b700dd5804884263.tar.gz
mbim-network: allow specifying APN user/password in profile
-rwxr-xr-xutils/mbim-network.in54
1 files changed, 51 insertions, 3 deletions
diff --git a/utils/mbim-network.in b/utils/mbim-network.in
index 88393ac..1eea201 100755
--- a/utils/mbim-network.in
+++ b/utils/mbim-network.in
@@ -55,7 +55,17 @@ help ()
echo " following way (e.g. assuming APN is called 'internet'):"
echo " APN=internet"
echo
- echo " 4) Once the mbim-network script reports a successful connection"
+ echo " 4) Optional APN user/password strings may be given in the"
+ echo " following way:"
+ echo " APN_USER=user"
+ echo " APN_PASS=password"
+ echo
+ echo " 5) If APN user/password is specified, the authentication protocol"
+ echo " to use (one of PAP, CHAP or MSCHAPV2) must also be specified in"
+ echo " the following way:"
+ echo " APN_AUTH=protocol"
+ echo
+ echo " 6) Once the mbim-network script reports a successful connection"
echo " you still need to run a DHCP client on the associated WWAN network"
echo " interface."
echo
@@ -140,6 +150,34 @@ load_profile ()
if [ -n "$APN" ]; then
echo " APN: $APN"
+ else
+ echo " APN: unset"
+ fi
+
+ if [ -n "$APN_AUTH" ]; then
+ echo " APN auth protocol: $APN_AUTH"
+ else
+ echo " APN auth protocol: unset"
+ fi
+
+ if [ -n "$APN_USER" ]; then
+ echo " APN user: $APN_USER"
+ if [ -z "$APN_AUTH" ]; then
+ echo "error: APN_USER in the profile requires APN_AUTH" 1>&2
+ exit 32
+ fi
+ else
+ echo " APN user: unset"
+ fi
+
+ if [ -n "$APN_PASS" ]; then
+ echo " APN password: $APN_PASS"
+ if [ -z "$APN_USER" ]; then
+ echo "error: APN_PASS in the profile requires APN_USER" 1>&2
+ exit 32
+ fi
+ else
+ echo " APN password: unset"
fi
else
echo "Profile at '$PROFILE_FILE' not found..."
@@ -217,7 +255,6 @@ connect ()
save_state "TRID" $TRID
fi
-
REGISTRATION_STATE_CMD="mbimcli -d $DEVICE --query-registration-state --no-open=$TRID --no-close"
echo "Querying registration state '$REGISTRATION_STATE_CMD'..."
@@ -241,7 +278,18 @@ connect ()
save_state "TRID" $TRID
fi
- CONNECT_CMD="mbimcli -d $DEVICE --connect=$APN --no-open=$TRID --no-close"
+ CONNECT_ARGS="apn='$APN'"
+ if [ -n "$APN_AUTH" ]; then
+ CONNECT_ARGS="${CONNECT_ARGS},auth='$APN_AUTH'"
+ if [ -n "$APN_USER" ]; then
+ CONNECT_ARGS="${CONNECT_ARGS},username='$APN_USER'"
+ if [ -n "$APN_PASS" ]; then
+ CONNECT_ARGS="${CONNECT_ARGS},password='$APN_PASS'"
+ fi
+ fi
+ fi
+
+ CONNECT_CMD="mbimcli -d $DEVICE --connect=$CONNECT_ARGS --no-open=$TRID --no-close"
echo "Starting network with '$CONNECT_CMD'..."
CONNECT_OUT=`$CONNECT_CMD`