diff options
| author | Donald Lee <dlqs@gmx.com> | 2021-08-18 20:22:21 +0800 |
|---|---|---|
| committer | Donald Lee <dlqs@gmx.com> | 2021-10-20 00:56:00 +0800 |
| commit | e6f42b94c6168b35ef9382d6aa68137b5c6c92ed (patch) | |
| tree | d26addad0b036467ef73ba2dd2ef66ab45829ec8 /lib/frrlua.c | |
| parent | d759866d5b9026f8761bf89dfc9c4107cc1df764 (diff) | |
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.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/frrlua.c b/lib/frrlua.c index 00491568f6..d407388bb9 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]; |
