"Fossies" - the Fresh Open Source Software Archive

Member "opensips-3.0.1/modules/tm/sip_msg.h" (29 May 2019, 3244 Bytes) of package /linux/misc/opensips-3.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "sip_msg.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 2.4.5_vs_3.0.0.

    1 /*
    2  * Copyright (C) 2001-2003 FhG Fokus
    3  *
    4  * This file is part of opensips, a free SIP server.
    5  *
    6  * opensips is free software; you can redistribute it and/or modify
    7  * it under the terms of the GNU General Public License as published by
    8  * the Free Software Foundation; either version 2 of the License, or
    9  * (at your option) any later version
   10  *
   11  * opensips is distributed in the hope that it will be useful,
   12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14  * GNU General Public License for more details.
   15  *
   16  * You should have received a copy of the GNU General Public License
   17  * along with this program; if not, write to the Free Software
   18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
   19  */
   20 
   21 
   22 
   23 #ifndef _SIP_MSG_H
   24 #define _SIP_MSG_H
   25 
   26 #include "../../parser/msg_parser.h"
   27 #include "../../mem/shm_mem.h"
   28 
   29 #define free_cloned_msg_unsafe( _msg ) \
   30     do { \
   31         if ((_msg)->msg_flags & FL_SHM_UPDATABLE) { \
   32             if ((_msg)->new_uri.s) \
   33                 shm_free_bulk((_msg)->new_uri.s);\
   34             if ((_msg)->dst_uri.s) \
   35                 shm_free_bulk((_msg)->dst_uri.s);\
   36             if ((_msg)->path_vec.s) \
   37                 shm_free_bulk((_msg)->path_vec.s);\
   38             if ((_msg)->set_global_address.s) \
   39                 shm_free_bulk((_msg)->set_global_address.s);\
   40             if ((_msg)->set_global_port.s) \
   41                 shm_free_bulk((_msg)->set_global_port.s);\
   42             if ((_msg)->add_rm) \
   43                 shm_free_bulk((_msg)->add_rm);\
   44             if ((_msg)->body_lumps) \
   45                 shm_free_bulk((_msg)->body_lumps);\
   46             if ((_msg)->reply_lump) \
   47                 shm_free_bulk((_msg)->reply_lump);\
   48         }\
   49         if ((_msg)->body) { \
   50             /* ungly hack to free the body parts which do not support
   51              * unsafe-free */ \
   52             shm_unlock(); \
   53             free_sip_body((_msg)->body);\
   54             shm_lock(); \
   55         }\
   56         shm_free_bulk((_msg));\
   57     }while(0)
   58 
   59 
   60 #define free_cloned_msg( _msg ) \
   61     do { \
   62         if ((_msg)->msg_flags & FL_SHM_UPDATABLE) { \
   63             if ((_msg)->new_uri.s) \
   64                 shm_free((_msg)->new_uri.s);\
   65             if ((_msg)->dst_uri.s) \
   66                 shm_free((_msg)->dst_uri.s);\
   67             if ((_msg)->path_vec.s) \
   68                 shm_free((_msg)->path_vec.s);\
   69             if ((_msg)->set_global_address.s) \
   70                 shm_free((_msg)->set_global_address.s);\
   71             if ((_msg)->set_global_port.s) \
   72                 shm_free((_msg)->set_global_port.s);\
   73             if ((_msg)->add_rm) \
   74                 shm_free((_msg)->add_rm);\
   75             if ((_msg)->body_lumps) \
   76                 shm_free((_msg)->body_lumps);\
   77             if ((_msg)->reply_lump) \
   78                 shm_free((_msg)->reply_lump);\
   79         }\
   80         free_sip_body((_msg)->body);\
   81         shm_free((_msg));\
   82     }while(0)
   83 
   84 
   85 struct sip_msg*  sip_msg_cloner( struct sip_msg *org_msg, int *sip_msg_len,
   86         int updatable );
   87 
   88 
   89 static inline void clean_msg_clone(struct sip_msg *msg,void *min, void *max)
   90 {
   91     struct hdr_field *hdr;
   92 
   93     /* free header's parsed structures that were added in pkg mem */
   94     for( hdr=msg->headers ; hdr ; hdr=hdr->next ) {
   95         if ( hdr->parsed && hdr_allocs_parse(hdr) &&
   96         (hdr->parsed<min || hdr->parsed>=max)) {
   97             /* header parsed filed doesn't point inside uas.request memory
   98              * chunk -> it was added by failure funcs.-> free it as pkg */
   99             LM_DBG("removing hdr->parsed %d\n", hdr->type);
  100             clean_hdr_field(hdr);
  101             hdr->parsed = 0;
  102         }
  103     }
  104 }
  105 
  106 
  107 int update_cloned_msg_from_msg(struct sip_msg *c_msg, struct sip_msg *msg);
  108 
  109 
  110 #endif