SMS over GSUP: implement forwarding of MT SMS

When an SMSC tries to deliver an SM to a subscriber, it will send us
an MT-forwardSM.req GSUP message.  We look up the subscriber by IMSI
and see if they are attached to a VLR.  If the subscriber is attached,
we forward the message to the MSC/VLR, otherwise return an error
to the SMSC.

Related: OS#6135
Change-Id: Ib3551bf7839690606c677461758c5cfef5f0aa7b
This commit is contained in:
Mychaela N. Falconia 2023-08-26 01:06:57 +00:00
parent 293d994f7c
commit f1158c7719
3 changed files with 32 additions and 0 deletions

View File

@ -29,3 +29,4 @@ struct hlr_smsc_route *smsc_route_alloc(struct hlr *hlr, const char *num_addr,
void smsc_route_del(struct hlr_smsc_route *rt);
void forward_mo_sms(struct osmo_gsup_req *req);
void forward_mt_sms(struct osmo_gsup_req *req);

View File

@ -560,6 +560,9 @@ static int read_cb(struct osmo_gsup_conn *conn, struct msgb *msg)
case OSMO_GSUP_MSGT_MO_FORWARD_SM_REQUEST:
forward_mo_sms(req);
break;
case OSMO_GSUP_MSGT_MT_FORWARD_SM_REQUEST:
forward_mt_sms(req);
break;
default:
LOGP(DMAIN, LOGL_DEBUG, "Unhandled GSUP message type %s\n",
osmo_gsup_message_type_name(req->gsup.message_type));

View File

@ -191,3 +191,31 @@ void forward_mo_sms(struct osmo_gsup_req *req)
strlen(smsc->name) + 1);
osmo_gsup_forward_to_local_peer(req->cb_data, &dest_peer, req, NULL);
}
/***********************************************************************
* forwarding of MT SMS from SMSCs to MSC/VLR based on IMSI
***********************************************************************/
void forward_mt_sms(struct osmo_gsup_req *req)
{
struct hlr_subscriber subscr;
struct osmo_cni_peer_id dest_peer;
int rc;
rc = db_subscr_get_by_imsi(g_hlr->dbc, req->gsup.imsi, &subscr);
if (rc < 0) {
osmo_gsup_req_respond_err(req, GMM_CAUSE_IMSI_UNKNOWN,
"IMSI unknown");
return;
}
/* is this subscriber currently attached to a VLR? */
if (!subscr.vlr_number[0]) {
osmo_gsup_req_respond_err(req, GMM_CAUSE_IMPL_DETACHED,
"subscriber not attached to a VLR");
return;
}
osmo_cni_peer_id_set(&dest_peer, OSMO_CNI_PEER_ID_IPA_NAME,
(const uint8_t *) subscr.vlr_number,
strlen(subscr.vlr_number) + 1);
osmo_gsup_forward_to_local_peer(req->cb_data, &dest_peer, req, NULL);
}