Exemplo n.º 1
0
int lfds611_ringbuffer_new( struct lfds611_ringbuffer_state **rs, lfds611_atom_t number_elements, int (*user_data_init_function)(void **user_data, void *user_state), void *user_state )
{
  int
    rv = 0;

  assert( rs != NULL );
  // TRD : number_elements can be any value in its range
  // TRD : user_data_init_function can be NULL
  // TRD : user_state can be NULL

  *rs = (struct lfds611_ringbuffer_state *) lfds611_liblfds_aligned_malloc( sizeof(struct lfds611_ringbuffer_state), LFDS611_ALIGN_DOUBLE_POINTER );

  if( *rs != NULL )
  {
    lfds611_freelist_new( &(*rs)->fs, number_elements, user_data_init_function, user_state );

    if( (*rs)->fs != NULL )
    {
      lfds611_queue_new( &(*rs)->qs, number_elements );

      if( (*rs)->qs != NULL )
        rv = 1;

      if( (*rs)->qs == NULL )
      {
        lfds611_liblfds_aligned_free( *rs );
        *rs = NULL;
      }
    }

    if( (*rs)->fs == NULL )
    {
      lfds611_liblfds_aligned_free( *rs );
      *rs = NULL;
    }
  }

  LFDS611_BARRIER_STORE;

  return( rv );
}
Exemplo n.º 2
0
lkfqCrQueue(
        lkfq_tc_t* pQ,
        U16        nBlockSize,
        U32        nQueue,
        U16        nChunkBlock,
        U16        nPages,
        BOOL       bLock)
{
    tresult_t  _result;

    CCURASSERT(pQ);

    do
    {
        _result = lfds611_queue_new(
                        &(pQ->tQAlloc.pRbQs), nQueue);
        if(!_result )
        {
            _result = ENOMEM;
            break;
        }
        _result = lfds611_queue_new(
                        &(pQ->tQFree.pRbQs), nQueue);
        if(!_result )
        {
            _result = ENOMEM;
            break;
        }
        if(bLock)
            pQ->bLock = TRUE;
        _result = pthread_mutex_init (
                &(pQ->tQAlloc.tLock), NULL);
        if(ESUCCESS != _result)
        {
            _result = EFAILURE;
            break;
        }
        _result = pthread_mutex_init (
                &(pQ->tQFree.tLock), NULL);
        if(ESUCCESS != _result)
        {
            _result = EFAILURE;
            break;
        }

        pQ->pMp =
            cp_mempool_create_by_option(CP_SHARED_MEMPOOL_TYPE_1, nBlockSize, 100);
        if(NULL == pQ->pMp)
        {
            _result = ENOMEM;
            pQ->pMp = NULL;
            break;
        }
        _result = ESUCCESS;
    }while(FALSE);

    if(ESUCCESS != _result)
    {
        lkfqDestQueue(pQ);
    }
    return _result;
}
Exemplo n.º 3
0
//-----------------------------------------------------------------------------
int
pdcp_netlink_init(
    void
)
//-----------------------------------------------------------------------------
{

    int                i;
    int                nb_inst_enb;
    int                nb_inst_ue;
    pthread_attr_t     attr;
    struct sched_param sched_param;

    reset_meas(&ip_pdcp_stats_tmp);
#if defined(USER_MODE) && defined(OAI_EMU)
    nb_inst_enb = oai_emulation.info.nb_enb_local;
    nb_inst_ue  = oai_emulation.info.nb_ue_local;
#else
    nb_inst_enb = 1;
    nb_inst_ue  = 1;
#endif

#if defined(LINK_ENB_PDCP_TO_GTPV1U)
    nb_inst_enb = 0;
    LOG_I(PDCP, "[NETLINK] Creating 0 queues for eNB Netlink -> PDCP communication\n");
#else
#warning " LG: When there will be handover in, there will problems because dim is based on local nums of ues"
    pdcp_netlink_queue_enb      = calloc(nb_inst_enb, sizeof(struct lfds611_queue_state*));
    pdcp_netlink_nb_element_enb = malloc(nb_inst_enb * sizeof(uint32_t));
    LOG_I(PDCP, "[NETLINK] Creating %d queues for eNB Netlink -> PDCP communication\n", nb_inst_enb);

    for (i = 0; i < nb_inst_enb; i++) {
        pdcp_netlink_nb_element_enb[i] = 0;

        if (lfds611_queue_new(&pdcp_netlink_queue_enb[i], PDCP_QUEUE_NB_ELEMENTS) < 0) {
            LOG_E(PDCP, "Failed to create new FIFO for eNB Netlink -> PDCP communcation instance %d\n", i);
            exit(EXIT_FAILURE);
        }
    }

#endif

    if (nb_inst_ue  > 0) {
        pdcp_netlink_queue_ue       = calloc(nb_inst_ue, sizeof(struct lfds611_queue_state*));
        pdcp_netlink_nb_element_ue  = malloc(nb_inst_ue * sizeof(uint32_t));

        LOG_I(PDCP, "[NETLINK] Creating %d queues for UE Netlink -> PDCP communication\n", nb_inst_ue);

        for (i = 0; i < nb_inst_ue; i++) {
            pdcp_netlink_nb_element_ue[i] = 0;

            if (lfds611_queue_new(&pdcp_netlink_queue_ue[i], PDCP_QUEUE_NB_ELEMENTS) < 0) {
                LOG_E(PDCP, "Failed to create new FIFO for UE Netlink -> PDCP communcation instance %d\n", i);
                exit(EXIT_FAILURE);
            }
        }
    }

    if ((nb_inst_ue + nb_inst_enb) > 0) {
        if (pthread_attr_init(&attr) != 0) {
            LOG_E(PDCP, "[NETLINK]Failed to initialize pthread attribute for Netlink -> PDCP communication (%d:%s)\n",
                  errno, strerror(errno));
            exit(EXIT_FAILURE);
        }

        sched_param.sched_priority = 10;

        pthread_attr_setschedpolicy(&attr, SCHED_RR);
        pthread_attr_setschedparam(&attr, &sched_param);

        /* Create one thread that fetchs packets from the netlink.
         * When the netlink fifo is full, packets are silently dropped, this behaviour
         * should be avoided if we want a reliable link.
         */
        if (pthread_create(&pdcp_netlink_thread, &attr, pdcp_netlink_thread_fct, NULL) != 0) {
            LOG_E(PDCP, "[NETLINK]Failed to create new thread for Netlink/PDCP communication (%d:%s)\n",
                  errno, strerror(errno));
            exit(EXIT_FAILURE);
        }

        pthread_setname_np( pdcp_netlink_thread, "PDCP netlink" );
    }

    return 0;
}
Exemplo n.º 4
0
void queue_test_enqueuing_and_dequeuing( void )
{
  unsigned int
    loop,
    subloop,
    cpu_count;

  thread_state_t
    *thread_handles;

  struct lfds611_queue_state
    *qs;

  struct queue_test_enqueuing_and_dequeuing_state
    *qteds;

  struct lfds611_validation_info
    vi = { 0, 0 };

  enum lfds611_data_structure_validity
    dvs[2];

  internal_display_test_name( "Enqueuing and dequeuing (10 seconds)" );

  cpu_count = abstraction_cpu_count();

  lfds611_queue_new( &qs, cpu_count );

  qteds = malloc( sizeof(struct queue_test_enqueuing_and_dequeuing_state) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
  {
    (qteds+loop)->qs = qs;
    (qteds+loop)->thread_number = loop;
    (qteds+loop)->counter = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8);
    (qteds+loop)->cpu_count = cpu_count;
    (qteds+loop)->error_flag = LOWERED;
    (qteds+loop)->per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count );

    for( subloop = 0 ; subloop < cpu_count ; subloop++ )
      *((qteds+loop)->per_thread_counters+subloop) = 0;
  }

  thread_handles = malloc( sizeof(thread_state_t) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_enqueuer_and_dequeuer, qteds+loop );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_wait( thread_handles[loop] );

  free( thread_handles );

  lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, (void *) &vi, (void *) dvs );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    if( (qteds+loop)->error_flag == RAISED )
      dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA;

  for( loop = 0 ; loop < cpu_count ; loop++ )
    free( (qteds+loop)->per_thread_counters );

  free( qteds );

  lfds611_queue_delete( qs, NULL, NULL );

  internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] );

  return;
}
Exemplo n.º 5
0
void queue_test_rapid_enqueuing_and_dequeuing( void )
{
  unsigned int
    loop,
    cpu_count;

  thread_state_t
    *thread_handles;

  struct lfds611_queue_state
    *qs;

  struct queue_test_rapid_enqueuing_and_dequeuing_state
    *qtreds;

  struct lfds611_validation_info
    vi = { 50000, 50000 };

  lfds611_atom_t
    user_data,
    thread,
    count,
    *per_thread_counters;

  enum lfds611_data_structure_validity
    dvs[2];

  internal_display_test_name( "Rapid enqueuing and dequeuing (10 seconds)" );

  cpu_count = abstraction_cpu_count();

  lfds611_queue_new( &qs, 100000 );

  for( loop = 0 ; loop < 50000 ; loop++ )
    lfds611_queue_enqueue( qs, NULL );

  qtreds = malloc( sizeof(struct queue_test_rapid_enqueuing_and_dequeuing_state) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
  {
    (qtreds+loop)->qs = qs;
    (qtreds+loop)->counter = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8);
  }

  thread_handles = malloc( sizeof(thread_state_t) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_rapid_enqueuer_and_dequeuer, qtreds+loop );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_wait( thread_handles[loop] );

  free( thread_handles );

  lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, (void *) &vi, (void *) dvs );

  // TRD : now check results
  per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    *(per_thread_counters+loop) = 0;

  while( dvs[0] == LFDS611_VALIDITY_VALID and dvs[1] == LFDS611_VALIDITY_VALID and lfds611_queue_dequeue(qs, (void *) &user_data) )
  {
    thread = user_data >> (sizeof(lfds611_atom_t)*8-8);
    count = (user_data << 8) >> 8;

    if( thread >= cpu_count )
    {
      dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA;
      break;
    }

    if( per_thread_counters[thread] == 0 )
      per_thread_counters[thread] = count;

    if( count < per_thread_counters[thread] )
      dvs[0] = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS;

    if( count >= per_thread_counters[thread] )
      per_thread_counters[thread] = count+1;
  }

  free( per_thread_counters );

  free( qtreds );

  lfds611_queue_delete( qs, NULL, NULL );

  internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] );

  return;
}
Exemplo n.º 6
0
void queue_test_enqueuing( void )
{
  unsigned int
    loop,
    cpu_count;

  thread_state_t
    *thread_handles;

  struct lfds611_queue_state
    *qs;

  struct queue_test_enqueuing_state
    *qtes;

  lfds611_atom_t
    user_data,
    thread,
    count,
    *per_thread_counters;

  struct lfds611_validation_info
    vi = { 1000000, 1000000 };

  enum lfds611_data_structure_validity
    dvs[2];

  /* TRD : create an empty queue with 1,000,000 elements in its freelist
           then run one thread per CPU
           where each thread busy-works, enqueuing elements (until there are no more elements)
           each element's void pointer of user data is (thread number | element number)
           where element_number is a thread-local counter starting at 0
           where the thread_number occupies the top byte

           when we're done, we check that all the elements are present
           and increment on a per-thread basis
  */

  internal_display_test_name( "Enqueuing" );

  cpu_count = abstraction_cpu_count();

  lfds611_queue_new( &qs, 1000000 );

  qtes = malloc( sizeof(struct queue_test_enqueuing_state) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
  {
    (qtes+loop)->qs = qs;
    (qtes+loop)->counter = (lfds611_atom_t) loop << (sizeof(lfds611_atom_t)*8-8);
  }

  thread_handles = malloc( sizeof(thread_state_t) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_simple_enqueuer, qtes+loop );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_wait( thread_handles[loop] );

  free( thread_handles );

  free( qtes );

  /* TRD : first, validate the queue

           then dequeue
           we expect to find element numbers increment on a per thread basis
  */

  lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, &vi, dvs );

  per_thread_counters = malloc( sizeof(lfds611_atom_t) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    *(per_thread_counters+loop) = 0;

  while( dvs[0] == LFDS611_VALIDITY_VALID and dvs[1] == LFDS611_VALIDITY_VALID and lfds611_queue_dequeue(qs, (void *) &user_data) )
  {
    thread = user_data >> (sizeof(lfds611_atom_t)*8-8);
    count = (user_data << 8) >> 8;

    if( thread >= cpu_count )
    {
      dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA;
      break;
    }

    if( count < per_thread_counters[thread] )
      dvs[0] = LFDS611_VALIDITY_INVALID_ADDITIONAL_ELEMENTS;

    if( count > per_thread_counters[thread] )
      dvs[0] = LFDS611_VALIDITY_INVALID_MISSING_ELEMENTS;

    if( count == per_thread_counters[thread] )
      per_thread_counters[thread]++;
  }

  free( per_thread_counters );

  lfds611_queue_delete( qs, NULL, NULL );

  internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] );

  return;
}
Exemplo n.º 7
0
void queue_test_dequeuing( void )
{
  unsigned int
    loop,
    cpu_count;

  thread_state_t
    *thread_handles;

  struct lfds611_queue_state
    *qs;

  struct queue_test_dequeuing_state
    *qtds;

  struct lfds611_validation_info
    vi = { 0, 0 };

  enum lfds611_data_structure_validity
    dvs[2];

  /* TRD : create a queue with 1,000,000 elements

           use a single thread to enqueue every element
           each elements user data is an incrementing counter

           then run one thread per CPU
           where each busy-works dequeuing

           when an element is dequeued, we check (on a per-thread basis) the
           value deqeued is greater than the element previously dequeued
  */

  internal_display_test_name( "Dequeuing" );

  cpu_count = abstraction_cpu_count();

  lfds611_queue_new( &qs, 1000000 );

  for( loop = 0 ; loop < 1000000 ; loop++ )
    lfds611_queue_enqueue( qs, (void *) (lfds611_atom_t) loop );

  qtds = malloc( sizeof(struct queue_test_dequeuing_state) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
  {
    (qtds+loop)->qs = qs;
    (qtds+loop)->error_flag = LOWERED;
  }

  thread_handles = malloc( sizeof(thread_state_t) * cpu_count );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_start( &thread_handles[loop], loop, queue_test_internal_thread_simple_dequeuer, qtds+loop );

  for( loop = 0 ; loop < cpu_count ; loop++ )
    abstraction_thread_wait( thread_handles[loop] );

  free( thread_handles );

  // TRD : check queue is empty
  lfds611_queue_query( qs, LFDS611_QUEUE_QUERY_VALIDATE, (void *) &vi, (void *) dvs );

  // TRD : check for raised error flags
  for( loop = 0 ; loop < cpu_count ; loop++ )
    if( (qtds+loop)->error_flag == RAISED )
      dvs[0] = LFDS611_VALIDITY_INVALID_TEST_DATA;

  free( qtds );

  lfds611_queue_delete( qs, NULL, NULL );

  internal_display_test_result( 2, "queue", dvs[0], "queue freelist", dvs[1] );

  return;
}
Exemplo n.º 8
0
SFTCPNetwork::SFTCPNetwork(void)
{
	lfds611_queue_new(&m_pQueue, 1000);
}
Exemplo n.º 9
0
P2PManager::P2PManager(void)
{	
	lfds611_queue_new(&m_pQueue, 1000);
}
Exemplo n.º 10
0
//------------------------------------------------------------------------------
int
msc_init (
  const msc_env_t envP,
  const int max_threadsP)
//------------------------------------------------------------------------------
{
  int                                     i;
  int                                     rv;
  void                                   *pointer_p;
  char                                    msc_filename[256];

  fprintf (stderr, "Initializing MSC logs\n");
  rv = snprintf (msc_filename, 256, "/tmp/openair.msc.%u.log", envP);   // TODO NAME

  if ((0 >= rv) || (256 < rv)) {
    fprintf (stderr, "Error in MSC log file name");
  }

  g_msc_fd = fopen (msc_filename, "w");
  AssertFatal (g_msc_fd != NULL, "Could not open MSC log file %s : %s", msc_filename, strerror (errno));
  rv = lfds611_stack_new (&g_msc_memory_stack_p, (lfds611_atom_t) max_threadsP + 2);

  if (0 >= rv) {
    AssertFatal (0, "lfds611_stack_new failed!\n");
  }

  rv = lfds611_queue_new (&g_msc_message_queue_p, (lfds611_atom_t) MSC_MAX_QUEUE_ELEMENTS);
  AssertFatal (rv, "lfds611_queue_new failed!\n");
  AssertFatal (g_msc_message_queue_p != NULL, "g_msc_message_queue_p is NULL!\n");
  msc_start_use ();

  for (i = 0; i < max_threadsP * 30; i++) {
    pointer_p = malloc (MSC_MAX_MESSAGE_LENGTH);
    AssertFatal (pointer_p, "malloc failed!\n");
    rv = lfds611_stack_guaranteed_push (g_msc_memory_stack_p, pointer_p);
    AssertFatal (rv, "lfds611_stack_guaranteed_push failed for item %u\n", i);
  }

  for (i = MIN_MSC_PROTOS; i < MAX_MSC_PROTOS; i++) {
    switch (i) {
    case MSC_NAS_UE:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_UE");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      break;


    case MSC_S1AP_ENB:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S1AP_ENB");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_GTPU_ENB:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "GTPU_ENB");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      break;

    case MSC_GTPU_SGW:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "GTPU_SGW");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if (envP == MSC_MME_GW)  {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_S1AP_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S1AP_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_MMEAPP_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "MME_APP");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_NAS_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      msc_log_declare_proto (i);
      break;

    case MSC_NAS_EMM_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_EMM");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_NAS_ESM_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "NAS_ESM");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_SP_GWAPP_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "SP_GW_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if (envP == MSC_MME_GW) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_S11_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S11_MME");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if (envP == MSC_MME) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_S6A_MME:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "S6A");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    case MSC_HSS:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "HSS");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }

      if ((envP == MSC_MME_GW) || (envP == MSC_MME)) {
        msc_log_declare_proto (i);
      }

      break;

    default:
      rv = snprintf (&g_msc_proto2str[i][0], MSC_MAX_PROTO_NAME_LENGTH, "UNKNOWN");

      if (rv >= MSC_MAX_PROTO_NAME_LENGTH) {
        g_msc_proto2str[i][MSC_MAX_PROTO_NAME_LENGTH - 1] = 0;
      }
    }
  }

  rv = itti_create_task (TASK_MSC, msc_task, NULL);
  AssertFatal (rv == 0, "Create task for MSC failed!\n");
  fprintf (stderr, "Initializing MSC logs Done\n");
  return 0;
}