Commit Graph

223 Commits

Author SHA1 Message Date
Richard Röjfors 88ee0123ab gprs: Do not detach when running LTE and GPRS is unavailable.
There are cases where the gprs status might updated to for instance
"unknown" while LTE is the bearer.
In that case we should not set the attach state to FALSE,
since then running LTE the conext activation reflects the attached
state.
2019-08-12 15:45:40 -05:00
Richard Röjfors 5752702cbe gprs: Do not leak CID on failure to assign context 2019-08-07 17:10:17 -05:00
Richard Röjfors d4ced627e0 gprs: Use -1 as netreg status during init.
Previously the valid "unknown" netreg status was set
during startup, but its a bit problematic for gprs.
There might be cases where a LTE context is activated
before netreg is finished updating its status.
Resulting in gprs taking faulty actions.
Instead we set the status to -1 until we are updated
with a known value.
During the time the status is -1, gprs postpones actions until
the status is valid (>= 0).
2019-08-07 16:54:25 -05:00
Denis Kenzior 5d3640397a core: Quiet warning about strncpy use 2019-05-16 15:10:40 -05:00
Denis Kenzior ca9d5b73ab gprs: Remove unneeded if conditions
ctx->message_center and ctx->message_proxy are arrays and thus
always evaluate as true
2019-04-29 19:30:22 -05:00
Denis Kenzior c56bd74cb1 gprs: Fix invalid string comparison
The default context created when provisioning fails is simply a context
with an empty APN
2019-04-29 19:27:29 -05:00
Denis Kenzior 91253a1ade gprs: Remove unneeded if statement
if (ctx->message_proxy) always resolves to TRUE
2019-04-29 19:25:57 -05:00
Alexander Couzens d604052cef gprs: netreg_status_changed: output the status as human readable string 2019-04-28 10:13:51 -05:00
Richard Röjfors 05aaab72ae gprs: Always store RoamingAllowed as a boolean.
In one instance it was stored as boolean and another as int.
Since its always parsed as a boolean and it is a boolean,
always store it as boolean.
2019-04-16 11:46:00 -05:00
Richard Röjfors b9fdba531f gprs: Fix allocation of context id read from settings
This fix is similar to the one in the following commit,
but fixes allocation for context ids after ap's are
read from settings.

commit c3fdf6a7c5
Author: Denis Kenzior <denkenz@gmail.com>
Date:   Thu Jan 3 17:17:21 2019 -0600

    gprs: Fix allocation of context id
2019-04-02 10:41:16 -05:00
Antara Borwankar 608c683250 gprs-context: Adding get function for inteface
Added definition of get function to get interface value in
gprs-context
2019-02-21 11:00:04 -06:00
Denis Kenzior 13c0e25eb2 gprs: Let gprs_context interface be settable once
This patch allows a driver to set the interface only once, instead of at
every context activation.  The previous way was originally designed for
PPP and RAW_IP based contexts which would have a (potentially)
differently named interface after each context activation due to use of
TUN/TAP.  This also worked for static high-speed interface setups as
well, since these usually had a single interface only.

For devices that support multiple high-speed interfaces it would be
advantageous to have each gprs_context get an interface assignment right
in the modem driver and skip having to setup the interface on every
activation.
2019-02-11 17:51:16 -06:00
Denis Kenzior c3fdf6a7c5 gprs: Fix allocation of context id
After the convertion to l_uintset, the creation of new contexts fails
due to a range error being returned from l_uintset_find_unused().

The error happens because the uinset is created with a min-value of 1,
but the start-value passed to l_uintset_find_unused() is initialized as
0.

Reported-by: Martin Hundebøll <martin@geanix.com>
2019-01-03 17:17:21 -06:00
Denis Kenzior ab55f2f811 gprs: Use l_uintset instead of idmap 2018-12-19 14:46:08 -06:00
Giacinto Cifelli 597ab6683f common: Move proto and auth_method related helpers
the following functions:
	gprs_proto_to_string
	gprs_proto_from_string
	gprs_auth_method_to_string
	gprs_auth_method_from_string

are moved from gprs.c to common.c, with related declaration in common.h
so that they can also be accessed from lte core functions
2018-10-09 15:10:25 -05:00
Giacinto Cifelli cc79162470 gprs: support for NONE auth type 2018-10-09 10:43:01 -05:00
Giacinto Cifelli 460040f427 gprs: make sure that the context is properly released 2018-09-20 11:05:06 -05:00
Giacinto Cifelli ce6c1087a2 gprs: Fix use of invalid operator for bitwise flags 2018-09-20 10:28:15 -05:00
Denis Kenzior f8d6a0a668 gprs: Add implementation of set_ipv4_prefix_length 2017-11-13 21:24:37 -06:00
Denis Kenzior 97e39299d0 gprs: Set Attached if no .read_settings
Some protocols (like MBIM) do not properly support default bearer
semantics.  Instead they want everything to function like UMTS/GSM where
the context has to be explicitly attached / activated.
2017-11-13 21:24:37 -06:00
Alexander Couzens d08a6043a3 gprs: use registration_status_to_string in debug messages 2017-09-07 16:50:51 -05:00
Alexander Couzens 7d27ccea5e common: move strlen(apn) check into is_valid_apn() 2017-09-05 10:41:05 -05:00
Denis Kenzior d9cb969dcf gprs: Don't use pri_set_apn for auto activated cids
There are two problems with using pri_set_apn.  The first issue is that
this function was built to be used by the set_property handler and
assumes the presence of a pending DBusMessage.

The second issue is that it touches the settings store.

In the case of auto-activated contexts no pending message exists.  Also,
we should not be touching the settings store as the APN might
potentially be a value that has not been provisioned.  Or in some cases
bogus.
2017-05-09 11:33:07 -05:00
Denis Kenzior 24f36da04d gprs: Return after releasing pri_ctx 2017-05-09 11:33:07 -05:00
Jonas Bonn 0167c3339c gprs: set driver_attached when activating automatic contexts
The ofono_gprs_cid_activated attachment machinery cannot go through
ofono_gprs_status_notify for getting the attached property set because
that would result in the automatic contexts that were just set up
being released.  As such, it needs to call gprs_set_attached_property
manually.  Doing so, however, means that the driver_attached property
never gets set, resulting in all contexts being released when the
network transitions between registered states (roaming/non-roaming).
2017-04-14 17:43:13 -05:00
Jonas Bonn 1fd419e5b4 gprs: _cid_activated is an 'attaching' state
ofono_gprs_status_notify is an asynchronous notification that messes
with the 'attached' state of the GPRS atom.  This method is normally
prevented from running while an attach is in progress because the
attachment machinery wants to finish up and make it's own determination
of attach state.

When automatic context activation is relevant, as for LTE networks,
the ofono_gprs_cid_activated machinery replaces the usual set_attach
machinery for attaching to the network.  The cid_activated variant,
however, does not guard against simulatenous invocations of
ofono_gprs_status_notify.  This causes a race whereby status_notify
sets the state to 'attached' before the context is fully constructed
and set to active.  If the connection manager sees the 'attached'
state before there are any 'active' contexts, it may decide to
activate a context manually which is not the correct behaviour for
this type of network.

This patch makes the *_cid_activated machinery an 'attaching' state,
introducing the same guards that set_attached has to prevent
ofono_gprs_status_notify from running concurrently.
2017-04-14 17:28:46 -05:00
Christophe Ronco d43e48ae73 gprs: fix error check of gprs_cid_alloc function
When there is no context id available, idmap_alloc and
gprs_cid_alloc return max + 1.
2017-02-15 14:39:36 -06:00
Dragos Tatulea c2b489dca8 gprs: lte: set attached after successful activation
Otherwise the attached state gets to be set before the actual LTE
automatic context is ready. This triggers a race between connman
and ofono: connman sees status attached before the context is active
so connman will try to activate another context with same apn and will
fail over and over again.
2016-11-22 10:51:09 -06:00
Slava Monich 27a9428eec gprs: Check GPRS_FLAG_ATTACHED_UPDATE
... in pri_deactivate_callback

This prevents attached state from getting stuck at 0 like this:

1. Context deactivation is initiated over D-Bus, ctx->pending is set
2. Attached becomes FALSE, context is still marked as active
3. Attached becomes TRUE, gprs_attached_update sets GPRS_FLAG_ATTACHED_UPDATE
4. Deactivation completes, attached is 0, driver_attached is 1

Futher network status updates don't call gprs_attached_update because
driver_attached is still 1, so attached is staying 0 until we lose the
data registration again which may not happen for quite a long time.
2016-11-03 14:24:41 -05:00
Caiwen Zhang 20d8cf9495 gprs: fix crash removing a context being activated
If remove the context before context activation is completed, it may
cause a crash.
2016-11-01 11:29:37 -05:00
Alfonso Sanchez-Beato 154f4aca65 gprs: Deactivate old contexts on attach
In some cases it is possible that a context is opened after a detach
event has been received, and right before an attach, depending on the
modem. We make sure that those contexts are removed to keep
consistency.
2016-04-04 14:48:05 -05:00
Dragos Tatulea a4cfaa1b6c gprs: assume attached state when registered on LTE
LTE doesn't really use the concept of an attached state. However,
the oFono API needs it. ConnMan needs it as well.
2016-03-21 10:59:44 -05:00
Dragos Tatulea e71b3b265a gprs: implement ofono_gprs_cid_activated
It works by looking for a context with the same APN and tries to use
that. Otherwise it will create it's own.

Then it assigns a gprs context driver and calls it's read_settings if
it exists.
2016-03-18 10:08:08 -05:00
Dragos Tatulea 9173d7e2e4 gprs: pri_set_apn: make reply msg optional
Automatic context activation will set the apn by itself. No
dbus message to reply to.
2016-03-17 12:39:24 -05:00
Dragos Tatulea 02dcc2f36e gprs: custom cid for assign_context
It's optional though. If 0 a cid is picked up automatically from the
allowed range.
2016-03-17 12:27:17 -05:00
John Ernberg ff476aa06f gprs: Fix the ContextAdded() signal Introspection
This matches the behavior described by the documentation the signal
value returned by the code. This was causing a headache when using
stricter D-Bus wrappers like dbus-c++.
2015-12-22 10:23:44 -06:00
Denis Kenzior 133165b5ca gprs: Implement ofono_gprs_context_get_type 2015-12-13 22:20:58 -06:00
Denis Kenzior 6fbb1e18f8 gprs: Implement ofono_gprs_get_modem 2015-12-03 13:23:28 -06:00
Denis Kenzior 418ca19f25 gprs: Allow synchronous callbacks for set_attached 2015-11-13 16:08:32 -06:00
Tony Espy f2f279b28d src: make bearer/operator enums public
Move enums for operator_status and packet_bearer to common.h to avoid
duplication in drivers.
2015-10-13 16:00:17 -05:00
Denis Kenzior dbb3ec13e5 gprs: Try re-attaching when we switch cells 2015-07-20 13:51:29 -05:00
Alfonso Sanchez-Beato e70afdd9dc gprs: Add comment to gprs_reset_contexts 2015-05-18 12:13:04 -05:00
Alfonso Sanchez-Beato 946b568f43 gprs: Refactor to remove forward declaration 2015-05-18 09:08:33 -05:00
Alfonso Sanchez-Beato 444611c086 gprs: Add DBus method to reset contexts
Add DBus method that removes the current contexts and re-provisions
using the APN database.
2015-05-18 09:08:13 -05:00
Philip Paeps c144fadca6 gprs: provision the authentication method 2014-06-24 12:46:18 -05:00
Denis Kenzior 3e13676766 gprs: Make the code a bit easier to read 2014-06-21 12:02:05 -05:00
Philip Paeps 73831c3d76 gprs: make PPP authentication method configurable
Add a new "AuthenticationMethod" property to select between "pap"
and "chap" PPP authentication, defaulting to "chap" (i.e.: previous
behaviour).
2014-06-21 11:58:03 -05:00
Christopher Vogl df05259e90 gprs: fix bearer dbus signal interface
According to the documentation the data bearer property should be
located on interface org.ofono.ConnectionManager.
2012-08-13 09:48:50 -05:00
Guillaume Zajac 05b8fe4794 gprs: Call detach_shutdown when network is lost 2012-07-15 20:05:23 -05:00
Marcel Holtmann 0d4e80c002 gprs: Avoid shadowing error variable 2012-07-15 20:26:12 -03:00