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 108
 	struct hostent* he;
108 109
 	struct sockaddr_in* to;
109 110
 	unsigned int new_len;
111
+	struct sr_module *mod;
110 112
 #ifdef DNS_IP_HACK
111 113
 	int err;
112 114
 #endif
113 115
 
114 116
 
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 117
 
122 118
 	/*check if first via host = us */
123 119
 	if (check_via){
... ...
@@ -132,6 +128,21 @@ int forward_reply(struct sip_msg* msg)
132 128
 	}
133 129
 
134 130
 	/* here will be called the T Module !!!!!!  */
131
+	/* quick hack, slower for mutliple modules*/
132
+	for (mod=modules;mod;mod=mod->next){
133
+		if ((mod->exports) && (mod->exports->response_f)){
134
+			DBG("forward_reply: found module %s, passing reply to it\n",
135
+					mod->exports->name);
136
+			if (mod->exports->response_f(msg)==0) goto skip;
137
+		}
138
+	}
139
+	
140
+	to=0;
141
+	to=(struct sockaddr_in*)malloc(sizeof(struct sockaddr));
142
+	if (to==0){
143
+		LOG(L_ERR, "ERROR: forward_reply: out of memory\n");
144
+		goto error;
145
+	}
135 146
 
136 147
 	new_buf = build_res_buf_from_sip_res( msg, &new_len);
137 148
 	if (!new_buf){
... ...
@@ -182,6 +193,7 @@ int forward_reply(struct sip_msg* msg)
182 193
 
183 194
 	free(new_buf);
184 195
 	free(to);
196
+skip:
185 197
 	return 0;
186 198
 error:
187 199
 	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);