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,170 +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:  xaddress.c
26
- * 
27
- *     Description:  Address manipulation tools
28
- * 
29
- *         Version:  1.0
30
- *         Created:  17/11/05 02:09:44 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 <string.h>
42
-#include <netinet/in.h>
43
-#include "../../mem/mem.h"
44
-#include "../../parser/msg_parser.h"
45
-#include "../../parser/parse_uri.h"
46
-#include "../../dprint.h"
47
-#include "encode_to_body.h"
48
-#include "encode_uri.h"
49
-#include "encode_header.h"
50
-#include "encode_parameters.h"
51
-#include "xaddress.h"
52
-
53
-
54
-/* Encoder for From and To headers.
55
- * Returns the length of the encoded structure in bytes
56
- * FORMAT (byte meanings):
57
- * 1: flags
58
- * 	0x10 :	there is a Display Name
59
- * 	0x20 :	there is a tag parameter
60
- * 	0x40 :	there are other parameters
61
- * 1: length of the XURI-encoded uri in bytes.
62
- * [2]: optionally, 1 HDR-based ptr to the displayname + the length of the name
63
- * [2]: optionally, 1 HDR-based ptr to the tag + the length of the tag parameter
64
- * N: the XURI-encoded URI.
65
- * [N:] optionally, HDR-based pointers to the different header-parameters
66
- *
67
- */
68
-int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char *where)
69
-{
70
-   int i=2,j=0;/* 1*flags + 1*URI_len*/
71
-   unsigned char flags=0;
72
-   struct sip_uri puri;
73
-
74
-   if(body->display.s && body->display.len){
75
-      flags|=HAS_DISPLAY_F;
76
-      if(body->display.s[0]=='\"'){
77
-	 body->display.s++;
78
-	 body->display.len-=2;
79
-      }
80
-      where[i++]=(unsigned char)(body->display.s-hdrstart);
81
-      where[i++]=(unsigned char)(body->display.len);
82
-   }
83
-   if(body->tag_value.s && body->tag_value.len){
84
-      flags|=HAS_TAG_F;
85
-      where[i++]=(unsigned char)(body->tag_value.s-hdrstart);
86
-      where[i++]=(unsigned char)body->tag_value.len;
87
-   }
88
-   if (parse_uri(body->uri.s, body->uri.len,&puri) < 0 ) {
89
-      LM_ERR("Bad URI in address\n");
90
-      return -1;
91
-   }else{
92
-      if((j=encode_uri2(hdrstart,hdrlen,body->uri,&puri,&where[i]))<0){
93
-	 LM_ERR("failed to codify the URI\n");
94
-	 return -1;
95
-      }else{
96
-	 i+=j;
97
-      }
98
-   }
99
-   where[0]=flags;
100
-   where[1]=(unsigned char)j;
101
-   i+=encode_parameters(&where[i],(void *)body->param_lst,hdrstart,body,'t');
102
-
103
-   return i;
104
-}
105
-
106
-int print_encoded_to_body(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
107
-{
108
-   int i=2;/* flags + urilength */
109
-   unsigned char flags=0;
110
-
111
-   flags=payload[0];
112
-   fprintf(fd,"%s",prefix);
113
-   for(i=0;i<paylen;i++)
114
-      fprintf(fd,"%s%d%s",i==0?"BODY CODE=[":":",payload[i],i==paylen-1?"]\n":"");
115
-   i=2;
116
-   if(flags & HAS_DISPLAY_F){
117
-      fprintf(fd,"%sDISPLAY NAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
118
-      i+=2;
119
-   }
120
-   if(flags & HAS_TAG_F){
121
-      fprintf(fd,"%sTAG=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
122
-      i+=2;
123
-   }
124
-   if(print_encoded_uri(fd,&payload[i],payload[1],hdr,hdrlen,strcat(prefix,"  "))<0){
125
-      fprintf(fd,"Error parsing URI\n");
126
-      prefix[strlen(prefix)-2]=0;
127
-      return -1;
128
-   }
129
-   prefix[strlen(prefix)-2]=0;
130
-   print_encoded_parameters(fd,&payload[i+payload[1]],hdr,paylen-i-payload[1],prefix);
131
-   return 0;
132
-}
133
-
134
-/**
135
- * dumps to FD a NBO int which is the header length, the header,
136
- * an NBO int which is the payload length, and the payload.
137
- *
138
- * hdr is the header,
139
- * hdrlen is the header length,
140
- * payload is the payload,
141
- * paylen is the payload length,
142
- * fd is the file descriptor to which to dump,
143
- * segregationLevel is wether only URIS must be dumped or all the header code.
144
- *
145
- * return 0 on success, <0 on error
146
- */
147
-int dump_to_body_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,FILE* fd,char segregationLevel)
148
-{
149
-   int i=2;/* flags + urilength */
150
-   unsigned char flags=0;
151
-
152
-   flags=payload[0];
153
-   if(!segregationLevel){
154
-      return dump_standard_hdr_test(hdr,hdrlen,payload,paylen,fd);
155
-   }
156
-   i=2;
157
-   if(flags & HAS_DISPLAY_F){
158
-      i+=2;
159
-   }
160
-   if(flags & HAS_TAG_F){
161
-      i+=2;
162
-   }
163
-   if(!(segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
164
-     return dump_standard_hdr_test(hdr,hdrlen,&payload[i],payload[1],fd);
165
-   }
166
-   if((segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
167
-     return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,1,"");
168
-   }
169
-   return 0;
170
-}
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
... ...
@@ -103,26 +103,26 @@ int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char
103 103
    return i;
104 104
 }
105 105
 
106
-int print_encoded_to_body(int fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
106
+int print_encoded_to_body(FILE *fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
107 107
 {
108 108
    int i=2;/* flags + urilength */
109 109
    unsigned char flags=0;
110 110
 
111 111
    flags=payload[0];
112
-   dprintf(fd,"%s",prefix);
112
+   fprintf(fd,"%s",prefix);
113 113
    for(i=0;i<paylen;i++)
114
-      dprintf(fd,"%s%d%s",i==0?"BODY CODE=[":":",payload[i],i==paylen-1?"]\n":"");
114
+      fprintf(fd,"%s%d%s",i==0?"BODY CODE=[":":",payload[i],i==paylen-1?"]\n":"");
115 115
    i=2;
116 116
    if(flags & HAS_DISPLAY_F){
117
-      dprintf(fd,"%sDISPLAY NAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
117
+      fprintf(fd,"%sDISPLAY NAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
118 118
       i+=2;
119 119
    }
120 120
    if(flags & HAS_TAG_F){
121
-      dprintf(fd,"%sTAG=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
121
+      fprintf(fd,"%sTAG=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
122 122
       i+=2;
123 123
    }
124 124
    if(print_encoded_uri(fd,&payload[i],payload[1],hdr,hdrlen,strcat(prefix,"  "))<0){
125
-      dprintf(fd,"Error parsing URI\n");
125
+      fprintf(fd,"Error parsing URI\n");
126 126
       prefix[strlen(prefix)-2]=0;
127 127
       return -1;
128 128
    }
... ...
@@ -144,7 +144,7 @@ int print_encoded_to_body(int fd,char *hdr,int hdrlen,unsigned char* payload,int
144 144
  *
145 145
  * return 0 on success, <0 on error
146 146
  */
147
-int dump_to_body_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,int fd,char segregationLevel)
147
+int dump_to_body_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,FILE* fd,char segregationLevel)
148 148
 {
149 149
    int i=2;/* flags + urilength */
150 150
    unsigned char flags=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
... ...
@@ -86,11 +86,11 @@ int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char
86 86
       where[i++]=(unsigned char)body->tag_value.len;
87 87
    }
88 88
    if (parse_uri(body->uri.s, body->uri.len,&puri) < 0 ) {
89
-      LOG(L_ERR, "Bad URI in address\n");
89
+      LM_ERR("Bad URI in address\n");
90 90
       return -1;
91 91
    }else{
92 92
       if((j=encode_uri2(hdrstart,hdrlen,body->uri,&puri,&where[i]))<0){
93
-	 LOG(L_ERR, "error codifying the URI\n");
93
+	 LM_ERR("failed to codify the URI\n");
94 94
 	 return -1;
95 95
       }else{
96 96
 	 i+=j;
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
... ...
@@ -66,11 +66,11 @@ int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char
66 66
       where[i++]=(unsigned char)body->tag_value.len;
67 67
    }
68 68
    if (parse_uri(body->uri.s, body->uri.len,&puri) < 0 ) {
69
-      SLOG(L_ERR, "Bad URI in address\n");
69
+      LOG(L_ERR, "Bad URI in address\n");
70 70
       return -1;
71 71
    }else{
72 72
       if((j=encode_uri2(hdrstart,hdrlen,body->uri,&puri,&where[i]))<0){
73
-	 SLOG(L_ERR, "error codifying the URI\n");
73
+	 LOG(L_ERR, "error codifying the URI\n");
74 74
 	 return -1;
75 75
       }else{
76 76
 	 i+=j;
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
... ...
@@ -66,11 +66,11 @@ int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char
66 66
       where[i++]=(unsigned char)body->tag_value.len;
67 67
    }
68 68
    if (parse_uri(body->uri.s, body->uri.len,&puri) < 0 ) {
69
-      LOG(L_ERR, "ERROR: encode_to_body: Bad URI in address\n");
69
+      SLOG(L_ERR, "Bad URI in address\n");
70 70
       return -1;
71 71
    }else{
72 72
       if((j=encode_uri2(hdrstart,hdrlen,body->uri,&puri,&where[i]))<0){
73
-	 LOG(L_ERR, "ERROR: addr2xaddr: error codifying the URI\n");
73
+	 SLOG(L_ERR, "error codifying the URI\n");
74 74
 	 return -1;
75 75
       }else{
76 76
 	 i+=j;
Browse code

Fixed 2 bugs in parsing ruri and the double-quotes of DisplayName in from and to

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

Elias Baixas authored on 11/01/2007 18:47:43
Showing 1 changed files
... ...
@@ -53,8 +53,12 @@ int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char
53 53
 
54 54
    if(body->display.s && body->display.len){
55 55
       flags|=HAS_DISPLAY_F;
56
+      if(body->display.s[0]=='\"'){
57
+	 body->display.s++;
58
+	 body->display.len-=2;
59
+      }
56 60
       where[i++]=(unsigned char)(body->display.s-hdrstart);
57
-      where[i++]=(unsigned char)body->display.len;
61
+      where[i++]=(unsigned char)(body->display.len);
58 62
    }
59 63
    if(body->tag_value.s && body->tag_value.len){
60 64
       flags|=HAS_TAG_F;
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,146 @@
1
+/* $Id$ */
2
+/*
3
+ * =====================================================================================
4
+ * 
5
+ *        Filename:  xaddress.c
6
+ * 
7
+ *     Description:  Address manipulation tools
8
+ * 
9
+ *         Version:  1.0
10
+ *         Created:  17/11/05 02:09:44 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 <string.h>
22
+#include <netinet/in.h>
23
+#include "../../mem/mem.h"
24
+#include "../../parser/msg_parser.h"
25
+#include "../../parser/parse_uri.h"
26
+#include "../../dprint.h"
27
+#include "encode_to_body.h"
28
+#include "encode_uri.h"
29
+#include "encode_header.h"
30
+#include "encode_parameters.h"
31
+#include "xaddress.h"
32
+
33
+
34
+/* Encoder for From and To headers.
35
+ * Returns the length of the encoded structure in bytes
36
+ * FORMAT (byte meanings):
37
+ * 1: flags
38
+ * 	0x10 :	there is a Display Name
39
+ * 	0x20 :	there is a tag parameter
40
+ * 	0x40 :	there are other parameters
41
+ * 1: length of the XURI-encoded uri in bytes.
42
+ * [2]: optionally, 1 HDR-based ptr to the displayname + the length of the name
43
+ * [2]: optionally, 1 HDR-based ptr to the tag + the length of the tag parameter
44
+ * N: the XURI-encoded URI.
45
+ * [N:] optionally, HDR-based pointers to the different header-parameters
46
+ *
47
+ */
48
+int encode_to_body(char *hdrstart,int hdrlen,struct to_body *body,unsigned char *where)
49
+{
50
+   int i=2,j=0;/* 1*flags + 1*URI_len*/
51
+   unsigned char flags=0;
52
+   struct sip_uri puri;
53
+
54
+   if(body->display.s && body->display.len){
55
+      flags|=HAS_DISPLAY_F;
56
+      where[i++]=(unsigned char)(body->display.s-hdrstart);
57
+      where[i++]=(unsigned char)body->display.len;
58
+   }
59
+   if(body->tag_value.s && body->tag_value.len){
60
+      flags|=HAS_TAG_F;
61
+      where[i++]=(unsigned char)(body->tag_value.s-hdrstart);
62
+      where[i++]=(unsigned char)body->tag_value.len;
63
+   }
64
+   if (parse_uri(body->uri.s, body->uri.len,&puri) < 0 ) {
65
+      LOG(L_ERR, "ERROR: encode_to_body: Bad URI in address\n");
66
+      return -1;
67
+   }else{
68
+      if((j=encode_uri2(hdrstart,hdrlen,body->uri,&puri,&where[i]))<0){
69
+	 LOG(L_ERR, "ERROR: addr2xaddr: error codifying the URI\n");
70
+	 return -1;
71
+      }else{
72
+	 i+=j;
73
+      }
74
+   }
75
+   where[0]=flags;
76
+   where[1]=(unsigned char)j;
77
+   i+=encode_parameters(&where[i],(void *)body->param_lst,hdrstart,body,'t');
78
+
79
+   return i;
80
+}
81
+
82
+int print_encoded_to_body(int fd,char *hdr,int hdrlen,unsigned char* payload,int paylen,char *prefix)
83
+{
84
+   int i=2;/* flags + urilength */
85
+   unsigned char flags=0;
86
+
87
+   flags=payload[0];
88
+   dprintf(fd,"%s",prefix);
89
+   for(i=0;i<paylen;i++)
90
+      dprintf(fd,"%s%d%s",i==0?"BODY CODE=[":":",payload[i],i==paylen-1?"]\n":"");
91
+   i=2;
92
+   if(flags & HAS_DISPLAY_F){
93
+      dprintf(fd,"%sDISPLAY NAME=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
94
+      i+=2;
95
+   }
96
+   if(flags & HAS_TAG_F){
97
+      dprintf(fd,"%sTAG=[%.*s]\n",prefix,payload[i+1],&hdr[payload[i]]);
98
+      i+=2;
99
+   }
100
+   if(print_encoded_uri(fd,&payload[i],payload[1],hdr,hdrlen,strcat(prefix,"  "))<0){
101
+      dprintf(fd,"Error parsing URI\n");
102
+      prefix[strlen(prefix)-2]=0;
103
+      return -1;
104
+   }
105
+   prefix[strlen(prefix)-2]=0;
106
+   print_encoded_parameters(fd,&payload[i+payload[1]],hdr,paylen-i-payload[1],prefix);
107
+   return 0;
108
+}
109
+
110
+/**
111
+ * dumps to FD a NBO int which is the header length, the header,
112
+ * an NBO int which is the payload length, and the payload.
113
+ *
114
+ * hdr is the header,
115
+ * hdrlen is the header length,
116
+ * payload is the payload,
117
+ * paylen is the payload length,
118
+ * fd is the file descriptor to which to dump,
119
+ * segregationLevel is wether only URIS must be dumped or all the header code.
120
+ *
121
+ * return 0 on success, <0 on error
122
+ */
123
+int dump_to_body_test(char *hdr,int hdrlen,unsigned char* payload,int paylen,int fd,char segregationLevel)
124
+{
125
+   int i=2;/* flags + urilength */
126
+   unsigned char flags=0;
127
+
128
+   flags=payload[0];
129
+   if(!segregationLevel){
130
+      return dump_standard_hdr_test(hdr,hdrlen,payload,paylen,fd);
131
+   }
132
+   i=2;
133
+   if(flags & HAS_DISPLAY_F){
134
+      i+=2;
135
+   }
136
+   if(flags & HAS_TAG_F){
137
+      i+=2;
138
+   }
139
+   if(!(segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
140
+     return dump_standard_hdr_test(hdr,hdrlen,&payload[i],payload[1],fd);
141
+   }
142
+   if((segregationLevel & JUNIT) && (segregationLevel & ONLY_URIS)){
143
+     return print_uri_junit_tests(hdr,hdrlen,&payload[i],payload[1],fd,1,"");
144
+   }
145
+   return 0;
146
+}