aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/libmsc/smpp_openbsc.c
AgeCommit message (Collapse)AuthorFilesLines
2019-02-28Don't deliver alert notifications to an ESME thatKeith1-0/+5
is not yet bound. We create a new ESME in smsc->esme_list on establishment of a TCP connection, yet we do not know the system id or anything else, until the ESME identifies and authenticates. So do not send alert notifications until we know the bind status (and system_id) Change-Id: I0e5d55d3fb6ac46d253902df2fe304e1b0fc8bbf
2019-01-17Make alert notifications vty configurable per ESMEKeith1-2/+6
OSMO-MSC backport Adds (no) alert-notifications as a per-esme vty command, in order to allow some ESMEs to be excluded from alerts. The default is still to send alert notifications to all esme, so no changes are required to the config file to maintain identical operation after this patch. Change-Id: I2b52f2778b24eebc82b2e5e2fb3c2250b1f9e5b0
2017-09-11libmsc: annotate esme route in the sms object from deliver_to_esme()Pablo Neira Ayuso1-0/+4
Annotate this esme route, so we can use it to return -EINPROGRESS to skip sending premature RP-ACK to the mobile station, in case we're handling sms routes through SMPP. Now that we have this information in place, we use it wherever possible to avoid kludgy checks on sms->receiver. sms_free() already releases references to this object, so we should be fine with this. Fixes: 4e5b90a594f9 ("libmsc: remove 'deferred' parameter in sms_route_mt_sms()") Change-Id: Ib8a8fd9bbb0d3b6aff7931e4bacbea99d000e484
2017-08-18libmsc: Fix wrong handling of user_message_reference parameterPau Espin Pedrol1-2/+2
libsmpp34 already converts received TLV integer values to native endianess in libsmpp34_(un)pack. Converting them again at receive time swaps the 2 bytes of user_message_reference, then using a wrong value. As GSM03.40 spec uses only 1 byte for the id, then only the high byte of the initial value is used and eventually sent back to the ESME. Again, at that time, htons() is not needed because libsmpp34 already handles that part. See OS-#2429 for more details. Change-Id: If748548a4a223e529a1110c89e483b599b406e8b
2017-08-16smpp: Fix compilation warningPau Espin Pedrol1-1/+1
I already stumbled into 2 compilation environments which had Werror enabled for -Wmaybe-uninitialized and the build failed, so let's workaround this warning. | smpp_openbsc.c: In function 'handle_smpp_submit': | smpp_openbsc.c:216:9: error: 'sms_msg_len' may be used uninitialized in this function [-Werror=maybe-uninitialized] | memcpy(sms->user_data, sms_msg, sms_msg_len); | ^ | smpp_openbsc.c:100:15: note: 'sms_msg_len' was declared here | unsigned int sms_msg_len; | ^ | cc1: some warnings being treated as errors Change-Id: I0901ddadb5f72e1585cb1797ac22c8ab95e83146
2017-08-15libmsc: use SMPP34_DELIVERY_RECEIPT_* in libsmpp34Pablo Neira Ayuso1-7/+1
Use new definitions in libsmpp34 to set the registered_delivery field accordingly, as provided by I5b3afff1b3b77cccd949e0606914c7ac3ba6114c. Moreover, do not set this header field to zero if status reports are off, the deliver_t structure has been already zeroed so this not required. Change-Id: Ie78e17323796120f576b9c0e1bc5ccc32da8ee12
2017-08-13libmsc: use new smpp34 esm_class definitionsPablo Neira Ayuso1-10/+8
Replace magic numbers by esm_class definitions, which have been added to latest libsmpp34 in Change-Id I91afd8b462b8fd3b2c4c5b54f4eeb7ec5b730b65 Change-Id: I6c458690da60c8f3637680efbd718f6e8c6feb4c
2017-08-12libmsc: use smpp34_tlv_for_each() to avoid suboptimal TLV handlingPablo Neira Ayuso1-30/+40
submit_to_sms() now handles two TLVs, so find_tlv() is suboptiomal and it can be removed, since it would result in two passes on the TLV list. Use new smpp34_tlv_for_each() helper to iterate over the list of TLVs that is available since I446929feed049d0411e1629ca263e2bc41f714cc. Change-Id: I53a65164a6cc4abc6bf57d9a8dc275cf21c90222
2017-08-09libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status reportPablo Neira Ayuso1-0/+4
This patch adds gsm340_sms_send_status_report_tpdu() to build a status-report. Moreover, set sms->report field if we see a SMPP SUBMIT_SM with Delivery Acknowledgment esm_class, so this identifies that this is a delivery report. MS GSM 03.40 SMSC SMPP 3.4 ESME | | | | | SUBMIT-SM | | | esm_class = Delivery Ack | | |<-------------------------------| | | SUBMIT-SM-RESP | | |------------------------------->| | | | | SMS-STATUS-REPORT | | |<----------------------------| | | GSM 04.11 RP-ACK | | |---------------------------->| | | | | There is a FIXME message in this patch, that I just copied from gsm340_gen_sms_deliver_tpdu() since TP-MMS is not supported by OpenBSC. Change-Id: Ib70e534840308ed315f7add440351e649de3f907
2017-08-09libmsc: add support for SMPP delivery receiptsPablo Neira Ayuso1-1/+20
If the mobile phone requests a status report via SMS, send a DELIVER_SM with esm_class = Delivery Receipt to ESME to indicate that the SMS has been already delivered to its destination. MS GSM 03.40 SMSC SMPP 3.4 ESME | | | | SMS-DELIVER | | |<----------------------------| | | GSM 04.11 RP-ACK | | |---------------------------->| | | | DELIVER-SM | | | esm_class = Delivery Receipt | | |------------------------------->| | | DELIVER-SM-RESP | | |<-------------------------------| | | | This patch implements "Appendix B. Delivery Receipt Format" as specified in the SMPP 3.4 specs. This string is conveyed in the SMS message as data, and it is only meaningful to the ESME, for logging purposes. The "submit date" and "done date" are not yet set, and other fields are just sent with dummy values, so they are left to be finished as future work. The new SMPP TLV tag TLVID_user_message_reference is added to the SMPP messages inconditionally now since this information is required by delivery-reports to associate the status-report with the original SMS. Change-Id: Ic1a9023074bfa938099377980b6aff9b262fab2a
2017-08-09libmsc: report status report request flag from SMPP SUBMIT_SMPablo Neira Ayuso1-0/+1
Restore the sms status report request flag from SUBMIT_SM. Change-Id: Iac05252253f8933a3875b4904599b7a225191a4b
2017-08-09libmsc: set registered_delivery field in SMPP 3.4 DELIVER_SM messagesPablo Neira Ayuso1-1/+8
Propagate the status report request field to the SMPP message through the registered_delivery field, so the ESME knows that the mobile phone is asking for explicit delivery acknowledgment is required. See SMPP 3.4 specs section 5.2.17. Change-Id: I59af60fa89cd10ae973c5e122789e3e03e3728ee
2017-08-08libmsc: remove 'deferred' parameter in sms_route_mt_sms()Pablo Neira Ayuso1-17/+13
No need to cache the sms object, just cache what we need into the smpp_cmd structure. This simplifies what that I introduced in 93ffbd0029d1 ("libmsc: send RP-ACK to MS after ESME sends SMPP DELIVER-SM-RESP"). Change-Id: Iba5f864f9bb963baff95969e306b1b7cff00c1e3
2017-08-08libmsc: remove duplicate lines in deliver_to_esme()Pablo Neira Ayuso1-2/+0
This code is accidentally doing the same thing twice, remove it. Change-Id: I68087a850399e22951d2407e4d8a09c671a775c9
2017-08-08libmsc: do not leak pending SMPP command object on error pathPablo Neira Ayuso1-5/+6
Make sure the SMPP command object is released on errors. Change-Id: I474584425d23fb379a9d71b33e29ac0e24f01e61
2017-07-08smpp: fix return causeBenoit Bolsee1-4/+5
Return cause 38 when default SMPP route is unavailable. This is better than cause 1. Change-Id: If3241d50a78fa611981e55fef6ae4c72b0a2a167
2017-05-20libmsc: Map SMPP command status to GSM 04.11 causeKeith1-4/+39
Send SMS RP ERROR with a failure cause that relates to the status returned by the ESME in the deliver_sm_resp. Actual mapping array is limited as most phones I tested don't seem to care about the failure cause anyway, although some will display a different notification for GSM411_RP_CAUSE_MO_NUM_UNASSIGNED Change-Id: I61fb2d9ef4f2d2eabdc49b53d9966ad328d15e51
2017-05-10src: use osmo_timer_setup()Pablo Neira Ayuso1-2/+1
Use new function available in libosmocore to set up timers. Compile tested only. Change-Id: Ibcfd915688e97d370a888888a83a7c95cbe16819
2017-05-08libmsc: send RP-ACK to MS after ESME sends SMPP DELIVER-SM-RESPPablo Neira Ayuso1-5/+122
Hold on with the GSM 04.11 RP-ACK/RP-ERROR that we send to the MS until we get a confirmation from the ESME, via SMPP DELIVER-SM-RESP, that we can route this sms somewhere we can reach indeed. After this change, the conversation looks like this: MS GSM 03.40 SMSC SMPP 3.4 ESME | | | | SMS-SUBMIT | | |------------------->| | | | DELIVER-SM | | |---------------->| | | | | | DELIVER-SM-RESP | | |<----------------| | GSM 04.11 RP-ACK | | |<-------------------| | | | | Before this patch, the RP-ACK was sent back straight forward to the MS, no matter if the sms can be route by the ESME or not. Thus, the user ends up getting a misleading "message delivered" in their phone screen, when the message may just be unroutable by the ESME hence silently dropped. If we get no reply from the ESME, there is a hardcoded timer that will expire to send back an RP-ERROR to the MS indicating that network is out-of-order. Currently this timer is arbitrarily set to 5 seconds. I found no specific good default value on the SMPP 3.4 specs, section 7.2, where the response_timer is described. There must be a place that describes a better default value for this. We could also expose this timer through VTY for configurability reasons, to be done later. Given all this needs to happen asyncronously, ie. block the SMSC, this patch extends the gsm_sms structure with two new fields to annotate useful information to send the RP-ACK/RP-ERROR back to the MS of origin. These new fields are: * the GSM 04.07 transaction id, to look up for the gsm_trans object. * the GSM 04.11 message reference so the MS of origin can correlate this response to its original request. Tested here using python-libsmpp script that replies with DELIVER_SM_RESP and status code 0x0b (Invalid Destination). I can see here on my motorola C155 that message cannot be delivered. I have tested with the success status code in the SMPP DELIVER_SM_RESP too. Change-Id: I0d5bd5693fed6d4f4bd2951711c7888712507bfd
2017-05-08libmsc: use GSM411_RP_CAUSE_MO_NUM_UNASSIGNED as return valuePablo Neira Ayuso1-1/+1
Instead of hardcoded value of 1 plus comment of the right hand side of the statement. Change-Id: I865bdbd6da17a0389044a8e749deeeebcb9cae06
2017-04-26Fix MS TO measurement representationMax1-2/+2
* set proper flag when saving MS Timing Offset * use gsm_subscriber's IMSI or lchan's name if bsc_subscriber is unknown * add comments with spec reference * store/display MS Timing Offset instead of raw Timing Offset field from RSL * Compute MS Timing Offset [-63; 192] from Timing Offset field [0; 255], adjust structure gsm_meas_rep with proper type to store it Change-Id: I7e003d23a6edb714c5f17688fd6a8edac131161d Related: OS#1574
2017-02-23logging fixup: shorter names for LOGGING_FILTER_* and LOGGING_CTX_*Neels Hofmeyr1-1/+1
In libosmocore, my patch was merged to master a bit too soon. To accomodate the request for naming that matches the general "LOG" prefix instead of "LOGGING", a fixup was committed to libosmocore. Adjust for that. Original patch: change-id I5c343630020f4b108099696fd96c2111614c8067 The fixup: change-id I424fe3f12ea620338902b2bb8230544bde3f1a93 Change-Id: Ib2ec5e4884aa90f48051ee2f832af557aa525991
2017-02-22logging: use central filter and ctx consts from libosmocoreNeels Hofmeyr1-1/+1
The LCHAN and BTS filter contexts are actually never used, so drop them until someone adds them properly. For now use only LOGGING_{FILTER,CTX}_VLR_SUBSCR. Some of these will change to _BSC_SUBSCR once struct bsc_subscriber is introduced, and later on, struct gsm_subscriber will be replaced by vlr_subscriber so that the names will match. Depends: libosmocore change-id I5c343630020f4b108099696fd96c2111614c8067 Change-Id: Ifa82f6a461ad4c0eeddb8a38fb3833460432d16b
2017-01-23cosmetic: use osmo_strlcpy() everywhereNeels Hofmeyr1-2/+3
Shorten some code and make obvious to the reader that the string copy is done in a safe way. Change-Id: I900726cf06d34128db22a3d3d911ee0d1423b1bd
2016-12-24Pass actual smpp_avail_status through to smpp in alert_all_esme()Keith1-2/+2
Change-Id: I4b00d8821c1688ca0c990b6042607f4ded0f80e3
2016-02-25smpp: refactor initialization, add bind addressNeels Hofmeyr1-16/+27
Make the SMPP bind address configurable (used to be harcoded as "0.0.0.0"). Add VTY command smpp local-tcp A.B.C.D <1-65535> while keeping the old command 'local-tcp-port <1-65535>'. Both the old and the new command immediately change the SMPP listening address and port. Add a LOGL_NOTICE log when the SMPP listening address and/or port change. However, to be useful, this patch has to go somewhat further: refactor the initialization procedure, because it was impossible to run the VTY commands without an already established connection. The SMPP initialization procedure was weird. It would first open a connection on the default port, and a subsequent VTY port reconfiguration while reading the config file would try to re-establish a connection on a different port. If that failed, smpp would switch back to the default port instead of failing the program launch as the user would expect. If anything else ran on port 2775, SMPP would thus refuse to launch despite the config file having a different port: the first bind would always happen on 0.0.0.0:2775. Change that. In the VTY commands, merely store address and port if no fd is established yet. Introduce several SMPP initialization stages: * allocate struct and initialize pointers, * then read config file without immediately starting to listen, * and once the main program is ready, start listening. After that, the VTY command behaves as before: try to re-establish the old connection if the newly supplied address and port don't work out. I'm not actually sure why this switch-back behavior is needed, but fair enough. In detail, replace the function smpp_smsc_init() with the various steps smpp_smsc_alloc_init() -- prepare struct for VTY commands smpp_smsc_conf() -- set addr an port only, for reading the config file smpp_smsc_start() -- establish a first connection, for main() smpp_smsc_restart() -- switch running connection, for telnet VTY smpp_smsc_stop() -- tear down connection, used by _start() twice And replace smpp_openbsc_init() smpp_openbsc_set_net() with smpp_openbsc_alloc_init() smpp_openbsc_start() I'd have picked function names like "_bind"/"_unbind", but in the SMPP protocol there is also a bind/unbind process, so instead I chose the names "_start", "_restart" and "_stop". The smsc struct used to be talloc'd outside of smpp_smsc_init(). Since the smsc code internally uses talloc anyway and employs the smsc struct as talloc context, I decided to enforce talloc allocation within smpp_smsc_alloc_init(). Be stricter about osmo_signal_register_handler() return codes.
2015-08-08subscr: Fix subscr refcount issue in case of message errorHolger Hans Peter Freyther1-0/+2
In case the SMPP payload didn't include the right fields we would leak the subscr reference count.
2015-07-06sms: Add a way to always route SMS through SMPP systemsHolger Hans Peter Freyther1-0/+5
default-route would only be looked at after there has been no subscriber in the local database. Depending on the setup this is not what one wants. This has been discussed at the OsmoDevCon and there have been hacks in some branches. Let's introduce a VTY command to select if SMPP should be consulted first and then fallback to the current behavior.
2015-02-08smpp: Fix potential crash in handling submitSMHolger Hans Peter Freyther1-3/+4
In case: * No message_payload and a 0 sm_length was used * esm_class indicates UDH being present * 7bit encoding was requested The code would execute: ud_len = *sms_msg + 1; Which is a NULL pointer dereference and would lead to a crash of the NITB. Enforce the limits of the sm_length parameter and reject the messae otherwise. Fixes: Coverity CID 1042373
2015-02-08smpp: Do not check conn for being nullHolger Hans Peter Freyther1-1/+1
We are deferencing conn earlier in this function without doing a null check. At the time deliver_to_esme is called the conn will always exist and even the lchan is likely to be present. Remove the null check for conn right now. Fixes: Coverity CID 1210594
2014-12-05msc: Add and use gsm_subscriber_groupJacob Erlbeck1-2/+2
Currently every subcriber object directly refers to the gsm_network which contains a flag shared by every related subscriber (keep_subscr). This adds a dependency on gsm_network even if only the function defined in gsm_subscriber_base.c are used. This patch adds a new struct gsm_subscriber_group which contains the keep_subscr flag and a back reference to the network object. The latter is not dereferenced in gsm_subscriber_base.c, so it can safely be set to NULL when only that part of the gsm_subscriber API is being used. It also changes that API to use gsm_subscriber_group instead of gsm_network parameters. Since there are some places where a pointer to the gsm_network is needed but where only a gsm_subscriber is available, a 'net' back pointer is added to the group struct, too. Nevertheless subscr group and network could be separated completely, but this is not the topic of this commit. Sponsored-by: On-Waves ehf
2014-07-19smpp: Fix small typo in the commentHolger Hans Peter Freyther1-1/+1
2014-04-30sms: Kill the sms->sender and use addr/ton/npi throughout the codeHolger Hans Peter Freyther1-3/+2
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-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.
2013-12-29smpp: In case we know the receiver set the context for loggingHolger Hans Peter Freyther1-0/+2
2013-08-03SMPP: use VTY setting for E212/E164 in ALERT NOTIFICATIONHarald Welte1-24/+25
There's a VTY option by which for every ESME the user can specify if the E.212 or E.164 number should be used in DELIVER-SM. The ALERT notifications generate by subscriber LU have so far always contained the E.212 (IMSI) rather than E.164 (MSISDN) which is a bit inconsistent. Rather than copying code, we create a new function that implements ALERTing all ESMEs.
2013-08-03SMPP: convert a SMMA to a SMPP ALERT NOTIFICATIONHarald Welte1-0/+28
2013-08-03SMPP: don't get stuck in case of SMS memory exceededHarald Welte1-0/+4
If the MS memory for SMS is exceeded and we get an RP-layer error, we need to report that back to the (transaction-mode) ESME. Otherwise the ESME will wait forever after sending a SUBMIT-SM without ever receiving a response to it. Thanks to Holger for catching this.
2013-07-27smpp: Move the coding/mode detection into a utils fileHolger Hans Peter Freyther1-35/+1
Make sure to not ever have issues with this code again, move the utility code to a new file and create a basic testcase. The method currently has 100% line and branch coverage. My initial patched missed the smpp_utils.c file and I re-did the copying (and verifying the branch coverage)
2013-07-14smpp: Fix possible NULL dereference of the emse->aclHolger Hans Peter Freyther1-2/+2
The esme->acl is treated like it can be NULL in other places of the code. Assume it can be NULL during this check as well. Dereference after null check (FORWARD_NULL) 9. var_deref_op: Dereferencing null pointer "esme->acl". Fixes: Coverity CID 1042374
2013-07-14smpp: Checking an array for NULL will always be falseHolger Hans Peter Freyther1-1/+1
The if (submit->short_message) and if (smsc->system_id) will always be true. Fixes: Coverity CID 1042371, CID 1042372
2013-07-13Fix license header at smpp_openbsc.c and smpp_smsc.cHarald Welte1-11/+12
As Holger pointed out, they contained a GPLv2+ disclaimer rather than the AGPLv3+ which we use for OpenBSC. This is not an incompaibility, but was done unintentionally. The code was always mean to be under AGPLv3+. Nevertheless, anyone using those two files in a version up to this commit have the right to use it under GPLv2+ as well. This is not applicable for any versions after this commit.
2013-07-11smpp_openbsc: Fix parsing of 03.38 data coding scheme in MO caseHarald Welte1-15/+28
2013-05-28SMPP: Add new 'dcs_transparent' ESME settingHarald Welte1-9/+30
If an ESME has the dcs_transparent config flag, then the TP-DCS of MO-SMS is transparently passed to SMPP and not converted to SMPP specific data_coding values. This is needed in cases where ESMEs actually care about the exact TP-DCS, as the conversion from TP-DCS to SMPP data_coding is not bijective.
2013-05-28SMPP: Pass on 0xFx style DCS from SMPP to GSMHarald Welte1-17/+33
There are multiple ways how the TS 03.38 TP-DCS can indicate 8bit or 7bit messages. SMPP has it's own data coding specification, which is different from TS 03.38. However, some SMPP ESMEs want to be able to have fine-grained control over the TP-DCS indicated in the TPDU header. If such values like 0xF6 are used in SMPP, we now transparently pass them on to the GSM side.
2013-03-13SMPP: Implement SMPP Osmocom Estensions on MO-SMS0.13.0Harald Welte1-4/+81
An ESME can now be configured in the VTY to enable osmocom-extensions, which will add vendor-specific SMPP TLVs for RxLev/RxQual/ARFCN/IMEI and transmit power to the SMPP DELIVER-SM message type.
2013-03-13SMPP: Fix crash on delivery of incoming SUBMIT-SMHarald Welte1-5/+8
As bsc_gsmnet is NULL at the time we call smpp_openbsc_init(), we later run into segfaults with subscribers that don't have a subscr->net set. However, we cannot delay smpp_openbsc_init() until after bsc_bootstrap_network(), as we then fail to parse the SMPP specific VTY/config file options...
2013-01-20smpp: Fix a memleak of the SMS on the submit pathHolger Hans Peter Freyther1-1/+2
2013-01-20SMPP: Inform the SMS Queue that a SMS was submitted to kick the queueHolger Hans Peter Freyther1-1/+6
Work on the 'forward' part.. tell the sms queue that something has been submitted for it.. Conflicts: openbsc/src/libmsc/smpp_openbsc.c
2012-11-24use DLSMS and not DSMS in SMPP related code (merge with master)Harald Welte1-8/+8