Example #1
0
/* Make new area structure */
struct ospf6_area *
ospf6_area_create (u_int32_t area_id)
{
  struct ospf6_area *o6a;

  /* allocate memory */
  o6a = (struct ospf6_area *) XMALLOC (MTYPE_OSPF6_AREA,
                                       sizeof (struct ospf6_area));
  if (!o6a)
    {
      char str[16];
      inet_ntop (AF_INET, &area_id, str, sizeof (str));
      zlog_err ("can't allocate memory for Area %s", str);
      return NULL;
    }

  /* initialize */
  memset (o6a, 0, sizeof (struct ospf6_area));
  inet_ntop (AF_INET, &area_id, o6a->str, sizeof (o6a->str));
  o6a->area_id = area_id;
  o6a->if_list = list_new ();

#if 0
  o6a->lsdb = list_new ();
#endif
  o6a->lsdb = ospf6_lsdb_create ();

  o6a->spf_tree = ospf6_spftree_create ();
  o6a->table_topology = route_table_init ();

  /* xxx, set options */
  OSPF6_OPT_SET (o6a->options, OSPF6_OPT_V6);
  OSPF6_OPT_SET (o6a->options, OSPF6_OPT_E);
  OSPF6_OPT_SET (o6a->options, OSPF6_OPT_R);

  o6a->foreach_if = ospf6_area_foreach_interface;
  o6a->foreach_nei = ospf6_area_foreach_neighbor;

  return o6a;
}
/* Make new area structure */
struct ospf6_area *
ospf6_area_create (u_int32_t area_id)
{
  struct ospf6_area *o6a;
  char namebuf[64];

  /* allocate memory */
  o6a = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area));

  /* initialize */
  inet_ntop (AF_INET, &area_id, o6a->str, sizeof (o6a->str));
  o6a->area_id = area_id;
  o6a->if_list = list_new ();

  o6a->lsdb = ospf6_lsdb_create ();
  o6a->spf_tree = ospf6_spftree_create ();

  snprintf (namebuf, sizeof (namebuf), "Area %s's route table", o6a->str);
  o6a->route_table = ospf6_route_table_create (namebuf);
  o6a->route_table->hook_add = ospf6_area_route_add;
  o6a->route_table->hook_change = ospf6_area_route_add;
  o6a->route_table->hook_remove = ospf6_area_route_remove;

  snprintf (namebuf, sizeof (namebuf), "Area %s's topology table", o6a->str);
  o6a->table_topology = ospf6_route_table_create (namebuf);
  o6a->table_topology->hook_add = ospf6_intra_topology_add;
  o6a->table_topology->hook_change = ospf6_intra_topology_add;
  o6a->table_topology->hook_remove = ospf6_intra_topology_remove;

  /* xxx, set options */
  OSPF6_OPT_SET (o6a->options, OSPF6_OPT_V6);
  OSPF6_OPT_SET (o6a->options, OSPF6_OPT_E);
  OSPF6_OPT_SET (o6a->options, OSPF6_OPT_R);

  o6a->foreach_if = ospf6_area_foreach_interface;
  o6a->foreach_nei = ospf6_area_foreach_neighbor;

  return o6a;
}