Skip to content

Commit

Permalink
feat: add OpenWRT plugin with umink ubus support
Browse files Browse the repository at this point in the history
  • Loading branch information
dfranusic committed Oct 24, 2023
1 parent 85d0c26 commit 098cb76
Show file tree
Hide file tree
Showing 9 changed files with 803 additions and 3 deletions.
22 changes: 20 additions & 2 deletions .github/workflows/on_push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,22 @@ jobs:
libcmocka-dev \
libasan5 \
iproute2 \
cmake \
libxml2-utils &&
sudo ln -s /usr/lib/x86_64-linux-gnu/pkgconfig/lua-5.3.pc \
/usr/lib/x86_64-linux-gnu/pkgconfig/lua.pc &&
pip3 install 'gcovr == 6'
- name: libubox
run: |
git clone https://github.com/openwrt/libubox.git
cd libubox && mkdir build && cd build
cmake -DBUILD_LUA=off .. && make install
- name: ubus
run: |
git clone https://github.com/openwrt/ubus.git
cd ubus && mkdir ubus && cd ubus
cmake -DBUILD_LUA=off ..
make install
- name: mosquitto
run: |
mosquitto_passwd -c -b /tmp/pwdfile user password
Expand All @@ -61,10 +73,16 @@ jobs:
export ASAN_OPTIONS=verify_asan_link_order=0
./autogen.sh
./configure --enable-mqtt \
--enable-mosquitto-auth
--enable-mosquitto-auth \
--enable-openwrt
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} \
make clean all
- name: run unit tests
run: |
rm -f /tmp/tmp_file_uuid
bash ./test/test_bin_upload.sh &
build-wrapper-linux-x86-64 --out-dir ${{ env.BUILD_WRAPPER_OUT_DIR }} make clean all check
sudo LD_LIBRARY_PATH=/usr/local/lib /usr/local/sbin/ubusd &
sudo LD_LIBRARY_PATH=/usr/local/lib make check
- name: generate coverage data
run: |
mkdir coverage-dir
Expand Down
40 changes: 39 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ if ENABLE_MQTT
check_PROGRAMS += check_mqtt
endif


if ENABLE_OPENWRT
check_PROGRAMS += check_openwrt
endif

check_LTLIBRARIES = check_umplg_plugin_01.la \
check_umplg_plugin_02.la
Expand All @@ -146,6 +148,10 @@ if ENABLE_MQTT
TESTS += check_mqtt
endif

if ENABLE_OPENWRT
TESTS += check_openwrt
endif

# umlua tester
check_umlua_SOURCES = test/check_umlua.c \
src/utils/umdb.c \
Expand Down Expand Up @@ -261,6 +267,33 @@ check_mqtt_LDADD = -lcmocka \
${SQLITE_LIBS}
endif

# openwrt tester
if ENABLE_OPENWRT
check_openwrt_SOURCES = test/check_openwrt.c \
src/umd/umdaemon.c \
src/utils/umcounters.c \
src/services/sysagent/umlua.c \
src/services/sysagent/umlua_m.c \
src/utils/umdb.c \
src/utils/umink_plugin.c
check_openwrt_CFLAGS = ${COMMON_INCLUDES} \
${JSON_C_CFLAGS} \
-DLUA_COMPAT_ALL \
-DLUA_COMPAT_5_1 \
-DLUA_COMPAT_5_2 \
-DLUA_COMPAT_5_3 \
${LUA_CFLAGS} \
${ASAN_FLAGS}
check_openwrt_LDFLAGS = -export-dynamic
check_openwrt_LDADD = -lcmocka \
${JSON_C_LIBS} \
${LUA_LIBS} \
${SQLITE_LIBS} \
${UBUS_LIBS} \
${UBOX_LIBS} \
${BLOBMSG_JSON_LIBS}
endif

# cleanup rule
distclean-local: distclean-ax-prefix-umink-pkg-config-h
distclean-ax-prefix-umink-pkg-config-h:
Expand All @@ -276,3 +309,8 @@ endif
if ENABLE_MOSQUITTO_AUTH
include src/services/sysagent/plugins/mosquitto_auth/Makefile.am
endif

# OpenWRT support plugin
if ENABLE_OPENWRT
include src/services/sysagent/plugins/openwrt/Makefile.am
endif
25 changes: 25 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,31 @@ if test "x$enable_coap" != "xno"; then
PKG_CHECK_MODULES([COAP], [libcoap-3], [], [AC_MSG_ERROR([libcoap-3 not found!])])
fi

# /***********/
# /* OpenWRT */
# /***********/
AC_ARG_ENABLE(openwrt,
[AS_HELP_STRING([--enable-openwrt], [Enable OpenWRT support [default=no]])],,
[enable_openwrt=no])
AM_CONDITIONAL(ENABLE_OPENWRT, test "x$enable_openwrt" = "xyes")
if test "x$enable_openwrt" != "xno"; then
AC_DEFINE([ENABLE_OPENWRT], [1], [Enable OpenWRT support])
AC_CHECK_LIB([ubus],
[ubus_connect],
[AC_SUBST([UBUS_LIBS], ["-lubus"])],
[AC_MSG_ERROR([libubus not found!])])

AC_CHECK_LIB([ubox],
[blob_buf_init],
[AC_SUBST([UBOX_LIBS], ["-lubox"])],
[AC_MSG_ERROR([libubox not found!])])

AC_CHECK_LIB([blobmsg_json],
[blobmsg_add_object],
[AC_SUBST([BLOBMSG_JSON_LIBS], ["-lblobmsg_json"])],
[AC_MSG_ERROR([libblobmsg_json not found!])])
fi

# /****************************/
# /* Checks for header files. */
# /****************************/
Expand Down
32 changes: 32 additions & 0 deletions src/services/sysagent/plugins/openwrt/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
pkglib_LTLIBRARIES += plg_sysagent_openwrt.la
plg_sysagent_openwrt_la_SOURCES = %reldir%/plg_sysagent_openwrt.c
plg_sysagent_openwrt_la_CFLAGS = ${COMMON_INCLUDES} \
${JSON_C_CFLAGS} \
-Isrc/services/sysagent
plg_sysagent_openwrt_la_LDFLAGS = -version-info 1:0:0 \
-shared \
-module \
-export-dynamic
plg_sysagent_openwrt_la_LIBADD = ${JSON_C_LIBS} \
${LUA_LIBS} \
${UBUS_LIBS} \
${BLOBMSG_JSON_LIBS}

check_LTLIBRARIES += check_plg_sysagent_openwrt.la
check_plg_sysagent_openwrt_la_SOURCES = %reldir%/plg_sysagent_openwrt.c
check_plg_sysagent_openwrt_la_CFLAGS = ${COMMON_INCLUDES} \
${ASAN_FLAGS} \
${JSON_C_CFLAGS} \
-Isrc/services/sysagent
check_plg_sysagent_openwrt_la_LDFLAGS = -version-info 1:0:0 \
-shared \
-module \
-export-dynamic \
-rpath /tmp
check_plg_sysagent_openwrt_la_LIBADD = ${JSON_C_LIBS} \
${LUA_LIBS} \
${UBUS_LIBS} \
${BLOBMSG_JSON_LIBS}



Loading

0 comments on commit 098cb76

Please sign in to comment.