| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#include "test.h" |
| 20 |
#include <pjsip.h> |
| 21 |
#include <pjlib.h> |
| 22 |
|
| 23 |
#define THIS_FILE "msg_err_test.c" |
| 24 |
|
| 25 |
|
| 26 |
static pj_bool_t verify_success(pjsip_msg *msg, |
| 27 |
pjsip_parser_err_report *err_list) |
| 28 |
{ |
| 29 |
PJ_UNUSED_ARG(msg); |
| 30 |
PJ_UNUSED_ARG(err_list); |
| 31 |
|
| 32 |
return PJ_TRUE; |
| 33 |
} |
| 34 |
|
| 35 |
static struct test_entry |
| 36 |
{ |
| 37 |
char msg[1024]; |
| 38 |
pj_bool_t (*verify)(pjsip_msg *msg, |
| 39 |
pjsip_parser_err_report *err_list); |
| 40 |
|
| 41 |
} test_entries[] = |
| 42 |
{ |
| 43 |
|
| 44 |
{ |
| 45 |
"SIP/2.0 200\r\n" |
| 46 |
"H-Name: H-Value\r\n" |
| 47 |
"\r\n", |
| 48 |
&verify_success |
| 49 |
}, |
| 50 |
|
| 51 |
|
| 52 |
{ |
| 53 |
"SIP/2.0 200 OK\r\n" |
| 54 |
"Via: SIP/2.0\r\n" |
| 55 |
"H-Name: H-Value\r\n" |
| 56 |
"\r\n", |
| 57 |
&verify_success |
| 58 |
}, |
| 59 |
|
| 60 |
|
| 61 |
{ |
| 62 |
"SIP/2.0 200 OK\r\n" |
| 63 |
"Via: SIP/2.0\r\n" |
| 64 |
"H-Name: H-Value\r\n" |
| 65 |
"Via: SIP/2.0\r\n" |
| 66 |
"\r\n", |
| 67 |
&verify_success |
| 68 |
} |
| 69 |
}; |
| 70 |
|
| 71 |
|
| 72 |
int msg_err_test(void) |
| 73 |
{ |
| 74 |
pj_pool_t *pool; |
| 75 |
unsigned i; |
| 76 |
|
| 77 |
PJ_LOG(3,(THIS_FILE, "Testing parsing error")); |
| 78 |
|
| 79 |
pool = pjsip_endpt_create_pool(endpt, "msgerrtest", 4000, 4000); |
| 80 |
|
| 81 |
for (i=0; i<PJ_ARRAY_SIZE(test_entries); ++i) { |
| 82 |
pjsip_parser_err_report err_list, *e; |
| 83 |
|
| 84 |
PJ_LOG(3,(THIS_FILE, " Parsing msg %d", i)); |
| 85 |
pj_list_init(&err_list); |
| 86 |
pjsip_parse_msg(pool, test_entries[i].msg, |
| 87 |
strlen(test_entries[i].msg), &err_list); |
| 88 |
|
| 89 |
e = err_list.next; |
| 90 |
while (e != &err_list) { |
| 91 |
PJ_LOG(3,(THIS_FILE, |
| 92 |
" reported syntax error at line %d col %d for %.*s", |
| 93 |
e->line, e->col, |
| 94 |
(int)e->hname.slen, |
| 95 |
e->hname.ptr)); |
| 96 |
e = e->next; |
| 97 |
} |
| 98 |
} |
| 99 |
|
| 100 |
pj_pool_release(pool); |
| 101 |
return 0; |
| 102 |
} |