Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <string.h>
- #include <pjsip.h>
- #include <pjlib.h>
- #define THIS_FILE "pjsiptest.cpp"
- int main()
- {
- char __MSG[] = {
- "INVITE sip:user@foo SIP/2.0\n" // 28
- "from: Hi I'm Joe <sip:joe.user@bar.otherdomain.com>;tag=123457890123456\r" // 73
- "To: Fellow User <sip:user@foo.bar.domain.com>\r\n" // 50
- "Call-ID: 12345678901234567890@bar\r\n" // 35
- "Content-Length: 0\r\n" // 19
- "CSeq: 123456 INVITE\n" // 20
- "Contact: <sip:joe@bar> ; q=0.5;expires=3600,sip:user@host;q=0.500\r" // 66
- " ,sip:user2@host2\n" // 19
- "Content-Type: text/html ; charset=ISO-8859-4\r" // 45
- "Route: <sip:bigbox3.site3.atlanta.com;lr>,\r\n" // 44
- " <sip:server10.biloxi.com;lr>\r" // 31
- "Record-Route: <sip:server10.biloxi.com>,\r\n" /* multiple routes+folding*/ // 42
- " <sip:bigbox3.site3.atlanta.com;lr>\n" // 37
- "v: SIP/2.0/SCTP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c230\n" // 66
- "Via: SIP/2.0/UDP pc33.atlanta.com;branch=z9hG4bKnashds8\n" /* folding. */ // 56
- " ;received=192.0.2.1\r\n" // 22
- "Via: SIP/2.0/UDP 10.2.1.1, SIP/2.0/TCP 192.168.1.1\n" //51
- "Organization: \r" // 15
- "Max-Forwards: 70\n" // 17
- "X-Header: \r\n" //12 /* empty header */
- "P-Associated-URI:\r\n" //19 /* empty header without space */
- "\r\n\0"
- };
- char msg2[] = {
- "SIP/2.0 200 OK\r\n"
- "Via: SIP/2.0/UDP bigbox3.site3.atlanta.com;branch=z9hG4bK77ef4c2312983.1;received=192.0.2.2\r\n"
- "To: Bob <sip:bob@biloxi.com>;tag=a6c85cf\r\n"
- "From: Alice <sip:alice@atlanta.com>;tag=1928301774\r\n"
- "Call-ID: a84b4c76e66710@pc33.atlanta.com\r\n"
- "CSeq: 314159 INVITE\r\n"
- ": <sips:bob@192.0.2.4>\r\n"
- "Content-Type: application/sdp\r\n"
- "Content-Length: 150\r\n"
- "\r\n"
- "v=0\r\n"
- "o=alice 53655765 2353687637 IN IP4 pc33.atlanta.com\r\n"
- "s=-\r\n"
- "t=0 0\r\n"
- "c=IN IP4 pc33.atlanta.com\r\n"
- "m=audio 3456 RTP/AVP 0 1 3 99\r\n"
- "a=rtpmap:0 PCMU/8000\r\n"
- };
- char msg3[] = {
- "ACK sip:odbiorcak@domena-ok.com SIP/2.0"
- "Via: SIP/2.0/UDP domena-n.com:5060;branch=z9hG4bK321g"
- "Max-Forwards: 70"
- "To: Nazwa odbiorcy <sip:odbiorca@domena-o.com>;tag=a53e42"
- "From: Nazwa nadawcy <sip: nadawca@domena-n.com>;tag=76341"
- "Call-ID: 123456789@domena-n.com"
- "CSeq: 1 ACK"
- "Content-Length: 0"
- };
- char msg4[] = {
- "ACK sip:odbiorcak@domena-ok.com SIP/2.0\r\n"
- };
- char *testmsg = msg4;
- pj_size_t msgsize;
- pj_status_t status;
- // INIT
- status = pj_init();
- PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
- status = pjlib_util_init();
- PJ_ASSERT_RETURN(status == PJ_SUCCESS, 1);
- // PARSING
- pj_caching_pool cp;
- pj_caching_pool_init(&cp, NULL, 1024*1024);
- pj_pool_t *pool = pj_pool_create(&cp.factory, "parser_pool", 4000, 4000, NULL);
- pjsip_parser_err_report err;
- int len = strlen(testmsg);
- pjsip_msg *msg = pjsip_parse_msg(pool, testmsg, len, &err);
- printf("The end...");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement