Module: sip-router
Branch: pd/outbound
Commit: 61674b59c6b14aded58fcd9801370b3648f9d21c
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=61674b59c6b14aded58fcd9801370b3648f9d21c

Author: Peter Dunkley <[email protected]>
Committer: Peter Dunkley <[email protected]>
Date:   Sun Aug 19 20:47:43 2012 +0100

modules_k/outbound: Started to fill in function that determines whether 
Outbound is required

---

 modules_k/outbound/ob_mod.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)

diff --git a/modules_k/outbound/ob_mod.c b/modules_k/outbound/ob_mod.c
index 57d5cf3..f561931 100644
--- a/modules_k/outbound/ob_mod.c
+++ b/modules_k/outbound/ob_mod.c
@@ -22,6 +22,7 @@
  */
 
 #include "../../dprint.h"
+#include "../../dset.h"
 #include "../../ip_addr.h"
 #include "../../mod_fix.h"
 #include "../../sr_module.h"
@@ -36,7 +37,7 @@ MODULE_VERSION
 
 static int mod_init(void);
 
-static int ob_force_bflag = -1;
+static unsigned int ob_force_bflag = (unsigned int) -1;
 static str ob_key = {0, 0};
 
 static cmd_export_t cmds[]= 
@@ -75,8 +76,13 @@ struct module_exports exports=
 
 static int mod_init(void)
 {
-       if (ob_force_bflag == -1)
-               LM_INFO("force_outbound_bflag not set\n");
+       if (ob_force_bflag == (unsigned int) -1)
+               ob_force_bflag = 0;
+       else if (ob_force_bflag >= 8 * sizeof (ob_force_bflag)) {
+               LM_ERR("force_outbound_bflag (%d) too big!\n", ob_force_bflag);
+               return -1;
+       } else
+               ob_force_bflag = 1 << ob_force_bflag;
 
        if (ob_key.s == 0)
        {
@@ -102,6 +108,18 @@ int decode_flow_token(struct receive_info *rcv, str 
flow_token)
 
 int use_outbound(struct sip_msg *msg)
 {
+       /* If Outbound is forced return success without any further checks */
+       if (isbflagset(0, ob_force_bflag) > 0)
+               return 1;
+
+       /* Use Outbound when:
+           # It's an initial request (out-of-dialog INVITE, REGISTER,
+             SUBSCRIBE, or REFER), with
+           # A single Via:, and
+           # Top Route: points to us and has ;ob parameter _OR_ Contact: has
+             ;ob parameter _OR_ it's a REGISTER with ;+sip.instance
+       */
+
        return 0;
 }
 
@@ -109,7 +127,8 @@ int bind_ob(struct ob_binds *pxb)
 {
        if (pxb == NULL)
        {
-               LM_WARN("bind_outbound: Cannot load outbound API into NULL 
pointer\n");
+               LM_WARN("bind_outbound: Cannot load outbound API into NULL "
+                       "pointer\n");
                return -1;
        }
 


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

Reply via email to