ranap: New ranap_new_msg_initial_ue() funcition

for testing, it is useful if we can also generate an InitialUE
message - even though a HNB-GW only needs to receive it.
diff --git a/src/hnbgw_ranap.c b/src/hnbgw_ranap.c
index 1e38cf0..1513099 100644
--- a/src/hnbgw_ranap.c
+++ b/src/hnbgw_ranap.c
@@ -55,13 +55,16 @@
 static int ranap_rx_init_reset(struct hnb_context *hnb, ANY_t *in)
 {
 	RANAP_ResetIEs_t ies;
-	int rc;
+	int rc, is_ps = 0;
 
 	rc = ranap_decode_reseties(&ies, in);
 	if (rc < 0)
 		return rc;
 
-	DEBUGP(DRANAP, "RESET.req\n");
+	if (ies.cN_DomainIndicator == RANAP_CN_DomainIndicator_ps_domain)
+		is_ps=1;
+
+	DEBUGP(DRANAP, "RESET.req(%s)\n", is_ps ? "ps" : "cs");
 
 	/* FIXME: Actually we have to wait for some guard time? */
 	/* FIXME: Reset all resources related to this HNB/RNC */
diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c
index 3202e1a..e0ff42b 100644
--- a/src/ranap_msg_factory.c
+++ b/src/ranap_msg_factory.c
@@ -86,7 +86,9 @@
 	 * ACKNOWLEDGE message to the CN */
 	if (rnc_id) {
 		ies.presenceMask = RESETACKNOWLEDGEIES_RANAP_GLOBALRNC_ID_PRESENT;
-		/* FIXME: Copy PLMN Identity TBCD-String */
+		OCTET_STRING_fromBuf(&ies.globalRNC_ID.pLMNidentity,
+				     rnc_id->pLMNidentity.buf,
+				     rnc_id->pLMNidentity.size);
 		ies.globalRNC_ID.rNC_ID = rnc_id->rNC_ID;
 	}
 
@@ -110,6 +112,55 @@
 	return msg;
 }
 
+/*! \brief generate RANAP INITIAL UE message */
+struct msgb *ranap_new_msg_initial_ue(uint32_t conn_id, int is_ps,
+				     RANAP_GlobalRNC_ID_t *rnc_id,
+				     uint8_t *nas_pdu, unsigned int nas_len)
+{
+	RANAP_InitialUE_MessageIEs_t ies;
+	RANAP_InitialUE_Message_t out;
+	struct msgb *msg;
+	uint32_t ctxidbuf;
+	int rc;
+	uint16_t buf0 = 0x2342;
+
+	memset(&ies, 0, sizeof(ies));
+	if (is_ps)
+		ies.cN_DomainIndicator = RANAP_CN_DomainIndicator_ps_domain;
+	else
+		ies.cN_DomainIndicator = RANAP_CN_DomainIndicator_cs_domain;
+
+	OCTET_STRING_fromBuf(&ies.lai.pLMNidentity, rnc_id->pLMNidentity.buf, rnc_id->pLMNidentity.size);
+	OCTET_STRING_fromBuf(&ies.lai.lAC, &buf0, sizeof(buf0));
+
+	OCTET_STRING_fromBuf(&ies.sai.pLMNidentity, rnc_id->pLMNidentity.buf, rnc_id->pLMNidentity.size);
+	OCTET_STRING_fromBuf(&ies.sai.lAC, &buf0, sizeof(buf0));
+	OCTET_STRING_fromBuf(&ies.sai.sAC, &buf0, sizeof(buf0));
+
+	OCTET_STRING_fromBuf(&ies.nas_pdu, nas_pdu, nas_len);
+	asn1_u24_to_bitstring(&ies.iuSigConId, &ctxidbuf, conn_id);
+	OCTET_STRING_fromBuf(&ies.globalRNC_ID.pLMNidentity, rnc_id->pLMNidentity.buf, rnc_id->pLMNidentity.size);
+	ies.globalRNC_ID.rNC_ID = rnc_id->rNC_ID;
+
+	memset(&out, 0, sizeof(out));
+	rc = ranap_encode_initialue_messageies(&out, &ies);
+	if (rc < 0) {
+		LOGP(DRANAP, LOGL_ERROR, "error encoding initial UE IEs: %d\n", rc);
+		return NULL;
+	}
+
+	msg = ranap_generate_initiating_message(RANAP_ProcedureCode_id_InitialUE_Message,
+						RANAP_Criticality_reject,
+						&asn_DEF_RANAP_InitialUE_Message,
+						&out);
+
+	/* release dynamic allocations attached to dt */
+	ASN_STRUCT_FREE_CONTENTS_ONLY(asn_DEF_RANAP_InitialUE_Message, &out);
+
+	return msg;
+}
+
+
 /*! \brief generate RANAP DIRECT TRANSFER message */
 struct msgb *ranap_new_msg_dt(uint8_t sapi, const uint8_t *nas, unsigned int nas_len)
 {
diff --git a/src/ranap_msg_factory.h b/src/ranap_msg_factory.h
index 3bc73e1..e48b1bf 100644
--- a/src/ranap_msg_factory.h
+++ b/src/ranap_msg_factory.h
@@ -33,3 +33,9 @@
 /*! \brief generate RANAP RESET ACK message */
 struct msgb *ranap_new_msg_reset_ack(RANAP_CN_DomainIndicator_t domain,
 				     RANAP_GlobalRNC_ID_t *rnc_id);
+
+
+/*! \brief generate RANAP INITIAL UE message */
+struct msgb *ranap_new_msg_initial_ue(uint32_t conn_id, int is_ps,
+				     RANAP_GlobalRNC_ID_t *rnc_id,
+				     uint8_t *nas_pdu, unsigned int nas_len);