Module: sip-router
Branch: master
Commit: 8ed9165103cfe93172ee18904a2f210674edfdce
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8ed9165103cfe93172ee18904a2f210674edfdce

Author: Andrei Pelinescu-Onciul <[email protected]>
Committer: Andrei Pelinescu-Onciul <[email protected]>
Date:   Fri Sep 18 20:58:20 2009 +0200

core: send_flags support in the onsend_route

send_flags can now be set also in the onsend_route
(via set_forward_no_connect() or set_forward_close()).

E.g.:
onsend_route{
        if (dsp_ip!=10.0.0.0/8)
                set_forward_no_connect(); # don't open new connection,
                                          # only reuse
}

---

 cfg.y    |    4 ++++
 onsend.h |   12 ++++++++++++
 2 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/cfg.y b/cfg.y
index af5335c..528a70a 100644
--- a/cfg.y
+++ b/cfg.y
@@ -2053,6 +2053,10 @@ fcmd:
                                case ISFLAGSET_T:
                                case IF_T:
                                case MODULE_T:
+                               case SET_FWD_NO_CONNECT_T:
+                               case SET_RPL_NO_CONNECT_T:
+                               case SET_FWD_CLOSE_T:
+                               case SET_RPL_CLOSE_T:
                                        $$=$1;
                                        break;
                                default:
diff --git a/onsend.h b/onsend.h
index 433100d..deec874 100644
--- a/onsend.h
+++ b/onsend.h
@@ -55,6 +55,7 @@ extern struct onsend_info* p_onsend;
 
 /*
  * returns: 0 drop the message, >= ok, <0 error (but forward the message)
+ * it also migh change dst->send_flags!
  * WARNING: buf must be 0 terminated (to allow regex matches on it) */
 static inline int run_onsend(struct sip_msg* orig_msg, struct dest_info* dst,
                                                                char* buf, int 
len)
@@ -63,6 +64,8 @@ static inline int run_onsend(struct sip_msg* orig_msg, struct 
dest_info* dst,
        int ret;
        struct run_act_ctx ra_ctx;
        int backup_route_type;
+       snd_flags_t fwd_snd_flags_bak;
+       snd_flags_t rpl_snd_flags_bak;
        
        ret=1;
        if (onsend_rt.rlist[DEFAULT_RT]){
@@ -74,8 +77,17 @@ static inline int run_onsend(struct sip_msg* orig_msg, 
struct dest_info* dst,
                backup_route_type=get_route_type();
                set_route_type(ONSEND_ROUTE);
                if (exec_pre_script_cb(orig_msg, ONSEND_CB_TYPE)>0) {
+                       /* backup orig_msg send flags */
+                       fwd_snd_flags_bak=orig_msg->fwd_send_flags;
+                       rpl_snd_flags_bak=orig_msg->rpl_send_flags;
+                       orig_msg->fwd_send_flags=dst->send_flags; /* intial 
value */
                        init_run_actions_ctx(&ra_ctx);
                        ret=run_actions(&ra_ctx, onsend_rt.rlist[DEFAULT_RT], 
orig_msg);
+                       /* update dst send_flags */
+                       dst->send_flags=orig_msg->fwd_send_flags;
+                       /* restore orig_msg flags */
+                       orig_msg->fwd_send_flags=fwd_snd_flags_bak;
+                       orig_msg->rpl_send_flags=rpl_snd_flags_bak;
                        exec_post_script_cb(orig_msg, ONSEND_CB_TYPE);
                } else {
                        ret=0; /* drop the message */


_______________________________________________
sr-dev mailing list
[email protected]
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to