Commit Graph

64 Commits

Author SHA1 Message Date
Pablo Neira Ayuso 4b50924fe8 libmsc: gsm340_gen_oa_sub() may return negative value
gsm340_gen_oa() returns a negative value if the output buffer that the
caller passes is too small, so we have to check the return value of this
function.

Fixes: CID 174178
Fixes: CID 174179
Change-Id: I47215d7d89771730a7f84efa8aeeb187a0911fdb
2017-08-27 02:33:49 +02:00
Pablo Neira Ayuso 27aed14892 libmsc: support GSM 03.40 status report for nitb
This patch adds support for GSM 03.40 in nitb mode.

          MS         GSM 03.40          SMSC
           |                            |
           |         SMS-SUBMIT         |
           |--------------------------->|
           |     GSM 04.11 RP-ACK       |
           |<---------------------------|
           |         SMS-DELIVER        |
           |<---------------------------|
           |     GSM 04.11 RP-ACK       |
           |--------------------------->|
           |     SMS-STATUS-REPORT      |
           |<---------------------------|
           |     GSM 04.11 RP-ACK       |
           |--------------------------->|
           |                            |

Change-Id: I5cc7bb4ebadde0940f44d10c3df34707b0615160
2017-08-27 02:33:49 +02:00
Pablo Neira Ayuso bd71d32dca libmsc: handle delivery ack via SMPP SUBMIT SM / send GSM 03.40 status report
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-27 02:33:49 +02:00
Pablo Neira Ayuso adae859eeb libmsc: add support for SMPP delivery receipts
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-27 02:33:49 +02:00
Pablo Neira Ayuso db5ed3b9c6 libmsc: missing bit shift in status report flag when stored in sms object
So we just store 0 or 1 depending on what the mobile phone requests.

Change-Id: Idb7d5594219c0e458ccb561383a59604bc1a4201
2017-08-27 02:33:49 +02:00
Pablo Neira Ayuso 3c14803b8d libmsc: move gsm340_rx_sms_submit() to sms_route_mt_sms()
Move the sms message-type-identifier (mti) handling away from the
routing logic. This patch allows us to reuse the sms_route_mt_sms()
function in a follow up patch for sms reports send through SMPP
DELIVER_SM with esm_class = Delivery Receipt whose Change-Id is
Ic1a9023074bfa938099377980b6aff9b262fab2a.

Change-Id: I3f3d30e0762b91e2099243b0be1a4b67cbb5e9c0
2017-08-27 02:33:48 +02:00
Pablo Neira Ayuso fdc9966a90 libmsc: remove 'deferred' parameter in sms_route_mt_sms()
No need to cache the sms object, just cache what we need into the
smpp_cmd structure. This simplifies what that I introduced in
93ffbd0029 ("libmsc: send RP-ACK to MS after ESME sends SMPP
DELIVER-SM-RESP").

Change-Id: Iba5f864f9bb963baff95969e306b1b7cff00c1e3
2017-08-27 02:33:48 +02:00
Pablo Neira Ayuso 19e0536ad3 libmsc: remove dead code in sms_route_mt_sms()
The following branch:

	if (!rc && !gsms->receiver)
		rc = GSM411_RP_CAUSE_MO_NUM_UNASSIGNED;

at the end of sms_route_mt_sms() always evaluates false.

Just a bit before, in such function, we have this:

        if (!gsms->receiver) {
                ...
 #ifdef BUILD_SMPP
                ...
 #else
                ...
 #endif
                return rc;
        }

So, if there is no receiver, we just stop running code and return the RP
cause via the rc variable. Same applies to the smpp_first check under
the BUILD_SMPP ifdef (that I have removed in this snippet to keep this
commit message small).

Change-Id: Ic3502b5b169bc7a73a67fd6ff53d8b6c0dc045c8
2017-08-27 02:33:48 +02:00
Pablo Neira Ayuso c0227194a3 gsm_04_11: get rid of unused parameter in sms_route_mt_sms()
This parameter is unused, remove it.

Change-Id: I797abce3f91447e8f397c7cf726db7425479fe0e
2017-08-27 02:33:48 +02:00
Benoit Bolsee d34ed5768c smpp: fix return cause
Return cause 38 when default SMPP route is unavailable. This
is better than cause 1.

Change-Id: If3241d50a78fa611981e55fef6ae4c72b0a2a167
2017-08-27 02:33:47 +02:00
Neels Hofmeyr 84da6b1edb Implement IuCS (large refactoring and addition)
osmo-nitb becomes osmo-msc
add DIUCS debug log constant
add iucs.[hc]
add msc vty, remove nitb vty
add libiudummy, to avoid linking Iu deps in tests
Use new msc_tx_dtap() instead of gsm0808_submit_dtap()
libmgcp: add mgcpgw client API
bridge calls via mgcpgw

Enable MSC specific CTRL commands, bsc_base_ctrl_cmds_install() still needs to
be split up.

Change-Id: I5b5b6a9678b458affa86800afb1ec726e66eed88
2017-08-08 19:17:53 +02:00
Neels Hofmeyr e2f24d53e4 mscsplit: various preparations to separate MSC from BSC
Disable large parts of the code that depend on BSC presence. The code sections
disabled by #if BEFORE_MSCSPLIT shall be modified or dropped in the course of
adding the A-interface.

Don't set msg->lchan nor msg->dst.
Don't use lchan in libmsc.
Decouple lac from bts.

Prepare entry/exit point for MSC -> BSC and MSC -> RNC communication:
Add msc_ifaces.[hc], a_iface.c, with a general msc_tx_dtap() to redirect to
different interfaces depending on the actual subscriber connection.
While iu_tx() is going to be functional fairly soon, the a_tx() is going to be
just a dummy for some time (see comment).
Add Iu specific fields in gsm_subscriber_connection: the UE connection pointer
and an indicator for the Integrity Protection status on Iu (to be fully
implemented in later commits).
Add lac member to gsm_subscriber_connection, to allow decoupling from
bts->location_area_code. The conn->lac will actually be set in iu.c in an
upcoming commit ("add iucs.[hc]").

move to libcommon-cs: gsm48_extract_mi(), gsm48_paging_extract_mi().

libmsc: duplicate gsm0808 / gsm48 functions (towards BSC).
In osmo-nitb, libmsc would directly call the functions on the BSC level, not
always via the bsc_api. When separating libmsc from libbsc, some functions are
missing from the linkage.
Hence duplicate these functions to libmsc, add an msc_ prefix for clarity, also
add a _tx to gsm0808_cipher_mode():
* add msc_gsm0808_tx_cipher_mode() (dummy/stub)
* add msc_gsm48_tx_mm_serv_ack()
* add msc_gsm48_tx_mm_serv_rej()
Call these from libmsc instead of
* gsm0808_cipher_mode()
* gsm48_tx_mm_serv_ack()
* gsm48_tx_mm_serv_rej()
Also add a comment related to msc_gsm0808_tx_cipher_mode() in two places.

Remove internal RTP streaming code; OsmoNITB supported that, but for OsmoMSC,
this will be done with an external MGCP gateway.

Remove LCHAN_MODIFY from internal MNCC state machine.

Temporarily disable all paging to be able to link libmsc without libbsc.
Skip the paging part of channel_test because the paging is now disabled.
Employ fake paging shims in order for msc_vlr_tests to still work.

msc_compl_l3(): publish in .h, tweak return value.  Use new libmsc enum values
for return val, to avoid dependency on libbsc headers.  Make callable from
other scopes: publish in osmo_msc.h and remove 'static' in osmo_msc.c

add gsm_encr to subscr_conn
move subscr_request to gsm_subscriber.h
subscr_request_channel() -> subscr_request_conn()
move to libmsc: osmo_stats_vty_add_cmds()
gsm_04_08: remove apply_codec_restrictions()
gsm0408_test: use NULL for root ctx
move to libbsc: gsm_bts_neighbor()
move to libbsc: lchan_next_meas_rep()
move vty config for t3212 to network level (periodic lu)
remove unneccessary linking from some tests
remove handle_abisip_signal()
abis_rsl.c: don't use libvlr from libbsc

gsm_subscriber_connection: put the LAC here, so that it is available without
accessing conn->bts. In bsc_api.c, place this lac in conn for the sake of
transition: Iu and A will use this new field to pass the LAC around, but in a
completely separate OsmoBSC this is not actually needed. It can be removed
again from osmo-bsc.git when the time has come.

Siemens MRPCI: completely drop sending the MRPCI messages for now, they shall
be added in osmo-bsc once the A-Interface code has settled. See OS#2389.

Related: OS#1845 OS#2257 OS#2389
Change-Id: Id3705236350d5f69e447046b0a764bbabc3d493c
2017-08-08 19:17:53 +02:00
Harald Welte 2483f1b050 Use libvlr in libmsc (large refactoring)
Original libvlr code is by Harald Welte <laforge@gnumonks.org>,
polished and tweaked by Neels Hofmeyr <nhofmeyr@sysmocom.de>.

This is a long series of trial-and-error development collapsed in one patch.
This may be split in smaller commits if reviewers prefer that. If we can keep
it as one, we have saved ourselves the additional separation work.

SMS:

The SQL based lookup of SMS for attached subscribers no longer works since the
SQL database no longer has the subscriber data. Replace with a round-robin on
the SMS recipient MSISDNs paired with a VLR subscriber RAM lookup whether the
subscriber is currently attached.

If there are many SMS for not-attached subscribers in the SMS database, this
will become inefficient: a DB hit returns a pending SMS, the RAM lookup will
reveal that the subscriber is not attached, after which the DB is hit for the
next SMS. It would become more efficient e.g. by having an MSISDN based hash
list for the VLR subscribers and by marking non-attached SMS recipients in the
SMS database so that they can be excluded with the SQL query already.

There is a sanity limit to do at most 100 db hits per attempt to find a pending
SMS. So if there are more than 100 stored SMS waiting for their recipients to
actually attach to the MSC, it may take more than one SMS queue trigger to
deliver SMS for subscribers that are actually attached.

This is not very beautiful, but is merely intended to carry us over to a time
when we have a proper separate SMSC entity.

Introduce gsm_subscriber_connection ref-counting in libmsc.

Remove/Disable VTY and CTRL commands to create subscribers, which is now a task
of the OsmoHLR. Adjust the python tests accordingly.

Remove VTY cmd subscriber-keep-in-ram.

Use OSMO_GSUP_PORT = 4222 instead of 2222. See
I4222e21686c823985be8ff1f16b1182be8ad6175.

So far use the LAC from conn->bts, will be replaced by conn->lac in
Id3705236350d5f69e447046b0a764bbabc3d493c.

Related: OS#1592 OS#1974
Change-Id: I639544a6cdda77a3aafc4e3446a55393f60e4050
2017-07-23 04:08:43 +02:00
Neels Hofmeyr 29b9206e80 move openbsc/* to repos root
This is the first step in creating this repository from the legacy openbsc.git.

Like all other Osmocom repositories, keep the autoconf and automake files in
the repository root. openbsc.git has been the sole exception, which ends now.

Change-Id: I9c6f2a448d9cb1cc088cf1cf6918b69d7e69b4e7
2017-07-12 23:17:10 +00:00