mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
Add support for RFC 4662 resource list subscriptions.
This commit adds the ability for a user to configure a resource list in pjsip.conf. Subscribing to this list simultaneously subscribes the subscriber to all resources listed. This has the potential to reduce the amount of SIP traffic when loads of subscribers on a system attempt to subscribe to each others' states. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@420384 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -16,6 +16,21 @@
|
||||
* at the top of the source tree.
|
||||
*/
|
||||
|
||||
/*!
|
||||
* \brief The length of the XML prolog when printing
|
||||
* presence or other XML in PJSIP.
|
||||
*
|
||||
* When calling any variant of pj_xml_print(), the documentation
|
||||
* claims that it will return -1 if the provided buffer is not
|
||||
* large enough. However, if the XML prolog is requested to be
|
||||
* printed, then the length of the XML prolog is returned upon
|
||||
* failure instead of -1.
|
||||
*
|
||||
* This constant is useful to check against when trying to determine
|
||||
* if printing XML succeeded or failed.
|
||||
*/
|
||||
#define AST_PJSIP_XML_PROLOG_LEN 39
|
||||
|
||||
/*!
|
||||
* PIDF state
|
||||
*/
|
||||
|
@@ -240,23 +240,29 @@ struct ast_sip_notifier {
|
||||
*/
|
||||
int (*new_subscribe)(struct ast_sip_endpoint *endpoint, const char *resource);
|
||||
/*!
|
||||
* \brief The subscription is in need of a NOTIFY request.
|
||||
* \brief Called when an inbound subscription has been accepted.
|
||||
*
|
||||
* A reason of AST_SIP_SUBSCRIPTION_NOTIFY_REASON_STARTED is given immediately
|
||||
* after a SUBSCRIBE is accepted. This is a good opportunity for the notifier to
|
||||
* perform setup duties such as establishing Stasis subscriptions or adding
|
||||
* datastores to the subscription.
|
||||
* This is a prime opportunity for notifiers to add any notifier-specific
|
||||
* data to the subscription (such as datastores) that it needs to.
|
||||
*
|
||||
* A reason of AST_SIP_SUBSCRIPTION_NOTIFY_REASON_TERMINATED is given when the
|
||||
* subscriber has terminated the subscription. If there are any duties that the
|
||||
* \note There is no need to send a NOTIFY request when this callback
|
||||
* is called
|
||||
*
|
||||
*
|
||||
* \param sub The subscription to send the NOTIFY on.
|
||||
* \param reason The reason why the NOTIFY is being sent.
|
||||
* \param sub The new subscription
|
||||
* \retval 0 Success
|
||||
* \retval -1 Failure
|
||||
*/
|
||||
int (*notify_required)(struct ast_sip_subscription *sub, enum ast_sip_subscription_notify_reason reason);
|
||||
int (*subscription_established)(struct ast_sip_subscription *sub);
|
||||
/*!
|
||||
* \brief Supply data needed to create a NOTIFY body.
|
||||
*
|
||||
* The returned data must be an ao2 object. The caller of this function
|
||||
* will be responsible for decrementing the refcount of the returned object
|
||||
*
|
||||
* \param sub The subscription
|
||||
* \return An ao2 object that can be used to create a NOTIFY body.
|
||||
*/
|
||||
void *(*get_notify_data)(struct ast_sip_subscription *sub);
|
||||
};
|
||||
|
||||
struct ast_sip_subscriber {
|
||||
@@ -343,10 +349,9 @@ struct ast_taskprocessor *ast_sip_subscription_get_serializer(struct ast_sip_sub
|
||||
/*!
|
||||
* \brief Notify a SIP subscription of a state change.
|
||||
*
|
||||
* This will create a NOTIFY body to be sent out for the subscribed resource.
|
||||
* On real subscriptions, a NOTIFY request will be generated and sent.
|
||||
* On virtual subscriptions, the NOTIFY is saved on the virtual subscription and the
|
||||
* parent subscription is alerted.
|
||||
* This tells the pubsub core that the state of a subscribed resource has changed.
|
||||
* The pubsub core will generate an appropriate NOTIFY request to send to the
|
||||
* subscriber.
|
||||
*
|
||||
* \param sub The subscription on which a state change is occurring.
|
||||
* \param notify_data Event package-specific data used to create the NOTIFY body.
|
||||
@@ -359,7 +364,7 @@ int ast_sip_subscription_notify(struct ast_sip_subscription *sub, void *notify_d
|
||||
/*!
|
||||
* \brief Retrieve the local URI for this subscription
|
||||
*
|
||||
* This is the local URI as determined by the underlying SIP dialog.
|
||||
* This is the local URI of the subscribed resource.
|
||||
*
|
||||
* \param sub The subscription
|
||||
* \param[out] buf The buffer into which to store the URI.
|
||||
|
@@ -1196,4 +1196,20 @@ int ast_str_container_add(struct ao2_container *str_container, const char *add);
|
||||
*/
|
||||
void ast_str_container_remove(struct ao2_container *str_container, const char *remove);
|
||||
|
||||
/*!
|
||||
* \brief Create a pseudo-random string of a fixed length.
|
||||
*
|
||||
* This function is useful for generating a string whose randomness
|
||||
* does not need to be across all time and space, does not need to
|
||||
* be cryptographically secure, and needs to fit in a limited space.
|
||||
*
|
||||
* This function will write a null byte at the final position
|
||||
* in the buffer (buf[size - 1]). So if you pass in a size of
|
||||
* 10, then this will generate a random 9-character string.
|
||||
*
|
||||
* \param buf Buffer to write random string into.
|
||||
* \param size The size of the buffer.
|
||||
* \return A pointer to buf
|
||||
*/
|
||||
char *ast_generate_random_string(char *buf, size_t size);
|
||||
#endif /* _ASTERISK_STRINGS_H */
|
||||
|
@@ -195,3 +195,15 @@ void ast_str_container_remove(struct ao2_container *str_container, const char *r
|
||||
{
|
||||
ao2_find(str_container, remove, OBJ_SEARCH_KEY | OBJ_NODATA | OBJ_UNLINK);
|
||||
}
|
||||
|
||||
char *ast_generate_random_string(char *buf, size_t size)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < size - 1; ++i) {
|
||||
buf[i] = 'a' + (ast_random() % 26);
|
||||
}
|
||||
buf[i] = '\0';
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
@@ -156,11 +156,6 @@ static int dialog_info_generate_body_content(void *body, void *data)
|
||||
*/
|
||||
#define MAX_STRING_GROWTHS 3
|
||||
|
||||
/* When having pj_xml_print add the XML prolog to the output body the function will return 39
|
||||
* instead of -1 if the rest of the document can not be printed into the body.
|
||||
*/
|
||||
#define XML_PROLOG 39
|
||||
|
||||
static void dialog_info_to_string(void *body, struct ast_str **str)
|
||||
{
|
||||
pj_xml_node *dialog_info = body;
|
||||
@@ -169,13 +164,13 @@ static void dialog_info_to_string(void *body, struct ast_str **str)
|
||||
|
||||
do {
|
||||
size = pj_xml_print(dialog_info, ast_str_buffer(*str), ast_str_size(*str), PJ_TRUE);
|
||||
if (size == XML_PROLOG) {
|
||||
if (size == AST_PJSIP_XML_PROLOG_LEN) {
|
||||
ast_str_make_space(str, ast_str_size(*str) * 2);
|
||||
++growths;
|
||||
}
|
||||
} while (size == XML_PROLOG && growths < MAX_STRING_GROWTHS);
|
||||
} while (size == AST_PJSIP_XML_PROLOG_LEN && growths < MAX_STRING_GROWTHS);
|
||||
|
||||
if (size == XML_PROLOG) {
|
||||
if (size == AST_PJSIP_XML_PROLOG_LEN) {
|
||||
ast_log(LOG_WARNING, "dialog-info+xml body text too large\n");
|
||||
return;
|
||||
}
|
||||
|
@@ -70,15 +70,23 @@ struct exten_state_subscription {
|
||||
|
||||
static void subscription_shutdown(struct ast_sip_subscription *sub);
|
||||
static int new_subscribe(struct ast_sip_endpoint *endpoint, const char *resource);
|
||||
static int notify_required(struct ast_sip_subscription *sub,
|
||||
enum ast_sip_subscription_notify_reason reason);
|
||||
static int subscription_established(struct ast_sip_subscription *sub);
|
||||
static void *get_notify_data(struct ast_sip_subscription *sub);
|
||||
static void to_ami(struct ast_sip_subscription *sub,
|
||||
struct ast_str **buf);
|
||||
|
||||
struct ast_sip_notifier presence_notifier = {
|
||||
.default_accept = DEFAULT_PRESENCE_BODY,
|
||||
.new_subscribe = new_subscribe,
|
||||
.notify_required = notify_required,
|
||||
.subscription_established = subscription_established,
|
||||
.get_notify_data = get_notify_data,
|
||||
};
|
||||
|
||||
struct ast_sip_notifier dialog_notifier = {
|
||||
.default_accept = DEFAULT_DIALOG_BODY,
|
||||
.new_subscribe = new_subscribe,
|
||||
.subscription_established = subscription_established,
|
||||
.get_notify_data = get_notify_data,
|
||||
};
|
||||
|
||||
struct ast_sip_subscription_handler presence_handler = {
|
||||
@@ -94,7 +102,7 @@ struct ast_sip_subscription_handler dialog_handler = {
|
||||
.accept = { DEFAULT_DIALOG_BODY, },
|
||||
.subscription_shutdown = subscription_shutdown,
|
||||
.to_ami = to_ami,
|
||||
.notifier = &presence_notifier,
|
||||
.notifier = &dialog_notifier,
|
||||
};
|
||||
|
||||
static void exten_state_subscription_destructor(void *obj)
|
||||
@@ -153,45 +161,6 @@ static struct exten_state_subscription *exten_state_subscription_alloc(
|
||||
return exten_state_sub;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \internal
|
||||
* \brief Get device state information and send notification to the subscriber.
|
||||
*/
|
||||
static void send_notify(struct exten_state_subscription *exten_state_sub)
|
||||
{
|
||||
RAII_VAR(struct ao2_container*, info, NULL, ao2_cleanup);
|
||||
char *subtype = NULL, *message = NULL;
|
||||
struct ast_sip_exten_state_data exten_state_data = {
|
||||
.exten = exten_state_sub->exten,
|
||||
.presence_state = ast_hint_presence_state(NULL, exten_state_sub->context,
|
||||
exten_state_sub->exten, &subtype, &message),
|
||||
.presence_subtype = subtype,
|
||||
.presence_message = message,
|
||||
.sub = exten_state_sub->sip_sub,
|
||||
.user_agent = exten_state_sub->user_agent
|
||||
};
|
||||
|
||||
ast_sip_subscription_get_local_uri(exten_state_sub->sip_sub,
|
||||
exten_state_data.local, sizeof(exten_state_data.local));
|
||||
ast_sip_subscription_get_remote_uri(exten_state_sub->sip_sub,
|
||||
exten_state_data.remote, sizeof(exten_state_data.remote));
|
||||
|
||||
if ((exten_state_data.exten_state = ast_extension_state_extended(
|
||||
NULL, exten_state_sub->context, exten_state_sub->exten, &info)) < 0) {
|
||||
|
||||
ast_log(LOG_WARNING, "Unable to get device hint/info for extension %s\n",
|
||||
exten_state_sub->exten);
|
||||
return;
|
||||
}
|
||||
|
||||
exten_state_data.pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
|
||||
"exten_state", 1024, 1024);
|
||||
|
||||
exten_state_data.device_state_info = info;
|
||||
ast_sip_subscription_notify(exten_state_sub->sip_sub, &exten_state_data, 0);
|
||||
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), exten_state_data.pool);
|
||||
}
|
||||
|
||||
struct notify_task_data {
|
||||
struct ast_sip_exten_state_data exten_state_data;
|
||||
struct exten_state_subscription *exten_state_sub;
|
||||
@@ -231,11 +200,8 @@ static struct notify_task_data *alloc_notify_task_data(char *exten, struct exten
|
||||
task_data->exten_state_data.presence_subtype = ast_strdup(info->presence_subtype);
|
||||
task_data->exten_state_data.presence_message = ast_strdup(info->presence_message);
|
||||
task_data->exten_state_data.user_agent = ast_strdup(exten_state_sub->user_agent);
|
||||
task_data->exten_state_data.device_state_info = info->device_state_info;
|
||||
|
||||
if (task_data->exten_state_data.device_state_info) {
|
||||
ao2_ref(task_data->exten_state_data.device_state_info, +1);
|
||||
}
|
||||
task_data->exten_state_data.device_state_info = ao2_bump(info->device_state_info);
|
||||
task_data->exten_state_data.sub = exten_state_sub->sip_sub;
|
||||
|
||||
ast_sip_subscription_get_local_uri(exten_state_sub->sip_sub,
|
||||
task_data->exten_state_data.local, sizeof(task_data->exten_state_data.local));
|
||||
@@ -259,6 +225,9 @@ static int notify_task(void *obj)
|
||||
/* Pool allocation has to happen here so that we allocate within a PJLIB thread */
|
||||
task_data->exten_state_data.pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
|
||||
"exten_state", 1024, 1024);
|
||||
if (!task_data->exten_state_data.pool) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
task_data->exten_state_data.sub = task_data->exten_state_sub->sip_sub;
|
||||
|
||||
@@ -366,7 +335,7 @@ static int new_subscribe(struct ast_sip_endpoint *endpoint,
|
||||
return 200;
|
||||
}
|
||||
|
||||
static int initial_subscribe(struct ast_sip_subscription *sip_sub)
|
||||
static int subscription_established(struct ast_sip_subscription *sip_sub)
|
||||
{
|
||||
struct ast_sip_endpoint *endpoint = ast_sip_subscription_get_endpoint(sip_sub);
|
||||
const char *resource = ast_sip_subscription_get_resource_name(sip_sub);
|
||||
@@ -403,33 +372,77 @@ static int initial_subscribe(struct ast_sip_subscription *sip_sub)
|
||||
return -1;
|
||||
}
|
||||
|
||||
send_notify(exten_state_sub);
|
||||
ao2_cleanup(exten_state_sub);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int notify_required(struct ast_sip_subscription *sub,
|
||||
enum ast_sip_subscription_notify_reason reason)
|
||||
static void exten_state_data_destructor(void *obj)
|
||||
{
|
||||
struct ast_sip_exten_state_data *exten_state_data = obj;
|
||||
|
||||
ao2_cleanup(exten_state_data->device_state_info);
|
||||
ast_free(exten_state_data->presence_subtype);
|
||||
ast_free(exten_state_data->presence_message);
|
||||
if (exten_state_data->pool) {
|
||||
pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), exten_state_data->pool);
|
||||
}
|
||||
}
|
||||
|
||||
static struct ast_sip_exten_state_data *exten_state_data_alloc(struct ast_sip_subscription *sip_sub,
|
||||
struct exten_state_subscription *exten_state_sub)
|
||||
{
|
||||
struct ast_sip_exten_state_data *exten_state_data;
|
||||
char *subtype = NULL;
|
||||
char *message = NULL;
|
||||
|
||||
exten_state_data = ao2_alloc(sizeof(*exten_state_data), exten_state_data_destructor);
|
||||
if (!exten_state_data) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
exten_state_data->exten = exten_state_sub->exten;
|
||||
if ((exten_state_data->presence_state = ast_hint_presence_state(NULL, exten_state_sub->context,
|
||||
exten_state_sub->exten, &subtype, &message)) == -1) {
|
||||
ao2_cleanup(exten_state_data);
|
||||
return NULL;
|
||||
}
|
||||
exten_state_data->presence_subtype = subtype;
|
||||
exten_state_data->presence_message = message;
|
||||
exten_state_data->user_agent = exten_state_sub->user_agent;
|
||||
ast_sip_subscription_get_local_uri(sip_sub, exten_state_data->local,
|
||||
sizeof(exten_state_data->local));
|
||||
ast_sip_subscription_get_remote_uri(sip_sub, exten_state_data->remote,
|
||||
sizeof(exten_state_data->remote));
|
||||
exten_state_data->sub = sip_sub;
|
||||
|
||||
exten_state_data->exten_state = ast_extension_state_extended(
|
||||
NULL, exten_state_sub->context, exten_state_sub->exten,
|
||||
&exten_state_data->device_state_info);
|
||||
if (exten_state_data->exten_state < 0) {
|
||||
ao2_cleanup(exten_state_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
exten_state_data->pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
|
||||
"exten_state", 1024, 1024);
|
||||
if (!exten_state_data->pool) {
|
||||
ao2_cleanup(exten_state_data);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return exten_state_data;
|
||||
}
|
||||
|
||||
static void *get_notify_data(struct ast_sip_subscription *sub)
|
||||
{
|
||||
struct exten_state_subscription *exten_state_sub;
|
||||
|
||||
switch (reason) {
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_STARTED:
|
||||
return initial_subscribe(sub);
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_RENEWED:
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_TERMINATED:
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_OTHER:
|
||||
exten_state_sub = get_exten_state_sub(sub);
|
||||
|
||||
if (!exten_state_sub) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
send_notify(exten_state_sub);
|
||||
break;
|
||||
exten_state_sub = get_exten_state_sub(sub);
|
||||
if (!exten_state_sub) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
return exten_state_data_alloc(sub, exten_state_sub);
|
||||
}
|
||||
|
||||
static void to_ami(struct ast_sip_subscription *sub,
|
||||
|
@@ -48,17 +48,20 @@ AO2_GLOBAL_OBJ_STATIC(unsolicited_mwi);
|
||||
#define MWI_TYPE "application"
|
||||
#define MWI_SUBTYPE "simple-message-summary"
|
||||
|
||||
#define MWI_DATASTORE "MWI datastore"
|
||||
|
||||
static void mwi_subscription_shutdown(struct ast_sip_subscription *sub);
|
||||
static void mwi_to_ami(struct ast_sip_subscription *sub, struct ast_str **buf);
|
||||
static int mwi_new_subscribe(struct ast_sip_endpoint *endpoint,
|
||||
const char *resource);
|
||||
static int mwi_notify_required(struct ast_sip_subscription *sip_sub,
|
||||
enum ast_sip_subscription_notify_reason reason);
|
||||
static int mwi_subscription_established(struct ast_sip_subscription *sub);
|
||||
static void *mwi_get_notify_data(struct ast_sip_subscription *sub);
|
||||
|
||||
static struct ast_sip_notifier mwi_notifier = {
|
||||
.default_accept = MWI_TYPE"/"MWI_SUBTYPE,
|
||||
.new_subscribe = mwi_new_subscribe,
|
||||
.notify_required = mwi_notify_required,
|
||||
.subscription_established = mwi_subscription_established,
|
||||
.get_notify_data = mwi_get_notify_data,
|
||||
};
|
||||
|
||||
static struct ast_sip_subscription_handler mwi_handler = {
|
||||
@@ -457,7 +460,7 @@ static void mwi_subscription_shutdown(struct ast_sip_subscription *sub)
|
||||
{
|
||||
struct mwi_subscription *mwi_sub;
|
||||
RAII_VAR(struct ast_datastore *, mwi_datastore,
|
||||
ast_sip_subscription_get_datastore(sub, "MWI datastore"), ao2_cleanup);
|
||||
ast_sip_subscription_get_datastore(sub, MWI_DATASTORE), ao2_cleanup);
|
||||
|
||||
if (!mwi_datastore) {
|
||||
return;
|
||||
@@ -473,7 +476,7 @@ static int add_mwi_datastore(struct mwi_subscription *sub)
|
||||
{
|
||||
RAII_VAR(struct ast_datastore *, mwi_datastore, NULL, ao2_cleanup);
|
||||
|
||||
mwi_datastore = ast_sip_subscription_alloc_datastore(&mwi_ds_info, "MWI datastore");
|
||||
mwi_datastore = ast_sip_subscription_alloc_datastore(&mwi_ds_info, MWI_DATASTORE);
|
||||
if (!mwi_datastore) {
|
||||
return -1;
|
||||
}
|
||||
@@ -676,7 +679,7 @@ static int mwi_new_subscribe(struct ast_sip_endpoint *endpoint,
|
||||
return 200;
|
||||
}
|
||||
|
||||
static int mwi_initial_subscription(struct ast_sip_subscription *sip_sub)
|
||||
static int mwi_subscription_established(struct ast_sip_subscription *sip_sub)
|
||||
{
|
||||
const char *resource = ast_sip_subscription_get_resource_name(sip_sub);
|
||||
struct mwi_subscription *sub;
|
||||
@@ -694,39 +697,32 @@ static int mwi_initial_subscription(struct ast_sip_subscription *sip_sub)
|
||||
return -1;
|
||||
}
|
||||
|
||||
send_mwi_notify(sub);
|
||||
|
||||
ao2_cleanup(sub);
|
||||
ao2_cleanup(endpoint);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mwi_notify_required(struct ast_sip_subscription *sip_sub,
|
||||
enum ast_sip_subscription_notify_reason reason)
|
||||
static void *mwi_get_notify_data(struct ast_sip_subscription *sub)
|
||||
{
|
||||
struct ast_sip_message_accumulator *counter;
|
||||
struct mwi_subscription *mwi_sub;
|
||||
struct ast_datastore *mwi_datastore;
|
||||
|
||||
switch (reason) {
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_STARTED:
|
||||
return mwi_initial_subscription(sip_sub);
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_RENEWED:
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_TERMINATED:
|
||||
case AST_SIP_SUBSCRIPTION_NOTIFY_REASON_OTHER:
|
||||
mwi_datastore = ast_sip_subscription_get_datastore(sip_sub, "MWI datastore");
|
||||
mwi_datastore = ast_sip_subscription_get_datastore(sub, MWI_DATASTORE);
|
||||
if (!mwi_datastore) {
|
||||
return NULL;
|
||||
}
|
||||
mwi_sub = mwi_datastore->data;
|
||||
|
||||
if (!mwi_datastore) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
mwi_sub = mwi_datastore->data;
|
||||
|
||||
send_mwi_notify(mwi_sub);
|
||||
counter = ao2_alloc(sizeof(*counter), NULL);
|
||||
if (!counter) {
|
||||
ao2_cleanup(mwi_datastore);
|
||||
break;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
ao2_callback(mwi_sub->stasis_subs, OBJ_NODATA, get_message_count, counter);
|
||||
ao2_cleanup(mwi_datastore);
|
||||
return counter;
|
||||
}
|
||||
|
||||
static void mwi_subscription_mailboxes_str(struct ao2_container *stasis_subs,
|
||||
@@ -753,7 +749,7 @@ static void mwi_to_ami(struct ast_sip_subscription *sub,
|
||||
{
|
||||
struct mwi_subscription *mwi_sub;
|
||||
RAII_VAR(struct ast_datastore *, mwi_datastore,
|
||||
ast_sip_subscription_get_datastore(sub, "MWI datastore"), ao2_cleanup);
|
||||
ast_sip_subscription_get_datastore(sub, MWI_DATASTORE), ao2_cleanup);
|
||||
|
||||
if (!mwi_datastore) {
|
||||
return;
|
||||
|
@@ -81,7 +81,6 @@ static int pidf_generate_body_content(void *body, void *data)
|
||||
}
|
||||
|
||||
#define MAX_STRING_GROWTHS 5
|
||||
#define XML_PROLOG 39
|
||||
|
||||
static void pidf_to_string(void *body, struct ast_str **str)
|
||||
{
|
||||
@@ -91,13 +90,13 @@ static void pidf_to_string(void *body, struct ast_str **str)
|
||||
|
||||
do {
|
||||
size = pjpidf_print(pres, ast_str_buffer(*str), ast_str_size(*str) - 1);
|
||||
if (size == XML_PROLOG) {
|
||||
if (size == AST_PJSIP_XML_PROLOG_LEN) {
|
||||
ast_str_make_space(str, ast_str_size(*str) * 2);
|
||||
++growths;
|
||||
}
|
||||
} while (size == XML_PROLOG && growths < MAX_STRING_GROWTHS);
|
||||
} while (size == AST_PJSIP_XML_PROLOG_LEN && growths < MAX_STRING_GROWTHS);
|
||||
|
||||
if (size == XML_PROLOG) {
|
||||
if (size == AST_PJSIP_XML_PROLOG_LEN) {
|
||||
ast_log(LOG_WARNING, "PIDF body text too large\n");
|
||||
return;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -98,7 +98,6 @@ static int xpidf_generate_body_content(void *body, void *data)
|
||||
}
|
||||
|
||||
#define MAX_STRING_GROWTHS 5
|
||||
#define XML_PROLOG 39
|
||||
|
||||
static void xpidf_to_string(void *body, struct ast_str **str)
|
||||
{
|
||||
@@ -108,13 +107,13 @@ static void xpidf_to_string(void *body, struct ast_str **str)
|
||||
|
||||
do {
|
||||
size = pjxpidf_print(pres, ast_str_buffer(*str), ast_str_size(*str));
|
||||
if (size == XML_PROLOG) {
|
||||
if (size == AST_PJSIP_XML_PROLOG_LEN) {
|
||||
ast_str_make_space(str, ast_str_size(*str) * 2);
|
||||
++growths;
|
||||
}
|
||||
} while (size == XML_PROLOG && growths < MAX_STRING_GROWTHS);
|
||||
} while (size == AST_PJSIP_XML_PROLOG_LEN && growths < MAX_STRING_GROWTHS);
|
||||
|
||||
if (size == XML_PROLOG) {
|
||||
if (size == AST_PJSIP_XML_PROLOG_LEN) {
|
||||
ast_log(LOG_WARNING, "XPIDF body text too large\n");
|
||||
return;
|
||||
}
|
||||
|
Reference in New Issue
Block a user