Module: sip-router
Branch: carstenbock/ims
Commit: cf5584901ae0e3d97e2b8ea3f5e34f0428df490a
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=cf55849…
Author: Carsten Bock <carsten(a)bock.info>
Committer: Carsten Bock <carsten(a)bock.info>
Date: Mon Apr 18 12:00:33 2011 +0200
- allow setting the expires for the SUBSCRIBE as optional parameter.
---
modules_k/pua_reginfo/doc/pua_reginfo_admin.xml | 5 ++++-
modules_k/pua_reginfo/pua_reginfo.c | 1 +
modules_k/pua_reginfo/subscribe.c | 22 +++++++++++++++++++---
modules_k/pua_reginfo/subscribe.h | 1 +
4 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/modules_k/pua_reginfo/doc/pua_reginfo_admin.xml
b/modules_k/pua_reginfo/doc/pua_reginfo_admin.xml
index 6ecc39a..6d7243d 100644
--- a/modules_k/pua_reginfo/doc/pua_reginfo_admin.xml
+++ b/modules_k/pua_reginfo/doc/pua_reginfo_admin.xml
@@ -213,7 +213,7 @@ if(is_method("NOTIFY"))
</section>
<section>
<title>
- <function moreinfo="none">reginfo_subscribe(uri)</function>
+ <function moreinfo="none">reginfo_subscribe(uri[,
expires])</function>
</title>
<para>
This function will subscribe for reginfo-information at the given
@@ -226,6 +226,9 @@ if(is_method("NOTIFY"))
<emphasis>uri</emphasis> - SIP-URI of the server, where to subscribe,
may contain pseudo-variables.
</para>
+ <para>
+ <emphasis>expires</emphasis> - Expiration date for this subscription, in
seconds (default 3600)
+ </para>
</listitem>
</itemizedlist>
<example>
diff --git a/modules_k/pua_reginfo/pua_reginfo.c b/modules_k/pua_reginfo/pua_reginfo.c
index 9a00a36..d5e4328 100644
--- a/modules_k/pua_reginfo/pua_reginfo.c
+++ b/modules_k/pua_reginfo/pua_reginfo.c
@@ -50,6 +50,7 @@ static int mod_init(void);
/* Commands */
static cmd_export_t cmds[] = {
{"reginfo_subscribe", (cmd_function)reginfo_subscribe, 1, fixup_subscribe, 0,
REQUEST_ROUTE|ONREPLY_ROUTE},
+ {"reginfo_subscribe", (cmd_function)reginfo_subscribe2, 2, fixup_subscribe, 0,
REQUEST_ROUTE|ONREPLY_ROUTE},
{"reginfo_handle_notify", (cmd_function)reginfo_handle_notify, 1,
domain_fixup, 0, REQUEST_ROUTE},
{0, 0, 0, 0, 0, 0}
};
diff --git a/modules_k/pua_reginfo/subscribe.c b/modules_k/pua_reginfo/subscribe.c
index 557d01c..4548a8e 100644
--- a/modules_k/pua_reginfo/subscribe.c
+++ b/modules_k/pua_reginfo/subscribe.c
@@ -23,17 +23,18 @@
#include "subscribe.h"
#include "../../pvar.h"
+#include "../../mod_fix.h"
#include "../pua/send_subscribe.h"
#include "../pua/pua.h"
#include "pua_reginfo.h"
-int reginfo_subscribe(struct sip_msg* msg, char* uri, char* s2) {
+int reginfo_subscribe_real(struct sip_msg* msg, pv_elem_t* uri, int expires) {
str uri_str = {0, 0};
char uri_buf[512];
int uri_buf_len = 512;
subs_info_t subs;
- if (pv_printf(msg, (pv_elem_t*)uri, uri_buf, &uri_buf_len) < 0) {
+ if (pv_printf(msg, uri, uri_buf, &uri_buf_len) < 0) {
LM_ERR("cannot print uri into the format\n");
return -1;
}
@@ -47,7 +48,7 @@ int reginfo_subscribe(struct sip_msg* msg, char* uri, char* s2) {
subs.remote_target = &uri_str;
subs.pres_uri= &uri_str;
subs.watcher_uri= &server_address;
- subs.expires = 3600;
+ subs.expires = expires;
subs.source_flag= REGINFO_SUBSCRIBE;
subs.event= REGINFO_EVENT;
@@ -65,6 +66,19 @@ int reginfo_subscribe(struct sip_msg* msg, char* uri, char* s2) {
return 1;
}
+int reginfo_subscribe(struct sip_msg* msg, char* uri, char* s2) {
+ return reginfo_subscribe_real(msg, (pv_elem_t*)uri, 3600);
+}
+
+int reginfo_subscribe2(struct sip_msg* msg, char* uri, char* param2) {
+ int expires;
+ if(fixup_get_ivalue(msg, (gparam_p)param2, &expires) != 0) {
+ LM_ERR("No expires provided!\n");
+ return -1;
+ }
+ return reginfo_subscribe_real(msg, (pv_elem_t*)uri, expires);
+}
+
int fixup_subscribe(void** param, int param_no) {
pv_elem_t *model;
str s;
@@ -81,6 +95,8 @@ int fixup_subscribe(void** param, int param_no) {
}
LM_ERR("null format\n");
return E_UNSPEC;
+ } else if (param_no == 2) {
+ return fixup_igp_igp(param, param_no);
} else return 1;
}
diff --git a/modules_k/pua_reginfo/subscribe.h b/modules_k/pua_reginfo/subscribe.h
index 8a09433..a084650 100644
--- a/modules_k/pua_reginfo/subscribe.h
+++ b/modules_k/pua_reginfo/subscribe.h
@@ -27,6 +27,7 @@
#include "../../parser/msg_parser.h"
int reginfo_subscribe(struct sip_msg*, char*, char*);
+int reginfo_subscribe2(struct sip_msg*, char*, char*);
int fixup_subscribe(void** param, int param_no);
#endif