aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc
AgeCommit message (Collapse)AuthorFilesLines
2014-03-12sms: WIP implementation of a delivery report aka SMS-STATUS-REPachemeris/sms_fixesAlexander Chemeris1-2/+117
2014-03-12sms: Use gsm_7bit_decode_n() in gsm340_rx_tpdu().Alexander Chemeris1-1/+1
gsm_7bit_decode() is deprecated and should not be used.
2014-03-12sms: Rename gsm340_gen_oa() to gsm340_gen_address_field().Alexander Chemeris1-3/+3
2014-03-12sms: Send the actual TP-Service-Centre-Time-Stamp with SMS-DELIVER instead ↵Alexander Chemeris1-1/+1
of a bogus current time.
2014-03-12sms,db: Update DB scheme to support more features in our SMSC.Alexander Chemeris3-12/+28
Do not store delivered messages in the DB. In a production system we should not store messages longer than needed, as it will quickly bloat our DB. In case one wants to store messages for debug purposes, we could add one of the following capabilities later: - hexdump to a log file - send to an SMPP entry on delivery - send to Wireshark sms,db: Store SMS Message Reference in the DB, since we need it to generate SMS-STATUS-REPORT. 03.40 9.2.3.6TP-Message-Reference (TP-MR) The SMS-STATUS-REPORT also contains a TP-Message-Reference field. The value sent to the MS will be the sameas the TP-Message-Reference value generated by the MS in the earlier SMS-SUBMIT or SMS-COMMAND to whichthe status report relates. sms,db: Add a 'type' filed to gsm_sms structure to be able diffrentiate normal DELIVER/SUBMIT messages from STATUS-REP messages.
2014-03-12sms: Rename gsm340_gen_tpdu() to gsm340_gen_sms_deliver_tpdu() to show that ↵Alexander Chemeris1-5/+5
it generates SMS-DELIVER TPDU and is not a generic function.
2014-03-12db,sms: Rename db_sms_mark_sent() to db_sms_mark_delivered(), as that's what ↵Alexander Chemeris2-3/+3
it does.
2014-03-12libmsc,sms: Properly calculate and store validity and received timestamps ↵achemeris/sms-validity-fixAlexander Chemeris2-10/+21
for incoming SMS.
2014-03-08db: Add testcase for the db migration.Holger Hans Peter Freyther1-0/+2
2014-03-08sms: Add code to migrate the database to the new schemaHolger Hans Peter Freyther1-16/+193
This is mostly based on Alexander's migration code. The code adds transaction handling and some sanity checks and cleanups to the code. We made the decision to fork the sms_from_result method and freeze it to that version. This way sms_from_result can move forward without having to deal with legacy.
2014-03-07sms: Do not store received id in the SMS database.Alexander Chemeris1-21/+10
That was a bad idea from the very beginning. A visible result of this is a wrong SMS routing when you change subscriber extensions, while having queued SMS. It's also a very wrong thing from the code layering perspective. I think the next logical step should be to remove "receiver" pointer from the gsm_sms structure into a structure, special for the internal SMS queue.
2014-03-07sms: Kill the sms->sender and use addr/ton/npi throughout the codeHolger Hans Peter Freyther3-35/+41
This is an incompatible database schema change. Store the type of the address in the database for both the sender and the receiver. Currently it is possible to use SMPP to store a SMS and the NPI and TON will be lost on the delivery of the SMS. The schema is changed to make the delivery always use the right NPI/TON. This patch is not ready for the master branch as there is no upgrade path for the HLR yet.
2014-03-07db: Remove the german from the log messageAlexander Chemeris1-1/+1
2014-03-06smpp_smsc: Fix integer overflow in read return value and msgb_alloc()Daniel Willmann1-6/+6
The size parameter of msgb_alloc is uint16_t so any length value above 65535 will allocate a msgb with incorrect size. This patch changes the type of rdlen and rc to ssize_t (the return value of read) and guards against the read length being larger than UINT16_MAX. To reproduce the issue run: echo -en "\x00\x01\x00\x01\x01" |socat stdin tcp:localhost:2775
2014-03-06smpp_smsc: Check that the size is large enough to hold actual dataDaniel Willmann1-0/+6
The first 4 bytes are the length including the length field. For length < 4 the subsequent msgb_put(msg, sizeof(uint32_t)) will fail, resulting in an abort. The code also expects (in smpp_msgb_cmdid()) the existence of 4 more bytes for the SMPP command ID. This patch checks that the length received is large enough to hold all 8 bytes in the msgb and drops the connection if that's not the case. The issue is reproducible with: echo -e "\x00\x00\x00\x02\x00" |socat stdin tcp:localhost:2775
2014-03-06smpp_smsc: Fix socket read() error handlingDaniel Willmann1-16/+31
Read returning -1 is an error here so make sure to print the actual reason and close the socket. Before this patch we just looped over the fd with read returning -1 every time. EINTR is handled to not cause an error and we don't need to check EAGAIN/EWOULDBLOCK since the callback is only called in case there is something to read. To avoid copy&paste issues the check is implemented as a macro and the log message moved into a separate if.
2014-02-24sms: Address the TODO and schedule the next SMS for an active subscriberHolger Hans Peter Freyther1-6/+45
When one SMS has been delivered check if a second SMS can be scheduled to that subscriber. If nothing can be scheduled kick the normal SMS queue as one slot has become free now. Otherwise send the SMS and create a pending entry.
2014-02-24sms: Do not interfere with the SMS queue from within gsm_04_11Holger Hans Peter Freyther2-17/+6
It was possible that two SMS would be delivered at the same time which violates GSM 04.11. We should solely rely on the sms queue to schedule more SMS to the subscriber.
2014-02-21SMPP: UCS2 data_coding is 0x08, not 0x80!Harald Welte1-1/+1
As can clearly be seen from SMPP Spec v3.4 Chapter 5.2.19, a SUBMIT-SM with data_coding == 0x08 is UCS2, not with 0x80. Thanks to ciaby@rhizomatica.org for reporting the bug.
2014-02-20sms: Increment the RP Message Reference for each transactionHolger Hans Peter Freyther3-3/+41
Each RP-DATA should have a unique msg reference. Currently 42 is used for all of these. Remember the last reference we used and increment it on the next SMS. Do not track if the reference is still in use a clash is a lot less likely now. First unless SMPP is used only one SMS is delivered at a time, second the transaction space is a lot smaller than the one for the reference.
2014-01-31sms/dtap: Add log messages to analyse SMS message lossJacob Erlbeck3-0/+10
Incoming DTAP messages from MS are discarded during silent calls, which leads to the repeated delivery of SMS since the ACKs are not being processed. This patch adds some log messages that have been helpful to track this down. Sponsored-by: On-Waves ehf
2014-01-27Add function to update TRAU muxer after assignment or handoverAndreas Eversberg1-3/+16
E1 based BTS use TRAU muxer to decode TRAU frames. After changing channel from one timeslot to another (due to handover or assignment), the TRAU muxer must be updated. The call reference of the call is disconnected from the old channel and connected to the new channel.
2014-01-16Remove obsolete check of conn and lchan pointers not beeing NULLAndreas Eversberg1-4/+2
The check is removed from gsm48_cc_rx_setup() and gsm48_cc_rx_call_conf(). Receiving a layer 3 message implies that the transaction has a subscriber connection and a logical channel. This patch fixes the Coverity issues with CID 115311 and CID 1155312.
2014-01-14Each BTS can be configured for speech support (other than GSM full rate)Andreas Eversberg2-1/+29
Speech codings which are not supported by BTS will be removed from the bearer capability information element after parsing. This way it is not required for the MNCC application to consider support of each BTS. Only GSM full rate is supported by default.
2014-01-08nitb: Set the DST field in generated MM info messagesJacob Erlbeck1-0/+15
Currently the NET_DST information element (see GSM 24.008) is not included in generated MM info messages even when the DST field in the timezone info has been set via the VTY or the control interface. This patch modifies gsm48_tx_mm_info() to append this information element if (and only if) a non-zero DST has been configured. The DST IE is not part of GSM 4.8. Therefore it will only be sent, if the DST offset is configured to a value != 0. The DST functionality has been verified with wireshark by Jacob. Sponsored-by: On-Waves ehf
2013-12-29smpp: In case we know the receiver set the context for loggingHolger Hans Peter Freyther1-0/+2
2013-12-29mncc: Add the context we get from the MNCC interfaceHolger Hans Peter Freyther1-0/+13
Currently we only set the SUBSCR on RSL messages. Extend it to messages that go through MNCC. For call control/bridging it is difficult to pick the right subscriber. We should support a list or at least two legs in the imsi filter context.
2013-12-28ussd: Reject and release unhandled SS requests/interrogationTobias Engel1-1/+9
In case the unpack of a USSD request is failing the channel would remain open and the phone would not receive a response. Simply reject the interrogation. Example interrogation: 0000 1b 7b 1c 0d a1 0b 02 01 01 02 01 0e 30 03 04 01 0010 11 7f 01 00
2013-12-27sms: Fix crash on RLL Establish Request timeouts with active callHolger Hans Peter Freyther1-13/+18
Sylvain pointed out that in the current crash log the transaction we try to read the SMS from is actually a transaction for Call Control. On AMD64 the struct layout is different and that leads to a crash when the CC transaction is in front of the SMS transaction. Look at the trans->protocol to fix the crash. The issue got introduced in 6a3d765bf97349535602ed5b2b55d2093aa18d71 (2010) when I added the SAPI N Reject handling. #0 smpp_sms_cb (subsys=1, signal=4, handler_data=0xbb8270, signal_data=0x7fff33574ea0) at smpp_openbsc.c:284 284 if (sms->source != SMS_SOURCE_SMPP) (gdb) bt #0 smpp_sms_cb (subsys=1, signal=4, handler_data=0xbb8270, signal_data=0x7fff33574ea0) at smpp_openbsc.c:284 #1 0x00007f424e4a094c in osmo_signal_dispatch (subsys=1, signal=4, signal_data=0x7fff33574ea0) at signal.c:105 #2 0x000000000042b070 in send_signal (sig_no=<optimized out>, trans=<optimized out>, sms=<optimized out>, paging_result=<optimized out>) at gsm_04_11.c:125 #3 0x000000000042ccd2 in gsm411_sapi_n_reject (conn=0xec6790) at gsm_04_11.c:1000 #4 0x0000000000408983 in send_sapi_reject (link_id=<optimized out>, conn=<optimized out>) at bsc_api.c:733 #5 rll_ind_cb (_data=<optimized out>, lchan=<optimized out>, link_id=<optimized out>, rllr_ind=<optimized out>) at bsc_api.c:755 #6 rll_ind_cb (lchan=<optimized out>, link_id=<optimized out>, _data=<optimized out>, rllr_ind=<optimized out>) at bsc_api.c:736 #7 0x000000000041f8d2 in complete_rllr (rllr=<optimized out>, type=<optimized out>) at bsc_rll.c:55 #8 0x00007f424e4a03bc in osmo_timers_update () at timer.c:243 #9 0x00007f424e4a069b in osmo_select_main (polling=0) at select.c:133 #10 0x0000000000407394 in main (argc=<optimized out>, argv=0x7fff33575238) at bsc_hack.c:346 (gdb) frame 3 #3 0x000000000042ccd2 in gsm411_sapi_n_reject (conn=0xec6790) at gsm_04_11.c:1000 1000 send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0); (gdb) p trans $1 = (struct gsm_trans *) 0xedba80 (gdb) p *trans .... data = 0x1}}, sms = 0x3439323400000003}}} (gdb) p trans->protocol $4 = 3 '\003'
2013-12-27db: Avoid crash we have seen with the dbi code when reading a SMSHolger Hans Peter Freyther1-0/+15
Avoid a crash when reading a SMS and a Subscriber could not be resolved. It is not clear why the read was failing. The sender_id and the receiver_id was valid for the given sms. I assume that the database has been locked due external access to it. The side-effect is that in case of such a failure the sms_queue will start to deliver starting from subscriber id = 0 again. #1 0x0000000000428bec in sms_from_result (net=0x156a270, result=0x15eda30) at db.c:1146 #2 0x000000000042a8e0 in db_sms_get_unsent_by_subscr (net=0x156a270, min_subscr_id=<optimized out>, failed=<optimized out>) at db.c:1255 #3 0x000000000042e900 in take_next_sms (smsq=<optimized out>) at sms_queue.c:193 #4 sms_submit_pending (_data=0x158e300) at sms_queue.c:227 #5 0x00007f3fd30de3bc in osmo_timers_update () at timer.c:243 #6 0x00007f3fd30de69b in osmo_select_main (polling=0) at select.c:133 #7 0x0000000000406fbc in main (argc=9, argv=<optimized out>) at bsc_hack.c:346 (gdb) frame 1 #1 0x0000000000428bec in sms_from_result (net=0x156a270, result=0x15eda30) at db.c:1146 1146 strncpy(sms->src.addr, sms->sender->extension, sizeof(sms->src.addr)-1); (gdb) p *sms (gdb) p sms->sender $1 = (struct gsm_subscriber *) 0x0 (gdb) p sender_id $2 = <optimized out>
2013-12-27libmsc: Set the "trans->conn" to NULL to catch invalid usageHolger Hans Peter Freyther1-1/+1
Make finding use-after-free more easy and set it to NULL.
2013-12-27lu crash: Fix a crash that likely occurred during the LU procedureHolger Hans Peter Freyther1-0/+3
conn->loc_operation is already NULL (e.g. due a five second timeout but we are still processing a RSL message after we initiated the release procedure). Do not attempt to authorize a subcriber without knowing the key_sequence. This can cause more problems but we will need to test this in the field. (gdb) bt #0 gsm0408_authorize (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:323 #1 gsm0408_authorize (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:319 #2 0x000000000043a99a in mm_rx_id_resp (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:495 #3 gsm0408_rcv_mm (msg=<optimized out>, conn=0x19fc2f0) at gsm_04_08.c:1041 #4 gsm0408_dispatch (conn=0x19fc2f0, msg=<optimized out>) at gsm_04_08.c:3232 (gdb) p *conn $5 = {entry = {next = 0x1746930, prev = 0x1a14270}, subscr = 0x1745eb0, expire_timer_stopped = 1 '\001', loc_operation = 0x0, sec_operation = 0x0, anch_operation = 0x0, silent_call = 0, put_channel = 0, sccp_con = 0x0, in_release = 0, lchan = 0x7f8c79007218, ho_lchan = 0x0, bts = 0x1719f90, T10 = {node = { rb_parent_color = 0, rb_right = 0x0, rb_left = 0x0}, list = {next = 0x0, prev = 0x0}, timeout = {tv_sec = 0, tv_usec = 0}, active = 0, cb = 0, data = 0x0}, secondary_lchan = 0x0}
2013-12-27periodic/lu: Attempt to implicitly attach a subscriber instead of rejectingHolger Hans Peter Freyther1-4/+17
When modern Smartphones receive "Not in VLR". The baseband firmware apparently does not try to do an IMSI ATTACH but just remains un-happy and will not connect to the network anymore.
2013-12-27Revert "gsm_04_11: Speculative fix for MT SMS and SAPI 'n Reject"Holger Hans Peter Freyther1-2/+0
Let's revert it and see if we can find the real issue about the sms being invalid. Sylvain has pointed out that we get invoked from a timer and might not have stopped it properly. This reverts commit 80ba9b5dd62cc8bfd10dae2f3b63420ef1e8452d.
2013-12-27gsm_04_11: Speculative fix for MT SMS and SAPI 'n RejectHolger Hans Peter Freyther1-0/+2
I am not sure why it is crashing so this is a speculative fix based on something we already did in 3e9b2ec257bc064b866ce6a2735206dc6131f615. #0 sms_find_pending (smsq=0x2706300, sms=<optimized out>) at sms_queue.c:77 #1 sms_sms_cb (subsys=<optimized out>, signal=4, handler_data=0x26e2270, signal_data=0x7fffdac256c0) at sms_queue.c:396 #2 0x00007fcdea94394c in osmo_signal_dispatch (subsys=1, signal=4, signal_data=0x7fffdac256c0) at signal.c:105 #3 0x000000000042acc0 in send_signal (sig_no=<optimized out>, trans=<optimized out>, sms=<optimized out>, paging_result=<optimized out>) at gsm_04_11.c:124 #4 0x000000000042c8e2 in gsm411_sapi_n_reject (conn=0x2722d30) at gsm_04_11.c:999 #5 0x00000000004085d3 in send_sapi_reject (link_id=<optimized out>, conn=<optimized out>) at bsc_api.c:733 #6 rll_ind_cb (_data=<optimized out>, lchan=<optimized out>, link_id=<optimized out>, rllr_ind=<optimized out>) at bsc_api.c:755 #7 rll_ind_cb (lchan=<optimized out>, link_id=<optimized out>, _data=<optimized out>, rllr_ind=<optimized out>) at bsc_api.c:736 #8 0x000000000041f522 in complete_rllr (rllr=<optimized out>, type=<optimized out>) at bsc_rll.c:55 #9 0x00007fcdea9433bc in osmo_timers_update () at timer.c:243 #10 0x00007fcdea94369b in osmo_select_main (polling=0) at select.c:133 #11 0x0000000000406fbc in main (argc=9, argv=<optimized out>) at bsc_hack.c:346
2013-12-26sms: Move to gsm_7bit_encode_n in the sms sending codeHolger Hans Peter Freyther1-1/+2
Do not rely on the potential wrong gsm_7bit_encode result but use gsm_7bit_encode_n with maximum available space.
2013-12-26ussd: Move to use gsm_7bit_encode_n_ussd for USSD encodingHolger Hans Peter Freyther1-1/+1
The legacy functions have a bad/wrong return value for the number of septets in the string. Change the code to use the new functions which will fix encoding issues as well.
2013-12-26db: Fetch the authorized key using ulonglongKevin Redon1-2/+3
Location Update Requests time out and get rejected because the subscriber is not authorized. Authorizing the subscriber through openBSC or sqlite3 doesn't help the subscriber is still seen and shown as not authorized The value is read as uint, this is the wrong type it's a (u)longlong in libdbi 0.9.0 and later.
2013-12-19Add EFR support to TRAU muxer + test caseAndreas Eversberg1-0/+1
Decoding and encoding of FR and EFR TRAU frames are put into seperate functions. CRC check is done to detect bad EFR TRAU frames. The test case includes FR and EFR transcoding. EFR support was tested with Nokia InSite BTS and Siemens BS11.
2013-11-01bsc: Move gsm48_tx_mm_serv_ack/rej to gsm_04_08_utils.cJacob Erlbeck1-23/+0
These functions are currently located in libmsc/gsm_04_08.c together with other symbols that (transitively) depend on many external symbols (and thus libraries) that aren't otherwise needed by e.g. osmo-bsc. Since gsm48_tx_mm_serv_ack() will be needed by osmo-bsc, these functions are moved to avoid the dependency on gsm_04_08.o. Sponsored-by: On-Waves ehf
2013-10-31Revert "bsc/ussd: Send faked CM Service Accept before sending USSD"Holger Hans Peter Freyther1-2/+2
This reverts commit 61bd965b04e4f00eaf4196eebb4ec6269926d551. No, we should not link to dbi.. and these libraries..
2013-10-31bsc/ussd: Send faked CM Service Accept before sending USSDJacob Erlbeck1-2/+2
The MS do not show the USSD messages yet. This patch modifies the implementation to insert a CM Service Accept before the ussdNotify to finish the establishment of the MM connection according to 3GPP TS 04.10/3.2.1. This fix has been tested with a Blackberry phone that has shown an ussd_grace_txt after rf_locked has been set to '1'. Without this patch, that message wasn't shown. The phone has sent a CC Setup and other messages before processing the channel release message sent by the BSC, but these messages have not been forwarded to the MSC (as expected). Ticket: OW#957 Sponsored-by: On-Waves ehf
2013-10-30vty: Use vty_install_default() instead of bsc_install_default()Jacob Erlbeck2-4/+3
Remove ournode_exit_cmd, ournode_end_cmd, and bsc_install_default() since this functionality is provided by the current libosmocore. Replace calls to bsc_install_default() by call to vty_install_default() with the following semantic patch: @rule1@ expression N; @@ - bsc_install_default(N); + vty_install_default(N); Ticket: OW#952 Sponsored-by: On-Waves ehf
2013-10-15ussd: Fix test for RELEASE COMPLETEAlexander Huemer1-1/+1
A correcsponding change in libosmocore sets text[0] to '\0'. The test for 0xFF could never have been true.
2013-10-13db: Remove the struct gsm_network from the database layerHolger Hans Peter Freyther4-13/+27
The database code should not know about the network. Move the setting of the network pointer into the subscriber layer.
2013-10-05nitb: Add "subscriber create" VTY command.Alexander Chemeris1-0/+27
It may be useful in production, but it's really required for VTY testing of subscriber related commands.
2013-10-04sms: Possiqble meamleak fix gsm340_rx_tpdu()Alexander Chemeris1-3/+4
Slight clean up of the code in gsm340_rx_tpdu() and a fix for an unlikely, but possible memory leak there.
2013-10-04Fix typo in console output: "PEROIDOC" -> "PERIODIC".Alexander Chemeris1-1/+1
2013-10-04Fix typo ',' -> ';' at the end of a line.Alexander Chemeris1-1/+1
Funny, this is a correct C expression and doesn't change execution, thus it stayed unnoticed for quite a while.
2013-09-19smpp: Fix the make distcheck for smppHolger Hans Peter Freyther1-0/+1
DISTCHECK_CONFIGURE_FLAGS="--enable-smpp" make distcheck