Browse code

- added call to the module response functions (not tetsted).

Andrei Pelinescu-Onciul authored on 30/11/2001 17:59:26
Showing 3 changed files
... ...
@@ -23,6 +23,7 @@
23 23
 #include "ut.h"
24 24
 #include "mem.h"
25 25
 #include "msg_translator.h"
26
+#include "sr_module.h"
26 27
 
27 28
 #ifdef DEBUG_DMALLOC
28 29
 #include <dmalloc.h>
... ...
@@ -107,17 +108,12 @@ int forward_reply(struct sip_msg* msg)
107 107
 	struct hostent* he;
108 108
 	struct sockaddr_in* to;
109 109
 	unsigned int new_len;
110
+	struct sr_module *mod;
110 111
 #ifdef DNS_IP_HACK
111 112
 	int err;
112 113
 #endif
113 114
 
114 115
 
115
-	to=0;
116
-	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
117
-	if (to==0){
118
-		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
119
-		goto error;
120
-	}
121 116
 
122 117
 	/*check if first via host = us */
123 118
 	if (check_via){
... ...
@@ -132,6 +128,21 @@ int forward_reply(struct sip_msg* msg)
132 132
 	}
133 133
 
134 134
 	/* here will be called the T Module !!!!!!  */
135
+	/* quick hack, slower for mutliple modules*/
136
+	for (mod=modules;mod;mod=mod->next){
137
+		if ((mod->exports) && (mod->exports->response_f)){
138
+			DBG("forward_reply: found module %s, passing reply to it\n",
139
+					mod->exports->name);
140
+			if (mod->exports->response_f(msg)==0) goto skip;
141
+		}
142
+	}
143
+	
144
+	to=0;
145
+	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
146
+	if (to==0){
147
+		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
148
+		goto error;
149
+	}
135 150
 
136 151
 	new_buf = build_res_buf_from_sip_res( msg, &new_len);
137 152
 	if (!new_buf){
... ...
@@ -182,6 +193,7 @@ int forward_reply(struct sip_msg* msg)
182 182
 
183 183
 	free(new_buf);
184 184
 	free(to);
185
+skip:
185 186
 	return 0;
186 187
 error:
187 188
 	if (new_buf) free(new_buf);
... ...
@@ -9,7 +9,7 @@
9 9
 #include <stdlib.h>
10 10
 
11 11
 
12
-static struct sr_module* modules=0;
12
+struct sr_module* modules=0;
13 13
 
14 14
 
15 15
 
... ...
@@ -31,7 +31,8 @@ struct sr_module{
31 31
 	struct module_exports* exports;
32 32
 	struct sr_module* next;
33 33
 };
34
-
34
+ 
35
+struct sr_module* modules; /* global module list*/
35 36
 
36 37
 int load_module(char* path);
37 38
 cmd_function find_export(char* name, int param_no);