Fix of IMMIDIATE ASSIGNMENT REJECT message

The message was corrupt at several points. They are fixed now and
successfully tested.

A default T3122 timer value of 10 is defined by default now. If set to 0,
the reject message will not be sent. Note that when using existing configs
with T3122 value set to 0.
diff --git a/openbsc/include/openbsc/gsm_data.h b/openbsc/include/openbsc/gsm_data.h
index feb692f..a4c6fbc 100644
--- a/openbsc/include/openbsc/gsm_data.h
+++ b/openbsc/include/openbsc/gsm_data.h
@@ -192,6 +192,7 @@
 #define GSM_T3101_DEFAULT 10
 #define GSM_T3105_DEFAULT 40
 #define GSM_T3113_DEFAULT 60
+#define GSM_T3122_DEFAULT 10
 
 struct gsm_network {
 	/* global parameters */
diff --git a/openbsc/src/libbsc/abis_rsl.c b/openbsc/src/libbsc/abis_rsl.c
index 12f68e9..6b62656 100644
--- a/openbsc/src/libbsc/abis_rsl.c
+++ b/openbsc/src/libbsc/abis_rsl.c
@@ -1295,7 +1295,7 @@
 	/* create IMMEDIATE ASSIGN REJECT 04.08 message */
 	memset(iar, 0, sizeof(*iar));
 	iar->proto_discr = GSM48_PDISC_RR;
-	iar->msg_type = GSM48_MT_RR_IMM_ASS;
+	iar->msg_type = GSM48_MT_RR_IMM_ASS_REJ;
 	iar->page_mode = GSM48_PM_SAME;
 
 	memcpy(&iar->req_ref1, &rqd_refs[0], sizeof(iar->req_ref1));
@@ -1319,7 +1319,10 @@
 		memcpy(&iar->req_ref4, &rqd_refs[0], sizeof(iar->req_ref4));
 	iar->wait_ind4 = wait_ind;
 
-	return rsl_imm_assign_cmd(bts, sizeof(iar), (uint8_t *) iar);
+	/* we need to subtract 1 byte from sizeof(*iar) since ia includes the l2_plen field */
+	iar->l2_plen = GSM48_LEN2PLEN((sizeof(*iar)-1));
+
+	return rsl_imm_assign_cmd(bts, sizeof(*iar), (uint8_t *) iar);
 }
 
 /* MS has requested a channel on the RACH */
diff --git a/openbsc/src/libcommon/gsm_data.c b/openbsc/src/libcommon/gsm_data.c
index c9f41fc..dd1d93b 100644
--- a/openbsc/src/libcommon/gsm_data.c
+++ b/openbsc/src/libcommon/gsm_data.c
@@ -97,6 +97,7 @@
 	net->T3101 = GSM_T3101_DEFAULT;
 	net->T3105 = GSM_T3105_DEFAULT;
 	net->T3113 = GSM_T3113_DEFAULT;
+	net->T3122 = GSM_T3122_DEFAULT;
 	/* FIXME: initialize all other timers! */
 
 	/* default set of handover parameters */