Asterisk - The Open Source Telephony Project  18.5.0
res_pjsip_exten_state.c
Go to the documentation of this file.
1 /*
2  * Asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2013, Digium, Inc.
5  *
6  * Kevin Harwell <[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 /*** MODULEINFO
20  <depend>pjproject</depend>
21  <depend>res_pjsip</depend>
22  <depend>res_pjsip_pubsub</depend>
23  <depend>res_pjsip_outbound_publish</depend>
24  <support_level>core</support_level>
25  ***/
26 
27 #include "asterisk.h"
28 
29 #include <regex.h>
30 
31 #include <pjsip.h>
32 #include <pjsip_simple.h>
33 #include <pjlib.h>
34 
35 #include "asterisk/res_pjsip.h"
39 #include "asterisk/module.h"
40 #include "asterisk/logger.h"
41 #include "asterisk/astobj2.h"
42 #include "asterisk/sorcery.h"
43 #include "asterisk/app.h"
44 #include "asterisk/taskprocessor.h"
45 
46 #define BODY_SIZE 1024
47 #define EVENT_TYPE_SIZE 50
48 
49 /*!
50  * \brief The number of buckets to use for storing publishers
51  */
52 #define PUBLISHER_BUCKETS 31
53 
54 /*!
55  * \brief Container of active outbound extension state publishers
56  */
57 static struct ao2_container *publishers;
58 
59 /*! Serializer for outbound extension state publishing. */
61 
62 /*!
63  * \brief A subscription for extension state
64  *
65  * This structure acts as the owner for the underlying SIP subscription. It
66  * also keeps a pointer to an associated "provider" so when a state changes
67  * a notify data creator is quickly accessible.
68  */
70  /*! Watcher id when registering for extension state changes */
71  int id;
72  /*! The SIP subscription */
74  /*! The serializer to use for notifications */
76  /*! Context in which subscription looks for updates */
78  /*! Extension within the context to receive updates from */
80  /*! The subscription's user agent */
81  char *user_agent;
82  /*! The last known extension state */
84  /*! The last known presence state */
86 };
87 
88 /*!
89  * \brief An extension state publisher
90  *
91  */
93  /*! Regular expression for context filtering */
94  regex_t context_regex;
95  /*! Regular expression for extension filtering */
96  regex_t exten_regex;
97  /*! Publish client to use for sending publish messages */
99  /*! Datastores container to hold persistent information */
101  /*! Whether context filtering is active */
102  unsigned int context_filter;
103  /*! Whether extension filtering is active */
104  unsigned int exten_filter;
105  /*! The body type to use for this publisher - stored after the name */
106  char *body_type;
107  /*! The body subtype to use for this publisher - stored after the body type */
109  /*! The name of this publisher */
110  char name[0];
111 };
112 
113 #define DEFAULT_PRESENCE_BODY "application/pidf+xml"
114 #define DEFAULT_DIALOG_BODY "application/dialog-info+xml"
115 
116 static void subscription_shutdown(struct ast_sip_subscription *sub);
117 static int new_subscribe(struct ast_sip_endpoint *endpoint, const char *resource);
119 static void *get_notify_data(struct ast_sip_subscription *sub);
120 static void to_ami(struct ast_sip_subscription *sub,
121  struct ast_str **buf);
122 static int publisher_start(struct ast_sip_outbound_publish *configuration,
123  struct ast_sip_outbound_publish_client *client);
124 static int publisher_stop(struct ast_sip_outbound_publish_client *client);
125 
128  .new_subscribe = new_subscribe,
129  .subscription_established = subscription_established,
130  .get_notify_data = get_notify_data,
131 };
132 
135  .new_subscribe = new_subscribe,
136  .subscription_established = subscription_established,
137  .get_notify_data = get_notify_data,
138 };
139 
141  .event_name = "presence",
142  .body_type = AST_SIP_EXTEN_STATE_DATA,
143  .accept = { DEFAULT_PRESENCE_BODY, },
144  .subscription_shutdown = subscription_shutdown,
145  .to_ami = to_ami,
146  .notifier = &presence_notifier,
147 };
148 
150  .event_name = "presence",
151  .start_publishing = publisher_start,
152  .stop_publishing = publisher_stop,
153 };
154 
156  .event_name = "dialog",
157  .body_type = AST_SIP_EXTEN_STATE_DATA,
158  .accept = { DEFAULT_DIALOG_BODY, },
159  .subscription_shutdown = subscription_shutdown,
160  .to_ami = to_ami,
161  .notifier = &dialog_notifier,
162 };
163 
165  .event_name = "dialog",
166  .start_publishing = publisher_start,
167  .stop_publishing = publisher_stop,
168 };
169 
171 {
172  struct exten_state_subscription *sub = obj;
173 
174  ast_free(sub->user_agent);
177 }
178 
179 static char *get_user_agent(const struct ast_sip_subscription *sip_sub)
180 {
181  size_t size;
182  char *user_agent = NULL;
183  pjsip_user_agent_hdr *user_agent_hdr = ast_sip_subscription_get_header(
184  sip_sub, "User-Agent");
185 
186  if (!user_agent_hdr) {
187  return NULL;
188  }
189 
190  size = pj_strlen(&user_agent_hdr->hvalue) + 1;
191  user_agent = ast_malloc(size);
192  ast_copy_pj_str(user_agent, &user_agent_hdr->hvalue, size);
193  return ast_str_to_lower(user_agent);
194 }
195 
196 /*!
197  * \internal
198  * \brief Initialize the last extension state to something outside
199  * its usual states.
200  */
201 #define INITIAL_LAST_EXTEN_STATE -3
202 
203 /*!
204  * \internal
205  * \brief Allocates an exten_state_subscription object.
206  *
207  * Creates the underlying SIP subscription for the given request. First makes
208  * sure that there are registered handler and provider objects available.
209  */
211  struct ast_sip_subscription *sip_sub, struct ast_sip_endpoint *endpoint)
212 {
213  struct exten_state_subscription * exten_state_sub;
214 
215  exten_state_sub = ao2_alloc(sizeof(*exten_state_sub), exten_state_subscription_destructor);
216  if (!exten_state_sub) {
217  return NULL;
218  }
219 
220  exten_state_sub->sip_sub = sip_sub;
221 
222  /* We keep our own reference to the serializer as there is no guarantee in state_changed
223  * that the subscription tree is still valid when it is called. This can occur when
224  * the subscription is terminated at around the same time as the state_changed
225  * callback is invoked.
226  */
227  exten_state_sub->serializer = ao2_bump(ast_sip_subscription_get_serializer(sip_sub));
228  exten_state_sub->last_exten_state = INITIAL_LAST_EXTEN_STATE;
229  exten_state_sub->last_presence_state = AST_PRESENCE_NOT_SET;
230  exten_state_sub->user_agent = get_user_agent(sip_sub);
231  return exten_state_sub;
232 }
233 
235  struct ast_sip_exten_state_data exten_state_data;
238 };
239 
240 static void notify_task_data_destructor(void *obj)
241 {
242  struct notify_task_data *task_data = obj;
243 
244  ao2_ref(task_data->exten_state_sub, -1);
249 }
250 
251 static struct notify_task_data *alloc_notify_task_data(const char *exten,
253  struct ast_state_cb_info *info)
254 {
255  struct notify_task_data *task_data =
256  ao2_alloc(sizeof(*task_data), notify_task_data_destructor);
257 
258  if (!task_data) {
259  ast_log(LOG_WARNING, "Unable to create notify task data\n");
260  return NULL;
261  }
262 
263  task_data->exten_state_sub = exten_state_sub;
264  task_data->exten_state_sub->last_exten_state = info->exten_state;
266  ao2_ref(task_data->exten_state_sub, +1);
267 
268  task_data->exten_state_data.exten = exten_state_sub->exten;
269  task_data->exten_state_data.exten_state = info->exten_state;
273  task_data->exten_state_data.user_agent = ast_strdup(exten_state_sub->user_agent);
275  task_data->exten_state_data.sub = exten_state_sub->sip_sub;
277 
278  if ((info->exten_state == AST_EXTENSION_DEACTIVATED) ||
279  (info->exten_state == AST_EXTENSION_REMOVED)) {
280  ast_verb(2, "Watcher for hint %s %s\n", exten, info->exten_state
281  == AST_EXTENSION_REMOVED ? "removed" : "deactivated");
282  task_data->terminate = 1;
283  }
284 
285  return task_data;
286 }
287 
288 static int notify_task(void *obj)
289 {
291  struct ast_sip_body_data data = {
293  .body_data = &task_data->exten_state_data,
294  };
295 
296  /* Terminated subscriptions are no longer associated with a valid tree, and sending
297  * NOTIFY messages on a subscription which has already been terminated won't work.
298  */
299  if (ast_sip_subscription_is_terminated(task_data->exten_state_sub->sip_sub)) {
300  return 0;
301  }
302 
303  /* All access to the subscription must occur within a task executed within its serializer */
304  ast_sip_subscription_get_local_uri(task_data->exten_state_sub->sip_sub,
305  task_data->exten_state_data.local, sizeof(task_data->exten_state_data.local));
306  ast_sip_subscription_get_remote_uri(task_data->exten_state_sub->sip_sub,
307  task_data->exten_state_data.remote, sizeof(task_data->exten_state_data.remote));
308 
309  /* Pool allocation has to happen here so that we allocate within a PJLIB thread */
310  task_data->exten_state_data.pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
311  "exten_state", 1024, 1024);
312  if (!task_data->exten_state_data.pool) {
313  return -1;
314  }
315 
316  task_data->exten_state_data.sub = task_data->exten_state_sub->sip_sub;
317  task_data->exten_state_data.datastores = ast_sip_subscription_get_datastores(task_data->exten_state_sub->sip_sub);
318 
319  ast_sip_subscription_notify(task_data->exten_state_sub->sip_sub, &data,
320  task_data->terminate);
321 
322  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(),
323  task_data->exten_state_data.pool);
324  return 0;
325 }
326 
327 /*!
328  * \internal
329  * \brief Callback for exten/device state changes.
330  *
331  * Upon state change, send the appropriate notification to the subscriber.
332  */
333 static int state_changed(const char *context, const char *exten,
334  struct ast_state_cb_info *info, void *data)
335 {
336  struct notify_task_data *task_data;
337  struct exten_state_subscription *exten_state_sub = data;
338 
339  if (!(task_data = alloc_notify_task_data(exten, exten_state_sub, info))) {
340  return -1;
341  }
342 
343  /* safe to push this async since we copy the data from info and
344  add a ref for the device state info */
346  task_data)) {
347  ao2_cleanup(task_data);
348  return -1;
349  }
350  return 0;
351 }
352 
353 static void state_changed_destroy(int id, void *data)
354 {
355  struct exten_state_subscription *exten_state_sub = data;
356  ao2_cleanup(exten_state_sub);
357 }
358 
359 static struct ast_datastore_info ds_info = { };
360 static const char ds_name[] = "exten state datastore";
361 
362 /*!
363  * \internal
364  * \brief Add a datastore for exten exten_state_subscription.
365  *
366  * Adds the exten_state_subscription wrapper object to a datastore so it can be retrieved
367  * later based upon its association with the ast_sip_subscription.
368  */
369 static int add_datastore(struct exten_state_subscription *exten_state_sub)
370 {
371  RAII_VAR(struct ast_datastore *, datastore,
373 
374  if (!datastore) {
375  return -1;
376  }
377 
378  datastore->data = exten_state_sub;
379  ast_sip_subscription_add_datastore(exten_state_sub->sip_sub, datastore);
380  ao2_ref(exten_state_sub, +1);
381  return 0;
382 }
383 
384 /*!
385  * \internal
386  * \brief Get the exten_state_subscription object associated with the given
387  * ast_sip_subscription in the datastore.
388  */
390  struct ast_sip_subscription *sub)
391 {
392  RAII_VAR(struct ast_datastore *, datastore,
394 
395  return datastore ? datastore->data : NULL;
396 }
397 
399 {
400  struct exten_state_subscription *exten_state_sub = get_exten_state_sub(sub);
401 
402  if (!exten_state_sub) {
403  return;
404  }
405 
406  ast_extension_state_del(exten_state_sub->id, state_changed);
408  /* remove data store reference */
409  ao2_cleanup(exten_state_sub);
410 }
411 
412 static int new_subscribe(struct ast_sip_endpoint *endpoint,
413  const char *resource)
414 {
415  const char *context = S_OR(endpoint->subscription.context, endpoint->context);
416 
417  if (!ast_exists_extension(NULL, context, resource, PRIORITY_HINT, NULL)) {
418  ast_log(LOG_NOTICE, "Endpoint '%s' state subscription failed: "
419  "Extension '%s' does not exist in context '%s' or has no associated hint\n",
420  ast_sorcery_object_get_id(endpoint), resource, context);
421  return 404;
422  }
423 
424  return 200;
425 }
426 
428 {
429  struct ast_sip_endpoint *endpoint = ast_sip_subscription_get_endpoint(sip_sub);
430  const char *resource = ast_sip_subscription_get_resource_name(sip_sub);
431  struct exten_state_subscription *exten_state_sub;
432 
433  if (!(exten_state_sub = exten_state_subscription_alloc(sip_sub, endpoint))) {
434  ao2_cleanup(endpoint);
435  return -1;
436  }
437 
438  ast_copy_string(exten_state_sub->context,
439  S_OR(endpoint->subscription.context, endpoint->context),
440  sizeof(exten_state_sub->context));
441  ast_copy_string(exten_state_sub->exten, resource, sizeof(exten_state_sub->exten));
442 
443  if ((exten_state_sub->id = ast_extension_state_add_destroy_extended(
444  exten_state_sub->context, exten_state_sub->exten,
445  state_changed, state_changed_destroy, exten_state_sub)) < 0) {
446  ast_log(LOG_WARNING, "Unable to subscribe endpoint '%s' to extension '%s@%s'\n",
447  ast_sorcery_object_get_id(endpoint), exten_state_sub->exten,
448  exten_state_sub->context);
449  ao2_cleanup(endpoint);
450  ao2_cleanup(exten_state_sub);
451  return -1;
452  }
453 
454  /* Go ahead and cleanup the endpoint since we don't need it anymore */
455  ao2_cleanup(endpoint);
456 
457  /* bump the ref since ast_extension_state_add holds a reference */
458  ao2_ref(exten_state_sub, +1);
459 
460  if (add_datastore(exten_state_sub)) {
461  ast_log(LOG_WARNING, "Unable to add to subscription datastore.\n");
462  ao2_cleanup(exten_state_sub);
463  return -1;
464  }
465 
466  ao2_cleanup(exten_state_sub);
467  return 0;
468 }
469 
470 static void exten_state_data_destructor(void *obj)
471 {
472  struct ast_sip_exten_state_data *exten_state_data = obj;
473 
474  ao2_cleanup(exten_state_data->device_state_info);
475  ast_free(exten_state_data->presence_subtype);
476  ast_free(exten_state_data->presence_message);
477  if (exten_state_data->pool) {
478  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), exten_state_data->pool);
479  }
480 }
481 
483  struct exten_state_subscription *exten_state_sub)
484 {
485  struct ast_sip_exten_state_data *exten_state_data;
486  char *subtype = NULL;
487  char *message = NULL;
488  int presence_state;
489 
490  exten_state_data = ao2_alloc(sizeof(*exten_state_data), exten_state_data_destructor);
491  if (!exten_state_data) {
492  return NULL;
493  }
494 
495  exten_state_data->exten = exten_state_sub->exten;
496  presence_state = ast_hint_presence_state(NULL, exten_state_sub->context, exten_state_sub->exten, &subtype, &message);
497  if (presence_state == -1 || presence_state == AST_PRESENCE_INVALID) {
498  ao2_cleanup(exten_state_data);
499  return NULL;
500  }
501  exten_state_data->presence_state = presence_state;
502  exten_state_data->presence_subtype = subtype;
503  exten_state_data->presence_message = message;
504  exten_state_data->user_agent = exten_state_sub->user_agent;
505  ast_sip_subscription_get_local_uri(sip_sub, exten_state_data->local,
506  sizeof(exten_state_data->local));
507  ast_sip_subscription_get_remote_uri(sip_sub, exten_state_data->remote,
508  sizeof(exten_state_data->remote));
509  exten_state_data->sub = sip_sub;
510  exten_state_data->datastores = ast_sip_subscription_get_datastores(sip_sub);
511 
512  exten_state_data->exten_state = ast_extension_state_extended(
513  NULL, exten_state_sub->context, exten_state_sub->exten,
514  &exten_state_data->device_state_info);
515  if (exten_state_data->exten_state < 0) {
516  ao2_cleanup(exten_state_data);
517  return NULL;
518  }
519 
520  exten_state_data->pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(),
521  "exten_state", 1024, 1024);
522  if (!exten_state_data->pool) {
523  ao2_cleanup(exten_state_data);
524  return NULL;
525  }
526 
527  return exten_state_data;
528 }
529 
531 {
532  struct exten_state_subscription *exten_state_sub;
533 
534  exten_state_sub = get_exten_state_sub(sub);
535  if (!exten_state_sub) {
536  return NULL;
537  }
538 
539  return exten_state_data_alloc(sub, exten_state_sub);
540 }
541 
542 static void to_ami(struct ast_sip_subscription *sub,
543  struct ast_str **buf)
544 {
545  struct exten_state_subscription *exten_state_sub =
546  get_exten_state_sub(sub);
547 
548  if (!exten_state_sub) {
549  return;
550  }
551 
552  ast_str_append(buf, 0, "SubscriptionType: extension_state\r\n"
553  "Extension: %s\r\nExtensionStates: %s\r\n",
554  exten_state_sub->exten, ast_extension_state2str(
555  exten_state_sub->last_exten_state));
556 }
557 
559  /*! Publishers needing state update */
560  AST_VECTOR(name, struct exten_state_publisher *) pubs;
561  /*! Body generator state data */
562  struct ast_sip_exten_state_data exten_state_data;
563 };
564 
566 {
567  if (!doomed) {
568  return;
569  }
570 
571  ast_free((void *) doomed->exten_state_data.exten);
572  ast_free(doomed->exten_state_data.presence_subtype);
573  ast_free(doomed->exten_state_data.presence_message);
574  ao2_cleanup(doomed->exten_state_data.device_state_info);
575 
576  AST_VECTOR_CALLBACK_VOID(&doomed->pubs, ao2_ref, -1);
577  AST_VECTOR_FREE(&doomed->pubs);
578 
579  ast_free(doomed);
580 }
581 
583 {
584  struct exten_state_pub_data *pub_data;
585 
586  pub_data = ast_calloc(1, sizeof(*pub_data));
587  if (!pub_data) {
588  return NULL;
589  }
590 
591  if (AST_VECTOR_INIT(&pub_data->pubs, ao2_container_count(publishers))) {
593  return NULL;
594  }
595 
596  /* Save off currently known information for the body generators. */
597  pub_data->exten_state_data.exten = ast_strdup(exten);
598  pub_data->exten_state_data.exten_state = info->exten_state;
599  pub_data->exten_state_data.presence_state = info->presence_state;
600  pub_data->exten_state_data.presence_subtype = ast_strdup(info->presence_subtype);
601  pub_data->exten_state_data.presence_message = ast_strdup(info->presence_message);
602  pub_data->exten_state_data.device_state_info = ao2_bump(info->device_state_info);
603  if (!pub_data->exten_state_data.exten
604  || !pub_data->exten_state_data.presence_subtype
605  || !pub_data->exten_state_data.presence_message) {
607  return NULL;
608  }
609  return pub_data;
610 }
611 
612 /*!
613  * \internal
614  * \brief Create exten state PUBLISH messages under PJSIP thread.
615  * \since 14.0.0
616  *
617  * \return 0
618  */
619 static int exten_state_publisher_cb(void *data)
620 {
621  struct exten_state_pub_data *pub_data = data;
622  struct exten_state_publisher *publisher;
623  size_t idx;
624  struct ast_str *body_text;
625  pj_pool_t *pool;
626  struct ast_sip_body_data gen_data = {
628  .body_data = &pub_data->exten_state_data,
629  };
630  struct ast_sip_body body;
631 
632  body_text = ast_str_create(64);
633  if (!body_text) {
635  return 0;
636  }
637 
638  /* Need a PJSIP memory pool to generate the bodies. */
639  pool = pjsip_endpt_create_pool(ast_sip_get_pjsip_endpoint(), "pub_state_body",
640  1024, 1024);
641  if (!pool) {
642  ast_log(LOG_WARNING, "Exten state publishing unable to create memory pool\n");
644  ast_free(body_text);
645  return 0;
646  }
647  pub_data->exten_state_data.pool = pool;
648 
649  for (idx = 0; idx < AST_VECTOR_SIZE(&pub_data->pubs); ++idx) {
650  const char *uri;
651  int res;
652 
653  publisher = AST_VECTOR_GET(&pub_data->pubs, idx);
654 
655  uri = ast_sip_publish_client_get_user_from_uri(publisher->client, pub_data->exten_state_data.exten,
656  pub_data->exten_state_data.local, sizeof(pub_data->exten_state_data.local));
657  if (ast_strlen_zero(uri)) {
658  ast_log(LOG_WARNING, "PUBLISH client '%s' has no from_uri or server_uri defined.\n",
659  publisher->name);
660  continue;
661  }
662 
663  uri = ast_sip_publish_client_get_user_to_uri(publisher->client, pub_data->exten_state_data.exten,
664  pub_data->exten_state_data.remote, sizeof(pub_data->exten_state_data.remote));
665  if (ast_strlen_zero(uri)) {
666  ast_log(LOG_WARNING, "PUBLISH client '%s' has no to_uri or server_uri defined.\n",
667  publisher->name);
668  continue;
669  }
670 
671  pub_data->exten_state_data.datastores = publisher->datastores;
672 
674  publisher->body_subtype, &gen_data, &body_text);
675  pj_pool_reset(pool);
676  if (res) {
678  "PUBLISH client '%s' unable to generate %s/%s PUBLISH body.\n",
679  publisher->name, publisher->body_type, publisher->body_subtype);
680  continue;
681  }
682 
683  body.type = publisher->body_type;
684  body.subtype = publisher->body_subtype;
685  body.body_text = ast_str_buffer(body_text);
686  ast_sip_publish_client_user_send(publisher->client, pub_data->exten_state_data.exten, &body);
687  }
688 
689  pjsip_endpt_release_pool(ast_sip_get_pjsip_endpoint(), pool);
690 
691  ast_free(body_text);
693  return 0;
694 }
695 
696 /*!
697  * \brief Global extension state callback function
698  */
699 static int exten_state_publisher_state_cb(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
700 {
701  struct ao2_iterator publisher_iter;
702  struct exten_state_publisher *publisher;
703  struct exten_state_pub_data *pub_data = NULL;
704 
705  ast_debug(5, "Exten state publisher: %s@%s Reason:%s State:%s Presence:%s Subtype:'%s' Message:'%s'\n",
706  exten, context,
708  ? "Device"
710  ? "Presence"
711  : "Unknown",
714  S_OR(info->presence_subtype, ""),
715  S_OR(info->presence_message, ""));
716  publisher_iter = ao2_iterator_init(publishers, 0);
717  for (; (publisher = ao2_iterator_next(&publisher_iter)); ao2_ref(publisher, -1)) {
718  if ((publisher->context_filter && regexec(&publisher->context_regex, context, 0, NULL, 0)) ||
719  (publisher->exten_filter && regexec(&publisher->exten_regex, exten, 0, NULL, 0))) {
720  continue;
721  }
722 
723  if (!pub_data) {
724  pub_data = exten_state_pub_data_alloc(exten, info);
725  if (!pub_data) {
726  ao2_ref(publisher, -1);
727  break;
728  }
729  }
730 
731  ao2_ref(publisher, +1);
732  if (AST_VECTOR_APPEND(&pub_data->pubs, publisher)) {
733  ao2_ref(publisher, -1);
734  } else {
735  ast_debug(5, "'%s' will publish exten state\n", publisher->name);
736  }
737  }
738  ao2_iterator_destroy(&publisher_iter);
739 
740  if (pub_data
741  && ast_sip_push_task(publish_exten_state_serializer, exten_state_publisher_cb,
742  pub_data)) {
744  }
745 
746  return 0;
747 }
748 
749 /*!
750  * \brief Hashing function for extension state publisher
751  */
752 static int exten_state_publisher_hash(const void *obj, const int flags)
753 {
754  const struct exten_state_publisher *object;
755  const char *key;
756 
757  switch (flags & OBJ_SEARCH_MASK) {
758  case OBJ_SEARCH_KEY:
759  key = obj;
760  break;
761  case OBJ_SEARCH_OBJECT:
762  object = obj;
763  key = object->name;
764  break;
765  default:
766  ast_assert(0);
767  return 0;
768  }
769  return ast_str_hash(key);
770 }
771 
772 /*!
773  * \brief Comparator function for extension state publisher
774  */
775 static int exten_state_publisher_cmp(void *obj, void *arg, int flags)
776 {
777  const struct exten_state_publisher *object_left = obj;
778  const struct exten_state_publisher *object_right = arg;
779  const char *right_key = arg;
780  int cmp;
781 
782  switch (flags & OBJ_SEARCH_MASK) {
783  case OBJ_SEARCH_OBJECT:
784  right_key = object_right->name;
785  /* Fall through */
786  case OBJ_SEARCH_KEY:
787  cmp = strcmp(object_left->name, right_key);
788  break;
790  /* Not supported by container. */
791  ast_assert(0);
792  return 0;
793  default:
794  cmp = 0;
795  break;
796  }
797  if (cmp) {
798  return 0;
799  }
800  return CMP_MATCH;
801 }
802 
803 /*!
804  * \brief Destructor for extension state publisher
805  */
806 static void exten_state_publisher_destroy(void *obj)
807 {
808  struct exten_state_publisher *publisher = obj;
809 
810  if (publisher->context_filter) {
811  regfree(&publisher->context_regex);
812  }
813 
814  if (publisher->exten_filter) {
815  regfree(&publisher->exten_regex);
816  }
817 
818  ao2_cleanup(publisher->client);
819  ao2_cleanup(publisher->datastores);
820 }
821 
822 static int build_regex(regex_t *regex, const char *text)
823 {
824  int res;
825 
826  if ((res = regcomp(regex, text, REG_EXTENDED | REG_ICASE | REG_NOSUB))) {
827  size_t len = regerror(res, regex, NULL, 0);
828  char buf[len];
829  regerror(res, regex, buf, len);
830  ast_log(LOG_ERROR, "Could not compile regex '%s': %s\n", text, buf);
831  return -1;
832  }
833 
834  return 0;
835 }
836 
838 {
839  struct exten_state_publisher *publisher;
840  size_t name_size;
841  size_t body_type_size;
842  size_t body_subtype_size;
843  char *body_subtype;
844  const char *body_full;
845  const char *body_type;
846  const char *name;
847  const char *context;
848  const char *exten;
849 
850  name = ast_sorcery_object_get_id(configuration);
851 
852  body_full = ast_sorcery_object_get_extended(configuration, "body");
853  if (ast_strlen_zero(body_full)) {
854  ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Body not set\n",
855  name);
856  return -1;
857  }
858 
859  body_subtype = ast_strdupa(body_full);
860  body_type = strsep(&body_subtype, "/");
861  if (ast_strlen_zero(body_type) || ast_strlen_zero(body_subtype)) {
862  ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Body '%s' missing type or subtype\n",
863  name, body_full);
864  return -1;
865  }
866 
867  if (!ast_sip_pubsub_is_body_generator_registered(body_type, body_subtype)) {
868  ast_log(LOG_ERROR, "Outbound extension state publisher '%s': '%s' body generator not registered\n",
869  name, body_full);
870  return -1;
871  }
872 
873  name_size = strlen(name) + 1;
874  body_type_size = strlen(body_type) + 1;
875  body_subtype_size = strlen(body_subtype) + 1;
876 
877  publisher = ao2_alloc_options(
878  sizeof(*publisher) + name_size + body_type_size + body_subtype_size,
880  if (!publisher) {
881  return -1;
882  }
883 
884  ast_copy_string(publisher->name, name, name_size);
885  publisher->body_type = publisher->name + name_size;
886  ast_copy_string(publisher->body_type, body_type, body_type_size);
887  publisher->body_subtype = publisher->body_type + body_type_size;
888  ast_copy_string(publisher->body_subtype, body_subtype, body_subtype_size);
889 
890  context = ast_sorcery_object_get_extended(configuration, "context");
891  if (!ast_strlen_zero(context)) {
892  if (build_regex(&publisher->context_regex, context)) {
893  ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Could not build context filter '%s'\n",
894  name, context);
895  ao2_ref(publisher, -1);
896  return -1;
897  }
898 
899  publisher->context_filter = 1;
900  }
901 
902  exten = ast_sorcery_object_get_extended(configuration, "exten");
903  if (!ast_strlen_zero(exten)) {
904  if (build_regex(&publisher->exten_regex, exten)) {
905  ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Could not build exten filter '%s'\n",
906  name, exten);
907  ao2_ref(publisher, -1);
908  return -1;
909  }
910 
911  publisher->exten_filter = 1;
912  }
913 
914  publisher->datastores = ast_datastores_alloc();
915  if (!publisher->datastores) {
916  ast_log(LOG_ERROR, "Outbound extension state publisher '%s': Could not create datastores container\n",
917  name);
918  ao2_ref(publisher, -1);
919  return -1;
920  }
921 
922  publisher->client = ao2_bump(client);
923 
924  ao2_lock(publishers);
925  if (!ao2_container_count(publishers)) {
927  }
928  ao2_link_flags(publishers, publisher, OBJ_NOLOCK);
929  ao2_unlock(publishers);
930 
931  ao2_ref(publisher, -1);
932 
933  return 0;
934 }
935 
937 {
939  return 0;
940 }
941 
942 static int unload_module(void)
943 {
946  ast_sip_unregister_event_publisher_handler(&presence_publisher);
947  ast_sip_unregister_subscription_handler(&presence_handler);
948 
950 
951  ast_taskprocessor_unreference(publish_exten_state_serializer);
952  publish_exten_state_serializer = NULL;
953 
954  ao2_cleanup(publishers);
955  publishers = NULL;
956 
957  return 0;
958 }
959 
960 static int load_module(void)
961 {
964  if (!publishers) {
965  ast_log(LOG_WARNING, "Unable to create container to store extension state publishers\n");
967  }
968 
969  publish_exten_state_serializer = ast_sip_create_serializer("pjsip/exten_state");
970  if (!publish_exten_state_serializer) {
971  unload_module();
973  }
974 
975  if (ast_sip_register_subscription_handler(&presence_handler)) {
976  ast_log(LOG_WARNING, "Unable to register subscription handler %s\n",
977  presence_handler.event_name);
978  unload_module();
980  }
981 
982  if (ast_sip_register_event_publisher_handler(&presence_publisher)) {
983  ast_log(LOG_WARNING, "Unable to register presence publisher %s\n",
984  presence_publisher.event_name);
985  unload_module();
987  }
988 
989  if (ast_sip_register_subscription_handler(&dialog_handler)) {
990  ast_log(LOG_WARNING, "Unable to register subscription handler %s\n",
991  dialog_handler.event_name);
992  unload_module();
994  }
995 
996  if (ast_sip_register_event_publisher_handler(&dialog_publisher)) {
997  ast_log(LOG_WARNING, "Unable to register presence publisher %s\n",
998  dialog_publisher.event_name);
999  unload_module();
1000  return AST_MODULE_LOAD_DECLINE;
1001  }
1002 
1003  return AST_MODULE_LOAD_SUCCESS;
1004 }
1005 
1006 AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER, "PJSIP Extension State Notifications",
1007  .support_level = AST_MODULE_SUPPORT_CORE,
1008  .load = load_module,
1009  .unload = unload_module,
1010  .load_pri = AST_MODPRI_CHANNEL_DEPEND + 5,
1011  .requires = "res_pjsip,res_pjsip_pubsub,res_pjsip_outbound_publish",
1012 );
char exten[AST_MAX_EXTENSION]
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174
static int load_module(void)
enum ast_extension_states last_exten_state
struct ast_sip_subscription_handler dialog_handler
const char * body_text
Definition: res_pjsip.h:2033
int ast_extension_state_add_destroy_extended(const char *context, const char *exten, ast_state_cb_type change_cb, ast_state_cb_destroy_type destroy_cb, void *data)
Add watcher for extended extension states with destructor.
Definition: pbx.c:3831
struct ast_sip_exten_state_data exten_state_data
#define PUBLISHER_BUCKETS
The number of buckets to use for storing publishers.
static void * get_notify_data(struct ast_sip_subscription *sub)
struct ast_sip_event_publisher_handler dialog_publisher
void ast_sip_subscription_get_local_uri(struct ast_sip_subscription *sub, char *buf, size_t size)
Retrieve the local URI for this subscription.
A subscription for extension state.
struct ast_sip_outbound_publish_client * client
ast_extension_states
Extension states.
Definition: pbx.h:61
Asterisk main include file. File version handling, generic pbx functions.
int ao2_container_count(struct ao2_container *c)
Returns the number of elements in a container.
const char * presence_message
Definition: pbx.h:108
struct ast_taskprocessor * ast_sip_subscription_get_serializer(struct ast_sip_subscription *sub)
Get the serializer for the subscription.
static void state_changed_destroy(int id, void *data)
static struct ao2_container * publishers
Container of active outbound extension state publishers.
int ast_sip_subscription_is_terminated(const struct ast_sip_subscription *sub)
Get whether the subscription has been terminated or not.
enum ast_presence_state last_presence_state
struct ast_sip_notifier dialog_notifier
int ast_sip_publish_client_user_send(struct ast_sip_outbound_publish_client *client, const char *user, const struct ast_sip_body *body)
Send an outgoing PUBLISH message based on the user.
The arg parameter is a search key, but is not an object.
Definition: astobj2.h:1105
const char * body_type
Data used to create bodies for NOTIFY/PUBLISH requests.
int ast_extension_state_del(int id, ast_state_cb_type change_cb)
Deletes a state change watcher by ID.
Definition: pbx.c:3858
char buf[BUFSIZE]
Definition: eagi_proxy.c:66
static struct notify_task_data * alloc_notify_task_data(const char *exten, struct exten_state_subscription *exten_state_sub, struct ast_state_cb_info *info)
#define LOG_WARNING
Definition: logger.h:274
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:714
static int notify_task(void *obj)
static void exten_state_data_destructor(void *obj)
enum ast_state_cb_update_reason reason
Definition: pbx.h:103
static pj_pool_t * pool
Global memory pool for configuration and timers.
#define AST_VECTOR_APPEND(vec, elem)
Append an element to a vector, growing the vector if needed.
Definition: vector.h:256
struct ast_sip_endpoint_subscription_configuration subscription
Definition: res_pjsip.h:843
int ast_sip_register_subscription_handler(struct ast_sip_subscription_handler *handler)
Register a subscription handler.
const ast_string_field context
Definition: res_pjsip.h:815
Assume that the ao2_container is already locked.
Definition: astobj2.h:1067
Structure for a data store type.
Definition: datastore.h:31
static void notify_task_data_destructor(void *obj)
enum ast_extension_states exten_state
static int add_datastore(struct exten_state_subscription *exten_state_sub)
static int exten_state_publisher_state_cb(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
Global extension state callback function.
static int exten_state_publisher_hash(const void *obj, const int flags)
Hashing function for extension state publisher.
static struct ast_sip_exten_state_data * exten_state_data_alloc(struct ast_sip_subscription *sip_sub, struct exten_state_subscription *exten_state_sub)
void ast_sip_subscription_get_remote_uri(struct ast_sip_subscription *sub, char *buf, size_t size)
Retrive the remote URI for this subscription.
int ast_str_append(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Append to a thread local dynamic string.
Definition: strings.h:1091
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
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.
struct ast_taskprocessor * serializer
#define ao2_alloc_options(data_size, destructor_fn, options)
Definition: astobj2.h:406
#define ast_assert(a)
Definition: utils.h:695
#define ao2_link_flags(container, obj, flags)
Definition: astobj2.h:1572
#define ao2_unlock(a)
Definition: astobj2.h:730
char * text
Definition: app_queue.c:1508
#define ast_strdup(str)
A wrapper for strdup()
Definition: astmm.h:243
Structure for a data store object.
Definition: datastore.h:68
void ast_copy_pj_str(char *dest, const pj_str_t *src, size_t size)
Copy a pj_str_t into a standard character buffer.
Definition: res_pjsip.c:5240
static int exten_state_publisher_cmp(void *obj, void *arg, int flags)
Comparator function for extension state publisher.
#define NULL
Definition: resample.c:96
struct ast_sip_subscription * sub
int ast_hint_presence_state(struct ast_channel *c, const char *context, const char *exten, char **subtype, char **message)
Uses hint and presence state callback to get the presence state of an extension.
Definition: pbx.c:3226
char context[AST_MAX_CONTEXT]
#define ast_verb(level,...)
Definition: logger.h:463
struct ast_sip_notifier presence_notifier
static int build_regex(regex_t *regex, const char *text)
struct ao2_container * ast_sip_subscription_get_datastores(const struct ast_sip_subscription *subscription)
Get the datastores container for a subscription.
#define ast_strlen_zero(foo)
Definition: strings.h:52
static int unload_module(void)
struct ao2_container * ast_datastores_alloc(void)
Allocate a specialized data stores container.
Definition: datastore.c:95
#define ao2_bump(obj)
Definition: astobj2.h:491
#define DEFAULT_DIALOG_BODY
#define AST_SIP_EXTEN_STATE_DATA
static void exten_state_pub_data_destroy(struct exten_state_pub_data *doomed)
An extension state publisher.
enum ast_extension_states exten_state
Definition: pbx.h:104
const char * ast_sorcery_object_get_extended(const void *object, const char *name)
Get an extended field value from a sorcery object.
Definition: sorcery.c:2330
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_log
Definition: astobj2.c:42
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
Definition: astobj2.h:1120
#define AST_VECTOR_INIT(vec, size)
Initialize a vector.
Definition: vector.h:113
void ast_sip_unregister_event_publisher_handler(struct ast_sip_event_publisher_handler *handler)
Unregister a publish handler.
static int state_changed(const char *context, const char *exten, struct ast_state_cb_info *info, void *data)
Outbound publish client state information (persists for lifetime of a publish)
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.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
enum ast_presence_state presence_state
Definition: pbx.h:106
enum ast_presence_state presence_state
const char * type
Definition: res_pjsip.h:2029
ast_presence_state
Definition: presencestate.h:26
const char * ast_sip_publish_client_get_user_to_uri(struct ast_sip_outbound_publish_client *client, const char *user, char *uri, size_t size)
Get the To URI the client will use for a specific user.
static int publisher_start(struct ast_sip_outbound_publish *configuration, struct ast_sip_outbound_publish_client *client)
Callbacks that event publisher handlers will define.
#define AST_MAX_EXTENSION
Definition: channel.h:135
const char * event_name
The name of the event this handler deals with.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
const char * ast_extension_state2str(int extension_state)
Return string representation of the state of an extension.
Definition: pbx.c:3126
const char * presence_subtype
Definition: pbx.h:107
#define ao2_lock(a)
Definition: astobj2.h:718
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
static struct exten_state_pub_data * exten_state_pub_data_alloc(const char *exten, struct ast_state_cb_info *info)
const char * ast_sorcery_object_get_id(const void *object)
Get the unique identifier of a sorcery object.
Definition: sorcery.c:2312
#define ast_malloc(len)
A wrapper for malloc()
Definition: astmm.h:193
#define AST_VECTOR(name, type)
Define a vector structure.
Definition: vector.h:44
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.
#define PRIORITY_HINT
Definition: pbx.h:54
int ast_exists_extension(struct ast_channel *c, const char *context, const char *exten, int priority, const char *callerid)
Determine whether an extension exists.
Definition: pbx.c:4179
static struct exten_state_subscription * exten_state_subscription_alloc(struct ast_sip_subscription *sip_sub, struct ast_sip_endpoint *endpoint)
struct ast_sip_subscription_handler presence_handler
static force_inline char * ast_str_to_lower(char *str)
Convert a string to all lower-case.
Definition: strings.h:1268
int ast_extension_state_extended(struct ast_channel *c, const char *context, const char *exten, struct ao2_container **device_state_info)
Uses hint and devicestate callback to get the extended state of an extension.
Definition: pbx.c:3176
void ast_sip_subscription_destroy(struct ast_sip_subscription *sub)
Alert the pubsub core that the subscription is ready for destruction.
struct ao2_container * device_state_info
Definition: pbx.h:105
Structure representing a "virtual" SIP subscription.
struct ao2_container * device_state_info
struct ast_sip_event_publisher_handler presence_publisher
#define LOG_ERROR
Definition: logger.h:285
#define ao2_container_alloc_hash(ao2_options, container_options, n_buckets, hash_fn, sort_fn, cmp_fn)
Definition: astobj2.h:1310
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Definition: strings.h:584
int ast_sip_push_task(struct ast_taskprocessor *serializer, int(*sip_task)(void *), void *task_data)
Pushes a task to SIP servants.
Definition: res_pjsip.c:5138
def info(msg)
static int len(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t buflen)
struct ast_datastore * ast_sip_subscription_alloc_datastore(const struct ast_datastore_info *info, const char *uid)
Alternative for ast_datastore_alloc()
const char * subtype
Definition: res_pjsip.h:2031
static int publisher_stop(struct ast_sip_outbound_publish_client *client)
struct ast_taskprocessor * ast_sip_create_serializer(const char *name)
Create a new serializer for SIP tasks.
Definition: res_pjsip.c:5133
static struct ast_taskprocessor * publish_exten_state_serializer
userdata associated with baseline taskprocessor test
Outbound publish information.
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:411
#define LOG_NOTICE
Definition: logger.h:263
#define DEFAULT_PRESENCE_BODY
static const char ds_name[]
#define AST_MAX_CONTEXT
Definition: channel.h:136
static const char name[]
Definition: cdr_mysql.c:74
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
static int regex(struct ast_channel *chan, const char *cmd, char *parse, char *buf, size_t len)
Definition: func_strings.c:948
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.
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
An API for managing task processing threads that can be shared across modules.
struct ast_datastore * ast_sip_subscription_get_datastore(struct ast_sip_subscription *subscription, const char *name)
Retrieve a subscription datastore.
static void exten_state_publisher_destroy(void *obj)
Destructor for extension state publisher.
static void subscription_shutdown(struct ast_sip_subscription *sub)
static char * get_user_agent(const struct ast_sip_subscription *sip_sub)
Support for logging to various files, console and syslog Configuration in file logger.conf.
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
pjsip_endpoint * ast_sip_get_pjsip_endpoint(void)
Get a pointer to the PJSIP endpoint.
Definition: res_pjsip.c:3718
struct ast_sip_endpoint * ast_sip_subscription_get_endpoint(struct ast_sip_subscription *sub)
Get the endpoint that is associated with this subscription.
structure used for presence XML bodies
The arg parameter is an object of the same type.
Definition: astobj2.h:1091
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
static struct exten_state_subscription * get_exten_state_sub(struct ast_sip_subscription *sub)
char * strsep(char **str, const char *delims)
A ast_taskprocessor structure is a singleton by name.
Definition: taskprocessor.c:69
#define INITIAL_LAST_EXTEN_STATE
static void exten_state_subscription_destructor(void *obj)
int ast_sip_subscription_add_datastore(struct ast_sip_subscription *subscription, struct ast_datastore *datastore)
Add a datastore to a SIP subscription.
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
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.
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
void * ast_taskprocessor_unreference(struct ast_taskprocessor *tps)
Unreference the specified taskprocessor and its reference count will decrement.
struct stasis_forward * sub
Definition: res_corosync.c:240
int ast_sip_register_event_publisher_handler(struct ast_sip_event_publisher_handler *handler)
Register an event publisher handler.
Generic container type.
Search option field mask.
Definition: astobj2.h:1076
int ast_extension_state_add(const char *context, const char *exten, ast_state_cb_type change_cb, void *data)
Add watcher for extension states.
Definition: pbx.c:3825
struct ao2_container * datastores
#define ASTERISK_GPL_KEY
The text the key() function should return.
Definition: module.h:46
const char * default_accept
Default body type defined for the event package this notifier handles.
Asterisk module definitions.
Application convenience functions, designed to give consistent look and feel to Asterisk apps...
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
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.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611
static struct ast_datastore_info ds_info
struct ast_sip_subscription * sip_sub
const char * ast_presence_state2str(enum ast_presence_state state)
Convert presence state to text string for output.
#define AST_VECTOR_CALLBACK_VOID(vec, callback,...)
Execute a callback on every element in a vector disregarding callback return.
Definition: vector.h:865
#define ast_str_create(init_len)
Create a malloc&#39;ed dynamic length string.
Definition: strings.h:620
Sorcery Data Access Layer API.
static force_inline int attribute_pure ast_str_hash(const char *str)
Compute a hash value on a string.
Definition: strings.h:1206
static int new_subscribe(struct ast_sip_endpoint *endpoint, const char *resource)
static int exten_state_publisher_cb(void *data)
struct exten_state_subscription * exten_state_sub
const char * ast_sip_publish_client_get_user_from_uri(struct ast_sip_outbound_publish_client *client, const char *user, char *uri, size_t size)
Get the From URI the client will use for a specific user.