diff options
-rw-r--r-- | bgpd/bgp_main.c | 2 | ||||
-rw-r--r-- | bgpd/bgp_routemap.c | 13 | ||||
-rw-r--r-- | bgpd/bgp_script.c | 6 | ||||
-rw-r--r-- | bgpd/bgp_script.h | 8 | ||||
-rwxr-xr-x | configure.ac | 24 | ||||
-rw-r--r-- | lib/command.c | 4 | ||||
-rw-r--r-- | lib/frrlua.c | 6 | ||||
-rw-r--r-- | lib/frrlua.h | 7 | ||||
-rw-r--r-- | lib/frrscript.c | 7 | ||||
-rw-r--r-- | lib/frrscript.h | 6 | ||||
-rw-r--r-- | lib/libfrr.c | 2 |
11 files changed, 58 insertions, 27 deletions
diff --git a/bgpd/bgp_main.c b/bgpd/bgp_main.c index f8669dd66..67704850a 100644 --- a/bgpd/bgp_main.c +++ b/bgpd/bgp_main.c @@ -507,7 +507,9 @@ int main(int argc, char **argv) /* Initializations. */ bgp_vrf_init(); +#ifdef HAVE_SCRIPTING bgp_script_init(); +#endif hook_register(routing_conf_event, routing_control_plane_protocols_name_validate); diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 59c49f76a..57414eadc 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -338,7 +338,7 @@ static const struct route_map_rule_cmd route_match_peer_cmd = { route_match_peer_free }; -#if defined(HAVE_LUA) +#ifdef HAVE_SCRIPTING enum frrlua_rm_status { /* @@ -468,7 +468,8 @@ static const struct route_map_rule_cmd route_match_script_cmd = { route_match_script_compile, route_match_script_free }; -#endif + +#endif /* HAVE_SCRIPTING */ /* `match ip address IP_ACCESS_LIST' */ @@ -4134,7 +4135,7 @@ DEFUN (no_match_peer, RMAP_EVENT_MATCH_DELETED); } -#if defined(HAVE_LUA) +#ifdef HAVE_SCRIPTING DEFUN (match_script, match_script_cmd, "[no] match script WORD", @@ -4156,7 +4157,7 @@ DEFUN (match_script, RMAP_EVENT_FILTER_ADDED); } } -#endif +#endif /* HAVE_SCRIPTING */ /* match probability */ DEFUN (match_probability, @@ -5670,7 +5671,7 @@ void bgp_route_map_init(void) route_map_install_match(&route_match_peer_cmd); route_map_install_match(&route_match_local_pref_cmd); -#if defined(HAVE_LUA) +#ifdef HAVE_SCRIPTING route_map_install_match(&route_match_script_cmd); #endif route_map_install_match(&route_match_ip_address_cmd); @@ -5835,7 +5836,7 @@ void bgp_route_map_init(void) install_element(RMAP_NODE, &no_set_ipv6_nexthop_prefer_global_cmd); install_element(RMAP_NODE, &set_ipv6_nexthop_peer_cmd); install_element(RMAP_NODE, &no_set_ipv6_nexthop_peer_cmd); -#if defined(HAVE_LUA) +#ifdef HAVE_SCRIPTING install_element(RMAP_NODE, &match_script_cmd); #endif } diff --git a/bgpd/bgp_script.c b/bgpd/bgp_script.c index c665f2e7c..0cda1927f 100644 --- a/bgpd/bgp_script.c +++ b/bgpd/bgp_script.c @@ -19,7 +19,8 @@ */ #include <zebra.h> -#include <lua.h> + +#ifdef HAVE_SCRIPTING #include "bgpd.h" #include "bgp_script.h" @@ -27,6 +28,7 @@ #include "bgp_aspath.h" #include "frratomic.h" #include "frrscript.h" +#include "frrlua.h" static void lua_pushpeer(lua_State *L, const struct peer *peer) { @@ -186,3 +188,5 @@ void bgp_script_init(void) { frrscript_register_type_codecs(frrscript_codecs_bgpd); } + +#endif /* HAVE_SCRIPTING */ diff --git a/bgpd/bgp_script.h b/bgpd/bgp_script.h index 15ed3345c..6682c2eeb 100644 --- a/bgpd/bgp_script.h +++ b/bgpd/bgp_script.h @@ -17,10 +17,18 @@ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, * MA 02110-1301 USA */ +#ifndef __BGP_SCRIPT__ +#define __BGP_SCRIPT__ #include <zebra.h> +#ifdef HAVE_SCRIPTING + /* * Initialize scripting stuff. */ void bgp_script_init(void); + +#endif /* HAVE_SCRIPTING */ + +#endif /* __BGP_SCRIPT__ */ diff --git a/configure.ac b/configure.ac index 6a7353d51..11b06cb12 100755 --- a/configure.ac +++ b/configure.ac @@ -274,24 +274,22 @@ if test "$enable_clang_coverage" = "yes"; then ]) fi +if test "$enable_scripting" = "yes"; then + AX_PROG_LUA([5.3]) + AX_LUA_HEADERS + AX_LUA_LIBS([ + AC_DEFINE([HAVE_SCRIPTING], [1], [Have support for scripting]) + LIBS="$LIBS $LUA_LIB" + ]) +fi + if test "$enable_dev_build" = "yes"; then AC_DEFINE([DEV_BUILD], [1], [Build for development]) if test "$orig_cflags" = ""; then AC_C_FLAG([-g3]) AC_C_FLAG([-O0]) fi - if test "$enable_lua" = "yes"; then - AX_PROG_LUA([5.3]) - AX_LUA_HEADERS - AX_LUA_LIBS([ - AC_DEFINE([HAVE_LUA], [1], [Have support for Lua interpreter]) - LIBS="$LIBS $LUA_LIB" - ]) - fi else - if test "$enable_lua" = "yes"; then - AC_MSG_ERROR([Lua is not meant to be built/used outside of development at this time]) - fi if test "$orig_cflags" = ""; then AC_C_FLAG([-g]) AC_C_FLAG([-O2]) @@ -693,8 +691,8 @@ fi AC_ARG_ENABLE([dev_build], AS_HELP_STRING([--enable-dev-build], [build for development])) -AC_ARG_ENABLE([lua], - AS_HELP_STRING([--enable-lua], [Build Lua scripting])) +AC_ARG_ENABLE([scripting], + AS_HELP_STRING([--enable-scripting], [Build with scripting support])) if test "$enable_time_check" != "no" ; then if test "$enable_time_check" = "yes" -o "$enable_time_check" = "" ; then diff --git a/lib/command.c b/lib/command.c index 3ca5c5882..b19147ed8 100644 --- a/lib/command.c +++ b/lib/command.c @@ -2281,7 +2281,7 @@ done: return CMD_SUCCESS; } -#ifdef DEV_BUILD +#if defined(DEV_BUILD) && defined(HAVE_SCRIPTING) DEFUN(script, script_cmd, "script SCRIPT", @@ -2399,7 +2399,7 @@ void cmd_init(int terminal) install_element(VIEW_NODE, &echo_cmd); install_element(VIEW_NODE, &autocomplete_cmd); install_element(VIEW_NODE, &find_cmd); -#ifdef DEV_BUILD +#if defined(DEV_BUILD) && defined(HAVE_SCRIPTING) install_element(VIEW_NODE, &script_cmd); #endif diff --git a/lib/frrlua.c b/lib/frrlua.c index bd1e5b00e..cd878eb71 100644 --- a/lib/frrlua.c +++ b/lib/frrlua.c @@ -19,9 +19,11 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ + #include <zebra.h> -#if defined(HAVE_LUA) +#ifdef HAVE_SCRIPTING + #include "prefix.h" #include "frrlua.h" #include "log.h" @@ -371,4 +373,4 @@ char *frrlua_stackdump(lua_State *L) return result; } -#endif +#endif /* HAVE_SCRIPTING */ diff --git a/lib/frrlua.h b/lib/frrlua.h index a105bd069..8e52931e5 100644 --- a/lib/frrlua.h +++ b/lib/frrlua.h @@ -19,7 +19,9 @@ #ifndef __FRRLUA_H__ #define __FRRLUA_H__ -#if defined(HAVE_LUA) +#include <zebra.h> + +#ifdef HAVE_SCRIPTING #include <lua.h> #include <lualib.h> @@ -166,5 +168,6 @@ char *frrlua_stackdump(lua_State *L); } #endif -#endif /* HAVE_LUA */ +#endif /* HAVE_SCRIPTING */ + #endif /* __FRRLUA_H__ */ diff --git a/lib/frrscript.c b/lib/frrscript.c index 60d3c2fc6..6d03ca119 100644 --- a/lib/frrscript.c +++ b/lib/frrscript.c @@ -16,8 +16,10 @@ * with this program; see the file COPYING; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ - #include <zebra.h> + +#ifdef HAVE_SCRIPTING + #include <stdarg.h> #include <lua.h> @@ -27,6 +29,7 @@ #include "hash.h" #include "log.h" + DEFINE_MTYPE_STATIC(LIB, SCRIPT, "Scripting"); /* Codecs */ @@ -267,3 +270,5 @@ void frrscript_init() /* Register core library types */ frrscript_register_type_codecs(frrscript_codecs_lib); } + +#endif /* HAVE_SCRIPTING */ diff --git a/lib/frrscript.h b/lib/frrscript.h index cbc0ca6c5..4206420f4 100644 --- a/lib/frrscript.h +++ b/lib/frrscript.h @@ -19,6 +19,10 @@ #ifndef __FRRSCRIPT_H__ #define __FRRSCRIPT_H__ +#include <zebra.h> + +#ifdef HAVE_SCRIPTING + #include <lua.h> #include "frrlua.h" @@ -128,4 +132,6 @@ void *frrscript_get_result(struct frrscript *fs, } #endif /* __cplusplus */ +#endif /* HAVE_SCRIPTING */ + #endif /* __FRRSCRIPT_H__ */ diff --git a/lib/libfrr.c b/lib/libfrr.c index 8e21ac11b..05e6cf36e 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -718,7 +718,9 @@ struct thread_master *frr_init(void) lib_cmd_init(); frr_pthread_init(); +#ifdef HAVE_SCRIPTING frrscript_init(); +#endif log_ref_init(); log_ref_vty_init(); |