Beispiel #1
0
void CommonRender::create_modules()
{
// Create a module for every track, playable or not
	Track *current = renderengine->edl->tracks->first;
	int module = 0;

	if(!modules)
	{
		total_modules = get_total_tracks();
		modules = new Module*[total_modules];

		for(module = 0; module < total_modules && current; current = NEXT)
		{
			if(current->data_type == data_type)
			{
				modules[module] = new_module(current);
				modules[module]->create_objects();
				module++;
			}
		}
	}
	else
// Update changes in plugins for existing modules
	{
		for(module = 0; module < total_modules; module++)
		{
			modules[module]->create_objects();
		}
	}
}
Beispiel #2
0
  static t_res		init_module_list(void *data_list, void *data)
  {
    char		*filename;
    t_loadmod		*t;
    t_module		*mod;
    loadmod_call	create;

    filename = data_list;
    t = data;
#ifdef DEBUG
    printf("*** init module [%s]\n", filename);
#endif /* !DEBUG */
    if ((t->handle = dlopen(filename, RTLD_NOW)) == NULL)
      {
#ifdef DEBUG
	perror(dlerror());
#endif /* !DEBUG */
	return (R_CONTINUE);
      }
    if ((create = (loadmod_call)dlsym(t->handle, "call")) == NULL)
      {
	dlclose(t->handle);
	return (R_CONTINUE);
      }
    mod = new_module();
    create(mod);
    if (list_all(mod->comp_version_list, check_version) == R_FOUND)
      if (mod->load_fct != NULL && (*(mod->load_fct))() >= 0)
	{
	  list_push(&(t->module_list), (void*)mod);
	  return (R_CONTINUE);
	}
    free(mod);
    return (R_CONTINUE);
  }
Beispiel #3
0
shared_llb_module_t 
llb_context_t::new_module(
    const std::string & name,
    std::shared_ptr<uint8_t> source) {

    sources_.push_back(source);
    return new_module(name, (const char *)source.get());
}
Beispiel #4
0
  /* Creates the rubinius object universe from scratch. */
  void VM::bootstrap_ontology() {

    /*
     * Bootstrap everything so we can create fully initialized
     * Classes.
     */
    bootstrap_class();

    /*
     * Everything is now setup for us to make fully initialized
     * classes.
     */

    /*
     * Create our Rubinius module that we hang stuff off
     */

    initialize_fundamental_constants();

    bootstrap_symbol();
    initialize_builtin_classes();
    bootstrap_exceptions();

    /*
     * Create any 'stock' objects
     */

    Object* main = new_object<Object>(G(object));
    GO(main).set(main);
    G(object)->set_const(this, "MAIN", main); // HACK test hooking up MAIN

    Object* undef = new_object<Object>(G(object));
    GO(undefined).set(undef);

    GO(vm).set(new_class_under("VM", G(rubinius)));
    G(vm)->name(state, state->symbol("Rubinius::VM"));

    Module* type = new_module("Type", G(rubinius));
    type->name(state, state->symbol("Rubinius::Type"));

    System::bootstrap_methods(this);
    Module::bootstrap_methods(this);
    StaticScope::bootstrap_methods(this);
    VariableScope::bootstrap_methods(this);

    /*
     * Setup the table we use to store ivars for immediates
     */

    GO(external_ivars).set(LookupTable::create(this));

    initialize_platform_data();
  }
Beispiel #5
0
int main(int argc, char **argv) {

    unsigned int i;

    /* parse input arguments */
    get_options(argc, argv);
    /* initialize logger and signal analyzer */
    debug_init();
    /* */
    set_latency_target();
    /* make a graceful exit when ctrl-c is pressed */
    signal(SIGSEGV, signal_handler);
    signal(SIGINT, signal_handler);

    /* create modules based on input arguments */
    if (eNB_flag==1) {
        enb_array=(rrh_module_t*)malloc(num_eNB_mod*sizeof(rrh_module_t));
        for(i=0; i<num_eNB_mod; i++) {
            enb_array[i]=new_module(i);//enb_array[i]=new_module(i, get_RF_interfaces(&hardware_target));
            config_BBU_mod(&enb_array[i],RT_flag,NRT_flag);
            LOG_I(RRH,"[eNB %d] module(s) created (out of %u) \n",i,num_eNB_mod);
        }
    }
    if (UE_flag==1) {
        ue_array=(rrh_module_t*)malloc(num_UE_mod*sizeof(rrh_module_t));
        for(i=0; i<num_UE_mod; i++) {
            ue_array[i]=new_module(i);
            config_UE_mod(&ue_array[i],RT_flag,NRT_flag);
            LOG_I(RRH,"[UE %d] module(s) created (out of %u)\n",i, num_UE_mod);
        }
    }

    printf("TYPE <CTRL-C> TO TERMINATE\n");

    while (rrh_exit==0)
        sleep(1);

    return EXIT_SUCCESS;
}
Beispiel #6
0
Var* ff_load_dv_module(vfuncptr func, Var* args)
{
	int ac;
	Var** av;
	Var* v_return     = NULL;
	char* module_name = NULL;

	Alist alist[2]; /* arguments list */

	alist[0]      = make_alist("mod", ID_STRING, NULL, &module_name);
	alist[1].name = NULL;

	if (parse_args(func, args, alist) == 0) {
		parse_error("%s(): argument parsing failed.", func->name);
		return NULL;
	}

	if (module_name == NULL) {
		parse_error("%s(): \"%s\" must be specified.", func->name, alist[0].name);
		return NULL;
	}

	if (get_global_sym(module_name)) {
		parse_error(
		    "%s(): Variable %s already exists in global space. "
		    "Module load aborted.",
		    func->name, module_name);
		return NULL;
	}

	v_return = new_module(module_name);
	if (v_return) {
		/*
		** Actually load the module into the davinci variable
		** just created.
		*/
		if (!load_dv_module(module_name, NULL, 1, &V_MODULE(v_return))) {
			free_var(v_return);
			return NULL;
		}
		/* stick the symbol into the symbol table */
		/* sym_put(global_scope(), v_return); */
		put_global_sym(v_return);
		V_MODULE(v_return).stage = MOD_VAR_ADDED;
	}

	return v_return;
	/* return NULL; */
}
Beispiel #7
0
static int autoload_dv_module(char* name, const char* ver)
{
	Var* v_return;

	if (VERBOSE) {
		parse_error("autoloading %s ...", name);
	}

	/*
	** TODO:
	**
	** Create a davinci module variable. Pass that variable
	** into load_module() to actually load the module. Check
	** the error returned by load_module() if any. On error
	** collapse the module we were trying to load.
	*/

	if (get_global_sym(name)) {
		parse_error(
		    "Variable %s already exists in global space. "
		    "Module load aborted.",
		    name);
		return 0;
	}

	v_return = new_module(name);
	if (v_return) {
		/*
		** Actually load the module into the davinci variable
		** just created.
		*/
		if (!load_dv_module(V_NAME(v_return), NULL, 1, &V_MODULE(v_return))) {
			free_var(v_return);
			return 0;
		}

		/* stick the named module variable into the symbol table */
		/* sym_put(global_scope(), v_return); */
		put_global_sym(v_return);
		V_MODULE(v_return).stage = MOD_VAR_ADDED;
	}

	return 1;
}
Beispiel #8
0
 void VM::init_ffi() {
   Module* mod = new_module("FFI");
   mod->set_const(this, "TYPE_OBJECT",     Fixnum::from(RBX_FFI_TYPE_OBJECT));
   mod->set_const(this, "TYPE_CHAR",       Fixnum::from(RBX_FFI_TYPE_CHAR));
   mod->set_const(this, "TYPE_UCHAR",      Fixnum::from(RBX_FFI_TYPE_UCHAR));
   mod->set_const(this, "TYPE_SHORT",      Fixnum::from(RBX_FFI_TYPE_SHORT));
   mod->set_const(this, "TYPE_USHORT",     Fixnum::from(RBX_FFI_TYPE_USHORT));
   mod->set_const(this, "TYPE_INT",        Fixnum::from(RBX_FFI_TYPE_INT));
   mod->set_const(this, "TYPE_UINT",       Fixnum::from(RBX_FFI_TYPE_UINT));
   mod->set_const(this, "TYPE_LONG",       Fixnum::from(RBX_FFI_TYPE_LONG));
   mod->set_const(this, "TYPE_ULONG",      Fixnum::from(RBX_FFI_TYPE_ULONG));
   mod->set_const(this, "TYPE_LL",         Fixnum::from(RBX_FFI_TYPE_LONG_LONG));
   mod->set_const(this, "TYPE_ULL",        Fixnum::from(RBX_FFI_TYPE_ULONG_LONG));
   mod->set_const(this, "TYPE_FLOAT",      Fixnum::from(RBX_FFI_TYPE_FLOAT));
   mod->set_const(this, "TYPE_DOUBLE",     Fixnum::from(RBX_FFI_TYPE_DOUBLE));
   mod->set_const(this, "TYPE_PTR",        Fixnum::from(RBX_FFI_TYPE_PTR));
   mod->set_const(this, "TYPE_VOID",       Fixnum::from(RBX_FFI_TYPE_VOID));
   mod->set_const(this, "TYPE_STRING",     Fixnum::from(RBX_FFI_TYPE_STRING));
   mod->set_const(this, "TYPE_STATE",      Fixnum::from(RBX_FFI_TYPE_STATE));
   mod->set_const(this, "TYPE_STRPTR",     Fixnum::from(RBX_FFI_TYPE_STRPTR));
   mod->set_const(this, "TYPE_CHARARR",    Fixnum::from(RBX_FFI_TYPE_CHARARR));
 }
Beispiel #9
0
  void VM::bootstrap_exceptions() {
    Class *exc, *scp, *std, *arg, *nam, *loe, *rex, *stk, *sxp, *sce, *type, *lje, *vme;
    Class* rng;

#define dexc(name, sup) new_class(#name, sup)

    exc = G(exception);
    scp = dexc(ScriptError, exc);
    std = dexc(StandardError, exc);
    type = dexc(TypeError, std);
    arg = dexc(ArgumentError, std);
    nam = dexc(NameError, std);
    rex = dexc(RegexpError, std);
    dexc(NoMethodError, nam);
    dexc(SyntaxError, scp);
    loe = dexc(LoadError, scp);
    dexc(RuntimeError, std);
    sce = dexc(SystemCallError, std);
    stk = dexc(StackError, exc);
    sxp = dexc(StackExploded, stk);
    lje = dexc(LocalJumpError, std);
    rng = dexc(RangeError, std);
    dexc(FloatDomainError, rng);
    dexc(ZeroDivisionError, std);
    dexc(IOError, std);

    GO(jump_error).set(lje);

    GO(exc_vm_internal).set(new_class("Internal", exc, G(rubinius)));

    // Some special exceptions scoped under the Rubinius module
    vme = new_class("VMException", exc, G(rubinius));
    new_class("AssertionError", vme, G(rubinius));
    new_class("ObjectBoundsExceededError", vme, G(rubinius));

    // Create the stack error object now, since we probably wont be
    // able to later.
    GO(stack_error).set(new_object<Exception>(stk));

    GO(exc_type).set(type);
    GO(exc_arg).set(arg);
    GO(exc_loe).set(loe);
    GO(exc_rex).set(rex);

    GO(exc_stack_explosion).set(sxp);
    GO(exc_primitive_failure).set(dexc(PrimitiveFailure, exc));

    GO(exc_segfault).set(dexc(MemorySegmentionError, exc));

    Module* ern = new_module("Errno");

    GO(errno_mapping).set(LookupTable::create(state));

    ern->set_const(state, symbol("Mapping"), G(errno_mapping));

#define set_syserr(num, name) setup_errno(num, name, sce, ern)

    /*
     * Stolen from MRI
     */

#ifdef EPERM
    set_syserr(EPERM, "EPERM");
#endif
#ifdef ENOENT
    set_syserr(ENOENT, "ENOENT");
#endif
#ifdef ESRCH
    set_syserr(ESRCH, "ESRCH");
#endif
#ifdef EINTR
    set_syserr(EINTR, "EINTR");
#endif
#ifdef EIO
    set_syserr(EIO, "EIO");
#endif
#ifdef ENXIO
    set_syserr(ENXIO, "ENXIO");
#endif
#ifdef E2BIG
    set_syserr(E2BIG, "E2BIG");
#endif
#ifdef ENOEXEC
    set_syserr(ENOEXEC, "ENOEXEC");
#endif
#ifdef EBADF
    set_syserr(EBADF, "EBADF");
#endif
#ifdef ECHILD
    set_syserr(ECHILD, "ECHILD");
#endif
#ifdef EAGAIN
    set_syserr(EAGAIN, "EAGAIN");
#endif
#ifdef ENOMEM
    set_syserr(ENOMEM, "ENOMEM");
#endif
#ifdef EACCES
    set_syserr(EACCES, "EACCES");
#endif
#ifdef EFAULT
    set_syserr(EFAULT, "EFAULT");
#endif
#ifdef ENOTBLK
    set_syserr(ENOTBLK, "ENOTBLK");
#endif
#ifdef EBUSY
    set_syserr(EBUSY, "EBUSY");
#endif
#ifdef EEXIST
    set_syserr(EEXIST, "EEXIST");
#endif
#ifdef EXDEV
    set_syserr(EXDEV, "EXDEV");
#endif
#ifdef ENODEV
    set_syserr(ENODEV, "ENODEV");
#endif
#ifdef ENOTDIR
    set_syserr(ENOTDIR, "ENOTDIR");
#endif
#ifdef EISDIR
    set_syserr(EISDIR, "EISDIR");
#endif
#ifdef EINVAL
    set_syserr(EINVAL, "EINVAL");
#endif
#ifdef ENFILE
    set_syserr(ENFILE, "ENFILE");
#endif
#ifdef EMFILE
    set_syserr(EMFILE, "EMFILE");
#endif
#ifdef ENOTTY
    set_syserr(ENOTTY, "ENOTTY");
#endif
#ifdef ETXTBSY
    set_syserr(ETXTBSY, "ETXTBSY");
#endif
#ifdef EFBIG
    set_syserr(EFBIG, "EFBIG");
#endif
#ifdef ENOSPC
    set_syserr(ENOSPC, "ENOSPC");
#endif
#ifdef ESPIPE
    set_syserr(ESPIPE, "ESPIPE");
#endif
#ifdef EROFS
    set_syserr(EROFS, "EROFS");
#endif
#ifdef EMLINK
    set_syserr(EMLINK, "EMLINK");
#endif
#ifdef EPIPE
    set_syserr(EPIPE, "EPIPE");
#endif
#ifdef EDOM
    set_syserr(EDOM, "EDOM");
#endif
#ifdef ERANGE
    set_syserr(ERANGE, "ERANGE");
#endif
#ifdef EDEADLK
    set_syserr(EDEADLK, "EDEADLK");
#endif
#ifdef ENAMETOOLONG
    set_syserr(ENAMETOOLONG, "ENAMETOOLONG");
#endif
#ifdef ENOLCK
    set_syserr(ENOLCK, "ENOLCK");
#endif
#ifdef ENOSYS
    set_syserr(ENOSYS, "ENOSYS");
#endif
#ifdef ENOTEMPTY
    set_syserr(ENOTEMPTY, "ENOTEMPTY");
#endif
#ifdef ELOOP
    set_syserr(ELOOP, "ELOOP");
#endif
#ifdef EWOULDBLOCK
    set_syserr(EWOULDBLOCK, "EWOULDBLOCK");
#endif
#ifdef ENOMSG
    set_syserr(ENOMSG, "ENOMSG");
#endif
#ifdef EIDRM
    set_syserr(EIDRM, "EIDRM");
#endif
#ifdef ECHRNG
    set_syserr(ECHRNG, "ECHRNG");
#endif
#ifdef EL2NSYNC
    set_syserr(EL2NSYNC, "EL2NSYNC");
#endif
#ifdef EL3HLT
    set_syserr(EL3HLT, "EL3HLT");
#endif
#ifdef EL3RST
    set_syserr(EL3RST, "EL3RST");
#endif
#ifdef ELNRNG
    set_syserr(ELNRNG, "ELNRNG");
#endif
#ifdef EUNATCH
    set_syserr(EUNATCH, "EUNATCH");
#endif
#ifdef ENOCSI
    set_syserr(ENOCSI, "ENOCSI");
#endif
#ifdef EL2HLT
    set_syserr(EL2HLT, "EL2HLT");
#endif
#ifdef EBADE
    set_syserr(EBADE, "EBADE");
#endif
#ifdef EBADR
    set_syserr(EBADR, "EBADR");
#endif
#ifdef EXFULL
    set_syserr(EXFULL, "EXFULL");
#endif
#ifdef ENOANO
    set_syserr(ENOANO, "ENOANO");
#endif
#ifdef EBADRQC
    set_syserr(EBADRQC, "EBADRQC");
#endif
#ifdef EBADSLT
    set_syserr(EBADSLT, "EBADSLT");
#endif
#ifdef EDEADLOCK
    set_syserr(EDEADLOCK, "EDEADLOCK");
#endif
#ifdef EBFONT
    set_syserr(EBFONT, "EBFONT");
#endif
#ifdef ENOSTR
    set_syserr(ENOSTR, "ENOSTR");
#endif
#ifdef ENODATA
    set_syserr(ENODATA, "ENODATA");
#endif
#ifdef ETIME
    set_syserr(ETIME, "ETIME");
#endif
#ifdef ENOSR
    set_syserr(ENOSR, "ENOSR");
#endif
#ifdef ENONET
    set_syserr(ENONET, "ENONET");
#endif
#ifdef ENOPKG
    set_syserr(ENOPKG, "ENOPKG");
#endif
#ifdef EREMOTE
    set_syserr(EREMOTE, "EREMOTE");
#endif
#ifdef ENOLINK
    set_syserr(ENOLINK, "ENOLINK");
#endif
#ifdef EADV
    set_syserr(EADV, "EADV");
#endif
#ifdef ESRMNT
    set_syserr(ESRMNT, "ESRMNT");
#endif
#ifdef ECOMM
    set_syserr(ECOMM, "ECOMM");
#endif
#ifdef EPROTO
    set_syserr(EPROTO, "EPROTO");
#endif
#ifdef EMULTIHOP
    set_syserr(EMULTIHOP, "EMULTIHOP");
#endif
#ifdef EDOTDOT
    set_syserr(EDOTDOT, "EDOTDOT");
#endif
#ifdef EBADMSG
    set_syserr(EBADMSG, "EBADMSG");
#endif
#ifdef EOVERFLOW
    set_syserr(EOVERFLOW, "EOVERFLOW");
#endif
#ifdef ENOTUNIQ
    set_syserr(ENOTUNIQ, "ENOTUNIQ");
#endif
#ifdef EBADFD
    set_syserr(EBADFD, "EBADFD");
#endif
#ifdef EREMCHG
    set_syserr(EREMCHG, "EREMCHG");
#endif
#ifdef ELIBACC
    set_syserr(ELIBACC, "ELIBACC");
#endif
#ifdef ELIBBAD
    set_syserr(ELIBBAD, "ELIBBAD");
#endif
#ifdef ELIBSCN
    set_syserr(ELIBSCN, "ELIBSCN");
#endif
#ifdef ELIBMAX
    set_syserr(ELIBMAX, "ELIBMAX");
#endif
#ifdef ELIBEXEC
    set_syserr(ELIBEXEC, "ELIBEXEC");
#endif
#ifdef EILSEQ
    set_syserr(EILSEQ, "EILSEQ");
#endif
#ifdef ERESTART
    set_syserr(ERESTART, "ERESTART");
#endif
#ifdef ESTRPIPE
    set_syserr(ESTRPIPE, "ESTRPIPE");
#endif
#ifdef EUSERS
    set_syserr(EUSERS, "EUSERS");
#endif
#ifdef ENOTSOCK
    set_syserr(ENOTSOCK, "ENOTSOCK");
#endif
#ifdef EDESTADDRREQ
    set_syserr(EDESTADDRREQ, "EDESTADDRREQ");
#endif
#ifdef EMSGSIZE
    set_syserr(EMSGSIZE, "EMSGSIZE");
#endif
#ifdef EPROTOTYPE
    set_syserr(EPROTOTYPE, "EPROTOTYPE");
#endif
#ifdef ENOPROTOOPT
    set_syserr(ENOPROTOOPT, "ENOPROTOOPT");
#endif
#ifdef EPROTONOSUPPORT
    set_syserr(EPROTONOSUPPORT, "EPROTONOSUPPORT");
#endif
#ifdef ESOCKTNOSUPPORT
    set_syserr(ESOCKTNOSUPPORT, "ESOCKTNOSUPPORT");
#endif
#ifdef EOPNOTSUPP
    set_syserr(EOPNOTSUPP, "EOPNOTSUPP");
#endif
#ifdef EPFNOSUPPORT
    set_syserr(EPFNOSUPPORT, "EPFNOSUPPORT");
#endif
#ifdef EAFNOSUPPORT
    set_syserr(EAFNOSUPPORT, "EAFNOSUPPORT");
#endif
#ifdef EADDRINUSE
    set_syserr(EADDRINUSE, "EADDRINUSE");
#endif
#ifdef EADDRNOTAVAIL
    set_syserr(EADDRNOTAVAIL, "EADDRNOTAVAIL");
#endif
#ifdef ENETDOWN
    set_syserr(ENETDOWN, "ENETDOWN");
#endif
#ifdef ENETUNREACH
    set_syserr(ENETUNREACH, "ENETUNREACH");
#endif
#ifdef ENETRESET
    set_syserr(ENETRESET, "ENETRESET");
#endif
#ifdef ECONNABORTED
    set_syserr(ECONNABORTED, "ECONNABORTED");
#endif
#ifdef ECONNRESET
    set_syserr(ECONNRESET, "ECONNRESET");
#endif
#ifdef ENOBUFS
    set_syserr(ENOBUFS, "ENOBUFS");
#endif
#ifdef EISCONN
    set_syserr(EISCONN, "EISCONN");
#endif
#ifdef ENOTCONN
    set_syserr(ENOTCONN, "ENOTCONN");
#endif
#ifdef ESHUTDOWN
    set_syserr(ESHUTDOWN, "ESHUTDOWN");
#endif
#ifdef ETOOMANYREFS
    set_syserr(ETOOMANYREFS, "ETOOMANYREFS");
#endif
#ifdef ETIMEDOUT
    set_syserr(ETIMEDOUT, "ETIMEDOUT");
#endif
#ifdef ECONNREFUSED
    set_syserr(ECONNREFUSED, "ECONNREFUSED");
#endif
#ifdef EHOSTDOWN
    set_syserr(EHOSTDOWN, "EHOSTDOWN");
#endif
#ifdef EHOSTUNREACH
    set_syserr(EHOSTUNREACH, "EHOSTUNREACH");
#endif
#ifdef EALREADY
    set_syserr(EALREADY, "EALREADY");
#endif
#ifdef EINPROGRESS
    set_syserr(EINPROGRESS, "EINPROGRESS");
#endif
#ifdef ESTALE
    set_syserr(ESTALE, "ESTALE");
#endif
#ifdef EUCLEAN
    set_syserr(EUCLEAN, "EUCLEAN");
#endif
#ifdef ENOTNAM
    set_syserr(ENOTNAM, "ENOTNAM");
#endif
#ifdef ENAVAIL
    set_syserr(ENAVAIL, "ENAVAIL");
#endif
#ifdef EISNAM
    set_syserr(EISNAM, "EISNAM");
#endif
#ifdef EREMOTEIO
    set_syserr(EREMOTEIO, "EREMOTEIO");
#endif
#ifdef EDQUOT
    set_syserr(EDQUOT, "EDQUOT");
#endif

  }
Beispiel #10
0
/*
 * -- do_config
 *
 * Apply the configuration on the map. It expects each useful line to 
 * start with a known keyword. Note the unconventional return values. 
 * It returns NULL if successful or an error string in case of error.
 *
 */
static char * 
do_config(struct _como * m, int argc, char *argv[])
{
    static char errstr[1024]; 
    static int scope = CTX_GLOBAL;      	/* scope of current keyword */
    static module_t * mdl = NULL;       	/* module currently open */
    static int node_id = 0; 			/* current node */
    static alias_t * alias = NULL;       	/* alias currently open */
    keyword_t *t;

    /*
     * run some checks on the token (i.e., that it exists
     * and that we have all the arguments it needs).
     */
    t = match_token(argv[0], keywords);
    if (t == NULL) {
	sprintf(errstr, "unknown token \"%s\"\n", argv[0]);
        return errstr;
    }

    if (argc < t->nargs) {
	sprintf(errstr, "\"%s\", requires at least %d arguments\n", argv[0],
	      t->nargs);
        return errstr;
    }

    /*
     * Check if the keyword is ok in the current scope.
     */
    if (!(t->scope & scope)) {
	sprintf(errstr, "\"%s\" out of scope\n", argv[0]);
        return errstr;
    }

    /*
     * configuration actions
     */
    switch (t->action) {
    case TOK_DBDIR:
	if (m->cli_args.dbdir_set == 0) {
	    safe_dup(&m->dbdir, argv[1]);
	}
	break;

    case TOK_QUERYPORT:
	if (m->cli_args.query_port_set == 0 || node_id > 0) {
	    m->node[node_id].query_port = atoi(argv[1]);
	}
	break;

    case TOK_DESCRIPTION:
	if (scope == CTX_MODULE) 
	    safe_dup(&mdl->description, argv[1]);
	else 
	    safe_dup(&alias->description, argv[1]);
	break;

    case TOK_END:
	if (scope == CTX_MODULE) { 
	    /*
	     * "end" of a module configuration.  run some checks depending 
	     * on context to make sure that all mandatory fields are there
	     * and set default values
	     */

	    if (check_module(m, mdl)) { 
		remove_module(m, mdl); 
		scope = CTX_GLOBAL;
		break;
	    }

	    if (m->runmode == RUNMODE_INLINE) 
		m->inline_mdl = mdl;

	    logmsg(LOGUI, "... module%s %s [%d][%d] ", 
		   (mdl->running == RUNNING_ON_DEMAND) ? " on-demand" : "",
		   mdl->name, mdl->node, mdl->priority); 
	    logmsg(LOGUI, " filter %s; out %s (%uMB)\n", 
		   mdl->filter_str, mdl->output, mdl->streamsize/(1024*1024));
        } else if (scope == CTX_VIRTUAL) { 
	    /* 
	     * we are done with this virtual node. let's go back to 
	     * the master node (i.e. node_id == 0)
	     */
	    node_id = 0; 
	}
	scope = CTX_GLOBAL; 
	break;
	    
    case TOK_FILTER:
	if (scope == CTX_MODULE) 
            safe_dup(&mdl->filter_str, argv[1]);
        else if (scope == CTX_VIRTUAL) 
	    safe_dup(&m->node[node_id].filter_str, argv[1]);
	break;

    case TOK_HASHSIZE:
        mdl->ex_hashsize = mdl->ca_hashsize = atoi(argv[1]);
        break;

    case TOK_SOURCE:
	if (scope == CTX_MODULE) { 
	    safe_dup(&mdl->source, argv[1]);
	} else { 
	    safe_dup(&m->node[node_id].source, argv[1]);
	} 
	break;

    case TOK_LIBRARYDIR:
	if (m->cli_args.libdir_set == 0) {
	    safe_dup(&m->libdir, argv[1]);
	}
	break;

    case TOK_LOGFLAGS:
	if (m->cli_args.logflags_set == 0) {
	    m->logflags = set_flags(0, argv[1]);
	}
	break;

    case TOK_MEMSIZE:
	/* this keyword can be used in two contexts */
	if (m->cli_args.mem_size_set == 0) {
	    m->mem_size = atoi(argv[1]);
	}
	break;

    case TOK_MODULE:
	if (scope == CTX_GLOBAL) {
	    int node = (m->runmode == RUNMODE_INLINE? -1 : 0);
	    mdl = new_module(m, argv[1], node, -1);
	    scope = CTX_MODULE; 		/* change scope */
	} else { 
	    safe_dup(&alias->module, argv[1]);
	} 
        break;
        
    case TOK_MODULE_MAX:
	m->module_max = atoi(argv[1]);
	m->modules = safe_realloc(m->modules, sizeof(module_t)*m->module_max); 
        break;

    case TOK_OUTPUT:
        safe_dup(&mdl->output, argv[1]);
	break;

    case TOK_SNIFFER:
	add_sniffer(m, argv[1], argv[2], argc > 3 ? argv[3] : NULL);
        break;

    case TOK_STREAMSIZE: 
	mdl->streamsize = parse_size(argv[1]);
	break;

    case TOK_MAXFILESIZE: 
	m->maxfilesize = parse_size(argv[1]); 
	if (m->maxfilesize > 1024*1024*1024) { 
	    m->maxfilesize = DEFAULT_FILESIZE; 
	    sprintf(errstr, "'filesize' should be < 1GB --> set to %dMB\n", 
		    (int)(m->maxfilesize / (1024*1024)));
	    return errstr; 
	} 
	break;

    case TOK_ARGS: 
	/* copy the arguments. one line may have multiple arguments 
 	 * starting from argv[1]. that's why we pass the pointer to 
	 * argv[1] and reduce argc by one. 
	 */
	if (scope == CTX_MODULE) 
	    mdl->args = copy_args(mdl->args, &argv[1], argc - 1); 
	else if (scope == CTX_VIRTUAL) 
	    m->node[node_id].args = copy_args(m->node->args, &argv[1], argc-1); 
        else if (scope == CTX_ALIAS) {
	    alias->args = copy_args(alias->args, &argv[1], argc - 1); 
	    alias->ac += argc - 1; 
	} 
	break;

    case TOK_ARGSFILE: 
	if (scope == CTX_MODULE) {
	    mdl->args = copy_args_from_file(mdl->args, argv[1], NULL); 
	} else if (scope == CTX_VIRTUAL) {
	    m->node[node_id].args = 
		copy_args_from_file(m->node[node_id].args, argv[1], NULL); 
        } else if (scope == CTX_ALIAS) {
	    int count; 
	    alias->args = copy_args_from_file(alias->args, argv[1], &count); 
	    alias->ac += count; 
	} 
	break; 
    
    case TOK_PRIORITY: 
        mdl->priority = atoi(argv[1]);
	break; 

    case TOK_RUNNING: 
        mdl->running = (strcmp(argv[1], "on-demand") == 0) ?
		       RUNNING_ON_DEMAND : RUNNING_NORMAL;
	break; 

    case TOK_NAME: 
        safe_dup(&m->node[node_id].name, argv[1]);
	break; 

    case TOK_LOCATION:
        safe_dup(&m->node[node_id].location, argv[1]);
	break; 

    case TOK_TYPE:
        safe_dup(&m->node[node_id].type, argv[1]);
	break; 

    case TOK_COMMENT: 
        safe_dup(&m->node[node_id].comment, argv[1]);
	break; 

    case TOK_VIRTUAL: 
	m->node = safe_realloc(m->node, (m->node_count + 1) * sizeof(node_t)); 
	node_id = m->node_count; 
	bzero(&m->node[node_id], sizeof(node_t)); 
	safe_dup(&m->node[node_id].name, argv[1]);
	m->node[node_id].location = strdup("Unknown");
	m->node[node_id].type = strdup("Unknown");
	m->node_count++;
	scope = CTX_VIRTUAL; 
	break;

    case TOK_ALIAS: 
	alias = safe_calloc(1, sizeof(alias_t)); 
	safe_dup(&alias->name, argv[1]);
	alias->next = m->aliases;
	m->aliases = alias; 
	scope = CTX_ALIAS; 
	break;

    case TOK_ASNFILE:
	safe_dup(&m->asnfile, argv[1]);
	break;

    case TOK_LIVE_THRESH:
	m->live_thresh = TIME2TS(0, atoi(argv[1]));
	break;

    default:
	sprintf(errstr, "unknown keyword %s\n", argv[0]);
	return errstr; 
    }

    return NULL;
}
Beispiel #11
0
int parse_config(char* config_file) {
  FILE* f = fopen(config_file, "r");
  if (!f) {
    fprintf(stderr, "Error '%s' while opening '%s'\n", strerror(errno), config_file);
    return 1;
  }
  char line_buffer[BUFSIZ];
  config = malloc(sizeof(struct config));
  bzero(config, sizeof(struct config));
  struct listener* listener = NULL;
  struct module* module = NULL;
  unsigned int line_count = 0;
  while (fgets(line_buffer, sizeof(line_buffer), f)) {
    line_count++;
    if (strlen(line_buffer) <= 1 || line_buffer[0] == '#')
      continue;
    char key[BUFSIZ];
    char value[BUFSIZ];
    if (sscanf(line_buffer, "%[a-z_] = %[^\t\n]", key, value) == 2) {
      if (config->disconnect_after_bytes == 0 && strcmp(key, "disconnect_after_bytes") == 0) {
        errno = 0;
        unsigned short tmp = strtol(value, NULL, 10);
        if (errno == 0)
          config->disconnect_after_bytes = tmp;
      } else if (!config->dateformat && strcmp(key, "dateformat") == 0)
        config->dateformat = strdup(value);
      else if (strcmp(key, "listener") == 0) {
        listener = new_listener(value);
        module = NULL;
        if (listener) {
          if (!config->listeners)
            config->listeners = listener;
          else {
            struct listener* l = config->listeners;
            while (l->next)
              l = l->next;
            l->next = listener;
          }
        }
      } else if (listener && strcmp(key, "module") == 0) {
        module = new_module(value);
        if (module) {
          if (!listener->modules)
            listener->modules = module;
          else {
            struct module* m = listener->modules;
            while (m->next)
              m = m->next;
            m->next = module;
          }
        }
      } else if (listener && module && !module->address && strcmp(key, "address") == 0) {
        char address[129];
        uint16_t port;
        if (sscanf(value, "%128[^:]:%hd", address, &port) == 2) {
          module->address = strdup(address);
          module->port = port;
        }
      } else if (listener && module && !module->logfile && strcmp(key, "logfile") == 0) {
        if (strcmp(value, "stderr") == 0)
          module->logfile = STDERR;
        else if (strcmp(value, "stdout") == 0)
          module->logfile = STDOUT;
        else if (strcmp(value, "syslog") == 0)
          module->logfile = SYSLOG;
        else {
          FILE* f = fopen(value, "a");
          if (f) {
            module->logfile = strdup(value);
            fclose(f);
          } else
            fprintf(stderr, "ERROR: %s\n", strerror(errno));
        }
      } else if (listener && module && !module->logformat && strcmp(key, "logformat") == 0)
        module->logformat = strdup(value);
    } else {
      fprintf(stderr, "Error on line %ud\tCould not be parsed correctly.\n", line_count);
      return 1;
    }
  };
  return 0;
};
Beispiel #12
0
static void test_symtab( void )
{
	Symbol *sym;
	SymbolHash *symtab, *symtab2;
	
	list_open("test.lst");
	opts.symtable = TRUE;
	opts.list     = TRUE;
	
	warn("Create current module\n");	
	set_cur_module( new_module() );

	warn("Create symbol\n");	
	sym = Symbol_create(S("Var1"), 123, TYPE_CONSTANT, 0, NULL, NULL);
	dump_Symbol(sym);
	OBJ_DELETE(sym);

	sym = Symbol_create(S("Var1"), 123, TYPE_CONSTANT, 0, CURRENTMODULE, NULL);
	dump_Symbol(sym);
	CURRENTMODULE->modname = "MODULE";
	dump_Symbol(sym);
	
	warn("Delete symbol\n");	
	OBJ_DELETE(sym);
	
	warn("Global symtab\n");	
	dump_SymbolHash(global_symtab, "global");
	dump_SymbolHash(static_symtab, "static");
	
	warn("check case insensitive - CH_0024\n");
	symtab = OBJ_NEW(SymbolHash);
	assert( symtab );
	_define_sym(S("Var1"), 1, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr();
	_define_sym(S("var1"), 2, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr(); 
	_define_sym(S("VAR1"), 3, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr();
	dump_SymbolHash(symtab, "tab1");
	
	assert( find_symbol(S("Var1"), symtab)->value == 1 );
	assert( find_symbol(S("var1"), symtab)->value == 2 );
	assert( find_symbol(S("VAR1"), symtab)->value == 3 );

	dump_SymbolHash(symtab, "tab1");
	
	warn("Concat symbol tables\n");	
	symtab = OBJ_NEW(SymbolHash);
	assert( symtab );
	_define_sym(S("Var1"),  1, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr();
	_define_sym(S("Var2"),  2, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr(); 
	_define_sym(S("Var3"), -3, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr();
	dump_SymbolHash(symtab, "tab1");
	
	symtab2 = OBJ_NEW(SymbolHash);
	assert( symtab2 );
	_define_sym(S("Var3"), 3, TYPE_CONSTANT, 0, NULL, NULL, &symtab2); inc_page_nr();
	_define_sym(S("Var4"), 4, TYPE_CONSTANT, 0, NULL, NULL, &symtab2); inc_page_nr();
	_define_sym(S("Var5"), 5, TYPE_CONSTANT, 0, NULL, NULL, &symtab2); inc_page_nr();
	dump_SymbolHash(symtab2, "tab2");
	
	SymbolHash_cat( &symtab, symtab2 );
	dump_SymbolHash(symtab, "merged_tab");
	
	OBJ_DELETE( symtab );
	OBJ_DELETE( symtab2 );
	
	warn("Sort\n");	
	symtab = OBJ_NEW(SymbolHash);
	assert( symtab );
	_define_sym(S("One"), 	1, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr();
	_define_sym(S("Two"),	2, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr(); 
	_define_sym(S("Three"),	3, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr();
	_define_sym(S("Four"),	4, TYPE_CONSTANT, 0, NULL, NULL, &symtab); inc_page_nr();
	dump_SymbolHash(symtab, "tab");
	
	SymbolHash_sort(symtab, SymbolHash_by_name);
	dump_SymbolHash(symtab, "tab by name");

	SymbolHash_sort(symtab, SymbolHash_by_value);
	dump_SymbolHash(symtab, "tab by value");

	OBJ_DELETE( symtab );

	warn("Use local symbol before definition\n");
	_define_sym(S("WIN32"), 1, TYPE_CONSTANT, 0, NULL, NULL, &static_symtab); inc_page_nr();
	SymbolHash_cat( & CURRENTMODULE->local_symtab, static_symtab ); inc_page_nr();
	_define_sym(S("PC"), 0, TYPE_CONSTANT, 0, NULL, NULL, &global_symtab); inc_page_nr();
	find_symbol( S("PC"), global_symtab )->value += 3; inc_page_nr();
	find_symbol( S("PC"), global_symtab )->value += 3; inc_page_nr();
	sym = get_used_symbol(S("NN")); inc_page_nr();
	assert( sym != NULL );
	assert( ! sym->is_defined );
	find_symbol( S("PC"), global_symtab )->value += 3; inc_page_nr();
	sym = get_used_symbol(S("NN")); inc_page_nr();
	assert( sym != NULL );
	assert( ! sym->is_defined );
	find_symbol( S("PC"), global_symtab )->value += 3; inc_page_nr();
	sym = define_symbol(S("NN"), find_symbol( "PC", global_symtab )->value, TYPE_ADDRESS); 
	sym->is_touched = TRUE;
	sym = get_used_symbol(S("NN")); inc_page_nr();
	assert( sym != NULL );
	dump_Symbol(sym);
	assert( sym->is_defined );
	
	dump_symtab();

	warn("Delete Local\n");	
	remove_all_local_syms();
	dump_symtab();
	
	warn("Delete Static\n");	
	remove_all_static_syms();
	dump_symtab();
	
	warn("Delete Global\n");	
	remove_all_global_syms();
	dump_symtab();
	
	warn("End\n");	

}
Beispiel #13
0
/*
 * -- do_config
 *
 * Apply the configuration on the map. It expects each useful line to 
 * start with a known keyword. Note the unconventional return values. 
 * It returns NULL if successful or an error string in case of error.
 *
 */
static char * 
do_config(struct _como * m, int argc, char *argv[])
{
    static char errstr[1024]; 
    static int scope = CTX_GLOBAL;      	/* scope of current keyword */
    static module_t * mdl = NULL;       	/* module currently open */
    keyword_t *t;

    /*
     * run some checks on the token (i.e., that it exists
     * and that we have all the arguments it needs).
     */
    t = match_token(argv[0], keywords);
    if (t == NULL) {
	sprintf(errstr, "unknown token \"%s\"\n", argv[0]);
        return errstr;
    }

    if (argc < t->nargs) {
	sprintf(errstr, "\"%s\", requires at least %d arguments\n", argv[0],
	      t->nargs);
        return errstr;
    }

    /*
     * Check if the keyword is ok in the current scope.
     */
    if (!(t->scope & scope)) {
	sprintf(errstr, "\"%s\" out of scope\n", argv[0]);
        return errstr;
    }

    /*
     * configuration actions
     */
    switch (t->action) {
    case TOK_BASEDIR:
	safe_dup(&m->basedir, argv[1]);
	break;

    case TOK_QUERYPORT:
	m->node->query_port = atoi(argv[1]);
	break;

    case TOK_DESCRIPTION:
	safe_dup(&mdl->description, argv[1]);
	break;

    case TOK_END:
	if (scope == CTX_MODULE) { 
	    /*
	     * "end" of a module configuration.  run some checks depending 
	     * on context to make sure that all mandatory fields are there
	     * and set default values
	     */

	    if (check_module(m, mdl)) { 
		remove_module(m, mdl); 
		scope = CTX_GLOBAL;
		break;
	    }

	    if (m->running == INLINE) 
		m->inline_mdl = mdl;

	    logmsg(LOGUI, "... module%s %s [%d][%d] ", 
		   (mdl->running == RUNNING_ON_DEMAND) ? " on-demand" : "",
		   mdl->name, mdl->node, mdl->priority); 
	    logmsg(LOGUI, " filter %s; out %s (%uMB)\n", 
		   mdl->filter_str, mdl->output, mdl->streamsize/(1024*1024));
	    if (mdl->description != NULL) 
		logmsg(LOGUI, "    -- %s\n", mdl->description); 
	    scope = CTX_GLOBAL;
        } else if (scope == CTX_VIRTUAL) { 
	    /* 
	     * we are done with this virtual node. let's recover
	     * the master node (associated with the global context)
	     */
	    node_t *p, *q;

	    for (p = m->node, q = NULL; p->id != 0; q = p, p = p->next)
		; 

	    if (q) {
		/* the master node is not at the head of the list. 
		 * move it there. 
		 */
		q->next = p->next; 
		p->next = m->node; 
		m->node = p;
	    } 
	    scope = CTX_GLOBAL; 
	}
	break;
	    
    case TOK_FILTER:
	if (scope == CTX_MODULE) 
            safe_dup(&mdl->filter_str, argv[1]);
        else if (scope == CTX_VIRTUAL) 
	    safe_dup(&m->node->filter_str, argv[1]);
	break;

    case TOK_HASHSIZE:
        mdl->ex_hashsize = mdl->ca_hashsize = atoi(argv[1]);
        break;

    case TOK_SOURCE:
	safe_dup(&mdl->source, argv[1]);
	break;

    case TOK_LIBRARYDIR:
        safe_dup(&m->libdir, argv[1]);
        break;

    case TOK_LOGFLAGS:
        m->logflags = set_flags(0, argv[1]);
        break;

    case TOK_MEMSIZE:
        /* this keyword can be used in two contexts */
	m->mem_size = atoi(argv[1]);
	if (m->mem_size <= 0 || m->mem_size > 512) {
	    sprintf(errstr, 
		    "invalid memory size %d, range is 1..512\n", 
		    m->mem_size);
	    return errstr; 
	} 
        break;

    case TOK_MODULE:
	mdl = new_module(m, argv[1], (m->running == INLINE? -1 : 0), -1);
        scope = CTX_MODULE; 		/* change scope */
        break;
        
    case TOK_MODULE_MAX:
	m->module_max = atoi(argv[1]);
	m->modules = safe_realloc(m->modules, sizeof(module_t)*m->module_max); 
        break;

    case TOK_OUTPUT:
        safe_dup(&mdl->output, argv[1]);
	break;

    case TOK_SNIFFER:
	add_sniffer(m, argv[1], argv[2], argc > 3 ? argv[3] : NULL);
        break;

    case TOK_STREAMSIZE: 
	mdl->streamsize = parse_size(argv[1]);
	break;

    case TOK_MAXFILESIZE: 
	m->maxfilesize = parse_size(argv[1]); 
	if (m->maxfilesize > 1024*1024*1024) { 
	    m->maxfilesize = DEFAULT_FILESIZE; 
	    sprintf(errstr, "'filesize' should be < 1GB --> set to %dMB\n", 
		   m->maxfilesize / (1024*1024));
	    return errstr; 
	} 
	break;

    case TOK_ARGS:
	do { 
	    int i,j;

	    if (mdl->args == NULL) {
		mdl->args = safe_calloc(argc, sizeof(char *));
		j = 0; 
	    } else { 
		/* 
		 * we need to add the current list of optional arguments 
		 * to the list we already have. first, count how many we 
		 * have got so far and then reallocate memory accordingly 
		 */
		for (j = 0; mdl->args[j]; j++) 
		    ; 
		mdl->args = safe_realloc(mdl->args, (argc + j) * sizeof(char*));
	    } 

	    for (i = 1; i < argc; i++) 
		mdl->args[i+j-1] = safe_strdup(argv[i]);

	    /* 
	     * Last position is set to null to be able to know
	     * when args finish from the modules
	     */
	    mdl->args[i+j-1] = NULL;
	} while (0); 
	break;

    case TOK_ARGSFILE: 
	do { 
	    FILE *auxfp;
	    char line[512];
	    int j;

	    /* open the file */
	    auxfp = fopen(argv[1], "r"); 
	    if (auxfp == NULL) { 
		sprintf(errstr, "opening file %s: %s\n", argv[1], 
			strerror(errno)); 
		return errstr; 
	    } 

	    /* count the number of arguments we already have */
	    for (j = 0; mdl->args[j]; j++) 
		; 

	    /* read each line in the file and parse it again */ 
	    /* XXX we reallocate mdl->args for each line in the file. 
	     *     this should be done better in a less expensive way. 
	     */
	    while (fgets(line, sizeof(line), auxfp)) {
		j++;
		mdl->args = safe_realloc(mdl->args, j * sizeof(char *));
		mdl->args[j - 1] = safe_strdup(line);
	    }

	    /* add the last NULL pointer */
	    mdl->args = safe_realloc(mdl->args, (j + 1) * sizeof(char *));
	    mdl->args[j] = NULL; 

	    fclose(auxfp);
	} while (0);
	break;
    
    case TOK_PRIORITY: 
        mdl->priority = atoi(argv[1]);
	break; 

    case TOK_RUNNING: 
        mdl->running = (strcmp(argv[1], "on-demand") == 0) ?
		       RUNNING_ON_DEMAND : RUNNING_NORMAL;
	break; 

    case TOK_NAME: 
        safe_dup(&m->node->name, argv[1]);
	break; 

    case TOK_LOCATION:
        safe_dup(&m->node->location, argv[1]);
	break; 

    case TOK_TYPE:
        safe_dup(&m->node->type, argv[1]);
	break; 

    case TOK_COMMENT: 
        safe_dup(&m->node->comment, argv[1]);
	break; 

    case TOK_VIRTUAL: 
	do { 
	    node_t * node; 
	    node = safe_calloc(1, sizeof(struct _node)); 
	    node->id = m->node_count; 
	    safe_dup(&node->name, argv[1]);
	    node->next = m->node;
	    m->node = node; 
	    m->node_count++;
	    scope = CTX_VIRTUAL; 
	} while (0);
	break;

    default:
	sprintf(errstr, "unknown keyword %s\n", argv[0]);
	return errstr; 
    }

    return NULL;
}
Beispiel #14
0
int main(int argc, char **argv) {

  unsigned int i;
  
  /* parse input arguments */
  get_options(argc, argv);
  /* initialize logger and signal analyzer */
  debug_init();
  /* */
  set_latency_target();
  /*make a graceful exit when ctrl-c is pressed */
  signal(SIGSEGV, signal_handler);
  signal(SIGINT, signal_handler);
  /*probe RF front end devices interfaced to RRH */
  // get_RFinterfaces();
  

#ifdef ETHERNET 
 int 			error_code_timer;
  pthread_t 		main_timer_proc_thread;

  LOG_I(RRH,"Creating timer thread with rt period  %d ns.\n",rt_period);
 
  /* setup the timer to generate an interrupt:
     -for the first time in (sample_per_packet/sample_rate) ns
     -and then every (sample_per_packet/sample_rate) ns */
  timerspec.it_value.tv_sec =     rt_period/1000000000;
  timerspec.it_value.tv_nsec =    rt_period%1000000000;
  timerspec.it_interval.tv_sec =  rt_period/1000000000;
  timerspec.it_interval.tv_nsec = rt_period%1000000000;
  

  //#ifndef LOWLATENCY
  pthread_attr_t 	attr_timer;
  struct sched_param 	sched_param_timer;
  
  pthread_attr_init(&attr_timer);
  sched_param_timer.sched_priority = sched_get_priority_max(SCHED_FIFO);
  pthread_attr_setschedparam(&attr_timer,&sched_param_timer);
  pthread_attr_setschedpolicy(&attr_timer,SCHED_FIFO);
   
  pthread_mutex_init(&timer_mutex,NULL);

  error_code_timer = pthread_create(&main_timer_proc_thread, &attr_timer, timer_proc, (void *)&timerspec);
  LOG_I(RRH,"[SCHED] FIFO scheduling applied to timer thread \n");		
  /*#else 
  error_code_timer = pthread_create(&main_timer_proc_thread, NULL, timer_proc, (void *)&timerspec);
  LOG_I(RRH,"[SCHED] deadline scheduling applied to timer thread \n");		
  #endif*/	
  
  if (error_code_timer) {
    LOG_E(RRH,"Error while creating timer proc thread\n");
    exit(-1);
  }
#endif

  /* create modules based on input arguments */
  if (eNB_flag==1){    
    enb_array=(rrh_module_t*)malloc(num_eNB_mod*sizeof(rrh_module_t));	
    for(i=0;i<num_eNB_mod;i++){  
      enb_array[i]=new_module(i);//enb_array[i]=new_module(i, get_RF_interfaces(&hardware_target));	
      create_eNB_trx_threads(&enb_array[i],RT_flag,NRT_flag);
      LOG_I(RRH,"[eNB %d] module(s) created (out of %u) \n",i,num_eNB_mod);		
    }
  }
  if (UE_flag==1){    
    ue_array=(rrh_module_t*)malloc(num_UE_mod*sizeof(rrh_module_t));	
    for(i=0;i<num_UE_mod;i++){
      ue_array[i]=new_module(i);
      create_UE_trx_threads(&ue_array[i],RT_flag,NRT_flag);			
      LOG_I(RRH,"[UE %d] module(s) created (out of %u)\n",i, num_UE_mod);
    }
  }
 
  printf("TYPE <CTRL-C> TO TERMINATE\n");
  
  while (rrh_exit==0)
    sleep(1);

  //close sockets 
  
  return EXIT_SUCCESS;
}