]> git.proxmox.com Git - mirror_frr.git/blob - lib/frrlua.h
Merge pull request #5590 from qlyoung/fix-nhrp-underflow
[mirror_frr.git] / lib / frrlua.h
1 /*
2 * This file defines the lua interface into
3 * FRRouting.
4 *
5 * Copyright (C) 2016 Cumulus Networks, Inc.
6 * Donald Sharp
7 *
8 * This file is part of FreeRangeRouting (FRR).
9 *
10 * FRR is free software; you can redistribute it and/or modify it under the
11 * terms of the GNU General Public License as published by the Free Software
12 * Foundation; either version 2, or (at your option) any later version.
13 *
14 * FRR is distributed in the hope that it will be useful, but WITHOUT ANY
15 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with FRR; see the file COPYING. If not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 */
23 #ifndef __LUA_H__
24 #define __LUA_H__
25
26 #if defined(HAVE_LUA)
27
28 #include "lua.h"
29 #include "lualib.h"
30 #include "lauxlib.h"
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /*
37 * These functions are helper functions that
38 * try to glom some of the lua_XXX functionality
39 * into what we actually need, instead of having
40 * to make multiple calls to set up what
41 * we want
42 */
43 enum lua_rm_status {
44 /*
45 * Script function run failure. This will translate into a
46 * deny
47 */
48 LUA_RM_FAILURE = 0,
49 /*
50 * No Match was found for the route map function
51 */
52 LUA_RM_NOMATCH,
53 /*
54 * Match was found but no changes were made to the
55 * incoming data.
56 */
57 LUA_RM_MATCH,
58 /*
59 * Match was found and data was modified, so
60 * figure out what changed
61 */
62 LUA_RM_MATCH_AND_CHANGE,
63 };
64
65 /*
66 * Open up the lua.scr file and parse
67 * initial global values, if any.
68 */
69 lua_State *lua_initialize(const char *file);
70
71 void lua_setup_prefix_table(lua_State *L, const struct prefix *prefix);
72
73 enum lua_rm_status lua_run_rm_rule(lua_State *L, const char *rule);
74
75 /*
76 * Get particular string/integer information
77 * from a table. It is *assumed* that
78 * the table has already been selected
79 */
80 const char *get_string(lua_State *L, const char *key);
81 int get_integer(lua_State *L, const char *key);
82
83 #ifdef __cplusplus
84 }
85 #endif
86
87 #endif
88 #endif