2006-02-26 20:46:11 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2006 Voop as
|
|
|
|
* Thorsten Lockert <tholo@voop.as>
|
|
|
|
*
|
|
|
|
* This program is free software, distributed under the terms of
|
|
|
|
* the GNU General Public License Version 2. See the LICENSE file
|
|
|
|
* at the top of the source tree.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*! \file
|
|
|
|
*
|
|
|
|
* \brief SNMP Agent / SubAgent support for Asterisk
|
|
|
|
*
|
|
|
|
* \author Thorsten Lockert <tholo@voop.as>
|
|
|
|
*/
|
|
|
|
|
2012-06-15 16:20:16 +00:00
|
|
|
/*** MODULEINFO
|
|
|
|
<support_level>extended</support_level>
|
|
|
|
***/
|
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
#include "asterisk.h"
|
|
|
|
|
git migration: Refactor the ASTERISK_FILE_VERSION macro
Git does not support the ability to replace a token with a version
string during check-in. While it does have support for replacing a
token on clone, this is somewhat sub-optimal: the token is replaced
with the object hash, which is not particularly easy for human
consumption. What's more, in practice, the source file version was often
not terribly useful. Generally, when triaging bugs, the overall version
of Asterisk is far more useful than an individual SVN version of a file. As a
result, this patch removes Asterisk's support for showing source file
versions.
Specifically, it does the following:
* Rename ASTERISK_FILE_VERSION macro to ASTERISK_REGISTER_FILE, and
remove passing the version in with the macro. Other facilities
than 'core show file version' make use of the file names, such as
setting a debug level only on a specific file. As such, the act of
registering source files with the Asterisk core still has use. The
macro rename now reflects the new macro purpose.
* main/asterisk:
- Refactor the file_version structure to reflect that it no longer
tracks a version field.
- Remove the "core show file version" CLI command. Without the file
version, it is no longer useful.
- Remove the ast_file_version_find function. The file version is no
longer tracked.
- Rename ast_register_file_version/ast_unregister_file_version to
ast_register_file/ast_unregister_file, respectively.
* main/manager: Remove value from the Version key of the ModuleCheck
Action. The actual key itself has not been removed, as doing so would
absolutely constitute a backwards incompatible change. However, since
the file version is no longer tracked, there is no need to attempt to
include it in the Version key.
* UPGRADE: Add notes for:
- Modification to the ModuleCheck AMI Action
- Removal of the "core show file version" CLI command
Change-Id: I6cf0ff280e1668bf4957dc21f32a5ff43444a40e
2015-04-11 21:38:22 -05:00
|
|
|
ASTERISK_REGISTER_FILE()
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-12-19 08:12:33 +00:00
|
|
|
/*
|
|
|
|
* There is some collision collision between netsmp and asterisk names,
|
|
|
|
* causing build under AST_DEVMODE to fail.
|
|
|
|
*
|
|
|
|
* The following PACKAGE_* macros are one place.
|
|
|
|
* Also netsnmp has an improper check for HAVE_DMALLOC_H, using
|
|
|
|
* #if HAVE_DMALLOC_H instead of #ifdef HAVE_DMALLOC_H
|
|
|
|
* As a countermeasure we define it to 0, however this will fail
|
|
|
|
* when the proper check is implemented.
|
|
|
|
*/
|
|
|
|
#ifdef PACKAGE_NAME
|
|
|
|
#undef PACKAGE_NAME
|
|
|
|
#endif
|
|
|
|
#ifdef PACKAGE_BUGREPORT
|
|
|
|
#undef PACKAGE_BUGREPORT
|
|
|
|
#endif
|
|
|
|
#ifdef PACKAGE_STRING
|
|
|
|
#undef PACKAGE_STRING
|
|
|
|
#endif
|
|
|
|
#ifdef PACKAGE_TARNAME
|
|
|
|
#undef PACKAGE_TARNAME
|
|
|
|
#endif
|
|
|
|
#ifdef PACKAGE_VERSION
|
|
|
|
#undef PACKAGE_VERSION
|
|
|
|
#endif
|
|
|
|
#ifndef HAVE_DMALLOC_H
|
|
|
|
#define HAVE_DMALLOC_H 0 /* XXX we shouldn't do this */
|
|
|
|
#endif
|
|
|
|
|
2008-12-10 11:34:09 +00:00
|
|
|
#if defined(__OpenBSD__)
|
|
|
|
/*
|
|
|
|
* OpenBSD uses old "legacy" cc which has a rather pedantic builtin preprocessor.
|
|
|
|
* Using a macro which is not #defined throws an error.
|
|
|
|
*/
|
|
|
|
#define __NetBSD_Version__ 0
|
|
|
|
#endif
|
|
|
|
|
2006-06-11 15:10:26 +00:00
|
|
|
#include <net-snmp/net-snmp-config.h>
|
|
|
|
#include <net-snmp/net-snmp-includes.h>
|
|
|
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
|
|
|
|
2007-12-20 09:55:05 +00:00
|
|
|
#include "asterisk/paths.h" /* need ast_config_AST_SOCKET */
|
2006-02-26 20:46:11 +00:00
|
|
|
#include "asterisk/channel.h"
|
|
|
|
#include "asterisk/logger.h"
|
|
|
|
#include "asterisk/options.h"
|
|
|
|
#include "asterisk/indications.h"
|
2008-02-26 22:14:22 +00:00
|
|
|
#include "asterisk/ast_version.h"
|
2006-02-26 20:46:11 +00:00
|
|
|
#include "asterisk/pbx.h"
|
|
|
|
|
|
|
|
/* Colission between Net-SNMP and Asterisk */
|
|
|
|
#define unload_module ast_unload_module
|
|
|
|
#include "asterisk/module.h"
|
|
|
|
#undef unload_module
|
|
|
|
|
|
|
|
#include "agent.h"
|
|
|
|
|
|
|
|
/* Helper functions in Net-SNMP, header file not installed by default */
|
|
|
|
int header_generic(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **);
|
|
|
|
int header_simple_table(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **, int);
|
|
|
|
int register_sysORTable(oid *, size_t, const char *);
|
|
|
|
int unregister_sysORTable(oid *, size_t);
|
|
|
|
|
|
|
|
/* Forward declaration */
|
|
|
|
static void init_asterisk_mib(void);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Anchor for all the Asterisk MIB values
|
|
|
|
*/
|
|
|
|
static oid asterisk_oid[] = { 1, 3, 6, 1, 4, 1, 22736, 1 };
|
|
|
|
|
|
|
|
/*
|
|
|
|
* MIB values -- these correspond to values in the Asterisk MIB,
|
|
|
|
* and MUST be kept in sync with the MIB for things to work as
|
|
|
|
* expected.
|
|
|
|
*/
|
|
|
|
#define ASTVERSION 1
|
|
|
|
#define ASTVERSTRING 1
|
|
|
|
#define ASTVERTAG 2
|
|
|
|
|
|
|
|
#define ASTCONFIGURATION 2
|
|
|
|
#define ASTCONFUPTIME 1
|
|
|
|
#define ASTCONFRELOADTIME 2
|
|
|
|
#define ASTCONFPID 3
|
|
|
|
#define ASTCONFSOCKET 4
|
2007-12-07 16:11:05 +00:00
|
|
|
#define ASTCONFACTIVECALLS 5
|
|
|
|
#define ASTCONFPROCESSEDCALLS 6
|
2006-02-26 20:46:11 +00:00
|
|
|
|
|
|
|
#define ASTMODULES 3
|
|
|
|
#define ASTMODCOUNT 1
|
|
|
|
|
|
|
|
#define ASTINDICATIONS 4
|
|
|
|
#define ASTINDCOUNT 1
|
|
|
|
#define ASTINDCURRENT 2
|
|
|
|
|
|
|
|
#define ASTINDTABLE 3
|
|
|
|
#define ASTINDINDEX 1
|
|
|
|
#define ASTINDCOUNTRY 2
|
|
|
|
#define ASTINDALIAS 3
|
|
|
|
#define ASTINDDESCRIPTION 4
|
|
|
|
|
|
|
|
#define ASTCHANNELS 5
|
|
|
|
#define ASTCHANCOUNT 1
|
|
|
|
|
|
|
|
#define ASTCHANTABLE 2
|
|
|
|
#define ASTCHANINDEX 1
|
|
|
|
#define ASTCHANNAME 2
|
|
|
|
#define ASTCHANLANGUAGE 3
|
|
|
|
#define ASTCHANTYPE 4
|
|
|
|
#define ASTCHANMUSICCLASS 5
|
|
|
|
#define ASTCHANBRIDGE 6
|
|
|
|
#define ASTCHANMASQ 7
|
|
|
|
#define ASTCHANMASQR 8
|
|
|
|
#define ASTCHANWHENHANGUP 9
|
|
|
|
#define ASTCHANAPP 10
|
|
|
|
#define ASTCHANDATA 11
|
|
|
|
#define ASTCHANCONTEXT 12
|
|
|
|
#define ASTCHANMACROCONTEXT 13
|
|
|
|
#define ASTCHANMACROEXTEN 14
|
|
|
|
#define ASTCHANMACROPRI 15
|
|
|
|
#define ASTCHANEXTEN 16
|
|
|
|
#define ASTCHANPRI 17
|
|
|
|
#define ASTCHANACCOUNTCODE 18
|
|
|
|
#define ASTCHANFORWARDTO 19
|
|
|
|
#define ASTCHANUNIQUEID 20
|
|
|
|
#define ASTCHANCALLGROUP 21
|
|
|
|
#define ASTCHANPICKUPGROUP 22
|
|
|
|
#define ASTCHANSTATE 23
|
|
|
|
#define ASTCHANMUTED 24
|
|
|
|
#define ASTCHANRINGS 25
|
|
|
|
#define ASTCHANCIDDNID 26
|
|
|
|
#define ASTCHANCIDNUM 27
|
|
|
|
#define ASTCHANCIDNAME 28
|
|
|
|
#define ASTCHANCIDANI 29
|
|
|
|
#define ASTCHANCIDRDNIS 30
|
|
|
|
#define ASTCHANCIDPRES 31
|
|
|
|
#define ASTCHANCIDANI2 32
|
|
|
|
#define ASTCHANCIDTON 33
|
|
|
|
#define ASTCHANCIDTNS 34
|
|
|
|
#define ASTCHANAMAFLAGS 35
|
|
|
|
#define ASTCHANADSI 36
|
|
|
|
#define ASTCHANTONEZONE 37
|
|
|
|
#define ASTCHANHANGUPCAUSE 38
|
|
|
|
#define ASTCHANVARIABLES 39
|
|
|
|
#define ASTCHANFLAGS 40
|
|
|
|
#define ASTCHANTRANSFERCAP 41
|
|
|
|
|
|
|
|
#define ASTCHANTYPECOUNT 3
|
|
|
|
|
|
|
|
#define ASTCHANTYPETABLE 4
|
|
|
|
#define ASTCHANTYPEINDEX 1
|
|
|
|
#define ASTCHANTYPENAME 2
|
|
|
|
#define ASTCHANTYPEDESC 3
|
|
|
|
#define ASTCHANTYPEDEVSTATE 4
|
|
|
|
#define ASTCHANTYPEINDICATIONS 5
|
|
|
|
#define ASTCHANTYPETRANSFER 6
|
|
|
|
#define ASTCHANTYPECHANNELS 7
|
|
|
|
|
2007-08-23 17:27:07 +00:00
|
|
|
#define ASTCHANSCALARS 5
|
|
|
|
#define ASTCHANBRIDGECOUNT 1
|
2007-06-08 21:31:33 +00:00
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
void *agent_thread(void *arg)
|
|
|
|
{
|
2007-12-14 14:48:38 +00:00
|
|
|
ast_verb(2, "Starting %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
snmp_enable_stderrlog();
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (res_snmp_agentx_subagent)
|
2006-02-26 20:46:11 +00:00
|
|
|
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
|
|
|
|
NETSNMP_DS_AGENT_ROLE,
|
|
|
|
1);
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
init_agent("asterisk");
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
init_asterisk_mib();
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
init_snmp("asterisk");
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (!res_snmp_agentx_subagent)
|
2006-02-26 20:46:11 +00:00
|
|
|
init_master_agent();
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
while (res_snmp_dont_stop)
|
2006-02-26 20:46:11 +00:00
|
|
|
agent_check_and_process(1);
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
snmp_shutdown("asterisk");
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-12-14 14:48:38 +00:00
|
|
|
ast_verb(2, "Terminating %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
return NULL;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *
|
|
|
|
ast_var_channels(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_generic(vp, name, length, exact, var_len, write_method))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (vp->magic != ASTCHANCOUNT)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
long_ret = ast_active_channels();
|
|
|
|
|
|
|
|
return (u_char *)&long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *ast_var_channels_table(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
|
|
|
static u_char bits_ret[2];
|
|
|
|
static char string_ret[256];
|
|
|
|
struct ast_channel *chan, *bridge;
|
|
|
|
struct timeval tval;
|
|
|
|
u_char *ret = NULL;
|
|
|
|
int i, bit;
|
2006-12-19 22:55:26 +00:00
|
|
|
struct ast_str *out = ast_str_alloca(2048);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
struct ast_channel_iterator *iter;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_simple_table(vp, name, length, exact, var_len, write_method, ast_active_channels()))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
i = name[*length - 1] - 1;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2009-10-21 21:08:47 +00:00
|
|
|
if (!(iter = ast_channel_iterator_all_new())) {
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((chan = ast_channel_iterator_next(iter)) && i) {
|
|
|
|
ast_channel_unref(chan);
|
|
|
|
i--;
|
|
|
|
}
|
|
|
|
|
|
|
|
iter = ast_channel_iterator_destroy(iter);
|
|
|
|
|
|
|
|
if (chan == NULL) {
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = sizeof(long_ret);
|
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
ast_channel_lock(chan);
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
switch (vp->magic) {
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTCHANINDEX:
|
|
|
|
long_ret = name[*length - 1];
|
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANNAME:
|
2012-01-09 22:15:50 +00:00
|
|
|
if (!ast_strlen_zero(ast_channel_name(chan))) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_name(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANLANGUAGE:
|
2012-01-24 20:12:09 +00:00
|
|
|
if (!ast_strlen_zero(ast_channel_language(chan))) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_language(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANTYPE:
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_tech(chan)->type, sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANMUSICCLASS:
|
2012-01-24 20:12:09 +00:00
|
|
|
if (!ast_strlen_zero(ast_channel_musicclass(chan))) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_musicclass(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANBRIDGE:
|
2015-01-20 16:59:30 +00:00
|
|
|
ast_channel_unlock(chan);
|
|
|
|
bridge = ast_channel_bridge_peer(chan);
|
|
|
|
if (bridge) {
|
|
|
|
ast_channel_lock(bridge);
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_name(bridge), sizeof(string_ret));
|
2015-01-20 16:59:30 +00:00
|
|
|
ast_channel_unlock(bridge);
|
|
|
|
ast_channel_unref(bridge);
|
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
2015-01-20 16:59:30 +00:00
|
|
|
ast_channel_lock(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
break;
|
|
|
|
case ASTCHANMASQ:
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_masq(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masq(chan)))) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_name(ast_channel_masq(chan)), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANMASQR:
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_masqr(chan) && !ast_strlen_zero(ast_channel_name(ast_channel_masqr(chan)))) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_name(ast_channel_masqr(chan)), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANWHENHANGUP:
|
2012-02-29 16:52:47 +00:00
|
|
|
if (!ast_tvzero(*ast_channel_whentohangup(chan))) {
|
2006-02-26 20:46:11 +00:00
|
|
|
gettimeofday(&tval, NULL);
|
2012-02-29 16:52:47 +00:00
|
|
|
long_ret = difftime(ast_channel_whentohangup(chan)->tv_sec, tval.tv_sec) * 100 - tval.tv_usec / 10000;
|
2006-02-26 20:46:11 +00:00
|
|
|
ret= (u_char *)&long_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANAPP:
|
2012-02-13 17:27:06 +00:00
|
|
|
if (ast_channel_appl(chan)) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_appl(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANDATA:
|
2012-02-13 17:27:06 +00:00
|
|
|
if (ast_channel_data(chan)) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_data(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANCONTEXT:
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_context(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANMACROCONTEXT:
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_macrocontext(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANMACROEXTEN:
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_macroexten(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANMACROPRI:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_macropriority(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANEXTEN:
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_exten(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANPRI:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_priority(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANACCOUNTCODE:
|
2012-01-24 20:12:09 +00:00
|
|
|
if (!ast_strlen_zero(ast_channel_accountcode(chan))) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_accountcode(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANFORWARDTO:
|
2012-01-24 20:12:09 +00:00
|
|
|
if (!ast_strlen_zero(ast_channel_call_forward(chan))) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_call_forward(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANUNIQUEID:
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_uniqueid(chan), sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANCALLGROUP:
|
2012-03-01 22:09:18 +00:00
|
|
|
long_ret = ast_channel_callgroup(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANPICKUPGROUP:
|
2012-03-01 22:09:18 +00:00
|
|
|
long_ret = ast_channel_pickupgroup(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANSTATE:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_state(chan) & 0xffff;
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANMUTED:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_state(chan) & AST_STATE_MUTE ? 1 : 2;
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANRINGS:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_rings(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDDNID:
|
2012-02-29 16:52:47 +00:00
|
|
|
if (ast_channel_dialed(chan)->number.str) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_dialed(chan)->number.str, sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDNUM:
|
2012-02-29 16:52:47 +00:00
|
|
|
if (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_caller(chan)->id.number.str, sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDNAME:
|
2012-02-29 16:52:47 +00:00
|
|
|
if (ast_channel_caller(chan)->id.name.valid && ast_channel_caller(chan)->id.name.str) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_caller(chan)->id.name.str, sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDANI:
|
2012-02-29 16:52:47 +00:00
|
|
|
if (ast_channel_caller(chan)->ani.number.valid && ast_channel_caller(chan)->ani.number.str) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_caller(chan)->ani.number.str, sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDRDNIS:
|
2012-02-29 16:52:47 +00:00
|
|
|
if (ast_channel_redirecting(chan)->from.number.valid && ast_channel_redirecting(chan)->from.number.str) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_redirecting(chan)->from.number.str, sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDPRES:
|
2012-02-29 16:52:47 +00:00
|
|
|
long_ret = ast_party_id_presentation(&ast_channel_caller(chan)->id);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDANI2:
|
2012-02-29 16:52:47 +00:00
|
|
|
long_ret = ast_channel_caller(chan)->ani2;
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDTON:
|
2012-02-29 16:52:47 +00:00
|
|
|
long_ret = ast_channel_caller(chan)->id.number.plan;
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANCIDTNS:
|
2012-02-29 16:52:47 +00:00
|
|
|
long_ret = ast_channel_dialed(chan)->transit_network_select;
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANAMAFLAGS:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_amaflags(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANADSI:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_adsicpe(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANTONEZONE:
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_zone(chan)) {
|
2012-04-19 19:05:17 +00:00
|
|
|
ast_copy_string(string_ret, ast_channel_zone(chan)->country, sizeof(string_ret));
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = strlen(string_ret);
|
|
|
|
ret = (u_char *)string_ret;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANHANGUPCAUSE:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_hangupcause(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANVARIABLES:
|
2006-12-19 22:55:26 +00:00
|
|
|
if (pbx_builtin_serialize_variables(chan, &out)) {
|
2008-12-13 18:25:58 +00:00
|
|
|
*var_len = ast_str_strlen(out);
|
2008-12-13 13:26:13 +00:00
|
|
|
ret = (u_char *)ast_str_buffer(out);
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ASTCHANFLAGS:
|
|
|
|
bits_ret[0] = 0;
|
|
|
|
for (bit = 0; bit < 8; bit++)
|
2012-03-13 18:20:34 +00:00
|
|
|
bits_ret[0] |= ((ast_channel_flags(chan)->flags & (1 << bit)) >> bit) << (7 - bit);
|
2006-02-26 20:46:11 +00:00
|
|
|
bits_ret[1] = 0;
|
|
|
|
for (bit = 0; bit < 8; bit++)
|
2012-03-13 18:20:34 +00:00
|
|
|
bits_ret[1] |= (((ast_channel_flags(chan)->flags >> 8) & (1 << bit)) >> bit) << (7 - bit);
|
2006-02-26 20:46:11 +00:00
|
|
|
*var_len = 2;
|
|
|
|
ret = bits_ret;
|
|
|
|
break;
|
|
|
|
case ASTCHANTRANSFERCAP:
|
2012-02-20 23:43:27 +00:00
|
|
|
long_ret = ast_channel_transfercapability(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
ret = (u_char *)&long_ret;
|
|
|
|
default:
|
|
|
|
break;
|
2007-06-13 16:19:37 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
ast_channel_unlock(chan);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
chan = ast_channel_unref(chan);
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
return ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *ast_var_channel_types(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
struct ast_variable *channel_types, *next;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_generic(vp, name, length, exact, var_len, write_method))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (vp->magic != ASTCHANTYPECOUNT)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
for (long_ret = 0, channel_types = next = ast_channeltype_list(); next; next = next->next)
|
|
|
|
long_ret++;
|
|
|
|
ast_variables_destroy(channel_types);
|
|
|
|
|
|
|
|
return (u_char *)&long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *ast_var_channel_types_table(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
|
|
|
const struct ast_channel_tech *tech = NULL;
|
|
|
|
struct ast_variable *channel_types, *next;
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
|
|
|
struct ast_channel *chan;
|
|
|
|
u_long i;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
|
|
|
channel_types = ast_channeltype_list();
|
|
|
|
for (i = 1, next = channel_types; next && i != name[*length - 1]; next = next->next, i++)
|
|
|
|
;
|
|
|
|
if (next != NULL)
|
|
|
|
tech = ast_get_channel_tech(next->name);
|
|
|
|
ast_variables_destroy(channel_types);
|
2007-06-13 16:19:37 +00:00
|
|
|
if (next == NULL || tech == NULL)
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
2007-06-13 16:19:37 +00:00
|
|
|
|
|
|
|
switch (vp->magic) {
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTCHANTYPEINDEX:
|
|
|
|
long_ret = name[*length - 1];
|
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCHANTYPENAME:
|
|
|
|
*var_len = strlen(tech->type);
|
|
|
|
return (u_char *)tech->type;
|
|
|
|
case ASTCHANTYPEDESC:
|
|
|
|
*var_len = strlen(tech->description);
|
|
|
|
return (u_char *)tech->description;
|
|
|
|
case ASTCHANTYPEDEVSTATE:
|
|
|
|
long_ret = tech->devicestate ? 1 : 2;
|
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCHANTYPEINDICATIONS:
|
|
|
|
long_ret = tech->indicate ? 1 : 2;
|
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCHANTYPETRANSFER:
|
|
|
|
long_ret = tech->transfer ? 1 : 2;
|
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCHANTYPECHANNELS:
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
{
|
|
|
|
struct ast_channel_iterator *iter;
|
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
long_ret = 0;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
2009-10-21 21:08:47 +00:00
|
|
|
if (!(iter = ast_channel_iterator_all_new())) {
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
while ((chan = ast_channel_iterator_next(iter))) {
|
2012-02-20 23:43:27 +00:00
|
|
|
if (ast_channel_tech(chan) == tech) {
|
2006-02-26 20:46:11 +00:00
|
|
|
long_ret++;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
|
|
|
chan = ast_channel_unref(chan);
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
ast_channel_iterator_destroy(iter);
|
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
return (u_char *)&long_ret;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
2006-02-26 20:46:11 +00:00
|
|
|
default:
|
|
|
|
break;
|
2007-06-13 16:19:37 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
2007-06-08 21:31:33 +00:00
|
|
|
static u_char *ast_var_channel_bridge(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-08-23 17:27:07 +00:00
|
|
|
static unsigned long long_ret;
|
2007-06-08 21:31:33 +00:00
|
|
|
struct ast_channel *chan = NULL;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
struct ast_channel_iterator *iter;
|
2007-06-08 21:31:33 +00:00
|
|
|
|
2007-08-23 17:27:07 +00:00
|
|
|
long_ret = 0;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
|
|
|
|
if (header_generic(vp, name, length, exact, var_len, write_method)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-10-21 21:08:47 +00:00
|
|
|
if (!(iter = ast_channel_iterator_all_new())) {
|
2007-06-08 21:31:33 +00:00
|
|
|
return NULL;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
2007-06-08 21:31:33 +00:00
|
|
|
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
while ((chan = ast_channel_iterator_next(iter))) {
|
|
|
|
ast_channel_lock(chan);
|
2013-08-02 15:01:37 +00:00
|
|
|
if (ast_channel_is_bridged(chan)) {
|
2007-06-08 21:31:33 +00:00
|
|
|
long_ret++;
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
}
|
2007-06-08 21:31:33 +00:00
|
|
|
ast_channel_unlock(chan);
|
Convert the ast_channel data structure over to the astobj2 framework.
There is a lot that could be said about this, but the patch is a big
improvement for performance, stability, code maintainability,
and ease of future code development.
The channel list is no longer an unsorted linked list. The main container
for channels is an astobj2 hash table. All of the code related to searching
for channels or iterating active channels has been rewritten. Let n be
the number of active channels. Iterating the channel list has gone from
O(n^2) to O(n). Searching for a channel by name went from O(n) to O(1).
Searching for a channel by extension is still O(n), but uses a new method
for doing so, which is more efficient.
The ast_channel object is now a reference counted object. The benefits
here are plentiful. Some benefits directly related to issues in the
previous code include:
1) When threads other than the channel thread owning a channel wanted
access to a channel, it had to hold the lock on it to ensure that it didn't
go away. This is no longer a requirement. Holding a reference is
sufficient.
2) There are places that now require less dealing with channel locks.
3) There are places where channel locks are held for much shorter periods
of time.
4) There are places where dealing with more than one channel at a time becomes
_MUCH_ easier. ChanSpy is a great example of this. Writing code in the
future that deals with multiple channels will be much easier.
Some additional information regarding channel locking and reference count
handling can be found in channel.h, where a new section has been added that
discusses some of the rules associated with it.
Mark Michelson also assisted with the development of this patch. He did the
conversion of ChanSpy and introduced a new API, ast_autochan, which makes it
much easier to deal with holding on to a channel pointer for an extended period
of time and having it get automatically updated if the channel gets masqueraded.
Mark was also a huge help in the code review process.
Thanks to David Vossel for his assistance with this branch, as well. David
did the conversion of the DAHDIScan application by making it become a wrapper
for ChanSpy internally.
The changes come from the svn/asterisk/team/russell/ast_channel_ao2 branch.
Review: http://reviewboard.digium.com/r/203/
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@190423 65c4cc65-6c06-0410-ace0-fbb531ad65f3
2009-04-24 14:04:26 +00:00
|
|
|
chan = ast_channel_unref(chan);
|
2007-06-08 21:31:33 +00:00
|
|
|
}
|
|
|
|
|
2009-10-21 21:08:47 +00:00
|
|
|
ast_channel_iterator_destroy(iter);
|
|
|
|
|
2007-06-08 21:31:33 +00:00
|
|
|
*var_len = sizeof(long_ret);
|
|
|
|
|
|
|
|
return (vp->magic == ASTCHANBRIDGECOUNT) ? (u_char *) &long_ret : NULL;
|
|
|
|
}
|
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
static u_char *ast_var_Config(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
|
|
|
struct timeval tval;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_generic(vp, name, length, exact, var_len, write_method))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
switch (vp->magic) {
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTCONFUPTIME:
|
|
|
|
gettimeofday(&tval, NULL);
|
2007-07-18 19:47:20 +00:00
|
|
|
long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
|
2006-02-26 20:46:11 +00:00
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCONFRELOADTIME:
|
|
|
|
gettimeofday(&tval, NULL);
|
2007-07-18 19:47:20 +00:00
|
|
|
if (ast_lastreloadtime.tv_sec)
|
|
|
|
long_ret = difftime(tval.tv_sec, ast_lastreloadtime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_lastreloadtime.tv_usec / 10000;
|
2006-02-26 20:46:11 +00:00
|
|
|
else
|
2007-07-18 19:47:20 +00:00
|
|
|
long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
|
2006-02-26 20:46:11 +00:00
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCONFPID:
|
|
|
|
long_ret = getpid();
|
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCONFSOCKET:
|
|
|
|
*var_len = strlen(ast_config_AST_SOCKET);
|
|
|
|
return (u_char *)ast_config_AST_SOCKET;
|
2007-12-07 16:11:05 +00:00
|
|
|
case ASTCONFACTIVECALLS:
|
|
|
|
long_ret = ast_active_calls();
|
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTCONFPROCESSEDCALLS:
|
|
|
|
long_ret = ast_processed_calls();
|
|
|
|
return (u_char *)&long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
default:
|
|
|
|
break;
|
2007-06-13 16:19:37 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *ast_var_indications(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
2009-02-17 20:41:24 +00:00
|
|
|
static char ret_buf[128];
|
|
|
|
struct ast_tone_zone *tz = NULL;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_generic(vp, name, length, exact, var_len, write_method))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
switch (vp->magic) {
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTINDCOUNT:
|
2009-02-17 20:41:24 +00:00
|
|
|
{
|
|
|
|
struct ao2_iterator i;
|
|
|
|
|
2006-02-26 20:46:11 +00:00
|
|
|
long_ret = 0;
|
2009-02-17 20:41:24 +00:00
|
|
|
|
|
|
|
i = ast_tone_zone_iterator_init();
|
|
|
|
while ((tz = ao2_iterator_next(&i))) {
|
|
|
|
tz = ast_tone_zone_unref(tz);
|
2006-02-26 20:46:11 +00:00
|
|
|
long_ret++;
|
2009-02-17 20:41:24 +00:00
|
|
|
}
|
2012-01-27 18:47:16 +00:00
|
|
|
ao2_iterator_destroy(&i);
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2009-02-17 20:41:24 +00:00
|
|
|
return (u_char *) &long_ret;
|
|
|
|
}
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTINDCURRENT:
|
|
|
|
tz = ast_get_indication_zone(NULL);
|
|
|
|
if (tz) {
|
2009-02-17 20:41:24 +00:00
|
|
|
ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
|
|
|
|
*var_len = strlen(ret_buf);
|
|
|
|
tz = ast_tone_zone_unref(tz);
|
|
|
|
return (u_char *) ret_buf;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
*var_len = 0;
|
|
|
|
return NULL;
|
|
|
|
default:
|
|
|
|
break;
|
2007-06-13 16:19:37 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *ast_var_indications_table(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
2009-02-17 20:41:24 +00:00
|
|
|
static char ret_buf[256];
|
|
|
|
struct ast_tone_zone *tz = NULL;
|
2007-06-13 16:19:37 +00:00
|
|
|
int i;
|
2009-02-17 20:41:24 +00:00
|
|
|
struct ao2_iterator iter;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2009-02-17 20:41:24 +00:00
|
|
|
if (header_simple_table(vp, name, length, exact, var_len, write_method, -1)) {
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
2009-02-17 20:41:24 +00:00
|
|
|
}
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
i = name[*length - 1] - 1;
|
2009-02-17 20:41:24 +00:00
|
|
|
|
|
|
|
iter = ast_tone_zone_iterator_init();
|
|
|
|
|
|
|
|
while ((tz = ao2_iterator_next(&iter)) && i) {
|
|
|
|
tz = ast_tone_zone_unref(tz);
|
|
|
|
i--;
|
|
|
|
}
|
2012-01-27 18:47:16 +00:00
|
|
|
ao2_iterator_destroy(&iter);
|
2009-02-17 20:41:24 +00:00
|
|
|
|
|
|
|
if (tz == NULL) {
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
2009-02-17 20:41:24 +00:00
|
|
|
}
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
switch (vp->magic) {
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTINDINDEX:
|
2012-01-27 18:47:16 +00:00
|
|
|
ast_tone_zone_unref(tz);
|
2006-02-26 20:46:11 +00:00
|
|
|
long_ret = name[*length - 1];
|
|
|
|
return (u_char *)&long_ret;
|
|
|
|
case ASTINDCOUNTRY:
|
2009-02-17 20:41:24 +00:00
|
|
|
ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
|
2012-01-27 18:47:16 +00:00
|
|
|
ast_tone_zone_unref(tz);
|
2009-02-17 20:41:24 +00:00
|
|
|
*var_len = strlen(ret_buf);
|
|
|
|
return (u_char *) ret_buf;
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTINDALIAS:
|
2009-02-17 20:41:24 +00:00
|
|
|
/* No longer exists */
|
2012-01-27 18:47:16 +00:00
|
|
|
ast_tone_zone_unref(tz);
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
case ASTINDDESCRIPTION:
|
2009-02-17 20:41:24 +00:00
|
|
|
ast_tone_zone_lock(tz);
|
|
|
|
ast_copy_string(ret_buf, tz->description, sizeof(ret_buf));
|
|
|
|
ast_tone_zone_unlock(tz);
|
2012-01-27 18:47:16 +00:00
|
|
|
ast_tone_zone_unref(tz);
|
2009-02-17 20:41:24 +00:00
|
|
|
*var_len = strlen(ret_buf);
|
|
|
|
return (u_char *) ret_buf;
|
2006-02-26 20:46:11 +00:00
|
|
|
default:
|
2012-01-27 18:47:16 +00:00
|
|
|
ast_tone_zone_unref(tz);
|
2006-02-26 20:46:11 +00:00
|
|
|
break;
|
2007-06-13 16:19:37 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
2014-07-25 16:47:17 +00:00
|
|
|
static int countmodule(const char *mod, const char *desc, int use, const char *status,
|
|
|
|
const char *like, enum ast_module_support_level support_level)
|
2006-02-26 20:46:11 +00:00
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
return 1;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *ast_var_Modules(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_generic(vp, name, length, exact, var_len, write_method))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (vp->magic != ASTMODCOUNT)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
long_ret = ast_update_module_list(countmodule, NULL);
|
|
|
|
|
|
|
|
return (u_char *)&long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u_char *ast_var_Version(struct variable *vp, oid *name, size_t *length,
|
|
|
|
int exact, size_t *var_len, WriteMethod **write_method)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static unsigned long long_ret;
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
if (header_generic(vp, name, length, exact, var_len, write_method))
|
2006-02-26 20:46:11 +00:00
|
|
|
return NULL;
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
switch (vp->magic) {
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTVERSTRING:
|
2008-01-05 23:05:35 +00:00
|
|
|
{
|
|
|
|
const char *version = ast_get_version();
|
|
|
|
*var_len = strlen(version);
|
|
|
|
return (u_char *)version;
|
|
|
|
}
|
2006-02-26 20:46:11 +00:00
|
|
|
case ASTVERTAG:
|
2009-08-10 19:20:57 +00:00
|
|
|
sscanf(ast_get_version_num(), "%30lu", &long_ret);
|
2006-02-26 20:46:11 +00:00
|
|
|
return (u_char *)&long_ret;
|
|
|
|
default:
|
|
|
|
break;
|
2007-06-13 16:19:37 +00:00
|
|
|
}
|
|
|
|
return NULL;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int term_asterisk_mib(int majorID, int minorID, void *serverarg, void *clientarg)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
unregister_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid));
|
|
|
|
return 0;
|
2006-02-26 20:46:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void init_asterisk_mib(void)
|
|
|
|
{
|
2007-06-13 16:19:37 +00:00
|
|
|
static struct variable4 asterisk_vars[] = {
|
2006-02-26 20:46:11 +00:00
|
|
|
{ASTVERSTRING, ASN_OCTET_STR, RONLY, ast_var_Version, 2, {ASTVERSION, ASTVERSTRING}},
|
|
|
|
{ASTVERTAG, ASN_UNSIGNED, RONLY, ast_var_Version, 2, {ASTVERSION, ASTVERTAG}},
|
|
|
|
{ASTCONFUPTIME, ASN_TIMETICKS, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFUPTIME}},
|
|
|
|
{ASTCONFRELOADTIME, ASN_TIMETICKS, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFRELOADTIME}},
|
|
|
|
{ASTCONFPID, ASN_INTEGER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFPID}},
|
|
|
|
{ASTCONFSOCKET, ASN_OCTET_STR, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFSOCKET}},
|
2007-12-07 16:11:05 +00:00
|
|
|
{ASTCONFACTIVECALLS, ASN_GAUGE, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFACTIVECALLS}},
|
2008-03-03 18:08:05 +00:00
|
|
|
{ASTCONFPROCESSEDCALLS, ASN_COUNTER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFPROCESSEDCALLS}},
|
2006-02-26 20:46:11 +00:00
|
|
|
{ASTMODCOUNT, ASN_INTEGER, RONLY, ast_var_Modules , 2, {ASTMODULES, ASTMODCOUNT}},
|
|
|
|
{ASTINDCOUNT, ASN_INTEGER, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCOUNT}},
|
|
|
|
{ASTINDCURRENT, ASN_OCTET_STR, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCURRENT}},
|
|
|
|
{ASTINDINDEX, ASN_INTEGER, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDINDEX}},
|
|
|
|
{ASTINDCOUNTRY, ASN_OCTET_STR, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDCOUNTRY}},
|
|
|
|
{ASTINDALIAS, ASN_OCTET_STR, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDALIAS}},
|
|
|
|
{ASTINDDESCRIPTION, ASN_OCTET_STR, RONLY, ast_var_indications_table, 4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDDESCRIPTION}},
|
2008-03-03 18:08:05 +00:00
|
|
|
{ASTCHANCOUNT, ASN_GAUGE, RONLY, ast_var_channels, 2, {ASTCHANNELS, ASTCHANCOUNT}},
|
2006-02-26 20:46:11 +00:00
|
|
|
{ASTCHANINDEX, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANINDEX}},
|
|
|
|
{ASTCHANNAME, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANNAME}},
|
|
|
|
{ASTCHANLANGUAGE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANLANGUAGE}},
|
|
|
|
{ASTCHANTYPE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTYPE}},
|
|
|
|
{ASTCHANMUSICCLASS, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUSICCLASS}},
|
|
|
|
{ASTCHANBRIDGE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANBRIDGE}},
|
|
|
|
{ASTCHANMASQ, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQ}},
|
|
|
|
{ASTCHANMASQR, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQR}},
|
|
|
|
{ASTCHANWHENHANGUP, ASN_TIMETICKS, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANWHENHANGUP}},
|
|
|
|
{ASTCHANAPP, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAPP}},
|
|
|
|
{ASTCHANDATA, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANDATA}},
|
|
|
|
{ASTCHANCONTEXT, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCONTEXT}},
|
|
|
|
{ASTCHANMACROCONTEXT, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROCONTEXT}},
|
|
|
|
{ASTCHANMACROEXTEN, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROEXTEN}},
|
|
|
|
{ASTCHANMACROPRI, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROPRI}},
|
|
|
|
{ASTCHANEXTEN, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANEXTEN}},
|
|
|
|
{ASTCHANPRI, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPRI}},
|
|
|
|
{ASTCHANACCOUNTCODE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANACCOUNTCODE}},
|
|
|
|
{ASTCHANFORWARDTO, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFORWARDTO}},
|
|
|
|
{ASTCHANUNIQUEID, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANUNIQUEID}},
|
|
|
|
{ASTCHANCALLGROUP, ASN_UNSIGNED, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCALLGROUP}},
|
|
|
|
{ASTCHANPICKUPGROUP, ASN_UNSIGNED, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPICKUPGROUP}},
|
|
|
|
{ASTCHANSTATE, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANSTATE}},
|
|
|
|
{ASTCHANMUTED, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUTED}},
|
|
|
|
{ASTCHANRINGS, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANRINGS}},
|
|
|
|
{ASTCHANCIDDNID, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDDNID}},
|
|
|
|
{ASTCHANCIDNUM, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNUM}},
|
|
|
|
{ASTCHANCIDNAME, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNAME}},
|
|
|
|
{ASTCHANCIDANI, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI}},
|
|
|
|
{ASTCHANCIDRDNIS, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDRDNIS}},
|
|
|
|
{ASTCHANCIDPRES, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDPRES}},
|
|
|
|
{ASTCHANCIDANI2, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI2}},
|
|
|
|
{ASTCHANCIDTON, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTON}},
|
|
|
|
{ASTCHANCIDTNS, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTNS}},
|
|
|
|
{ASTCHANAMAFLAGS, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAMAFLAGS}},
|
|
|
|
{ASTCHANADSI, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANADSI}},
|
|
|
|
{ASTCHANTONEZONE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTONEZONE}},
|
|
|
|
{ASTCHANHANGUPCAUSE, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANHANGUPCAUSE}},
|
|
|
|
{ASTCHANVARIABLES, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANVARIABLES}},
|
|
|
|
{ASTCHANFLAGS, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFLAGS}},
|
|
|
|
{ASTCHANTRANSFERCAP, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTRANSFERCAP}},
|
|
|
|
{ASTCHANTYPECOUNT, ASN_INTEGER, RONLY, ast_var_channel_types, 2, {ASTCHANNELS, ASTCHANTYPECOUNT}},
|
|
|
|
{ASTCHANTYPEINDEX, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDEX}},
|
|
|
|
{ASTCHANTYPENAME, ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPENAME}},
|
|
|
|
{ASTCHANTYPEDESC, ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDESC}},
|
|
|
|
{ASTCHANTYPEDEVSTATE, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDEVSTATE}},
|
|
|
|
{ASTCHANTYPEINDICATIONS, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDICATIONS}},
|
|
|
|
{ASTCHANTYPETRANSFER, ASN_INTEGER, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPETRANSFER}},
|
|
|
|
{ASTCHANTYPECHANNELS, ASN_GAUGE, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPECHANNELS}},
|
2007-08-23 17:27:07 +00:00
|
|
|
{ASTCHANBRIDGECOUNT, ASN_GAUGE, RONLY, ast_var_channel_bridge, 3, {ASTCHANNELS, ASTCHANSCALARS, ASTCHANBRIDGECOUNT}},
|
2007-06-13 16:19:37 +00:00
|
|
|
};
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
register_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid),
|
2006-02-26 20:46:11 +00:00
|
|
|
"ASTERISK-MIB implementation for Asterisk.");
|
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
REGISTER_MIB("res_snmp", asterisk_vars, variable4, asterisk_oid);
|
2006-02-26 20:46:11 +00:00
|
|
|
|
2007-06-13 16:19:37 +00:00
|
|
|
snmp_register_callback(SNMP_CALLBACK_LIBRARY,
|
2006-02-26 20:46:11 +00:00
|
|
|
SNMP_CALLBACK_SHUTDOWN,
|
|
|
|
term_asterisk_mib, NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Local Variables:
|
|
|
|
* c-basic-offset: 4
|
|
|
|
* c-file-offsets: ((case-label . 0))
|
|
|
|
* tab-width: 4
|
|
|
|
* indent-tabs-mode: t
|
|
|
|
* End:
|
|
|
|
*/
|