hf.c

Go to the documentation of this file.
00001 /*
00002  * $Id: hf.c 4720 2008-08-23 10:56:15Z henningw $ 
00003  *
00004  * Copyright (C) 2001-2003 FhG Fokus
00005  *
00006  * This file is part of Kamailio, a free SIP server.
00007  *
00008  * Kamailio is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version
00012  *
00013  * Kamailio is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License 
00019  * along with this program; if not, write to the Free Software 
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  * History:
00023  * -------
00024  * 2006-02-17 Session-Expires, Min-SE (dhsueh@somanetworks.com)
00025  */
00026 
00027 /**
00028  * \file parser/hf.c
00029  * \brief Helper functions for SIP headers.
00030  * \ingroup parser
00031  *
00032  * Memory management and debugging functions for SIP headers.
00033  */
00034 
00035 
00036 #include "hf.h"
00037 #include "parse_via.h"
00038 #include "parse_to.h"
00039 #include "parse_cseq.h"
00040 #include "../dprint.h"
00041 #include "../mem/mem.h"
00042 #include "parse_def.h"
00043 #include "digest/digest.h" /* free_credentials */
00044 #include "parse_event.h"
00045 #include "parse_expires.h"
00046 #include "parse_rr.h"
00047 #include "contact/parse_contact.h"
00048 #include "parse_disposition.h"
00049 #include "../ut.h"
00050 #include "parse_supported.h"
00051 #include "parse_allow.h"
00052 #include "parse_sst.h"
00053 
00054 
00055 /*!
00056  * Frees a hdr_field structure,
00057  * \warning it frees only parsed (and not name.s, body.s)
00058  */
00059 void clean_hdr_field(struct hdr_field* hf)
00060 {
00061    if (hf->parsed){
00062       switch(hf->type){
00063       case HDR_VIA_T:
00064          free_via_list(hf->parsed);
00065          break;
00066 
00067       case HDR_TO_T:
00068          free_to(hf->parsed);
00069          break;
00070 
00071       case HDR_FROM_T:
00072          free_to(hf->parsed);
00073          break;
00074 
00075       case HDR_CSEQ_T:
00076          free_cseq(hf->parsed);
00077          break;
00078 
00079       case HDR_CALLID_T:
00080          break;
00081 
00082       case HDR_CONTACT_T:
00083          free_contact((contact_body_t**)(void*)(&(hf->parsed)));
00084          break;
00085 
00086       case HDR_MAXFORWARDS_T:
00087          break;
00088 
00089       case HDR_ROUTE_T:
00090          free_rr((rr_t**)(void*)(&hf->parsed));
00091          break;
00092 
00093       case HDR_RECORDROUTE_T:
00094          free_rr((rr_t**)(void*)(&hf->parsed));
00095          break;
00096 
00097       case HDR_PATH_T:
00098          free_rr((rr_t**)(void*)(&hf->parsed));
00099          break;
00100 
00101       case HDR_CONTENTTYPE_T:
00102          break;
00103 
00104       case HDR_CONTENTLENGTH_T:
00105          break;
00106 
00107       case HDR_AUTHORIZATION_T:
00108          free_credentials((auth_body_t**)(void*)(&(hf->parsed)));
00109          break;
00110 
00111       case HDR_EXPIRES_T:
00112          free_expires((exp_body_t**)(void*)(&(hf->parsed)));
00113          break;
00114 
00115       case HDR_PROXYAUTH_T:
00116          free_credentials((auth_body_t**)(void*)(&(hf->parsed)));
00117          break;
00118 
00119       case HDR_SUPPORTED_T:
00120          free_supported((struct supported_body**)(void*)(&(hf->parsed)));
00121          break;
00122 
00123       case HDR_PROXYREQUIRE_T:
00124          break;
00125 
00126       case HDR_UNSUPPORTED_T:
00127          break;
00128 
00129       case HDR_ALLOW_T:
00130          free_allow((struct allow_body**)(void*)(&(hf->parsed)));
00131          break;
00132 
00133       case HDR_EVENT_T:
00134          free_event((event_t**)(void*)(&(hf->parsed)));
00135          break;
00136 
00137       case HDR_ACCEPT_T:
00138          pkg_free(hf->parsed);
00139          break;
00140 
00141       case HDR_ACCEPTLANGUAGE_T:
00142          break;
00143          
00144       case HDR_ORGANIZATION_T:
00145          break;
00146          
00147       case HDR_PRIORITY_T:
00148          break;
00149 
00150       case HDR_SUBJECT_T:
00151          break;
00152 
00153       case HDR_USERAGENT_T:
00154          break;
00155 
00156       case HDR_ACCEPTDISPOSITION_T:
00157          break;
00158 
00159       case HDR_CONTENTDISPOSITION_T:
00160          free_disposition( ((struct disposition**)(void*)(&hf->parsed)) );
00161          break;
00162 
00163       case HDR_DIVERSION_T:
00164          free_to(hf->parsed);
00165          break;
00166 
00167       case HDR_RPID_T:
00168          free_to(hf->parsed);
00169          break;
00170 
00171       case HDR_REFER_TO_T:
00172          free_to(hf->parsed);
00173          break;
00174 
00175       case HDR_SESSION_EXPIRES_T:
00176          free_session_expires((struct session_expires*)hf->parsed );
00177          break;
00178 
00179       case HDR_MIN_SE_T:
00180          break;
00181 
00182       case HDR_PPI_T:
00183          free_to(hf->parsed);
00184          break;
00185 
00186       case HDR_PAI_T:
00187          free_to(hf->parsed);
00188          break;
00189 
00190       case HDR_PRIVACY_T:
00191          break;
00192 
00193       case HDR_RETRY_AFTER_T:
00194          break;
00195 
00196       default:
00197          LM_CRIT("unknown header type %d\n", hf->type);
00198          break;
00199       }
00200    }
00201 }
00202 
00203 
00204 /*!
00205  * Frees a hdr_field list,
00206  * \warning frees only ->parsed and ->next*/
00207 void free_hdr_field_lst(struct hdr_field* hf)
00208 {
00209    struct hdr_field* foo;
00210    
00211    while(hf) {
00212       foo=hf;
00213       hf=hf->next;
00214       clean_hdr_field(foo);
00215       pkg_free(foo);
00216    }
00217 }
00218 
00219 void dump_hdr_field( struct hdr_field* hf )
00220 {
00221    LM_ERR("type=%d, name=%.*s, body=%.*s, parsed=%p, next=%p\n",
00222       hf->type, hf->name.len, ZSW(hf->name.s),
00223       hf->body.len, ZSW(hf->body.s),
00224       hf->parsed, hf->next );
00225 }

Generated on Wed May 23 06:00:46 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6