tsip_parser_header.rl 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863
  1. /*
  2. * Copyright (C) 2010-2011 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. /**@file tsip_parser_header.c
  23. * @brief SIP headers parser.
  24. *
  25. * @author Mamadou Diop <diopmamadou(at)doubango[dot]org>
  26. *
  27. */
  28. #include "tinysip/parsers/tsip_parser_header.h"
  29. #include "tinysip/headers/tsip_headers.h"
  30. #include "tsk_debug.h"
  31. #undef ADD_HEADERS
  32. #undef ADD_HEADER
  33. #define ADD_HEADERS(headers)\
  34. if(headers)\
  35. {\
  36. const tsk_list_item_t *item;\
  37. tsk_list_foreach(item, headers){\
  38. tsip_header_t *hdr = tsk_object_ref((void*)item->data);\
  39. tsk_list_push_back_data(message->headers, ((void**) &hdr));\
  40. }\
  41. \
  42. TSK_OBJECT_SAFE_FREE(headers);\
  43. }
  44. #define ADD_HEADER(header)\
  45. if(header)\
  46. {\
  47. tsk_list_push_back_data(message->headers, ((void**) &header));\
  48. }
  49. // Check if we have ",CRLF" ==> See WWW-Authenticate header
  50. // As :>CRLF is preceded by any+ ==> p will be at least (start + 1)
  51. // p point to CR
  52. #define prev_not_comma(p) !(p && p[-1] == ',')
  53. /***********************************
  54. * Ragel state machine.
  55. */
  56. %%{
  57. machine tsip_machine_parser_headers;
  58. # /*== Accept: ==*/
  59. action parse_header_Accept
  60. {
  61. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  62. ADD_HEADER(header);
  63. //TSK_DEBUG_WARN("parse_header_Accept NOT IMPLEMENTED. Will be added as Dummy header.");
  64. }
  65. # /*== Accept-Contact: ==*/
  66. action parse_header_Accept_Contact
  67. {
  68. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  69. ADD_HEADER(header);
  70. //TSK_DEBUG_WARN("parse_header_Accept_Contact NOT IMPLEMENTED. Will be added as Dummy header.");
  71. }
  72. # /*== Accept-Encoding: ==*/
  73. action parse_header_Accept_Encoding
  74. {
  75. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  76. ADD_HEADER(header);
  77. //TSK_DEBUG_WARN("parse_header_Accept_Encoding NOT IMPLEMENTED. Will be added as Dummy header.");
  78. }
  79. # /*== Accept-Language: ==*/
  80. action parse_header_Accept_Language
  81. {
  82. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  83. ADD_HEADER(header);
  84. //TSK_DEBUG_WARN("parse_header_Accept_Language NOT IMPLEMENTED. Will be added as Dummy header.");
  85. }
  86. # /*== Accept-Resource-Priority : ==*/
  87. action parse_header_Accept_Resource_Priority
  88. {
  89. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  90. ADD_HEADER(header);
  91. //TSK_DEBUG_WARN("parse_header_Accept_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header.");
  92. }
  93. # /*== Alert-Info: ==*/
  94. action parse_header_Alert_Info
  95. {
  96. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  97. ADD_HEADER(header);
  98. //TSK_DEBUG_WARN("parse_header_Alert_Info NOT IMPLEMENTED. Will be added as Dummy header.");
  99. }
  100. # /*== Allow: ==*/
  101. action parse_header_Allow
  102. {
  103. tsip_header_Allow_t *header = tsip_header_Allow_parse(state->tag_start, (state->tag_end-state->tag_start));
  104. ADD_HEADER(header);
  105. }
  106. # /*== Allow-Events: ==*/
  107. action parse_header_Allow_Events
  108. {
  109. tsip_header_Allow_Events_t *header = tsip_header_Allow_Events_parse(state->tag_start, (state->tag_end-state->tag_start));
  110. ADD_HEADER(header);
  111. }
  112. # /*== Authentication-Info: ==*/
  113. action parse_header_Authentication_Info
  114. {
  115. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  116. ADD_HEADER(header);
  117. //TSK_DEBUG_WARN("parse_header_Authentication_Info NOT IMPLEMENTED. Will be added as Dummy header.");
  118. }
  119. # /*== Authorization: ==*/
  120. action parse_header_Authorization
  121. {
  122. tsip_header_Authorization_t *header = tsip_header_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start));
  123. ADD_HEADER(header);
  124. }
  125. # /*== Call-ID: ==*/
  126. action parse_header_Call_ID
  127. {
  128. if(!message->Call_ID){
  129. message->Call_ID = tsip_header_Call_ID_parse(state->tag_start, (state->tag_end-state->tag_start));
  130. }
  131. else{
  132. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  133. ADD_HEADER(header);
  134. TSK_DEBUG_WARN("The message already have 'Call-ID' header.");
  135. }
  136. }
  137. # /*== Call-Info: ==*/
  138. action parse_header_Call_Info
  139. {
  140. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  141. ADD_HEADER(header);
  142. //TSK_DEBUG_WARN("parse_header_Call_Info NOT IMPLEMENTED. Will be added as Dummy header.");
  143. }
  144. # /*== Contact: ==*/
  145. action parse_header_Contact
  146. {
  147. tsip_header_Contacts_L_t* headers = tsip_header_Contact_parse(state->tag_start, (state->tag_end-state->tag_start));
  148. if(headers)
  149. {
  150. tsk_list_item_t *item;
  151. tsk_list_foreach(item, headers)
  152. {
  153. tsip_header_Contact_t *hdr = tsk_object_ref(item->data);
  154. if(!message->Contact){
  155. message->Contact = hdr;
  156. }
  157. else{
  158. tsk_list_push_back_data(message->headers, ((void**) &hdr));
  159. }
  160. }
  161. TSK_OBJECT_SAFE_FREE(headers);
  162. }
  163. }
  164. # /*== Content-Disposition: ==*/
  165. action parse_header_Content_Disposition
  166. {
  167. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  168. ADD_HEADER(header);
  169. //TSK_DEBUG_WARN("parse_header_Content_Disposition NOT IMPLEMENTED. Will be added as Dummy header.");
  170. }
  171. # /*== Content-Encoding: ==*/
  172. action parse_header_Content_Encoding
  173. {
  174. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  175. ADD_HEADER(header);
  176. TSK_DEBUG_WARN("PARSE_HEADER_ACCEPT NOT IMPLEMENTED. Will be added as Dummy header.");
  177. }
  178. # /*== Content-Language: ==*/
  179. action parse_header_Content_Language
  180. {
  181. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  182. ADD_HEADER(header);
  183. //TSK_DEBUG_WARN("parse_header_Content_Language NOT IMPLEMENTED. Will be added as Dummy header.");
  184. }
  185. # /*== Content-Length: ==*/
  186. action parse_header_Content_Length
  187. {
  188. if(!message->Content_Length){
  189. message->Content_Length = tsip_header_Content_Length_parse(state->tag_start, (state->tag_end-state->tag_start));
  190. }
  191. else{
  192. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  193. ADD_HEADER(header);
  194. TSK_DEBUG_WARN("The message already have 'Content-Length' header.");
  195. }
  196. }
  197. # /*== Content-Type: ==*/
  198. action parse_header_Content_Type
  199. {
  200. if(!message->Content_Type){
  201. message->Content_Type = tsip_header_Content_Type_parse(state->tag_start, (state->tag_end-state->tag_start));
  202. }
  203. else{
  204. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  205. ADD_HEADER(header);
  206. TSK_DEBUG_WARN("The message already have 'Content-Type' header.");
  207. }
  208. }
  209. # /*== CSeq: ==*/
  210. action parse_header_CSeq
  211. {
  212. if(!message->CSeq){
  213. message->CSeq = tsip_header_CSeq_parse(state->tag_start, (state->tag_end-state->tag_start));
  214. }
  215. else{
  216. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  217. ADD_HEADER(header);
  218. TSK_DEBUG_WARN("The message already have 'CSeq' header.");
  219. }
  220. }
  221. # /*== Date: ==*/
  222. action parse_header_Date
  223. {
  224. tsip_header_Date_t *header = tsip_header_Date_parse(state->tag_start, (state->tag_end-state->tag_start));
  225. ADD_HEADER(header);
  226. }
  227. # /*== Error-Info: ==*/
  228. action parse_header_Error_Info
  229. {
  230. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  231. ADD_HEADER(header);
  232. //TSK_DEBUG_WARN("parse_header_Error_Info NOT IMPLEMENTED. Will be added as Dummy header.");
  233. }
  234. # /*== Event: ==*/
  235. action parse_header_Event
  236. {
  237. tsip_header_Event_t *header = tsip_header_Event_parse(state->tag_start, (state->tag_end-state->tag_start));
  238. ADD_HEADER(header);
  239. }
  240. # /*== Expires: ==*/
  241. action parse_header_Expires
  242. {
  243. if(!message->Expires){
  244. message->Expires = tsip_header_Expires_parse(state->tag_start, (state->tag_end-state->tag_start));
  245. }
  246. else{
  247. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  248. ADD_HEADER(header);
  249. TSK_DEBUG_WARN("The message already have 'Expires' header.");
  250. }
  251. }
  252. # /*== From: ==*/
  253. action parse_header_From
  254. {
  255. if(!message->From){
  256. message->From = tsip_header_From_parse(state->tag_start, (state->tag_end-state->tag_start));
  257. }
  258. else{
  259. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  260. ADD_HEADER(header);
  261. TSK_DEBUG_WARN("The message already have 'From' header.");
  262. }
  263. }
  264. # /*== History-Info: ==*/
  265. action parse_header_History_Info
  266. {
  267. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  268. ADD_HEADER(header);
  269. //TSK_DEBUG_WARN("parse_header_History_Info NOT IMPLEMENTED. Will be added as Dummy header.");
  270. }
  271. # /*== Identity: ==*/
  272. action parse_header_Identity
  273. {
  274. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  275. ADD_HEADER(header);
  276. //TSK_DEBUG_WARN("parse_header_Identity NOT IMPLEMENTED. Will be added as Dummy header.");
  277. }
  278. # /*== Identity-Info: ==*/
  279. action parse_header_Identity_Info
  280. {
  281. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  282. ADD_HEADER(header);
  283. //TSK_DEBUG_WARN("parse_header_Identity_Info NOT IMPLEMENTED. Will be added as Dummy header.");
  284. }
  285. # /*== In_Reply-To: ==*/
  286. action parse_header_In_Reply_To
  287. {
  288. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  289. ADD_HEADER(header);
  290. //TSK_DEBUG_WARN("parse_header_In_Reply_To NOT IMPLEMENTED. Will be added as Dummy header.");
  291. }
  292. # /*== Join: ==*/
  293. action parse_header_Join
  294. {
  295. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  296. ADD_HEADER(header);
  297. //TSK_DEBUG_WARN("parse_header_Join NOT IMPLEMENTED. Will be added as Dummy header.");
  298. }
  299. # /*== Max-Forwards: ==*/
  300. action parse_header_Max_Forwards
  301. {
  302. tsip_header_Max_Forwards_t *header = tsip_header_Max_Forwards_parse(state->tag_start, (state->tag_end-state->tag_start));
  303. ADD_HEADER(header);
  304. }
  305. # /*== MIME-Version: ==*/
  306. action parse_header_MIME_Version
  307. {
  308. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  309. ADD_HEADER(header);
  310. //TSK_DEBUG_WARN("parse_header_MIME_Version NOT IMPLEMENTED. Will be added as Dummy header.");
  311. }
  312. # /*== Min-Expires: ==*/
  313. action parse_header_Min_Expires
  314. {
  315. tsip_header_Min_Expires_t *header = tsip_header_Min_Expires_parse(state->tag_start, (state->tag_end-state->tag_start));
  316. ADD_HEADER(header);
  317. }
  318. # /*== Min-SE: ==*/
  319. action parse_header_Min_SE
  320. {
  321. tsip_header_Min_SE_t *header = tsip_header_Min_SE_parse(state->tag_start, (state->tag_end-state->tag_start));
  322. ADD_HEADER(header);
  323. }
  324. # /*== Organization: ==*/
  325. action parse_header_Organization
  326. {
  327. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  328. ADD_HEADER(header);
  329. //TSK_DEBUG_WARN("parse_header_Organization NOT IMPLEMENTED. Will be added as Dummy header.");
  330. }
  331. # /*== P-Access-Network-Info: ==*/
  332. action parse_header_P_Access_Network_Info
  333. {
  334. tsip_header_P_Access_Network_Info_t *header = tsip_header_P_Access_Network_Info_parse(state->tag_start, (state->tag_end-state->tag_start));
  335. ADD_HEADER(header);
  336. }
  337. # /*== P-Answer-State: ==*/
  338. action parse_header_P_Answer_State
  339. {
  340. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  341. ADD_HEADER(header);
  342. //TSK_DEBUG_WARN("parse_header_P_Answer_State NOT IMPLEMENTED. Will be added as Dummy header.");
  343. }
  344. # /*== P-Asserted-Identity: ==*/
  345. action parse_header_P_Asserted_Identity
  346. {
  347. tsip_header_P_Asserted_Identities_L_t* headers = tsip_header_P_Asserted_Identity_parse(state->tag_start, (state->tag_end-state->tag_start));
  348. ADD_HEADERS(headers);
  349. }
  350. # /*== P-Associated-URI: ==*/
  351. action parse_header_P_Associated_URI
  352. {
  353. tsip_header_P_Associated_URIs_L_t* headers = tsip_header_P_Associated_URI_parse(state->tag_start, (state->tag_end-state->tag_start));
  354. ADD_HEADERS(headers);
  355. }
  356. # /*== P-Called-Party-ID: ==*/
  357. action parse_header_P_Called_Party_ID
  358. {
  359. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  360. ADD_HEADER(header);
  361. //TSK_DEBUG_WARN("parse_header_P_Called_Party_ID NOT IMPLEMENTED. Will be added as Dummy header.");
  362. }
  363. # /*== P-Charging-Function-Addresses : ==*/
  364. action parse_header_P_Charging_Function_Addresses
  365. {
  366. tsip_header_P_Charging_Function_Addressess_L_t* headers = tsip_header_P_Charging_Function_Addresses_parse(state->tag_start, (state->tag_end-state->tag_start));
  367. ADD_HEADERS(headers);
  368. }
  369. # /*== P_Charging_Vector: ==*/
  370. action parse_header_P_Charging_Vector
  371. {
  372. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  373. ADD_HEADER(header);
  374. //TSK_DEBUG_WARN("parse_header_P_Charging_Vector NOT IMPLEMENTED. Will be added as Dummy header.");
  375. }
  376. # /*== P-DCS-Billing-Info: ==*/
  377. action parse_header_P_DCS_Billing_Info
  378. {
  379. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  380. ADD_HEADER(header);
  381. //TSK_DEBUG_WARN("parse_header_P_DCS_Billing_Info NOT IMPLEMENTED. Will be added as Dummy header.");
  382. }
  383. # /*== P-DCS-LAES: ==*/
  384. action parse_header_P_DCS_LAES
  385. {
  386. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  387. ADD_HEADER(header);
  388. //TSK_DEBUG_WARN("parse_header_P_DCS_LAES NOT IMPLEMENTED. Will be added as Dummy header.");
  389. }
  390. # /*== P-DCS-OSPS: ==*/
  391. action parse_header_P_DCS_OSPS
  392. {
  393. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  394. ADD_HEADER(header);
  395. //TSK_DEBUG_WARN("parse_header_P_DCS_OSPS NOT IMPLEMENTED. Will be added as Dummy header.");
  396. }
  397. # /*== P-DCS-Redirect: ==*/
  398. action parse_header_P_DCS_Redirect
  399. {
  400. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  401. ADD_HEADER(header);
  402. //TSK_DEBUG_WARN("parse_header_P_DCS_Redirect NOT IMPLEMENTED. Will be added as Dummy header.");
  403. }
  404. # /*== P-DCS-Trace-Party-ID: ==*/
  405. action parse_header_P_DCS_Trace_Party_ID
  406. {
  407. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  408. ADD_HEADER(header);
  409. //TSK_DEBUG_WARN("parse_header_P_DCS_Trace_Party_ID NOT IMPLEMENTED. Will be added as Dummy header.");
  410. }
  411. # /*== P-Early-Media: ==*/
  412. action parse_header_P_Early_Media
  413. {
  414. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  415. ADD_HEADER(header);
  416. //TSK_DEBUG_WARN("parse_header_P_Early_Media NOT IMPLEMENTED. Will be added as Dummy header.");
  417. }
  418. # /*== P-Media-Authorization: ==*/
  419. action parse_header_P_Media_Authorization
  420. {
  421. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  422. ADD_HEADER(header);
  423. //TSK_DEBUG_WARN("parse_header_P_Media_Authorization NOT IMPLEMENTED. Will be added as Dummy header.");
  424. }
  425. # /*== P-Preferred-Identity: ==*/
  426. action parse_header_P_Preferred_Identity
  427. {
  428. tsip_header_P_Preferred_Identity_t *header = tsip_header_P_Preferred_Identity_parse(state->tag_start, (state->tag_end-state->tag_start));
  429. ADD_HEADER(header);
  430. }
  431. # /*== P-Profile-Key: ==*/
  432. action parse_header_P_Profile_Key
  433. {
  434. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  435. ADD_HEADER(header);
  436. //TSK_DEBUG_WARN("parse_header_P_Profile_Key NOT IMPLEMENTED. Will be added as Dummy header.");
  437. }
  438. # /*== P-User-Database: ==*/
  439. action parse_header_P_User_Database
  440. {
  441. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  442. ADD_HEADER(header);
  443. //TSK_DEBUG_WARN("parse_header_P_User_Database NOT IMPLEMENTED. Will be added as Dummy header.");
  444. }
  445. # /*== P-Visited-Network-ID: ==*/
  446. action parse_header_P_Visited_Network_ID
  447. {
  448. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  449. ADD_HEADER(header);
  450. //TSK_DEBUG_WARN("parse_header_P_Visited_Network_ID NOT IMPLEMENTED. Will be added as Dummy header.");
  451. }
  452. # /*== Path: ==*/
  453. action parse_header_Path
  454. {
  455. tsip_header_Paths_L_t* headers = tsip_header_Path_parse(state->tag_start, (state->tag_end-state->tag_start));
  456. ADD_HEADERS(headers);
  457. }
  458. # /* == Priority: ==*/
  459. action parse_header_Priority
  460. {
  461. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  462. ADD_HEADER(header);
  463. //TSK_DEBUG_WARN("parse_header_Priority NOT IMPLEMENTED. Will be added as Dummy header.");
  464. }
  465. # /*== Privacy: ==*/
  466. action parse_header_Privacy
  467. {
  468. tsip_header_Privacy_t *header = tsip_header_Privacy_parse(state->tag_start, (state->tag_end-state->tag_start));
  469. ADD_HEADER(header);
  470. }
  471. # /*== Authenticate: ==*/
  472. action parse_header_Proxy_Authenticate
  473. {
  474. tsip_header_Proxy_Authenticate_t *header = tsip_header_Proxy_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start));
  475. ADD_HEADER(header);
  476. }
  477. # /*== Proxy-Authorization: ==*/
  478. action parse_header_Proxy_Authorization
  479. {
  480. tsip_header_Proxy_Authorization_t *header = tsip_header_Proxy_Authorization_parse(state->tag_start, (state->tag_end-state->tag_start));
  481. ADD_HEADER(header);
  482. }
  483. # /*== Proxy-Require: ==*/
  484. action parse_header_Proxy_Require
  485. {
  486. tsip_header_Proxy_Require_t *header = tsip_header_Proxy_Require_parse(state->tag_start, (state->tag_end-state->tag_start));
  487. ADD_HEADER(header);
  488. }
  489. # /*== RAck: ==*/
  490. action parse_header_RAck
  491. {
  492. tsip_header_RAck_t *header = tsip_header_RAck_parse(state->tag_start, (state->tag_end-state->tag_start));
  493. ADD_HEADER(header);
  494. }
  495. # /*== Reason: ==*/
  496. action parse_header_Reason
  497. {
  498. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  499. ADD_HEADER(header);
  500. //TSK_DEBUG_WARN("parse_header_Reason NOT IMPLEMENTED. Will be added as Dummy header.");
  501. }
  502. # /*== Record-Route: ==*/
  503. action parse_header_Record_Route
  504. {
  505. tsip_header_Record_Routes_L_t* headers = tsip_header_Record_Route_parse(state->tag_start, (state->tag_end-state->tag_start));
  506. ADD_HEADERS(headers);
  507. }
  508. # /*== Refer-Sub: ==*/
  509. action parse_header_Refer_Sub
  510. {
  511. tsip_header_Refer_Sub_t *header = tsip_header_Refer_Sub_parse(state->tag_start, (state->tag_end-state->tag_start));
  512. ADD_HEADER(header);
  513. }
  514. # /*== Refer-To: ==*/
  515. action parse_header_Refer_To
  516. {
  517. tsip_header_Refer_To_t *header = tsip_header_Refer_To_parse(state->tag_start, (state->tag_end-state->tag_start));
  518. ADD_HEADER(header);
  519. }
  520. # /*== Referred-By: ==*/
  521. action parse_header_Referred_By
  522. {
  523. tsip_header_Referred_By_t *header = tsip_header_Referred_By_parse(state->tag_start, (state->tag_end-state->tag_start));
  524. ADD_HEADER(header);
  525. }
  526. # /*== Reject-Contact: ==*/
  527. action parse_header_Reject_Contact
  528. {
  529. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  530. ADD_HEADER(header);
  531. //TSK_DEBUG_WARN("parse_header_Reject_Contact NOT IMPLEMENTED. Will be added as Dummy header.");
  532. }
  533. # /*== Replaces: ==*/
  534. action parse_header_Replaces
  535. {
  536. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  537. ADD_HEADER(header);
  538. //TSK_DEBUG_WARN("parse_header_Replaces NOT IMPLEMENTED. Will be added as Dummy header.");
  539. }
  540. # /*== Reply-To: ==*/
  541. action parse_header_Reply_To
  542. {
  543. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  544. ADD_HEADER(header);
  545. //TSK_DEBUG_WARN("parse_header_Reply_To NOT IMPLEMENTED. Will be added as Dummy header.");
  546. }
  547. # /*== Request-Disposition: ==*/
  548. action parse_header_Request_Disposition
  549. {
  550. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  551. ADD_HEADER(header);
  552. //TSK_DEBUG_WARN("parse_header_Request_Disposition NOT IMPLEMENTED. Will be added as Dummy header.");
  553. }
  554. # /*== Require: ==*/
  555. action parse_header_Require
  556. {
  557. tsip_header_Require_t *header = tsip_header_Require_parse(state->tag_start, (state->tag_end-state->tag_start));
  558. ADD_HEADER(header);
  559. }
  560. # /*== Resource-Priority: ==*/
  561. action parse_header_Resource_Priority
  562. {
  563. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  564. ADD_HEADER(header);
  565. //TSK_DEBUG_WARN("parse_header_Resource_Priority NOT IMPLEMENTED. Will be added as Dummy header.");
  566. }
  567. # /*== Retry-After: ==*/
  568. action parse_header_Retry_After
  569. {
  570. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  571. ADD_HEADER(header);
  572. //TSK_DEBUG_WARN("parse_header_Retry_After NOT IMPLEMENTED. Will be added as Dummy header.");
  573. }
  574. # /*== Route: ==*/
  575. action parse_header_Route
  576. {
  577. tsip_header_Routes_L_t* headers = tsip_header_Route_parse(state->tag_start, (state->tag_end-state->tag_start));
  578. ADD_HEADERS(headers);
  579. }
  580. # /*== RSeq: ==*/
  581. action parse_header_RSeq
  582. {
  583. tsip_header_RSeq_t *header = tsip_header_RSeq_parse(state->tag_start, (state->tag_end-state->tag_start));
  584. ADD_HEADER(header);
  585. }
  586. # /*== Security_Client: ==*/
  587. action parse_header_Security_Client
  588. {
  589. tsip_header_Security_Clients_L_t* headers = tsip_header_Security_Client_parse(state->tag_start, (state->tag_end-state->tag_start));
  590. ADD_HEADERS(headers);
  591. }
  592. # /*== Security-Server: ==*/
  593. action parse_header_Security_Server
  594. {
  595. tsip_header_Security_Servers_L_t* headers = tsip_header_Security_Server_parse(state->tag_start, (state->tag_end-state->tag_start));
  596. ADD_HEADERS(headers);
  597. }
  598. # /*== Security-Verify: ==*/
  599. action parse_header_Security_Verify
  600. {
  601. tsip_header_Security_Verifies_L_t* headers = tsip_header_Security_Verify_parse(state->tag_start, (state->tag_end-state->tag_start));
  602. ADD_HEADERS(headers);
  603. }
  604. # /*== Server: ==*/
  605. action parse_header_Server
  606. {
  607. tsip_header_Server_t *header = tsip_header_Server_parse(state->tag_start, (state->tag_end-state->tag_start));
  608. ADD_HEADER(header);
  609. }
  610. # /*== Service-Route: ==*/
  611. action parse_header_Service_Route
  612. {
  613. tsip_header_Service_Routes_L_t* headers = tsip_header_Service_Route_parse(state->tag_start, (state->tag_end-state->tag_start));
  614. ADD_HEADERS(headers);
  615. }
  616. # /*== Session-Expires: ==*/
  617. action parse_header_Session_Expires
  618. {
  619. tsip_header_Session_Expires_t *header = tsip_header_Session_Expires_parse(state->tag_start, (state->tag_end-state->tag_start));
  620. ADD_HEADER(header);
  621. }
  622. # /*== SIP-ETag: ==*/
  623. action parse_header_SIP_ETag
  624. {
  625. tsip_header_SIP_ETag_t *header = tsip_header_SIP_ETag_parse(state->tag_start, (state->tag_end-state->tag_start));
  626. ADD_HEADER(header);
  627. }
  628. # /*== SIP-If-Match: ==*/
  629. action parse_header_SIP_If_Match
  630. {
  631. tsip_header_SIP_If_Match_t *header = tsip_header_SIP_If_Match_parse(state->tag_start, (state->tag_end-state->tag_start));
  632. ADD_HEADER(header);
  633. }
  634. # /*== Subject: ==*/
  635. action parse_header_Subject
  636. {
  637. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  638. ADD_HEADER(header);
  639. //TSK_DEBUG_WARN("parse_header_Subject NOT IMPLEMENTED. Will be added as Dummy header.");
  640. }
  641. # /*== Subscription-State: ==*/
  642. action parse_header_Subscription_State
  643. {
  644. tsip_header_Subscription_State_t* header = tsip_header_Subscription_State_parse(state->tag_start, (state->tag_end-state->tag_start));
  645. ADD_HEADER(header);
  646. }
  647. # /*== Supported: ==*/
  648. action parse_header_Supported
  649. {
  650. tsip_header_Supported_t *header = tsip_header_Supported_parse(state->tag_start, (state->tag_end-state->tag_start));
  651. ADD_HEADER(header);
  652. }
  653. # /*== Target-Dialog: ==*/
  654. action parse_header_Target_Dialog
  655. {
  656. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  657. ADD_HEADER(header);
  658. //TSK_DEBUG_WARN("parse_header_Target_Dialog NOT IMPLEMENTED. Will be added as Dummy header.");
  659. }
  660. # /*== Timestamp: ==*/
  661. action parse_header_Timestamp
  662. {
  663. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  664. ADD_HEADER(header);
  665. //TSK_DEBUG_WARN("parse_header_Timestamp NOT IMPLEMENTED. Will be added as Dummy header.");
  666. }
  667. # /*== To: ==*/
  668. action parse_header_To
  669. {
  670. if(!message->To){
  671. message->To = tsip_header_To_parse(state->tag_start, (state->tag_end-state->tag_start));
  672. }
  673. else{
  674. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  675. ADD_HEADER(header);
  676. TSK_DEBUG_WARN("The message already have 'To' header.");
  677. }
  678. }
  679. # /*== Unsupported: ==*/
  680. action parse_header_Unsupported
  681. {
  682. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  683. ADD_HEADER(header);
  684. //TSK_DEBUG_WARN("parse_header_Unsupported NOT IMPLEMENTED. Will be added as Dummy header.");
  685. }
  686. # /*== User-Agent: ==*/
  687. action parse_header_User_Agent
  688. {
  689. tsip_header_User_Agent_t *header = tsip_header_User_Agent_parse(state->tag_start, (state->tag_end-state->tag_start));
  690. ADD_HEADER(header);
  691. }
  692. # /*== Via: ==*/
  693. action parse_header_Via
  694. {
  695. tsip_header_Vias_L_t* headers = tsip_header_Via_parse(state->tag_start, (state->tag_end-state->tag_start));
  696. if(headers){
  697. tsk_list_item_t *item;
  698. tsk_list_foreach(item, headers){
  699. tsip_header_Via_t *hdr = tsk_object_ref(item->data);
  700. if(!message->firstVia){
  701. message->firstVia = hdr;
  702. }
  703. else{
  704. tsk_list_push_back_data(message->headers, ((void**) &hdr));
  705. }
  706. }
  707. TSK_OBJECT_SAFE_FREE(headers);
  708. }
  709. }
  710. # /*== Warning: ==*/
  711. action parse_header_Warning
  712. {
  713. tsip_header_Warnings_L_t* headers = tsip_header_Warning_parse(state->tag_start, (state->tag_end-state->tag_start));
  714. ADD_HEADERS(headers);
  715. }
  716. # /*== WWW-Authenticate: ==*/
  717. action parse_header_WWW_Authenticate
  718. {
  719. tsip_header_WWW_Authenticate_t *header = tsip_header_WWW_Authenticate_parse(state->tag_start, (state->tag_end-state->tag_start));
  720. ADD_HEADER(header);
  721. }
  722. # /*== extension_header: ==*/
  723. action parse_header_extension_header
  724. {
  725. tsip_header_Dummy_t *header = tsip_header_Dummy_parse(state->tag_start, (state->tag_end-state->tag_start));
  726. ADD_HEADER(header);
  727. }
  728. action prev_not_comma{
  729. prev_not_comma(p)
  730. }
  731. # Includes
  732. include tsip_machine_utils "./ragel/tsip_machine_utils.rl";
  733. include tsip_machine_header "./ragel/tsip_machine_header.rl";
  734. # Entry point
  735. main := HEADER;
  736. }%%
  737. tsk_bool_t tsip_header_parse(tsk_ragel_state_t *state, tsip_message_t *message)
  738. {
  739. int cs = 0;
  740. const char *p = state->tag_start;
  741. const char *pe = state->tag_end;
  742. const char *eof = pe;
  743. %%write data;
  744. (void)(eof);
  745. (void)(tsip_machine_parser_headers_first_final);
  746. (void)(tsip_machine_parser_headers_error);
  747. (void)(tsip_machine_parser_headers_en_main);
  748. %%write init;
  749. %%write exec;
  750. return ( cs >= %%{ write first_final; }%% );
  751. //return (cs == tsip_machine_parser_headers_first_final);
  752. }