#include "bgp_aspath.h"
#include "frratomic.h"
#include "frrscript.h"
-#include "frrlua.h"
-static void lua_pushpeer(lua_State *L, const struct peer *peer)
+void lua_pushpeer(lua_State *L, const struct peer *peer)
{
lua_newtable(L);
lua_pushinteger(L, peer->as);
lua_setfield(L, -2, "stats");
}
-static void lua_pushattr(lua_State *L, const struct attr *attr)
+void lua_pushattr(lua_State *L, const struct attr *attr)
{
lua_newtable(L);
lua_pushinteger(L, attr->med);
lua_setfield(L, -2, "localpref");
}
-static void *lua_toattr(lua_State *L, int idx)
+void lua_decode_attr(lua_State *L, int idx, struct attr *attr)
{
- struct attr *attr = XCALLOC(MTYPE_TMP, sizeof(struct attr));
-
lua_getfield(L, -1, "metric");
attr->med = lua_tointeger(L, -1);
lua_pop(L, 1);
lua_getfield(L, -1, "localpref");
attr->local_pref = lua_tointeger(L, -1);
lua_pop(L, 1);
+}
+
+void *lua_toattr(lua_State *L, int idx)
+{
+ struct attr *attr = XCALLOC(MTYPE_TMP, sizeof(struct attr));
+ lua_decode_attr(L, idx, attr);
return attr;
}
#define __BGP_SCRIPT__
#include <zebra.h>
+#include "bgpd.h"
#ifdef HAVE_SCRIPTING
+#include "frrlua.h"
+
/*
* Initialize scripting stuff.
*/
void bgp_script_init(void);
+void lua_pushpeer(lua_State *L, const struct peer *peer);
+
+void lua_pushattr(lua_State *L, const struct attr *attr);
+
+void lua_decode_attr(lua_State *L, int idx, struct attr *attr);
+
+void *lua_toattr(lua_State *L, int idx);
+
#endif /* HAVE_SCRIPTING */
#endif /* __BGP_SCRIPT__ */
#include <lua.h>
#include "frrlua.h"
+#include "../bgpd/bgp_script.h"
#ifdef __cplusplus
extern "C" {
struct in6_addr * : lua_pushin6addr, \
union sockunion * : lua_pushsockunion, \
time_t * : lua_pushtimet, \
-char * : lua_pushstring_wrapper \
+char * : lua_pushstring_wrapper, \
+struct attr * : lua_pushattr, \
+struct peer * : lua_pushpeer \
)(L, value)
#define DECODE_ARGS_WITH_STATE(L, value) \
struct in6_addr * : lua_decode_in6addr, \
union sockunion * : lua_decode_sockunion, \
time_t * : lua_decode_timet, \
-char * : lua_decode_stringp \
+char * : lua_decode_stringp, \
+struct attr * : lua_decode_attr \
)(L, -1, value)
/*