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
This commit is contained in:
Joshua Colp
2014-06-12 11:34:36 +00:00
parent 3b0ad74e17
commit 58f4c18ab6
8 changed files with 542 additions and 37 deletions

View File

@@ -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} };