Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Macros | Functions | Variables
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.

Macros

#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 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 ASTMM_LIBC   ASTMM_IGNORE
 
#define ASTMODCOUNT   1
 
#define ASTMODULES   3
 
#define ASTVERSION   1
 
#define ASTVERSTRING   1
 
#define ASTVERTAG   2
 
#define HAVE_DMALLOC_H   0 /* XXX we shouldn't do this */
 
#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 *status, const char *like, enum ast_module_support_level support_level)
 
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.nosp@m.@voo.nosp@m.p.as

Definition in file agent.c.

Macro Definition Documentation

◆ ASTCHANACCOUNTCODE

#define ASTCHANACCOUNTCODE   18

Definition at line 147 of file agent.c.

◆ ASTCHANADSI

#define ASTCHANADSI   36

Definition at line 165 of file agent.c.

◆ ASTCHANAMAFLAGS

#define ASTCHANAMAFLAGS   35

Definition at line 164 of file agent.c.

◆ ASTCHANAPP

#define ASTCHANAPP   10

Definition at line 142 of file agent.c.

◆ ASTCHANBRIDGE

#define ASTCHANBRIDGE   6

Definition at line 138 of file agent.c.

◆ ASTCHANBRIDGECOUNT

#define ASTCHANBRIDGECOUNT   1

Definition at line 184 of file agent.c.

◆ ASTCHANCALLGROUP

#define ASTCHANCALLGROUP   21

Definition at line 150 of file agent.c.

◆ ASTCHANCIDANI

#define ASTCHANCIDANI   29

Definition at line 158 of file agent.c.

◆ ASTCHANCIDANI2

#define ASTCHANCIDANI2   32

Definition at line 161 of file agent.c.

◆ ASTCHANCIDDNID

#define ASTCHANCIDDNID   26

Definition at line 155 of file agent.c.

◆ ASTCHANCIDNAME

#define ASTCHANCIDNAME   28

Definition at line 157 of file agent.c.

◆ ASTCHANCIDNUM

#define ASTCHANCIDNUM   27

Definition at line 156 of file agent.c.

◆ ASTCHANCIDPRES

#define ASTCHANCIDPRES   31

Definition at line 160 of file agent.c.

◆ ASTCHANCIDRDNIS

#define ASTCHANCIDRDNIS   30

Definition at line 159 of file agent.c.

◆ ASTCHANCIDTNS

#define ASTCHANCIDTNS   34

Definition at line 163 of file agent.c.

◆ ASTCHANCIDTON

#define ASTCHANCIDTON   33

Definition at line 162 of file agent.c.

◆ ASTCHANCONTEXT

#define ASTCHANCONTEXT   12

Definition at line 144 of file agent.c.

◆ ASTCHANCOUNT

#define ASTCHANCOUNT   1

Definition at line 130 of file agent.c.

◆ ASTCHANDATA

#define ASTCHANDATA   11

Definition at line 143 of file agent.c.

◆ ASTCHANEXTEN

#define ASTCHANEXTEN   16

Definition at line 145 of file agent.c.

◆ ASTCHANFLAGS

#define ASTCHANFLAGS   40

Definition at line 169 of file agent.c.

◆ ASTCHANFORWARDTO

#define ASTCHANFORWARDTO   19

Definition at line 148 of file agent.c.

◆ ASTCHANHANGUPCAUSE

#define ASTCHANHANGUPCAUSE   38

Definition at line 167 of file agent.c.

◆ ASTCHANINDEX

#define ASTCHANINDEX   1

Definition at line 133 of file agent.c.

◆ ASTCHANLANGUAGE

#define ASTCHANLANGUAGE   3

Definition at line 135 of file agent.c.

◆ ASTCHANMASQ

#define ASTCHANMASQ   7

Definition at line 139 of file agent.c.

◆ ASTCHANMASQR

#define ASTCHANMASQR   8

Definition at line 140 of file agent.c.

◆ ASTCHANMUSICCLASS

#define ASTCHANMUSICCLASS   5

Definition at line 137 of file agent.c.

◆ ASTCHANMUTED

#define ASTCHANMUTED   24

Definition at line 153 of file agent.c.

◆ ASTCHANNAME

#define ASTCHANNAME   2

Definition at line 134 of file agent.c.

◆ ASTCHANNELS

#define ASTCHANNELS   5

Definition at line 129 of file agent.c.

◆ ASTCHANPICKUPGROUP

#define ASTCHANPICKUPGROUP   22

Definition at line 151 of file agent.c.

◆ ASTCHANPRI

#define ASTCHANPRI   17

Definition at line 146 of file agent.c.

◆ ASTCHANRINGS

#define ASTCHANRINGS   25

Definition at line 154 of file agent.c.

◆ ASTCHANSCALARS

#define ASTCHANSCALARS   5

Definition at line 183 of file agent.c.

◆ ASTCHANSTATE

#define ASTCHANSTATE   23

Definition at line 152 of file agent.c.

◆ ASTCHANTABLE

#define ASTCHANTABLE   2

Definition at line 132 of file agent.c.

◆ ASTCHANTONEZONE

#define ASTCHANTONEZONE   37

Definition at line 166 of file agent.c.

◆ ASTCHANTRANSFERCAP

#define ASTCHANTRANSFERCAP   41

Definition at line 170 of file agent.c.

◆ ASTCHANTYPE

#define ASTCHANTYPE   4

Definition at line 136 of file agent.c.

◆ ASTCHANTYPECHANNELS

#define ASTCHANTYPECHANNELS   7

Definition at line 181 of file agent.c.

◆ ASTCHANTYPECOUNT

#define ASTCHANTYPECOUNT   3

Definition at line 172 of file agent.c.

◆ ASTCHANTYPEDESC

#define ASTCHANTYPEDESC   3

Definition at line 177 of file agent.c.

◆ ASTCHANTYPEDEVSTATE

#define ASTCHANTYPEDEVSTATE   4

Definition at line 178 of file agent.c.

◆ ASTCHANTYPEINDEX

#define ASTCHANTYPEINDEX   1

Definition at line 175 of file agent.c.

◆ ASTCHANTYPEINDICATIONS

#define ASTCHANTYPEINDICATIONS   5

Definition at line 179 of file agent.c.

◆ ASTCHANTYPENAME

#define ASTCHANTYPENAME   2

Definition at line 176 of file agent.c.

◆ ASTCHANTYPETABLE

#define ASTCHANTYPETABLE   4

Definition at line 174 of file agent.c.

◆ ASTCHANTYPETRANSFER

#define ASTCHANTYPETRANSFER   6

Definition at line 180 of file agent.c.

◆ ASTCHANUNIQUEID

#define ASTCHANUNIQUEID   20

Definition at line 149 of file agent.c.

◆ ASTCHANVARIABLES

#define ASTCHANVARIABLES   39

Definition at line 168 of file agent.c.

◆ ASTCHANWHENHANGUP

#define ASTCHANWHENHANGUP   9

Definition at line 141 of file agent.c.

◆ ASTCONFACTIVECALLS

#define ASTCONFACTIVECALLS   5

Definition at line 113 of file agent.c.

◆ ASTCONFIGURATION

#define ASTCONFIGURATION   2

Definition at line 108 of file agent.c.

◆ ASTCONFPID

#define ASTCONFPID   3

Definition at line 111 of file agent.c.

◆ ASTCONFPROCESSEDCALLS

#define ASTCONFPROCESSEDCALLS   6

Definition at line 114 of file agent.c.

◆ ASTCONFRELOADTIME

#define ASTCONFRELOADTIME   2

Definition at line 110 of file agent.c.

◆ ASTCONFSOCKET

#define ASTCONFSOCKET   4

Definition at line 112 of file agent.c.

◆ ASTCONFUPTIME

#define ASTCONFUPTIME   1

Definition at line 109 of file agent.c.

◆ ASTINDALIAS

#define ASTINDALIAS   3

Definition at line 126 of file agent.c.

◆ ASTINDCOUNT

#define ASTINDCOUNT   1

Definition at line 120 of file agent.c.

◆ ASTINDCOUNTRY

#define ASTINDCOUNTRY   2

Definition at line 125 of file agent.c.

◆ ASTINDCURRENT

#define ASTINDCURRENT   2

Definition at line 121 of file agent.c.

◆ ASTINDDESCRIPTION

#define ASTINDDESCRIPTION   4

Definition at line 127 of file agent.c.

◆ ASTINDICATIONS

#define ASTINDICATIONS   4

Definition at line 119 of file agent.c.

◆ ASTINDINDEX

#define ASTINDINDEX   1

Definition at line 124 of file agent.c.

◆ ASTINDTABLE

#define ASTINDTABLE   3

Definition at line 123 of file agent.c.

◆ ASTMM_LIBC

#define ASTMM_LIBC   ASTMM_IGNORE

Definition at line 22 of file agent.c.

◆ ASTMODCOUNT

#define ASTMODCOUNT   1

Definition at line 117 of file agent.c.

◆ ASTMODULES

#define ASTMODULES   3

Definition at line 116 of file agent.c.

◆ ASTVERSION

#define ASTVERSION   1

Definition at line 104 of file agent.c.

◆ ASTVERSTRING

#define ASTVERSTRING   1

Definition at line 105 of file agent.c.

◆ ASTVERTAG

#define ASTVERTAG   2

Definition at line 106 of file agent.c.

◆ HAVE_DMALLOC_H

#define HAVE_DMALLOC_H   0 /* XXX we shouldn't do this */

Definition at line 51 of file agent.c.

◆ unload_module

static int unload_module (   void)    ast_unload_module

Definition at line 79 of file agent.c.

Function Documentation

◆ agent_thread()

void * agent_thread ( void *  arg)

Definition at line 186 of file agent.c.

187{
188 ast_verb(2, "Starting %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
189
190 snmp_enable_stderrlog();
191
193 netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID,
194 NETSNMP_DS_AGENT_ROLE,
195 1);
196
197 init_agent("asterisk");
198
200
201 init_snmp("asterisk");
202
204 init_master_agent();
205
206 while (res_snmp_dont_stop)
207 agent_check_and_process(1);
208
209 snmp_shutdown("asterisk");
210
211 ast_verb(2, "Terminating %sAgent\n", res_snmp_agentx_subagent ? "Sub" : "");
212
213 return NULL;
214}
static void init_asterisk_mib(void)
Definition: agent.c:809
#define ast_verb(level,...)
int res_snmp_dont_stop
Definition: res_snmp.c:44
int res_snmp_agentx_subagent
Definition: res_snmp.c:43
#define NULL
Definition: resample.c:96

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

Referenced by load_module().

◆ ast_var_channel_bridge()

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

590{
591 static unsigned long long_ret;
592 struct ast_channel *chan = NULL;
593 struct ast_channel_iterator *iter;
594
595 long_ret = 0;
596
597 if (header_generic(vp, name, length, exact, var_len, write_method)) {
598 return NULL;
599 }
600
601 if (!(iter = ast_channel_iterator_all_new())) {
602 return NULL;
603 }
604
605 while ((chan = ast_channel_iterator_next(iter))) {
606 ast_channel_lock(chan);
607 if (ast_channel_is_bridged(chan)) {
608 long_ret++;
609 }
610 ast_channel_unlock(chan);
611 chan = ast_channel_unref(chan);
612 }
613
615
616 *var_len = sizeof(long_ret);
617
618 return (vp->magic == ASTCHANBRIDGECOUNT) ? (u_char *) &long_ret : NULL;
619}
int header_generic(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **)
#define ASTCHANBRIDGECOUNT
Definition: agent.c:184
struct ast_channel_iterator * ast_channel_iterator_destroy(struct ast_channel_iterator *i)
Destroy a channel iterator.
Definition: channel.c:1360
#define ast_channel_lock(chan)
Definition: channel.h:2922
struct ast_channel * ast_channel_iterator_next(struct ast_channel_iterator *i)
Get the next channel for a channel iterator.
Definition: channel.c:1422
int ast_channel_is_bridged(const struct ast_channel *chan)
Determine if a channel is in a bridge.
Definition: channel.c:10545
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
struct ast_channel_iterator * ast_channel_iterator_all_new(void)
Create a new channel iterator.
Definition: channel.c:1408
#define ast_channel_unlock(chan)
Definition: channel.h:2923
static const char name[]
Definition: format_mp3.c:68
Main Channel structure associated with a channel.

References ast_channel_is_bridged(), ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_lock, ast_channel_unlock, ast_channel_unref, ASTCHANBRIDGECOUNT, header_generic(), name, and NULL.

Referenced by init_asterisk_mib().

◆ ast_var_channel_types()

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

504{
505 static unsigned long long_ret;
506 struct ast_variable *channel_types, *next;
507
508 if (header_generic(vp, name, length, exact, var_len, write_method))
509 return NULL;
510
511 if (vp->magic != ASTCHANTYPECOUNT)
512 return NULL;
513
514 for (long_ret = 0, channel_types = next = ast_channeltype_list(); next; next = next->next)
515 long_ret++;
516 ast_variables_destroy(channel_types);
517
518 return (u_char *)&long_ret;
519}
#define ASTCHANTYPECOUNT
Definition: agent.c:172
struct ast_variable * ast_channeltype_list(void)
return an ast_variable list of channeltypes
Definition: channel.c:188
void ast_variables_destroy(struct ast_variable *var)
Free variable list.
Definition: extconf.c:1262
Structure for variables, used for configurations and for channel variables.
struct ast_variable * next

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

Referenced by init_asterisk_mib().

◆ ast_var_channel_types_table()

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

523{
524 const struct ast_channel_tech *tech = NULL;
525 struct ast_variable *channel_types, *next;
526 static unsigned long long_ret;
527 struct ast_channel *chan;
528 u_long i;
529
530 if (header_simple_table(vp, name, length, exact, var_len, write_method, -1))
531 return NULL;
532
533 channel_types = ast_channeltype_list();
534 for (i = 1, next = channel_types; next && i != name[*length - 1]; next = next->next, i++)
535 ;
536 if (next != NULL)
538 ast_variables_destroy(channel_types);
539 if (next == NULL || tech == NULL)
540 return NULL;
541
542 switch (vp->magic) {
543 case ASTCHANTYPEINDEX:
544 long_ret = name[*length - 1];
545 return (u_char *)&long_ret;
546 case ASTCHANTYPENAME:
547 *var_len = strlen(tech->type);
548 return (u_char *)tech->type;
549 case ASTCHANTYPEDESC:
550 *var_len = strlen(tech->description);
551 return (u_char *)tech->description;
553 long_ret = tech->devicestate ? 1 : 2;
554 return (u_char *)&long_ret;
556 long_ret = tech->indicate ? 1 : 2;
557 return (u_char *)&long_ret;
559 long_ret = tech->transfer ? 1 : 2;
560 return (u_char *)&long_ret;
562 {
563 struct ast_channel_iterator *iter;
564
565 long_ret = 0;
566
567 if (!(iter = ast_channel_iterator_all_new())) {
568 return NULL;
569 }
570
571 while ((chan = ast_channel_iterator_next(iter))) {
572 if (ast_channel_tech(chan) == tech) {
573 long_ret++;
574 }
575 chan = ast_channel_unref(chan);
576 }
577
579
580 return (u_char *)&long_ret;
581 }
582 default:
583 break;
584 }
585 return NULL;
586}
#define ASTCHANTYPEINDEX
Definition: agent.c:175
#define ASTCHANTYPEDESC
Definition: agent.c:177
#define ASTCHANTYPEDEVSTATE
Definition: agent.c:178
#define ASTCHANTYPEINDICATIONS
Definition: agent.c:179
int header_simple_table(struct variable *, oid *, size_t *, int, size_t *, WriteMethod **, int)
#define ASTCHANTYPECHANNELS
Definition: agent.c:181
#define ASTCHANTYPENAME
Definition: agent.c:176
#define ASTCHANTYPETRANSFER
Definition: agent.c:180
const struct ast_channel_tech * ast_channel_tech(const struct ast_channel *chan)
const struct ast_channel_tech * ast_get_channel_tech(const char *name)
Get a channel technology structure by name.
Definition: channel.c:592
Structure to describe a channel "technology", ie a channel driver See for examples:
Definition: channel.h:628
int(*const indicate)(struct ast_channel *c, int condition, const void *data, size_t datalen)
Indicate a particular condition (e.g. AST_CONTROL_BUSY or AST_CONTROL_RINGING or AST_CONTROL_CONGESTI...
Definition: channel.h:771
const char *const type
Definition: channel.h:629
const char *const description
Definition: channel.h:630
int(*const transfer)(struct ast_channel *chan, const char *newdest)
Blind transfer other side (see app_transfer.c and ast_transfer()
Definition: channel.h:783
int(*const devicestate)(const char *device_number)
Definition: channel.h:675
const struct ast_channel_tech * tech

References ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_tech(), 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, name, ast_variable::name, ast_variable::next, NULL, ast_channel::tech, ast_channel_tech::transfer, and ast_channel_tech::type.

Referenced by init_asterisk_mib().

◆ ast_var_channels()

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

219{
220 static unsigned long long_ret;
221
222 if (header_generic(vp, name, length, exact, var_len, write_method))
223 return NULL;
224
225 if (vp->magic != ASTCHANCOUNT)
226 return NULL;
227
228 long_ret = ast_active_channels();
229
230 return (u_char *)&long_ret;
231}
#define ASTCHANCOUNT
Definition: agent.c:130
int ast_active_channels(void)
returns number of active/allocated channels
Definition: channel.c:499

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

Referenced by init_asterisk_mib().

◆ ast_var_channels_table()

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

235{
236 static unsigned long long_ret;
237 static u_char bits_ret[2];
238 static char string_ret[256];
239 struct ast_channel *chan, *bridge;
240 struct timeval tval;
241 u_char *ret = NULL;
242 int i, bit;
243 struct ast_str *out = ast_str_alloca(2048);
244 struct ast_channel_iterator *iter;
245
246 if (header_simple_table(vp, name, length, exact, var_len, write_method, ast_active_channels()))
247 return NULL;
248
249 i = name[*length - 1] - 1;
250
251 if (!(iter = ast_channel_iterator_all_new())) {
252 return NULL;
253 }
254
255 while ((chan = ast_channel_iterator_next(iter)) && i) {
256 ast_channel_unref(chan);
257 i--;
258 }
259
260 iter = ast_channel_iterator_destroy(iter);
261
262 if (chan == NULL) {
263 return NULL;
264 }
265
266 *var_len = sizeof(long_ret);
267
268 ast_channel_lock(chan);
269
270 switch (vp->magic) {
271 case ASTCHANINDEX:
272 long_ret = name[*length - 1];
273 ret = (u_char *)&long_ret;
274 break;
275 case ASTCHANNAME:
276 if (!ast_strlen_zero(ast_channel_name(chan))) {
277 ast_copy_string(string_ret, ast_channel_name(chan), sizeof(string_ret));
278 *var_len = strlen(string_ret);
279 ret = (u_char *)string_ret;
280 }
281 break;
282 case ASTCHANLANGUAGE:
284 ast_copy_string(string_ret, ast_channel_language(chan), sizeof(string_ret));
285 *var_len = strlen(string_ret);
286 ret = (u_char *)string_ret;
287 }
288 break;
289 case ASTCHANTYPE:
290 ast_copy_string(string_ret, ast_channel_tech(chan)->type, sizeof(string_ret));
291 *var_len = strlen(string_ret);
292 ret = (u_char *)string_ret;
293 break;
296 ast_copy_string(string_ret, ast_channel_musicclass(chan), sizeof(string_ret));
297 *var_len = strlen(string_ret);
298 ret = (u_char *)string_ret;
299 }
300 break;
301 case ASTCHANBRIDGE:
302 ast_channel_unlock(chan);
303 bridge = ast_channel_bridge_peer(chan);
304 if (bridge) {
305 ast_channel_lock(bridge);
306 ast_copy_string(string_ret, ast_channel_name(bridge), sizeof(string_ret));
307 ast_channel_unlock(bridge);
308 ast_channel_unref(bridge);
309
310 *var_len = strlen(string_ret);
311 ret = (u_char *)string_ret;
312 }
313 ast_channel_lock(chan);
314 break;
315 case ASTCHANMASQ:
317 ast_copy_string(string_ret, ast_channel_name(ast_channel_masq(chan)), sizeof(string_ret));
318 *var_len = strlen(string_ret);
319 ret = (u_char *)string_ret;
320 }
321 break;
322 case ASTCHANMASQR:
324 ast_copy_string(string_ret, ast_channel_name(ast_channel_masqr(chan)), sizeof(string_ret));
325 *var_len = strlen(string_ret);
326 ret = (u_char *)string_ret;
327 }
328 break;
331 gettimeofday(&tval, NULL);
332 long_ret = difftime(ast_channel_whentohangup(chan)->tv_sec, tval.tv_sec) * 100 - tval.tv_usec / 10000;
333 ret= (u_char *)&long_ret;
334 }
335 break;
336 case ASTCHANAPP:
337 if (ast_channel_appl(chan)) {
338 ast_copy_string(string_ret, ast_channel_appl(chan), sizeof(string_ret));
339 *var_len = strlen(string_ret);
340 ret = (u_char *)string_ret;
341 }
342 break;
343 case ASTCHANDATA:
344 if (ast_channel_data(chan)) {
345 ast_copy_string(string_ret, ast_channel_data(chan), sizeof(string_ret));
346 *var_len = strlen(string_ret);
347 ret = (u_char *)string_ret;
348 }
349 break;
350 case ASTCHANCONTEXT:
351 ast_copy_string(string_ret, ast_channel_context(chan), sizeof(string_ret));
352 *var_len = strlen(string_ret);
353 ret = (u_char *)string_ret;
354 break;
355 case ASTCHANEXTEN:
356 ast_copy_string(string_ret, ast_channel_exten(chan), sizeof(string_ret));
357 *var_len = strlen(string_ret);
358 ret = (u_char *)string_ret;
359 break;
360 case ASTCHANPRI:
361 long_ret = ast_channel_priority(chan);
362 ret = (u_char *)&long_ret;
363 break;
366 ast_copy_string(string_ret, ast_channel_accountcode(chan), sizeof(string_ret));
367 *var_len = strlen(string_ret);
368 ret = (u_char *)string_ret;
369 }
370 break;
371 case ASTCHANFORWARDTO:
373 ast_copy_string(string_ret, ast_channel_call_forward(chan), sizeof(string_ret));
374 *var_len = strlen(string_ret);
375 ret = (u_char *)string_ret;
376 }
377 break;
378 case ASTCHANUNIQUEID:
379 ast_copy_string(string_ret, ast_channel_uniqueid(chan), sizeof(string_ret));
380 *var_len = strlen(string_ret);
381 ret = (u_char *)string_ret;
382 break;
383 case ASTCHANCALLGROUP:
384 long_ret = ast_channel_callgroup(chan);
385 ret = (u_char *)&long_ret;
386 break;
388 long_ret = ast_channel_pickupgroup(chan);
389 ret = (u_char *)&long_ret;
390 break;
391 case ASTCHANSTATE:
392 long_ret = ast_channel_state(chan) & 0xffff;
393 ret = (u_char *)&long_ret;
394 break;
395 case ASTCHANMUTED:
396 long_ret = ast_channel_state(chan) & AST_STATE_MUTE ? 1 : 2;
397 ret = (u_char *)&long_ret;
398 break;
399 case ASTCHANRINGS:
400 long_ret = ast_channel_rings(chan);
401 ret = (u_char *)&long_ret;
402 break;
403 case ASTCHANCIDDNID:
404 if (ast_channel_dialed(chan)->number.str) {
405 ast_copy_string(string_ret, ast_channel_dialed(chan)->number.str, sizeof(string_ret));
406 *var_len = strlen(string_ret);
407 ret = (u_char *)string_ret;
408 }
409 break;
410 case ASTCHANCIDNUM:
412 ast_copy_string(string_ret, ast_channel_caller(chan)->id.number.str, sizeof(string_ret));
413 *var_len = strlen(string_ret);
414 ret = (u_char *)string_ret;
415 }
416 break;
417 case ASTCHANCIDNAME:
419 ast_copy_string(string_ret, ast_channel_caller(chan)->id.name.str, sizeof(string_ret));
420 *var_len = strlen(string_ret);
421 ret = (u_char *)string_ret;
422 }
423 break;
424 case ASTCHANCIDANI:
426 ast_copy_string(string_ret, ast_channel_caller(chan)->ani.number.str, sizeof(string_ret));
427 *var_len = strlen(string_ret);
428 ret = (u_char *)string_ret;
429 }
430 break;
431 case ASTCHANCIDRDNIS:
433 ast_copy_string(string_ret, ast_channel_redirecting(chan)->from.number.str, sizeof(string_ret));
434 *var_len = strlen(string_ret);
435 ret = (u_char *)string_ret;
436 }
437 break;
438 case ASTCHANCIDPRES:
439 long_ret = ast_party_id_presentation(&ast_channel_caller(chan)->id);
440 ret = (u_char *)&long_ret;
441 break;
442 case ASTCHANCIDANI2:
443 long_ret = ast_channel_caller(chan)->ani2;
444 ret = (u_char *)&long_ret;
445 break;
446 case ASTCHANCIDTON:
447 long_ret = ast_channel_caller(chan)->id.number.plan;
448 ret = (u_char *)&long_ret;
449 break;
450 case ASTCHANCIDTNS:
452 ret = (u_char *)&long_ret;
453 break;
454 case ASTCHANAMAFLAGS:
455 long_ret = ast_channel_amaflags(chan);
456 ret = (u_char *)&long_ret;
457 break;
458 case ASTCHANADSI:
459 long_ret = ast_channel_adsicpe(chan);
460 ret = (u_char *)&long_ret;
461 break;
462 case ASTCHANTONEZONE:
463 if (ast_channel_zone(chan)) {
464 ast_copy_string(string_ret, ast_channel_zone(chan)->country, sizeof(string_ret));
465 *var_len = strlen(string_ret);
466 ret = (u_char *)string_ret;
467 }
468 break;
470 long_ret = ast_channel_hangupcause(chan);
471 ret = (u_char *)&long_ret;
472 break;
473 case ASTCHANVARIABLES:
475 *var_len = ast_str_strlen(out);
476 ret = (u_char *)ast_str_buffer(out);
477 }
478 break;
479 case ASTCHANFLAGS:
480 bits_ret[0] = 0;
481 for (bit = 0; bit < 8; bit++)
482 bits_ret[0] |= ((ast_channel_flags(chan)->flags & (1 << bit)) >> bit) << (7 - bit);
483 bits_ret[1] = 0;
484 for (bit = 0; bit < 8; bit++)
485 bits_ret[1] |= (((ast_channel_flags(chan)->flags >> 8) & (1 << bit)) >> bit) << (7 - bit);
486 *var_len = 2;
487 ret = bits_ret;
488 break;
490 long_ret = ast_channel_transfercapability(chan);
491 ret = (u_char *)&long_ret;
492 default:
493 break;
494 }
495
496 ast_channel_unlock(chan);
497 chan = ast_channel_unref(chan);
498
499 return ret;
500}
#define ASTCHANMASQR
Definition: agent.c:140
#define ASTCHANMUSICCLASS
Definition: agent.c:137
#define ASTCHANCIDDNID
Definition: agent.c:155
#define ASTCHANTONEZONE
Definition: agent.c:166
#define ASTCHANTRANSFERCAP
Definition: agent.c:170
#define ASTCHANBRIDGE
Definition: agent.c:138
#define ASTCHANMUTED
Definition: agent.c:153
#define ASTCHANDATA
Definition: agent.c:143
#define ASTCHANTYPE
Definition: agent.c:136
#define ASTCHANCIDANI
Definition: agent.c:158
#define ASTCHANFLAGS
Definition: agent.c:169
#define ASTCHANWHENHANGUP
Definition: agent.c:141
#define ASTCHANPICKUPGROUP
Definition: agent.c:151
#define ASTCHANCIDANI2
Definition: agent.c:161
#define ASTCHANCIDTON
Definition: agent.c:162
#define ASTCHANMASQ
Definition: agent.c:139
#define ASTCHANCIDNUM
Definition: agent.c:156
#define ASTCHANNAME
Definition: agent.c:134
#define ASTCHANRINGS
Definition: agent.c:154
#define ASTCHANACCOUNTCODE
Definition: agent.c:147
#define ASTCHANADSI
Definition: agent.c:165
#define ASTCHANCIDRDNIS
Definition: agent.c:159
#define ASTCHANCIDNAME
Definition: agent.c:157
#define ASTCHANAMAFLAGS
Definition: agent.c:164
#define ASTCHANFORWARDTO
Definition: agent.c:148
#define ASTCHANEXTEN
Definition: agent.c:145
#define ASTCHANUNIQUEID
Definition: agent.c:149
#define ASTCHANHANGUPCAUSE
Definition: agent.c:167
#define ASTCHANVARIABLES
Definition: agent.c:168
#define ASTCHANLANGUAGE
Definition: agent.c:135
#define ASTCHANINDEX
Definition: agent.c:133
#define ASTCHANAPP
Definition: agent.c:142
#define ASTCHANPRI
Definition: agent.c:146
#define ASTCHANCIDPRES
Definition: agent.c:160
#define ASTCHANCONTEXT
Definition: agent.c:144
#define ASTCHANCALLGROUP
Definition: agent.c:150
#define ASTCHANSTATE
Definition: agent.c:152
#define ASTCHANCIDTNS
Definition: agent.c:163
static const char type[]
Definition: chan_ooh323.c:109
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_channel * ast_channel_masq(const struct ast_channel *chan)
const char * ast_channel_data(const struct ast_channel *chan)
int ast_channel_rings(const struct ast_channel *chan)
struct ast_channel * ast_channel_bridge_peer(struct ast_channel *chan)
Get the channel's bridge peer only if the bridge is two-party.
Definition: channel.c:10564
int ast_party_id_presentation(const struct ast_party_id *id)
Determine the overall presentation value for the given party.
Definition: channel.c:1821
const char * ast_channel_musicclass(const struct ast_channel *chan)
struct ast_party_redirecting * ast_channel_redirecting(struct ast_channel *chan)
unsigned short ast_channel_transfercapability(const struct ast_channel *chan)
ast_group_t ast_channel_pickupgroup(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
int ast_channel_priority(const struct ast_channel *chan)
const char * ast_channel_uniqueid(const struct ast_channel *chan)
const char * ast_channel_accountcode(const struct ast_channel *chan)
const char * ast_channel_context(const struct ast_channel *chan)
ast_channel_adsicpe
Definition: channel.h:868
const char * ast_channel_appl(const struct ast_channel *chan)
enum ama_flags ast_channel_amaflags(const struct ast_channel *chan)
int ast_channel_hangupcause(const struct ast_channel *chan)
struct ast_party_dialed * ast_channel_dialed(struct ast_channel *chan)
struct ast_tone_zone * ast_channel_zone(const struct ast_channel *chan)
struct timeval * ast_channel_whentohangup(struct ast_channel *chan)
ast_group_t ast_channel_callgroup(const struct ast_channel *chan)
const char * ast_channel_language(const struct ast_channel *chan)
const char * ast_channel_call_forward(const struct ast_channel *chan)
struct ast_channel * ast_channel_masqr(const struct ast_channel *chan)
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
const char * ast_channel_exten(const struct ast_channel *chan)
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_MUTE
Definition: channelstate.h:47
int pbx_builtin_serialize_variables(struct ast_channel *chan, struct ast_str **buf)
Create a human-readable string, specifying all variables and their corresponding values.
static char country[80]
Definition: pbx_dundi.c:205
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
Definition: strings.h:761
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
#define ast_str_alloca(init_len)
Definition: strings.h:848
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
struct ast_bridge * bridge
struct ast_party_id id
Caller party ID.
Definition: channel.h:420
int ani2
Automatic Number Identification 2 (Info Digits)
Definition: channel.h:433
struct ast_party_id ani
Automatic Number Identification (ANI)
Definition: channel.h:427
struct ast_party_dialed::@208 number
Dialed/Called number.
char * str
Subscriber phone number (Malloced)
Definition: channel.h:386
int transit_network_select
Transit Network Select.
Definition: channel.h:397
struct ast_party_name name
Subscriber name.
Definition: channel.h:340
struct ast_party_number number
Subscriber phone number.
Definition: channel.h:342
unsigned char valid
TRUE if the name information is valid/present.
Definition: channel.h:279
char * str
Subscriber name (Malloced)
Definition: channel.h:264
unsigned char valid
TRUE if the number information is valid/present.
Definition: channel.h:297
char * str
Subscriber phone number (Malloced)
Definition: channel.h:291
int plan
Q.931 Type-Of-Number and Numbering-Plan encoded fields.
Definition: channel.h:293
struct ast_party_id from
Who is redirecting the call (Sent to the party the call is redirected toward)
Definition: channel.h:527
Support for dynamic strings.
Definition: strings.h:623
Number structure.
Definition: app_followme.c:154
int ast_tvzero(const struct timeval t)
Returns true if the argument is 0,0.
Definition: time.h:117
FILE * out
Definition: utils/frame.c:33

References ast_party_caller::ani, ast_party_caller::ani2, ast_active_channels(), ast_channel_accountcode(), ast_channel_amaflags(), ast_channel_appl(), ast_channel_bridge_peer(), ast_channel_call_forward(), ast_channel_caller(), ast_channel_callgroup(), ast_channel_context(), ast_channel_data(), ast_channel_dialed(), ast_channel_exten(), ast_channel_flags(), ast_channel_hangupcause(), ast_channel_iterator_all_new(), ast_channel_iterator_destroy(), ast_channel_iterator_next(), ast_channel_language(), ast_channel_lock, ast_channel_masq(), ast_channel_masqr(), ast_channel_musicclass(), ast_channel_name(), ast_channel_pickupgroup(), ast_channel_priority(), ast_channel_redirecting(), ast_channel_rings(), ast_channel_tech(), ast_channel_transfercapability(), ast_channel_uniqueid(), ast_channel_unlock, ast_channel_unref, ast_channel_whentohangup(), ast_channel_zone(), ast_copy_string(), 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, ASTCHANMASQ, ASTCHANMASQR, ASTCHANMUSICCLASS, ASTCHANMUTED, ASTCHANNAME, ASTCHANPICKUPGROUP, ASTCHANPRI, ASTCHANRINGS, ASTCHANSTATE, ASTCHANTONEZONE, ASTCHANTRANSFERCAP, ASTCHANTYPE, ASTCHANUNIQUEID, ASTCHANVARIABLES, ASTCHANWHENHANGUP, ast_channel::bridge, country, ast_party_redirecting::from, header_simple_table(), ast_party_caller::id, name, ast_party_id::name, NULL, ast_party_id::number, ast_party_dialed::number, out, pbx_builtin_serialize_variables(), ast_party_number::plan, ast_party_name::str, ast_party_number::str, ast_party_dialed::str, ast_party_dialed::transit_network_select, type, ast_party_name::valid, and ast_party_number::valid.

Referenced by init_asterisk_mib().

◆ ast_var_Config()

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

623{
624 static unsigned long long_ret;
625 struct timeval tval;
626
627 if (header_generic(vp, name, length, exact, var_len, write_method))
628 return NULL;
629
630 switch (vp->magic) {
631 case ASTCONFUPTIME:
632 gettimeofday(&tval, NULL);
633 long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
634 return (u_char *)&long_ret;
636 gettimeofday(&tval, NULL);
637 if (ast_lastreloadtime.tv_sec)
638 long_ret = difftime(tval.tv_sec, ast_lastreloadtime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_lastreloadtime.tv_usec / 10000;
639 else
640 long_ret = difftime(tval.tv_sec, ast_startuptime.tv_sec) * 100 + tval.tv_usec / 10000 - ast_startuptime.tv_usec / 10000;
641 return (u_char *)&long_ret;
642 case ASTCONFPID:
643 long_ret = getpid();
644 return (u_char *)&long_ret;
645 case ASTCONFSOCKET:
646 *var_len = strlen(ast_config_AST_SOCKET);
647 return (u_char *)ast_config_AST_SOCKET;
649 long_ret = ast_active_calls();
650 return (u_char *)&long_ret;
652 long_ret = ast_processed_calls();
653 return (u_char *)&long_ret;
654 default:
655 break;
656 }
657 return NULL;
658}
#define ASTCONFACTIVECALLS
Definition: agent.c:113
#define ASTCONFPROCESSEDCALLS
Definition: agent.c:114
#define ASTCONFPID
Definition: agent.c:111
#define ASTCONFUPTIME
Definition: agent.c:109
#define ASTCONFSOCKET
Definition: agent.c:112
#define ASTCONFRELOADTIME
Definition: agent.c:110
struct timeval ast_lastreloadtime
Definition: asterisk.c:337
struct timeval ast_startuptime
Definition: asterisk.c:336
const char * ast_config_AST_SOCKET
Definition: options.c:167
int ast_active_calls(void)
Retrieve the number of active calls.
Definition: pbx.c:4760
int ast_processed_calls(void)
Retrieve the total number of calls processed through the PBX since last restart.
Definition: pbx.c:4765

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

Referenced by init_asterisk_mib().

◆ ast_var_indications()

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

662{
663 static unsigned long long_ret;
664 static char ret_buf[128];
665 struct ast_tone_zone *tz = NULL;
666
667 if (header_generic(vp, name, length, exact, var_len, write_method))
668 return NULL;
669
670 switch (vp->magic) {
671 case ASTINDCOUNT:
672 {
673 struct ao2_iterator i;
674
675 long_ret = 0;
676
678 while ((tz = ao2_iterator_next(&i))) {
680 long_ret++;
681 }
683
684 return (u_char *) &long_ret;
685 }
686 case ASTINDCURRENT:
688 if (tz) {
689 ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
690 *var_len = strlen(ret_buf);
692 return (u_char *) ret_buf;
693 }
694 *var_len = 0;
695 return NULL;
696 default:
697 break;
698 }
699 return NULL;
700}
#define ASTINDCURRENT
Definition: agent.c:121
#define ASTINDCOUNT
Definition: agent.c:120
#define ao2_iterator_next(iter)
Definition: astobj2.h:1911
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static char * tz
Definition: cdr_pgsql.c:71
struct ao2_iterator ast_tone_zone_iterator_init(void)
Get an iterator for the available tone zones.
Definition: indications.c:403
static struct ast_tone_zone * ast_tone_zone_unref(struct ast_tone_zone *tz)
Release a reference to an ast_tone_zone.
Definition: indications.h:205
struct ast_tone_zone * ast_get_indication_zone(const char *country)
locate ast_tone_zone
Definition: indications.c:439
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821
A set of tones for a given locale.
Definition: indications.h:74

References ao2_iterator_destroy(), ao2_iterator_next, ast_copy_string(), ast_get_indication_zone(), ast_tone_zone_iterator_init(), ast_tone_zone_unref(), ASTINDCOUNT, ASTINDCURRENT, header_generic(), name, NULL, and tz.

Referenced by init_asterisk_mib().

◆ ast_var_indications_table()

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

704{
705 static unsigned long long_ret;
706 static char ret_buf[256];
707 struct ast_tone_zone *tz = NULL;
708 int i;
709 struct ao2_iterator iter;
710
711 if (header_simple_table(vp, name, length, exact, var_len, write_method, -1)) {
712 return NULL;
713 }
714
715 i = name[*length - 1] - 1;
716
718
719 while ((tz = ao2_iterator_next(&iter)) && i) {
721 i--;
722 }
724
725 if (tz == NULL) {
726 return NULL;
727 }
728
729 switch (vp->magic) {
730 case ASTINDINDEX:
732 long_ret = name[*length - 1];
733 return (u_char *)&long_ret;
734 case ASTINDCOUNTRY:
735 ast_copy_string(ret_buf, tz->country, sizeof(ret_buf));
737 *var_len = strlen(ret_buf);
738 return (u_char *) ret_buf;
739 case ASTINDALIAS:
740 /* No longer exists */
742 return NULL;
745 ast_copy_string(ret_buf, tz->description, sizeof(ret_buf));
748 *var_len = strlen(ret_buf);
749 return (u_char *) ret_buf;
750 default:
752 break;
753 }
754 return NULL;
755}
#define ASTINDDESCRIPTION
Definition: agent.c:127
#define ASTINDINDEX
Definition: agent.c:124
#define ASTINDCOUNTRY
Definition: agent.c:125
#define ASTINDALIAS
Definition: agent.c:126
#define ast_tone_zone_unlock(tz)
Unlock an ast_tone_zone.
Definition: indications.h:193
#define ast_tone_zone_lock(tz)
Lock an ast_tone_zone.
Definition: indications.h:188

References ao2_iterator_destroy(), 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(), name, NULL, and tz.

Referenced by init_asterisk_mib().

◆ ast_var_Modules()

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

765{
766 static unsigned long long_ret;
767
768 if (header_generic(vp, name, length, exact, var_len, write_method))
769 return NULL;
770
771 if (vp->magic != ASTMODCOUNT)
772 return NULL;
773
775
776 return (u_char *)&long_ret;
777}
#define ASTMODCOUNT
Definition: agent.c:117
static int countmodule(const char *mod, const char *desc, int use, const char *status, const char *like, enum ast_module_support_level support_level)
Definition: agent.c:757
int ast_update_module_list(int(*modentry)(const char *module, const char *description, int usecnt, const char *status, const char *like, enum ast_module_support_level support_level), const char *like)
Ask for a list of modules, descriptions, use counts and status.
Definition: loader.c:2583

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

Referenced by init_asterisk_mib().

◆ ast_var_Version()

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

781{
782 static unsigned long long_ret;
783
784 if (header_generic(vp, name, length, exact, var_len, write_method))
785 return NULL;
786
787 switch (vp->magic) {
788 case ASTVERSTRING:
789 {
790 const char *version = ast_get_version();
791 *var_len = strlen(version);
792 return (u_char *)version;
793 }
794 case ASTVERTAG:
795 sscanf(ast_get_version_num(), "%30lu", &long_ret);
796 return (u_char *)&long_ret;
797 default:
798 break;
799 }
800 return NULL;
801}
#define ASTVERTAG
Definition: agent.c:106
#define ASTVERSTRING
Definition: agent.c:105
const char * ast_get_version(void)
Retrieve the Asterisk version string.
const char * ast_get_version_num(void)
Retrieve the numeric Asterisk version.
static char version[AST_MAX_EXTENSION]
Definition: chan_ooh323.c:391

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

Referenced by init_asterisk_mib().

◆ countmodule()

static int countmodule ( const char *  mod,
const char *  desc,
int  use,
const char *  status,
const char *  like,
enum ast_module_support_level  support_level 
)
static

Definition at line 757 of file agent.c.

759{
760 return 1;
761}

Referenced by ast_var_Modules().

◆ header_generic()

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

◆ header_simple_table()

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

◆ init_asterisk_mib()

static void init_asterisk_mib ( void  )
static

Definition at line 809 of file agent.c.

810{
811 static struct variable4 asterisk_vars[] = {
812 {ASTVERSTRING, ASN_OCTET_STR, RONLY, ast_var_Version, 2, {ASTVERSION, ASTVERSTRING}},
813 {ASTVERTAG, ASN_UNSIGNED, RONLY, ast_var_Version, 2, {ASTVERSION, ASTVERTAG}},
814 {ASTCONFUPTIME, ASN_TIMETICKS, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFUPTIME}},
816 {ASTCONFPID, ASN_INTEGER, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFPID}},
817 {ASTCONFSOCKET, ASN_OCTET_STR, RONLY, ast_var_Config, 2, {ASTCONFIGURATION, ASTCONFSOCKET}},
820 {ASTMODCOUNT, ASN_INTEGER, RONLY, ast_var_Modules , 2, {ASTMODULES, ASTMODCOUNT}},
821 {ASTINDCOUNT, ASN_INTEGER, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCOUNT}},
822 {ASTINDCURRENT, ASN_OCTET_STR, RONLY, ast_var_indications, 2, {ASTINDICATIONS, ASTINDCURRENT}},
827 {ASTCHANCOUNT, ASN_GAUGE, RONLY, ast_var_channels, 2, {ASTCHANNELS, ASTCHANCOUNT}},
829 {ASTCHANNAME, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANNAME}},
831 {ASTCHANTYPE, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANTYPE}},
834 {ASTCHANMASQ, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQ}},
835 {ASTCHANMASQR, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANMASQR}},
837 {ASTCHANAPP, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANAPP}},
838 {ASTCHANDATA, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANDATA}},
840 {ASTCHANEXTEN, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANEXTEN}},
841 {ASTCHANPRI, ASN_INTEGER, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANPRI}},
864 {ASTCHANFLAGS, ASN_OCTET_STR, RONLY, ast_var_channels_table, 4, {ASTCHANNELS, ASTCHANTABLE, 1, ASTCHANFLAGS}},
875 };
876
878 "ASTERISK-MIB implementation for Asterisk.");
879
880 REGISTER_MIB("res_snmp", asterisk_vars, variable4, asterisk_oid);
881
882 snmp_register_callback(SNMP_CALLBACK_LIBRARY,
883 SNMP_CALLBACK_SHUTDOWN,
885}
static u_char * ast_var_indications_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:702
#define ASTCHANTYPETABLE
Definition: agent.c:174
static u_char * ast_var_indications(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:660
#define ASTCONFIGURATION
Definition: agent.c:108
static u_char * ast_var_Modules(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:763
#define ASTMODULES
Definition: agent.c:116
static u_char * ast_var_channels(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:217
#define ASTCHANNELS
Definition: agent.c:129
static u_char * ast_var_Version(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:779
#define ASTCHANTABLE
Definition: agent.c:132
#define ASTCHANSCALARS
Definition: agent.c:183
static u_char * ast_var_Config(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:621
static u_char * ast_var_channel_types(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:502
static oid asterisk_oid[]
Definition: agent.c:97
static u_char * ast_var_channel_bridge(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:588
#define ASTINDTABLE
Definition: agent.c:123
int register_sysORTable(oid *, size_t, const char *)
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)
Definition: agent.c:521
#define ASTVERSION
Definition: agent.c:104
#define ASTINDICATIONS
Definition: agent.c:119
static int term_asterisk_mib(int majorID, int minorID, void *serverarg, void *clientarg)
Definition: agent.c:803
static u_char * ast_var_channels_table(struct variable *vp, oid *name, size_t *length, int exact, size_t *var_len, WriteMethod **write_method)
Definition: agent.c:233

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, 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, NULL, register_sysORTable(), and term_asterisk_mib().

Referenced by agent_thread().

◆ register_sysORTable()

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

Referenced by init_asterisk_mib().

◆ term_asterisk_mib()

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

Definition at line 803 of file agent.c.

804{
806 return 0;
807}
int unregister_sysORTable(oid *, size_t)

References asterisk_oid, and unregister_sysORTable().

Referenced by init_asterisk_mib().

◆ unregister_sysORTable()

int unregister_sysORTable ( oid *  ,
size_t   
)

Referenced by term_asterisk_mib().

Variable Documentation

◆ asterisk_oid

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

Definition at line 97 of file agent.c.

Referenced by init_asterisk_mib(), and term_asterisk_mib().