From 51e8afbe3c7b32b63ce5db466ed75ef59d2b92fc Mon Sep 17 00:00:00 2001 From: Dmitry Kozlov Date: Wed, 2 Oct 2013 22:22:40 +0400 Subject: ipoe: lua: check for session is dhcp --- accel-pppd/ctrl/ipoe/lua.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'accel-pppd/ctrl/ipoe') diff --git a/accel-pppd/ctrl/ipoe/lua.c b/accel-pppd/ctrl/ipoe/lua.c index dbc87e2..ab95e41 100644 --- a/accel-pppd/ctrl/ipoe/lua.c +++ b/accel-pppd/ctrl/ipoe/lua.c @@ -68,7 +68,7 @@ static int packet4_hdr(lua_State *L) char str[20]; uint8_t *ptr; - if (!ses) + if (!ses || !ses->dhcpv4_request) return 0; if (!strcmp(name, "xid")) @@ -107,10 +107,12 @@ static int packet4_option(lua_State *L) int type = luaL_checkinteger(L, 2); struct dhcpv4_option *opt; - list_for_each_entry(opt, &ses->dhcpv4_request->options, entry) { - if (opt->type == type) { - lua_pushlstring(L, (char *)opt->data, opt->len); - return 1; + if (ses && ses->dhcpv4_request) { + list_for_each_entry(opt, &ses->dhcpv4_request->options, entry) { + if (opt->type == type) { + lua_pushlstring(L, (char *)opt->data, opt->len); + return 1; + } } } @@ -125,7 +127,7 @@ static int packet4_options(lua_State *L) struct dhcpv4_option *opt; int i = 1; - if (!ses) + if (!ses || !ses->dhcpv4_request) return 0; lua_newtable(L); @@ -142,7 +144,7 @@ static int packet4_agent_circuit_id(lua_State *L) { struct ipoe_session *ses = luaL_checkudata(L, 1, IPOE_PACKET4); - if (!ses) + if (!ses || !ses->dhcpv4_request) return 0; if (ses->agent_circuit_id) @@ -157,7 +159,7 @@ static int packet4_agent_remote_id(lua_State *L) { struct ipoe_session *ses = luaL_checkudata(L, 1, IPOE_PACKET4); - if (!ses) + if (!ses || !ses->dhcpv4_request) return 0; if (ses->agent_remote_id) -- cgit v1.2.3