From ac8e3062dd7c9f3b9d6b4c88ac34f005e9644468 Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Fri, 1 Jun 2018 10:50:58 +0300 Subject: ipoe: lua: introduced ipaddr field to session object --- accel-pppd/ctrl/ipoe/lua.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'accel-pppd/ctrl/ipoe') diff --git a/accel-pppd/ctrl/ipoe/lua.c b/accel-pppd/ctrl/ipoe/lua.c index 9fbce926..22279f43 100644 --- a/accel-pppd/ctrl/ipoe/lua.c +++ b/accel-pppd/ctrl/ipoe/lua.c @@ -35,7 +35,7 @@ static int packet4_agent_circuit_id(lua_State *L); static int packet4_agent_remote_id(lua_State *L); static int packet4_vlan(lua_State *L); static int packet4_hwaddr(lua_State *L); - +static int packet4_ipaddr(lua_State *L); static const struct luaL_Reg packet4_lib [] = { {"hdr", packet4_hdr}, @@ -46,6 +46,7 @@ static const struct luaL_Reg packet4_lib [] = { {"agent_remote_id", packet4_agent_remote_id}, {"vlan", packet4_vlan}, {"hwaddr", packet4_hwaddr}, + {"ipaddr", packet4_ipaddr}, {NULL, NULL} }; @@ -201,6 +202,20 @@ static int packet4_hwaddr(lua_State *L) return 1; } +static int packet4_ipaddr(lua_State *L) +{ + struct ipoe_session *ses = luaL_checkudata(L, 1, IPOE_PACKET4); + char str[20]; + + if (!ses) + return 0; + + u_inet_ntoa(ses->yiaddr, str); + lua_pushstring(L, str); + + return 1; +} + static void init_lua() { __serial = serial; -- cgit v1.2.3