]>
Commit | Line | Data |
---|---|---|
634949ae | 1 | /* |
60219659 QY |
2 | * Copyright (C) 2016-2019 Cumulus Networks, Inc. |
3 | * Donald Sharp, Quentin Young | |
634949ae | 4 | * |
60219659 QY |
5 | * This program is free software; you can redistribute it and/or modify it |
6 | * under the terms of the GNU General Public License as published by the Free | |
7 | * Software Foundation; either version 2 of the License, or (at your option) | |
8 | * any later version. | |
634949ae | 9 | * |
60219659 QY |
10 | * This program is distributed in the hope that it will be useful, but WITHOUT |
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | |
13 | * more details. | |
634949ae DS |
14 | * |
15 | * You should have received a copy of the GNU General Public License along | |
60219659 QY |
16 | * with this program; see the file COPYING; if not, write to the Free Software |
17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | |
634949ae | 18 | */ |
60219659 QY |
19 | #ifndef __FRRLUA_H__ |
20 | #define __FRRLUA_H__ | |
634949ae DS |
21 | |
22 | #if defined(HAVE_LUA) | |
23 | ||
5dbb0a7b QY |
24 | #include "lua.h" |
25 | #include "lualib.h" | |
26 | #include "lauxlib.h" | |
634949ae | 27 | |
60219659 QY |
28 | #include "prefix.h" |
29 | ||
5e244469 RW |
30 | #ifdef __cplusplus |
31 | extern "C" { | |
32 | #endif | |
33 | ||
60219659 QY |
34 | /* |
35 | * Pushes a new table containing relevant fields from a prefix structure. | |
36 | * | |
37 | * Additionally sets the global variable "prefix" to point at this table. | |
634949ae | 38 | */ |
60219659 | 39 | void frrlua_newtable_prefix(lua_State *L, const struct prefix *prefix); |
634949ae | 40 | |
cd6ca660 QY |
41 | /* |
42 | * Pushes a new table containing relevant fields from an interface structure. | |
43 | */ | |
44 | void frrlua_newtable_interface(lua_State *L, const struct interface *ifp); | |
45 | ||
60219659 QY |
46 | /* |
47 | * Retrieve a string from table on the top of the stack. | |
48 | * | |
49 | * key | |
50 | * Key of string value in table | |
51 | */ | |
52 | const char *frrlua_table_get_string(lua_State *L, const char *key); | |
634949ae DS |
53 | |
54 | /* | |
60219659 QY |
55 | * Retrieve an integer from table on the top of the stack. |
56 | * | |
57 | * key | |
58 | * Key of string value in table | |
634949ae | 59 | */ |
60219659 | 60 | int frrlua_table_get_integer(lua_State *L, const char *key); |
5e244469 | 61 | |
d473bdc7 QY |
62 | /* |
63 | * Exports a new table containing bindings to FRR zlog functions into the | |
64 | * global namespace. | |
65 | * | |
66 | * From Lua, these functions may be accessed as: | |
67 | * | |
68 | * - log.debug() | |
69 | * - log.info() | |
70 | * - log.warn() | |
71 | * - log.error() | |
72 | * | |
73 | * They take a single string argument. | |
74 | */ | |
75 | void frrlua_export_logging(lua_State *L); | |
76 | ||
e93f19fb QY |
77 | /* |
78 | * Dump Lua stack to a string. | |
79 | * | |
80 | * Return value must be freed with XFREE(MTYPE_TMP, ...); | |
81 | */ | |
82 | char *frrlua_stackdump(lua_State *L); | |
83 | ||
5e244469 RW |
84 | #ifdef __cplusplus |
85 | } | |
86 | #endif | |
87 | ||
60219659 QY |
88 | #endif /* HAVE_LUA */ |
89 | #endif /* __FRRLUA_H__ */ |