From 9fe48bc1aeb4ab99d5e53ee73d7e4b365fa111d6 Mon Sep 17 00:00:00 2001 From: huangxin Date: Mon, 30 Jan 2023 10:43:20 +0800 Subject: [PATCH] =?UTF-8?q?OCT=201.=20=E4=BF=AE=E6=AD=A3=E4=B8=80=E5=A4=84?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E5=AD=98=E5=9C=A8=E7=9A=84=E5=86=85=E5=AD=98?= =?UTF-8?q?=E5=BC=82=E5=B8=B8=E9=97=AE=E9=A2=98=202.=20=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E4=B8=8A=E7=BA=BF=EF=BC=8C=E4=B8=8B=E7=BA=BF?= =?UTF-8?q?=E9=80=9A=E7=9F=A5Agent=E8=BF=9B=E7=A8=8B=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- srcs/opendhcp183/query.cpp | 20 ++++++++++---------- srcs/vcpe_main.c | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 10 deletions(-) diff --git a/srcs/opendhcp183/query.cpp b/srcs/opendhcp183/query.cpp index bc4f499..88dc261 100644 --- a/srcs/opendhcp183/query.cpp +++ b/srcs/opendhcp183/query.cpp @@ -1201,13 +1201,13 @@ int opendhcp_add_listener() { return i; } -void on_http_response_cb(void *pData, - unsigned int size, - const char *pReqUrl, - const char *pDlPath, - const char *pTaskUuid, - int iFinished, - void *pUserData) { +static void on_http_response_cb(void *pData, + unsigned int size, + const char *pReqUrl, + const char *pDlPath, + const char *pTaskUuid, + int iFinished, + void *pUserData) { if (iFinished == 0) { dzlog_debug("Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size); } else if (iFinished == 1) { @@ -1215,6 +1215,8 @@ void on_http_response_cb(void *pData, } else { dzlog_error("Download Error Code: %d\n", iFinished); } + + free(pUserData); } void iptvCacheCb(void *UNUSED(pArg)) { @@ -1262,9 +1264,7 @@ void iptvCacheCb(void *UNUSED(pArg)) { const char *pStrPro = proto_create_new(pRspMsg, 200); // Report new IPTV device MAC - inet_http_post_async(config_get_agent_iptv_report_url(), pStrPro, on_http_response_cb, nullptr); - - free((void *)pStrPro); + inet_http_post_async(pUrl, pStrPro, on_http_response_cb, (void *)pStrPro); } uv_sleep(10); diff --git a/srcs/vcpe_main.c b/srcs/vcpe_main.c index f42c61a..ebe20db 100644 --- a/srcs/vcpe_main.c +++ b/srcs/vcpe_main.c @@ -19,6 +19,8 @@ #ifdef OPENDHCPD_ON #include "proto.h" +#include "inet_misc.h" +#include "config.h" #endif #ifdef OPENDHCPDDNS_ON @@ -48,6 +50,31 @@ static void lwip_init_env() { } #endif +cJSON *create_app_process_status(int isStart) { + cJSON *pRspMsg = cJSON_CreateObject(); + cJSON_AddNumberToObject(pRspMsg, "vni", cfg_get_user_vni_id()); + cJSON_AddStringToObject(pRspMsg, "process", isStart ? "setup" : "exit"); + return pRspMsg; +} + +static void on_http_response_cb(void *pData, + unsigned int size, + const char *pReqUrl, + const char *pDlPath, + const char *pTaskUuid, + int iFinished, + void *pUserData) { + if (iFinished == 0) { + dzlog_debug("Request(%s): [%s] Response: [%u] OK:\n", pTaskUuid, pReqUrl, size); + } else if (iFinished == 1) { + dzlog_error("Request(%s): [%s] Response: [%u] Error\n", pTaskUuid, pReqUrl, size); + } else { + dzlog_error("Download Error Code: %d\n", iFinished); + } + + free(pUserData); +} + int main(int argc, char **argv) { int ret; #ifdef OPENDHCPDDNS_ON @@ -76,8 +103,13 @@ int main(int argc, char **argv) { pppoe_session_init(); #endif + const char *pStrSetup = proto_create_new(create_app_process_status(1), 200); + inet_http_post_async(config_get_agent_moniter_report_url(), pStrSetup, on_http_response_cb, (void *)pStrSetup); task_manager_run(); + const char *pStrExit = proto_create_new(create_app_process_status(0), 200); + inet_http_post_async(config_get_agent_moniter_report_url(), pStrSetup, on_http_response_cb, (void *)pStrSetup); + while (!is_system_cleanup()) { sleep(1); }