/*! * \brief Determines if an endpoint is receiving unsolicited MWI for a particular mailbox. * * \param endpoint The endpoint to check * \param mailbox The candidate mailbox * \retval 0 The endpoint does not receive unsolicited MWI for this mailbox * \retval 1 The endpoint receives unsolicited MWI for this mailbox */ static int endpoint_receives_unsolicited_mwi_for_mailbox(struct ast_sip_endpoint *endpoint, const char *mailbox) { struct ao2_container *unsolicited = ao2_global_obj_ref(unsolicited_mwi); struct ao2_iterator *mwi_subs; struct mwi_subscription *mwi_sub; const char *endpoint_id = ast_sorcery_object_get_id(endpoint); int ret = 0; if (!unsolicited) { return 0; } mwi_subs = ao2_find(unsolicited, endpoint_id, OBJ_SEARCH_KEY | OBJ_MULTIPLE); ao2_cleanup(unsolicited); if (!mwi_subs) { return 0; } for (; (mwi_sub = ao2_iterator_next(mwi_subs)) && !ret; ao2_cleanup(mwi_sub)) { struct mwi_stasis_subscription *mwi_stasis; mwi_stasis = ao2_find(mwi_sub->stasis_subs, mailbox, OBJ_SEARCH_KEY); if (mwi_stasis) { ret = 1; ao2_cleanup(mwi_stasis); } } ao2_iterator_destroy(mwi_subs); return ret; }
struct ast_ari_conf *ast_ari_config_get(void) { struct ast_ari_conf *res = ao2_global_obj_ref(confs); if (!res) { ast_log(LOG_ERROR, "Error obtaining config from " CONF_FILENAME "\n"); } return res; }
/*! \brief Task invoked to send initial MWI NOTIFY for unsolicited */ static int send_initial_notify_all(void *obj) { struct ao2_container *mwi_subscriptions = ao2_global_obj_ref(unsolicited_mwi); if (!mwi_subscriptions) { return 0; } ao2_callback(mwi_subscriptions, OBJ_NODATA, send_notify, NULL); ao2_ref(mwi_subscriptions, -1); return 0; }
/*! \brief Function called when a contact is created or updated */ static void mwi_contact_changed_observer(const void *object) { char *id = ast_strdupa(ast_sorcery_object_get_id(object)), *aor = NULL; struct ao2_container *mwi_subscriptions = ao2_global_obj_ref(unsolicited_mwi); if (!mwi_subscriptions) { return; } aor = strsep(&id, ";@"); ao2_callback(mwi_subscriptions, OBJ_NODATA, send_contact_notify, aor); ao2_ref(mwi_subscriptions, -1); }
/*! * \internal * \brief CLI command to send a SIP notify to an endpoint. * * \details Attempts to match the "type" given in the CLI command to a * configured one. If found, sends a NOTIFY to the endpoint * with the associated payload. */ static char *cli_notify(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) { RAII_VAR(struct notify_cfg *, cfg, NULL, ao2_cleanup); RAII_VAR(struct notify_option *, option, NULL, ao2_cleanup); int i; int using_uri = 0; switch (cmd) { case CLI_INIT: e->command = "pjsip send notify"; e->usage = "Usage: pjsip send notify <type> {endpoint|uri} <peer> [<peer>...]\n" " Send a NOTIFY request to an endpoint\n" " Message types are defined in pjsip_notify.conf\n"; return NULL; case CLI_GENERATE: if (a->argc > 4 && (!strcasecmp(a->argv[4], "uri"))) { using_uri = 1; } return cli_complete_notify(a->line, a->word, a->pos, a->n, using_uri); } if (a->argc < 6) { return CLI_SHOWUSAGE; } if (!strcasecmp(a->argv[4], "uri")) { using_uri = 1; } else if (strcasecmp(a->argv[4], "endpoint")) { return CLI_SHOWUSAGE; } cfg = ao2_global_obj_ref(globals); if (!(option = notify_option_find(cfg->notify_options, a->argv[3]))) { ast_cli(a->fd, "Unable to find notify type '%s'\n", a->argv[3]); return CLI_FAILURE; } for (i = 5; i < a->argc; ++i) { ast_cli(a->fd, "Sending NOTIFY of type '%s' to '%s'\n", a->argv[3], a->argv[i]); switch (using_uri ? push_notify_uri(a->argv[i], option, notify_cli_uri_data_create) : push_notify(a->argv[i], option, notify_cli_data_create)) { case INVALID_ENDPOINT: ast_cli(a->fd, "Unable to retrieve endpoint %s\n", a->argv[i]); break; case ALLOC_ERROR: ast_cli(a->fd, "Unable to allocate NOTIFY task data\n"); return CLI_FAILURE; case TASK_PUSH_ERROR: ast_cli(a->fd, "Unable to push NOTIFY task\n"); return CLI_FAILURE; default: break; } } return CLI_SUCCESS; }
struct ast_sip_auth *ast_sip_get_artificial_auth(void) { return ao2_global_obj_ref(artificial_auth); }