Exemplo n.º 1
0
static void
circuit_commence_level (struct isis_circuit *circuit, int level)
{
  if (level == 1)
    {
      if (! circuit->is_passive)
        THREAD_TIMER_ON (master, circuit->t_send_psnp[0], send_l1_psnp, circuit,
		         isis_jitter (circuit->psnp_interval[0], PSNP_JITTER));

      if (circuit->circ_type == CIRCUIT_T_BROADCAST)
	{
	  THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[0], isis_run_dr_l1,
			   circuit, 2 * circuit->hello_interval[0]);

	  THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[0],
			   send_lan_l1_hello, circuit,
			   isis_jitter (circuit->hello_interval[0],
					IIH_JITTER));

	  circuit->u.bc.lan_neighs[0] = list_new ();
	}
    }
  else
    {
      if (! circuit->is_passive)
        THREAD_TIMER_ON (master, circuit->t_send_psnp[1], send_l2_psnp, circuit,
		         isis_jitter (circuit->psnp_interval[1], PSNP_JITTER));

      if (circuit->circ_type == CIRCUIT_T_BROADCAST)
	{
	  THREAD_TIMER_ON (master, circuit->u.bc.t_run_dr[1], isis_run_dr_l2,
			   circuit, 2 * circuit->hello_interval[1]);

	  THREAD_TIMER_ON (master, circuit->u.bc.t_send_lan_hello[1],
			   send_lan_l2_hello, circuit,
			   isis_jitter (circuit->hello_interval[1],
					IIH_JITTER));

	  circuit->u.bc.lan_neighs[1] = list_new ();
	}
    }

  return;
}
Exemplo n.º 2
0
void isis_pdu_runner(u_char *user, const struct pcap_pkthdr *pkthdr, const u_char *buf)
{
  struct pcap_isis_callback_data *cb_data = (struct pcap_isis_callback_data *) user;
  struct pcap_device *device = cb_data->device;
  struct isis_circuit *circuit = cb_data->circuit;
  struct packet_ptrs pptrs;
  struct thread thread;
  int ret;

  struct stream stm;
  char *ssnpa;

  /* Let's export a time reference */
  memcpy(&isis_now, &pkthdr->ts, sizeof(struct timeval));

  /* check if we have to expire adjacency first */
  if (circuit && circuit->u.p2p.neighbor) {
    if (timeval_cmp(&isis_now, &circuit->u.p2p.neighbor->expire) >= 0)
      isis_adj_expire(circuit->u.p2p.neighbor);
  }

  memset(&pptrs, 0, sizeof(pptrs));
  memset(&stm, 0, sizeof(stm));

  if (buf) {
    pptrs.pkthdr = (struct pcap_pkthdr *) pkthdr;
    pptrs.packet_ptr = (u_char *) buf;

    (*device->data->handler)(pkthdr, &pptrs);
    if (pptrs.iph_ptr) {
      if ((*pptrs.l3_handler)(&pptrs)) {

	/*assembling handover to isis_handle_pdu() */
	stm.data = pptrs.iph_ptr;
	stm.getp = 0;
	stm.endp = pkthdr->caplen - (pptrs.iph_ptr - pptrs.packet_ptr);
	stm.size = pkthdr->caplen - (pptrs.iph_ptr - pptrs.packet_ptr);
	ssnpa = pptrs.packet_ptr;
	circuit->rcv_stream = &stm;
	circuit->interface->mtu = config.nfacctd_isis_mtu;

	/* process IS-IS packet */
	isis_handle_pdu (circuit, ssnpa);
      }
    }
  }

  /* check if it's time to run SPF */
  if (timeval_cmp(&isis_now, &isis_spf_deadline) >= 0) {
    if (circuit->area->is_type & IS_LEVEL_1) {
      if (circuit->area->ip_circuits) {
	ret = isis_run_spf(circuit->area, 1, AF_INET);
	isis_route_validate_table (circuit->area, circuit->area->route_table[0]);
      }
      /* XXX: IPv6 handled here */
    }

    if (circuit->area->is_type & IS_LEVEL_2) {
      if (circuit->area->ip_circuits) {
	ret = isis_run_spf(circuit->area, 2, AF_INET);
	isis_route_validate_table (circuit->area, circuit->area->route_table[1]);
      }
      /* XXX: IPv6 handled here */
    }

    isis_route_validate_merge (circuit->area, AF_INET);

    dyn_cache_cleanup();

    isis_spf_deadline.tv_sec = isis_now.tv_sec + isis_jitter(PERIODIC_SPF_INTERVAL, 10);
    isis_spf_deadline.tv_usec = 0;
  }

  if (timeval_cmp(&isis_now, &isis_psnp_deadline) >= 0) {
    send_psnp(1, circuit);
    send_psnp(2, circuit);

    isis_psnp_deadline.tv_sec = isis_now.tv_sec + isis_jitter(PSNP_INTERVAL, PSNP_JITTER);
    isis_psnp_deadline.tv_usec = 0;
  }
}