Commit Graph

7 Commits

Author SHA1 Message Date
Quentin Young
f937164459 lib: remove frrlua_initialize
This was toy code used for testing purposes. Code calling Lua should be
very explicit about what is loaded into the Lua state. Also, the
allocator used is exactly the same allocator used by default w/
luaL_newstate().

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
d473bdc7f1 lib: allow exporting all logging functions to Lua
Add a function that will export FRR's logging functions into a Lua
table, and add that table to the table of your choice (usually _ENV).

For instance, to add logging to the global environment:

  lua_gettable(L, LUA_REGISTRYINDEX);
  lua_gettable(L, LUA_RIDX_GLOBALS);
  frrlua_export_logging(L);

Then the following functions are globally accessible to any Lua scripts
running with state L:

  - log.debug()
  - log.info()
  - log.notice()
  - log.warn()
  - log.error()

These are bound to zlog_debug, zlog_info, etc. They only take one string
argument for now but this shouldn't be an issue given Lua's builtin
facilities for formatting strings.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
cd6ca660c5 lib: add interface -> table encoder
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Quentin Young
6021965926 lib: clean up frrlua.[ch]
* Use frrlua_* prefix to differentiate from Lua builtins
* Allow frrlua_initialize to pass an empty script
* Fixup naming of table accessors
* Fixup naming of prefix -> table encoder
* Fixup BGP routemap code to new function names
* Fix includes for frrlua.h
* Clean up doc comments

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-12-01 18:37:14 -05:00
Lou Berger
8678d6387c *: use the current project name (FRRouting)
Signed-off-by: Lou Berger <lberger@labn.net>
2020-03-25 17:38:56 -04:00
David Lamparter
2618a52ed3 *: config.h or zebra.h is the first #include
This is mostly relevant for Solaris, where config.h sets up some #define
that affect overall header behaviour, so it needs to be before anything
else.

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-06-13 13:35:33 +02:00
Quentin Young
5dbb0a7b2a build: fix Lua build
Each of Lua's major versions are incompatible with each other. Ubuntu,
at least, does not provide a single liblua.so or /usr/include/lua; all
SOs and headers are versioned, e.g. liblua5.3.so and
/usr/include/lua5.3. There's already an m4 macro in the GNU collection
to handle this situation, so let's use that.

This allows building with Lua enabled to work on platforms other than
Fedora.

* Move lib/lua.[ch] -> lib/frrlua.[ch] to prevent path conflicts
* Fix configure.ac search for proper CPP and linker flags
* Add Lua include path to AM_CPPFLAGS
* Update vtysh/extract.pl.in

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-10 16:08:32 +00:00