From c20427b71b5032dec5605c409e91c8e8ba1e59d0 Mon Sep 17 00:00:00 2001 From: ChenLing <chenlinghy@cmhi.chinamobile.com> Date: Wed, 25 Sep 2019 15:14:12 +0800 Subject: [PATCH 1/2] =?UTF-8?q?Mod=20=20aaa-12=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=9C=A8=E7=BA=BF=E7=94=A8=E6=88=B7=E4=BF=A1=E6=81=AF=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E5=92=8C=E4=B8=8B=E7=BA=BF=E5=8A=9F=E8=83=BD=20RCA?= =?UTF-8?q?=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE=E6=94=B9=E4=BA=BA=EF=BC=9A?= =?UTF-8?q?chenling=20=E6=A3=80=E8=A7=86=E4=BA=BA=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../files/lighttpd/config/portal_modules.conf | 1 + libs/src/lighttpd-1.4.51/src/Makefile.am | 5 + libs/src/lighttpd-1.4.51/src/Makefile.in | 26 +- libs/src/lighttpd-1.4.51/src/mod_usermagnet.c | 520 ++++++++++++++++++ libs/src/lighttpd-1.4.51/src/user_auth.c | 12 +- libs/src/lighttpd-1.4.51/src/user_auth.h | 5 + 6 files changed, 563 insertions(+), 6 deletions(-) create mode 100644 libs/src/lighttpd-1.4.51/src/mod_usermagnet.c diff --git a/libs/files/lighttpd/config/portal_modules.conf b/libs/files/lighttpd/config/portal_modules.conf index 47430debd..699014e14 100644 --- a/libs/files/lighttpd/config/portal_modules.conf +++ b/libs/files/lighttpd/config/portal_modules.conf @@ -41,6 +41,7 @@ server.modules = ( "mod_portal", + "mod_usermagnet", # "mod_webm", # "mod_access", # "mod_alias", diff --git a/libs/src/lighttpd-1.4.51/src/Makefile.am b/libs/src/lighttpd-1.4.51/src/Makefile.am index 31f14592e..fe43ae7e2 100644 --- a/libs/src/lighttpd-1.4.51/src/Makefile.am +++ b/libs/src/lighttpd-1.4.51/src/Makefile.am @@ -414,6 +414,11 @@ mod_portal_la_SOURCES = mod_portal.c json.c user_hashtable.c user_auth.c mod_portal_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/ mod_portal_la_LIBADD = $(common_libadd) -ldatabase-$(host_cpu) +lib_LTLIBRARIES += mod_usermagnet.la +mod_usermagnet_la_SOURCES = mod_usermagnet.c json.c user_hashtable.c user_auth.c +mod_usermagnet_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/ +mod_usermagnet_la_LIBADD = $(common_libadd) -ldatabase-$(host_cpu) + hdr = server.h base64.h buffer.h burl.h network.h log.h http_kv.h keyvalue.h \ response.h request.h fastcgi.h chunk.h \ first.h settings.h http_chunk.h \ diff --git a/libs/src/lighttpd-1.4.51/src/Makefile.in b/libs/src/lighttpd-1.4.51/src/Makefile.in index b7d4b8f85..700ef57ac 100644 --- a/libs/src/lighttpd-1.4.51/src/Makefile.in +++ b/libs/src/lighttpd-1.4.51/src/Makefile.in @@ -583,6 +583,14 @@ mod_userdir_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ $(AM_CFLAGS) $(CFLAGS) $(mod_userdir_la_LDFLAGS) $(LDFLAGS) -o \ $@ +mod_usermagnet_la_DEPENDENCIES = $(am__DEPENDENCIES_2) +am_mod_usermagnet_la_OBJECTS = mod_usermagnet.lo json.lo \ + user_hashtable.lo user_auth.lo +mod_usermagnet_la_OBJECTS = $(am_mod_usermagnet_la_OBJECTS) +mod_usermagnet_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \ + $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \ + $(AM_CFLAGS) $(CFLAGS) $(mod_usermagnet_la_LDFLAGS) $(LDFLAGS) \ + -o $@ mod_usertrack_la_DEPENDENCIES = $(am__DEPENDENCIES_2) am_mod_usertrack_la_OBJECTS = mod_usertrack.lo mod_usertrack_la_OBJECTS = $(am_mod_usertrack_la_OBJECTS) @@ -925,9 +933,9 @@ SOURCES = $(liblightcomp_la_SOURCES) $(mod_access_la_SOURCES) \ $(mod_staticfile_la_SOURCES) $(mod_status_la_SOURCES) \ $(mod_trigger_b4_dl_la_SOURCES) \ $(mod_uploadprogress_la_SOURCES) $(mod_userdir_la_SOURCES) \ - $(mod_usertrack_la_SOURCES) $(mod_vhostdb_la_SOURCES) \ - $(mod_vhostdb_dbi_la_SOURCES) $(mod_vhostdb_ldap_la_SOURCES) \ - $(mod_vhostdb_mysql_la_SOURCES) \ + $(mod_usermagnet_la_SOURCES) $(mod_usertrack_la_SOURCES) \ + $(mod_vhostdb_la_SOURCES) $(mod_vhostdb_dbi_la_SOURCES) \ + $(mod_vhostdb_ldap_la_SOURCES) $(mod_vhostdb_mysql_la_SOURCES) \ $(mod_vhostdb_pgsql_la_SOURCES) $(mod_webdav_la_SOURCES) \ $(mod_webm_la_SOURCES) $(mod_wstunnel_la_SOURCES) \ $(lighttpd_SOURCES) $(lighttpd_angel_SOURCES) \ @@ -960,7 +968,8 @@ DIST_SOURCES = $(am__liblightcomp_la_SOURCES_DIST) \ $(mod_staticfile_la_SOURCES) $(mod_status_la_SOURCES) \ $(am__mod_trigger_b4_dl_la_SOURCES_DIST) \ $(mod_uploadprogress_la_SOURCES) $(mod_userdir_la_SOURCES) \ - $(mod_usertrack_la_SOURCES) $(mod_vhostdb_la_SOURCES) \ + $(mod_usermagnet_la_SOURCES) $(mod_usertrack_la_SOURCES) \ + $(mod_vhostdb_la_SOURCES) \ $(am__mod_vhostdb_dbi_la_SOURCES_DIST) \ $(am__mod_vhostdb_ldap_la_SOURCES_DIST) \ $(am__mod_vhostdb_mysql_la_SOURCES_DIST) \ @@ -1246,7 +1255,7 @@ lib_LTLIBRARIES = $(am__append_1) mod_flv_streaming.la $(am__append_3) \ $(am__append_14) $(am__append_15) mod_rewrite.la \ mod_redirect.la mod_status.la mod_accesslog.la \ mod_uploadprogress.la mod_wstunnel.la mod_webm.la \ - mod_portal.la + mod_portal.la mod_usermagnet.la @NO_RDYNAMIC_FALSE@common_ldflags = -avoid-version # if the linker doesn't allow referencing symbols of the binary @@ -1422,6 +1431,9 @@ mod_webm_la_LIBADD = $(common_libadd) mod_portal_la_SOURCES = mod_portal.c json.c user_hashtable.c user_auth.c mod_portal_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/ mod_portal_la_LIBADD = $(common_libadd) -ldatabase-$(host_cpu) +mod_usermagnet_la_SOURCES = mod_usermagnet.c json.c user_hashtable.c user_auth.c +mod_usermagnet_la_LDFLAGS = -module -export-dynamic -avoid-version -L../../../../Platform/build/debug/ +mod_usermagnet_la_LIBADD = $(common_libadd) -ldatabase-$(host_cpu) hdr = server.h base64.h buffer.h burl.h network.h log.h http_kv.h keyvalue.h \ response.h request.h fastcgi.h chunk.h \ first.h settings.h http_chunk.h \ @@ -1706,6 +1718,9 @@ mod_uploadprogress.la: $(mod_uploadprogress_la_OBJECTS) $(mod_uploadprogress_la_ mod_userdir.la: $(mod_userdir_la_OBJECTS) $(mod_userdir_la_DEPENDENCIES) $(EXTRA_mod_userdir_la_DEPENDENCIES) $(AM_V_CCLD)$(mod_userdir_la_LINK) -rpath $(libdir) $(mod_userdir_la_OBJECTS) $(mod_userdir_la_LIBADD) $(LIBS) +mod_usermagnet.la: $(mod_usermagnet_la_OBJECTS) $(mod_usermagnet_la_DEPENDENCIES) $(EXTRA_mod_usermagnet_la_DEPENDENCIES) + $(AM_V_CCLD)$(mod_usermagnet_la_LINK) -rpath $(libdir) $(mod_usermagnet_la_OBJECTS) $(mod_usermagnet_la_LIBADD) $(LIBS) + mod_usertrack.la: $(mod_usertrack_la_OBJECTS) $(mod_usertrack_la_DEPENDENCIES) $(EXTRA_mod_usertrack_la_DEPENDENCIES) $(AM_V_CCLD)$(mod_usertrack_la_LINK) -rpath $(libdir) $(mod_usertrack_la_OBJECTS) $(mod_usertrack_la_LIBADD) $(LIBS) @@ -2046,6 +2061,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_trigger_b4_dl.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_uploadprogress.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_userdir.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_usermagnet.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_usertrack.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_vhostdb.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mod_vhostdb_dbi_la-mod_vhostdb_dbi.Plo@am__quote@ diff --git a/libs/src/lighttpd-1.4.51/src/mod_usermagnet.c b/libs/src/lighttpd-1.4.51/src/mod_usermagnet.c new file mode 100644 index 000000000..9886b39b2 --- /dev/null +++ b/libs/src/lighttpd-1.4.51/src/mod_usermagnet.c @@ -0,0 +1,520 @@ +#include "first.h" +#include "base_decls.h" +#include "json.h" +#include "user_hashtable.h" +#include "base.h" +#include "plugin.h" +#include "http_auth.h" +#include "http_header.h" +#include "log.h" +#include "dlfcn.h" +#include "connections.h" +#include <stdlib.h> +#include <string.h> +#include <stdio.h> +#include <sys/socket.h> +#include "user_auth.h" +#include "arpa/inet.h" +#include "unistd.h" +#include "stddef.h" +#include "/usr/include/x86_64-linux-gnu/sys/socket.h" + +#define DEL_MAX_NUM (100) +#define DEL_MAX_SIZE (24) + +/*函数指针*/ +typedef void (*mod_usermagnet_cfg_exec_sync)(int page_num, int count, char *user_name, cJSON *array); + +typedef struct { + PLUGIN_DATA; + void *cfgm_lib; + mod_usermagnet_cfg_exec_sync usermagnet_cfg_exec; +} mod_usermagnet_plugin_data; + + +INIT_FUNC(mod_usermagnet_init) { + mod_usermagnet_plugin_data *p; + + p = calloc(1, sizeof(*p)); + + return p; +} + +/*认证模块释放*/ +FREE_FUNC(mod_usermagnet_free) { + mod_usermagnet_plugin_data *p = p_d; + srv = srv; + if (!p) return HANDLER_GO_ON; + + //dlclose(p->cfgm_lib); + free(p); + + return HANDLER_GO_ON; +} + +/*查询在线用户信息 +查询条件 1、用户IP 唯一性 + 2、用户名 一个用户名对应多个IP + 3、NULL 查询所有在线用户信息 +*/ +static handler_t get_onlineuser_info(server *srv, connection *con, void* p_d) +{ + p_d = p_d; + cJSON *cjson,*userip, *username, *Page_Num, *Count; + cJSON *pJsonArry; + USER_INFO *user_info; + uint32_t clientip; + char *ip = NULL; + char *name = NULL; + char *result_str = NULL; + int page_num = 0; + int count = 0; + char str[INET_ADDRSTRLEN]; + + user_info = (USER_INFO *)malloc(sizeof(USER_INFO)); + + if(NULL == user_info) + { + return HANDLER_ERROR; + } + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + /*get payload*/ + handler_t result = connection_handle_read_post_state(srv, con); + log_error_write(srv, __FILE__, __LINE__, "sd","test", result); + + if (result != HANDLER_GO_ON) + { + return result ; + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + buffer *b = buffer_init(); + chunkqueue *dst_cq = con->request_content_queue; + chunk *c = dst_cq->first; + if (NULL == c) + { + return HANDLER_ERROR; + } + + while(c != NULL) + { + buffer_append_string(b, c->mem->ptr + c->offset); + c = c->next; + } + + log_error_write(srv, __FILE__, __LINE__, "sb","test",b); + + /*JSON字符串到JSON格式 */ + cjson = cJSON_Parse(b->ptr); + if(!cjson) + { + return HANDLER_ERROR; + } + + /*get userip */ + userip = cJSON_GetObjectItem(cjson , "user_ip"); + if(userip) + { + ip = userip->valuestring; + log_error_write(srv, __FILE__, __LINE__, "ss", "test", ip); + } + + /*get username*/ + username = cJSON_GetObjectItem(cjson , "user_name"); + if(username) + { + name = username->valuestring; + log_error_write(srv, __FILE__, __LINE__, "ss", "test", name); + } + + /*get page_num*/ + Page_Num = cJSON_GetObjectItem(cjson, "page_num"); + if(Page_Num) + { + page_num = Page_Num->valueint; + log_error_write(srv, __FILE__, __LINE__, "sd", "test", page_num); + } + + /*get count*/ + Count = cJSON_GetObjectItem(cjson, "count"); + if(Count) + { + count = Count->valueint; + log_error_write(srv, __FILE__, __LINE__, "sd", "test", count); + } + + /*如果用户IP存在 通过用户IP查询在线用户信息*/ + if(ip != NULL) + { + cJSON *data, *res; + + /*点分十进制转化十进制*/ + inet_pton(AF_INET, ip, &clientip); + log_error_write(srv, __FILE__, __LINE__, "sd", "test", clientip); + + /*通过用户IP地址查找用户信息*/ + user_info = ufind_user_by_ippage(page_num, count, clientip); + if(user_info == NULL) /*无符合条件的用户信息*/ + { + /*创建json对象*/ + res = cJSON_CreateObject(); + if(!res) return HANDLER_ERROR; + + cJSON_AddNumberToObject(res, "resultcode", 0); + cJSON_AddStringToObject(res, "message", "查询成功"); + cJSON_AddStringToObject(res, "data", ""); + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + } + else + { + /*创建json对象*/ + data = cJSON_CreateObject(); + if(!data) + { + return HANDLER_ERROR; + } + + memset(str, 0, INET_ADDRSTRLEN); + inet_ntop(AF_INET,&user_info->auth_user.user_ip, str, sizeof(str)); + + cJSON_AddStringToObject(data, "user_ip", str); + cJSON_AddStringToObject(data, "user_name", user_info->auth_user.user_name); + cJSON_AddNumberToObject(data, "user_id", user_info->auth_user.user_id); + cJSON_AddNumberToObject(data, "group_id", user_info->auth_user.group_id); + cJSON_AddNumberToObject(data, "message_num", user_info->auth_user.message_num); + cJSON_AddNumberToObject(data, "byte_num", user_info->auth_user.byte_num); + cJSON_AddNumberToObject(data, "online_time", user_info->auth_user.online_time); + + /*创建json对象*/ + res = cJSON_CreateObject(); + if(!res) + { + return HANDLER_ERROR; + } + + cJSON_AddNumberToObject(res, "resultcode", 0); + cJSON_AddStringToObject(res, "message", "查询成功"); + cJSON_AddItemToObject(res, "data", data); + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + } + + /*json对象转换为json字符串*/ + result_str = cJSON_Print(res); + buffer *result_info = buffer_init(); + result_info = buffer_init_string(result_str); + chunkqueue_append_buffer(con->write_queue, result_info); + buffer_free(result_info); + con->http_status = 200; + con->file_finished = 1; + cJSON_Delete(res); + + return HANDLER_FINISHED; + } + else + { + cJSON *res; + log_error_write(srv, __FILE__, __LINE__, "ss", "test", username->valuestring); + ufind_user_by_name(page_num, count, username->valuestring, &pJsonArry); + + /*计算数组长度 如果为0 说明没有在线用户信息*/ + int iCount = cJSON_GetArraySize(pJsonArry); + log_error_write(srv, __FILE__, __LINE__, "sd", "test", iCount); + + if(iCount == 0) + { + /*创建json对象*/ + res = cJSON_CreateObject(); + if(!res) return HANDLER_ERROR; + + cJSON_AddNumberToObject(res, "resultcode", 0); + cJSON_AddStringToObject(res, "message", "查询成功"); + cJSON_AddStringToObject(res, "data", ""); + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + } + else + { + /*创建json对象*/ + res = cJSON_CreateObject(); + if(!res) + { + return HANDLER_ERROR; + } + + cJSON_AddNumberToObject(res, "resultcode", 0); + cJSON_AddStringToObject(res, "message", "查询成功"); + cJSON_AddItemToObject(res, "data", pJsonArry); + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + } + + /*json对象转换为json字符串*/ + result_str = cJSON_Print(res); + buffer *result_info = buffer_init(); + result_info = buffer_init_string(result_str); + chunkqueue_append_buffer(con->write_queue, result_info); + buffer_free(result_info); + con->http_status = 200; + con->file_finished = 1; + cJSON_Delete(res); + } + + return HANDLER_FINISHED; +} + + +/*在线用户(单个、批量)下线*/ +/*iuput格式: +{ + "data": [ + {"user_ip":"192.168.1.1", "user_port": 1010}, + {"user_ip":"192.168.1.2", "user_port": 1010}, + {"user_ip":"192.168.1.3", "user_port": 1010} + ] +} +*/ +/*删除所有在线用户*/ +/*iuput格式: +{ + "data":"all", +} +*/ +static handler_t user_offline(server *srv, connection *con, void* p_d) +{ + p_d = p_d; + cJSON *cjson, *useripArry, *userip,*res; + cJSON *DelArry =NULL; + cJSON *Delsub; + uint32_t clientip; + int iCount; + char *result_str = NULL; + USER_INFO *user_info; + int del_num = 0; + char str[INET_ADDRSTRLEN]; + char del[DEL_MAX_NUM][DEL_MAX_SIZE] = {0}; + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + /*get payload*/ + handler_t result = connection_handle_read_post_state(srv, con); + log_error_write(srv, __FILE__, __LINE__, "sd","test", result); + + if (result != HANDLER_GO_ON) + { + return result ; + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + buffer *b = buffer_init(); + chunkqueue *dst_cq = con->request_content_queue; + chunk *c = dst_cq->first; + if (NULL == c) + { + return HANDLER_ERROR; + } + + while(c != NULL) + { + buffer_append_string(b, c->mem->ptr + c->offset); + c = c->next; + } + + log_error_write(srv, __FILE__, __LINE__, "sb","test",b); + + /*JSON字符串到JSON格式 */ + cjson = cJSON_Parse(b->ptr); + if(!cjson) + { + return HANDLER_ERROR; + } + + /*get data解析数组 */ + useripArry = cJSON_GetObjectItem(cjson , "data"); + if(!useripArry) + { + return HANDLER_ERROR; + } + + /*获取数组长度*/ + iCount = cJSON_GetArraySize(useripArry); + log_error_write(srv, __FILE__, __LINE__, "sd","test", iCount); + + + for(int i = 0; i < iCount; i++) + { + cJSON *pArrayItem = cJSON_GetArrayItem(useripArry, i); + if(pArrayItem) + { + /*用户IP地址*/ + userip = cJSON_GetObjectItem(pArrayItem, "user_ip"); + log_error_write(srv, __FILE__, __LINE__, "sd","test", i); + if(userip) + { + /*点分十进制转为十进制*/ + inet_pton(AF_INET, userip->valuestring, &clientip); + log_error_write(srv, __FILE__, __LINE__, "sds","test", clientip, userip->valuestring); + + user_info = ufind_user(clientip); + + if(NULL != user_info) + { + /*根据用户IP删除用户信息*/ + udelete_user(clientip); + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + memset(str, 0, INET_ADDRSTRLEN); + inet_ntop(AF_INET, &clientip, str, sizeof(str)); + log_error_write(srv, __FILE__, __LINE__, "ssd","test" , str, del_num); + strncpy(del[del_num], str, 24); + log_error_write(srv, __FILE__, __LINE__, "ssd","test" , del[del_num], del_num); + del_num++; + } + } + } + } + + DelArry = cJSON_CreateArray(); /*创建数组*/ + + if(del_num == 0) + { + /*创建json对象*/ + res = cJSON_CreateObject(); + if(!res) + { + return HANDLER_ERROR; + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + cJSON_AddNumberToObject(res, "resultcode", 0); + cJSON_AddStringToObject(res, "message", "删除成功"); + cJSON_AddStringToObject(res, "data", ""); + log_error_write(srv, __FILE__, __LINE__, "s","test"); + } + else + { + for(int i = 0; i < del_num; i++) + { + char ipAddr[INET_ADDRSTRLEN]; + memset(ipAddr, 0, INET_ADDRSTRLEN); + + log_error_write(srv, __FILE__, __LINE__, "sd","test", i); + + cJSON_AddItemToArray(DelArry, Delsub = cJSON_CreateObject()); /* 给创建的数组增加对象*/ + + strncpy(ipAddr, del[i], INET_ADDRSTRLEN); + log_error_write(srv, __FILE__, __LINE__, "ss","test", ipAddr); + cJSON_AddStringToObject(Delsub, "user_ip", ipAddr); + log_error_write(srv, __FILE__, __LINE__, "s","test"); + } + + /*创建json对象*/ + res = cJSON_CreateObject(); + if(!res) + { + return HANDLER_ERROR; + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + cJSON_AddNumberToObject(res, "resultcode", 0); + cJSON_AddStringToObject(res, "message", "删除成功"); + cJSON_AddItemToObject(res, "data", DelArry); + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + /*json对象转换为json字符串*/ + result_str = cJSON_Print(res); + buffer *result_info = buffer_init(); + result_info = buffer_init_string(result_str); + chunkqueue_append_buffer(con->write_queue, result_info); + buffer_free(result_info); + con->http_status = 200; + con->file_finished = 1; + cJSON_Delete(res); + + return HANDLER_FINISHED; +} + + +/*根据传输过来的url分情况执行*/ +static handler_t mod_usermagnet_uri_handler(server *srv, connection *con, void* p_d) +{ + /*case 1 根据不同条件查询用户信息 + case 2 -选择用户下线*/ + log_error_write(srv, __FILE__, __LINE__, "s","mod_usermagnet_uri_handler"); + + handler_t t = HANDLER_GO_ON; + p_d = p_d; + if (con->request.http_method == HTTP_METHOD_GET) + { + return HANDLER_GO_ON; + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + if (con->state == CON_STATE_READ_POST) { + chunkqueue *cq = con->request_content_queue; + if (cq->bytes_in != (off_t)con->request.content_length) { + handler_t r = connection_handle_read_post_state(srv, con); + if (r != HANDLER_GO_ON) return r; + } + } + else if (0 == con->request.content_length) + { + return HANDLER_GO_ON; + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + /*url 与"/user-get"匹配,根据条件查询用户信息*/ + if (0 == strcmp(con->uri.path->ptr, "/user-get")) + { + t = get_onlineuser_info(srv, con, p_d); + log_error_write(srv, __FILE__, __LINE__, "s","test"); + } + else if (0 == strcmp(con->uri.path->ptr, "/user-offline")) + { + t = user_offline(srv, con, p_d); + log_error_write(srv, __FILE__, __LINE__, "s","test"); + + } + + log_error_write(srv, __FILE__, __LINE__, "s","test"); + con->http_status = 200; + con->file_finished = 1; + return t; +} + + +SETDEFAULTS_FUNC(mod_usermagnet_set_defaults) +{ + mod_usermagnet_plugin_data *p = p_d; + p = p;//解决编译告警; + //srv = srv;//解决编译告警; + + init_svr_ptr(srv); + + return HANDLER_GO_ON; +} + + +int mod_usermagnet_plugin_init(plugin *p); +int mod_usermagnet_plugin_init(plugin *p) { + p->version = LIGHTTPD_VERSION_ID; + p->name = buffer_init_string("usermagnet"); + p->init = mod_usermagnet_init; + p->set_defaults = mod_usermagnet_set_defaults; + p->handle_uri_clean = mod_usermagnet_uri_handler; + p->cleanup = mod_usermagnet_free; + p->data = NULL; + + return 0; +} + + + diff --git a/libs/src/lighttpd-1.4.51/src/user_auth.c b/libs/src/lighttpd-1.4.51/src/user_auth.c index 4081cf77c..e03db6ef6 100644 --- a/libs/src/lighttpd-1.4.51/src/user_auth.c +++ b/libs/src/lighttpd-1.4.51/src/user_auth.c @@ -17,6 +17,7 @@ #define UDESIZE (63) #define UPWDSIZE (63) +static server* b_svr = NULL; void * g_auth_hdbc = NULL; //用户认证连接句柄 typedef struct user_auth @@ -487,6 +488,7 @@ void user_auth_login(char* username, char* password, USER_AUTH_RET *auth_result) /* 连接数据库 */ if(NULL == g_auth_hdbc) { + //log_error_write(b_svr, __FILE__, __LINE__, "s","test"); g_auth_hdbc = connect_database(20); } @@ -496,6 +498,7 @@ void user_auth_login(char* username, char* password, USER_AUTH_RET *auth_result) bool ret_getconfig = get_config_data(g_auth_hdbc, config_data); if (!ret_getconfig) { + //log_error_write(b_svr, __FILE__, __LINE__, "s","test"); auth_result->ret = AUTH_FAIL_LACKINFO; return; } @@ -689,4 +692,11 @@ void reset_online_by_groupid(int *group_ids) g_user_auth_ret_table[i].online_num = 0; } } -} \ No newline at end of file +} + +void binit_svr_ptr(void *srv) +{ + if(srv) { + b_svr = (server*)srv; + } +} diff --git a/libs/src/lighttpd-1.4.51/src/user_auth.h b/libs/src/lighttpd-1.4.51/src/user_auth.h index 53bba5eee..afb3f15ae 100644 --- a/libs/src/lighttpd-1.4.51/src/user_auth.h +++ b/libs/src/lighttpd-1.4.51/src/user_auth.h @@ -3,6 +3,9 @@ #include <time.h> +struct server; +typedef struct server server; + typedef enum { AUTH_SUCCESS = 0, AUTH_FAIL_PASSWD = 1, @@ -64,4 +67,6 @@ void reset_online_by_userid(int *user_ids, int num); /* 用户在线节点重置-按用户组id */ void reset_online_by_groupid(int *group_ids); +void binit_svr_ptr(void *srv); + #endif \ No newline at end of file From b0a174cf303ba2611fd55ccea9e49e36e5d2391f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=98=95?= <huangxin@cmhi.chinamobile.com> Date: Wed, 25 Sep 2019 15:42:59 +0800 Subject: [PATCH 2/2] =?UTF-8?q?Mod=20=20aaa-12=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E5=AF=B9=E8=B1=A1=E7=AE=A1=E7=90=86=E5=88=A0=E9=99=A4=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20RCA=EF=BC=9A=20SOL=EF=BC=9A=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BA=BA=EF=BC=9Ahuangxin=20=E6=A3=80=E8=A7=86=E4=BA=BA?= =?UTF-8?q?=EF=BC=9Ahuangxin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Product/common/common.h | 95 +++++++++++++ Product/modules/proc_api/proc_api.c | 1 + Product/modules/proc_api/proc_api.h | 2 - Product/user/object_manager/json_interface.c | 75 ++++++++-- Product/user/object_manager/json_interface.h | 22 ++- Product/user/object_manager/main.c | 142 ++++++++++++++----- 6 files changed, 280 insertions(+), 57 deletions(-) diff --git a/Product/common/common.h b/Product/common/common.h index 70696f1e2..b86a0e3de 100644 --- a/Product/common/common.h +++ b/Product/common/common.h @@ -42,4 +42,99 @@ #define RET_SENDERR 13 #define RET_NOCMID 14 #define RET_SRCERR 15 +#define RET_JSONERR 16 +#define RET_USED 17 + +static inline char *get_err_message(int err) +{ + if(err < 0) { + err = -err; + } + + switch(err) { + case RET_OK: return "OK"; + + case RET_ERR: return "Error"; + + case RET_UNKNOWN: return "Unkown"; + + case RET_SYSERR: return "SystemError"; + + case RET_NOTFOUND: return "NotFound"; + + case RET_TIMEOUT: return "Timeout"; + + case RET_NULLP: return "NullPointer" ; + + case RET_NOMEM: return "NotEnoughMemory"; + + case RET_CHKERR: return "CheckError"; + + case RET_NOTSUPPORT: return "NotSupport"; + + case RET_INPUTERR: return "InputError"; + + case RET_EXIST: return "AlreadyExist"; + + case RET_FULL: return "Full"; + + case RET_SENDERR: return "SendErr"; + + case RET_NOCMID: return "CanNotFindConfig"; + + case RET_SRCERR: return "ConfigSourceErr"; + + case RET_JSONERR: return "JsonFormatErr"; + + case RET_USED: return "ItemUsed"; +#if 0 + + case RET_IPINVALID: return "IpInvalid"; + + case RET_BRNAMEERR: return "BrNameInvalid"; + + case RET_VIDNUM_INVALID: return "VidNumInvalid"; + + case RET_VID_INVALID: return "VidValueInvalid"; + + case RET_VID_EXIST: return "VidHasExist"; + + case RET_VID_NOT_EXIST: return "VidHasNotExist"; + + case RET_INTERFACE_NOT_EXIST: return "InterfaceHasNotExist"; + + case RET_ATTR_INVALID: return "AttrInvalid"; + + case RET_OPTYPE_ERR: return "OperationTypeError"; + + case RET_SYS_VCONFIG_ERR: return "SystemVconfigError"; + + case RET_SYS_IFCONFIG_ERR: return "SystemIfconfigError"; + + case RET_SYS_FILEOP_ERR: return "SystemFileOperationError"; + + case RET_OPEN_FILE_ERR: return "CanNotOpenConfigFile"; + + case RET_EXEC_ERR: return "CanNotExecuateShell"; + + case RET_METRIC_ERR: return "InvalidMetric"; + + case RET_NETMASK_ERR: return "InvalidNetmask"; + + case RET_EMPTY_STRING: return "InputEmpty"; + + case RET_WRONG_TYPE: return "WrongType"; + + case RET_VERSION_ERR: return "InvalidProtocol"; + + case RET_DESTIP_ERR: return "InvalidDestIP"; + + case RET_GATEWAY_ERR: return "InvalidGateway"; + + case RET_GW_DEV_ERR: return "Gateway&DevEmpty"; +#endif + } + + return "Unknown err code"; +} #endif \ No newline at end of file diff --git a/Product/modules/proc_api/proc_api.c b/Product/modules/proc_api/proc_api.c index 39c68c0c2..f53fd829a 100644 --- a/Product/modules/proc_api/proc_api.c +++ b/Product/modules/proc_api/proc_api.c @@ -12,6 +12,7 @@ #include "proc_api.h" #include "../../common/uthash.h" +#include "../../common/common.h" #define MAX_COMMAND_LEN (256) #define MAX_CMD_LEN (32) diff --git a/Product/modules/proc_api/proc_api.h b/Product/modules/proc_api/proc_api.h index 7447272c0..263cd020d 100644 --- a/Product/modules/proc_api/proc_api.h +++ b/Product/modules/proc_api/proc_api.h @@ -4,8 +4,6 @@ #include <asm/atomic.h> -#include "../../common/common.h" - #define PROC_API_DIR_NAME ("isg") typedef enum { diff --git a/Product/user/object_manager/json_interface.c b/Product/user/object_manager/json_interface.c index 231daf7cb..e3208cfac 100644 --- a/Product/user/object_manager/json_interface.c +++ b/Product/user/object_manager/json_interface.c @@ -4,8 +4,6 @@ #include <time.h> #include <cjson/cJSON.h> -#include "../../common/common.h" - #include "log.h" #include "json_interface.h" @@ -72,7 +70,8 @@ static int __interface_decode(const char *pJsonS, void **pStruct) pData->timeStamp = cJSON_GetObjectItem(pRoot, "timeStamp")->valueint; if(cJSON_HasObjectItem(pRoot, "msgContent")) { - pData->msgContent = strdup(cJSON_GetObjectItem(pRoot, "msgContent")->valuestring); + pData->msgContent = strdup(cJSON_GetObjectItem(pRoot, + "msgContent")->valuestring); } cJSON_Delete(pRoot); @@ -82,7 +81,48 @@ static int __interface_decode(const char *pJsonS, void **pStruct) static const char *__obj_add_encode(void *pData) { + const char *pJsonS; + PIFC_RET_MSG p = (PIFC_RET_MSG)pData; + cJSON *pRoot = cJSON_CreateObject(); + if(!p) { + return NULL; + } + + cJSON_AddNumberToObject(pRoot, "ret_code", p->ret_code); + + if(p->mesg) { + cJSON_AddStringToObject(pRoot, "mesg", p->mesg); + } + + if(p->n_items > 0) { + int i; + cJSON *pArray = cJSON_AddArrayToObject(pRoot, "data"); + + if(pArray) { + for(i = 0; i < p->n_items; i++) { + cJSON *pItem = cJSON_CreateObject(); + + if(!pItem) { + continue; + } + + cJSON_AddStringToObject(pItem, "name", p->data[i].name); + cJSON_AddNumberToObject(pItem, "ret_code", p->data[i].ret_code); + + if(p->data[i].mesg) { + cJSON_AddStringToObject(pItem, "mesg", p->data[i].mesg); + } + + cJSON_AddItemToArray(pArray, pItem); + } + } + } + + pJsonS = cJSON_Print(pRoot); + cJSON_Delete(pRoot); + + return pJsonS; } static int __obj_add_decode(const char *pJsonS, void **pStruct) @@ -147,25 +187,32 @@ static int __obj_add_decode(const char *pJsonS, void **pStruct) pObj->prio = cJSON_GetObjectItem(pSub, "prio")->valueint; pObjK->type = cJSON_GetObjectItem(pSub, "type")->valueint; - strncpy(pObj->name, cJSON_GetObjectItem(pSub, "name")->valuestring, MAX_NAME_LEN - 1); - strncpy(pObj->desc, cJSON_GetObjectItem(pSub, "desc")->valuestring, MAX_DESC - 1); + strncpy(pObj->name, cJSON_GetObjectItem(pSub, "name")->valuestring, + MAX_NAME_LEN - 1); + strncpy(pObj->desc, cJSON_GetObjectItem(pSub, "desc")->valuestring, + MAX_DESC - 1); for(j = 0; j < pObjK->ctx_num; j++) { cJSON *pItem = cJSON_GetArrayItem(pSubContent, j); switch(pObjK->type / 10) { case OBJ_TYPE_SERVER: - pObjK->objs.svr_obj[j].pro_type = cJSON_GetObjectItem(pItem, "proType")->valueint; - pObjK->objs.svr_obj[j].str_val = strdup(cJSON_GetObjectItem(pItem, "porPort")->valuestring); + pObjK->objs.svr_obj[j].pro_type = cJSON_GetObjectItem(pItem, + "proType")->valueint; + pObjK->objs.svr_obj[j].str_val = strdup(cJSON_GetObjectItem(pItem, + "porPort")->valuestring); break; case OBJ_TYPE_ADDR: - pObjK->objs.addr_obj[j].str_val = strdup(cJSON_GetObjectItem(pItem, "ipAddr")->valuestring); + pObjK->objs.addr_obj[j].str_val = strdup(cJSON_GetObjectItem(pItem, + "ipAddr")->valuestring); break; case OBJ_TYPE_DATETIME: - pObjK->objs.dt_obj[j].rep_mode = cJSON_GetObjectItem(pItem, "repType")->valueint; - pObjK->objs.dt_obj[j].str_val = strdup(cJSON_GetObjectItem(pItem, "timeValue")->valuestring); + pObjK->objs.dt_obj[j].rep_mode = cJSON_GetObjectItem(pItem, + "repType")->valueint; + pObjK->objs.dt_obj[j].str_val = strdup(cJSON_GetObjectItem(pItem, + "timeValue")->valuestring); break; } } @@ -179,10 +226,11 @@ static int __obj_add_decode(const char *pJsonS, void **pStruct) static JSON_ENGINE g_jSonEngine[] = { {JE_INTERFACE, __interface_encode, __interface_decode, NULL}, - {OBJ_CMD_ADD, NULL, __obj_add_decode, NULL} + {OBJ_CMD_ADD, __obj_add_encode, __obj_add_decode, NULL}, }; -int Json2Struct(const char *pJsonStr, void *pData, JSON_ENGINE_TYPE type, int enBase64) +int Json2Struct(const char *pJsonStr, void *pData, JSON_ENGINE_TYPE type, + int enBase64) { if(pJsonStr == NULL || pData == NULL) { return -RET_INPUTERR; @@ -207,7 +255,8 @@ int Json2Struct(const char *pJsonStr, void *pData, JSON_ENGINE_TYPE type, int en } } -const char *Struct2Json(void *pStruct, JSON_ENGINE_TYPE type, int enBase64, int *pErr) +const char *Struct2Json(void *pStruct, JSON_ENGINE_TYPE type, int enBase64, + int *pErr) { if(pStruct == NULL || pErr == NULL) { if(pErr) { diff --git a/Product/user/object_manager/json_interface.h b/Product/user/object_manager/json_interface.h index f386afbec..c844727f3 100644 --- a/Product/user/object_manager/json_interface.h +++ b/Product/user/object_manager/json_interface.h @@ -13,8 +13,7 @@ typedef enum { OBJ_CMD_QUERYDETAIL = 104, } JSON_CMD; -typedef enum -{ +typedef enum { JE_INTERFACE, JE_OBJ_ADD, JE_OBJ_MOD, @@ -47,8 +46,23 @@ typedef struct { int n_obj; } IFACE_ADD_OBJ, *PIFACE_ADD_OBJ; -int Json2Struct(const char *pJsonStr, void* pData, JSON_ENGINE_TYPE type, int enBase64); -const char* Struct2Json(void* pStruct, JSON_ENGINE_TYPE type, int enBase64, int* pErr); +typedef struct { + char *name; + char *mesg; + int ret_code; +} IFC_RET_LIST, *PIFC_RET_LIST; + +typedef struct { + int ret_code; + char *mesg; + int n_items; + IFC_RET_LIST data[100]; +} IFC_RET_MSG, *PIFC_RET_MSG; + +int Json2Struct(const char *pJsonStr, void *pData, JSON_ENGINE_TYPE type, + int enBase64); +const char *Struct2Json(void *pStruct, JSON_ENGINE_TYPE type, int enBase64, + int *pErr); #ifdef __cplusplus } diff --git a/Product/user/object_manager/main.c b/Product/user/object_manager/main.c index 3c751d8c9..03e0ffa89 100644 --- a/Product/user/object_manager/main.c +++ b/Product/user/object_manager/main.c @@ -25,7 +25,7 @@ static PCMHI_OBJECT g_pObject = NULL; static OBJECT_K g_objItem[MAX_OBJ]; static pthread_mutex_t g_obj_lock = PTHREAD_MUTEX_INITIALIZER; -int split_params(char *pInput, char **pFirst, char **pSecond, const char *split) +static int split_params(char *pInput, char **pFirst, char **pSecond, const char *split) { char *pStr = (char *)pInput; char *p; @@ -174,7 +174,7 @@ int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK) switch(pObjK->type / 10) { case OBJ_TYPE_SERVER: - split_params((char*)pSvr->str_val, &pStart, &pEnd, "-"); + split_params((char *)pSvr->str_val, &pStart, &pEnd, "-"); if(!pcre_match(REGEX_SVR_PORT, pStart)) { LOG_EX(LOG_Error, "Input %s format error\n", pStart); @@ -210,14 +210,14 @@ int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK) break; case OBJ_TYPE_ADDR: - split_params((char*)pAddr->str_val, &pStart, &pEnd, "-"); + split_params((char *)pAddr->str_val, &pStart, &pEnd, "-"); if(!pcre_match(REGEX_IP_ADDR, pStart)) { LOG_EX(LOG_Error, "Input %s format error\n", pStart); return -RET_INPUTERR; } - split_params((char*)pStart, &pSubStart, &pSubEnd, "/"); + split_params((char *)pStart, &pSubStart, &pSubEnd, "/"); if(pSubEnd && strlen(pSubEnd) > 0) { pAddr->net_mask = strtoul(pSubEnd, NULL, 10); @@ -263,7 +263,7 @@ int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK) break; case OBJ_TYPE_DATETIME: - split_params((char*)pDt->str_val, &pStart, &pEnd, "-"); + split_params((char *)pDt->str_val, &pStart, &pEnd, "-"); if(!pcre_match(REGEX_DT, pStart)) { LOG_EX(LOG_Error, "Input %s format error\n", pStart); @@ -332,6 +332,34 @@ int object_add(PCMHI_OBJECT pObj, POBJECT_K pObjK) pthread_mutex_unlock(&g_obj_lock); } +int object_del(const char* pName) +{ + PCMHI_OBJECT p, pTmp; + + pthread_mutex_lock(&g_obj_lock); + HASH_FIND_STR(g_pObject, pName, p); + pthread_mutex_unlock(&g_obj_lock); + + if(p == NULL) { + LOG_EX(LOG_Error, "Item %s exists\n", p->name); + return -RET_NOTFOUND; + } + + if(g_objItem[p->obj_index].ref_count > 0) { + LOG_EX(LOG_Error, "Item %s used %d\n", p->name, g_objItem[p->obj_index].ref_count); + return -RET_USED; + } + + pthread_mutex_lock(&g_obj_lock); + HASH_DEL(g_pObject, p); + pthread_mutex_unlock(&g_obj_lock); + + memset(&g_objItem[p->obj_index].memTag, 0, sizeof(OBJECT_K)); + free(p); + + return RET_OK; +} + static const char *read_json_file(const char *pPath) { FILE *pFile; @@ -369,18 +397,45 @@ static const char *read_json_file(const char *pPath) return (const char *)pBuf; } +static void test_del_object(void) +{ + +} + static void test_add_object(void) { - PJSON_INTERFACE p = NULL; - PIFACE_ADD_OBJ pAdd = NULL; - int i, j, ret; - const char *pJson = read_json_file(ADD_JS_FILE); + int i, ret; + const char *pRetJson; + IFC_RET_MSG retCtx; + PJSON_INTERFACE p = NULL; + PIFACE_ADD_OBJ pAdd = NULL; + const char *pJson = read_json_file(ADD_JS_FILE); ret = Json2Struct(pJson, &p, JE_INTERFACE, FALSE); + memset(&retCtx, 0, sizeof(IFC_RET_MSG)); + if(ret != RET_OK || p == NULL) { LOG_EX(LOG_Error, "Decode json error: %d\n", ret); - free((void*)pJson); + free((void *)pJson); + + if(p) { + free(p); + } + + retCtx.ret_code = -RET_JSONERR; + retCtx.mesg = get_err_message(RET_JSONERR); + retCtx.n_items = 0; + + pRetJson = Struct2Json(&retCtx, JE_OBJ_ADD, FALSE, &ret); + + if(!pRetJson || ret != RET_OK) { + LOG_EX(LOG_Error, "Json format error: %d\n", ret); + return; + } + + LOG_EX(LOG_Debug, "Respons:\n%s\n", pRetJson); + free((void *)pRetJson); return; } @@ -396,56 +451,67 @@ static void test_add_object(void) LOG_EX(LOG_Error, "Decode json error: %d\n", ret); if(p->msgContent) { - free((void*)p->msgContent); + free((void *)p->msgContent); } free(p); - free((void*)pJson); + free((void *)pJson); + + retCtx.ret_code = -RET_JSONERR; + retCtx.mesg = get_err_message(RET_JSONERR); + retCtx.n_items = 0; + + pRetJson = Struct2Json(&retCtx, JE_OBJ_ADD, FALSE, &ret); + + if(!pRetJson || ret != RET_OK) { + LOG_EX(LOG_Error, "Json format error: %d\n", ret); + return; + } + + LOG_EX(LOG_Debug, "Respons:\n%s\n", pRetJson); + free((void *)pRetJson); + return; + } else { + retCtx.n_items = pAdd->n_obj; } for(i = 0; i < pAdd->n_obj; i++) { - LOG_EX(LOG_Info, "name: %s\n", pAdd->pCtx[i].obj.name); - LOG_EX(LOG_Info, "desc: %s\n", pAdd->pCtx[i].obj.desc); - LOG_EX(LOG_Info, "prio: %d\n", pAdd->pCtx[i].obj.prio); - LOG_EX(LOG_Info, "type: %d\n", pAdd->pCtx[i].objk.type); - LOG_EX(LOG_Info, "items: %d\n", pAdd->pCtx[i].objk.ctx_num); + ret = object_add(&pAdd->pCtx[i].obj, &pAdd->pCtx[i].objk); - for(j = 0; j < pAdd->pCtx[i].objk.ctx_num; j++) { - POBJECT_K pObjK = &pAdd->pCtx[i].objk; - - switch(pObjK->type / 10) { - case OBJ_TYPE_SERVER: - LOG_EX(LOG_Info, " porType: %d\n", pObjK->objs.svr_obj[j].pro_type); - LOG_EX(LOG_Info, " value: %s\n", pObjK->objs.svr_obj[j].str_val); - break; - - case OBJ_TYPE_ADDR: - LOG_EX(LOG_Info, " value: %s\n", pObjK->objs.addr_obj[j].str_val); - break; - - case OBJ_TYPE_DATETIME: - LOG_EX(LOG_Info, " repeat: %d\n", pObjK->objs.dt_obj[j].rep_mode); - LOG_EX(LOG_Info, " value: %s\n", pObjK->objs.dt_obj[j].str_val); - break; - } + if(ret != RET_OK && retCtx.ret_code == RET_OK) { + retCtx.ret_code = -RET_JSONERR; } - object_add(&pAdd->pCtx[i].obj, &pAdd->pCtx[i].objk); + retCtx.data[i].name = pAdd->pCtx[i].obj.name; + retCtx.data[i].ret_code = ret; + retCtx.data[i].mesg = get_err_message(ret); } dump_object(); + retCtx.mesg = get_err_message(retCtx.data[i].ret_code); + + pRetJson = Struct2Json(&retCtx, JE_OBJ_ADD, FALSE, &ret); + + if(!pRetJson || ret != RET_OK) { + LOG_EX(LOG_Error, "Json format error: %d\n", ret); + return; + } + + LOG_EX(LOG_Debug, "Respons:\n%s\n", pRetJson); + free((void *)pRetJson); + if(pAdd) { free(pAdd); } if(p->msgContent) { - free((void*)p->msgContent); + free((void *)p->msgContent); } free(p); - free((void*)pJson); + free((void *)pJson); } static void test_strsep(char *pVal)