diff options
author | Dmitry Kozlov <xeb@mail.ru> | 2018-05-31 16:03:12 +0300 |
---|---|---|
committer | Dmitry Kozlov <xeb@mail.ru> | 2018-05-31 16:03:18 +0300 |
commit | 1f59c6152777e38112b2de5c7f7c60772a9f9115 (patch) | |
tree | 95ea5af0d51fa7ba12678cc26335e141d9d80542 /accel-pppd/ctrl | |
parent | 03d9f8c59b6375325d7dfef0313c8c54705cfe0b (diff) | |
download | accel-ppp-xebd-1f59c6152777e38112b2de5c7f7c60772a9f9115.tar.gz accel-ppp-xebd-1f59c6152777e38112b2de5c7f7c60772a9f9115.zip |
ipoe: lua: introduced hwaddr field to session object
example function to use mac address as username:
function username(ses)
return ses:hwaddr()
end
Diffstat (limited to 'accel-pppd/ctrl')
-rw-r--r-- | accel-pppd/ctrl/ipoe/lua.c | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/ipoe/lua.c b/accel-pppd/ctrl/ipoe/lua.c index 88dbeef..9fbce92 100644 --- a/accel-pppd/ctrl/ipoe/lua.c +++ b/accel-pppd/ctrl/ipoe/lua.c @@ -34,6 +34,7 @@ static int packet4_options(lua_State *L); 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 const struct luaL_Reg packet4_lib [] = { @@ -44,6 +45,7 @@ static const struct luaL_Reg packet4_lib [] = { {"agent_circuit_id", packet4_agent_circuit_id}, {"agent_remote_id", packet4_agent_remote_id}, {"vlan", packet4_vlan}, + {"hwaddr", packet4_hwaddr}, {NULL, NULL} }; @@ -184,6 +186,21 @@ static int packet4_vlan(lua_State *L) return 1; } +static int packet4_hwaddr(lua_State *L) +{ + struct ipoe_session *ses = luaL_checkudata(L, 1, IPOE_PACKET4); + char str[20]; + + if (!ses) + return 0; + + sprintf(str, "%02x:%02x:%02x:%02x:%02x:%02x", + ses->hwaddr[0], ses->hwaddr[1], ses->hwaddr[2], ses->hwaddr[3], ses->hwaddr[4], ses->hwaddr[5]); + lua_pushstring(L, str); + + return 1; +} + static void init_lua() { __serial = serial; |