Asterisk - The Open Source Telephony Project
21.4.1
|
Asterisk endpoint API. More...
#include "asterisk.h"
#include "asterisk/astobj2.h"
#include "asterisk/endpoints.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/stasis_endpoints.h"
#include "asterisk/stasis_message_router.h"
#include "asterisk/stringfields.h"
#include "asterisk/_private.h"
Go to the source code of this file.
Data Structures | |
struct | ast_endpoint |
Macros | |
#define | ENDPOINT_BUCKETS 127 |
#define | ENDPOINT_CHANNEL_BUCKETS 127 |
#define | TECH_ENDPOINT_BUCKETS 11 |
Functions | |
int | ast_endpoint_add_channel (struct ast_endpoint *endpoint, struct ast_channel *chan) |
Adds a channel to the given endpoint. More... | |
struct ast_endpoint * | ast_endpoint_create (const char *tech, const char *resource) |
Create an endpoint struct. More... | |
struct ast_endpoint * | ast_endpoint_find_by_id (const char *id) |
Finds the endpoint with the given tech[/resource] id. More... | |
const char * | ast_endpoint_get_id (const struct ast_endpoint *endpoint) |
Gets the tech/resource id of the given endpoint. More... | |
const char * | ast_endpoint_get_resource (const struct ast_endpoint *endpoint) |
Gets the resource name of the given endpoint. More... | |
enum ast_endpoint_state | ast_endpoint_get_state (const struct ast_endpoint *endpoint) |
Gets the state of the given endpoint. More... | |
const char * | ast_endpoint_get_tech (const struct ast_endpoint *endpoint) |
Gets the technology of the given endpoint. More... | |
int | ast_endpoint_init (void) |
Endpoint support initialization. More... | |
void | ast_endpoint_set_max_channels (struct ast_endpoint *endpoint, int max_channels) |
Updates the maximum number of channels an endpoint supports. More... | |
void | ast_endpoint_set_state (struct ast_endpoint *endpoint, enum ast_endpoint_state state) |
Updates the state of the given endpoint. More... | |
void | ast_endpoint_shutdown (struct ast_endpoint *endpoint) |
Shutsdown an ast_endpoint. More... | |
struct ast_endpoint_snapshot * | ast_endpoint_snapshot_create (struct ast_endpoint *endpoint) |
Create a snapshot of an endpoint. More... | |
const char * | ast_endpoint_state_to_string (enum ast_endpoint_state state) |
Returns a string representation of the given endpoint state. More... | |
struct stasis_topic * | ast_endpoint_topic (struct ast_endpoint *endpoint) |
Returns the topic for a specific endpoint. More... | |
struct stasis_topic * | ast_endpoint_topic_cached (struct ast_endpoint *endpoint) |
Returns the topic for a specific endpoint. More... | |
static struct stasis_message * | create_endpoint_snapshot_message (struct ast_endpoint *endpoint) |
static void | endpoint_cache_clear (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
Handler for channel snapshot update. | |
static void | endpoint_cleanup (void) |
static void | endpoint_dtor (void *obj) |
static struct ast_endpoint * | endpoint_internal_create (const char *tech, const char *resource) |
static void | endpoint_publish_snapshot (struct ast_endpoint *endpoint) |
static void | endpoint_snapshot_dtor (void *obj) |
static void | endpoint_subscription_change (void *data, struct stasis_subscription *sub, struct stasis_message *message) |
Variables | |
static struct ao2_container * | endpoints |
static struct ao2_container * | tech_endpoints |
Asterisk endpoint API.
Definition in file main/endpoints.c.
#define ENDPOINT_BUCKETS 127 |
Buckets for endpoint hash. Keep it prime!
Definition at line 45 of file main/endpoints.c.
Referenced by ast_endpoint_init().
#define ENDPOINT_CHANNEL_BUCKETS 127 |
Buckets for endpoint->channel mappings. Keep it prime!
Definition at line 42 of file main/endpoints.c.
#define TECH_ENDPOINT_BUCKETS 11 |
Buckets for technology endpoints.
Definition at line 48 of file main/endpoints.c.
Referenced by ast_endpoint_init().
int ast_endpoint_add_channel | ( | struct ast_endpoint * | endpoint, |
struct ast_channel * | chan | ||
) |
Adds a channel to the given endpoint.
The channel is automagically removed from the endpoint when it is disposed of.
endpoint | |
chan | Channel. |
0 | on success. |
Non-zero | on error. |
Definition at line 164 of file main/endpoints.c.
References ast_channel_forward_endpoint(), ast_str_container_add(), ast_endpoint::channel_ids, and ast_endpoint::resource.
Referenced by __ast_channel_alloc_ap().
struct ast_endpoint* ast_endpoint_create | ( | const char * | tech, |
const char * | resource | ||
) |
Create an endpoint struct.
The endpoint is created with a state of UNKNOWN and max_channels of -1 (unlimited). While ast_endpoint is AO2 managed, you have to shut it down with ast_endpoint_shutdown() to clean up references from subscriptions.
tech | Technology for this endpoint. |
resource | Name of this endpoint. |
NULL | on error. |
Definition at line 319 of file main/endpoints.c.
Referenced by build_peer(), and xmpp_client_alloc().
struct ast_endpoint* ast_endpoint_find_by_id | ( | const char * | id | ) |
Finds the endpoint with the given tech[/resource] id.
Endpoints are refcounted, so ao2_cleanup() when you're done.
id | Tech[/resource] id to look for. |
NULL | if not found. |
Definition at line 82 of file main/endpoints.c.
References OBJ_KEY.
Referenced by ast_ari_endpoints_list_by_tech(), and messaging_app_unsubscribe_endpoint().
const char* ast_endpoint_get_id | ( | const struct ast_endpoint * | endpoint | ) |
Gets the tech/resource id of the given endpoint.
This is unique across all endpoints, and immutable.
endpoint | The endpoint. |
NULL | if endpoint is NULL . |
Definition at line 391 of file main/endpoints.c.
References ast_endpoint::id.
Referenced by app_subscribe_endpoint(), forwards_create_endpoint(), messaging_app_subscribe_endpoint(), and messaging_app_unsubscribe_endpoint().
const char* ast_endpoint_get_resource | ( | const struct ast_endpoint * | endpoint | ) |
Gets the resource name of the given endpoint.
This is unique for the endpoint's technology, and immutable.
endpoint | The endpoint. |
NULL | if endpoint is NULL . |
Definition at line 383 of file main/endpoints.c.
References ast_endpoint::resource.
Referenced by chan_pjsip_devicestate(), and messaging_app_unsubscribe_endpoint().
enum ast_endpoint_state ast_endpoint_get_state | ( | const struct ast_endpoint * | endpoint | ) |
Gets the state of the given endpoint.
endpoint | The endpoint. |
AST_ENDPOINT_UNKNOWN | if endpoint is NULL . |
Definition at line 399 of file main/endpoints.c.
References AST_ENDPOINT_UNKNOWN, and ast_endpoint::state.
const char* ast_endpoint_get_tech | ( | const struct ast_endpoint * | endpoint | ) |
Gets the technology of the given endpoint.
This is an immutable string describing the channel provider technology (SIP, IAX2, etc.).
endpoint | The endpoint. |
NULL | if endpoint is NULL . |
Definition at line 375 of file main/endpoints.c.
References ast_endpoint::tech.
Referenced by chan_pjsip_devicestate().
int ast_endpoint_init | ( | void | ) |
Endpoint support initialization.
Definition at line 496 of file main/endpoints.c.
References AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_hash, ast_register_cleanup(), ENDPOINT_BUCKETS, and TECH_ENDPOINT_BUCKETS.
void ast_endpoint_set_max_channels | ( | struct ast_endpoint * | endpoint, |
int | max_channels | ||
) |
Updates the maximum number of channels an endpoint supports.
Set to -1 for unlimited channels.
endpoint | Endpoint to modify. |
max_channels | Maximum number of concurrent channels this endpoint supports. |
Definition at line 419 of file main/endpoints.c.
References ast_endpoint::max_channels, and ast_endpoint::resource.
void ast_endpoint_set_state | ( | struct ast_endpoint * | endpoint, |
enum ast_endpoint_state | state | ||
) |
Updates the state of the given endpoint.
endpoint | Endpoint to modify. |
state | New state. |
Definition at line 407 of file main/endpoints.c.
References ast_endpoint::resource, and ast_endpoint::state.
Referenced by update_registry(), and xmpp_client_change_state().
void ast_endpoint_shutdown | ( | struct ast_endpoint * | endpoint | ) |
Shutsdown an ast_endpoint.
endpoint | Endpoint to shut down. |
Definition at line 350 of file main/endpoints.c.
References ao2_ref, ao2_unlink, ast_endpoint_topic(), RAII_VAR, ast_endpoint::router, stasis_cache_clear_create(), stasis_message_router_unsubscribe(), stasis_publish(), and ast_endpoint::tech_forward.
Referenced by xmpp_client_destructor().
const char* ast_endpoint_state_to_string | ( | enum ast_endpoint_state | state | ) |
Returns a string representation of the given endpoint state.
state | Endpoint state. |
? | if state isn't in ast_endpoint_state. |
Definition at line 109 of file main/endpoints.c.
References AST_ENDPOINT_OFFLINE, AST_ENDPOINT_ONLINE, and AST_ENDPOINT_UNKNOWN.
Referenced by ast_endpoint_snapshot_to_json().