2 * Copyright (C) 2001 Yasuhiro Ohara
4 * This file is part of GNU Zebra.
6 * GNU Zebra is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2, or (at your option) any
11 * GNU Zebra is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GNU Zebra; see the file COPYING. If not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
27 #include "ospf6_hook.h"
29 struct ospf6_hook_master neighbor_hook
;
30 struct ospf6_hook_master interface_hook
;
31 struct ospf6_hook_master area_hook
;
32 struct ospf6_hook_master top_hook
;
33 struct ospf6_hook_master database_hook
;
34 struct ospf6_hook_master intra_topology_hook
;
35 struct ospf6_hook_master inter_topology_hook
;
36 struct ospf6_hook_master route_hook
;
37 struct ospf6_hook_master redistribute_hook
;
39 static struct ospf6_hook
*
42 struct ospf6_hook
*new;
43 new = XMALLOC (MTYPE_OSPF6_OTHER
, sizeof (struct ospf6_hook
));
46 memset (new, 0, sizeof (struct ospf6_hook
));
51 ospf6_hook_delete (struct ospf6_hook
*hook
)
53 XFREE (MTYPE_OSPF6_OTHER
, hook
);
57 ospf6_hook_issame (struct ospf6_hook
*hook1
, struct ospf6_hook
*hook2
)
59 if (hook1
->name
&& hook2
->name
&&
60 strcmp (hook1
->name
, hook2
->name
) != 0)
62 if (hook1
->hook_add
!= hook2
->hook_add
)
64 if (hook1
->hook_change
!= hook2
->hook_change
)
66 if (hook1
->hook_remove
!= hook2
->hook_remove
)
72 ospf6_hook_register (struct ospf6_hook
*hook
,
73 struct ospf6_hook_master
*master
)
75 struct ospf6_hook
*new;
77 new = ospf6_hook_create ();
80 new->name
= strdup (hook
->name
);
81 new->hook_add
= hook
->hook_add
;
82 new->hook_change
= hook
->hook_change
;
83 new->hook_remove
= hook
->hook_remove
;
85 new->prev
= master
->tail
;
87 master
->tail
->next
= new;
95 if (IS_OSPF6_DUMP_HOOK
)
97 zlog_info ("HOOK: Register hook%s%s%s%s",
98 (hook
->name
? " " : ""),
99 (hook
->name
? hook
->name
: ""),
100 (master
->name
? " to " : ""),
101 (master
->name
? master
->name
: ""));
106 ospf6_hook_unregister (struct ospf6_hook
*req
,
107 struct ospf6_hook_master
*master
)
109 struct ospf6_hook
*hook
;
111 for (hook
= master
->head
; hook
; hook
= hook
->next
)
113 if (ospf6_hook_issame (hook
, req
))
120 hook
->prev
->next
= hook
->next
;
122 hook
->next
->prev
= hook
->prev
;
123 if (master
->head
== hook
)
124 master
->head
= hook
->next
;
125 if (master
->tail
== hook
)
126 master
->tail
= hook
->prev
;
130 if (IS_OSPF6_DUMP_HOOK
)
132 zlog_info ("HOOK: Unregister hook%s%s%s%s",
133 (hook
->name
? " " : ""),
134 (hook
->name
? hook
->name
: ""),
135 (master
->name
? " to " : ""),
136 (master
->name
? master
->name
: ""));
141 ospf6_hook_delete (hook
);
145 ospf6_hook_unregister_all (struct ospf6_hook_master
*master
)
147 struct ospf6_hook
*hook
, *next
;
149 for (hook
= master
->head
; hook
; hook
= next
)
152 ospf6_hook_delete (hook
);
164 neighbor_hook
.name
= "Neighbor Hooklist";
165 interface_hook
.name
= "Interface Hooklist";
166 area_hook
.name
= "Area Hooklist";
167 top_hook
.name
= "Top Hooklist";
168 database_hook
.name
= "Database Hooklist";
169 intra_topology_hook
.name
= "IntraTopology Hooklist";
170 inter_topology_hook
.name
= "InterTopology Hooklist";
171 route_hook
.name
= "Route Hooklist";