diff options
-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 d5f9e95d..91ff02c4 100644 --- a/accel-pppd/ctrl/ipoe/lua.c +++ b/accel-pppd/ctrl/ipoe/lua.c @@ -33,6 +33,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); int luaopen_lpack(lua_State *L); int luaopen_bit(lua_State *L); @@ -45,6 +46,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} }; @@ -185,6 +187,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; |