Ejemplo n.º 1
0
Archivo: lsalib.c Proyecto: bootc/bird
int
lsa_flooding_allowed(u32 type, u32 domain, struct ospf_iface *ifa)
{
  /* Handle inactive vlinks */
  if (ifa->state == OSPF_IS_DOWN)
    return 0;

  /* 4.5.2 (Case 2) */
  switch (LSA_SCOPE(type))
  {
  case LSA_SCOPE_LINK:
    return ifa->iface_id == domain;

  case LSA_SCOPE_AREA:
    return ifa->oa->areaid == domain;

  case LSA_SCOPE_AS:
    if (ifa->type == OSPF_IT_VLINK)
      return 0;
    if (!oa_is_ext(ifa->oa))
      return 0;
    return 1;

  default:
    log(L_ERR "OSPF: LSA with invalid scope");
    return 0;
  }
}
Ejemplo n.º 2
0
Archivo: dbdes.c Proyecto: ColinBS/bird
static int
ospf_process_dbdes(struct ospf_proto *p, struct ospf_packet *pkt, struct ospf_neighbor *n)
{
  struct ospf_iface *ifa = n->ifa;
  struct ospf_lsa_header *lsas, lsa;
  struct top_hash_entry *en, *req;
  const char *err_dsc = NULL;
  u32 lsa_type, lsa_domain;
  uint i, lsa_count;

  ospf_dbdes_body(p, pkt, &lsas, &lsa_count);

  for (i = 0; i < lsa_count; i++)
  {
    lsa_ntoh_hdr(lsas + i, &lsa);
    lsa_get_type_domain(&lsa, ifa, &lsa_type, &lsa_domain);

    /* RFC 2328 10.6 and RFC 5340 4.2.2 */

    if (!lsa_type)
      DROP1("LSA of unknown type");

    if (!oa_is_ext(ifa->oa) && (LSA_SCOPE(lsa_type) == LSA_SCOPE_AS))
      DROP1("LSA with AS scope in stub area");

    /* Errata 3746 to RFC 2328 - rt-summary-LSAs forbidden in stub areas */
    if (!oa_is_ext(ifa->oa) && (lsa_type == LSA_T_SUM_RT))
      DROP1("rt-summary-LSA in stub area");

    /* Not explicitly mentioned in RFC 5340 4.2.2 but makes sense */
    if (LSA_SCOPE(lsa_type) == LSA_SCOPE_RES)
      DROP1("LSA with invalid scope");

    en = ospf_hash_find(p->gr, lsa_domain, lsa.id, lsa.rt, lsa_type);
    if (!en || (lsa_comp(&lsa, &(en->lsa)) == CMP_NEWER))
    {
      /* This should be splitted to ospf_lsa_lsrq_up() */
      req = ospf_hash_get(n->lsrqh, lsa_domain, lsa.id, lsa.rt, lsa_type);

      if (!SNODE_VALID(req))
	s_add_tail(&n->lsrql, SNODE req);

      if (!SNODE_VALID(n->lsrqi))
	n->lsrqi = req;

      req->lsa = lsa;
      req->lsa_body = LSA_BODY_DUMMY;

      if (!tm_active(n->lsrq_timer))
	tm_start(n->lsrq_timer, 0);
    }
  }

  return 0;

drop:
  LOG_LSA1("Bad LSA (Type: %04x, Id: %R, Rt: %R) in DBDES", lsa_type, lsa.id, lsa.rt);
  LOG_LSA2("  received from nbr %R on %s - %s", n->rid, ifa->ifname, err_dsc);

  ospf_neigh_sm(n, INM_SEQMIS);
  return -1;
}