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,249 +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_via.c
26
- * 
27
- *     Description:  functions to encode VIA headers
28
- * 
29
- *         Version:  1.0
30
- *         Created:  21/11/05 02:30:50 CET
31
- *        Revision:  none
32
- *        Compiler:  gcc
33
- * 
34
- *          Author:  Elias Baixas (EB), elias@conillera.net
35
- *         Company:  VozTele.com
36
- * 
37
- * =====================================================================================
38
- */
39
-
40
-#define _GNU_SOURCE
41
-#include <stdio.h>
42
-
43
-#include "../../parser/parse_via.h"
44
-#include "../../parser/parse_uri.h"
45
-#include "encode_via.h"
46
-#include "encode_uri.h"
47
-#include "xaddress.h"
48
-#include "encode_header.h"
49
-#include "encode_parameters.h"
50
-
51
-#define HAS_PARAMS_F		0x01
52
-#define HAS_BRANCH_F		0x02
53
-#define HAS_RECEIVED_F		0x04
54
-#define HAS_RPORT_F		0x08
55
-#define HAS_I_F			0x10
56
-#define HAS_ALIAS_F		0x20
57
-#define HAS_PORT_F		0x40
58
-
59
-#define REL_PTR(a,b) (unsigned char)((b)-(a))
60
-
61
-/*
62
- * encodes a (maybe aggregated) via header.
63
- * encoding is:
64
- * 1: flags
65
- * 1: number of vias present
66
- * N: fore each via present, the length of the via
67
- * N*M: the via structures concatenated
68
- */
69
-int encode_via_body(char *hdr,int hdrlen,struct via_body *via_parsed,unsigned char *where)
70
-{
71
-   int i=0,k,via_offset;
72
-   unsigned char flags,tmp[500];
73
-   struct via_body *myvia;
74
-
75
-   flags=0;
76
-   if(via_parsed)
77
-      for(via_offset=0,i=0,myvia=via_parsed;myvia;myvia=myvia->next,i++){
78
-	 if((k=encode_via(hdr,hdrlen,myvia,&tmp[via_offset]))<0){
79
-	    LM_ERR("failed to parse via number %d\n",i);
80
-	    return -1;
81
-	 }
82
-	 where[2+i]=(unsigned char)k;
83
-	 via_offset+=k;
84
-      }
85
-   else
86
-      return -1;
87
-   where[1]=(unsigned char)i;/*how may vias there are*/
88
-   memcpy(&where[2+i],tmp,via_offset);
89
-   return 2+i+via_offset;
90
-}
91
-
92
-/* Encoder for vias.
93
- * Returns the length of the encoded structure in bytes
94
- * FORMAT (byte meanings):
95
- * 1: flags
96
- *
97
- */
98
-int encode_via(char *hdrstart,int hdrlen,struct via_body *body,unsigned char *where)
99
-{
100
-   int i;/* 1*flags + 1*hostport_len*/
101
-   unsigned char flags=0;
102
-
103
-   where[1]=REL_PTR(hdrstart,body->name.s);
104
-   where[2]=REL_PTR(hdrstart,body->version.s);
105
-   where[3]=REL_PTR(hdrstart,body->transport.s);
106
-   where[4]=REL_PTR(hdrstart,body->transport.s+body->transport.len+1);
107
-   where[5]=REL_PTR(hdrstart,body->host.s);
108
-   if(body->port_str.s && body->port_str.len){
109
-      flags|=HAS_PORT_F;
110
-      where[6]=REL_PTR(hdrstart,body->port_str.s);
111
-      where[7]=REL_PTR(hdrstart,body->port_str.s+body->port_str.len+1);
112
-      i=8;
113
-   }else{
114
-      where[6]=REL_PTR(hdrstart,body->host.s+body->host.len+1);
115
-      i=7;
116
-   }
117
-   if(body->params.s && body->params.len){
118
-      flags|=HAS_PARAMS_F;
119
-      where[i++]=REL_PTR(hdrstart,body->params.s);
120
-      where[i++]=(unsigned char)body->params.len;
121
-   }
122
-   if(body->branch && body->branch->value.s && body->branch->value.len){
123
-      flags|=HAS_BRANCH_F;
124
-      where[i++]=REL_PTR(hdrstart,body->branch->value.s);
125
-      where[i++]=(unsigned char)body->branch->value.len;
126
-   }
127
-   if(body->received && body->received->value.s && body->received->value.len){
128
-      flags|=HAS_RECEIVED_F;
129
-      where[i++]=REL_PTR(hdrstart,body->received->value.s);
130
-      where[i++]=(unsigned char)body->received->value.len;
131
-   }
132
-   if(body->rport && body->rport->value.s && body->rport->value.len){
133
-      flags|=HAS_RPORT_F;
134
-      where[i++]=REL_PTR(hdrstart,body->rport->value.s);
135
-      where[i++]=(unsigned char)body->rport->value.len;
136
-   }
137
-   if(body->i && body->i->value.s && body->i->value.len){
138
-      flags|=HAS_I_F;
139
-      where[i++]=REL_PTR(hdrstart,body->i->value.s);
140
-      where[i++]=(unsigned char)body->i->value.len;
141
-   }
142
-   if(body->alias && body->alias->value.s && body->alias->value.len){
143
-      flags|=HAS_ALIAS_F;
144
-      where[i++]=REL_PTR(hdrstart,body->alias->value.s);
145
-      where[i++]=(unsigned char)body->alias->value.len;
146
-   }
147
-
148
-   where[0]=flags;
149
-   i+=encode_parameters(&where[i],body->param_lst,hdrstart,(void *)body,'v');
150
-   return i;
151
-}
152
-
153
-int print_encoded_via_body(FILE *fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
154
-{
155
-   unsigned char flags, numvias;
156
-   int i,offset;
157
-
158
-   flags=payload[0];
159
-   fprintf(fd,"%s",prefix);
160
-   for(i=0;i<paylen;i++)
161
-      fprintf(fd,"%s%d%s",i==0?"ENCODED VIA BODY:[":":",payload[i],i==paylen-1?"]\n":"");
162
-   numvias=payload[1];
163
-   fprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
164
-   if(numvias==0){
165
-      LM_ERR("no vias present?\n");
166
-      return -1;
167
-   }
168
-   for(i=0,offset=2+numvias;i<numvias;i++){
169
-      print_encoded_via(fd,hdr,hdrlen,&payload[offset],payload[2+i],strcat(prefix,"  "));
170
-      offset+=payload[2+i];
171
-      prefix[strlen(prefix)-2]=0;
172
-   }
173
-   return 1;
174
-}
175
-
176
-int print_encoded_via(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
177
-{
178
-   int i=2;/* flags + urilength */
179
-   unsigned char flags=0;
180
-
181
-   flags=payload[0];
182
-   fprintf(fd,"%s",prefix);
183
-   for(i=0;i<paylen;i++)
184
-      fprintf(fd,"%s%d%s",i==0?"ENCODED VIA=[":":",payload[i],i==paylen-1?"]\n":"");
185
-
186
-   fprintf(fd,"%sPROT=[%.*s]\n",prefix,payload[2]-payload[1]-1,&hdr[payload[1]]);
187
-   fprintf(fd,"%sVER=[%.*s]\n",prefix,payload[3]-payload[2]-1,&hdr[payload[2]]);
188
-   fprintf(fd,"%sTRANSP=[%.*s]\n",prefix,payload[4]-payload[3]-1,&hdr[payload[3]]);
189
-
190
-   fprintf(fd,"%sHOST=[%.*s]\n",prefix,payload[6]-payload[5]-1,&hdr[payload[5]]);
191
-   if(flags & HAS_PORT_F){
192
-      fprintf(fd,"%sPORT=[%.*s]\n",prefix,payload[7]-payload[6]-1,&hdr[payload[6]]);
193
-      i=8;
194
-   }else
195
-      i=7;
196
-   if(flags & HAS_PARAMS_F){
197
-      fprintf(fd,"%sPARAMS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
198
-      i+=2;
199
-   }
200
-   if(flags & HAS_BRANCH_F){
201
-      fprintf(fd,"%sBRANCH=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
202
-      i+=2;
203
-   }
204
-   if(flags & HAS_RECEIVED_F){
205
-      fprintf(fd,"%sRECEIVED=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
206
-      i+=2;
207
-   }
208
-   if(flags & HAS_RPORT_F){
209
-      fprintf(fd,"%sRPORT=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
210
-      i+=2;
211
-   }
212
-   if(flags & HAS_I_F){
213
-      fprintf(fd,"%sI=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
214
-      i+=2;
215
-   }
216
-   if(flags & HAS_ALIAS_F){
217
-      fprintf(fd,"%sALIAS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
218
-      i+=2;
219
-   }
220
-   for(;i<paylen-1;i+=2){
221
-      fprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
222
-      fprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
223
-   }
224
-   return 0;
225
-}
226
-
227
-int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,FILE* fd,char segregationLevel)
228
-{
229
-   unsigned char flags, numvias;
230
-   int i,offset;
231
-
232
-   flags=payload[0];
233
-
234
-   if(!segregationLevel){
235
-      return dump_standard_hdr_test(hdr,hdrlen,payload,paylen,fd);
236
-   }
237
-
238
-   numvias=payload[1];
239
-   if(numvias==0){
240
-      LM_ERR("no vias present?\n");
241
-      return -1;
242
-   }
243
-   if(segregationLevel & SEGREGATE)
244
-      for(i=0,offset=2+numvias;i<numvias;i++){
245
-	 dump_standard_hdr_test(hdr,hdrlen,&payload[offset],payload[2+i],fd);
246
-	 offset+=payload[2+i];
247
-      }
248
-   return 1;
249
-}
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
... ...
@@ -150,17 +150,17 @@ int encode_via(char *hdrstart,int hdrlen,struct via_body *body,unsigned char *wh
150 150
    return i;
151 151
 }
152 152
 
153
-int print_encoded_via_body(int fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
153
+int print_encoded_via_body(FILE *fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
154 154
 {
155 155
    unsigned char flags, numvias;
156 156
    int i,offset;
157 157
 
158 158
    flags=payload[0];
159
-   dprintf(fd,"%s",prefix);
159
+   fprintf(fd,"%s",prefix);
160 160
    for(i=0;i<paylen;i++)
161
-      dprintf(fd,"%s%d%s",i==0?"ENCODED VIA BODY:[":":",payload[i],i==paylen-1?"]\n":"");
161
+      fprintf(fd,"%s%d%s",i==0?"ENCODED VIA BODY:[":":",payload[i],i==paylen-1?"]\n":"");
162 162
    numvias=payload[1];
163
-   dprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
163
+   fprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
164 164
    if(numvias==0){
165 165
       LM_ERR("no vias present?\n");
166 166
       return -1;
... ...
@@ -173,58 +173,58 @@ int print_encoded_via_body(int fd,char *hdr,int hdrlen,unsigned char *payload,in
173 173
    return 1;
174 174
 }
175 175
 
176
-int print_encoded_via(int fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
176
+int print_encoded_via(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
177 177
 {
178 178
    int i=2;/* flags + urilength */
179 179
    unsigned char flags=0;
180 180
 
181 181
    flags=payload[0];
182
-   dprintf(fd,"%s",prefix);
182
+   fprintf(fd,"%s",prefix);
183 183
    for(i=0;i<paylen;i++)
184
-      dprintf(fd,"%s%d%s",i==0?"ENCODED VIA=[":":",payload[i],i==paylen-1?"]\n":"");
184
+      fprintf(fd,"%s%d%s",i==0?"ENCODED VIA=[":":",payload[i],i==paylen-1?"]\n":"");
185 185
 
186
-   dprintf(fd,"%sPROT=[%.*s]\n",prefix,payload[2]-payload[1]-1,&hdr[payload[1]]);
187
-   dprintf(fd,"%sVER=[%.*s]\n",prefix,payload[3]-payload[2]-1,&hdr[payload[2]]);
188
-   dprintf(fd,"%sTRANSP=[%.*s]\n",prefix,payload[4]-payload[3]-1,&hdr[payload[3]]);
186
+   fprintf(fd,"%sPROT=[%.*s]\n",prefix,payload[2]-payload[1]-1,&hdr[payload[1]]);
187
+   fprintf(fd,"%sVER=[%.*s]\n",prefix,payload[3]-payload[2]-1,&hdr[payload[2]]);
188
+   fprintf(fd,"%sTRANSP=[%.*s]\n",prefix,payload[4]-payload[3]-1,&hdr[payload[3]]);
189 189
 
190
-   dprintf(fd,"%sHOST=[%.*s]\n",prefix,payload[6]-payload[5]-1,&hdr[payload[5]]);
190
+   fprintf(fd,"%sHOST=[%.*s]\n",prefix,payload[6]-payload[5]-1,&hdr[payload[5]]);
191 191
    if(flags & HAS_PORT_F){
192
-      dprintf(fd,"%sPORT=[%.*s]\n",prefix,payload[7]-payload[6]-1,&hdr[payload[6]]);
192
+      fprintf(fd,"%sPORT=[%.*s]\n",prefix,payload[7]-payload[6]-1,&hdr[payload[6]]);
193 193
       i=8;
194 194
    }else
195 195
       i=7;
196 196
    if(flags & HAS_PARAMS_F){
197
-      dprintf(fd,"%sPARAMS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
197
+      fprintf(fd,"%sPARAMS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
198 198
       i+=2;
199 199
    }
200 200
    if(flags & HAS_BRANCH_F){
201
-      dprintf(fd,"%sBRANCH=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
201
+      fprintf(fd,"%sBRANCH=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
202 202
       i+=2;
203 203
    }
204 204
    if(flags & HAS_RECEIVED_F){
205
-      dprintf(fd,"%sRECEIVED=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
205
+      fprintf(fd,"%sRECEIVED=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
206 206
       i+=2;
207 207
    }
208 208
    if(flags & HAS_RPORT_F){
209
-      dprintf(fd,"%sRPORT=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
209
+      fprintf(fd,"%sRPORT=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
210 210
       i+=2;
211 211
    }
212 212
    if(flags & HAS_I_F){
213
-      dprintf(fd,"%sI=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
213
+      fprintf(fd,"%sI=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
214 214
       i+=2;
215 215
    }
216 216
    if(flags & HAS_ALIAS_F){
217
-      dprintf(fd,"%sALIAS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
217
+      fprintf(fd,"%sALIAS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
218 218
       i+=2;
219 219
    }
220 220
    for(;i<paylen-1;i+=2){
221
-      dprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
222
-      dprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
221
+      fprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
222
+      fprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
223 223
    }
224 224
    return 0;
225 225
 }
226 226
 
227
-int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,int fd,char segregationLevel)
227
+int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,FILE* fd,char segregationLevel)
228 228
 {
229 229
    unsigned char flags, numvias;
230 230
    int i,offset;
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

- changed LOG with LM_*

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

Anca Vamanu authored on 19/10/2007 15:15:01
Showing 1 changed files
... ...
@@ -76,7 +76,7 @@ int encode_via_body(char *hdr,int hdrlen,struct via_body *via_parsed,unsigned ch
76 76
    if(via_parsed)
77 77
       for(via_offset=0,i=0,myvia=via_parsed;myvia;myvia=myvia->next,i++){
78 78
 	 if((k=encode_via(hdr,hdrlen,myvia,&tmp[via_offset]))<0){
79
-	    LOG(L_ERR,"parsing via number %d\n",i);
79
+	    LM_ERR("failed to parse via number %d\n",i);
80 80
 	    return -1;
81 81
 	 }
82 82
 	 where[2+i]=(unsigned char)k;
... ...
@@ -162,7 +162,7 @@ int print_encoded_via_body(int fd,char *hdr,int hdrlen,unsigned char *payload,in
162 162
    numvias=payload[1];
163 163
    dprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
164 164
    if(numvias==0){
165
-      LOG(L_ERR,"no vias present?\n");
165
+      LM_ERR("no vias present?\n");
166 166
       return -1;
167 167
    }
168 168
    for(i=0,offset=2+numvias;i<numvias;i++){
... ...
@@ -237,7 +237,7 @@ int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,in
237 237
 
238 238
    numvias=payload[1];
239 239
    if(numvias==0){
240
-      LOG(L_ERR,"no vias present?\n");
240
+      LM_ERR("no vias present?\n");
241 241
       return -1;
242 242
    }
243 243
    if(segregationLevel & SEGREGATE)
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

reverted to old logging system. fixed a couple of warnings regarding printf("%d",(int)sizeof(something))

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

Elias Baixas authored on 08/03/2007 11:08:03
Showing 1 changed files
... ...
@@ -56,7 +56,7 @@ int encode_via_body(char *hdr,int hdrlen,struct via_body *via_parsed,unsigned ch
56 56
    if(via_parsed)
57 57
       for(via_offset=0,i=0,myvia=via_parsed;myvia;myvia=myvia->next,i++){
58 58
 	 if((k=encode_via(hdr,hdrlen,myvia,&tmp[via_offset]))<0){
59
-	    SLOG(L_ERR,"parsing via number %d\n",i);
59
+	    LOG(L_ERR,"parsing via number %d\n",i);
60 60
 	    return -1;
61 61
 	 }
62 62
 	 where[2+i]=(unsigned char)k;
... ...
@@ -142,7 +142,7 @@ int print_encoded_via_body(int fd,char *hdr,int hdrlen,unsigned char *payload,in
142 142
    numvias=payload[1];
143 143
    dprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
144 144
    if(numvias==0){
145
-      SLOG(L_ERR,"no vias present?\n");
145
+      LOG(L_ERR,"no vias present?\n");
146 146
       return -1;
147 147
    }
148 148
    for(i=0,offset=2+numvias;i<numvias;i++){
... ...
@@ -217,7 +217,7 @@ int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,in
217 217
 
218 218
    numvias=payload[1];
219 219
    if(numvias==0){
220
-      SLOG(L_ERR,"no vias present?\n");
220
+      LOG(L_ERR,"no vias present?\n");
221 221
       return -1;
222 222
    }
223 223
    if(segregationLevel & SEGREGATE)
Browse code

Changed the logging system

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

Elias Baixas authored on 01/03/2007 17:25:55
Showing 1 changed files
... ...
@@ -56,7 +56,7 @@ int encode_via_body(char *hdr,int hdrlen,struct via_body *via_parsed,unsigned ch
56 56
    if(via_parsed)
57 57
       for(via_offset=0,i=0,myvia=via_parsed;myvia;myvia=myvia->next,i++){
58 58
 	 if((k=encode_via(hdr,hdrlen,myvia,&tmp[via_offset]))<0){
59
-	    LOG(L_ERR,"ERROR: encode_via_header: parsing via number %d\n",i);
59
+	    SLOG(L_ERR,"parsing via number %d\n",i);
60 60
 	    return -1;
61 61
 	 }
62 62
 	 where[2+i]=(unsigned char)k;
... ...
@@ -142,7 +142,7 @@ int print_encoded_via_body(int fd,char *hdr,int hdrlen,unsigned char *payload,in
142 142
    numvias=payload[1];
143 143
    dprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
144 144
    if(numvias==0){
145
-      LOG(L_ERR,"ERROR: print_encoded_struct via_body: no vias present?\n");
145
+      SLOG(L_ERR,"no vias present?\n");
146 146
       return -1;
147 147
    }
148 148
    for(i=0,offset=2+numvias;i<numvias;i++){
... ...
@@ -217,7 +217,7 @@ int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,in
217 217
 
218 218
    numvias=payload[1];
219 219
    if(numvias==0){
220
-      LOG(L_ERR,"ERROR: dump_via_body_test: no vias present?\n");
220
+      SLOG(L_ERR,"no vias present?\n");
221 221
       return -1;
222 222
    }
223 223
    if(segregationLevel & SEGREGATE)
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,229 @@
1
+/* $Id$ */
2
+/*
3
+ * =====================================================================================
4
+ * 
5
+ *        Filename:  encode_via.c
6
+ * 
7
+ *     Description:  functions to encode VIA headers
8
+ * 
9
+ *         Version:  1.0
10
+ *         Created:  21/11/05 02:30:50 CET
11
+ *        Revision:  none
12
+ *        Compiler:  gcc
13
+ * 
14
+ *          Author:  Elias Baixas (EB), elias@conillera.net
15
+ *         Company:  VozTele.com
16
+ * 
17
+ * =====================================================================================
18
+ */
19
+
20
+#define _GNU_SOURCE
21
+#include <stdio.h>
22
+
23
+#include "../../parser/parse_via.h"
24
+#include "../../parser/parse_uri.h"
25
+#include "encode_via.h"
26
+#include "encode_uri.h"
27
+#include "xaddress.h"
28
+#include "encode_header.h"
29
+#include "encode_parameters.h"
30
+
31
+#define HAS_PARAMS_F		0x01
32
+#define HAS_BRANCH_F		0x02
33
+#define HAS_RECEIVED_F		0x04
34
+#define HAS_RPORT_F		0x08
35
+#define HAS_I_F			0x10
36
+#define HAS_ALIAS_F		0x20
37
+#define HAS_PORT_F		0x40
38
+
39
+#define REL_PTR(a,b) (unsigned char)((b)-(a))
40
+
41
+/*
42
+ * encodes a (maybe aggregated) via header.
43
+ * encoding is:
44
+ * 1: flags
45
+ * 1: number of vias present
46
+ * N: fore each via present, the length of the via
47
+ * N*M: the via structures concatenated
48
+ */
49
+int encode_via_body(char *hdr,int hdrlen,struct via_body *via_parsed,unsigned char *where)
50
+{
51
+   int i=0,k,via_offset;
52
+   unsigned char flags,tmp[500];
53
+   struct via_body *myvia;
54
+
55
+   flags=0;
56
+   if(via_parsed)
57
+      for(via_offset=0,i=0,myvia=via_parsed;myvia;myvia=myvia->next,i++){
58
+	 if((k=encode_via(hdr,hdrlen,myvia,&tmp[via_offset]))<0){
59
+	    LOG(L_ERR,"ERROR: encode_via_header: parsing via number %d\n",i);
60
+	    return -1;
61
+	 }
62
+	 where[2+i]=(unsigned char)k;
63
+	 via_offset+=k;
64
+      }
65
+   else
66
+      return -1;
67
+   where[1]=(unsigned char)i;/*how may vias there are*/
68
+   memcpy(&where[2+i],tmp,via_offset);
69
+   return 2+i+via_offset;
70
+}
71
+
72
+/* Encoder for vias.
73
+ * Returns the length of the encoded structure in bytes
74
+ * FORMAT (byte meanings):
75
+ * 1: flags
76
+ *
77
+ */
78
+int encode_via(char *hdrstart,int hdrlen,struct via_body *body,unsigned char *where)
79
+{
80
+   int i;/* 1*flags + 1*hostport_len*/
81
+   unsigned char flags=0;
82
+
83
+   where[1]=REL_PTR(hdrstart,body->name.s);
84
+   where[2]=REL_PTR(hdrstart,body->version.s);
85
+   where[3]=REL_PTR(hdrstart,body->transport.s);
86
+   where[4]=REL_PTR(hdrstart,body->transport.s+body->transport.len+1);
87
+   where[5]=REL_PTR(hdrstart,body->host.s);
88
+   if(body->port_str.s && body->port_str.len){
89
+      flags|=HAS_PORT_F;
90
+      where[6]=REL_PTR(hdrstart,body->port_str.s);
91
+      where[7]=REL_PTR(hdrstart,body->port_str.s+body->port_str.len+1);
92
+      i=8;
93
+   }else{
94
+      where[6]=REL_PTR(hdrstart,body->host.s+body->host.len+1);
95
+      i=7;
96
+   }
97
+   if(body->params.s && body->params.len){
98
+      flags|=HAS_PARAMS_F;
99
+      where[i++]=REL_PTR(hdrstart,body->params.s);
100
+      where[i++]=(unsigned char)body->params.len;
101
+   }
102
+   if(body->branch && body->branch->value.s && body->branch->value.len){
103
+      flags|=HAS_BRANCH_F;
104
+      where[i++]=REL_PTR(hdrstart,body->branch->value.s);
105
+      where[i++]=(unsigned char)body->branch->value.len;
106
+   }
107
+   if(body->received && body->received->value.s && body->received->value.len){
108
+      flags|=HAS_RECEIVED_F;
109
+      where[i++]=REL_PTR(hdrstart,body->received->value.s);
110
+      where[i++]=(unsigned char)body->received->value.len;
111
+   }
112
+   if(body->rport && body->rport->value.s && body->rport->value.len){
113
+      flags|=HAS_RPORT_F;
114
+      where[i++]=REL_PTR(hdrstart,body->rport->value.s);
115
+      where[i++]=(unsigned char)body->rport->value.len;
116
+   }
117
+   if(body->i && body->i->value.s && body->i->value.len){
118
+      flags|=HAS_I_F;
119
+      where[i++]=REL_PTR(hdrstart,body->i->value.s);
120
+      where[i++]=(unsigned char)body->i->value.len;
121
+   }
122
+   if(body->alias && body->alias->value.s && body->alias->value.len){
123
+      flags|=HAS_ALIAS_F;
124
+      where[i++]=REL_PTR(hdrstart,body->alias->value.s);
125
+      where[i++]=(unsigned char)body->alias->value.len;
126
+   }
127
+
128
+   where[0]=flags;
129
+   i+=encode_parameters(&where[i],body->param_lst,hdrstart,(void *)body,'v');
130
+   return i;
131
+}
132
+
133
+int print_encoded_via_body(int fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
134
+{
135
+   unsigned char flags, numvias;
136
+   int i,offset;
137
+
138
+   flags=payload[0];
139
+   dprintf(fd,"%s",prefix);
140
+   for(i=0;i<paylen;i++)
141
+      dprintf(fd,"%s%d%s",i==0?"ENCODED VIA BODY:[":":",payload[i],i==paylen-1?"]\n":"");
142
+   numvias=payload[1];
143
+   dprintf(fd,"%s%d","NUMBER OF VIAS:",numvias);
144
+   if(numvias==0){
145
+      LOG(L_ERR,"ERROR: print_encoded_struct via_body: no vias present?\n");
146
+      return -1;
147
+   }
148
+   for(i=0,offset=2+numvias;i<numvias;i++){
149
+      print_encoded_via(fd,hdr,hdrlen,&payload[offset],payload[2+i],strcat(prefix,"  "));
150
+      offset+=payload[2+i];
151
+      prefix[strlen(prefix)-2]=0;
152
+   }
153
+   return 1;
154
+}
155
+
156
+int print_encoded_via(int fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
157
+{
158
+   int i=2;/* flags + urilength */
159
+   unsigned char flags=0;
160
+
161
+   flags=payload[0];
162
+   dprintf(fd,"%s",prefix);
163
+   for(i=0;i<paylen;i++)
164
+      dprintf(fd,"%s%d%s",i==0?"ENCODED VIA=[":":",payload[i],i==paylen-1?"]\n":"");
165
+
166
+   dprintf(fd,"%sPROT=[%.*s]\n",prefix,payload[2]-payload[1]-1,&hdr[payload[1]]);
167
+   dprintf(fd,"%sVER=[%.*s]\n",prefix,payload[3]-payload[2]-1,&hdr[payload[2]]);
168
+   dprintf(fd,"%sTRANSP=[%.*s]\n",prefix,payload[4]-payload[3]-1,&hdr[payload[3]]);
169
+
170
+   dprintf(fd,"%sHOST=[%.*s]\n",prefix,payload[6]-payload[5]-1,&hdr[payload[5]]);
171
+   if(flags & HAS_PORT_F){
172
+      dprintf(fd,"%sPORT=[%.*s]\n",prefix,payload[7]-payload[6]-1,&hdr[payload[6]]);
173
+      i=8;
174
+   }else
175
+      i=7;
176
+   if(flags & HAS_PARAMS_F){
177
+      dprintf(fd,"%sPARAMS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
178
+      i+=2;
179
+   }
180
+   if(flags & HAS_BRANCH_F){
181
+      dprintf(fd,"%sBRANCH=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
182
+      i+=2;
183
+   }
184
+   if(flags & HAS_RECEIVED_F){
185
+      dprintf(fd,"%sRECEIVED=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
186
+      i+=2;
187
+   }
188
+   if(flags & HAS_RPORT_F){
189
+      dprintf(fd,"%sRPORT=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
190
+      i+=2;
191
+   }
192
+   if(flags & HAS_I_F){
193
+      dprintf(fd,"%sI=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
194
+      i+=2;
195
+   }
196
+   if(flags & HAS_ALIAS_F){
197
+      dprintf(fd,"%sALIAS=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
198
+      i+=2;
199
+   }
200
+   for(;i<paylen-1;i+=2){
201
+      dprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
202
+      dprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
203
+   }
204
+   return 0;
205
+}
206
+
207
+int dump_via_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,int fd,char segregationLevel)
208
+{
209
+   unsigned char flags, numvias;
210
+   int i,offset;
211
+
212
+   flags=payload[0];
213
+
214
+   if(!segregationLevel){
215
+      return dump_standard_hdr_test(hdr,hdrlen,payload,paylen,fd);
216
+   }
217
+
218
+   numvias=payload[1];
219
+   if(numvias==0){
220
+      LOG(L_ERR,"ERROR: dump_via_body_test: no vias present?\n");
221
+      return -1;
222
+   }
223
+   if(segregationLevel & SEGREGATE)
224
+      for(i=0,offset=2+numvias;i<numvias;i++){
225
+	 dump_standard_hdr_test(hdr,hdrlen,&payload[offset],payload[2+i],fd);
226
+	 offset+=payload[2+i];
227
+      }
228
+   return 1;
229
+}