- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)
1 | 1 |
deleted file mode 100644 |
... | ... |
@@ -1,157 +0,0 @@ |
1 |
-/* |
|
2 |
- * Copyright (C) 2001-2003 FhG Fokus |
|
3 |
- * |
|
4 |
- * This file is part of Kamailio, a free SIP server. |
|
5 |
- * |
|
6 |
- * Kamailio is free software; you can redistribute it and/or modify |
|
7 |
- * it under the terms of the GNU General Public License as published by |
|
8 |
- * the Free Software Foundation; either version 2 of the License, or |
|
9 |
- * (at your option) any later version |
|
10 |
- * |
|
11 |
- * Kamailio is distributed in the hope that it will be useful, |
|
12 |
- * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
- * GNU General Public License for more details. |
|
15 |
- * |
|
16 |
- * You should have received a copy of the GNU General Public License |
|
17 |
- * along with this program; if not, write to the Free Software |
|
18 |
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
19 |
- * |
|
20 |
- */ |
|
21 |
-/*! |
|
22 |
- * \file |
|
23 |
- * \brief Kamailio core :: Data lump handling |
|
24 |
- * \ingroup core |
|
25 |
- * Module: \ref core |
|
26 |
- */ |
|
27 |
- |
|
28 |
- |
|
29 |
- |
|
30 |
-#include <string.h> |
|
31 |
-#include "dprint.h" |
|
32 |
-#include "mem/mem.h" |
|
33 |
-#include "data_lump_rpl.h" |
|
34 |
- |
|
35 |
- |
|
36 |
- |
|
37 |
-struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s, |
|
38 |
- int len, int flags) |
|
39 |
-{ |
|
40 |
- struct lump_rpl *lump = 0; |
|
41 |
- struct lump_rpl *foo; |
|
42 |
- struct lump_rpl** ret; |
|
43 |
- |
|
44 |
- /* some checking */ |
|
45 |
- if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY) |
|
46 |
- || (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0 || (flags&LUMP_RPL_SHMEM) ) { |
|
47 |
- LM_ERR("bad flags combination (%d)!\n",flags); |
|
48 |
- goto error; |
|
49 |
- } |
|
50 |
- if (len<=0 || s==0) { |
|
51 |
- LM_ERR("I won't add an empty lump!\n"); |
|
52 |
- goto error; |
|
53 |
- } |
|
54 |
- |
|
55 |
- /* build the lump */ |
|
56 |
- lump = (struct lump_rpl*) pkg_malloc |
|
57 |
- ( sizeof(struct lump_rpl) + ((flags&LUMP_RPL_NODUP)?0:len) ); |
|
58 |
- if (!lump) { |
|
59 |
- LM_ERR("no free pkg memory !\n"); |
|
60 |
- goto error; |
|
61 |
- } |
|
62 |
- |
|
63 |
- if (flags&LUMP_RPL_NODUP) { |
|
64 |
- lump->text.s = s; |
|
65 |
- } else { |
|
66 |
- lump->text.s = ((char*)lump)+sizeof(struct lump_rpl); |
|
67 |
- memcpy( lump->text.s, s, len); |
|
68 |
- } |
|
69 |
- lump->text.len = len; |
|
70 |
- lump->flags = flags; |
|
71 |
- lump->next = 0; |
|
72 |
- |
|
73 |
- /* add the lump to the msg */ |
|
74 |
- if (!msg->reply_lump) { |
|
75 |
- msg->reply_lump = lump; |
|
76 |
- ret=&msg->reply_lump; |
|
77 |
- }else{ |
|
78 |
- if (!(flags&LUMP_RPL_BODY)) |
|
79 |
- for(foo=msg->reply_lump;foo->next;foo=foo->next); |
|
80 |
- else |
|
81 |
- for(foo=msg->reply_lump; ;foo=foo->next) { |
|
82 |
- if (foo->flags&LUMP_RPL_BODY) { |
|
83 |
- LM_ERR("LUMP_RPL_BODY already added!\n"); |
|
84 |
- pkg_free(lump); |
|
85 |
- goto error; |
|
86 |
- } |
|
87 |
- if (foo->next==0) |
|
88 |
- break; |
|
89 |
- } |
|
90 |
- foo->next = lump; |
|
91 |
- ret= &(foo->next); |
|
92 |
- } |
|
93 |
- |
|
94 |
- return ret; |
|
95 |
-error: |
|
96 |
- return 0; |
|
97 |
-} |
|
98 |
- |
|
99 |
- |
|
100 |
- |
|
101 |
-void free_lump_rpl(struct lump_rpl* lump) |
|
102 |
-{ |
|
103 |
- if (lump) { |
|
104 |
- if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP) |
|
105 |
- && lump->text.s) { |
|
106 |
- pkg_free(lump->text.s); |
|
107 |
- lump->text.s = 0; |
|
108 |
- } |
|
109 |
- pkg_free(lump); |
|
110 |
- lump = 0; |
|
111 |
- } |
|
112 |
-} |
|
113 |
- |
|
114 |
- |
|
115 |
-void unlink_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
116 |
-{ |
|
117 |
- struct lump_rpl *foo,*prev; |
|
118 |
- |
|
119 |
- /* look for the lump to be unlink */ |
|
120 |
- foo = msg->reply_lump; |
|
121 |
- prev = 0; |
|
122 |
- while( foo && foo!=lump ) { |
|
123 |
- prev = foo; |
|
124 |
- foo = foo->next; |
|
125 |
- } |
|
126 |
- |
|
127 |
- /* if the lump was found into the list -> unlink it */ |
|
128 |
- if (foo) { |
|
129 |
- if (prev) |
|
130 |
- prev->next = foo->next; |
|
131 |
- else |
|
132 |
- msg->reply_lump = foo->next; |
|
133 |
- } |
|
134 |
-} |
|
135 |
- |
|
136 |
-void del_nonshm_lump_rpl(struct lump_rpl** list) |
|
137 |
-{ |
|
138 |
- struct lump_rpl* it, *tmp; |
|
139 |
- struct lump_rpl** pred; |
|
140 |
- |
|
141 |
- it = *list; |
|
142 |
- pred = list; |
|
143 |
- |
|
144 |
- while(it) { |
|
145 |
- if (!(it->flags & LUMP_RPL_SHMEM)) { |
|
146 |
- tmp = it; |
|
147 |
- *pred = it->next; |
|
148 |
- it = it->next; |
|
149 |
- free_lump_rpl(tmp); |
|
150 |
- continue; |
|
151 |
- } |
|
152 |
- |
|
153 |
- pred = &it->next; |
|
154 |
- it = it->next; |
|
155 |
- } |
|
156 |
-} |
|
157 |
- |
... | ... |
@@ -102,9 +102,12 @@ void free_lump_rpl(struct lump_rpl* lump) |
102 | 102 |
{ |
103 | 103 |
if (lump) { |
104 | 104 |
if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP) |
105 |
- && lump->text.s) |
|
105 |
+ && lump->text.s) { |
|
106 | 106 |
pkg_free(lump->text.s); |
107 |
+ lump->text.s = 0; |
|
108 |
+ } |
|
107 | 109 |
pkg_free(lump); |
110 |
+ lump = 0; |
|
108 | 111 |
} |
109 | 112 |
} |
110 | 113 |
|
... | ... |
@@ -8,11 +8,6 @@ |
8 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
9 | 9 |
* (at your option) any later version |
10 | 10 |
* |
11 |
- * For a license to use the Kamailio software under conditions |
|
12 |
- * other than those described here, or to purchase support for this |
|
13 |
- * software, please contact iptel.org by e-mail at the following addresses: |
|
14 |
- * info@iptel.org |
|
15 |
- * |
|
16 | 11 |
* Kamailio is distributed in the hope that it will be useful, |
17 | 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 | 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
... | ... |
@@ -25,7 +20,7 @@ |
25 | 20 |
*/ |
26 | 21 |
/*! |
27 | 22 |
* \file |
28 |
- * \brief SIP-router core :: Data lump handling |
|
23 |
+ * \brief Kamailio core :: Data lump handling |
|
29 | 24 |
* \ingroup core |
30 | 25 |
* Module: \ref core |
31 | 26 |
*/ |
... | ... |
@@ -1,22 +1,19 @@ |
1 | 1 |
/* |
2 |
- * $Id$ |
|
3 |
- * |
|
4 |
- * |
|
5 | 2 |
* Copyright (C) 2001-2003 FhG Fokus |
6 | 3 |
* |
7 |
- * This file is part of ser, a free SIP server. |
|
4 |
+ * This file is part of Kamailio, a free SIP server. |
|
8 | 5 |
* |
9 |
- * ser is free software; you can redistribute it and/or modify |
|
6 |
+ * Kamailio is free software; you can redistribute it and/or modify |
|
10 | 7 |
* it under the terms of the GNU General Public License as published by |
11 | 8 |
* the Free Software Foundation; either version 2 of the License, or |
12 | 9 |
* (at your option) any later version |
13 | 10 |
* |
14 |
- * For a license to use the ser software under conditions |
|
11 |
+ * For a license to use the Kamailio software under conditions |
|
15 | 12 |
* other than those described here, or to purchase support for this |
16 | 13 |
* software, please contact iptel.org by e-mail at the following addresses: |
17 | 14 |
* info@iptel.org |
18 | 15 |
* |
19 |
- * ser is distributed in the hope that it will be useful, |
|
16 |
+ * Kamailio is distributed in the hope that it will be useful, |
|
20 | 17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
21 | 18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22 | 19 |
* GNU General Public License for more details. |
... | ... |
@@ -25,18 +22,10 @@ |
25 | 22 |
* along with this program; if not, write to the Free Software |
26 | 23 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
27 | 24 |
* |
28 |
- * History: |
|
29 |
- * 2002-02-14 : created by bogdan |
|
30 |
- * 2003-09-11 : lump_rpl type added - LUMP_RPL_BODY & LUMP_RPL_HDR (bogdan) |
|
31 |
- * 2003-11-11 : build_lump_rpl merged into add_lump_rpl; types -> flags ; |
|
32 |
- * flags LUMP_RPL_NODUP and LUMP_RPL_NOFREE added (bogdan) |
|
33 |
- * 2006-10-16 add_lump_rpl2 added: same as the old add_lump_rpl, but |
|
34 |
- * returns a lump_rpl**, making a specific lump removal much |
|
35 |
- * more easy (andrei) |
|
36 | 25 |
*/ |
37 | 26 |
/*! |
38 | 27 |
* \file |
39 |
- * \brief SIP-router core :: |
|
28 |
+ * \brief SIP-router core :: Data lump handling |
|
40 | 29 |
* \ingroup core |
41 | 30 |
* Module: \ref core |
42 | 31 |
*/ |
... | ... |
@@ -60,11 +60,11 @@ struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s, |
60 | 60 |
/* some checking */ |
61 | 61 |
if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY) |
62 | 62 |
|| (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0 || (flags&LUMP_RPL_SHMEM) ) { |
63 |
- LOG(L_ERR,"ERROR:add_lump_rpl: bad flags combination (%d)!\n",flags); |
|
63 |
+ LM_ERR("bad flags combination (%d)!\n",flags); |
|
64 | 64 |
goto error; |
65 | 65 |
} |
66 | 66 |
if (len<=0 || s==0) { |
67 |
- LOG(L_ERR,"ERROR:add_lump_rpl: I won't add an empty lump!\n"); |
|
67 |
+ LM_ERR("I won't add an empty lump!\n"); |
|
68 | 68 |
goto error; |
69 | 69 |
} |
70 | 70 |
|
... | ... |
@@ -72,7 +72,7 @@ struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s, |
72 | 72 |
lump = (struct lump_rpl*) pkg_malloc |
73 | 73 |
( sizeof(struct lump_rpl) + ((flags&LUMP_RPL_NODUP)?0:len) ); |
74 | 74 |
if (!lump) { |
75 |
- LOG(L_ERR,"ERROR:add_lump_rpl : no free pkg memory !\n"); |
|
75 |
+ LM_ERR("no free pkg memory !\n"); |
|
76 | 76 |
goto error; |
77 | 77 |
} |
78 | 78 |
|
... | ... |
@@ -96,8 +96,7 @@ struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s, |
96 | 96 |
else |
97 | 97 |
for(foo=msg->reply_lump; ;foo=foo->next) { |
98 | 98 |
if (foo->flags&LUMP_RPL_BODY) { |
99 |
- LOG(L_ERR,"ERROR:add_lump_rpl: LUMP_RPL_BODY " |
|
100 |
- "already added!\n"); |
|
99 |
+ LM_ERR("LUMP_RPL_BODY already added!\n"); |
|
101 | 100 |
pkg_free(lump); |
102 | 101 |
goto error; |
103 | 102 |
} |
... | ... |
@@ -23,7 +23,7 @@ |
23 | 23 |
* |
24 | 24 |
* You should have received a copy of the GNU General Public License |
25 | 25 |
* along with this program; if not, write to the Free Software |
26 |
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
26 |
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
|
27 | 27 |
* |
28 | 28 |
* History: |
29 | 29 |
* 2002-02-14 : created by bogdan |
Please fill in after the :: to explain the function of this file.
... | ... |
@@ -30,6 +30,9 @@ |
30 | 30 |
* 2003-09-11 : lump_rpl type added - LUMP_RPL_BODY & LUMP_RPL_HDR (bogdan) |
31 | 31 |
* 2003-11-11 : build_lump_rpl merged into add_lump_rpl; types -> flags ; |
32 | 32 |
* flags LUMP_RPL_NODUP and LUMP_RPL_NOFREE added (bogdan) |
33 |
+ * 2006-10-16 add_lump_rpl2 added: same as the old add_lump_rpl, but |
|
34 |
+ * returns a lump_rpl**, making a specific lump removal much |
|
35 |
+ * more easy (andrei) |
|
33 | 36 |
*/ |
34 | 37 |
|
35 | 38 |
|
... | ... |
@@ -40,10 +43,12 @@ |
40 | 43 |
|
41 | 44 |
|
42 | 45 |
|
43 |
-struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags) |
|
46 |
+struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s, |
|
47 |
+ int len, int flags) |
|
44 | 48 |
{ |
45 | 49 |
struct lump_rpl *lump = 0; |
46 | 50 |
struct lump_rpl *foo; |
51 |
+ struct lump_rpl** ret; |
|
47 | 52 |
|
48 | 53 |
/* some checking */ |
49 | 54 |
if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY) |
... | ... |
@@ -77,6 +82,7 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags) |
77 | 82 |
/* add the lump to the msg */ |
78 | 83 |
if (!msg->reply_lump) { |
79 | 84 |
msg->reply_lump = lump; |
85 |
+ ret=&msg->reply_lump; |
|
80 | 86 |
}else{ |
81 | 87 |
if (!(flags&LUMP_RPL_BODY)) |
82 | 88 |
for(foo=msg->reply_lump;foo->next;foo=foo->next); |
... | ... |
@@ -92,9 +98,10 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags) |
92 | 98 |
break; |
93 | 99 |
} |
94 | 100 |
foo->next = lump; |
101 |
+ ret= &(foo->next); |
|
95 | 102 |
} |
96 | 103 |
|
97 |
- return lump; |
|
104 |
+ return ret; |
|
98 | 105 |
error: |
99 | 106 |
return 0; |
100 | 107 |
} |
... | ... |
@@ -133,17 +133,25 @@ void unlink_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
133 | 133 |
} |
134 | 134 |
} |
135 | 135 |
|
136 |
- |
|
137 |
- |
|
138 |
-void del_nonshm_lump_rpl( struct lump_rpl **head_list) |
|
136 |
+void del_nonshm_lump_rpl(struct lump_rpl** list) |
|
139 | 137 |
{ |
140 |
- struct lump_rpl *foo; |
|
141 |
- |
|
142 |
- while( (*head_list) && (((*head_list)->flags&LUMP_RPL_SHMEM)==0) ) { |
|
143 |
- foo = (*head_list); |
|
144 |
- (*head_list) = foo->next; |
|
145 |
- free_lump_rpl( foo ); |
|
146 |
- } |
|
138 |
+ struct lump_rpl* it, *tmp; |
|
139 |
+ struct lump_rpl** pred; |
|
140 |
+ |
|
141 |
+ it = *list; |
|
142 |
+ pred = list; |
|
143 |
+ |
|
144 |
+ while(it) { |
|
145 |
+ if (!(it->flags & LUMP_RPL_SHMEM)) { |
|
146 |
+ tmp = it; |
|
147 |
+ *pred = it->next; |
|
148 |
+ it = it->next; |
|
149 |
+ free_lump_rpl(tmp); |
|
150 |
+ continue; |
|
151 |
+ } |
|
152 |
+ |
|
153 |
+ pred = &it->next; |
|
154 |
+ it = it->next; |
|
155 |
+ } |
|
147 | 156 |
} |
148 | 157 |
|
149 |
- |
... | ... |
@@ -2,7 +2,7 @@ |
2 | 2 |
* $Id$ |
3 | 3 |
* |
4 | 4 |
* |
5 |
- * Copyright (C) 2001-2003 Fhg Fokus |
|
5 |
+ * Copyright (C) 2001-2003 FhG Fokus |
|
6 | 6 |
* |
7 | 7 |
* This file is part of ser, a free SIP server. |
8 | 8 |
* |
... | ... |
@@ -45,7 +45,7 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags) |
45 | 45 |
struct lump_rpl *lump = 0; |
46 | 46 |
struct lump_rpl *foo; |
47 | 47 |
|
48 |
- /* some checkings */ |
|
48 |
+ /* some checking */ |
|
49 | 49 |
if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY) |
50 | 50 |
|| (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0 || (flags&LUMP_RPL_SHMEM) ) { |
51 | 51 |
LOG(L_ERR,"ERROR:add_lump_rpl: bad flags combination (%d)!\n",flags); |
... | ... |
@@ -47,8 +47,8 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags) |
47 | 47 |
|
48 | 48 |
/* some checkings */ |
49 | 49 |
if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY) |
50 |
- || (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0) { |
|
51 |
- LOG(L_ERR,"ERROR:add_lump_rpl: bad type flags (none or both)!\n"); |
|
50 |
+ || (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0 || (flags&LUMP_RPL_SHMEM) ) { |
|
51 |
+ LOG(L_ERR,"ERROR:add_lump_rpl: bad flags combination (%d)!\n",flags); |
|
52 | 52 |
goto error; |
53 | 53 |
} |
54 | 54 |
if (len<=0 || s==0) { |
... | ... |
@@ -101,7 +101,7 @@ error: |
101 | 101 |
|
102 | 102 |
|
103 | 103 |
|
104 |
-void free_lump_rpl(struct lump_rpl* lump) |
|
104 |
+inline void free_lump_rpl(struct lump_rpl* lump) |
|
105 | 105 |
{ |
106 | 106 |
if (lump) { |
107 | 107 |
if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP) |
... | ... |
@@ -134,3 +134,16 @@ void unlink_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
134 | 134 |
} |
135 | 135 |
|
136 | 136 |
|
137 |
+ |
|
138 |
+void del_nonshm_lump_rpl( struct lump_rpl **head_list) |
|
139 |
+{ |
|
140 |
+ struct lump_rpl *foo; |
|
141 |
+ |
|
142 |
+ while( (*head_list) && (((*head_list)->flags&LUMP_RPL_SHMEM)==0) ) { |
|
143 |
+ foo = (*head_list); |
|
144 |
+ (*head_list) = foo->next; |
|
145 |
+ free_lump_rpl( foo ); |
|
146 |
+ } |
|
147 |
+} |
|
148 |
+ |
|
149 |
+ |
... | ... |
@@ -81,13 +81,16 @@ struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags) |
81 | 81 |
if (!(flags&LUMP_RPL_BODY)) |
82 | 82 |
for(foo=msg->reply_lump;foo->next;foo=foo->next); |
83 | 83 |
else |
84 |
- for(foo=msg->reply_lump;foo->next;foo=foo->next) |
|
85 |
- if (lump->flags&LUMP_RPL_BODY) { |
|
84 |
+ for(foo=msg->reply_lump; ;foo=foo->next) { |
|
85 |
+ if (foo->flags&LUMP_RPL_BODY) { |
|
86 | 86 |
LOG(L_ERR,"ERROR:add_lump_rpl: LUMP_RPL_BODY " |
87 | 87 |
"already added!\n"); |
88 | 88 |
pkg_free(lump); |
89 | 89 |
goto error; |
90 | 90 |
} |
91 |
+ if (foo->next==0) |
|
92 |
+ break; |
|
93 |
+ } |
|
91 | 94 |
foo->next = lump; |
92 | 95 |
} |
93 | 96 |
|
... | ... |
@@ -24,6 +24,12 @@ |
24 | 24 |
* You should have received a copy of the GNU General Public License |
25 | 25 |
* along with this program; if not, write to the Free Software |
26 | 26 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
27 |
+ * |
|
28 |
+ * History: |
|
29 |
+ * 2002-02-14 : created by bogdan |
|
30 |
+ * 2003-09-11 : lump_rpl type added - LUMP_RPL_BODY & LUMP_RPL_HDR (bogdan) |
|
31 |
+ * 2003-11-11 : build_lump_rpl merged into add_lump_rpl; types -> flags ; |
|
32 |
+ * flags LUMP_RPL_NODUP and LUMP_RPL_NOFREE added (bogdan) |
|
27 | 33 |
*/ |
28 | 34 |
|
29 | 35 |
|
... | ... |
@@ -33,62 +39,60 @@ |
33 | 39 |
#include "data_lump_rpl.h" |
34 | 40 |
|
35 | 41 |
|
36 |
-struct lump_rpl* build_lump_rpl( char* text, int len , int type) |
|
42 |
+ |
|
43 |
+struct lump_rpl* add_lump_rpl(struct sip_msg *msg, char *s, int len, int flags) |
|
37 | 44 |
{ |
38 | 45 |
struct lump_rpl *lump = 0; |
46 |
+ struct lump_rpl *foo; |
|
39 | 47 |
|
40 |
- lump = (struct lump_rpl*) pkg_malloc(sizeof(struct lump_rpl)); |
|
41 |
- if (!lump) |
|
42 |
- { |
|
43 |
- LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (struct)!\n"); |
|
48 |
+ /* some checkings */ |
|
49 |
+ if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY) |
|
50 |
+ || (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0) { |
|
51 |
+ LOG(L_ERR,"ERROR:add_lump_rpl: bad type flags (none or both)!\n"); |
|
52 |
+ goto error; |
|
53 |
+ } |
|
54 |
+ if (len<=0 || s==0) { |
|
55 |
+ LOG(L_ERR,"ERROR:add_lump_rpl: I won't add an empty lump!\n"); |
|
44 | 56 |
goto error; |
45 | 57 |
} |
46 | 58 |
|
47 |
- lump->text.s = pkg_malloc( len ); |
|
48 |
- if (!lump->text.s) |
|
49 |
- { |
|
50 |
- LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (%d)!\n", len ); |
|
59 |
+ /* build the lump */ |
|
60 |
+ lump = (struct lump_rpl*) pkg_malloc |
|
61 |
+ ( sizeof(struct lump_rpl) + ((flags&LUMP_RPL_NODUP)?0:len) ); |
|
62 |
+ if (!lump) { |
|
63 |
+ LOG(L_ERR,"ERROR:add_lump_rpl : no free pkg memory !\n"); |
|
51 | 64 |
goto error; |
52 | 65 |
} |
53 | 66 |
|
54 |
- memcpy(lump->text.s,text,len); |
|
67 |
+ if (flags&LUMP_RPL_NODUP) { |
|
68 |
+ lump->text.s = s; |
|
69 |
+ } else { |
|
70 |
+ lump->text.s = ((char*)lump)+sizeof(struct lump_rpl); |
|
71 |
+ memcpy( lump->text.s, s, len); |
|
72 |
+ } |
|
55 | 73 |
lump->text.len = len; |
56 |
- lump->type = type; |
|
74 |
+ lump->flags = flags; |
|
57 | 75 |
lump->next = 0; |
58 | 76 |
|
59 |
- return lump; |
|
60 |
- |
|
61 |
-error: |
|
62 |
- if (lump) pkg_free(lump); |
|
63 |
- return 0; |
|
64 |
-} |
|
65 |
- |
|
66 |
- |
|
67 |
- |
|
68 |
-int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
69 |
-{ |
|
70 |
- struct lump_rpl *foo; |
|
71 |
- |
|
72 |
- if (lump==0 || lump->text.s==0 || lump->text.len==0) { |
|
73 |
- LOG(L_ERR,"ERROR:add_lump_rpl: I won't add an empty lump!\n"); |
|
74 |
- return -1; |
|
75 |
- } |
|
76 |
- |
|
77 |
- if (!msg->reply_lump) |
|
78 |
- { |
|
77 |
+ /* add the lump to the msg */ |
|
78 |
+ if (!msg->reply_lump) { |
|
79 | 79 |
msg->reply_lump = lump; |
80 | 80 |
}else{ |
81 |
- if (lump->type!=LUMP_RPL_BODY) |
|
81 |
+ if (!(flags&LUMP_RPL_BODY)) |
|
82 | 82 |
for(foo=msg->reply_lump;foo->next;foo=foo->next); |
83 | 83 |
else |
84 | 84 |
for(foo=msg->reply_lump;foo->next;foo=foo->next) |
85 |
- if (lump->type==LUMP_RPL_BODY) { |
|
85 |
+ if (lump->flags&LUMP_RPL_BODY) { |
|
86 | 86 |
LOG(L_ERR,"ERROR:add_lump_rpl: LUMP_RPL_BODY " |
87 | 87 |
"already added!\n"); |
88 |
- return -1; |
|
88 |
+ pkg_free(lump); |
|
89 |
+ goto error; |
|
89 | 90 |
} |
90 | 91 |
foo->next = lump; |
91 | 92 |
} |
93 |
+ |
|
94 |
+ return lump; |
|
95 |
+error: |
|
92 | 96 |
return 0; |
93 | 97 |
} |
94 | 98 |
|
... | ... |
@@ -96,8 +100,12 @@ int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
96 | 100 |
|
97 | 101 |
void free_lump_rpl(struct lump_rpl* lump) |
98 | 102 |
{ |
99 |
- if (lump && lump->text.s) pkg_free(lump->text.s); |
|
100 |
- if (lump) pkg_free(lump); |
|
103 |
+ if (lump) { |
|
104 |
+ if (!((lump->flags)&LUMP_RPL_NOFREE) && ((lump->flags)&LUMP_RPL_NODUP) |
|
105 |
+ && lump->text.s) |
|
106 |
+ pkg_free(lump->text.s); |
|
107 |
+ pkg_free(lump); |
|
108 |
+ } |
|
101 | 109 |
} |
102 | 110 |
|
103 | 111 |
|
... | ... |
@@ -69,7 +69,7 @@ int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
69 | 69 |
{ |
70 | 70 |
struct lump_rpl *foo; |
71 | 71 |
|
72 |
- if (lump->text.s==0 || lump->text.len==0) { |
|
72 |
+ if (lump==0 || lump->text.s==0 || lump->text.len==0) { |
|
73 | 73 |
LOG(L_ERR,"ERROR:add_lump_rpl: I won't add an empty lump!\n"); |
74 | 74 |
return -1; |
75 | 75 |
} |
... | ... |
@@ -69,6 +69,11 @@ int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
69 | 69 |
{ |
70 | 70 |
struct lump_rpl *foo; |
71 | 71 |
|
72 |
+ if (lump->text.s==0 || lump->text.len==0) { |
|
73 |
+ LOG(L_ERR,"ERROR:add_lump_rpl: I won't add an empty lump!\n"); |
|
74 |
+ return -1; |
|
75 |
+ } |
|
76 |
+ |
|
72 | 77 |
if (!msg->reply_lump) |
73 | 78 |
{ |
74 | 79 |
msg->reply_lump = lump; |
... | ... |
@@ -33,7 +33,7 @@ |
33 | 33 |
#include "data_lump_rpl.h" |
34 | 34 |
|
35 | 35 |
|
36 |
-struct lump_rpl* build_lump_rpl( char* text, int len ) |
|
36 |
+struct lump_rpl* build_lump_rpl( char* text, int len , int type) |
|
37 | 37 |
{ |
38 | 38 |
struct lump_rpl *lump = 0; |
39 | 39 |
|
... | ... |
@@ -53,6 +53,7 @@ struct lump_rpl* build_lump_rpl( char* text, int len ) |
53 | 53 |
|
54 | 54 |
memcpy(lump->text.s,text,len); |
55 | 55 |
lump->text.len = len; |
56 |
+ lump->type = type; |
|
56 | 57 |
lump->next = 0; |
57 | 58 |
|
58 | 59 |
return lump; |
... | ... |
@@ -64,7 +65,7 @@ error: |
64 | 65 |
|
65 | 66 |
|
66 | 67 |
|
67 |
-void add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
68 |
+int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
68 | 69 |
{ |
69 | 70 |
struct lump_rpl *foo; |
70 | 71 |
|
... | ... |
@@ -72,9 +73,18 @@ void add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
72 | 73 |
{ |
73 | 74 |
msg->reply_lump = lump; |
74 | 75 |
}else{ |
75 |
- for(foo=msg->reply_lump;foo->next;foo=foo->next); |
|
76 |
+ if (lump->type!=LUMP_RPL_BODY) |
|
77 |
+ for(foo=msg->reply_lump;foo->next;foo=foo->next); |
|
78 |
+ else |
|
79 |
+ for(foo=msg->reply_lump;foo->next;foo=foo->next) |
|
80 |
+ if (lump->type==LUMP_RPL_BODY) { |
|
81 |
+ LOG(L_ERR,"ERROR:add_lump_rpl: LUMP_RPL_BODY " |
|
82 |
+ "already added!\n"); |
|
83 |
+ return -1; |
|
84 |
+ } |
|
76 | 85 |
foo->next = lump; |
77 | 86 |
} |
87 |
+ return 0; |
|
78 | 88 |
} |
79 | 89 |
|
80 | 90 |
|
... | ... |
@@ -86,4 +96,25 @@ void free_lump_rpl(struct lump_rpl* lump) |
86 | 96 |
} |
87 | 97 |
|
88 | 98 |
|
99 |
+void unlink_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
100 |
+{ |
|
101 |
+ struct lump_rpl *foo,*prev; |
|
102 |
+ |
|
103 |
+ /* look for the lump to be unlink */ |
|
104 |
+ foo = msg->reply_lump; |
|
105 |
+ prev = 0; |
|
106 |
+ while( foo && foo!=lump ) { |
|
107 |
+ prev = foo; |
|
108 |
+ foo = foo->next; |
|
109 |
+ } |
|
110 |
+ |
|
111 |
+ /* if the lump was found into the list -> unlink it */ |
|
112 |
+ if (foo) { |
|
113 |
+ if (prev) |
|
114 |
+ prev->next = foo->next; |
|
115 |
+ else |
|
116 |
+ msg->reply_lump = foo->next; |
|
117 |
+ } |
|
118 |
+} |
|
119 |
+ |
|
89 | 120 |
|
... | ... |
@@ -1,8 +1,32 @@ |
1 | 1 |
/* |
2 | 2 |
* $Id$ |
3 | 3 |
* |
4 |
+ * |
|
5 |
+ * Copyright (C) 2001-2003 Fhg Fokus |
|
6 |
+ * |
|
7 |
+ * This file is part of ser, a free SIP server. |
|
8 |
+ * |
|
9 |
+ * ser is free software; you can redistribute it and/or modify |
|
10 |
+ * it under the terms of the GNU General Public License as published by |
|
11 |
+ * the Free Software Foundation; either version 2 of the License, or |
|
12 |
+ * (at your option) any later version |
|
13 |
+ * |
|
14 |
+ * For a license to use the ser software under conditions |
|
15 |
+ * other than those described here, or to purchase support for this |
|
16 |
+ * software, please contact iptel.org by e-mail at the following addresses: |
|
17 |
+ * info@iptel.org |
|
18 |
+ * |
|
19 |
+ * ser is distributed in the hope that it will be useful, |
|
20 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
21 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
22 |
+ * GNU General Public License for more details. |
|
23 |
+ * |
|
24 |
+ * You should have received a copy of the GNU General Public License |
|
25 |
+ * along with this program; if not, write to the Free Software |
|
26 |
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
4 | 27 |
*/ |
5 | 28 |
|
29 |
+ |
|
6 | 30 |
#include <string.h> |
7 | 31 |
#include "dprint.h" |
8 | 32 |
#include "mem/mem.h" |
... | ... |
@@ -12,14 +12,14 @@ struct lump_rpl* build_lump_rpl( char* text, int len ) |
12 | 12 |
lump = (struct lump_rpl*) pkg_malloc(sizeof(struct lump_rpl)); |
13 | 13 |
if (!lump) |
14 | 14 |
{ |
15 |
- LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n"); |
|
15 |
+ LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (struct)!\n"); |
|
16 | 16 |
goto error; |
17 | 17 |
} |
18 | 18 |
|
19 | 19 |
lump->text.s = pkg_malloc( len ); |
20 | 20 |
if (!lump->text.s) |
21 | 21 |
{ |
22 |
- LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n"); |
|
22 |
+ LOG(L_ERR,"ERROR:build_lump_rpl : no free memory (%d)!\n", len ); |
|
23 | 23 |
goto error; |
24 | 24 |
} |
25 | 25 |
|
... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
|
2 |
- |
|
2 |
+#include <string.h> |
|
3 | 3 |
#include "dprint.h" |
4 | 4 |
#include "mem/mem.h" |
5 | 5 |
#include "data_lump_rpl.h" |
... | ... |
@@ -36,7 +36,7 @@ error: |
36 | 36 |
|
37 | 37 |
|
38 | 38 |
|
39 |
-int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
39 |
+void add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
40 | 40 |
{ |
41 | 41 |
struct lump_rpl *foo; |
42 | 42 |
|
... | ... |
@@ -51,7 +51,7 @@ int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
51 | 51 |
|
52 | 52 |
|
53 | 53 |
|
54 |
-int free_lump_rpl(struct lump_rpl* lump) |
|
54 |
+void free_lump_rpl(struct lump_rpl* lump) |
|
55 | 55 |
{ |
56 | 56 |
if (lump && lump->text.s) pkg_free(lump->text.s); |
57 | 57 |
if (lump) pkg_free(lump); |
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,61 @@ |
1 |
+ |
|
2 |
+ |
|
3 |
+#include "dprint.h" |
|
4 |
+#include "mem/mem.h" |
|
5 |
+#include "data_lump_rpl.h" |
|
6 |
+ |
|
7 |
+ |
|
8 |
+struct lump_rpl* build_lump_rpl( char* text, int len ) |
|
9 |
+{ |
|
10 |
+ struct lump_rpl *lump = 0; |
|
11 |
+ |
|
12 |
+ lump = (struct lump_rpl*) pkg_malloc(sizeof(struct lump_rpl)); |
|
13 |
+ if (!lump) |
|
14 |
+ { |
|
15 |
+ LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n"); |
|
16 |
+ goto error; |
|
17 |
+ } |
|
18 |
+ |
|
19 |
+ lump->text.s = pkg_malloc( len ); |
|
20 |
+ if (!lump->text.s) |
|
21 |
+ { |
|
22 |
+ LOG(L_ERR,"ERROR:build_lump_rpl : no free memory!\n"); |
|
23 |
+ goto error; |
|
24 |
+ } |
|
25 |
+ |
|
26 |
+ memcpy(lump->text.s,text,len); |
|
27 |
+ lump->text.len = len; |
|
28 |
+ lump->next = 0; |
|
29 |
+ |
|
30 |
+ return lump; |
|
31 |
+ |
|
32 |
+error: |
|
33 |
+ if (lump) pkg_free(lump); |
|
34 |
+ return 0; |
|
35 |
+} |
|
36 |
+ |
|
37 |
+ |
|
38 |
+ |
|
39 |
+int add_lump_rpl(struct sip_msg * msg, struct lump_rpl* lump) |
|
40 |
+{ |
|
41 |
+ struct lump_rpl *foo; |
|
42 |
+ |
|
43 |
+ if (!msg->reply_lump) |
|
44 |
+ { |
|
45 |
+ msg->reply_lump = lump; |
|
46 |
+ }else{ |
|
47 |
+ for(foo=msg->reply_lump;foo->next;foo=foo->next); |
|
48 |
+ foo->next = lump; |
|
49 |
+ } |
|
50 |
+} |
|
51 |
+ |
|
52 |
+ |
|
53 |
+ |
|
54 |
+int free_lump_rpl(struct lump_rpl* lump) |
|
55 |
+{ |
|
56 |
+ if (lump && lump->text.s) pkg_free(lump->text.s); |
|
57 |
+ if (lump) pkg_free(lump); |
|
58 |
+} |
|
59 |
+ |
|
60 |
+ |
|
61 |
+ |