summaryrefslogtreecommitdiffstats
path: root/bgpd/bgp_table.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_table.c')
-rw-r--r--bgpd/bgp_table.c36
1 files changed, 16 insertions, 20 deletions
diff --git a/bgpd/bgp_table.c b/bgpd/bgp_table.c
index 5faf5856..15630a24 100644
--- a/bgpd/bgp_table.c
+++ b/bgpd/bgp_table.c
@@ -28,16 +28,15 @@ Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
#include "bgpd/bgpd.h"
#include "bgpd/bgp_table.h"
-void bgp_node_delete (struct bgp_node *);
-void bgp_table_free (struct bgp_table *);
+static void bgp_node_delete (struct bgp_node *);
+static void bgp_table_free (struct bgp_table *);
struct bgp_table *
bgp_table_init (afi_t afi, safi_t safi)
{
struct bgp_table *rt;
- rt = XMALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table));
- memset (rt, 0, sizeof (struct bgp_table));
+ rt = XCALLOC (MTYPE_BGP_TABLE, sizeof (struct bgp_table));
rt->type = BGP_TABLE_MAIN;
rt->afi = afi;
@@ -47,19 +46,16 @@ bgp_table_init (afi_t afi, safi_t safi)
}
void
-bgp_table_finish (struct bgp_table *rt)
+bgp_table_finish (struct bgp_table **rt)
{
- bgp_table_free (rt);
+ bgp_table_free (*rt);
+ *rt = NULL;
}
static struct bgp_node *
bgp_node_create ()
{
- struct bgp_node *rn;
-
- rn = (struct bgp_node *) XMALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node));
- memset (rn, 0, sizeof (struct bgp_node));
- return rn;
+ return XCALLOC (MTYPE_BGP_NODE, sizeof (struct bgp_node));
}
/* Allocate new route node with prefix set. */
@@ -84,7 +80,7 @@ bgp_node_free (struct bgp_node *node)
}
/* Free route table. */
-void
+static void
bgp_table_free (struct bgp_table *rt)
{
struct bgp_node *tmp_node;
@@ -229,7 +225,7 @@ bgp_unlock_node (struct bgp_node *node)
/* Find matched prefix. */
struct bgp_node *
-bgp_node_match (struct bgp_table *table, struct prefix *p)
+bgp_node_match (const struct bgp_table *table, struct prefix *p)
{
struct bgp_node *node;
struct bgp_node *matched;
@@ -255,7 +251,7 @@ bgp_node_match (struct bgp_table *table, struct prefix *p)
}
struct bgp_node *
-bgp_node_match_ipv4 (struct bgp_table *table, struct in_addr *addr)
+bgp_node_match_ipv4 (const struct bgp_table *table, struct in_addr *addr)
{
struct prefix_ipv4 p;
@@ -269,7 +265,7 @@ bgp_node_match_ipv4 (struct bgp_table *table, struct in_addr *addr)
#ifdef HAVE_IPV6
struct bgp_node *
-bgp_node_match_ipv6 (struct bgp_table *table, struct in6_addr *addr)
+bgp_node_match_ipv6 (const struct bgp_table *table, struct in6_addr *addr)
{
struct prefix_ipv6 p;
@@ -284,7 +280,7 @@ bgp_node_match_ipv6 (struct bgp_table *table, struct in6_addr *addr)
/* Lookup same prefix node. Return NULL when we can't find route. */
struct bgp_node *
-bgp_node_lookup (struct bgp_table *table, struct prefix *p)
+bgp_node_lookup (const struct bgp_table *table, struct prefix *p)
{
struct bgp_node *node;
@@ -304,7 +300,7 @@ bgp_node_lookup (struct bgp_table *table, struct prefix *p)
/* Add node to routing table. */
struct bgp_node *
-bgp_node_get (struct bgp_table *table, struct prefix *p)
+bgp_node_get (struct bgp_table *const table, struct prefix *p)
{
struct bgp_node *new;
struct bgp_node *node;
@@ -360,7 +356,7 @@ bgp_node_get (struct bgp_table *table, struct prefix *p)
}
/* Delete node from the routing table. */
-void
+static void
bgp_node_delete (struct bgp_node *node)
{
struct bgp_node *child;
@@ -405,7 +401,7 @@ bgp_node_delete (struct bgp_node *node)
/* Get fist node and lock it. This function is useful when one want
to lookup all the node exist in the routing table. */
struct bgp_node *
-bgp_table_top (struct bgp_table *table)
+bgp_table_top (const struct bgp_table *const table)
{
/* If there is no node in the routing table return NULL. */
if (table->top == NULL)
@@ -499,7 +495,7 @@ bgp_route_next_until (struct bgp_node *node, struct bgp_node *limit)
}
unsigned long
-bgp_table_count (struct bgp_table *table)
+bgp_table_count (const struct bgp_table *table)
{
return table->count;
}