diff --git a/source/WanManager/Makefile.am b/source/WanManager/Makefile.am index ec96f1c..bfc014c 100644 --- a/source/WanManager/Makefile.am +++ b/source/WanManager/Makefile.am @@ -29,5 +29,5 @@ wanmanager_CPPFLAGS = -I$(top_srcdir)/source/TR-181/middle_layer_src \ wanmanager_CFLAGS = -DFEATURE_SUPPORT_RDKLOG $(DBUS_CFLAGS) $(SYSTEMD_CFLAGS) wanmanager_CFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\" -wanmanager_SOURCES = wanmgr_webconfig_apis.c wanmgr_webconfig.c wanmgr_main.c wanmgr_ssp_action.c wanmgr_ssp_messagebus_interface.c wanmgr_core.c wanmgr_controller.c wanmgr_data.c wanmgr_sysevents.c wanmgr_interface_sm.c wanmgr_utils.c wanmgr_net_utils.c wanmgr_dhcpv4_apis.c wanmgr_dhcpv6_apis.c wanmgr_ipc.c wanmgr_dhcpv4_internal.c wanmgr_dhcpv6_internal.c wanmgr_policy_autowan_impl.c wanmgr_policy_auto_impl.c dm_pack_datamodel.c wanmgr_wan_failover.c wanmgr_policy_parallel_scan_impl.c wanmgr_dhcp_legacy_apis.c +wanmanager_SOURCES = wanmgr_webconfig_apis.c wanmgr_webconfig.c wanmgr_main.c wanmgr_ssp_action.c wanmgr_ssp_messagebus_interface.c wanmgr_core.c wanmgr_controller.c wanmgr_data.c wanmgr_sysevents.c wanmgr_interface_sm.c wanmgr_utils.c wanmgr_net_utils.c wanmgr_dhcpv4_apis.c wanmgr_dhcpv6_apis.c wanmgr_ipc.c wanmgr_dhcpv4_internal.c wanmgr_dhcpv6_internal.c wanmgr_policy_autowan_impl.c wanmgr_policy_auto_impl.c dm_pack_datamodel.c wanmgr_wan_failover.c wanmgr_policy_parallel_scan_impl.c wanmgr_dhcp_legacy_apis.c wan_telemetry_marker.c wanmanager_LDADD = $(wanmanager_DEPENDENCIES) -lccsp_common -lrdkloggers $(DBUS_LIBS) $(SYSTEMD_LDFLAGS) -lhal_platform -lapi_dhcpv4c -lnanomsg -lwebconfig_framework -lmsgpackc -ldhcp_client_utils -lprivilege -lrbus -lsecure_wrapper diff --git a/source/WanManager/wan_telemetry_marker.c b/source/WanManager/wan_telemetry_marker.c new file mode 100644 index 0000000..9e44f34 --- /dev/null +++ b/source/WanManager/wan_telemetry_marker.c @@ -0,0 +1,117 @@ +#include "wan_telemetry_marker.h" +#ifdef ENABLE_FEATURE_TELEMETRY2_0 +#include +#endif +#include +#include "ccsp_trace.h" + +struct marker +{ + char *t1_marker_string; + return_status_e (*telemetry_marker_set)(struct marker *marker_p, char *marker, void **data); +}; + +static return_status_e telemetry_marker_t2_string(struct marker *marker_p, char *marker, void **data) +{ + char buf[128] = {0}; + char **data_p = (char **)data; + + if (data != NULL) + { + snprintf(buf, 128, marker_p->t1_marker_string, data_p[0], data_p[1]); + } + else + { + strcpy(buf, marker_p->t1_marker_string); + } + CcspTraceInfo(("%s-%d: %s-%s", __FUNCTION__, __LINE__, marker, buf)); +#ifdef ENABLE_FEATURE_TELEMETRY2_0 + t2_event_s(marker, data_p); +#endif + return STATUS_SUCCESS; +} + + +static return_status_e telemetry_marker_t1_string(struct marker *marker_p, char *marker, void **data) +{ + char buf[128] = {0}; + + if (data != NULL) + { + char **data_p = (char **)data; + snprintf(buf, 128, marker_p->t1_marker_string, data_p[0], data_p[1]); + } + else + { + strcpy(buf, marker_p->t1_marker_string); + } + CcspTraceInfo(("%s-%d: %s-%s", __FUNCTION__, __LINE__, marker, buf)); + return STATUS_SUCCESS; +} + +static return_status_e telemetry_marker_t2_int(struct marker *marker_p, char *marker, void **data) +{ + char buf[128] = {0}; + int **data_p = (int **)data; + + if (data != NULL) + { + snprintf(buf, 128, marker_p->t1_marker_string, (**data_p)); + } + else + { + strcpy(buf, marker_p->t1_marker_string); + } + CcspTraceInfo(("%s-%d: %s-%s", __FUNCTION__, __LINE__, marker, buf)); +#ifdef ENABLE_FEATURE_TELEMETRY2_0 + t2_event_d(marker, (**data_p)); +#endif + return STATUS_SUCCESS; +} + + +static struct marker marker_table[] = +{ + { + //marker id : WAN_INFO_PHY_TYPE + .t1_marker_string = "Selecting Base Interface:%s Phy_Type:%s", + .telemetry_marker_set = telemetry_marker_t2_string, + }, + { + //marker id : SYS_INFO_EthWanMode + .t1_marker_string = "Ethernet WAN is enabled", + .telemetry_marker_set = telemetry_marker_t1_string, + }, + { + //marker id : WAN_ERROR_PHY_DOWN + .t1_marker_string = "Received Base Interface:%s down", + .telemetry_marker_set = telemetry_marker_t2_string, + }, + { + //marker id : WAN_INFO_PHY_UP + .t1_marker_string = "Received Base Interface:%s up", + .telemetry_marker_set = telemetry_marker_t2_string, + }, + { + //marker id : WAN_WARNING_IP_OBTAIN_TIMER_EXPIRED + .t1_marker_string = "Wan Router Interface:%s, IP Obtaining Timer Expired %s", + .telemetry_marker_set = telemetry_marker_t2_string, + }, + { + //marker id : WAN_BTIME_WANINIT + .t1_marker_string = "Wan Boot Time Init %d", + .telemetry_marker_set = telemetry_marker_t2_int, + }, + { }, +}; + + + +return_status_e __wan_telemetry_marker_set(marker_id_e marker_id, char* marker, void **data) +{ + return_status_e return_status; + return_status = marker_table[marker_id].telemetry_marker_set(&marker_table[marker_id], marker, data); + return return_status; +} + + diff --git a/source/WanManager/wan_telemetry_marker.h b/source/WanManager/wan_telemetry_marker.h new file mode 100644 index 0000000..448ca41 --- /dev/null +++ b/source/WanManager/wan_telemetry_marker.h @@ -0,0 +1,29 @@ +#ifndef _WAN_TELEMETRY_MARKER_H_ +#define _WAN_TELEMETRY_MARKER_H_ + +typedef enum _return_status_e +{ + STATUS_SUCCESS, + STATUS_FAILED, + STATUS_FEATURE_DISABLED, + STATUS_UNDEFINED, + STATUS_INVALID, + STATUS_UNKNOWN, +}return_status_e; + +typedef enum _marker_id_e +{ + WAN_INFO_PHY_TYPE, + SYS_INFO_EthWanMode, + WAN_ERROR_PHY_DOWN, + WAN_INFO_PHY_UP, + WAN_WARNING_IP_OBTAIN_TIMER_EXPIRED, + WAN_BTIME_WANINIT, //exp for int arg +}marker_id_e; + +#define wan_telemetry_marker_set(marker_id, data) \ + __wan_telemetry_marker_set(marker_id, #marker_id, data); + +extern return_status_e __wan_telemetry_marker_set(marker_id_e marker_id, char* marker, void **data); + +#endif //_WAN_TELEMETRY_MARKER_H_