sms: Create signal data for SMS with more information

This is providing access to the paging result, the sms,
the transaction. This will allow the SMS queue to do
decisions based on the source of the failure.
diff --git a/openbsc/src/gsm_04_11.c b/openbsc/src/gsm_04_11.c
index faa712c..31bdf38 100644
--- a/openbsc/src/gsm_04_11.c
+++ b/openbsc/src/gsm_04_11.c
@@ -119,6 +119,18 @@
 	talloc_free(sms);
 }
 
+static void send_signal(int sig_no,
+			struct gsm_trans *trans,
+			struct gsm_sms *sms,
+			int paging_result)
+{
+	struct sms_signal_data sig;
+	sig.trans = trans;
+	sig.sms = sms;
+	sig.paging_result = paging_result;
+	dispatch_signal(SS_SMS, sig_no, &sig);
+}
+
 /*
  * This should be called whenever all SMS to a given subscriber
  * on a given connection has been sent. This will inform the higher
@@ -422,7 +434,7 @@
 		return GSM411_RP_CAUSE_MO_NET_OUT_OF_ORDER;
 	}
 	/* dispatch a signal to tell higher level about it */
-	dispatch_signal(SS_SMS, S_SMS_SUBMITTED, gsms);
+	send_signal(S_SMS_SUBMITTED, NULL, gsms, 0);
 
 	return 0;
 }
@@ -614,7 +626,8 @@
 
 	gsms->validity_minutes = gsm340_validity_period(sms_vpf, sms_vp);
 
-	dispatch_signal(SS_SMS, 0, gsms);
+	/* FIXME: This looks very wrong */
+	send_signal(0, NULL, gsms, 0);
 
 	/* determine gsms->receiver based on dialled number */
 	gsms->receiver = subscr_get_by_extension(conn->bts->network, gsms->dest_addr);
@@ -754,7 +767,7 @@
 	/* mark this SMS as sent in database */
 	db_sms_mark_sent(sms);
 
-	dispatch_signal(SS_SMS, S_SMS_DELIVERED, sms);
+	send_signal(S_SMS_DELIVERED, trans, sms, 0);
 
 	sms_free(sms);
 	trans->sms.sms = NULL;
@@ -809,10 +822,10 @@
 		/* MS has not enough memory to store the message.  We need
 		 * to store this in our database and wait for a SMMA message */
 		/* FIXME */
-		dispatch_signal(SS_SMS, S_SMS_MEM_EXCEEDED, sms);
+		send_signal(S_SMS_MEM_EXCEEDED, trans, sms, 0);
 		counter_inc(net->stats.sms.rp_err_mem);
 	} else {
-		dispatch_signal(SS_SMS, S_SMS_UNKNOWN_ERROR, sms);
+		send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0);
 		counter_inc(net->stats.sms.rp_err_other);
 	}
 
@@ -834,7 +847,7 @@
 	/* MS tells us that it has memory for more SMS, we need
 	 * to check if we have any pending messages for it and then
 	 * transfer those */
-	dispatch_signal(SS_SMS, S_SMS_SMMA, trans->subscr);
+	send_signal(S_SMS_SMMA, trans, NULL, 0);
 
 	/* check for more messages for this subscriber */
 	sms = db_sms_get_unsent_for_subscr(trans->subscr);
@@ -1046,7 +1059,7 @@
 	transaction_id = trans_assign_trans_id(conn->subscr, GSM48_PDISC_SMS, 0);
 	if (transaction_id == -1) {
 		LOGP(DSMS, LOGL_ERROR, "No available transaction ids\n");
-		dispatch_signal(SS_SMS, S_SMS_UNKNOWN_ERROR, sms);
+		send_signal(S_SMS_UNKNOWN_ERROR, NULL, sms, 0);
 		sms_free(sms);
 		return -EBUSY;
 	}
@@ -1058,7 +1071,7 @@
 			    transaction_id, new_callref++);
 	if (!trans) {
 		LOGP(DSMS, LOGL_ERROR, "No memory for trans\n");
-		dispatch_signal(SS_SMS, S_SMS_UNKNOWN_ERROR, sms);
+		send_signal(S_SMS_UNKNOWN_ERROR, NULL, sms, 0);
 		sms_free(sms);
 		/* FIXME: send some error message */
 		return -ENOMEM;
@@ -1092,7 +1105,7 @@
 	/* generate the 03.40 TPDU */
 	rc = gsm340_gen_tpdu(msg, sms);
 	if (rc < 0) {
-		dispatch_signal(SS_SMS, S_SMS_UNKNOWN_ERROR, sms);
+		send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0);
 		trans_free(trans);
 		sms_free(sms);
 		msgb_free(msg);
@@ -1132,7 +1145,7 @@
 	case GSM_PAGING_EXPIRED:
 	case GSM_PAGING_OOM:
 	case GSM_PAGING_BUSY:
-		dispatch_signal(SS_SMS, S_SMS_UNKNOWN_ERROR, sms);
+		send_signal(S_SMS_UNKNOWN_ERROR, NULL, sms, event);
 		sms_free(sms);
 		rc = -ETIMEDOUT;
 		break;
@@ -1191,7 +1204,7 @@
 {
 	if (trans->sms.sms) {
 		LOGP(DSMS, LOGL_ERROR, "Transaction contains SMS.\n");
-		dispatch_signal(SS_SMS, S_SMS_UNKNOWN_ERROR, trans->sms.sms);
+		send_signal(S_SMS_UNKNOWN_ERROR, trans, trans->sms.sms, 0);
 		sms_free(trans->sms.sms);
 		trans->sms.sms = NULL;
 	}
@@ -1211,7 +1224,7 @@
 				continue;
 			}
 
-			dispatch_signal(SS_SMS, S_SMS_UNKNOWN_ERROR, sms);
+			send_signal(S_SMS_UNKNOWN_ERROR, trans, sms, 0);
 			sms_free(sms);
 			trans->sms.sms = NULL;
 			trans_free(trans);