]> git.proxmox.com Git - mirror_frr.git/blame - lib/frrlua.h
lib: change encoder_func signature
[mirror_frr.git] / lib / frrlua.h
CommitLineData
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
9e47ee98
QY
24#include <lua.h>
25#include <lualib.h>
26#include <lauxlib.h>
634949ae 27
60219659 28#include "prefix.h"
5f98c815 29#include "frrscript.h"
60219659 30
5e244469
RW
31#ifdef __cplusplus
32extern "C" {
33#endif
34
60219659
QY
35/*
36 * Pushes a new table containing relevant fields from a prefix structure.
634949ae 37 */
47dd8736 38void lua_pushprefix(lua_State *L, const struct prefix *prefix);
634949ae 39
cd6ca660
QY
40/*
41 * Pushes a new table containing relevant fields from an interface structure.
42 */
47dd8736 43void lua_pushinterface(lua_State *L, const struct interface *ifp);
cd6ca660 44
60219659 45/*
42ae55b5
QY
46 * Pushes a new table containing both numeric and string representations of an
47 * in_addr to the stack.
48 */
47dd8736 49void lua_pushinaddr(lua_State *L, const struct in_addr *addr);
42ae55b5
QY
50
51/*
52 * Pushes a new table containing both numeric and string representations of an
53 * in6_addr to the stack.
54 */
47dd8736 55void lua_pushin6addr(lua_State *L, const struct in6_addr *addr);
42ae55b5
QY
56
57/*
58 * Pushes a time_t to the stack.
59 */
47dd8736 60void lua_pushtimet(lua_State *L, const time_t *time);
42ae55b5
QY
61
62/*
63 * Pushes a table representing a sockunion to the stack.
60219659 64 */
47dd8736 65void lua_pushsockunion(lua_State *L, const union sockunion *su);
634949ae
DS
66
67/*
60219659
QY
68 * Retrieve an integer from table on the top of the stack.
69 *
70 * key
71 * Key of string value in table
634949ae 72 */
60219659 73int frrlua_table_get_integer(lua_State *L, const char *key);
5e244469 74
d473bdc7
QY
75/*
76 * Exports a new table containing bindings to FRR zlog functions into the
77 * global namespace.
78 *
79 * From Lua, these functions may be accessed as:
80 *
81 * - log.debug()
82 * - log.info()
83 * - log.warn()
84 * - log.error()
85 *
86 * They take a single string argument.
87 */
88void frrlua_export_logging(lua_State *L);
89
e93f19fb
QY
90/*
91 * Dump Lua stack to a string.
92 *
93 * Return value must be freed with XFREE(MTYPE_TMP, ...);
94 */
95char *frrlua_stackdump(lua_State *L);
96
5e244469
RW
97#ifdef __cplusplus
98}
99#endif
100
60219659
QY
101#endif /* HAVE_LUA */
102#endif /* __FRRLUA_H__ */