2 Copyright (C) 1998, 2001 Kunihiro Ishiguro
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 Free
18 Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
25 #include "sockunion.h"
30 #include "bgpd/bgpd.h"
31 #include "bgpd/bgp_table.h"
34 bgp_table_lock (struct bgp_table
*rt
)
40 bgp_table_unlock (struct bgp_table
*rt
)
42 assert (rt
->lock
> 0);
50 route_table_finish (rt
->route_table
);
51 rt
->route_table
= NULL
;
55 peer_unlock (rt
->owner
);
59 XFREE (MTYPE_BGP_TABLE
, rt
);
63 bgp_table_finish (struct bgp_table
**rt
)
67 bgp_table_unlock(*rt
);
75 static struct route_node
*
76 bgp_node_create (route_table_delegate_t
*delegate
, struct route_table
*table
)
78 struct bgp_node
*node
;
79 node
= XCALLOC (MTYPE_BGP_NODE
, sizeof (struct bgp_node
));
80 return bgp_node_to_rnode (node
);
87 bgp_node_destroy (route_table_delegate_t
*delegate
,
88 struct route_table
*table
, struct route_node
*node
)
90 struct bgp_node
*bgp_node
;
91 bgp_node
= bgp_node_from_rnode (node
);
92 XFREE (MTYPE_BGP_NODE
, bgp_node
);
96 * Function vector to customize the behavior of the route table
97 * library for BGP route tables.
99 route_table_delegate_t bgp_table_delegate
= {
100 .create_node
= bgp_node_create
,
101 .destroy_node
= bgp_node_destroy
108 bgp_table_init (afi_t afi
, safi_t safi
)
110 struct bgp_table
*rt
;
112 rt
= XCALLOC (MTYPE_BGP_TABLE
, sizeof (struct bgp_table
));
114 rt
->route_table
= route_table_init_with_delegate (&bgp_table_delegate
);
117 * Set up back pointer to bgp_table.
119 rt
->route_table
->info
= rt
;