hf.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * $Id$
  3. *
  4. * Copyright (C) 2001-2003 Fhg Fokus
  5. *
  6. * This file is part of ser, a free SIP server.
  7. *
  8. * ser 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 2 of the License, or
  11. * (at your option) any later version
  12. *
  13. * For a license to use the ser software under conditions
  14. * other than those described here, or to purchase support for this
  15. * software, please contact iptel.org by e-mail at the following addresses:
  16. * [email protected]
  17. *
  18. * ser is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, write to the Free Software
  25. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  26. */
  27. #include "hf.h"
  28. #include "parse_via.h"
  29. #include "parse_to.h"
  30. #include "parse_cseq.h"
  31. #include "../dprint.h"
  32. #include "../mem/mem.h"
  33. #include "parse_def.h"
  34. #include "digest/digest.h" /* free_credentials */
  35. #include "parse_event.h"
  36. #include "parse_expires.h"
  37. #include "contact/parse_contact.h"
  38. /*
  39. * Frees a hdr_field structure,
  40. * WARNING: it frees only parsed (and not name.s, body.s)
  41. */
  42. void clean_hdr_field(struct hdr_field* hf)
  43. {
  44. if (hf->parsed){
  45. switch(hf->type){
  46. case HDR_VIA:
  47. free_via_list(hf->parsed);
  48. break;
  49. case HDR_TO:
  50. free_to(hf->parsed);
  51. break;
  52. case HDR_CSEQ:
  53. free_cseq(hf->parsed);
  54. break;
  55. case HDR_AUTHORIZATION:
  56. case HDR_PROXYAUTH:
  57. free_credentials((auth_body_t**)(&(hf->parsed)));
  58. break;
  59. case HDR_FROM:
  60. free_to(hf->parsed);
  61. break;
  62. case HDR_EVENT:
  63. free_event((event_t**)(&(hf->parsed)));
  64. break;
  65. case HDR_EXPIRES:
  66. free_expires((exp_body_t**)(&(hf->parsed)));
  67. break;
  68. case HDR_CONTACT:
  69. free_contact((contact_body_t**)(&(hf->parsed)));
  70. break;
  71. case HDR_CONTENTLENGTH:
  72. case HDR_CONTENTTYPE:
  73. break;
  74. default:
  75. LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
  76. hf->type);
  77. break;
  78. }
  79. }
  80. }
  81. /*
  82. * Frees a hdr_field list,
  83. * WARNING: frees only ->parsed and ->next*/
  84. void free_hdr_field_lst(struct hdr_field* hf)
  85. {
  86. struct hdr_field* foo;
  87. while(hf) {
  88. foo=hf;
  89. hf=hf->next;
  90. clean_hdr_field(foo);
  91. pkg_free(foo);
  92. }
  93. }
  94. void dump_hdr_field( struct hdr_field* hf )
  95. {
  96. LOG(L_ERR, "DEBUG: dump_hdr_field: type=%d, name=%.*s, "
  97. "body=%.*s, parsed=%p, next=%p\n",
  98. hf->type, hf->name.len, hf->name.s,
  99. hf->body.len, hf->body.s,
  100. hf->parsed, hf->next );
  101. }