Asterisk - The Open Source Telephony Project  18.5.0
res_pjsip_pubsub.h
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2013, Digium, Inc.
5  *
6  * Mark Michelson <[email protected]>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18 
19 #ifndef _RES_PJSIP_PUBSUB_H
20 #define _RES_PJSIP_PUBSUB_H
21 
22 #include "asterisk/linkedlists.h"
23 
24 /* Forward declarations */
25 struct pjsip_rx_data;
26 struct pjsip_tx_data;
27 struct pjsip_evsub;
28 struct ast_sip_endpoint;
29 struct ast_datastore;
30 struct ast_datastore_info;
31 
32 /*!
33  * \brief Opaque structure representing a publication
34  */
35 struct ast_sip_publication;
36 
38  /*! Publication has just been initialized */
40  /*! Publication is currently active */
42  /*! Publication has been terminated */
44 };
45 
46 /*!
47  * \brief Callbacks that publication handlers will define
48  */
50  /*! \brief The name of the event this handler deals with */
51  const char *event_name;
52 
53  /*! \brief Publications */
55 
56  /*!
57  * \brief Called when a PUBLISH to establish a new publication arrives.
58  *
59  * \param endpoint The endpoint from whom the PUBLISH arrived.
60  * \param resource The resource whose state is being published.
61  * \param event_configuration The name of the event type configuration to use for this resource.
62  * \return Response code for the incoming PUBLISH
63  */
64  int (*new_publication)(struct ast_sip_endpoint *endpoint, const char *resource, const char *event_configuration);
65  /*!
66  * \brief Called when a publication has reached its expiration.
67  */
68  void (*publish_expire)(struct ast_sip_publication *pub);
69  /*!
70  * \brief Published resource has changed states.
71  *
72  * The state parameter can be used to take further action. For instance,
73  * if the state is AST_SIP_PUBLISH_STATE_INITIALIZED, then this is the initial
74  * PUBLISH request. This is a good time to set up datastores on the publication
75  * or any other initial needs.
76  *
77  * AST_SIP_PUBLISH_STATE_TERMINATED is used when the remote end is terminating
78  * its publication. This is a good opportunity to free any resources associated with
79  * the publication.
80  *
81  * AST_SIP_PUBLISH_STATE_ACTIVE is used when a publication that modifies state
82  * arrives.
83  *
84  * \param pub The publication whose state has changed
85  * \param body The body of the inbound PUBLISH
86  * \param state The state of the publication
87  */
88  int (*publication_state_change)(struct ast_sip_publication *pub, pjsip_msg_body *body,
91 };
92 
93 /*!
94  * \brief Given a publication, get the associated endpoint
95  *
96  * \param pub The publication
97  * \retval NULL Failure
98  * \retval non-NULL The associated endpoint
99  */
101 
102 /*!
103  * \brief Given a publication, get the resource the publication is to
104  *
105  * \param pub The publication
106  * \return The resource
107  */
108 const char *ast_sip_publication_get_resource(const struct ast_sip_publication *pub);
109 
110 /*!
111  * \brief Given a publication, get the configuration name for the event type in use
112  *
113  * \param pub The publication
114  * \return The configuration name
115  */
117 
118 /*!
119  * \brief Register a publish handler
120  *
121  * \retval 0 Handler was registered successfully
122  * \retval non-zero Handler was not registered successfully
123  */
125 
126 /*!
127  * \brief Unregister a publish handler
128  */
130 
131 /*!
132  * \brief Add a datastore to a SIP publication
133  *
134  * Note that SIP uses reference counted datastores. The datastore passed into this function
135  * must have been allocated using ao2_alloc() or there will be serious problems.
136  *
137  * \param publication The publication to add the datastore to
138  * \param datastore The datastore to be added to the subscription
139  * \retval 0 Success
140  * \retval -1 Failure
141  */
142 int ast_sip_publication_add_datastore(struct ast_sip_publication *publication, struct ast_datastore *datastore);
143 
144 /*!
145  * \brief Retrieve a publication datastore
146  *
147  * The datastore retrieved will have its reference count incremented. When the caller is done
148  * with the datastore, the reference counted needs to be decremented using ao2_ref().
149  *
150  * \param publication The publication from which to retrieve the datastore
151  * \param name The name of the datastore to retrieve
152  * \retval NULL Failed to find the specified datastore
153  * \retval non-NULL The specified datastore
154  */
155 struct ast_datastore *ast_sip_publication_get_datastore(struct ast_sip_publication *publication, const char *name);
156 
157 /*!
158  * \brief Remove a publication datastore from the publication
159  *
160  * This operation may cause the datastore's free() callback to be called if the reference
161  * count reaches zero.
162  *
163  * \param publication The publication to remove the datastore from
164  * \param name The name of the datastore to remove
165  */
166 void ast_sip_publication_remove_datastore(struct ast_sip_publication *publication, const char *name);
167 
168 /*!
169  * \brief Get the datastores container for a publication
170  *
171  * \param publication The publication to get the datastores container from
172  *
173  * \retval NULL datastores container not present
174  * \retval non-NULL datastores container
175  *
176  * \note The container is NOT returned with reference count bumped
177  *
178  * \since 14.0.0
179  */
180 struct ao2_container *ast_sip_publication_get_datastores(const struct ast_sip_publication *publication);
181 
182 /*!
183  * \brief Opaque structure representing an RFC 3265 SIP subscription
184  */
185 struct ast_sip_subscription;
186 
187 /*!
188  * \brief Role for the subscription that is being created
189  */
191  /* Sending SUBSCRIBEs, receiving NOTIFYs */
193  /* Sending NOTIFYs, receiving SUBSCRIBEs */
195 };
196 
197 /*!
198  * \brief Data for responses to SUBSCRIBEs and NOTIFIEs
199  *
200  * Some of PJSIP's evsub callbacks expect us to provide them
201  * with data so that they can craft a response rather than have
202  * us create our own response.
203  *
204  * Filling in the structure is optional, since the framework
205  * will automatically respond with a 200 OK response if we do
206  * not provide it with any additional data.
207  */
209  /*! Status code of the response */
211  /*! Optional status text */
212  const char *status_text;
213  /*! Optional additional headers to add to the response */
215  /*! Optional body to add to the response */
217 };
218 
219 #define AST_SIP_MAX_ACCEPT 32
221  /*! Initial NOTIFY for subscription */
223  /*! Subscription has been renewed */
225  /*! Subscription is being terminated */
227  /*! Other unspecified reason */
229 };
230 
231 /*! Type used for extension state/presence */
232 #define AST_SIP_EXTEN_STATE_DATA "ast_sip_exten_state_data"
233 /*! Type used for conveying mailbox state */
234 #define AST_SIP_MESSAGE_ACCUMULATOR "ast_sip_message_accumulator"
235 
236 /*!
237  * \brief Data used to create bodies for NOTIFY/PUBLISH requests.
238  */
240  /*! The type of the data */
241  const char *body_type;
242  /*! The actual data from which the body is generated */
243  void *body_data;
244 };
245 
247  /*!
248  * \brief Default body type defined for the event package this notifier handles.
249  *
250  * Typically, a SUBSCRIBE request will contain one or more Accept headers that tell
251  * what format they expect the body of NOTIFY requests to use. However, every event
252  * package is required to define a default body format type to be used if a SUBSCRIBE
253  * request for the event contains no Accept header.
254  */
255  const char *default_accept;
256  /*!
257  * \brief Called when a SUBSCRIBE arrives attempting to establish a new subscription.
258  *
259  * The notifier is expected to return the response that should be sent to the
260  * SUBSCRIBE request.
261  *
262  * If a 200-class response is returned, then the notifier's notify_required
263  * callback will immediately be called into with a reason of
264  * AST_SIP_SUBSCRIPTION_NOTIFY_REASON_STARTED.
265  *
266  * \param endpoint The endpoint from which we received the SUBSCRIBE
267  * \param resource The name of the resource to which the subscription is being made
268  * \return The response code to send to the SUBSCRIBE.
269  */
270  int (*new_subscribe)(struct ast_sip_endpoint *endpoint, const char *resource);
271  /*!
272  * \brief Called when an inbound subscription has been accepted.
273  *
274  * This is a prime opportunity for notifiers to add any notifier-specific
275  * data to the subscription (such as datastores) that it needs to.
276  *
277  * \note There is no need to send a NOTIFY request when this callback
278  * is called
279  *
280  * \param sub The new subscription
281  * \retval 0 Success
282  * \retval -1 Failure
283  */
285  /*!
286  * \brief Supply data needed to create a NOTIFY body.
287  *
288  * The returned data must be an ao2 object. The caller of this function
289  * will be responsible for decrementing the refcount of the returned object
290  *
291  * \param sub The subscription
292  * \return An ao2 object that can be used to create a NOTIFY body.
293  */
294  void *(*get_notify_data)(struct ast_sip_subscription *sub);
295 };
296 
298  /*!
299  * \brief A NOTIFY has been received.
300  *
301  * The body of the NOTIFY is provided so that it may be parsed and appropriate
302  * internal state change may be generated.
303  *
304  * The state can be used to determine if the subscription has been terminated
305  * by the far end or if this is just a typical resource state change.
306  *
307  * \param sub The subscription on which the NOTIFY arrived
308  * \param body The body of the NOTIFY
309  * \param state The subscription state
310  */
311  void (*state_change)(struct ast_sip_subscription *sub, pjsip_msg_body *body, enum pjsip_evsub_state state);
312 };
313 
315  /*! The name of the event this subscriber deals with */
316  const char *event_name;
317  /*! Type of data used to generate NOTIFY bodies */
318  const char *body_type;
319  /*! The types of body this subscriber accepts. */
320  const char *accept[AST_SIP_MAX_ACCEPT];
321  /*!
322  * \brief Called when a subscription is to be destroyed
323  *
324  * The handler is not expected to send any sort of requests or responses
325  * during this callback. The handler MUST, however, begin the destruction
326  * process for the subscription during this callback.
327  */
328  void (*subscription_shutdown)(struct ast_sip_subscription *subscription);
329  /*!
330  * \brief Converts the subscriber to AMI
331  *
332  * \param sub The subscription
333  * \param buf The string to write AMI data
334  */
335  void (*to_ami)(struct ast_sip_subscription *sub, struct ast_str **buf);
336  /*! Subscriber callbacks for this handler */
338  /*! Notifier callbacks for this handler */
341 };
342 
343 /*!
344  * \brief Create a new ast_sip_subscription structure
345  *
346  * When a subscriber wishes to create a subscription, it may call this function
347  * to allocate resources and to send the initial SUBSCRIBE out.
348  *
349  * \param subscriber The subscriber that is making the request.
350  * \param endpoint The endpoint to whome the SUBSCRIBE will be sent.
351  * \param resource The resource to place in the SUBSCRIBE's Request-URI.
352  */
354  struct ast_sip_endpoint *endpoint, const char *resource);
355 
356 /*!
357  * \brief Get the pjsip dialog that is associated with this subscription
358  * \since 13.9.0
359  *
360  * \retval NULL Could not get dialog
361  * \retval non-NULL The dialog
362  */
364 
365 /*!
366  * \brief Get the endpoint that is associated with this subscription
367  *
368  * This function will increase the reference count of the endpoint. Be sure to
369  * release the reference to it when you are finished with the endpoint.
370  *
371  * \retval NULL Could not get endpoint
372  * \retval non-NULL The endpoint
373  */
375 
376 /*!
377  * \brief Get the serializer for the subscription
378  *
379  * Tasks that originate outside of a SIP servant thread should get the serializer
380  * and push the task to the serializer.
381  *
382  * \param sub The subscription
383  * \retval NULL Failure
384  * \retval non-NULL The subscription's serializer
385  */
387 
388 /*!
389  * \brief Notify a SIP subscription of a state change.
390  *
391  * This tells the pubsub core that the state of a subscribed resource has changed.
392  * The pubsub core will generate an appropriate NOTIFY request to send to the
393  * subscriber.
394  *
395  * \param sub The subscription on which a state change is occurring.
396  * \param notify_data Event package-specific data used to create the NOTIFY body.
397  * \param terminate True if this NOTIFY is intended to terminate the subscription.
398  * \retval 0 Success
399  * \retval non-zero Failure
400  */
402 
403 /*!
404  * \brief Retrieve the local sip uri for this subscription
405  * \since 13.9.0
406  *
407  * This is the local sip URI of the subscribed resource.
408  *
409  * \param sub The subscription
410  * \retval NULL Could not get uri
411  * \retval non-NULL The local pjsip_sip_uri
412  */
414 
415 /*!
416  * \brief Retrieve the local URI for this subscription
417  *
418  * This is the local URI of the subscribed resource.
419  *
420  * \param sub The subscription
421  * \param[out] buf The buffer into which to store the URI.
422  * \param size The size of the buffer.
423  */
424 void ast_sip_subscription_get_local_uri(struct ast_sip_subscription *sub, char *buf, size_t size);
425 
426 /*!
427  * \brief Retrive the remote URI for this subscription
428  *
429  * This is the remote URI as determined by the underlying SIP dialog.
430  *
431  * \param sub The subscription
432  * \param[out] buf The buffer into which to store the URI.
433  * \param size The size of the buffer.
434  */
435 void ast_sip_subscription_get_remote_uri(struct ast_sip_subscription *sub, char *buf, size_t size);
436 
437 /*!
438  * \brief Get the name of the subscribed resource.
439  */
441 
442 /*!
443  * \brief Get whether the subscription has been terminated or not.
444  *
445  * \param sub The subscription.
446  * \retval 0 not terminated.
447  * \retval 1 terminated.
448  * \since 13.4.0
449  */
451 
452 /*!
453  * \brief Get a header value for a subscription.
454  *
455  * For notifiers, the headers of the inbound SUBSCRIBE that started the dialog
456  * are stored on the subscription. This method allows access to the header. The
457  * return is the same as pjsip_msg_find_hdr_by_name(), meaning that it is dependent
458  * on the header being searched for.
459  *
460  * \param sub The subscription to search in.
461  * \param header The name of the header to search for.
462  * \return The discovered header, or NULL if the header cannot be found.
463  */
464 void *ast_sip_subscription_get_header(const struct ast_sip_subscription *sub, const char *header);
465 
466 /*!
467  * \brief Send a request created via a PJSIP evsub method
468  *
469  * Callers of this function should take care to do so within a SIP servant
470  * thread.
471  *
472  * \param sub The subscription on which to send the request
473  * \param tdata The request to send
474  * \retval 0 Success
475  * \retval non-zero Failure
476  */
477 int ast_sip_subscription_send_request(struct ast_sip_subscription *sub, pjsip_tx_data *tdata);
478 
479 /*!
480  * \brief Alternative for ast_datastore_alloc()
481  *
482  * There are two major differences between this and ast_datastore_alloc()
483  * 1) This allocates a refcounted object
484  * 2) This will fill in a uid if one is not provided
485  *
486  * DO NOT call ast_datastore_free() on a datastore allocated in this
487  * way since that function will attempt to free the datastore rather
488  * than play nicely with its refcount.
489  *
490  * \param info Callbacks for datastore
491  * \param uid Identifier for datastore
492  * \retval NULL Failed to allocate datastore
493  * \retval non-NULL Newly allocated datastore
494  */
496 
497 /*!
498  * \brief Add a datastore to a SIP subscription
499  *
500  * Note that SIP uses reference counted datastores. The datastore passed into this function
501  * must have been allocated using ao2_alloc() or there will be serious problems.
502  *
503  * \param subscription The ssubscription to add the datastore to
504  * \param datastore The datastore to be added to the subscription
505  * \retval 0 Success
506  * \retval -1 Failure
507  */
508 int ast_sip_subscription_add_datastore(struct ast_sip_subscription *subscription, struct ast_datastore *datastore);
509 
510 /*!
511  * \brief Retrieve a subscription datastore
512  *
513  * The datastore retrieved will have its reference count incremented. When the caller is done
514  * with the datastore, the reference counted needs to be decremented using ao2_ref().
515  *
516  * \param subscription The subscription from which to retrieve the datastore
517  * \param name The name of the datastore to retrieve
518  * \retval NULL Failed to find the specified datastore
519  * \retval non-NULL The specified datastore
520  */
521 struct ast_datastore *ast_sip_subscription_get_datastore(struct ast_sip_subscription *subscription, const char *name);
522 
523 /*!
524  * \brief Remove a subscription datastore from the subscription
525  *
526  * This operation may cause the datastore's free() callback to be called if the reference
527  * count reaches zero.
528  *
529  * \param subscription The subscription to remove the datastore from
530  * \param name The name of the datastore to remove
531  */
532 void ast_sip_subscription_remove_datastore(struct ast_sip_subscription *subscription, const char *name);
533 
534 /*!
535  * \brief Get the datastores container for a subscription
536  *
537  * \param subscription The subscription to get the datastores container from
538  *
539  * \retval NULL datastores container not present
540  * \retval non-NULL datastores container
541  *
542  * \note The container is NOT returned with reference count bumped
543  *
544  * \since 14.0.0
545  */
547 
548 /*!
549  * \since 13.31.0
550  * \since 16.8.0
551  * \since 17.2.0
552  * \brief Set persistence data for a subscription
553  *
554  * \param subscription The subscription to set persistence data on
555  * \param persistence_data The persistence data to set
556  *
557  * \note This steals the reference to persistence_data
558  */
559 void ast_sip_subscription_set_persistence_data(struct ast_sip_subscription *subscription, struct ast_json *persistence_data);
560 
561 /*!
562  * \since 13.31.0
563  * \since 16.8.0
564  * \since 17.2.0
565  * \brief Retrieve persistence data for a subscription
566  *
567  * \param subscription The subscription to retrieve persistence data from
568  */
569 const struct ast_json *ast_sip_subscription_get_persistence_data(const struct ast_sip_subscription *subscription);
570 
571 /*!
572  * \brief Register a subscription handler
573  *
574  * \retval 0 Handler was registered successfully
575  * \retval non-zero Handler was not registered successfully
576  */
578 
579 /*!
580  * \brief Unregister a subscription handler
581  */
583 
584 /*!
585  * \brief Pubsub body generator
586  *
587  * A body generator is responsible for taking Asterisk content
588  * and converting it into a body format to be placed in an outbound
589  * SIP NOTIFY or PUBLISH request.
590  */
592  /*!
593  * \brief Content type
594  * In "plain/text", "plain" is the type
595  */
596  const char *type;
597  /*!
598  * \brief Content subtype
599  * In "plain/text", "text" is the subtype
600  */
601  const char *subtype;
602  /*! Type of data the body generator takes as input */
603  const char *body_type;
604  /*!
605  * \brief allocate body structure.
606  *
607  * Body generators will have this method called when a NOTIFY
608  * or PUBLISH body needs to be created. The type returned depends on
609  * the type of content being produced for the body. The data parameter
610  * is provided by the subscription handler and will vary between different
611  * event types.
612  *
613  * \param data The subscription data provided by the event handler
614  * \retval non-NULL The allocated body
615  * \retval NULL Failure
616  */
617  void *(*allocate_body)(void *data);
618  /*!
619  * \brief Add content to the body of a SIP request
620  *
621  * The body of the request has already been allocated by the body generator's
622  * allocate_body callback.
623  *
624  * \param body The body of the SIP request. The type is determined by the
625  * content type.
626  * \param data The subscription data used to populate the body. The type is
627  * determined by the content type.
628  */
629  int (*generate_body_content)(void *body, void *data);
630  /*!
631  * \brief Convert the body to a string.
632  *
633  * \param body The request body.
634  * \param str The converted string form of the request body
635  */
636  void (*to_string)(void *body, struct ast_str **str);
637  /*!
638  * \brief Deallocate resources created for the body
639  *
640  * Optional callback to destroy resources allocated for the
641  * message body.
642  *
643  * \param body Body to be destroyed
644  */
645  void (*destroy_body)(void *body);
647 };
648 
649 /*!
650  * \brief Body supplement
651  *
652  * Body supplements provide additions to bodies not already
653  * provided by body generators. This may include proprietary
654  * extensions, optional content, or other nonstandard fare.
655  */
657  /*!
658  * \brief Content type
659  * In "plain/text", "plain" is the type
660  */
661  const char *type;
662  /*!
663  * \brief Content subtype
664  * In "plain/text", "text" is the subtype
665  */
666  const char *subtype;
667  /*!
668  * \brief Add additional content to a SIP request body.
669  *
670  * A body generator will have already allocated a body and populated
671  * it with base data for the event. The supplement's duty is, if desired,
672  * to extend the body to have optional data beyond what a base RFC specifies.
673  *
674  * \param body The body of the SIP request. The type is determined by the
675  * body generator that allocated the body.
676  * \param data The subscription data used to populate the body. The type is
677  * determined by the content type.
678  */
679  int (*supplement_body)(void *body, void *data);
681 };
682 
683 /*!
684  * \since 13.0.0
685  * \brief Generate body content for a PUBLISH or NOTIFY
686  *
687  * This function takes a pre-allocated body and calls into registered body
688  * generators in order to fill in the body with appropriate details.
689  * The primary body generator will be called first, followed by the
690  * supplementary body generators
691  *
692  * \param content_type The content type of the body
693  * \param content_subtype The content subtype of the body
694  * \param data The data associated with body generation.
695  * \param[out] str The string representation of the generated body
696  * \retval 0 Success
697  * \retval non-zero Failure
698  */
699 int ast_sip_pubsub_generate_body_content(const char *content_type,
700  const char *content_subtype, struct ast_sip_body_data *data, struct ast_str **str);
701 
702 /*!
703  * \brief Is a body generator registered for the given type/subtype.
704  * \since 14.0.0
705  *
706  * \param type The content type of the body
707  * \param subtype The content subtype of the body
708  *
709  * \note In "plain/text", "plain" is the type and "text" is the subtype.
710  *
711  * \retval non-zero if a generator is registered.
712  */
713 int ast_sip_pubsub_is_body_generator_registered(const char *type, const char *subtype);
714 
715 /*!
716  * \since 13.0.0
717  * \brief Register a body generator with the pubsub core.
718  *
719  * This may fail if an attempt is made to register a primary body supplement
720  * for a given content type if a primary body supplement for that content type
721  * has already been registered.
722  *
723  * \param generator Body generator to register
724  * \retval 0 Success
725  * \retval -1 Failure
726  */
728 
729 /*!
730  * \since 13.0.0
731  * \brief Unregister a body generator with the pubsub core.
732  *
733  * \param generator Body generator to unregister
734  */
736 
737 /*!
738  * \since 13.0.0
739  * \brief Register a body generator with the pubsub core.
740  *
741  * This may fail if an attempt is made to register a primary body supplement
742  * for a given content type if a primary body supplement for that content type
743  * has already been registered.
744  *
745  * \param generator Body generator to register
746  * \retval 0 Success
747  * \retval -1 Failure
748  */
750 
751 /*!
752  * \since 13.0.0
753  * \brief Unregister a body generator with the pubsub core.
754  *
755  * \param generator Body generator to unregister
756  */
758 
759 /*!
760  * \since 13.0.0
761  * \brief Get the body type used for this subscription
762  */
764 
765 /*!
766  * \since 13.0.0
767  * \brief Get the body subtype used for this subscription
768  */
770 
771 /*!
772  * \since 13.6.0
773  * \brief Alert the pubsub core that the subscription is ready for destruction
774  *
775  * \param sub The subscription that is complete
776  * \return Nothing
777  */
779 
780 #endif /* RES_PJSIP_PUBSUB_H */
const char * event_name
The name of the event this handler deals with.
static const char type[]
Definition: chan_ooh323.c:109
enum sip_cc_notify_state state
Definition: chan_sip.c:959
void ast_sip_subscription_get_local_uri(struct ast_sip_subscription *sub, char *buf, size_t size)
Retrieve the local URI for this subscription.
struct ast_taskprocessor * ast_sip_subscription_get_serializer(struct ast_sip_subscription *sub)
Get the serializer for the subscription.
int ast_sip_subscription_is_terminated(const struct ast_sip_subscription *sub)
Get whether the subscription has been terminated or not.
struct ast_sip_subscriber * subscriber
Pubsub body generator.
const char * type
Content type In "plain/text", "plain" is the type.
const char * body_type
Data used to create bodies for NOTIFY/PUBLISH requests.
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
struct ast_sip_notifier * notifier
const char * ast_sip_subscription_get_body_type(struct ast_sip_subscription *sub)
Get the body type used for this subscription.
Structure for variables, used for configurations and for channel variables.
int ast_sip_register_subscription_handler(struct ast_sip_subscription_handler *handler)
Register a subscription handler.
int(* new_publication)(struct ast_sip_endpoint *endpoint, const char *resource, const char *event_configuration)
Called when a PUBLISH to establish a new publication arrives.
Structure for a data store type.
Definition: datastore.h:31
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 * type
Content type In "plain/text", "plain" is the type.
int ast_sip_register_publish_handler(struct ast_sip_publish_handler *handler)
Register a publish handler.
static int subscription_established(struct ast_sip_subscription *sub)
const char * ast_sip_subscription_get_resource_name(struct ast_sip_subscription *sub)
Get the name of the subscribed resource.
static void to_string(struct val *vp)
Definition: ast_expr2.c:2630
Structure for a data store object.
Definition: datastore.h:68
const char * str
Definition: app_jack.c:147
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_publication_add_datastore(struct ast_sip_publication *publication, struct ast_datastore *datastore)
Add a datastore to a SIP publication.
const char * uid
Definition: datastore.h:69
struct ao2_container * ast_sip_publication_get_datastores(const struct ast_sip_publication *publication)
Get the datastores container for a publication.
struct ao2_container * ast_sip_subscription_get_datastores(const struct ast_sip_subscription *subscription)
Get the datastores container for a subscription.
void(* publish_expire)(struct ast_sip_publication *pub)
Called when a publication has reached its expiration.
pjsip_sip_uri * ast_sip_subscription_get_sip_uri(struct ast_sip_subscription *sub)
Retrieve the local sip uri for this subscription.
const char * subtype
Content subtype In "plain/text", "text" is the subtype.
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.
void ast_sip_subscription_set_persistence_data(struct ast_sip_subscription *subscription, struct ast_json *persistence_data)
Set persistence data for a subscription.
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.
ast_sip_publish_state
ast_sip_subscription_notify_reason
#define AST_SIP_MAX_ACCEPT
struct ast_sip_publish_handler * next
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.
struct ast_sip_endpoint * ast_sip_publication_get_endpoint(struct ast_sip_publication *pub)
Given a publication, get the associated endpoint.
A set of macros to manage forward-linked lists.
An entity with which Asterisk communicates.
Definition: res_pjsip.h:812
int ast_sip_pubsub_is_body_generator_registered(const char *type, const char *subtype)
Is a body generator registered for the given type/subtype.
const char * subtype
Content subtype In "plain/text", "text" is the subtype.
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_destroy(struct ast_sip_subscription *sub)
Alert the pubsub core that the subscription is ready for destruction.
Structure representing a "virtual" SIP subscription.
int(* publication_state_change)(struct ast_sip_publication *pub, pjsip_msg_body *body, enum ast_sip_publish_state state)
Published resource has changed states.
const char * ast_sip_subscription_get_body_subtype(struct ast_sip_subscription *sub)
Get the body subtype used for this subscription.
void ast_sip_publication_remove_datastore(struct ast_sip_publication *publication, const char *name)
Remove a publication datastore from the publication.
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
static struct ast_generator generator
Definition: app_fax.c:359
const char * ast_sip_publication_get_resource(const struct ast_sip_publication *pub)
Given a publication, get the resource the publication is to.
def info(msg)
struct ast_datastore * ast_sip_subscription_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Alternative for ast_datastore_alloc()
Callbacks that publication handlers will define.
#define AST_LIST_ENTRY(type)
Declare a forward link structure inside a list entry.
Definition: linkedlists.h:409
static const char name[]
Definition: cdr_mysql.c:74
static void to_ami(struct ast_sip_subscription *sub, struct ast_str **buf)
void ast_sip_unregister_subscription_handler(struct ast_sip_subscription_handler *handler)
Unregister a subscription handler.
struct ast_datastore * ast_sip_subscription_get_datastore(struct ast_sip_subscription *subscription, const char *name)
Retrieve a subscription datastore.
static void subscription_shutdown(struct ast_sip_subscription *sub)
void ast_sip_unregister_publish_handler(struct ast_sip_publish_handler *handler)
Unregister a publish handler.
struct ast_sip_endpoint * ast_sip_subscription_get_endpoint(struct ast_sip_subscription *sub)
Get the endpoint that is associated with this subscription.
pjsip_dialog * ast_sip_subscription_get_dialog(struct ast_sip_subscription *sub)
Get the pjsip dialog that is associated with this subscription.
int ast_sip_pubsub_register_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
Register a body generator with the pubsub core.
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
int ast_sip_subscription_add_datastore(struct ast_sip_subscription *subscription, struct ast_datastore *datastore)
Add a datastore to a SIP subscription.
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.
ast_sip_subscription_role
Role for the subscription that is being created.
void ast_sip_subscription_remove_datastore(struct ast_sip_subscription *subscription, const char *name)
Remove a subscription datastore from the subscription.
void ast_sip_pubsub_unregister_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
Unregister a body generator with the pubsub core.
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
struct stasis_forward * sub
Definition: res_corosync.c:240
Abstract JSON element (object, array, string, int, ...).
Structure representing a SIP publication.
const struct ast_json * ast_sip_subscription_get_persistence_data(const struct ast_sip_subscription *subscription)
Retrieve persistence data for a subscription.
struct ast_sip_subscription_handler * next
Generic container type.
const char * default_accept
Default body type defined for the event package this notifier handles.
struct ao2_container * publications
Publications.
struct ast_datastore * ast_sip_publication_get_datastore(struct ast_sip_publication *publication, const char *name)
Retrieve a publication datastore.
SIP body description.
Definition: res_pjsip.h:2027
void * ast_sip_subscription_get_header(const struct ast_sip_subscription *sub, const char *header)
Get a header value for a subscription.
Data for responses to SUBSCRIBEs and NOTIFIEs.
void ast_sip_pubsub_unregister_body_generator(struct ast_sip_pubsub_body_generator *generator)
Unregister a body generator with the pubsub core.
static int new_subscribe(struct ast_sip_endpoint *endpoint, const char *resource)