Browse code

modules_k/*: moved k modules in directory modules/

Daniel-Constantin Mierla authored on 20/01/2013 11:57:52
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,237 +0,0 @@
1
-/* $Id$
2
- *
3
- * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4
- *
5
- * This file is part of Kamailio, a free SIP server.
6
- *
7
- * Kamailio is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License as published by
9
- * the Free Software Foundation; either version 2 of the License, or
10
- * (at your option) any later version
11
- *
12
- * Kamailio is distributed in the hope that it will be useful,
13
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
- * GNU General Public License for more details.
16
- *
17
- * You should have received a copy of the GNU General Public License 
18
- * along with this program; if not, write to the Free Software 
19
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
- */
21
-
22
-/*
23
- * =====================================================================================
24
- * 
25
- *        Filename:  encode_parameters.c
26
- * 
27
- *     Description:  Functions to encode/print parameters
28
- * 
29
- *         Version:  1.0
30
- *         Created:  25/01/06 17:46:04 CET
31
- *        Revision:  none
32
- *        Compiler:  gcc
33
- * 
34
- *          Author:  Elias Baixas (EB), elias@conillera.net
35
- *         Company:  VozTele.com
36
- * 
37
- * =====================================================================================
38
- */
39
-#define _GNU_SOURCE
40
-#include <stdio.h>
41
-#include "../../str.h"
42
-#include "../../parser/parse_param.h"
43
-#include "../../parser/parse_to.h"
44
-#include "../../parser/parse_via.h"
45
-#include "../../parser/parse_disposition.h"
46
-#include "encode_parameters.h"
47
-
48
-#define REL_PTR(a,b) (unsigned char)((b)-(a))
49
-
50
-/**
51
- * Returns how many bytes in *where have been used
52
- *
53
- * TODO this is little shitty, someone should unify all the param flavours 
54
- * to a sigle universal type of parameter (to_param,param,disposition_param)
55
- * the way is done here, at least, we dont have the parameter-hanling code spread all around.
56
- */
57
-int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body,char to)
58
-{
59
-   struct param *parametro,*params;
60
-   struct to_param *toparam,*toparams;
61
-   struct disposition_param *dparam,*dparams;
62
-   struct via_param *vparam,*vparams;
63
-   struct via_body *vbody;
64
-   struct to_body *tbody;
65
-   char *mylittlepointer,*paramstart; 
66
-   int i,j,paramlen;
67
-   i=0;
68
-   if(!pars)
69
-      return 0;
70
-   if(to=='t'){
71
-      toparams=(struct to_param*)pars;
72
-      tbody=(struct to_body*)_body;
73
-      for(toparam=toparams;toparam;toparam=toparam->next){
74
-	 where[i++]=(unsigned char)(toparam->name.s-hdrstart);
75
-	 if(toparam->value.s)
76
-	    mylittlepointer=toparam->value.s;
77
-	 else
78
-	    if(toparam->next)
79
-	       mylittlepointer=toparam->next->name.s;
80
-	    else
81
-	       mylittlepointer=toparam->name.s+toparam->name.len+1;
82
-         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
83
-            mylittlepointer--;/*if so, account for quotes*/
84
-	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
85
-      }
86
-      if((toparam=tbody->last_param)){
87
-	 if(toparam->value.s)
88
-	    mylittlepointer=toparam->value.s+toparam->value.len;
89
-	 else
90
-	    mylittlepointer=toparam->name.s+toparam->name.len;
91
-         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
92
-            mylittlepointer++;/*if so, account for quotes*/
93
-	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
94
-      }
95
-      return i;
96
-   }else if(to=='n'){
97
-      params=(struct param*)pars;
98
-      for(parametro=reverseParameters(params);parametro;parametro=parametro->next){
99
-	 where[i++]=(unsigned char)(parametro->name.s-hdrstart);
100
-	 if(parametro->body.s)
101
-	    mylittlepointer=parametro->body.s;
102
-	 else
103
-	    if(parametro->next)
104
-	       mylittlepointer=parametro->next->name.s;
105
-	    else
106
-	       mylittlepointer=parametro->name.s+parametro->name.len+1;
107
-         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
108
-            mylittlepointer--;/*if so, account for quotes*/
109
-	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
110
-      }
111
-      /*look for the last parameter*/
112
-      /*WARNING the ** parameters are in reversed order !!! */
113
-      /*TODO parameter encoding logic should be moved to a specific function...*/
114
-      for(parametro=params;parametro && parametro->next;parametro=parametro->next);
115
-      /*printf("PARAMETRO:%.*s\n",parametro->name.len,parametro->name.s);*/
116
-      if(parametro){
117
-	 if(parametro->body.s)
118
-	    mylittlepointer=parametro->body.s+parametro->body.len;
119
-	 else
120
-	    mylittlepointer=parametro->name.s+parametro->name.len;
121
-         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
122
-            mylittlepointer++;/*if so, account for quotes*/
123
-	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
124
-      }
125
-      return i;
126
-   }else if(to=='d'){
127
-      dparams=(struct disposition_param*)pars;
128
-      for(dparam=dparams;dparam;dparam=dparam->next){
129
-	 where[i++]=(unsigned char)(dparam->name.s-hdrstart);
130
-	 if(dparam->body.s)
131
-	    mylittlepointer=dparam->body.s;
132
-	 else
133
-	    if(dparam->next)
134
-	       mylittlepointer=dparam->next->name.s;
135
-	    else
136
-	       mylittlepointer=dparam->name.s+dparam->name.len+1;
137
-         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
138
-            mylittlepointer--;/*if so, account for quotes*/
139
-	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
140
-      }
141
-      /*WARNING the ** parameters are in reversed order !!! */
142
-      /*TODO parameter encoding logic should be moved to a specific function...*/
143
-      for(dparam=dparams;dparam && dparam->next;dparam=dparam->next);
144
-      if(dparam){
145
-	 if(dparam->body.s)
146
-	    mylittlepointer=dparam->body.s+dparam->body.len;
147
-	 else
148
-	    mylittlepointer=dparam->name.s+dparam->name.len;
149
-         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
150
-            mylittlepointer++;/*if so, account for quotes*/
151
-	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
152
-      }
153
-      return i;
154
-   }else if(to=='v'){
155
-      vparams=(struct via_param*)pars;
156
-      vbody=(struct via_body*)_body;
157
-      for(vparam=vparams;vparam;vparam=vparam->next){
158
-	 where[i++]=REL_PTR(hdrstart,vparam->name.s);
159
-	 if(vparam->value.s)
160
-	    mylittlepointer=vparam->value.s;
161
-	 else
162
-	    if(vparam->next)
163
-	       mylittlepointer=vparam->next->name.s;
164
-	    else
165
-	       mylittlepointer=vparam->name.s+vparam->name.len+1;
166
-         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
167
-            mylittlepointer--;/*if so, account for quotes*/
168
-	 where[i++]=REL_PTR(hdrstart,mylittlepointer);
169
-      }
170
-      if((vparam=vbody->last_param)){
171
-	 if(vparam->value.s)
172
-	    mylittlepointer=vparam->value.s+vparam->value.len;
173
-	 else
174
-	    mylittlepointer=vparam->name.s+vparam->name.len;
175
-         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
176
-            mylittlepointer++;/*if so, account for quotes*/
177
-	 where[i++]=REL_PTR(hdrstart,mylittlepointer+1);
178
-      }
179
-      return i;
180
-   }else if(to=='u'){
181
-      paramlen=*((int*)_body);
182
-      paramstart=(char *)pars;
183
-      j=i=0;
184
-      if(paramstart==0 || paramlen==0)
185
-	 return 0;
186
-      /*the first parameter start index, I suppose paramstart points to the first
187
-       letter of the first parameter: sip:elias@voztele.com;param1=true;param2=false
188
-                                     paramstart points to __^                      
189
-       each parameter is codified with its {param_name_start_idx,[param_value_start_idx|next_param_start_idx]} */
190
-      where[j++]=paramstart-hdrstart;
191
-      while(i<paramlen){
192
-	 i++;
193
-	 if(paramstart[i]==';'){/*no '=' found !*/
194
-	    where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
195
-	    where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
196
-	 }
197
-	 if(paramstart[i]=='='){/* '=' found, look for the next ';' and let 'i' pointing to it*/
198
-	    where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
199
-	    for(;i<paramlen&&paramstart[i]!=';';i++);
200
-	    if(paramstart[i]==';')
201
-	       where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
202
-	 }
203
-      }
204
-      where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
205
-      if(j%2 == 0)/*this is because maybe the LAST parameter doesn't have an '='*/
206
-	 where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
207
-      return j;
208
-   }
209
-   return 0;
210
-}
211
-
212
-/**reverses a param_t linked-list
213
- */
214
-param_t *reverseParameters(param_t *p)
215
-{
216
-   param_t *previous=NULL,*tmp;
217
-   while (p != NULL)
218
-   {
219
-      tmp = p->next;/* store the next */
220
-      p->next = previous;/* next = previous */
221
-      previous = p;/* previous = current */
222
-      p = tmp;/* current = "the next" */
223
-   }
224
-   return previous;
225
-}
226
-
227
-/*prints the encoded parameters
228
- */
229
-int print_encoded_parameters(FILE *fd,unsigned char *payload,char *hdr,int paylen,char *prefix)
230
-{
231
-   int i;
232
-   for(i=0;i<paylen-1;i+=2){
233
-      fprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
234
-      fprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
235
-   }
236
-   return 0;
237
-}
Browse code

seas: fixed header-encoding for longest headers

-refactorings for newer sip-router TM apis
-some headers longer than 255 bytes were wrongly encoded

Elias Baixas authored on 04/10/2010 10:39:46
Showing 1 changed files
... ...
@@ -79,6 +79,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
79 79
 	       mylittlepointer=toparam->next->name.s;
80 80
 	    else
81 81
 	       mylittlepointer=toparam->name.s+toparam->name.len+1;
82
+         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
83
+            mylittlepointer--;/*if so, account for quotes*/
82 84
 	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
83 85
       }
84 86
       if((toparam=tbody->last_param)){
... ...
@@ -86,6 +88,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
86 88
 	    mylittlepointer=toparam->value.s+toparam->value.len;
87 89
 	 else
88 90
 	    mylittlepointer=toparam->name.s+toparam->name.len;
91
+         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
92
+            mylittlepointer++;/*if so, account for quotes*/
89 93
 	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
90 94
       }
91 95
       return i;
... ...
@@ -100,6 +104,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
100 104
 	       mylittlepointer=parametro->next->name.s;
101 105
 	    else
102 106
 	       mylittlepointer=parametro->name.s+parametro->name.len+1;
107
+         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
108
+            mylittlepointer--;/*if so, account for quotes*/
103 109
 	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
104 110
       }
105 111
       /*look for the last parameter*/
... ...
@@ -112,6 +118,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
112 118
 	    mylittlepointer=parametro->body.s+parametro->body.len;
113 119
 	 else
114 120
 	    mylittlepointer=parametro->name.s+parametro->name.len;
121
+         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
122
+            mylittlepointer++;/*if so, account for quotes*/
115 123
 	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
116 124
       }
117 125
       return i;
... ...
@@ -126,6 +134,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
126 134
 	       mylittlepointer=dparam->next->name.s;
127 135
 	    else
128 136
 	       mylittlepointer=dparam->name.s+dparam->name.len+1;
137
+         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
138
+            mylittlepointer--;/*if so, account for quotes*/
129 139
 	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
130 140
       }
131 141
       /*WARNING the ** parameters are in reversed order !!! */
... ...
@@ -136,6 +146,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
136 146
 	    mylittlepointer=dparam->body.s+dparam->body.len;
137 147
 	 else
138 148
 	    mylittlepointer=dparam->name.s+dparam->name.len;
149
+         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
150
+            mylittlepointer++;/*if so, account for quotes*/
139 151
 	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
140 152
       }
141 153
       return i;
... ...
@@ -151,6 +163,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
151 163
 	       mylittlepointer=vparam->next->name.s;
152 164
 	    else
153 165
 	       mylittlepointer=vparam->name.s+vparam->name.len+1;
166
+         if(mylittlepointer[-1]=='\"')/*check if the parameter was quoted*/
167
+            mylittlepointer--;/*if so, account for quotes*/
154 168
 	 where[i++]=REL_PTR(hdrstart,mylittlepointer);
155 169
       }
156 170
       if((vparam=vbody->last_param)){
... ...
@@ -158,6 +172,8 @@ int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body
158 172
 	    mylittlepointer=vparam->value.s+vparam->value.len;
159 173
 	 else
160 174
 	    mylittlepointer=vparam->name.s+vparam->name.len;
175
+         if(mylittlepointer[0]=='\"')/*check if the parameter was quoted*/
176
+            mylittlepointer++;/*if so, account for quotes*/
161 177
 	 where[i++]=REL_PTR(hdrstart,mylittlepointer+1);
162 178
       }
163 179
       return i;
Browse code

Replaced dprintf for fprintf (dprintf is somewhat gnu-specific and does not compile on Mac). even though it was just used for debugging (not on the module) it prevented compilation

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@5192 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 13/11/2008 10:18:48
Showing 1 changed files
... ...
@@ -210,12 +210,12 @@ param_t *reverseParameters(param_t *p)
210 210
 
211 211
 /*prints the encoded parameters
212 212
  */
213
-int print_encoded_parameters(int fd,unsigned char *payload,char *hdr,int paylen,char *prefix)
213
+int print_encoded_parameters(FILE *fd,unsigned char *payload,char *hdr,int paylen,char *prefix)
214 214
 {
215 215
    int i;
216 216
    for(i=0;i<paylen-1;i+=2){
217
-      dprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
218
-      dprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
217
+      fprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
218
+      fprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
219 219
    }
220 220
    return 0;
221 221
 }
Browse code

- change name in copyright headers

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@4518 689a6050-402a-0410-94f2-e92a70836424

Henning Westerholt authored on 28/07/2008 15:39:28
Showing 1 changed files
... ...
@@ -2,14 +2,14 @@
2 2
  *
3 3
  * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4 4
  *
5
- * This file is part of openser, a free SIP server.
5
+ * This file is part of Kamailio, a free SIP server.
6 6
  *
7
- * openser is free software; you can redistribute it and/or modify
7
+ * Kamailio is free software; you can redistribute it and/or modify
8 8
  * it under the terms of the GNU General Public License as published by
9 9
  * the Free Software Foundation; either version 2 of the License, or
10 10
  * (at your option) any later version
11 11
  *
12
- * openser is distributed in the hope that it will be useful,
12
+ * Kamailio is distributed in the hope that it will be useful,
13 13
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 14
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 15
  * GNU General Public License for more details.
Browse code

- added license and copyright

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1819 689a6050-402a-0410-94f2-e92a70836424

Daniel-Constantin Mierla authored on 11/03/2007 19:20:59
Showing 1 changed files
... ...
@@ -1,4 +1,24 @@
1
-/* $Id$ */
1
+/* $Id$
2
+ *
3
+ * Copyright (C) 2006-2007 VozTelecom Sistemas S.L
4
+ *
5
+ * This file is part of openser, a free SIP server.
6
+ *
7
+ * openser is free software; you can redistribute it and/or modify
8
+ * it under the terms of the GNU General Public License as published by
9
+ * the Free Software Foundation; either version 2 of the License, or
10
+ * (at your option) any later version
11
+ *
12
+ * openser is distributed in the hope that it will be useful,
13
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
+ * GNU General Public License for more details.
16
+ *
17
+ * You should have received a copy of the GNU General Public License 
18
+ * along with this program; if not, write to the Free Software 
19
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
+ */
21
+
2 22
 /*
3 23
  * =====================================================================================
4 24
  * 
Browse code

Added code files for SEAS module

git-svn-id: https://openser.svn.sourceforge.net/svnroot/openser/trunk@1448 689a6050-402a-0410-94f2-e92a70836424

Elias Baixas authored on 22/12/2006 17:07:44
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,201 @@
1
+/* $Id$ */
2
+/*
3
+ * =====================================================================================
4
+ * 
5
+ *        Filename:  encode_parameters.c
6
+ * 
7
+ *     Description:  Functions to encode/print parameters
8
+ * 
9
+ *         Version:  1.0
10
+ *         Created:  25/01/06 17:46:04 CET
11
+ *        Revision:  none
12
+ *        Compiler:  gcc
13
+ * 
14
+ *          Author:  Elias Baixas (EB), elias@conillera.net
15
+ *         Company:  VozTele.com
16
+ * 
17
+ * =====================================================================================
18
+ */
19
+#define _GNU_SOURCE
20
+#include <stdio.h>
21
+#include "../../str.h"
22
+#include "../../parser/parse_param.h"
23
+#include "../../parser/parse_to.h"
24
+#include "../../parser/parse_via.h"
25
+#include "../../parser/parse_disposition.h"
26
+#include "encode_parameters.h"
27
+
28
+#define REL_PTR(a,b) (unsigned char)((b)-(a))
29
+
30
+/**
31
+ * Returns how many bytes in *where have been used
32
+ *
33
+ * TODO this is little shitty, someone should unify all the param flavours 
34
+ * to a sigle universal type of parameter (to_param,param,disposition_param)
35
+ * the way is done here, at least, we dont have the parameter-hanling code spread all around.
36
+ */
37
+int encode_parameters(unsigned char *where,void *pars,char *hdrstart,void *_body,char to)
38
+{
39
+   struct param *parametro,*params;
40
+   struct to_param *toparam,*toparams;
41
+   struct disposition_param *dparam,*dparams;
42
+   struct via_param *vparam,*vparams;
43
+   struct via_body *vbody;
44
+   struct to_body *tbody;
45
+   char *mylittlepointer,*paramstart; 
46
+   int i,j,paramlen;
47
+   i=0;
48
+   if(!pars)
49
+      return 0;
50
+   if(to=='t'){
51
+      toparams=(struct to_param*)pars;
52
+      tbody=(struct to_body*)_body;
53
+      for(toparam=toparams;toparam;toparam=toparam->next){
54
+	 where[i++]=(unsigned char)(toparam->name.s-hdrstart);
55
+	 if(toparam->value.s)
56
+	    mylittlepointer=toparam->value.s;
57
+	 else
58
+	    if(toparam->next)
59
+	       mylittlepointer=toparam->next->name.s;
60
+	    else
61
+	       mylittlepointer=toparam->name.s+toparam->name.len+1;
62
+	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
63
+      }
64
+      if((toparam=tbody->last_param)){
65
+	 if(toparam->value.s)
66
+	    mylittlepointer=toparam->value.s+toparam->value.len;
67
+	 else
68
+	    mylittlepointer=toparam->name.s+toparam->name.len;
69
+	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
70
+      }
71
+      return i;
72
+   }else if(to=='n'){
73
+      params=(struct param*)pars;
74
+      for(parametro=reverseParameters(params);parametro;parametro=parametro->next){
75
+	 where[i++]=(unsigned char)(parametro->name.s-hdrstart);
76
+	 if(parametro->body.s)
77
+	    mylittlepointer=parametro->body.s;
78
+	 else
79
+	    if(parametro->next)
80
+	       mylittlepointer=parametro->next->name.s;
81
+	    else
82
+	       mylittlepointer=parametro->name.s+parametro->name.len+1;
83
+	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
84
+      }
85
+      /*look for the last parameter*/
86
+      /*WARNING the ** parameters are in reversed order !!! */
87
+      /*TODO parameter encoding logic should be moved to a specific function...*/
88
+      for(parametro=params;parametro && parametro->next;parametro=parametro->next);
89
+      /*printf("PARAMETRO:%.*s\n",parametro->name.len,parametro->name.s);*/
90
+      if(parametro){
91
+	 if(parametro->body.s)
92
+	    mylittlepointer=parametro->body.s+parametro->body.len;
93
+	 else
94
+	    mylittlepointer=parametro->name.s+parametro->name.len;
95
+	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
96
+      }
97
+      return i;
98
+   }else if(to=='d'){
99
+      dparams=(struct disposition_param*)pars;
100
+      for(dparam=dparams;dparam;dparam=dparam->next){
101
+	 where[i++]=(unsigned char)(dparam->name.s-hdrstart);
102
+	 if(dparam->body.s)
103
+	    mylittlepointer=dparam->body.s;
104
+	 else
105
+	    if(dparam->next)
106
+	       mylittlepointer=dparam->next->name.s;
107
+	    else
108
+	       mylittlepointer=dparam->name.s+dparam->name.len+1;
109
+	 where[i++]=(unsigned char)(mylittlepointer-hdrstart);
110
+      }
111
+      /*WARNING the ** parameters are in reversed order !!! */
112
+      /*TODO parameter encoding logic should be moved to a specific function...*/
113
+      for(dparam=dparams;dparam && dparam->next;dparam=dparam->next);
114
+      if(dparam){
115
+	 if(dparam->body.s)
116
+	    mylittlepointer=dparam->body.s+dparam->body.len;
117
+	 else
118
+	    mylittlepointer=dparam->name.s+dparam->name.len;
119
+	 where[i++]=(unsigned char)(mylittlepointer-hdrstart+1);
120
+      }
121
+      return i;
122
+   }else if(to=='v'){
123
+      vparams=(struct via_param*)pars;
124
+      vbody=(struct via_body*)_body;
125
+      for(vparam=vparams;vparam;vparam=vparam->next){
126
+	 where[i++]=REL_PTR(hdrstart,vparam->name.s);
127
+	 if(vparam->value.s)
128
+	    mylittlepointer=vparam->value.s;
129
+	 else
130
+	    if(vparam->next)
131
+	       mylittlepointer=vparam->next->name.s;
132
+	    else
133
+	       mylittlepointer=vparam->name.s+vparam->name.len+1;
134
+	 where[i++]=REL_PTR(hdrstart,mylittlepointer);
135
+      }
136
+      if((vparam=vbody->last_param)){
137
+	 if(vparam->value.s)
138
+	    mylittlepointer=vparam->value.s+vparam->value.len;
139
+	 else
140
+	    mylittlepointer=vparam->name.s+vparam->name.len;
141
+	 where[i++]=REL_PTR(hdrstart,mylittlepointer+1);
142
+      }
143
+      return i;
144
+   }else if(to=='u'){
145
+      paramlen=*((int*)_body);
146
+      paramstart=(char *)pars;
147
+      j=i=0;
148
+      if(paramstart==0 || paramlen==0)
149
+	 return 0;
150
+      /*the first parameter start index, I suppose paramstart points to the first
151
+       letter of the first parameter: sip:elias@voztele.com;param1=true;param2=false
152
+                                     paramstart points to __^                      
153
+       each parameter is codified with its {param_name_start_idx,[param_value_start_idx|next_param_start_idx]} */
154
+      where[j++]=paramstart-hdrstart;
155
+      while(i<paramlen){
156
+	 i++;
157
+	 if(paramstart[i]==';'){/*no '=' found !*/
158
+	    where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
159
+	    where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
160
+	 }
161
+	 if(paramstart[i]=='='){/* '=' found, look for the next ';' and let 'i' pointing to it*/
162
+	    where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
163
+	    for(;i<paramlen&&paramstart[i]!=';';i++);
164
+	    if(paramstart[i]==';')
165
+	       where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
166
+	 }
167
+      }
168
+      where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
169
+      if(j%2 == 0)/*this is because maybe the LAST parameter doesn't have an '='*/
170
+	 where[j++]=(unsigned char)(&paramstart[i+1]-hdrstart);
171
+      return j;
172
+   }
173
+   return 0;
174
+}
175
+
176
+/**reverses a param_t linked-list
177
+ */
178
+param_t *reverseParameters(param_t *p)
179
+{
180
+   param_t *previous=NULL,*tmp;
181
+   while (p != NULL)
182
+   {
183
+      tmp = p->next;/* store the next */
184
+      p->next = previous;/* next = previous */
185
+      previous = p;/* previous = current */
186
+      p = tmp;/* current = "the next" */
187
+   }
188
+   return previous;
189
+}
190
+
191
+/*prints the encoded parameters
192
+ */
193
+int print_encoded_parameters(int fd,unsigned char *payload,char *hdr,int paylen,char *prefix)
194
+{
195
+   int i;
196
+   for(i=0;i<paylen-1;i+=2){
197
+      dprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
198
+      dprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
199
+   }
200
+   return 0;
201
+}