test_sipmessages.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * Copyright (C) 2009 Mamadou Diop.
  3. *
  4. * Contact: Mamadou Diop <diopmamadou(at)doubango[dot]org>
  5. *
  6. * This file is part of Open Source Doubango Framework.
  7. *
  8. * DOUBANGO is free software: you can redistribute it and/or modify
  9. * it under the terms of the GNU General Public License as published by
  10. * the Free Software Foundation, either version 3 of the License, or
  11. * (at your option) any later version.
  12. *
  13. * DOUBANGO is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with DOUBANGO.
  20. *
  21. */
  22. #ifndef _TEST_SIPMESSAGES_H
  23. #define _TEST_SIPMESSAGES_H
  24. #define SIP_REQUEST \
  25. "REGISTER sip:open-ims.test SIP/2.0\r\n" \
  26. "Test-Header: 0\r\n" \
  27. "v: SIP/2.0/UDP [::]:1988;test=1234;comp=sigcomp;rport=254;ttl=457;received=192.0.2.101;branch=z9hG4bK1245420841406\r\n" \
  28. "f: \"Mamadou\" <sip:mamadou@open-ims.test>;tag=29358\r\n" \
  29. "t: <sip:mamadou@open-ims.test>;tag= 12345\r\n" \
  30. "i: M-fa53180346f7f55ceb8d8670f9223dbb\r\n" \
  31. "CSeq: 201 REGISTER\r\n" \
  32. "Max-Forwards: 70\r\n" \
  33. "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK\r\n" \
  34. "Allow: REFER, UPDATE\r\n" \
  35. "u: talk, hold, conference, LocalModeStatus\r\n" \
  36. "m: <sip:mamadou@[::]:1988;comp=sigcomp;transport=udp>;expires=600000;+deviceID=\"3ca50bcb-7a67-44f1-afd0-994a55f930f4\";mobility=\"fixed\";+g.3gpp.cs-voice;+g.3gpp.app%5fref=\"urn%3Aurnxxx%3A3gpp-application.ims.iari.gsmais\";+g.oma.sip-im.large-message;+g.oma.sip-im\r\n" \
  37. "User-Agent: IM-client/OMA1.0 doubango/v0.0.0\r\n" \
  38. "Require: pref, path\r\n" \
  39. "Service-Route: <sip:orig@open-ims.test:6060;lr>,<sip:orig2@open-ims.test:6060;lr>\r\n" \
  40. "Path: <sip:term@open-ims.test:4060;lr>\r\n" \
  41. "Require: 100rel\r\n" \
  42. "P-Preferred-Identity: <sip:mamadou@open-ims.test>\r\n" \
  43. "k: path\r\n" \
  44. "k: gruu, outbound, timer\r\n" \
  45. "P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n" \
  46. "Privacy: none;user;id\r\n" \
  47. "Supported: gruu, outbound, path, timer\r\n" \
  48. "Expires12: 1983\r\n" \
  49. "l: 180\r\n" \
  50. "\r\n"
  51. #define SIP_RESPONSE \
  52. "SIP/2.0 200 This is my reason phrase\r\n" \
  53. "To: <sip:mamadou@open-ims.test>;tag=bweyal\r\n" \
  54. "Via: SIP/2.0/UDP 192.168.0.11:63140;branch=z9hG4bK1261611942868;rport=63140\r\n" \
  55. "CSeq: 31516 REGISTER\r\n" \
  56. "Content-Length: 0\r\n" \
  57. "Call-ID: 1261611941121\r\n" \
  58. "Min-Expires: 30\r\n" \
  59. "Event: reg\r\n" \
  60. "From: <sip:mamadou@open-ims.test>;tag=1261611941121\r\n" \
  61. "Contact: <sip:mamadou@192.168.0.12:58827;transport=udp>;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300,<sip:mamadou@192.168.0.12:58828;transport=udp>;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300,<sip:mamadou@192.168.0.12:58829;transport=udp>;mobility=fixed;+deviceid=\"DD1289FA-C3D7-47bd-A40D-F1F1B2CC5FFC\";expires=300\r\n"\
  62. "Contact: <sip:mamadou@192.168.0.11:63140>;expires=3600;q=1.0,<sip:mamadou@192.168.0.11:56717>;expires=3600;q=1.0\r\n" \
  63. "Contact: <sip:mamadou@127.0.0.1:5060>;expires=3600;q=1.0\r\n" \
  64. "Contact: <sip:mamadou@127.0.0.1>;expires=3600;q=1.0\r\n" \
  65. "P-Preferred-Identity: <sip:mamadou@open-ims.test>\r\n" \
  66. "Service-Route: <sip:orig@open-ims.test:6060;lr><sip:orig2@open-ims.test:6060;lr>,<sip:orig3@open-ims.test:6060;lr>\r\n" \
  67. "Path: <sip:term@open-ims.test:4060;lr>\r\n" \
  68. "P-Access-Network-Info: 3GPP-UTRAN-TDD;utran-cell-id-3gpp=00000000\r\n" \
  69. "Authorization: Digest username=\"Alice\", realm=\"atlanta.com\",nonce=\"84a4cc6f3082121f32b42a2187831a9e\",response=\"7587245234b3434cc3412213e5f113a5432,test=123\"\r\n" \
  70. "Privacy: none;user;id\r\n" \
  71. "Proxy-Authenticate: Digest realm=\"atlanta.com\",domain=\"sip:ss1.carrier.com\",qop=\"auth,auth-int\",nonce=\"f84f1cec41e6cbe5aea9c8e88d359\",opaque=\"\", stale=FALSE, algorithm=MD5,test=124\r\n" \
  72. "Authorization: Digest username=\"bob\", realm=\"atlanta.example.com\",nonce=\"ea9c8e88df84f1cec4341ae6cbe5a359\", opaque=\"\",uri=\"sips:ss2.biloxi.example.com\",test=\"7854\",response=\"dfe56131d1958046689d83306477ecc\"\r\n" \
  73. "Proxy-Authorization: Digest username=\"Alice\", test=666,realm=\"atlanta.com\",nonce=\"c60f3082ee1212b402a21831ae\",response=\"245f23415f11432b3434341c022\"\r\n" \
  74. "WWW-Authenticate: Digest realm=\"atlanta.com\",domain=\"sip:boxesbybob.com\", qop=\"auth\",nonce=\"f84f1cec41e6cbe5aea9c8e88d359\",opaque=\"\",stale=FALSE,algorithm=MD5,test=\"3\"\r\n" \
  75. "l: 0\r\n" \
  76. "Subscription-State: active;reason=deactivated;expires=507099;retry-after=145;test=jk\r\n"\
  77. "\r\n"
  78. //"Via: SIP/2.0/UDP 192.168.0.11:64163;rport=4;branch=z9hG4bK1262758946486\r\n" \
  79. //"Via: SIP/2.0/UDP 192.168.0.11:59265;rport=59265;branch=z9hG4bK1263064096664\r\n" \
  80. #define SIP_MESSAGE \
  81. "MESSAGE sip:mamadou@open-ims.test SIP/2.0\r\n" \
  82. "Via: SIP/2.0/tcp 127.0.0.1:5082;branch=z9hG4bKc16be5aee32df400d01015675ab911ba,SIP/2.0/udp 127.0.0.1:5082;branch=z9hG4bKeec53b25db240bec92ea250964b8c1fa;received_port_ext=5081;received=192.168.0.13,SIP/2.0/UDP 192.168.0.12:57121;rport=57121;branch=z9hG4bK1274980921982;received_port_ext=5081;received=192.168.0.12\r\n" \
  83. "From: Bob <sip:bob@open-ims.test>;tag=mercuro\r\n" \
  84. "To: \"Alice\"<sip:alice@open-ims.test>\r\n" \
  85. "m: <sip:mamadou@127.0.0.1:5060>\r\n" \
  86. "Call-ID: 1262767804423\r\n" \
  87. "CSeq: 8 MESSAGE\r\n" \
  88. "Refer-To: <sips:a8342043f@atlanta.example.com?Replaces=12345601%40atlanta.example.com%3Bfrom-tag%3D314159%3Bto-tag%3D1234567>\r\n" \
  89. "Refer-To: sip:conf44@example.com;isfocus\r\n" \
  90. "Referred-By: <sip:referrer@referrer.example>;cid=\"20398823.2UWQFN309shb3@referrer.example\"\r\n" \
  91. "Refer-Sub: false;test=45;op\r\n" \
  92. "Refer-Sub: true;p\r\n" \
  93. "RSeq: 17422\r\n" \
  94. "RAck: 776656 1 INVITE\r\n" \
  95. "Min-SE: 90;test;y=0\r\n" \
  96. "Session-Expires: 95;refresher=uas;y=4\r\n" \
  97. "x: 95;refresher=uac;o=7;k\r\n" \
  98. "Max-Forwards: 70\r\n" \
  99. "Date: Wed, 28 Apr 2010 23:42:50 GMT\r\n" \
  100. "Date: Sun, 2 May 2010 20:27:49 GMT\r\n" \
  101. "Allow: INVITE, ACK, CANCEL, BYE, MESSAGE, OPTIONS, NOTIFY, PRACK, UPDATE, REFER\r\n" \
  102. "User-Agent: IM-client/OMA1.0 TestUA/v4.0.1508.0\r\n" \
  103. "c: text/plain; charset=utf-8\r\n" \
  104. "Security-Client: ipsec-3gpp;alg=hmac-md5-96;ealg=aes-cbc;prot=esp;mod=trans;port-c=61676;port-s=61662;spi-c=4294967295;spi-s=67890,tls;q=0.2\r\n" \
  105. "Security-Client: ipsec-ike;q=0.1,tls;q=0.2;test=123\r\n" \
  106. "Security-Server: ipsec-ike;q=0.1,ipsec-3gpp;alg=hmac-md5-96;prot=esp;mod=trans;ealg=aes-cbc;spi-c=5000;spi-s=5001;port-c=78952;port-s=77854\r\n" \
  107. "Security-Verify: ipsec-3gpp;alg=hmac-md5-96;prot=esp;mod=trans;ealg=aes-cbc;spi-c=5000;spi-s=5001;port-c=9999;port-s=20000,ipsec-ike;q=0.1;test=458;toto\r\n" \
  108. "Service-Route: <sip:orig@open-ims.test:6060;lr;transport=udp>,<sip:atlanta.com>,\"Originating\" <sip:orig2@open-ims.test:6060;lr>\r\n" \
  109. "Path: <sip:term@open-ims.test:4060;lr>\r\n" \
  110. "Route: \"Prox-CSCF\" <sip:pcscf.open-ims.test:4060;lr;transport=udp>;test=1,\"Originating\" <sip:orig@scscf.open-ims.test:6060;lr>\r\n" \
  111. "Record-Route: <sip:mo@pcscf.ims.inexbee.com:4060;lr>,\"Originating\"<sip:pcscf.open-ims.test:4060;lr;transport=udp>;test=2\r\n" \
  112. "P-Preferred-Identity: <sip:bob@open-ims.test\r\n" \
  113. "Allow-Events: presence, presence.winfo\r\n" \
  114. "Event: reg\r\n" \
  115. "P-Associated-URI: <sip:bob@open-ims.test>, <sip:0600000001@open-ims.test>, <sip:0100000001@open-ims.test>\r\n" \
  116. "P-Charging-Function-Addresses: ccf=pri_ccf_address\r\n" \
  117. "Server: Sip EXpress router (2.0.0-dev1 OpenIMSCore (i386/linux))\r\n" \
  118. "Warning: 392 192.168.0.15:6060 \"Noisy feedback tells: pid=4521 req_src_ip=192.168.0.15 req_src_port=5060 in_uri=sip:scscf.open-ims.test:6060 out_uri=sip:scscf.open-ims.test:6060 via_cnt==3\"\r\n" \
  119. "P-Asserted-Identity: \"Cullen Jennings\" <sip:fluffy@cisco.com>\r\n" \
  120. "P-Asserted-Identity: tel:+14085264000\r\n" \
  121. "WWW-Authenticate: Digest realm=\"ims.inexbee.com\", nonce=\"iTaxDEv2uO8sKxzVVaRy6IkU9Lra6wAA2xv4BrmCzvY=\", algorithm=AKAv1-MD5, qop=\"auth\"\r\n" \
  122. "WWW-Authenticate: Digest realm=\"ims.cingularme.com\",\r\n nonce=\"b7c9036dbf3054aea9404c7286aee9703dc8f84c2008\",\r\n opaque=\"Lss:scsf-stdn.imsgroup0-001.ims1.wtcdca1.mobility.att.net:5060\",\r\n algorithm=MD5,\r\n qop=\"auth\"\r\n" \
  123. "Content-Length: 11\r\n" \
  124. "Etag: W/'1231-3213213'\r\n" \
  125. "\r\n" \
  126. "How are you"
  127. #define SIP_PUB_GRUU \
  128. "SIP/2.0 200 OK - SAR succesful and registrar saved\r\n" \
  129. "Via: SIP/2.0/UDP 192.168.1.103:46268;received=10.19.3.201;received=10.19.3.201;branch=z9hG4bK1431761912;rport=46268;keep\r\n" \
  130. "From: <sip:1111111111@open-ims.test>;tag=728193295\r\n" \
  131. "To: <sip:1111111111@open-ims.test>;tag=80332102165c3c2994562ca45e4f4401-b009\r\n" \
  132. "Call-ID: ecfb4022-eb8f-ca0d-6885-fbeaafa65854\r\n" \
  133. "CSeq: 1767541515 REGISTER\r\n" \
  134. "P-Associated-URI: <sip:1111111111@open-ims.test>\r\n" \
  135. "Contact: <sip:1111111111@192.168.1.103:37761;transport=udp>;expires=1593;pub-gruu=\"sip:1111111111@open-ims.test;gr=urn%3Auuid%3A00000000-0000-AAAA-8000-18879680264c\"\r\n" \
  136. "Contact: <sip:1111111111@192.168.1.103:46268;transport=udp>;expires=1700;pub-gruu=\"sip:1111111111@open-ims.test;gr=urn%3Auuid%3A00000000-0000-AAAA-8000-18879680264c\"\r\n" \
  137. "Path: <sip:term@pcscf.open-ims.test:4060;lr>\r\n" \
  138. "Service-Route: <sip:orig@scscf.open-ims.test:6060;lr>\r\n" \
  139. "Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, PUBLISH, MESSAGE, INFO\r\n" \
  140. "P-Charging-Function-Addresses: ccf=pri_ccf_address\r\n" \
  141. "Server: Sip EXpress router (2.1.0-dev1 OpenIMSCore (x86_64/linux))\r\n" \
  142. "Content-Length: 0\r\n" \
  143. "Warning: 392 10.19.3.160:6060 \"Noisy feedback tells: pid=30444 req_src_ip=10.19.3.160 req_src_port=5060 in_uri=sip:scscf.open-ims.test:6060 out_uri=sip:scscf.open-ims.test:6060 via_cnt==3\"\r\n" \
  144. "\r\n" \
  145. #define SIP_OPTIONS \
  146. "SIP/2.0 200 OK\r\n" \
  147. "Via: SIP/2.0/TCP 192.168.1.110:49144;received=10.19.3.223;received=10.19.3.223;branch=z9hG4bK580365294;rport=49144\r\n" \
  148. "From: <sip:bob@open-ims.test>;tag=912385275\r\n" \
  149. "To: <sip:1947@open-ims.test>;tag=131610378\r\n" \
  150. "Contact: <sip:bob@192.168.1.135:46716;transport=tcp>;impi=a@example.com\r\n" \
  151. "Call-ID: cbfac0bb-9426-c8cf-fbd9-96bc91ec8acb\r\n" \
  152. "CSeq: 756765417 OPTIONS\r\n" \
  153. "Content-Length: 0\r\n" \
  154. "Accept-Contact: \r\n" \
  155. "Accept: application/sdp\r\n" \
  156. "Accept-Encoding: *\r\n" \
  157. "Accept-Language: en\r\n" \
  158. "Allow: INVITE, ACK, CANCEL, BYE, PRACK, UPDATE, REFER, MESSAGE,OPTIONS\r\n" \
  159. "Supported: gruu\r\n" \
  160. "P-Asserted-Identity: <sip:1947@open-ims.test>\r\n" \
  161. "\r\n"
  162. #define SIP_COMPACT \
  163. "SIP/2.0 200 OK\r\n" \
  164. "Via: SIP/2.0/TCP 10.51.2.181:51483;branch=z9hG4bK1652501;rport=51483;received=10.51.2.181\r\n" \
  165. "From: <sip:847...@10.50.4.29>;tag=1656856\r\n" \
  166. "To: <sip:847...@10.50.4.29>;tag=4553420699375288838\r\n" \
  167. "Contact: <sip:8475551001@10.51.2.181:51483;transport=tcp>;+g.oma.sip-im;language=\"en,fr\"\r\n" \
  168. "Call-ID: d1dab636-ff9b-2672-7521-4bea5e73fa7f\r\n" \
  169. "CSeq: 24466 SUBSCRIBE\r\n" \
  170. "l: 0\r\n" \
  171. "Expires: 3600\r\n" \
  172. "\r\n"
  173. #define SIP_MSG_2_TEST SIP_OPTIONS
  174. void test_parser()
  175. {
  176. tsk_ragel_state_t state;
  177. tsip_message_t *message = tsk_null;
  178. tsk_buffer_t *buffer = tsk_buffer_create_null();
  179. const tsip_header_Contact_t* header_contact;
  180. tsk_size_t i;
  181. tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST));
  182. tsip_message_parse(&state, &message, tsk_true);
  183. for(i = 0; (header_contact = (const tsip_header_Contact_t*)tsip_message_get_headerAt(message, tsip_htype_Contact, i)); ++i) {
  184. const char* pub_gruu = TSIP_HEADER_GET_PARAM_VALUE(header_contact, "pub-gruu");
  185. TSK_DEBUG_INFO("pub-gruu for contact header at index %d = %s", i, (pub_gruu ? pub_gruu : "null"));
  186. }
  187. tsip_message_tostring(message, buffer);
  188. TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer));
  189. TSK_OBJECT_SAFE_FREE(message);
  190. TSK_OBJECT_SAFE_FREE(buffer);
  191. }
  192. void test_requests()
  193. {
  194. tsk_buffer_t *buffer = tsk_buffer_create_null();
  195. tsip_uri_t *from = tsip_uri_parse("sip:mamadou@open-ims.test", tsk_strlen("sip:mamadou@open-ims.test"));
  196. tsip_uri_t *request_uri = tsip_uri_parse("sip:open-ims.test", tsk_strlen("sip:open-ims.test"));
  197. tsip_request_t *request = tsip_request_new("REGISTER", request_uri, from, from, "ABCDEFGHIJKLMOPQRSTUVWXYZ", 4521);
  198. tsip_message_tostring(request, buffer);
  199. TSK_DEBUG_INFO("Buffer=\n%s", TSK_BUFFER_TO_STRING(buffer));
  200. TSK_OBJECT_SAFE_FREE(from);
  201. TSK_OBJECT_SAFE_FREE(request_uri);
  202. TSK_OBJECT_SAFE_FREE(request);
  203. TSK_OBJECT_SAFE_FREE(buffer);
  204. }
  205. void test_responses()
  206. {
  207. tsk_ragel_state_t state;
  208. tsip_request_t *request = 0;
  209. tsip_request_t *response = 0;
  210. tsk_ragel_state_init(&state, SIP_MSG_2_TEST, tsk_strlen(SIP_MSG_2_TEST));
  211. tsip_message_parse(&state, &request, tsk_true);
  212. /* Create the response and destroy the request */
  213. response = tsip_response_new(200, "OK you can move forward", request);
  214. TSK_OBJECT_SAFE_FREE(request);
  215. {
  216. /* DUMP the response */
  217. tsk_buffer_t *buffer = tsk_buffer_create_null();
  218. tsip_message_tostring(response, buffer);
  219. TSK_DEBUG_INFO("Response=\n%s", TSK_BUFFER_TO_STRING(buffer));
  220. TSK_OBJECT_SAFE_FREE(buffer);
  221. }
  222. TSK_OBJECT_SAFE_FREE(response);
  223. }
  224. void test_messages()
  225. {
  226. test_parser();
  227. //test_requests();
  228. //test_responses();
  229. }
  230. #endif /* _TEST_SIPMESSAGES_H */