Browse code

- cpl-c allows you run a script route before doing relay - lookup sets a flag when fetched contact is marked as behind nat

Bogdan-Andrei Iancu authored on 28/11/2003 18:37:22
Showing 3 changed files
... ...
@@ -72,8 +72,9 @@ static char *DB_TABLE      = 0;  /* */
72 72
 static char *dtd_file      = 0;  /* name of the DTD file for CPL parser */
73 73
 static char *lookup_domain = 0;
74 74
 int    proxy_recurse       = 0;
75
-char   *log_dir            = 0;  /* dir where the user log should be dumped*/
76
-
75
+char   *log_dir            = 0;  /* dir where the user log should be dumped */
76
+int    proxy_route         = 0;  /* script route to be run before proxy */
77
+int    cpl_nat_flag        = 6;  /* flag for marking lookuped contact as NAT */
77 78
 
78 79
 static pid_t aux_process = 0;  /* pid of the private aux. process */
79 80
 int    cpl_cmd_pipe[2];
... ...
@@ -119,6 +120,8 @@ static param_export_t params[] = {
119 120
 	{"cpl_table",     STR_PARAM, &DB_TABLE      },
120 121
 	{"cpl_dtd_file",  STR_PARAM, &dtd_file      },
121 122
 	{"proxy_recurse", INT_PARAM, &proxy_recurse },
123
+	{"proxy_route",   INT_PARAM, &proxy_route   },
124
+	{"nat_flag",      INT_PARAM, &cpl_nat_flag  },
122 125
 	{"lookup_domain", STR_PARAM, &lookup_domain },
123 126
 	{"log_dir",       STR_PARAM, &log_dir       },
124 127
 	{0, 0, 0}
... ...
@@ -107,10 +107,11 @@
107 107
 	}while(0)
108 108
 
109 109
 
110
-extern char   *log_dir;
110
+extern char            *log_dir;
111 111
 extern struct tm_binds cpl_tmb;
112
-extern udomain_t*   cpl_domain;
113
-extern usrloc_api_t cpl_ulb;
112
+extern udomain_t*      cpl_domain;
113
+extern usrloc_api_t    cpl_ulb;
114
+extern int             cpl_nat_flag;
114 115
 
115 116
 
116 117
 struct cpl_interpreter* new_cpl_interpreter( struct sip_msg *msg, str *script)
... ...
@@ -290,6 +291,7 @@ static inline char *run_lookup( struct cpl_interpreter *intr )
290 291
 			while ((contact) && ((contact->expires <= tc) ||
291 292
 			(contact->state >= CS_ZOMBIE_N)))
292 293
 				contact = contact->next;
294
+			/* any contacts left? */
293 295
 			if (contact) {
294 296
 				/* clear loc set if requested */
295 297
 				if (clear)
... ...
@@ -304,6 +306,9 @@ static inline char *run_lookup( struct cpl_interpreter *intr )
304 306
 					cpl_ulb.unlock_udomain( cpl_domain );
305 307
 					goto runtime_error;
306 308
 				}
309
+				/* mark as nated */
310
+				if (contact->flags & FL_NAT)
311
+					setflag( intr->msg, cpl_nat_flag);
307 312
 				/* set the flag for modifing the location set */
308 313
 				intr->flags |= CPL_LOC_SET_MODIFIED;
309 314
 				/* we found a valid contact */
... ...
@@ -33,6 +33,7 @@
33 33
 #include "cpl_sig.h"
34 34
 
35 35
 extern struct tm_binds cpl_tmb;
36
+extern int    proxy_route;
36 37
 
37 38
 
38 39
 /* forwards the msg to the given location set; if flags has set the
... ...
@@ -89,6 +90,14 @@ int cpl_proxy_to_loc_set( struct sip_msg *msg, struct location **locs,
89 90
 		*locs = foo;
90 91
 	}
91 92
 
93
+	/* run what proxy route is set */
94
+	if (proxy_route) {
95
+		if (run_actions( rlist[proxy_route], msg)<0) {
96
+			LOG(L_ERR,"ERROR:cpl_c:cpl_proxy_to_loc_set: "
97
+				"Error in do_action for proxy_route\n");
98
+		}
99
+	}
100
+
92 101
 	/* do t_forward */
93 102
 	if (cpl_tmb.t_forward_nonack(msg, 0/*no proxy*/)==-1) {
94 103
 		LOG(L_ERR,"ERROR:cpl_c:cpl_proxy_to_loc_set: t_forward_nonack "