1 /* 2 * adding/removing headers or any other data chunk from a message 3 * 4 * Copyright (C) 2001-2003 FhG Fokus 5 * 6 * This file is part of Kamailio, a free SIP server. 7 * 8 * Kamailio 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 * Kamailio 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 this program; if not, write to the Free Software 20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 21 */ 22 23 /*! 24 * \file 25 * \brief Kamailio core :: Data_lumps 26 * \author jiri, andrei, janakj 27 * adding/removing headers or any other data chunk from a message 28 * \ingroup core 29 * Module: \ref core 30 */ 31 32 33 #ifndef data_lump_h 34 #define data_lump_h 35 36 #include "lump_struct.h" 37 #include "parser/msg_parser.h" 38 #include "parser/hf.h" 39 40 41 /* adds a header right after an anchor point if exists */ 42 struct lump* add_new_lump(struct lump** list, char* new_hdr, 43 int len, enum _hdr_types_t type); 44 45 /*! \brief adds a header to the end */ 46 struct lump* append_new_lump(struct lump** list, char* new_hdr, 47 int len, enum _hdr_types_t type); 48 /*! \brief inserts a header to the beginning */ 49 struct lump* insert_new_lump(struct lump** list, char* new_hdr, 50 int len, enum _hdr_types_t type); 51 struct lump* insert_new_lump_after(struct lump* after, 52 char* new_hdr, int len, enum _hdr_types_t type); 53 struct lump* insert_new_lump_before(struct lump* before, char* new_hdr, 54 int len,enum _hdr_types_t type); 55 /*! \brief substitutions (replace with ip address, port etc) */ 56 struct lump* insert_subst_lump_after(struct lump* after, enum lump_subst subst, 57 enum _hdr_types_t type); 58 struct lump* insert_subst_lump_before(struct lump* before,enum lump_subst subst, 59 enum _hdr_types_t type); 60 61 /*! \brief conditional lumps */ 62 struct lump* insert_cond_lump_after(struct lump* after, enum lump_conditions c, 63 enum _hdr_types_t type); 64 struct lump* insert_cond_lump_before(struct lump* after, enum lump_conditions c, 65 enum _hdr_types_t type); 66 67 /* set an anchor if there is no existing one at the given offset, 68 * otherwise return the existing anchor */ 69 struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type, 70 int *is_ref); 71 /*! \brief removes an already existing header */ 72 struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); 73 /*! \brief set an anchor */ 74 struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_t type); 75 76 77 78 /*! \brief duplicates a lump list shallowly in pkg-mem */ 79 struct lump* dup_lump_list( struct lump *l ); 80 /*! \brief frees a shallowly duplicated lump list */ 81 void free_duped_lump_list(struct lump* l); 82 83 84 /*! \brief remove all non-SHMEM lumps from the list */ 85 void del_nonshm_lump( struct lump** lump_list ); 86 87 /*! \brief remove the lump from the internal lists */ 88 int remove_lump(sip_msg_t *msg, struct lump *l); 89 90 int sr_hdr_add(sip_msg_t *msg, str *sname, str *sbody); 91 int sr_hdr_add_zz(sip_msg_t *msg, char *hname, char *hbody); 92 int sr_hdr_add_zs(sip_msg_t *msg, char *hname, str *sbody); 93 int sr_hdr_del_z(sip_msg_t *msg, char *hname); 94 hdr_field_t *sr_hdr_get_z(sip_msg_t *msg, char *hname); 95 96 #endif 97