Mon Jun 27 16:50:57 2011

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"

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 612 of file agent.c.

References ast_bridged_channel(), ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ASTCHANBRIDGECOUNT, and header_generic().

Referenced by init_asterisk_mib().

00614 {
00615    static unsigned long long_ret;
00616    struct ast_channel *chan = NULL;
00617    struct ast_channel_iterator *iter;
00618 
00619    long_ret = 0;
00620 
00621    if (header_generic(vp, name, length, exact, var_len, write_method)) {
00622       return NULL;
00623    }
00624 
00625    if (!(iter = ast_channel_iterator_all_new())) {
00626       return NULL;
00627    }
00628 
00629    while ((chan = ast_channel_iterator_next(iter))) {
00630       ast_channel_lock(chan);
00631       if (ast_bridged_channel(chan)) {
00632          long_ret++;
00633       }
00634       ast_channel_unlock(chan);
00635       chan = ast_channel_unref(chan);
00636    }
00637 
00638    ast_channel_iterator_destroy(iter);
00639 
00640    *var_len = sizeof(long_ret);
00641 
00642    return (vp->magic == ASTCHANBRIDGECOUNT) ? (u_char *) &long_ret : NULL;
00643 }

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 526 of file agent.c.

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

Referenced by init_asterisk_mib().

00528 {
00529    static unsigned long long_ret;
00530    struct ast_variable *channel_types, *next;
00531 
00532    if (header_generic(vp, name, length, exact, var_len, write_method))
00533       return NULL;
00534 
00535    if (vp->magic != ASTCHANTYPECOUNT)
00536       return NULL;
00537 
00538    for (long_ret = 0, channel_types = next = ast_channeltype_list(); next; next = next->next)
00539       long_ret++;
00540    ast_variables_destroy(channel_types);
00541 
00542    return (u_char *)&long_ret;
00543 }

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 545 of file agent.c.

References ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_unref, ast_channeltype_list(), ast_get_channel_tech(), ast_variables_destroy(), ASTCHANTYPECHANNELS, ASTCHANTYPEDESC, ASTCHANTYPEDEVSTATE, ASTCHANTYPEINDEX, ASTCHANTYPEINDICATIONS, ASTCHANTYPENAME, ASTCHANTYPETRANSFER, 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().

00547 {
00548    const struct ast_channel_tech *tech = NULL;
00549    struct ast_variable *channel_types, *next;
00550    static unsigned long long_ret;
00551    struct ast_channel *chan;
00552    u_long i;
00553 
00554    if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
00555       return NULL;
00556 
00557    channel_types = ast_channeltype_list();
00558    for (i = 1, next = channel_types; next && i != name[*length - 1]; next = next->next, i++)
00559       ;
00560    if (next != NULL)
00561       tech = ast_get_channel_tech(next->name);
00562    ast_variables_destroy(channel_types);
00563    if (next == NULL || tech == NULL)
00564       return NULL;
00565    
00566    switch (vp->magic) {
00567    case ASTCHANTYPEINDEX:
00568       long_ret = name[*length - 1];
00569       return (u_char *)&long_ret;
00570    case ASTCHANTYPENAME:
00571       *var_len = strlen(tech->type);
00572       return (u_char *)tech->type;
00573    case ASTCHANTYPEDESC:
00574       *var_len = strlen(tech->description);
00575       return (u_char *)tech->description;
00576    case ASTCHANTYPEDEVSTATE:
00577       long_ret = tech->devicestate ? 1 : 2;
00578       return (u_char *)&long_ret;
00579    case ASTCHANTYPEINDICATIONS:
00580       long_ret = tech->indicate ? 1 : 2;
00581       return (u_char *)&long_ret;
00582    case ASTCHANTYPETRANSFER:
00583       long_ret = tech->transfer ? 1 : 2;
00584       return (u_char *)&long_ret;
00585    case ASTCHANTYPECHANNELS:
00586    {
00587       struct ast_channel_iterator *iter;
00588 
00589       long_ret = 0;
00590 
00591       if (!(iter = ast_channel_iterator_all_new())) {
00592          return NULL;
00593       }
00594 
00595       while ((chan = ast_channel_iterator_next(iter))) {
00596          if (chan->tech == tech) {
00597             long_ret++;
00598          }
00599          chan = ast_channel_unref(chan);
00600       }
00601 
00602       ast_channel_iterator_destroy(iter);
00603 
00604       return (u_char *)&long_ret;
00605    }
00606    default:
00607       break;
00608    }
00609    return NULL;
00610 }

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

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

00647 {
00648    static unsigned long long_ret;
00649    struct timeval tval;
00650 
00651    if (header_generic(vp, name, length, exact, var_len, write_method))
00652       return NULL;
00653 
00654    switch (vp->magic) {
00655    case ASTCONFUPTIME:
00656       gettimeofday(&tval, NULL);
00657       long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
00658       return (u_char *)&long_ret;
00659    case ASTCONFRELOADTIME:
00660       gettimeofday(&tval, NULL);
00661       if (ast_lastreloadtime.tv_sec)
00662          long_ret = difftime(tval.tv_sec, ast_lastreloadtime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_lastreloadtime.tv_usec / 10000;
00663       else
00664          long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
00665       return (u_char *)&long_ret;
00666    case ASTCONFPID:
00667       long_ret = getpid();
00668       return (u_char *)&long_ret;
00669    case ASTCONFSOCKET:
00670       *var_len = strlen(ast_config_AST_SOCKET);
00671       return (u_char *)ast_config_AST_SOCKET;
00672    case ASTCONFACTIVECALLS:
00673       long_ret = ast_active_calls();
00674       return (u_char *)&long_ret;
00675    case ASTCONFPROCESSEDCALLS:
00676       long_ret = ast_processed_calls();
00677       return (u_char *)&long_ret;
00678    default:
00679       break;
00680    }
00681    return NULL;
00682 }

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 684 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, header_generic(), and tz.

Referenced by init_asterisk_mib().

00686 {
00687    static unsigned long long_ret;
00688    static char ret_buf[128];
00689    struct ast_tone_zone *tz = NULL;
00690 
00691    if (header_generic(vp, name, length, exact, var_len, write_method))
00692       return NULL;
00693 
00694    switch (vp->magic) {
00695    case ASTINDCOUNT:
00696    {
00697       struct ao2_iterator i;
00698 
00699       long_ret = 0;
00700 
00701       i = ast_tone_zone_iterator_init();
00702       while ((tz = ao2_iterator_next(&i))) {
00703          tz = ast_tone_zone_unref(tz);
00704          long_ret++;
00705       }
00706 
00707       return (u_char *) &long_ret;
00708    }
00709    case ASTINDCURRENT:
00710       tz = ast_get_indication_zone(NULL);
00711       if (tz) {
00712          ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
00713          *var_len = strlen(ret_buf);
00714          tz = ast_tone_zone_unref(tz);
00715          return (u_char *) ret_buf;
00716       }
00717       *var_len = 0;
00718       return NULL;
00719    default:
00720       break;
00721    }
00722    return NULL;
00723 }

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 725 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, header_simple_table(), and tz.

Referenced by init_asterisk_mib().

00727 {
00728    static unsigned long long_ret;
00729    static char ret_buf[256];
00730    struct ast_tone_zone *tz = NULL;
00731    int i;
00732    struct ao2_iterator iter;
00733 
00734    if (header_simple_table(vp, name, length, exact, var_len, write_method, -1)) {
00735       return NULL;
00736    }
00737 
00738    i = name[*length - 1] - 1;
00739 
00740    iter = ast_tone_zone_iterator_init();
00741 
00742    while ((tz = ao2_iterator_next(&iter)) && i) {
00743       tz = ast_tone_zone_unref(tz);
00744       i--;
00745    }
00746 
00747    if (tz == NULL) {
00748       return NULL;
00749    }
00750 
00751    switch (vp->magic) {
00752    case ASTINDINDEX:
00753       long_ret = name[*length - 1];
00754       return (u_char *)&long_ret;
00755    case ASTINDCOUNTRY:
00756       ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
00757       tz = ast_tone_zone_unref(tz);
00758       *var_len = strlen(ret_buf);
00759       return (u_char *) ret_buf;
00760    case ASTINDALIAS:
00761       /* No longer exists */
00762       return NULL;
00763    case ASTINDDESCRIPTION:
00764       ast_tone_zone_lock(tz);
00765       ast_copy_string(ret_buf, tz->description, sizeof(ret_buf));
00766       ast_tone_zone_unlock(tz);
00767       tz = ast_tone_zone_unref(tz);
00768       *var_len = strlen(ret_buf);
00769       return (u_char *) ret_buf;
00770    default:
00771       break;
00772    }
00773    return NULL;
00774 }

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 781 of file agent.c.

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

Referenced by init_asterisk_mib().

00783 {
00784    static unsigned long long_ret;
00785 
00786    if (header_generic(vp, name, length, exact, var_len, write_method))
00787       return NULL;
00788 
00789    if (vp->magic != ASTMODCOUNT)
00790       return NULL;
00791 
00792    long_ret = ast_update_module_list(countmodule, NULL);
00793 
00794    return (u_char *)&long_ret;
00795 }

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 797 of file agent.c.

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

Referenced by init_asterisk_mib().

00799 {
00800    static unsigned long long_ret;
00801 
00802    if (header_generic(vp, name, length, exact, var_len, write_method))
00803       return NULL;
00804 
00805    switch (vp->magic) {
00806    case ASTVERSTRING:
00807    {
00808       const char *version = ast_get_version();
00809       *var_len = strlen(version);
00810       return (u_char *)version;
00811    }
00812    case ASTVERTAG:
00813       sscanf(ast_get_version_num(), "%30lu", &long_ret);
00814       return (u_char *)&long_ret;
00815    default:
00816       break;
00817    }
00818    return NULL;
00819 }

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

Definition at line 776 of file agent.c.

Referenced by ast_var_Modules().

00777 {
00778    return 1;
00779 }

int header_generic ( struct variable *  ,
oid *  ,
size_t *  ,
int  ,
size_t *  ,
WriteMethod **   
)

Referenced by ast_var_channel_bridge(), ast_var_channel_types(), ast_var_channels(), ast_var_Config(), ast_var_indications(), ast_var_Modules(), and ast_var_Version().

int header_simple_table ( struct variable *  ,
oid *  ,
size_t *  ,
int  ,
size_t *  ,
WriteMethod **  ,
int   
)

Referenced by ast_var_channel_types_table(), ast_var_channels_table(), and ast_var_indications_table().

static void init_asterisk_mib ( void   )  [static]

Definition at line 827 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, asterisk_oid, ASTINDALIAS, ASTINDCOUNT, ASTINDCOUNTRY, ASTINDCURRENT, ASTINDDESCRIPTION, ASTINDICATIONS, ASTINDINDEX, ASTINDTABLE, ASTMODCOUNT, ASTMODULES, ASTVERSION, ASTVERSTRING, ASTVERTAG, register_sysORTable(), and term_asterisk_mib().

Referenced by agent_thread().

00828 {
00829    static struct variable4 asterisk_vars[] = {
00830       {ASTVERSTRING,           ASN_OCTET_STR, RONLY, ast_var_Version,             2, {ASTVERSION, ASTVERSTRING}},
00831       {ASTVERTAG,              ASN_UNSIGNED,  RONLY, ast_var_Version,             2, {ASTVERSION, ASTVERTAG}},
00832       {ASTCONFUPTIME,          ASN_TIMETICKS, RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFUPTIME}},
00833       {ASTCONFRELOADTIME,      ASN_TIMETICKS, RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFRELOADTIME}},
00834       {ASTCONFPID,             ASN_INTEGER,   RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFPID}},
00835       {ASTCONFSOCKET,          ASN_OCTET_STR, RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFSOCKET}},
00836       {ASTCONFACTIVECALLS,     ASN_GAUGE,    RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFACTIVECALLS}},
00837       {ASTCONFPROCESSEDCALLS,  ASN_COUNTER,   RONLY, ast_var_Config,              2, {ASTCONFIGURATION, ASTCONFPROCESSEDCALLS}},
00838       {ASTMODCOUNT,            ASN_INTEGER,   RONLY, ast_var_Modules ,            2, {ASTMODULES, ASTMODCOUNT}},
00839       {ASTINDCOUNT,            ASN_INTEGER,   RONLY, ast_var_indications,         2, {ASTINDICATIONS, ASTINDCOUNT}},
00840       {ASTINDCURRENT,          ASN_OCTET_STR, RONLY, ast_var_indications,         2, {ASTINDICATIONS, ASTINDCURRENT}},
00841       {ASTINDINDEX,            ASN_INTEGER,   RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDINDEX}},
00842       {ASTINDCOUNTRY,          ASN_OCTET_STR, RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDCOUNTRY}},
00843       {ASTINDALIAS,            ASN_OCTET_STR, RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDALIAS}},
00844       {ASTINDDESCRIPTION,      ASN_OCTET_STR, RONLY, ast_var_indications_table,   4, {ASTINDICATIONS, ASTINDTABLE, 1, ASTINDDESCRIPTION}},
00845       {ASTCHANCOUNT,           ASN_GAUGE,     RONLY, ast_var_channels,            2, {ASTCHANNELS, ASTCHANCOUNT}},
00846       {ASTCHANINDEX,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANINDEX}},
00847       {ASTCHANNAME,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANNAME}},
00848       {ASTCHANLANGUAGE,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANLANGUAGE}},
00849       {ASTCHANTYPE,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTYPE}},
00850       {ASTCHANMUSICCLASS,      ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUSICCLASS}},
00851       {ASTCHANBRIDGE,          ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANBRIDGE}},
00852       {ASTCHANMASQ,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQ}},
00853       {ASTCHANMASQR,           ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQR}},
00854       {ASTCHANWHENHANGUP,      ASN_TIMETICKS, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANWHENHANGUP}},
00855       {ASTCHANAPP,             ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAPP}},
00856       {ASTCHANDATA,            ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANDATA}},
00857       {ASTCHANCONTEXT,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCONTEXT}},
00858       {ASTCHANMACROCONTEXT,    ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROCONTEXT}},
00859       {ASTCHANMACROEXTEN,      ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROEXTEN}},
00860       {ASTCHANMACROPRI,        ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMACROPRI}},
00861       {ASTCHANEXTEN,           ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANEXTEN}},
00862       {ASTCHANPRI,             ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPRI}},
00863       {ASTCHANACCOUNTCODE,     ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANACCOUNTCODE}},
00864       {ASTCHANFORWARDTO,       ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFORWARDTO}},
00865       {ASTCHANUNIQUEID,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANUNIQUEID}},
00866       {ASTCHANCALLGROUP,       ASN_UNSIGNED,  RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCALLGROUP}},
00867       {ASTCHANPICKUPGROUP,     ASN_UNSIGNED,  RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPICKUPGROUP}},
00868       {ASTCHANSTATE,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANSTATE}},
00869       {ASTCHANMUTED,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMUTED}},
00870       {ASTCHANRINGS,           ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANRINGS}},
00871       {ASTCHANCIDDNID,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDDNID}},
00872       {ASTCHANCIDNUM,          ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNUM}},
00873       {ASTCHANCIDNAME,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDNAME}},
00874       {ASTCHANCIDANI,          ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI}},
00875       {ASTCHANCIDRDNIS,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDRDNIS}},
00876       {ASTCHANCIDPRES,         ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDPRES}},
00877       {ASTCHANCIDANI2,         ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDANI2}},
00878       {ASTCHANCIDTON,          ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTON}},
00879       {ASTCHANCIDTNS,          ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANCIDTNS}},
00880       {ASTCHANAMAFLAGS,        ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAMAFLAGS}},
00881       {ASTCHANADSI,            ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANADSI}},
00882       {ASTCHANTONEZONE,        ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTONEZONE}},
00883       {ASTCHANHANGUPCAUSE,     ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANHANGUPCAUSE}},
00884       {ASTCHANVARIABLES,       ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANVARIABLES}},
00885       {ASTCHANFLAGS,           ASN_OCTET_STR, RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFLAGS}},
00886       {ASTCHANTRANSFERCAP,     ASN_INTEGER,   RONLY, ast_var_channels_table,      4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTRANSFERCAP}},
00887       {ASTCHANTYPECOUNT,       ASN_INTEGER,   RONLY, ast_var_channel_types,       2, {ASTCHANNELS, ASTCHANTYPECOUNT}},
00888       {ASTCHANTYPEINDEX,       ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDEX}},
00889       {ASTCHANTYPENAME,        ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPENAME}},
00890       {ASTCHANTYPEDESC,        ASN_OCTET_STR, RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDESC}},
00891       {ASTCHANTYPEDEVSTATE,    ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEDEVSTATE}},
00892       {ASTCHANTYPEINDICATIONS, ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPEINDICATIONS}},
00893       {ASTCHANTYPETRANSFER,    ASN_INTEGER,   RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPETRANSFER}},
00894       {ASTCHANTYPECHANNELS,    ASN_GAUGE,     RONLY, ast_var_channel_types_table, 4, {ASTCHANNELS, ASTCHANTYPETABLE, 1, ASTCHANTYPECHANNELS}},
00895       {ASTCHANBRIDGECOUNT,     ASN_GAUGE,     RONLY, ast_var_channel_bridge,      3, {ASTCHANNELS, ASTCHANSCALARS, ASTCHANBRIDGECOUNT}},
00896    };
00897 
00898    register_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid),
00899          "ASTERISK-MIB implementation for Asterisk.");
00900 
00901    REGISTER_MIB("res_snmp", asterisk_vars, variable4, asterisk_oid);
00902 
00903    snmp_register_callback(SNMP_CALLBACK_LIBRARY,
00904             SNMP_CALLBACK_SHUTDOWN,
00905             term_asterisk_mib, NULL);
00906 }

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 821 of file agent.c.

References asterisk_oid, and unregister_sysORTable().

Referenced by init_asterisk_mib().

00822 {
00823    unregister_sysORTable(asterisk_oid, OID_LENGTH(asterisk_oid));
00824    return 0;
00825 }

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.

Referenced by init_asterisk_mib(), and term_asterisk_mib().


Generated on Mon Jun 27 16:50:57 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7