コード例 #1
0
int nas_init(mme_config_t *mme_config_p)
{
  NAS_DEBUG("Initializing NAS task interface\n");

#if !defined(DISABLE_USE_NAS)
  nas_log_init(0x3F);
  nas_network_initialize(mme_config_p);
#endif

  if (itti_create_task(TASK_NAS_MME, &nas_intertask_interface,
                       NULL) < 0) {
    NAS_ERROR("Create task failed");
    NAS_DEBUG("Initializing NAS task interface: FAILED\n");
    return -1;
  }

  NAS_DEBUG("Initializing NAS task interface: DONE\n");
  return 0;
}
コード例 #2
0
/*
 * -----------------------------------------------------------------------------
 *				RRC simulator main process
 * -----------------------------------------------------------------------------
 */
int main (int argc, const char* argv[])
{
    /*
     * Get the command line options
     */
    if ( as_simulator_parser_get_options(argc, argv) != RETURNok )
    {
	as_simulator_parser_print_usage();
	exit(EXIT_FAILURE);
    }
    const char* uhost = as_simulator_parser_get_uhost();
    const char* uport = as_simulator_parser_get_uport();
    const char* mhost = as_simulator_parser_get_mhost();
    const char* mport = as_simulator_parser_get_mport();

    nas_log_init(0x2f);

    /*
     * Initialize the communication channel to the UE NAS process
     */
    _as_simulator_ue_sid = socket_udp_open(SOCKET_SERVER, uhost, uport);
    if (_as_simulator_ue_sid == NULL) {
	const char* error = ( (errno < 0) ?
			      gai_strerror(errno) : strerror(errno) );
	printf("ERROR\t: socket_udp_open() failed: %s\n", error);
	exit(EXIT_FAILURE);
    }
    printf("INFO\t: %s - The RRC Simulator is now connected to %s/%s (%d)\n",
	   __FUNCTION__, uhost, uport, socket_get_fd(_as_simulator_ue_sid));

    /*
     * Initialize the communication channel to the MME NAS process
     */
    _as_simulator_mme_sid = socket_udp_open(SOCKET_CLIENT, mhost, mport);
    if (_as_simulator_mme_sid == NULL) {
	const char* error = ( (errno < 0) ?
			      gai_strerror(errno) : strerror(errno) );
	printf("ERROR\t: socket_udp_open() failed: %s\n", error);
	socket_close(_as_simulator_ue_sid);
	exit(EXIT_FAILURE);
    }
    printf("INFO\t: %s - The RRC Simulator is now connected to %s/%s (%d)\n",
	   __FUNCTION__, mhost, mport, socket_get_fd(_as_simulator_mme_sid));

    MSCGEN("[MSC_NEW][%s][AS=%s]\n", getTime(), _as_id);

    /*
     * Set up signal handler
     */
   (void) _set_signal_handler(SIGINT, _signal_handler);
   (void) _set_signal_handler(SIGTERM, _signal_handler);

    pthread_attr_t attr;
    pthread_attr_init(&attr);
    pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM);
    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);

    /*
     * Start thread use to manage the connection endpoint with the
     * UE NAS process
     */
    pthread_t ue_mngr;
    if ( pthread_create (&ue_mngr, &attr, _as_simulator_ue_mngr, NULL) != 0 )
    {
        perror("ERROR\t: Failed to create the UE management thread\n");
	socket_close(_as_simulator_ue_sid);
	socket_close(_as_simulator_mme_sid);
	exit(EXIT_FAILURE);	
    }

    /*
     * Start thread use to manage the connection endpoint with the
     * MME NAS process
     */
    pthread_t mme_mngr;
    if ( pthread_create (&mme_mngr, &attr, _as_simulator_mme_mngr, NULL) != 0 )
    {
        perror("ERROR\t: Failed to create the MME management thread\n");
	socket_close(_as_simulator_ue_sid);
	socket_close(_as_simulator_mme_sid);
	exit(EXIT_FAILURE);	
    }
    pthread_attr_destroy(&attr);

    /*
     * Suspend execution of the main process until connection
     * managers are running
     */
    poll(NULL, 0, SLEEP_TIMEOUT);
    while (_as_simulator_ue_is_running && _as_simulator_mme_is_running)
    {
	poll(NULL, 0, SLEEP_TIMEOUT);
    }

    /*
     * Termination cleanup
     */
    printf("INFO\t: %s - Closing UE's connection endpoint %d\n",
	   __FUNCTION__, socket_get_fd(_as_simulator_ue_sid));
    socket_close(_as_simulator_ue_sid);
    printf("INFO\t: %s - Closing MME's connection endpoint %d\n",
	   __FUNCTION__, socket_get_fd(_as_simulator_mme_sid));
    socket_close(_as_simulator_mme_sid);

    printf("INFO\t: %s - RRC simulator exited\n", __FUNCTION__);
    exit(EXIT_SUCCESS);
}