From a1c1e9ce3845aad37b1a4ae34872c2a615007ed3 Mon Sep 17 00:00:00 2001
From: Tien-Thinh Nguyen <tien-thinh.nguyen@eurecom.fr>
Date: Wed, 3 Jan 2018 22:54:38 +0100
Subject: [PATCH] enable control socket

---
 openair2/RRC/LITE/defs.h             |  8 ++++----
 openair2/RRC/LITE/proto.h            |  5 ++++-
 openair2/RRC/LITE/rrc_UE.c           | 11 ++++-------
 targets/RT/USER/lte-softmodem-stub.c |  2 +-
 4 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/openair2/RRC/LITE/defs.h b/openair2/RRC/LITE/defs.h
index 18defaec82..e14c14f415 100644
--- a/openair2/RRC/LITE/defs.h
+++ b/openair2/RRC/LITE/defs.h
@@ -47,7 +47,7 @@
 
 #include "LAYER2/MAC/defs.h"
 
-//TTN-for D2D
+//for D2D
 #define CONTROL_SOCKET_PORT_NO 8888
 #define DEBUG_CTRL_SOCKET
 #define BUFSIZE 1024
@@ -58,8 +58,8 @@
 #define UE_IP_PDCP_NETLINK_ID 31
 #define PDCP_PID 1
 #define NETLINK_HEADER_SIZE 16
-#define SL_DEFAULT_RAB_ID     1
-#define SLRB_ID              11
+#define SL_DEFAULT_RAB_ID     3
+#define SLRB_ID              3
 
 #define MAX_PAYLOAD 1024 /* maximum payload size*/
 
@@ -130,7 +130,7 @@ extern pthread_mutex_t slrb_mutex;
 //the thread function
 void *send_UE_status_notification(void *);
 
-//end TTN
+
 
 //#include "COMMON/openair_defs.h"
 #ifndef USER_MODE
diff --git a/openair2/RRC/LITE/proto.h b/openair2/RRC/LITE/proto.h
index 468565fb5b..f349090aa2 100644
--- a/openair2/RRC/LITE/proto.h
+++ b/openair2/RRC/LITE/proto.h
@@ -352,7 +352,10 @@ SL_DiscConfig_r12_t rrc_eNB_get_sidelink_discTXPool(
       int n_discoveryMessages
 );
 
-
+/** \brief Process request from control socket
+ *  \param arg
+ */
+static void *rrc_control_socket_thread_fct(void *arg);
 
 //L2_interface.c
 int8_t
diff --git a/openair2/RRC/LITE/rrc_UE.c b/openair2/RRC/LITE/rrc_UE.c
index 3a44791f1d..9b59ecf1f8 100644
--- a/openair2/RRC/LITE/rrc_UE.c
+++ b/openair2/RRC/LITE/rrc_UE.c
@@ -91,17 +91,13 @@
 #ifdef Rel14
 #include "SL-Preconfiguration-r12.h"
 
-#endif
-
-//TTN - for D2D
-#define D2D_MODE //enable d2d
+//for D2D
 int ctrl_sock_fd;
 #define BUFSIZE 1024
 struct sockaddr_in prose_app_addr;
 int slrb_id;
 pthread_mutex_t slrb_mutex;
-static void *rrc_control_socket_thread_fct(void *arg);
-//end TTN
+#endif
 
 #ifdef PHY_EMUL
 extern EMULATION_VARS *Emul_vars;
@@ -5305,7 +5301,7 @@ rrc_ue_process_sidelink_radioResourceConfig(
    }
 }
 
-#ifdef D2D_MODE
+#ifdef Rel14
 //-----------------------------------------------------------
 void
 rrc_control_socket_init(){
@@ -5450,6 +5446,7 @@ void *rrc_control_socket_thread_fct(void *arg)
          LOG_I(RRC,"[rrc_control_socket_thread_fct][GroupCommunicationEstablishReq] group IP Address: " IPV4_ADDR "\n",IPV4_ADDR_FORMAT(sl_ctrl_msg_recv->sidelinkPrimitive.group_comm_establish_req.groupIpAddress));
 #endif
          // configure lower layers PDCP/MAC/PHY for this communication
+         //init_SL_preconfig()
 
          LOG_I(RRC,"[rrc_control_socket_thread_fct]Send GroupCommunicationEstablishResp to ProSe App\n");
          memset(send_buf, 0, BUFSIZE);
diff --git a/targets/RT/USER/lte-softmodem-stub.c b/targets/RT/USER/lte-softmodem-stub.c
index 958bb03f7b..cd048a0075 100644
--- a/targets/RT/USER/lte-softmodem-stub.c
+++ b/targets/RT/USER/lte-softmodem-stub.c
@@ -1064,7 +1064,7 @@ int main( int argc, char **argv )
 #endif
 
 //TTN for D2D
-#ifdef D2D_MODE
+#ifdef Rel14
   printf ("RRC control socket\n");
   rrc_control_socket_init();
 #endif
-- 
GitLab