summaryrefslogtreecommitdiff
path: root/res/res_pjsip.c
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2014-06-12 11:34:36 +0000
committerJoshua Colp <jcolp@digium.com>2014-06-12 11:34:36 +0000
commit58f4c18ab692ad0c43d9cb4418fc2b680bb17b80 (patch)
treed718320702c43bf77a048defeab91d1cc9c8e1c8 /res/res_pjsip.c
parent3b0ad74e1741c78afbab229cb38965280744f76d (diff)
res_pjsip_pubsub: Persist subscriptions in sorcery so they are recreated on startup.
This change makes res_pjsip_pubsub persist inbound subscriptions in sorcery. By default this uses the local astdb but it can also be configured to store within an outside database. When Asterisk is started these subscriptions are recreated if they have not expired. Notifications are sent to the devices which have subscribed and they are none the wiser that the system has restarted. Review: https://reviewboard.asterisk.org/r/3598/ ........ Merged revisions 415766 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@415767 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip.c')
-rw-r--r--res/res_pjsip.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/res/res_pjsip.c b/res/res_pjsip.c
index 5a3fe2fe8..339cf1dfe 100644
--- a/res/res_pjsip.c
+++ b/res/res_pjsip.c
@@ -1613,6 +1613,36 @@ pjsip_dialog *ast_sip_create_dialog_uas(const struct ast_sip_endpoint *endpoint,
return dlg;
}
+int ast_sip_create_rdata(pjsip_rx_data *rdata, char *packet, const char *src_name, int src_port,
+ char *transport_type, const char *local_name, int local_port)
+{
+ pj_str_t tmp;
+
+ rdata->tp_info.transport = PJ_POOL_ZALLOC_T(rdata->tp_info.pool, pjsip_transport);
+ if (!rdata->tp_info.transport) {
+ return -1;
+ }
+
+ ast_copy_string(rdata->pkt_info.packet, packet, sizeof(rdata->pkt_info.packet));
+ ast_copy_string(rdata->pkt_info.src_name, src_name, sizeof(rdata->pkt_info.src_name));
+ rdata->pkt_info.src_port = src_port;
+
+ pjsip_parse_rdata(packet, strlen(packet), rdata);
+ if (!rdata->msg_info.msg) {
+ return -1;
+ }
+
+ pj_strdup2(rdata->tp_info.pool, &rdata->msg_info.via->recvd_param, rdata->pkt_info.src_name);
+ rdata->msg_info.via->rport_param = -1;
+
+ rdata->tp_info.transport->key.type = pjsip_transport_get_type_from_name(pj_cstr(&tmp, transport_type));
+ rdata->tp_info.transport->type_name = transport_type;
+ pj_strdup2(rdata->tp_info.pool, &rdata->tp_info.transport->local_name.host, local_name);
+ rdata->tp_info.transport->local_name.port = local_port;
+
+ return 0;
+}
+
/* PJSIP doesn't know about the INFO method, so we have to define it ourselves */
static const pjsip_method info_method = {PJSIP_OTHER_METHOD, {"INFO", 4} };
static const pjsip_method message_method = {PJSIP_OTHER_METHOD, {"MESSAGE", 7} };