Fri Nov 12 11:47:47 2010

Asterisk developer's documentation


agent.c File Reference

SNMP Agent / SubAgent support for Asterisk. More...

#include "asterisk.h"
#include <net-snmp/net-snmp-config.h>
#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include "asterisk/paths.h"
#include "asterisk/channel.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/indications.h"
#include "asterisk/ast_version.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"
#include "agent.h"
Include dependency graph for agent.c:

Go to the source code of this file.

Defines

#define ASTCHANACCOUNTCODE   18
#define ASTCHANADSI   36
#define ASTCHANAMAFLAGS   35
#define ASTCHANAPP   10
#define ASTCHANBRIDGE   6
#define ASTCHANBRIDGECOUNT   1
#define ASTCHANCALLGROUP   21
#define ASTCHANCIDANI   29
#define ASTCHANCIDANI2   32
#define ASTCHANCIDDNID   26
#define ASTCHANCIDNAME   28
#define ASTCHANCIDNUM   27
#define ASTCHANCIDPRES   31
#define ASTCHANCIDRDNIS   30
#define ASTCHANCIDTNS   34
#define ASTCHANCIDTON   33
#define ASTCHANCONTEXT   12
#define ASTCHANCOUNT   1
#define ASTCHANDATA   11
#define ASTCHANEXTEN   16
#define ASTCHANFLAGS   40
#define ASTCHANFORWARDTO   19
#define ASTCHANHANGUPCAUSE   38
#define ASTCHANINDEX   1
#define ASTCHANLANGUAGE   3
#define ASTCHANMACROCONTEXT   13
#define ASTCHANMACROEXTEN   14
#define ASTCHANMACROPRI   15
#define ASTCHANMASQ   7
#define ASTCHANMASQR   8
#define ASTCHANMUSICCLASS   5
#define ASTCHANMUTED   24
#define ASTCHANNAME   2
#define ASTCHANNELS   5
#define ASTCHANPICKUPGROUP   22
#define ASTCHANPRI   17
#define ASTCHANRINGS   25
#define ASTCHANSCALARS   5
#define ASTCHANSTATE   23
#define ASTCHANTABLE   2
#define ASTCHANTONEZONE   37
#define ASTCHANTRANSFERCAP   41
#define ASTCHANTYPE   4
#define ASTCHANTYPECHANNELS   7
#define ASTCHANTYPECOUNT   3
#define ASTCHANTYPEDESC   3
#define ASTCHANTYPEDEVSTATE   4
#define ASTCHANTYPEINDEX   1
#define ASTCHANTYPEINDICATIONS   5
#define ASTCHANTYPENAME   2
#define ASTCHANTYPETABLE   4
#define ASTCHANTYPETRANSFER   6
#define ASTCHANUNIQUEID   20
#define ASTCHANVARIABLES   39
#define ASTCHANWHENHANGUP   9
#define ASTCONFACTIVECALLS   5
#define ASTCONFIGURATION   2
#define ASTCONFPID   3
#define ASTCONFPROCESSEDCALLS   6
#define ASTCONFRELOADTIME   2
#define ASTCONFSOCKET   4
#define ASTCONFUPTIME   1
#define ASTINDALIAS   3
#define ASTINDCOUNT   1
#define ASTINDCOUNTRY   2
#define ASTINDCURRENT   2
#define ASTINDDESCRIPTION   4
#define ASTINDICATIONS   4
#define ASTINDINDEX   1
#define ASTINDTABLE   3
#define ASTMODCOUNT   1
#define ASTMODULES   3
#define ASTVERSION   1
#define ASTVERSTRING   1
#define ASTVERTAG   2
#define HAVE_DMALLOC_H   0
#define unload_module   ast_unload_module

Functions

void * agent_thread (void *arg)
static u_char * ast_var_channel_bridge (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static u_char * ast_var_channel_types (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
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)
static u_char * ast_var_channels (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static u_char * ast_var_channels_table (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static u_char * ast_var_Config (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static u_char * ast_var_indications (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static u_char * ast_var_indications_table (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static u_char * ast_var_Modules (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static u_char * ast_var_Version (struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
static int countmodule (const char *mod, const char *desc, int use, const char *like)
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)
static void init_asterisk_mib (void)
int register_sysORTable (oid *, size_t, const char *)
static int term_asterisk_mib (int majorID, int minorID, void *serverarg, void *clientarg)
int unregister_sysORTable (oid *, size_t)

Variables

static oid asterisk_oid [] = { 1, 3, 6, 1, 4, 1, 22736, 1 }

Detailed Description

SNMP Agent / SubAgent support for Asterisk.

Author:
Thorsten Lockert <tholo@voop.as>

Definition in file agent.c.


Define Documentation

#define ASTCHANACCOUNTCODE   18

Definition at line 142 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANADSI   36

Definition at line 160 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANAMAFLAGS   35

Definition at line 159 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANAPP   10

Definition at line 134 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANBRIDGE   6

Definition at line 130 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANBRIDGECOUNT   1

Definition at line 179 of file agent.c.

Referenced by ast_var_channel_bridge(), and init_asterisk_mib().

#define ASTCHANCALLGROUP   21

Definition at line 145 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDANI   29

Definition at line 153 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDANI2   32

Definition at line 156 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDDNID   26

Definition at line 150 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDNAME   28

Definition at line 152 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDNUM   27

Definition at line 151 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDPRES   31

Definition at line 155 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDRDNIS   30

Definition at line 154 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDTNS   34

Definition at line 158 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCIDTON   33

Definition at line 157 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCONTEXT   12

Definition at line 136 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANCOUNT   1

Definition at line 122 of file agent.c.

Referenced by ast_var_channels(), and init_asterisk_mib().

#define ASTCHANDATA   11

Definition at line 135 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANEXTEN   16

Definition at line 140 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANFLAGS   40

Definition at line 164 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANFORWARDTO   19

Definition at line 143 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANHANGUPCAUSE   38

Definition at line 162 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANINDEX   1

Definition at line 125 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANLANGUAGE   3

Definition at line 127 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANMACROCONTEXT   13

Definition at line 137 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANMACROEXTEN   14

Definition at line 138 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANMACROPRI   15

Definition at line 139 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANMASQ   7

Definition at line 131 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANMASQR   8

Definition at line 132 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANMUSICCLASS   5

Definition at line 129 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANMUTED   24

Definition at line 148 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANNAME   2

Definition at line 126 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANNELS   5

Definition at line 121 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTCHANPICKUPGROUP   22

Definition at line 146 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANPRI   17

Definition at line 141 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANRINGS   25

Definition at line 149 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANSCALARS   5

Definition at line 178 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTCHANSTATE   23

Definition at line 147 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANTABLE   2

Definition at line 124 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTCHANTONEZONE   37

Definition at line 161 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANTRANSFERCAP   41

Definition at line 165 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANTYPE   4

Definition at line 128 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANTYPECHANNELS   7

Definition at line 176 of file agent.c.

Referenced by ast_var_channel_types_table(), and init_asterisk_mib().

#define ASTCHANTYPECOUNT   3

Definition at line 167 of file agent.c.

Referenced by ast_var_channel_types(), and init_asterisk_mib().

#define ASTCHANTYPEDESC   3

Definition at line 172 of file agent.c.

Referenced by ast_var_channel_types_table(), and init_asterisk_mib().

#define ASTCHANTYPEDEVSTATE   4

Definition at line 173 of file agent.c.

Referenced by ast_var_channel_types_table(), and init_asterisk_mib().

#define ASTCHANTYPEINDEX   1

Definition at line 170 of file agent.c.

Referenced by ast_var_channel_types_table(), and init_asterisk_mib().

#define ASTCHANTYPEINDICATIONS   5

Definition at line 174 of file agent.c.

Referenced by ast_var_channel_types_table(), and init_asterisk_mib().

#define ASTCHANTYPENAME   2

Definition at line 171 of file agent.c.

Referenced by ast_var_channel_types_table(), and init_asterisk_mib().

#define ASTCHANTYPETABLE   4

Definition at line 169 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTCHANTYPETRANSFER   6

Definition at line 175 of file agent.c.

Referenced by ast_var_channel_types_table(), and init_asterisk_mib().

#define ASTCHANUNIQUEID   20

Definition at line 144 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANVARIABLES   39

Definition at line 163 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCHANWHENHANGUP   9

Definition at line 133 of file agent.c.

Referenced by ast_var_channels_table(), and init_asterisk_mib().

#define ASTCONFACTIVECALLS   5

Definition at line 105 of file agent.c.

Referenced by ast_var_Config(), and init_asterisk_mib().

#define ASTCONFIGURATION   2

Definition at line 100 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTCONFPID   3

Definition at line 103 of file agent.c.

Referenced by ast_var_Config(), and init_asterisk_mib().

#define ASTCONFPROCESSEDCALLS   6

Definition at line 106 of file agent.c.

Referenced by ast_var_Config(), and init_asterisk_mib().

#define ASTCONFRELOADTIME   2

Definition at line 102 of file agent.c.

Referenced by ast_var_Config(), and init_asterisk_mib().

#define ASTCONFSOCKET   4

Definition at line 104 of file agent.c.

Referenced by ast_var_Config(), and init_asterisk_mib().

#define ASTCONFUPTIME   1

Definition at line 101 of file agent.c.

Referenced by ast_var_Config(), and init_asterisk_mib().

#define ASTINDALIAS   3

Definition at line 118 of file agent.c.

Referenced by ast_var_indications_table(), and init_asterisk_mib().

#define ASTINDCOUNT   1

Definition at line 112 of file agent.c.

Referenced by ast_var_indications(), and init_asterisk_mib().

#define ASTINDCOUNTRY   2

Definition at line 117 of file agent.c.

Referenced by ast_var_indications_table(), and init_asterisk_mib().

#define ASTINDCURRENT   2

Definition at line 113 of file agent.c.

Referenced by ast_var_indications(), and init_asterisk_mib().

#define ASTINDDESCRIPTION   4

Definition at line 119 of file agent.c.

Referenced by ast_var_indications_table(), and init_asterisk_mib().

#define ASTINDICATIONS   4

Definition at line 111 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTINDINDEX   1

Definition at line 116 of file agent.c.

Referenced by ast_var_indications_table(), and init_asterisk_mib().

#define ASTINDTABLE   3

Definition at line 115 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTMODCOUNT   1

Definition at line 109 of file agent.c.

Referenced by ast_var_Modules(), and init_asterisk_mib().

#define ASTMODULES   3

Definition at line 108 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTVERSION   1

Definition at line 96 of file agent.c.

Referenced by init_asterisk_mib().

#define ASTVERSTRING   1

Definition at line 97 of file agent.c.

Referenced by ast_var_Version(), and init_asterisk_mib().

#define ASTVERTAG   2

Definition at line 98 of file agent.c.

Referenced by ast_var_Version(), and init_asterisk_mib().

#define HAVE_DMALLOC_H   0

Definition at line 47 of file agent.c.

#define unload_module   ast_unload_module

Definition at line 71 of file agent.c.

Referenced by config_module(), and load_module().


Function Documentation

void* agent_thread ( void *  arg  ) 

Definition at line 181 of file agent.c.

References ast_verb, init_asterisk_mib(), res_snmp_agentx_subagent, and res_snmp_dont_stop.

Referenced by load_module().

00182 {
00183    ast_verb(2, "Starting %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
00184 
00185    snmp_enable_stderrlog();
00186 
00187    if (res_snmp_agentx_subagent)
00188       netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
00189                         NETSNMP_DS_AGENT_ROLE,
00190                         1);
00191 
00192    init_agent("asterisk");
00193 
00194    init_asterisk_mib();
00195 
00196    init_snmp("asterisk");
00197 
00198    if (!res_snmp_agentx_subagent)
00199       init_master_agent();
00200 
00201    while (res_snmp_dont_stop)
00202       agent_check_and_process(1);
00203 
00204    snmp_shutdown("asterisk");
00205 
00206    ast_verb(2, "Terminating %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
00207 
00208    return NULL;
00209 }

static u_char* ast_var_channel_bridge ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 583 of file agent.c.

References ast_bridged_channel(), ast_channel_unlock, ast_channel_walk_locked(), ASTCHANBRIDGECOUNT, chan, and header_generic().

Referenced by init_asterisk_mib().

00585 {
00586    static unsigned long long_ret;
00587    struct ast_channel *chan = NULL;
00588 
00589    long_ret = 0;
00590    if (header_generic(vp, name, length, exact, var_len, write_method))
00591       return NULL;
00592 
00593    while ((chan = ast_channel_walk_locked(chan))) {
00594       if (ast_bridged_channel(chan))
00595          long_ret++;
00596       ast_channel_unlock(chan);
00597    }
00598 
00599    *var_len = sizeof(long_ret);
00600 
00601    return (vp->magic == ASTCHANBRIDGECOUNT) ? (u_char *) &long_ret : NULL;
00602 }

static u_char* ast_var_channel_types ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 510 of file agent.c.

References ast_channeltype_list(), ast_variables_destroy(), ASTCHANTYPECOUNT, header_generic(), and ast_variable::next.

Referenced by init_asterisk_mib().

00512 {
00513    static unsigned long long_ret;
00514    struct ast_variable *channel_types, *next;
00515 
00516    if (header_generic(vp, name, length, exact, var_len, write_method))
00517       return NULL;
00518 
00519    if (vp->magic != ASTCHANTYPECOUNT)
00520       return NULL;
00521 
00522    for (long_ret = 0, channel_types = next = ast_channeltype_list(); next; next = next->next)
00523       long_ret++;
00524    ast_variables_destroy(channel_types);
00525 
00526    return (u_char *)&long_ret;
00527 }

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 
) [static]

Definition at line 529 of file agent.c.

References ast_channel_unlock, ast_channel_walk_locked(), ast_channeltype_list(), ast_get_channel_tech(), ast_variables_destroy(), ASTCHANTYPECHANNELS, ASTCHANTYPEDESC, ASTCHANTYPEDEVSTATE, ASTCHANTYPEINDEX, ASTCHANTYPEINDICATIONS, ASTCHANTYPENAME, ASTCHANTYPETRANSFER, chan, ast_channel_tech::description, ast_channel_tech::devicestate, header_simple_table(), ast_channel_tech::indicate, ast_variable::name, ast_variable::next, ast_channel::tech, ast_channel_tech::transfer, and ast_channel_tech::type.

Referenced by init_asterisk_mib().

00531 {
00532    const struct ast_channel_tech *tech = NULL;
00533    struct ast_variable *channel_types, *next;
00534    static unsigned long long_ret;
00535    struct ast_channel *chan;
00536    u_long i;
00537 
00538    if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
00539       return NULL;
00540 
00541    channel_types = ast_channeltype_list();
00542    for (i = 1, next = channel_types; next && i != name[*length - 1]; next = next->next, i++)
00543       ;
00544    if (next != NULL)
00545       tech = ast_get_channel_tech(next->name);
00546    ast_variables_destroy(channel_types);
00547    if (next == NULL || tech == NULL)
00548       return NULL;
00549    
00550    switch (vp->magic) {
00551    case ASTCHANTYPEINDEX:
00552       long_ret = name[*length - 1];
00553       return (u_char *)&long_ret;
00554    case ASTCHANTYPENAME:
00555       *var_len = strlen(tech->type);
00556       return (u_char *)tech->type;
00557    case ASTCHANTYPEDESC:
00558       *var_len = strlen(tech->description);
00559       return (u_char *)tech->description;
00560    case ASTCHANTYPEDEVSTATE:
00561       long_ret = tech->devicestate ? 1 : 2;
00562       return (u_char *)&long_ret;
00563    case ASTCHANTYPEINDICATIONS:
00564       long_ret = tech->indicate ? 1 : 2;
00565       return (u_char *)&long_ret;
00566    case ASTCHANTYPETRANSFER:
00567       long_ret = tech->transfer ? 1 : 2;
00568       return (u_char *)&long_ret;
00569    case ASTCHANTYPECHANNELS:
00570       long_ret = 0;
00571       for (chan = ast_channel_walk_locked(NULL); chan; chan = ast_channel_walk_locked(chan)) {
00572          if (chan->tech == tech)
00573             long_ret++;
00574          ast_channel_unlock(chan);
00575       }
00576       return (u_char *)&long_ret;
00577    default:
00578       break;
00579    }
00580    return NULL;
00581 }

static u_char* ast_var_channels ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 212 of file agent.c.

References ast_active_channels(), ASTCHANCOUNT, and header_generic().

Referenced by init_asterisk_mib().

00214 {
00215    static unsigned long long_ret;
00216 
00217    if (header_generic(vp, name, length, exact, var_len, write_method))
00218       return NULL;
00219 
00220    if (vp->magic != ASTCHANCOUNT)
00221       return NULL;
00222 
00223    long_ret = ast_active_channels();
00224 
00225    return (u_char *)&long_ret;
00226 }

static u_char* ast_var_channels_table ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 228 of file agent.c.

References ast_channel::_state, ast_channel::accountcode, ast_channel::adsicpe, ast_channel::amaflags, ast_channel::appl, ast_active_channels(), ast_bridged_channel(), ast_channel_unlock, ast_channel_walk_locked(), AST_STATE_MUTE, ast_str_alloca, ast_str_buffer(), ast_str_strlen(), ast_strlen_zero(), ast_tvzero(), ASTCHANACCOUNTCODE, ASTCHANADSI, ASTCHANAMAFLAGS, ASTCHANAPP, ASTCHANBRIDGE, ASTCHANCALLGROUP, ASTCHANCIDANI, ASTCHANCIDANI2, ASTCHANCIDDNID, ASTCHANCIDNAME, ASTCHANCIDNUM, ASTCHANCIDPRES, ASTCHANCIDRDNIS, ASTCHANCIDTNS, ASTCHANCIDTON, ASTCHANCONTEXT, ASTCHANDATA, ASTCHANEXTEN, ASTCHANFLAGS, ASTCHANFORWARDTO, ASTCHANHANGUPCAUSE, ASTCHANINDEX, ASTCHANLANGUAGE, ASTCHANMACROCONTEXT, ASTCHANMACROEXTEN, ASTCHANMACROPRI, ASTCHANMASQ, ASTCHANMASQR, ASTCHANMUSICCLASS, ASTCHANMUTED, ASTCHANNAME, ASTCHANPICKUPGROUP, ASTCHANPRI, ASTCHANRINGS, ASTCHANSTATE, ASTCHANTONEZONE, ASTCHANTRANSFERCAP, ASTCHANTYPE, ASTCHANUNIQUEID, ASTCHANVARIABLES, ASTCHANWHENHANGUP, ast_channel::bridge, ast_channel::call_forward, ast_channel::callgroup, chan, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_ani2, ast_callerid::cid_dnid, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_pres, ast_callerid::cid_rdnis, ast_callerid::cid_tns, ast_callerid::cid_ton, ast_channel::context, ast_tone_zone::country, ast_channel::data, ast_channel::exten, ast_channel::flags, ast_channel::hangupcause, header_simple_table(), ast_channel::language, ast_channel::macrocontext, ast_channel::macroexten, ast_channel::macropriority, ast_channel::masq, ast_channel::masqr, ast_channel::musicclass, ast_channel::name, pbx_builtin_serialize_variables(), ast_channel::pickupgroup, ast_channel::priority, ast_channel::rings, ast_channel::tech, ast_channel::transfercapability, ast_channel_tech::type, ast_channel::uniqueid, ast_channel::whentohangup, and ast_channel::zone.

Referenced by init_asterisk_mib().

00230 {
00231    static unsigned long long_ret;
00232    static u_char bits_ret[2];
00233    static char string_ret[256];
00234    struct ast_channel *chan, *bridge;
00235    struct timeval tval;
00236    u_char *ret = NULL;
00237    int i, bit;
00238    struct ast_str *out = ast_str_alloca(2048);
00239 
00240    if (header_simple_table(vp, name, length, exact, var_len, write_method, ast_active_channels()))
00241       return NULL;
00242 
00243    i = name[*length - 1] - 1;
00244    for (chan = ast_channel_walk_locked(NULL);
00245        chan && i;
00246        chan = ast_channel_walk_locked(chan), i--)
00247       ast_channel_unlock(chan);
00248    if (chan == NULL)
00249       return NULL;
00250    *var_len = sizeof(long_ret);
00251 
00252    switch (vp->magic) {
00253    case ASTCHANINDEX:
00254       long_ret = name[*length - 1];
00255       ret = (u_char *)&long_ret;
00256       break;
00257    case ASTCHANNAME:
00258       if (!ast_strlen_zero(chan->name)) {
00259          strncpy(string_ret, chan->name, sizeof(string_ret));
00260          string_ret[sizeof(string_ret) - 1] = '\0';
00261          *var_len = strlen(string_ret);
00262          ret = (u_char *)string_ret;
00263       }
00264       break;
00265    case ASTCHANLANGUAGE:
00266       if (!ast_strlen_zero(chan->language)) {
00267          strncpy(string_ret, chan->language, sizeof(string_ret));
00268          string_ret[sizeof(string_ret) - 1] = '\0';
00269          *var_len = strlen(string_ret);
00270          ret = (u_char *)string_ret;
00271       }
00272       break;
00273    case ASTCHANTYPE:
00274       strncpy(string_ret, chan->tech->type, sizeof(string_ret));
00275       string_ret[sizeof(string_ret) - 1] = '\0';
00276       *var_len = strlen(string_ret);
00277       ret = (u_char *)string_ret;
00278       break;
00279    case ASTCHANMUSICCLASS:
00280       if (!ast_strlen_zero(chan->musicclass)) {
00281          strncpy(string_ret, chan->musicclass, sizeof(string_ret));
00282          string_ret[sizeof(string_ret) - 1] = '\0';
00283          *var_len = strlen(string_ret);
00284          ret = (u_char *)string_ret;
00285       }
00286       break;
00287    case ASTCHANBRIDGE:
00288       if ((bridge = ast_bridged_channel(chan)) != NULL) {
00289          strncpy(string_ret, bridge->name, sizeof(string_ret));
00290          string_ret[sizeof(string_ret) - 1] = '\0';
00291          *var_len = strlen(string_ret);
00292          ret = (u_char *)string_ret;
00293       }
00294       break;
00295    case ASTCHANMASQ:
00296       if (chan->masq && !ast_strlen_zero(chan->masq->name)) {
00297          strncpy(string_ret, chan->masq->name, sizeof(string_ret));
00298          string_ret[sizeof(string_ret) - 1] = '\0';
00299          *var_len = strlen(string_ret);
00300          ret = (u_char *)string_ret;
00301       }
00302       break;
00303    case ASTCHANMASQR:
00304       if (chan->masqr && !ast_strlen_zero(chan->masqr->name)) {
00305          strncpy(string_ret, chan->masqr->name, sizeof(string_ret));
00306          string_ret[sizeof(string_ret) - 1] = '\0';
00307          *var_len = strlen(string_ret);
00308          ret = (u_char *)string_ret;
00309       }
00310       break;
00311    case ASTCHANWHENHANGUP:
00312       if (!ast_tvzero(chan->whentohangup)) {
00313          gettimeofday(&tval, NULL);
00314          long_ret = difftime(chan->whentohangup.tv_sec, tval.tv_sec) * 100 - tval.tv_usec / 10000;
00315          ret= (u_char *)&long_ret;
00316       }
00317       break;
00318    case ASTCHANAPP:
00319       if (chan->appl) {
00320          strncpy(string_ret, chan->appl, sizeof(string_ret));
00321          string_ret[sizeof(string_ret) - 1] = '\0';
00322          *var_len = strlen(string_ret);
00323          ret = (u_char *)string_ret;
00324       }
00325       break;
00326    case ASTCHANDATA:
00327       if (chan->data) {
00328          strncpy(string_ret, chan->data, sizeof(string_ret));
00329          string_ret[sizeof(string_ret) - 1] = '\0';
00330          *var_len = strlen(string_ret);
00331          ret = (u_char *)string_ret;
00332       }
00333       break;
00334    case ASTCHANCONTEXT:
00335       strncpy(string_ret, chan->context, sizeof(string_ret));
00336       string_ret[sizeof(string_ret) - 1] = '\0';
00337       *var_len = strlen(string_ret);
00338       ret = (u_char *)string_ret;
00339       break;
00340    case ASTCHANMACROCONTEXT:
00341       strncpy(string_ret, chan->macrocontext, sizeof(string_ret));
00342       string_ret[sizeof(string_ret) - 1] = '\0';
00343       *var_len = strlen(string_ret);
00344       ret = (u_char *)string_ret;
00345       break;
00346    case ASTCHANMACROEXTEN:
00347       strncpy(string_ret, chan->macroexten, sizeof(string_ret));
00348       string_ret[sizeof(string_ret) - 1] = '\0';
00349       *var_len = strlen(string_ret);
00350       ret = (u_char *)string_ret;
00351       break;
00352    case ASTCHANMACROPRI:
00353       long_ret = chan->macropriority;
00354       ret = (u_char *)&long_ret;
00355       break;
00356    case ASTCHANEXTEN:
00357       strncpy(string_ret, chan->exten, sizeof(string_ret));
00358       string_ret[sizeof(string_ret) - 1] = '\0';
00359       *var_len = strlen(string_ret);
00360       ret = (u_char *)string_ret;
00361       break;
00362    case ASTCHANPRI:
00363       long_ret = chan->priority;
00364       ret = (u_char *)&long_ret;
00365       break;
00366    case ASTCHANACCOUNTCODE:
00367       if (!ast_strlen_zero(chan->accountcode)) {
00368          strncpy(string_ret, chan->accountcode, sizeof(string_ret));
00369          string_ret[sizeof(string_ret) - 1] = '\0';
00370          *var_len = strlen(string_ret);
00371          ret = (u_char *)string_ret;
00372       }
00373       break;
00374    case ASTCHANFORWARDTO:
00375       if (!ast_strlen_zero(chan->call_forward)) {
00376          strncpy(string_ret, chan->call_forward, sizeof(string_ret));
00377          string_ret[sizeof(string_ret) - 1] = '\0';
00378          *var_len = strlen(string_ret);
00379          ret = (u_char *)string_ret;
00380       }
00381       break;
00382    case ASTCHANUNIQUEID:
00383       strncpy(string_ret, chan->uniqueid, sizeof(string_ret));
00384       string_ret[sizeof(string_ret) - 1] = '\0';
00385       *var_len = strlen(string_ret);
00386       ret = (u_char *)string_ret;
00387       break;
00388    case ASTCHANCALLGROUP:
00389       long_ret = chan->callgroup;
00390       ret = (u_char *)&long_ret;
00391       break;
00392    case ASTCHANPICKUPGROUP:
00393       long_ret = chan->pickupgroup;
00394       ret = (u_char *)&long_ret;
00395       break;
00396    case ASTCHANSTATE:
00397       long_ret = chan->_state & 0xffff;
00398       ret = (u_char *)&long_ret;
00399       break;
00400    case ASTCHANMUTED:
00401       long_ret = chan->_state & AST_STATE_MUTE ? 1 : 2;
00402       ret = (u_char *)&long_ret;
00403       break;
00404    case ASTCHANRINGS:
00405       long_ret = chan->rings;
00406       ret = (u_char *)&long_ret;
00407       break;
00408    case ASTCHANCIDDNID:
00409       if (chan->cid.cid_dnid) {
00410          strncpy(string_ret, chan->cid.cid_dnid, sizeof(string_ret));
00411          string_ret[sizeof(string_ret) - 1] = '\0';
00412          *var_len = strlen(string_ret);
00413          ret = (u_char *)string_ret;
00414       }
00415       break;
00416    case ASTCHANCIDNUM:
00417       if (chan->cid.cid_num) {
00418          strncpy(string_ret, chan->cid.cid_num, sizeof(string_ret));
00419          string_ret[sizeof(string_ret) - 1] = '\0';
00420          *var_len = strlen(string_ret);
00421          ret = (u_char *)string_ret;
00422       }
00423       break;
00424    case ASTCHANCIDNAME:
00425       if (chan->cid.cid_name) {
00426          strncpy(string_ret, chan->cid.cid_name, sizeof(string_ret));
00427          string_ret[sizeof(string_ret) - 1] = '\0';
00428          *var_len = strlen(string_ret);
00429          ret = (u_char *)string_ret;
00430       }
00431       break;
00432    case ASTCHANCIDANI:
00433       if (chan->cid.cid_ani) {
00434          strncpy(string_ret, chan->cid.cid_ani, sizeof(string_ret));
00435          string_ret[sizeof(string_ret) - 1] = '\0';
00436          *var_len = strlen(string_ret);
00437          ret = (u_char *)string_ret;
00438       }
00439       break;
00440    case ASTCHANCIDRDNIS:
00441       if (chan->cid.cid_rdnis) {
00442          strncpy(string_ret, chan->cid.cid_rdnis, sizeof(string_ret));
00443          string_ret[sizeof(string_ret) - 1] = '\0';
00444          *var_len = strlen(string_ret);
00445          ret = (u_char *)string_ret;
00446       }
00447       break;
00448    case ASTCHANCIDPRES:
00449       long_ret = chan->cid.cid_pres;
00450       ret = (u_char *)&long_ret;
00451       break;
00452    case ASTCHANCIDANI2:
00453       long_ret = chan->cid.cid_ani2;
00454       ret = (u_char *)&long_ret;
00455       break;
00456    case ASTCHANCIDTON:
00457       long_ret = chan->cid.cid_ton;
00458       ret = (u_char *)&long_ret;
00459       break;
00460    case ASTCHANCIDTNS:
00461       long_ret = chan->cid.cid_tns;
00462       ret = (u_char *)&long_ret;
00463       break;
00464    case ASTCHANAMAFLAGS:
00465       long_ret = chan->amaflags;
00466       ret = (u_char *)&long_ret;
00467       break;
00468    case ASTCHANADSI:
00469       long_ret = chan->adsicpe;
00470       ret = (u_char *)&long_ret;
00471       break;
00472    case ASTCHANTONEZONE:
00473       if (chan->zone) {
00474          strncpy(string_ret, chan->zone->country, sizeof(string_ret));
00475          string_ret[sizeof(string_ret) - 1] = '\0';
00476          *var_len = strlen(string_ret);
00477          ret = (u_char *)string_ret;
00478       }
00479       break;
00480    case ASTCHANHANGUPCAUSE:
00481       long_ret = chan->hangupcause;
00482       ret = (u_char *)&long_ret;
00483       break;
00484    case ASTCHANVARIABLES:
00485       if (pbx_builtin_serialize_variables(chan, &out)) {
00486          *var_len = ast_str_strlen(out);
00487          ret = (u_char *)ast_str_buffer(out);
00488       }
00489       break;
00490    case ASTCHANFLAGS:
00491       bits_ret[0] = 0;
00492       for (bit = 0; bit < 8; bit++)
00493          bits_ret[0] |= ((chan->flags & (1 << bit)) >> bit) << (7 - bit);
00494       bits_ret[1] = 0;
00495       for (bit = 0; bit < 8; bit++)
00496          bits_ret[1] |= (((chan->flags >> 8) & (1 << bit)) >> bit) << (7 - bit);
00497       *var_len = 2;
00498       ret = bits_ret;
00499       break;
00500    case ASTCHANTRANSFERCAP:
00501       long_ret = chan->transfercapability;
00502       ret = (u_char *)&long_ret;
00503    default:
00504       break;
00505    }
00506    ast_channel_unlock(chan);
00507    return ret;
00508 }

static u_char* ast_var_Config ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 604 of file agent.c.

References ast_active_calls(), ast_config_AST_SOCKET, ast_lastreloadtime, ast_processed_calls(), ast_startuptime, ASTCONFACTIVECALLS, ASTCONFPID, ASTCONFPROCESSEDCALLS, ASTCONFRELOADTIME, ASTCONFSOCKET, ASTCONFUPTIME, and header_generic().

Referenced by init_asterisk_mib().

00606 {
00607    static unsigned long long_ret;
00608    struct timeval tval;
00609 
00610    if (header_generic(vp, name, length, exact, var_len, write_method))
00611       return NULL;
00612 
00613    switch (vp->magic) {
00614    case ASTCONFUPTIME:
00615       gettimeofday(&tval, NULL);
00616       long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
00617       return (u_char *)&long_ret;
00618    case ASTCONFRELOADTIME:
00619       gettimeofday(&tval, NULL);
00620       if (ast_lastreloadtime.tv_sec)
00621          long_ret = difftime(tval.tv_sec, ast_lastreloadtime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_lastreloadtime.tv_usec / 10000;
00622       else
00623          long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
00624       return (u_char *)&long_ret;
00625    case ASTCONFPID:
00626       long_ret = getpid();
00627       return (u_char *)&long_ret;
00628    case ASTCONFSOCKET:
00629       *var_len = strlen(ast_config_AST_SOCKET);
00630       return (u_char *)ast_config_AST_SOCKET;
00631    case ASTCONFACTIVECALLS:
00632       long_ret = ast_active_calls();
00633       return (u_char *)&long_ret;
00634    case ASTCONFPROCESSEDCALLS:
00635       long_ret = ast_processed_calls();
00636       return (u_char *)&long_ret;
00637    default:
00638       break;
00639    }
00640    return NULL;
00641 }

static u_char* ast_var_indications ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 643 of file agent.c.

References ao2_iterator_next, ast_copy_string(), ast_get_indication_zone(), ast_tone_zone_iterator_init(), ast_tone_zone_unref(), ASTINDCOUNT, ASTINDCURRENT, ast_tone_zone::country, and header_generic().

Referenced by init_asterisk_mib().

00645 {
00646    static unsigned long long_ret;
00647    static char ret_buf[128];
00648    struct ast_tone_zone *tz = NULL;
00649 
00650    if (header_generic(vp, name, length, exact, var_len, write_method))
00651       return NULL;
00652 
00653    switch (vp->magic) {
00654    case ASTINDCOUNT:
00655    {
00656       struct ao2_iterator i;
00657 
00658       long_ret = 0;
00659 
00660       i = ast_tone_zone_iterator_init();
00661       while ((tz = ao2_iterator_next(&i))) {
00662          tz = ast_tone_zone_unref(tz);
00663          long_ret++;
00664       }
00665 
00666       return (u_char *) &long_ret;
00667    }
00668    case ASTINDCURRENT:
00669       tz = ast_get_indication_zone(NULL);
00670       if (tz) {
00671          ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
00672          *var_len = strlen(ret_buf);
00673          tz = ast_tone_zone_unref(tz);
00674          return (u_char *) ret_buf;
00675       }
00676       *var_len = 0;
00677       return NULL;
00678    default:
00679       break;
00680    }
00681    return NULL;
00682 }

static u_char* ast_var_indications_table ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 684 of file agent.c.

References ao2_iterator_next, ast_copy_string(), ast_tone_zone_iterator_init(), ast_tone_zone_lock, ast_tone_zone_unlock, ast_tone_zone_unref(), ASTINDALIAS, ASTINDCOUNTRY, ASTINDDESCRIPTION, ASTINDINDEX, ast_tone_zone::country, ast_tone_zone::description, and header_simple_table().

Referenced by init_asterisk_mib().

00686 {
00687    static unsigned long long_ret;
00688    static char ret_buf[256];
00689    struct ast_tone_zone *tz = NULL;
00690    int i;
00691    struct ao2_iterator iter;
00692 
00693    if (header_simple_table(vp, name, length, exact, var_len, write_method, -1)) {
00694       return NULL;
00695    }
00696 
00697    i = name[*length - 1] - 1;
00698 
00699    iter = ast_tone_zone_iterator_init();
00700 
00701    while ((tz = ao2_iterator_next(&iter)) && i) {
00702       tz = ast_tone_zone_unref(tz);
00703       i--;
00704    }
00705 
00706    if (tz == NULL) {
00707       return NULL;
00708    }
00709 
00710    switch (vp->magic) {
00711    case ASTINDINDEX:
00712       long_ret = name[*length - 1];
00713       return (u_char *)&long_ret;
00714    case ASTINDCOUNTRY:
00715       ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
00716       tz = ast_tone_zone_unref(tz);
00717       *var_len = strlen(ret_buf);
00718       return (u_char *) ret_buf;
00719    case ASTINDALIAS:
00720       /* No longer exists */
00721       return NULL;
00722    case ASTINDDESCRIPTION:
00723       ast_tone_zone_lock(tz);
00724       ast_copy_string(ret_buf, tz->description, sizeof(ret_buf));
00725       ast_tone_zone_unlock(tz);
00726       tz = ast_tone_zone_unref(tz);
00727       *var_len = strlen(ret_buf);
00728       return (u_char *) ret_buf;
00729    default:
00730       break;
00731    }
00732    return NULL;
00733 }

static u_char* ast_var_Modules ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 740 of file agent.c.

References ast_update_module_list(), ASTMODCOUNT, countmodule(), and header_generic().

Referenced by init_asterisk_mib().

00742 {
00743    static unsigned long long_ret;
00744 
00745    if (header_generic(vp, name, length, exact, var_len, write_method))
00746       return NULL;
00747 
00748    if (vp->magic != ASTMODCOUNT)
00749       return NULL;
00750 
00751    long_ret = ast_update_module_list(countmodule, NULL);
00752 
00753    return (u_char *)&long_ret;
00754 }

static u_char* ast_var_Version ( struct variable *  vp,
oid *  name,
size_t *  length,
int  exact,
size_t *  var_len,
WriteMethod **  write_method 
) [static]

Definition at line 756 of file agent.c.

References ast_get_version(), ast_get_version_num(), ASTVERSTRING, ASTVERTAG, header_generic(), and version.

Referenced by init_asterisk_mib().

00758 {
00759    static unsigned long long_ret;
00760 
00761    if (header_generic(vp, name, length, exact, var_len, write_method))
00762       return NULL;
00763 
00764    switch (vp->magic) {
00765    case ASTVERSTRING:
00766    {
00767       const char *version = ast_get_version();
00768       *var_len = strlen(version);
00769       return (u_char *)version;
00770    }
00771    case ASTVERTAG:
00772       sscanf(ast_get_version_num(), "%30lu", &long_ret);
00773       return (u_char *)&long_ret;
00774    default:
00775       break;
00776    }
00777    return NULL;
00778 }

static int countmodule ( const char *  mod,
const char *  desc,
int  use,
const char *  like 
) [static]

Definition at line 735 of file agent.c.

Referenced by ast_var_Modules().

00736 {
00737    return 1;
00738 }

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   
)
static void init_asterisk_mib ( void   )  [static]

Definition at line 786 of file agent.c.

References ast_var_channel_bridge(), ast_var_channel_types(), ast_var_channel_types_table(), ast_var_channels(), ast_var_channels_table(), ast_var_Config(), ast_var_indications(), ast_var_indications_table(), ast_var_Modules(), ast_var_Version(), ASTCHANACCOUNTCODE, ASTCHANADSI, ASTCHANAMAFLAGS, ASTCHANAPP, ASTCHANBRIDGE, ASTCHANBRIDGECOUNT, ASTCHANCALLGROUP, ASTCHANCIDANI, ASTCHANCIDANI2, ASTCHANCIDDNID, ASTCHANCIDNAME, ASTCHANCIDNUM, ASTCHANCIDPRES, ASTCHANCIDRDNIS, ASTCHANCIDTNS, ASTCHANCIDTON, ASTCHANCONTEXT, ASTCHANCOUNT, ASTCHANDATA, ASTCHANEXTEN, ASTCHANFLAGS, ASTCHANFORWARDTO, ASTCHANHANGUPCAUSE, ASTCHANINDEX, ASTCHANLANGUAGE, ASTCHANMACROCONTEXT, ASTCHANMACROEXTEN, ASTCHANMACROPRI, ASTCHANMASQ, ASTCHANMASQR, ASTCHANMUSICCLASS, ASTCHANMUTED, ASTCHANNAME, ASTCHANNELS, ASTCHANPICKUPGROUP, ASTCHANPRI, ASTCHANRINGS, ASTCHANSCALARS, ASTCHANSTATE, ASTCHANTABLE, ASTCHANTONEZONE, ASTCHANTRANSFERCAP, ASTCHANTYPE, ASTCHANTYPECHANNELS, ASTCHANTYPECOUNT, ASTCHANTYPEDESC, ASTCHANTYPEDEVSTATE, ASTCHANTYPEINDEX, ASTCHANTYPEINDICATIONS, ASTCHANTYPENAME, ASTCHANTYPETABLE, ASTCHANTYPETRANSFER, ASTCHANUNIQUEID, ASTCHANVARIABLES, ASTCHANWHENHANGUP, ASTCONFACTIVECALLS, ASTCONFIGURATION, ASTCONFPID, ASTCONFPROCESSEDCALLS, ASTCONFRELOADTIME, ASTCONFSOCKET, ASTCONFUPTIME, ASTINDALIAS, ASTINDCOUNT, ASTINDCOUNTRY, ASTINDCURRENT, ASTINDDESCRIPTION, ASTINDICATIONS, ASTINDINDEX, ASTINDTABLE, ASTMODCOUNT, ASTMODULES, ASTVERSION, ASTVERSTRING, ASTVERTAG, register_sysORTable(), and term_asterisk_mib().

Referenced by agent_thread().

00787 {
00788    static struct variable4 asterisk_vars[] = {
00789       {ASTVERSTRING,           ASN_OCTET_STR, RONLY, ast_var_Version,             2, {ASTVERSION, ASTVERSTRING}},
00790       {ASTVERTAG,              ASN_UNSIGNED,  RONLY, ast_var_Version,             2, {ASTVERSION, ASTVERTAG}},
00791       {ASTCONFUPTIME,          ASN_TIMETICKS, RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFUPTIME}},
00792       {ASTCONFRELOADTIME,      ASN_TIMETICKS, RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFRELOADTIME}},
00793       {ASTCONFPID,             ASN_INTEGER,   RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFPID}},
00794       {ASTCONFSOCKET,          ASN_OCTET_STR, RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFSOCKET}},
00795       {ASTCONFACTIVECALLS,     ASN_GAUGE,    RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFACTIVECALLS}},
00796       {ASTCONFPROCESSEDCALLS,  ASN_COUNTER,   RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFPROCESSEDCALLS}},
00797       {ASTMODCOUNT,            ASN_INTEGER,   RONLY, ast_var_Modules ,            2, {ASTMODULES, ASTMODCOUNT}},
00798       {ASTINDCOUNT,            ASN_INTEGER,   RONLY, ast_var_indications,         2, {ASTINDICATIONS, ASTINDCOUNT}},
00799       {ASTINDCURRENT,          ASN_OCTET_STR, RONLY, ast_var_indications,         2, {ASTINDICATIONS, ASTINDCURRENT}},
00800       {ASTINDINDEX,            ASN_INTEGER,   RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDINDEX}},
00801       {ASTINDCOUNTRY,          ASN_OCTET_STR, RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDCOUNTRY}},
00802       {ASTINDALIAS,            ASN_OCTET_STR, RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDALIAS}},
00803       {ASTINDDESCRIPTION,      ASN_OCTET_STR, RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDDESCRIPTION}},
00804       {ASTCHANCOUNT,           ASN_GAUGE,     RONLY, ast_var_channels,            2, {ASTCHANNELS, ASTCHANCOUNT}},
00805       {ASTCHANINDEX,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANINDEX}},
00806       {ASTCHANNAME,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANNAME}},
00807       {ASTCHANLANGUAGE,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANLANGUAGE}},
00808       {ASTCHANTYPE,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTYPE}},
00809       {ASTCHANMUSICCLASS,      ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUSICCLASS}},
00810       {ASTCHANBRIDGE,          ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANBRIDGE}},
00811       {ASTCHANMASQ,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQ}},
00812       {ASTCHANMASQR,           ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQR}},
00813       {ASTCHANWHENHANGUP,      ASN_TIMETICKS, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANWHENHANGUP}},
00814       {ASTCHANAPP,             ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAPP}},
00815       {ASTCHANDATA,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANDATA}},
00816       {ASTCHANCONTEXT,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCONTEXT}},
00817       {ASTCHANMACROCONTEXT,    ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROCONTEXT}},
00818       {ASTCHANMACROEXTEN,      ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROEXTEN}},
00819       {ASTCHANMACROPRI,        ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROPRI}},
00820       {ASTCHANEXTEN,           ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANEXTEN}},
00821       {ASTCHANPRI,             ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPRI}},
00822       {ASTCHANACCOUNTCODE,     ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANACCOUNTCODE}},
00823       {ASTCHANFORWARDTO,       ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFORWARDTO}},
00824       {ASTCHANUNIQUEID,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANUNIQUEID}},
00825       {ASTCHANCALLGROUP,       ASN_UNSIGNED,  RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCALLGROUP}},
00826       {ASTCHANPICKUPGROUP,     ASN_UNSIGNED,  RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPICKUPGROUP}},
00827       {ASTCHANSTATE,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANSTATE}},
00828       {ASTCHANMUTED,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUTED}},
00829       {ASTCHANRINGS,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANRINGS}},
00830       {ASTCHANCIDDNID,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDDNID}},
00831       {ASTCHANCIDNUM,          ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNUM}},
00832       {ASTCHANCIDNAME,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNAME}},
00833       {ASTCHANCIDANI,          ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI}},
00834       {ASTCHANCIDRDNIS,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDRDNIS}},
00835       {ASTCHANCIDPRES,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDPRES}},
00836       {ASTCHANCIDANI2,         ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI2}},
00837       {ASTCHANCIDTON,          ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTON}},
00838       {ASTCHANCIDTNS,          ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTNS}},
00839       {ASTCHANAMAFLAGS,        ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAMAFLAGS}},
00840       {ASTCHANADSI,            ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANADSI}},
00841       {ASTCHANTONEZONE,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTONEZONE}},
00842       {ASTCHANHANGUPCAUSE,     ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANHANGUPCAUSE}},
00843       {ASTCHANVARIABLES,       ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANVARIABLES}},
00844       {ASTCHANFLAGS,           ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFLAGS}},
00845       {ASTCHANTRANSFERCAP,     ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTRANSFERCAP}},
00846       {ASTCHANTYPECOUNT,       ASN_INTEGER,   RONLY, ast_var_channel_types,       2, {ASTCHANNELS, ASTCHANTYPECOUNT}},
00847       {ASTCHANTYPEINDEX,       ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDEX}},
00848       {ASTCHANTYPENAME,        ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPENAME}},
00849       {ASTCHANTYPEDESC,        ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDESC}},
00850       {ASTCHANTYPEDEVSTATE,    ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDEVSTATE}},
00851       {ASTCHANTYPEINDICATIONS, ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDICATIONS}},
00852       {ASTCHANTYPETRANSFER,    ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPETRANSFER}},
00853       {ASTCHANTYPECHANNELS,    ASN_GAUGE,     RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPECHANNELS}},
00854       {ASTCHANBRIDGECOUNT,     ASN_GAUGE,     RONLY, ast_var_channel_bridge,      3, {ASTCHANNELS, ASTCHANSCALARS, ASTCHANBRIDGECOUNT}},
00855    };
00856 
00857    register_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid),
00858          "ASTERISK-MIB implementation for Asterisk.");
00859 
00860    REGISTER_MIB("res_snmp", asterisk_vars, variable4, asterisk_oid);
00861 
00862    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
00863             SNMP_CALLBACK_SHUTDOWN,
00864             term_asterisk_mib, NULL);
00865 }

int register_sysORTable ( oid *  ,
size_t  ,
const char *   
)

Referenced by init_asterisk_mib().

static int term_asterisk_mib ( int  majorID,
int  minorID,
void *  serverarg,
void *  clientarg 
) [static]

Definition at line 780 of file agent.c.

References unregister_sysORTable().

Referenced by init_asterisk_mib().

00781 {
00782    unregister_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid));
00783    return 0;
00784 }

int unregister_sysORTable ( oid *  ,
size_t   
)

Referenced by term_asterisk_mib().


Variable Documentation

oid asterisk_oid[] = { 1, 3, 6, 1, 4, 1, 22736, 1 } [static]

Definition at line 89 of file agent.c.


Generated by  doxygen 1.6.2