Commit Graph

26 Commits

Author SHA1 Message Date
Neels Hofmeyr 785450c4bf mobile: add audio config, with unused audio loopback setting
The aim is to add configurable audio loopback to mobile. An existing patch on a
branch from fixeria [1] adds the audio config section. Add a reduced version of
this audio config to be compatible with the future merge.

Add the audio loopback setting, so far without functionality.
Subsequent patch adds the actual loopback.

[1] osmocom-bb branch fixeria/audio,
    patch "mobile/vty_interface.c: add new 'audio' section"
    Change-id I62cd5ef22ca2290fcafe65c78537ddbcb39fb8c6

Change-Id: Ie03e4a6c6f81ea3925266dd22e87506d722a6e1a
2020-05-05 12:02:31 +07:00
Vadim Yanitskiy e11725aa86 host/layer23: rename GSM_SIM_TYPE_READER to GSM_SIM_TYPE_L1PHY
Since we have two ways to interact with a physical SIM:

  - using built-in SIM reader of the L1 PHY (via L1CTL),
  - using remote reader via (BT)SAP protocol,

name 'GSM_SIM_TYPE_READER' looks quite confusing. Let's rename it
in order to explicitly indicate the role of L1 PHY.

Change-Id: I0f83f365ed50cfd658fdd3a9d6866ed76c8c4009
2018-12-26 20:52:18 +00:00
Harald Welte 1d68468636 layer23: Fix possible buffer overflow writing NUL beyond end of string
settings.c: In function ‘gsm_random_imei’:
settings.c:188:26: warning: ‘sprintf’ may write a terminating nul past the end of the destination [-Wformat-overflow=]
  sprintf(rand + 8, "%07ld", random() % 10000000);
                          ^
settings.c:188:2: note: ‘sprintf’ output between 8 and 9 bytes into a destination of size 8
  sprintf(rand + 8, "%07ld", random() % 10000000);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Change-Id: Id949487111235cd4af5ff068f1dce2f4b0801480
2018-08-11 14:09:14 +00:00
Harald Welte d68833cd85 layer23: Use osmo_strlcpy() to avoid non-terminated strings
settings.c:191:2: warning: ‘strncpy’ output may be truncated copying 15 bytes from a string of length 15 -Wstringop-truncation]
  strncpy(set->imeisv, set->imei, 15);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CC       subscriber.o
  CC       support.o
  CC       transaction.o
  CC       vty_interface.o
  CC       voice.o
  CC       mncc_sock.o
  CC       primitives.o
mncc_sock.c: In function ‘osmo_unixsock_listen’:
mncc_sock.c:318:2: warning: ‘strncpy’ specified bound 108 equals destination size [-Wstringop-truncation]
  strncpy(local.sun_path, path, sizeof(local.sun_path));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  CC       script_lua.o
vty_interface.c: In function ‘cfg_gps_device’:
vty_interface.c:1144:2: warning: ‘strncpy’ specified bound 32 equals destination size [-Wstringop-truncation]
  strncpy(g.device, argv[0], sizeof(g.device));
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  AR       libmobile.a

Change-Id: Id52978f3bf7a8abea62237d7c32f8f87e1bb34a1
2018-08-11 12:59:30 +00:00
Holger Hans Peter Freyther 812866daab Move from libc random() to osmo_get_rand_id (2nd attempt)
When starting multiple mobile in the same second, the libc random number
generator will be seeded to exactly the same value.

The random bits inside the RACH request(s) will be exactly the same
across multiple mobile and when the channel fails they all pick the same
randomized back-off timing.

Use stronger random numbers and replace all calls to random(2) with
osmo_get_rand_id. Add a fallback to try random().

[v2: Add helper to make sure the result is int and between 0 and
RAND_MAX]

Change-Id: Icdd4be88c62bba1e9d954568e48f0c12a67ac182
2018-07-23 20:55:45 +01:00
Vadim Yanitskiy a0eef8d2e8 Revert "Move from libc random() to osmo_get_rand_id"
It was decided to migrate to osmo_get_rand_id() and use random()
as a fall-back. But there is a critical difference between both
functions: osmo_get_rand_id() fills an input buffer with random
bytes (0x00 - 0xff), while *random() returns a value in range
between 0 and RAND_MAX.

osmo_get_rand_id() was used in a wrong way, so in some cases we
could get a negative value (how about IMEI starting from '-'?),
what isn't expected in many cases and could lead to unexpected
behaviour and segmentation faults...

This reverts commit 6d49b049ee.

Change-Id: I7b2a8a5c63cf64360a824926a2219fd7e419b1bb
2018-07-17 05:09:58 +07:00
Holger Hans Peter Freyther 6d49b049ee Move from libc random() to osmo_get_rand_id
When starting multiple mobile in the same second, the libc random number
generator will be seeded to exactly the same value.

The random bits inside the RACH request(s) will be exactly the same
across multiple mobile and when the channel fails they all pick the same
randomized back-off timing.

Use stronger random numbers and replace all calls to random(2) with
osmo_get_rand_id. Add a fallback to try random().

Change-Id: Ie0cc64663cd4b90c027b79545dc5d3ac9d87b9dd
2018-07-11 21:13:11 +00:00
Holger Hans Peter Freyther fcb420d50b mobile/sms: Make it optional to store the SMS on disk
Disable storing the SMS on disk. This is useful when scripting mobile.
Keep the default of attempting to store it to disk.

Change-Id: I6353447343d98ebaa5e12ab63f995750f81c8500
2018-06-04 06:50:25 +02:00
Holger Hans Peter Freyther 5a3dd6eb1a mobile: Make time spent in c7 configurable
When no cell was found during the PLMN search the camp on any cell
state will be entered. LUs are prevented in this state and it will be
left after the start_any_timer has timedout. Even if camping on the
home network the state will not be left before the expiry of the timer.

For systematic tests this is producing a too high upper bound. Make it
configurable so we can succeed with a UL more quickly.

Change-Id: I25bc985cd4360d5e37d05a7b16b39eefb75ce20f
2018-06-01 23:32:23 +08:00
Holger Hans Peter Freyther 4080e622b7 mobile: Add initial support for scripting support
Right now the script will be executed once it is loaded. Make sure
to write it into the config file last. Expose various log commands
for logging. Jump through some hoops and get the filename and line
number from lua.

Change-Id: I456f6b6b5e1a14ed6c8cb0dcc5140093d3c61ef6
2017-12-03 12:58:53 +00:00
Andreas Eversberg d72cb4401e Rename various "rxlev" variable to "rxlev_dbm" and correct their signess
All levels in range of 0..63 are now uint8_t and use "rxlev" as
variable name. All levels in range of -110..-47 are now int8_t and use
"rxlev_dbm" as variable name.
2012-11-22 16:00:33 +01:00
Andreas Eversberg 925322c634 layer23/mobile: Enable SIM reader by default
If there is no SIM card in the reader, the SIM process would
automatically proceed without SIM anyway.
2012-01-02 02:08:08 +01:00
Sylvain Munaut 9311c0025f host/mobile: Whitespace fixes, no functional changes
Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2011-11-13 20:25:19 +01:00
Andreas Eversberg 9548ac0a41 [layer23/mobile] Improvement and fixes of idle mode process
This patch introduces cell re-relection. When camping on a cell, it
scanns neighbour cells. If a 'better' cell is found, the cell is selected.
If the cell is in a different location area, a location upating is
performed under certain conditions.

The 'better' cell depends on various informations that are broadcasted on
the BCCH of a neihbour cell and of course the RX level. Most operators
don't set these informations, so the 'better' cell depend on a better
RX level for the same location area, or a much better RX level (6 dBm)
at a different location area.

There were many issues at the idle mode process that has been fixed.
Expecially when moving, the state machines got stuck, so no more cell search
was possible, or no further calls / location updating was possible.

In order to see the process of cell selection, enter the VTY interface and
enable the network monitor:

enable
monitor network 1  (where '1' is the instance of the MS)

In order to see the current state of the processes, enter:

show ms
2011-07-17 11:12:15 +02:00
Andreas.Eversberg 58ac7e0e98 [layer23] Adding Quadband support and GSM 4x0 support
This makes it possible to use GSM 850 and PCS 1900 bands, as used in the
US. The support relies on the phone hardware.

Each band (900, DCS, 850, PCS, 480 and 450) can be enabled and
disabled individually for each setting.
2011-05-29 19:51:54 +02:00
Pablo Neira Ayuso ade79a0083 src: use new libosmogsm and include/osmocom/[gsm|core] path to headers
This patch changes include paths to get osmocom-bb working with
the current libosmocore tree.

Among all these renames, you can notice several tweaks that I
added on purpose, and that require some explanation, they are:

* hexdump() in osmocon.c and osmoload.c has been renamed to avoid
clashing with hexdump() defined in libosmocore.

* gsmmap now depends on libosmogsm. Actually I had to cleanup
Makefile.am because I was experiencing weird linking problems,
probably due to a bug in the autotools. With the change included
in this patch, I got it compiled and linked here correctly.

This patch has been tested with the phone Motorola C123 and the
following images files:

* firmware/board/compal_e88/hello_world.compalram.bin
* firmware/board/compal_e88/layer1.compalram.bin

Using the osmocon, bcch_scan and mobile tools.

Signed-off-by: Pablo Neira Ayuso <pablo@gnumonks.org>
2011-04-26 02:55:30 +02:00
Andreas.Eversberg f72baf40d5 [layer23] Adding LAC and TMSI (both optional) to test card (rplmn) 2010-11-20 08:32:32 +00:00
Andreas.Eversberg 6f2b172780 [layer23] Added support for multiple MS instances
To create another instance: 'ms <name> create'

To remove an instance: 'no ms <name>'

If no instance exists, 'ms 1' is created automatically on startup.

Each instance can be enabled / disabled by using 'shutdown' or
'no shutdown'. Multiple instances may share the same layer2 socket (same
phone hardware), but in this case only one instance can be enabled at the
same time. This makes it much easier to select different settings without
modifying them.

A 'shutdown' initiates the IMSI detach procedure before shutdown is
completed. A 'shutdown force' will immidiately shutdown.

There is no need to restart the software anymore, if fundamental settings
are changed. In this case, a 'shutdown' followed by a 'no shutdown' will
do the job.

If you already have an old osmocom.cfg, you need to "no shutdown" it.
Everything else behaves as before.
2010-11-13 18:45:09 +00:00
Andreas.Eversberg adf65e29fd [layer23] DTMF support 2010-10-15 18:54:57 +00:00
Andreas.Eversberg 1dd14c0b26 [layer23] Adding abbreviated dialing to VTY
It is possible to store phone numbers with abbreviations now. Dialing these
abbreviation makes testing of mobile originated calls much easier too.
2010-10-14 07:37:52 +00:00
Andreas.Eversberg 6d4915b91b [layer23] Implementation of signal loss criteria as defined in TS 05.08
There are two criterions for lossing a signal, idle mode and dedicated mode.
A counter counts down when a frame is dropped, and counts up when a valid
frame is received on  certain channel. The loss criterion is reached, if the
counter reaches 0. The values added to / removed from the counter and the
limits depend on the process.
2010-10-12 08:26:48 +00:00
Andreas.Eversberg f0c807a682 [layer23] Rework of "support"-features, features can be disabled now
Supported features of hardware (support.c) can be disabled by config.
This way the full featured mobile can be downgraded to indicate less
features to the network, like disabling speech support or crypto support.
2010-10-03 10:51:31 +00:00
Andreas.Eversberg 66ff1cb347 [layer23] Minimum RX-level is now a configuratio option
The default (if config not yet created/updated), is still taken from
settings.c.
2010-10-01 19:24:34 +00:00
Andreas.Eversberg b0336cd484 [layer23] Speech codec selection and negotiation with network 2010-09-26 17:08:10 +00:00
Sylvain Munaut 9e9f99c0a0 layer23: Split [2/2] -> The header files
This split the headers and adapt the source.

We use osmocom/bb as a prefix because libosomore also
uses osmocom and generic names such as misc & common could
conflict in the future.

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-07-27 20:49:27 +02:00
Sylvain Munaut de21ca4aaf layer23: Split [1/2] -> The source code
We split into :
 - common: Everything that can be shared
 - mobile: The real spec compliant mobile phones
 - misc:   Different test stuff

Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2010-07-27 20:49:04 +02:00