diff options
author | Vadim Yanitskiy <axilirator@gmail.com> | 2018-11-15 01:05:53 +0700 |
---|---|---|
committer | Vadim Yanitskiy <axilirator@gmail.com> | 2019-01-11 21:42:43 +0000 |
commit | 82cc8a5cfa234068ded337e90596d3d1e45b3244 (patch) | |
tree | 702f60febc19116b8890dd4c962c7e3f6968ba5b /src/libmsc/gsm_04_11_gsup.c | |
parent | 4a5cfa559a674d3012e6e38a8d61d159ebef2ba1 (diff) |
libmsc/gsm_04_11.c: accept MT SMS messages over GSUP
Change-Id: I57357982ca0e51f6722c24a4aa1d0fb3e6caef88
Depends-on: (core) Ibe325c64ae2d6c626b232533bb4cbc65fc2b5d71
Depends-on: (OsmoHLR) I0589ff27933e9bca2bcf93b8259004935778db8f
Related Change-Id: (TTCN) I63a25c8366cce0852df6b628365151661a22a25f
Related: OS#3587
Diffstat (limited to 'src/libmsc/gsm_04_11_gsup.c')
-rw-r--r-- | src/libmsc/gsm_04_11_gsup.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/src/libmsc/gsm_04_11_gsup.c b/src/libmsc/gsm_04_11_gsup.c index 5c0107245..f2de95f70 100644 --- a/src/libmsc/gsm_04_11_gsup.c +++ b/src/libmsc/gsm_04_11_gsup.c @@ -201,3 +201,99 @@ msg_error: msg_name, msg_is_err ? "Err" : "Res"); return -EINVAL; } + +int gsm411_gsup_mt_fwd_sm_res(struct gsm_trans *trans, uint8_t sm_rp_mr) +{ + struct osmo_gsup_message gsup_msg; + + /* Associate logging messages with this subscriber */ + log_set_context(LOG_CTX_VLR_SUBSCR, trans->vsub); + + LOGP(DLSMS, LOGL_DEBUG, "TX MT-forwardSM-Res\n"); + + /* Initialize a new GSUP message */ + gsup_sm_msg_init(&gsup_msg, OSMO_GSUP_MSGT_MT_FORWARD_SM_RESULT, + trans->vsub->imsi, &sm_rp_mr); + + return osmo_gsup_client_enc_send(trans->net->vlr->gsup_client, &gsup_msg); +} + +int gsm411_gsup_mt_fwd_sm_err(struct gsm_trans *trans, + uint8_t sm_rp_mr, uint8_t cause) +{ + struct osmo_gsup_message gsup_msg; + + /* Associate logging messages with this subscriber */ + log_set_context(LOG_CTX_VLR_SUBSCR, trans->vsub); + + LOGP(DLSMS, LOGL_DEBUG, "TX MT-forwardSM-Err\n"); + + /* Initialize a new GSUP message */ + gsup_sm_msg_init(&gsup_msg, OSMO_GSUP_MSGT_MT_FORWARD_SM_ERROR, + trans->vsub->imsi, &sm_rp_mr); + + /* SM-RP-Cause value */ + gsup_msg.sm_rp_cause = &cause; + + /* TODO: include optional SM-RP-UI field if present */ + return osmo_gsup_client_enc_send(trans->net->vlr->gsup_client, &gsup_msg); +} + +/* Handles MT SMS (and triggers Paging Request if required) */ +int gsm411_gsup_mt_handler(struct vlr_subscr *vsub, + struct osmo_gsup_message *gsup_msg) +{ + struct vlr_instance *vlr; + struct gsm_network *net; + int rc; + + /* Obtain required pointers */ + vlr = vsub->vlr; + net = (struct gsm_network *) vlr->user_ctx; + + /* Associate logging messages with this subscriber */ + log_set_context(LOG_CTX_VLR_SUBSCR, vsub); + + LOGP(DLSMS, LOGL_DEBUG, "RX MT-forwardSM-Req\n"); + + /* Make sure that 'SMS over GSUP' is expected */ + if (!net->sms_over_gsup) { + LOGP(DLSMS, LOGL_NOTICE, "Unexpected MT SMS over GSUP, " + "ignoring message...\n"); + /* TODO: notify sender about that? */ + return -EIO; + } + + /** + * Verify GSUP message + * + * FIXME: SM-RP-MR is not known yet (to be assigned by MSC) + * NOTE: SM-RP-DA is out of our interest + */ + if (!gsup_msg->sm_rp_mr) + goto msg_error; + if (!gsup_msg->sm_rp_ui) + goto msg_error; + + /* SM-RP-OA shall contain SMSC address */ + if (gsup_msg->sm_rp_oa_type != OSMO_GSUP_SMS_SM_RP_ODA_SMSC_ADDR) + goto msg_error; + + /* Send RP-DATA */ + rc = gsm411_send_rp_data(net, vsub, + gsup_msg->sm_rp_oa_len, gsup_msg->sm_rp_oa, + gsup_msg->sm_rp_ui_len, gsup_msg->sm_rp_ui); + if (rc) { + LOGP(DLSMS, LOGL_NOTICE, "Failed to send MT SMS, " + "ignoring MT-forwardSM-Req message...\n"); + /* TODO: notify sender about that? */ + return rc; + } + + return 0; + +msg_error: + /* TODO: notify sender about that? */ + LOGP(DLSMS, LOGL_NOTICE, "RX malformed MT-forwardSM-Req\n"); + return -EINVAL; +} |