Skip to content

Commit 1742c3d

Browse files
authored
Merge pull request cisco#682 from pabuhler/use-bool-in-test
use bool for test_extension_headers in test
2 parents fc45123 + 2a5148e commit 1742c3d

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

test/srtp_driver.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void srtp_do_timing(const srtp_policy_t *policy);
112112
void srtp_do_rejection_timing(const srtp_policy_t *policy);
113113

114114
srtp_err_status_t srtp_test(const srtp_policy_t *policy,
115-
int extension_header,
115+
bool test_extension_headers,
116116
int mki_index);
117117

118118
srtp_err_status_t srtcp_test(const srtp_policy_t *policy, int mki_index);
@@ -326,7 +326,7 @@ int main(int argc, char *argv[])
326326
/* loop over policy array, testing srtp and srtcp for each policy */
327327
while (*policy != NULL) {
328328
printf("testing srtp_protect and srtp_unprotect\n");
329-
if (srtp_test(*policy, 0, -1) == srtp_err_status_ok) {
329+
if (srtp_test(*policy, false, -1) == srtp_err_status_ok) {
330330
printf("passed\n\n");
331331
} else {
332332
printf("failed\n");
@@ -335,7 +335,7 @@ int main(int argc, char *argv[])
335335

336336
printf("testing srtp_protect and srtp_unprotect with encrypted "
337337
"extensions headers\n");
338-
if (srtp_test(*policy, 1, -1) == srtp_err_status_ok) {
338+
if (srtp_test(*policy, true, -1) == srtp_err_status_ok) {
339339
printf("passed\n\n");
340340
} else {
341341
printf("failed\n");
@@ -350,15 +350,15 @@ int main(int argc, char *argv[])
350350
}
351351
printf("testing srtp_protect_rtp and srtp_unprotect_rtp with MKI "
352352
"index set to 0\n");
353-
if (srtp_test(*policy, 0, 0) == srtp_err_status_ok) {
353+
if (srtp_test(*policy, false, 0) == srtp_err_status_ok) {
354354
printf("passed\n\n");
355355
} else {
356356
printf("failed\n");
357357
exit(1);
358358
}
359359
printf("testing srtp_protect_rtp and srtp_unprotect_rtp with MKI "
360360
"index set to 1\n");
361-
if (srtp_test(*policy, 0, 1) == srtp_err_status_ok) {
361+
if (srtp_test(*policy, false, 1) == srtp_err_status_ok) {
362362
printf("passed\n\n");
363363
} else {
364364
printf("failed\n");
@@ -406,15 +406,15 @@ int main(int argc, char *argv[])
406406
exit(1);
407407
}
408408
printf("testing srtp_protect and srtp_unprotect with big policy\n");
409-
if (srtp_test(big_policy, 0, -1) == srtp_err_status_ok) {
409+
if (srtp_test(big_policy, false, -1) == srtp_err_status_ok) {
410410
printf("passed\n\n");
411411
} else {
412412
printf("failed\n");
413413
exit(1);
414414
}
415415
printf("testing srtp_protect and srtp_unprotect with big policy and "
416416
"encrypted extensions headers\n");
417-
if (srtp_test(big_policy, 1, -1) == srtp_err_status_ok) {
417+
if (srtp_test(big_policy, true, -1) == srtp_err_status_ok) {
418418
printf("passed\n\n");
419419
} else {
420420
printf("failed\n");
@@ -429,15 +429,15 @@ int main(int argc, char *argv[])
429429
/* run test on wildcard policy */
430430
printf("testing srtp_protect and srtp_unprotect on "
431431
"wildcard ssrc policy\n");
432-
if (srtp_test(&wildcard_policy, 0, -1) == srtp_err_status_ok) {
432+
if (srtp_test(&wildcard_policy, false, -1) == srtp_err_status_ok) {
433433
printf("passed\n\n");
434434
} else {
435435
printf("failed\n");
436436
exit(1);
437437
}
438438
printf("testing srtp_protect and srtp_unprotect on "
439439
"wildcard ssrc policy and encrypted extensions headers\n");
440-
if (srtp_test(&wildcard_policy, 1, -1) == srtp_err_status_ok) {
440+
if (srtp_test(&wildcard_policy, true, -1) == srtp_err_status_ok) {
441441
printf("passed\n\n");
442442
} else {
443443
printf("failed\n");
@@ -1087,7 +1087,7 @@ srtp_err_status_t srtp_test_call_unprotect_rtcp(srtp_t srtp_sender,
10871087
}
10881088

10891089
srtp_err_status_t srtp_test(const srtp_policy_t *policy,
1090-
int extension_header,
1090+
bool test_extension_headers,
10911091
int mki_index)
10921092
{
10931093
size_t i;
@@ -1109,7 +1109,7 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy,
11091109
if (mki_index >= 0)
11101110
use_mki = true;
11111111

1112-
if (extension_header) {
1112+
if (test_extension_headers) {
11131113
memcpy(&tmp_policy, policy, sizeof(srtp_policy_t));
11141114
tmp_policy.enc_xtn_hdr = &header;
11151115
tmp_policy.enc_xtn_hdr_count = 1;
@@ -1132,7 +1132,7 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy,
11321132
ssrc = policy->ssrc.value;
11331133
}
11341134
msg_len_octets = 28;
1135-
if (extension_header) {
1135+
if (test_extension_headers) {
11361136
hdr = srtp_create_test_packet_ext_hdr(msg_len_octets, ssrc, &len);
11371137
hdr2 = srtp_create_test_packet_ext_hdr(msg_len_octets, ssrc, &len2);
11381138
} else {
@@ -1233,7 +1233,7 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy,
12331233
free(hdr2);
12341234
return srtp_err_status_alloc_fail;
12351235
}
1236-
if (extension_header) {
1236+
if (test_extension_headers) {
12371237
memcpy(rcvr_policy, &tmp_policy, sizeof(srtp_policy_t));
12381238
if (tmp_policy.ssrc.type == ssrc_any_outbound) {
12391239
rcvr_policy->ssrc.type = ssrc_any_inbound;
@@ -1270,7 +1270,7 @@ srtp_err_status_t srtp_test(const srtp_policy_t *policy,
12701270
* if the policy includes authentication, then test for false positives
12711271
*/
12721272
if (policy->rtp.sec_serv & sec_serv_auth) {
1273-
uint8_t *data = hdr + (extension_header ? 24 : 12);
1273+
uint8_t *data = hdr + (test_extension_headers ? 24 : 12);
12741274

12751275
printf("testing for false positives in replay check...");
12761276

0 commit comments

Comments
 (0)