#include "if.h"
#include "if_rmap.h"
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP, "Interface route map")
+DEFINE_MTYPE_STATIC(LIB, IF_RMAP_NAME, "I.f. route map name")
+
struct hash *ifrmaphash;
/* Hook functions. */
static void (*if_rmap_add_hook) (struct if_rmap *) = NULL;
static void (*if_rmap_delete_hook) (struct if_rmap *) = NULL;
-\f
+
static struct if_rmap *
if_rmap_new (void)
{
struct if_rmap *if_rmap;
/* temporary copy */
- key.ifname = (char *)ifname;
+ key.ifname = (ifname) ? XSTRDUP (MTYPE_IF_RMAP_NAME, ifname) : NULL;
if_rmap = hash_lookup (ifrmaphash, &key);
+ if (key.ifname)
+ XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
+
return if_rmap;
}
static void *
if_rmap_hash_alloc (void *arg)
{
- struct if_rmap *ifarg = arg;
+ struct if_rmap *ifarg = (struct if_rmap *)arg;
struct if_rmap *if_rmap;
if_rmap = if_rmap_new ();
if_rmap_get (const char *ifname)
{
struct if_rmap key;
+ struct if_rmap *ret;
/* temporary copy */
- key.ifname = (char *)ifname;
+ key.ifname = (ifname) ? XSTRDUP (MTYPE_IF_RMAP_NAME, ifname) : NULL;
+
+ ret = hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
- return (struct if_rmap *) hash_get (ifrmaphash, &key, if_rmap_hash_alloc);
+ if (key.ifname)
+ XFREE(MTYPE_IF_RMAP_NAME, key.ifname);
+
+ return ret;
}
static unsigned int
return strcmp (if_rmap1->ifname, if_rmap2->ifname) == 0;
}
-\f
+
static struct if_rmap *
if_rmap_set (const char *ifname, enum if_rmap_type type,
const char *routemap_name)
"Route map for input filtering\n"
"Route map for output filtering\n"
"Route map interface name\n")
-\f
+
/* Configuration write function. */
int
config_write_if_rmap (struct vty *vty)