mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-16 04:50:29 +00:00
lib: Add encoders/decoders for ipaddr/ethaddr
Signed-off-by: Donald Lee <dlqs@gmx.com>
This commit is contained in:
parent
d759866d5b
commit
e6f42b94c6
15
lib/frrlua.c
15
lib/frrlua.c
@ -223,6 +223,21 @@ void *lua_toin6addr(lua_State *L, int idx)
|
|||||||
return in6addr;
|
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)
|
void lua_pushsockunion(lua_State *L, const union sockunion *su)
|
||||||
{
|
{
|
||||||
char buf[SU_ADDRSTRLEN];
|
char buf[SU_ADDRSTRLEN];
|
||||||
|
@ -100,6 +100,10 @@ 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_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.
|
* Converts the Lua value at idx to an in6_addr.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user