]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/frrlua.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / lib / frrlua.h
index 6fb30938b061d5bedd4cc5328cd90f850bb68f72..bf6eb5fd913bb926f1334a90bc272d459d4be9c9 100644 (file)
@@ -1,20 +1,7 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * Copyright (C) 2016-2019 Cumulus Networks, Inc.
  * Donald Sharp, Quentin Young
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #ifndef __FRRLUA_H__
 #define __FRRLUA_H__
@@ -34,6 +21,8 @@
 extern "C" {
 #endif
 
+DECLARE_MTYPE(SCRIPT_RES);
+
 /*
  * gcc-10 is complaining about the wrapper function
  * not being compatible with lua_pushstring returning
@@ -50,6 +39,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 +54,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 +70,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 +85,12 @@ 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);
+
+void lua_pushipaddr(lua_State *L, const struct ipaddr *addr);
+
+void lua_pushethaddr(lua_State *L, const struct ethaddr *addr);
+
 /*
  * Converts the Lua value at idx to an in6_addr.
  *
@@ -103,6 +104,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 +119,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.
  *
@@ -124,11 +129,17 @@ void lua_pushsockunion(lua_State *L, const union sockunion *su);
  */
 void *lua_tosockunion(lua_State *L, int idx);
 
+void lua_pushnexthop_group(lua_State *L, const struct nexthop_group *ng);
+
+void lua_pushnexthop(lua_State *L, const struct nexthop *nexthop);
+
 /*
  * Converts an int to a Lua value and pushes it on the stack.
  */
 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 +148,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.
  *
@@ -145,6 +158,13 @@ void *lua_tointegerp(lua_State *L, int idx);
  */
 void *lua_tostringp(lua_State *L, int idx);
 
+/*
+ * No-op decoders
+ */
+void lua_decode_noop(lua_State *L, int idx, const void *ptr);
+
+void lua_decode_integer_noop(lua_State *L, int idx, int i);
+
 /*
  * Retrieve an integer from table on the top of the stack.
  *