/* Make new area structure */ struct ospf6_area * ospf6_area_create (u_int32_t area_id, struct ospf6 *o) { struct ospf6_area *oa; struct ospf6_route *route; oa = XCALLOC (MTYPE_OSPF6_AREA, sizeof (struct ospf6_area)); inet_ntop (AF_INET, &area_id, oa->name, sizeof (oa->name)); oa->area_id = area_id; oa->if_list = list_new (); oa->lsdb = ospf6_lsdb_create (oa); oa->lsdb->hook_add = ospf6_area_lsdb_hook_add; oa->lsdb->hook_remove = ospf6_area_lsdb_hook_remove; oa->lsdb_self = ospf6_lsdb_create (oa); oa->spf_table = OSPF6_ROUTE_TABLE_CREATE (AREA, SPF_RESULTS); oa->spf_table->scope = oa; oa->route_table = OSPF6_ROUTE_TABLE_CREATE (AREA, ROUTES); oa->route_table->scope = oa; oa->route_table->hook_add = ospf6_area_route_hook_add; oa->route_table->hook_remove = ospf6_area_route_hook_remove; oa->range_table = OSPF6_ROUTE_TABLE_CREATE (AREA, PREFIX_RANGES); oa->range_table->scope = oa; oa->summary_prefix = OSPF6_ROUTE_TABLE_CREATE (AREA, SUMMARY_PREFIXES); oa->summary_prefix->scope = oa; oa->summary_router = OSPF6_ROUTE_TABLE_CREATE (AREA, SUMMARY_ROUTERS); oa->summary_router->scope = oa; /* set default options */ OSPF6_OPT_SET (oa->options, OSPF6_OPT_V6); OSPF6_OPT_SET (oa->options, OSPF6_OPT_E); OSPF6_OPT_SET (oa->options, OSPF6_OPT_R); oa->ospf6 = o; listnode_add_sort (o->area_list, oa); /* import athoer area's routes as inter-area routes */ for (route = ospf6_route_head (o->route_table); route; route = ospf6_route_next (route)) ospf6_abr_originate_summary_to_area (route, oa); return oa; }
/* 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; }