summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2017-10-16 15:36:34 +0300
committerDmitry Kozlov <xeb@mail.ru>2017-10-16 15:36:34 +0300
commit3abdeb226386bae855446c583b6dafd152b54c9d (patch)
tree55e034d2b85df959b12bf2171e92b59f9717f5d2
parent5b193c892c75e52e10be96ec16aad6394e444020 (diff)
parentec3d2f2942172d79fe74a01f5c980873e01ff5dd (diff)
downloadaccel-ppp-3abdeb226386bae855446c583b6dafd152b54c9d.tar.gz
accel-ppp-3abdeb226386bae855446c583b6dafd152b54c9d.zip
Merge branch 'master' of ssh://git.code.sf.net/p/accel-ppp/code
-rw-r--r--accel-pppd/CMakeLists.txt11
-rw-r--r--accel-pppd/ctrl/ipoe/CMakeLists.txt11
-rw-r--r--accel-pppd/ctrl/ipoe/lua.c25
l---------accel-pppd/include/luasupp.h1
-rw-r--r--accel-pppd/lua/CMakeLists.txt12
-rw-r--r--accel-pppd/lua/lua_bit.c (renamed from accel-pppd/ctrl/ipoe/lua_bit.c)6
-rw-r--r--accel-pppd/lua/lua_lpack.c (renamed from accel-pppd/ctrl/ipoe/lua_lpack.c)14
-rw-r--r--accel-pppd/lua/luasupp.h9
8 files changed, 63 insertions, 26 deletions
diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt
index 8ffcbf4d..082c93bc 100644
--- a/accel-pppd/CMakeLists.txt
+++ b/accel-pppd/CMakeLists.txt
@@ -30,6 +30,17 @@ IF (RADIUS)
ADD_SUBDIRECTORY(radius)
ENDIF (RADIUS)
+IF (LUA)
+ IF (LUA STREQUAL "TRUE")
+ include(FindLua51)
+ ELSE ()
+ find_package("Lua" ${LUA})
+ ENDIF ()
+ IF (NOT DEFINED LUA_VERSION_STRING)
+ MESSAGE(FATAL_ERROR "lua not found")
+ ENDIF ()
+ ADD_SUBDIRECTORY(lua)
+ENDIF (LUA)
ADD_SUBDIRECTORY(triton)
ADD_SUBDIRECTORY(vlan-mon)
diff --git a/accel-pppd/ctrl/ipoe/CMakeLists.txt b/accel-pppd/ctrl/ipoe/CMakeLists.txt
index bba74633..8ab5975a 100644
--- a/accel-pppd/ctrl/ipoe/CMakeLists.txt
+++ b/accel-pppd/ctrl/ipoe/CMakeLists.txt
@@ -10,20 +10,19 @@ SET(sources
)
IF (LUA)
- include(FindLua51)
- IF (NOT LUA51_FOUND)
- MESSAGE(FATAL_ERROR "lua not found")
- ENDIF (NOT LUA51_FOUND)
INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
ADD_DEFINITIONS(-DUSE_LUA)
- SET(sources ${sources} lua.c lua_lpack.c lua_bit.c)
+ SET(sources ${sources} lua.c)
ENDIF (LUA)
ADD_LIBRARY(ipoe SHARED ${sources})
+
IF (LUA)
- TARGET_LINK_LIBRARIES(ipoe ${LUA_LIBRARIES})
+ TARGET_LINK_LIBRARIES(ipoe luasupp)
ENDIF(LUA)
+
TARGET_LINK_LIBRARIES(ipoe vlan-mon)
+
set_property(TARGET ipoe PROPERTY CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set_property(TARGET ipoe PROPERTY INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/accel-ppp)
diff --git a/accel-pppd/ctrl/ipoe/lua.c b/accel-pppd/ctrl/ipoe/lua.c
index d5f9e95d..88dbeef8 100644
--- a/accel-pppd/ctrl/ipoe/lua.c
+++ b/accel-pppd/ctrl/ipoe/lua.c
@@ -11,6 +11,7 @@
#include "events.h"
#include "log.h"
#include "utils.h"
+#include "luasupp.h"
#include "ipoe.h"
@@ -34,10 +35,8 @@ 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);
-int luaopen_lpack(lua_State *L);
-int luaopen_bit(lua_State *L);
-static const struct luaL_reg packet4_lib [] = {
+static const struct luaL_Reg packet4_lib [] = {
{"hdr", packet4_hdr},
{"ifname", packet4_ifname},
{"option", packet4_option},
@@ -52,14 +51,14 @@ static int luaopen_packet4(lua_State *L)
{
luaL_newmetatable(L, IPOE_PACKET4);
- lua_pushstring(L, "__index");
- lua_pushvalue(L, -2); /* pushes the metatable */
- lua_settable(L, -3); /* metatable.__index = metatable */
+ lua_pushvalue(L, -1);
+ lua_setfield(L, -2, "__index");
-
- luaI_openlib(L, NULL, packet4_lib, 0);
-
- luaI_openlib(L, "packet4", packet4_lib, 0);
+#if LUA_VERSION_NUM < 502
+ luaL_register(L, NULL, packet4_lib);
+#else
+ luaL_setfuncs(L, packet4_lib, 0);
+#endif
return 1;
}
@@ -189,12 +188,14 @@ static void init_lua()
{
__serial = serial;
- L = lua_open();
+ L = luaL_newstate();
luaL_openlibs(L);
luaopen_lpack(L);
+#if LUA_VERSION_NUM < 503
luaopen_bit(L);
+#endif
luaopen_packet4(L);
if (luaL_loadfile(L, conf_filename))
@@ -264,6 +265,8 @@ char *ipoe_lua_get_username(struct ipoe_session *ses, const char *func)
lua_getglobal(L, func);
lua_pushlightuserdata(L, ses);
+ luaL_getmetatable(L, IPOE_PACKET4);
+ lua_setmetatable(L, -2);
if (lua_pcall(L, 1, 1, 0)) {
log_ppp_error("ipoe: lua: %s\n", lua_tostring(L, -1));
diff --git a/accel-pppd/include/luasupp.h b/accel-pppd/include/luasupp.h
new file mode 120000
index 00000000..2bdd30a5
--- /dev/null
+++ b/accel-pppd/include/luasupp.h
@@ -0,0 +1 @@
+../lua/luasupp.h \ No newline at end of file
diff --git a/accel-pppd/lua/CMakeLists.txt b/accel-pppd/lua/CMakeLists.txt
new file mode 100644
index 00000000..699cfb7b
--- /dev/null
+++ b/accel-pppd/lua/CMakeLists.txt
@@ -0,0 +1,12 @@
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
+INCLUDE_DIRECTORIES(${LUA_INCLUDE_DIR})
+
+SET(sources
+ lua_lpack.c
+ lua_bit.c
+)
+
+ADD_LIBRARY(luasupp SHARED ${sources})
+TARGET_LINK_LIBRARIES(luasupp ${LUA_LIBRARIES})
+
+INSTALL(TARGETS luasupp LIBRARY DESTINATION lib${LIB_SUFFIX}/accel-ppp)
diff --git a/accel-pppd/ctrl/ipoe/lua_bit.c b/accel-pppd/lua/lua_bit.c
index 690df7d3..be7e7687 100644
--- a/accel-pppd/ctrl/ipoe/lua_bit.c
+++ b/accel-pppd/lua/lua_bit.c
@@ -32,6 +32,8 @@
#include "lua.h"
#include "lauxlib.h"
+#if LUA_VERSION_NUM < 503
+
#ifdef _MSC_VER
/* MSVC is stuck in the last century and doesn't have C99's stdint.h. */
typedef __int32 int32_t;
@@ -160,7 +162,7 @@ static const struct luaL_Reg bit_funcs[] = {
*/
#define BAD_SAR (bsar(-8, 2) != (SBits)-2)
-LUALIB_API int luaopen_bit(lua_State *L)
+LUALIB_API __attribute__((visibility("default"))) int luaopen_bit(lua_State *L)
{
UBits b;
lua_pushnumber(L, (lua_Number)1437217655L);
@@ -186,4 +188,4 @@ LUALIB_API int luaopen_bit(lua_State *L)
#endif
return 1;
}
-
+#endif
diff --git a/accel-pppd/ctrl/ipoe/lua_lpack.c b/accel-pppd/lua/lua_lpack.c
index feb0a5a8..e9ceb852 100644
--- a/accel-pppd/ctrl/ipoe/lua_lpack.c
+++ b/accel-pppd/lua/lua_lpack.c
@@ -252,20 +252,20 @@ static int l_pack(lua_State *L) /** pack(f,...) */
return 1;
}
-static const luaL_reg R[] =
+static const struct luaL_Reg R[] =
{
{"pack", l_pack},
{"unpack", l_unpack},
{NULL, NULL}
};
-int luaopen_lpack(lua_State *L)
+LUALIB_API __attribute__((visibility("default"))) int luaopen_lpack(lua_State *L)
{
-#ifdef USE_GLOBALS
- lua_register(L,"bpack",l_pack);
- lua_register(L,"bunpack",l_unpack);
+#if LUA_VERSION_NUM < 502
+ luaL_register(L, LUA_STRLIBNAME, R);
#else
- luaI_openlib(L, LUA_STRLIBNAME, R, 0);
+ luaL_newmetatable(L, LUA_STRLIBNAME);
+ luaL_newlib(L, R);
#endif
- return 0;
+ return 1;
}
diff --git a/accel-pppd/lua/luasupp.h b/accel-pppd/lua/luasupp.h
new file mode 100644
index 00000000..fa7a7c30
--- /dev/null
+++ b/accel-pppd/lua/luasupp.h
@@ -0,0 +1,9 @@
+#ifndef __LUASUPP_H
+#define __LUASUPP_H
+
+#include "lua.h"
+
+int luaopen_lpack(lua_State *L);
+int luaopen_bit(lua_State *L);
+
+#endif