[sr-dev] git:master: modules/pua: added outbound_proxy to struct publ_info

Juha Heinanen jh at tutpro.com
Sat Oct 25 17:47:20 CEST 2014


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

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date:   Sat Oct 25 18:46:25 2014 +0300

modules/pua: added outbound_proxy to struct publ_info

---

 modules/pua/README            |   25 ++++++++++++++-----------
 modules/pua/doc/pua_admin.xml |    3 ++-
 modules/pua/doc/pua_devel.xml |    2 ++
 modules/pua/hash.h            |    2 +-
 modules/pua/send_publish.c    |   20 ++++++++++++++++++--
 modules/pua/send_publish.h    |    1 +
 6 files changed, 38 insertions(+), 15 deletions(-)

diff --git a/modules/pua/README b/modules/pua/README
index c8c7d8a..ed64a3b 100644
--- a/modules/pua/README
+++ b/modules/pua/README
@@ -8,7 +8,7 @@ Edited by
 
 Anca-Maria Vamanu
 
-   Copyright © 2006 Voice Sistem SRL
+   Copyright (c) 2006 Voice Sistem SRL
      __________________________________________________________________
 
    Table of Contents
@@ -186,7 +186,7 @@ modparam("pua", "hash_size", 11)
 
    Database url.
 
-   Default value is ">mysql://openser:openserrw@localhost/openser".
+   Default value is ">mysql://kamailio:kamailiorw@localhost/kamailio".
 
    Example 1.2. Set db_url parameter
 ...
@@ -243,7 +243,8 @@ modparam("pua", "update_period", 100)
 
 3.7. outbound_proxy (str)
 
-   SIP URI of outbound proxy to be used when sending PUBLISH requests.
+   SIP URI of outbound proxy to be used when sending PUBLISH requests if
+   no outbound proxy is given in outbound_proxy field of struct publ_info.
 
    By default, no outbound proxy has been defined.
 
@@ -334,7 +335,7 @@ modparam("pua", "fetch_rows", 1000)
 
    4.1. pua_update_contact()
 
-4.1. pua_update_contact()
+4.1.  pua_update_contact()
 
    The remote target can be updated by the Contact of a subsequent in
    dialog request. In the PUA watcher case (sending a SUBSCRIBE messages),
@@ -359,7 +360,7 @@ if(method=="NOTIFY")
 
    5.1. pua_cleanup
 
-5.1. pua_cleanup
+5.1.  pua_cleanup
 
    Manually triggers the cleanup functions for the pua table. Useful if
    you have set update_period to zero or less.
@@ -394,7 +395,7 @@ Chapter 2. Developer Guide
    The module provides the following functions that can be used by other
    Kamailio modules.
 
-1. bind_pua(pua_api_t* api)
+1.  bind_pua(pua_api_t* api)
 
    This function binds the pua modules and fills the structure with the
    two exported functions.
@@ -410,7 +411,7 @@ typedef struct pua_api {
 } pua_api_t;
 ...
 
-2. send_publish
+2.  send_publish
 
    Field type:
 ...
@@ -445,12 +446,14 @@ typedef struct publ_info
                           for that event)*/
   str* etag;          /*  (optional) the value of the etag the request
                           should match */
+  str* outbound_proxy;/*  outbound_proxy to use when sending the
+                          Publish request */
   str* extra_headers  /*  (optional) extra_headers that should be added
                           to Publish msg*/
 }publ_info_t;
 ...
 
-3. send_subscribe
+3.  send_subscribe
 
    Field type:
 ...
@@ -489,7 +492,7 @@ typedef struct subs_info
 }subs_info_t;
 ...
 
-4. is_dialog
+4.  is_dialog
 
    Field type:
 ...
@@ -508,7 +511,7 @@ typedef int  (*query_dialog_t)(ua_pres_t* presentity);
         }
 ...
 
-5. register_puacb
+5.  register_puacb
 
    Field type:
 ...
@@ -537,7 +540,7 @@ typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
 typedef int (pua_cb)(ua_pres_t* hentity, struct sip_msg*);
 ...
 
-6. add_event
+6.  add_event
 
    Field type:
 ...
diff --git a/modules/pua/doc/pua_admin.xml b/modules/pua/doc/pua_admin.xml
index f692786..e7b242d 100644
--- a/modules/pua/doc/pua_admin.xml
+++ b/modules/pua/doc/pua_admin.xml
@@ -197,7 +197,8 @@ modparam("pua", "update_period", 100)
 		<title><varname>outbound_proxy</varname> (str)</title>
 		<para>
 		SIP URI of outbound proxy to be used when sending
-		PUBLISH requests.
+		PUBLISH requests if no outbound proxy is given in
+                outbound_proxy field of struct publ_info.
 		</para>
 		<para>
 		<emphasis>By default, no outbound proxy has been defined.
diff --git a/modules/pua/doc/pua_devel.xml b/modules/pua/doc/pua_devel.xml
index 75014b4..d36c8d1 100644
--- a/modules/pua/doc/pua_devel.xml
+++ b/modules/pua/doc/pua_devel.xml
@@ -86,6 +86,8 @@ typedef struct publ_info
                           for that event)*/
   str* etag;          /*  (optional) the value of the etag the request
                           should match */
+  str* outbound_proxy;/*  outbound_proxy to use when sending the 
+                          Publish request */
   str* extra_headers  /*  (optional) extra_headers that should be added
                           to Publish msg*/
 }publ_info_t;
diff --git a/modules/pua/hash.h b/modules/pua/hash.h
index af32d13..161939b 100644
--- a/modules/pua/hash.h
+++ b/modules/pua/hash.h
@@ -81,6 +81,7 @@ typedef struct ua_pres{
 	void* cb_param;
 	struct ua_pres* next;
 	int ua_flag;
+	str* outbound_proxy; /* croc-not sored in db_only mode */
 	
 	/* publish */
 	str etag;
@@ -96,7 +97,6 @@ typedef struct ua_pres{
 	int cseq;
 	int version;
 /*  int watcher_count; croc-nolonger used!! */
-	str* outbound_proxy; /* croc-not sored in db_only mode */
 	str* extra_headers;
 	str record_route;
 	str remote_contact;
diff --git a/modules/pua/send_publish.c b/modules/pua/send_publish.c
index da74ab7..3ddd5e7 100644
--- a/modules/pua/send_publish.c
+++ b/modules/pua/send_publish.c
@@ -274,6 +274,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
 			publ.content_type= hentity->content_type;	
 			publ.id= hentity->id;
 			publ.extra_headers= hentity->extra_headers;
+			publ.outbound_proxy = hentity->outbound_proxy;
 			publ.cb_param= hentity->cb_param;
 
 			if (dbmode == PUA_DB_ONLY && pua_dbf.end_transaction)
@@ -692,8 +693,9 @@ send_publish:
 	result= tmb.t_request(&uac_r,
 			publ->pres_uri,			/*! Request-URI */
 			publ->pres_uri,			/*! To */
-			publ->pres_uri,			/*! From */
-			&outbound_proxy		/*! Outbound proxy*/
+ 		        publ->pres_uri,			/*! From */
+		        publ->outbound_proxy?
+			      publ->outbound_proxy:&outbound_proxy /*! Outbound proxy*/
 			);
 
 	if(result< 0)
@@ -757,6 +759,9 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 
 	size= sizeof(ua_pres_t)+ sizeof(str)+ (publ->pres_uri->len+ 
 		+ publ->content_type.len+ publ->id.len+ 1)*sizeof(char);
+
+	if(publ->outbound_proxy)
+		size+= sizeof(str)+ publ->outbound_proxy->len* sizeof(char);
 	if(body && body->s && body->len)
 		size+= sizeof(str)+ body->len* sizeof(char);
 	if(publ->etag)
@@ -822,6 +827,16 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 		cb_param->extra_headers->len= publ->extra_headers->len;
 		size+= publ->extra_headers->len;
 	}	
+	if(publ->outbound_proxy)
+	{
+		cb_param->outbound_proxy = (str*)((char*)cb_param + size);
+		size += sizeof(str);
+		cb_param->outbound_proxy->s = (char*)cb_param + size;
+		memcpy(cb_param->outbound_proxy->s, publ->outbound_proxy->s,
+		       publ->outbound_proxy->len);
+		cb_param->outbound_proxy->len = publ->outbound_proxy->len;
+		size+= publ->outbound_proxy->len;
+	}	
 
 	if(publ->content_type.s && publ->content_type.len)
 	{
@@ -837,6 +852,7 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
 		cb_param->tuple_id.len= tuple_id->len;
 		size+= tuple_id->len;
 	}
+
 	cb_param->event= publ->event;
 	cb_param->flag|= publ->source_flag;
 	cb_param->cb_param= publ->cb_param;
diff --git a/modules/pua/send_publish.h b/modules/pua/send_publish.h
index ef81ee9..667d7aa 100644
--- a/modules/pua/send_publish.h
+++ b/modules/pua/send_publish.h
@@ -44,6 +44,7 @@ typedef struct publ_info
 	str content_type;  /*! the content_type of the body if present(optional if the
 				same as the default value for that event) */
 	str* etag;
+	str* outbound_proxy;
 	str* extra_headers;
 	void* cb_param;   /*! the parameter for the function to be called on the callback 
 				for the received reply; it must be allocated in share memory;




More information about the sr-dev mailing list