summaryrefslogtreecommitdiff
path: root/lib/frrlua.h
diff options
context:
space:
mode:
authorDonald Lee <dlqs@gmx.com>2021-06-20 08:25:22 +0800
committerDonald Lee <dlqs@gmx.com>2021-06-22 05:02:03 +0800
commit3a3cfe4762753dbd5744acaa02153c49f6c73fe1 (patch)
tree53a29163daef84516c7568a4e311834be4926fc6 /lib/frrlua.h
parentc2642aab24cdbfc7a0b0b203aca9835d52d938ef (diff)
lib: Add decoder functions
Split existing lua_to* functions into two functions: - lua_decode_*: unmarshall Lua values into an existing C data structure - lua_to*: allocate *and* unmarshall Lua values into C data structure This allows us to mutate C data structures passed into frrscript_call, without allocation Signed-off-by: Donald Lee <dlqs@gmx.com>
Diffstat (limited to 'lib/frrlua.h')
-rw-r--r--lib/frrlua.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/frrlua.h b/lib/frrlua.h
index 6fb30938b0..3ca5b1f778 100644
--- a/lib/frrlua.h
+++ b/lib/frrlua.h
@@ -50,6 +50,8 @@ static inline void lua_pushstring_wrapper(lua_State *L, const char *str)
*/
void lua_pushprefix(lua_State *L, const struct prefix *prefix);
+void lua_decode_prefix(lua_State *L, int idx, struct prefix *prefix);
+
/*
* Converts the Lua value at idx to a prefix.
*
@@ -63,6 +65,8 @@ void *lua_toprefix(lua_State *L, int idx);
*/
void lua_pushinterface(lua_State *L, const struct interface *ifp);
+void lua_decode_interface(lua_State *L, int idx, struct interface *ifp);
+
/*
* Converts the Lua value at idx to an interface.
*
@@ -77,6 +81,8 @@ void *lua_tointerface(lua_State *L, int idx);
*/
void lua_pushinaddr(lua_State *L, const struct in_addr *addr);
+void lua_decode_inaddr(lua_State *L, int idx, struct in_addr *addr);
+
/*
* Converts the Lua value at idx to an in_addr.
*
@@ -90,6 +96,8 @@ void *lua_toinaddr(lua_State *L, int idx);
*/
void lua_pushin6addr(lua_State *L, const struct in6_addr *addr);
+void lua_decode_in6addr(lua_State *L, int idx, struct in6_addr *addr);
+
/*
* Converts the Lua value at idx to an in6_addr.
*
@@ -103,6 +111,8 @@ void *lua_toin6addr(lua_State *L, int idx);
*/
void lua_pushtimet(lua_State *L, const time_t *time);
+void lua_decode_timet(lua_State *L, int idx, time_t *time);
+
/*
* Converts the Lua value at idx to a time_t.
*
@@ -116,6 +126,8 @@ void *lua_totimet(lua_State *L, int idx);
*/
void lua_pushsockunion(lua_State *L, const union sockunion *su);
+void lua_decode_sockunion(lua_State *L, int idx, union sockunion *su);
+
/*
* Converts the Lua value at idx to a sockunion.
*
@@ -129,6 +141,8 @@ void *lua_tosockunion(lua_State *L, int idx);
*/
void lua_pushintegerp(lua_State *L, const long long *num);
+void lua_decode_integerp(lua_State *L, int idx, long long *num);
+
/*
* Converts the Lua value at idx to an int.
*
@@ -137,6 +151,8 @@ void lua_pushintegerp(lua_State *L, const long long *num);
*/
void *lua_tointegerp(lua_State *L, int idx);
+void lua_decode_stringp(lua_State *L, int idx, char *str);
+
/*
* Pop string.
*