From a0083404b2f4e0e7978189b6646c1c522cd5da8e Mon Sep 17 00:00:00 2001
From: Navid Nikaein <navid.nikaein@eurecom.fr>
Date: Thu, 19 Sep 2013 09:30:07 +0000
Subject: [PATCH] * change the mcs limit for DCI format 1A from 7 to 8 in
 dci_tools.c, supported by MAC * activate the sencond MBSFNArea when eMBMS
 relaying is activated * add wireshark interface for MCH PDUs (Not tested
 feature) * pre-ci test passed

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@4156 818b1a75-f10b-46b9-bf7c-635c3b92a50f
---
 openair1/PHY/LTE_TRANSPORT/dci_tools.c |  4 +--
 openair1/SCHED/phy_procedures_lte_ue.c | 12 +++----
 openair2/LAYER2/MAC/defs.h             |  5 +--
 openair2/LAYER2/MAC/eNB_scheduler.c    | 11 +++++++
 openair2/LAYER2/MAC/main.c             | 34 ++++++--------------
 openair2/LAYER2/MAC/ue_procedures.c    |  1 +
 openair2/PHY_INTERFACE/defs.h          |  6 ++--
 openair2/RRC/LITE/L2_interface.c       | 34 ++++++++------------
 openair2/RRC/LITE/MESSAGES/asn1_msg.c  | 44 +++++++++++++++-----------
 9 files changed, 75 insertions(+), 76 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index c2fb90585f..b03b99337b 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -1812,8 +1812,8 @@ int generate_ue_dlsch_params_from_dci(uint8_t subframe,
 	  LOG_E(PHY,"Format 1A: NPRB=0\n");
             return(-1);
         }
-        
-        if (mcs > 7) {
+        // change the mcs limit from 7 to 8, supported by MAC
+        if (mcs > 8) {
 	  LOG_E(PHY,"Format 1A: unlikely mcs for format 1A (%d)\n",mcs);
             return(-1);
         } 
diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c
index 60bb9af50e..d94d673230 100755
--- a/openair1/SCHED/phy_procedures_lte_ue.c
+++ b/openair1/SCHED/phy_procedures_lte_ue.c
@@ -1660,7 +1660,7 @@ void lte_ue_pbch_procedures(u8 eNB_id,u8 last_slot, PHY_VARS_UE *phy_vars_ue,u8
 
     if (first_run) {
       first_run = 0;
-      LOG_I(PHY,"[UE  %d] frame %d, slot %d: Adjusting frame counter (PBCH ant_tx=%d, frame_tx=%d, phase %d).\n",
+      LOG_I(PHY,"[UE %d] frame %d, slot %d: Adjusting frame counter (PBCH ant_tx=%d, frame_tx=%d, phase %d).\n",
 	    phy_vars_ue->Mod_id, 
 	    phy_vars_ue->frame,
 	    last_slot,
@@ -1672,7 +1672,7 @@ void lte_ue_pbch_procedures(u8 eNB_id,u8 last_slot, PHY_VARS_UE *phy_vars_ue,u8
     else 
       if (((frame_tx & 0x03FF) != (phy_vars_ue->frame & 0x03FF))) { 
 	  //(pbch_tx_ant != phy_vars_ue->lte_frame_parms.nb_antennas_tx)) {
-	LOG_D(PHY,"[UE  %d] frame %d, slot %d: Re-adjusting frame counter (PBCH ant_tx=%d, frame_tx=%d, frame%1024=%d, phase %d).\n",
+	LOG_D(PHY,"[UE %d] frame %d, slot %d: Re-adjusting frame counter (PBCH ant_tx=%d, frame_tx=%d, frame%1024=%d, phase %d).\n",
 	      phy_vars_ue->Mod_id, 
 	      phy_vars_ue->frame,
 	      last_slot,
@@ -1704,7 +1704,7 @@ void lte_ue_pbch_procedures(u8 eNB_id,u8 last_slot, PHY_VARS_UE *phy_vars_ue,u8
       }
         
 #ifdef DEBUG_PHY_PROC
-    LOG_D(PHY,"[UE  %d] frame %d, slot %d, PBCH: mode1_flag %d, tx_ant %d, frame_tx %d. N_RB_DL %d, phich_duration %d, phich_resource %d/6!\n",
+    LOG_D(PHY,"[UE %d] frame %d, slot %d, Received PBCH (MIB): mode1_flag %d, tx_ant %d, frame_tx %d. N_RB_DL %d, phich_duration %d, phich_resource %d/6!\n",
 	      phy_vars_ue->Mod_id, 
 	      phy_vars_ue->frame,
 	      last_slot,
@@ -1715,7 +1715,7 @@ void lte_ue_pbch_procedures(u8 eNB_id,u8 last_slot, PHY_VARS_UE *phy_vars_ue,u8
 	      phy_vars_ue->lte_frame_parms.phich_config_common.phich_duration,
 	      phy_vars_ue->lte_frame_parms.phich_config_common.phich_resource);
     if ((phy_vars_ue->frame%100==0)&&(phy_vars_ue!=NULL)) {
-      LOG_I(PHY,"[UE  %d] frame %d, slot %d, PBCH: mode1_flag %d, tx_ant %d, frame_tx %d, phase %d. N_RB_DL %d, phich_duration %d, phich_resource %d/6\n",
+      LOG_I(PHY,"[UE %d] frame %d, slot %d, PBCH: mode1_flag %d, tx_ant %d, frame_tx %d, phase %d. N_RB_DL %d, phich_duration %d, phich_resource %d/6\n",
 	      phy_vars_ue->Mod_id, 
 	      phy_vars_ue->frame,
 	      last_slot,
@@ -1732,7 +1732,7 @@ void lte_ue_pbch_procedures(u8 eNB_id,u8 last_slot, PHY_VARS_UE *phy_vars_ue,u8
         
   }  
   else {
-    LOG_E(PHY,"[UE  %d] frame %d, slot %d, Error decoding PBCH!\n",
+    LOG_E(PHY,"[UE %d] frame %d, slot %d, Error decoding PBCH!\n",
 	phy_vars_ue->Mod_id,phy_vars_ue->frame, last_slot);
     phy_vars_ue->lte_ue_pbch_vars[eNB_id]->pdu_errors_conseq++;
     phy_vars_ue->lte_ue_pbch_vars[eNB_id]->pdu_errors++;
@@ -1748,7 +1748,7 @@ void lte_ue_pbch_procedures(u8 eNB_id,u8 last_slot, PHY_VARS_UE *phy_vars_ue,u8
   }
   
 #ifdef DEBUG_PHY_PROC  
-  LOG_D(PHY,"[UE  %d] frame %d, slot %d, PBCH errors = %d, consecutive errors = %d!\n",
+  LOG_D(PHY,"[UE %d] frame %d, slot %d, PBCH errors = %d, consecutive errors = %d!\n",
 	    phy_vars_ue->Mod_id,phy_vars_ue->frame, last_slot, 
 	    phy_vars_ue->lte_ue_pbch_vars[eNB_id]->pdu_errors, 
 	    phy_vars_ue->lte_ue_pbch_vars[eNB_id]->pdu_errors_conseq);
diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h
index bbb04536e6..2d3bff1383 100644
--- a/openair2/LAYER2/MAC/defs.h
+++ b/openair2/LAYER2/MAC/defs.h
@@ -31,6 +31,7 @@
 * \author Raymond Knopp, Navid Nikaein
 * \date 2011
 * \version 0.5
+* \email navid.nikaein@eurecom.fr
 * @ingroup _mac
 
 */
@@ -959,7 +960,7 @@ s8 get_deltaP_rampup(u8 Mod_id);
 
 void chbch_phy_sync_success(u8 Mod_id,u32 frame,u8 CH_index);
 
-void mrbch_phy_sync_failure(u8 Mod_id, u32 frame,u8 Free_ch_index);
+void mrbch_phy_sync_failure(u8 Mod_id, u32 frame,u8 free_eNB_index);
 
 int mac_top_init(int eMBMS_active, u8 cba_group_active);
 
@@ -1136,7 +1137,7 @@ u32 ue_get_SR(u8 Mod_id, u32 frame, u8 eNB_id,u16 rnti,u8 subframe);
 u8 get_ue_weight(u8 Mod_id, u8 UE_id);
 
 // UE functions
-void out_of_sync_ind(u8 Mod_id, u32 frame, u16);
+void mac_out_of_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index);
 
 void ue_decode_si(u8 Mod_id, u32 frame, u8 CH_index, void *pdu, u16 len);
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 5f9f32f191..3f9a622fcd 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -30,6 +30,7 @@
  * \brief procedures related to UE
  * \author Raymond Knopp, Navid Nikaein
  * \date 2011
+ * \email: navid.nikaein@eurecom.fr
  * \version 0.5
  * @ingroup _mac
 
@@ -1458,6 +1459,16 @@ int schedule_MBMS(unsigned char Mod_id,u32 frame, u8 subframe) {
     // filling remainder of MCH with random data if necessery
     for (j=0;j<(TBS-sdu_length_total-offset);j++)
       eNB_mac_inst[Mod_id].MCH_pdu.payload[offset+sdu_length_total+j] = (char)(taus()&0xff);
+
+#if defined(USER_MODE) && defined(OAI_EMU)
+        /* Tracing of PDU is done on UE side */
+	if (oai_emulation.info.opt_enabled)
+            trace_pdu(1, (uint8_t *)eNB_mac_inst[Mod_id].MCH_pdu.payload[0],
+		      TBS, Mod_id, 6, 0xffff,  // M_RNTI = 6 in wirehsark
+		      eNB_mac_inst[Mod_id].subframe,0,0);
+	LOG_D(OPT,"[eNB %d][MCH] Frame %d : MAC PDU with size %d\n", 
+	      Mod_id, frame, TBS);
+#endif
 /*    
    for (j=0;j<sdu_length_total;j++)
       printf("%2x.",eNB_mac_inst[Mod_id].MCH_pdu.payload[j+offset]);
diff --git a/openair2/LAYER2/MAC/main.c b/openair2/LAYER2/MAC/main.c
index 616e88d1e3..e44b1d5caa 100644
--- a/openair2/LAYER2/MAC/main.c
+++ b/openair2/LAYER2/MAC/main.c
@@ -31,6 +31,7 @@
 * \author Raymond Knopp and Navid Nikaein
 * \date 2011
 * \version 0.5
+* \email: navid.nikaein@eurecom.fr
 * @ingroup _mac
 
 */
@@ -78,40 +79,27 @@ void dl_phy_sync_success(unsigned char Mod_id,
 			 unsigned char eNB_index,
 			 u8 first_sync){  //init as MR
 /***********************************************************************/
-  // msg("[MAC]Node %d, PHY SYNC to eNB_index %d\n",NODE_ID[Mod_id],eNB_index);
+  LOG_D(MAC,"[UE %d] Frame %d: PHY Sync to eNB_index %d successful \n", Mod_id, frame, eNB_index);
   if (first_sync==1) {
-    if( (layer2_init_UE(Mod_id)==-1) ||
-	(openair_rrc_ue_init(Mod_id,eNB_index)==-1) ) {
-	//(openair_rrc_lite_ue_init(Mod_id,eNB_index)==-1) ) {
-      //    Mac_rlc_xface->Is_cluster_head[Mod_id]=2;
-    }
+    layer2_init_UE(Mod_id);
+    openair_rrc_ue_init(Mod_id,eNB_index);
   }
   else {
     mac_in_sync_ind(Mod_id,frame,eNB_index);
   }
-
+  
 }
 
 /***********************************************************************/
-void mrbch_phy_sync_failure(u8 Mod_id, u32 frame, u8 Free_ch_index){//init as CH
+void mrbch_phy_sync_failure(u8 Mod_id, u32 frame, u8 free_eNB_index){//init as CH
   /***********************************************************************/
-  LOG_I(MAC,"FRAME %d: Node %d, NO PHY SYNC to master\n",frame,Mod_id);
-  //if((layer2_init_eNB(Mod_id, Free_ch_index)==-1) || ( openair_rrc_lite_eNB_init(Mod_id)==-1)){
-  if((layer2_init_eNB(Mod_id, Free_ch_index)==-1) || ( openair_rrc_eNB_init(Mod_id)==-1)){
-    //    Mac_rlc_xface->Is_cluster_head[Mod_id]=2;
-    }
-
-
+  LOG_I(MAC,"[eNB %d] Frame %d: PHY Sync failure \n",Mod_id,frame);
+  layer2_init_eNB(Mod_id, free_eNB_index);
+  openair_rrc_eNB_init(Mod_id);
 
 }
 
-/***********************************************************************/
 char layer2_init_eNB(unsigned char Mod_id, unsigned char eNB_index){
-/***********************************************************************/
-
-  Mac_rlc_xface->Is_cluster_head[Mod_id]=1;
-
-  //  msg("\nMAC: INIT eNB %d Successful \n\n",Mod_id);
 
   return 0;
 
@@ -119,9 +107,7 @@ char layer2_init_eNB(unsigned char Mod_id, unsigned char eNB_index){
 
 /***********************************************************************/
 char layer2_init_UE(unsigned char Mod_id){
-  /***********************************************************************/
-  Mac_rlc_xface->Is_cluster_head[NB_eNB_INST + Mod_id]=0;
-
+ 
   return 0;
 }
 
diff --git a/openair2/LAYER2/MAC/ue_procedures.c b/openair2/LAYER2/MAC/ue_procedures.c
index 84cdadda80..8934acb311 100644
--- a/openair2/LAYER2/MAC/ue_procedures.c
+++ b/openair2/LAYER2/MAC/ue_procedures.c
@@ -31,6 +31,7 @@
 * \author Raymond Knopp, Navid Nikaein
 * \date 2011
 * \version 0.5
+* \email: navid.nikaein@eurecom.fr
 * @ingroup _mac
 
 */
diff --git a/openair2/PHY_INTERFACE/defs.h b/openair2/PHY_INTERFACE/defs.h
index 839efe98ba..69377b19cf 100755
--- a/openair2/PHY_INTERFACE/defs.h
+++ b/openair2/PHY_INTERFACE/defs.h
@@ -88,7 +88,7 @@ typedef struct
     void (*rx_sdu)(u8 Mod_id,u32 frame,u16 rnti, u8 *sdu,u16 sdu_len);
 
     /// Indicate failure to synch to external source
-    void (*mrbch_phy_sync_failure) (u8 Mod_id,u32 frame, u8 Free_ch_index);
+    void (*mrbch_phy_sync_failure) (u8 Mod_id,u32 frame, u8 free_eNB_index);
 
     /// Indicate Scheduling Request from UE
     void (*SR_indication)(u8 Mod_id,u32 frame,u16 rnti,u8 subframe);
@@ -126,8 +126,8 @@ typedef struct
 
     // UE functions
 
-    /// Indicate loss of synchronization of PBCH
-    void (*out_of_sync_ind)(u8 Mod_id,u32 frame,u16);
+    /// Indicate loss of synchronization of PBCH for this eNB to MAC layer
+    void (*out_of_sync_ind)(u8 Mod_id,u32 frame,u16 eNB_index);
 
     ///  Send a received SI sdu
     void (*ue_decode_si)(u8 Mod_id,u32 frame, u8 CH_index, void *pdu, u16 len);
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index 829e04883b..1b1951f642 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -184,19 +184,11 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
   SRB_INFO *Srb_info;
   int si_window;
 
-#ifdef DEBUG_RRC
-  if (Srb_id == BCCH)
-    msg("[RRC]Node =%d: mac_rrc_data_ind to SI, eNB_UE_INDEX %d...\n",Mod_id,eNB_index);
-  else
-    msg("[RRC]Node =%d: mac_rrc_data_ind to SRB ID=%d, eNB_UE_INDEX %d...\n",Mod_id,Srb_id,eNB_index);
-#endif
-
   if(eNB_flag == 0){
 
-    //LOG_D(RRC,"[RRC][UE %d] Received SDU for SRB %d\n",Mod_id,Srb_id);
-
     if(Srb_id == BCCH){
-
+      
+      LOG_T(RRC,"[UE %d] Received SDU for BCCH on SRB %d from eNB %d\n",Mod_id,Srb_id,eNB_index);
       decode_BCCH_DLSCH_Message(Mod_id,frame,eNB_index,Sdu,Sdu_len);
       /*
       if ((frame %2) == 0) {
@@ -245,6 +237,7 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
       Srb_info = &UE_rrc_inst[Mod_id].Srb0[eNB_index];
       
       if (Sdu_len>0) {
+	LOG_T(RRC,"[UE %d] Received SDU for CCCH on SRB %d from eNB %d\n",Mod_id,Srb_id & RAB_OFFSET,eNB_index);
 	memcpy(Srb_info->Rx_buffer.Payload,Sdu,Sdu_len);
 	Srb_info->Rx_buffer.payload_size = Sdu_len;
 	rrc_ue_decode_ccch(Mod_id,frame,Srb_info,eNB_index);
@@ -253,7 +246,7 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
       
 #ifdef Rel10
     if ((Srb_id & RAB_OFFSET) == MCCH) {
-
+      LOG_T(RRC,"[UE %d] Received SDU for MCCH on SRB %d from eNB %d\n",Mod_id,Srb_id & RAB_OFFSET,eNB_index);
        decode_MCCH_Message(Mod_id, frame, eNB_index, Sdu, Sdu_len);
     }
 #endif // Rel10
@@ -261,8 +254,10 @@ s8 mac_rrc_lite_data_ind(u8 Mod_id, u32 frame, u16 Srb_id, char *Sdu, u16 Sdu_le
   }
 
   else{  // This is an eNB
+    LOG_T(RRC,"[eNB %d] Received SDU for CCCH on SRB %d\n",Mod_id,Srb_info->Srb_id);
+    
     Srb_info = &eNB_rrc_inst[Mod_id].Srb0;
-    //    msg("\n***********************************INST %d Srb_info %p, Srb_id=%d**********************************\n\n",Mod_id,Srb_info,Srb_info->Srb_id);
+    //    msg("\n******INST %d Srb_info %p, Srb_id=%d****\n\n",Mod_id,Srb_info,Srb_info->Srb_id);
     memcpy(Srb_info->Rx_buffer.Payload,Sdu,6);
     rrc_eNB_decode_ccch(Mod_id,frame,Srb_info);
  }
@@ -276,15 +271,16 @@ void mac_lite_sync_ind(u8 Mod_id,u8 Status){
 //-------------------------------------------------------------------------------------------//
 }
 
-//------------------------------------------------------------------------------------------------------------------//
+// this function is Not USED anymore
 void rrc_lite_data_ind( u8 Mod_id, u32 frame, u8 eNB_flag,u32 Srb_id, u32 sdu_size,u8 *Buffer){
-    //------------------------------------------------------------------------------------------------------------------//
 
   u8 UE_index=(Srb_id-1)/NB_RB_MAX;
   u8 DCCH_index = Srb_id % NB_RB_MAX;
 
-  LOG_D(RRC,"[SRB %d]RECEIVED MSG ON DCCH %d, UE %d, Size %d\n",
-	Srb_id-1, DCCH_index,UE_index,sdu_size);
+  LOG_N(RRC,"[%s %d] Frame %d: received a DCCH %d message on SRB %d with Size %d (Deprecated function)\n",
+	(eNB_flag == 1)? "eNB": "UE", 
+	(eNB_flag == 1)? Mod_id : UE_index, 
+	frame, DCCH_index,Srb_id-1,sdu_size);
   if (eNB_flag ==1)
     rrc_eNB_decode_dcch(Mod_id,frame,DCCH_index,UE_index,Buffer,sdu_size);
   else
@@ -298,15 +294,13 @@ void rrc_lite_in_sync_ind(u8 Mod_id, u32 frame, u16 eNB_index) {
   if (UE_rrc_inst[Mod_id].Info[eNB_index].T310_active==1)
     UE_rrc_inst[Mod_id].Info[eNB_index].N311_cnt++;
 }
-/*-------------------------------------------------------------------------------------------*/
 void rrc_lite_out_of_sync_ind(u8  Mod_id, u32 frame, u16 eNB_index){
-/*-------------------------------------------------------------------------------------------*/
-
 
 //  rlc_info_t rlc_infoP;
 //  rlc_infoP.rlc_mode=RLC_UM;
 
-  LOG_D(RRC,"[UE %d] Frame %d OUT OF SYNC FROM CH %d (T310 %d, N310 %d, N311 %d)\n ",Mod_id,frame,eNB_index,
+  LOG_I(RRC,"[UE %d] Frame %d: OUT OF SYNC FROM eNB %d (T310 %d, N310 %d, N311 %d)\n ",
+	Mod_id,frame,eNB_index,
 	UE_rrc_inst[Mod_id].Info[eNB_index].T310_cnt,
 	UE_rrc_inst[Mod_id].Info[eNB_index].N310_cnt,
 	UE_rrc_inst[Mod_id].Info[eNB_index].N311_cnt);
diff --git a/openair2/RRC/LITE/MESSAGES/asn1_msg.c b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
index cacff00cc8..763208b31d 100644
--- a/openair2/RRC/LITE/MESSAGES/asn1_msg.c
+++ b/openair2/RRC/LITE/MESSAGES/asn1_msg.c
@@ -559,7 +559,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
   struct SystemInformation_r8_IEs__sib_TypeAndInfo__Member *sib13_part;
   MBSFN_SubframeConfigList_t *MBSFNSubframeConfigList;
   MBSFN_AreaInfoList_r9_t *MBSFNArea_list;
-  struct MBSFN_AreaInfo_r9 *MBSFN_Area1;
+  struct MBSFN_AreaInfo_r9 *MBSFN_Area1, *MBSFN_Area2;
 #endif
   asn_enc_rval_t enc_rval;
 
@@ -797,7 +797,7 @@ uint8_t do_SIB23(uint8_t Mod_id,
     // MBSFN Area 1
     MBSFN_Area1= CALLOC(1, sizeof(*MBSFN_Area1));
     MBSFN_Area1->mbsfn_AreaId_r9= 1;
-    MBSFN_Area1->non_MBSFNregionLength= MBSFN_AreaInfo_r9__non_MBSFNregionLength_s1;
+    MBSFN_Area1->non_MBSFNregionLength= MBSFN_AreaInfo_r9__non_MBSFNregionLength_s2;
     MBSFN_Area1->notificationIndicator_r9= 0;
     MBSFN_Area1->mcch_Config_r9.mcch_RepetitionPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_RepetitionPeriod_r9_rf32;
     MBSFN_Area1->mcch_Config_r9.mcch_Offset_r9= 1; // in accordance with mbsfn subframe configuration in sib2
@@ -817,23 +817,29 @@ uint8_t do_SIB23(uint8_t Mod_id,
 
     ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area1);
     
-    /*    //MBSFN Area 2
-    MBSFN_Area2= CALLOC(1, sizeof(*MBSFN_Area2));
-    MBSFN_Area2->mbsfn_AreaId_r9= 2;
-    MBSFN_Area2->non_MBSFNregionLength= MBSFN_AreaInfo_r9__non_MBSFNregionLength_s1;
-    MBSFN_Area2->notificationIndicator_r9= 0;
-    MBSFN_Area2->mcch_Config_r9.mcch_RepetitionPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_RepetitionPeriod_r9_rf32;
-    MBSFN_Area2->mcch_Config_r9.mcch_Offset_r9= 0;
-    MBSFN_Area2->mcch_Config_r9.mcch_ModificationPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_ModificationPeriod_r9_rf512;
-    // Subframe Allocation Info
-    MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1);
-    MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
-    MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x8;
-    MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
-
-    MBSFN_Area2->mcch_Config_r9.signallingMCS_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n2;
-
-    ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area2);*/
+    //MBSFN Area 2: currently only activated for eMBMS relaying
+    if (MBMS_flag == 4 ) {
+      MBSFN_Area2= CALLOC(1, sizeof(*MBSFN_Area2));
+      MBSFN_Area2->mbsfn_AreaId_r9= 2;
+      MBSFN_Area2->non_MBSFNregionLength= MBSFN_AreaInfo_r9__non_MBSFNregionLength_s2;
+      MBSFN_Area2->notificationIndicator_r9= 1;
+      MBSFN_Area2->mcch_Config_r9.mcch_RepetitionPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_RepetitionPeriod_r9_rf32;
+      MBSFN_Area2->mcch_Config_r9.mcch_Offset_r9= 1;
+      MBSFN_Area2->mcch_Config_r9.mcch_ModificationPeriod_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__mcch_ModificationPeriod_r9_rf512;
+      // Subframe Allocation Info
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.buf= MALLOC(1);
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.size= 1;
+      MBSFN_Area2->mcch_Config_r9.sf_AllocInfo_r9.bits_unused= 2;
+      if (frame_parms->frame_type == TDD) {//TDD: SF7
+	MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x08<<2; 
+      } 
+      else {
+	MBSFN_Area1->mcch_Config_r9.sf_AllocInfo_r9.buf[0]=0x04<<2;  // FDD: SF6
+      }
+      MBSFN_Area2->mcch_Config_r9.signallingMCS_r9= MBSFN_AreaInfo_r9__mcch_Config_r9__signallingMCS_r9_n2;
+      
+      ASN_SEQUENCE_ADD(&MBSFNArea_list->list,MBSFN_Area2);
+    }
     //  end of adding for MBMS SIB13
   }
 #endif
-- 
GitLab