endpoints.c File Reference

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"

Include dependency graph for endpoints.c:

Go to the source code of this file.

Data Structures

struct  ast_endpoint

Defines

#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.
struct ast_endpointast_endpoint_create (const char *tech, const char *resource)
 Create an endpoint struct.
struct ast_endpointast_endpoint_find_by_id (const char *id)
 Finds the endpoint with the given tech[/resource] id.
const char * ast_endpoint_get_id (const struct ast_endpoint *endpoint)
 Gets the tech/resource id of the given endpoint.
const char * ast_endpoint_get_resource (const struct ast_endpoint *endpoint)
 Gets the resource name of the given endpoint.
const char * ast_endpoint_get_tech (const struct ast_endpoint *endpoint)
 Gets the technology of the given endpoint.
int ast_endpoint_init (void)
 Endpoint support initialization.
void ast_endpoint_set_max_channels (struct ast_endpoint *endpoint, int max_channels)
 Updates the maximum number of channels an endpoint supports.
void ast_endpoint_set_state (struct ast_endpoint *endpoint, enum ast_endpoint_state state)
 Updates the state of the given endpoint.
void ast_endpoint_shutdown (struct ast_endpoint *endpoint)
 Shutsdown an ast_endpoint.
struct ast_endpoint_snapshotast_endpoint_snapshot_create (struct ast_endpoint *endpoint)
 Create a snapshot of an endpoint.
const char * ast_endpoint_state_to_string (enum ast_endpoint_state state)
 Returns a string representation of the given endpoint state.
struct stasis_topicast_endpoint_topic (struct ast_endpoint *endpoint)
 Returns the topic for a specific endpoint.
struct stasis_topicast_endpoint_topic_cached (struct ast_endpoint *endpoint)
 Returns the topic for a specific endpoint.
static struct stasis_messagecreate_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 cache clears.
static void endpoint_cleanup (void)
static int endpoint_cmp (void *obj, void *arg, int flags)
static void endpoint_default (void *data, struct stasis_subscription *sub, struct stasis_message *message)
static void endpoint_dtor (void *obj)
static int endpoint_hash (const void *obj, int flags)
static struct ast_endpointendpoint_internal_create (const char *tech, const char *resource)
static void endpoint_publish_snapshot (struct ast_endpoint *endpoint)
static void endpoint_snapshot_dtor (void *obj)

Variables

static struct ao2_containerendpoints
static struct ao2_containertech_endpoints


Detailed Description

Asterisk endpoint API.

Author:
David M. Lee, II <dlee@digium.com>

Definition in file endpoints.c.


Define Documentation

#define ENDPOINT_BUCKETS   127

Buckets for endpoint hash. Keep it prime!

Definition at line 47 of file endpoints.c.

#define ENDPOINT_CHANNEL_BUCKETS   127

Buckets for endpoint->channel mappings. Keep it prime!

Definition at line 44 of file endpoints.c.

Referenced by endpoint_internal_create().

#define TECH_ENDPOINT_BUCKETS   11

Buckets for technology endpoints.

Definition at line 50 of file endpoints.c.

Referenced by ast_endpoint_init().


Function Documentation

int ast_endpoint_add_channel ( struct ast_endpoint endpoint,
struct ast_channel chan 
)

Adds a channel to the given endpoint.

Since:
12 This updates the endpoint's statistics, as well as forwarding all of the channel's messages to the endpoint's topic.
The channel is automagically removed from the endpoint when it is disposed of.

Parameters:
endpoint 
chan Channel.
Return values:
0 on success.
Non-zero on error.

Definition at line 211 of file endpoints.c.

References ao2_lock, ao2_unlock, ast_assert, ast_channel_forward_endpoint(), ast_channel_uniqueid(), ast_str_container_add(), ast_strlen_zero, ast_endpoint::channel_ids, endpoint_publish_snapshot(), NULL, and ast_endpoint::resource.

Referenced by __ast_channel_alloc_ap(), and AST_TEST_DEFINE().

00213 {
00214    ast_assert(chan != NULL);
00215    ast_assert(endpoint != NULL);
00216    ast_assert(!ast_strlen_zero(endpoint->resource));
00217 
00218    ast_channel_forward_endpoint(chan, endpoint);
00219 
00220    ao2_lock(endpoint);
00221    ast_str_container_add(endpoint->channel_ids, ast_channel_uniqueid(chan));
00222    ao2_unlock(endpoint);
00223 
00224    endpoint_publish_snapshot(endpoint);
00225 
00226    return 0;
00227 }

struct ast_endpoint* ast_endpoint_create ( const char *  tech,
const char *  resource 
) [read]

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.

Parameters:
tech Technology for this endpoint.
resource Name of this endpoint.
Returns:
Newly created endpoint.

NULL on error.

Since:
12

Definition at line 338 of file endpoints.c.

References ast_log, ast_strlen_zero, endpoint_internal_create(), LOG_ERROR, and NULL.

Referenced by AST_TEST_DEFINE(), build_peer(), persistent_endpoint_find_or_create(), skinny_device_alloc(), and xmpp_client_alloc().

00339 {
00340    if (ast_strlen_zero(tech)) {
00341       ast_log(LOG_ERROR, "Endpoint tech cannot be empty\n");
00342       return NULL;
00343    }
00344 
00345    if (ast_strlen_zero(resource)) {
00346       ast_log(LOG_ERROR, "Endpoint resource cannot be empty\n");
00347       return NULL;
00348    }
00349 
00350    return endpoint_internal_create(tech, resource);
00351 }

struct ast_endpoint* ast_endpoint_find_by_id ( const char *  id  )  [read]

Finds the endpoint with the given tech[/resource] id.

Endpoints are refcounted, so ao2_cleanup() when you're done.

Note:
The resource portion of an ID is optional. If not provided, an aggregate endpoint for the entire technology is returned. These endpoints must not be modified, but can be subscribed to in order to receive updates for all endpoints of a given technology.
Parameters:
id Tech[/resource] id to look for.
Returns:
Associated endpoint.

NULL if not found.

Since:
12

Definition at line 129 of file endpoints.c.

References ao2_find, and OBJ_KEY.

Referenced by ast_ari_endpoints_list_by_tech(), endpoint_find(), and messaging_app_unsubscribe_endpoint().

00130 {
00131    struct ast_endpoint *endpoint = ao2_find(endpoints, id, OBJ_KEY);
00132 
00133    if (!endpoint) {
00134       endpoint = ao2_find(tech_endpoints, id, OBJ_KEY);
00135    }
00136 
00137    return endpoint;
00138 }

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.

Parameters:
endpoint The endpoint.
Returns:
Tech/resource id of the endpoint.

NULL if endpoint is NULL.

Since:
12

Definition at line 410 of file endpoints.c.

References ast_endpoint::id, and NULL.

Referenced by app_subscribe_endpoint(), forwards_create_endpoint(), get_or_create_subscription(), messaging_app_subscribe_endpoint(), and messaging_app_unsubscribe_endpoint().

00411 {
00412    if (!endpoint) {
00413       return NULL;
00414    }
00415    return endpoint->id;
00416 }

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.

Note:
If the endpoint being queried is a technology aggregate endpoint, this will be an empty string.
Parameters:
endpoint The endpoint.
Returns:
Resource name of the endpoint.

NULL if endpoint is NULL.

Since:
12

Definition at line 402 of file endpoints.c.

References NULL, and ast_endpoint::resource.

Referenced by ast_sip_get_endpoint_snapshot(), AST_TEST_DEFINE(), chan_pjsip_devicestate(), get_or_create_subscription(), get_subscription(), messaging_app_unsubscribe_endpoint(), persistent_endpoint_cmp(), persistent_endpoint_hash(), and persistent_endpoint_update_state().

00403 {
00404    if (!endpoint) {
00405       return NULL;
00406    }
00407    return endpoint->resource;
00408 }

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.).

Parameters:
endpoint The endpoint.
Returns:
Tec of the endpoint.

NULL if endpoint is NULL.

Since:
12

Definition at line 394 of file endpoints.c.

References NULL, and ast_endpoint::tech.

Referenced by ast_sip_get_endpoint_snapshot(), AST_TEST_DEFINE(), chan_pjsip_devicestate(), and get_subscription().

00395 {
00396    if (!endpoint) {
00397       return NULL;
00398    }
00399    return endpoint->tech;
00400 }

int ast_endpoint_init ( void   ) 

Endpoint support initialization.

Returns:
0 on success.

Non-zero on error.

Definition at line 508 of file endpoints.c.

References ao2_container_alloc, ast_register_cleanup(), ENDPOINT_BUCKETS, endpoint_cleanup(), endpoint_cmp(), endpoint_hash(), and TECH_ENDPOINT_BUCKETS.

Referenced by main().

00509 {
00510    ast_register_cleanup(endpoint_cleanup);
00511 
00512    endpoints = ao2_container_alloc(ENDPOINT_BUCKETS, endpoint_hash,
00513       endpoint_cmp);
00514    if (!endpoints) {
00515       return -1;
00516    }
00517 
00518    tech_endpoints = ao2_container_alloc(TECH_ENDPOINT_BUCKETS, endpoint_hash,
00519       endpoint_cmp);
00520    if (!tech_endpoints) {
00521       return -1;
00522    }
00523 
00524    return 0;
00525 }

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.

Parameters:
endpoint Endpoint to modify.
max_channels Maximum number of concurrent channels this endpoint supports.

Definition at line 430 of file endpoints.c.

References ao2_lock, ao2_unlock, ast_assert, ast_strlen_zero, endpoint_publish_snapshot(), ast_endpoint::max_channels, NULL, and ast_endpoint::resource.

Referenced by AST_TEST_DEFINE().

00432 {
00433    ast_assert(endpoint != NULL);
00434    ast_assert(!ast_strlen_zero(endpoint->resource));
00435 
00436    ao2_lock(endpoint);
00437    endpoint->max_channels = max_channels;
00438    ao2_unlock(endpoint);
00439    endpoint_publish_snapshot(endpoint);
00440 }

void ast_endpoint_set_state ( struct ast_endpoint endpoint,
enum ast_endpoint_state  state 
)

void ast_endpoint_shutdown ( struct ast_endpoint endpoint  ) 

Shutsdown an ast_endpoint.

Parameters:
endpoint Endpoint to shut down.
Since:
12

Definition at line 369 of file endpoints.c.

References ao2_cleanup, ao2_ref, ao2_unlink, ast_endpoint_topic(), create_endpoint_snapshot_message(), NULL, RAII_VAR, ast_endpoint::router, stasis_cache_clear_create(), stasis_forward_cancel(), stasis_message_router_unsubscribe(), stasis_publish(), and ast_endpoint::tech_forward.

Referenced by AST_TEST_DEFINE(), peer_destructor(), persistent_endpoint_destroy(), sip_destroy_peer(), skinny_device_destroy(), and xmpp_client_destructor().

00370 {
00371    RAII_VAR(struct stasis_message *, clear_msg, NULL, ao2_cleanup);
00372 
00373    if (endpoint == NULL) {
00374       return;
00375    }
00376 
00377    ao2_unlink(endpoints, endpoint);
00378    endpoint->tech_forward = stasis_forward_cancel(endpoint->tech_forward);
00379 
00380    clear_msg = create_endpoint_snapshot_message(endpoint);
00381    if (clear_msg) {
00382       RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
00383       message = stasis_cache_clear_create(clear_msg);
00384       if (message) {
00385          stasis_publish(ast_endpoint_topic(endpoint), message);
00386       }
00387    }
00388 
00389    /* Bump refcount to hold on to the router */
00390    ao2_ref(endpoint->router, +1);
00391    stasis_message_router_unsubscribe(endpoint->router);
00392 }

const char* ast_endpoint_state_to_string ( enum ast_endpoint_state  state  ) 

Returns a string representation of the given endpoint state.

Parameters:
state Endpoint state.
Returns:
String representation of state.

"?" if state isn't in ast_endpoint_state.

Definition at line 156 of file endpoints.c.

References AST_ENDPOINT_OFFLINE, AST_ENDPOINT_ONLINE, and AST_ENDPOINT_UNKNOWN.

Referenced by ast_endpoint_snapshot_to_json().

00157 {
00158    switch (state) {
00159    case AST_ENDPOINT_UNKNOWN:
00160       return "unknown";
00161    case AST_ENDPOINT_OFFLINE:
00162       return "offline";
00163    case AST_ENDPOINT_ONLINE:
00164       return "online";
00165    }
00166    return "?";
00167 }

static struct stasis_message* create_endpoint_snapshot_message ( struct ast_endpoint endpoint  )  [static, read]

Definition at line 353 of file endpoints.c.

References ao2_cleanup, ast_endpoint_snapshot_create(), ast_endpoint_snapshot_type(), NULL, RAII_VAR, and stasis_message_create().

Referenced by ast_endpoint_shutdown().

00354 {
00355    RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);
00356 
00357    if (!ast_endpoint_snapshot_type()) {
00358       return NULL;
00359    }
00360 
00361    snapshot = ast_endpoint_snapshot_create(endpoint);
00362    if (!snapshot) {
00363       return NULL;
00364    }
00365 
00366    return stasis_message_create(ast_endpoint_snapshot_type(), snapshot);
00367 }

static void endpoint_cache_clear ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Handler for channel snapshot cache clears.

Definition at line 230 of file endpoints.c.

References ao2_lock, ao2_unlock, ast_assert, ast_channel_snapshot_type(), ast_str_container_remove(), ast_endpoint::channel_ids, endpoint_publish_snapshot(), NULL, stasis_message_data(), stasis_message_type(), and ast_channel_snapshot::uniqueid.

Referenced by endpoint_internal_create().

00233 {
00234    struct ast_endpoint *endpoint = data;
00235    struct stasis_message *clear_msg = stasis_message_data(message);
00236    struct ast_channel_snapshot *clear_snapshot;
00237 
00238    if (stasis_message_type(clear_msg) != ast_channel_snapshot_type()) {
00239       return;
00240    }
00241 
00242    clear_snapshot = stasis_message_data(clear_msg);
00243 
00244    ast_assert(endpoint != NULL);
00245 
00246    ao2_lock(endpoint);
00247    ast_str_container_remove(endpoint->channel_ids, clear_snapshot->uniqueid);
00248    ao2_unlock(endpoint);
00249    endpoint_publish_snapshot(endpoint);
00250 }

static void endpoint_cleanup ( void   )  [static]

Definition at line 499 of file endpoints.c.

References ao2_cleanup, and NULL.

Referenced by ast_endpoint_init().

00500 {
00501    ao2_cleanup(endpoints);
00502    endpoints = NULL;
00503 
00504    ao2_cleanup(tech_endpoints);
00505    tech_endpoints = NULL;
00506 }

static int endpoint_cmp ( void *  obj,
void *  arg,
int  flags 
) [static]

Definition at line 100 of file endpoints.c.

References ast_assert, CMP_MATCH, ast_endpoint::id, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, OBJ_SEARCH_OBJECT, and OBJ_SEARCH_PARTIAL_KEY.

Referenced by ast_endpoint_init().

00101 {
00102    const struct ast_endpoint *left = obj;
00103    const struct ast_endpoint *right = arg;
00104    const char *right_key = arg;
00105    int cmp;
00106 
00107    switch (flags & OBJ_SEARCH_MASK) {
00108    case OBJ_SEARCH_OBJECT:
00109       right_key = right->id;
00110       /* Fall through */
00111    case OBJ_SEARCH_KEY:
00112       cmp = strcmp(left->id, right_key);
00113       break;
00114    case OBJ_SEARCH_PARTIAL_KEY:
00115       cmp = strncmp(left->id, right_key, strlen(right_key));
00116       break;
00117    default:
00118       ast_assert(0);
00119       cmp = 0;
00120       break;
00121    }
00122    if (cmp) {
00123       return 0;
00124    }
00125 
00126    return CMP_MATCH;
00127 }

static void endpoint_default ( void *  data,
struct stasis_subscription sub,
struct stasis_message message 
) [static]

Definition at line 252 of file endpoints.c.

References ao2_cleanup, and stasis_subscription_final_message().

Referenced by endpoint_internal_create().

00255 {
00256    struct stasis_endpoint *endpoint = data;
00257 
00258    if (stasis_subscription_final_message(sub, message)) {
00259       ao2_cleanup(endpoint);
00260    }
00261 }

static void endpoint_dtor ( void *  obj  )  [static]

Definition at line 192 of file endpoints.c.

References ao2_cleanup, ast_assert, ast_string_field_free_memory, ast_endpoint::channel_ids, NULL, ast_endpoint::router, stasis_cp_single_unsubscribe(), stasis_message_router_is_done(), and ast_endpoint::topics.

Referenced by endpoint_internal_create().

00193 {
00194    struct ast_endpoint *endpoint = obj;
00195 
00196    /* The router should be shut down already */
00197    ast_assert(stasis_message_router_is_done(endpoint->router));
00198    ao2_cleanup(endpoint->router);
00199    endpoint->router = NULL;
00200 
00201    stasis_cp_single_unsubscribe(endpoint->topics);
00202    endpoint->topics = NULL;
00203 
00204    ao2_cleanup(endpoint->channel_ids);
00205    endpoint->channel_ids = NULL;
00206 
00207    ast_string_field_free_memory(endpoint);
00208 }

static int endpoint_hash ( const void *  obj,
int  flags 
) [static]

Definition at line 81 of file endpoints.c.

References ast_assert, ast_str_hash(), ast_endpoint::id, OBJ_SEARCH_KEY, OBJ_SEARCH_MASK, and OBJ_SEARCH_OBJECT.

Referenced by ast_endpoint_init().

00082 {
00083    const struct ast_endpoint *endpoint;
00084    const char *key;
00085 
00086    switch (flags & OBJ_SEARCH_MASK) {
00087    case OBJ_SEARCH_KEY:
00088       key = obj;
00089       return ast_str_hash(key);
00090    case OBJ_SEARCH_OBJECT:
00091       endpoint = obj;
00092       return ast_str_hash(endpoint->id);
00093    default:
00094       /* Hash can only work on something with a full key. */
00095       ast_assert(0);
00096       return 0;
00097    }
00098 }

static struct ast_endpoint* endpoint_internal_create ( const char *  tech,
const char *  resource 
) [static, read]

Definition at line 263 of file endpoints.c.

References ao2_alloc, AO2_ALLOC_OPT_LOCK_NOLOCK, ao2_cleanup, ao2_find, ao2_link, ao2_ref, ast_endpoint_cache_all(), ast_endpoint_topic(), AST_ENDPOINT_UNKNOWN, ast_str_container_alloc_options(), ast_string_field_build, ast_string_field_init, ast_string_field_set, ast_strlen_zero, endpoint_cache_clear(), ENDPOINT_CHANNEL_BUCKETS, endpoint_default(), endpoint_dtor(), endpoint_publish_snapshot(), NULL, OBJ_KEY, RAII_VAR, S_OR, stasis_cache_clear_type(), stasis_cp_single_create(), stasis_cp_single_topic(), stasis_forward_all(), stasis_message_router_add(), stasis_message_router_create_pool(), and stasis_message_router_set_default().

Referenced by ast_endpoint_create().

00264 {
00265    RAII_VAR(struct ast_endpoint *, endpoint, NULL, ao2_cleanup);
00266    RAII_VAR(struct ast_endpoint *, tech_endpoint, NULL, ao2_cleanup);
00267    int r = 0;
00268 
00269    /* Get/create the technology endpoint */
00270    if (!ast_strlen_zero(resource)) {
00271       tech_endpoint = ao2_find(tech_endpoints, tech, OBJ_KEY);
00272       if (!tech_endpoint) {
00273          tech_endpoint = endpoint_internal_create(tech, NULL);
00274          if (!tech_endpoint) {
00275             return NULL;
00276          }
00277       }
00278    }
00279 
00280    endpoint = ao2_alloc(sizeof(*endpoint), endpoint_dtor);
00281    if (!endpoint) {
00282       return NULL;
00283    }
00284 
00285    endpoint->max_channels = -1;
00286    endpoint->state = AST_ENDPOINT_UNKNOWN;
00287 
00288    if (ast_string_field_init(endpoint, 80) != 0) {
00289       return NULL;
00290    }
00291    ast_string_field_set(endpoint, tech, tech);
00292    ast_string_field_set(endpoint, resource, S_OR(resource, ""));
00293    ast_string_field_build(endpoint, id, "%s%s%s",
00294       tech,
00295       !ast_strlen_zero(resource) ? "/" : "",
00296       S_OR(resource, ""));
00297 
00298    /* All access to channel_ids should be covered by the endpoint's
00299     * lock; no extra lock needed. */
00300    endpoint->channel_ids = ast_str_container_alloc_options(
00301       AO2_ALLOC_OPT_LOCK_NOLOCK, ENDPOINT_CHANNEL_BUCKETS);
00302    if (!endpoint->channel_ids) {
00303       return NULL;
00304    }
00305 
00306    endpoint->topics = stasis_cp_single_create(ast_endpoint_cache_all(),
00307       endpoint->id);
00308    if (!endpoint->topics) {
00309       return NULL;
00310    }
00311 
00312    if (!ast_strlen_zero(resource)) {
00313       endpoint->router = stasis_message_router_create_pool(ast_endpoint_topic(endpoint));
00314       if (!endpoint->router) {
00315          return NULL;
00316       }
00317       r |= stasis_message_router_add(endpoint->router,
00318          stasis_cache_clear_type(), endpoint_cache_clear,
00319          endpoint);
00320       r |= stasis_message_router_set_default(endpoint->router,
00321          endpoint_default, endpoint);
00322       if (r) {
00323          return NULL;
00324       }
00325 
00326       endpoint->tech_forward = stasis_forward_all(stasis_cp_single_topic(endpoint->topics),
00327          stasis_cp_single_topic(tech_endpoint->topics));
00328       endpoint_publish_snapshot(endpoint);
00329       ao2_link(endpoints, endpoint);
00330    } else {
00331       ao2_link(tech_endpoints, endpoint);
00332    }
00333 
00334    ao2_ref(endpoint, +1);
00335    return endpoint;
00336 }

static void endpoint_publish_snapshot ( struct ast_endpoint endpoint  )  [static]

Definition at line 169 of file endpoints.c.

References ao2_cleanup, ast_assert, ast_endpoint_snapshot_create(), ast_endpoint_snapshot_type(), ast_endpoint_topic(), NULL, RAII_VAR, stasis_message_create(), stasis_publish(), and ast_endpoint::topics.

Referenced by ast_endpoint_add_channel(), ast_endpoint_set_max_channels(), ast_endpoint_set_state(), endpoint_cache_clear(), and endpoint_internal_create().

00170 {
00171    RAII_VAR(struct ast_endpoint_snapshot *, snapshot, NULL, ao2_cleanup);
00172    RAII_VAR(struct stasis_message *, message, NULL, ao2_cleanup);
00173 
00174    ast_assert(endpoint != NULL);
00175    ast_assert(endpoint->topics != NULL);
00176 
00177    if (!ast_endpoint_snapshot_type()) {
00178       return;
00179    }
00180 
00181    snapshot = ast_endpoint_snapshot_create(endpoint);
00182    if (!snapshot) {
00183       return;
00184    }
00185    message = stasis_message_create(ast_endpoint_snapshot_type(), snapshot);
00186    if (!message) {
00187       return;
00188    }
00189    stasis_publish(ast_endpoint_topic(endpoint), message);
00190 }

static void endpoint_snapshot_dtor ( void *  obj  )  [static]

Definition at line 442 of file endpoints.c.

References ao2_ref, ast_assert, ast_string_field_free_memory, ast_endpoint_snapshot::channel_ids, NULL, and ast_endpoint_snapshot::num_channels.

Referenced by ast_endpoint_snapshot_create().

00443 {
00444    struct ast_endpoint_snapshot *snapshot = obj;
00445    int channel;
00446 
00447    ast_assert(snapshot != NULL);
00448 
00449    for (channel = 0; channel < snapshot->num_channels; channel++) {
00450       ao2_ref(snapshot->channel_ids[channel], -1);
00451    }
00452 
00453    ast_string_field_free_memory(snapshot);
00454 }


Variable Documentation

struct ao2_container* endpoints [static]

struct ao2_container* tech_endpoints [static]

Definition at line 54 of file endpoints.c.


Generated on Thu Apr 16 06:30:50 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6