Mailing List Archive

[PATCH v3 10/11] *: enhance memtype and memgroup generation across lib and daemons
This commit introduces a bash script called from Makefile from each
lib/daemon. Upon call, this script takes as input a txt file
describing the various memory group and type that need to be defined,
initialised and declared. The output of this script is 2 .c and .h
files used for compilation within lib/and or daemons and describing
the memory group and memory types.
Note that this generator tool takes into account global memory
declarations, but not static memory group and types defined inside
specific .c files.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
---
.gitignore | 2 +
bgpd/Makefile.am | 9 ++-
bgpd/bgp_memory.c | 168 --------------------------------------------
bgpd/bgp_memory.h | 97 -------------------------
bgpd/bgp_memory.txt | 66 +++++++++++++++++
isisd/Makefile.am | 7 ++
isisd/isis_memory.c | 74 -------------------
isisd/isis_memory.h | 52 --------------
isisd/isis_memory.txt | 22 ++++++
lib/Makefile.am | 6 +-
lib/lib_memory.c | 151 ---------------------------------------
lib/lib_memory.h | 98 --------------------------
lib/lib_memory.txt | 66 +++++++++++++++++
memory_gen.sh | 154 ++++++++++++++++++++++++++++++++++++++++
ospf6d/Makefile.am | 7 ++
ospf6d/ospf6_memory.c | 68 ------------------
ospf6d/ospf6_memory.h | 49 -------------
ospf6d/ospf6_memory.txt | 19 +++++
ospfclient/ospf_apiclient.c | 3 -
ospfd/Makefile.am | 8 ++-
ospfd/ospf_memory.c | 92 ------------------------
ospfd/ospf_memory.h | 59 ----------------
ospfd/ospf_memory.txt | 30 ++++++++
pimd/Makefile.am | 7 ++
pimd/pim_memory.c | 58 ---------------
pimd/pim_memory.h | 44 ------------
pimd/pim_memory.txt | 14 ++++
ripd/Makefile.am | 8 ++-
ripd/rip_memory.c | 48 -------------
ripd/rip_memory.h | 39 ----------
ripd/rip_memory.txt | 9 +++
ripngd/Makefile.am | 6 ++
ripngd/ripng_memory.c | 48 -------------
ripngd/ripng_memory.h | 39 ----------
ripngd/ripng_memory.txt | 9 +++
zebra/Makefile.am | 8 ++-
zebra/zebra_memory.c | 56 ---------------
zebra/zebra_memory.h | 43 ------------
zebra/zebra_memory.txt | 14 ++++
39 files changed, 466 insertions(+), 1291 deletions(-)
delete mode 100644 bgpd/bgp_memory.c
delete mode 100644 bgpd/bgp_memory.h
create mode 100644 bgpd/bgp_memory.txt
delete mode 100644 isisd/isis_memory.c
delete mode 100644 isisd/isis_memory.h
create mode 100644 isisd/isis_memory.txt
delete mode 100644 lib/lib_memory.c
delete mode 100644 lib/lib_memory.h
create mode 100644 lib/lib_memory.txt
create mode 100644 memory_gen.sh
delete mode 100644 ospf6d/ospf6_memory.c
delete mode 100644 ospf6d/ospf6_memory.h
create mode 100644 ospf6d/ospf6_memory.txt
delete mode 100644 ospfd/ospf_memory.c
delete mode 100644 ospfd/ospf_memory.h
create mode 100644 ospfd/ospf_memory.txt
delete mode 100644 pimd/pim_memory.c
delete mode 100644 pimd/pim_memory.h
create mode 100644 pimd/pim_memory.txt
delete mode 100644 ripd/rip_memory.c
delete mode 100644 ripd/rip_memory.h
create mode 100644 ripd/rip_memory.txt
delete mode 100644 ripngd/ripng_memory.c
delete mode 100644 ripngd/ripng_memory.h
create mode 100644 ripngd/ripng_memory.txt
delete mode 100644 zebra/zebra_memory.c
delete mode 100644 zebra/zebra_memory.h
create mode 100644 zebra/zebra_memory.txt

diff --git a/.gitignore b/.gitignore
index a281555e494b..8ee1a8ac67e3 100644
--- a/.gitignore
+++ b/.gitignore
@@ -41,3 +41,5 @@ cscope.*
*.pb.h
*.pb-c.h
*.pb-c.c
+*/*_memory.c
+*/*_memory.h
diff --git a/bgpd/Makefile.am b/bgpd/Makefile.am
index 55c51d038143..2d9c0efe8d6f 100644
--- a/bgpd/Makefile.am
+++ b/bgpd/Makefile.am
@@ -28,7 +28,14 @@ noinst_HEADERS = \
bgp_advertise.h bgp_snmp.h bgp_vty.h bgp_mpath.h \
bgp_encap.h bgp_encap_tlv.h bgp_encap_types.h bgp_nht.h

+
+bgp_memory.h: $(srcdir)/bgp_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh bgp)
+
bgpd_SOURCES = bgp_main.c
+
+BUILT_SOURCES = bgp_memory.h bgp_memory.c
+
bgpd_LDADD = libbgp.a ../lib/libzebra.la @LIBCAP@ @LIBM@

bgp_btoa_SOURCES = bgp_btoa.c
@@ -37,5 +44,5 @@ bgp_btoa_LDADD = libbgp.a ../lib/libzebra.la @LIBCAP@ @LIBM@
examplesdir = $(exampledir)
dist_examples_DATA = bgpd.conf.sample bgpd.conf.sample2

-EXTRA_DIST = BGP4-MIB.txt
+EXTRA_DIST = BGP4-MIB.txt bgp_memory.txt ../memory_gen.sh

diff --git a/bgpd/bgp_memory.c b/bgpd/bgp_memory.c
deleted file mode 100644
index 1c0ec1e6b360..000000000000
--- a/bgpd/bgp_memory.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/* bgpd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "bgp_memory.h"
-
-/* this file is temporary in nature; definitions should be moved to the
- * files they're used in */
-
-DEFINE_MGROUP(BGPD, "bgpd")
-DEFINE_MTYPE(BGPD, BGP, "BGP instance")
-DEFINE_MTYPE(BGPD, BGP_LISTENER, "BGP listen socket details")
-DEFINE_MTYPE(BGPD, BGP_PEER, "BGP peer")
-DEFINE_MTYPE(BGPD, BGP_PEER_HOST, "BGP peer hostname")
-DEFINE_MTYPE(BGPD, PEER_GROUP, "Peer group")
-DEFINE_MTYPE(BGPD, PEER_DESC, "Peer description")
-DEFINE_MTYPE(BGPD, PEER_PASSWORD, "Peer password string")
-DEFINE_MTYPE(BGPD, ATTR, "BGP attribute")
-DEFINE_MTYPE(BGPD, ATTR_EXTRA, "BGP extra attributes")
-DEFINE_MTYPE(BGPD, AS_PATH, "BGP aspath")
-DEFINE_MTYPE(BGPD, AS_SEG, "BGP aspath seg")
-DEFINE_MTYPE(BGPD, AS_SEG_DATA, "BGP aspath segment data")
-DEFINE_MTYPE(BGPD, AS_STR, "BGP aspath str")
-
-DEFINE_MTYPE(BGPD, BGP_TABLE, "BGP table")
-DEFINE_MTYPE(BGPD, BGP_NODE, "BGP node")
-DEFINE_MTYPE(BGPD, BGP_ROUTE, "BGP route")
-DEFINE_MTYPE(BGPD, BGP_ROUTE_EXTRA, "BGP ancillary route info")
-DEFINE_MTYPE(BGPD, BGP_CONN, "BGP connected")
-DEFINE_MTYPE(BGPD, BGP_STATIC, "BGP static")
-DEFINE_MTYPE(BGPD, BGP_ADVERTISE_ATTR, "BGP adv attr")
-DEFINE_MTYPE(BGPD, BGP_ADVERTISE, "BGP adv")
-DEFINE_MTYPE(BGPD, BGP_SYNCHRONISE, "BGP synchronise")
-DEFINE_MTYPE(BGPD, BGP_ADJ_IN, "BGP adj in")
-DEFINE_MTYPE(BGPD, BGP_ADJ_OUT, "BGP adj out")
-DEFINE_MTYPE(BGPD, BGP_MPATH_INFO, "BGP multipath info")
-
-DEFINE_MTYPE(BGPD, AS_LIST, "BGP AS list")
-DEFINE_MTYPE(BGPD, AS_FILTER, "BGP AS filter")
-DEFINE_MTYPE(BGPD, AS_FILTER_STR, "BGP AS filter str")
-
-DEFINE_MTYPE(BGPD, COMMUNITY, "community")
-DEFINE_MTYPE(BGPD, COMMUNITY_VAL, "community val")
-DEFINE_MTYPE(BGPD, COMMUNITY_STR, "community str")
-
-DEFINE_MTYPE(BGPD, ECOMMUNITY, "extcommunity")
-DEFINE_MTYPE(BGPD, ECOMMUNITY_VAL, "extcommunity val")
-DEFINE_MTYPE(BGPD, ECOMMUNITY_STR, "extcommunity str")
-
-DEFINE_MTYPE(BGPD, COMMUNITY_LIST, "community-list")
-DEFINE_MTYPE(BGPD, COMMUNITY_LIST_NAME, "community-list name")
-DEFINE_MTYPE(BGPD, COMMUNITY_LIST_ENTRY, "community-list entry")
-DEFINE_MTYPE(BGPD, COMMUNITY_LIST_CONFIG, "community-list config")
-DEFINE_MTYPE(BGPD, COMMUNITY_LIST_HANDLER, "community-list handler")
-
-DEFINE_MTYPE(BGPD, CLUSTER, "Cluster list")
-DEFINE_MTYPE(BGPD, CLUSTER_VAL, "Cluster list val")
-
-DEFINE_MTYPE(BGPD, BGP_PROCESS_QUEUE, "BGP Process queue")
-DEFINE_MTYPE(BGPD, BGP_CLEAR_NODE_QUEUE, "BGP node clear queue")
-
-DEFINE_MTYPE(BGPD, TRANSIT, "BGP transit attr")
-DEFINE_MTYPE(BGPD, TRANSIT_VAL, "BGP transit val")
-
-DEFINE_MTYPE(BGPD, BGP_DISTANCE, "BGP distance")
-DEFINE_MTYPE(BGPD, BGP_NEXTHOP_CACHE, "BGP nexthop")
-DEFINE_MTYPE(BGPD, BGP_CONFED_LIST, "BGP confed list")
-DEFINE_MTYPE(BGPD, PEER_UPDATE_SOURCE, "BGP peer update interface")
-DEFINE_MTYPE(BGPD, BGP_DAMP_INFO, "Dampening info")
-DEFINE_MTYPE(BGPD, BGP_DAMP_ARRAY, "BGP Dampening array")
-DEFINE_MTYPE(BGPD, BGP_REGEXP, "BGP regexp")
-DEFINE_MTYPE(BGPD, BGP_AGGREGATE, "BGP aggregate")
-DEFINE_MTYPE(BGPD, BGP_ADDR, "BGP own address")
-DEFINE_MTYPE(BGPD, ENCAP_TLV, "ENCAP TLV")
-
-void bgp_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(BGPD);
- INIT_MTYPE(BGP);
- INIT_MTYPE(BGP_LISTENER);
- INIT_MTYPE(BGP_PEER);
- INIT_MTYPE(BGP_PEER_HOST);
- INIT_MTYPE(PEER_GROUP);
- INIT_MTYPE(PEER_DESC);
- INIT_MTYPE(PEER_PASSWORD);
- INIT_MTYPE(ATTR);
- INIT_MTYPE(ATTR_EXTRA);
- INIT_MTYPE(AS_PATH);
- INIT_MTYPE(AS_SEG);
- INIT_MTYPE(AS_SEG_DATA);
- INIT_MTYPE(AS_STR);
-
- INIT_MTYPE(BGP_TABLE);
- INIT_MTYPE(BGP_NODE);
- INIT_MTYPE(BGP_ROUTE);
- INIT_MTYPE(BGP_ROUTE_EXTRA);
- INIT_MTYPE(BGP_CONN);
- INIT_MTYPE(BGP_STATIC);
- INIT_MTYPE(BGP_ADVERTISE_ATTR);
- INIT_MTYPE(BGP_ADVERTISE);
- INIT_MTYPE(BGP_SYNCHRONISE);
- INIT_MTYPE(BGP_ADJ_IN);
- INIT_MTYPE(BGP_ADJ_OUT);
- INIT_MTYPE(BGP_MPATH_INFO);
-
- INIT_MTYPE(AS_LIST);
- INIT_MTYPE(AS_FILTER);
- INIT_MTYPE(AS_FILTER_STR);
-
- INIT_MTYPE(COMMUNITY);
- INIT_MTYPE(COMMUNITY_VAL);
- INIT_MTYPE(COMMUNITY_STR);
-
- INIT_MTYPE(ECOMMUNITY);
- INIT_MTYPE(ECOMMUNITY_VAL);
- INIT_MTYPE(ECOMMUNITY_STR);
-
- INIT_MTYPE(COMMUNITY_LIST);
- INIT_MTYPE(COMMUNITY_LIST_NAME);
- INIT_MTYPE(COMMUNITY_LIST_ENTRY);
- INIT_MTYPE(COMMUNITY_LIST_CONFIG);
- INIT_MTYPE(COMMUNITY_LIST_HANDLER);
-
- INIT_MTYPE(CLUSTER);
- INIT_MTYPE(CLUSTER_VAL);
-
- INIT_MTYPE(BGP_PROCESS_QUEUE);
- INIT_MTYPE(BGP_CLEAR_NODE_QUEUE);
-
- INIT_MTYPE(TRANSIT);
- INIT_MTYPE(TRANSIT_VAL);
-
- INIT_MTYPE(BGP_DISTANCE);
- INIT_MTYPE(BGP_NEXTHOP_CACHE);
- INIT_MTYPE(BGP_CONFED_LIST);
- INIT_MTYPE(PEER_UPDATE_SOURCE);
- INIT_MTYPE(BGP_DAMP_INFO);
- INIT_MTYPE(BGP_DAMP_ARRAY);
- INIT_MTYPE(BGP_REGEXP);
- INIT_MTYPE(BGP_AGGREGATE);
- INIT_MTYPE(BGP_ADDR);
- INIT_MTYPE(ENCAP_TLV);
-
-}
diff --git a/bgpd/bgp_memory.h b/bgpd/bgp_memory.h
deleted file mode 100644
index a17f40f3b2af..000000000000
--- a/bgpd/bgp_memory.h
+++ /dev/null
@@ -1,97 +0,0 @@
-/* bgpd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_BGP_MEMORY_H
-#define _QUAGGA_BGP_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(BGPD)
-DECLARE_MTYPE(BGP)
-DECLARE_MTYPE(BGP_LISTENER)
-DECLARE_MTYPE(BGP_PEER)
-DECLARE_MTYPE(BGP_PEER_HOST)
-DECLARE_MTYPE(PEER_GROUP)
-DECLARE_MTYPE(PEER_DESC)
-DECLARE_MTYPE(PEER_PASSWORD)
-DECLARE_MTYPE(ATTR)
-DECLARE_MTYPE(ATTR_EXTRA)
-DECLARE_MTYPE(AS_PATH)
-DECLARE_MTYPE(AS_SEG)
-DECLARE_MTYPE(AS_SEG_DATA)
-DECLARE_MTYPE(AS_STR)
-
-DECLARE_MTYPE(BGP_TABLE)
-DECLARE_MTYPE(BGP_NODE)
-DECLARE_MTYPE(BGP_ROUTE)
-DECLARE_MTYPE(BGP_ROUTE_EXTRA)
-DECLARE_MTYPE(BGP_CONN)
-DECLARE_MTYPE(BGP_STATIC)
-DECLARE_MTYPE(BGP_ADVERTISE_ATTR)
-DECLARE_MTYPE(BGP_ADVERTISE)
-DECLARE_MTYPE(BGP_SYNCHRONISE)
-DECLARE_MTYPE(BGP_ADJ_IN)
-DECLARE_MTYPE(BGP_ADJ_OUT)
-DECLARE_MTYPE(BGP_MPATH_INFO)
-
-DECLARE_MTYPE(AS_LIST)
-DECLARE_MTYPE(AS_FILTER)
-DECLARE_MTYPE(AS_FILTER_STR)
-
-DECLARE_MTYPE(COMMUNITY)
-DECLARE_MTYPE(COMMUNITY_VAL)
-DECLARE_MTYPE(COMMUNITY_STR)
-
-DECLARE_MTYPE(ECOMMUNITY)
-DECLARE_MTYPE(ECOMMUNITY_VAL)
-DECLARE_MTYPE(ECOMMUNITY_STR)
-
-DECLARE_MTYPE(COMMUNITY_LIST)
-DECLARE_MTYPE(COMMUNITY_LIST_NAME)
-DECLARE_MTYPE(COMMUNITY_LIST_ENTRY)
-DECLARE_MTYPE(COMMUNITY_LIST_CONFIG)
-DECLARE_MTYPE(COMMUNITY_LIST_HANDLER)
-
-DECLARE_MTYPE(CLUSTER)
-DECLARE_MTYPE(CLUSTER_VAL)
-
-DECLARE_MTYPE(BGP_PROCESS_QUEUE)
-DECLARE_MTYPE(BGP_CLEAR_NODE_QUEUE)
-
-DECLARE_MTYPE(TRANSIT)
-DECLARE_MTYPE(TRANSIT_VAL)
-
-DECLARE_MTYPE(BGP_DISTANCE)
-DECLARE_MTYPE(BGP_NEXTHOP_CACHE)
-DECLARE_MTYPE(BGP_CONFED_LIST)
-DECLARE_MTYPE(PEER_UPDATE_SOURCE)
-DECLARE_MTYPE(BGP_DAMP_INFO)
-DECLARE_MTYPE(BGP_DAMP_ARRAY)
-DECLARE_MTYPE(BGP_REGEXP)
-DECLARE_MTYPE(BGP_AGGREGATE)
-DECLARE_MTYPE(BGP_ADDR)
-DECLARE_MTYPE(ENCAP_TLV)
-
-extern void bgp_memory_init(void);
-
-#endif /* _QUAGGA_BGP_MEMORY_H */
diff --git a/bgpd/bgp_memory.txt b/bgpd/bgp_memory.txt
new file mode 100644
index 000000000000..4c0d797bfee8
--- /dev/null
+++ b/bgpd/bgp_memory.txt
@@ -0,0 +1,66 @@
+#include "lib_memory.h"
+MGROUP(BGPD, "bgpd")
+MTYPE(BGPD, BGP, "BGP instance")
+MTYPE(BGPD, BGP_LISTENER, "BGP listen socket details")
+MTYPE(BGPD, BGP_PEER, "BGP peer")
+MTYPE(BGPD, BGP_PEER_HOST, "BGP peer hostname")
+MTYPE(BGPD, PEER_GROUP, "Peer group")
+MTYPE(BGPD, PEER_DESC, "Peer description")
+MTYPE(BGPD, PEER_PASSWORD, "Peer password string")
+MTYPE(BGPD, ATTR, "BGP attribute")
+MTYPE(BGPD, ATTR_EXTRA, "BGP extra attributes")
+MTYPE(BGPD, AS_PATH, "BGP aspath")
+MTYPE(BGPD, AS_SEG, "BGP aspath seg")
+MTYPE(BGPD, AS_SEG_DATA, "BGP aspath segment data")
+MTYPE(BGPD, AS_STR, "BGP aspath str")
+
+MTYPE(BGPD, BGP_TABLE, "BGP table")
+MTYPE(BGPD, BGP_NODE, "BGP node")
+MTYPE(BGPD, BGP_ROUTE, "BGP route")
+MTYPE(BGPD, BGP_ROUTE_EXTRA, "BGP ancillary route info")
+MTYPE(BGPD, BGP_CONN, "BGP connected")
+MTYPE(BGPD, BGP_STATIC, "BGP static")
+MTYPE(BGPD, BGP_ADVERTISE_ATTR, "BGP adv attr")
+MTYPE(BGPD, BGP_ADVERTISE, "BGP adv")
+MTYPE(BGPD, BGP_SYNCHRONISE, "BGP synchronise")
+MTYPE(BGPD, BGP_ADJ_IN, "BGP adj in")
+MTYPE(BGPD, BGP_ADJ_OUT, "BGP adj out")
+MTYPE(BGPD, BGP_MPATH_INFO, "BGP multipath info")
+
+MTYPE(BGPD, AS_LIST, "BGP AS list")
+MTYPE(BGPD, AS_FILTER, "BGP AS filter")
+MTYPE(BGPD, AS_FILTER_STR, "BGP AS filter str")
+
+MTYPE(BGPD, COMMUNITY, "community")
+MTYPE(BGPD, COMMUNITY_VAL, "community val")
+MTYPE(BGPD, COMMUNITY_STR, "community str")
+
+MTYPE(BGPD, ECOMMUNITY, "extcommunity")
+MTYPE(BGPD, ECOMMUNITY_VAL, "extcommunity val")
+MTYPE(BGPD, ECOMMUNITY_STR, "extcommunity str")
+
+MTYPE(BGPD, COMMUNITY_LIST, "community-list")
+MTYPE(BGPD, COMMUNITY_LIST_NAME, "community-list name")
+MTYPE(BGPD, COMMUNITY_LIST_ENTRY, "community-list entry")
+MTYPE(BGPD, COMMUNITY_LIST_CONFIG, "community-list config")
+MTYPE(BGPD, COMMUNITY_LIST_HANDLER, "community-list handler")
+
+MTYPE(BGPD, CLUSTER, "Cluster list")
+MTYPE(BGPD, CLUSTER_VAL, "Cluster list val")
+
+MTYPE(BGPD, BGP_PROCESS_QUEUE, "BGP Process queue")
+MTYPE(BGPD, BGP_CLEAR_NODE_QUEUE, "BGP node clear queue")
+
+MTYPE(BGPD, TRANSIT, "BGP transit attr")
+MTYPE(BGPD, TRANSIT_VAL, "BGP transit val")
+
+MTYPE(BGPD, BGP_DISTANCE, "BGP distance")
+MTYPE(BGPD, BGP_NEXTHOP_CACHE, "BGP nexthop")
+MTYPE(BGPD, BGP_CONFED_LIST, "BGP confed list")
+MTYPE(BGPD, PEER_UPDATE_SOURCE, "BGP peer update interface")
+MTYPE(BGPD, BGP_DAMP_INFO, "Dampening info")
+MTYPE(BGPD, BGP_DAMP_ARRAY, "BGP Dampening array")
+MTYPE(BGPD, BGP_REGEXP, "BGP regexp")
+MTYPE(BGPD, BGP_AGGREGATE, "BGP aggregate")
+MTYPE(BGPD, BGP_ADDR, "BGP own address")
+MTYPE(BGPD, ENCAP_TLV, "ENCAP TLV")
diff --git a/isisd/Makefile.am b/isisd/Makefile.am
index c14351ca3ac7..56065e6922db 100644
--- a/isisd/Makefile.am
+++ b/isisd/Makefile.am
@@ -30,11 +30,18 @@ noinst_HEADERS = \
isis_route.h isis_routemap.h isis_te.h \
include-netbsd/clnp.h include-netbsd/esis.h include-netbsd/iso.h

+isis_memory.h: $(srcdir)/isis_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh isis)
+
isisd_SOURCES = \
isis_main.c $(libisis_a_SOURCES) \
isis_bpf.c isis_dlpi.c isis_pfpacket.c

+BUILT_SOURCES = isis_memory.h isis_memory.c
+
isisd_LDADD = @ISIS_TOPOLOGY_LIB@ ../lib/libzebra.la @LIBCAP@

examplesdir = $(exampledir)
dist_examples_DATA = isisd.conf.sample
+
+EXTRA_DIST = isis_memory.txt ../memory_gen.sh
diff --git a/isisd/isis_memory.c b/isisd/isis_memory.c
deleted file mode 100644
index e1ec42e22dc4..000000000000
--- a/isisd/isis_memory.c
+++ /dev/null
@@ -1,74 +0,0 @@
-/* isisd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "isis_memory.h"
-
-DEFINE_MGROUP(ISISD, "isisd")
-DEFINE_MTYPE(ISISD, ISIS, "ISIS")
-DEFINE_MTYPE(ISISD, ISIS_TMP, "ISIS TMP")
-DEFINE_MTYPE(ISISD, ISIS_CIRCUIT, "ISIS circuit")
-DEFINE_MTYPE(ISISD, ISIS_LSP, "ISIS LSP")
-DEFINE_MTYPE(ISISD, ISIS_ADJACENCY, "ISIS adjacency")
-DEFINE_MTYPE(ISISD, ISIS_AREA, "ISIS area")
-DEFINE_MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address")
-DEFINE_MTYPE(ISISD, ISIS_TLV, "ISIS TLV")
-DEFINE_MTYPE(ISISD, ISIS_DYNHN, "ISIS dyn hostname")
-DEFINE_MTYPE(ISISD, ISIS_SPFTREE, "ISIS SPFtree")
-DEFINE_MTYPE(ISISD, ISIS_VERTEX, "ISIS vertex")
-DEFINE_MTYPE(ISISD, ISIS_ROUTE_INFO, "ISIS route info")
-DEFINE_MTYPE(ISISD, ISIS_NEXTHOP, "ISIS nexthop")
-DEFINE_MTYPE(ISISD, ISIS_NEXTHOP6, "ISIS nexthop6")
-DEFINE_MTYPE(ISISD, ISIS_DICT, "ISIS dictionary")
-DEFINE_MTYPE(ISISD, ISIS_DICT_NODE, "ISIS dictionary node")
-DEFINE_MTYPE(ISISD, ISIS_MPLS_TE, "ISIS MPLS Traffic Engineering")
-DEFINE_MTYPE(ISISD, ISIS_EXT_ROUTE, "ISIS redistributed route")
-DEFINE_MTYPE(ISISD, ISIS_EXT_INFO, "ISIS Ext Info")
-
-void isis_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(ISISD);
- INIT_MTYPE(ISIS);
- INIT_MTYPE(ISIS_TMP);
- INIT_MTYPE(ISIS_CIRCUIT);
- INIT_MTYPE(ISIS_LSP);
- INIT_MTYPE(ISIS_ADJACENCY);
- INIT_MTYPE(ISIS_AREA);
- INIT_MTYPE(ISIS_AREA_ADDR);
- INIT_MTYPE(ISIS_TLV);
- INIT_MTYPE(ISIS_DYNHN);
- INIT_MTYPE(ISIS_SPFTREE);
- INIT_MTYPE(ISIS_VERTEX);
- INIT_MTYPE(ISIS_ROUTE_INFO);
- INIT_MTYPE(ISIS_NEXTHOP);
- INIT_MTYPE(ISIS_NEXTHOP6);
- INIT_MTYPE(ISIS_DICT);
- INIT_MTYPE(ISIS_DICT_NODE);
- INIT_MTYPE(ISIS_MPLS_TE);
- INIT_MTYPE(ISIS_EXT_ROUTE);
- INIT_MTYPE(ISIS_EXT_INFO);
-}
diff --git a/isisd/isis_memory.h b/isisd/isis_memory.h
deleted file mode 100644
index 3c8f6b131a98..000000000000
--- a/isisd/isis_memory.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* isisd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_ISIS_MEMORY_H
-#define _QUAGGA_ISIS_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(ISISD)
-DECLARE_MTYPE(ISIS)
-DECLARE_MTYPE(ISIS_TMP)
-DECLARE_MTYPE(ISIS_CIRCUIT)
-DECLARE_MTYPE(ISIS_LSP)
-DECLARE_MTYPE(ISIS_ADJACENCY)
-DECLARE_MTYPE(ISIS_AREA)
-DECLARE_MTYPE(ISIS_AREA_ADDR)
-DECLARE_MTYPE(ISIS_TLV)
-DECLARE_MTYPE(ISIS_DYNHN)
-DECLARE_MTYPE(ISIS_SPFTREE)
-DECLARE_MTYPE(ISIS_VERTEX)
-DECLARE_MTYPE(ISIS_ROUTE_INFO)
-DECLARE_MTYPE(ISIS_NEXTHOP)
-DECLARE_MTYPE(ISIS_NEXTHOP6)
-DECLARE_MTYPE(ISIS_DICT)
-DECLARE_MTYPE(ISIS_DICT_NODE)
-DECLARE_MTYPE(ISIS_MPLS_TE)
-DECLARE_MTYPE(ISIS_EXT_ROUTE)
-DECLARE_MTYPE(ISIS_EXT_INFO)
-
-extern void isis_memory_init(void);
-
-#endif /* _QUAGGA_ISIS_MEMORY_H */
diff --git a/isisd/isis_memory.txt b/isisd/isis_memory.txt
new file mode 100644
index 000000000000..7bc75d0eb148
--- /dev/null
+++ b/isisd/isis_memory.txt
@@ -0,0 +1,22 @@
+#include "lib_memory.h"
+
+MGROUP(ISISD, "isisd")
+MTYPE(ISISD, ISIS, "ISIS")
+MTYPE(ISISD, ISIS_TMP, "ISIS TMP")
+MTYPE(ISISD, ISIS_CIRCUIT, "ISIS circuit")
+MTYPE(ISISD, ISIS_LSP, "ISIS LSP")
+MTYPE(ISISD, ISIS_ADJACENCY, "ISIS adjacency")
+MTYPE(ISISD, ISIS_AREA, "ISIS area")
+MTYPE(ISISD, ISIS_AREA_ADDR, "ISIS area address")
+MTYPE(ISISD, ISIS_TLV, "ISIS TLV")
+MTYPE(ISISD, ISIS_DYNHN, "ISIS dyn hostname")
+MTYPE(ISISD, ISIS_SPFTREE, "ISIS SPFtree")
+MTYPE(ISISD, ISIS_VERTEX, "ISIS vertex")
+MTYPE(ISISD, ISIS_ROUTE_INFO, "ISIS route info")
+MTYPE(ISISD, ISIS_NEXTHOP, "ISIS nexthop")
+MTYPE(ISISD, ISIS_NEXTHOP6, "ISIS nexthop6")
+MTYPE(ISISD, ISIS_DICT, "ISIS dictionary")
+MTYPE(ISISD, ISIS_DICT_NODE, "ISIS dictionary node")
+MTYPE(ISISD, ISIS_MPLS_TE, "ISIS MPLS Traffic Engineering")
+MTYPE(ISISD, ISIS_EXT_ROUTE, "ISIS redistributed route")
+MTYPE(ISISD, ISIS_EXT_INFO, "ISIS redistributed route info")
diff --git a/lib/Makefile.am b/lib/Makefile.am
index c942129d3d01..4f4a7e19470f 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -16,7 +16,7 @@ libzebra_la_SOURCES = \
sigevent.c pqueue.c jhash.c lib_memory.c workqueue.c vrf.c \
event_counter.c nexthop.c memory_vty.c memory.c

-BUILT_SOURCES = route_types.h gitversion.h
+BUILT_SOURCES = route_types.h gitversion.h lib_memory.h lib_memory.c

libzebra_la_DEPENDENCIES = @LIB_REGEX@

@@ -39,8 +39,12 @@ EXTRA_DIST = \
regex.c regex-gnu.h \
queue.h \
route_types.pl route_types.txt \
+ lib_memory.txt ../memory_gen.sh \
gitversion.pl

+lib_memory.h: $(srcdir)/lib_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh lib)
+
route_types.h: $(srcdir)/route_types.txt $(srcdir)/route_types.pl
@PERL@ $(srcdir)/route_types.pl < $(srcdir)/route_types.txt > $@

diff --git a/lib/lib_memory.c b/lib/lib_memory.c
deleted file mode 100644
index 00697dbc0795..000000000000
--- a/lib/lib_memory.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * Memory type definitions. This file is parsed by memtypes.awk to extract
- * MTYPE_ and memory_list_.. information in order to autogenerate
- * lib_memory.h.
- *
- * The script is sensitive to the format (though not whitespace), see
- * the top of memtypes.awk for more details.
- */
-
-#include "zebra.h"
-#include "lib_memory.h"
-
-DEFINE_MGROUP(LIB, "libzebra")
-DEFINE_MTYPE(LIB, TMP, "Temporary memory")
-DEFINE_MTYPE(LIB, STRVEC, "String vector")
-DEFINE_MTYPE(LIB, VECTOR, "Vector")
-DEFINE_MTYPE(LIB, VECTOR_INDEX, "Vector index")
-DEFINE_MTYPE(LIB, LINK_LIST, "Link List")
-DEFINE_MTYPE(LIB, LINK_NODE, "Link Node")
-DEFINE_MTYPE(LIB, THREAD, "Thread")
-DEFINE_MTYPE(LIB, THREAD_MASTER, "Thread master")
-DEFINE_MTYPE(LIB, THREAD_STATS, "Thread stats")
-DEFINE_MTYPE(LIB, VTY, "VTY")
-DEFINE_MTYPE(LIB, VTY_OUT_BUF, "VTY output buffer")
-DEFINE_MTYPE(LIB, VTY_HIST, "VTY history")
-DEFINE_MTYPE(LIB, IF, "Interface")
-DEFINE_MTYPE(LIB, CONNECTED, "Connected")
-DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
-DEFINE_MTYPE(LIB, BUFFER, "Buffer")
-DEFINE_MTYPE(LIB, BUFFER_DATA, "Buffer data")
-DEFINE_MTYPE(LIB, STREAM, "Stream")
-DEFINE_MTYPE(LIB, STREAM_DATA, "Stream data")
-DEFINE_MTYPE(LIB, STREAM_FIFO, "Stream FIFO")
-DEFINE_MTYPE(LIB, PREFIX, "Prefix")
-DEFINE_MTYPE(LIB, PREFIX_IPV4, "Prefix IPv4")
-DEFINE_MTYPE(LIB, PREFIX_IPV6, "Prefix IPv6")
-DEFINE_MTYPE(LIB, HASH, "Hash")
-DEFINE_MTYPE(LIB, HASH_BACKET, "Hash Bucket")
-DEFINE_MTYPE(LIB, HASH_INDEX, "Hash Index")
-DEFINE_MTYPE(LIB, ROUTE_TABLE, "Route table")
-DEFINE_MTYPE(LIB, ROUTE_NODE, "Route node")
-DEFINE_MTYPE(LIB, DISTRIBUTE, "Distribute list")
-DEFINE_MTYPE(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname")
-DEFINE_MTYPE(LIB, ACCESS_LIST, "Access List")
-DEFINE_MTYPE(LIB, ACCESS_LIST_STR, "Access List Str")
-DEFINE_MTYPE(LIB, ACCESS_FILTER, "Access Filter")
-DEFINE_MTYPE(LIB, PREFIX_LIST, "Prefix List")
-DEFINE_MTYPE(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry")
-DEFINE_MTYPE(LIB, PREFIX_LIST_STR, "Prefix List Str")
-DEFINE_MTYPE(LIB, ROUTE_MAP, "Route map")
-DEFINE_MTYPE(LIB, ROUTE_MAP_NAME, "Route map name")
-DEFINE_MTYPE(LIB, ROUTE_MAP_INDEX, "Route map index")
-DEFINE_MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule")
-DEFINE_MTYPE(LIB, ROUTE_MAP_RULE_STR, "Route map rule str")
-DEFINE_MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled")
-DEFINE_MTYPE(LIB, CMD_TOKENS, "Command desc")
-DEFINE_MTYPE(LIB, KEY, "Key")
-DEFINE_MTYPE(LIB, KEYCHAIN, "Key chain")
-DEFINE_MTYPE(LIB, IF_RMAP, "Interface route map")
-DEFINE_MTYPE(LIB, IF_RMAP_NAME, "I.f. route map name")
-DEFINE_MTYPE(LIB, SOCKUNION, "Socket union")
-DEFINE_MTYPE(LIB, PRIVS, "Privilege information")
-DEFINE_MTYPE(LIB, ZLOG, "Logging")
-DEFINE_MTYPE(LIB, ZCLIENT, "Zclient")
-DEFINE_MTYPE(LIB, WORK_QUEUE, "Work queue")
-DEFINE_MTYPE(LIB, WORK_QUEUE_ITEM, "Work queue item")
-DEFINE_MTYPE(LIB, WORK_QUEUE_NAME, "Work queue name string")
-DEFINE_MTYPE(LIB, PQUEUE, "Priority queue")
-DEFINE_MTYPE(LIB, PQUEUE_DATA, "Priority queue data")
-DEFINE_MTYPE(LIB, HOST, "host configuration")
-DEFINE_MTYPE(LIB, VRF, "VRF")
-DEFINE_MTYPE(LIB, VRF_NAME, "VRF name")
-DEFINE_MTYPE(LIB, VRF_BITMAP, "VRF bit-map")
-DEFINE_MTYPE(LIB, IF_LINK_PARAMS, "Informational Link Parameters")
-DEFINE_MTYPE(LIB, LIB_NEXTHOP, "Nexthop" )
-
-DEFINE_MGROUP(BABELD, "babeld")
-DEFINE_MTYPE(BABELD, BABEL, "Babel structure")
-DEFINE_MTYPE(BABELD, BABEL_IF, "Babel interface")
-
-void lib_memory_init(void)
-{
- INIT_MGROUP(LIB);
- INIT_MTYPE( TMP);
- INIT_MTYPE( STRVEC);
- INIT_MTYPE( VECTOR);
- INIT_MTYPE( VECTOR_INDEX);
- INIT_MTYPE( LINK_LIST);
- INIT_MTYPE( LINK_NODE);
- INIT_MTYPE( THREAD);
- INIT_MTYPE( THREAD_MASTER);
- INIT_MTYPE( THREAD_STATS);
- INIT_MTYPE( VTY);
- INIT_MTYPE( VTY_OUT_BUF);
- INIT_MTYPE( VTY_HIST);
- INIT_MTYPE( IF);
- INIT_MTYPE( CONNECTED);
- INIT_MTYPE( CONNECTED_LABEL);
- INIT_MTYPE( BUFFER);
- INIT_MTYPE( BUFFER_DATA);
- INIT_MTYPE( STREAM);
- INIT_MTYPE( STREAM_DATA);
- INIT_MTYPE( STREAM_FIFO);
- INIT_MTYPE( PREFIX);
- INIT_MTYPE( PREFIX_IPV4);
- INIT_MTYPE( PREFIX_IPV6);
- INIT_MTYPE( HASH);
- INIT_MTYPE( HASH_BACKET);
- INIT_MTYPE( HASH_INDEX);
- INIT_MTYPE( ROUTE_TABLE);
- INIT_MTYPE( ROUTE_NODE);
- INIT_MTYPE( DISTRIBUTE);
- INIT_MTYPE( DISTRIBUTE_IFNAME);
- INIT_MTYPE( ACCESS_LIST);
- INIT_MTYPE( ACCESS_LIST_STR);
- INIT_MTYPE( ACCESS_FILTER);
- INIT_MTYPE( PREFIX_LIST);
- INIT_MTYPE( PREFIX_LIST_ENTRY);
- INIT_MTYPE( PREFIX_LIST_STR);
- INIT_MTYPE( ROUTE_MAP);
- INIT_MTYPE( ROUTE_MAP_NAME);
- INIT_MTYPE( ROUTE_MAP_INDEX);
- INIT_MTYPE( ROUTE_MAP_RULE);
- INIT_MTYPE( ROUTE_MAP_RULE_STR);
- INIT_MTYPE( ROUTE_MAP_COMPILED);
- INIT_MTYPE( CMD_TOKENS);
- INIT_MTYPE( KEY);
- INIT_MTYPE( KEYCHAIN);
- INIT_MTYPE( IF_RMAP);
- INIT_MTYPE( IF_RMAP_NAME);
- INIT_MTYPE( SOCKUNION);
- INIT_MTYPE( PRIVS);
- INIT_MTYPE( ZLOG);
- INIT_MTYPE( ZCLIENT);
- INIT_MTYPE( WORK_QUEUE);
- INIT_MTYPE( WORK_QUEUE_ITEM);
- INIT_MTYPE( WORK_QUEUE_NAME);
- INIT_MTYPE( PQUEUE);
- INIT_MTYPE( PQUEUE_DATA);
- INIT_MTYPE( HOST);
- INIT_MTYPE( VRF);
- INIT_MTYPE( VRF_NAME);
- INIT_MTYPE( VRF_BITMAP);
- INIT_MTYPE( IF_LINK_PARAMS);
- INIT_MTYPE( LIB_NEXTHOP);
-
- INIT_MGROUP(BABELD);
- INIT_MTYPE(BABEL);
- INIT_MTYPE(BABEL_IF);
-
-}
diff --git a/lib/lib_memory.h b/lib/lib_memory.h
deleted file mode 100644
index 50e305e24bd3..000000000000
--- a/lib/lib_memory.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/* lib memory type declarations
- *
- * Copyright (C) 2016 6WIND
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_LIB_MEMORY_H
-#define _QUAGGA_LIB_MEMORY_H
-
-#include "memory.h"
-
-DECLARE_MGROUP(LIB)
-DECLARE_MTYPE(TMP)
-DECLARE_MTYPE(STRVEC)
-DECLARE_MTYPE(VECTOR)
-DECLARE_MTYPE(VECTOR_INDEX)
-DECLARE_MTYPE(LINK_LIST)
-DECLARE_MTYPE(LINK_NODE)
-DECLARE_MTYPE(THREAD)
-DECLARE_MTYPE(THREAD_MASTER)
-DECLARE_MTYPE(THREAD_STATS)
-DECLARE_MTYPE(VTY)
-DECLARE_MTYPE(VTY_OUT_BUF)
-DECLARE_MTYPE(VTY_HIST)
-DECLARE_MTYPE(IF)
-DECLARE_MTYPE(CONNECTED)
-DECLARE_MTYPE(CONNECTED_LABEL)
-DECLARE_MTYPE(BUFFER)
-DECLARE_MTYPE(BUFFER_DATA)
-DECLARE_MTYPE(STREAM)
-DECLARE_MTYPE(STREAM_DATA)
-DECLARE_MTYPE(STREAM_FIFO)
-DECLARE_MTYPE(PREFIX)
-DECLARE_MTYPE(PREFIX_IPV4)
-DECLARE_MTYPE(PREFIX_IPV6)
-DECLARE_MTYPE(HASH)
-DECLARE_MTYPE(HASH_BACKET)
-DECLARE_MTYPE(HASH_INDEX)
-DECLARE_MTYPE(ROUTE_TABLE)
-DECLARE_MTYPE(ROUTE_NODE)
-DECLARE_MTYPE(DISTRIBUTE)
-DECLARE_MTYPE(DISTRIBUTE_IFNAME)
-DECLARE_MTYPE(ACCESS_LIST)
-DECLARE_MTYPE(ACCESS_LIST_STR)
-DECLARE_MTYPE(ACCESS_FILTER)
-DECLARE_MTYPE(PREFIX_LIST)
-DECLARE_MTYPE(PREFIX_LIST_ENTRY)
-DECLARE_MTYPE(PREFIX_LIST_STR)
-DECLARE_MTYPE(ROUTE_MAP)
-DECLARE_MTYPE(ROUTE_MAP_NAME)
-DECLARE_MTYPE(ROUTE_MAP_INDEX)
-DECLARE_MTYPE(ROUTE_MAP_RULE)
-DECLARE_MTYPE(ROUTE_MAP_RULE_STR)
-DECLARE_MTYPE(ROUTE_MAP_COMPILED)
-DECLARE_MTYPE(CMD_TOKENS)
-DECLARE_MTYPE(KEY)
-DECLARE_MTYPE(KEYCHAIN)
-DECLARE_MTYPE(IF_RMAP)
-DECLARE_MTYPE(IF_RMAP_NAME)
-DECLARE_MTYPE(SOCKUNION)
-DECLARE_MTYPE(PRIVS)
-DECLARE_MTYPE(ZLOG)
-DECLARE_MTYPE(ZCLIENT)
-DECLARE_MTYPE(WORK_QUEUE)
-DECLARE_MTYPE(WORK_QUEUE_ITEM)
-DECLARE_MTYPE(WORK_QUEUE_NAME)
-DECLARE_MTYPE(PQUEUE)
-DECLARE_MTYPE(PQUEUE_DATA)
-DECLARE_MTYPE(HOST)
-DECLARE_MTYPE(VRF)
-DECLARE_MTYPE(VRF_NAME)
-DECLARE_MTYPE(VRF_BITMAP)
-DECLARE_MTYPE(IF_LINK_PARAMS)
-DECLARE_MTYPE(LIB_NEXTHOP)
-
-DECLARE_MGROUP(BABELD)
-DECLARE_MTYPE(BABEL)
-DECLARE_MTYPE(BABEL_IF)
-
-extern void lib_memory_init(void);
-
-#endif /* _QUAGGA_LIB_MEMORY_H */
diff --git a/lib/lib_memory.txt b/lib/lib_memory.txt
new file mode 100644
index 000000000000..3b2a40fa3171
--- /dev/null
+++ b/lib/lib_memory.txt
@@ -0,0 +1,66 @@
+MGROUP(LIB, "libzebra")
+MTYPE(LIB, TMP, "Temporary memory")
+MTYPE(LIB, STRVEC, "String vector")
+MTYPE(LIB, VECTOR, "Vector")
+MTYPE(LIB, VECTOR_INDEX, "Vector index")
+MTYPE(LIB, LINK_LIST, "Link List")
+MTYPE(LIB, LINK_NODE, "Link Node")
+MTYPE(LIB, THREAD, "Thread")
+MTYPE(LIB, THREAD_MASTER, "Thread master")
+MTYPE(LIB, THREAD_STATS, "Thread stats")
+MTYPE(LIB, VTY, "VTY")
+MTYPE(LIB, VTY_OUT_BUF, "VTY output buffer")
+MTYPE(LIB, VTY_HIST, "VTY history")
+MTYPE(LIB, IF, "Interface")
+MTYPE(LIB, CONNECTED, "Connected")
+MTYPE(LIB, CONNECTED_LABEL, "Connected interface label")
+MTYPE(LIB, BUFFER, "Buffer")
+MTYPE(LIB, BUFFER_DATA, "Buffer data")
+MTYPE(LIB, STREAM, "Stream")
+MTYPE(LIB, STREAM_DATA, "Stream data")
+MTYPE(LIB, STREAM_FIFO, "Stream FIFO")
+MTYPE(LIB, PREFIX, "Prefix")
+MTYPE(LIB, PREFIX_IPV4, "Prefix IPv4")
+MTYPE(LIB, PREFIX_IPV6, "Prefix IPv6")
+MTYPE(LIB, HASH, "Hash")
+MTYPE(LIB, HASH_BACKET, "Hash Bucket")
+MTYPE(LIB, HASH_INDEX, "Hash Index")
+MTYPE(LIB, ROUTE_TABLE, "Route table")
+MTYPE(LIB, ROUTE_NODE, "Route node")
+MTYPE(LIB, DISTRIBUTE, "Distribute list")
+MTYPE(LIB, DISTRIBUTE_IFNAME, "Dist-list ifname")
+MTYPE(LIB, ACCESS_LIST, "Access List")
+MTYPE(LIB, ACCESS_LIST_STR, "Access List Str")
+MTYPE(LIB, ACCESS_FILTER, "Access Filter")
+MTYPE(LIB, PREFIX_LIST, "Prefix List")
+MTYPE(LIB, PREFIX_LIST_ENTRY, "Prefix List Entry")
+MTYPE(LIB, PREFIX_LIST_STR, "Prefix List Str")
+MTYPE(LIB, ROUTE_MAP, "Route map")
+MTYPE(LIB, ROUTE_MAP_NAME, "Route map name")
+MTYPE(LIB, ROUTE_MAP_INDEX, "Route map index")
+MTYPE(LIB, ROUTE_MAP_RULE, "Route map rule")
+MTYPE(LIB, ROUTE_MAP_RULE_STR, "Route map rule str")
+MTYPE(LIB, ROUTE_MAP_COMPILED, "Route map compiled")
+MTYPE(LIB, CMD_TOKENS, "Command desc")
+MTYPE(LIB, KEY, "Key")
+MTYPE(LIB, KEYCHAIN, "Key chain")
+MTYPE(LIB, IF_RMAP, "Interface route map")
+MTYPE(LIB, IF_RMAP_NAME, "I.f. route map name")
+MTYPE(LIB, SOCKUNION, "Socket union")
+MTYPE(LIB, PRIVS, "Privilege information")
+MTYPE(LIB, ZLOG, "Logging")
+MTYPE(LIB, ZCLIENT, "Zclient")
+MTYPE(LIB, WORK_QUEUE, "Work queue")
+MTYPE(LIB, WORK_QUEUE_ITEM, "Work queue item")
+MTYPE(LIB, WORK_QUEUE_NAME, "Work queue name string")
+MTYPE(LIB, PQUEUE, "Priority queue")
+MTYPE(LIB, PQUEUE_DATA, "Priority queue data")
+MTYPE(LIB, HOST, "host configuration")
+MTYPE(LIB, VRF, "VRF")
+MTYPE(LIB, VRF_NAME, "VRF name")
+MTYPE(LIB, VRF_BITMAP, "VRF bit-map")
+MTYPE(LIB, IF_LINK_PARAMS, "Informational Link Parameters" )
+MTYPE(LIB, LIB_NEXTHOP, "NextHop")
+MGROUP(BABELD, "babeld")
+MTYPE(BABELD, BABEL, "Babel structure")
+MTYPE(BABELD, BABEL_IF, "Babel interface")
diff --git a/memory_gen.sh b/memory_gen.sh
new file mode 100644
index 000000000000..7c9e7d985933
--- /dev/null
+++ b/memory_gen.sh
@@ -0,0 +1,154 @@
+#!/bin/bash
+# Copyright (C) 2016, 6WIND
+# converter of memory types and groups from txt file to .ch format
+# ** Script usage:
+# bash ../memory_gen.sh <prefix>
+#
+# the script must be executed at the place where .c and .h files have to be generated.
+# <prefix> generally stands for the prefix of the txt file to convert
+# eg if you wish to generate bgp memory files, then passing bgp as paramter will permit
+# to do the following: bgp_memory.txt file is taken as input, and bgp_memory.[ch] file will
+# be generated
+#
+# ** Script work:
+# 2 standard lines of txt input file look like below
+# MGROUP(BGPD, "bgpd")
+# MTYPE(BGPD, BGP, "BGP instance")
+# The script is declaring the above lines as mgroups and mtypes in header file
+# DECLARE_MGROUP(BGPD)
+# DECLARE_MGROUP(BGP)
+# The script is defining and initialising the 2 lines into .c file
+# DEFINE_MGROUP(BGPD, "bgpd")
+# DEFINE_MTYPE(BGPD, BGP, "BGP instance")
+# ...
+# INIT_MGROUP(BGPD);
+# INIT_MTYPE( BGP);
+
+## upper case
+i=`echo $1 | tr '[:lower:]' '[:upper:]'`
+# lower case
+j=`echo $1 | tr '[:upper:]' '[:lower:]'`
+txt_file=$j"_memory.txt"
+h_file=$j"_memory.h"
+c_file=$j"_memory.c"
+
+echo "======================================"
+echo "memory txt parser and .[ch] generator"
+echo "input txt file : "$txt_file
+echo "output [ch] files: "$c_file" and "$h_file
+echo ""
+
+rm $c_file 2>/dev/null
+rm $h_file 2>/dev/null
+
+echo "/*
+ * Memory type definitions. This file is generated by memtypes.sh to extract
+ * MTYPE_ .. information in order to autogenerate
+ * "$j"_memory.h and "$j"_memory.c.
+ */
+/* "$j" memory type declarations
+ * Copyright (C) 2016 6WIND
+ * This file is part of Quagga.
+ * Quagga is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * Quagga is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#ifndef _QUAGGA_"$i"_MEMORY_
+#define _QUAGGA_"$i"_MEMORY_
+
+#include \"memory.h\"
+" >> $h_file
+
+while read p; do
+ c=`echo $p | head -n1 | cut -d "(" -f1`
+ if [ "$c" != "MTYPE" -a "$c" != "MGROUP" ]
+ then
+ echo $p >> $h_file
+ continue
+ fi
+ if [[ "$c" = "MTYPE" ]]
+ then
+ d=`echo $p | head -n1 | cut -d "," -f2`
+ a="DECLARE_MTYPE("$d
+ else
+ a=`echo DECLARE_$p | head -n1 | cut -d "," -f1`
+ fi
+ b="$a)"
+ echo $b >> $h_file
+done <$txt_file
+
+echo "
+extern void "$j"_memory_init(void);
+
+#endif /* _QUAGGA_"$i"_MEMORY_ */" >> $h_file
+
+echo "/*
+ * Memory type definitions. This file is generated by memtypes.sh to extract
+ * MTYPE_ .. information in order to autogenerate
+ * "$j"_memory.h and "$j"_memory.c.
+ */
+/* "$j" memory type declarations
+ * Copyright (C) 2016 6WIND
+ * This file is part of Quagga.
+ * Quagga is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation; either version 2, or (at your option) any
+ * later version.
+ *
+ * Quagga is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Quagga; see the file COPYING. If not, write to the Free
+ * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ */
+
+#include \"zebra.h\"
+#include \""$j"_memory.h\"
+
+" >> $c_file
+
+while read p; do
+ c=`echo $p | head -n1 | cut -d "(" -f1`
+ if [ "$c" != "MTYPE" -a "$c" != "MGROUP" ]
+ then
+ continue
+ fi
+ echo DEFINE_$p >> $c_file
+done <$txt_file
+
+echo "
+void "$j"_memory_init(void)
+{" >> $c_file
+while read p; do
+ c=`echo $p | head -n1 | cut -d "(" -f1`
+ if [ "$c" != "MTYPE" -a "$c" != "MGROUP" ]
+ then
+ continue
+ fi
+ if [[ "$c" = "MTYPE" ]]
+ then
+ d=`echo $p | head -n1 | cut -d "," -f2`
+ a=" INIT_MTYPE("$d");"
+ else
+ a=`echo " "INIT_$p | head -n1 | cut -d "," -f1`");"
+ fi
+ echo $a >> $c_file
+done <$txt_file
+
+echo "}" >> $c_file
diff --git a/ospf6d/Makefile.am b/ospf6d/Makefile.am
index d988ae92b6de..a21aec01a843 100644
--- a/ospf6d/Makefile.am
+++ b/ospf6d/Makefile.am
@@ -25,10 +25,17 @@ noinst_HEADERS = \
ospf6_spf.h ospf6_proto.h ospf6_asbr.h ospf6_abr.h ospf6_snmp.h \
ospf6d.h

+ospf6_memory.h: $(srcdir)/ospf6_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh ospf6)
+
ospf6d_SOURCES = \
ospf6_main.c $(libospf6_a_SOURCES)

+BUILT_SOURCES = ospf6_memory.h ospf6_memory.c
+
ospf6d_LDADD = ../lib/libzebra.la @LIBCAP@

examplesdir = $(exampledir)
dist_examples_DATA = ospf6d.conf.sample
+
+EXTRA_DIST = ospf6_memory.txt ../memory_gen.sh
diff --git a/ospf6d/ospf6_memory.c b/ospf6d/ospf6_memory.c
deleted file mode 100644
index ad2c544431c2..000000000000
--- a/ospf6d/ospf6_memory.c
+++ /dev/null
@@ -1,68 +0,0 @@
-/* ospf6d memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "ospf6_memory.h"
-
-DEFINE_MGROUP(OSPF6D, "ospf6d")
-DEFINE_MTYPE(OSPF6D, OSPF6_TOP, "OSPF6 top")
-DEFINE_MTYPE(OSPF6D, OSPF6_AREA, "OSPF6 area")
-DEFINE_MTYPE(OSPF6D, OSPF6_IF, "OSPF6 interface")
-DEFINE_MTYPE(OSPF6D, OSPF6_NEIGHBOR, "OSPF6 neighbor")
-DEFINE_MTYPE(OSPF6D, OSPF6_ROUTE, "OSPF6 route")
-DEFINE_MTYPE(OSPF6D, OSPF6_PREFIX, "OSPF6 prefix")
-DEFINE_MTYPE(OSPF6D, OSPF6_MESSAGE, "OSPF6 message")
-DEFINE_MTYPE(OSPF6D, OSPF6_LSA, "OSPF6 LSA")
-DEFINE_MTYPE(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary")
-DEFINE_MTYPE(OSPF6D, OSPF6_LSDB, "OSPF6 LSA database")
-DEFINE_MTYPE(OSPF6D, OSPF6_VERTEX, "OSPF6 vertex")
-DEFINE_MTYPE(OSPF6D, OSPF6_SPFTREE, "OSPF6 SPF tree")
-DEFINE_MTYPE(OSPF6D, OSPF6_NEXTHOP, "OSPF6 nexthop")
-DEFINE_MTYPE(OSPF6D, OSPF6_EXTERNAL_INFO,"OSPF6 ext. info")
-DEFINE_MTYPE(OSPF6D, OSPF6_OTHER, "OSPF6 other")
-DEFINE_MTYPE(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance")
-
-void ospf6_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(OSPF6D);
- INIT_MTYPE(OSPF6_TOP);
- INIT_MTYPE(OSPF6_AREA);
- INIT_MTYPE(OSPF6_IF);
- INIT_MTYPE(OSPF6_NEIGHBOR);
- INIT_MTYPE(OSPF6_ROUTE);
- INIT_MTYPE(OSPF6_PREFIX);
- INIT_MTYPE(OSPF6_MESSAGE);
- INIT_MTYPE(OSPF6_LSA);
- INIT_MTYPE(OSPF6_LSA_SUMMARY);
- INIT_MTYPE(OSPF6_LSDB);
- INIT_MTYPE(OSPF6_VERTEX);
- INIT_MTYPE(OSPF6_SPFTREE);
- INIT_MTYPE(OSPF6_NEXTHOP);
- INIT_MTYPE(OSPF6_EXTERNAL_INFO);
- INIT_MTYPE(OSPF6_OTHER);
- INIT_MTYPE(OSPF6_DISTANCE);
-}
diff --git a/ospf6d/ospf6_memory.h b/ospf6d/ospf6_memory.h
deleted file mode 100644
index a62590ac81d1..000000000000
--- a/ospf6d/ospf6_memory.h
+++ /dev/null
@@ -1,49 +0,0 @@
-/* ospf6d memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_OSPF6_MEMORY_H
-#define _QUAGGA_OSPF6_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(OSPF6D)
-DECLARE_MTYPE(OSPF6_TOP)
-DECLARE_MTYPE(OSPF6_AREA)
-DECLARE_MTYPE(OSPF6_IF)
-DECLARE_MTYPE(OSPF6_NEIGHBOR)
-DECLARE_MTYPE(OSPF6_ROUTE)
-DECLARE_MTYPE(OSPF6_PREFIX)
-DECLARE_MTYPE(OSPF6_MESSAGE)
-DECLARE_MTYPE(OSPF6_LSA)
-DECLARE_MTYPE(OSPF6_LSA_SUMMARY)
-DECLARE_MTYPE(OSPF6_LSDB)
-DECLARE_MTYPE(OSPF6_VERTEX)
-DECLARE_MTYPE(OSPF6_SPFTREE)
-DECLARE_MTYPE(OSPF6_NEXTHOP)
-DECLARE_MTYPE(OSPF6_EXTERNAL_INFO)
-DECLARE_MTYPE(OSPF6_OTHER)
-DECLARE_MTYPE(OSPF6_DISTANCE)
-
-extern void ospf6_memory_init(void);
-
-#endif /* _QUAGGA_OSPF6_MEMORY_H */
diff --git a/ospf6d/ospf6_memory.txt b/ospf6d/ospf6_memory.txt
new file mode 100644
index 000000000000..1ed97c7f8b33
--- /dev/null
+++ b/ospf6d/ospf6_memory.txt
@@ -0,0 +1,19 @@
+#include "lib_memory.h"
+
+MGROUP(OSPF6D, "ospf6d")
+MTYPE(OSPF6D, OSPF6_TOP, "OSPF6 top")
+MTYPE(OSPF6D, OSPF6_AREA, "OSPF6 area")
+MTYPE(OSPF6D, OSPF6_IF, "OSPF6 interface")
+MTYPE(OSPF6D, OSPF6_NEIGHBOR, "OSPF6 neighbor")
+MTYPE(OSPF6D, OSPF6_ROUTE, "OSPF6 route")
+MTYPE(OSPF6D, OSPF6_PREFIX, "OSPF6 prefix")
+MTYPE(OSPF6D, OSPF6_MESSAGE, "OSPF6 message")
+MTYPE(OSPF6D, OSPF6_LSA, "OSPF6 LSA")
+MTYPE(OSPF6D, OSPF6_LSA_SUMMARY, "OSPF6 LSA summary")
+MTYPE(OSPF6D, OSPF6_LSDB, "OSPF6 LSA database")
+MTYPE(OSPF6D, OSPF6_VERTEX, "OSPF6 vertex")
+MTYPE(OSPF6D, OSPF6_SPFTREE, "OSPF6 SPF tree")
+MTYPE(OSPF6D, OSPF6_NEXTHOP, "OSPF6 nexthop")
+MTYPE(OSPF6D, OSPF6_EXTERNAL_INFO,"OSPF6 ext. info")
+MTYPE(OSPF6D, OSPF6_OTHER, "OSPF6 other")
+MTYPE(OSPF6D, OSPF6_DISTANCE, "OSPF6 distance")
diff --git a/ospfclient/ospf_apiclient.c b/ospfclient/ospf_apiclient.c
index c77322a7dcf5..799d63f0c203 100644
--- a/ospfclient/ospf_apiclient.c
+++ b/ospfclient/ospf_apiclient.c
@@ -54,9 +54,6 @@ DEFINE_MTYPE_STATIC(OSPFD, OSPF_APICLIENT, "OSPF-API client")
/* Backlog for listen */
#define BACKLOG 5

-DEFINE_MGROUP(OSPFCLIENT, "ospfclient")
-DEFINE_MTYPE_STATIC(OSPFCLIENT, OSPF_APICLIENT, "OSPF API client")
-
/* -----------------------------------------------------------
* Forward declarations
* -----------------------------------------------------------
diff --git a/ospfd/Makefile.am b/ospfd/Makefile.am
index d8b6a3028812..95968f7a2d5f 100644
--- a/ospfd/Makefile.am
+++ b/ospfd/Makefile.am
@@ -31,11 +31,17 @@ noinst_HEADERS = \
ospf_flood.h ospf_snmp.h ospf_te.h ospf_ri.h ospf_vty.h ospf_apiserver.h \
ospf_memory.h

+ospf_memory.h: $(srcdir)/ospf_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh ospf)
+
ospfd_SOURCES = ospf_main.c

+BUILT_SOURCES = ospf_memory.h ospf_memory.c
+
ospfd_LDADD = libospf.la ../lib/libzebra.la @LIBCAP@ @LIBM@

-EXTRA_DIST = OSPF-MIB.txt OSPF-TRAP-MIB.txt ChangeLog.opaque.txt
+EXTRA_DIST = OSPF-MIB.txt OSPF-TRAP-MIB.txt ChangeLog.opaque.txt \
+ ospf_memory.txt ../memory_gen.sh

examplesdir = $(exampledir)
dist_examples_DATA = ospfd.conf.sample
diff --git a/ospfd/ospf_memory.c b/ospfd/ospf_memory.c
deleted file mode 100644
index d489057873d2..000000000000
--- a/ospfd/ospf_memory.c
+++ /dev/null
@@ -1,92 +0,0 @@
-/* ospfd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "ospf_memory.h"
-
-DEFINE_MGROUP(OSPFD, "ospfd")
-DEFINE_MTYPE(OSPFD, OSPF_TOP, "OSPF top")
-DEFINE_MTYPE(OSPFD, OSPF_AREA, "OSPF area")
-DEFINE_MTYPE(OSPFD, OSPF_AREA_RANGE, "OSPF area range")
-DEFINE_MTYPE(OSPFD, OSPF_NETWORK, "OSPF network")
-DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR_STATIC, "OSPF static nbr")
-DEFINE_MTYPE(OSPFD, OSPF_IF, "OSPF interface")
-DEFINE_MTYPE(OSPFD, OSPF_NEIGHBOR, "OSPF neighbor")
-DEFINE_MTYPE(OSPFD, OSPF_ROUTE, "OSPF route")
-DEFINE_MTYPE(OSPFD, OSPF_TMP, "OSPF tmp mem")
-DEFINE_MTYPE(OSPFD, OSPF_LSA, "OSPF LSA")
-DEFINE_MTYPE(OSPFD, OSPF_LSA_DATA, "OSPF LSA data")
-DEFINE_MTYPE(OSPFD, OSPF_LSDB, "OSPF LSDB")
-DEFINE_MTYPE(OSPFD, OSPF_PACKET, "OSPF packet")
-DEFINE_MTYPE(OSPFD, OSPF_FIFO, "OSPF FIFO queue")
-DEFINE_MTYPE(OSPFD, OSPF_VERTEX, "OSPF vertex")
-DEFINE_MTYPE(OSPFD, OSPF_VERTEX_PARENT, "OSPF vertex parent")
-DEFINE_MTYPE(OSPFD, OSPF_NEXTHOP, "OSPF nexthop")
-DEFINE_MTYPE(OSPFD, OSPF_PATH, "OSPF path")
-DEFINE_MTYPE(OSPFD, OSPF_VL_DATA, "OSPF VL data")
-DEFINE_MTYPE(OSPFD, OSPF_CRYPT_KEY, "OSPF crypt key")
-DEFINE_MTYPE(OSPFD, OSPF_EXTERNAL_INFO, "OSPF ext. info")
-DEFINE_MTYPE(OSPFD, OSPF_DISTANCE, "OSPF distance")
-DEFINE_MTYPE(OSPFD, OSPF_IF_INFO, "OSPF if info")
-DEFINE_MTYPE(OSPFD, OSPF_IF_PARAMS, "OSPF if params")
-DEFINE_MTYPE(OSPFD, OSPF_MESSAGE, "OSPF message")
-DEFINE_MTYPE(OSPFD, OSPF_MPLS_TE, "OSPF MPLS TE")
-DEFINE_MTYPE(OSPFD, OSPF_PCE_PARAMS, "OSPF PCS Params")
-
-
-void ospf_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(OSPFD);
- INIT_MTYPE(OSPF_TOP);
- INIT_MTYPE(OSPF_AREA);
- INIT_MTYPE(OSPF_AREA_RANGE);
- INIT_MTYPE(OSPF_NETWORK);
- INIT_MTYPE(OSPF_NEIGHBOR_STATIC);
- INIT_MTYPE(OSPF_IF);
- INIT_MTYPE(OSPF_NEIGHBOR);
- INIT_MTYPE(OSPF_ROUTE);
- INIT_MTYPE(OSPF_TMP);
- INIT_MTYPE(OSPF_LSA);
- INIT_MTYPE(OSPF_LSA_DATA);
- INIT_MTYPE(OSPF_LSDB);
- INIT_MTYPE(OSPF_PACKET);
- INIT_MTYPE(OSPF_FIFO);
- INIT_MTYPE(OSPF_VERTEX);
- INIT_MTYPE(OSPF_VERTEX_PARENT);
- INIT_MTYPE(OSPF_NEXTHOP);
- INIT_MTYPE(OSPF_PATH);
- INIT_MTYPE(OSPF_VL_DATA);
- INIT_MTYPE(OSPF_CRYPT_KEY);
- INIT_MTYPE(OSPF_EXTERNAL_INFO);
- INIT_MTYPE(OSPF_DISTANCE);
- INIT_MTYPE(OSPF_IF_INFO);
- INIT_MTYPE(OSPF_IF_PARAMS);
- INIT_MTYPE(OSPF_MESSAGE);
- INIT_MTYPE(OSPF_MPLS_TE);
- INIT_MTYPE(OSPF_PCE_PARAMS);
-}
-
diff --git a/ospfd/ospf_memory.h b/ospfd/ospf_memory.h
deleted file mode 100644
index 81bcd4865fa2..000000000000
--- a/ospfd/ospf_memory.h
+++ /dev/null
@@ -1,59 +0,0 @@
-/* ospfd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_OSPF_MEMORY_H
-#define _QUAGGA_OSPF_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(OSPFD)
-DECLARE_MTYPE(OSPF_TOP)
-DECLARE_MTYPE(OSPF_AREA)
-DECLARE_MTYPE(OSPF_AREA_RANGE)
-DECLARE_MTYPE(OSPF_NETWORK)
-DECLARE_MTYPE(OSPF_NEIGHBOR_STATIC)
-DECLARE_MTYPE(OSPF_IF)
-DECLARE_MTYPE(OSPF_NEIGHBOR)
-DECLARE_MTYPE(OSPF_ROUTE)
-DECLARE_MTYPE(OSPF_TMP)
-DECLARE_MTYPE(OSPF_LSA)
-DECLARE_MTYPE(OSPF_LSA_DATA)
-DECLARE_MTYPE(OSPF_LSDB)
-DECLARE_MTYPE(OSPF_PACKET)
-DECLARE_MTYPE(OSPF_FIFO)
-DECLARE_MTYPE(OSPF_VERTEX)
-DECLARE_MTYPE(OSPF_VERTEX_PARENT)
-DECLARE_MTYPE(OSPF_NEXTHOP)
-DECLARE_MTYPE(OSPF_PATH)
-DECLARE_MTYPE(OSPF_VL_DATA)
-DECLARE_MTYPE(OSPF_CRYPT_KEY)
-DECLARE_MTYPE(OSPF_EXTERNAL_INFO)
-DECLARE_MTYPE(OSPF_DISTANCE)
-DECLARE_MTYPE(OSPF_IF_INFO)
-DECLARE_MTYPE(OSPF_IF_PARAMS)
-DECLARE_MTYPE(OSPF_MESSAGE)
-DECLARE_MTYPE(OSPF_MPLS_TE)
-DECLARE_MTYPE(OSPF_PCE_PARAMS)
-
-extern void ospf_memory_init(void);
-#endif /* _QUAGGA_OSPF_MEMORY_H */
diff --git a/ospfd/ospf_memory.txt b/ospfd/ospf_memory.txt
new file mode 100644
index 000000000000..ae2aae41757c
--- /dev/null
+++ b/ospfd/ospf_memory.txt
@@ -0,0 +1,30 @@
+#include "lib_memory.h"
+
+MGROUP(OSPFD, "ospfd")
+MTYPE(OSPFD, OSPF_TOP, "OSPF top")
+MTYPE(OSPFD, OSPF_AREA, "OSPF area")
+MTYPE(OSPFD, OSPF_AREA_RANGE, "OSPF area range")
+MTYPE(OSPFD, OSPF_NETWORK, "OSPF network")
+MTYPE(OSPFD, OSPF_NEIGHBOR_STATIC, "OSPF static nbr")
+MTYPE(OSPFD, OSPF_IF, "OSPF interface")
+MTYPE(OSPFD, OSPF_NEIGHBOR, "OSPF neighbor")
+MTYPE(OSPFD, OSPF_ROUTE, "OSPF route")
+MTYPE(OSPFD, OSPF_TMP, "OSPF tmp mem")
+MTYPE(OSPFD, OSPF_LSA, "OSPF LSA")
+MTYPE(OSPFD, OSPF_LSA_DATA, "OSPF LSA data")
+MTYPE(OSPFD, OSPF_LSDB, "OSPF LSDB")
+MTYPE(OSPFD, OSPF_PACKET, "OSPF packet")
+MTYPE(OSPFD, OSPF_FIFO, "OSPF FIFO queue")
+MTYPE(OSPFD, OSPF_VERTEX, "OSPF vertex")
+MTYPE(OSPFD, OSPF_VERTEX_PARENT, "OSPF vertex parent")
+MTYPE(OSPFD, OSPF_NEXTHOP, "OSPF nexthop")
+MTYPE(OSPFD, OSPF_PATH, "OSPF path")
+MTYPE(OSPFD, OSPF_VL_DATA, "OSPF VL data")
+MTYPE(OSPFD, OSPF_CRYPT_KEY, "OSPF crypt key")
+MTYPE(OSPFD, OSPF_EXTERNAL_INFO, "OSPF ext. info")
+MTYPE(OSPFD, OSPF_DISTANCE, "OSPF distance")
+MTYPE(OSPFD, OSPF_IF_INFO, "OSPF if info")
+MTYPE(OSPFD, OSPF_IF_PARAMS, "OSPF if params")
+MTYPE(OSPFD, OSPF_MESSAGE, "OSPF message")
+MTYPE(OSPFD, OSPF_MPLS_TE, "OSPF MPLS TE")
+MTYPE(OSPFD, OSPF_PCE_PARAMS, "OSPF PCS Params")
diff --git a/pimd/Makefile.am b/pimd/Makefile.am
index 037aa571df47..b45f9ba8e78c 100644
--- a/pimd/Makefile.am
+++ b/pimd/Makefile.am
@@ -65,9 +65,14 @@ noinst_HEADERS = \
pim_msg.h pim_upstream.h pim_rpf.h pim_macro.h \
pim_igmp_join.h pim_ssmpingd.h pim_int.h pim_static.h

+pim_memory.h: $(srcdir)/pim_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh pim)
+
pimd_SOURCES = \
pim_main.c $(libpim_a_SOURCES)

+BUILT_SOURCES = pim_memory.h pim_memory.c
+
test_igmpv3_join_SOURCES = \
test_igmpv3_join.c pim_igmp_join.c

@@ -75,3 +80,5 @@ pimd_LDADD = ../lib/libzebra.la @LIBCAP@

examplesdir = $(exampledir)
dist_examples_DATA = pimd.conf.sample
+
+EXTRA_DIST = pim_memory.txt ../memory_gen.sh
diff --git a/pimd/pim_memory.c b/pimd/pim_memory.c
deleted file mode 100644
index e84f5df19c97..000000000000
--- a/pimd/pim_memory.c
+++ /dev/null
@@ -1,58 +0,0 @@
-/* pimd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "pim_memory.h"
-
-DEFINE_MGROUP(PIMD, "pimd")
-DEFINE_MTYPE(PIMD, PIM_CHANNEL_OIL, "PIM SSM (S,G) channel OIL")
-DEFINE_MTYPE(PIMD, PIM_INTERFACE, "PIM interface")
-DEFINE_MTYPE(PIMD, PIM_IGMP_JOIN, "PIM interface IGMP static join")
-DEFINE_MTYPE(PIMD, PIM_IGMP_SOCKET, "PIM interface IGMP socket")
-DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP, "PIM interface IGMP group")
-DEFINE_MTYPE(PIMD, PIM_IGMP_GROUP_SOURCE, "PIM interface IGMP source")
-DEFINE_MTYPE(PIMD, PIM_NEIGHBOR, "PIM interface neighbor")
-DEFINE_MTYPE(PIMD, PIM_IFCHANNEL, "PIM interface (S,G) state")
-DEFINE_MTYPE(PIMD, PIM_UPSTREAM, "PIM upstream (S,G) state")
-DEFINE_MTYPE(PIMD, PIM_SSMPINGD, "PIM sspimgd socket")
-DEFINE_MTYPE(PIMD, PIM_STATIC_ROUTE, "PIM Static Route")
-
-void pim_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(PIMD);
- INIT_MTYPE(PIM_CHANNEL_OIL);
- INIT_MTYPE(PIM_INTERFACE);
- INIT_MTYPE(PIM_IGMP_JOIN);
- INIT_MTYPE(PIM_IGMP_SOCKET);
- INIT_MTYPE(PIM_IGMP_GROUP);
- INIT_MTYPE(PIM_IGMP_GROUP_SOURCE);
- INIT_MTYPE(PIM_NEIGHBOR);
- INIT_MTYPE(PIM_IFCHANNEL);
- INIT_MTYPE(PIM_UPSTREAM);
- INIT_MTYPE(PIM_SSMPINGD);
- INIT_MTYPE(PIM_STATIC_ROUTE);
-}
diff --git a/pimd/pim_memory.h b/pimd/pim_memory.h
deleted file mode 100644
index 53591b0900ae..000000000000
--- a/pimd/pim_memory.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* pimd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_PIM_MEMORY_H
-#define _QUAGGA_PIM_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(PIMD)
-DECLARE_MTYPE(PIM_CHANNEL_OIL)
-DECLARE_MTYPE(PIM_INTERFACE)
-DECLARE_MTYPE(PIM_IGMP_JOIN)
-DECLARE_MTYPE(PIM_IGMP_SOCKET)
-DECLARE_MTYPE(PIM_IGMP_GROUP)
-DECLARE_MTYPE(PIM_IGMP_GROUP_SOURCE)
-DECLARE_MTYPE(PIM_NEIGHBOR)
-DECLARE_MTYPE(PIM_IFCHANNEL)
-DECLARE_MTYPE(PIM_UPSTREAM)
-DECLARE_MTYPE(PIM_SSMPINGD)
-DECLARE_MTYPE(PIM_STATIC_ROUTE)
-
-extern void pim_memory_init(void);
-
-#endif /* _QUAGGA_PIM_MEMORY_H */
diff --git a/pimd/pim_memory.txt b/pimd/pim_memory.txt
new file mode 100644
index 000000000000..fea2c3e1ae82
--- /dev/null
+++ b/pimd/pim_memory.txt
@@ -0,0 +1,14 @@
+#include "lib_memory.h"
+
+MGROUP(PIMD, "pimd")
+MTYPE(PIMD, PIM_CHANNEL_OIL, "PIM SSM (S,G) channel OIL")
+MTYPE(PIMD, PIM_INTERFACE, "PIM interface")
+MTYPE(PIMD, PIM_IGMP_JOIN, "PIM interface IGMP static join")
+MTYPE(PIMD, PIM_IGMP_SOCKET, "PIM interface IGMP socket")
+MTYPE(PIMD, PIM_IGMP_GROUP, "PIM interface IGMP group")
+MTYPE(PIMD, PIM_IGMP_GROUP_SOURCE, "PIM interface IGMP source")
+MTYPE(PIMD, PIM_NEIGHBOR, "PIM interface neighbor")
+MTYPE(PIMD, PIM_IFCHANNEL, "PIM interface (S,G) state")
+MTYPE(PIMD, PIM_UPSTREAM, "PIM upstream (S,G) state")
+MTYPE(PIMD, PIM_SSMPINGD, "PIM sspimgd socket")
+MTYPE(PIMD, PIM_STATIC_ROUTE, "PIM Static Route")
diff --git a/ripd/Makefile.am b/ripd/Makefile.am
index e7073a79026b..6b326181c2eb 100644
--- a/ripd/Makefile.am
+++ b/ripd/Makefile.am
@@ -18,13 +18,19 @@ noinst_HEADERS = \
rip_memory.h \
ripd.h rip_debug.h rip_interface.h

+rip_memory.h: $(srcdir)/rip_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh rip)
+
ripd_SOURCES = \
rip_main.c $(librip_a_SOURCES)

+BUILT_SOURCES = rip_memory.h rip_memory.c
+
ripd_LDADD = ../lib/libzebra.la @LIBCAP@

examplesdir = $(exampledir)
dist_examples_DATA = ripd.conf.sample

-EXTRA_DIST = RIPv2-MIB.txt
+EXTRA_DIST = RIPv2-MIB.txt rip_memory.txt ../memory_gen.sh
+

diff --git a/ripd/rip_memory.c b/ripd/rip_memory.c
deleted file mode 100644
index 259a85ae4f27..000000000000
--- a/ripd/rip_memory.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ripd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "rip_memory.h"
-
-DEFINE_MGROUP(RIPD, "ripd")
-DEFINE_MTYPE(RIPD, RIP, "RIP structure")
-DEFINE_MTYPE(RIPD, RIP_INFO, "RIP route info")
-DEFINE_MTYPE(RIPD, RIP_INTERFACE, "RIP interface")
-DEFINE_MTYPE(RIPD, RIP_PEER, "RIP peer")
-DEFINE_MTYPE(RIPD, RIP_OFFSET_LIST, "RIP offset list")
-DEFINE_MTYPE(RIPD, RIP_DISTANCE, "RIP distance")
-
-void rip_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(RIPD);
- INIT_MTYPE(RIP);
- INIT_MTYPE(RIP_INFO);
- INIT_MTYPE(RIP_INTERFACE);
- INIT_MTYPE(RIP_PEER);
- INIT_MTYPE(RIP_OFFSET_LIST);
- INIT_MTYPE(RIP_DISTANCE);
-}
diff --git a/ripd/rip_memory.h b/ripd/rip_memory.h
deleted file mode 100644
index 9544602bbadb..000000000000
--- a/ripd/rip_memory.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ripd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_RIP_MEMORY_H
-#define _QUAGGA_RIP_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(RIPD)
-DECLARE_MTYPE(RIP)
-DECLARE_MTYPE(RIP_INFO)
-DECLARE_MTYPE(RIP_INTERFACE)
-DECLARE_MTYPE(RIP_PEER)
-DECLARE_MTYPE(RIP_OFFSET_LIST)
-DECLARE_MTYPE(RIP_DISTANCE)
-
-extern void rip_memory_init(void);
-
-#endif /* _QUAGGA_RIP_MEMORY_H */
diff --git a/ripd/rip_memory.txt b/ripd/rip_memory.txt
new file mode 100644
index 000000000000..9b0b75f2fc8f
--- /dev/null
+++ b/ripd/rip_memory.txt
@@ -0,0 +1,9 @@
+#include "lib_memory.h"
+
+MGROUP(RIPD, "ripd")
+MTYPE(RIPD, RIP, "RIP structure")
+MTYPE(RIPD, RIP_INFO, "RIP route info")
+MTYPE(RIPD, RIP_INTERFACE, "RIP interface")
+MTYPE(RIPD, RIP_PEER, "RIP peer")
+MTYPE(RIPD, RIP_OFFSET_LIST, "RIP offset list")
+MTYPE(RIPD, RIP_DISTANCE, "RIP distance")
diff --git a/ripngd/Makefile.am b/ripngd/Makefile.am
index c08e58a90c66..7ca38bb6249f 100644
--- a/ripngd/Makefile.am
+++ b/ripngd/Makefile.am
@@ -18,11 +18,17 @@ noinst_HEADERS = \
ripng_memory.h \
ripng_debug.h ripng_route.h ripngd.h ripng_nexthop.h

+ripng_memory.h: $(srcdir)/ripng_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh ripng)
+
ripngd_SOURCES = \
ripng_main.c $(libripng_a_SOURCES)

+BUILT_SOURCES = ripng_memory.h ripng_memory.c
+
ripngd_LDADD = ../lib/libzebra.la @LIBCAP@

examplesdir = $(exampledir)
dist_examples_DATA = ripngd.conf.sample

+EXTRA_DIST = ripng_memory.txt ../memory_gen.sh
diff --git a/ripngd/ripng_memory.c b/ripngd/ripng_memory.c
deleted file mode 100644
index e1e60c748a01..000000000000
--- a/ripngd/ripng_memory.c
+++ /dev/null
@@ -1,48 +0,0 @@
-/* ripngd memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "ripng_memory.h"
-
-DEFINE_MGROUP(RIPNGD, "ripngd")
-DEFINE_MTYPE(RIPNGD, RIPNG, "RIPng structure")
-DEFINE_MTYPE(RIPNGD, RIPNG_ROUTE, "RIPng route info")
-DEFINE_MTYPE(RIPNGD, RIPNG_AGGREGATE, "RIPng aggregate")
-DEFINE_MTYPE(RIPNGD, RIPNG_PEER, "RIPng peer")
-DEFINE_MTYPE(RIPNGD, RIPNG_OFFSET_LIST, "RIPng offset lst")
-DEFINE_MTYPE(RIPNGD, RIPNG_RTE_DATA, "RIPng rte data")
-
-void ripng_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(RIPNGD);
- INIT_MTYPE(RIPNG);
- INIT_MTYPE(RIPNG_ROUTE);
- INIT_MTYPE(RIPNG_AGGREGATE);
- INIT_MTYPE(RIPNG_PEER);
- INIT_MTYPE(RIPNG_OFFSET_LIST);
- INIT_MTYPE(RIPNG_RTE_DATA);
-}
diff --git a/ripngd/ripng_memory.h b/ripngd/ripng_memory.h
deleted file mode 100644
index 448125753f8a..000000000000
--- a/ripngd/ripng_memory.h
+++ /dev/null
@@ -1,39 +0,0 @@
-/* ripngd memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_RIPNG_MEMORY_H
-#define _QUAGGA_RIPNG_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(RIPNGD)
-DECLARE_MTYPE(RIPNG)
-DECLARE_MTYPE(RIPNG_ROUTE)
-DECLARE_MTYPE(RIPNG_AGGREGATE)
-DECLARE_MTYPE(RIPNG_PEER)
-DECLARE_MTYPE(RIPNG_OFFSET_LIST)
-DECLARE_MTYPE(RIPNG_RTE_DATA)
-
-extern void ripng_memory_init(void);
-
-#endif /* _QUAGGA_RIPNG_MEMORY_H */
diff --git a/ripngd/ripng_memory.txt b/ripngd/ripng_memory.txt
new file mode 100644
index 000000000000..e80ac61823e6
--- /dev/null
+++ b/ripngd/ripng_memory.txt
@@ -0,0 +1,9 @@
+#include "lib_memory.h"
+
+MGROUP(RIPNGD, "ripngd")
+MTYPE(RIPNGD, RIPNG, "RIPng structure")
+MTYPE(RIPNGD, RIPNG_ROUTE, "RIPng route info")
+MTYPE(RIPNGD, RIPNG_AGGREGATE, "RIPng aggregate")
+MTYPE(RIPNGD, RIPNG_PEER, "RIPng peer")
+MTYPE(RIPNGD, RIPNG_OFFSET_LIST, "RIPng offset lst")
+MTYPE(RIPNGD, RIPNG_RTE_DATA, "RIPng rte data")
diff --git a/zebra/Makefile.am b/zebra/Makefile.am
index fc09aebb7b42..6321871a1514 100644
--- a/zebra/Makefile.am
+++ b/zebra/Makefile.am
@@ -57,6 +57,11 @@ noinst_HEADERS = \
rt_netlink.h zebra_fpm.h zebra_fpm_private.h \
ioctl_solaris.h zebra_rnh.h

+zebra_memory.h: $(srcdir)/zebra_memory.txt $(srcdir)/../memory_gen.sh
+ (bash $(srcdir)/../memory_gen.sh zebra)
+
+BUILT_SOURCES = zebra_memory.h zebra_memory.c
+
zebra_LDADD = $(otherobj) ../lib/libzebra.la $(LIBCAP) $(Q_FPM_PB_CLIENT_LDOPTS)

testzebra_LDADD = ../lib/libzebra.la $(LIBCAP)
@@ -69,7 +74,8 @@ EXTRA_DIST = if_ioctl.c if_ioctl_solaris.c if_netlink.c \
rt_socket.c rtread_netlink.c rtread_sysctl.c \
rtread_getmsg.c kernel_socket.c kernel_netlink.c \
ioctl.c ioctl_solaris.c \
- GNOME-SMI GNOME-PRODUCT-ZEBRA-MIB
+ GNOME-SMI GNOME-PRODUCT-ZEBRA-MIB \
+ zebra_memory.txt ../memory_gen.sh

client : client_main.o ../lib/libzebra.la
$(CC) -g -o client client_main.o ../liblzebra.la $(LIBS) $(LIB_IPV6)
diff --git a/zebra/zebra_memory.c b/zebra/zebra_memory.c
deleted file mode 100644
index a6683f143077..000000000000
--- a/zebra/zebra_memory.c
+++ /dev/null
@@ -1,56 +0,0 @@
-/* zebra memory type definitions
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include "zebra_memory.h"
-
-DEFINE_MGROUP(ZEBRA, "zebra")
-DEFINE_MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix")
-DEFINE_MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
-DEFINE_MTYPE(ZEBRA, NEXTHOP, "Nexthop")
-DEFINE_MTYPE(ZEBRA, RIB, "RIB")
-DEFINE_MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue")
-DEFINE_MTYPE(ZEBRA, STATIC_ROUTE, "Static route")
-DEFINE_MTYPE(ZEBRA, RIB_DEST, "RIB destination")
-DEFINE_MTYPE(ZEBRA, RIB_TABLE_INFO, "RIB table info")
-DEFINE_MTYPE(ZEBRA, NETLINK_NAME, "Netlink name")
-DEFINE_MTYPE(ZEBRA, RNH, "RNH")
-
-void zebra_memory_init(void)
-{
- lib_memory_init();
-
- INIT_MGROUP(ZEBRA);
- INIT_MTYPE(RTADV_PREFIX);
- INIT_MTYPE(ZEBRA_VRF);
- INIT_MTYPE(NEXTHOP);
- INIT_MTYPE(RIB);
- INIT_MTYPE(RIB_QUEUE);
- INIT_MTYPE(STATIC_ROUTE);
- INIT_MTYPE(RIB_DEST);
- INIT_MTYPE(RIB_TABLE_INFO);
- INIT_MTYPE(NETLINK_NAME);
- INIT_MTYPE(RNH);
-}
diff --git a/zebra/zebra_memory.h b/zebra/zebra_memory.h
deleted file mode 100644
index 9cd989a00c75..000000000000
--- a/zebra/zebra_memory.h
+++ /dev/null
@@ -1,43 +0,0 @@
-/* zebra memory type declarations
- *
- * Copyright (C) 2015 David Lamparter
- *
- * This file is part of Quagga.
- *
- * Quagga is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2, or (at your option) any
- * later version.
- *
- * Quagga is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with Quagga; see the file COPYING. If not, write to the Free
- * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
- * 02111-1307, USA.
- */
-
-#ifndef _QUAGGA_ZEBRA_MEMORY_H
-#define _QUAGGA_ZEBRA_MEMORY_H
-
-#include "memory.h"
-#include "lib_memory.h"
-
-DECLARE_MGROUP(ZEBRA)
-DECLARE_MTYPE(RTADV_PREFIX)
-DECLARE_MTYPE(ZEBRA_VRF)
-DECLARE_MTYPE(NEXTHOP)
-DECLARE_MTYPE(RIB)
-DECLARE_MTYPE(RIB_QUEUE)
-DECLARE_MTYPE(STATIC_ROUTE)
-DECLARE_MTYPE(RIB_DEST)
-DECLARE_MTYPE(RIB_TABLE_INFO)
-DECLARE_MTYPE(NETLINK_NAME)
-DECLARE_MTYPE(RNH)
-
-extern void zebra_memory_init(void);
-
-#endif /* _QUAGGA_ZEBRA_MEMORY_H */
diff --git a/zebra/zebra_memory.txt b/zebra/zebra_memory.txt
new file mode 100644
index 000000000000..2d9c65dfb8b4
--- /dev/null
+++ b/zebra/zebra_memory.txt
@@ -0,0 +1,14 @@
+#include "lib_memory.h"
+
+MGROUP(ZEBRA, "zebra")
+MTYPE(ZEBRA, RTADV_PREFIX, "Router Advertisement Prefix")
+MTYPE(ZEBRA, ZEBRA_VRF, "ZEBRA VRF")
+MTYPE(ZEBRA, NEXTHOP, "Nexthop")
+MTYPE(ZEBRA, RIB, "RIB")
+MTYPE(ZEBRA, RIB_QUEUE, "RIB process work queue")
+MTYPE(ZEBRA, STATIC_ROUTE, "Static route")
+MTYPE(ZEBRA, RIB_DEST, "RIB destination")
+MTYPE(ZEBRA, RIB_TABLE_INFO, "RIB table info")
+MTYPE(ZEBRA, NETLINK_NAME, "Netlink name")
+MTYPE(ZEBRA, RNH, "RNH")
+
--
2.1.4


_______________________________________________
Quagga-dev mailing list
Quagga-dev@lists.quagga.net
https://lists.quagga.net/mailman/listinfo/quagga-dev