Asterisk - The Open Source Telephony Project GIT-master-8f1982c
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Modules Pages
Data Structures | Macros | Enumerations | Functions
res_pjsip_pubsub.h File Reference
#include "asterisk/linkedlists.h"
Include dependency graph for res_pjsip_pubsub.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_sip_body_data
 Data used to create bodies for NOTIFY/PUBLISH requests. More...
 
struct  ast_sip_notifier
 
struct  ast_sip_publish_handler
 Callbacks that publication handlers will define. More...
 
struct  ast_sip_pubsub_body_generator
 Pubsub body generator. More...
 
struct  ast_sip_pubsub_body_supplement
 Body supplement. More...
 
struct  ast_sip_subscriber
 
struct  ast_sip_subscription_handler
 
struct  ast_sip_subscription_response_data
 Data for responses to SUBSCRIBEs and NOTIFIEs. More...
 

Macros

#define AST_SIP_DEVICE_FEATURE_SYNC_DATA   "ast_sip_device_feature_sync_data"
 
#define AST_SIP_EXTEN_STATE_DATA   "ast_sip_exten_state_data"
 
#define AST_SIP_MAX_ACCEPT   32
 
#define AST_SIP_MESSAGE_ACCUMULATOR   "ast_sip_message_accumulator"
 

Enumerations

enum  ast_sip_publish_state { AST_SIP_PUBLISH_STATE_INITIALIZED , AST_SIP_PUBLISH_STATE_ACTIVE , AST_SIP_PUBLISH_STATE_TERMINATED }
 
enum  ast_sip_subscription_notify_reason { AST_SIP_SUBSCRIPTION_NOTIFY_REASON_STARTED , AST_SIP_SUBSCRIPTION_NOTIFY_REASON_RENEWED , AST_SIP_SUBSCRIPTION_NOTIFY_REASON_TERMINATED , AST_SIP_SUBSCRIPTION_NOTIFY_REASON_OTHER }
 
enum  ast_sip_subscription_role { AST_SIP_SUBSCRIBER , AST_SIP_NOTIFIER }
 Role for the subscription that is being created. More...
 

Functions

struct ast_sip_subscriptionast_sip_create_subscription (const struct ast_sip_subscription_handler *handler, struct ast_sip_endpoint *endpoint, const char *resource)
 Create a new ast_sip_subscription structure. More...
 
int ast_sip_publication_add_datastore (struct ast_sip_publication *publication, struct ast_datastore *datastore)
 Add a datastore to a SIP publication. More...
 
struct ast_datastoreast_sip_publication_get_datastore (struct ast_sip_publication *publication, const char *name)
 Retrieve a publication datastore. More...
 
struct ao2_containerast_sip_publication_get_datastores (const struct ast_sip_publication *publication)
 Get the datastores container for a publication. More...
 
struct ast_sip_endpointast_sip_publication_get_endpoint (struct ast_sip_publication *pub)
 Given a publication, get the associated endpoint. More...
 
const char * ast_sip_publication_get_event_configuration (const struct ast_sip_publication *pub)
 Given a publication, get the configuration name for the event type in use. More...
 
const char * ast_sip_publication_get_resource (const struct ast_sip_publication *pub)
 Given a publication, get the resource the publication is to. More...
 
void ast_sip_publication_remove_datastore (struct ast_sip_publication *publication, const char *name)
 Remove a publication datastore from the publication. More...
 
int ast_sip_pubsub_generate_body_content (const char *content_type, const char *content_subtype, struct ast_sip_body_data *data, struct ast_str **str)
 Generate body content for a PUBLISH or NOTIFY. More...
 
int ast_sip_pubsub_is_body_generator_registered (const char *type, const char *subtype)
 Is a body generator registered for the given type/subtype. More...
 
int ast_sip_pubsub_register_body_generator (struct ast_sip_pubsub_body_generator *generator)
 Register a body generator with the pubsub core. More...
 
int ast_sip_pubsub_register_body_supplement (struct ast_sip_pubsub_body_supplement *supplement)
 Register a body generator with the pubsub core. More...
 
void ast_sip_pubsub_unregister_body_generator (struct ast_sip_pubsub_body_generator *generator)
 Unregister a body generator with the pubsub core. More...
 
void ast_sip_pubsub_unregister_body_supplement (struct ast_sip_pubsub_body_supplement *supplement)
 Unregister a body generator with the pubsub core. More...
 
int ast_sip_register_publish_handler (struct ast_sip_publish_handler *handler)
 Register a publish handler. More...
 
int ast_sip_register_subscription_handler (struct ast_sip_subscription_handler *handler)
 Register a subscription handler. More...
 
int ast_sip_subscription_add_datastore (struct ast_sip_subscription *subscription, struct ast_datastore *datastore)
 Add a datastore to a SIP subscription. More...
 
struct ast_datastoreast_sip_subscription_alloc_datastore (const struct ast_datastore_info *info, const char *uid)
 Alternative for ast_datastore_alloc() More...
 
void ast_sip_subscription_destroy (struct ast_sip_subscription *sub)
 Alert the pubsub core that the subscription is ready for destruction. More...
 
const char * ast_sip_subscription_get_body_subtype (struct ast_sip_subscription *sub)
 Get the body subtype used for this subscription. More...
 
const char * ast_sip_subscription_get_body_type (struct ast_sip_subscription *sub)
 Get the body type used for this subscription. More...
 
struct ast_datastoreast_sip_subscription_get_datastore (struct ast_sip_subscription *subscription, const char *name)
 Retrieve a subscription datastore. More...
 
struct ao2_containerast_sip_subscription_get_datastores (const struct ast_sip_subscription *subscription)
 Get the datastores container for a subscription. More...
 
pjsip_dialog * ast_sip_subscription_get_dialog (struct ast_sip_subscription *sub)
 Get the pjsip dialog that is associated with this subscription. More...
 
struct ast_sip_endpointast_sip_subscription_get_endpoint (struct ast_sip_subscription *sub)
 Get the endpoint that is associated with this subscription. More...
 
void * ast_sip_subscription_get_header (const struct ast_sip_subscription *sub, const char *header)
 Get a header value for a subscription. More...
 
void ast_sip_subscription_get_local_uri (struct ast_sip_subscription *sub, char *buf, size_t size)
 Retrieve the local URI for this subscription. More...
 
const struct ast_jsonast_sip_subscription_get_persistence_data (const struct ast_sip_subscription *subscription)
 Retrieve persistence data for a subscription. More...
 
void ast_sip_subscription_get_remote_uri (struct ast_sip_subscription *sub, char *buf, size_t size)
 Retrive the remote URI for this subscription. More...
 
const char * ast_sip_subscription_get_resource_name (struct ast_sip_subscription *sub)
 Get the name of the subscribed resource. More...
 
struct ast_taskprocessorast_sip_subscription_get_serializer (struct ast_sip_subscription *sub)
 Get the serializer for the subscription. More...
 
pjsip_sip_uri * ast_sip_subscription_get_sip_uri (struct ast_sip_subscription *sub)
 Retrieve the local sip uri for this subscription. More...
 
int ast_sip_subscription_is_terminated (const struct ast_sip_subscription *sub)
 Get whether the subscription has been terminated or not. More...
 
int ast_sip_subscription_notify (struct ast_sip_subscription *sub, struct ast_sip_body_data *notify_data, int terminate)
 Notify a SIP subscription of a state change. More...
 
void ast_sip_subscription_remove_datastore (struct ast_sip_subscription *subscription, const char *name)
 Remove a subscription datastore from the subscription. More...
 
int ast_sip_subscription_send_request (struct ast_sip_subscription *sub, pjsip_tx_data *tdata)
 Send a request created via a PJSIP evsub method. More...
 
void ast_sip_subscription_set_persistence_data (struct ast_sip_subscription *subscription, struct ast_json *persistence_data)
 Set persistence data for a subscription. More...
 
void ast_sip_unregister_publish_handler (struct ast_sip_publish_handler *handler)
 Unregister a publish handler. More...
 
void ast_sip_unregister_subscription_handler (struct ast_sip_subscription_handler *handler)
 Unregister a subscription handler. More...
 

Macro Definition Documentation

◆ AST_SIP_DEVICE_FEATURE_SYNC_DATA

#define AST_SIP_DEVICE_FEATURE_SYNC_DATA   "ast_sip_device_feature_sync_data"

Type used for device feature synchronization

Definition at line 236 of file res_pjsip_pubsub.h.

◆ AST_SIP_EXTEN_STATE_DATA

#define AST_SIP_EXTEN_STATE_DATA   "ast_sip_exten_state_data"

Type used for extension state/presence

Definition at line 232 of file res_pjsip_pubsub.h.

◆ AST_SIP_MAX_ACCEPT

#define AST_SIP_MAX_ACCEPT   32

Definition at line 219 of file res_pjsip_pubsub.h.

◆ AST_SIP_MESSAGE_ACCUMULATOR

#define AST_SIP_MESSAGE_ACCUMULATOR   "ast_sip_message_accumulator"

Type used for conveying mailbox state

Definition at line 234 of file res_pjsip_pubsub.h.

Enumeration Type Documentation

◆ ast_sip_publish_state

Enumerator
AST_SIP_PUBLISH_STATE_INITIALIZED 

Publication has just been initialized

AST_SIP_PUBLISH_STATE_ACTIVE 

Publication is currently active

AST_SIP_PUBLISH_STATE_TERMINATED 

Publication has been terminated

Definition at line 37 of file res_pjsip_pubsub.h.

37 {
38 /*! Publication has just been initialized */
40 /*! Publication is currently active */
42 /*! Publication has been terminated */
44};
@ AST_SIP_PUBLISH_STATE_ACTIVE
@ AST_SIP_PUBLISH_STATE_TERMINATED
@ AST_SIP_PUBLISH_STATE_INITIALIZED

◆ ast_sip_subscription_notify_reason

Enumerator
AST_SIP_SUBSCRIPTION_NOTIFY_REASON_STARTED 

Initial NOTIFY for subscription

AST_SIP_SUBSCRIPTION_NOTIFY_REASON_RENEWED 

Subscription has been renewed

AST_SIP_SUBSCRIPTION_NOTIFY_REASON_TERMINATED 

Subscription is being terminated

AST_SIP_SUBSCRIPTION_NOTIFY_REASON_OTHER 

Other unspecified reason

Definition at line 220 of file res_pjsip_pubsub.h.

220 {
221 /*! Initial NOTIFY for subscription */
223 /*! Subscription has been renewed */
225 /*! Subscription is being terminated */
227 /*! Other unspecified reason */
229};
@ AST_SIP_SUBSCRIPTION_NOTIFY_REASON_RENEWED
@ AST_SIP_SUBSCRIPTION_NOTIFY_REASON_STARTED
@ AST_SIP_SUBSCRIPTION_NOTIFY_REASON_OTHER
@ AST_SIP_SUBSCRIPTION_NOTIFY_REASON_TERMINATED

◆ ast_sip_subscription_role

Role for the subscription that is being created.

Enumerator
AST_SIP_SUBSCRIBER 
AST_SIP_NOTIFIER 

Definition at line 190 of file res_pjsip_pubsub.h.

190 {
191 /* Sending SUBSCRIBEs, receiving NOTIFYs */
193 /* Sending NOTIFYs, receiving SUBSCRIBEs */
195};
@ AST_SIP_SUBSCRIBER
@ AST_SIP_NOTIFIER

Function Documentation

◆ ast_sip_create_subscription()

struct ast_sip_subscription * ast_sip_create_subscription ( const struct ast_sip_subscription_handler handler,
struct ast_sip_endpoint endpoint,
const char *  resource 
)

Create a new ast_sip_subscription structure.

When a subscriber wishes to create a subscription, it may call this function to allocate resources and to send the initial SUBSCRIBE out.

Parameters
handlerThe subscriber that is making the request.
endpointThe endpoint to whome the SUBSCRIBE will be sent.
resourceThe resource to place in the SUBSCRIBE's Request-URI.

Definition at line 2116 of file res_pjsip_pubsub.c.

2118{
2119 struct ast_sip_subscription *sub;
2120 pjsip_dialog *dlg;
2121 struct ast_sip_contact *contact;
2122 pj_str_t event;
2123 pjsip_tx_data *tdata;
2124 pjsip_evsub *evsub;
2125 struct sip_subscription_tree *sub_tree = NULL;
2126
2128 if (!sub_tree) {
2129 return NULL;
2130 }
2131
2132 sub = allocate_subscription(handler, resource, NULL, sub_tree);
2133 if (!sub) {
2134 ao2_cleanup(sub_tree);
2135 return NULL;
2136 }
2137
2139 if (!contact || ast_strlen_zero(contact->uri)) {
2140 ast_log(LOG_WARNING, "No contacts configured for endpoint %s. Unable to create SIP subsription\n",
2142 ao2_ref(sub_tree, -1);
2143 ao2_cleanup(contact);
2144 return NULL;
2145 }
2146
2148 ao2_cleanup(contact);
2149 if (!dlg) {
2150 ast_log(LOG_WARNING, "Unable to create dialog for SIP subscription\n");
2151 ao2_ref(sub_tree, -1);
2152 return NULL;
2153 }
2154
2155 pj_cstr(&event, handler->event_name);
2156 pjsip_evsub_create_uac(dlg, &pubsub_cb, &event, 0, &sub_tree->evsub);
2157 subscription_setup_dialog(sub_tree, dlg);
2158
2159 evsub = sub_tree->evsub;
2160
2161 if (pjsip_evsub_initiate(evsub, NULL, -1, &tdata) == PJ_SUCCESS) {
2162 pjsip_evsub_send_request(sub_tree->evsub, tdata);
2163 } else {
2164 /* pjsip_evsub_terminate will result in pubsub_on_evsub_state,
2165 * being called and terminating the subscription. Therefore, we don't
2166 * need to decrease the reference count of sub here.
2167 */
2168 pjsip_evsub_terminate(evsub, PJ_TRUE);
2169 ao2_ref(sub_tree, -1);
2170 return NULL;
2171 }
2172
2173 add_subscription(sub_tree);
2174
2175 return sub;
2176}
#define ast_log
Definition: astobj2.c:42
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
#define LOG_WARNING
struct stasis_forward * sub
Definition: res_corosync.c:240
struct ast_sip_contact * ast_sip_location_retrieve_contact_from_aor_list(const char *aor_list)
Retrieve the first bound contact from a list of AORs.
Definition: location.c:304
pjsip_dialog * ast_sip_create_dialog_uac(const struct ast_sip_endpoint *endpoint, const char *aor_name, const char *request_user)
General purpose method for creating a UAC dialog with an endpoint.
Definition: res_pjsip.c:964
static struct ast_sip_subscription * allocate_subscription(const struct ast_sip_subscription_handler *handler, const char *resource, const char *display_name, struct sip_subscription_tree *tree)
static pjsip_evsub_user pubsub_cb
static void add_subscription(struct sip_subscription_tree *obj)
static void subscription_setup_dialog(struct sip_subscription_tree *sub_tree, pjsip_dialog *dlg)
static struct sip_subscription_tree * allocate_subscription_tree(struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
#define NULL
Definition: resample.c:96
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2317
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Contact associated with an address of record.
Definition: res_pjsip.h:390
const ast_string_field uri
Definition: res_pjsip.h:412
const ast_string_field aors
Definition: res_pjsip.h:1080
Structure representing a "virtual" SIP subscription.
Definition: astman.c:222
A tree of SIP subscriptions.
struct ast_sip_endpoint * endpoint
static void handler(const char *name, int response_code, struct ast_variable *get_params, struct ast_variable *path_vars, struct ast_variable *headers, struct ast_json *body, struct ast_ari_response *response)
Definition: test_ari.c:59

References add_subscription(), allocate_subscription(), allocate_subscription_tree(), ao2_cleanup, ao2_ref, ast_sip_endpoint::aors, ast_log, ast_sip_create_dialog_uac(), ast_sip_location_retrieve_contact_from_aor_list(), ast_sorcery_object_get_id(), ast_strlen_zero(), sip_subscription_tree::dlg, sip_subscription_tree::endpoint, sip_subscription_tree::evsub, handler(), LOG_WARNING, NULL, pubsub_cb, sub, subscription_setup_dialog(), and ast_sip_contact::uri.

◆ ast_sip_publication_add_datastore()

int ast_sip_publication_add_datastore ( struct ast_sip_publication publication,
struct ast_datastore datastore 
)

Add a datastore to a SIP publication.

Note that SIP uses reference counted datastores. The datastore passed into this function must have been allocated using ao2_alloc() or there will be serious problems.

Parameters
publicationThe publication to add the datastore to
datastoreThe datastore to be added to the subscription
Return values
0Success
-1Failure

Definition at line 2920 of file res_pjsip_pubsub.c.

2921{
2922 return ast_datastores_add(publication->datastores, datastore);
2923}
int ast_datastores_add(struct ao2_container *datastores, struct ast_datastore *datastore)
Add a data store to a container.
Definition: datastore.c:105
struct ao2_container * datastores

References ast_datastores_add(), and ast_sip_publication::datastores.

◆ ast_sip_publication_get_datastore()

struct ast_datastore * ast_sip_publication_get_datastore ( struct ast_sip_publication publication,
const char *  name 
)

Retrieve a publication datastore.

The datastore retrieved will have its reference count incremented. When the caller is done with the datastore, the reference counted needs to be decremented using ao2_ref().

Parameters
publicationThe publication from which to retrieve the datastore
nameThe name of the datastore to retrieve
Return values
NULLFailed to find the specified datastore
non-NULLThe specified datastore

Definition at line 2925 of file res_pjsip_pubsub.c.

2926{
2927 return ast_datastores_find(publication->datastores, name);
2928}
struct ast_datastore * ast_datastores_find(struct ao2_container *datastores, const char *name)
Find a data store in a container.
Definition: datastore.c:123
static const char name[]
Definition: format_mp3.c:68

References ast_datastores_find(), ast_sip_publication::datastores, and name.

◆ ast_sip_publication_get_datastores()

struct ao2_container * ast_sip_publication_get_datastores ( const struct ast_sip_publication publication)

Get the datastores container for a publication.

Parameters
publicationThe publication to get the datastores container from
Return values
NULLdatastores container not present
non-NULLdatastores container
Note
The container is NOT returned with reference count bumped
Since
14.0.0

Definition at line 2935 of file res_pjsip_pubsub.c.

2936{
2937 return publication->datastores;
2938}

References ast_sip_publication::datastores.

◆ ast_sip_publication_get_endpoint()

struct ast_sip_endpoint * ast_sip_publication_get_endpoint ( struct ast_sip_publication pub)

Given a publication, get the associated endpoint.

Parameters
pubThe publication
Return values
NULLFailure
non-NULLThe associated endpoint

Definition at line 3694 of file res_pjsip_pubsub.c.

3695{
3696 return pub->endpoint;
3697}
struct ast_sip_endpoint * endpoint
The endpoint with which the subscription is communicating.

References ast_sip_publication::endpoint.

◆ ast_sip_publication_get_event_configuration()

const char * ast_sip_publication_get_event_configuration ( const struct ast_sip_publication pub)

Given a publication, get the configuration name for the event type in use.

Parameters
pubThe publication
Returns
The configuration name

Definition at line 3704 of file res_pjsip_pubsub.c.

3705{
3706 return pub->event_configuration_name;
3707}
char * event_configuration_name
The name of the event type configuration.

References ast_sip_publication::event_configuration_name.

Referenced by asterisk_publication_devicestate_state_change(), and asterisk_publication_mwi_state_change().

◆ ast_sip_publication_get_resource()

const char * ast_sip_publication_get_resource ( const struct ast_sip_publication pub)

Given a publication, get the resource the publication is to.

Parameters
pubThe publication
Returns
The resource

Definition at line 3699 of file res_pjsip_pubsub.c.

3700{
3701 return pub->resource;
3702}
char * resource
The resource the publication is to.

References ast_sip_publication::resource.

◆ ast_sip_publication_remove_datastore()

void ast_sip_publication_remove_datastore ( struct ast_sip_publication publication,
const char *  name 
)

Remove a publication datastore from the publication.

This operation may cause the datastore's free() callback to be called if the reference count reaches zero.

Parameters
publicationThe publication to remove the datastore from
nameThe name of the datastore to remove

Definition at line 2930 of file res_pjsip_pubsub.c.

2931{
2932 ast_datastores_remove(publication->datastores, name);
2933}
void ast_datastores_remove(struct ao2_container *datastores, const char *name)
Remove a data store from a container.
Definition: datastore.c:118

References ast_datastores_remove(), ast_sip_publication::datastores, and name.

◆ ast_sip_pubsub_generate_body_content()

int ast_sip_pubsub_generate_body_content ( const char *  content_type,
const char *  content_subtype,
struct ast_sip_body_data data,
struct ast_str **  str 
)

Generate body content for a PUBLISH or NOTIFY.

Since
13.0.0

This function takes a pre-allocated body and calls into registered body generators in order to fill in the body with appropriate details. The primary body generator will be called first, followed by the supplementary body generators

Parameters
content_typeThe content type of the body
content_subtypeThe content subtype of the body
dataThe data associated with body generation.
[out]strThe string representation of the generated body
Return values
0Success
non-zeroFailure

Definition at line 3793 of file res_pjsip_pubsub.c.

3795{
3796 struct ast_sip_pubsub_body_supplement *supplement;
3797 struct ast_sip_pubsub_body_generator *generator;
3798 int res = 0;
3799 void *body;
3800
3802 if (!generator) {
3803 ast_log(LOG_WARNING, "Unable to find a body generator for %s/%s\n",
3804 type, subtype);
3805 return -1;
3806 }
3807
3808 if (strcmp(data->body_type, generator->body_type)) {
3809 ast_log(LOG_WARNING, "%s/%s body generator does not accept the type of data provided\n",
3810 type, subtype);
3811 return -1;
3812 }
3813
3814 body = generator->allocate_body(data->body_data);
3815 if (!body) {
3816 ast_log(LOG_WARNING, "%s/%s body generator could not to allocate a body\n",
3817 type, subtype);
3818 return -1;
3819 }
3820
3821 if (generator->generate_body_content(body, data->body_data)) {
3822 res = -1;
3823 goto end;
3824 }
3825
3828 if (!strcmp(generator->type, supplement->type) &&
3829 !strcmp(generator->subtype, supplement->subtype)) {
3830 res = supplement->supplement_body(body, data->body_data);
3831 if (res) {
3832 break;
3833 }
3834 }
3835 }
3837
3838 if (!res) {
3839 generator->to_string(body, str);
3840 }
3841
3842end:
3843 if (generator->destroy_body) {
3844 generator->destroy_body(body);
3845 }
3846
3847 return res;
3848}
const char * str
Definition: app_jack.c:150
static const char type[]
Definition: chan_ooh323.c:109
char * end
Definition: eagi_proxy.c:73
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:494
static struct ast_sip_pubsub_body_generator * find_body_generator_type_subtype(const char *type, const char *subtype)
const char * body_type
Pubsub body generator.
void(* to_string)(void *body, struct ast_str **str)
Convert the body to a string.
struct ast_sip_pubsub_body_generator::@263 list
void(* destroy_body)(void *body)
Deallocate resources created for the body.
const char * type
Content type In "plain/text", "plain" is the type.
const char * subtype
Content subtype In "plain/text", "text" is the subtype.
void *(* allocate_body)(void *data)
allocate body structure.
int(* generate_body_content)(void *body, void *data)
Add content to the body of a SIP request.
int(* supplement_body)(void *body, void *data)
Add additional content to a SIP request body.
const char * type
Content type In "plain/text", "plain" is the type.
const char * subtype
Content subtype In "plain/text", "text" is the subtype.

References ast_sip_pubsub_body_generator::allocate_body, ast_log, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, ast_sip_body_data::body_data, ast_sip_body_data::body_type, ast_sip_pubsub_body_generator::body_type, ast_sip_pubsub_body_generator::destroy_body, end, find_body_generator_type_subtype(), ast_sip_pubsub_body_generator::generate_body_content, ast_sip_pubsub_body_generator::list, LOG_WARNING, str, ast_sip_pubsub_body_generator::subtype, ast_sip_pubsub_body_supplement::subtype, ast_sip_pubsub_body_supplement::supplement_body, ast_sip_pubsub_body_generator::to_string, type, ast_sip_pubsub_body_generator::type, and ast_sip_pubsub_body_supplement::type.

Referenced by ast_sip_subscription_notify(), exten_state_publisher_cb(), generate_initial_notify(), and send_unsolicited_mwi_notify_to_contact().

◆ ast_sip_pubsub_is_body_generator_registered()

int ast_sip_pubsub_is_body_generator_registered ( const char *  type,
const char *  subtype 
)

Is a body generator registered for the given type/subtype.

Since
14.0.0
Parameters
typeThe content type of the body
subtypeThe content subtype of the body
Note
In "plain/text", "plain" is the type and "text" is the subtype.
Return values
non-zeroif a generator is registered.

Definition at line 3709 of file res_pjsip_pubsub.c.

3710{
3711 return !!find_body_generator_type_subtype(type, subtype);
3712}

References find_body_generator_type_subtype(), and type.

Referenced by publisher_start().

◆ ast_sip_pubsub_register_body_generator()

int ast_sip_pubsub_register_body_generator ( struct ast_sip_pubsub_body_generator generator)

Register a body generator with the pubsub core.

Since
13.0.0

This may fail if an attempt is made to register a primary body supplement for a given content type if a primary body supplement for that content type has already been registered.

Parameters
generatorBody generator to register
Return values
0Success
-1Failure

Definition at line 3714 of file res_pjsip_pubsub.c.

3715{
3716 struct ast_sip_pubsub_body_generator *existing;
3717 pj_str_t accept;
3718 pj_size_t accept_len;
3719
3721 existing = find_body_generator_type_subtype_nolock(generator->type, generator->subtype);
3722 if (existing) {
3724 ast_log(LOG_WARNING, "A body generator for %s/%s is already registered.\n",
3725 generator->type, generator->subtype);
3726 return -1;
3727 }
3730
3731 /* Lengths of type and subtype plus a slash. */
3732 accept_len = strlen(generator->type) + strlen(generator->subtype) + 1;
3733
3734 /* Add room for null terminator that sprintf() will set. */
3735 pj_strset(&accept, ast_alloca(accept_len + 1), accept_len);
3736 sprintf((char *) pj_strbuf(&accept), "%s/%s", generator->type, generator->subtype);/* Safe */
3737
3738 pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), &pubsub_module,
3739 PJSIP_H_ACCEPT, NULL, 1, &accept);
3740
3741 return 0;
3742}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:520
static struct pjsip_module pubsub_module
static struct ast_sip_pubsub_body_generator * find_body_generator_type_subtype_nolock(const char *type, const char *subtype)

References ast_alloca, AST_LIST_INSERT_HEAD, ast_log, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_sip_get_pjsip_endpoint(), find_body_generator_type_subtype_nolock(), ast_sip_pubsub_body_generator::list, LOG_WARNING, NULL, pubsub_module, ast_sip_pubsub_body_generator::subtype, and ast_sip_pubsub_body_generator::type.

Referenced by load_module().

◆ ast_sip_pubsub_register_body_supplement()

int ast_sip_pubsub_register_body_supplement ( struct ast_sip_pubsub_body_supplement supplement)

Register a body generator with the pubsub core.

Since
13.0.0

This may fail if an attempt is made to register a primary body supplement for a given content type if a primary body supplement for that content type has already been registered.

Parameters
supplementBody generator to register
Return values
0Success
-1Failure

Definition at line 3759 of file res_pjsip_pubsub.c.

3760{
3762 AST_RWLIST_INSERT_TAIL(&body_supplements, supplement, list);
3764
3765 return 0;
3766}
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:741

References AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and ast_sip_pubsub_body_generator::list.

Referenced by load_module().

◆ ast_sip_pubsub_unregister_body_generator()

void ast_sip_pubsub_unregister_body_generator ( struct ast_sip_pubsub_body_generator generator)

Unregister a body generator with the pubsub core.

Since
13.0.0
Parameters
generatorBody generator to unregister

Definition at line 3744 of file res_pjsip_pubsub.c.

3745{
3746 struct ast_sip_pubsub_body_generator *iter;
3747
3750 if (iter == generator) {
3752 break;
3753 }
3754 }
3757}
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
Definition: linkedlists.h:545
#define AST_RWLIST_TRAVERSE_SAFE_END
Definition: linkedlists.h:617
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557

References AST_LIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and ast_sip_pubsub_body_generator::list.

Referenced by unload_module(), and unregister_all().

◆ ast_sip_pubsub_unregister_body_supplement()

void ast_sip_pubsub_unregister_body_supplement ( struct ast_sip_pubsub_body_supplement supplement)

Unregister a body generator with the pubsub core.

Since
13.0.0
Parameters
supplementBody generator to unregister

Definition at line 3768 of file res_pjsip_pubsub.c.

3769{
3770 struct ast_sip_pubsub_body_supplement *iter;
3771
3774 if (iter == supplement) {
3776 break;
3777 }
3778 }
3781}
struct ast_sip_pubsub_body_supplement::@264 list

References AST_LIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and ast_sip_pubsub_body_supplement::list.

Referenced by unload_module().

◆ ast_sip_register_publish_handler()

int ast_sip_register_publish_handler ( struct ast_sip_publish_handler handler)

Register a publish handler.

Return values
0Handler was registered successfully
non-zeroHandler was not registered successfully

Definition at line 2989 of file res_pjsip_pubsub.c.

2990{
2991 if (ast_strlen_zero(handler->event_name)) {
2992 ast_log(LOG_ERROR, "No event package specified for publish handler. Cannot register\n");
2993 return -1;
2994 }
2995
2998 if (!handler->publications) {
2999 ast_log(LOG_ERROR, "Could not allocate publications container for event '%s'\n",
3000 handler->event_name);
3001 return -1;
3002 }
3003
3005
3006 return 0;
3007}
@ AO2_ALLOC_OPT_LOCK_MUTEX
Definition: astobj2.h:363
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Allocate and initialize a hash container with the desired number of buckets.
Definition: astobj2.h:1303
#define LOG_ERROR
static int publication_hash_fn(const void *obj, const int flags)
static int publication_cmp_fn(void *obj, void *arg, int flags)
#define PUBLICATIONS_BUCKETS
Number of buckets for publications (on a per handler)
static void publish_add_handler(struct ast_sip_publish_handler *handler)

References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_log, ast_strlen_zero(), handler(), LOG_ERROR, NULL, publication_cmp_fn(), publication_hash_fn(), PUBLICATIONS_BUCKETS, and publish_add_handler().

Referenced by load_module().

◆ ast_sip_register_subscription_handler()

int ast_sip_register_subscription_handler ( struct ast_sip_subscription_handler handler)

Register a subscription handler.

Return values
0Handler was registered successfully
non-zeroHandler was not registered successfully

Definition at line 3048 of file res_pjsip_pubsub.c.

3049{
3050 pj_str_t event;
3051 pj_str_t accept[AST_SIP_MAX_ACCEPT] = { {0, }, };
3052 struct ast_sip_subscription_handler *existing;
3053 int i = 0;
3054
3055 if (ast_strlen_zero(handler->event_name)) {
3056 ast_log(LOG_ERROR, "No event package specified for subscription handler. Cannot register\n");
3057 return -1;
3058 }
3059
3060 existing = find_sub_handler_for_event_name(handler->event_name);
3061 if (existing) {
3063 "Unable to register subscription handler for event %s. A handler is already registered\n",
3064 handler->event_name);
3065 return -1;
3066 }
3067
3068 for (i = 0; i < AST_SIP_MAX_ACCEPT && !ast_strlen_zero(handler->accept[i]); ++i) {
3069 pj_cstr(&accept[i], handler->accept[i]);
3070 }
3071
3072 pj_cstr(&event, handler->event_name);
3073
3074 pjsip_evsub_register_pkg(&pubsub_module, &event, DEFAULT_EXPIRES, i, accept);
3075
3077
3078 return 0;
3079}
static struct ast_sip_subscription_handler * find_sub_handler_for_event_name(const char *event_name)
static void sub_add_handler(struct ast_sip_subscription_handler *handler)
#define DEFAULT_EXPIRES
Default expiration for subscriptions.
#define AST_SIP_MAX_ACCEPT
const char * accept[AST_SIP_MAX_ACCEPT]

References ast_sip_subscription_handler::accept, ast_log, AST_SIP_MAX_ACCEPT, ast_strlen_zero(), DEFAULT_EXPIRES, find_sub_handler_for_event_name(), handler(), LOG_ERROR, pubsub_module, and sub_add_handler().

Referenced by load_module().

◆ ast_sip_subscription_add_datastore()

int ast_sip_subscription_add_datastore ( struct ast_sip_subscription subscription,
struct ast_datastore datastore 
)

Add a datastore to a SIP subscription.

Note that SIP uses reference counted datastores. The datastore passed into this function must have been allocated using ao2_alloc() or there will be serious problems.

Parameters
subscriptionThe ssubscription to add the datastore to
datastoreThe datastore to be added to the subscription
Return values
0Success
-1Failure

Definition at line 2900 of file res_pjsip_pubsub.c.

2901{
2902 return ast_datastores_add(subscription->datastores, datastore);
2903}
struct ao2_container * datastores

References ast_datastores_add(), and ast_sip_subscription::datastores.

Referenced by add_datastore(), and add_mwi_datastore().

◆ ast_sip_subscription_alloc_datastore()

struct ast_datastore * ast_sip_subscription_alloc_datastore ( const struct ast_datastore_info info,
const char *  uid 
)

Alternative for ast_datastore_alloc()

There are two major differences between this and ast_datastore_alloc() 1) This allocates a refcounted object 2) This will fill in a uid if one is not provided

DO NOT call ast_datastore_free() on a datastore allocated in this way since that function will attempt to free the datastore rather than play nicely with its refcount.

Parameters
infoCallbacks for datastore
uidIdentifier for datastore
Return values
NULLFailed to allocate datastore
non-NULLNewly allocated datastore

Definition at line 2895 of file res_pjsip_pubsub.c.

2896{
2898}
struct ast_datastore * ast_datastores_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Allocate a datastore for use with the datastores container.
Definition: datastore.c:142
def info(msg)

References ast_datastores_alloc_datastore(), sip_to_pjsip::info(), and ast_datastore::uid.

Referenced by add_datastore(), and add_mwi_datastore().

◆ ast_sip_subscription_destroy()

void ast_sip_subscription_destroy ( struct ast_sip_subscription sub)

Alert the pubsub core that the subscription is ready for destruction.

Since
13.6.0
Parameters
subThe subscription that is complete

Definition at line 1636 of file res_pjsip_pubsub.c.

1637{
1638 ast_debug(3, "Removing subscription %p '%s->%s' reference to subscription tree %p\n",
1639 sub, ast_sorcery_object_get_id(sub->tree->endpoint), sub->resource, sub->tree);
1640 ao2_cleanup(sub->tree);
1641}
#define ast_debug(level,...)
Log a DEBUG message.

References ao2_cleanup, ast_debug, ast_sorcery_object_get_id(), and sub.

Referenced by exten_state_subscription_destructor(), and mwi_subscription_destructor().

◆ ast_sip_subscription_get_body_subtype()

const char * ast_sip_subscription_get_body_subtype ( struct ast_sip_subscription sub)

Get the body subtype used for this subscription.

Since
13.0.0

Definition at line 3788 of file res_pjsip_pubsub.c.

3789{
3790 return sub->body_generator->subtype;
3791}

References sub.

Referenced by ast_sip_subscription_notify(), generate_initial_notify(), and generate_notify_body().

◆ ast_sip_subscription_get_body_type()

const char * ast_sip_subscription_get_body_type ( struct ast_sip_subscription sub)

Get the body type used for this subscription.

Since
13.0.0

Definition at line 3783 of file res_pjsip_pubsub.c.

3784{
3785 return sub->body_generator->type;
3786}

References sub.

Referenced by ast_sip_subscription_notify(), generate_initial_notify(), and generate_notify_body().

◆ ast_sip_subscription_get_datastore()

struct ast_datastore * ast_sip_subscription_get_datastore ( struct ast_sip_subscription subscription,
const char *  name 
)

Retrieve a subscription datastore.

The datastore retrieved will have its reference count incremented. When the caller is done with the datastore, the reference counted needs to be decremented using ao2_ref().

Parameters
subscriptionThe subscription from which to retrieve the datastore
nameThe name of the datastore to retrieve
Return values
NULLFailed to find the specified datastore
non-NULLThe specified datastore

Definition at line 2905 of file res_pjsip_pubsub.c.

2906{
2907 return ast_datastores_find(subscription->datastores, name);
2908}

References ast_datastores_find(), ast_sip_subscription::datastores, and name.

Referenced by get_exten_state_sub(), mwi_get_notify_data(), mwi_subscription_shutdown(), and mwi_to_ami().

◆ ast_sip_subscription_get_datastores()

struct ao2_container * ast_sip_subscription_get_datastores ( const struct ast_sip_subscription subscription)

Get the datastores container for a subscription.

Parameters
subscriptionThe subscription to get the datastores container from
Return values
NULLdatastores container not present
non-NULLdatastores container
Note
The container is NOT returned with reference count bumped
Since
14.0.0

Definition at line 2915 of file res_pjsip_pubsub.c.

2916{
2917 return subscription->datastores;
2918}

References ast_sip_subscription::datastores.

Referenced by alloc_notify_task_data(), exten_state_data_alloc(), and notify_task().

◆ ast_sip_subscription_get_dialog()

pjsip_dialog * ast_sip_subscription_get_dialog ( struct ast_sip_subscription sub)

Get the pjsip dialog that is associated with this subscription.

Since
13.9.0
Return values
NULLCould not get dialog
non-NULLThe dialog

Definition at line 2178 of file res_pjsip_pubsub.c.

2179{
2180 ast_assert(sub->tree->dlg != NULL);
2181 return sub->tree->dlg;
2182}
#define ast_assert(a)
Definition: utils.h:739

References ast_assert, NULL, and sub.

Referenced by dialog_info_generate_body_content(), mwi_get_notify_data(), and send_mwi_notify().

◆ ast_sip_subscription_get_endpoint()

struct ast_sip_endpoint * ast_sip_subscription_get_endpoint ( struct ast_sip_subscription sub)

Get the endpoint that is associated with this subscription.

This function will increase the reference count of the endpoint. Be sure to release the reference to it when you are finished with the endpoint.

Return values
NULLCould not get endpoint
non-NULLThe endpoint

Definition at line 2184 of file res_pjsip_pubsub.c.

2185{
2186 ast_assert(sub->tree->endpoint != NULL);
2187 return ao2_bump(sub->tree->endpoint);
2188}
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480

References ao2_bump, ast_assert, NULL, and sub.

Referenced by dialog_info_generate_body_content(), mwi_get_notify_data(), mwi_subscription_established(), send_mwi_notify(), and subscription_established().

◆ ast_sip_subscription_get_header()

void * ast_sip_subscription_get_header ( const struct ast_sip_subscription sub,
const char *  header 
)

Get a header value for a subscription.

For notifiers, the headers of the inbound SUBSCRIBE that started the dialog are stored on the subscription. This method allows access to the header. The return is the same as pjsip_msg_find_hdr_by_name(), meaning that it is dependent on the header being searched for.

Parameters
subThe subscription to search in.
headerThe name of the header to search for.
Returns
The discovered header, or NULL if the header cannot be found.

Definition at line 2102 of file res_pjsip_pubsub.c.

2103{
2104 pjsip_dialog *dlg;
2105 pjsip_msg *msg;
2106 pj_str_t name;
2107
2108 dlg = sub->tree->dlg;
2109 msg = ast_sip_mod_data_get(dlg->mod_data, pubsub_module.id, MOD_DATA_MSG);
2110 pj_cstr(&name, header);
2111
2112 return pjsip_msg_find_hdr_by_name(msg, &name, NULL);
2113}
#define ast_sip_mod_data_get(mod_data, id, key)
Using the dictionary stored in mod_data array at a given id, retrieve the value associated with the g...
Definition: res_pjsip.h:3067
#define MOD_DATA_MSG

References ast_sip_mod_data_get, MOD_DATA_MSG, name, NULL, pubsub_module, and sub.

Referenced by get_user_agent().

◆ ast_sip_subscription_get_local_uri()

void ast_sip_subscription_get_local_uri ( struct ast_sip_subscription sub,
char *  buf,
size_t  size 
)

Retrieve the local URI for this subscription.

This is the local URI of the subscribed resource.

Parameters
subThe subscription
[out]bufThe buffer into which to store the URI.
sizeThe size of the buffer.

Definition at line 2849 of file res_pjsip_pubsub.c.

2850{
2851 pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, sub->uri, buf, size);
2852}
char buf[BUFSIZE]
Definition: eagi_proxy.c:66

References buf, and sub.

Referenced by build_rlmi_body(), exten_state_data_alloc(), and notify_task().

◆ ast_sip_subscription_get_persistence_data()

const struct ast_json * ast_sip_subscription_get_persistence_data ( const struct ast_sip_subscription subscription)

Retrieve persistence data for a subscription.

Since
13.31.0
16.8.0
17.2.0
Parameters
subscriptionThe subscription to retrieve persistence data from

Definition at line 2957 of file res_pjsip_pubsub.c.

2958{
2959 return subscription->persistence_data;
2960}
struct ast_json * persistence_data

References ast_sip_subscription::persistence_data.

Referenced by dialog_info_generate_body_content().

◆ ast_sip_subscription_get_remote_uri()

void ast_sip_subscription_get_remote_uri ( struct ast_sip_subscription sub,
char *  buf,
size_t  size 
)

Retrive the remote URI for this subscription.

This is the remote URI as determined by the underlying SIP dialog.

Parameters
subThe subscription
[out]bufThe buffer into which to store the URI.
sizeThe size of the buffer.

Definition at line 2854 of file res_pjsip_pubsub.c.

2855{
2856 pjsip_dialog *dlg;
2857 pjsip_sip_uri *uri;
2858
2859 dlg = sub->tree->dlg;
2860 uri = pjsip_uri_get_uri(dlg->remote.info->uri);
2861
2862 if (pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, uri, buf, size) < 0) {
2863 *buf = '\0';
2864 }
2865}

References buf, sip_subscription_tree::dlg, and sub.

Referenced by exten_state_data_alloc(), and notify_task().

◆ ast_sip_subscription_get_resource_name()

const char * ast_sip_subscription_get_resource_name ( struct ast_sip_subscription sub)

Get the name of the subscribed resource.

Definition at line 2867 of file res_pjsip_pubsub.c.

2868{
2869 return sub->resource;
2870}

References sub.

Referenced by build_rlmi_body(), mwi_get_notify_data(), mwi_subscription_established(), remove_subscription(), send_mwi_notify(), and subscription_established().

◆ ast_sip_subscription_get_serializer()

struct ast_taskprocessor * ast_sip_subscription_get_serializer ( struct ast_sip_subscription sub)

Get the serializer for the subscription.

Tasks that originate outside of a SIP servant thread should get the serializer and push the task to the serializer.

Parameters
subThe subscription
Return values
NULLFailure
non-NULLThe subscription's serializer

Definition at line 2190 of file res_pjsip_pubsub.c.

2191{
2192 ast_assert(sub->tree->serializer != NULL);
2193 return sub->tree->serializer;
2194}

References ast_assert, NULL, and sub.

Referenced by exten_state_subscription_alloc(), and send_notify().

◆ ast_sip_subscription_get_sip_uri()

pjsip_sip_uri * ast_sip_subscription_get_sip_uri ( struct ast_sip_subscription sub)

Retrieve the local sip uri for this subscription.

Since
13.9.0

This is the local sip URI of the subscribed resource.

Parameters
subThe subscription
Return values
NULLCould not get uri
non-NULLThe local pjsip_sip_uri

Definition at line 2844 of file res_pjsip_pubsub.c.

2845{
2846 return sub->uri;
2847}

References sub.

Referenced by mwi_get_notify_data(), and send_mwi_notify().

◆ ast_sip_subscription_is_terminated()

int ast_sip_subscription_is_terminated ( const struct ast_sip_subscription sub)

Get whether the subscription has been terminated or not.

Parameters
subThe subscription.
Return values
0not terminated.
1terminated.
Since
13.4.0

Definition at line 2872 of file res_pjsip_pubsub.c.

2873{
2874 return sub->subscription_state == PJSIP_EVSUB_STATE_TERMINATED ? 1 : 0;
2875}

References sub.

Referenced by notify_task(), and state_changed().

◆ ast_sip_subscription_notify()

int ast_sip_subscription_notify ( struct ast_sip_subscription sub,
struct ast_sip_body_data notify_data,
int  terminate 
)

Notify a SIP subscription of a state change.

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.

Parameters
subThe subscription on which a state change is occurring.
notify_dataEvent package-specific data used to create the NOTIFY body.
terminateTrue if this NOTIFY is intended to terminate the subscription.
Return values
0Success
non-zeroFailure

Definition at line 2800 of file res_pjsip_pubsub.c.

2802{
2803 int res;
2804 pjsip_dialog *dlg = sub->tree->dlg;
2805
2806 pjsip_dlg_inc_lock(dlg);
2807
2808 if (sub->tree->state != SIP_SUB_TREE_NORMAL) {
2809 pjsip_dlg_dec_lock(dlg);
2810 return 0;
2811 }
2812
2815 pjsip_dlg_dec_lock(dlg);
2816 return -1;
2817 }
2818
2819 sub->body_changed = 1;
2820 if (terminate) {
2821 sub->subscription_state = PJSIP_EVSUB_STATE_TERMINATED;
2822 sub->tree->state = SIP_SUB_TREE_TERMINATE_PENDING;
2823 }
2824
2825 if (sub->tree->notification_batch_interval) {
2826 res = schedule_notification(sub->tree);
2827 } else {
2828 /* See the note in pubsub_on_rx_refresh() for why sub->tree is refbumped here */
2829 ao2_ref(sub->tree, +1);
2830 if (terminate) {
2832 }
2833 res = send_notify(sub->tree, 0);
2834 ast_test_suite_event_notify(terminate ? "SUBSCRIPTION_TERMINATED" : "SUBSCRIPTION_STATE_CHANGED",
2835 "Resource: %s",
2836 sub->tree->root->resource);
2837 ao2_ref(sub->tree, -1);
2838 }
2839
2840 pjsip_dlg_dec_lock(dlg);
2841 return res;
2842}
const char * ast_sip_subscription_get_body_type(struct ast_sip_subscription *sub)
Get the body type used for this subscription.
static int schedule_notification(struct sip_subscription_tree *sub_tree)
@ SIP_SUB_TREE_TERMINATE_PENDING
@ SIP_SUB_TREE_NORMAL
@ SIP_SUB_TREE_TERMINATE_IN_PROGRESS
const char * ast_sip_subscription_get_body_subtype(struct ast_sip_subscription *sub)
Get the body subtype used for this subscription.
static int send_notify(struct sip_subscription_tree *sub_tree, unsigned int force_full_state)
Send a NOTIFY request to a subscriber.
int ast_sip_pubsub_generate_body_content(const char *type, const char *subtype, struct ast_sip_body_data *data, struct ast_str **str)
Generate body content for a PUBLISH or NOTIFY.
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189

References ao2_ref, ast_sip_pubsub_generate_body_content(), ast_sip_subscription_get_body_subtype(), ast_sip_subscription_get_body_type(), ast_test_suite_event_notify, sip_subscription_tree::dlg, schedule_notification(), send_notify(), SIP_SUB_TREE_NORMAL, SIP_SUB_TREE_TERMINATE_IN_PROGRESS, SIP_SUB_TREE_TERMINATE_PENDING, and sub.

Referenced by notify_task(), and send_mwi_notify().

◆ ast_sip_subscription_remove_datastore()

void ast_sip_subscription_remove_datastore ( struct ast_sip_subscription subscription,
const char *  name 
)

Remove a subscription datastore from the subscription.

This operation may cause the datastore's free() callback to be called if the reference count reaches zero.

Parameters
subscriptionThe subscription to remove the datastore from
nameThe name of the datastore to remove

Definition at line 2910 of file res_pjsip_pubsub.c.

2911{
2912 ast_datastores_remove(subscription->datastores, name);
2913}

References ast_datastores_remove(), ast_sip_subscription::datastores, and name.

Referenced by mwi_subscription_established(), mwi_subscription_shutdown(), and subscription_shutdown().

◆ ast_sip_subscription_send_request()

int ast_sip_subscription_send_request ( struct ast_sip_subscription sub,
pjsip_tx_data *  tdata 
)

Send a request created via a PJSIP evsub method.

Callers of this function should take care to do so within a SIP servant thread.

Parameters
subThe subscription on which to send the request
tdataThe request to send
Return values
0Success
non-zeroFailure

◆ ast_sip_subscription_set_persistence_data()

void ast_sip_subscription_set_persistence_data ( struct ast_sip_subscription subscription,
struct ast_json persistence_data 
)

Set persistence data for a subscription.

Since
13.31.0
16.8.0
17.2.0
Parameters
subscriptionThe subscription to set persistence data on
persistence_dataThe persistence data to set
Note
This steals the reference to persistence_data

Definition at line 2940 of file res_pjsip_pubsub.c.

2941{
2942 ast_json_unref(subscription->persistence_data);
2943 subscription->persistence_data = persistence_data;
2944
2945 if (subscription->tree->persistence) {
2946 if (!subscription->tree->persistence->generator_data) {
2948 if (!subscription->tree->persistence->generator_data) {
2949 return;
2950 }
2951 }
2952 ast_json_object_set(subscription->tree->persistence->generator_data, subscription->resource,
2953 ast_json_ref(persistence_data));
2954 }
2955}
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_object_create(void)
Create a new JSON object.
Definition: json.c:399
struct ast_json * ast_json_ref(struct ast_json *value)
Increase refcount on value.
Definition: json.c:67
int ast_json_object_set(struct ast_json *object, const char *key, struct ast_json *value)
Set a field in a JSON object.
Definition: json.c:414
struct sip_subscription_tree * tree
struct subscription_persistence * persistence
struct ast_json * generator_data

References ast_json_object_create(), ast_json_object_set(), ast_json_ref(), ast_json_unref(), subscription_persistence::generator_data, sip_subscription_tree::persistence, ast_sip_subscription::persistence_data, ast_sip_subscription::resource, and ast_sip_subscription::tree.

Referenced by dialog_info_generate_body_content().

◆ ast_sip_unregister_publish_handler()

void ast_sip_unregister_publish_handler ( struct ast_sip_publish_handler handler)

Unregister a publish handler.

Definition at line 3009 of file res_pjsip_pubsub.c.

3010{
3011 struct ast_sip_publish_handler *iter;
3012
3015 if (handler == iter) {
3017 ao2_cleanup(handler->publications);
3018 break;
3019 }
3020 }
3023}
#define AST_RWLIST_REMOVE_CURRENT
Definition: linkedlists.h:570
Callbacks that publication handlers will define.
struct ast_sip_publish_handler * next

References ao2_cleanup, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, handler(), and ast_sip_publish_handler::next.

Referenced by load_module(), and unload_module().

◆ ast_sip_unregister_subscription_handler()

void ast_sip_unregister_subscription_handler ( struct ast_sip_subscription_handler handler)