Browse code

modules/pua: added outbound_proxy to struct publ_info

Juha Heinanen authored on 25/10/2014 15:46:25
Showing 6 changed files
... ...
@@ -8,7 +8,7 @@ Edited by
8 8
 
9 9
 Anca-Maria Vamanu
10 10
 
11
-   Copyright � 2006 Voice Sistem SRL
11
+   Copyright (c) 2006 Voice Sistem SRL
12 12
      __________________________________________________________________
13 13
 
14 14
    Table of Contents
... ...
@@ -186,7 +186,7 @@ modparam("pua", "hash_size", 11)
186 186
 
187 187
    Database url.
188 188
 
189
-   Default value is ">mysql://openser:openserrw@localhost/openser".
189
+   Default value is ">mysql://kamailio:kamailiorw@localhost/kamailio".
190 190
 
191 191
    Example 1.2. Set db_url parameter
192 192
 ...
... ...
@@ -243,7 +243,8 @@ modparam("pua", "update_period", 100)
243 243
 
244 244
 3.7. outbound_proxy (str)
245 245
 
246
-   SIP URI of outbound proxy to be used when sending PUBLISH requests.
246
+   SIP URI of outbound proxy to be used when sending PUBLISH requests if
247
+   no outbound proxy is given in outbound_proxy field of struct publ_info.
247 248
 
248 249
    By default, no outbound proxy has been defined.
249 250
 
... ...
@@ -334,7 +335,7 @@ modparam("pua", "fetch_rows", 1000)
334 335
 
335 336
    4.1. pua_update_contact()
336 337
 
337
-4.1. pua_update_contact()
338
+4.1.  pua_update_contact()
338 339
 
339 340
    The remote target can be updated by the Contact of a subsequent in
340 341
    dialog request. In the PUA watcher case (sending a SUBSCRIBE messages),
... ...
@@ -359,7 +360,7 @@ if(method=="NOTIFY")
359 360
 
360 361
    5.1. pua_cleanup
361 362
 
362
-5.1. pua_cleanup
363
+5.1.  pua_cleanup
363 364
 
364 365
    Manually triggers the cleanup functions for the pua table. Useful if
365 366
    you have set update_period to zero or less.
... ...
@@ -394,7 +395,7 @@ Chapter 2. Developer Guide
394 395
    The module provides the following functions that can be used by other
395 396
    Kamailio modules.
396 397
 
397
-1. bind_pua(pua_api_t* api)
398
+1.  bind_pua(pua_api_t* api)
398 399
 
399 400
    This function binds the pua modules and fills the structure with the
400 401
    two exported functions.
... ...
@@ -410,7 +411,7 @@ typedef struct pua_api {
410 411
 } pua_api_t;
411 412
 ...
412 413
 
413
-2. send_publish
414
+2.  send_publish
414 415
 
415 416
    Field type:
416 417
 ...
... ...
@@ -445,12 +446,14 @@ typedef struct publ_info
445 446
                           for that event)*/
446 447
   str* etag;          /*  (optional) the value of the etag the request
447 448
                           should match */
449
+  str* outbound_proxy;/*  outbound_proxy to use when sending the
450
+                          Publish request */
448 451
   str* extra_headers  /*  (optional) extra_headers that should be added
449 452
                           to Publish msg*/
450 453
 }publ_info_t;
451 454
 ...
452 455
 
453
-3. send_subscribe
456
+3.  send_subscribe
454 457
 
455 458
    Field type:
456 459
 ...
... ...
@@ -489,7 +492,7 @@ typedef struct subs_info
489 492
 }subs_info_t;
490 493
 ...
491 494
 
492
-4. is_dialog
495
+4.  is_dialog
493 496
 
494 497
    Field type:
495 498
 ...
... ...
@@ -508,7 +511,7 @@ typedef int  (*query_dialog_t)(ua_pres_t* presentity);
508 511
         }
509 512
 ...
510 513
 
511
-5. register_puacb
514
+5.  register_puacb
512 515
 
513 516
    Field type:
514 517
 ...
... ...
@@ -537,7 +540,7 @@ typedef int (*register_puacb_t)(int types, pua_cb f, void* param );
537 540
 typedef int (pua_cb)(ua_pres_t* hentity, struct sip_msg*);
538 541
 ...
539 542
 
540
-6. add_event
543
+6.  add_event
541 544
 
542 545
    Field type:
543 546
 ...
... ...
@@ -197,7 +197,8 @@ modparam("pua", "update_period", 100)
197 197
 		<title><varname>outbound_proxy</varname> (str)</title>
198 198
 		<para>
199 199
 		SIP URI of outbound proxy to be used when sending
200
-		PUBLISH requests.
200
+		PUBLISH requests if no outbound proxy is given in
201
+                outbound_proxy field of struct publ_info.
201 202
 		</para>
202 203
 		<para>
203 204
 		<emphasis>By default, no outbound proxy has been defined.
... ...
@@ -86,6 +86,8 @@ typedef struct publ_info
86 86
                           for that event)*/
87 87
   str* etag;          /*  (optional) the value of the etag the request
88 88
                           should match */
89
+  str* outbound_proxy;/*  outbound_proxy to use when sending the 
90
+                          Publish request */
89 91
   str* extra_headers  /*  (optional) extra_headers that should be added
90 92
                           to Publish msg*/
91 93
 }publ_info_t;
... ...
@@ -81,6 +81,7 @@ typedef struct ua_pres{
81 81
 	void* cb_param;
82 82
 	struct ua_pres* next;
83 83
 	int ua_flag;
84
+	str* outbound_proxy; /* croc-not sored in db_only mode */
84 85
 	
85 86
 	/* publish */
86 87
 	str etag;
... ...
@@ -96,7 +97,6 @@ typedef struct ua_pres{
96 97
 	int cseq;
97 98
 	int version;
98 99
 /*  int watcher_count; croc-nolonger used!! */
99
-	str* outbound_proxy; /* croc-not sored in db_only mode */
100 100
 	str* extra_headers;
101 101
 	str record_route;
102 102
 	str remote_contact;
... ...
@@ -274,6 +274,7 @@ void publ_cback_func(struct cell *t, int type, struct tmcb_params *ps)
274 274
 			publ.content_type= hentity->content_type;	
275 275
 			publ.id= hentity->id;
276 276
 			publ.extra_headers= hentity->extra_headers;
277
+			publ.outbound_proxy = hentity->outbound_proxy;
277 278
 			publ.cb_param= hentity->cb_param;
278 279
 
279 280
 			if (dbmode == PUA_DB_ONLY && pua_dbf.end_transaction)
... ...
@@ -692,8 +693,9 @@ send_publish:
692 693
 	result= tmb.t_request(&uac_r,
693 694
 			publ->pres_uri,			/*! Request-URI */
694 695
 			publ->pres_uri,			/*! To */
695
-			publ->pres_uri,			/*! From */
696
-			&outbound_proxy		/*! Outbound proxy*/
696
+ 		        publ->pres_uri,			/*! From */
697
+		        publ->outbound_proxy?
698
+			      publ->outbound_proxy:&outbound_proxy /*! Outbound proxy*/
697 699
 			);
698 700
 
699 701
 	if(result< 0)
... ...
@@ -757,6 +759,9 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
757 759
 
758 760
 	size= sizeof(ua_pres_t)+ sizeof(str)+ (publ->pres_uri->len+ 
759 761
 		+ publ->content_type.len+ publ->id.len+ 1)*sizeof(char);
762
+
763
+	if(publ->outbound_proxy)
764
+		size+= sizeof(str)+ publ->outbound_proxy->len* sizeof(char);
760 765
 	if(body && body->s && body->len)
761 766
 		size+= sizeof(str)+ body->len* sizeof(char);
762 767
 	if(publ->etag)
... ...
@@ -822,6 +827,16 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
822 827
 		cb_param->extra_headers->len= publ->extra_headers->len;
823 828
 		size+= publ->extra_headers->len;
824 829
 	}	
830
+	if(publ->outbound_proxy)
831
+	{
832
+		cb_param->outbound_proxy = (str*)((char*)cb_param + size);
833
+		size += sizeof(str);
834
+		cb_param->outbound_proxy->s = (char*)cb_param + size;
835
+		memcpy(cb_param->outbound_proxy->s, publ->outbound_proxy->s,
836
+		       publ->outbound_proxy->len);
837
+		cb_param->outbound_proxy->len = publ->outbound_proxy->len;
838
+		size+= publ->outbound_proxy->len;
839
+	}	
825 840
 
826 841
 	if(publ->content_type.s && publ->content_type.len)
827 842
 	{
... ...
@@ -837,6 +852,7 @@ ua_pres_t* publish_cbparam(publ_info_t* publ,str* body,str* tuple_id,
837 852
 		cb_param->tuple_id.len= tuple_id->len;
838 853
 		size+= tuple_id->len;
839 854
 	}
855
+
840 856
 	cb_param->event= publ->event;
841 857
 	cb_param->flag|= publ->source_flag;
842 858
 	cb_param->cb_param= publ->cb_param;
... ...
@@ -44,6 +44,7 @@ typedef struct publ_info
44 44
 	str content_type;  /*! the content_type of the body if present(optional if the
45 45
 				same as the default value for that event) */
46 46
 	str* etag;
47
+	str* outbound_proxy;
47 48
 	str* extra_headers;
48 49
 	void* cb_param;   /*! the parameter for the function to be called on the callback 
49 50
 				for the received reply; it must be allocated in share memory;