summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2018-05-31 16:03:12 +0300
committerDmitry Kozlov <xeb@mail.ru>2018-05-31 16:05:53 +0300
commitd569e0099a97dfbfd1a6157e11bc3089992c4695 (patch)
tree142184a3018e3515f7150044da40b92cd5ce3fc5
parentcead7e72688f475c9bd2f8c7b9d650d07b300056 (diff)
downloadaccel-ppp-d569e0099a97dfbfd1a6157e11bc3089992c4695.tar.gz
accel-ppp-d569e0099a97dfbfd1a6157e11bc3089992c4695.zip
ipoe: lua: introduced hwaddr field to session object
example function to use mac address as username: function username(ses) return ses:hwaddr() end
-rw-r--r--accel-pppd/ctrl/ipoe/lua.c17
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;