libmsc: Map SMPP command status to GSM 04.11 cause
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
This commit is contained in:
parent
9f77d7bd0e
commit
320960cf9d
|
@ -461,6 +461,37 @@ static void append_osmo_tlvs(tlv_t **req_tlv, const struct gsm_lchan *lchan)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
struct {
|
||||||
|
uint32_t smpp_status_code;
|
||||||
|
uint8_t gsm411_cause;
|
||||||
|
} smpp_to_gsm411_err_array[] = {
|
||||||
|
|
||||||
|
/* Seems like most phones don't care about the failure cause,
|
||||||
|
* although some will display a different notification for
|
||||||
|
* GSM411_RP_CAUSE_MO_NUM_UNASSIGNED
|
||||||
|
* Some provoke a display of "Try again later"
|
||||||
|
* while others a more definitive "Message sending failed"
|
||||||
|
*/
|
||||||
|
|
||||||
|
{ ESME_RSYSERR, GSM411_RP_CAUSE_MO_DEST_OUT_OF_ORDER },
|
||||||
|
{ ESME_RINVDSTADR, GSM411_RP_CAUSE_MO_NUM_UNASSIGNED },
|
||||||
|
{ ESME_RMSGQFUL, GSM411_RP_CAUSE_MO_CONGESTION },
|
||||||
|
{ ESME_RINVSRCADR, GSM411_RP_CAUSE_MO_SMS_REJECTED },
|
||||||
|
{ ESME_RINVMSGID, GSM411_RP_CAUSE_INV_TRANS_REF }
|
||||||
|
};
|
||||||
|
|
||||||
|
static int smpp_to_gsm411_err(uint32_t smpp_status_code, int *gsm411_cause)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < ARRAY_SIZE(smpp_to_gsm411_err_array); i++) {
|
||||||
|
if (smpp_to_gsm411_err_array[i].smpp_status_code != smpp_status_code)
|
||||||
|
continue;
|
||||||
|
*gsm411_cause = smpp_to_gsm411_err_array[i].gsm411_cause;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
static void smpp_cmd_free(struct osmo_smpp_cmd *cmd)
|
static void smpp_cmd_free(struct osmo_smpp_cmd *cmd)
|
||||||
{
|
{
|
||||||
osmo_timer_del(&cmd->response_timer);
|
osmo_timer_del(&cmd->response_timer);
|
||||||
|
@ -501,10 +532,11 @@ void smpp_cmd_ack(struct osmo_smpp_cmd *cmd)
|
||||||
smpp_cmd_free(cmd);
|
smpp_cmd_free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
void smpp_cmd_err(struct osmo_smpp_cmd *cmd)
|
void smpp_cmd_err(struct osmo_smpp_cmd *cmd, uint32_t status)
|
||||||
{
|
{
|
||||||
struct gsm_subscriber_connection *conn;
|
struct gsm_subscriber_connection *conn;
|
||||||
struct gsm_trans *trans;
|
struct gsm_trans *trans;
|
||||||
|
int gsm411_cause;
|
||||||
|
|
||||||
conn = connection_for_subscr(cmd->subscr);
|
conn = connection_for_subscr(cmd->subscr);
|
||||||
if (!conn) {
|
if (!conn) {
|
||||||
|
@ -520,14 +552,17 @@ void smpp_cmd_err(struct osmo_smpp_cmd *cmd)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
gsm411_send_rp_error(trans, cmd->sms->gsm411.msg_ref,
|
if (smpp_to_gsm411_err(status, &gsm411_cause) < 0)
|
||||||
GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER);
|
gsm411_cause = GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER;
|
||||||
|
|
||||||
|
gsm411_send_rp_error(trans, cmd->sms->gsm411.msg_ref, gsm411_cause);
|
||||||
|
|
||||||
smpp_cmd_free(cmd);
|
smpp_cmd_free(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void smpp_deliver_sm_cb(void *data)
|
static void smpp_deliver_sm_cb(void *data)
|
||||||
{
|
{
|
||||||
smpp_cmd_err(data);
|
smpp_cmd_err(data, ESME_RSYSERR);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int smpp_cmd_enqueue(struct osmo_esme *esme,
|
static int smpp_cmd_enqueue(struct osmo_esme *esme,
|
||||||
|
|
|
@ -681,11 +681,10 @@ static int smpp_handle_deliver_resp(struct osmo_esme *esme, struct msgb *msg)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Map SMPP command status to GSM 04.11 cause? */
|
|
||||||
if (deliver_r.command_status == ESME_ROK)
|
if (deliver_r.command_status == ESME_ROK)
|
||||||
smpp_cmd_ack(cmd);
|
smpp_cmd_ack(cmd);
|
||||||
else
|
else
|
||||||
smpp_cmd_err(cmd);
|
smpp_cmd_err(cmd, deliver_r.command_status);
|
||||||
|
|
||||||
LOGP(DSMPP, LOGL_INFO, "[%s] Rx DELIVER-SM RESP (%s)\n",
|
LOGP(DSMPP, LOGL_INFO, "[%s] Rx DELIVER-SM RESP (%s)\n",
|
||||||
esme->system_id, get_value_string(smpp_status_strs,
|
esme->system_id, get_value_string(smpp_status_strs,
|
||||||
|
|
|
@ -97,7 +97,7 @@ struct osmo_smpp_cmd {
|
||||||
struct osmo_smpp_cmd *smpp_cmd_find_by_seqnum(struct osmo_esme *esme,
|
struct osmo_smpp_cmd *smpp_cmd_find_by_seqnum(struct osmo_esme *esme,
|
||||||
uint32_t sequence_number);
|
uint32_t sequence_number);
|
||||||
void smpp_cmd_ack(struct osmo_smpp_cmd *cmd);
|
void smpp_cmd_ack(struct osmo_smpp_cmd *cmd);
|
||||||
void smpp_cmd_err(struct osmo_smpp_cmd *cmd);
|
void smpp_cmd_err(struct osmo_smpp_cmd *cmd, uint32_t status);
|
||||||
void smpp_cmd_flush_pending(struct osmo_esme *esme);
|
void smpp_cmd_flush_pending(struct osmo_esme *esme);
|
||||||
|
|
||||||
struct smsc {
|
struct smsc {
|
||||||
|
|
Loading…
Reference in New Issue