summaryrefslogtreecommitdiffstats
path: root/src/host/layer23/include
AgeCommit message (Collapse)AuthorFilesLines
2019-05-23[WIP] HO: VTY test option to fake a better neighbor cell to force handoverAndreas Eversberg1-0/+3
The handover is forced by reporting perfect measurement results of a given neighbor cell. All other neighbor cells and the serving cell is reported as poor. The falke report will sustain until the connection is released or a new 'better' cell is specified. Change-Id: Ie9245dbbb9142f14459ed13b2ff29a6c2dbf3d6c
2019-05-23[WIP] HO: Completed handover process at mobile (layer 3).Andreas Eversberg1-2/+24
The implementation supports: - Non-synchronised handover - Synchronized handover - Pre-sychronized handover - Pseudo-synchronized handover Change-Id: I0aebe1adfddcc3ff794b980ea4e3651ff616c032
2019-05-23[WIP] HO: Add new parameters to L1CTL_DM_EST_REQAndreas Eversberg1-2/+3
* Flag to enter dedicated mode with TX disabled * Flag to use sync info of neighbor cell * Flag to use sync info of previous serving cell * Index of neighbor cell All these parameters are required to handover to a new channel. Change-Id: Iadbc47f006d1f8a019822aedee180814de13cb2d
2019-05-23[WIP] HO: Add BSIC and TOA to L1CTL_NEIGH_PM_INDAndreas Eversberg1-0/+2
Change-Id: I792b52d9bf115a2def9720eed3d62982d8cdbe00
2019-05-23layer23: Fix 'make distcheck'Harald Welte3-3/+4
Change-Id: Ic48e240ee1484aaa793af23c62a24d2949900b86
2019-05-03mobile/gsm48_rr.h: mark gsm48_rr_hdr struct as packedVadim Yanitskiy1-1/+1
In both gsm48_mm.c and gsm48_rr.c we put / push 'gsm48_rr_hdr' structure into the message buffers, so then it's retrieved by the message receivers. The AddressSanitizer complains about unaligned pointer access and potentially unexpected behaviour. Change-Id: I8aa2c0074b405afd0e76044ef076b6819fe1083b
2019-02-02common/osmocom_data.h: use proper type for SAP card statusVadim Yanitskiy1-1/+4
Change-Id: I7388ec60ca2dff59c0a0e3fdacf5a3af0c244c73
2019-01-15layer23/sap_interface.c: reimplement (BT)SAP interfaceVadim Yanitskiy6-24/+98
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-07layer23/sap_interface.c: separate protocol definitionVadim Yanitskiy3-84/+95
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 Yanitskiy2-8/+8
The 'osmo' prefix is usually used by libosmo-* symbols. Change-Id: Id37d8553c2f2c20012fb1b729967b92a9a03f612
2019-01-07layer23/sap_interface.c: define missing enums and use themVadim Yanitskiy1-0/+31
Change-Id: I4ba5a8a42bf25d04b152ac3f1f0e4d7eac7f068f
2019-01-07layer23/sap_interface.c: prettify value_string definitionsVadim Yanitskiy1-2/+2
Change-Id: Ib3aa81986987027718e2a8b461afd28787bda4c2
2018-12-26layer23/sap_interface.c: remove redundant socket_path argumentVadim Yanitskiy1-1/+1
Change-Id: I408b3e1fa40e9b5daf88fa6ed5f3930b83dffe6f
2018-12-26layer23/sap_interface.c: drop unused osmosap_sapsocket()Vadim Yanitskiy1-1/+0
Change-Id: Ie3040c75bb61094b9b601aef9d699db603d292f4
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 Yanitskiy1-0/+3
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 Yanitskiy1-1/+1
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-11-21mobile: use VTY bind addr from config, deprecate cmd line optionsVadim Yanitskiy1-1/+1
This change revives the main idea of: Change-Id: I32517567847fd5c54b1742f18bf409ff81e316fa to stop ignoring the VTY bind address from the config file. Furthermore, it deprecates (and disables) both 'u' and 'v' command line options, because they are redundant. Change-Id: I99e0ec1717edd29b3be231be86616cc7effe5d95
2018-11-16mobile: use proper type for boolean flagsMax1-3/+3
This makes reading code easier and simplifies further modifications. Change-Id: I7eff2a61495ff167dc19fc9a41882a7a11fbf32d
2018-11-16mobile: add header for MS' MNCC functionsMax2-1/+10
This simplifies adding new functions and re-using them from other parts of the code. Change-Id: Ibad400a99afe052f011f54fc706836b6bf89f4b9
2018-10-27layer23/common: move SIM APDU caching from l1ctl.cVadim Yanitskiy1-0/+4
L1CTL implementation (i.e. l1ctl.c) is not a good place for the SIM specific stuff. Let's move it to the proper place (i.e. sim.c). As a bonus, this change fixes a possible problem of loosing the cached APDUs if two or more L2&3 applications are using a single LAPDm connection. The APDU buffer is dedicated per MS now. Change-Id: I564c610e45aa3b630ca5d1ec6bc1cace0dc9c566
2018-09-16lua: Expose API to trigger a network reselectionHolger Hans Peter Freyther1-0/+1
Same as the "network search" VTY command but implemented as primitive and exposed to LUA. Change-Id: I096233a2ca9dd7daa358cebed0523cb8c0dbf593
2018-09-16Add includes so the file can be included by itselfHolger Hans Peter Freyther1-0/+5
Add missing dependencies to make this file be includeable as the only file. Change-Id: I05b5f689f389b89deb5ff49507486b246111fc59
2018-09-07common/l1ctl.c: fix: use signed type for TA in l1ctl_tx_param_req()Vadim Yanitskiy1-1/+1
Despite the correct range of Timing Advance value is [0..63], there is a special feature in OsmocomBB which allows one to simulate the distance between both MS and a BTS by playing with the signal delay. It was discovered that l1ctl_tx_param_req() is using an unsigned 'uint8_t' type for Timing Advance value, while other code and L1CTL protocol is using signed 'int8_t'. This may result in distortion of negative values, so let's fix this! Change-Id: I6ee42b5fa2ca9ebe187f0b933465c49f840a55c2
2018-07-23Move from libc random() to osmo_get_rand_id (2nd attempt)Holger Hans Peter Freyther2-1/+4
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-06-04mobile/sms: Make it optional to store the SMS on diskHolger Hans Peter Freyther1-0/+1
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-01mobile: Make time spent in c7 configurableHolger Hans Peter Freyther1-0/+5
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-03-14L1CTL/L1CTL_CRYPTO_REQ: add key length and channel infoVadim Yanitskiy1-2/+2
Previously, the L1CTL_CRYPTO_REQ message contained only a ciphering algorithm and actual Kc key to be used. The key length was calculated manually using the MSGB API. Let's avoid manual calculations here, as it may cause unexpected behavior if the message structure is changed. Also, let's fill the UL header with minimal information about a channel, which is going to be encrypted. Change-Id: I5fab079907c5276322d3ec2b46cab81f10c7ed09
2017-12-27mobile: Send SMS through the primitive interfaceHolger Hans Peter Freyther2-0/+4
Make this symmetric and send the SMS through the primitive interface. Construct and copy the sms into the prim, store the SCA in the prim as well. In 04.11 we see we can store 2*10 digits in the destination address and a NUL. Change-Id: I91d7537f4f6ce5ba00218c58f3456947ec7bc662
2017-12-03mobile: Create "ms" singleton for struct osmocom_msHolger Hans Peter Freyther1-0/+1
Make the MS the script is associated with accessible to lua. Provide access to IMSI and IMEI. The IMSI might not be available at the given time and just return an empty string. Example lua usage: print(osmo.ms():imsi()); print(osmo.ms():imei()); print(osmo.ms():shutdown_state()) print(osmo.ms():started()) function ms_started_cb(started) print("MS started", started) end function ms_shutdown_cb(old_state, new_state) print("MS shutdown", old_state, "->", new_state) end function sms_cb(sms, cause, valid) print("SMS data cb", sms, cause, valid) for i, v in pairs(sms) do print(i, v) end end function mm_cb(new_state, new_substate, old_substate) if new_state == 19 and new_substate == 1 then osmo.ms():sms_send_simple("1234", "21321324", "fooooooo", 23) end end local cbs = { Started=ms_started_cb, Shutdown=ms_shutdown_cb, Sms=sms_cb, Mm=mm_cb } timer = osmo.timeout(20, function() print("Timeout occurred after 20s") end) osmo.ms():register(cbs) # Can fail. Best to wait for state changes... print(osmo.ms().start()) print(osmo.ms().stop(true)) Change-Id: Ia3ace33d6ba4e904b1ff8e271a02d67777334a58
2017-12-03mobile: Add initial support for scripting supportHolger Hans Peter Freyther2-0/+7
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-03mobile: Add LUA as debug category to the applicationsHolger Hans Peter Freyther1-0/+1
Change-Id: Id2d266c48d30c06dfdc3b8c84d875038b43f2ad8
2017-12-03mobile: Notify MM status changes and generate primitive op indHolger Hans Peter Freyther1-0/+12
Notify once the mm state has been changed. Unfortunaley one state transition can immediately trigger more transitions (recursively). In the mid-term it might be best to force all primitives to be async to avoid unpredictable behavior (e.g. make a shutdown while being a recursion down?) Change-Id: I8e9dcf7fd9116985aa060ba027ba74107a19223a
2017-12-03mobile: Inform the primitive layer about status and new smsHolger Hans Peter Freyther2-1/+24
Inform the layer about new SMS and inform about the cause of it. In both cases pass the SMS. Change-Id: Ib7ab34b1b85b62ef0e8fff347adccbc5dc414161
2017-12-03mobile: Directly inform the primitive layer about an eventHolger Hans Peter Freyther1-1/+24
Forward started/shutdown changes to the primitive layer which will turn them into indications. The other option might be to use the signals but it seems primitives are a superset of the signals. The notify will be done per MS and then the right primitive instance will be searched and the indication be sent. The approach will be applied to other systems as well. The signal framework might be seen as a subset of the primitives A signal mostly being a different form of an indication. Change-Id: I5df20a4ab79c06b515780675b6df2929aa976f0d
2017-12-03mobile: Begin with a primitive interface on top of the codeHolger Hans Peter Freyther3-1/+50
We want the script interface to interface through a primitive interface. This will allow to move it to a different thread or a process in the future. The script interface will just use the primitives. It is not clear how "sap" will be used here. I am keeping it at 0 right now. The first primitive is starting a timer with a request and then getting an indication as a response. Change-Id: Id2456b7fae35546553c4805f12a40c0812d9255c
2017-12-03mobile: Move starting/stopping a MS into a separate functionHolger Hans Peter Freyther1-2/+5
Move the check if within the mobile app there is no other active MS using the same L1 socket. This way we can call this function from the primitive code as well. Change-Id: Ib4aa5ff212fa6bead8f620abaecc6a0b51a99fec
2017-12-03mobile: Declare struct osmocom/vty to be self includeableHolger Hans Peter Freyther1-0/+2
In file included from settings.c:27:0: ../../include/osmocom/bb/mobile/app_mobile.h:10:42: warning: ‘struct osmocom_ms’ declared inside parameter list will not be visible outside of this definition or declaration int l23_app_init(int (*mncc_recv)(struct osmocom_ms *ms, int, void *), ^~~~~~~~~~ ../../include/osmocom/bb/mobile/app_mobile.h:14:26: warning: ‘struct osmocom_ms’ declared inside parameter list will not be visible outside of this definition or declaration int mobile_delete(struct osmocom_ms *ms, int force); Change-Id: I9348b3ed71a8490c03edda954402ab954f645b7c
2017-11-30mobile: Re-introduce msg_ref in struct gsm_smsHolger Hans Peter Freyther1-0/+1
In I4bac5f06921b5fd85a98d97770d42d4858ca1c42 I have removed the msg_ref field. But in case we delete a transaction with a pending SMS we need to get the msg_ref from somewhere. This is a partial revert but for RX SMS it makes sure that msg_ref will be set (it wasn't set before). Change-Id: I9b0f90f875de5f072565878861d38b0bb3bfbded
2017-11-27mobile: Avoid msg_ref going out of syncHolger Hans Peter Freyther1-2/+1
It seemed like msg_ref could go out of sync. In some places we are using sms->msg_ref in other cases we pass it as parameter (e.g. when sending the SMS) or we get it out of the gsm411_rp_hdr. Instead of hardcoding 42 for all messages make it configurable and pass the parameter from the caller. Change-Id: I4bac5f06921b5fd85a98d97770d42d4858ca1c42
2017-11-27mobile: Change started and shutdown state through functionHolger Hans Peter Freyther1-0/+5
Instead of changing the field all over the place, do the state change in a function. This will allow us to emit a notification when things change. It is similar to the lchan_state. Change-Id: I6a0591bb2785232681b23e41368323f16d3c960c
2017-11-27mobile: Instead of putting semantic in a comment, use an enumHolger Hans Peter Freyther1-0/+7
The enum was created to understand the different states during the shutdown and find places where it is used. The normal transitions are like. Idle -> Imsi Detach -> L1 Reset -> Done Idle -> L1 Reset -> Done The shutdown can get stuck in case: * Out of memory situation while handling IMSI detach (timeout) * Never receiving l1 reset acknnowledgment. The code could benefit from the move to osmo fsm to deal with proper timeouts. Change-Id: Iee1140e4848923c7270495c381bf87b7e3fddee1
2017-11-27mobile: Use bool to show started can only be true or falseHolger Hans Peter Freyther1-1/+2
The state handling is complicated and maybe it gets better by moving started to bool and then the rest to an enum. Change-Id: I6aef22e7bf954a8a4ecda980c2c558eb8c9180b7
2017-11-27mobile: Switch from printf to LOGP statementsHolger Hans Peter Freyther1-0/+1
Add a mobile application logging category and replace printf with a LOGP. The code is sadly still using exit in the middle of handling. Change-Id: I71e7f6e6375a485b45bad76ada2be17b0901577d
2017-11-08host/mobile: use osmocom_ms as talloc contextVadim Yanitskiy1-1/+1
As we use talloc, it's absurdly not to use the main feature of the library - hierarchical memory management. This change sets talloc context of all sub-allocated objects to related osmocom_ms instance. So, as soon as osmocom_ms instance is destroyed, all sub-allocated chunks are getting destroyed too. Change-Id: I6e3467ff739f3e6dc8dd60cc6d1fcd3f8e490ce9
2017-11-05mobile/vty_interface.c: fix incompatible pointer type warningVadim Yanitskiy1-1/+1
According to the vty_app_info struct definition, the go_parent_cb() should return an integer, but not enum. So, this change fixes the following compiler warning: > warning: initialization from incompatible pointer type > .go_parent_cb = ms_vty_go_parent, Change-Id: Ib55e43eaaebdd9fe0d74a030b1057ae82804a77e
2017-05-25host/mobile: use talloc for ms->name allocationVadim Yanitskiy1-1/+1
The approach of talloc memory management reduces memory usage, and prevents some buffer overflows, which were possible before. Change-Id: Icd6706117fdd7f1b3481b0e3817bbb3b31f12f60
2016-01-18host/mobile: Improved SAP interface integrationЯницкий Ва дим2-1/+5
1) Now the SAP interface is selectable as SIM source using the 'sim sap' command in VTY. 2) SAP connection starts only if it is configured as SIM source. 3) Fixed sap_socket_path configuration r/w errors. Written-by: Яницкий Ва дим <axilirator@gmail.com> Signed-off-by: Sylvain Munaut <tnt@246tNt.com>
2015-04-28host/mobile: Finish working support for the SAP interfaceSylvain Munaut2-1/+66
Patch mostly written by Nico Golde and some cleanup/testing by Domonkos Tomcsanyi Signed-off-by: Sylvain Munaut <tnt@246tNt.com>