2 * OSPFv3 Top Level 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.
34 #include "ospf6_hook.h"
35 #include "ospf6_proto.h"
36 #include "ospf6_prefix.h"
37 #include "ospf6_lsa.h"
38 #include "ospf6_lsdb.h"
40 #include "ospf6_message.h"
41 #include "ospf6_neighbor.h"
42 #include "ospf6_interface.h"
43 #include "ospf6_area.h"
44 #include "ospf6_top.h"
46 #include "ospf6_route.h"
47 #include "ospf6_zebra.h"
49 #include "ospf6_nsm.h"
50 #include "ospf6_asbr.h"
51 #include "ospf6_abr.h"
53 #define HEADER_DEPENDENCY
55 #undef HEADER_DEPENDENCY
57 /* global ospf6d variable */
61 ospf6_top_foreach_area (struct ospf6
*o6
, void *arg
, int val
,
62 void (*func
) (void *, int, void *))
65 struct ospf6_area
*o6a
;
67 for (node
= listhead (o6
->area_list
); node
; nextnode (node
))
69 o6a
= (struct ospf6_area
*) getdata (node
);
70 (*func
) (arg
, val
, o6a
);
75 ospf6_top_foreach_interface (struct ospf6
*o6
, void *arg
, int val
,
76 void (*func
) (void *, int, void *))
79 struct ospf6_area
*o6a
;
81 for (node
= listhead (o6
->area_list
); node
; nextnode (node
))
83 o6a
= (struct ospf6_area
*) getdata (node
);
84 (*o6a
->foreach_if
) (o6a
, arg
, val
, func
);
89 ospf6_top_foreach_neighbor (struct ospf6
*o6
, void *arg
, int val
,
90 void (*func
) (void *, int, void *))
93 struct ospf6_area
*o6a
;
95 for (node
= listhead (o6
->area_list
); node
; nextnode (node
))
97 o6a
= (struct ospf6_area
*) getdata (node
);
98 (*o6a
->foreach_nei
) (o6a
, arg
, val
, func
);
103 ospf6_top_maxage_remover (struct thread
*t
)
106 struct ospf6
*o6
= (struct ospf6
*) THREAD_ARG (t
);
108 o6
->maxage_remover
= (struct thread
*) NULL
;
111 o6
->foreach_nei (o6
, &count
, NBS_EXCHANGE
, ospf6_count_state
);
112 o6
->foreach_nei (o6
, &count
, NBS_LOADING
, ospf6_count_state
);
116 ospf6_lsdb_remove_maxage (o6
->lsdb
);
121 ospf6_top_schedule_maxage_remover (void *arg
, int val
, struct ospf6
*o6
)
123 if (o6
->maxage_remover
!= NULL
)
127 thread_add_event (master
, ospf6_top_maxage_remover
, o6
, 0);
131 ospf6_show (struct vty
*vty
)
134 struct ospf6_area
*area
;
136 unsigned long day
, hour
, min
, sec
;
137 struct timeval now
, running
;
139 /* process id, router id */
140 inet_ntop (AF_INET
, &ospf6
->router_id
, id_string
, sizeof (id_string
));
141 vty_out (vty
, " Routing Process (%lu) with ID %s%s",
142 ospf6
->process_id
, id_string
, VTY_NEWLINE
);
145 gettimeofday (&now
, (struct timezone
*)NULL
);
146 ospf6_timeval_sub (&now
, &ospf6
->starttime
, &running
);
147 ospf6_timeval_decode (&running
, &day
, &hour
, &min
, &sec
, NULL
, NULL
);
148 vty_out (vty
, " Running %ld days %ld hours %ld minutes %ld seconds%s",
149 day
, hour
, min
, sec
, VTY_NEWLINE
);
151 vty_out (vty
, " Supports only single TOS(TOS0) routes%s", VTY_NEWLINE
);
153 /* Redistribute config */
154 ospf6_redistribute_show_config (vty
);
157 vty_out (vty
, " Number of AS scoped LSAs is %u%s",
158 ospf6
->lsdb
->count
, VTY_NEWLINE
);
159 vty_out (vty
, " Route calculation executed %d times%s",
160 ospf6
->stat_route_calculation_execed
, VTY_NEWLINE
);
162 /* Route Statistics */
164 ospf6_route_statistics_show (vty
, ospf6
->route_table
);
168 vty_out (vty
, " Number of areas in this router is %u%s",
169 listcount (ospf6
->area_list
), VTY_NEWLINE
);
170 for (n
= listhead (ospf6
->area_list
); n
; nextnode (n
))
172 area
= (struct ospf6_area
*) getdata (n
);
173 ospf6_area_show (vty
, area
);
178 ospf6_statistics_show (struct vty
*vty
, struct ospf6
*o6
)
181 struct ospf6_area
*o6a
;
182 char running_time
[128];
183 struct timeval now
, running
;
185 gettimeofday (&now
, (struct timezone
*) NULL
);
186 ospf6_timeval_sub (&now
, &o6
->starttime
, &running
);
187 ospf6_timeval_string (&running
, running_time
, sizeof (running_time
));
189 vty_out (vty
, "Statistics of OSPF process %ld%s",
190 o6
->process_id
, VTY_NEWLINE
);
191 vty_out (vty
, " Running: %s%s", running_time
, VTY_NEWLINE
);
194 ospf6_route_statistics_show (vty
, o6
->route_table
);
197 for (node
= listhead (o6
->area_list
); node
; nextnode (node
))
199 o6a
= (struct ospf6_area
*) getdata (node
);
200 ospf6_area_statistics_show (vty
, o6a
);
204 static struct ospf6
*
208 new = XMALLOC (MTYPE_OSPF6_TOP
, sizeof (struct ospf6
));
210 memset (new, 0, sizeof (struct ospf6
));
215 ospf6_free (struct ospf6
*ospf6
)
217 XFREE (MTYPE_OSPF6_TOP
, ospf6
);
221 ospf6_top_topology_add (struct ospf6_route_req
*request
)
223 assert (request
->route
.type
== OSPF6_DEST_TYPE_ROUTER
);
224 if (CHECK_FLAG (request
->path
.router_bits
, OSPF6_ROUTER_LSA_BIT_E
))
225 ospf6_asbr_asbr_entry_add (request
);
229 ospf6_top_topology_remove (struct ospf6_route_req
*request
)
231 assert (request
->route
.type
== OSPF6_DEST_TYPE_ROUTER
);
232 if (CHECK_FLAG (request
->path
.router_bits
, OSPF6_ROUTER_LSA_BIT_E
))
233 ospf6_asbr_asbr_entry_remove (request
);
237 ospf6_create (unsigned long process_id
)
245 gettimeofday (&o6
->starttime
, (struct timezone
*)NULL
);
246 o6
->process_id
= process_id
;
247 o6
->version
= OSPF6_VERSION
;
248 o6
->area_list
= list_new ();
250 o6
->lsdb
= ospf6_lsdb_create ();
252 o6
->foreach_area
= ospf6_top_foreach_area
;
253 o6
->foreach_if
= ospf6_top_foreach_interface
;
254 o6
->foreach_nei
= ospf6_top_foreach_neighbor
;
256 snprintf (namebuf
, sizeof (namebuf
), "InterTopology table");
257 o6
->topology_table
= ospf6_route_table_create (namebuf
);
258 ospf6_route_hook_register (ospf6_top_topology_add
,
259 ospf6_top_topology_add
,
260 ospf6_top_topology_remove
,
264 snprintf (namebuf
, sizeof (namebuf
), "External table");
265 o6
->external_table
= ospf6_route_table_create (namebuf
);
266 ospf6_route_hook_register (ospf6_asbr_external_route_add
,
267 ospf6_asbr_external_route_add
,
268 ospf6_asbr_external_route_remove
,
272 snprintf (namebuf
, sizeof (namebuf
), "Top route table");
273 o6
->route_table
= ospf6_route_table_create (namebuf
);
274 ospf6_route_hook_register (ospf6_zebra_route_update_add
,
275 ospf6_zebra_route_update_add
,
276 ospf6_zebra_route_update_remove
,
278 ospf6_route_hook_register (ospf6_abr_route_add
,
280 ospf6_abr_route_remove
,
287 ospf6_delete (struct ospf6
*ospf6
)
289 ospf6_route_remove_all (ospf6
->route_table
);
299 ospf6
= ospf6_create (0);
309 ospf6_delete (ospf6
);
314 ospf6_is_asbr (struct ospf6
*o6
)
317 i
|= ospf6_zebra_is_redistribute (ZEBRA_ROUTE_SYSTEM
);
318 i
|= ospf6_zebra_is_redistribute (ZEBRA_ROUTE_CONNECT
);
319 i
|= ospf6_zebra_is_redistribute (ZEBRA_ROUTE_STATIC
);
320 i
|= ospf6_zebra_is_redistribute (ZEBRA_ROUTE_KERNEL
);
321 i
|= ospf6_zebra_is_redistribute (ZEBRA_ROUTE_RIPNG
);
322 i
|= ospf6_zebra_is_redistribute (ZEBRA_ROUTE_BGP
);
326 DEFUN (show_ipv6_ospf6_route
,
327 show_ipv6_ospf6_route_cmd
,
328 "show ipv6 ospf6 route",
335 OSPF6_CMD_CHECK_RUNNING ();
336 return ospf6_route_table_show (vty
, argc
, argv
, ospf6
->route_table
);
339 ALIAS (show_ipv6_ospf6_route
,
340 show_ipv6_ospf6_route_prefix_cmd
,
341 "show ipv6 ospf6 route (X::X|detail)",
346 "match IPv6 prefix\n"
349 DEFUN (show_ipv6_ospf6_topology
,
350 show_ipv6_ospf6_topology_cmd
,
351 "show ipv6 ospf6 topology",
355 "Inter Area topology information\n"
358 OSPF6_CMD_CHECK_RUNNING ();
359 return ospf6_route_table_show (vty
, argc
, argv
, ospf6
->topology_table
);
362 ALIAS (show_ipv6_ospf6_topology
,
363 show_ipv6_ospf6_topology_router_cmd
,
364 "show ipv6 ospf6 topology (A.B.C.D|<0-4294967295>|detail)",
368 "Inter Area topology information\n"
371 "Detailed information\n"
374 ALIAS (show_ipv6_ospf6_topology
,
375 show_ipv6_ospf6_topology_router_lsid_cmd
,
376 "show ipv6 ospf6 topology (A.B.C.D|<0-4294967295>) (A.B.C.D|<0-4294967295>)",
380 "Inter Area topology information\n"
390 install_element (VIEW_NODE
, &show_ipv6_ospf6_route_cmd
);
391 install_element (VIEW_NODE
, &show_ipv6_ospf6_route_prefix_cmd
);
392 install_element (VIEW_NODE
, &show_ipv6_ospf6_topology_cmd
);
393 install_element (VIEW_NODE
, &show_ipv6_ospf6_topology_router_cmd
);
394 install_element (VIEW_NODE
, &show_ipv6_ospf6_topology_router_lsid_cmd
);
395 install_element (ENABLE_NODE
, &show_ipv6_ospf6_route_cmd
);
396 install_element (ENABLE_NODE
, &show_ipv6_ospf6_route_prefix_cmd
);
397 install_element (ENABLE_NODE
, &show_ipv6_ospf6_topology_cmd
);
398 install_element (ENABLE_NODE
, &show_ipv6_ospf6_topology_router_cmd
);
399 install_element (ENABLE_NODE
, &show_ipv6_ospf6_topology_router_lsid_cmd
);