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 15
 - add User-Agent (for the replies)
16 16
 
17 17
 Low priority:
18
+- exec improvments (add format strings to it)
18 19
 - command line switch for checking the config file syntax
19 20
 - config file version (a la sendmail)
20 21
 - loop detection
... ...
@@ -23,6 +26,7 @@ Low priority:
23 23
 
24 24
 - handle SIGCHLD, SIGHUP
25 25
 - use a  standard lex compatible .lex format (instead of flex)
26
+- try & use native compiler & ld if possible
26 27
 
27 28
 - make install
28 29
 - init.d scripts (and rc.local? for *BSD or Slackware)
29 30
new file mode 100644
... ...
@@ -0,0 +1,210 @@
0
+/* $Id$
1
+ *
2
+ */
3
+
4
+#include "data_lump.h"
5
+#include "dprint.h"
6
+
7
+#include <stdlib.h>
8
+
9
+#ifdef DEBUG_DMALLOC
10
+#include <dmalloc.h>
11
+#endif
12
+
13
+
14
+
15
+/* adds a header to the end
16
+ * returns  pointer on success, 0 on error */
17
+struct lump* append_new_lump(struct lump** list, char* new_hdr,
18
+							 int len, int type)
19
+{
20
+	struct lump** t;
21
+	struct lump* tmp;
22
+	
23
+	for (t=list;*t;t=&((*t)->next));
24
+
25
+	tmp=malloc(sizeof(struct lump));
26
+	if (tmp==0){
27
+		LOG(L_ERR, "ERROR: append_new_lump: out of memory\n");
28
+		return 0;
29
+	}
30
+		
31
+	memset(tmp,0,sizeof(struct lump));
32
+	tmp->type=type;
33
+	tmp->op=LUMP_ADD;
34
+	tmp->u.value=new_hdr;
35
+	tmp->len=len;
36
+	*t=tmp;
37
+	return tmp;
38
+}
39
+
40
+
41
+
42
+/* inserts a header to the beginning 
43
+ * returns pointer if success, 0 on error */
44
+struct lump* insert_new_lump(struct lump** list, char* new_hdr,
45
+								int len, int type)
46
+{
47
+	struct lump* tmp;
48
+
49
+	tmp=malloc(sizeof(struct lump));
50
+	if (tmp==0){
51
+		LOG(L_ERR, "ERROR: insert_new_lump: out of memory\n");
52
+		return 0;
53
+	}
54
+	memset(tmp,0,sizeof(struct lump));
55
+	tmp->next=*list;
56
+	tmp->type=type;
57
+	tmp->op=LUMP_ADD;
58
+	tmp->u.value=new_hdr;
59
+	tmp->len=len;
60
+	*list=tmp;
61
+	return tmp;
62
+}
63
+
64
+
65
+
66
+/* inserts a  header/data lump immediately after hdr 
67
+ * returns pointer on success, 0 on error */
68
+struct lump* insert_new_lump_after( struct lump* after, char* new_hdr,
69
+							int len, int type)
70
+{
71
+	struct lump* tmp;
72
+
73
+	tmp=malloc(sizeof(struct lump));
74
+	if (tmp==0){
75
+		LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n");
76
+		return 0;
77
+	}
78
+	memset(tmp,0,sizeof(struct lump));
79
+	tmp->after=after->after;
80
+	tmp->type=type;
81
+	tmp->op=LUMP_ADD;
82
+	tmp->u.value=new_hdr;
83
+	tmp->len=len;
84
+	after->after=tmp;
85
+	return tmp;
86
+}
87
+
88
+
89
+
90
+/* inserts a  header/data lump immediately before "before" 
91
+ * returns pointer on success, 0 on error */
92
+struct lump* insert_new_lump_before( struct lump* before, char* new_hdr,
93
+							int len, int type)
94
+{
95
+	struct lump* tmp;
96
+
97
+	tmp=malloc(sizeof(struct lump));
98
+	if (tmp==0){
99
+		LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n");
100
+		return 0;
101
+	}
102
+	memset(tmp,0,sizeof(struct lump));
103
+	tmp->before=before->before;
104
+	tmp->type=type;
105
+	tmp->op=LUMP_ADD;
106
+	tmp->u.value=new_hdr;
107
+	tmp->len=len;
108
+	before->before=tmp;
109
+	return tmp;
110
+}
111
+
112
+
113
+
114
+/* removes an already existing header/data lump */
115
+struct lump* del_lump(struct lump** list, int offset, int len, int type)
116
+{
117
+	struct lump* tmp;
118
+	struct lump* prev, *t;
119
+
120
+	tmp=malloc(sizeof(struct lump));
121
+	if (tmp==0){
122
+		LOG(L_ERR, "ERROR: insert_new_lump_before: out of memory\n");
123
+		return 0;
124
+	}
125
+	memset(tmp,0,sizeof(struct lump));
126
+	tmp->op=LUMP_DEL;
127
+	tmp->type=type;
128
+	tmp->u.offset=offset;
129
+	tmp->len=len;
130
+	prev=0;
131
+	for (t=*list;t; prev=t, t=t->next){
132
+		/* insert it sorted after offset */
133
+		if (((t->op==LUMP_DEL)||(t->op==LUMP_NOP))&&(t->u.offset>offset))
134
+			break;
135
+	}
136
+	tmp->next=t;
137
+	if (prev) prev->next=tmp;
138
+	else *list=tmp;
139
+	return tmp;
140
+}
141
+
142
+
143
+
144
+/* add an anhor */
145
+struct lump* anchor_lump(struct lump** list, int offset, int len, int type)
146
+{
147
+	struct lump* tmp;
148
+	struct lump* prev, *t;
149
+
150
+	tmp=malloc(sizeof(struct lump));
151
+	if (tmp==0){
152
+		LOG(L_ERR, "ERROR: insert_new_lump_before: out of memory\n");
153
+		return 0;
154
+	}
155
+	memset(tmp,0,sizeof(struct lump));
156
+	tmp->op=LUMP_NOP;
157
+	tmp->type=type;
158
+	tmp->u.offset=offset;
159
+	tmp->len=len;
160
+	prev=0;
161
+	DBG("anchor: new tmp=%x\n", tmp);
162
+	for (t=*list;t; prev=t, t=t->next){
163
+		/* insert it sorted after offset */
164
+		if (((t->op==LUMP_DEL)||(t->op==LUMP_NOP))&&(t->u.offset>offset))
165
+			break;
166
+	}
167
+	DBG("anchor: inserting it between %x and %x (*list=%x)\n", prev, t,*list);
168
+	tmp->next=t;
169
+	
170
+	if (prev) prev->next=tmp;
171
+	else *list=tmp;
172
+	return tmp;
173
+}
174
+
175
+
176
+
177
+void free_lump(struct lump* lmp)
178
+{
179
+	DBG("- free_lump(%x), op=%d\n", lmp, lmp->op);
180
+	if (lmp && (lmp->op==LUMP_ADD)){
181
+		if (lmp->u.value) free(lmp->u.value);
182
+		lmp->u.value=0;
183
+		lmp->len=0;
184
+	}
185
+	DBG("- exiting free_lump(%x)\n", lmp);
186
+}
187
+
188
+
189
+
190
+void free_lump_list(struct lump* l)
191
+{
192
+	struct lump* t, *crt;
193
+	t=l;
194
+	DBG("+ free_lump_list(%x)\n", l);
195
+	while(t){
196
+		crt=t;
197
+		t=t->next;
198
+		DBG("free_lump_list: freeing %x\n", crt);
199
+		/* dangerous recursive clean*/
200
+		if (crt->before) free_lump_list(crt->before);
201
+		if (crt->after)  free_lump_list(crt->after);
202
+		DBG("free_lump_list: back from recursive calls (%x) \n", crt);
203
+		/*clean current elem*/
204
+		free_lump(crt);
205
+		free(crt);
206
+		DBG("after free_lump_list: %x\n", crt);
207
+	}
208
+	DBG("+ exiting free_lump_list(%x)\n", l);
209
+}
0 210
new file mode 100644
... ...
@@ -0,0 +1,76 @@
0
+/*
1
+ * $Id$
2
+ *
3
+ * adding/removing headers or any other data chunk from a message
4
+ */
5
+
6
+#ifndef data_lump_h
7
+#define data_lump_h
8
+
9
+
10
+enum { LUMP_NOP=0, LUMP_DEL, LUMP_ADD };
11
+
12
+struct lump{
13
+	int type; /* VIA, OTHER, UNSPEC(=0), ... */
14
+	int op;   /* DEL, ADD, NOP, UNSPEC(=0) */
15
+	
16
+	union{
17
+		int offset; /* used for DEL, MODIFY */
18
+		char * value; /* used for ADD */
19
+	}u;
20
+	int len; /* length of this header field */
21
+	
22
+	
23
+	struct lump* before; /* list of headers to be inserted in front of the
24
+								current one */
25
+	struct lump* after; /* list of headers to be inserted immediately after
26
+							  the current one */
27
+	
28
+	struct lump* next;
29
+};
30
+
31
+/*
32
+ * hdrs must be kept sorted after their offset (DEL, NOP, UNSPEC)
33
+ * and/or their position (ADD). E.g.:
34
+ *  - to delete header Z insert it in to the list according to its offset 
35
+ *   and with op=DELETE
36
+ * - if you want to add a new header X after a  header Y, insert Y in the list
37
+ *   with op NOP and after it X (op ADD).
38
+ * - if you want X before Y, insert X in Y's before list.
39
+ * - if you want X to be the first header just put it first in hdr_lst.
40
+ *  -if you want to replace Y with X, insert Y with op=DELETE and then X with
41
+ *  op=ADD.
42
+ * before and after must contain only ADD ops!
43
+ * 
44
+ * Difference between "after" & "next" when ADDing:
45
+ * "after" forces the new header immediately after the current one while
46
+ * "next" means another header can be inserted between them.
47
+ * 
48
+ */
49
+
50
+
51
+
52
+/* adds a header to the end */
53
+struct lump* append_new_lump(struct lump** list, char* new_hdr,
54
+							 int len, int type);
55
+/* inserts a header to the beginning */
56
+struct lump* insert_new_lump(struct lump** list, char* new_hdr,
57
+							  int len, int type);
58
+struct lump* insert_new_lump_after(struct lump* after,
59
+									char* new_hdr, int len, int type);
60
+struct lump* insert_new_lump_before(struct lump* before, char* new_hdr,
61
+									int len,int type);
62
+
63
+
64
+/* removes an already existing header */
65
+struct lump* del_lump(struct lump** list, int offset, int len, int type);
66
+/* set an anchor */
67
+struct lump* anchor_lump(struct lump** list, int offset, int len, int type);
68
+
69
+
70
+/* frees the content of a lump struct */
71
+void free_lump(struct lump* l);
72
+/*frees an entire lump list, recursively */
73
+void free_lump_list(struct lump* lump_list);
74
+
75
+#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 68
 int forward_request( struct sip_msg* msg, struct proxy_l * p)
69 69
 {
70 70
 	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];
71
+	char* line_buf;
72
+	char* received_buf;
73 73
 	char* new_buf;
74 74
 	char* orig;
75 75
 	char* buf;
76 76
 	unsigned int offset, s_offset, size;
77 77
 	struct sockaddr_in* to;
78 78
 	unsigned long source_ip;
79
+	struct lump *t,*r;
80
+	struct lump* anchor;
79 81
 
80 82
 	orig=msg->orig;
81 83
 	buf=msg->buf;
... ...
@@ -83,6 +86,8 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
83 83
 	source_ip=msg->src_ip;
84 84
 	received_len=0;
85 85
 	new_buf=0;
86
+	line_buf=0;
87
+	received_buf=0;
86 88
 	to=0;
87 89
 	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
88 90
 	if (to==0){
... ...
@@ -90,20 +95,102 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
90 90
 		goto error;
91 91
 	}
92 92
 
93
+	line_buf=malloc(sizeof(char)*MAX_VIA_LINE_SIZE);
94
+	if (line_buf==0){
95
+		LOG(L_ERR, "ERROR: forward_request: out of memory\n");
96
+		goto error1;
97
+	}
93 98
 	via_len=snprintf(line_buf, MAX_VIA_LINE_SIZE, "Via: SIP/2.0/UDP %s:%d\r\n",
94 99
 						names[0], port_no);
95 100
 	/* check if received needs to be added */
96 101
 	if (check_address(source_ip, msg->via1.host, received_dns)!=0){
102
+		received_buf=malloc(sizeof(char)*MAX_RECEIVED_SIZE);
103
+		if (received_buf==0){
104
+			LOG(L_ERR, "ERROR: forward_request: out of memory\n");
105
+			goto error1;
106
+		}
97 107
 		received_len=snprintf(received_buf, MAX_RECEIVED_SIZE,
98 108
 								";received=%s", 
99 109
 								inet_ntoa(*(struct in_addr *)&source_ip));
100 110
 	}
101 111
 	
102
-	new_len=len+via_len+received_len;
112
+	/* add via header to the list */
113
+	/* try to add it before msg. 1st via */
114
+	DBG("forward_request: before via\n");
115
+	/*add first via, as an anchor for second via*/
116
+	anchor=anchor_lump(&(msg->add_rm), msg->via1.hdr-buf, 0, HDR_VIA);
117
+	if (anchor==0) goto error;
118
+	if (insert_new_lump_before(anchor, line_buf, via_len, HDR_VIA)==0)
119
+		goto error;
120
+	/* if received needs to be added, add anchor after host and add it */
121
+	if (received_len){
122
+	DBG("forward_request: adding received\n");
123
+		if (msg->via1.params){
124
+				size= msg->via1.params-msg->via1.hdr-1; /*compensate for ';' */
125
+		}else{
126
+				size= msg->via1.host-msg->via1.hdr+strlen(msg->via1.host);
127
+				if (msg->via1.port!=0){
128
+					size+=strlen(msg->via1.hdr+size+1)+1; /* +1 for ':'*/
129
+				}
130
+		}
131
+		anchor=anchor_lump(&(msg->add_rm), msg->via1.hdr-buf+size, 0, HDR_VIA);
132
+		if (anchor==0) goto error;
133
+		if (insert_new_lump_after(anchor, received_buf, received_len, HDR_VIA) 
134
+				==0 ) goto error;
135
+	}
136
+	
137
+	
138
+	/* compute new msg len*/
139
+	new_len=len;
140
+	DBG("forward_request: computing new_len\n");
141
+	for(t=msg->add_rm;t;t=t->next){
142
+		DBG("forward_request: in for t.(%x)..\n", t);
143
+		for(r=t->before;r;r=r->before){
144
+		DBG("- forward_request: in for r...\n");
145
+			switch(r->op){
146
+				case LUMP_ADD:
147
+					new_len+=r->len;
148
+					break;
149
+				default:
150
+					/* only ADD allowed for before/after */
151
+					LOG(L_CRIT, "BUG:forward_request: invalid op for"
152
+								" data lump (%x)\n", r->op);
153
+			}
154
+		}
155
+		switch(t->op){
156
+			case LUMP_ADD:
157
+				new_len+=t->len;
158
+				break;
159
+			case LUMP_DEL:
160
+				new_len-=t->len;
161
+				break;
162
+			case LUMP_NOP:
163
+				/* do nothing */
164
+				break;
165
+			debug:
166
+				LOG(L_CRIT,"BUG:forward_request: invalid" 
167
+							" op for data lump (%x)\n", r->op);
168
+		}
169
+		for (r=t->after;r;r=r->after){
170
+		DBG("- forward_request: in for2 r...\n");
171
+			switch(r->op){
172
+				case LUMP_ADD:
173
+					new_len+=r->len;
174
+					break;
175
+				default:
176
+					/* only ADD allowed for before/after */
177
+					LOG(L_CRIT, "BUG:forward_request: invalid"
178
+								" op for data lump (%x)\n", r->op);
179
+			}
180
+		}
181
+	}
182
+	
183
+	
103 184
 	if (msg->new_uri){ 
104 185
 		uri_len=strlen(msg->new_uri); 
105 186
 		new_len=new_len-strlen(msg->first_line.u.request.uri)+uri_len;
106 187
 	}
188
+	DBG("forward_request: new_len=%d\n",new_len);
107 189
 	new_buf=(char*)malloc(new_len+1);
108 190
 	if (new_buf==0){
109 191
 		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 122
 		offset+=uri_len;
123 123
 		s_offset+=strlen(msg->first_line.u.request.uri); /* skip original uri */
124 124
 	}
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 ':'*/
125
+/* copy msg adding/removing lumps */
126
+	for (t=msg->add_rm;t;t=t->next){
127
+		DBG("adding/rming %x, op=%x, offset=%d\n", t, t->op, t->u.offset);
128
+		switch(t->op){
129
+			case LUMP_ADD:
130
+				/* just add it here! */
131
+				memcpy(new_buf+offset, t->u.value, t->len);
132
+				offset+=t->len;
133
+				break;
134
+			case LUMP_NOP:
135
+			case LUMP_DEL:
136
+				/* copy till offset */
137
+				if (s_offset>t->u.offset){
138
+					LOG(L_CRIT, "BUG: invalid offset in lump (%d)\n",
139
+								t->u.offset);
140
+					goto error;
141
+				}
142
+				size=t->u.offset-s_offset;
143
+				if (size){
144
+					memcpy(new_buf+offset, orig+s_offset,size);
145
+					offset+=size;
146
+					s_offset+=size;
147
+				}
148
+				/* process before  */
149
+				for(r=t->before;r;r=r->before){
150
+					switch (r->op){
151
+						case LUMP_ADD:
152
+							/*just add it here*/
153
+							memcpy(new_buf+offset, r->u.value, r->len);
154
+							offset+=r->len;
155
+							break;
156
+						defaut:
157
+							/* only ADD allowed for before/after */
158
+							LOG(L_CRIT, "BUG:forward_request: invalid op for"
159
+									" data lump (%x)\n", r->op);
160
+								
161
+					}
162
+				}
163
+				/* process main (del only) */
164
+				if (t->op==LUMP_DEL){
165
+					/* skip len bytes from orig msg */
166
+					s_offset+=t->len;
167
+				}
168
+				/* process after */
169
+				for(r=t->after;r;r=r->after){
170
+					switch (r->op){
171
+						case LUMP_ADD:
172
+							/*just add it here*/
173
+							memcpy(new_buf+offset, r->u.value, r->len);
174
+							offset+=r->len;
175
+							break;
176
+						default:
177
+							/* only ADD allowed for before/after */
178
+							LOG(L_CRIT, "BUG:forward_request: invalid op for"
179
+									" data lump (%x)\n", r->op);
180
+					}
141 181
 				}
182
+				break;
183
+			default:
184
+					LOG(L_CRIT, "BUG: forward_request: unknown op (%x)\n",
185
+							t->op);
142 186
 		}
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 187
 	}
150
- 	/* copy the rest of the msg */
151
- 	memcpy(new_buf+offset, orig+s_offset, len-s_offset);
188
+	/* copy the rest of the message */
189
+	memcpy(new_buf+offset, orig+s_offset, len-s_offset);
152 190
 	new_buf[new_len]=0;
153 191
 
154 192
 	 /* send it! */
... ...
@@ -178,12 +303,15 @@ int forward_request( struct sip_msg* msg, struct proxy_l * p)
178 178
 
179 179
 	free(new_buf);
180 180
 	free(to);
181
+	/* received_buf & line_buf will be freed in receiv_msg by free_lump_list*/
181 182
 	return 0;
183
+error1:
184
+	if (line_buf) free(line_buf);
185
+	if (received_buf) free(received_buf);
182 186
 error:
183 187
 	if (new_buf) free(new_buf);
184 188
 	if (to) free(to);
185 189
 	return -1;
186
-
187 190
 }
188 191
 
189 192
 
... ...
@@ -276,7 +404,6 @@ int forward_reply(struct sip_msg* msg)
276 276
 	free(new_buf);
277 277
 	free(to);
278 278
 	return 0;
279
-
280 279
 error:
281 280
 	if (new_buf) free(new_buf);
282 281
 	if (to) free(to);
283 282
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 75
 
76 76
 	/* modifications */
77 77
 	char* new_uri; /* changed first line uri*/
78
+
79
+	struct lump* add_rm;      /* used for all the forwarded messages */
80
+	struct lump* repl_add_rm; /* only for localy generated replies !!!*/
78 81
 	
79 82
 };
80 83
 
... ...
@@ -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