data_lump.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * $Id$
  3. *
  4. * adding/removing headers or any other data chunk from a message
  5. *
  6. * Copyright (C) 2001-2003 FhG Fokus
  7. *
  8. * This file is part of ser, a free SIP server.
  9. *
  10. * ser is free software; you can redistribute it and/or modify
  11. * it under the terms of the GNU General Public License as published by
  12. * the Free Software Foundation; either version 2 of the License, or
  13. * (at your option) any later version
  14. *
  15. * ser is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  23. */
  24. /* History:
  25. * --------
  26. * 2003-01-29 s/int/enum ... more convenient for gdb (jiri)
  27. * 2003-03-31 added subst lumps -- they expand in ip addr, port a.s.o (andrei)
  28. * 2003-04-01 added opt (condition) lumps (andrei)
  29. * 2003-04-02 added more subst lumps: SUBST_{SND,RCV}_ALL
  30. * => ip:port;transport=proto (andrei)
  31. * 2005-03-22 the type of type attribute changed to enum _hdr_types_t (janakj)
  32. *
  33. */
  34. /*!
  35. * \file
  36. * \brief SIP-router core :: Data_lumps
  37. * \ingroup core
  38. * Module: \ref core
  39. */
  40. #ifndef data_lump_h
  41. #define data_lump_h
  42. #include "lump_struct.h"
  43. #include "parser/msg_parser.h"
  44. #include "parser/hf.h"
  45. /* adds a header right after an anchor point if exists */
  46. struct lump* add_new_lump(struct lump** list, char* new_hdr,
  47. int len, enum _hdr_types_t type);
  48. /*! \brief adds a header to the end */
  49. struct lump* append_new_lump(struct lump** list, char* new_hdr,
  50. int len, enum _hdr_types_t type);
  51. /*! \brief inserts a header to the beginning */
  52. struct lump* insert_new_lump(struct lump** list, char* new_hdr,
  53. int len, enum _hdr_types_t type);
  54. struct lump* insert_new_lump_after(struct lump* after,
  55. char* new_hdr, int len, enum _hdr_types_t type);
  56. struct lump* insert_new_lump_before(struct lump* before, char* new_hdr,
  57. int len,enum _hdr_types_t type);
  58. /*! \brief substitutions (replace with ip address, port etc) */
  59. struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst,
  60. enum _hdr_types_t type);
  61. struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst,
  62. enum _hdr_types_t type);
  63. /*! \brief conditional lumps */
  64. struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c,
  65. enum _hdr_types_t type);
  66. struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c,
  67. enum _hdr_types_t type);
  68. /* set an anchor if there is no existing one at the given offset,
  69. * otherwise return the existing anchor */
  70. struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type,
  71. int *is_ref);
  72. /*! \brief removes an already existing header */
  73. struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type);
  74. /*! \brief set an anchor */
  75. struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type);
  76. /*! \brief duplicates a lump list shallowly in pkg-mem */
  77. struct lump* dup_lump_list( struct lump *l );
  78. /*! \brief frees a shallowly duplicated lump list */
  79. void free_duped_lump_list(struct lump* l);
  80. /*! \brief remove all non-SHMEM lumps from the list */
  81. void del_nonshm_lump( struct lump** lump_list );
  82. /*! \brief remove the lump from the internal lists */
  83. int remove_lump(sip_msg_t *msg, struct lump *l);
  84. #endif