AgeCommit message (Collapse)AuthorFilesLines
2018-03-03WIP: virtphy: Add L1CTL_DATA_ABS_REQ supportlaforge/virtphy-gprsHarald Welte4-1/+113
L1CTL_DATA_ABS_REQ is used for transmitting single uplink blocks at pre-determined frame numbers. This is required as part of the "polling" procedure for UL ACK of DL control blocks, which works irrespective of any USF. Change-Id: I77b168791cf972d8e625df54c4653b23f4abcb82
2018-02-23mobile: Fix memory leak when not using a LUA scriptHolger Hans Peter Freyther2-2/+1
The primitives are still allocated and dispatched but there was no script handler to delete them. Change the ownership to delete it at the end of the dispatch. Change-Id: I510af13bcbb46f73a0a289f26a4921cc90bd986a Fixes: OS#2925
2018-02-10mobile/primitives.c: fix format string compiler warningVadim Yanitskiy1-3/+7
The recent LUA integration code introduced the following compiler warnings (on GCC 4.8.5): primitives.c: In function ‘create_timer’: primitives.c:90:2: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘uint64_t’ [-Wformat=] primitives.c: In function ‘cancel_timer’: primitives.c:166:3: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 7 has type ‘uint64_t’ [-Wformat=] The recommended and portable way of printing an 'uint64_t' is to use the corresponding macros 'PRIu64'. Change-Id: Ic7f54063a35a89ad54dfa63868f43009cbe469bb
2018-02-08layer23/cell_log: set default logfile to /dev/nullVadim Yanitskiy1-1/+1
When '/var/log/osmocom.log' does not exist the cell_log app cannot start normally, because it has no permissions to create a new file. Furthermore, logfile is optional now. Change-Id: I2a9982f221871c78c5c9a73b7b7a1787ff07a86c
2018-02-06Import gprsdecode utility from SRLabsLuca Melette19-1/+7848
This change introduces a modified version of gprsdecode utility, which is intended to decode the GPRS burst captures and forward decoded packets to the GSMTAP sink. The following modifications were made: - use shared libosmocoding library for GSM 05.03 coding; - use optget for command line options parsing; - use a single application select loop; - use GNU automake as the build system; - add regression tests (GNU autotest); - clean up and comment the code; - add license headers; The code is based on work of SRLabs: git:// Related: OS#1672 Change-Id: I12234d37c66b83b8abd60f7511fa1d7837db1856
2018-02-06l1ctl_proto.h: define burst indication messagesSylvain Munaut1-0/+14
One burst indication message carries a single raw burst, forwarded to the higher layers from DSP. The burst bits are hard-bits (0 or 1) coming from demodulator, packed to 14.5 bytes. This is why we call them 'raw' - no bit correction nor deciphering is performed. Related: OS#1672 Change-Id: I75e33c38accdf2a0af961c89836c5e7a3a056bda
2018-01-22Don't ignore top-level MakefileMax2-1/+1
Move corresponding .gitignore entry inside virt-phy to avoid interfering with other subprojects still using hand-crafted Makefiles. Change-Id: I19a8661b74ae0b28da51cf2e81f0ca40de76fcbd
2018-01-22cosmetic: fix Makefile whitespaceMax1-1/+1
Change-Id: Ia55d54d7ec7ec04e122d2e5250037c2d166abeb5
2018-01-18mobile: Print an error message if the VTY cannot be initializedStefan Sperling1-1/+4
If we fail to initialize the VTY, print an error mesage instead of failing silently. For example: "Cannot init VTY on port 4247: Address already in use" Change-Id: I24161f53fa621ae1c8b1916bd0c8055c494b531e
2017-12-27mobile: Add lua examples for basic functions that are availableHolger Hans Peter Freyther5-0/+91
Link to Lua docs, link to our manual. Demo logging, timer, MS on/off, sms sending and sms receiving. For the MM state I will need to export constants/names to make this usable. Currently it is a bit of a hack (first time to MM_IDLE) to send a SMS. We would know when we attached though. Change-Id: I10ac656330b65e3905d6cbbb7865aa0f969cd9ff
2017-12-27mobile: Properly close the primitive interface on reloadHolger Hans Peter Freyther1-3/+6
When reloading a script go through script_lua_close. Get the primitive first. Then destruct the lua environment which will lead to GC (e.g. cancellation of timers) and then delete the primitive code. Change-Id: I5bb4fa9e7c5010f3ad50b258dcb14956eea8822a
2017-12-27mobile: Send SMS through the primitive interfaceHolger Hans Peter Freyther5-4/+39
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-13mobile/vty_interface.c: fix 'channel-capability' descriptionVadim Yanitskiy1-3/+6
Change-Id: I0c08e071ffaac9b8e7c4af6a7be2bd8125145842
2017-12-13mobile/gsm48_rr.c: cosmetic: drop wrong commentVadim Yanitskiy1-1/+0
Nothing is actually being skipped in this function. Change-Id: I9d5a33cf3a1dd7a75f9769d3c5ba85c59594b8f4
2017-12-13mobile/gsm48_rr.c: fix ACCH System Information parsingVadim Yanitskiy1-15/+11
According to GSM 04.08, the System Information messages, such as SI5, SI5ter, SI5bis and SI6 (described in sections 9.1.37-40), have no the 'L2 Pseudo Length' ( field, unlike others. So, previously the ACCH SI messages were ignored due to an implementation error - the gsm48_system_information_type_header struct isn't applicable here, because it assumes the 'l2_plen'. Since there is no (yet?) equivalent struct for the ACCH SI, this change replaces the wrong struct by the 'gsm48_hdr', which satisfies described requirements. Moreover, this change cleans up some gsm48_rr_rx_sysinfo* functions, getting rid of meaningless pionter shifting. Change-Id: I9166996f146af7973bf02a8a1c965581dc58a4a5
2017-12-07target/firmware: fix Mediatek firmware compilationCraig Comstock1-4/+6
The existing Makefile.mtk isn't compatible with the current Makefile scheme, so nothing would happen when it was called. This change updates the Makefile.mtk, so the Mediatek firmware can be successfully compiled again. Change-Id: Iecd619ed862f4d825095292ffde50544e647f6ff
2017-12-03mobile: Return the name of the configured "MS"Holger Hans Peter Freyther1-0/+7
In lua will print the name/number of the MS. This can be used by scripting code to use in events and then be analyzed. Change-Id: I881d3e87daa19f4e6f4f5bd30fe95906129e60ef
2017-12-03mobile: Simplify code and check the cb ref in load_cbHolger Hans Peter Freyther1-21/+14
Change parameters and check if the cb_ref is valid or not. Change-Id: I74fbcd7e853e24b1225ecc4c19304134b8467c9b
2017-12-03mobile: Use new LOGPSRCC macro to print multiple valuesHolger Hans Peter Freyther1-1/+2
We need continuation to avoid printing the logging category again. E.g. when print(one, two, three) is called. Change-Id: Id8491fa949768f170a8c74ab554cb1166afda1b7
2017-12-03mobile: Create "ms" singleton for struct osmocom_msHolger Hans Peter Freyther2-7/+271
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(; print(; print( print( 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"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) # Can fail. Best to wait for state changes... print( print( Change-Id: Ia3ace33d6ba4e904b1ff8e271a02d67777334a58
2017-12-03mobile: Add osmo.timeout for lua code to have timeoutsHolger Hans Peter Freyther1-2/+134
Allow to callback into lua code after a user configured timeout. Make it only work on seconds (truncate double to int). Change-Id: I355d2f8d15aeaa13abb1c5e4a8e0c958e5faf7f3
2017-12-03mobile: Add initial support for scripting supportHolger Hans Peter Freyther7-1/+227
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 Freyther3-1/+8
Change-Id: Id2d266c48d30c06dfdc3b8c84d875038b43f2ad8
2017-12-03mobile: Search for lua5.3 and link to itHolger Hans Peter Freyther2-2/+9
I will be adding a high-level async scripting interface to the mobile application. The initial implementation will use Lua 5.3. This version was released in January 2015 and is the latest version at the time the commit was made. Lua as extension and extensible language seems well suited for scripting. The plan is to attach a script to a ms and be able to trigger high level operations (send SMS, attach to network, detach). Change-Id: Ic649e49a22c878585a6c20b5b80108909f2374eb
2017-12-03mobile: Notify MM status changes and generate primitive op indHolger Hans Peter Freyther3-0/+24
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 Freyther4-1/+46
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 Freyther3-1/+61
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 Freyther7-3/+193
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 Freyther3-37/+70
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-12-03mobile: Fix compiler warning on printing ptrdiff_tHolger Hans Peter Freyther1-1/+1
The "msg->tail - msg->l4h" subtract two unsigned char* pointers and should result in a ptrdiff_t. Fix the compiler warning by using "%ti" in the printf. Fixes: gsm411_sms.c: In function ‘gsm411_rx_rp_ud’: gsm411_sms.c:382:25: warning: format ‘%li’ expects argument of type ‘long int’, but argument 7 has type ‘int’ [-Wformat=] LOGP(DLSMS, LOGL_INFO, "TPDU(%li,%s)\n", msg->tail-msg->l4h, ^ /home/ich/install/openbsc/include/osmocom/core/logging.h:93:54: note: in definition of macro ‘LOGPSRCC’ logp2(ss, level, caller_file, caller_line, cont, fmt, ##args); \ ^~~ /home/ich/install/openbsc/include/osmocom/core/logging.h:47:2: note: in expansion of macro ‘LOGPSRC’ LOGPSRC(ss, level, NULL, 0, fmt, ## args) ^~~~~~~ gsm411_sms.c:382:2: note: in expansion of macro ‘LOGP’ LOGP(DLSMS, LOGL_INFO, "TPDU(%li,%s)\n", msg->tail-msg->l4h, ^~~~ gsm411_sms.c:382:25: warning: format ‘%li’ expects argument of type ‘long int’, but argument 7 has type ‘int’ [-Wformat=] LOGP(DLSMS, LOGL_INFO, "TPDU(%li,%s)\n", msg->tail-msg->l4h, ^ /home/ich/install/openbsc/include/osmocom/core/logging.h:95:53: note: in definition of macro ‘LOGPSRCC’ logp2(ss, level, __BASE_FILE__, __LINE__, cont, fmt, ##args); \ ^~~ /home/ich/install/openbsc/include/osmocom/core/logging.h:47:2: note: in expansion of macro ‘LOGPSRC’ LOGPSRC(ss, level, NULL, 0, fmt, ## args) ^~~~~~~ gsm411_sms.c:382:2: note: in expansion of macro ‘LOGP’ LOGP(DLSMS, LOGL_INFO, "TPDU(%li,%s)\n", msg->tail-msg->l4h, Change-Id: Ia574fc7849bd00a94cf6651eb0d26fdc91ef1443
2017-11-30mobile: Use enum and not magic value in the VTYHolger Hans Peter Freyther1-1/+1
Change-Id: I8a1d975997e592344327e6b0783bd0c5d2534b02
2017-11-30mobile: Re-introduce msg_ref in struct gsm_smsHolger Hans Peter Freyther2-7/+10
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-30mobile: ms->shutdown was not converted properly to enumHolger Hans Peter Freyther1-1/+1
ms->shutdown is ms->shutdown != 0 which should have been converted to ms->shutdown != MS_SHUTDOWN_NONE. This is fixing sending SMS. This was introduced in Iee1140e4848923c7270495c381bf87b7e3fddee1. Change-Id: Ia74374dd9c0dd0ba9cf5725d66f4d2f2a2cfe9ef
2017-11-30mobile: Speculative crash fix of the SI pointerHolger Hans Peter Freyther1-0/+1
The SIs are kept per ARFCN and for the current cell the cs->si alias will be assigned[1]. On mobile_exit all SIs will be freed but the alias will not be set to NULL. This is a speculative fix but it doesn't seem to make things worse. Related: OS#2690 [1] cs->si = cs->list[cs->arfci].sysinfo; Change-Id: Icf20f9aa03dd26d4bee78772b7f3da034bb34b99
2017-11-27mobile: Avoid msg_ref going out of syncHolger Hans Peter Freyther3-13/+11
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 Freyther2-7/+21
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 Freyther7-27/+34
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 Freyther2-4/+5
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 Freyther5-12/+19
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-24mobile/vty_interface.c: fix Kc / Ki confusionVadim Yanitskiy1-2/+2
Change-Id: Ibbd1d080896b5cadc3d4281fe8f839a103a35088
2017-11-14layer23 vty: fix prompts: insert space after '#'Neels Hofmeyr1-3/+3
"All" our VTY prompts have a space after the prompt. Also do that for '(ms)', '(test-sim)' and '(support)' prompts. Change OsmocomBB(ms)#exit to OsmocomBB(ms)# exit Change-Id: Id437279e0fa9845630a306958b404efa3b94b492
2017-11-09mobile: Make VTY logging commands available to the mobile appHolger Hans Peter Freyther1-0/+2
So far logging_vty_add_cmds wasn't called. The main.c might be shared with other apps so place it into the routine that is setting up the VTY. Change-Id: I3db9cf288bce12f51e36caad44e9bc34094638f4
2017-11-09mobile/gsm322.c: prevent buffer over-/under-runVadim Yanitskiy1-0/+3
Change-Id: Ic12587a6c6456b8663e5357cf68a22c6d1927a07
2017-11-09mobile/gsm322.c: prevent calling memset() with zero lengthVadim Yanitskiy1-0/+4
This change prevents a possibility of calling memset() with constant zero length parameter, and the corresponding compiler warning. Change-Id: I2d8d78474614939659a7f24d5007b1c890776b1a
2017-11-09mobile: Do not exclude DGPS from the list of default categoriesHolger Hans Peter Freyther1-1/+1
I don't remember why we parse the categories like this. First if the mobile doesn't use a subsystem there is no harm to have it enabled, second the default levels can be adjusted for all apps and third we have the VTY to reconfigure these logging targets. Change-Id: Ia874b7ed127026b8395072a3bac2aed9944b1cce
2017-11-09vty: skip installing cmds now always installed by defaultNeels Hofmeyr5-7/+0
vty_install_default() and install_default() will soon be deprecated. Depends: I5021c64a787b63314e0f2f1cba0b8fc7bff4f09b Change-Id: I300a4b34a2031fd09d110ef18375d140a6dca7ba
2017-11-08host/mobile: use osmocom_ms as talloc contextVadim Yanitskiy10-35/+23
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: get rid of unused variables / functionsVadim Yanitskiy3-28/+19
Change-Id: Id867ffed9b2b67025320d002e1e009e19c759a23
2017-11-05mobile/gsm411_sms.c: use secure gsm_7bit_(en|de)code_nVadim Yanitskiy1-2/+4
Since some 'gsm_7bit_*' functions were deprecated and replaced by more secure ones with the '_n_' postfix in names, it's better to use the updated functions. Change-Id: I58150e9b74699e5f54b9a83416ad8efcb2eccd8e