summaryrefslogtreecommitdiffstats
path: root/lib/frrlua.c
diff options
context:
space:
mode:
authorDonald Lee <dlqs@gmx.com>2021-08-18 14:22:21 +0200
committerDonald Lee <dlqs@gmx.com>2021-10-19 18:56:00 +0200
commite6f42b94c6168b35ef9382d6aa68137b5c6c92ed (patch)
treed26addad0b036467ef73ba2dd2ef66ab45829ec8 /lib/frrlua.c
parentMerge pull request #9806 from jonglezb/master (diff)
downloadfrr-e6f42b94c6168b35ef9382d6aa68137b5c6c92ed.tar.xz
frr-e6f42b94c6168b35ef9382d6aa68137b5c6c92ed.zip
lib: Add encoders/decoders for ipaddr/ethaddr
Signed-off-by: Donald Lee <dlqs@gmx.com>
Diffstat (limited to 'lib/frrlua.c')
-rw-r--r--lib/frrlua.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/frrlua.c b/lib/frrlua.c
index 00491568f..d407388bb 100644
--- a/lib/frrlua.c
+++ b/lib/frrlua.c
@@ -223,6 +223,21 @@ void *lua_toin6addr(lua_State *L, int idx)
return in6addr;
}
+void lua_pushipaddr(lua_State *L, const struct ipaddr *addr)
+{
+ if (IS_IPADDR_V4(addr))
+ lua_pushinaddr(L, &addr->ipaddr_v4);
+ else
+ lua_pushin6addr(L, &addr->ipaddr_v6);
+}
+
+void lua_pushethaddr(lua_State *L, const struct ethaddr *addr)
+{
+ lua_newtable(L);
+ lua_pushinteger(L, *(addr->octet));
+ lua_setfield(L, -2, "octet");
+}
+
void lua_pushsockunion(lua_State *L, const union sockunion *su)
{
char buf[SU_ADDRSTRLEN];