summaryrefslogtreecommitdiffstats
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2019-01-17trxcon/trxcon.c: do not expose tall_trx_ctxVadim Yanitskiy4-15/+14
Both l1ctl_link_init() and trx_if_open() do accept 'tall_ctx' now, so there is no need to expose the root context anymore. For logging initialization, we can just pass a pointer. Change-Id: I7a2231eb880a995d3296b94481a7799e6ff07489
2019-01-17trxcon/l1ctl_link.c: refactor l1ctl_link_init()Vadim Yanitskiy3-22/+20
The main changes are: - return pointer to the allocated l1ctl_link or NULL, - accept the talloc context as 'tall_ctx' argument. Change-Id: I7fe1bc306494ac692c182dcfd2a2d9412929194b
2019-01-17trxcon/trx_if: refactor trx_if_open()Vadim Yanitskiy3-34/+32
The main changes are: - return pointer to the allocated trx_instance or NULL, - extend debug message with TRX address and base port, - accept the talloc context as 'tall_ctx' argument, - rename goto label 'error' to 'udp_error', - rename argument 'port' to 'base_port'. Change-Id: I39b24afee2f09d6a6c500cfc26ac45f206589c5c
2019-01-17trxcon: do not include trxcon.h everywhereVadim Yanitskiy9-9/+0
Change-Id: Ia78bd6dac7ab12970838e0b1a2929a106b898d9d
2019-01-17trxcon/trx_if.c: check if trx_fsm allocation failedVadim Yanitskiy1-4/+11
Change-Id: I31c9f2a651182b258d0a4d4504365b778529715a
2019-01-17trxcon/l1ctl_link.c: check if l1ctl_fsm allocation failedVadim Yanitskiy1-4/+11
Change-Id: Ibd9404a888f02798224238a7b9ff4ebf09f03850
2019-01-17trxcon: register both l1ctl_fsm and trx_fsm on DSO loadVadim Yanitskiy2-2/+10
Change-Id: I7111e368afa47c88ff3c610bae9044f2d5baf037
2019-01-15trxcon/sched_trx.c: use bool in sched_trx_reset()Vadim Yanitskiy4-7/+8
Change-Id: I4f6990520836edb5eecce38c04857a4b3bc6f2fc
2019-01-14trx_toolkit/README: update fake_trx.py descriptionVadim Yanitskiy1-2/+3
Since Ibff31fb3a958a714c828d0dea7e87d47f778fd80, fake_trx.py does support multiple transceivers. Let's update its description. Change-Id: I6e4351693da3a1f7e3eadd8e11971c34044dde20
2019-01-14trx_toolkit/transceiver.py: add optional transceiver nameVadim Yanitskiy2-13/+26
Since fake_trx.py can handle multiple transceivers, it may be useful to name transceivers. If transceiver has some name, it will appear in logging messages, for example: [INFO] transceiver.py:104 Init transceiver 'BTS@127.0.0.1:5700' [INFO] transceiver.py:104 Init transceiver 'MS@127.0.0.1:6700' [INFO] transceiver.py:104 Init transceiver '127.0.0.1:5700/1' This change additionally assigns names to the both default transceivers, and extends the '--trx' option with ability to specify some name, for example: --trx foo@127.0.0.1:5700 or --trx bar@127.0.0.1:5700/1 --trx ipv6@[2001:0db8:85a3:0000:0000:8a2e:0370:7334]:6700 Change-Id: I2f58f02e7819bb008b8aab1a8bf9e0adeb2e44ec
2019-01-14trx_toolkit/transceiver.py: add init logging messageVadim Yanitskiy1-0/+2
Change-Id: I9a8b327748fbfcbae438cb531cd0b2767b6ca4dd
2019-01-14trx_toolkit: use 'TRXC' and 'TRXD' in logging messagesVadim Yanitskiy5-7/+12
One can confuse TRX control interface with libosmoctrl's one. TRX toolkit is not using libosmoctrl, and will never do. But, in order to avoid this confusion, and potential confusion of DATA interface, let's call them 'TRXC' and 'TRXD' in logging. Change-Id: I67b1e850094cf8e279777c45c7544886be42a009
2019-01-14trx_toolkit/{ctrl,data}_if.py: add init log messageVadim Yanitskiy3-1/+8
Change-Id: I1a2caf6999ed4f33df76328e48ff5076d166d9fe
2019-01-14trx_toolkit/fake_trx.py: enrich TRX logging messagesVadim Yanitskiy3-30/+41
Since fake_trx.py can handle multiple transceivers, it makes sense to print some info in logging messages about transceivers they belong to. This acvieved by defining __str__() for Transceiver. Some examples: [DEBUG] ctrl_if_trx.py:83 (127.0.0.1:5700) Recv POWEROFF cmd [INFO] ctrl_if_trx.py:85 (127.0.0.1:5700) Stopping transceiver... [DEBUG] ctrl_if_trx.py:95 (127.0.0.1:5700/1) Recv RXTUNE cmd [DEBUG] ctrl_if_trx.py:102 (127.0.0.1:5700/1) Recv TXTUNE cmd [DEBUG] ctrl_if_trx.py:155 (127.0.0.1:5700/1) Ignore CMD SETTSC [DEBUG] ctrl_if_trx.py:155 (127.0.0.1:5700/1) Ignore CMD SETPOWER Change-Id: I1f706790a2da226f1418f89d2cfbb55baa6ea624
2019-01-14trx_toolkit/fake_trx.py: move init code to __init__()Vadim Yanitskiy1-30/+30
There should be no code in run() that does initialization, __init__() is the best place for this. This change allows to import the Application class from fake_trx.py, and run it from script (e.g. for testing). Change-Id: I84969630348a189d237cc98354e568421839a37b
2019-01-15layer23/sap_interface.c: reimplement (BT)SAP interfaceVadim Yanitskiy12-386/+1259
The (BT)SAP (Bluetooth SIM Access Profile) is a part of Bluetooth specifications, that defines the protocol and procedures that shall be used to access a smart card (usually GSM SIM) via a Bluetooth link. The profile defines two roles: - Server - the side that has direct access to a smart card. It acts as a SIM card reader, which assists the Client in accessing and controlling the smart card. - Client - the side that accesses and controls the smart card inside the Server through the connection with Server. Typical examples of a Server are a simple SIM card holder or a portable phone in the car environment. A typical example of a Client is a car phone, which uses a subscription module in the Server for a connection to the cellular network. OsmocomBB implements the Client role providing abstract SAP interface API to the higher layers. Instead of Bluetooth, a UNIX socket is used to communicate with a Server. The previous implementation of (BT)SAP interface was incomplete and hard to maintain. This change (re)implements it almost from scratch on top of the Osmocom FSM framework. Besides that, the most significant changes are: - The implementation is separated into three parts: - sap_interface.{c|h} - public SAP interface API, - sap_proto.{c|h} - SAP protocol definition, - sap_fsm.{c|h} - SAP FSM implementation. - Both 'sap_message' and 'sap_param' structures follow the SAP message format definition according to 5.1 and 5.2. - The message parsing is done more carefully in order to prevent buffer overflow and NULL-pointer dereference. - Introduced public API for getting / adding message parameters, and checking the ResultCode. - Introduced public API for opening / closing a connection with the server, powering on / off and resetting the SIM card, sending ATR and APDU. - Introduced a call-back for handling the response message. - Card reader state is also a part of the public API. The new implementation was tested against softsim [1]. The only limitation is Server-initiated Release, that allows the Server to 'ask' a Client to release connection as soon as communication with the smart card is finished. This is not implemented (yet), and leads to immediate release. [1] https://git.osmocom.org/softsim/ Change-Id: I77bb108615bb2c94c441568f195b04e0a5421643
2019-01-13trx_toolkit/fake_trx.py: fix: update trx_list of FakePMVadim Yanitskiy1-0/+1
It seems in Ice44e2b22566b3652ef6d43896055963b13ab185 I forgot to do this, so all measurements triggered by MEASURE command were incorrect (always noise). Let's fix this! Change-Id: I155f118b2d3e3b23eb148fe7e2630790f8fcd18c
2019-01-13trx_toolkit/fake_trx.py: handle multiple transceiversVadim Yanitskiy1-31/+81
Since Ice44e2b22566b3652ef6d43896055963b13ab185 is merged, the class hierarchy has become much more flexible, so it's possible to create multiple Transceiver / FakeTRX instances and distribute bursts using a single instance of BurstForwarder. This change introduces a new command line option, that can be used to specify additional transceivers. Please note that fake_trx.py still initializes a pair of BTS and BB transceivers by default. The new option has the following format: --trx REMOTE_ADDR:BASE_PORT[/TRX_NUM] Some examples for IPv4 and IPv6: --trx 127.0.0.1:5703 --trx [2001:0db8:85a3:0000:0000:8a2e:0370:7334]:6703 If optional TRX_NUM > 0 is specified, e.g.: --trx 127.0.0.1:5700/1 then this transceiver is considered as a child of another one. See I7e97b7f32dde7ab74779133e9d7504f1d0fce60c for details. Change-Id: Ibff31fb3a958a714c828d0dea7e87d47f778fd80
2019-01-13trx_toolkit/transceiver.py: add support for child transceiversVadim Yanitskiy2-6/+100
A BTS can (optionally) have more than one transceiver. In this case additional (let's say child) transceivers basically share the same clock source of the first transceiver, and being powered on / off as soon as the first transceiver is powered on / off. Change-Id: I7e97b7f32dde7ab74779133e9d7504f1d0fce60c
2019-01-13trx_toolkit/burst_fwd.py: fix trx_list cross-referenceVadim Yanitskiy1-2/+5
It was discovered that using an empty list as default argument value does result into the cross-reference, i.e. all instances of BurstForwarder would reference the same trx_list object. This is not an expected behaviour, let's fix this. Change-Id: Id71185de05b0ebc5adb105b10fad2cbde5f800b1
2019-01-07layer23/sap_interface.c: separate protocol definitionVadim Yanitskiy6-161/+205
Change-Id: Iad9b3d88b02cc7ec4cf64483bbc85e3a61c9ad10
2019-01-07layer23/include/Makefile.am: add missing headerVadim Yanitskiy1-1/+2
Change-Id: I0a379718eeb7db63696cabd5689e0625fb85d85e
2019-01-07layer23/sap_interface.c: avoid using 'osmo' prefixVadim Yanitskiy5-18/+18
The 'osmo' prefix is usually used by libosmo-* symbols. Change-Id: Id37d8553c2f2c20012fb1b729967b92a9a03f612
2019-01-07layer23/sap_interface.c: define missing enums and use themVadim Yanitskiy2-24/+55
Change-Id: I4ba5a8a42bf25d04b152ac3f1f0e4d7eac7f068f
2019-01-07layer23/sap_interface.c: terminate value_string definitionsVadim Yanitskiy1-0/+5
Change-Id: I0776bc43360dfa2229243fb022cd318242ca6400
2019-01-07layer23/sap_interface.c: prettify value_string definitionsVadim Yanitskiy2-54/+58
Change-Id: Ib3aa81986987027718e2a8b461afd28787bda4c2
2019-01-07layer23/sap_interface.c: fix: properly call sap_msg_free()Vadim Yanitskiy1-6/+8
Passing NULL to sap_msg_free() is not only meaningless, but also would result in NULL pointer dereference. We should call it in successful case only, so let's fix this. Change-Id: Icf868c4299e292a17c4b7aad1f9e728ea3653494
2019-01-02trxcon/scheduler: fix RSSI -> RX level conversionVadim Yanitskiy1-1/+11
Due to a mistake, average RSSI value of received bursts was not converted to GSM RX level (range 0..63), so trxcon has been sending incorrect values to the higher layers. Let's fix this, and also prevent possible division by zero. Change-Id: Id4659de899411ec1ba1718fdcb40aec562dbfd65
2018-12-26layer23/sap_interface.c: use LOGP() instead of fprintf()Vadim Yanitskiy1-3/+3
Change-Id: I054be24666fcd5eb8a70cfcac0e7ed566e909b90
2018-12-26layer23/sap_interface.c: use int for rc in sap_open()Vadim Yanitskiy1-1/+1
Change-Id: I683f87ae09393c45377c39317b08c613055ceb16
2018-12-26layer23/sap_interface.c: remove redundant socket_path argumentVadim Yanitskiy3-5/+6
Change-Id: I408b3e1fa40e9b5daf88fa6ed5f3930b83dffe6f
2018-12-26layer23/sap_interface.c: drop unused osmosap_sapsocket()Vadim Yanitskiy2-10/+0
Change-Id: Ie3040c75bb61094b9b601aef9d699db603d292f4
2018-12-26layer23/sap_interface.c: return rc from osmosap_send_apdu()Vadim Yanitskiy1-7/+10
Change-Id: I3965843c4d49e31b1b5156d9ee8439eef6ecaab1
2018-12-26layer23/include/sap_interface.h: use #pragma onceVadim Yanitskiy1-5/+1
Change-Id: I98e407c2b6604438d2495700cb62753ad55369ea
2018-12-26mobile/subscriber.c: consider GSM_SIM_TYPE_SAP tooVadim Yanitskiy2-5/+7
There are several SIM card interfaces, two of which: - GSM_SIM_TYPE_L1PHY (using built-in SIM reader of the L1 PHY), - GSM_SIM_TYPE_SAP (using remote reader via (BT)SAP protocol), can actually deal with a physical SIM card. But, for some reason, only GSM_SIM_TYPE_L1PHY was considered as such. Let's also get along with GSM_SIM_TYPE_SAP for the following procedures: - PIN management and verification, - FPLMN / LOCI updating, - A3 authentication. Change-Id: I4b3080fa7a5332467a449a314ba3cc3a07a9b7df
2018-12-26host/layer23: rename GSM_SIM_TYPE_READER to GSM_SIM_TYPE_L1PHYVadim Yanitskiy5-10/+10
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-26layer23/common/sim.c: don't ignore rc of sim_apdu_send()Vadim Yanitskiy1-3/+5
Change-Id: I8cab7cc72f026947859cc607f65d925803424cf7
2018-12-23mobile: Use new VTY telnet API to allow binding to random portHolger Hans Peter Freyther1-2/+1
Change-Id: I5a6214aec2dcb92495038ea8311c0df22fa8d07b
2018-12-19layer23/mobile: drop dead SAP initialization codeVadim Yanitskiy1-10/+0
SAP connection can be initialized upon request. Change-Id: Ic89089c4850ab2c9252bfd43a05d5271e2e3a160
2018-12-18host/layer23/sap_interface.c: cosmetic: use ARRAY_SIZE()Vadim Yanitskiy1-1/+1
Change-Id: I3a2908bf11300ec681beddb5a54f9a62ca5430ae
2018-12-18host/layer23: don't init SAP interface by defaultVadim Yanitskiy1-4/+0
Almost all layer23 applications, excluding mobile, have nothing to do with SAP interface. Moreover, the current implementation does initialize SAP connection automatically, as soon as the first message is sent. Change-Id: I62cc69c06fa15468a55bb0a9d408267d0745174c
2018-12-18trx_toolkit/fake_trx.py: refactor global class hierarchyVadim Yanitskiy7-790/+663
This change is a big step towards handling of multiple transceivers in a single process, i.e. multiple MS and multiple BTS connections. The old class hierarchy wasn't flexible enough, because initially fake_trx was designed as a bridge between OsmocomBB and OsmoBTS, but not as the burst router. There were two separate, but 90% similar implementations of the CTRL interface, two variations of each simulation parameter - one for UL, another for DL. The following new classes are introduced: - Transceiver - represents a single transceiver, that can be used as for the BTS side, as for the MS side. Each instance has its own CTRL, DATA, and (optionally) CLCK interfaces, among with basic state variables, such as both RX / TX freq., power state (running or idle) and list of active timeslots. - CTRLInterfaceTRX - unified control interface handler for common transceiver management commands, such as POWERON, RXTUNE, and SETSLOT. Deprecates both CTRLInterface{BB|BTS}. - FakeTRX - basically, a child of Transceiver, extended with RF path (burst loss, RSSI, TA, ToA) simulation. Implements a custom CTRL command handler for CTRLInterfaceTRX. The following classes were refactored: - BurstForwarder - still performs burst forwarding, but now it doesn't store any simulation parameters, and doesn't know who is BTS, and who is MS. Actually, BurstForwarder transforms each L12TRX message into a TRX2L1 message, and dispatches it between running transceivers with matching RX frequency and matching timeslot. - FakePM - still generates random RSSI values, but doesn't distinguish between MS and BTS anymore. As soon as a measurement request is received, it attempts to find at least one running TRX on a given frequency. Please note that fake_trx.py still does handle only a single pair of MS and BTS. No regressions have been observed. Both new and refactored classes were documented. Change-Id: Ice44e2b22566b3652ef6d43896055963b13ab185 Related: OS#3667
2018-12-18trx_toolkit/data_if.py: add optional legacy message coding flagVadim Yanitskiy1-2/+2
In I6b9a8b611ea1e9badc4d9ddf13aa9e237028e39a an optional legacy message coding mode was introduced. Let's add the corresponding argument to send_msg() and pass it to gen_msg(). Change-Id: I6b9a8b611ea1e9badc4d9ddf13aa9e237028e39a
2018-12-18trx_toolkit/data_msg.py: add optional legacy message coding flagVadim Yanitskiy1-1/+14
Some transceivers (e.g. OsmoTRX) have inherited a rudiment from OpenBTS - two dummy bytes at the end of TRX2L1 messages. Despite they are absolutely useless, some L1 implementations, such as trxcon and OpenBTS, still do expect them when checking the message length. Let's add an optional (disabled by default) argument to gen_msg(), that would enable adding those two dummy bytes. Change-Id: I0cf1314c399411886420176704cadd6e6d84787f
2018-12-18trx_toolkit/data_msg.py: use struct API for fn and toa256 codingVadim Yanitskiy1-16/+4
The built-in struct module is already used for toa256 decoding, so let's use it for toa256 encoding, and TDMA frame number coding too - no need to (re)implement the wheel! Change-Id: I10d2e15ac57a0524e9bc1c80ed6a0f6f5a263436
2018-12-16trx_toolkit/ctrl_if_bb.py: drop meaningless warningsVadim Yanitskiy1-8/+0
A timeslot can be reconfigured at runtime, this is normal. We should neither complain nor reject such commands. Change-Id: I0a69ebceed5aa724093e6d1b23faad8c16705055
2018-12-16trx_toolkit/burst_send.py: exit if DATA dump parsing failedVadim Yanitskiy1-1/+2
False is not iterable, so we should properly handle the case when parsing of the whole DATA dump was failed (e.g. due to incorrect offset specified). Change-Id: I5443efb39bb9d3377290ce7ec5e34016cae0edb2
2018-12-16trx_toolkit/burst_send.py: fix: use proper argparse groupVadim Yanitskiy1-3/+3
Found using Flake8, F841 "local variable 'pf_group' is assigned to but never used". The filtering related options should be defined in 'pf_group' group, not in 'cnt_group'. Change-Id: I15d17c134cbbbd54d761113a56c1f83910ab6407
2018-12-16trx_toolkit: fix missing / useless importsVadim Yanitskiy4-4/+2
Found using Flake8: - data_if.py:57:4: F405 'log' may be undefined, or defined from star imports: data_msg - clck_gen.py:29:1: F401 'time' imported but unused - clck_gen.py:30:1: F401 'sys' imported but unused - trx_sniff.py:28:1: F401 'signal' imported but unused Change-Id: Id0c42319b445db218b77fd5e99a9a0a89724281d
2018-12-12trx_toolkit/data_if.py: add message parsing methodsVadim Yanitskiy1-0/+33
This change extends DATAInterface class with new methods: - recv_raw_data() - read raw data from socket; - recv_l12trx_msg() - read raw data and parse as L12TRX; - recv_trx2l1_msg() - read raw data and parse as TRX2L1; which would simplify the further usage of this class. Change-Id: I761c4e63864622d3882b8f9c80ea43b58f092cb1