From afa51b623b05e952f43255070b0fa2bf65422d97 Mon Sep 17 00:00:00 2001 From: Omar Kallel Date: Tue, 24 Sep 2019 14:32:37 +0100 Subject: [PATCH] Ticket refs #1253: libtr098: move all TR-098 datamodel support from icwmp to libtr098 package --- bin/Makefile.am | 9 ++++++++- config.c | 5 +++++ configure.ac | 3 +++ cwmp.c | 11 ++++++++++- diagnostic.c | 5 +++++ event.c | 9 ++++++++- external.c | 5 ++++- inc/cwmp.h | 4 ++++ inc/diagnostic.h | 2 ++ ubus.c | 5 +++++ xml.c | 8 +++++++- 11 files changed, 61 insertions(+), 5 deletions(-) diff --git a/bin/Makefile.am b/bin/Makefile.am index 40ad9ca..1bf3dda 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -52,8 +52,15 @@ icwmpd_LDADD = \ $(LIBJSON_LIBS) \ $(LBLOBMSG_LIBS) \ $(LIBZ_LIBS) \ - $(LIBM_LIBS) \ + $(LIBM_LIBS) + +if TR098 +icwmpd_LDADD += \ + -ltr098 +else +icwmpd_LDADD += \ -lbbfdm +endif icwmpd_CFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\" icwmpd_LDFLAGS+=-DCWMP_VERSION=\"$(CWMP_VERSION)\" diff --git a/config.c b/config.c index 1903a8f..6b662bf 100644 --- a/config.c +++ b/config.c @@ -24,8 +24,13 @@ #include "backupSession.h" #include "xml.h" #include "log.h" +#ifdef TR098 +#include +#include +#else #include #include +#endif #include "config.h" pthread_mutex_t mutex_config_load = PTHREAD_MUTEX_INITIALIZER; diff --git a/configure.ac b/configure.ac index 49495bf..cf9c01c 100644 --- a/configure.ac +++ b/configure.ac @@ -26,6 +26,9 @@ AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug], [enable debugging message AC_ARG_ENABLE(devel, [AS_HELP_STRING([--enable-devel], [enable development messages])], AC_DEFINE(WITH_DEV_DEBUG),) AC_ARG_ENABLE(dummy_mode, [AS_HELP_STRING([--enable-dummy-mode], [enable dummy mode])], AC_DEFINE(DUMMY_MODE),) +AC_ARG_ENABLE(tr098, [AS_HELP_STRING([--enable-tr098], [enable tr098])], AC_DEFINE(TR098),) +AM_CONDITIONAL([TR098],[test "x$enable_tr098" = "xyes"]) + # checks for programs AC_PROG_CC AM_PROG_CC_C_O diff --git a/cwmp.c b/cwmp.c index 376602d..3f40766 100644 --- a/cwmp.c +++ b/cwmp.c @@ -26,9 +26,14 @@ #include "diagnostic.h" #include "config.h" #include +#ifdef TR098 +#include +#include +#else #include #include #include +#endif struct cwmp cwmp_main = {0}; @@ -522,7 +527,7 @@ int run_session_end_func (struct session *session) CWMP_LOG (INFO,"Executing ippingdiagnostic: end session request"); cwmp_ip_ping_diagnostic(); } - +#ifndef TR098 if (end_session_flag & END_SESSION_DOWNLOAD_DIAGNOSTIC) { CWMP_LOG (INFO,"Executing download diagnostic: end session request"); @@ -534,6 +539,7 @@ int run_session_end_func (struct session *session) CWMP_LOG (INFO,"Executing upload diagnostic: end session request"); cwmp_start_diagnostic(UPLOAD_DIAGNOSTIC); } +#endif if (end_session_flag & END_SESSION_REBOOT) { CWMP_LOG (INFO,"Executing Reboot: end session request"); @@ -671,7 +677,10 @@ int main(int argc, char **argv) pthread_t http_cr_server_thread; struct sigaction act = {0}; +#ifndef TR098 bbfdatamodel_type = BBFDM_CWMP; // To show only CWMP parameters +#endif + if (error = cwmp_init(argc, argv, cwmp)) { return error; diff --git a/diagnostic.c b/diagnostic.c index 6566bfe..5679bbd 100644 --- a/diagnostic.c +++ b/diagnostic.c @@ -24,6 +24,10 @@ #include "ubus.h" #include "diagnostic.h" #include "config.h" +#ifdef TR098 +#include +#include +#else #include #include #include @@ -109,6 +113,7 @@ int cwmp_start_diagnostic(int diagnostic_type) free(interface); return 0; } +#endif int cwmp_ip_ping_diagnostic() { diff --git a/event.c b/event.c index 6a27433..efa4db8 100644 --- a/event.c +++ b/event.c @@ -24,12 +24,19 @@ #include "jshn.h" #include "external.h" #include "config.h" +#ifdef TR098 +#include +#include +#include +#include +#include +#else #include #include #include #include #include - +#endif LIST_HEAD(list_value_change); LIST_HEAD(list_lw_value_change); pthread_mutex_t mutex_value_change = PTHREAD_MUTEX_INITIALIZER; diff --git a/external.c b/external.c index c351174..7f3f4ba 100644 --- a/external.c +++ b/external.c @@ -31,8 +31,11 @@ #include "cwmp.h" #include "xml.h" #include "log.h" +#ifdef TR098 +#include +#else #include - +#endif #include static int pid; static json_object *json_obj_in; diff --git a/inc/cwmp.h b/inc/cwmp.h index 62bf8d3..99afef0 100644 --- a/inc/cwmp.h +++ b/inc/cwmp.h @@ -19,7 +19,11 @@ #include #include #include +#ifdef TR098 +#include +#else #include +#endif #define MAX_EVENTS 64 #define MAX_INT32 2147483646 diff --git a/inc/diagnostic.h b/inc/diagnostic.h index 4c2cfe3..841a038 100644 --- a/inc/diagnostic.h +++ b/inc/diagnostic.h @@ -13,7 +13,9 @@ #define __DIAGNOSTIC__H int cwmp_ip_ping_diagnostic(); +#ifndef TR098 int cwmp_start_diagnostic(int diagnostic_type); +#endif int cwmp_nslookup_diagnostic(); int cwmp_traceroute_diagnostic(); int cwmp_udp_echo_diagnostic(); diff --git a/ubus.c b/ubus.c index 9529a60..ba4e002 100644 --- a/ubus.c +++ b/ubus.c @@ -19,8 +19,13 @@ #include "external.h" #include "xml.h" #include "log.h" +#ifdef TR098 +#include +#include +#else #include #include +#endif #include "netlink.h" static struct ubus_context *ctx = NULL; diff --git a/xml.c b/xml.c index 0545334..8e7b668 100644 --- a/xml.c +++ b/xml.c @@ -23,11 +23,17 @@ #include "backupSession.h" #include "log.h" #include "jshn.h" +#ifdef TR098 +#include +#include +#include +#include +#else #include #include #include #include - +#endif LIST_HEAD(list_download); LIST_HEAD(list_upload); LIST_HEAD(list_schedule_download);