channel_internal.h File Reference

Internal channel functions for channel.c to use. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define ast_channel_internal_alloc(destructor, assignedid, requestor)   __ast_channel_internal_alloc(destructor, assignedid, requestor, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Functions

struct ast_channel__ast_channel_internal_alloc (void(*destructor)(void *obj), const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *file, int line, const char *function)
void ast_channel_internal_cleanup (struct ast_channel *chan)
void ast_channel_internal_finalize (struct ast_channel *chan)
int ast_channel_internal_is_finalized (struct ast_channel *chan)
int ast_channel_internal_setup_topics (struct ast_channel *chan)


Detailed Description

Internal channel functions for channel.c to use.

Definition in file channel_internal.h.


Define Documentation

#define ast_channel_internal_alloc ( destructor,
assignedid,
requestor   )     __ast_channel_internal_alloc(destructor, assignedid, requestor, __FILE__, __LINE__, __PRETTY_FUNCTION__)

Definition at line 21 of file channel_internal.h.

Referenced by __ast_channel_alloc_ap(), and ast_dummy_channel_alloc().


Function Documentation

struct ast_channel* __ast_channel_internal_alloc ( void(*)(void *obj)  destructor,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  file,
int  line,
const char *  function 
) [read]

Definition at line 1439 of file channel_internal_api.c.

References __ao2_alloc_debug(), ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc, ast_atomic_fetchadd_int(), ast_channel_unref, ast_config_AST_SYSTEM_NAME, ast_copy_string(), ast_string_field_init, ast_strlen_zero, ast_channel_id::creation_time, ast_channel_id::creation_unique, ast_channel::dialed_causes, DIALED_CAUSES_BUCKETS, ast_channel::linkedid, NULL, pvt_cause_cmp_fn(), pvt_cause_hash_fn(), tmp(), ast_channel_id::unique_id, ast_assigned_ids::uniqueid, and ast_channel::uniqueid.

01440 {
01441    struct ast_channel *tmp;
01442 #if defined(REF_DEBUG)
01443    tmp = __ao2_alloc_debug(sizeof(*tmp), destructor,
01444       AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function, 1);
01445 #elif defined(__AST_DEBUG_MALLOC)
01446    tmp = __ao2_alloc_debug(sizeof(*tmp), destructor,
01447       AO2_ALLOC_OPT_LOCK_MUTEX, "", file, line, function, 0);
01448 #else
01449    tmp = ao2_alloc(sizeof(*tmp), destructor);
01450 #endif
01451 
01452    if ((ast_string_field_init(tmp, 128))) {
01453       return ast_channel_unref(tmp);
01454    }
01455 
01456    if (!(tmp->dialed_causes = ao2_container_alloc(DIALED_CAUSES_BUCKETS, pvt_cause_hash_fn, pvt_cause_cmp_fn))) {
01457       return ast_channel_unref(tmp);
01458    }
01459 
01460    /* set the creation time in the uniqueid */
01461    tmp->uniqueid.creation_time = time(NULL);
01462    tmp->uniqueid.creation_unique = ast_atomic_fetchadd_int(&uniqueint, 1);
01463 
01464    /* use provided id or default to historical {system-}time.# format */
01465    if (assignedids && !ast_strlen_zero(assignedids->uniqueid)) {
01466       ast_copy_string(tmp->uniqueid.unique_id, assignedids->uniqueid, sizeof(tmp->uniqueid.unique_id));
01467    } else if (ast_strlen_zero(ast_config_AST_SYSTEM_NAME)) {
01468       snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%li.%d",
01469          (long)(tmp->uniqueid.creation_time),
01470          tmp->uniqueid.creation_unique);
01471    } else {
01472       snprintf(tmp->uniqueid.unique_id, sizeof(tmp->uniqueid.unique_id), "%s-%li.%d",
01473          ast_config_AST_SYSTEM_NAME,
01474          (long)(tmp->uniqueid.creation_time),
01475          tmp->uniqueid.creation_unique);
01476    }
01477 
01478    /* copy linked id from parent channel if known */
01479    if (requestor) {
01480       tmp->linkedid = requestor->linkedid;
01481    } else {
01482       tmp->linkedid = tmp->uniqueid;
01483    }
01484 
01485    return tmp;
01486 }

void ast_channel_internal_cleanup ( struct ast_channel chan  ) 

void ast_channel_internal_finalize ( struct ast_channel chan  ) 

Definition at line 1561 of file channel_internal_api.c.

References ast_channel::finalized.

Referenced by __ast_channel_alloc_ap().

01562 {
01563    chan->finalized = 1;
01564 }

int ast_channel_internal_is_finalized ( struct ast_channel chan  ) 

Definition at line 1566 of file channel_internal_api.c.

References ast_channel::finalized.

Referenced by ast_channel_destructor().

01567 {
01568    return chan->finalized;
01569 }

int ast_channel_internal_setup_topics ( struct ast_channel chan  ) 

Definition at line 1612 of file channel_internal_api.c.

References ast_assert, ast_channel_cache_all(), ast_strlen_zero, NULL, stasis_cp_single_create(), ast_channel::topics, ast_channel_id::unique_id, and ast_channel::uniqueid.

Referenced by __ast_channel_alloc_ap(), and ast_dummy_channel_alloc().

01613 {
01614    const char *topic_name = chan->uniqueid.unique_id;
01615    ast_assert(chan->topics == NULL);
01616 
01617    if (ast_strlen_zero(topic_name)) {
01618       topic_name = "<dummy-channel>";
01619    }
01620 
01621    chan->topics = stasis_cp_single_create(
01622       ast_channel_cache_all(), topic_name);
01623    if (!chan->topics) {
01624       return -1;
01625    }
01626 
01627    return 0;
01628 }


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