Commit Graph

1755 Commits

Author SHA1 Message Date
Marcel Holtmann 2a5c9cf0f2 mbimmodem: Convert back to using __builtin_bswap16 with proper indexing 2018-10-31 21:03:49 +01:00
Marcel Holtmann 2df69194ac mbimmodem: Fix conversion of strings into UTF16-LE on big endian 2018-10-31 21:00:38 +01:00
Marcel Holtmann 63ed2c2080 mbimmodem: Fix endian issue with UTF16-LE to UTF16-CPU conversion 2018-10-31 20:42:14 +01:00
Denis Kenzior 4029ef3a11 mbimmodem: Fix compilation on 32-bit
CC       drivers/mbimmodem/mbim.o
drivers/mbimmodem/mbim.c: In function ‘command_write_handler’:
drivers/mbimmodem/mbim.c:490:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘size_t’ [-Wformat=]
   l_info("n_iov: %lu, %lu", n_iov + 1, (size_t) written);
   ^
drivers/mbimmodem/mbim.c:490:3: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 7 has type ‘unsigned int’ [-Wformat=]
drivers/mbimmodem/mbim.c: In function ‘command_read_handler’:
drivers/mbimmodem/mbim.c:649:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘size_t’ [-Wformat=]
  l_info("header_offset: %lu", device->header_offset);
  ^
drivers/mbimmodem/mbim.c:650:2: warning: format ‘%lu’ expects argument of type ‘long unsigned int’, but argument 6 has type ‘size_t’ [-Wformat=]
  l_info("segment_bytes_remaining: %lu", device->segment_bytes_remaining);
  ^
2018-10-31 14:20:00 -05:00
Marcel Holtmann 8452a7f349 build: Add support for internal and external Embedded Linux library 2018-10-31 19:58:10 +01:00
Giacinto Cifelli d7bb1d9254 atmodem: remove vendor Cinterion 2018-10-29 15:01:50 -05:00
Giacinto Cifelli 713585963f atmodem: Change cinterion prefix to gemalto 2018-10-29 15:00:44 -05:00
Giacinto Cifelli a429950f2f atmodem: change vendor cinterion to gemalto 2018-10-29 15:00:05 -05:00
Jonas Bonn a1141ae393 qmimodem: prevent use of unitialized variable
'index' may not be initialized in the error path so don't try to print a
message with it.
2018-10-29 13:35:01 -05:00
Jonas Bonn 1e176755af atmodem: enlarge command buffer
The ofono phone number max length is 80 so a buffer size of 64 is
obviously insufficient.  Expanding the buffer to 128 prevents a
potential failure and suppresses the folowing compiler warning:

../drivers/atmodem/sms.c: In function ‘at_csca_set’:
../drivers/atmodem/sms.c:108:40: warning: ‘%s’ directive output may be truncated writing up to 80 bytes into a region of size 55 [-Wformat-truncation=]
  snprintf(buf, sizeof(buf), "AT+CSCA=\"%s\",%d", sca->number, sca->type);
                                        ^~
../drivers/atmodem/sms.c:108:2: note: ‘snprintf’ output between 13 and 103 bytes into a destination of size 64
  snprintf(buf, sizeof(buf), "AT+CSCA=\"%s\",%d", sca->number, sca->type);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2018-10-29 13:33:56 -05:00
Denis Kenzior dd6ae48d19 atmodem: Make sure to use none_prefix
Otherwise all unsolicited notifications would also be consumed when
invoking +CGAUTH/+CGDCONT
2018-10-25 13:51:57 -05:00
Giacinto Cifelli c1f7135261 atmodem: Add proto and authentication handling to lte
The ofono_lte_default_attach_info now handles also the protocol and the
authentication method, username and password.

Co-authored-by: Martin Baschin <martin.baschin@googlemail.com>
2018-10-25 11:15:59 -05:00
Giacinto Cifelli eed785a4d7 atmodem: Add reference counting to cb_data
the cb_data can be used by creating the structure with cb_data_new,
and then there are two possibilities:
- use it in a single callback function, and destroy it with a call to
  g_free.
  Example:
  - calling function:
    struct cb_data *cbd = cb_data_new(cb, data);
    if (g_at_chat_send(chat, buf, NULL, at_cgatt_cb, cbd, g_free) > 0)
	return;
    g_free(cbd);
  - called function (here at_cgatt_cb):
	static void at_cgatt_cb(gboolean ok, GAtResult *result,
						gpointer user_data)
	{
		struct cb_data *cbd = user_data;
		ofono_gprs_cb_t cb = cbd->cb;
		struct ofono_error error;

		decode_at_error(&error,
				g_at_result_final_response(result));

		cb(&error, cbd->data);
	}
    note the absence of explicit g_free(cbd);

- pass it through a train of callback functions, adding a reference at
  each pass cb_data_ref, and removing it with cb_data_unref.
  the use of cb_data_ref would replace a new object creation, while the
  use of cb_data_unref the use of g_free.
  Example:
  - calling function:
	struct cb_data *cbd = cb_data_new(cb, data);
	// no cb_ref at the creation
	if (g_at_chat_send(chat, buf, NULL,
				at_lte_set_default_attach_info_cb,
				cbd, cb_data_unref) > 0)
		goto end;
	cb_data_unref(cbd);
  - called function 1 (at_lte_set_default_attach_info_cb):
	static void at_lte_set_default_attach_info_cb(gboolean ok,
				GAtResult *result, gpointer user_data)
	{
		struct cb_data *cbd = user_data;

		cbd = cb_data_ref(cbd);
		if (g_at_chat_send(chat, buf, NULL,
				at_cgatt_cb, cbd, cb_data_unref) > 0)
			return;
		cb_data_unref(cbd);
	}
  - called function 2 (at_cgatt_cb):
    like above. no call to g_free or cb_data_unref. The terminal function
    doesn't need to know about the reference scheme.
2018-10-25 10:55:09 -05:00
Giacinto Cifelli 92bf7fb867 atmodem: added Gemalto vendor quirk for +CNMI 2018-10-23 09:54:59 -05:00
Giacinto Cifelli 0d9a380ea0 atmodem: Add at_util_get_cgdcont_command
The function at_util_get_cgdcont_command computes the AT+CGDCONT
string, as per 3GPP 27.007.
It uses a second function, at_util_gprs_proto_to_pdp_type,
that returns the pdp_type string for the command
2018-10-22 15:05:38 -05:00
Giacinto Cifelli 0208c10e9b atmodem: Add at_util_gprs_auth_method_to_auth_proto
This function converts the ofono enum ofono_gprs_auth_method
into the value of the 3GPP 27.007 'auth_proto' variable of +CGAUTH so
that it can be passed directly to the AT command.
2018-10-22 15:01:51 -05:00
Giacinto Cifelli b18560441d gemalto: Add Gemalto specific voicecall atom
This atom uses the URC ^SLCC to monitor the call status, as well as
incoming calls.
Note the use in the atom of the variable GemaltoVtsQuotes: this is
needed to support future modules, as of today not yet available in the
plugin.
2018-10-17 17:03:03 -05:00
Jonas Bonn 3beeff758d treewide: Remove superfluous use of _GNU_SOURCE
There are a large number of files in the tree that define _GNU_SOURCE
despite not actually using features hidden behind this flag.  This patch
removes all these definitions in one fell swoop...
2018-10-17 10:01:57 -05:00
Jonas Bonn 67701b1c40 drivers: constify vtables
The driver vtables are read-only structures.  This patch declares them as
'const' allowing the compiler to (optionally) put them in the RELRO
section.  RELRO pages may be marked as read-only by the linker after
the relocations have been done ensuring that they aren't inadvertently
or maliciously altered at runtime.
2018-10-17 09:56:27 -05:00
Denis Kenzior 352a9f4b23 xmm7modem: Fix memory leak in netmon 2018-10-12 13:45:23 -05:00
Antara a4a7e553dc netmon: Added netmon driver for xmm7modem
adding netmon driver for xmm7modem which uses intel proprietary
AT command +XMCI
2018-10-09 12:54:24 -05:00
Giacinto Cifelli bd6f807849 drivers: support for auth NONE
Added the explicit support for auth NONE.
It needs to be added in all drivers/*/gprs-context.c atoms.

This method is already supported by all atoms that support
authentication (ie, all but Sierra' swmodem driver).

The behavior is left unchanged in case of inconsistent parameters:
if username is empty, then fallback to auth NONE.
2018-10-09 12:35:44 -05:00
Anirudh Gargi 4b44fb3910 gprs: fix seg fault in case of NULL callback
In case of AT callback if callback handler is NULL, check for null
before calling the success macro.

Logs:
ofonod[32496]: src/network.c:current_operator_callback() 0x157ad60, (nil)
ofonod[32496]: src/gprs.c:netreg_status_changed() 0
ofonod[32496]: src/gprs.c:gprs_netreg_update() attach: 0, driver_attached: 1
ofonod[32496]: src/gprs.c:ofono_gprs_detached_notify() /xmm7xxx_0
ofonod[32496]: drivers/ifxmodem/gprs-context.c:ifx_gprs_detach_shutdown()
ofonod[32496]: drivers/ifxmodem/gprs-context.c:ifx_gprs_deactivate_primary() cid 0
ofonod[32496]: src/gprs.c:ofono_gprs_detached_notify() /xmm7xxx_0
ofonod[32496]: src/gprs.c:gprs_attach_callback() /xmm7xxx_0 error = 0
ofonod[32496]: drivers/ifxmodem/gprs-context.c:deactivate_cb() ok 0
ofonod[32496]: Aborting (signal 11) [./../src/ofonod]
ofonod[32496]: ++++++++ backtrace ++++++++
ofonod[32496]: +++++++++++++++++++++++++++
2018-10-01 14:46:35 -05:00
Anirudh Gargi 276330abc4 atmodem: add EUTRAN tech for creg read status
Add handling for CREG's status to get the technology type. CREG
notify URC does not need additional handling as 'AcT' is mapped
one-on-one to tech.
2018-09-27 07:35:17 -05:00
Giacinto Cifelli 579e9dd3ec atmodem/sms: no mms support for Gemalto 2018-09-27 07:32:03 -05:00
Giacinto Cifelli df5bc68fcf atmodem: change vendor CINTERION in GEMALTO in sms 2018-09-25 09:44:30 -05:00
Giacinto Cifelli 66e9a30040 atmodem: change vendor CINTERION to GEMALTO in sim 2018-09-25 09:39:56 -05:00
Giacinto Cifelli 9556d7bd78 atmodem: added Gemalto vendor to CBS CSCB logic 2018-09-24 15:57:58 -05:00
Giacinto Cifelli abd219c89f atmodem/sms: Do not print an error message incorrectly
add missing return in at_cmt_notify.  Without it an error message was
generated in all cases, even successful ones.
2018-09-20 10:50:44 -05:00
Giacinto Cifelli 9f747730a8 mbim: fix calling mbim_sms_exit instead of _init 2018-09-20 10:49:06 -05:00
Giacinto Cifelli c269d92fac atmodem: added vendor Gemalto 2018-09-20 10:22:31 -05:00
Christophe Ronco 157d188587 qmimodem: fix roaming status report
Problem seen with a MC7304 modem and a roaming SIM card.
Status in org.ofono.NetworkRegistration properties ends up in "registered"
instead of roaming. Both AT command and qmicli indicates we are roaming.

What's happening is the following:

1) first QMI_NAS_SS_INFO_IND indicating we are registered contains a
QMI_NAS_RESULT_ROAMING_STATUS parameter.
Parameter inside says we are roaming and qmimidem driver correctly reports
status NETWORK_REGISTRATION_STATUS_ROAMING.
2) other QMI_NAS_SS_INFO_IND arrive, saying we are registered without
QMI_NAS_RESULT_ROAMING_STATUS parameter.
Driver reports NETWORK_REGISTRATION_STATUS_REGISTERED.

Extract of traces with QMI binary debug interpreted (as far as I can...):
a) first "searching" indication
ofonod[855]: QMI: < 01 3b 00 80 03 01 04 00 00 24 00 2f 00
29 05 00 d0 00 14 00 00 MCC:208 MNC:20
22 05 00 01 02 00 01 00 Detailed Service Status:
                        QMI_NAS_SERVICE_STATUS_LIMITED,
                        QMI_NAS_NETWORK_SERVICE_DOMAIN_PS, ...
15 03 00 01 08 01 LTE, no roaming
12 05 00 d0 00 14 00 00 Current PLMN: MCC:208 MNC:20, no desc
11 01 00 00
10 01 00 01 No roaming
01 06 00 02 02 02 02 01 08 NAS_REGISTRATION_STATE_NOT_REGISTERED_SEARCHING,
                           CS detached, PS detached, NETWORK_TYPE_3GPP,
                           QMI_NAS_RADIO_INTERFACE_LTE
ofonod[855]: QMI: NAS_ind msg=36 len=47 [client=1,type=4,tid=0,len=59]
ofonod[855]: QMI: {type=41,len=5} {type=34,len=5} {type=21,len=3}
             {type=18,len=5}
ofonod[855]: QMI: {type=17,len=1} {type=16,len=1} {type=1,len=6}
ofonod[855]: ofono_netreg_status_notify modem /sierra_0 status 2 lac -1
             cellid -1 tech 7

b) second "searching" indication
ofonod[855]: QMI: < 01 21 00 80 03 01 04 00 00 24 00 15 00
22 05 00 03 03 00 01 00 Detailed Service Status:
                        QMI_NAS_SERVICE_STATUS_LIMITED_REGIONAL, CS_PS, ...
11 01 00 00
01 06 00 02 02 02 02 01 08 NAS_REGISTRATION_STATE_NOT_REGISTERED_SEARCHING,
                           CS detached, PS detached, NETWORK_TYPE_3GPP,
                           QMI_NAS_RADIO_INTERFACE_LTE

ofonod[855]: QMI: NAS_ind msg=36 len=21 [client=1,type=4,tid=0,len=33]
ofonod[855]: QMI: {type=34,len=5} {type=17,len=1} {type=1,len=6}

c) First indication while "registered"
ofonod[855]: QMI: < 01 5e 00 80 03 01 04 00 00 24 00 52 00
2a 01 00 00
29 05 00 d0 00 14 00 00 MCC:208 MNC:20
28 02 00 15 01 UMTS Primary Scrambling Code
26 08 00 03 00 00 00 03 00 00 00 CS: all calls allowed,
                                 PS: all calls allowed
22 05 00 02 03 00 01 00 Detailed Service Status:
                        QMI_NAS_SERVICE_STATUS_AVAILABLE, CS_PS, ...
1e 04 00 f7 00 95 04 CID 3GPP
1d 02 00 fb 50 LAC 3GPP
15 03 00 01 05 00 UMTS: roaming
12 05 00 d0 00 14 00 00 Current PLMN: MCC:208 MNC:20, no desc
11 04 00 03 03 04 05
10 01 00 00 ROAMING ON
01 06 00 01 01 01 02 01 05 NAS_REGISTRATION_STATE_REGISTERED, CS attached,
                           PS attached, NETWORK_TYPE_3GPP,
                           QMI_NAS_RADIO_INTERFACE_UMTS
ofonod[855]: QMI: NAS_ind msg=36 len=82 [client=1,type=4,tid=0,len=94]
ofonod[855]: QMI: {type=42,len=1} {type=41,len=5} {type=40,len=2}
             {type=38,len=8}
ofonod[855]: QMI: {type=34,len=5} {type=30,len=4} {type=29,len=2}
             {type=21,len=3}
ofonod[855]: QMI: {type=18,len=5} {type=17,len=4} {type=16,len=1}
             {type=1,len=6}
ofonod[855]: ofono_gprs_status_notify modem /sierra_0 status 1

==================> ROAMING status reported <==========================
ofonod[855]: ofono_netreg_status_notify modem /sierra_0 status 5 lac 20731
             cellid 76873975 tech 2

d) second indication while "registered"
ofonod[855]: QMI: < 01 31 00 80 03 01 04 00 00 24 00 25 00
29 05 00 d0 00 14 00 00 MCC:208 MNC:20
28 02 00 15 01 UMTS Primary Scrambling Code
12 05 00 d0 00 14 00 00 Current PLMN: MCC:208 MNC:20, no desc
11 04 00 03 03 04 05
01 06 00 01 01 01 02 01 05 NAS_REGISTRATION_STATE_REGISTERED, CS attached,
                           PS attached, NETWORK_TYPE_3GPP,
                           QMI_NAS_RADIO_INTERFACE_UMTS
ofonod[855]: QMI: NAS_ind msg=36 len=37 [client=1,type=4,tid=0,len=49]
ofonod[855]: QMI: {type=41,len=5} {type=40,len=2} {type=18,len=5}
                  {type=17,len=4}
ofonod[855]: QMI: {type=1,len=6}
==================> ROAMING information lost <==========================
ofonod[855]: ofono_netreg_status_notify modem /sierra_0 status 1 lac -1
             cellid -1 tech 2

I can't tell if not having the ROAMING_STATUS parameter in all indication
is something happening only on MC7304 or if it happens on all "QMI" modems.

I have also seen (on MC7430, with a roaming SIM card):
 - first notification indicating status
QMI_NAS_REGISTRATION_STATE_SEARCHING and roaming ON
 - following notifications indicating status
QMI_NAS_REGISTRATION_STATE_REGISTERED and no roaming notification

So we must handle roaming information even when not registered.
2018-09-07 11:33:56 -05:00
Julien Tournier 925006f49d atmodem: Handle cinterion modems compliant with 27.005 2018-08-29 16:10:29 -05:00
Martin Hundebøll 8b63185929 atmodem: add Quectel M95 special case for PIN query
The AT command reference for Quectel M95 specifies that remaining SIM
pin retires can be queried using AT+QTRPIN, which responds with one
count for each pin-type:

+QTRPIN: 3,3,10,10

After entering the PIN code, enable an extra AT+CPIN? for the M95
vendor.
2018-08-28 14:09:45 -05:00
Christophe Ronco 527e6b1f86 atmodem: Add gprs-context quirk for HUAWEI vendor
When ofono dies while connected using PPP, modem AT channel is not put
back to command mode (tested with HUAWEI modems E3372 and MS2372).
If ofono is restarted, it won't be able to connect as it gets no answer
to AT commands on this AT channel.
This patch adds a quirk to immediately send escape sequence on modem
channel when gprs-context atom is removed.
2018-07-25 14:11:45 -05:00
Marcel Holtmann 77398ff772 rilmodem: Use pragma to mask restrict buffer warnings
In file included from drivers/rilmodem/network-registration.c:40:
drivers/rilmodem/network-registration.c: In function ‘ril_cops_list_cb’:
./gril/gril.h:98:11: error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
   sprintf(print_buf, x);  \
           ^~~~~~~~~
drivers/rilmodem/network-registration.c:583:3: note: in expansion of macro ‘g_ril_append_print_buf’
   g_ril_append_print_buf(nd->ril, "%s [lalpha=%s, salpha=%s, "
   ^~~~~~~~~~~~~~~~~~~~~~
./gril/gril.h:98:11: error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
   sprintf(print_buf, x);  \
           ^~~~~~~~~
drivers/rilmodem/network-registration.c:593:2: note: in expansion of macro ‘g_ril_append_print_buf’
  g_ril_append_print_buf(nd->ril, "%s}", print_buf);
  ^~~~~~~~~~~~~~~~~~~~~~

In file included from drivers/rilmodem/call-forwarding.c:41:
drivers/rilmodem/call-forwarding.c: In function ‘ril_query_call_fwd_cb’:
./gril/gril.h:98:11: error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
   sprintf(print_buf, x);  \
           ^~~~~~~~~
drivers/rilmodem/call-forwarding.c:114:3: note: in expansion of macro ‘g_ril_append_print_buf’
   g_ril_append_print_buf(fd->ril, "%s [%d,%d,%d,%s,%d]",
   ^~~~~~~~~~~~~~~~~~~~~~
./gril/gril.h:98:11: error: passing argument 1 to restrict-qualified parameter aliases with argument 3 [-Werror=restrict]
   sprintf(print_buf, x);  \
           ^~~~~~~~~
drivers/rilmodem/call-forwarding.c:124:2: note: in expansion of macro ‘g_ril_append_print_buf’
  g_ril_append_print_buf(fd->ril, "%s}", print_buf);
  ^~~~~~~~~~~~~~~~~~~~~~
2018-06-14 15:19:16 +02:00
Antara Borwankar 1fe34da0af atmodem: Support ETWS & CMAS on XMM series modems 2018-06-13 11:58:45 -05:00
Florent Beillonnet 46896014ee atmodem: Fix at_pin_send_puk userdata use
It seems that the function at_pin_send_puk should have been changed
along with at_pin_send, because it's also refering to the
at_pin_send_cb callback

See this commit : ba9f126716
2018-05-23 09:02:16 -05:00
Bob Ham 1ebae47777 atmodem: Don't set AT+COLP=1 on SIMCom modems
On the SIMCom SIM7100E, setting AT+COLP=1 causes there to be no
response at all from "ATD...;" commands until the call is answered.
The results in oFono stalling rather than creating a new VoiceCall
object.

We fix this by adding SIMCOM to the list of vendors for whom we set
AT+COLP=0 rather than AT+COLP=1.
2018-05-14 11:11:14 -05:00
Christophe Ronco beed2aee9e qmi: report SIM not inserted when unable to get PIN type 2018-04-19 10:29:40 -05:00
Christophe Ronco 8af406a45d qmi: report failure or retry in case of invalid pin type
QMI_UIM_GET_CARD_STATUS is retried in more error cases
when trying to get password type.
In case of failure, driver report an error instead of
OFONO_SIM_PASSWORD_INVALID. This avoids a crash.
2018-04-19 10:27:32 -05:00
Christophe Ronco bfa0ac979e qmi: use right slot and application during SIM detection
Use right slot and application to get card status, PIN status and PIN
retries. Without this patch, SIMs where selected application and slot
numbers are different are not detected.
2018-04-19 10:24:50 -05:00
Jonas Bonn 88d9b1a32d qmi: make services always shared 2018-04-04 10:03:13 -05:00
Jonas Bonn 6485522c91 qmi: make version_list private 2018-04-04 09:59:44 -05:00
Jonas Bonn 76471964e2 qmi: assume version_list is up to date
The way things are currently coded, the gobi plugin calls
qmi_device_discover and does nothing else until it succeeds.  As such,
we can safely assume that the version_list is set up when we go to
create a service.
2018-04-04 09:56:22 -05:00
Jonas Bonn 81180147cf qmi: drop header output parameter from request_alloc
The only thing this output parameter is being used for now is for
getting the transaction ID.  Return the TID directly from
__submit_requesta and drop the 'head' parameter altogether.
2018-04-04 09:55:56 -05:00
Jonas Bonn a357565377 qmi: request_alloc has no meaningful failure path
The only way request_alloc can fail is if one of the memory allocation
routines fail to allocate memory.  However, Linux memory allocation
doesn't really fail in this manner; memory can be overcommited and the
out-of-memory reaper will take care of re-establishing the balance when
excess memory is actually accessed.

Given this, request_alloc will never return anything other than success
and the failure paths will never be exercised.
2018-04-04 09:55:21 -05:00
Jonas Bonn 093bdda7be qmi: unify common request header setup
The service and control requests differ slightly in their headers, but
this difference is minor enough that we can handle it directly in the
request submission routine.  This patch unifies the header setup for the
two request types.
2018-04-04 09:55:13 -05:00
Jonas Bonn 4ef8814215 qmi: remove headroom parameter from req_alloc
The headroom can be established from the service type, so it's redundant
to pass it as a parameter.
2018-03-29 09:54:39 -05:00
Jonas Bonn 4846c26948 qmi: remove unused fields of service_send_data
After setting up the request structure, qmi_service_send makes no
further use of the 'param' and 'service' fields of the service_send_data
structure.  This patch removes those fields and frees 'param'
immediately after the request has been allocated and the parameter data
thereby copied into the send buffer.
2018-03-29 09:52:22 -05:00