Asterisk - The Open Source Telephony Project GIT-master-4f2b068
Loading...
Searching...
No Matches
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.
 
int ast_sip_publication_add_datastore (struct ast_sip_publication *publication, struct ast_datastore *datastore)
 Add a datastore to a SIP publication.
 
struct ast_datastoreast_sip_publication_get_datastore (struct ast_sip_publication *publication, const char *name)
 Retrieve a publication datastore.
 
struct ao2_containerast_sip_publication_get_datastores (const struct ast_sip_publication *publication)
 Get the datastores container for a publication.
 
struct ast_sip_endpointast_sip_publication_get_endpoint (struct ast_sip_publication *pub)
 Given a publication, get the associated endpoint.
 
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.
 
const char * ast_sip_publication_get_resource (const struct ast_sip_publication *pub)
 Given a publication, get the resource the publication is to.
 
void ast_sip_publication_remove_datastore (struct ast_sip_publication *publication, const char *name)
 Remove a publication datastore from the publication.
 
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.
 
int ast_sip_pubsub_is_body_generator_registered (const char *type, const char *subtype)
 Is a body generator registered for the given type/subtype.
 
int ast_sip_pubsub_register_body_generator (struct ast_sip_pubsub_body_generator *generator)
 Register a body generator with the pubsub core.
 
int ast_sip_pubsub_register_body_supplement (struct ast_sip_pubsub_body_supplement *supplement)
 Register a body generator with the pubsub core.
 
void ast_sip_pubsub_unregister_body_generator (struct ast_sip_pubsub_body_generator *generator)
 Unregister a body generator with the pubsub core.
 
void ast_sip_pubsub_unregister_body_supplement (struct ast_sip_pubsub_body_supplement *supplement)
 Unregister a body generator with the pubsub core.
 
int ast_sip_register_publish_handler (struct ast_sip_publish_handler *handler)
 Register a publish handler.
 
int ast_sip_register_subscription_handler (struct ast_sip_subscription_handler *handler)
 Register a subscription handler.
 
int ast_sip_subscription_add_datastore (struct ast_sip_subscription *subscription, struct ast_datastore *datastore)
 Add a datastore to a SIP subscription.
 
struct ast_datastoreast_sip_subscription_alloc_datastore (const struct ast_datastore_info *info, const char *uid)
 Alternative for ast_datastore_alloc()
 
void ast_sip_subscription_destroy (struct ast_sip_subscription *sub)
 Alert the pubsub core that the subscription is ready for destruction.
 
const char * ast_sip_subscription_get_body_subtype (struct ast_sip_subscription *sub)
 Get the body subtype used for this subscription.
 
const char * ast_sip_subscription_get_body_type (struct ast_sip_subscription *sub)
 Get the body type used for this subscription.
 
struct ast_datastoreast_sip_subscription_get_datastore (struct ast_sip_subscription *subscription, const char *name)
 Retrieve a subscription datastore.
 
struct ao2_containerast_sip_subscription_get_datastores (const struct ast_sip_subscription *subscription)
 Get the datastores container for a subscription.
 
pjsip_dialog * ast_sip_subscription_get_dialog (struct ast_sip_subscription *sub)
 Get the pjsip dialog that is associated with this subscription.
 
struct ast_sip_endpointast_sip_subscription_get_endpoint (struct ast_sip_subscription *sub)
 Get the endpoint that is associated with this subscription.
 
void * ast_sip_subscription_get_header (const struct ast_sip_subscription *sub, const char *header)
 Get a header value for a subscription.
 
void ast_sip_subscription_get_local_uri (struct ast_sip_subscription *sub, char *buf, size_t size)
 Retrieve the local URI for this subscription.
 
const struct ast_jsonast_sip_subscription_get_persistence_data (const struct ast_sip_subscription *subscription)
 Retrieve persistence data for a subscription.
 
void ast_sip_subscription_get_remote_uri (struct ast_sip_subscription *sub, char *buf, size_t size)
 Retrive the remote URI for this subscription.
 
const char * ast_sip_subscription_get_resource_name (struct ast_sip_subscription *sub)
 Get the name of the subscribed resource.
 
struct ast_taskprocessorast_sip_subscription_get_serializer (struct ast_sip_subscription *sub)
 Get the serializer for the subscription.
 
pjsip_sip_uri * ast_sip_subscription_get_sip_uri (struct ast_sip_subscription *sub)
 Retrieve the local sip uri for this subscription.
 
int ast_sip_subscription_is_terminated (const struct ast_sip_subscription *sub)
 Get whether the subscription has been terminated or not.
 
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.
 
void ast_sip_subscription_remove_datastore (struct ast_sip_subscription *subscription, const char *name)
 Remove a subscription datastore from the subscription.
 
int ast_sip_subscription_send_request (struct ast_sip_subscription *sub, pjsip_tx_data *tdata)
 Send a request created via a PJSIP evsub method.
 
void ast_sip_subscription_set_persistence_data (struct ast_sip_subscription *subscription, struct ast_json *persistence_data)
 Set persistence data for a subscription.
 
void ast_sip_unregister_publish_handler (struct ast_sip_publish_handler *handler)
 Unregister a publish handler.
 
void ast_sip_unregister_subscription_handler (struct ast_sip_subscription_handler *handler)
 Unregister a subscription handler.
 

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 2124 of file res_pjsip_pubsub.c.

2126{
2127 struct ast_sip_subscription *sub;
2128 pjsip_dialog *dlg;
2129 struct ast_sip_contact *contact;
2130 pj_str_t event;
2131 pjsip_tx_data *tdata;
2132 pjsip_evsub *evsub;
2133 struct sip_subscription_tree *sub_tree = NULL;
2134
2136 if (!sub_tree) {
2137 return NULL;
2138 }
2139
2140 sub = allocate_subscription(handler, resource, NULL, sub_tree);
2141 if (!sub) {
2142 ao2_cleanup(sub_tree);
2143 return NULL;
2144 }
2145
2147 if (!contact || ast_strlen_zero(contact->uri)) {
2148 ast_log(LOG_WARNING, "No contacts configured for endpoint %s. Unable to create SIP subsription\n",
2150 ao2_ref(sub_tree, -1);
2151 ao2_cleanup(contact);
2152 return NULL;
2153 }
2154
2156 ao2_cleanup(contact);
2157 if (!dlg) {
2158 ast_log(LOG_WARNING, "Unable to create dialog for SIP subscription\n");
2159 ao2_ref(sub_tree, -1);
2160 return NULL;
2161 }
2162
2163 pj_cstr(&event, handler->event_name);
2164 pjsip_evsub_create_uac(dlg, &pubsub_cb, &event, 0, &sub_tree->evsub);
2165 subscription_setup_dialog(sub_tree, dlg);
2166
2167 evsub = sub_tree->evsub;
2168
2169 if (pjsip_evsub_initiate(evsub, NULL, -1, &tdata) == PJ_SUCCESS) {
2170 pjsip_evsub_send_request(sub_tree->evsub, tdata);
2171 } else {
2172 /* pjsip_evsub_terminate will result in pubsub_on_evsub_state,
2173 * being called and terminating the subscription. Therefore, we don't
2174 * need to decrease the reference count of sub here.
2175 */
2176 pjsip_evsub_terminate(evsub, PJ_TRUE);
2177 ao2_ref(sub_tree, -1);
2178 return NULL;
2179 }
2180
2181 add_subscription(sub_tree);
2182
2183 return sub;
2184}
#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
static struct stasis_subscription * sub
Statsd channel stats. Exmaple of how to subscribe to Stasis events.
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:958
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:2381
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:1090
Structure representing a "virtual" SIP subscription.
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 2928 of file res_pjsip_pubsub.c.

2929{
2930 return ast_datastores_add(publication->datastores, datastore);
2931}
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 2933 of file res_pjsip_pubsub.c.

2934{
2935 return ast_datastores_find(publication->datastores, name);
2936}
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 2943 of file res_pjsip_pubsub.c.

2944{
2945 return publication->datastores;
2946}

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 3702 of file res_pjsip_pubsub.c.

3703{
3704 return pub->endpoint;
3705}
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 3712 of file res_pjsip_pubsub.c.

3713{
3714 return pub->event_configuration_name;
3715}
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 3707 of file res_pjsip_pubsub.c.

3708{
3709 return pub->resource;
3710}
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 2938 of file res_pjsip_pubsub.c.

2939{
2940 ast_datastores_remove(publication->datastores, name);
2941}
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 3801 of file res_pjsip_pubsub.c.

3803{
3804 struct ast_sip_pubsub_body_supplement *supplement;
3805 struct ast_sip_pubsub_body_generator *generator;
3806 int res = 0;
3807 void *body;
3808
3810 if (!generator) {
3811 ast_log(LOG_WARNING, "Unable to find a body generator for %s/%s\n",
3812 type, subtype);
3813 return -1;
3814 }
3815
3816 if (strcmp(data->body_type, generator->body_type)) {
3817 ast_log(LOG_WARNING, "%s/%s body generator does not accept the type of data provided\n",
3818 type, subtype);
3819 return -1;
3820 }
3821
3822 body = generator->allocate_body(data->body_data);
3823 if (!body) {
3824 ast_log(LOG_WARNING, "%s/%s body generator could not to allocate a body\n",
3825 type, subtype);
3826 return -1;
3827 }
3828
3829 if (generator->generate_body_content(body, data->body_data)) {
3830 res = -1;
3831 goto end;
3832 }
3833
3836 if (!strcmp(generator->type, supplement->type) &&
3837 !strcmp(generator->subtype, supplement->subtype)) {
3838 res = supplement->supplement_body(body, data->body_data);
3839 if (res) {
3840 break;
3841 }
3842 }
3843 }
3845
3846 if (!res) {
3847 generator->to_string(body, str);
3848 }
3849
3850end:
3851 if (generator->destroy_body) {
3852 generator->destroy_body(body);
3853 }
3854
3855 return res;
3856}
const char * str
Definition app_jack.c:150
static const char type[]
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.
#define AST_RWLIST_TRAVERSE
static struct ast_sip_pubsub_body_generator * find_body_generator_type_subtype(const char *type, const char *subtype)
void(* to_string)(void *body, struct ast_str **str)
Convert the body to a string.
struct ast_sip_pubsub_body_generator::@280 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 3717 of file res_pjsip_pubsub.c.

3718{
3719 return !!find_body_generator_type_subtype(type, subtype);
3720}

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 3722 of file res_pjsip_pubsub.c.

3723{
3724 struct ast_sip_pubsub_body_generator *existing;
3725 pj_str_t accept;
3726 pj_size_t accept_len;
3727
3729 existing = find_body_generator_type_subtype_nolock(generator->type, generator->subtype);
3730 if (existing) {
3732 ast_log(LOG_WARNING, "A body generator for %s/%s is already registered.\n",
3733 generator->type, generator->subtype);
3734 return -1;
3735 }
3738
3739 /* Lengths of type and subtype plus a slash. */
3740 accept_len = strlen(generator->type) + strlen(generator->subtype) + 1;
3741
3742 /* Add room for null terminator that sprintf() will set. */
3743 pj_strset(&accept, ast_alloca(accept_len + 1), accept_len);
3744 sprintf((char *) pj_strbuf(&accept), "%s/%s", generator->type, generator->subtype);/* Safe */
3745
3746 pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), &pubsub_module,
3747 PJSIP_H_ACCEPT, NULL, 1, &accept);
3748
3749 return 0;
3750}
#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.
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition res_pjsip.c:514
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(), load_module(), load_module(), and 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 3767 of file res_pjsip_pubsub.c.

3768{
3770 AST_RWLIST_INSERT_TAIL(&body_supplements, supplement, list);
3772
3773 return 0;
3774}
#define AST_RWLIST_INSERT_TAIL

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

Referenced by load_module(), and 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 3752 of file res_pjsip_pubsub.c.

3753{
3754 struct ast_sip_pubsub_body_generator *iter;
3755
3758 if (iter == generator) {
3760 break;
3761 }
3762 }
3765}
#define AST_RWLIST_TRAVERSE_SAFE_BEGIN
#define AST_RWLIST_TRAVERSE_SAFE_END
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.

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(), unload_module(), 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 3776 of file res_pjsip_pubsub.c.

3777{
3778 struct ast_sip_pubsub_body_supplement *iter;
3779
3782 if (iter == supplement) {
3784 break;
3785 }
3786 }
3789}
struct ast_sip_pubsub_body_supplement::@281 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(), and 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 2997 of file res_pjsip_pubsub.c.

2998{
2999 if (ast_strlen_zero(handler->event_name)) {
3000 ast_log(LOG_ERROR, "No event package specified for publish handler. Cannot register\n");
3001 return -1;
3002 }
3003
3006 if (!handler->publications) {
3007 ast_log(LOG_ERROR, "Could not allocate publications container for event '%s'\n",
3008 handler->event_name);
3009 return -1;
3010 }
3011
3013
3014 return 0;
3015}
@ 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 3056 of file res_pjsip_pubsub.c.

3057{
3058 pj_str_t event;
3059 pj_str_t accept[AST_SIP_MAX_ACCEPT] = { {0, }, };
3060 struct ast_sip_subscription_handler *existing;
3061 int i = 0;
3062
3063 if (ast_strlen_zero(handler->event_name)) {
3064 ast_log(LOG_ERROR, "No event package specified for subscription handler. Cannot register\n");
3065 return -1;
3066 }
3067
3068 existing = find_sub_handler_for_event_name(handler->event_name);
3069 if (existing) {
3071 "Unable to register subscription handler for event %s. A handler is already registered\n",
3072 handler->event_name);
3073 return -1;
3074 }
3075
3076 for (i = 0; i < AST_SIP_MAX_ACCEPT && !ast_strlen_zero(handler->accept[i]); ++i) {
3077 pj_cstr(&accept[i], handler->accept[i]);
3078 }
3079
3080 pj_cstr(&event, handler->event_name);
3081
3082 pjsip_evsub_register_pkg(&pubsub_module, &event, DEFAULT_EXPIRES, i, accept);
3083
3085
3086 return 0;
3087}
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(), and 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 2908 of file res_pjsip_pubsub.c.

2909{
2910 return ast_datastores_add(subscription->datastores, datastore);
2911}
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 2903 of file res_pjsip_pubsub.c.

2904{
2905 return ast_datastores_alloc_datastore(info, uid);
2906}
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

References ast_datastores_alloc_datastore(), ast_datastore::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 1639 of file res_pjsip_pubsub.c.

1640{
1641 ast_debug(3, "Removing subscription %p '%s->%s' reference to subscription tree %p\n",
1642 sub, ast_sorcery_object_get_id(sub->tree->endpoint), sub->resource, sub->tree);
1643 if (sub->tree) {
1644 /* Clear tree before cleanup to avoid re-entrant destruction */
1645 struct sip_subscription_tree *tree = sub->tree;
1646 sub->tree = NULL;
1647 ao2_cleanup(tree);
1648 }
1649}
#define ast_debug(level,...)
Log a DEBUG message.

References ao2_cleanup, ast_debug, ast_sorcery_object_get_id(), NULL, 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 3796 of file res_pjsip_pubsub.c.

3797{
3798 return sub->body_generator->subtype;
3799}

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 3791 of file res_pjsip_pubsub.c.

3792{
3793 return sub->body_generator->type;
3794}

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 2913 of file res_pjsip_pubsub.c.

2914{
2915 return ast_datastores_find(subscription->datastores, name);
2916}

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 2923 of file res_pjsip_pubsub.c.

2924{
2925 return subscription->datastores;
2926}

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 2186 of file res_pjsip_pubsub.c.

2187{
2188 ast_assert(sub->tree->dlg != NULL);
2189 return sub->tree->dlg;
2190}
#define ast_assert(a)
Definition utils.h:779

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 2192 of file res_pjsip_pubsub.c.

2193{
2194 ast_assert(sub->tree->endpoint != NULL);
2195 return ao2_bump(sub->tree->endpoint);
2196}
#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 2110 of file res_pjsip_pubsub.c.

2111{
2112 pjsip_dialog *dlg;
2113 pjsip_msg *msg;
2114 pj_str_t name;
2115
2116 dlg = sub->tree->dlg;
2117 msg = ast_sip_mod_data_get(dlg->mod_data, pubsub_module.id, MOD_DATA_MSG);
2118 pj_cstr(&name, header);
2119
2120 return pjsip_msg_find_hdr_by_name(msg, &name, NULL);
2121}
#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:3092
#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 2857 of file res_pjsip_pubsub.c.

2858{
2859 pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, sub->uri, buf, size);
2860}
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 2965 of file res_pjsip_pubsub.c.

2966{
2967 return subscription->persistence_data;
2968}
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 2862 of file res_pjsip_pubsub.c.

2863{
2864 pjsip_dialog *dlg;
2865 pjsip_sip_uri *uri;
2866
2867 dlg = sub->tree->dlg;
2868 uri = pjsip_uri_get_uri(dlg->remote.info->uri);
2869
2870 if (pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, uri, buf, size) < 0) {
2871 *buf = '\0';
2872 }
2873}

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 2875 of file res_pjsip_pubsub.c.

2876{
2877 return sub->resource;
2878}

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 2198 of file res_pjsip_pubsub.c.

2199{
2200 ast_assert(sub->tree->serializer != NULL);
2201 return sub->tree->serializer;
2202}

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 2852 of file res_pjsip_pubsub.c.

2853{
2854 return sub->uri;
2855}

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 2880 of file res_pjsip_pubsub.c.

2881{
2882 return sub->subscription_state == PJSIP_EVSUB_STATE_TERMINATED ? 1 : 0;
2883}

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 2808 of file res_pjsip_pubsub.c.

2810{
2811 int res;
2812 pjsip_dialog *dlg = sub->tree->dlg;
2813
2814 pjsip_dlg_inc_lock(dlg);
2815
2816 if (sub->tree->state != SIP_SUB_TREE_NORMAL) {
2817 pjsip_dlg_dec_lock(dlg);
2818 return 0;
2819 }
2820
2823 pjsip_dlg_dec_lock(dlg);
2824 return -1;
2825 }
2826
2827 sub->body_changed = 1;
2828 if (terminate) {
2829 sub->subscription_state = PJSIP_EVSUB_STATE_TERMINATED;
2830 sub->tree->state = SIP_SUB_TREE_TERMINATE_PENDING;
2831 }
2832
2833 if (sub->tree->notification_batch_interval) {
2834 res = schedule_notification(sub->tree);
2835 } else {
2836 /* See the note in pubsub_on_rx_refresh() for why sub->tree is refbumped here */
2837 ao2_ref(sub->tree, +1);
2838 if (terminate) {
2840 }
2841 res = send_notify(sub->tree, 0);
2842 ast_test_suite_event_notify(terminate ? "SUBSCRIPTION_TERMINATED" : "SUBSCRIPTION_STATE_CHANGED",
2843 "Resource: %s",
2844 sub->tree->root->resource);
2845 ao2_ref(sub->tree, -1);
2846 }
2847
2848 pjsip_dlg_dec_lock(dlg);
2849 return res;
2850}
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 2918 of file res_pjsip_pubsub.c.

2919{
2920 ast_datastores_remove(subscription->datastores, name);
2921}

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 2948 of file res_pjsip_pubsub.c.

2949{
2950 ast_json_unref(subscription->persistence_data);
2951 subscription->persistence_data = persistence_data;
2952
2953 if (subscription->tree->persistence) {
2954 if (!subscription->tree->persistence->generator_data) {
2956 if (!subscription->tree->persistence->generator_data) {
2957 return;
2958 }
2959 }
2960 ast_json_object_set(subscription->tree->persistence->generator_data, subscription->resource,
2961 ast_json_ref(persistence_data));
2962 }
2963}
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 3017 of file res_pjsip_pubsub.c.

3018{
3019 struct ast_sip_publish_handler *iter;
3020
3023 if (handler == iter) {
3025 ao2_cleanup(handler->publications);
3026 break;
3027 }
3028 }
3031}
#define AST_RWLIST_REMOVE_CURRENT
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)