Support cancelled diagnostics state

This commit is contained in:
Suvendhu Hansa 2024-03-27 10:10:31 +00:00 committed by Vivek Kumar Dutta
parent ef4354e7b0
commit 524952deaf
5 changed files with 64 additions and 49 deletions

View file

@ -152,68 +152,77 @@ struct diagnostic_input nslookup_diagnostics[] = {
{ "Timeout", "Device.DNS.Diagnostics.NSLookupDiagnostics.Timeout", NULL }
};
void set_diagnostic_state_end_session_flag(char *parameter_name, char *value)
static unsigned int get_diagnostic_flag(const char *parameter_name)
{
if (CWMP_STRLEN(parameter_name) == 0 || CWMP_STRLEN(value) == 0)
return;
if (strcmp(value, "Requested") != 0)
return;
if (CWMP_STRLEN(parameter_name) == 0)
return 0;
if (strcmp(parameter_name, "Device.IP.Diagnostics.DownloadDiagnostics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_DOWNLOAD_DIAGNOSTIC);
return;
return END_SESSION_DOWNLOAD_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.IP.Diagnostics.UploadDiagnostics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_UPLOAD_DIAGNOSTIC);
return;
return END_SESSION_UPLOAD_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.IP.Diagnostics.IPPing.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_IPPING_DIAGNOSTIC);
return;
return END_SESSION_IPPING_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.IP.Diagnostics.ServerSelectionDiagnostics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_SERVERSELECTION_DIAGNOSTIC);
return;
return END_SESSION_SERVERSELECTION_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.IP.Diagnostics.TraceRoute.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_TRACEROUTE_DIAGNOSTIC);
return;
return END_SESSION_TRACEROUTE_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.IP.Diagnostics.UDPEchoDiagnostics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_UDPECHO_DIAGNOSTIC);
return;
return END_SESSION_UDPECHO_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.DNS.Diagnostics.NSLookupDiagnostics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_NSLOOKUP_DIAGNOSTIC);
return;
return END_SESSION_NSLOOKUP_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.IP.Diagnostics.IPLayerCapacityMetrics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_IPLAYERCAPACITY_DIAGNOSTIC);
return;
return END_SESSION_IPLAYERCAPACITY_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.WiFi.NeighboringWiFiDiagnostic.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_NEIGBORING_WIFI_DIAGNOSTIC);
return;
return END_SESSION_NEIGBORING_WIFI_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.PacketCaptureDiagnostics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_PACKETCAPTURE_DIAGNOSTIC);
return;
return END_SESSION_PACKETCAPTURE_DIAGNOSTIC;
}
if (strcmp(parameter_name, "Device.SelfTestDiagnostics.DiagnosticsState") == 0) {
cwmp_set_end_session(END_SESSION_SELFTEST_DIAGNOSTIC);
return;
return END_SESSION_SELFTEST_DIAGNOSTIC;
}
return 0;
}
void set_diagnostic_state_end_session_flag(char *parameter_name, char *value)
{
unsigned int flag = 0;
if (CWMP_STRLEN(parameter_name) == 0 || CWMP_STRLEN(value) == 0)
return;
flag = get_diagnostic_flag(parameter_name);
if (flag == 0)
return;
if (strcmp(value, "Requested") == 0) {
cwmp_set_end_session(flag);
} else if (strcmp(value, "Canceled") == 0) {
cwmp_clear_end_session(flag);
}
return;
}
static bool set_specific_diagnostic_object_parameter_structure_value(struct diagnostic_input (*diagnostics_array)[], int number_inputs, char *parameter, char *value)

View file

@ -639,6 +639,11 @@ void cwmp_set_end_session(unsigned int flag)
end_session_flag |= flag;
}
void cwmp_clear_end_session(unsigned int flag)
{
end_session_flag &= ~(flag);
}
int run_session_end_func(void)
{
CWMP_LOG(INFO, "Handling end session with: (%u)", end_session_flag);

View file

@ -91,6 +91,7 @@ enum enum_session_status
extern unsigned int end_session_flag;
void cwmp_set_end_session(unsigned int flag);
void cwmp_clear_end_session(unsigned int flag);
struct rpc *build_sessin_rcp_cpe(int type);
struct rpc *cwmp_add_session_rpc_acs(int type);
struct rpc *cwmp_add_session_rpc_acs_head(int type);

View file

@ -150,7 +150,7 @@ static void dm_set_multiple_parameter_values_test(void **state)
/*
* Test of non writable, valid parameter path
*/
add_dm_parameter_to_list(&list_set_param_value, "Device.ATM.Link.1.Status", "Up", NULL, 0, false);
add_dm_parameter_to_list(&list_set_param_value, "Device.DeviceInfo.UpTime", "1234", NULL, 0, false);
cwmp_transaction("start", false);
fault = cwmp_set_multi_parameters_value(&list_set_param_value,&faults_array);
assert_int_not_equal(fault, 0);

View file

@ -8,56 +8,56 @@ TEST_NAME="ICWMP COMMAND LINE"
echo "Running: $TEST_NAME"
echo "GET METHOD: Correct Path" >> ./funl-test-debug.log
res=$(./icwmpd -c get Device.ATM.Link.1.Alias 2>&1)
res=$(./icwmpd -c get Device.DeviceInfo.VendorLogFile.1.Alias 2>&1)
if [[ $res != *"cpe-1"* ]]; then
echo "Error: Get Method with correct path doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "GET METHOD: Wrong Path" >> ./funl-test-debug.log
res=$(./icwmpd -c get Device.ATM.Link.1.Alia 2>&1)
res=$(./icwmpd -c get Device.DeviceInfo.VendorLogFile.1.Alia 2>&1)
if [[ $res != *"9005"* ]]; then
echo "Error: Get Method with wrong path doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "SET METHOD: Correct Path && Value" >> ./funl-test-debug.log
res=$(./icwmpd -c set Device.ATM.Link.1.Enable 0 2>&1)
if [[ $res != *"=> 0"* ]]; then
res=$(./icwmpd -c set Device.DeviceInfo.ProvisioningCode 1234 2>&1)
if [[ $res != *"=> 1234"* ]]; then
echo "Error: Set Method with correct path && value doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "SET METHOD: Wrong Path && Correct Value" >> ./funl-test-debug.log
res=$(./icwmpd -c set Device.ATM.Link.1.Enble 0 2>&1)
res=$(./icwmpd -c set Device.DeviceInfo.WrongPath 1234 2>&1)
if [[ $res != *"9005"* ]]; then
echo "Error: Set Method with wrong path && correct value doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "SET METHOD: Correct Path && Wrong Value" >> ./funl-test-debug.log
res=$(./icwmpd -c set Device.ATM.Link.1.Enable test 2>&1)
res=$(./icwmpd -c set Device.IP.Interface.1.Enable test 2>&1)
if [[ $res != *"9007"* ]]; then
echo "Error: Set Method with correct path && wrong value doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "GET NAME METHOD: Correct Path && level" >> ./funl-test-debug.log
res=$(./icwmpd -c get_names Device.ATM.Link.1.Alias 0 2>&1)
res=$(./icwmpd -c get_names Device.DeviceInfo.VendorLogFile.1.Alias 0 2>&1)
if [[ $res != *"=> writable"* ]]; then
echo "Error: Get Name Method with correct path && level doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "GET NAME METHOD: Correct Path && Wrong level" >> ./funl-test-debug.log
res=$(./icwmpd -c get_names Device.ATM.Link.1.Alias 1 2>&1)
res=$(./icwmpd -c get_names Device.DeviceInfo.VendorLogFile.1.Alias 1 2>&1)
if [[ $res != *"9003"* ]]; then
echo "Error: Get Name Method with correct path && wrong level doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "GET NAME METHOD: Wrong Path && Correct level" >> ./funl-test-debug.log
res=$(./icwmpd -c get_names Device.ATM.Link.1.Ali 0 2>&1)
res=$(./icwmpd -c get_names Device.DeviceInfo.VendorLogFile.1.Ali 0 2>&1)
if [[ $res != *"9005"* ]]; then
echo "Error: Get Name Method with wrong path && correct level doesn't work correctly" >> ./funl-test-debug.log
exit 1
@ -71,21 +71,21 @@ if [[ $res != *"=> active"* ]]; then
fi
echo "GET NOTIFICATION METHOD: Wrong Path" >> ./funl-test-debug.log
res=$(./icwmpd -c get_notif Device.ATM.Link.1.Ali 2>&1)
res=$(./icwmpd -c get_notif Device.DeviceInfo.VendorLogFile.1.Ali 2>&1)
if [[ $res != *"9005"* ]]; then
echo "Error: Get Notification Method with wrong path doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "SET NOTIFICATION METHOD: Correct Path" >> ./funl-test-debug.log
res=$(./icwmpd -c set_notif Device.ATM.Link.1.Alias 2 2>&1)
res=$(./icwmpd -c set_notif Device.DeviceInfo.VendorLogFile.1.Alias 2 2>&1)
if [[ $res != *"=> 2"* ]]; then
echo "Error: Set Notification Method with correct path doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "SET NOTIFICATION METHOD: Wrong Path" >> ./funl-test-debug.log
res=$(./icwmpd -c set_notif Device.ATM.Link.1.Ali 1 2>&1)
res=$(./icwmpd -c set_notif Device.DeviceInfo.VendorLogFile.1.Ali 1 2>&1)
if [[ $res != *"9005"* ]]; then
echo "Error: Set Notification Method with wrong path doesn't work correctly" >> ./funl-test-debug.log
exit 1
@ -99,36 +99,36 @@ if [[ $res != *"9009"* ]]; then
fi
echo "ADD METHOD: Correct Path" >> ./funl-test-debug.log
res=$(./icwmpd -c add Device.ATM.Link. 2>&1)
if [[ $res != *"Device.ATM.Link.2."* ]]; then
res=$(./icwmpd -c add Device.IP.Interface. 2>&1)
if [[ $res != *"Device.IP.Interface."* ]]; then
echo "Error: Add Method with correct path doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "ADD METHOD: Wrong Path" >> ./funl-test-debug.log
res=$(./icwmpd -c add Device.ATM.Lin 2>&1)
res=$(./icwmpd -c add Device.DeviceInfo.VendorLogFil 2>&1)
if [[ $res != *"9005"* ]]; then
echo "Error: Add Method with wrong path doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "DELETE METHOD: Wrong Path" >> ./funl-test-debug.log
res=$(./icwmpd -c del Device.ATM.Lin 2>&1)
res=$(./icwmpd -c del Device.DeviceInfo.VendorLogFil 2>&1)
if [[ $res != *"9005"* ]]; then
echo "Error: Delete Method with wrong path doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "DELETE METHOD: Correct Path && one instance" >> ./funl-test-debug.log
res=$(./icwmpd -c del Device.ATM.Link.2. 2>&1)
if [[ $res != *"Deleted Device.ATM.Link.2."* ]]; then
res=$(./icwmpd -c del Device.IP.Interface.2. 2>&1)
if [[ $res != *"Deleted Device.IP.Interface.2."* ]]; then
echo "Error: Delete Method with correct path && one instance doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi
echo "DELETE METHOD: Correct Path && all instance" >> ./funl-test-debug.log
res=$(./icwmpd -c del Device.ATM.Link. 2>&1)
if [[ $res != *"Deleted Device.ATM.Link."* ]]; then
res=$(./icwmpd -c del Device.IP.Interface. 2>&1)
if [[ $res != *"Deleted Device.IP.Interface."* ]]; then
echo "Error: Delete Method with correct path && all instances doesn't work correctly" >> ./funl-test-debug.log
exit 1
fi