]>
Commit | Line | Data |
---|---|---|
634949ae DS |
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 | /* | |
33 | * These functions are helper functions that | |
34 | * try to glom some of the lua_XXX functionality | |
35 | * into what we actually need, instead of having | |
36 | * to make multiple calls to set up what | |
37 | * we want | |
38 | */ | |
39 | enum lua_rm_status { | |
40 | /* | |
41 | * Script function run failure. This will translate into a | |
42 | * deny | |
43 | */ | |
44 | LUA_RM_FAILURE = 0, | |
45 | /* | |
46 | * No Match was found for the route map function | |
47 | */ | |
48 | LUA_RM_NOMATCH, | |
49 | /* | |
50 | * Match was found but no changes were made to the | |
51 | * incoming data. | |
52 | */ | |
53 | LUA_RM_MATCH, | |
54 | /* | |
55 | * Match was found and data was modified, so | |
56 | * figure out what changed | |
57 | */ | |
58 | LUA_RM_MATCH_AND_CHANGE, | |
59 | }; | |
60 | ||
61 | /* | |
62 | * Open up the lua.scr file and parse | |
63 | * initial global values, if any. | |
64 | */ | |
65 | lua_State *lua_initialize(const char *file); | |
66 | ||
67 | void lua_setup_prefix_table(lua_State *L, const struct prefix *prefix); | |
68 | ||
69 | enum lua_rm_status lua_run_rm_rule(lua_State *L, const char *rule); | |
70 | ||
71 | /* | |
72 | * Get particular string/integer information | |
73 | * from a table. It is *assumed* that | |
74 | * the table has already been selected | |
75 | */ | |
76 | const char *get_string(lua_State *L, const char *key); | |
77 | int get_integer(lua_State *L, const char *key); | |
78 | #endif | |
79 | #endif |