OSDN Git Service

Add MS7619SE
[uclinux-h8/uClinux-dist.git] / user / ser / parser / hf.c
1 /* 
2  * $Id: hf.c,v 1.21 2004/12/03 17:11:36 jamey Exp $ 
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  *    info@iptel.org
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  * History:
28  * -------
29  * 2003-03-26 Frees also hdr->parsed for Route & Record-Route (janakj)
30  * 2003-04-26 ZSW (jiri)
31  * 2003-08-05 free the parsed part of Accept header (bogdan)
32  */
33
34
35 #include "hf.h"
36 #include "parse_via.h"
37 #include "parse_to.h"
38 #include "parse_cseq.h"
39 #include "../dprint.h"
40 #include "../mem/mem.h"
41 #include "parse_def.h"
42 #include "digest/digest.h" /* free_credentials */
43 #include "parse_event.h"
44 #include "parse_expires.h"
45 #include "parse_rr.h"
46 #include "contact/parse_contact.h"
47 #include "parse_disposition.h"
48 #include "../ut.h"
49
50
51 /* 
52  * Frees a hdr_field structure,
53  * WARNING: it frees only parsed (and not name.s, body.s)
54  */
55 void clean_hdr_field(struct hdr_field* hf)
56 {
57         if (hf->parsed){
58                 switch(hf->type){
59                 case HDR_VIA:
60                         free_via_list(hf->parsed);
61                         break;
62
63                 case HDR_TO:
64                         free_to(hf->parsed);
65                         break;
66
67                 case HDR_FROM:
68                         free_to(hf->parsed);
69                         break;
70
71                 case HDR_CSEQ:
72                         free_cseq(hf->parsed);
73                         break;
74
75                 case HDR_CALLID:
76                         break;
77
78                 case HDR_CONTACT:
79                         free_contact((contact_body_t**)(&(hf->parsed)));
80                         break;
81
82                 case HDR_MAXFORWARDS:
83                         break;
84
85                 case HDR_ROUTE:
86                         free_rr((rr_t**)(&hf->parsed));
87                         break;
88
89                 case HDR_RECORDROUTE:
90                         free_rr((rr_t**)(&hf->parsed));
91                         break;
92
93                 case HDR_CONTENTTYPE:
94                         break;
95
96                 case HDR_CONTENTLENGTH:
97                         break;
98
99                 case HDR_AUTHORIZATION:
100                         free_credentials((auth_body_t**)(&(hf->parsed)));
101                         break;
102
103                 case HDR_EXPIRES:
104                         free_expires((exp_body_t**)(&(hf->parsed)));
105                         break;
106
107                 case HDR_PROXYAUTH:
108                         free_credentials((auth_body_t**)(&(hf->parsed)));
109                         break;
110
111                 case HDR_SUPPORTED:
112                         break;
113
114                 case HDR_PROXYREQUIRE:
115                         break;
116
117                 case HDR_UNSUPPORTED:
118                         break;
119
120                 case HDR_ALLOW:
121                         break;
122
123                 case HDR_EVENT:
124                         free_event((event_t**)(&(hf->parsed)));
125                         break;
126
127                 case HDR_ACCEPT:
128                         pkg_free(hf->parsed);
129                         break;
130
131                 case HDR_ACCEPTLANGUAGE:
132                         break;
133                         
134                 case HDR_ORGANIZATION:
135                         break;
136                         
137                 case HDR_PRIORITY:
138                         break;
139
140                 case HDR_SUBJECT:
141                         break;
142
143                 case HDR_USERAGENT:
144                         break;
145
146                 case HDR_ACCEPTDISPOSITION:
147                         break;
148
149                 case HDR_CONTENTDISPOSITION:
150                         free_disposition( ((struct disposition**)(&hf->parsed)) );
151                         break;
152
153                 case HDR_DIVERSION:
154                         free_to(hf->parsed);
155                         break;
156
157                 case HDR_RPID:
158                         free_to(hf->parsed);
159                         break;
160
161                 default:
162                         LOG(L_CRIT, "BUG: clean_hdr_field: unknown header type %d\n",
163                             hf->type);
164                         break;
165                 }
166         }
167 }
168
169
170 /* 
171  * Frees a hdr_field list,
172  * WARNING: frees only ->parsed and ->next*/
173 void free_hdr_field_lst(struct hdr_field* hf)
174 {
175         struct hdr_field* foo;
176         
177         while(hf) {
178                 foo=hf;
179                 hf=hf->next;
180                 clean_hdr_field(foo);
181                 pkg_free(foo);
182         }
183 }
184
185 void dump_hdr_field( struct hdr_field* hf )
186 {
187         LOG(L_ERR, "DEBUG: dump_hdr_field: type=%d, name=%.*s, "
188                 "body=%.*s, parsed=%p, next=%p\n",
189                 hf->type, hf->name.len, ZSW(hf->name.s),
190                 hf->body.len, ZSW(hf->body.s),
191                 hf->parsed, hf->next );
192 }