msg_parser.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614
  1. /*
  2. * $Id$
  3. *
  4. * sip msg. header proxy parser
  5. *
  6. *
  7. * Copyright (C) 2001-2003 Fhg Fokus
  8. *
  9. * This file is part of ser, a free SIP server.
  10. *
  11. * ser is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License as published by
  13. * the Free Software Foundation; either version 2 of the License, or
  14. * (at your option) any later version
  15. *
  16. * For a license to use the ser software under conditions
  17. * other than those described here, or to purchase support for this
  18. * software, please contact iptel.org by e-mail at the following addresses:
  19. * [email protected]
  20. *
  21. * ser is distributed in the hope that it will be useful,
  22. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  23. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  24. * GNU General Public License for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software
  28. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  29. *
  30. * History:
  31. * ---------
  32. * 2003-02-28 scratchpad compatibility abandoned (jiri)
  33. * 2003-01-29 scrathcpad removed (jiri)
  34. * 2003-01-27 next baby-step to removing ZT - PRESERVE_ZT (jiri)
  35. * 2003-03-31 removed msg->repl_add_rm (andrei)
  36. * 2003-04-26 ZSW (jiri)
  37. * 2003-05-01 parser extended to support Accept header field (janakj)
  38. * 2005-03-02 free_via_list(vb) on via parse error (andrei)
  39. */
  40. #include <string.h>
  41. #include <stdlib.h>
  42. #include "../comp_defs.h"
  43. #include "msg_parser.h"
  44. #include "parser_f.h"
  45. #include "../ut.h"
  46. #include "../error.h"
  47. #include "../dprint.h"
  48. #include "../data_lump_rpl.h"
  49. #include "../mem/mem.h"
  50. #include "../error.h"
  51. #include "../globals.h"
  52. #include "parse_hname2.h"
  53. #include "parse_uri.h"
  54. #include "parse_content.h"
  55. #ifdef DEBUG_DMALLOC
  56. #include <mem/dmalloc.h>
  57. #endif
  58. #define parse_hname(_b,_e,_h) parse_hname2((_b),(_e),(_h))
  59. /* number of via's encounteded */
  60. int via_cnt;
  61. /* returns pointer to next header line, and fill hdr_f ;
  62. * if at end of header returns pointer to the last crlf (always buf)*/
  63. char* get_hdr_field(char* buf, char* end, struct hdr_field* hdr)
  64. {
  65. char* tmp;
  66. char *match;
  67. struct via_body *vb;
  68. struct cseq_body* cseq_b;
  69. struct to_body* to_b;
  70. int integer;
  71. if ((*buf)=='\n' || (*buf)=='\r'){
  72. /* double crlf or lflf or crcr */
  73. DBG("found end of header\n");
  74. hdr->type=HDR_EOH;
  75. return buf;
  76. }
  77. tmp=parse_hname(buf, end, hdr);
  78. if (hdr->type==HDR_ERROR){
  79. LOG(L_ERR, "ERROR: get_hdr_field: bad header\n");
  80. goto error;
  81. }
  82. /* eliminate leading whitespace */
  83. tmp=eat_lws_end(tmp, end);
  84. if (tmp>=end) {
  85. LOG(L_ERR, "ERROR: get_hdr_field: HF empty\n");
  86. goto error;
  87. }
  88. /* if header-field well-known, parse it, find its end otherwise ;
  89. * after leaving the hdr->type switch, tmp should be set to the
  90. * next header field
  91. */
  92. switch(hdr->type){
  93. case HDR_VIA:
  94. /* keep number of vias parsed -- we want to report it in
  95. replies for diagnostic purposes */
  96. via_cnt++;
  97. vb=pkg_malloc(sizeof(struct via_body));
  98. if (vb==0){
  99. LOG(L_ERR, "get_hdr_field: out of memory\n");
  100. goto error;
  101. }
  102. memset(vb,0,sizeof(struct via_body));
  103. hdr->body.s=tmp;
  104. tmp=parse_via(tmp, end, vb);
  105. if (vb->error==PARSE_ERROR){
  106. LOG(L_ERR, "ERROR: get_hdr_field: bad via\n");
  107. free_via_list(vb);
  108. goto error;
  109. }
  110. hdr->parsed=vb;
  111. vb->hdr.s=hdr->name.s;
  112. vb->hdr.len=hdr->name.len;
  113. hdr->body.len=tmp-hdr->body.s;
  114. break;
  115. case HDR_CSEQ:
  116. cseq_b=pkg_malloc(sizeof(struct cseq_body));
  117. if (cseq_b==0){
  118. LOG(L_ERR, "get_hdr_field: out of memory\n");
  119. goto error;
  120. }
  121. memset(cseq_b, 0, sizeof(struct cseq_body));
  122. hdr->body.s=tmp;
  123. tmp=parse_cseq(tmp, end, cseq_b);
  124. if (cseq_b->error==PARSE_ERROR){
  125. LOG(L_ERR, "ERROR: get_hdr_field: bad cseq\n");
  126. pkg_free(cseq_b);
  127. goto error;
  128. }
  129. hdr->parsed=cseq_b;
  130. hdr->body.len=tmp-hdr->body.s;
  131. DBG("get_hdr_field: cseq <%.*s>: <%.*s> <%.*s>\n",
  132. hdr->name.len, ZSW(hdr->name.s),
  133. cseq_b->number.len, ZSW(cseq_b->number.s),
  134. cseq_b->method.len, cseq_b->method.s);
  135. break;
  136. case HDR_TO:
  137. to_b=pkg_malloc(sizeof(struct to_body));
  138. if (to_b==0){
  139. LOG(L_ERR, "get_hdr_field: out of memory\n");
  140. goto error;
  141. }
  142. memset(to_b, 0, sizeof(struct to_body));
  143. hdr->body.s=tmp;
  144. tmp=parse_to(tmp, end,to_b);
  145. if (to_b->error==PARSE_ERROR){
  146. LOG(L_ERR, "ERROR: get_hdr_field: bad to header\n");
  147. pkg_free(to_b);
  148. goto error;
  149. }
  150. hdr->parsed=to_b;
  151. hdr->body.len=tmp-hdr->body.s;
  152. DBG("DEBUG: get_hdr_field: <%.*s> [%d]; uri=[%.*s] \n",
  153. hdr->name.len, ZSW(hdr->name.s),
  154. hdr->body.len, to_b->uri.len,ZSW(to_b->uri.s));
  155. DBG("DEBUG: to body [%.*s]\n",to_b->body.len,
  156. ZSW(to_b->body.s));
  157. break;
  158. case HDR_CONTENTLENGTH:
  159. hdr->body.s=tmp;
  160. tmp=parse_content_length(tmp,end, &integer);
  161. if (tmp==0){
  162. LOG(L_ERR, "ERROR:get_hdr_field: bad content_length header\n");
  163. goto error;
  164. }
  165. hdr->parsed=(void*)(long)integer;
  166. hdr->body.len=tmp-hdr->body.s;
  167. DBG("DEBUG: get_hdr_body : content_length=%d\n",
  168. (int)(long)hdr->parsed);
  169. break;
  170. case HDR_SUPPORTED:
  171. case HDR_CONTENTTYPE:
  172. case HDR_FROM:
  173. case HDR_CALLID:
  174. case HDR_CONTACT:
  175. case HDR_ROUTE:
  176. case HDR_RECORDROUTE:
  177. case HDR_MAXFORWARDS:
  178. case HDR_AUTHORIZATION:
  179. case HDR_EXPIRES:
  180. case HDR_PROXYAUTH:
  181. case HDR_PROXYREQUIRE:
  182. case HDR_UNSUPPORTED:
  183. case HDR_ALLOW:
  184. case HDR_EVENT:
  185. case HDR_ACCEPT:
  186. case HDR_ACCEPTLANGUAGE:
  187. case HDR_ORGANIZATION:
  188. case HDR_PRIORITY:
  189. case HDR_SUBJECT:
  190. case HDR_USERAGENT:
  191. case HDR_CONTENTDISPOSITION:
  192. case HDR_ACCEPTDISPOSITION:
  193. case HDR_OTHER:
  194. /* just skip over it */
  195. hdr->body.s=tmp;
  196. /* find end of header */
  197. /* find lf */
  198. do{
  199. match=q_memchr(tmp, '\n', end-tmp);
  200. if (match){
  201. match++;
  202. }else {
  203. LOG(L_ERR,
  204. "ERROR: get_hdr_field: bad body for <%s>(%d)\n",
  205. hdr->name.s, hdr->type);
  206. /* abort(); */
  207. tmp=end;
  208. goto error;
  209. }
  210. tmp=match;
  211. }while( match<end &&( (*match==' ')||(*match=='\t') ) );
  212. tmp=match;
  213. hdr->body.len=match-hdr->body.s;
  214. break;
  215. default:
  216. LOG(L_CRIT, "BUG: get_hdr_field: unknown header type %d\n",
  217. hdr->type);
  218. goto error;
  219. }
  220. /* jku: if \r covered by current length, shrink it */
  221. trim_r( hdr->body );
  222. hdr->len=tmp-hdr->name.s;
  223. return tmp;
  224. error:
  225. DBG("get_hdr_field: error exit\n");
  226. hdr->type=HDR_ERROR;
  227. hdr->len=tmp-hdr->name.s;
  228. return tmp;
  229. }
  230. /* parse the headers and adds them to msg->headers and msg->to, from etc.
  231. * It stops when all the headers requested in flags were parsed, on error
  232. * (bad header) or end of headers */
  233. /* note: it continues where it previously stopped and goes ahead until
  234. end is encountered or desired HFs are found; if you call it twice
  235. for the same HF which is present only once, it will fail the second
  236. time; if you call it twice and the HF is found on second time too,
  237. it's not replaced in the well-known HF pointer but just added to
  238. header list; if you want to use a dumbie convenience function which will
  239. give you the first occurance of a header you are interested in,
  240. look at check_transaction_quadruple
  241. */
  242. int parse_headers(struct sip_msg* msg, int flags, int next)
  243. {
  244. struct hdr_field* hf;
  245. char* tmp;
  246. char* rest;
  247. char* end;
  248. int orig_flag;
  249. end=msg->buf+msg->len;
  250. tmp=msg->unparsed;
  251. if (next) {
  252. orig_flag = msg->parsed_flag;
  253. msg->parsed_flag &= ~flags;
  254. }else
  255. orig_flag=0;
  256. DBG("parse_headers: flags=%d\n", flags);
  257. while( tmp<end && (flags & msg->parsed_flag) != flags){
  258. hf=pkg_malloc(sizeof(struct hdr_field));
  259. if (hf==0){
  260. ser_error=E_OUT_OF_MEM;
  261. LOG(L_ERR, "ERROR:parse_headers: memory allocation error\n");
  262. goto error;
  263. }
  264. memset(hf,0, sizeof(struct hdr_field));
  265. hf->type=HDR_ERROR;
  266. rest=get_hdr_field(tmp, msg->buf+msg->len, hf);
  267. switch (hf->type){
  268. case HDR_ERROR:
  269. LOG(L_INFO,"ERROR: bad header field\n");
  270. goto error;
  271. case HDR_EOH:
  272. msg->eoh=tmp; /* or rest?*/
  273. msg->parsed_flag|=HDR_EOH;
  274. pkg_free(hf);
  275. goto skip;
  276. case HDR_OTHER: /*do nothing*/
  277. break;
  278. case HDR_CALLID:
  279. if (msg->callid==0) msg->callid=hf;
  280. msg->parsed_flag|=HDR_CALLID;
  281. break;
  282. case HDR_TO:
  283. if (msg->to==0) msg->to=hf;
  284. msg->parsed_flag|=HDR_TO;
  285. break;
  286. case HDR_CSEQ:
  287. if (msg->cseq==0) msg->cseq=hf;
  288. msg->parsed_flag|=HDR_CSEQ;
  289. break;
  290. case HDR_FROM:
  291. if (msg->from==0) msg->from=hf;
  292. msg->parsed_flag|=HDR_FROM;
  293. break;
  294. case HDR_CONTACT:
  295. if (msg->contact==0) msg->contact=hf;
  296. msg->parsed_flag|=HDR_CONTACT;
  297. break;
  298. case HDR_MAXFORWARDS:
  299. if(msg->maxforwards==0) msg->maxforwards=hf;
  300. msg->parsed_flag|=HDR_MAXFORWARDS;
  301. break;
  302. case HDR_ROUTE:
  303. if (msg->route==0) msg->route=hf;
  304. msg->parsed_flag|=HDR_ROUTE;
  305. break;
  306. case HDR_RECORDROUTE:
  307. if (msg->record_route==0) msg->record_route = hf;
  308. msg->parsed_flag|=HDR_RECORDROUTE;
  309. break;
  310. case HDR_CONTENTTYPE:
  311. if (msg->content_type==0) msg->content_type = hf;
  312. msg->parsed_flag|=HDR_CONTENTTYPE;
  313. break;
  314. case HDR_CONTENTLENGTH:
  315. if (msg->content_length==0) msg->content_length = hf;
  316. msg->parsed_flag|=HDR_CONTENTLENGTH;
  317. break;
  318. case HDR_AUTHORIZATION:
  319. if (msg->authorization==0) msg->authorization = hf;
  320. msg->parsed_flag|=HDR_AUTHORIZATION;
  321. break;
  322. case HDR_EXPIRES:
  323. if (msg->expires==0) msg->expires = hf;
  324. msg->parsed_flag|=HDR_EXPIRES;
  325. break;
  326. case HDR_PROXYAUTH:
  327. if (msg->proxy_auth==0) msg->proxy_auth = hf;
  328. msg->parsed_flag|=HDR_PROXYAUTH;
  329. break;
  330. case HDR_PROXYREQUIRE:
  331. if (msg->proxy_require==0) msg->proxy_require = hf;
  332. msg->parsed_flag|=HDR_PROXYREQUIRE;
  333. break;
  334. case HDR_SUPPORTED:
  335. if (msg->supported==0) msg->supported=hf;
  336. msg->parsed_flag|=HDR_SUPPORTED;
  337. break;
  338. case HDR_UNSUPPORTED:
  339. if (msg->unsupported==0) msg->unsupported=hf;
  340. msg->parsed_flag|=HDR_UNSUPPORTED;
  341. break;
  342. case HDR_ALLOW:
  343. if (msg->allow==0) msg->allow = hf;
  344. msg->parsed_flag|=HDR_ALLOW;
  345. break;
  346. case HDR_EVENT:
  347. if (msg->event==0) msg->event = hf;
  348. msg->parsed_flag|=HDR_EVENT;
  349. break;
  350. case HDR_ACCEPT:
  351. if (msg->accept==0) msg->accept = hf;
  352. msg->parsed_flag|=HDR_ACCEPT;
  353. break;
  354. case HDR_ACCEPTLANGUAGE:
  355. if (msg->accept_language==0) msg->accept_language = hf;
  356. msg->parsed_flag|=HDR_ACCEPTLANGUAGE;
  357. break;
  358. case HDR_ORGANIZATION:
  359. if (msg->organization==0) msg->organization = hf;
  360. msg->parsed_flag|=HDR_ORGANIZATION;
  361. break;
  362. case HDR_PRIORITY:
  363. if (msg->priority==0) msg->priority = hf;
  364. msg->parsed_flag|=HDR_PRIORITY;
  365. break;
  366. case HDR_SUBJECT:
  367. if (msg->subject==0) msg->subject = hf;
  368. msg->parsed_flag|=HDR_SUBJECT;
  369. break;
  370. case HDR_USERAGENT:
  371. if (msg->user_agent==0) msg->user_agent = hf;
  372. msg->parsed_flag|=HDR_USERAGENT;
  373. break;
  374. case HDR_CONTENTDISPOSITION:
  375. if (msg->content_disposition==0) msg->content_disposition = hf;
  376. msg->parsed_flag|=HDR_CONTENTDISPOSITION;
  377. break;
  378. case HDR_ACCEPTDISPOSITION:
  379. if (msg->accept_disposition==0) msg->accept_disposition = hf;
  380. msg->parsed_flag|=HDR_ACCEPTDISPOSITION;
  381. break;
  382. case HDR_VIA:
  383. msg->parsed_flag|=HDR_VIA;
  384. DBG("parse_headers: Via found, flags=%d\n", flags);
  385. if (msg->via1==0) {
  386. DBG("parse_headers: this is the first via\n");
  387. msg->h_via1=hf;
  388. msg->via1=hf->parsed;
  389. if (msg->via1->next){
  390. msg->via2=msg->via1->next;
  391. msg->parsed_flag|=HDR_VIA2;
  392. }
  393. }else if (msg->via2==0){
  394. msg->h_via2=hf;
  395. msg->via2=hf->parsed;
  396. msg->parsed_flag|=HDR_VIA2;
  397. DBG("parse_headers: this is the second via\n");
  398. }
  399. break;
  400. default:
  401. LOG(L_CRIT, "BUG: parse_headers: unknown header type %d\n",
  402. hf->type);
  403. goto error;
  404. }
  405. /* add the header to the list*/
  406. if (msg->last_header==0){
  407. msg->headers=hf;
  408. msg->last_header=hf;
  409. }else{
  410. msg->last_header->next=hf;
  411. msg->last_header=hf;
  412. }
  413. #ifdef EXTRA_DEBUG
  414. DBG("header field type %d, name=<%.*s>, body=<%.*s>\n",
  415. hf->type,
  416. hf->name.len, ZSW(hf->name.s),
  417. hf->body.len, ZSW(hf->body.s));
  418. #endif
  419. tmp=rest;
  420. }
  421. skip:
  422. msg->unparsed=tmp;
  423. return 0;
  424. error:
  425. ser_error=E_BAD_REQ;
  426. if (hf) pkg_free(hf);
  427. if (next) msg->parsed_flag |= orig_flag;
  428. return -1;
  429. }
  430. /* returns 0 if ok, -1 for errors */
  431. int parse_msg(char* buf, unsigned int len, struct sip_msg* msg)
  432. {
  433. char *tmp;
  434. char* rest;
  435. char* first_via;
  436. char* second_via;
  437. struct msg_start *fl;
  438. int offset;
  439. int flags;
  440. /* eat crlf from the beginning */
  441. for (tmp=buf; (*tmp=='\n' || *tmp=='\r')&&
  442. tmp-buf < len ; tmp++);
  443. offset=tmp-buf;
  444. fl=&(msg->first_line);
  445. rest=parse_first_line(tmp, len-offset, fl);
  446. #if 0
  447. rest=parse_fline(tmp, buf+len, fl);
  448. #endif
  449. offset+=rest-tmp;
  450. tmp=rest;
  451. switch(fl->type){
  452. case SIP_INVALID:
  453. DBG("parse_msg: invalid message\n");
  454. goto error;
  455. break;
  456. case SIP_REQUEST:
  457. DBG("SIP Request:\n");
  458. DBG(" method: <%.*s>\n",fl->u.request.method.len,
  459. ZSW(fl->u.request.method.s));
  460. DBG(" uri: <%.*s>\n",fl->u.request.uri.len,
  461. ZSW(fl->u.request.uri.s));
  462. DBG(" version: <%.*s>\n",fl->u.request.version.len,
  463. ZSW(fl->u.request.version.s));
  464. flags=HDR_VIA;
  465. break;
  466. case SIP_REPLY:
  467. DBG("SIP Reply (status):\n");
  468. DBG(" version: <%.*s>\n",fl->u.reply.version.len,
  469. ZSW(fl->u.reply.version.s));
  470. DBG(" status: <%.*s>\n", fl->u.reply.status.len,
  471. ZSW(fl->u.reply.status.s));
  472. DBG(" reason: <%.*s>\n", fl->u.reply.reason.len,
  473. ZSW(fl->u.reply.reason.s));
  474. /* flags=HDR_VIA | HDR_VIA2; */
  475. /* we don't try to parse VIA2 for local messages; -Jiri */
  476. flags=HDR_VIA;
  477. break;
  478. default:
  479. DBG("unknown type %d\n",fl->type);
  480. goto error;
  481. }
  482. msg->unparsed=tmp;
  483. /*find first Via: */
  484. first_via=0;
  485. second_via=0;
  486. if (parse_headers(msg, flags, 0)==-1) goto error;
  487. #ifdef EXTRA_DEBUG
  488. /* dump parsed data */
  489. if (msg->via1){
  490. DBG(" first via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
  491. msg->via1->name.len,
  492. ZSW(msg->via1->name.s),
  493. msg->via1->version.len,
  494. ZSW(msg->via1->version.s),
  495. msg->via1->transport.len,
  496. ZSW(msg->via1->transport.s),
  497. msg->via1->host.len,
  498. ZSW(msg->via1->host.s),
  499. msg->via1->port_str.len,
  500. ZSW(msg->via1->port_str.s),
  501. msg->via1->port);
  502. if (msg->via1->params.s) DBG(";<%.*s>",
  503. msg->via1->params.len, ZSW(msg->via1->params.s));
  504. if (msg->via1->comment.s)
  505. DBG(" <%.*s>",
  506. msg->via1->comment.len, ZSW(msg->via1->comment.s));
  507. DBG ("\n");
  508. }
  509. if (msg->via2){
  510. DBG(" first via: <%.*s/%.*s/%.*s> <%.*s:%.*s(%d)>",
  511. msg->via2->name.len,
  512. ZSW(msg->via2->name.s),
  513. msg->via2->version.len,
  514. ZSW(msg->via2->version.s),
  515. msg->via2->transport.len,
  516. ZSW(msg->via2->transport.s),
  517. msg->via2->host.len,
  518. ZSW(msg->via2->host.s),
  519. msg->via2->port_str.len,
  520. ZSW(msg->via2->port_str.s),
  521. msg->via2->port);
  522. if (msg->via2->params.s) DBG(";<%.*s>",
  523. msg->via2->params.len, ZSW(msg->via2->params.s));
  524. if (msg->via2->comment.s) DBG(" <%.*s>",
  525. msg->via2->comment.len, ZSW(msg->via2->comment.s));
  526. DBG ("\n");
  527. }
  528. #endif
  529. #ifdef EXTRA_DEBUG
  530. DBG("exiting parse_msg\n");
  531. #endif
  532. return 0;
  533. error:
  534. /* more debugging, msg->orig is/should be null terminated*/
  535. LOG(L_ERR, "ERROR: parse_msg: message=<%.*s>\n",
  536. (int)msg->len, ZSW(msg->buf));
  537. return -1;
  538. }
  539. void free_reply_lump( struct lump_rpl *lump)
  540. {
  541. struct lump_rpl *foo, *bar;
  542. for(foo=lump;foo;)
  543. {
  544. bar=foo->next;
  545. free_lump_rpl(foo);
  546. foo = bar;
  547. }
  548. }
  549. /*only the content*/
  550. void free_sip_msg(struct sip_msg* msg)
  551. {
  552. if (msg->new_uri.s) { pkg_free(msg->new_uri.s); msg->new_uri.len=0; }
  553. if (msg->headers) free_hdr_field_lst(msg->headers);
  554. if (msg->add_rm) free_lump_list(msg->add_rm);
  555. if (msg->body_lumps) free_lump_list(msg->body_lumps);
  556. if (msg->reply_lump) free_reply_lump(msg->reply_lump);
  557. /* don't free anymore -- now a pointer to a static buffer */
  558. # ifdef DYN_BUF
  559. pkg_free(msg->buf);
  560. # endif
  561. }
  562. /* make sure all HFs needed for transaction identification have been
  563. parsed; return 0 if those HFs can't be found
  564. */
  565. int check_transaction_quadruple( struct sip_msg* msg )
  566. {
  567. if ( parse_headers(msg, HDR_FROM|HDR_TO|HDR_CALLID|HDR_CSEQ,0)!=-1
  568. && msg->from && msg->to && msg->callid && msg->cseq ) {
  569. return 1;
  570. } else {
  571. ser_error=E_BAD_TUPEL;
  572. return 0;
  573. }
  574. }