浏览代码

modules/pua: added outbound_proxy to struct publ_info

Juha Heinanen 11 年之前
父节点
当前提交
b0d089b685
共有 6 个文件被更改,包括 38 次插入15 次删除
  1. 14 11
      modules/pua/README
  2. 2 1
      modules/pua/doc/pua_admin.xml
  3. 2 0
      modules/pua/doc/pua_devel.xml
  4. 1 1
      modules/pua/hash.h
  5. 18 2
      modules/pua/send_publish.c
  6. 1 0
      modules/pua/send_publish.h

+ 14 - 11
modules/pua/README

@@ -8,7 +8,7 @@ Edited by
 
 
 Anca-Maria Vamanu
 Anca-Maria Vamanu
 
 
-   Copyright © 2006 Voice Sistem SRL
+   Copyright (c) 2006 Voice Sistem SRL
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents
@@ -186,7 +186,7 @@ modparam("pua", "hash_size", 11)
 
 
    Database url.
    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
    Example 1.2. Set db_url parameter
 ...
 ...
@@ -243,7 +243,8 @@ modparam("pua", "update_period", 100)
 
 
 3.7. outbound_proxy (str)
 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.
    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()
+4.1.  pua_update_contact()
 
 
    The remote target can be updated by the Contact of a subsequent in
    The remote target can be updated by the Contact of a subsequent in
    dialog request. In the PUA watcher case (sending a SUBSCRIBE messages),
    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
+5.1.  pua_cleanup
 
 
    Manually triggers the cleanup functions for the pua table. Useful if
    Manually triggers the cleanup functions for the pua table. Useful if
    you have set update_period to zero or less.
    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
    The module provides the following functions that can be used by other
    Kamailio modules.
    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
    This function binds the pua modules and fills the structure with the
    two exported functions.
    two exported functions.
@@ -410,7 +411,7 @@ typedef struct pua_api {
 } pua_api_t;
 } pua_api_t;
 ...
 ...
 
 
-2. send_publish
+2.  send_publish
 
 
    Field type:
    Field type:
 ...
 ...
@@ -445,12 +446,14 @@ typedef struct publ_info
                           for that event)*/
                           for that event)*/
   str* etag;          /*  (optional) the value of the etag the request
   str* etag;          /*  (optional) the value of the etag the request
                           should match */
                           should match */
+  str* outbound_proxy;/*  outbound_proxy to use when sending the
+                          Publish request */
   str* extra_headers  /*  (optional) extra_headers that should be added
   str* extra_headers  /*  (optional) extra_headers that should be added
                           to Publish msg*/
                           to Publish msg*/
 }publ_info_t;
 }publ_info_t;
 ...
 ...
 
 
-3. send_subscribe
+3.  send_subscribe
 
 
    Field type:
    Field type:
 ...
 ...
@@ -489,7 +492,7 @@ typedef struct subs_info
 }subs_info_t;
 }subs_info_t;
 ...
 ...
 
 
-4. is_dialog
+4.  is_dialog
 
 
    Field type:
    Field type:
 ...
 ...
@@ -508,7 +511,7 @@ typedef int  (*query_dialog_t)(ua_pres_t* presentity);
         }
         }
 ...
 ...
 
 
-5. register_puacb
+5.  register_puacb
 
 
    Field type:
    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*);
 typedef int (pua_cb)(ua_pres_t* hentity, struct sip_msg*);
 ...
 ...
 
 
-6. add_event
+6.  add_event
 
 
    Field type:
    Field type:
 ...
 ...

+ 2 - 1
modules/pua/doc/pua_admin.xml

@@ -197,7 +197,8 @@ modparam("pua", "update_period", 100)
 		<title><varname>outbound_proxy</varname> (str)</title>
 		<title><varname>outbound_proxy</varname> (str)</title>
 		<para>
 		<para>
 		SIP URI of outbound proxy to be used when sending
 		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>
 		<para>
 		<para>
 		<emphasis>By default, no outbound proxy has been defined.
 		<emphasis>By default, no outbound proxy has been defined.

+ 2 - 0
modules/pua/doc/pua_devel.xml

@@ -86,6 +86,8 @@ typedef struct publ_info
                           for that event)*/
                           for that event)*/
   str* etag;          /*  (optional) the value of the etag the request
   str* etag;          /*  (optional) the value of the etag the request
                           should match */
                           should match */
+  str* outbound_proxy;/*  outbound_proxy to use when sending the 
+                          Publish request */
   str* extra_headers  /*  (optional) extra_headers that should be added
   str* extra_headers  /*  (optional) extra_headers that should be added
                           to Publish msg*/
                           to Publish msg*/
 }publ_info_t;
 }publ_info_t;

+ 1 - 1
modules/pua/hash.h

@@ -81,6 +81,7 @@ typedef struct ua_pres{
 	void* cb_param;
 	void* cb_param;
 	struct ua_pres* next;
 	struct ua_pres* next;
 	int ua_flag;
 	int ua_flag;
+	str* outbound_proxy; /* croc-not sored in db_only mode */
 	
 	
 	/* publish */
 	/* publish */
 	str etag;
 	str etag;
@@ -96,7 +97,6 @@ typedef struct ua_pres{
 	int cseq;
 	int cseq;
 	int version;
 	int version;
 /*  int watcher_count; croc-nolonger used!! */
 /*  int watcher_count; croc-nolonger used!! */
-	str* outbound_proxy; /* croc-not sored in db_only mode */
 	str* extra_headers;
 	str* extra_headers;
 	str record_route;
 	str record_route;
 	str remote_contact;
 	str remote_contact;

+ 18 - 2
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.content_type= hentity->content_type;	
 			publ.id= hentity->id;
 			publ.id= hentity->id;
 			publ.extra_headers= hentity->extra_headers;
 			publ.extra_headers= hentity->extra_headers;
+			publ.outbound_proxy = hentity->outbound_proxy;
 			publ.cb_param= hentity->cb_param;
 			publ.cb_param= hentity->cb_param;
 
 
 			if (dbmode == PUA_DB_ONLY && pua_dbf.end_transaction)
 			if (dbmode == PUA_DB_ONLY && pua_dbf.end_transaction)
@@ -692,8 +693,9 @@ send_publish:
 	result= tmb.t_request(&uac_r,
 	result= tmb.t_request(&uac_r,
 			publ->pres_uri,			/*! Request-URI */
 			publ->pres_uri,			/*! Request-URI */
 			publ->pres_uri,			/*! To */
 			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)
 	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+ 
 	size= sizeof(ua_pres_t)+ sizeof(str)+ (publ->pres_uri->len+ 
 		+ publ->content_type.len+ publ->id.len+ 1)*sizeof(char);
 		+ 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)
 	if(body && body->s && body->len)
 		size+= sizeof(str)+ body->len* sizeof(char);
 		size+= sizeof(str)+ body->len* sizeof(char);
 	if(publ->etag)
 	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;
 		cb_param->extra_headers->len= publ->extra_headers->len;
 		size+= 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)
 	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;
 		cb_param->tuple_id.len= tuple_id->len;
 		size+= tuple_id->len;
 		size+= tuple_id->len;
 	}
 	}
+
 	cb_param->event= publ->event;
 	cb_param->event= publ->event;
 	cb_param->flag|= publ->source_flag;
 	cb_param->flag|= publ->source_flag;
 	cb_param->cb_param= publ->cb_param;
 	cb_param->cb_param= publ->cb_param;

+ 1 - 0
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
 	str content_type;  /*! the content_type of the body if present(optional if the
 				same as the default value for that event) */
 				same as the default value for that event) */
 	str* etag;
 	str* etag;
+	str* outbound_proxy;
 	str* extra_headers;
 	str* extra_headers;
 	void* cb_param;   /*! the parameter for the function to be called on the callback 
 	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;
 				for the received reply; it must be allocated in share memory;