[sr-dev] git:master: modules/pua_mi: added publish_with_ob_proxy module param

Juha Heinanen jh at tutpro.com
Tue Nov 4 16:04:00 CET 2014


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

Author: Juha Heinanen <jh at tutpro.com>
Committer: Juha Heinanen <jh at tutpro.com>
Date:   Tue Nov  4 17:02:04 2014 +0200

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

---

 modules/pua_mi/README               |   56 ++++++++++++++++++++++++++---------
 modules/pua_mi/doc/pua_mi_admin.xml |   31 +++++++++++++++++++
 modules/pua_mi/mi_func.c            |   30 ++++++++++++++++++-
 modules/pua_mi/pua_mi.c             |   13 +++++++-
 modules/pua_mi/pua_mi.h             |    2 +
 5 files changed, 116 insertions(+), 16 deletions(-)

diff --git a/modules/pua_mi/README b/modules/pua_mi/README
index bfeaccf..6218ac4 100644
--- a/modules/pua_mi/README
+++ b/modules/pua_mi/README
@@ -12,7 +12,7 @@ Edited by
 
 Juha Heinanen
 
-   Copyright © 2006 Voice Sistem SRL
+   Copyright (c) 2006 Voice Sistem SRL
      __________________________________________________________________
 
    Table of Contents
@@ -25,14 +25,19 @@ Juha Heinanen
               2.1. Kamailio Modules
               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
 
-   1.1. pua_publish FIFO example
+   1.1. Set publish_with_ob_proxy parameter
+   1.2. pua_publish FIFO example
 
 Chapter 1. Admin Guide
 
@@ -44,10 +49,14 @@ Chapter 1. Admin Guide
         2.1. Kamailio Modules
         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
 
@@ -76,12 +85,27 @@ Chapter 1. Admin Guide
    running Kamailio with this module loaded:
      * 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:
      * presentity_uri - e.g. sip:system at kamailio.org
@@ -97,13 +121,17 @@ Chapter 1. Admin Guide
        user take place. The dialog-id from the dialog-info body qualifies
        as a suitable id here.
      * 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.
      * body - The body of the publish request containing published
        information or missing if no published information. It has to be a
        single line for FIFO transport.
 
-   Example 1.1. pua_publish FIFO example
+   Example 1.2. pua_publish FIFO example
 ...
 
 :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
 76</dm:note></dm:person></presence>
 
-3.2. pua_subscribe
+4.2.  pua_subscribe
 
    Command parameters:
      * presentity_uri - e.g. sip:presentity at kamailio.org
diff --git a/modules/pua_mi/doc/pua_mi_admin.xml b/modules/pua_mi/doc/pua_mi_admin.xml
index f10c42f..7d4385f 100644
--- a/modules/pua_mi/doc/pua_mi_admin.xml
+++ b/modules/pua_mi/doc/pua_mi_admin.xml
@@ -63,6 +63,28 @@
 			</itemizedlist>
 	</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>
 		<title>MI Commands</title>
@@ -123,6 +145,15 @@
 			</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>
+				<para>
 					<emphasis>extra_headers</emphasis>
 					- Extra headers added to PUBLISH
 		request or . if no extra headers.
diff --git a/modules/pua_mi/mi_func.c b/modules/pua_mi/mi_func.c
index 7bd7dc7..a107c4d 100644
--- a/modules/pua_mi/mi_func.c
+++ b/modules/pua_mi/mi_func.c
@@ -33,7 +33,6 @@
 #include "../../lib/kcore/cmpapi.h"
 
 #include "../pua/pua_bind.h"
-#include "../pua/pua.h"
 #include "pua_mi.h"
 
 /*
@@ -44,6 +43,7 @@
  *		<content_type>     - body type if body of a type different from default
  *                            event content-type or . 
  *		<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 .
  *		<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 id;
 	str etag;
+	str outbound_proxy;
 	str extra_headers;
 	int result;
 	int sign= 1;
@@ -169,6 +170,21 @@ struct mi_root* mi_pua_publish(struct mi_root* cmd, void* param)
 	if(node == NULL)
 		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 */
 	extra_headers = node->value;
 	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;
 
+	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] == '.')) {
 	    publ.extra_headers = &extra_headers;
 	}
 
+	if (!(etag.len== 1 && etag.s[0]== '.'))
+	{
+		publ.etag= &etag;
+	}	
+	publ.expires= exp;
+
 	if (cmd->async_hdl!=NULL)
 	{
 		publ.source_flag= MI_ASYN_PUBLISH;
diff --git a/modules/pua_mi/pua_mi.c b/modules/pua_mi/pua_mi.c
index 1e6bf2c..ec5cfa7 100644
--- a/modules/pua_mi/pua_mi.c
+++ b/modules/pua_mi/pua_mi.c
@@ -48,6 +48,9 @@ MODULE_VERSION
 
 pua_api_t pua;
 
+/** module params */
+int publish_with_ob_proxy = 0;
+
 /** module functions */
 
 static int mod_init(void);
@@ -56,6 +59,14 @@ send_publish_t pua_send_publish;
 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
  */
 static mi_export_t mi_cmds[] = {
@@ -69,7 +80,7 @@ struct module_exports exports= {
 	"pua_mi",					/* module name */
 	DEFAULT_DLFLAGS,			/* dlopen flags */
 	0,							/* exported functions */
-	0,							/* exported parameters */
+	params,							/* exported parameters */
 	0,							/* exported statistics */
 	mi_cmds,					/* exported MI functions */
 	0,							/* exported pseudo-variables */
diff --git a/modules/pua_mi/pua_mi.h b/modules/pua_mi/pua_mi.h
index c1eadbc..74af4e1 100644
--- a/modules/pua_mi/pua_mi.h
+++ b/modules/pua_mi/pua_mi.h
@@ -27,6 +27,8 @@
 
 #include "../pua/pua_bind.h"
 
+extern int publish_with_ob_proxy;
+
 extern send_publish_t pua_send_publish;
 extern send_subscribe_t pua_send_subscribe;
 




More information about the sr-dev mailing list