2 * OSPF6 Area Data Structure
3 * Copyright (C) 1999 Yasuhiro Ohara
5 * This file is part of GNU Zebra.
7 * GNU Zebra is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
12 * GNU Zebra is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Zebra; see the file COPYING. If not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
26 ospf6_area_foreach_interface (struct ospf6_area
*o6a
, void *arg
, int val
,
27 void (*func
) (void *, int, void *))
30 struct ospf6_interface
*o6i
;
32 for (node
= listhead (o6a
->if_list
); node
; nextnode (node
))
34 o6i
= (struct ospf6_interface
*) getdata (node
);
35 (*func
) (arg
, val
, o6i
);
40 ospf6_area_foreach_neighbor (struct ospf6_area
*o6a
, void *arg
, int val
,
41 void (*func
) (void *, int, void *))
44 struct ospf6_interface
*o6i
;
46 for (node
= listhead (o6a
->if_list
); node
; nextnode (node
))
48 o6i
= (struct ospf6_interface
*) getdata (node
);
49 (*o6i
->foreach_nei
) (o6i
, arg
, val
, func
);
54 ospf6_area_maxage_remover (struct thread
*t
)
57 struct ospf6_area
*o6a
= (struct ospf6_area
*) THREAD_ARG (t
);
59 o6a
->maxage_remover
= (struct thread
*) NULL
;
62 o6a
->foreach_nei (o6a
, &count
, NBS_EXCHANGE
, ospf6_count_state
);
63 o6a
->foreach_nei (o6a
, &count
, NBS_LOADING
, ospf6_count_state
);
67 ospf6_lsdb_remove_maxage (o6a
->lsdb
);
72 ospf6_area_schedule_maxage_remover (void *arg
, int val
, void *obj
)
74 struct ospf6_area
*o6a
= (struct ospf6_area
*) obj
;
76 if (o6a
->maxage_remover
!= NULL
)
80 thread_add_event (master
, ospf6_area_maxage_remover
, o6a
, 0);
84 ospf6_area_is_stub (struct ospf6_area
*o6a
)
86 if (OSPF6_OPT_ISSET (o6a
->options
, OSPF6_OPT_E
))
92 ospf6_area_is_transit (struct ospf6_area
*o6a
)
97 /* Make new area structure */
99 ospf6_area_create (u_int32_t area_id
)
101 struct ospf6_area
*o6a
;
103 /* allocate memory */
104 o6a
= (struct ospf6_area
*) XMALLOC (MTYPE_OSPF6_AREA
,
105 sizeof (struct ospf6_area
));
109 inet_ntop (AF_INET
, &area_id
, str
, sizeof (str
));
110 zlog_err ("can't allocate memory for Area %s", str
);
115 memset (o6a
, 0, sizeof (struct ospf6_area
));
116 inet_ntop (AF_INET
, &area_id
, o6a
->str
, sizeof (o6a
->str
));
117 o6a
->area_id
= area_id
;
118 o6a
->if_list
= list_new ();
121 o6a
->lsdb
= list_new ();
123 o6a
->lsdb
= ospf6_lsdb_create ();
125 o6a
->spf_tree
= ospf6_spftree_create ();
126 o6a
->table_topology
= route_table_init ();
128 /* xxx, set options */
129 OSPF6_OPT_SET (o6a
->options
, OSPF6_OPT_V6
);
130 OSPF6_OPT_SET (o6a
->options
, OSPF6_OPT_E
);
131 OSPF6_OPT_SET (o6a
->options
, OSPF6_OPT_R
);
133 o6a
->foreach_if
= ospf6_area_foreach_interface
;
134 o6a
->foreach_nei
= ospf6_area_foreach_neighbor
;
140 ospf6_area_delete (struct ospf6_area
*o6a
)
143 struct ospf6_interface
*o6i
;
145 /* ospf6 interface list */
146 for (n
= listhead (o6a
->if_list
); n
; nextnode (n
))
148 o6i
= (struct ospf6_interface
*) getdata (n
);
149 /* ospf6_interface_delete (o6i); */
151 list_delete (o6a
->if_list
);
154 ospf6_lsdb_remove_all (o6a
->lsdb
);
156 /* spf tree terminate */
161 thread_cancel (o6a
->spf_calc
);
162 o6a
->spf_calc
= (struct thread
*) NULL
;
164 thread_cancel (o6a
->route_calc
);
165 o6a
->route_calc
= (struct thread
*) NULL
;
168 ospf6_spftree_delete (o6a
->spf_tree
);
169 ospf6_route_delete_all (o6a
->table_topology
);
170 route_table_finish (o6a
->table_topology
);
173 XFREE (MTYPE_OSPF6_AREA
, o6a
);
177 ospf6_area_lookup (u_int32_t area_id
, struct ospf6
*o6
)
179 struct ospf6_area
*o6a
;
182 for (n
= listhead (o6
->area_list
); n
; nextnode (n
))
184 o6a
= (struct ospf6_area
*) getdata (n
);
185 if (o6a
->area_id
== area_id
)
189 return (struct ospf6_area
*) NULL
;
193 ospf6_area_show (struct vty
*vty
, struct ospf6_area
*o6a
)
196 struct ospf6_interface
*o6i
;
198 vty_out (vty
, " Area %s%s", o6a
->str
, VTY_NEWLINE
);
199 vty_out (vty
, " Number of Area scoped LSAs is %u%s",
200 o6a
->lsdb
->count
, VTY_NEWLINE
);
202 ospf6_spf_statistics_show (vty
, o6a
->spf_tree
);
204 vty_out (vty
, " Interface attached to this area:");
205 for (i
= listhead (o6a
->if_list
); i
; nextnode (i
))
207 o6i
= (struct ospf6_interface
*) getdata (i
);
208 vty_out (vty
, " %s", o6i
->interface
->name
);
210 vty_out (vty
, "%s", VTY_NEWLINE
);
212 for (i
= listhead (o6a
->if_list
); i
; nextnode (i
))
214 o6i
= (struct ospf6_interface
*) getdata (i
);
215 if (listcount (o6i
->neighbor_list
) != 0)
216 ospf6_interface_statistics_show (vty
, o6i
);
221 ospf6_area_statistics_show (struct vty
*vty
, struct ospf6_area
*o6a
)
225 struct ospf6_interface
*o6i
;
227 vty_out (vty
, " Statistics of Area %s%s", o6a
->str
, VTY_NEWLINE
);