From b45a55ebcf4b12f9bd2b8a30ad5e0a78077df327 Mon Sep 17 00:00:00 2001 From: Feten Besbes Date: Mon, 26 Feb 2018 17:44:46 +0100 Subject: [PATCH] Ticket 14153: DSCP in tr069 datamodell --- dm/dmtree/tr098/downloaddiagnostic.c | 30 +++++++++++++++++++++++++++- dm/dmtree/tr098/downloaddiagnostic.h | 2 ++ dm/dmtree/tr098/ippingdiagnostics.c | 30 +++++++++++++++++++++++++++- dm/dmtree/tr098/uploaddiagnostic.c | 30 +++++++++++++++++++++++++++- dm/dmtree/tr098/uploaddiagnostic.h | 2 ++ 5 files changed, 91 insertions(+), 3 deletions(-) diff --git a/dm/dmtree/tr098/downloaddiagnostic.c b/dm/dmtree/tr098/downloaddiagnostic.c index fc7368b..7317247 100644 --- a/dm/dmtree/tr098/downloaddiagnostic.c +++ b/dm/dmtree/tr098/downloaddiagnostic.c @@ -30,7 +30,7 @@ DMLEAF tDownloadDiagnosticsParam[] = { {"TotalBytesReceived", &DMREAD, DMT_UNINT, get_download_diagnostic_totalbytes, NULL, NULL, NULL}, {"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_download_diagnostic_tcp_open_request_time, NULL, NULL, NULL}, {"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_download_diagnostic_tcp_open_response_time, NULL, NULL, NULL}, -//{"DSCP", &DMWRITE, DMT_UNINT, get_download_diagnostics_dscp, set_download_diagnostics_dscp, NULL, NULL}, +{"DSCP", &DMWRITE, DMT_UNINT, get_download_diagnostics_dscp, set_download_diagnostics_dscp, NULL, NULL}, //{"Interface", &DMWRITE, DMT_UNINT, get_download_diagnostics_interface, set_download_diagnostics_interface, NULL, NULL}, {0} }; @@ -215,3 +215,31 @@ int get_download_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *value = "0"; return 0; } + +int get_download_diagnostics_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) +{ + dmuci_get_varstate_string("cwmp", "@downloaddiagnostic[0]", "DSCP", value); + if ((*value)[0] == '\0') + *value = "0"; + return 0; +} +int set_download_diagnostics_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) +{ + char *tmp; + struct uci_section *curr_section = NULL; + + switch (action) { + case VALUECHECK: + return 0; + case VALUESET: + DOWNLOAD_DIAGNOSTIC_STOP + curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "downloaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION); + if(!curr_section) + { + dmuci_add_state_section("cwmp", "downloaddiagnostic", &curr_section, &tmp); + } + dmuci_set_varstate_value("cwmp", "@downloaddiagnostic[0]", "DSCP", value); + return 0; + } + return 0; +} diff --git a/dm/dmtree/tr098/downloaddiagnostic.h b/dm/dmtree/tr098/downloaddiagnostic.h index 630fe04..c2c1584 100644 --- a/dm/dmtree/tr098/downloaddiagnostic.h +++ b/dm/dmtree/tr098/downloaddiagnostic.h @@ -27,6 +27,8 @@ int get_download_diagnostic_testbytes(char *refparam, struct dmctx *ctx, void *d int get_download_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int get_download_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int get_download_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); +int get_download_diagnostics_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); +int set_download_diagnostics_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action); extern DMLEAF tDownloadDiagnosticsParam[]; #endif diff --git a/dm/dmtree/tr098/ippingdiagnostics.c b/dm/dmtree/tr098/ippingdiagnostics.c index 29b62c5..7f3a3ea 100644 --- a/dm/dmtree/tr098/ippingdiagnostics.c +++ b/dm/dmtree/tr098/ippingdiagnostics.c @@ -26,7 +26,7 @@ DMLEAF tIPPingDiagnosticsParam[] = { {"NumberOfRepetitions", &DMWRITE, DMT_UNINT, get_ipping_repetition_number, set_ipping_repetition_number, NULL, NULL}, {"Timeout", &DMWRITE, DMT_UNINT, get_ipping_timeout, set_ipping_timeout, NULL, NULL}, {"DataBlockSize", &DMWRITE, DMT_UNINT, get_ipping_block_size, set_ipping_block_size, NULL, NULL}, -//{"DSCP", &DMWRITE, DMT_UNINT, get_ipping_dscp, set_ipping_dscp, NULL, NULL}, +{"DSCP", &DMWRITE, DMT_UNINT, get_ipping_dscp, set_ipping_dscp, NULL, NULL}, {"SuccessCount", &DMREAD, DMT_UNINT, get_ipping_success_count, NULL, NULL, NULL}, {"FailureCount", &DMREAD, DMT_UNINT, get_ipping_failure_count, NULL, NULL, NULL}, {"AverageResponseTime", &DMREAD, DMT_UNINT, get_ipping_average_response_time, NULL, NULL, NULL}, @@ -35,6 +35,7 @@ DMLEAF tIPPingDiagnosticsParam[] = { {0} }; + static inline char *ipping_get(char *option, char *def) { char *tmp; @@ -207,6 +208,33 @@ int set_ipping_block_size(char *refparam, struct dmctx *ctx, void *data, char *i return 0; } +int get_ipping_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) +{ + *value = ipping_get("DSCP", "0"); + + return 0; +} + +int set_ipping_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) +{ + + char *tmp; + struct uci_section *curr_section = NULL; + switch (action) { + case VALUECHECK: + return 0; + case VALUESET: + IPPING_STOP + curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "ippingdiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION); + if(!curr_section) + { + dmuci_add_state_section("cwmp", "ippingdiagnostic", &curr_section, &tmp); + } + dmuci_set_varstate_value("cwmp", "@ippingdiagnostic[0]", "DSCP", value); + } + return 0; +} + int get_ipping_success_count(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) { *value = ipping_get("SuccessCount", "0"); diff --git a/dm/dmtree/tr098/uploaddiagnostic.c b/dm/dmtree/tr098/uploaddiagnostic.c index 20c9ced..ab5270e 100644 --- a/dm/dmtree/tr098/uploaddiagnostic.c +++ b/dm/dmtree/tr098/uploaddiagnostic.c @@ -30,7 +30,7 @@ DMLEAF tUploadDiagnosticsParam[] = { {"TotalBytesSent", &DMREAD, DMT_UNINT, get_upload_diagnostic_totalbytes, NULL, NULL, NULL}, {"TCPOpenRequestTime", &DMREAD, DMT_TIME, get_upload_diagnostic_tcp_open_request_time, NULL, NULL, NULL}, {"TCPOpenResponseTime", &DMREAD, DMT_TIME, get_upload_diagnostic_tcp_open_response_time, NULL, NULL, NULL}, -//{"DSCP", &DMWRITE, DMT_UNINT, get_upload_diagnostics_dscp, set_upload_diagnostics_dscp, NULL, NULL}, +{"DSCP", &DMWRITE, DMT_UNINT, get_upload_diagnostic_dscp, set_upload_diagnostic_dscp, NULL, NULL}, //{"Interface", &DMWRITE, DMT_UNINT, get_upload_diagnostics_interface, set_upload_diagnostics_interface, NULL, NULL}, {0} }; @@ -236,4 +236,32 @@ int get_upload_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *c *value = "0"; return 0; } +int get_upload_diagnostic_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value) +{ + dmuci_get_varstate_string("cwmp", "@uploaddiagnostic[0]", "DSCP", value); + if ((*value)[0] == '\0') + *value = "0"; + return 0; +} + +int set_upload_diagnostic_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action) +{ + char *tmp; + struct uci_section *curr_section = NULL; + + switch (action) { + case VALUECHECK: + return 0; + case VALUESET: + UPLOAD_DIAGNOSTIC_STOP + curr_section = (struct uci_section *)dmuci_walk_state_section("cwmp", "uploaddiagnostic", NULL, NULL, CMP_SECTION, NULL, NULL, GET_FIRST_SECTION); + if(!curr_section) + { + dmuci_add_state_section("cwmp", "uploaddiagnostic", &curr_section, &tmp); + } + dmuci_set_varstate_value("cwmp", "@uploaddiagnostic[0]", "DSCP", value); + return 0; + } + return 0; +} diff --git a/dm/dmtree/tr098/uploaddiagnostic.h b/dm/dmtree/tr098/uploaddiagnostic.h index e2ccc23..fb6f5db 100644 --- a/dm/dmtree/tr098/uploaddiagnostic.h +++ b/dm/dmtree/tr098/uploaddiagnostic.h @@ -28,5 +28,7 @@ int set_upload_diagnostic_test_file_length(char *refparam, struct dmctx *ctx, vo int get_upload_diagnostic_totalbytes(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int get_upload_diagnostic_tcp_open_request_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); int get_upload_diagnostic_tcp_open_response_time(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); +int get_upload_diagnostic_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char **value); +int set_upload_diagnostic_dscp(char *refparam, struct dmctx *ctx, void *data, char *instance, char *value, int action); #endif