Wed Aug 18 22:34:21 2010

Asterisk developer's documentation


devicestate.h File Reference

Device state management. More...

#include "asterisk/channel.h"

Go to the source code of this file.

Data Structures

struct  ast_devstate_aggregate
 You shouldn't care about the contents of this struct. More...

Enumerations

enum  ast_device_state {
  AST_DEVICE_UNKNOWN, AST_DEVICE_NOT_INUSE, AST_DEVICE_INUSE, AST_DEVICE_BUSY,
  AST_DEVICE_INVALID, AST_DEVICE_UNAVAILABLE, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE,
  AST_DEVICE_ONHOLD, AST_DEVICE_TOTAL
}
 Device States. More...

Functions

enum ast_device_state ast_device_state (const char *device)
 Asks a channel for device state.
int ast_device_state_changed (const char *fmt,...)
 Tells Asterisk the State for Device is changed. (Accept change notification, add it to change queue.).
int ast_device_state_changed_literal (const char *device)
 Tells Asterisk the State for Device is changed.
void ast_devstate_aggregate_add (struct ast_devstate_aggregate *agg, enum ast_device_state state)
 Add a device state to the aggregate device state.
void ast_devstate_aggregate_init (struct ast_devstate_aggregate *agg)
 Initialize aggregate device state.
enum ast_device_state ast_devstate_aggregate_result (struct ast_devstate_aggregate *agg)
 Get the aggregate device state result.
int ast_devstate_changed (enum ast_device_state state, const char *fmt,...)
 Tells Asterisk the State for Device is changed.
int ast_devstate_changed_literal (enum ast_device_state state, const char *device)
 Tells Asterisk the State for Device is changed.
int ast_devstate_prov_add (const char *label, ast_devstate_prov_cb_type callback)
 Add device state provider.
int ast_devstate_prov_del (const char *label)
 Remove device state provider.
const char * ast_devstate_str (enum ast_device_state devstate)
 Convert device state to text string that is easier to parse.
enum ast_device_state ast_devstate_val (const char *val)
 Convert device state from text to integer value.
int ast_enable_distributed_devstate (void)
 Enable distributed device state processing.
enum ast_device_state ast_parse_device_state (const char *device)
 Search the Channels by Name.
enum ast_device_state ast_state_chan2dev (enum ast_channel_state chanstate)
 Convert channel state to devicestate.
const char * devstate2str (enum ast_device_state devstate)
 Convert device state to text string for output.

Variables

enum ast_device_state(*) ast_devstate_prov_cb_type (const char *data)
 Devicestate provider call back.


Detailed Description

Device state management.

To subscribe to device state changes, use the generic ast_event_subscribe method. For an example, see apps/app_queue.c.

Todo:
Currently, when the state of a device changes, the device state provider calls one of the functions defined here to queue an object to say that the state of a device has changed. However, this does not include the new state. Another thread processes these device state change objects and calls the device state provider's callback to figure out what the new state is. It would make a lot more sense for the new state to be included in the original function call that says the state of a device has changed. However, it will take a lot of work to change this.

Definition in file devicestate.h.


Enumeration Type Documentation

enum ast_device_state

Device States.

Note:
The order of these states may not change because they are included in Asterisk events which may be transmitted across the network to other servers.
Enumerator:
AST_DEVICE_UNKNOWN  Device is valid but channel didn't know state
AST_DEVICE_NOT_INUSE  Device is not used
AST_DEVICE_INUSE  Device is in use
AST_DEVICE_BUSY  Device is busy
AST_DEVICE_INVALID  Device is invalid
AST_DEVICE_UNAVAILABLE  Device is unavailable
AST_DEVICE_RINGING  Device is ringing
AST_DEVICE_RINGINUSE  Device is ringing *and* in use
AST_DEVICE_ONHOLD  Device is on hold
AST_DEVICE_TOTAL 

Definition at line 51 of file devicestate.h.

00051                       {
00052    AST_DEVICE_UNKNOWN,      /*!< Device is valid but channel didn't know state */
00053    AST_DEVICE_NOT_INUSE,    /*!< Device is not used */
00054    AST_DEVICE_INUSE,        /*!< Device is in use */
00055    AST_DEVICE_BUSY,         /*!< Device is busy */
00056    AST_DEVICE_INVALID,      /*!< Device is invalid */
00057    AST_DEVICE_UNAVAILABLE,  /*!< Device is unavailable */
00058    AST_DEVICE_RINGING,      /*!< Device is ringing */
00059    AST_DEVICE_RINGINUSE,    /*!< Device is ringing *and* in use */
00060    AST_DEVICE_ONHOLD,       /*!< Device is on hold */
00061    AST_DEVICE_TOTAL,        /*/ Total num of device states, used for testing */
00062 };


Function Documentation

enum ast_device_state ast_device_state ( const char *  device  ) 

Asks a channel for device state.

Parameters:
device like a dial string
Asks a channel for device state, data is normally a number from a dial string used by the low level module Tries the channel device state callback if not supported search in the active channels list for the device.

Return values:
an AST_DEVICE_??? state
-1 on failure

Definition at line 386 of file devicestate.c.

References _ast_device_state().

Referenced by _ast_device_state(), ast_extension_state2(), ast_parse_device_state(), chanavail_exec(), create_queue_member(), device_state_cb(), devstate_cached(), devstate_read(), devstate_write(), do_state_change(), handle_cli_devstate_change(), page_exec(), process_collection(), ring_entry(), skinny_extensionstate_cb(), sla_state(), and transmit_state_notify().

00387 {
00388    /* This function is called from elsewhere in the code to find out the
00389     * current state of a device.  Check the cache, first. */
00390 
00391    return _ast_device_state(device, 1);
00392 }

int ast_device_state_changed ( const char *  fmt,
  ... 
)

Tells Asterisk the State for Device is changed. (Accept change notification, add it to change queue.).

Parameters:
fmt device name like a dial string with format parameters
Asterisk polls the new extension states and calls the registered callbacks for the changed extensions

Return values:
0 on success
-1 on failure
Note:
This is deprecated in favor of ast_devstate_changed()
Version:
1.6.1 deprecated

Definition at line 546 of file devicestate.c.

References AST_DEVICE_UNKNOWN, ast_devstate_changed_literal(), AST_MAX_EXTENSION, and buf.

00547 {
00548    char buf[AST_MAX_EXTENSION];
00549    va_list ap;
00550 
00551    va_start(ap, fmt);
00552    vsnprintf(buf, sizeof(buf), fmt, ap);
00553    va_end(ap);
00554 
00555    return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, buf);
00556 }

int ast_device_state_changed_literal ( const char *  device  ) 

Tells Asterisk the State for Device is changed.

Parameters:
device device name like a dial string
Asterisk polls the new extension states and calls the registered callbacks for the changed extensions

Return values:
0 on success
-1 on failure
Note:
This is deprecated in favor of ast_devstate_changed_literal()
Version:
1.6.1 deprecated

Definition at line 529 of file devicestate.c.

References AST_DEVICE_UNKNOWN, and ast_devstate_changed_literal().

00530 {
00531    return ast_devstate_changed_literal(AST_DEVICE_UNKNOWN, dev);
00532 }

void ast_devstate_aggregate_add ( struct ast_devstate_aggregate agg,
enum ast_device_state  state 
)

Add a device state to the aggregate device state.

Parameters:
[in] agg the state object
[in] state the state to add
Returns:
nothing
Since:
1.6.1

Definition at line 769 of file devicestate.c.

References ast_devstate_aggregate::all_busy, ast_devstate_aggregate::all_free, ast_devstate_aggregate::all_unavail, ast_devstate_aggregate::all_unknown, AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, AST_DEVICE_TOTAL, AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, ast_devstate_aggregate::busy, ast_devstate_aggregate::in_use, ast_devstate_aggregate::on_hold, and ast_devstate_aggregate::ring.

Referenced by ast_extension_state2(), and process_collection().

00770 {
00771    switch (state) {
00772    case AST_DEVICE_NOT_INUSE:
00773       agg->all_unknown = 0;
00774       agg->all_unavail = 0;
00775       agg->all_busy = 0;
00776       break;
00777    case AST_DEVICE_INUSE:
00778       agg->in_use = 1;
00779       agg->all_unavail = 0;
00780       agg->all_free = 0;
00781       agg->all_unknown = 0;
00782       break;
00783    case AST_DEVICE_RINGING:
00784       agg->ring = 1;
00785       agg->all_unavail = 0;
00786       agg->all_free = 0;
00787       agg->all_unknown = 0;
00788       break;
00789    case AST_DEVICE_RINGINUSE:
00790       agg->in_use = 1;
00791       agg->ring = 1;
00792       agg->all_unavail = 0;
00793       agg->all_free = 0;
00794       agg->all_unknown = 0;
00795       break;
00796    case AST_DEVICE_ONHOLD:
00797       agg->all_unknown = 0;
00798       agg->all_unavail = 0;
00799       agg->all_free = 0;
00800       agg->on_hold = 1;
00801       break;
00802    case AST_DEVICE_BUSY:
00803       agg->all_unknown = 0;
00804       agg->all_unavail = 0;
00805       agg->all_free = 0;
00806       agg->busy = 1;
00807       agg->in_use = 1;
00808       break;
00809    case AST_DEVICE_UNAVAILABLE:
00810       agg->all_unknown = 0;
00811    case AST_DEVICE_INVALID:
00812       agg->all_busy = 0;
00813       agg->all_free = 0;
00814       break;
00815    case AST_DEVICE_UNKNOWN:
00816       agg->all_busy = 0;
00817       agg->all_free = 0;
00818       break;
00819    case AST_DEVICE_TOTAL: /* not a device state, included for completeness. */
00820       break;
00821    }
00822 }

void ast_devstate_aggregate_init ( struct ast_devstate_aggregate agg  ) 

Initialize aggregate device state.

Parameters:
[in] agg the state object
Returns:
nothing
Since:
1.6.1

Definition at line 759 of file devicestate.c.

Referenced by ast_extension_state2(), and process_collection().

00760 {
00761    memset(agg, 0, sizeof(*agg));
00762 
00763    agg->all_unknown = 1;
00764    agg->all_unavail = 1;
00765    agg->all_busy = 1;
00766    agg->all_free = 1;
00767 }

enum ast_device_state ast_devstate_aggregate_result ( struct ast_devstate_aggregate agg  ) 

Get the aggregate device state result.

Parameters:
[in] agg the state object
Returns:
the aggregate device state after adding some number of device states.
Since:
1.6.1

Definition at line 825 of file devicestate.c.

References ast_devstate_aggregate::all_busy, ast_devstate_aggregate::all_free, ast_devstate_aggregate::all_unavail, ast_devstate_aggregate::all_unknown, AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, ast_devstate_aggregate::busy, ast_devstate_aggregate::in_use, ast_devstate_aggregate::on_hold, and ast_devstate_aggregate::ring.

Referenced by ast_extension_state2(), and process_collection().

00826 {
00827    if (agg->all_free)
00828       return AST_DEVICE_NOT_INUSE;
00829    if ((agg->in_use || agg->on_hold) && agg->ring)
00830       return AST_DEVICE_RINGINUSE;
00831    if (agg->ring)
00832       return AST_DEVICE_RINGING;
00833    if (agg->busy)
00834       return AST_DEVICE_BUSY;
00835    if (agg->in_use)
00836       return AST_DEVICE_INUSE;
00837    if (agg->on_hold)
00838       return AST_DEVICE_ONHOLD;
00839    if (agg->all_busy)
00840       return AST_DEVICE_BUSY;
00841    if (agg->all_unknown)
00842       return AST_DEVICE_UNKNOWN;
00843    if (agg->all_unavail)
00844       return AST_DEVICE_UNAVAILABLE;
00845 
00846    return AST_DEVICE_NOT_INUSE;
00847 }

int ast_devstate_changed ( enum ast_device_state  state,
const char *  fmt,
  ... 
)

Tells Asterisk the State for Device is changed.

Parameters:
state the new state of the device
fmt device name like a dial string with format parameters
The new state of the device will be sent off to any subscribers of device states. It will also be stored in the internal event cache.

Return values:
0 on success
-1 on failure

Definition at line 534 of file devicestate.c.

References ast_devstate_changed_literal(), AST_MAX_EXTENSION, and buf.

Referenced by __expire_registry(), __iax2_poke_noanswer(), agent_call(), agent_hangup(), agent_logoff_maintenance(), agent_read(), conf_run(), devstate_write(), expire_register(), handle_cli_devstate_change(), handle_offhook_message(), handle_onhook_message(), handle_response_peerpoke(), handle_soft_key_event_message(), handle_stimulus_message(), load_module(), login_exec(), notify_metermaids(), reg_source_db(), register_verify(), reload_agents(), sip_peer_hold(), sip_poke_noanswer(), skinny_register(), skinny_unregister(), sla_change_trunk_state(), sla_handle_hold_event(), sla_station_exec(), socket_process(), update_call_counter(), and update_registry().

00535 {
00536    char buf[AST_MAX_EXTENSION];
00537    va_list ap;
00538 
00539    va_start(ap, fmt);
00540    vsnprintf(buf, sizeof(buf), fmt, ap);
00541    va_end(ap);
00542 
00543    return ast_devstate_changed_literal(state, buf);
00544 }

int ast_devstate_changed_literal ( enum ast_device_state  state,
const char *  device 
)

Tells Asterisk the State for Device is changed.

Parameters:
state the new state of the device
device device name like a dial string with format parameters
The new state of the device will be sent off to any subscribers of device states. It will also be stored in the internal event cache.

Return values:
0 on success
-1 on failure

Definition at line 491 of file devicestate.c.

References ast_calloc, ast_cond_signal(), AST_DEVICE_UNKNOWN, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_UNLOCK, change_thread, devstate_event(), do_state_change(), and devstate_prov::list.

Referenced by ast_channel_free(), ast_device_state_changed(), ast_device_state_changed_literal(), ast_devstate_changed(), ast_setstate(), and dahdi_new().

00492 {
00493    struct state_change *change;
00494 
00495    /* 
00496     * If we know the state change (how nice of the caller of this function!)
00497     * then we can just generate a device state event. 
00498     *
00499     * Otherwise, we do the following:
00500     *   - Queue an event up to another thread that the state has changed
00501     *   - In the processing thread, it calls the callback provided by the
00502     *     device state provider (which may or may not be a channel driver)
00503     *     to determine the state.
00504     *   - If the device state provider does not know the state, or this is
00505     *     for a channel and the channel driver does not implement a device
00506     *     state callback, then we will look through the channel list to
00507     *     see if we can determine a state based on active calls.
00508     *   - Once a state has been determined, a device state event is generated.
00509     */
00510 
00511    if (state != AST_DEVICE_UNKNOWN) {
00512       devstate_event(device, state);
00513    } else if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
00514       /* we could not allocate a change struct, or */
00515       /* there is no background thread, so process the change now */
00516       do_state_change(device);
00517    } else {
00518       /* queue the change */
00519       strcpy(change->device, device);
00520       AST_LIST_LOCK(&state_changes);
00521       AST_LIST_INSERT_TAIL(&state_changes, change, list);
00522       ast_cond_signal(&change_pending);
00523       AST_LIST_UNLOCK(&state_changes);
00524    }
00525 
00526    return 1;
00527 }

int ast_devstate_prov_add ( const char *  label,
ast_devstate_prov_cb_type  callback 
)

Add device state provider.

Parameters:
label to use in hint, like label:object
callback Callback
Return values:
0 success
-1 failure

Definition at line 395 of file devicestate.c.

References ast_calloc, ast_copy_string(), AST_RWLIST_INSERT_HEAD, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and devstate_prov::list.

Referenced by ast_features_init(), and load_module().

00396 {
00397    struct devstate_prov *devprov;
00398 
00399    if (!callback || !(devprov = ast_calloc(1, sizeof(*devprov))))
00400       return -1;
00401 
00402    devprov->callback = callback;
00403    ast_copy_string(devprov->label, label, sizeof(devprov->label));
00404 
00405    AST_RWLIST_WRLOCK(&devstate_provs);
00406    AST_RWLIST_INSERT_HEAD(&devstate_provs, devprov, list);
00407    AST_RWLIST_UNLOCK(&devstate_provs);
00408 
00409    return 0;
00410 }

int ast_devstate_prov_del ( const char *  label  ) 

Remove device state provider.

Parameters:
label to use in hint, like label:object
Return values:
-1 on failure
0 on success

Definition at line 413 of file devicestate.c.

References ast_free, AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, devstate_prov::label, and devstate_prov::list.

Referenced by unload_module().

00414 {
00415    struct devstate_prov *devcb;
00416    int res = -1;
00417 
00418    AST_RWLIST_WRLOCK(&devstate_provs);
00419    AST_RWLIST_TRAVERSE_SAFE_BEGIN(&devstate_provs, devcb, list) {
00420       if (!strcasecmp(devcb->label, label)) {
00421          AST_RWLIST_REMOVE_CURRENT(list);
00422          ast_free(devcb);
00423          res = 0;
00424          break;
00425       }
00426    }
00427    AST_RWLIST_TRAVERSE_SAFE_END;
00428    AST_RWLIST_UNLOCK(&devstate_provs);
00429 
00430    return res;
00431 }

const char* ast_devstate_str ( enum ast_device_state  devstate  ) 

Convert device state to text string that is easier to parse.

Parameters:
devstate Current device state

Definition at line 226 of file devicestate.c.

References AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, AST_DEVICE_TOTAL, AST_DEVICE_UNAVAILABLE, and AST_DEVICE_UNKNOWN.

Referenced by devstate_read().

00227 {
00228    const char *res = "UNKNOWN";
00229 
00230    switch (state) {
00231    case AST_DEVICE_UNKNOWN:
00232       break;
00233    case AST_DEVICE_NOT_INUSE:
00234       res = "NOT_INUSE";
00235       break;
00236    case AST_DEVICE_INUSE:
00237       res = "INUSE";
00238       break;
00239    case AST_DEVICE_BUSY:
00240       res = "BUSY";
00241       break;
00242    case AST_DEVICE_INVALID:
00243       res = "INVALID";
00244       break;
00245    case AST_DEVICE_UNAVAILABLE:
00246       res = "UNAVAILABLE";
00247       break;
00248    case AST_DEVICE_RINGING:
00249       res = "RINGING";
00250       break;
00251    case AST_DEVICE_RINGINUSE:
00252       res = "RINGINUSE";
00253       break;
00254    case AST_DEVICE_ONHOLD:
00255       res = "ONHOLD";
00256       break;
00257    case AST_DEVICE_TOTAL:
00258       break;
00259    }
00260 
00261    return res;
00262 }

enum ast_device_state ast_devstate_val ( const char *  val  ) 

Convert device state from text to integer value.

Parameters:
val The text representing the device state. Valid values are anything that comes after AST_DEVICE_ in one of the defined values.
Returns:
The AST_DEVICE_ integer value

Definition at line 264 of file devicestate.c.

References AST_DEVICE_BUSY, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_ONHOLD, AST_DEVICE_RINGING, AST_DEVICE_RINGINUSE, AST_DEVICE_UNAVAILABLE, and AST_DEVICE_UNKNOWN.

Referenced by custom_devstate_callback(), devstate_write(), handle_cli_devstate_change(), and load_module().

00265 {
00266    if (!strcasecmp(val, "NOT_INUSE"))
00267       return AST_DEVICE_NOT_INUSE;
00268    else if (!strcasecmp(val, "INUSE"))
00269       return AST_DEVICE_INUSE;
00270    else if (!strcasecmp(val, "BUSY"))
00271       return AST_DEVICE_BUSY;
00272    else if (!strcasecmp(val, "INVALID"))
00273       return AST_DEVICE_INVALID;
00274    else if (!strcasecmp(val, "UNAVAILABLE"))
00275       return AST_DEVICE_UNAVAILABLE;
00276    else if (!strcasecmp(val, "RINGING"))
00277       return AST_DEVICE_RINGING;
00278    else if (!strcasecmp(val, "RINGINUSE"))
00279       return AST_DEVICE_RINGINUSE;
00280    else if (!strcasecmp(val, "ONHOLD"))
00281       return AST_DEVICE_ONHOLD;
00282 
00283    return AST_DEVICE_UNKNOWN;
00284 }

int ast_enable_distributed_devstate ( void   ) 

Enable distributed device state processing.

By default, Asterisk assumes that device state change events will only be originating from one instance. If a module gets loaded and configured such that multiple instances of Asterisk will be sharing device state, this function should be called to enable distributed device state processing. It is off by default to save on unnecessary processing.

Return values:
0 success
-1 failure

Definition at line 849 of file devicestate.c.

References ast_cond_init(), AST_EVENT_DEVICE_STATE_CHANGE, AST_EVENT_IE_END, ast_event_subscribe(), ast_log(), ast_mutex_init(), ast_pthread_create_background, devstate_change_collector_cb(), devstate_collector, LOG_ERROR, and run_devstate_collector().

00850 {
00851    if (devstate_collector.enabled) {
00852       return 0;
00853    }
00854 
00855    devstate_collector.event_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE_CHANGE,
00856       devstate_change_collector_cb, NULL, AST_EVENT_IE_END);
00857 
00858    if (!devstate_collector.event_sub) {
00859       ast_log(LOG_ERROR, "Failed to create subscription for the device state change collector\n");
00860       return -1;
00861    }
00862 
00863    ast_mutex_init(&devstate_collector.lock);
00864    ast_cond_init(&devstate_collector.cond, NULL);
00865    if (ast_pthread_create_background(&devstate_collector.thread, NULL, run_devstate_collector, NULL) < 0) {
00866       ast_log(LOG_ERROR, "Unable to start device state collector thread.\n");
00867       return -1;
00868    }
00869 
00870    devstate_collector.enabled = 1;
00871 
00872    return 0;
00873 }

enum ast_device_state ast_parse_device_state ( const char *  device  ) 

Search the Channels by Name.

Note:
find channels with the device's name in it This function is only used for channels that does not implement devicestate natively

Definition at line 291 of file devicestate.c.

References ast_channel::_state, AST_CHANNEL_NAME, ast_channel_unlock, ast_copy_string(), AST_DEVICE_INUSE, AST_DEVICE_RINGING, ast_device_state(), AST_DEVICE_UNKNOWN, ast_get_channel_by_name_prefix_locked(), AST_STATE_RINGING, chan, and match().

Referenced by _ast_device_state(), and chanavail_exec().

00292 {
00293    struct ast_channel *chan;
00294    char match[AST_CHANNEL_NAME];
00295    enum ast_device_state res;
00296 
00297    ast_copy_string(match, device, sizeof(match)-1);
00298    strcat(match, "-");
00299    chan = ast_get_channel_by_name_prefix_locked(match, strlen(match));
00300 
00301    if (!chan)
00302       return AST_DEVICE_UNKNOWN;
00303 
00304    if (chan->_state == AST_STATE_RINGING)
00305       res = AST_DEVICE_RINGING;
00306    else
00307       res = AST_DEVICE_INUSE;
00308    
00309    ast_channel_unlock(chan);
00310 
00311    return res;
00312 }

enum ast_device_state ast_state_chan2dev ( enum ast_channel_state  chanstate  ) 

Convert channel state to devicestate.

Parameters:
chanstate Current channel state
Since:
1.6.1

Definition at line 214 of file devicestate.c.

References AST_DEVICE_UNKNOWN, and chan.

Referenced by dahdi_new().

00215 {
00216    int i;
00217    chanstate &= 0xFFFF;
00218    for (i = 0; chan2dev[i].chan != -100; i++) {
00219       if (chan2dev[i].chan == chanstate) {
00220          return chan2dev[i].dev;
00221       }
00222    }
00223    return AST_DEVICE_UNKNOWN;
00224 }

const char* devstate2str ( enum ast_device_state  devstate  ) 

Convert device state to text string for output.

Parameters:
devstate Current device state

Definition at line 209 of file devicestate.c.

Referenced by __queues_show(), do_state_change(), handle_statechange(), notify_metermaids(), page_exec(), and process_collection().

00210 {
00211    return devstatestring[devstate];
00212 }


Variable Documentation

enum ast_device_state(*) ast_devstate_prov_cb_type(const char *data)

Devicestate provider call back.

Definition at line 65 of file devicestate.h.


Generated on Wed Aug 18 22:34:21 2010 for Asterisk - the Open Source PBX by  doxygen 1.4.7