Asterisk - The Open Source Telephony Project GIT-master-a358458
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 1909 of file res_pjsip_pubsub.c.

1911{
1912 struct ast_sip_subscription *sub;
1913 pjsip_dialog *dlg;
1914 struct ast_sip_contact *contact;
1915 pj_str_t event;
1916 pjsip_tx_data *tdata;
1917 pjsip_evsub *evsub;
1918 struct sip_subscription_tree *sub_tree = NULL;
1919
1921 if (!sub_tree) {
1922 return NULL;
1923 }
1924
1925 sub = allocate_subscription(handler, resource, NULL, sub_tree);
1926 if (!sub) {
1927 ao2_cleanup(sub_tree);
1928 return NULL;
1929 }
1930
1932 if (!contact || ast_strlen_zero(contact->uri)) {
1933 ast_log(LOG_WARNING, "No contacts configured for endpoint %s. Unable to create SIP subsription\n",
1935 ao2_ref(sub_tree, -1);
1936 ao2_cleanup(contact);
1937 return NULL;
1938 }
1939
1941 ao2_cleanup(contact);
1942 if (!dlg) {
1943 ast_log(LOG_WARNING, "Unable to create dialog for SIP subscription\n");
1944 ao2_ref(sub_tree, -1);
1945 return NULL;
1946 }
1947
1948 pj_cstr(&event, handler->event_name);
1949 pjsip_evsub_create_uac(dlg, &pubsub_cb, &event, 0, &sub_tree->evsub);
1950 subscription_setup_dialog(sub_tree, dlg);
1951
1952 evsub = sub_tree->evsub;
1953
1954 if (pjsip_evsub_initiate(evsub, NULL, -1, &tdata) == PJ_SUCCESS) {
1955 pjsip_evsub_send_request(sub_tree->evsub, tdata);
1956 } else {
1957 /* pjsip_evsub_terminate will result in pubsub_on_evsub_state,
1958 * being called and terminating the subscription. Therefore, we don't
1959 * need to decrease the reference count of sub here.
1960 */
1961 pjsip_evsub_terminate(evsub, PJ_TRUE);
1962 ao2_ref(sub_tree, -1);
1963 return NULL;
1964 }
1965
1966 add_subscription(sub_tree);
1967
1968 return sub;
1969}
#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:2312
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:392
const ast_string_field uri
Definition: res_pjsip.h:414
const ast_string_field aors
Definition: res_pjsip.h:992
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 2713 of file res_pjsip_pubsub.c.

2714{
2715 return ast_datastores_add(publication->datastores, datastore);
2716}
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 2718 of file res_pjsip_pubsub.c.

2719{
2720 return ast_datastores_find(publication->datastores, name);
2721}
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 2728 of file res_pjsip_pubsub.c.

2729{
2730 return publication->datastores;
2731}

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

3488{
3489 return pub->endpoint;
3490}
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 3497 of file res_pjsip_pubsub.c.

3498{
3499 return pub->event_configuration_name;
3500}
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 3492 of file res_pjsip_pubsub.c.

3493{
3494 return pub->resource;
3495}
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 2723 of file res_pjsip_pubsub.c.

2724{
2725 ast_datastores_remove(publication->datastores, name);
2726}
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 3586 of file res_pjsip_pubsub.c.

3588{
3589 struct ast_sip_pubsub_body_supplement *supplement;
3590 struct ast_sip_pubsub_body_generator *generator;
3591 int res = 0;
3592 void *body;
3593
3595 if (!generator) {
3596 ast_log(LOG_WARNING, "Unable to find a body generator for %s/%s\n",
3597 type, subtype);
3598 return -1;
3599 }
3600
3601 if (strcmp(data->body_type, generator->body_type)) {
3602 ast_log(LOG_WARNING, "%s/%s body generator does not accept the type of data provided\n",
3603 type, subtype);
3604 return -1;
3605 }
3606
3607 body = generator->allocate_body(data->body_data);
3608 if (!body) {
3609 ast_log(LOG_WARNING, "%s/%s body generator could not to allocate a body\n",
3610 type, subtype);
3611 return -1;
3612 }
3613
3614 if (generator->generate_body_content(body, data->body_data)) {
3615 res = -1;
3616 goto end;
3617 }
3618
3621 if (!strcmp(generator->type, supplement->type) &&
3622 !strcmp(generator->subtype, supplement->subtype)) {
3623 res = supplement->supplement_body(body, data->body_data);
3624 if (res) {
3625 break;
3626 }
3627 }
3628 }
3630
3631 if (!res) {
3632 generator->to_string(body, str);
3633 }
3634
3635end:
3636 if (generator->destroy_body) {
3637 generator->destroy_body(body);
3638 }
3639
3640 return res;
3641}
const char * str
Definition: app_jack.c:147
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.
void(* destroy_body)(void *body)
Deallocate resources created for the body.
struct ast_sip_pubsub_body_generator::@261 list
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 3502 of file res_pjsip_pubsub.c.

3503{
3504 return !!find_body_generator_type_subtype(type, subtype);
3505}

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

3508{
3509 struct ast_sip_pubsub_body_generator *existing;
3510 pj_str_t accept;
3511 pj_size_t accept_len;
3512
3514 existing = find_body_generator_type_subtype_nolock(generator->type, generator->subtype);
3515 if (existing) {
3517 ast_log(LOG_WARNING, "A body generator for %s/%s is already registered.\n",
3518 generator->type, generator->subtype);
3519 return -1;
3520 }
3523
3524 /* Lengths of type and subtype plus a slash. */
3525 accept_len = strlen(generator->type) + strlen(generator->subtype) + 1;
3526
3527 /* Add room for null terminator that sprintf() will set. */
3528 pj_strset(&accept, ast_alloca(accept_len + 1), accept_len);
3529 sprintf((char *) pj_strbuf(&accept), "%s/%s", generator->type, generator->subtype);/* Safe */
3530
3531 pjsip_endpt_add_capability(ast_sip_get_pjsip_endpoint(), &pubsub_module,
3532 PJSIP_H_ACCEPT, NULL, 1, &accept);
3533
3534 return 0;
3535}
#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 3552 of file res_pjsip_pubsub.c.

3553{
3555 AST_RWLIST_INSERT_TAIL(&body_supplements, supplement, list);
3557
3558 return 0;
3559}
#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 3537 of file res_pjsip_pubsub.c.

3538{
3539 struct ast_sip_pubsub_body_generator *iter;
3540
3543 if (iter == generator) {
3545 break;
3546 }
3547 }
3550}
#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 3561 of file res_pjsip_pubsub.c.

3562{
3563 struct ast_sip_pubsub_body_supplement *iter;
3564
3567 if (iter == supplement) {
3569 break;
3570 }
3571 }
3574}
struct ast_sip_pubsub_body_supplement::@262 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 2782 of file res_pjsip_pubsub.c.

2783{
2784 if (ast_strlen_zero(handler->event_name)) {
2785 ast_log(LOG_ERROR, "No event package specified for publish handler. Cannot register\n");
2786 return -1;
2787 }
2788
2791 if (!handler->publications) {
2792 ast_log(LOG_ERROR, "Could not allocate publications container for event '%s'\n",
2793 handler->event_name);
2794 return -1;
2795 }
2796
2798
2799 return 0;
2800}
@ 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 2841 of file res_pjsip_pubsub.c.

2842{
2843 pj_str_t event;
2844 pj_str_t accept[AST_SIP_MAX_ACCEPT] = { {0, }, };
2845 struct ast_sip_subscription_handler *existing;
2846 int i = 0;
2847
2848 if (ast_strlen_zero(handler->event_name)) {
2849 ast_log(LOG_ERROR, "No event package specified for subscription handler. Cannot register\n");
2850 return -1;
2851 }
2852
2853 existing = find_sub_handler_for_event_name(handler->event_name);
2854 if (existing) {
2856 "Unable to register subscription handler for event %s. A handler is already registered\n",
2857 handler->event_name);
2858 return -1;
2859 }
2860
2861 for (i = 0; i < AST_SIP_MAX_ACCEPT && !ast_strlen_zero(handler->accept[i]); ++i) {
2862 pj_cstr(&accept[i], handler->accept[i]);
2863 }
2864
2865 pj_cstr(&event, handler->event_name);
2866
2867 pjsip_evsub_register_pkg(&pubsub_module, &event, DEFAULT_EXPIRES, i, accept);
2868
2870
2871 return 0;
2872}
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 2693 of file res_pjsip_pubsub.c.

2694{
2695 return ast_datastores_add(subscription->datastores, datastore);
2696}
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 2688 of file res_pjsip_pubsub.c.

2689{
2691}
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 1429 of file res_pjsip_pubsub.c.

1430{
1431 ast_debug(3, "Removing subscription %p '%s->%s' reference to subscription tree %p\n",
1432 sub, ast_sorcery_object_get_id(sub->tree->endpoint), sub->resource, sub->tree);
1433 ao2_cleanup(sub->tree);
1434}
#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 3581 of file res_pjsip_pubsub.c.

3582{
3583 return sub->body_generator->subtype;
3584}

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

3577{
3578 return sub->body_generator->type;
3579}

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

2699{
2700 return ast_datastores_find(subscription->datastores, name);
2701}

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

2709{
2710 return subscription->datastores;
2711}

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

1972{
1973 ast_assert(sub->tree->dlg != NULL);
1974 return sub->tree->dlg;
1975}
#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 1977 of file res_pjsip_pubsub.c.

1978{
1979 ast_assert(sub->tree->endpoint != NULL);
1980 return ao2_bump(sub->tree->endpoint);
1981}
#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 1895 of file res_pjsip_pubsub.c.

1896{
1897 pjsip_dialog *dlg;
1898 pjsip_msg *msg;
1899 pj_str_t name;
1900
1901 dlg = sub->tree->dlg;
1902 msg = ast_sip_mod_data_get(dlg->mod_data, pubsub_module.id, MOD_DATA_MSG);
1903 pj_cstr(&name, header);
1904
1905 return pjsip_msg_find_hdr_by_name(msg, &name, NULL);
1906}
#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:2948
#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 2642 of file res_pjsip_pubsub.c.

2643{
2644 pjsip_uri_print(PJSIP_URI_IN_CONTACT_HDR, sub->uri, buf, size);
2645}
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 2750 of file res_pjsip_pubsub.c.

2751{
2752 return subscription->persistence_data;
2753}
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 2647 of file res_pjsip_pubsub.c.

2648{
2649 pjsip_dialog *dlg;
2650 pjsip_sip_uri *uri;
2651
2652 dlg = sub->tree->dlg;
2653 uri = pjsip_uri_get_uri(dlg->remote.info->uri);
2654
2655 if (pjsip_uri_print(PJSIP_URI_IN_FROMTO_HDR, uri, buf, size) < 0) {
2656 *buf = '\0';
2657 }
2658}

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

2661{
2662 return sub->resource;
2663}

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

1984{
1985 ast_assert(sub->tree->serializer != NULL);
1986 return sub->tree->serializer;
1987}

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

2638{
2639 return sub->uri;
2640}

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

2666{
2667 return sub->subscription_state == PJSIP_EVSUB_STATE_TERMINATED ? 1 : 0;
2668}

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

2595{
2596 int res;
2597 pjsip_dialog *dlg = sub->tree->dlg;
2598
2599 pjsip_dlg_inc_lock(dlg);
2600
2601 if (sub->tree->state != SIP_SUB_TREE_NORMAL) {
2602 pjsip_dlg_dec_lock(dlg);
2603 return 0;
2604 }
2605
2608 pjsip_dlg_dec_lock(dlg);
2609 return -1;
2610 }
2611
2612 sub->body_changed = 1;
2613 if (terminate) {
2614 sub->subscription_state = PJSIP_EVSUB_STATE_TERMINATED;
2615 sub->tree->state = SIP_SUB_TREE_TERMINATE_PENDING;
2616 }
2617
2618 if (sub->tree->notification_batch_interval) {
2619 res = schedule_notification(sub->tree);
2620 } else {
2621 /* See the note in pubsub_on_rx_refresh() for why sub->tree is refbumped here */
2622 ao2_ref(sub->tree, +1);
2623 if (terminate) {
2625 }
2626 res = send_notify(sub->tree, 0);
2627 ast_test_suite_event_notify(terminate ? "SUBSCRIPTION_TERMINATED" : "SUBSCRIPTION_STATE_CHANGED",
2628 "Resource: %s",
2629 sub->tree->root->resource);
2630 ao2_ref(sub->tree, -1);
2631 }
2632
2633 pjsip_dlg_dec_lock(dlg);
2634 return res;
2635}
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 2703 of file res_pjsip_pubsub.c.

2704{
2705 ast_datastores_remove(subscription->datastores, name);
2706}

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

2734{
2735 ast_json_unref(subscription->persistence_data);
2736 subscription->persistence_data = persistence_data;
2737
2738 if (subscription->tree->persistence) {
2739 if (!subscription->tree->persistence->generator_data) {
2741 if (!subscription->tree->persistence->generator_data) {
2742 return;
2743 }
2744 }
2745 ast_json_object_set(subscription->tree->persistence->generator_data, subscription->resource,
2746 ast_json_ref(persistence_data));
2747 }
2748}
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 2802 of file res_pjsip_pubsub.c.

2803{
2804 struct ast_sip_publish_handler *iter;
2805
2808 if (handler == iter) {
2810 ao2_cleanup(handler->publications);
2811 break;
2812 }
2813 }
2816}
#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)