Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@ AC_ARG_ENABLE([support-typing-fields],

AM_CONDITIONAL([ENABLE_SUPPORT_TYPING_FIELDS], [test x$ENABLE_SUPPORT_TYPING_FIELDS = xtrue])

ENABLE_T2_ENABLE_STS_TS_TIMESTAMP=false

AC_ARG_ENABLE([t2-enable-sts-ts-timestamp],
[AS_HELP_STRING(
[--enable-t2-enable-sts-ts-timestamp],
[enable T2_ENABLE_STS_TS_TIMESTAMP (default is no)]
)],
[
case "${enableval}" in
yes) ENABLE_T2_ENABLE_STS_TS_TIMESTAMP=true ;;
no) ENABLE_T2_ENABLE_STS_TS_TIMESTAMP=false ;;
*) AC_MSG_ERROR([bad value ${enableval} for --enable-t2-enable-sts-ts-timestamp]) ;;
esac
]
)

AM_CONDITIONAL([ENABLE_T2_ENABLE_STS_TS_TIMESTAMP],
[test "x${ENABLE_T2_ENABLE_STS_TS_TIMESTAMP}" = "xtrue"])

#privacy control flag
IS_PRIVACYCONTROL_ENABLED=false
AC_ARG_ENABLE([privacycontrol],
Expand Down
4 changes: 4 additions & 0 deletions source/bulkdata/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,7 @@ endif
if IS_LIBRDKCERTSEL_ENABLED
libbulkdata_la_CFLAGS = $(LIBRDKCERTSEL_FLAG)
endif

if ENABLE_T2_ENABLE_STS_TS_TIMESTAMP
libbulkdata_la_CPPFLAGS += -DT2_ENABLE_STS_TS_TIMESTAMP
endif
29 changes: 29 additions & 0 deletions source/bulkdata/profile.c
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,35 @@ static void* CollectAndReport(void* data)
{
cJSON_AddItemToArray(valArray, triggercondition);
}
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
/* Add the collection timestamp as a separate object in Report[]. */
if(valArray != NULL && cJSON_IsArray(valArray))
{
struct timespec collectionTime;
Comment on lines +572 to +576
if(clock_gettime(CLOCK_REALTIME, &collectionTime) == 0)
{
long long collectionTimeMs =
(long long)collectionTime.tv_sec * 1000LL +
collectionTime.tv_nsec / 1000000LL;
cJSON *timestamp = cJSON_CreateObject();
if(timestamp != NULL)
{
if(cJSON_AddNumberToObject(timestamp, "ts",
(double)collectionTimeMs) != NULL)
{
if(!cJSON_AddItemToArray(valArray, timestamp))
{
cJSON_Delete(timestamp);
}
}
else
{
cJSON_Delete(timestamp);
}
}
}
}
#endif
ret = prepareJSONReport(profile->jsonReportObj, &jsonReport);
destroyJSONReport(profile->jsonReportObj);
profile->jsonReportObj = NULL;
Expand Down
4 changes: 4 additions & 0 deletions source/protocol/http/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,7 @@ libhttp_la_CPPFLAGS = -fPIC -I${PKG_CONFIG_SYSROOT_DIR}$(includedir)/dbus-1.0 \
-I${top_srcdir}/source/bulkdata \
-I${top_srcdir}/source/utils

if ENABLE_T2_ENABLE_STS_TS_TIMESTAMP
libhttp_la_CPPFLAGS += -DT2_ENABLE_STS_TS_TIMESTAMP
libhttp_la_LDFLAGS += -lcjson
endif
50 changes: 50 additions & 0 deletions source/protocol/http/curlinterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
#include <sys/wait.h>
#include <curl/curl.h>
#include <signal.h>
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
#include <time.h>
#include <cjson/cJSON.h>
#endif

#include "curlinterface.h"
#include "reportprofiles.h"
Expand Down Expand Up @@ -73,14 +77,60 @@ typedef enum _ADDRESS_TYPE
T2ERROR sendReportOverHTTP(char *httpUrl, char *payload)
{
T2ERROR ret = T2ERROR_FAILURE;
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
char *payloadWithSts = NULL;
#endif

T2Debug("%s ++in\n", __FUNCTION__);
if(httpUrl == NULL || payload == NULL)
{
return ret;
}
// Use new dedicated POST API
#ifdef T2_ENABLE_STS_TS_TIMESTAMP
cJSON *root = cJSON_Parse(payload);
if(root != NULL)
Comment on lines +90 to +92
{
cJSON *report = cJSON_GetObjectItemCaseSensitive(root, "Report");
if(report != NULL && cJSON_IsArray(report))
{
struct timespec sendTime;
if(clock_gettime(CLOCK_REALTIME, &sendTime) == 0)
{
long long sendTimeMs =
(long long)sendTime.tv_sec * 1000LL +
sendTime.tv_nsec / 1000000LL;
cJSON *timestamp = cJSON_CreateObject();
if(timestamp != NULL)
{
if(cJSON_AddNumberToObject(timestamp, "sts",
(double)sendTimeMs) != NULL)
{
if(cJSON_AddItemToArray(report, timestamp))
{
payloadWithSts = cJSON_PrintUnformatted(root);
}
else
{
cJSON_Delete(timestamp);
}
}
else
{
cJSON_Delete(timestamp);
}
}
}
}
cJSON_Delete(root);
}

ret = http_pool_post(httpUrl,
payloadWithSts != NULL ? payloadWithSts : payload);
free(payloadWithSts);
#else
ret = http_pool_post(httpUrl, payload);
#endif

if(ret == T2ERROR_SUCCESS)
{
Expand Down