XID: resend xid with pdp-ctx-ack messages

If a pdp context is created a xid request is sent right after
the pdp-context-ack message. The sending of the pdp-context-ack
and the xid message is triggered from the GGSN via the GTP
interface.

When the pdp-context-ack message is not received by the MS, it will
send the pdp-context-request again. A lost pdp-context-ack is resent
by the SGSN directly so that the mechanism described  above does
not work for pdp-context-ack resents.

This commit adds code to trigger the sending of xid messages also
for resent pdp-context-ack messages.

Change-Id: Ice66790803154310a61a70a54be76cec539c97a7
diff --git a/openbsc/src/gprs/gprs_gmm.c b/openbsc/src/gprs/gprs_gmm.c
index 3f59a2b..da243a4 100644
--- a/openbsc/src/gprs/gprs_gmm.c
+++ b/openbsc/src/gprs/gprs_gmm.c
@@ -68,6 +68,7 @@
 #include <openbsc/sgsn.h>
 #include <openbsc/signal.h>
 #include <openbsc/iu.h>
+#include <openbsc/gprs_sndcp.h>
 
 #include <pdp.h>
 
@@ -2438,6 +2439,7 @@
 	char apn_str[GSM_APN_LENGTH] = { 0, };
 	char *hostname;
 	int rc;
+	struct gprs_llc_lle *lle;
 
 	LOGMMCTXP(LOGL_INFO, mmctx, "-> ACTIVATE PDP CONTEXT REQ: SAPI=%u NSAPI=%u ",
 		act_req->req_llc_sapi, act_req->req_nsapi);
@@ -2513,7 +2515,19 @@
 		    pdp->ti == transaction_id) {
 			/* This apparently is a re-transmission of a PDP CTX
 			 * ACT REQ (our ACT ACK must have got dropped) */
-			return gsm48_tx_gsm_act_pdp_acc(pdp);
+			rc = gsm48_tx_gsm_act_pdp_acc(pdp);
+			if (rc < 0)
+				return rc;
+
+			if (pdp->mm->ran_type == MM_CTX_T_GERAN_Gb) {
+				/* Also re-transmit the SNDCP XID message */
+				lle = &pdp->mm->gb.llme->lle[pdp->sapi];
+				rc = sndcp_sn_xid_req(lle,pdp->nsapi);
+				if (rc < 0)
+					return rc;
+			}
+
+			return 0;
 		}
 
 		/* Send reject with GSM_CAUSE_NSAPI_IN_USE */