Beispiel #1
0
static void
dev_ifa_notify(struct proto *p, unsigned c, struct ifa *ad)
{
  struct rt_dev_config *P = (void *) p->cf;

  if (!EMPTY_LIST(P->iface_list) &&
      !iface_patt_find(&P->iface_list, ad->iface, ad->iface->addr))
    /* Empty list is automagically treated as "*" */
    return;

  if (ad->flags & IA_SECONDARY)
    return;

  if (ad->scope <= SCOPE_LINK)
    return;

  if (c & IF_CHANGE_DOWN)
    {
      net *n;

      DBG("dev_if_notify: %s:%I going down\n", ad->iface->name, ad->ip);
      n = net_find(p->table, ad->prefix, ad->pxlen);
      if (!n)
	{
	  DBG("dev_if_notify: device shutdown: prefix not found\n");
	  return;
	}

      /* Use iface ID as local source ID */
      struct rte_src *src = rt_get_source(p, ad->iface->index);
      rte_update2(p->main_ahook, n, NULL, src);
    }
  else if (c & IF_CHANGE_UP)
    {
      rta *a;
      net *n;
      rte *e;

      DBG("dev_if_notify: %s:%I going up\n", ad->iface->name, ad->ip);

      /* Use iface ID as local source ID */
      struct rte_src *src = rt_get_source(p, ad->iface->index);

      rta a0 = {
	.src = src,
	.source = RTS_DEVICE,
	.scope = SCOPE_UNIVERSE,
	.cast = RTC_UNICAST,
	.dest = RTD_DEVICE,
	.iface = ad->iface
      };

      a = rta_lookup(&a0);
      n = net_get(p->table, ad->prefix, ad->pxlen);
      e = rte_get_temp(a);
      e->net = n;
      e->pflags = 0;
      rte_update2(p->main_ahook, n, e, src);
    }
}
Beispiel #2
0
void net_sim(char *debug_file_name) {
    struct net_t *net;
    double *inject_time; /* Next injection time (one per node) */

    /* Initialize */
    debug_init();
    esim_init();
    net_init();
    net_debug_category = debug_new_category(debug_file_name);

    /* Network to work with */
    if (!*net_sim_network_name) panic("%s: no network", __FUNCTION__);
    net = net_find(net_sim_network_name);
    if (!net) fatal("%s: network does not exist", net_sim_network_name);
    /* Initialize */
    inject_time = xcalloc(net->node_count, sizeof(double));

    /* FIXME: error for no dest node in network */

    /* Simulation loop */
    esim_process_events(TRUE);
    if (!strcmp(net_traffic_pattern, "") ||
            (!strcmp(net_traffic_pattern, "uniform"))) {
        net_traffic_uniform(net, inject_time);
    } else if (!strcmp(net_traffic_pattern, "command")) {
        while (1) {
            long long cycle;

            cycle = esim_domain_cycle(net_domain_index);
            if (cycle >= net_max_cycles) break;

            net_debug("___cycle %lld___ \n", cycle);
            esim_process_events(TRUE);
        }
    } else
        fatal("Network %s: unknown traffic pattern (%s). \n", net->name,
              net_traffic_pattern);

    /* Drain events */
    esim_process_all_events();

    /* Free */
    free(inject_time);

    /* Finalize */
    net_done();
    esim_done();
    debug_done();

    /* Finish program */
    mhandle_done();
    exit(0);
}
Beispiel #3
0
void net_sim(char *debug_file_name)
{
	struct net_t *net;
	double *inject_time;	/* Next injection time (one per node) */

	/* Initialize */
	debug_init();
	esim_init();
	net_init();
	net_debug_category = debug_new_category(debug_file_name);

	/* Network to work with */
	if (!*net_sim_network_name)
		panic("%s: no network", __FUNCTION__);
	net = net_find(net_sim_network_name);
	if (!net)
		fatal("%s: network does not exist", net_sim_network_name);
	/* Network Trace = Stand Alone */
        if (net_tracing())
        {
                /* Initialization of Trace */
                 net_trace_header("net.init version=\"%d.%d\"\n",
                                 NET_SYSTEM_TRACE_VERSION_MAJOR, NET_SYSTEM_TRACE_VERSION_MINOR);

                 /* Network Trace Header */
                 net_config_trace(net);
        }
	inject_time = xcalloc(net->node_count, sizeof(double));

	/* FIXME: error for no dest node in network */

	/* Simulation loop */
	esim_process_events(TRUE);
	if (!strcmp(net_traffic_pattern, "") ||
			(!strcmp(net_traffic_pattern, "uniform")))
	{
		net_traffic_uniform(net, inject_time);
	}
	else if (!strcmp(net_traffic_pattern, "command"))
	{
		while(1)
		{
			long long cycle;

			cycle = esim_domain_cycle(net_domain_index);
			if (cycle >= net_max_cycles)
				break;

			net_debug("___cycle %lld___ \n", cycle);
			esim_process_events(TRUE);
		}
	}
	else
		fatal("Network %s: unknown traffic pattern (%s). \n", net->name
				,net_traffic_pattern);


	/* Drain events */
	esim_process_all_events();

	/* Free */
	free(inject_time);

	/* Finalize */
	net_done();
	esim_done();
	trace_done();
	debug_done();
}