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,234 +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_route.c
26
- * 
27
- *     Description:  functions to encode/decode/print the route header
28
- * 
29
- *         Version:  1.0
30
- *         Created:  20/11/05 04:24:55 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_rr.h"
44
-#include "../../parser/parse_uri.h"
45
-#include "encode_route.h"
46
-#include "encode_uri.h"
47
-#include "encode_header.h"
48
-#include "encode_parameters.h"
49
-#include "xaddress.h"
50
-
51
-
52
-#define HAS_NAME_F		0x01
53
-#define HAS_Q_F			0x02
54
-#define HAS_EXPIRES_F		0x04
55
-#define HAS_RECEIVED_F		0x08
56
-#define HAS_METHOD_F		0x10
57
-
58
-/*
59
- * encodes a (maybe aggregated) route/record-route header.
60
- * encoding is:
61
- * 1: flags
62
- * 1: number of routes present
63
- * N: fore each route present, the length of the route
64
- * N*M: the route structures concatenated
65
- */
66
-int encode_route_body(char *hdr,int hdrlen,rr_t *route_parsed,unsigned char *where)
67
-{
68
-   int i=0,k,route_offset;
69
-   unsigned char flags,tmp[500];
70
-   rr_t *myroute;
71
-   
72
-   flags=0;
73
-   for(route_offset=0,i=0,myroute=route_parsed;myroute;myroute=myroute->next,i++){
74
-      if((k=encode_route(hdr,hdrlen,myroute,&tmp[route_offset]))<0){
75
-	 LM_ERR("parsing route number %d\n",i);
76
-	 return -1;
77
-      }
78
-      where[2+i]=(unsigned char)k;
79
-      route_offset+=k;
80
-   }
81
-   where[1]=(unsigned char)i;
82
-   memcpy(&where[2+i],tmp,route_offset);
83
-   return 2+i+route_offset;
84
-}
85
-
86
-/* Encoder for route/record-route units (may be inside an aggegated
87
- * Route/RRoute header, see [rfc3261, 7.3.1, page 30] ).
88
- * Returns the length of the encoded structure in bytes
89
- * FORMAT (byte meanings):
90
- * 1: flags
91
- * 	0x01 :	there is a Display Name
92
- * 1: length of the XURI-encoded uri in bytes.
93
- * [2]: optionally, 1 HDR-based ptr to the displayname + the length of the name
94
- * N: the XURI-encoded URI.
95
- * [N:] optionally, HDR-based pointers to the different header-parameters
96
- *
97
- */
98
-int encode_route(char *hdrstart,int hdrlen,rr_t *body,unsigned char *where)
99
-{
100
-   int i=2,j=0;/* 1*flags + 1*URI_len*/
101
-   unsigned char flags=0;
102
-   struct sip_uri puri;
103
-
104
-   if(body->nameaddr.name.s && body->nameaddr.name.len){
105
-      flags|=HAS_NAME_F;
106
-      where[i++]=(unsigned char)(body->nameaddr.name.s-hdrstart);
107
-      where[i++]=(unsigned char)body->nameaddr.name.len;
108
-   }
109
-
110
-   if (parse_uri(body->nameaddr.uri.s, body->nameaddr.uri.len,&puri) < 0 ) {
111
-      LM_ERR("Bad URI in address\n");
112
-	  return -1;
113
-   }else{
114
-      if((j=encode_uri2(hdrstart,hdrlen,body->nameaddr.uri,&puri,&where[i]))<0){
115
-	 LM_ERR("error codifying the URI\n");
116
-	 return -1;
117
-      }else{
118
-	 i+=j;
119
-      }
120
-   }
121
-   where[0]=flags;
122
-   where[1]=(unsigned char)j;
123
-   i+=encode_parameters(&where[i],(void *)body->params,hdrstart,body,'n');
124
-   return i;
125
-}
126
-
127
-
128
-int print_encoded_route_body(FILE *fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
129
-{
130
-   unsigned char flags, numroutes;
131
-   int i,offset;
132
-
133
-   flags=payload[0];
134
-   fprintf(fd,"%s",prefix);
135
-   for(i=0;i<paylen;i++)
136
-      fprintf(fd,"%s%d%s",i==0?"ENCODED CONTACT BODY:[":":",payload[i],i==paylen-1?"]\n":"");
137
-
138
-   numroutes=payload[1];
139
-   if(numroutes==0){
140
-      LM_ERR("no routes present?\n");
141
-      return -1;
142
-   }
143
-   for(i=0,offset=2+numroutes;i<numroutes;i++){
144
-      print_encoded_route(fd,hdr,hdrlen,&payload[offset],payload[2+i],strcat(prefix,"  "));
145
-      offset+=payload[2+i];
146
-      prefix[strlen(prefix)-2]=0;
147
-   }
148
-   return 1;
149
-}
150
-
151
-int print_encoded_route(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
152
-{
153
-   int i=2;/* flags + urilength */
154
-   unsigned char flags=0;
155
-
156
-   flags=payload[0];
157
-   fprintf(fd,"%s",prefix);
158
-   for(i=0;i<paylen;i++)
159
-      fprintf(fd,"%s%d%s",i==0?"ENCODED ROUTE=[":":",payload[i],i==paylen-1?"]\n":"");
160
-   i=2;
161
-   if(flags & HAS_NAME_F){
162
-      fprintf(fd,"%sNAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
163
-      i+=2;
164
-   }
165
-   if(print_encoded_uri(fd,&payload[i],payload[1],hdr,hdrlen,strcat(prefix,"  "))<0){
166
-      prefix[strlen(prefix)-2]=0;
167
-      fprintf(fd,"Error parsing URI\n");
168
-      return -1;
169
-   }
170
-   prefix[strlen(prefix)-2]=0;
171
-   print_encoded_parameters(fd,&payload[i+payload[1]],hdr,paylen-i-payload[1],prefix);
172
-   /* for(i+=payload[1];i<paylen-1;i+=2){
173
-      fprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
174
-      fprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
175
-   }*/
176
-   return 0;
177
-}
178
-
179
-
180
-int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,FILE* fd,char segregationLevel,char *prefix)
181
-{
182
-   unsigned char flags, numroutes;
183
-   int i,offset;
184
-
185
-   flags=payload[0];
186
-   if(!segregationLevel){
187
-      return dump_standard_hdr_test(hdr,hdrlen,(unsigned char*)payload,paylen,fd);
188
-   }
189
-
190
-   numroutes=payload[1];
191
-   if(numroutes==0){
192
-      LM_ERR("no routes present?\n");
193
-      return -1;
194
-   }
195
-   if(segregationLevel & (JUNIT|SEGREGATE|ONLY_URIS)){
196
-      for(i=0,offset=2+numroutes;i<numroutes;i++){
197
-	 dump_route_test(hdr,hdrlen,&payload[offset],payload[2+i],fd,segregationLevel,prefix);
198
-	 offset+=payload[2+i];
199
-      }
200
-   }
201
-   return 1;
202
-}
203
-
204
-int dump_route_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,FILE* fd,char segregationLevel,char *prefix)
205
-{
206
-   int i=2;/* flags + urilength */
207
-   unsigned char flags=0;
208
-
209
-   if(!(segregationLevel & (ONLY_URIS|JUNIT))){
210
-      return dump_standard_hdr_test(hdr,hdrlen,(unsigned char*)payload,paylen,fd);
211
-   }
212
-   flags=payload[0];
213
-   i=2;
214
-   if(flags & HAS_NAME_F){
215
-      i+=2;
216
-   }
217
-   if((!(segregationLevel & JUNIT)) && (segregationLevel & ONLY_URIS)){
218
-      return dump_standard_hdr_test(hdr,hdrlen,(unsigned char*)(payload+i),payload[1],fd);
219
-   }
220
-   if((segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
221
-      return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,1,"");
222
-   }
223
-   if(segregationLevel & JUNIT){
224
-      i=2;
225
-      fprintf(fd,"%sgetAddress.getDisplayName=(S)",prefix);
226
-      if(flags & HAS_NAME_F){
227
-	 fprintf(fd,"%.*s\n",payload[i+1],&hdr[payload[i]]);
228
-	 i+=2;
229
-      }else
230
-	 fprintf(fd,"(null)\n");
231
-      return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,0,"getAddress.getURI.");
232
-   }
233
-   return 0;
234
-}
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
... ...
@@ -125,15 +125,15 @@ int encode_route(char *hdrstart,int hdrlen,rr_t *body,unsigned char *where)
125 125
 }
126 126
 
127 127
 
128
-int print_encoded_route_body(int fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
128
+int print_encoded_route_body(FILE *fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
129 129
 {
130 130
    unsigned char flags, numroutes;
131 131
    int i,offset;
132 132
 
133 133
    flags=payload[0];
134
-   dprintf(fd,"%s",prefix);
134
+   fprintf(fd,"%s",prefix);
135 135
    for(i=0;i<paylen;i++)
136
-      dprintf(fd,"%s%d%s",i==0?"ENCODED CONTACT BODY:[":":",payload[i],i==paylen-1?"]\n":"");
136
+      fprintf(fd,"%s%d%s",i==0?"ENCODED CONTACT BODY:[":":",payload[i],i==paylen-1?"]\n":"");
137 137
 
138 138
    numroutes=payload[1];
139 139
    if(numroutes==0){
... ...
@@ -148,36 +148,36 @@ int print_encoded_route_body(int fd,char *hdr,int hdrlen,unsigned char *payload,
148 148
    return 1;
149 149
 }
150 150
 
151
-int print_encoded_route(int fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
151
+int print_encoded_route(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
152 152
 {
153 153
    int i=2;/* flags + urilength */
154 154
    unsigned char flags=0;
155 155
 
156 156
    flags=payload[0];
157
-   dprintf(fd,"%s",prefix);
157
+   fprintf(fd,"%s",prefix);
158 158
    for(i=0;i<paylen;i++)
159
-      dprintf(fd,"%s%d%s",i==0?"ENCODED ROUTE=[":":",payload[i],i==paylen-1?"]\n":"");
159
+      fprintf(fd,"%s%d%s",i==0?"ENCODED ROUTE=[":":",payload[i],i==paylen-1?"]\n":"");
160 160
    i=2;
161 161
    if(flags & HAS_NAME_F){
162
-      dprintf(fd,"%sNAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
162
+      fprintf(fd,"%sNAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
163 163
       i+=2;
164 164
    }
165 165
    if(print_encoded_uri(fd,&payload[i],payload[1],hdr,hdrlen,strcat(prefix,"  "))<0){
166 166
       prefix[strlen(prefix)-2]=0;
167
-      dprintf(fd,"Error parsing URI\n");
167
+      fprintf(fd,"Error parsing URI\n");
168 168
       return -1;
169 169
    }
170 170
    prefix[strlen(prefix)-2]=0;
171 171
    print_encoded_parameters(fd,&payload[i+payload[1]],hdr,paylen-i-payload[1],prefix);
172 172
    /* for(i+=payload[1];i<paylen-1;i+=2){
173
-      dprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
174
-      dprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
173
+      fprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
174
+      fprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
175 175
    }*/
176 176
    return 0;
177 177
 }
178 178
 
179 179
 
180
-int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,int fd,char segregationLevel,char *prefix)
180
+int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,FILE* fd,char segregationLevel,char *prefix)
181 181
 {
182 182
    unsigned char flags, numroutes;
183 183
    int i,offset;
... ...
@@ -201,7 +201,7 @@ int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,
201 201
    return 1;
202 202
 }
203 203
 
204
-int dump_route_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,int fd,char segregationLevel,char *prefix)
204
+int dump_route_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,FILE* fd,char segregationLevel,char *prefix)
205 205
 {
206 206
    int i=2;/* flags + urilength */
207 207
    unsigned char flags=0;
... ...
@@ -222,12 +222,12 @@ int dump_route_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,int f
222 222
    }
223 223
    if(segregationLevel & JUNIT){
224 224
       i=2;
225
-      dprintf(fd,"%sgetAddress.getDisplayName=(S)",prefix);
225
+      fprintf(fd,"%sgetAddress.getDisplayName=(S)",prefix);
226 226
       if(flags & HAS_NAME_F){
227
-	 dprintf(fd,"%.*s\n",payload[i+1],&hdr[payload[i]]);
227
+	 fprintf(fd,"%.*s\n",payload[i+1],&hdr[payload[i]]);
228 228
 	 i+=2;
229 229
       }else
230
-	 dprintf(fd,"(null)\n");
230
+	 fprintf(fd,"(null)\n");
231 231
       return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,0,"getAddress.getURI.");
232 232
    }
233 233
    return 0;
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
... ...
@@ -72,7 +72,7 @@ int encode_route_body(char *hdr,int hdrlen,rr_t *route_parsed,unsigned char *whe
72 72
    flags=0;
73 73
    for(route_offset=0,i=0,myroute=route_parsed;myroute;myroute=myroute->next,i++){
74 74
       if((k=encode_route(hdr,hdrlen,myroute,&tmp[route_offset]))<0){
75
-	 LOG(L_ERR,"parsing route number %d\n",i);
75
+	 LM_ERR("parsing route number %d\n",i);
76 76
 	 return -1;
77 77
       }
78 78
       where[2+i]=(unsigned char)k;
... ...
@@ -108,11 +108,11 @@ int encode_route(char *hdrstart,int hdrlen,rr_t *body,unsigned char *where)
108 108
    }
109 109
 
110 110
    if (parse_uri(body->nameaddr.uri.s, body->nameaddr.uri.len,&puri) < 0 ) {
111
-      LOG(L_ERR, "Bad URI in address\n");
112
-      return -1;
111
+      LM_ERR("Bad URI in address\n");
112
+	  return -1;
113 113
    }else{
114 114
       if((j=encode_uri2(hdrstart,hdrlen,body->nameaddr.uri,&puri,&where[i]))<0){
115
-	 LOG(L_ERR, "error codifying the URI\n");
115
+	 LM_ERR("error codifying the URI\n");
116 116
 	 return -1;
117 117
       }else{
118 118
 	 i+=j;
... ...
@@ -137,7 +137,7 @@ int print_encoded_route_body(int fd,char *hdr,int hdrlen,unsigned char *payload,
137 137
 
138 138
    numroutes=payload[1];
139 139
    if(numroutes==0){
140
-      LOG(L_ERR,"no routes present?\n");
140
+      LM_ERR("no routes present?\n");
141 141
       return -1;
142 142
    }
143 143
    for(i=0,offset=2+numroutes;i<numroutes;i++){
... ...
@@ -189,7 +189,7 @@ int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,
189 189
 
190 190
    numroutes=payload[1];
191 191
    if(numroutes==0){
192
-      LOG(L_ERR,"no routes present?\n");
192
+      LM_ERR("no routes present?\n");
193 193
       return -1;
194 194
    }
195 195
    if(segregationLevel & (JUNIT|SEGREGATE|ONLY_URIS)){
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
... ...
@@ -52,7 +52,7 @@ int encode_route_body(char *hdr,int hdrlen,rr_t *route_parsed,unsigned char *whe
52 52
    flags=0;
53 53
    for(route_offset=0,i=0,myroute=route_parsed;myroute;myroute=myroute->next,i++){
54 54
       if((k=encode_route(hdr,hdrlen,myroute,&tmp[route_offset]))<0){
55
-	 SLOG(L_ERR,"parsing route number %d\n",i);
55
+	 LOG(L_ERR,"parsing route number %d\n",i);
56 56
 	 return -1;
57 57
       }
58 58
       where[2+i]=(unsigned char)k;
... ...
@@ -88,11 +88,11 @@ int encode_route(char *hdrstart,int hdrlen,rr_t *body,unsigned char *where)
88 88
    }
89 89
 
90 90
    if (parse_uri(body->nameaddr.uri.s, body->nameaddr.uri.len,&puri) < 0 ) {
91
-      SLOG(L_ERR, "Bad URI in address\n");
91
+      LOG(L_ERR, "Bad URI in address\n");
92 92
       return -1;
93 93
    }else{
94 94
       if((j=encode_uri2(hdrstart,hdrlen,body->nameaddr.uri,&puri,&where[i]))<0){
95
-	 SLOG(L_ERR, "error codifying the URI\n");
95
+	 LOG(L_ERR, "error codifying the URI\n");
96 96
 	 return -1;
97 97
       }else{
98 98
 	 i+=j;
... ...
@@ -117,7 +117,7 @@ int print_encoded_route_body(int fd,char *hdr,int hdrlen,unsigned char *payload,
117 117
 
118 118
    numroutes=payload[1];
119 119
    if(numroutes==0){
120
-      SLOG(L_ERR,"no routes present?\n");
120
+      LOG(L_ERR,"no routes present?\n");
121 121
       return -1;
122 122
    }
123 123
    for(i=0,offset=2+numroutes;i<numroutes;i++){
... ...
@@ -169,7 +169,7 @@ int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,
169 169
 
170 170
    numroutes=payload[1];
171 171
    if(numroutes==0){
172
-      SLOG(L_ERR,"no routes present?\n");
172
+      LOG(L_ERR,"no routes present?\n");
173 173
       return -1;
174 174
    }
175 175
    if(segregationLevel & (JUNIT|SEGREGATE|ONLY_URIS)){
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
... ...
@@ -52,7 +52,7 @@ int encode_route_body(char *hdr,int hdrlen,rr_t *route_parsed,unsigned char *whe
52 52
    flags=0;
53 53
    for(route_offset=0,i=0,myroute=route_parsed;myroute;myroute=myroute->next,i++){
54 54
       if((k=encode_route(hdr,hdrlen,myroute,&tmp[route_offset]))<0){
55
-	 LOG(L_ERR,"ERROR: encode_route_header: parsing route number %d\n",i);
55
+	 SLOG(L_ERR,"parsing route number %d\n",i);
56 56
 	 return -1;
57 57
       }
58 58
       where[2+i]=(unsigned char)k;
... ...
@@ -88,11 +88,11 @@ int encode_route(char *hdrstart,int hdrlen,rr_t *body,unsigned char *where)
88 88
    }
89 89
 
90 90
    if (parse_uri(body->nameaddr.uri.s, body->nameaddr.uri.len,&puri) < 0 ) {
91
-      LOG(L_ERR, "ERROR: encode_route: Bad URI in address\n");
91
+      SLOG(L_ERR, "Bad URI in address\n");
92 92
       return -1;
93 93
    }else{
94 94
       if((j=encode_uri2(hdrstart,hdrlen,body->nameaddr.uri,&puri,&where[i]))<0){
95
-	 LOG(L_ERR, "ERROR: addr2xaddr: error codifying the URI\n");
95
+	 SLOG(L_ERR, "error codifying the URI\n");
96 96
 	 return -1;
97 97
       }else{
98 98
 	 i+=j;
... ...
@@ -117,7 +117,7 @@ int print_encoded_route_body(int fd,char *hdr,int hdrlen,unsigned char *payload,
117 117
 
118 118
    numroutes=payload[1];
119 119
    if(numroutes==0){
120
-      LOG(L_ERR,"ERROR: print_encoded_route_body: no routes present?\n");
120
+      SLOG(L_ERR,"no routes present?\n");
121 121
       return -1;
122 122
    }
123 123
    for(i=0,offset=2+numroutes;i<numroutes;i++){
... ...
@@ -169,7 +169,7 @@ int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,
169 169
 
170 170
    numroutes=payload[1];
171 171
    if(numroutes==0){
172
-      LOG(L_ERR,"ERROR: print_encoded_route_body: no routes present?\n");
172
+      SLOG(L_ERR,"no routes present?\n");
173 173
       return -1;
174 174
    }
175 175
    if(segregationLevel & (JUNIT|SEGREGATE|ONLY_URIS)){
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,214 @@
1
+/* $Id$ */
2
+/*
3
+ * =====================================================================================
4
+ * 
5
+ *        Filename:  encode_route.c
6
+ * 
7
+ *     Description:  functions to encode/decode/print the route header
8
+ * 
9
+ *         Version:  1.0
10
+ *         Created:  20/11/05 04:24:55 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_rr.h"
24
+#include "../../parser/parse_uri.h"
25
+#include "encode_route.h"
26
+#include "encode_uri.h"
27
+#include "encode_header.h"
28
+#include "encode_parameters.h"
29
+#include "xaddress.h"
30
+
31
+
32
+#define HAS_NAME_F		0x01
33
+#define HAS_Q_F			0x02
34
+#define HAS_EXPIRES_F		0x04
35
+#define HAS_RECEIVED_F		0x08
36
+#define HAS_METHOD_F		0x10
37
+
38
+/*
39
+ * encodes a (maybe aggregated) route/record-route header.
40
+ * encoding is:
41
+ * 1: flags
42
+ * 1: number of routes present
43
+ * N: fore each route present, the length of the route
44
+ * N*M: the route structures concatenated
45
+ */
46
+int encode_route_body(char *hdr,int hdrlen,rr_t *route_parsed,unsigned char *where)
47
+{
48
+   int i=0,k,route_offset;
49
+   unsigned char flags,tmp[500];
50
+   rr_t *myroute;
51
+   
52
+   flags=0;
53
+   for(route_offset=0,i=0,myroute=route_parsed;myroute;myroute=myroute->next,i++){
54
+      if((k=encode_route(hdr,hdrlen,myroute,&tmp[route_offset]))<0){
55
+	 LOG(L_ERR,"ERROR: encode_route_header: parsing route number %d\n",i);
56
+	 return -1;
57
+      }
58
+      where[2+i]=(unsigned char)k;
59
+      route_offset+=k;
60
+   }
61
+   where[1]=(unsigned char)i;
62
+   memcpy(&where[2+i],tmp,route_offset);
63
+   return 2+i+route_offset;
64
+}
65
+
66
+/* Encoder for route/record-route units (may be inside an aggegated
67
+ * Route/RRoute header, see [rfc3261, 7.3.1, page 30] ).
68
+ * Returns the length of the encoded structure in bytes
69
+ * FORMAT (byte meanings):
70
+ * 1: flags
71
+ * 	0x01 :	there is a Display Name
72
+ * 1: length of the XURI-encoded uri in bytes.
73
+ * [2]: optionally, 1 HDR-based ptr to the displayname + the length of the name
74
+ * N: the XURI-encoded URI.
75
+ * [N:] optionally, HDR-based pointers to the different header-parameters
76
+ *
77
+ */
78
+int encode_route(char *hdrstart,int hdrlen,rr_t *body,unsigned char *where)
79
+{
80
+   int i=2,j=0;/* 1*flags + 1*URI_len*/
81
+   unsigned char flags=0;
82
+   struct sip_uri puri;
83
+
84
+   if(body->nameaddr.name.s && body->nameaddr.name.len){
85
+      flags|=HAS_NAME_F;
86
+      where[i++]=(unsigned char)(body->nameaddr.name.s-hdrstart);
87
+      where[i++]=(unsigned char)body->nameaddr.name.len;
88
+   }
89
+
90
+   if (parse_uri(body->nameaddr.uri.s, body->nameaddr.uri.len,&puri) < 0 ) {
91
+      LOG(L_ERR, "ERROR: encode_route: Bad URI in address\n");
92
+      return -1;
93
+   }else{
94
+      if((j=encode_uri2(hdrstart,hdrlen,body->nameaddr.uri,&puri,&where[i]))<0){
95
+	 LOG(L_ERR, "ERROR: addr2xaddr: error codifying the URI\n");
96
+	 return -1;
97
+      }else{
98
+	 i+=j;
99
+      }
100
+   }
101
+   where[0]=flags;
102
+   where[1]=(unsigned char)j;
103
+   i+=encode_parameters(&where[i],(void *)body->params,hdrstart,body,'n');
104
+   return i;
105
+}
106
+
107
+
108
+int print_encoded_route_body(int fd,char *hdr,int hdrlen,unsigned char *payload,int paylen,char *prefix)
109
+{
110
+   unsigned char flags, numroutes;
111
+   int i,offset;
112
+
113
+   flags=payload[0];
114
+   dprintf(fd,"%s",prefix);
115
+   for(i=0;i<paylen;i++)
116
+      dprintf(fd,"%s%d%s",i==0?"ENCODED CONTACT BODY:[":":",payload[i],i==paylen-1?"]\n":"");
117
+
118
+   numroutes=payload[1];
119
+   if(numroutes==0){
120
+      LOG(L_ERR,"ERROR: print_encoded_route_body: no routes present?\n");
121
+      return -1;
122
+   }
123
+   for(i=0,offset=2+numroutes;i<numroutes;i++){
124
+      print_encoded_route(fd,hdr,hdrlen,&payload[offset],payload[2+i],strcat(prefix,"  "));
125
+      offset+=payload[2+i];
126
+      prefix[strlen(prefix)-2]=0;
127
+   }
128
+   return 1;
129
+}
130
+
131
+int print_encoded_route(int fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
132
+{
133
+   int i=2;/* flags + urilength */
134
+   unsigned char flags=0;
135
+
136
+   flags=payload[0];
137
+   dprintf(fd,"%s",prefix);
138
+   for(i=0;i<paylen;i++)
139
+      dprintf(fd,"%s%d%s",i==0?"ENCODED ROUTE=[":":",payload[i],i==paylen-1?"]\n":"");
140
+   i=2;
141
+   if(flags & HAS_NAME_F){
142
+      dprintf(fd,"%sNAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
143
+      i+=2;
144
+   }
145
+   if(print_encoded_uri(fd,&payload[i],payload[1],hdr,hdrlen,strcat(prefix,"  "))<0){
146
+      prefix[strlen(prefix)-2]=0;
147
+      dprintf(fd,"Error parsing URI\n");
148
+      return -1;
149
+   }
150
+   prefix[strlen(prefix)-2]=0;
151
+   print_encoded_parameters(fd,&payload[i+payload[1]],hdr,paylen-i-payload[1],prefix);
152
+   /* for(i+=payload[1];i<paylen-1;i+=2){
153
+      dprintf(fd,"%s[PARAMETER[%.*s]",prefix,payload[i+1]-payload[i]-1,&hdr[payload[i]]);
154
+      dprintf(fd,"VALUE[%.*s]]\n",(payload[i+2]-payload[i+1])==0?0:(payload[i+2]-payload[i+1]-1),&hdr[payload[i+1]]);
155
+   }*/
156
+   return 0;
157
+}
158
+
159
+
160
+int dump_route_body_test(char *hdr,int hdrlen,unsigned char *payload,int paylen,int fd,char segregationLevel,char *prefix)
161
+{
162
+   unsigned char flags, numroutes;
163
+   int i,offset;
164
+
165
+   flags=payload[0];
166
+   if(!segregationLevel){
167
+      return dump_standard_hdr_test(hdr,hdrlen,(unsigned char*)payload,paylen,fd);
168
+   }
169
+
170
+   numroutes=payload[1];
171
+   if(numroutes==0){
172
+      LOG(L_ERR,"ERROR: print_encoded_route_body: no routes present?\n");
173
+      return -1;
174
+   }
175
+   if(segregationLevel & (JUNIT|SEGREGATE|ONLY_URIS)){
176
+      for(i=0,offset=2+numroutes;i<numroutes;i++){
177
+	 dump_route_test(hdr,hdrlen,&payload[offset],payload[2+i],fd,segregationLevel,prefix);
178
+	 offset+=payload[2+i];
179
+      }
180
+   }
181
+   return 1;
182
+}
183
+
184
+int dump_route_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,int fd,char segregationLevel,char *prefix)
185
+{
186
+   int i=2;/* flags + urilength */
187
+   unsigned char flags=0;
188
+
189
+   if(!(segregationLevel & (ONLY_URIS|JUNIT))){
190
+      return dump_standard_hdr_test(hdr,hdrlen,(unsigned char*)payload,paylen,fd);
191
+   }
192
+   flags=payload[0];
193
+   i=2;
194
+   if(flags & HAS_NAME_F){
195
+      i+=2;
196
+   }
197
+   if((!(segregationLevel & JUNIT)) && (segregationLevel & ONLY_URIS)){
198
+      return dump_standard_hdr_test(hdr,hdrlen,(unsigned char*)(payload+i),payload[1],fd);
199
+   }
200
+   if((segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
201
+      return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,1,"");
202
+   }
203
+   if(segregationLevel & JUNIT){
204
+      i=2;
205
+      dprintf(fd,"%sgetAddress.getDisplayName=(S)",prefix);
206
+      if(flags & HAS_NAME_F){
207
+	 dprintf(fd,"%.*s\n",payload[i+1],&hdr[payload[i]]);
208
+	 i+=2;
209
+      }else
210
+	 dprintf(fd,"(null)\n");
211
+      return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,0,"getAddress.getURI.");
212
+   }
213
+   return 0;
214
+}