@@ -2347,72 +2347,72 @@ get_parameters(struct iperf_test *test)
2347
2347
cJSON_free (str );
2348
2348
}
2349
2349
2350
- if ((j_p = cJSON_GetObjectItem (j , "tcp" )) != NULL )
2350
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "tcp" , cJSON_True )) != NULL )
2351
2351
set_protocol (test , Ptcp );
2352
- if ((j_p = cJSON_GetObjectItem (j , "udp" )) != NULL )
2352
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "udp" , cJSON_True )) != NULL )
2353
2353
set_protocol (test , Pudp );
2354
- if ((j_p = cJSON_GetObjectItem (j , "sctp" )) != NULL )
2354
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "sctp" , cJSON_True )) != NULL )
2355
2355
set_protocol (test , Psctp );
2356
- if ((j_p = cJSON_GetObjectItem (j , "omit" )) != NULL )
2356
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "omit" , cJSON_Number )) != NULL )
2357
2357
test -> omit = j_p -> valueint ;
2358
- if ((j_p = cJSON_GetObjectItem (j , "server_affinity" )) != NULL )
2358
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "server_affinity" , cJSON_Number )) != NULL )
2359
2359
test -> server_affinity = j_p -> valueint ;
2360
- if ((j_p = cJSON_GetObjectItem (j , "time" )) != NULL )
2360
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "time" , cJSON_Number )) != NULL )
2361
2361
test -> duration = j_p -> valueint ;
2362
2362
test -> settings -> bytes = 0 ;
2363
- if ((j_p = cJSON_GetObjectItem (j , "num" )) != NULL )
2363
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "num" , cJSON_Number )) != NULL )
2364
2364
test -> settings -> bytes = j_p -> valueint ;
2365
2365
test -> settings -> blocks = 0 ;
2366
- if ((j_p = cJSON_GetObjectItem (j , "blockcount" )) != NULL )
2366
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "blockcount" , cJSON_Number )) != NULL )
2367
2367
test -> settings -> blocks = j_p -> valueint ;
2368
- if ((j_p = cJSON_GetObjectItem (j , "MSS" )) != NULL )
2368
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "MSS" , cJSON_Number )) != NULL )
2369
2369
test -> settings -> mss = j_p -> valueint ;
2370
- if ((j_p = cJSON_GetObjectItem (j , "nodelay" )) != NULL )
2370
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "nodelay" , cJSON_True )) != NULL )
2371
2371
test -> no_delay = 1 ;
2372
- if ((j_p = cJSON_GetObjectItem (j , "parallel" )) != NULL )
2372
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "parallel" , cJSON_Number )) != NULL )
2373
2373
test -> num_streams = j_p -> valueint ;
2374
- if ((j_p = cJSON_GetObjectItem (j , "reverse" )) != NULL )
2374
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "reverse" , cJSON_True )) != NULL )
2375
2375
iperf_set_test_reverse (test , 1 );
2376
- if ((j_p = cJSON_GetObjectItem (j , "bidirectional" )) != NULL )
2376
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "bidirectional" , cJSON_True )) != NULL )
2377
2377
iperf_set_test_bidirectional (test , 1 );
2378
- if ((j_p = cJSON_GetObjectItem (j , "window" )) != NULL )
2378
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "window" , cJSON_Number )) != NULL )
2379
2379
test -> settings -> socket_bufsize = j_p -> valueint ;
2380
- if ((j_p = cJSON_GetObjectItem (j , "len" )) != NULL )
2380
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "len" , cJSON_Number )) != NULL )
2381
2381
test -> settings -> blksize = j_p -> valueint ;
2382
- if ((j_p = cJSON_GetObjectItem (j , "bandwidth" )) != NULL )
2382
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "bandwidth" , cJSON_Number )) != NULL )
2383
2383
test -> settings -> rate = j_p -> valueint ;
2384
- if ((j_p = cJSON_GetObjectItem (j , "fqrate" )) != NULL )
2384
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "fqrate" , cJSON_Number )) != NULL )
2385
2385
test -> settings -> fqrate = j_p -> valueint ;
2386
- if ((j_p = cJSON_GetObjectItem (j , "pacing_timer" )) != NULL )
2386
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "pacing_timer" , cJSON_Number )) != NULL )
2387
2387
test -> settings -> pacing_timer = j_p -> valueint ;
2388
- if ((j_p = cJSON_GetObjectItem (j , "burst" )) != NULL )
2388
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "burst" , cJSON_Number )) != NULL )
2389
2389
test -> settings -> burst = j_p -> valueint ;
2390
- if ((j_p = cJSON_GetObjectItem (j , "TOS" )) != NULL )
2390
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "TOS" , cJSON_Number )) != NULL )
2391
2391
test -> settings -> tos = j_p -> valueint ;
2392
- if ((j_p = cJSON_GetObjectItem (j , "flowlabel" )) != NULL )
2392
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "flowlabel" , cJSON_Number )) != NULL )
2393
2393
test -> settings -> flowlabel = j_p -> valueint ;
2394
- if ((j_p = cJSON_GetObjectItem (j , "title" )) != NULL )
2394
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "title" , cJSON_String )) != NULL )
2395
2395
test -> title = strdup (j_p -> valuestring );
2396
- if ((j_p = cJSON_GetObjectItem (j , "extra_data" )) != NULL )
2396
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "extra_data" , cJSON_String )) != NULL )
2397
2397
test -> extra_data = strdup (j_p -> valuestring );
2398
- if ((j_p = cJSON_GetObjectItem (j , "congestion" )) != NULL )
2398
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "congestion" , cJSON_String )) != NULL )
2399
2399
test -> congestion = strdup (j_p -> valuestring );
2400
- if ((j_p = cJSON_GetObjectItem (j , "congestion_used" )) != NULL )
2400
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "congestion_used" , cJSON_String )) != NULL )
2401
2401
test -> congestion_used = strdup (j_p -> valuestring );
2402
- if ((j_p = cJSON_GetObjectItem (j , "get_server_output" )) != NULL )
2402
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "get_server_output" , cJSON_Number )) != NULL )
2403
2403
iperf_set_test_get_server_output (test , 1 );
2404
- if ((j_p = cJSON_GetObjectItem (j , "udp_counters_64bit" )) != NULL )
2404
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "udp_counters_64bit" , cJSON_Number )) != NULL )
2405
2405
iperf_set_test_udp_counters_64bit (test , 1 );
2406
- if ((j_p = cJSON_GetObjectItem (j , "repeating_payload" )) != NULL )
2406
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "repeating_payload" , cJSON_Number )) != NULL )
2407
2407
test -> repeating_payload = 1 ;
2408
- if ((j_p = cJSON_GetObjectItem (j , "zerocopy" )) != NULL )
2408
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "zerocopy" , cJSON_Number )) != NULL )
2409
2409
test -> zerocopy = j_p -> valueint ;
2410
2410
#if defined(HAVE_DONT_FRAGMENT )
2411
- if ((j_p = cJSON_GetObjectItem (j , "dont_fragment" )) != NULL )
2411
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "dont_fragment" , cJSON_Number )) != NULL )
2412
2412
test -> settings -> dont_fragment = j_p -> valueint ;
2413
2413
#endif /* HAVE_DONT_FRAGMENT */
2414
2414
#if defined(HAVE_SSL )
2415
- if ((j_p = cJSON_GetObjectItem (j , "authtoken" )) != NULL )
2415
+ if ((j_p = iperf_cJSON_GetObjectItemType (j , "authtoken" , cJSON_String )) != NULL )
2416
2416
test -> settings -> authtoken = strdup (j_p -> valuestring );
2417
2417
#endif //HAVE_SSL
2418
2418
if (test -> mode && test -> protocol -> id == Ptcp && has_tcpinfo_retransmits ())
@@ -2571,10 +2571,10 @@ get_results(struct iperf_test *test)
2571
2571
i_errno = IERECVRESULTS ;
2572
2572
r = -1 ;
2573
2573
} else {
2574
- j_cpu_util_total = cJSON_GetObjectItem (j , "cpu_util_total" );
2575
- j_cpu_util_user = cJSON_GetObjectItem (j , "cpu_util_user" );
2576
- j_cpu_util_system = cJSON_GetObjectItem (j , "cpu_util_system" );
2577
- j_sender_has_retransmits = cJSON_GetObjectItem (j , "sender_has_retransmits" );
2574
+ j_cpu_util_total = iperf_cJSON_GetObjectItemType (j , "cpu_util_total" , cJSON_Number );
2575
+ j_cpu_util_user = iperf_cJSON_GetObjectItemType (j , "cpu_util_user" , cJSON_Number );
2576
+ j_cpu_util_system = iperf_cJSON_GetObjectItemType (j , "cpu_util_system" , cJSON_Number );
2577
+ j_sender_has_retransmits = iperf_cJSON_GetObjectItemType (j , "sender_has_retransmits" , cJSON_Number );
2578
2578
if (j_cpu_util_total == NULL || j_cpu_util_user == NULL || j_cpu_util_system == NULL || j_sender_has_retransmits == NULL ) {
2579
2579
i_errno = IERECVRESULTS ;
2580
2580
r = -1 ;
@@ -2596,7 +2596,7 @@ get_results(struct iperf_test *test)
2596
2596
else if ( test -> mode == BIDIRECTIONAL )
2597
2597
test -> other_side_has_retransmits = result_has_retransmits ;
2598
2598
2599
- j_streams = cJSON_GetObjectItem (j , "streams" );
2599
+ j_streams = iperf_cJSON_GetObjectItemType (j , "streams" , cJSON_Array );
2600
2600
if (j_streams == NULL ) {
2601
2601
i_errno = IERECVRESULTS ;
2602
2602
r = -1 ;
@@ -2608,16 +2608,16 @@ get_results(struct iperf_test *test)
2608
2608
i_errno = IERECVRESULTS ;
2609
2609
r = -1 ;
2610
2610
} else {
2611
- j_id = cJSON_GetObjectItem (j_stream , "id" );
2612
- j_bytes = cJSON_GetObjectItem (j_stream , "bytes" );
2613
- j_retransmits = cJSON_GetObjectItem (j_stream , "retransmits" );
2614
- j_jitter = cJSON_GetObjectItem (j_stream , "jitter" );
2615
- j_errors = cJSON_GetObjectItem (j_stream , "errors" );
2616
- j_omitted_errors = cJSON_GetObjectItem (j_stream , "omitted_errors" );
2617
- j_packets = cJSON_GetObjectItem (j_stream , "packets" );
2618
- j_omitted_packets = cJSON_GetObjectItem (j_stream , "omitted_packets" );
2619
- j_start_time = cJSON_GetObjectItem (j_stream , "start_time" );
2620
- j_end_time = cJSON_GetObjectItem (j_stream , "end_time" );
2611
+ j_id = iperf_cJSON_GetObjectItemType (j_stream , "id" , cJSON_Number );
2612
+ j_bytes = iperf_cJSON_GetObjectItemType (j_stream , "bytes" , cJSON_Number );
2613
+ j_retransmits = iperf_cJSON_GetObjectItemType (j_stream , "retransmits" , cJSON_Number );
2614
+ j_jitter = iperf_cJSON_GetObjectItemType (j_stream , "jitter" , cJSON_Number );
2615
+ j_errors = iperf_cJSON_GetObjectItemType (j_stream , "errors" , cJSON_Number );
2616
+ j_omitted_errors = iperf_cJSON_GetObjectItemType (j_stream , "omitted_errors" , cJSON_Number );
2617
+ j_packets = iperf_cJSON_GetObjectItemType (j_stream , "packets" , cJSON_Number );
2618
+ j_omitted_packets = iperf_cJSON_GetObjectItemType (j_stream , "omitted_packets" , cJSON_Number );
2619
+ j_start_time = iperf_cJSON_GetObjectItemType (j_stream , "start_time" , cJSON_Number );
2620
+ j_end_time = iperf_cJSON_GetObjectItemType (j_stream , "end_time" , cJSON_Number );
2621
2621
if (j_id == NULL || j_bytes == NULL || j_retransmits == NULL || j_jitter == NULL || j_errors == NULL || j_packets == NULL ) {
2622
2622
i_errno = IERECVRESULTS ;
2623
2623
r = -1 ;
@@ -2706,7 +2706,7 @@ get_results(struct iperf_test *test)
2706
2706
}
2707
2707
else {
2708
2708
/* No JSON, look for textual output. Make a copy of the text for later. */
2709
- j_server_output = cJSON_GetObjectItem (j , "server_output_text" );
2709
+ j_server_output = iperf_cJSON_GetObjectItemType (j , "server_output_text" , cJSON_String );
2710
2710
if (j_server_output != NULL ) {
2711
2711
test -> server_output_text = strdup (j_server_output -> valuestring );
2712
2712
}
@@ -2715,7 +2715,7 @@ get_results(struct iperf_test *test)
2715
2715
}
2716
2716
}
2717
2717
2718
- j_remote_congestion_used = cJSON_GetObjectItem (j , "congestion_used" );
2718
+ j_remote_congestion_used = iperf_cJSON_GetObjectItemType (j , "congestion_used" , cJSON_String );
2719
2719
if (j_remote_congestion_used != NULL ) {
2720
2720
test -> remote_congestion_used = strdup (j_remote_congestion_used -> valuestring );
2721
2721
}
@@ -4960,7 +4960,7 @@ iperf_json_finish(struct iperf_test *test)
4960
4960
4961
4961
/* --json-stream, so we print various individual objects */
4962
4962
if (test -> json_stream ) {
4963
- cJSON * error = cJSON_GetObjectItem (test -> json_top , "error" );
4963
+ cJSON * error = iperf_cJSON_GetObjectItemType (test -> json_top , "error" , cJSON_String );
4964
4964
if (error ) {
4965
4965
JSONStream_Output (test , "error" , error );
4966
4966
}
0 commit comments