Browse code

- added preliminary forward request plugin support

Andrei Pelinescu-Onciul authored on 23/10/2001 19:59:08
Showing 8 changed files
... ...
@@ -4,9 +4,11 @@ $Id$
4 4
 
5 5
 - better Via parsing (handle ' ' in uri, eg: foo.bar : 1234 ; received=) and
6 6
  ipv6 addresses ([fec0:aa::01]).
7
+- fix format string vulnerability in log()
7 8
 
8 9
 High priority:
9 10
 x if () {} else {}
11
+- plugin interface
10 12
 - ipv6 support
11 13
 - reply ("response line")
12 14
 - drop ACKs for our replies
... ...
@@ -15,6 +17,7 @@ x if () {} else {}
15 17
 - add User-Agent (for the replies)
16 18
 
17 19
 Low priority:
20
+- exec improvments (add format strings to it)
18 21
 - command line switch for checking the config file syntax
19 22
 - config file version (a la sendmail)
20 23
 - loop detection
... ...
@@ -23,6 +26,7 @@ Low priority:
23 26
 
24 27
 - handle SIGCHLD, SIGHUP
25 28
 - use a  standard lex compatible .lex format (instead of flex)
29
+- try & use native compiler & ld if possible
26 30
 
27 31
 - make install
28 32
 - init.d scripts (and rc.local? for *BSD or Slackware)
29 33
new file mode 100644
... ...
@@ -0,0 +1,210 @@
1
+/* $Id$
2
+ *
3
+ */
4
+
5
+#include "data_lump.h"
6
+#include "dprint.h"
7
+
8
+#include <stdlib.h>
9
+
10
+#ifdef DEBUG_DMALLOC
11
+#include <dmalloc.h>
12
+#endif
13
+
14
+
15
+
16
+/* adds a header to the end
17
+ * returns  pointer on success, 0 on error */
18
+struct lump* append_new_lump(struct lump** list, char* new_hdr,
19
+							 int len, int type)
20
+{
21
+	struct lump** t;
22
+	struct lump* tmp;
23
+	
24
+	for (t=list;*t;t=&((*t)->next));
25
+
26
+	tmp=malloc(sizeof(struct lump));
27
+	if (tmp==0){
28
+		LOG(L_ERR, "ERROR: append_new_lump: out of memory\n");
29
+		return 0;
30
+	}
31
+		
32
+	memset(tmp,0,sizeof(struct lump));
33
+	tmp->type=type;
34
+	tmp->op=LUMP_ADD;
35
+	tmp->u.value=new_hdr;
36
+	tmp->len=len;
37
+	*t=tmp;
38
+	return tmp;
39
+}
40
+
41
+
42
+
43
+/* inserts a header to the beginning 
44
+ * returns pointer if success, 0 on error */
45
+struct lump* insert_new_lump(struct lump** list, char* new_hdr,
46
+								int len, int type)
47
+{
48
+	struct lump* tmp;
49
+
50
+	tmp=malloc(sizeof(struct lump));
51
+	if (tmp==0){
52
+		LOG(L_ERR, "ERROR: insert_new_lump: out of memory\n");
53
+		return 0;
54
+	}
55
+	memset(tmp,0,sizeof(struct lump));
56
+	tmp->next=*list;
57
+	tmp->type=type;
58
+	tmp->op=LUMP_ADD;
59
+	tmp->u.value=new_hdr;
60
+	tmp->len=len;
61
+	*list=tmp;
62
+	return tmp;
63
+}
64
+
65
+
66
+
67
+/* inserts a  header/data lump immediately after hdr 
68
+ * returns pointer on success, 0 on error */
69
+struct lump* insert_new_lump_after( struct lump* after, char* new_hdr,
70
+							int len, int type)
71
+{
72
+	struct lump* tmp;
73
+
74
+	tmp=malloc(sizeof(struct lump));
75
+	if (tmp==0){
76
+		LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n");
77
+		return 0;
78
+	}
79
+	memset(tmp,0,sizeof(struct lump));
80
+	tmp->after=after->after;
81
+	tmp->type=type;
82
+	tmp->op=LUMP_ADD;
83
+	tmp->u.value=new_hdr;
84
+	tmp->len=len;
85
+	after->after=tmp;
86
+	return tmp;
87
+}
88
+
89
+
90
+
91
+/* inserts a  header/data lump immediately before "before" 
92
+ * returns pointer on success, 0 on error */
93
+struct lump* insert_new_lump_before( struct lump* before, char* new_hdr,
94
+							int len, int type)
95
+{
96
+	struct lump* tmp;
97
+
98
+	tmp=malloc(sizeof(struct lump));
99
+	if (tmp==0){
100
+		LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n");
101
+		return 0;
102
+	}
103
+	memset(tmp,0,sizeof(struct lump));
104
+	tmp->before=before->before;
105
+	tmp->type=type;
106
+	tmp->op=LUMP_ADD;
107
+	tmp->u.value=new_hdr;
108
+	tmp->len=len;
109
+	before->before=tmp;
110
+	return tmp;
111
+}
112
+
113
+
114
+
115
+/* removes an already existing header/data lump */
116
+struct lump* del_lump(struct lump** list, int offset, int len, int type)
117
+{
118
+	struct lump* tmp;
119
+	struct lump* prev, *t;
120
+
121
+	tmp=malloc(sizeof(struct lump));
122
+	if (tmp==0){
123
+		LOG(L_ERR, "ERROR: insert_new_lump_before: out of memory\n");
124
+		return 0;
125
+	}
126
+	memset(tmp,0,sizeof(struct lump));
127
+	tmp->op=LUMP_DEL;
128
+	tmp->type=type;
129
+	tmp->u.offset=offset;
130
+	tmp->len=len;
131
+	prev=0;
132
+	for (t=*list;t; prev=t, t=t->next){
133
+		/* insert it sorted after offset */
134
+		if (((t->op==LUMP_DEL)||(t->op==LUMP_NOP))&&(t->u.offset>offset))
135
+			break;
136
+	}
137
+	tmp->next=t;
138
+	if (prev) prev->next=tmp;
139
+	else *list=tmp;
140
+	return tmp;
141
+}
142
+
143
+
144
+
145
+/* add an anhor */
146
+struct lump* anchor_lump(struct lump** list, int offset, int len, int type)
147
+{
148
+	struct lump* tmp;
149
+	struct lump* prev, *t;
150
+
151
+	tmp=malloc(sizeof(struct lump));
152
+	if (tmp==0){
153
+		LOG(L_ERR, "ERROR: insert_new_lump_before: out of memory\n");
154
+		return 0;
155
+	}
156
+	memset(tmp,0,sizeof(struct lump));
157
+	tmp->op=LUMP_NOP;
158
+	tmp->type=type;
159
+	tmp->u.offset=offset;
160
+	tmp->len=len;
161
+	prev=0;
162
+	DBG("anchor: new tmp=%x\n", tmp);
163
+	for (t=*list;t; prev=t, t=t->next){
164
+		/* insert it sorted after offset */
165
+		if (((t->op==LUMP_DEL)||(t->op==LUMP_NOP))&&(t->u.offset>offset))
166
+			break;
167
+	}
168
+	DBG("anchor: inserting it between %x and %x (*list=%x)\n", prev, t,*list);
169
+	tmp->next=t;
170
+	
171
+	if (prev) prev->next=tmp;
172
+	else *list=tmp;
173
+	return tmp;
174
+}
175
+
176
+
177
+
178
+void free_lump(struct lump* lmp)
179
+{
180
+	DBG("- free_lump(%x), op=%d\n", lmp, lmp->op);
181
+	if (lmp && (lmp->op==LUMP_ADD)){
182
+		if (lmp->u.value) free(lmp->u.value);
183
+		lmp->u.value=0;
184
+		lmp->len=0;
185
+	}
186
+	DBG("- exiting free_lump(%x)\n", lmp);
187
+}
188
+
189
+
190
+
191
+void free_lump_list(struct lump* l)
192
+{
193
+	struct lump* t, *crt;
194
+	t=l;
195
+	DBG("+ free_lump_list(%x)\n", l);
196
+	while(t){
197
+		crt=t;
198
+		t=t->next;
199
+		DBG("free_lump_list: freeing %x\n", crt);
200
+		/* dangerous recursive clean*/
201
+		if (crt->before) free_lump_list(crt->before);
202
+		if (crt->after)  free_lump_list(crt->after);
203
+		DBG("free_lump_list: back from recursive calls (%x) \n", crt);
204
+		/*clean current elem*/
205
+		free_lump(crt);
206
+		free(crt);
207
+		DBG("after free_lump_list: %x\n", crt);
208
+	}
209
+	DBG("+ exiting free_lump_list(%x)\n", l);
210
+}
0 211
new file mode 100644
... ...
@@ -0,0 +1,76 @@
1
+/*
2
+ * $Id$
3
+ *
4
+ * adding/removing headers or any other data chunk from a message
5
+ */
6
+
7
+#ifndef data_lump_h
8
+#define data_lump_h
9
+
10
+
11
+enum { LUMP_NOP=0, LUMP_DEL, LUMP_ADD };
12
+
13
+struct lump{
14
+	int type; /* VIA, OTHER, UNSPEC(=0), ... */
15
+	int op;   /* DEL, ADD, NOP, UNSPEC(=0) */
16
+	
17
+	union{
18
+		int offset; /* used for DEL, MODIFY */
19
+		char * value; /* used for ADD */
20
+	}u;
21
+	int len; /* length of this header field */
22
+	
23
+	
24
+	struct lump* before; /* list of headers to be inserted in front of the
25
+								current one */
26
+	struct lump* after; /* list of headers to be inserted immediately after
27
+							  the current one */
28
+	
29
+	struct lump* next;
30
+};
31
+
32
+/*
33
+ * hdrs must be kept sorted after their offset (DEL, NOP, UNSPEC)
34
+ * and/or their position (ADD). E.g.:
35
+ *  - to delete header Z insert it in to the list according to its offset 
36
+ *   and with op=DELETE
37
+ * - if you want to add a new header X after a  header Y, insert Y in the list
38
+ *   with op NOP and after it X (op ADD).
39
+ * - if you want X before Y, insert X in Y's before list.
40
+ * - if you want X to be the first header just put it first in hdr_lst.
41
+ *  -if you want to replace Y with X, insert Y with op=DELETE and then X with
42
+ *  op=ADD.
43
+ * before and after must contain only ADD ops!
44
+ * 
45
+ * Difference between "after" & "next" when ADDing:
46
+ * "after" forces the new header immediately after the current one while
47
+ * "next" means another header can be inserted between them.
48
+ * 
49
+ */
50
+
51
+
52
+
53
+/* adds a header to the end */
54
+struct lump* append_new_lump(struct lump** list, char* new_hdr,
55
+							 int len, int type);
56
+/* inserts a header to the beginning */
57
+struct lump* insert_new_lump(struct lump** list, char* new_hdr,
58
+							  int len, int type);
59
+struct lump* insert_new_lump_after(struct lump* after,
60
+									char* new_hdr, int len, int type);
61
+struct lump* insert_new_lump_before(struct lump* before, char* new_hdr,
62
+									int len,int type);
63
+
64
+
65
+/* removes an already existing header */
66
+struct lump* del_lump(struct lump** list, int offset, int len, int type);
67
+/* set an anchor */
68
+struct lump* anchor_lump(struct lump** list, int offset, int len, int type);
69
+
70
+
71
+/* frees the content of a lump struct */
72
+void free_lump(struct lump* l);
73
+/*frees an entire lump list, recursively */
74
+void free_lump_list(struct lump* lump_list);
75
+
76
+#endif
... ...
@@ -19,6 +19,7 @@
19 19
 #include "dprint.h"
20 20
 #include "udp_server.h"
21 21
 #include "globals.h"
22
+#include "data_lump.h"
22 23
 
23 24
 #ifdef DEBUG_DMALLOC
24 25
 #include <dmalloc.h>
... ...
@@ -68,14 +69,16 @@ int check_address(unsigned long ip, char *name, int resolver)
68 69
 int forward_request( struct sip_msg* msg, struct proxy_l * p)
69 70
 {
70 71
 	unsigned int len, new_len, via_len, received_len, uri_len;
71
-	char line_buf[MAX_VIA_LINE_SIZE];
72
-	char received_buf[MAX_RECEIVED_SIZE];
72
+	char* line_buf;
73
+	char* received_buf;
73 74
 	char* new_buf;
74 75
 	char* orig;
75 76
 	char* buf;
76 77
 	unsigned int offset, s_offset, size;
77 78
 	struct sockaddr_in* to;
78 79
 	unsigned long source_ip;
80
+	struct lump *t,*r;
81
+	struct lump* anchor;
79 82
 
80 83
 	orig=msg->orig;
81 84
 	buf=msg->buf;
... ...
@@ -83,6 +86,8 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
83 86
 	source_ip=msg->src_ip;
84 87
 	received_len=0;
85 88
 	new_buf=0;
89
+	line_buf=0;
90
+	received_buf=0;
86 91
 	to=0;
87 92
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
88 93
 	if (to==0){
... ...
@@ -90,20 +95,102 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
90 95
 		goto error;
91 96
 	}
92 97
 
98
+	line_buf=malloc(sizeof(char)*MAX_VIA_LINE_SIZE);
99
+	if (line_buf==0){
100
+		LOG(L_ERR, "ERROR: forward_request: out of memory\n");
101
+		goto error1;
102
+	}
93 103
 	via_len=snprintf(line_buf, MAX_VIA_LINE_SIZE, "Via: SIP/2.0/UDP %s:%d\r\n",
94 104
 						names[0], port_no);
95 105
 	/* check if received needs to be added */
96 106
 	if (check_address(source_ip, msg->via1.host, received_dns)!=0){
107
+		received_buf=malloc(sizeof(char)*MAX_RECEIVED_SIZE);
108
+		if (received_buf==0){
109
+			LOG(L_ERR, "ERROR: forward_request: out of memory\n");
110
+			goto error1;
111
+		}
97 112
 		received_len=snprintf(received_buf, MAX_RECEIVED_SIZE,
98 113
 								";received=%s", 
99 114
 								inet_ntoa(*(struct in_addr *)&source_ip));
100 115
 	}
101 116
 	
102
-	new_len=len+via_len+received_len;
117
+	/* add via header to the list */
118
+	/* try to add it before msg. 1st via */
119
+	DBG("forward_request: before via\n");
120
+	/*add first via, as an anchor for second via*/
121
+	anchor=anchor_lump(&(msg->add_rm), msg->via1.hdr-buf, 0, HDR_VIA);
122
+	if (anchor==0) goto error;
123
+	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA)==0)
124
+		goto error;
125
+	/* if received needs to be added, add anchor after host and add it */
126
+	if (received_len){
127
+	DBG("forward_request: adding received\n");
128
+		if (msg->via1.params){
129
+				size= msg->via1.params-msg->via1.hdr-1; /*compensate for ';' */
130
+		}else{
131
+				size= msg->via1.host-msg->via1.hdr+strlen(msg->via1.host);
132
+				if (msg->via1.port!=0){
133
+					size+=strlen(msg->via1.hdr+size+1)+1; /* +1 for ':'*/
134
+				}
135
+		}
136
+		anchor=anchor_lump(&(msg->add_rm), msg->via1.hdr-buf+size, 0, HDR_VIA);
137
+		if (anchor==0) goto error;
138
+		if (insert_new_lump_after(anchor, received_buf, received_len, HDR_VIA) 
139
+				==0 ) goto error;
140
+	}
141
+	
142
+	
143
+	/* compute new msg len*/
144
+	new_len=len;
145
+	DBG("forward_request: computing new_len\n");
146
+	for(t=msg->add_rm;t;t=t->next){
147
+		DBG("forward_request: in for t.(%x)..\n", t);
148
+		for(r=t->before;r;r=r->before){
149
+		DBG("- forward_request: in for r...\n");
150
+			switch(r->op){
151
+				case LUMP_ADD:
152
+					new_len+=r->len;
153
+					break;
154
+				default:
155
+					/* only ADD allowed for before/after */
156
+					LOG(L_CRIT, "BUG:forward_request: invalid op for"
157
+								" data lump (%x)\n", r->op);
158
+			}
159
+		}
160
+		switch(t->op){
161
+			case LUMP_ADD:
162
+				new_len+=t->len;
163
+				break;
164
+			case LUMP_DEL:
165
+				new_len-=t->len;
166
+				break;
167
+			case LUMP_NOP:
168
+				/* do nothing */
169
+				break;
170
+			debug:
171
+				LOG(L_CRIT,"BUG:forward_request: invalid" 
172
+							" op for data lump (%x)\n", r->op);
173
+		}
174
+		for (r=t->after;r;r=r->after){
175
+		DBG("- forward_request: in for2 r...\n");
176
+			switch(r->op){
177
+				case LUMP_ADD:
178
+					new_len+=r->len;
179
+					break;
180
+				default:
181
+					/* only ADD allowed for before/after */
182
+					LOG(L_CRIT, "BUG:forward_request: invalid"
183
+								" op for data lump (%x)\n", r->op);
184
+			}
185
+		}
186
+	}
187
+	
188
+	
103 189
 	if (msg->new_uri){ 
104 190
 		uri_len=strlen(msg->new_uri); 
105 191
 		new_len=new_len-strlen(msg->first_line.u.request.uri)+uri_len;
106 192
 	}
193
+	DBG("forward_request: new_len=%d\n",new_len);
107 194
 	new_buf=(char*)malloc(new_len+1);
108 195
 	if (new_buf==0){
109 196
 		LOG(L_ERR, "ERROR: forward_request: out of memory\n");
... ...
@@ -122,33 +209,71 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
122 209
 		offset+=uri_len;
123 210
 		s_offset+=strlen(msg->first_line.u.request.uri); /* skip original uri */
124 211
 	}
125
-/* copy msg till first via */
126
-	size=msg->via1.hdr-(buf+s_offset);
127
-	memcpy(new_buf+offset, orig+s_offset, size);
128
-	offset+=size;
129
-	s_offset+=size;
130
- /* add our via */
131
-	memcpy(new_buf+offset, line_buf, via_len);
132
-	offset+=via_len;
133
- /* modify original via if neccesarry (received=...)*/
134
-	if (received_len){
135
-		if (msg->via1.params){
136
-				size= msg->via1.params-msg->via1.hdr-1; /*compensate for ';' */
137
-		}else{
138
-				size= msg->via1.host-msg->via1.hdr+strlen(msg->via1.host);
139
-				if (msg->via1.port!=0){
140
-					size+=strlen(msg->via1.hdr+size+1)+1; /* +1 for ':'*/
212
+/* copy msg adding/removing lumps */
213
+	for (t=msg->add_rm;t;t=t->next){
214
+		DBG("adding/rming %x, op=%x, offset=%d\n", t, t->op, t->u.offset);
215
+		switch(t->op){
216
+			case LUMP_ADD:
217
+				/* just add it here! */
218
+				memcpy(new_buf+offset, t->u.value, t->len);
219
+				offset+=t->len;
220
+				break;
221
+			case LUMP_NOP:
222
+			case LUMP_DEL:
223
+				/* copy till offset */
224
+				if (s_offset>t->u.offset){
225
+					LOG(L_CRIT, "BUG: invalid offset in lump (%d)\n",
226
+								t->u.offset);
227
+					goto error;
228
+				}
229
+				size=t->u.offset-s_offset;
230
+				if (size){
231
+					memcpy(new_buf+offset, orig+s_offset,size);
232
+					offset+=size;
233
+					s_offset+=size;
234
+				}
235
+				/* process before  */
236
+				for(r=t->before;r;r=r->before){
237
+					switch (r->op){
238
+						case LUMP_ADD:
239
+							/*just add it here*/
240
+							memcpy(new_buf+offset, r->u.value, r->len);
241
+							offset+=r->len;
242
+							break;
243
+						defaut:
244
+							/* only ADD allowed for before/after */
245
+							LOG(L_CRIT, "BUG:forward_request: invalid op for"
246
+									" data lump (%x)\n", r->op);
247
+								
248
+					}
249
+				}
250
+				/* process main (del only) */
251
+				if (t->op==LUMP_DEL){
252
+					/* skip len bytes from orig msg */
253
+					s_offset+=t->len;
254
+				}
255
+				/* process after */
256
+				for(r=t->after;r;r=r->after){
257
+					switch (r->op){
258
+						case LUMP_ADD:
259
+							/*just add it here*/
260
+							memcpy(new_buf+offset, r->u.value, r->len);
261
+							offset+=r->len;
262
+							break;
263
+						default:
264
+							/* only ADD allowed for before/after */
265
+							LOG(L_CRIT, "BUG:forward_request: invalid op for"
266
+									" data lump (%x)\n", r->op);
267
+					}
141 268
 				}
269
+				break;
270
+			default:
271
+					LOG(L_CRIT, "BUG: forward_request: unknown op (%x)\n",
272
+							t->op);
142 273
 		}
143
-		memcpy(new_buf+offset, orig+s_offset, 
144
-								size);
145
-		offset+=size;
146
-		s_offset+=size;
147
-		memcpy(new_buf+offset, received_buf, received_len);
148
-		offset+=received_len;
149 274
 	}
150
- 	/* copy the rest of the msg */
151
- 	memcpy(new_buf+offset, orig+s_offset, len-s_offset);
275
+	/* copy the rest of the message */
276
+	memcpy(new_buf+offset, orig+s_offset, len-s_offset);
152 277
 	new_buf[new_len]=0;
153 278
 
154 279
 	 /* send it! */
... ...
@@ -178,12 +303,15 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
178 303
 
179 304
 	free(new_buf);
180 305
 	free(to);
306
+	/* received_buf & line_buf will be freed in receiv_msg by free_lump_list*/
181 307
 	return 0;
308
+error1:
309
+	if (line_buf) free(line_buf);
310
+	if (received_buf) free(received_buf);
182 311
 error:
183 312
 	if (new_buf) free(new_buf);
184 313
 	if (to) free(to);
185 314
 	return -1;
186
-
187 315
 }
188 316
 
189 317
 
... ...
@@ -276,7 +404,6 @@ int forward_reply(struct sip_msg* msg)
276 404
 	free(new_buf);
277 405
 	free(to);
278 406
 	return 0;
279
-
280 407
 error:
281 408
 	if (new_buf) free(new_buf);
282 409
 	if (to) free(to);
283 410
deleted file mode 100644
... ...
@@ -1,50 +0,0 @@
1
-/*
2
- * $Id$
3
- *
4
- * interface for modules
5
- */
6
-
7
-#ifndef mod_iface_h
8
-#define mod_iface_h
9
-
10
-
11
-struct hdr_lst{
12
-	int type; /* VIA, OTHER, UNSPEC(=0), ... */
13
-	int op;   /* DEL, ADD, NOP, UNSPEC(=0) */
14
-	
15
-	union{
16
-		int offset; /* used for DEL, MODIFY */
17
-		char * value; /* used for ADD */
18
-	}u;
19
-	int len; /* length of this header field */
20
-	
21
-	
22
-	struct hdr_lst* before; /* list of headers to be inserted in front of the
23
-								current one */
24
-	struct hdr_lst* after; /* list of headers to be inserted immediately after
25
-							  the current one */
26
-	
27
-	struct hdr_lst* next;
28
-};
29
-
30
-/*
31
- * hdrs must be kept sorted after their offset (DEL, NOP, UNSPEC)
32
- * and/or their position (ADD). E.g.:
33
- *  - to delete header Z insert it in to the list according to its offset 
34
- *   and with op=DELETE
35
- * - if you want to add a new header X after a  header Y, insert Y in the list
36
- *   with op NOP and after it X (op ADD).
37
- * - if you want X before Y, insert X in Y's before list.
38
- * - if you want X to be the first header just put it first in hdr_lst.
39
- *  -if you want to replace Y with X, insert Y with op=DELETE and then X with
40
- *  op=ADD.
41
- * before and after must contain only ADD ops!
42
- * 
43
- * Difference between "after" & "next" when ADDing:
44
- * "after" forces the new header immediately after the current one while
45
- * "next" means another header can be inserted between them.
46
- * 
47
- */
48
-
49
-
50
-#endif
... ...
@@ -6,6 +6,8 @@
6 6
 #define msg_parser_h
7 7
 
8 8
 
9
+#include "data_lump.h"
10
+
9 11
 #define SIP_REQUEST 1
10 12
 #define SIP_REPLY   2
11 13
 #define SIP_INVALID 0
... ...
@@ -75,6 +77,9 @@ struct sip_msg{
75 77
 
76 78
 	/* modifications */
77 79
 	char* new_uri; /* changed first line uri*/
80
+
81
+	struct lump* add_rm;      /* used for all the forwarded messages */
82
+	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
78 83
 	
79 84
 };
80 85
 
... ...
@@ -72,10 +72,14 @@ int receive_msg(char* buf, unsigned int len, unsigned long src_ip)
72 72
 	}
73 73
 skip:
74 74
 	if (msg.new_uri) free(msg.new_uri);
75
+	if (msg.add_rm) free_lump_list(msg.add_rm);
76
+	if (msg.repl_add_rm) free_lump_list(msg.repl_add_rm);
75 77
 	free(msg.orig);
76 78
 	return 0;
77 79
 error:
78 80
 	if (msg.new_uri) free(msg.new_uri);
81
+	if (msg.add_rm) free_lump_list(msg.add_rm);
82
+	if (msg.repl_add_rm) free_lump_list(msg.repl_add_rm);
79 83
 	free(msg.orig);
80 84
 error1:
81 85
 	return -1;
... ...
@@ -1,10 +1,10 @@
1
-debug=1			# for speed
1
+debug=9			# for speed
2 2
 check_via=0
3 3
 dns=off
4 4
 rev_dns=off
5
-fork=yes
6
-log_stderror=no
7
-children=64
5
+fork=no
6
+log_stderror=yes
7
+children=8
8 8
 
9 9
 route{
10 10