hi,
I am reading the AMI documentation from the Asterisk Developpers Documentation project website these days but its very difficult to understand as for most functions, variables and data structures no plain english is used to tell what their functionality is before we dive in the code. or maybe i dont kow if there is any documentation out there or not which gives you a basic ides first and then starts with the code, as im new asterisk user.
So anybody who has aome material related to AMI plz share. and also give me some tips on reading someone else’s code. Everybody knows how painful it is to read and understand someone else’s code.
babye
What exactly do you want to know in muted.c ?
im just reading manager.c these days and im here to find an easy way to understand it. there is no properly maintained document about it. i came here with a hope that maybe someone here can help me understand it.
for example im reading the function:
int action_events (struct mansession *s, struct message *m)
but i have no idea what it does. all i can think of is, its about event masking, why event masking? again no idea.
Events is the action command in manager api that can decide if the client wants to receive
or not receive events.
There is no fine graned control in that either all events are sent(when eventmask is on) or
no events are sent to the client when the eventmask is off.
For more details refer:
voip-info.org/wiki/index.php … ion+Events
In manager.h the event bits are set
#define EVENT_FLAG_SYSTEM (1 << 0) /* System events such as module load/unload */
#define EVENT_FLAG_CALL (1 << 1) /* Call event, such as state change, etc */
#define EVENT_FLAG_LOG (1 << 2) /* Log events */
#define EVENT_FLAG_VERBOSE (1 << 3) /* Verbose messages */
#define EVENT_FLAG_COMMAND (1 << 4) /* Ability to read/set commands */
#define EVENT_FLAG_AGENT (1 << 5) /* Ability to read/set agent info */
#define EVENT_FLAG_USER (1 << 6) /* Ability to read/set user info */
as you can see the values are 1,2,4,8,16,32
and in manager.c the perms struct array gives a label to the events
static struct permalias {
int num;
char *label;
} perms[] = {
{ EVENT_FLAG_SYSTEM, "system" },
{ EVENT_FLAG_CALL, "call" },
{ EVENT_FLAG_LOG, "log" },
{ EVENT_FLAG_VERBOSE, "verbose" },
{ EVENT_FLAG_COMMAND, "command" },
{ EVENT_FLAG_AGENT, "agent" },
{ EVENT_FLAG_USER, "user" },
{ -1, "all" },
{ 0, "none" },
}
In the function ast_strings_to_mask(manager.c) :
[code]static int ast_strings_to_mask(char *string)
{
int x, ret = -1;
x = ast_is_number(string);
if (x) {
ret = x;
} else if (ast_strlen_zero(string)) {
ret = -1;
} else if (ast_false(string)) {
ret = 0;
} else if (ast_true(string)) {
ret = 0;
for (x=0; x<sizeof(perms) / sizeof(perms[0]);act x++)
ret |= perms[x].num;
} else {
ret = 0;
for (x=0; x<sizeof(perms) / sizeof(perms[0]); x++) {
if (ast_instring(string, perms[x].label, ','))
ret |= perms[x].num;
}
}
return ret;
}[/code]
If the string contains a number that event mask is sent as it is.
So I have to take my previous statement and say that it is really fine grained in that
you can set some events and mask other events e.g.
0001 means that only send me(client) System events such as module load/unload(EVENT_FLAG_SYSTEM).
ast_false and ast_true checks for the “on” and “off” states and returns true(1) accordingly.
The others are self explainatory.
see if the above information helps.