new RAB: add use_x213_nsap parameter / change it to bool

Allow the *caller* of ranap_new_msg_rab_assign_data() to make the decision for
using 32 bit or longer IP addresses in RAB Assignment Request messages.

This requires a follow-up change in openbsc branch sysmocom/iu.
diff --git a/include/osmocom/ranap/ranap_msg_factory.h b/include/osmocom/ranap/ranap_msg_factory.h
index cf4350d..9639881 100644
--- a/include/osmocom/ranap/ranap_msg_factory.h
+++ b/include/osmocom/ranap/ranap_msg_factory.h
@@ -1,6 +1,7 @@
 #pragma once
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <osmocom/ranap/RANAP_Cause.h>
 #include <osmocom/ranap/RANAP_CN-DomainIndicator.h>
 #include <osmocom/ranap/RANAP_GlobalRNC-ID.h>
@@ -34,7 +35,8 @@
 struct msgb *ranap_new_msg_rab_assign_voice(uint8_t rab_id, uint32_t rtp_ip, uint16_t rtp_port);
 
 /*! \brief generate RANAP RAB ASSIGNMENT REQUEST message for PS (data) */
-struct msgb *ranap_new_msg_rab_assign_data(uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei);
+struct msgb *ranap_new_msg_rab_assign_data(uint8_t rab_id, uint32_t gtp_ip,
+					   uint32_t gtp_tei, bool use_x213_nsap);
 
 /*! \brief generate RANAP RESET message */
 struct msgb *ranap_new_msg_reset(RANAP_CN_DomainIndicator_t domain,
diff --git a/src/ranap_msg_factory.c b/src/ranap_msg_factory.c
index 7e03b13..0292442 100644
--- a/src/ranap_msg_factory.c
+++ b/src/ranap_msg_factory.c
@@ -614,7 +614,7 @@
 	return rab;
 }
 
-static void new_transp_layer_addr(BIT_STRING_t *out, uint32_t ip, int use_x213_nsap)
+static void new_transp_layer_addr(BIT_STRING_t *out, uint32_t ip, bool use_x213_nsap)
 {
 	uint8_t *buf;
 	unsigned int len;
@@ -658,12 +658,13 @@
 	return tli;
 }
 
-static RANAP_TransportLayerInformation_t *new_transp_info_gtp(uint32_t ip, uint32_t tei)
+static RANAP_TransportLayerInformation_t *new_transp_info_gtp(uint32_t ip, uint32_t tei,
+							      bool use_x213_nsap)
 {
 	RANAP_TransportLayerInformation_t *tli = CALLOC(1, sizeof(*tli));
 	uint32_t binding_buf = htonl(tei);
 
-	new_transp_layer_addr(&tli->transportLayerAddress, ip, 1);
+	new_transp_layer_addr(&tli->transportLayerAddress, ip, use_x213_nsap);
 	tli->iuTransportAssociation.present = RANAP_IuTransportAssociation_PR_gTP_TEI;
 	OCTET_STRING_fromBuf(&tli->iuTransportAssociation.choice.gTP_TEI,
 			     (const char *) &binding_buf, sizeof(binding_buf));
@@ -763,7 +764,8 @@
 }
 
 /*! \brief generate RANAP RAB ASSIGNMENT REQUEST message for PS (data) */
-struct msgb *ranap_new_msg_rab_assign_data(uint8_t rab_id, uint32_t gtp_ip, uint32_t gtp_tei)
+struct msgb *ranap_new_msg_rab_assign_data(uint8_t rab_id, uint32_t gtp_ip,
+					   uint32_t gtp_tei, bool use_x213_nsap)
 {
 	RANAP_ProtocolIE_FieldPair_t *pair;
 	RANAP_RAB_AssignmentRequestIEs_t ies;
@@ -786,7 +788,8 @@
 
 	first.rAB_Parameters = new_rab_par_data(1600000, 800000);
 	first.userPlaneInformation = new_upi(RANAP_UserPlaneMode_transparent_mode, 1);
-	first.transportLayerInformation = new_transp_info_gtp(gtp_ip, gtp_tei);
+	first.transportLayerInformation = new_transp_info_gtp(gtp_ip, gtp_tei,
+							      use_x213_nsap);
 
 	/* put together the 'Second' part */
 	RANAP_RAB_SetupOrModifyItemSecond_t second;
diff --git a/src/tests/test-ranap.c b/src/tests/test-ranap.c
index 713ee8c..acdf05b 100644
--- a/src/tests/test-ranap.c
+++ b/src/tests/test-ranap.c
@@ -96,7 +96,7 @@
 		msgb_free(msg);
 
 		printf("\n==> RAB ASSIGNMENT COMMAND (DATA)\n");
-		msg = ranap_new_msg_rab_assign_data(2, gtp_ip, gtp_tei);
+		msg = ranap_new_msg_rab_assign_data(2, gtp_ip, gtp_tei, 1);
 		if (msg)
 			printf("%s\n", msgb_hexdump(msg));
 		msgb_free(msg);