2
0
Эх сурвалжийг харах

modules/pua_mi: added publish_with_ob_proxy module param
- and optional outbound proxy parameter to pua_publish mi command

Juha Heinanen 11 жил өмнө
parent
commit
c3fd94ff68

+ 42 - 14
modules/pua_mi/README

@@ -12,7 +12,7 @@ Edited by
 
 
 Juha Heinanen
 Juha Heinanen
 
 
-   Copyright © 2006 Voice Sistem SRL
+   Copyright (c) 2006 Voice Sistem SRL
      __________________________________________________________________
      __________________________________________________________________
 
 
    Table of Contents
    Table of Contents
@@ -25,14 +25,19 @@ Juha Heinanen
               2.1. Kamailio Modules
               2.1. Kamailio Modules
               2.2. External Libraries or Applications
               2.2. External Libraries or Applications
 
 
-        3. MI Commands
+        3. Parameters
 
 
-              3.1. pua_publish
-              3.2. pua_subscribe
+              3.1. publish_with_ob_proxy (int)
+
+        4. MI Commands
+
+              4.1. pua_publish
+              4.2. pua_subscribe
 
 
    List of Examples
    List of Examples
 
 
-   1.1. pua_publish FIFO example
+   1.1. Set publish_with_ob_proxy parameter
+   1.2. pua_publish FIFO example
 
 
 Chapter 1. Admin Guide
 Chapter 1. Admin Guide
 
 
@@ -44,10 +49,14 @@ Chapter 1. Admin Guide
         2.1. Kamailio Modules
         2.1. Kamailio Modules
         2.2. External Libraries or Applications
         2.2. External Libraries or Applications
 
 
-   3. MI Commands
+   3. Parameters
+
+        3.1. publish_with_ob_proxy (int)
 
 
-        3.1. pua_publish
-        3.2. pua_subscribe
+   4. MI Commands
+
+        4.1. pua_publish
+        4.2. pua_subscribe
 
 
 1. Overview
 1. Overview
 
 
@@ -76,12 +85,27 @@ Chapter 1. Admin Guide
    running Kamailio with this module loaded:
    running Kamailio with this module loaded:
      * none
      * none
 
 
-3. MI Commands
+3. Parameters
+
+   3.1. publish_with_ob_proxy (int)
+
+3.1. publish_with_ob_proxy (int)
+
+   If 1, pua_publish MI command has outbound proxy parameter.
+
+   Default value is "0".
+
+   Example 1.1. Set publish_with_ob_proxy parameter
+...
+modparam("pua_mi", "publish_with_ob_proxy", 1)
+...
+
+4. MI Commands
 
 
-   3.1. pua_publish
-   3.2. pua_subscribe
+   4.1. pua_publish
+   4.2. pua_subscribe
 
 
-3.1. pua_publish
+4.1.  pua_publish
 
 
    Command parameters:
    Command parameters:
      * presentity_uri - e.g. sip:[email protected]
      * presentity_uri - e.g. sip:[email protected]
@@ -97,13 +121,17 @@ Chapter 1. Admin Guide
        user take place. The dialog-id from the dialog-info body qualifies
        user take place. The dialog-id from the dialog-info body qualifies
        as a suitable id here.
        as a suitable id here.
      * ETag - ETag that publish should match or . if no ETag is given.
      * ETag - ETag that publish should match or . if no ETag is given.
+     * outbound proxy - SIP URI of outbound proxy to be used when sending
+       PUBLISH request or . if no outbound proxy is given. This parameter
+       is present only when publish_with_ob_proxy module parameter has
+       value 1.
      * extra_headers - Extra headers added to PUBLISH request or . if no
      * extra_headers - Extra headers added to PUBLISH request or . if no
        extra headers.
        extra headers.
      * body - The body of the publish request containing published
      * body - The body of the publish request containing published
        information or missing if no published information. It has to be a
        information or missing if no published information. It has to be a
        single line for FIFO transport.
        single line for FIFO transport.
 
 
-   Example 1.1. pua_publish FIFO example
+   Example 1.2. pua_publish FIFO example
 ...
 ...
 
 
 :pua_publish:fifo_test_reply
 :pua_publish:fifo_test_reply
@@ -121,7 +149,7 @@ le id='0x81475a0'><status><basic>open</basic></status></tuple><dm:person id='pdd
 748945'><rpid:activities><rpid:away/>away</rpid:activities><dm:note>CPU:16 MEM:4
 748945'><rpid:activities><rpid:away/>away</rpid:activities><dm:note>CPU:16 MEM:4
 76</dm:note></dm:person></presence>
 76</dm:note></dm:person></presence>
 
 
-3.2. pua_subscribe
+4.2.  pua_subscribe
 
 
    Command parameters:
    Command parameters:
      * presentity_uri - e.g. sip:[email protected]
      * presentity_uri - e.g. sip:[email protected]

+ 31 - 0
modules/pua_mi/doc/pua_mi_admin.xml

@@ -63,6 +63,28 @@
 			</itemizedlist>
 			</itemizedlist>
 	</section>
 	</section>
 	</section>
 	</section>
+
+	<section>
+	<title>Parameters</title>
+	<section>
+		<title><varname>publish_with_ob_proxy</varname> (int)</title>
+		<para>
+		If 1, pua_publish MI command has outbound proxy parameter.
+        	</para>
+		<para>
+		<emphasis>Default value is <quote>0</quote>.	
+		</emphasis>
+		</para>
+		<example>
+		<title>Set <varname>publish_with_ob_proxy</varname> parameter</title>
+		<programlisting format="linespecific">
+...
+modparam("pua_mi", "publish_with_ob_proxy", 1)
+...
+</programlisting>
+		</example>
+	</section>
+	</section>
 	
 	
 	<section>
 	<section>
 		<title>MI Commands</title>
 		<title>MI Commands</title>
@@ -121,6 +143,15 @@
 		match or . if no ETag is given.
 		match or . if no ETag is given.
 		                </para> 
 		                </para> 
 			</listitem>
 			</listitem>
+			<listitem>
+				<para>
+				  <emphasis>outbound proxy</emphasis>
+				  - SIP URI of outbound proxy to be used when
+       sending PUBLISH request or . if no outbound proxy is given.  This
+       parameter is present only when publish_with_ob_proxy module
+       parameter has value 1. 
+		                </para> 
+			</listitem>
 			<listitem>
 			<listitem>
 				<para>
 				<para>
 					<emphasis>extra_headers</emphasis>
 					<emphasis>extra_headers</emphasis>

+ 29 - 1
modules/pua_mi/mi_func.c

@@ -33,7 +33,6 @@
 #include "../../lib/kcore/cmpapi.h"
 #include "../../lib/kcore/cmpapi.h"
 
 
 #include "../pua/pua_bind.h"
 #include "../pua/pua_bind.h"
-#include "../pua/pua.h"
 #include "pua_mi.h"
 #include "pua_mi.h"
 
 
 /*
 /*
@@ -44,6 +43,7 @@
  *		<content_type>     - body type if body of a type different from default
  *		<content_type>     - body type if body of a type different from default
  *                            event content-type or . 
  *                            event content-type or . 
  *		<ETag>             - ETag that publish should match or . if no ETag
  *		<ETag>             - ETag that publish should match or . if no ETag
+ *		<outbound_proxy>   - outbound proxy or .
  *		<extra_headers>    - extra headers to be added to the request or .
  *		<extra_headers>    - extra headers to be added to the request or .
  *		<publish_body>     - may not be present in case of update for expire
  *		<publish_body>     - may not be present in case of update for expire
  */
  */
@@ -60,6 +60,7 @@ struct mi_root* mi_pua_publish(struct mi_root* cmd, void* param)
 	str content_type;
 	str content_type;
 	str id;
 	str id;
 	str etag;
 	str etag;
+	str outbound_proxy;
 	str extra_headers;
 	str extra_headers;
 	int result;
 	int result;
 	int sign= 1;
 	int sign= 1;
@@ -169,6 +170,21 @@ struct mi_root* mi_pua_publish(struct mi_root* cmd, void* param)
 	if(node == NULL)
 	if(node == NULL)
 		return 0;
 		return 0;
 
 
+	/* Get outbound_proxy */
+	if (publish_with_ob_proxy) {
+
+		outbound_proxy = node->value;
+		if(outbound_proxy.s== NULL || outbound_proxy.len== 0) {
+			LM_ERR("empty outbound proxy parameter\n");
+			return init_mi_tree(400, "Empty outbound proxy", 20);
+		}
+		LM_DBG("outbound_proxy '%.*s'\n",
+		       outbound_proxy.len, outbound_proxy.s);
+	
+		node = node->next;
+		if(node == NULL) return 0;
+	}
+
 	/* Get extra_headers */
 	/* Get extra_headers */
 	extra_headers = node->value;
 	extra_headers = node->value;
 	if(extra_headers.s== NULL || extra_headers.len== 0)
 	if(extra_headers.s== NULL || extra_headers.len== 0)
@@ -239,10 +255,22 @@ struct mi_root* mi_pua_publish(struct mi_root* cmd, void* param)
 	}	
 	}	
 	publ.expires= exp;
 	publ.expires= exp;
 
 
+	if (publish_with_ob_proxy) {
+		if (!((outbound_proxy.len == 1) &&
+		      (outbound_proxy.s[0] == '.')))
+			publ.outbound_proxy = &outbound_proxy;
+	}
+
 	if (!(extra_headers.len == 1 && extra_headers.s[0] == '.')) {
 	if (!(extra_headers.len == 1 && extra_headers.s[0] == '.')) {
 	    publ.extra_headers = &extra_headers;
 	    publ.extra_headers = &extra_headers;
 	}
 	}
 
 
+	if (!(etag.len== 1 && etag.s[0]== '.'))
+	{
+		publ.etag= &etag;
+	}	
+	publ.expires= exp;
+
 	if (cmd->async_hdl!=NULL)
 	if (cmd->async_hdl!=NULL)
 	{
 	{
 		publ.source_flag= MI_ASYN_PUBLISH;
 		publ.source_flag= MI_ASYN_PUBLISH;

+ 12 - 1
modules/pua_mi/pua_mi.c

@@ -48,6 +48,9 @@ MODULE_VERSION
 
 
 pua_api_t pua;
 pua_api_t pua;
 
 
+/** module params */
+int publish_with_ob_proxy = 0;
+
 /** module functions */
 /** module functions */
 
 
 static int mod_init(void);
 static int mod_init(void);
@@ -55,6 +58,14 @@ static int mod_init(void);
 send_publish_t pua_send_publish;
 send_publish_t pua_send_publish;
 send_subscribe_t pua_send_subscribe;
 send_subscribe_t pua_send_subscribe;
 
 
+/*
+ * Exported params
+ */
+static param_export_t params[]={
+	{"publish_with_ob_proxy",    INT_PARAM, &publish_with_ob_proxy},
+	{0,                          0,         0}
+};
+
 /*
 /*
  * Exported MI functions
  * Exported MI functions
  */
  */
@@ -69,7 +80,7 @@ struct module_exports exports= {
 	"pua_mi",					/* module name */
 	"pua_mi",					/* module name */
 	DEFAULT_DLFLAGS,			/* dlopen flags */
 	DEFAULT_DLFLAGS,			/* dlopen flags */
 	0,							/* exported functions */
 	0,							/* exported functions */
-	0,							/* exported parameters */
+	params,							/* exported parameters */
 	0,							/* exported statistics */
 	0,							/* exported statistics */
 	mi_cmds,					/* exported MI functions */
 	mi_cmds,					/* exported MI functions */
 	0,							/* exported pseudo-variables */
 	0,							/* exported pseudo-variables */

+ 2 - 0
modules/pua_mi/pua_mi.h

@@ -27,6 +27,8 @@
 
 
 #include "../pua/pua_bind.h"
 #include "../pua/pua_bind.h"
 
 
+extern int publish_with_ob_proxy;
+
 extern send_publish_t pua_send_publish;
 extern send_publish_t pua_send_publish;
 extern send_subscribe_t pua_send_subscribe;
 extern send_subscribe_t pua_send_subscribe;