pdcp_fifo.c 34.8 KB
Newer Older
1
/*******************************************************************************
gauthier's avatar
gauthier committed
2 3
    OpenAirInterface
    Copyright(c) 1999 - 2014 Eurecom
4

gauthier's avatar
gauthier committed
5 6 7 8
    OpenAirInterface is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
9 10


gauthier's avatar
gauthier committed
11 12 13 14
    OpenAirInterface is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
15

gauthier's avatar
gauthier committed
16 17 18 19
    You should have received a copy of the GNU General Public License
    along with OpenAirInterface.The full GNU General Public License is
   included in this distribution in the file called "COPYING". If not,
   see <http://www.gnu.org/licenses/>.
20 21

  Contact Information
gauthier's avatar
gauthier committed
22 23
  OpenAirInterface Admin: openair_admin@eurecom.fr
  OpenAirInterface Tech : openair_tech@eurecom.fr
24
  OpenAirInterface Dev  : openair4g-devel@lists.eurecom.fr
gauthier's avatar
gauthier committed
25

ghaddab's avatar
ghaddab committed
26
  Address      : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
27

gauthier's avatar
gauthier committed
28
 *******************************************************************************/
29 30

/*! \file pdcp_fifo.c
gauthier's avatar
gauthier committed
31
 * \brief pdcp interface with linux IP interface, have a look at http://man7.org/linux/man-pages/man7/netlink.7.html for netlink
32 33
 * \author  Navid Nikaein and Lionel GAUTHIER
 * \date 2009 - 2016
gauthier's avatar
gauthier committed
34
 * \version 0.5
35
 * \email navid.nikaein@eurecom.fr
gauthier's avatar
gauthier committed
36 37 38
 * \warning This component can be runned only in user-space
 * @ingroup pdcp
 */
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

#define PDCP_FIFO_C
#define PDCP_DEBUG 1

#ifndef OAI_EMU
extern int otg_enabled;
#endif

#include "pdcp.h"
#include "pdcp_primitives.h"

#ifdef USER_MODE
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define rtf_put write
#define rtf_get read
#else
#include <rtai_fifos.h>
#endif //USER_MODE

#include "../MAC/extern.h"
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
63
#include "NETWORK_DRIVER/LITE/constant.h"
64 65 66 67
#include "SIMULATION/ETH_TRANSPORT/extern.h"
#include "UTIL/OCG/OCG.h"
#include "UTIL/OCG/OCG_extern.h"
#include "UTIL/LOG/log.h"
68
#include "UTIL/OTG/otg_tx.h"
69
#include "UTIL/FIFO/pad_list.h"
70
#include "platform_constants.h"
gauthier's avatar
msc  
gauthier committed
71
#include "msc.h"
72

73
#include "assertions.h"
74

75
#ifdef PDCP_USE_NETLINK
76 77
#include <sys/socket.h>
#include <linux/netlink.h>
78
#include "NETWORK_DRIVER/UE_IP/constant.h"
79

80
extern char nl_rx_buf[NL_MAX_PAYLOAD];
81
extern struct sockaddr_nl nas_src_addr, nas_dest_addr;
82 83 84 85
extern struct nlmsghdr *nas_nlh_tx;
extern struct nlmsghdr *nas_nlh_rx;
extern struct iovec nas_iov_tx;
extern struct iovec nas_iov_rx;
86
extern int nas_sock_fd;
87 88
extern struct msghdr nas_msg_tx;
extern struct msghdr nas_msg_rx;
89

gauthier's avatar
gauthier committed
90
unsigned char pdcp_read_state_g = 0;
91 92
#endif

93
extern Packet_OTG_List_t *otg_pdcp_buffer;
94

95
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
96
#  include "gtpv1u_eNB_task.h"
gauthier's avatar
gauthier committed
97 98
#endif

gauthier's avatar
gauthier committed
99
pdcp_data_req_header_t pdcp_read_header_g;
100 101

//-----------------------------------------------------------------------------
102
int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const  ctxt_pP)
103 104 105
{
  //-----------------------------------------------------------------------------

gauthier's avatar
gauthier committed
106 107 108
  mem_block_t     *sdu_p            = list_get_head (&pdcp_sdu_list);
  int              bytes_wrote      = 0;
  int              pdcp_nb_sdu_sent = 0;
gauthier's avatar
gauthier committed
109
  uint8_t          cont             = 1;
110
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
111
  //MessageDef      *message_p        = NULL;
gauthier's avatar
gauthier committed
112
#endif
113

114
#if defined(PDCP_USE_NETLINK) && defined(LINUX)
115 116 117
  int ret = 0;
#endif

gauthier's avatar
gauthier committed
118
  while (sdu_p && cont) {
119

gauthier's avatar
gauthier committed
120
#if ! defined(OAI_EMU)
121
    ((pdcp_data_ind_header_t *)(sdu_p->data))->inst = 0;
122 123
#endif

124
#if defined(LINK_ENB_PDCP_TO_GTPV1U)
gauthier's avatar
gauthier committed
125

126 127 128 129
    if (ctxt_pP->enb_flag) {
      AssertFatal(0, "Now execution should not go here");
      LOG_D(PDCP,"Sending to GTPV1U %d bytes\n", ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
      gtpv1u_new_data_req(
130 131
        ctxt_pP->module_id, //gtpv1u_data_t *gtpv1u_data_p,
        ctxt_pP->rnti,//rb_id/maxDRB, TO DO UE ID
132 133 134 135 136 137 138 139 140 141 142 143 144
        ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id + 4,
        &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t)]),
        ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);

      list_remove_head (&pdcp_sdu_list);
      free_mem_block (sdu_p);
      cont = 1;
      pdcp_nb_sdu_sent += 1;
      sdu_p = list_get_head (&pdcp_sdu_list);
      LOG_D(OTG,"After  GTPV1U\n");
      continue; // loop again
    }

gauthier's avatar
gauthier committed
145
#endif /* defined(ENABLE_USE_MME) */
146
#ifdef PDCP_DEBUG
147
    LOG_D(PDCP, "PDCP->IP TTI %d INST %d: Preparing %d Bytes of data from rab %d to Nas_mesh\n",
148
          ctxt_pP->frame, ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
gauthier's avatar
gauthier committed
149
          ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size, ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
150
#endif //PDCP_DEBUG
151
    cont = 0;
152

153 154 155 156
    if (!pdcp_output_sdu_bytes_to_write) {
      if (!pdcp_output_header_bytes_to_write) {
        pdcp_output_header_bytes_to_write = sizeof (pdcp_data_ind_header_t);
      }
157

158 159
#ifdef PDCP_USE_RT_FIFO
      bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
160 161
                             &(((uint8_t *) sdu->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
                             pdcp_output_header_bytes_to_write);
162 163

#else
164
#ifdef PDCP_USE_NETLINK
165
#ifdef LINUX
166 167 168
      memcpy(NLMSG_DATA(nas_nlh_tx), &(((uint8_t *) sdu_p->data)[sizeof (pdcp_data_ind_header_t) - pdcp_output_header_bytes_to_write]),
             pdcp_output_header_bytes_to_write);
      nas_nlh_tx->nlmsg_len = pdcp_output_header_bytes_to_write;
169
#endif //LINUX
170
#endif //PDCP_USE_NETLINK
171

172
      bytes_wrote = pdcp_output_header_bytes_to_write;
173
#endif //PDCP_USE_RT_FIFO
174 175

#ifdef PDCP_DEBUG
176
      LOG_D(PDCP, "Frame %d Sent %d Bytes of header to Nas_mesh\n",
177 178
            ctxt_pP->frame,
            bytes_wrote);
179 180
#endif //PDCP_DEBUG

181 182
      if (bytes_wrote > 0) {
        pdcp_output_header_bytes_to_write = pdcp_output_header_bytes_to_write - bytes_wrote;
183

184 185
        if (!pdcp_output_header_bytes_to_write) { // continue with sdu
          pdcp_output_sdu_bytes_to_write = ((pdcp_data_ind_header_t *) sdu_p->data)->data_size;
186

187 188
#ifdef PDCP_USE_RT_FIFO
          bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO, &(sdu->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
189 190
#else

191
#ifdef PDCP_USE_NETLINK
192
#ifdef LINUX
193 194 195 196 197
          memcpy(NLMSG_DATA(nas_nlh_tx)+sizeof(pdcp_data_ind_header_t), &(sdu_p->data[sizeof (pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write);
          nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write;
          ret = sendmsg(nas_sock_fd,&nas_msg_tx,0);

          if (ret<0) {
198
            LOG_E(PDCP, "[PDCP_FIFOS] sendmsg returns %d (errno: %d)\n", ret, errno);
gauthier's avatar
msc  
gauthier committed
199 200 201 202 203 204 205 206 207 208
      	    MSC_LOG_TX_MESSAGE_FAILED(
      	      (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
      	      (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
      	      NULL,
      	      0,
      	      MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
      	      MSC_AS_TIME_ARGS(ctxt_pP),
      	      ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
      	      ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
           mac_xface->macphy_exit("sendmsg failed for nas_sock_fd\n");
209
            break;
gauthier's avatar
msc  
gauthier committed
210 211 212 213 214 215 216 217 218 219
          } else {
        	  MSC_LOG_TX_MESSAGE(
        	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
        	    (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
        	    NULL,
        	    0,
        	    MSC_AS_TIME_FMT" DATA-IND RNTI %"PRIx16" rb %u size %u",
        	    MSC_AS_TIME_ARGS(ctxt_pP),
        	    ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
        	    ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size);
220 221
          }

222
#endif // LINUX
223
#endif //PDCP_USE_NETLINK
224
          bytes_wrote= pdcp_output_sdu_bytes_to_write;
225
#endif // PDCP_USE_RT_FIFO
226 227

#ifdef PDCP_DEBUG
228 229 230 231 232
          LOG_D(PDCP, "PDCP->IP Frame %d INST %d: Sent %d Bytes of data from rab %d to higher layers\n",
                ctxt_pP->frame,
                ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
                bytes_wrote,
                ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);
233
#endif //PDCP_DEBUG
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255

          if (bytes_wrote > 0) {
            pdcp_output_sdu_bytes_to_write -= bytes_wrote;

            if (!pdcp_output_sdu_bytes_to_write) { // OK finish with this SDU
              // LOG_D(PDCP, "rb sent a sdu qos_sap %d\n", sapiP);
              LOG_D(PDCP,
                    "[FRAME %05d][xxx][PDCP][MOD xx/xx][RB %u][--- PDCP_DATA_IND / %d Bytes --->][IP][INSTANCE %u][RB %u]\n",
                    ctxt_pP->frame,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->data_size,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->inst,
                    ((pdcp_data_ind_header_t *)(sdu_p->data))->rb_id);

              list_remove_head (&pdcp_sdu_list);
              free_mem_block (sdu_p);
              cont = 1;
              pdcp_nb_sdu_sent += 1;
              sdu_p = list_get_head (&pdcp_sdu_list);
            }
          } else {
            LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n");
256
          }
257 258 259 260 261 262
        } else {
          LOG_W(PDCP, "RADIO->IP SEND SDU CONGESTION!\n");
        }
      }
    } else {
      // continue writing sdu
263 264
#ifdef PDCP_USE_RT_FIFO
      bytes_wrote = rtf_put (PDCP2PDCP_USE_RT_FIFO,
265 266
                             (uint8_t *) (&(sdu_p->data[sizeof (pdcp_data_ind_header_t) + ((pdcp_data_ind_header_t *) sdu_p->data)->data_size - pdcp_output_sdu_bytes_to_write])),
                             pdcp_output_sdu_bytes_to_write);
267
#else  // PDCP_USE_RT_FIFO
268
      bytes_wrote = pdcp_output_sdu_bytes_to_write;
269
#endif  // PDCP_USE_RT_FIFO
270

271 272 273 274 275 276 277 278 279 280 281 282
      if (bytes_wrote > 0) {
        pdcp_output_sdu_bytes_to_write -= bytes_wrote;

        if (!pdcp_output_sdu_bytes_to_write) {     // OK finish with this SDU
          //PRINT_RB_SEND_OUTPUT_SDU ("[PDCP] RADIO->IP SEND SDU\n");
          list_remove_head (&pdcp_sdu_list);
          free_mem_block (sdu_p);
          cont = 1;
          pdcp_nb_sdu_sent += 1;
          sdu_p = list_get_head (&pdcp_sdu_list);
          // LOG_D(PDCP, "rb sent a sdu from rab\n");
        }
283
      }
284
    }
285
  }
286

287
#ifdef PDCP_USE_RT_FIFO
288

289
  if ((pdcp_nb_sdu_sent)) {
290
    if ((pdcp_2_nas_irq > 0)) {
291
#ifdef PDCP_DEBUG
292
      LOG_D(PDCP, "Frame %d : Trigger NAS RX interrupt\n",
293
            ctxt_pP->frame);
294
#endif //PDCP_DEBUG
295
      rt_pend_linux_srq (pdcp_2_nas_irq);
296

297 298 299 300 301
    } else {
      LOG_E(PDCP, "Frame %d: ERROR IF IP STACK WANTED : NOTIF PACKET(S) pdcp_2_nas_irq not initialized : %d\n",
            ctxt_pP->frame,
            pdcp_2_nas_irq);
    }
302
  }
303

304
#endif  //PDCP_USE_RT_FIFO
305 306 307 308 309

  return pdcp_nb_sdu_sent;
}

//-----------------------------------------------------------------------------
310
int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const  ctxt_pP)
311
{
312
#ifdef PDCP_USE_NETLINK
313
  protocol_ctxt_t                ctxt_cpy = *ctxt_pP;
314 315 316 317
  protocol_ctxt_t                ctxt;
  hash_key_t                     key       = HASHTABLE_NOT_A_KEY_VALUE;
  hashtable_rc_t                 h_rc;
  struct pdcp_netlink_element_s* data_p    = NULL;
Cedric Roux's avatar
Cedric Roux committed
318 319
  /* avoid gcc warnings */
  (void)data_p;
gauthier's avatar
gauthier committed
320
  module_id_t                    ue_id     = 0;
321
  pdcp_t*                        pdcp_p    = NULL;
322
# if defined(PDCP_USE_NETLINK_QUEUES)
gauthier's avatar
gauthier committed
323
  rb_id_t                        rab_id    = 0;
324

325
  pdcp_transmission_mode_t       pdcp_mode = PDCP_TRANSMISSION_MODE_UNKNOWN;
gauthier's avatar
gauthier committed
326

gauthier's avatar
gauthier committed
327

328
  while (pdcp_netlink_dequeue_element(ctxt_pP, &data_p) != 0) {
329
    DevAssert(data_p != NULL);
330 331 332 333 334 335 336 337 338 339 340 341 342
    rab_id = data_p->pdcp_read_header.rb_id % maxDRB;
    // ctxt_pP->rnti is NOT_A_RNTI
    ctxt_cpy.rnti = pdcp_module_id_to_rnti[ctxt_cpy.module_id][data_p->pdcp_read_header.inst];
    key = PDCP_COLL_KEY_VALUE(ctxt_pP->module_id, ctxt_cpy.rnti, ctxt_pP->enb_flag, rab_id, SRB_FLAG_NO);
    h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);

    if (h_rc != HASH_TABLE_OK) {
      LOG_W(PDCP, PROTOCOL_CTXT_FMT" Dropped IP PACKET cause no PDCP instanciated\n",
            PROTOCOL_CTXT_ARGS(ctxt_pP));
      free(data_p->data);
      free(data_p);
      data_p = NULL;
      continue;
343 344
    }

345
    CHECK_CTXT_ARGS(&ctxt_cpy);
346 347 348 349 350

    AssertFatal (rab_id    < maxDRB,                       "RB id is too high (%u/%d)!\n", rab_id, maxDRB);

    if (rab_id != 0) {
        LOG_D(PDCP, "[FRAME %05d][%s][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ "
351
            "/ %d Bytes --->][PDCP][MOD %u][RB %u]\n",
352 353
              ctxt_cpy.frame,
              (ctxt_cpy.enb_flag) ? "eNB" : "UE",
354 355 356 357
            data_p->pdcp_read_header.inst,
            data_p->pdcp_read_header.rb_id,
            data_p->pdcp_read_header.data_size,
            ctxt_cpy.module_id,
358 359 360
              rab_id);
#ifdef  OAI_NW_DRIVER_TYPE_ETHERNET

361 362 363
      if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_MULTICAST) /*TRAFFIC_IPV6_TYPE_MULTICAST */ ||
          (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_MULTICAST) /*TRAFFIC_IPV4_TYPE_MULTICAST */ ||
          (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_BROADCAST) /*TRAFFIC_IPV4_TYPE_BROADCAST */ ) {
364
#if defined (Rel10)
365
          PDCP_TRANSMISSION_MODE_TRANSPARENT;
366
#else
367
          pdcp_mode= PDCP_TRANSMISSION_MODE_DATA;
368
#endif
369 370
      } else if ((data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV6_TYPE_UNICAST) /* TRAFFIC_IPV6_TYPE_UNICAST */ ||
                 (data_p->pdcp_read_header.traffic_type == TRAFFIC_IPV4_TYPE_UNICAST) /*TRAFFIC_IPV4_TYPE_UNICAST*/ ) {
371 372 373 374 375 376
          pdcp_mode=  PDCP_TRANSMISSION_MODE_DATA;
        } else {
          pdcp_mode= PDCP_TRANSMISSION_MODE_DATA;
          LOG_W(PDCP,"unknown IP traffic type \n");
        }

377
#else // OAI_NW_DRIVER_TYPE_ETHERNET NASMESH driver does not curreenlty support multicast traffic
378
        pdcp_mode = PDCP_TRANSMISSION_MODE_DATA;
379
#endif
380
      pdcp_data_req(&ctxt_cpy,
381
                      SRB_FLAG_NO,
382
                      rab_id % maxDRB,
gauthier's avatar
gauthier committed
383 384
                      RLC_MUI_UNDEFINED,
                      RLC_SDU_CONFIRM_NO,
385 386
                    data_p->pdcp_read_header.data_size,
                    data_p->data,
387 388 389 390 391 392 393 394 395
                      pdcp_mode);
    } else if (ctxt_cpy.enb_flag) {
      /* rb_id = 0, thus interpreated as broadcast and transported as
       * multiple unicast is a broadcast packet, we have to send this
       * packet on all default RABS of all connected UEs
       */
      LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID first_ue_local %u nb_ue_local %u\n", oai_emulation.info.first_ue_local, oai_emulation.info.nb_ue_local);

      for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) {
396
        if (pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) {
397
          LOG_D(PDCP, "eNB Try Forcing send on DEFAULT_RAB_ID UE %d\n", ue_id);
398 399
          ctxt.module_id     = ctxt_cpy.module_id;
          ctxt.rnti          = ctxt_cpy.pdcp_module_id_to_rnti[ctxt_cpy.module_id][ue_id];
400 401 402
          ctxt.frame         = ctxt_cpy.frame;
          ctxt.enb_flag      = ctxt_cpy.enb_flag;

gauthier's avatar
gauthier committed
403
          pdcp_data_req(
404 405 406 407 408
            &ctxt,
            SRB_FLAG_NO,
            DEFAULT_RAB_ID,
            RLC_MUI_UNDEFINED,
            RLC_SDU_CONFIRM_NO,
409 410
            data_p->pdcp_read_header.data_size,
            data_p->data,
411 412
            PDCP_TRANSMISSION_MODE_DATA);
        }
gauthier's avatar
gauthier committed
413
      }
414 415 416 417 418 419 420 421
    } else {
      LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n");
      pdcp_data_req(
        &ctxt_cpy,
        SRB_FLAG_NO,
        DEFAULT_RAB_ID,
        RLC_MUI_UNDEFINED,
        RLC_SDU_CONFIRM_NO,
422 423
        data_p->pdcp_read_header.data_size,
        data_p->data,
424 425 426
        PDCP_TRANSMISSION_MODE_DATA);
    }

427 428 429
    free(data_p->data);
    free(data_p);
    data_p = NULL;
gauthier's avatar
gauthier committed
430
  }
431

gauthier's avatar
gauthier committed
432
  return 0;
433
# else /* PDCP_USE_NETLINK_QUEUES*/
434 435 436
  int              len = 1;
  rb_id_t          rab_id  = 0;

437 438 439 440 441
  while (len > 0) {
    len = recvmsg(nas_sock_fd, &nas_msg_rx, 0);

    if (len<=0) {
      // nothing in pdcp NAS socket
442
      //LOG_D(PDCP, "[PDCP][NETLINK] Nothing in socket, length %d \n", len);
443 444 445 446 447 448
    } else {
      for (nas_nlh_rx = (struct nlmsghdr *) nl_rx_buf;
           NLMSG_OK (nas_nlh_rx, len);
           nas_nlh_rx = NLMSG_NEXT (nas_nlh_rx, len)) {

        if (nas_nlh_rx->nlmsg_type == NLMSG_DONE) {
449
          LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_DONE\n");
450 451 452 453
          //return;
        }

        if (nas_nlh_rx->nlmsg_type == NLMSG_ERROR) {
454
          LOG_D(PDCP, "[PDCP][NETLINK] RX NLMSG_ERROR\n");
455 456 457 458 459 460
        }

        if (pdcp_read_state_g == 0) {
          if (nas_nlh_rx->nlmsg_len == sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)) {
            pdcp_read_state_g = 1;  //get
            memcpy((void *)&pdcp_read_header_g, (void *)NLMSG_DATA(nas_nlh_rx), sizeof(pdcp_data_req_header_t));
461
            LOG_D(PDCP, "[PDCP][NETLINK] RX pdcp_data_req_header_t inst %u, rb_id %u data_size %d\n",
462 463
                  pdcp_read_header_g.inst, pdcp_read_header_g.rb_id, pdcp_read_header_g.data_size);
          } else {
464
            LOG_E(PDCP, "[PDCP][NETLINK] WRONG size %d should be sizeof (pdcp_data_req_header_t) + sizeof(struct nlmsghdr)\n",
465 466 467 468 469
                  nas_nlh_rx->nlmsg_len);
          }
        } else {
          pdcp_read_state_g = 0;
          // print_active_requests()
470
#ifdef PDCP_DEBUG
471
          LOG_D(PDCP, "[PDCP][NETLINK] Something in socket, length %d \n",
472
                nas_nlh_rx->nlmsg_len - sizeof(struct nlmsghdr));
473
#endif
gauthier's avatar
gauthier committed
474

475
#ifdef OAI_EMU
476 477 478 479 480

          // overwrite function input parameters, because only one netlink socket for all instances
          if (pdcp_read_header_g.inst < oai_emulation.info.nb_enb_local) {
            ctxt.frame         = ctxt_cpy.frame;
            ctxt.enb_flag      = ENB_FLAG_YES;
481 482
            ctxt.module_id     = pdcp_read_header_g.inst  +  oai_emulation.info.first_enb_local;
            ctxt.rnti          = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id ][pdcp_read_header_g.rb_id / maxDRB + oai_emulation.info.first_ue_local];
483 484 485 486
            rab_id    = pdcp_read_header_g.rb_id % maxDRB;
          } else {
            ctxt.frame         = ctxt_cpy.frame;
            ctxt.enb_flag      = ENB_FLAG_NO;
487 488
            ctxt.module_id     = pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local + oai_emulation.info.first_ue_local;
            ctxt.rnti          = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
nikaeinn's avatar
nikaeinn committed
489
            rab_id    = pdcp_read_header_g.rb_id % maxDRB;
490 491
          }

492
          CHECK_CTXT_ARGS(&ctxt);
493 494 495 496
          AssertFatal (rab_id    < maxDRB,                       "RB id is too high (%u/%d)!\n", rab_id, maxDRB);
          /*LGpdcp_read_header.inst = (pdcp_read_header_g.inst >= oai_emulation.info.nb_enb_local) ? \
                  pdcp_read_header_g.inst - oai_emulation.info.nb_enb_local+ NB_eNB_INST + oai_emulation.info.first_ue_local :
                  pdcp_read_header_g.inst +  oai_emulation.info.first_enb_local;*/
497
#else // OAI_EMU
498
          pdcp_read_header_g.inst = 0;
Cedric Roux's avatar
Cedric Roux committed
499
//#warning "TO DO CORRCT VALUES FOR ue mod id, enb mod id"
500
          ctxt.frame         = ctxt_cpy.frame;
501
          ctxt.enb_flag      = ctxt_cpy.enb_flag;
502

503 504 505 506
#ifdef PDCP_DEBUG
          LOG_I(PDCP, "[PDCP][NETLINK] pdcp_read_header_g.rb_id = %d\n", pdcp_read_header_g.rb_id);
#endif

507
          if (ctxt_cpy.enb_flag) {
508
            ctxt.module_id = 0;
509
            rab_id      = pdcp_read_header_g.rb_id % maxDRB;
510
            ctxt.rnti          = pdcp_eNB_UE_instance_to_rnti[pdcp_eNB_UE_instance_to_rnti_index];
511
          } else {
512
            ctxt.module_id = 0;
513
            rab_id      = pdcp_read_header_g.rb_id % maxDRB;
514
            ctxt.rnti          = pdcp_UE_UE_module_id_to_rnti[ctxt.module_id];
515
          }
516

517

gauthier's avatar
gauthier committed
518 519
#endif

520 521 522
          if (ctxt.enb_flag) {
            if (rab_id != 0) {
              rab_id = rab_id % maxDRB;
523 524
              key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
              h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
525

526
              if (h_rc == HASH_TABLE_OK) {
527
#ifdef PDCP_DEBUG
528 529 530 531 532 533
                LOG_D(PDCP, "[FRAME %5u][eNB][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n",
                      ctxt.frame,
                      pdcp_read_header_g.inst,
                      len,
                      nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr),
                      pdcp_read_header_g.rb_id);
534 535
#endif

gauthier's avatar
msc  
gauthier committed
536 537 538 539 540
          	    MSC_LOG_RX_MESSAGE(
          	      (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
                  (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
          	      NULL,
          	      0,
gauthier's avatar
gauthier committed
541
          	      MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
gauthier's avatar
msc  
gauthier committed
542 543 544 545 546
          	      MSC_AS_TIME_ARGS(ctxt_pP),
                  pdcp_read_header_g.inst,
          	      pdcp_read_header_g.rb_id,
          	      rab_id,
          	      pdcp_read_header_g.data_size);
547
                LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u]UE %u][RB %u]\n",
548 549 550 551
                      ctxt_cpy.frame,
                      pdcp_read_header_g.inst,
                      pdcp_read_header_g.rb_id,
                      pdcp_read_header_g.data_size,
552 553
                      ctxt.module_id,
                      ctxt.rnti,
554 555 556 557 558 559 560 561 562 563 564
                      rab_id);

                pdcp_data_req(&ctxt,
                              SRB_FLAG_NO,
                              rab_id,
                              RLC_MUI_UNDEFINED,
                              RLC_SDU_CONFIRM_NO,
                              pdcp_read_header_g.data_size,
                              (unsigned char *)NLMSG_DATA(nas_nlh_rx),
                              PDCP_TRANSMISSION_MODE_DATA);
              } else {
565
                LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE, DROPPED\n",
566 567 568 569
                      ctxt.frame,
                      pdcp_read_header_g.inst,
                      pdcp_read_header_g.rb_id,
                      pdcp_read_header_g.data_size,
570 571
                      ctxt.module_id,
                      ctxt.rnti,
572 573 574 575
                      rab_id);
              }
            } else  { // rb_id =0, thus interpreated as broadcast and transported as multiple unicast
              // is a broadcast packet, we have to send this packet on all default RABS of all connected UEs
Cedric Roux's avatar
Cedric Roux committed
576
//#warning CODE TO BE REVIEWED, ONLY WORK FOR SIMPLE TOPOLOGY CASES
577 578 579 580
              for (ue_id = 0; ue_id < NB_UE_INST; ue_id++) {
                if (oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id] != NOT_A_RNTI) {
                  ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt_cpy.module_id][ue_id];
                  LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
581 582 583 584
                        ctxt.frame,
                        pdcp_read_header_g.inst,
                        pdcp_read_header_g.rb_id,
                        pdcp_read_header_g.data_size,
585 586
                        ctxt.module_id,
                        ctxt.rnti,
587 588 589 590 591 592 593 594 595 596 597 598 599
                        DEFAULT_RAB_ID);
                  pdcp_data_req (
                    &ctxt,
                    SRB_FLAG_NO,
                    DEFAULT_RAB_ID,
                    RLC_MUI_UNDEFINED,
                    RLC_SDU_CONFIRM_NO,
                    pdcp_read_header_g.data_size,
                    (unsigned char *)NLMSG_DATA(nas_nlh_rx),
                    PDCP_TRANSMISSION_MODE_DATA);
                }
              }
            }
600
          } else { // enb_flag
601
            if (rab_id != 0) {
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616
#ifndef ASTRI_FIX // 2016-05-30 wilson : fix hard-code default DRB ID
              if (rab_id == UE_IP_DEFAULT_RAB_ID) {
                LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n",
                    ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
                key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag);
                h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
              } else
#endif
              {
                rab_id = rab_id % maxDRB;
                LOG_D(PDCP, "PDCP_COLL_KEY_VALUE(module_id=%d, rnti=%x, enb_flag=%d, rab_id=%d, SRB_FLAG=%d)\n",
                    ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
                key = PDCP_COLL_KEY_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag, rab_id, SRB_FLAG_NO);
                h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p);
              }
617 618

              if (h_rc == HASH_TABLE_OK) {
619 620 621
#ifndef ASTRI_FIX // 2016-05-30 wilson : fix default DRB-ID to be configurable
                rab_id = pdcp_p->rb_id;
#endif
gauthier's avatar
gauthier committed
622
#ifdef PDCP_DEBUG
623 624 625 626 627 628
                LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d (nlmsg_len = %d) on Rab %d \n",
                      ctxt.frame,
                      pdcp_read_header_g.inst,
                      len,
                      nas_nlh_rx->nlmsg_len-sizeof(struct nlmsghdr),
                      pdcp_read_header_g.rb_id);
629

630
                LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n",
631 632 633 634
                      ctxt.frame,
                      pdcp_read_header_g.inst,
                      pdcp_read_header_g.rb_id,
                      pdcp_read_header_g.data_size,
635 636
                      ctxt.module_id,
                      ctxt.rnti,
637 638
                      rab_id);
#endif
gauthier's avatar
msc  
gauthier committed
639 640 641 642 643
          	    MSC_LOG_RX_MESSAGE(
          	      (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
                  (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
          	      NULL,
          	      0,
gauthier's avatar
gauthier committed
644
          	      MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
gauthier's avatar
msc  
gauthier committed
645 646 647 648 649
          	      MSC_AS_TIME_ARGS(ctxt_pP),
                  pdcp_read_header_g.inst,
          	      pdcp_read_header_g.rb_id,
          	      rab_id,
          	      pdcp_read_header_g.data_size);
gauthier's avatar
gauthier committed
650

651 652 653 654 655 656 657 658 659 660
                pdcp_data_req(
                  &ctxt,
                  SRB_FLAG_NO,
                  rab_id,
                  RLC_MUI_UNDEFINED,
                  RLC_SDU_CONFIRM_NO,
                  pdcp_read_header_g.data_size,
                  (unsigned char *)NLMSG_DATA(nas_nlh_rx),
                  PDCP_TRANSMISSION_MODE_DATA);
              } else {
gauthier's avatar
msc  
gauthier committed
661 662 663 664 665
            	MSC_LOG_RX_DISCARDED_MESSAGE(
                  (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
                  (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
                  NULL,
                  0,
gauthier's avatar
gauthier committed
666
                  MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u",
gauthier's avatar
msc  
gauthier committed
667 668 669 670 671
                  MSC_AS_TIME_ARGS(ctxt_pP),
                  pdcp_read_header_g.inst,
                  pdcp_read_header_g.rb_id,
                  rab_id,
                  pdcp_read_header_g.data_size);
672 673
                LOG_D(PDCP,
                      "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n",
674 675 676 677
                      ctxt.frame,
                      pdcp_read_header_g.inst,
                      pdcp_read_header_g.rb_id,
                      pdcp_read_header_g.data_size,
678 679 680 681
                      ctxt.module_id,
                      ctxt.rnti,
                      rab_id,
                      key);
682
              }
683 684
            }  else {
              LOG_D(PDCP, "Forcing send on DEFAULT_RAB_ID\n");
685
              LOG_D(PDCP, "[FRAME %5u][eNB][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB DEFAULT_RAB_ID %u]\n",
686 687 688 689
                    ctxt.frame,
                    pdcp_read_header_g.inst,
                    pdcp_read_header_g.rb_id,
                    pdcp_read_header_g.data_size,
690 691
                    ctxt.module_id,
                    ctxt.rnti,
692
                    DEFAULT_RAB_ID);
gauthier's avatar
msc  
gauthier committed
693 694 695 696
          	  MSC_LOG_RX_MESSAGE(
                (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE,
                (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE,
                NULL,0,
gauthier's avatar
gauthier committed
697
                MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u default rab %u size %u",
gauthier's avatar
msc  
gauthier committed
698 699 700 701 702 703
                MSC_AS_TIME_ARGS(ctxt_pP),
                pdcp_read_header_g.inst,
                pdcp_read_header_g.rb_id,
                DEFAULT_RAB_ID,
                pdcp_read_header_g.data_size);

704 705 706 707 708 709 710 711 712 713
              pdcp_data_req (
                &ctxt,
                SRB_FLAG_NO,
                DEFAULT_RAB_ID,
                RLC_MUI_UNDEFINED,
                RLC_SDU_CONFIRM_NO,
                pdcp_read_header_g.data_size,
                (unsigned char *)NLMSG_DATA(nas_nlh_rx),
                PDCP_TRANSMISSION_MODE_DATA);
            }
714
          }
715 716

        }
gauthier's avatar
gauthier committed
717
      }
718
    }
719
  }
720

721
  return len;
722
# endif
723
#else // neither PDCP_USE_NETLINK nor PDCP_USE_RT_FIFO
724
  return 0;
725
#endif // PDCP_USE_NETLINK
726 727 728
}


729 730
void pdcp_fifo_read_input_sdus_from_otg (const protocol_ctxt_t* const  ctxt_pP) {

731 732 733
  unsigned char       *otg_pkt=NULL;
  module_id_t          dst_id; // dst for otg
  rb_id_t              rb_id;
734
  unsigned int         pkt_size=0;
735
#if defined(USER_MODE) && defined(OAI_EMU)
736
  module_id_t          src_id;
737
  static unsigned int  pkt_cnt_enb=0, pkt_cnt_ue=0;
738

739 740
  Packet_otg_elt_t    *otg_pkt_info=NULL;
  int                  result;
741 742 743 744 745
  uint8_t              pdcp_mode, is_ue=0;
#endif
  protocol_ctxt_t      ctxt;
  // we need to add conditions to avoid transmitting data when the UE is not RRC connected.
#if defined(USER_MODE) && defined(OAI_EMU)
746

747
  if (oai_emulation.info.otg_enabled ==1 ) {
748 749 750 751 752 753 754 755 756
    // module_id is source id
    while ((otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[ctxt_pP->instance]))) != NULL) {
      LOG_I(OTG,"Mod_id %d Frame %d Got a packet (%p), HEAD of otg_pdcp_buffer[%d] is %p and Nb elements is %d\n",
            ctxt_pP->module_id,
            ctxt_pP->frame,
            otg_pkt_info,
            ctxt_pP->instance,
            pkt_list_get_head(&(otg_pdcp_buffer[ctxt_pP->instance])),
            otg_pdcp_buffer[ctxt_pP->instance].nb_elements);
757
      //otg_pkt_info = pkt_list_remove_head(&(otg_pdcp_buffer[module_id]));
758 759
      dst_id    = (otg_pkt_info->otg_pkt).dst_id; // type is module_id_t
      src_id    = (otg_pkt_info->otg_pkt).module_id; // type is module_id_t
760 761 762 763 764 765 766 767 768 769 770 771
      rb_id     = (otg_pkt_info->otg_pkt).rb_id;
      is_ue     = (otg_pkt_info->otg_pkt).is_ue;
      pdcp_mode = (otg_pkt_info->otg_pkt).mode;
      //    LOG_I(PDCP,"pdcp_fifo, pdcp mode is= %d\n",pdcp_mode);

      // generate traffic if the ue is rrc reconfigured state
      // if (mac_get_rrc_status(module_id, ctxt_pP->enb_flag, dst_id ) > 2 /*RRC_CONNECTED*/) { // not needed: this test is already done in update_otg_enb
      otg_pkt = (unsigned char*) (otg_pkt_info->otg_pkt).sdu_buffer;
      pkt_size = (otg_pkt_info->otg_pkt).sdu_buffer_size;

      if (otg_pkt != NULL) {
        if (is_ue == 0 ) {
772 773 774 775 776 777
          PROTOCOL_CTXT_SET_BY_MODULE_ID(
            &ctxt,
            src_id,
            ENB_FLAG_YES,
            oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id],
            ctxt_pP->frame,
778 779
            ctxt_pP->subframe,
	    src_id);
780

781
          LOG_D(OTG,"[eNB %d] Frame %d sending packet %d from module %d on rab id %d (src %d, dst %d/%x) pkt size %d for pdcp mode %d\n",
782 783 784 785 786 787 788
                ctxt.module_id,
                ctxt.frame,
                pkt_cnt_enb++,
                src_id,
                rb_id,
                src_id,
                dst_id,
789
		oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id],
790 791
                pkt_size,
                pdcp_mode);
792 793 794 795 796 797 798 799
          result = pdcp_data_req(&ctxt,
                                 SRB_FLAG_NO,
                                 rb_id,
                                 RLC_MUI_UNDEFINED,
                                 RLC_SDU_CONFIRM_NO,
                                 pkt_size,
                                 otg_pkt,
                                 pdcp_mode);
800 801 802
          if (result != TRUE) {
            LOG_W(OTG,"PDCP data request failed!\n");
          }
803 804 805 806
        } else {
          //rb_id= eNB_index * MAX_NUM_RB + DTCH;


807
          LOG_D(OTG,"[UE %d] Frame %d: sending packet %d from module %d on rab id %d (src %d/%x, dst %d) pkt size %d\n",
808 809 810 811 812
                ctxt_pP->module_id,
                ctxt_pP->frame,
                pkt_cnt_ue++,
                ctxt_pP->module_id,
                rb_id,
813 814
                src_id,
		pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id], // [src_id]
815 816 817 818
                dst_id,
                pkt_size);
          PROTOCOL_CTXT_SET_BY_MODULE_ID(
            &ctxt,
819
            ctxt_pP->module_id, //src_id,
820
            ENB_FLAG_NO,
821
            pdcp_UE_UE_module_id_to_rnti[ctxt_pP->module_id],// [src_id]
822
            ctxt_pP->frame,
823 824
            ctxt_pP->subframe,
	    dst_id);
825 826 827 828 829 830 831 832 833

          result = pdcp_data_req( &ctxt,
                                  SRB_FLAG_NO,
                                  rb_id,
                                  RLC_MUI_UNDEFINED,
                                  RLC_SDU_CONFIRM_NO,
                                  pkt_size,
                                  otg_pkt,
                                  PDCP_TRANSMISSION_MODE_DATA);
834 835 836
          if (result != TRUE) {
            LOG_W(OTG,"PDCP data request failed!\n");
          }
837 838 839 840
        }

        free(otg_pkt);
        otg_pkt = NULL;
841
      }
842 843 844 845

      // } //else LOG_D(OTG,"ctxt_pP->frame %d enb %d-> ue %d link not yet established state %d  \n", ctxt_pP->frame, eNB_index,dst_id - NB_eNB_INST, mac_get_rrc_status(module_id, ctxt_pP->enb_flag, dst_id - NB_eNB_INST));

    }
846
  }
847

848
#else
849

850
  if ((otg_enabled==1) && (ctxt_pP->enb_flag == ENB_FLAG_YES)) { // generate DL traffic
851 852 853 854 855
    unsigned int ctime=0;
    ctime = ctxt_pP->frame * 100;

    /*if  ((mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 0 ) > 2) &&
    (mac_get_rrc_status(eNB_index, ctxt_pP->enb_flag, 1 ) > 2)) { */
856 857 858 859 860 861
    PROTOCOL_CTXT_SET_BY_MODULE_ID(
      &ctxt,
      ctxt_pP->module_id,
      ctxt_pP->enb_flag,
      NOT_A_RNTI,
      ctxt_pP->frame,
862 863
      ctxt_pP->subframe,
      ctxt_pP->module_id);
864 865

    for (dst_id = 0; dst_id<NUMBER_OF_UE_MAX; dst_id++) {
866 867 868 869
      ctxt.rnti = oai_emulation.info.eNB_ue_module_id_to_rnti[ctxt.module_id][dst_id];

      if (ctxt.rnti != NOT_A_RNTI) {
        if (mac_eNB_get_rrc_status(ctxt.module_id, ctxt.rnti ) > 2 /*RRC_SI_RECEIVED*/) {
870
        unsigned int temp = 0;
871 872 873 874 875 876
          otg_pkt=packet_gen(
                    ENB_MODULE_ID_TO_INSTANCE(ctxt.module_id),
                    UE_MODULE_ID_TO_INSTANCE(dst_id),
                    0,
                    ctime,
                    &temp);
877 878 879 880 881 882 883 884 885 886 887 888
        pkt_size = temp;

        if (otg_pkt != NULL) {
          rb_id = dst_id * maxDRB + DTCH;
          pdcp_data_req(&ctxt,
                        SRB_FLAG_NO,
                        rb_id,
                        RLC_MUI_UNDEFINED,
                        RLC_SDU_CONFIRM_NO,
                        pkt_size,
                        otg_pkt,
                        PDCP_TRANSMISSION_MODE_DATA);
889 890 891 892 893
            LOG_I(OTG,
                  "send packet from module %d on rab id %d (src %d, dst %d) pkt size %d\n",
                  ctxt_pP->module_id, rb_id, ctxt_pP->module_id, dst_id, pkt_size);
            free(otg_pkt);
          }
894
        }
gauthier's avatar
gauthier committed
895
      }
896
    }
897
  }
898

899 900
#endif
}