[asterisk-commits] nadi: branch group/trunk-cm-csel-hash r47421 -
/team/group/trunk-cm-csel-hash...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Fri Nov 10 07:29:34 MST 2006
Author: nadi
Date: Fri Nov 10 08:29:34 2006
New Revision: 47421
URL: http://svn.digium.com/view/asterisk?view=rev&rev=47421
Log:
event logging revisited
Modified:
team/group/trunk-cm-csel-hash/channels/chan_misdn.c
Modified: team/group/trunk-cm-csel-hash/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/channels/chan_misdn.c?view=diff&rev=47421&r1=47420&r2=47421
==============================================================================
--- team/group/trunk-cm-csel-hash/channels/chan_misdn.c (original)
+++ team/group/trunk-cm-csel-hash/channels/chan_misdn.c Fri Nov 10 08:29:34 2006
@@ -136,12 +136,12 @@
};
enum event_log_elements {
- L_CHANNEL = 1 << 0,
- L_OAD = 1 << 1,
- L_DAD = 1 << 2,
- L_CAD = 1 << 3,
- L_RAD = 1 << 4,
- L_PID = 1 << 5,
+ L_PID = 1 << 0,
+ L_CHANNEL = 1 << 1,
+ L_OAD = 1 << 2,
+ L_DAD = 1 << 3,
+ L_CAD = 1 << 4,
+ L_RAD = 1 << 5,
L_MODE = 1 << 6,
L_CAUSE = 1 << 7,
L_OCAUSE = 1 << 8,
@@ -791,9 +791,9 @@
/* State Machine: mISDN */
static int handle_aevent_hangup (void *p, int state, int event);
static int handle_mevent_setup (void *p, int state, int event);
-static int handle_mevent_setup_folowup (void *p, int state, int event);
-static int handle_mevent_information(void *p, int state, int event);
-static int handle_mevent_information_dtmf(void *p, int state, int event);
+static int handle_mevent_setup_followup (void *p, int state, int event);
+static int handle_mevent_information (void *p, int state, int event);
+static int handle_mevent_information_dtmf (void *p, int state, int event);
static int handle_mevent_setup_acknowledge (void *p, int state, int event);
static int handle_mevent_connect (void *p, int state, int event);
static int handle_mevent_disconnect (void *p, int state, int event);
@@ -831,11 +831,11 @@
/*
* MISDN EVENTS
*/
- { STATE_ANY, EVENT_SETUP, STATE_CONTINUE, EVENT_NONE, handle_mevent_setup },
- { STATE_ANY, EVENT_SETUP, MISDN_DIALING, EVENT_NONE, handle_mevent_setup_folowup },
- { MISDN_WAITING4DIGS, EVENT_INFORMATION, STATE_CONTINUE, EVENT_NONE, handle_mevent_information},
- { MISDN_WAITING4DIGS, EVENT_INFORMATION, STATE_KEEP, EVENT_NONE, handle_mevent_setup_folowup},
- { MISDN_CONNECTED, EVENT_INFORMATION, STATE_KEEP, EVENT_NONE, handle_mevent_information_dtmf},
+ { STATE_ANY, EVENT_SETUP, STATE_CONTINUE, EVENT_NONE, handle_mevent_setup },
+ { STATE_ANY, EVENT_SETUP, MISDN_DIALING, EVENT_NONE, handle_mevent_setup_followup },
+ { MISDN_WAITING4DIGS, EVENT_INFORMATION, STATE_CONTINUE, EVENT_NONE, handle_mevent_information },
+ { MISDN_WAITING4DIGS, EVENT_INFORMATION, STATE_KEEP, EVENT_NONE, handle_mevent_setup_followup },
+ { MISDN_CONNECTED, EVENT_INFORMATION, STATE_KEEP, EVENT_NONE, handle_mevent_information_dtmf },
{ STATE_ANY, EVENT_SETUP_ACKNOWLEDGE, MISDN_CALLING_ACKNOWLEDGE, EVENT_NONE, handle_mevent_setup_acknowledge },
{ STATE_ANY, EVENT_PROCEEDING, MISDN_PROCEEDING, AEVENT_CPROCEEDING, handle_mevent_proceeding_progress },
{ STATE_ANY, EVENT_PROGRESS, MISDN_PROGRESS, AEVENT_CPROGRESS, handle_mevent_proceeding_progress },
@@ -859,71 +859,74 @@
{ STATE_ANY, EVENT_STATUS, STATE_KEEP, EVENT_NONE, NULL},
};
-static const struct event_log_info * geteventinfo (int event)
-{
+static const struct event_log_info * get_event_info (int event)
+{
+
+#define L_DEFAULTS (L_PID | L_OAD | L_DAD)
+
static struct event_log_info mevents[] = {
- { "NOTHING", L_PID | L_OAD | L_DAD, 0 },
- { "TONE_GENERATE", L_PID | L_OAD | L_DAD, 0 },
- { "BCHAN_DATA", L_PID | L_OAD | L_DAD, 0 },
- { "BCHAN_ACTIVATED", L_PID | L_OAD | L_DAD, 0 },
- { "BCHAN_ERROR", L_PID | L_OAD | L_DAD, 0 },
- { "CLEANUP", L_PID | L_OAD | L_DAD, 0 },
- { "PROCEEDING", L_PID | L_OAD | L_DAD, 0 },
- { "PROGRESS", L_PID | L_OAD | L_DAD, 0 },
- { "SETUP", L_PID | L_OAD | L_DAD, 0},
- { "ALERTING", L_PID | L_OAD | L_DAD, 0 },
- { "CONNECT", L_PID | L_OAD | L_DAD, 0 },
- { "SETUP_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
- { "CONNECT_ACKNOWLEDGE ", L_PID | L_OAD | L_DAD, 0 },
- { "USER_INFORMATION", L_PID | L_OAD | L_DAD, 0 },
- { "SUSPEND_REJECT", L_PID | L_OAD | L_DAD, 0 },
- { "RESUME_REJECT", L_PID | L_OAD | L_DAD, 0 },
- { "HOLD", L_PID | L_OAD | L_DAD, 0 },
- { "SUSPEND", L_PID | L_OAD | L_DAD, 0 },
- { "RESUME", L_PID | L_OAD | L_DAD, 0 },
- { "HOLD_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
- { "SUSPEND_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
- { "RESUME_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
- { "HOLD_REJECT", L_PID | L_OAD | L_DAD, 0 },
- { "RETRIEVE", L_PID | L_OAD | L_DAD, 0 },
- { "RETRIEVE_ACKNOWLEDGE", L_PID | L_OAD | L_DAD, 0 },
- { "RETRIEVE_REJECT", L_PID | L_OAD | L_DAD, 0 },
- { "DISCONNECT", L_PID | L_OAD | L_DAD, 0 },
- { "RESTART", L_PID | L_OAD | L_DAD, 0 },
- { "RELEASE", L_PID | L_OAD | L_DAD, 0 },
- { "RELEASE_COMPLETE", L_PID | L_OAD | L_DAD, 0 },
- { "FACILITY", L_PID | L_OAD | L_DAD, 0 },
- { "NOTIFY", L_PID | L_OAD | L_DAD, 0 },
- { "STATUS_ENQUIRY", L_PID | L_OAD | L_DAD, 0 },
- { "INFORMATION", L_PID | L_OAD | L_DAD, 0 },
- { "STATUS", L_PID | L_OAD | L_DAD, 0 },
- { "TIMEOUT", L_PID | L_OAD | L_DAD, 0 },
- { "DTMF_TONE", L_PID | L_OAD | L_DAD, 0 },
- { "NEW_L3ID", L_PID | L_OAD | L_DAD, 0 },
- { "NEW_BC", L_PID | L_OAD | L_DAD, 0 },
- { "PORT_ALARM", L_PID | L_OAD | L_DAD, 0 },
- { "NEW_CHANNEL", L_PID | L_OAD | L_DAD, 0 },
- { "UNKNOWN", L_PID | L_OAD | L_DAD, 0 },
+ { "NOTHING", L_DEFAULTS, 0 },
+ { "TONE_GENERATE", L_DEFAULTS, 0 },
+ { "BCHAN_DATA", L_DEFAULTS, 0 },
+ { "BCHAN_ACTIVATED", L_DEFAULTS, 0 },
+ { "BCHAN_ERROR", L_DEFAULTS, 0 },
+ { "CLEANUP", L_DEFAULTS, 0 },
+ { "PROCEEDING", L_DEFAULTS, 0 },
+ { "PROGRESS", L_DEFAULTS, 0 },
+ { "SETUP", L_DEFAULTS, 0},
+ { "ALERTING", L_DEFAULTS, 0 },
+ { "CONNECT", L_DEFAULTS, 0 },
+ { "SETUP_ACKNOWLEDGE", L_DEFAULTS, 0 },
+ { "CONNECT_ACKNOWLEDGE ", L_DEFAULTS, 0 },
+ { "USER_INFORMATION", L_DEFAULTS, 0 },
+ { "SUSPEND_REJECT", L_DEFAULTS, 0 },
+ { "RESUME_REJECT", L_DEFAULTS, 0 },
+ { "HOLD", L_DEFAULTS, 0 },
+ { "SUSPEND", L_DEFAULTS, 0 },
+ { "RESUME", L_DEFAULTS, 0 },
+ { "HOLD_ACKNOWLEDGE", L_DEFAULTS, 0 },
+ { "SUSPEND_ACKNOWLEDGE", L_DEFAULTS, 0 },
+ { "RESUME_ACKNOWLEDGE", L_DEFAULTS, 0 },
+ { "HOLD_REJECT", L_DEFAULTS, 0 },
+ { "RETRIEVE", L_DEFAULTS, 0 },
+ { "RETRIEVE_ACKNOWLEDGE", L_DEFAULTS, 0 },
+ { "RETRIEVE_REJECT", L_DEFAULTS, 0 },
+ { "DISCONNECT", L_DEFAULTS, 0 },
+ { "RESTART", L_DEFAULTS, 0 },
+ { "RELEASE", L_DEFAULTS, 0 },
+ { "RELEASE_COMPLETE", L_DEFAULTS, 0 },
+ { "FACILITY", L_DEFAULTS, 0 },
+ { "NOTIFY", L_DEFAULTS, 0 },
+ { "STATUS_ENQUIRY", L_DEFAULTS, 0 },
+ { "INFORMATION", L_DEFAULTS | L_INFODAD, 0 },
+ { "STATUS", L_DEFAULTS, 0 },
+ { "TIMEOUT", L_DEFAULTS, 0 },
+ { "DTMF_TONE", L_DEFAULTS, 0 },
+ { "NEW_L3ID", L_DEFAULTS, 0 },
+ { "NEW_BC", L_DEFAULTS, 0 },
+ { "PORT_ALARM", L_DEFAULTS, 0 },
+ { "NEW_CHANNEL", L_DEFAULTS, 0 },
+ { "UNKNOWN", L_DEFAULTS, 0 },
};
static struct event_log_info aevents[] = {
- { "NOTHING", L_PID | L_OAD | L_DAD, 0 },
- { "CALL", L_PID | L_OAD | L_DAD, 0 },
- { "HANGUP", L_PID | L_OAD | L_DAD, 0 },
- { "ANSWER", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_BUSY", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_RING", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_RINGING", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_ANSWER", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_TAKEOFFHOOK", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_OFFHOOK", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_FLASH", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_PROGRESS", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_PROCEEDING", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_CONGESTION", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_HOLD", L_PID | L_OAD | L_DAD, 0 },
- { "CONTROL_UNHOLD", L_PID | L_OAD | L_DAD, 0 },
- { "UNKNOWN", L_PID | L_OAD | L_DAD, 0 },
+ { "NOTHING", L_DEFAULTS, 0 },
+ { "CALL", L_DEFAULTS, 0 },
+ { "HANGUP", L_DEFAULTS, 0 },
+ { "ANSWER", L_DEFAULTS, 0 },
+ { "CONTROL_BUSY", L_DEFAULTS, 0 },
+ { "CONTROL_RING", L_DEFAULTS, 0 },
+ { "CONTROL_RINGING", L_DEFAULTS, 0 },
+ { "CONTROL_ANSWER", L_DEFAULTS, 0 },
+ { "CONTROL_TAKEOFFHOOK", L_DEFAULTS, 0 },
+ { "CONTROL_OFFHOOK", L_DEFAULTS, 0 },
+ { "CONTROL_FLASH", L_DEFAULTS, 0 },
+ { "CONTROL_PROGRESS", L_DEFAULTS, 0 },
+ { "CONTROL_PROCEEDING", L_DEFAULTS, 0 },
+ { "CONTROL_CONGESTION", L_DEFAULTS, 0 },
+ { "CONTROL_HOLD", L_DEFAULTS, 0 },
+ { "CONTROL_UNHOLD", L_DEFAULTS, 0 },
+ { "UNKNOWN", L_DEFAULTS, 0 },
};
if (event >= EVENT_NOTHING && event <= EVENT_UNKNOWN)
@@ -932,6 +935,100 @@
return &aevents[event - AEVENT_NOTHING];
else
return &mevents[EVENT_UNKNOWN];
+}
+
+static const char * get_state_string (int state)
+{
+ static const char *misdn_chan_states[] = {
+ "NOTHING",
+ "WAITING4DIGS",
+ "EXTCANTMATCH",
+ "DIALING",
+ "PROGRESS",
+ "PROCEEDING",
+ "CALLING",
+ "CALLING_ACKNOWLEDGE",
+ "ALERTING",
+ "BUSY",
+ "CONNECTED",
+ "PRECONNECTED",
+ "DISCONNECTED",
+ "RELEASED",
+ "BRIDGED",
+ "CLEANING",
+ "HUNGUP_FROM_MISDN",
+ "HUNGUP_FROM_AST",
+ "HOLDED",
+ "HOLD_DISCONNECT",
+ "FIXUP",
+ "UNKNOWN",
+ };
+
+ if (state < MISDN_NOTHING || state > MISDN_FIXUP)
+ return misdn_chan_states[MISDN_FIXUP + 1];
+
+ return misdn_chan_states[state];
+}
+
+static inline void event_info_string (char *buf, int bufsize, struct chan_list *ch, int *elems, int num)
+{
+ int first = 0;
+ char tmpbuf[256];
+
+#define IF_INFO(i,fmt,parm) \
+ if (*elems & (i) && num) { \
+ *elems &= ~(i); \
+ snprintf(tmpbuf, sizeof(tmpbuf), "%s" fmt, !(first--) ? "" : " ", parm); \
+ strncat(buf, tmpbuf, bufsize); \
+ buf[bufsize - 1] = 0; \
+ if (!--num) \
+ return; \
+ }
+
+ IF_INFO(L_PID, "pid:%d", ch->bc->pid);
+ IF_INFO(L_CHANNEL, "ch:%d", ch->bc->channel);
+ IF_INFO(L_OAD, "oad:%s", ch->bc->oad);
+ IF_INFO(L_DAD, "dad:%s", ch->bc->dad);
+ IF_INFO(L_CAD, "cad:%s", ch->bc->cad);
+ IF_INFO(L_RAD, "rad:%s", ch->bc->rad);
+ IF_INFO(L_MODE, "mode:%s", ch->bc->nt ? "nt" : "te");
+ IF_INFO(L_CAUSE, "cause:%d", ch->bc->cause);
+ IF_INFO(L_OCAUSE, "out_cause:%d", ch->bc->out_cause);
+ IF_INFO(L_DNUMPLAN, "dnumplan:%d", ch->bc->dnumplan);
+ IF_INFO(L_RNUMPLAN, "rnumplan:%d", ch->bc->rnumplan);
+ IF_INFO(L_CPNNUMPLAN, "cpnnumplan:%d", ch->bc->cpnnumplan);
+ IF_INFO(L_INFODAD, "infodad:%s", ch->bc->info_dad);
+ IF_INFO(L_PRES, "pres:%d", ch->bc->pres);
+ IF_INFO(L_SCREEN, "screen:%d", ch->bc->screen);
+ IF_INFO(L_STATE, "state:%s", get_state_string(state_machine_get_state(ch->sm)));
+ IF_INFO(L_BCSTATE, "bc_state:%s", bc_state2str(ch->bc->bc_state));
+ IF_INFO(L_CONTEXT, "ctx:%s", ch->context);
+}
+
+static void log_event (void *p, int direction, int state, int event)
+{
+ struct chan_list *ch = p;
+ const struct event_log_info *info = get_event_info(event);
+ int elems;
+ char buf[1024] = "";
+
+ elems = info->elements;
+ if (elems)
+ event_info_string(buf, sizeof(buf), ch, &elems, 7);
+ chan_misdn_log(1, ch->bc->port, "%c%s %s%s%s%s",
+ event > EVENT_NOTHING && event < EVENT_UNKNOWN ? 'I' : '*',
+ direction == LOG_RECEIVE ? "->" : "<-",
+ info->name,
+ info->elements ? " (" : "",
+ info->elements ? buf : "",
+ info->elements ? ")\n" : "\n");
+
+ elems = info->additional;
+ while (elems) {
+ *buf = 0;
+ event_info_string(buf, sizeof(buf), ch, &elems, 3);
+ chan_misdn_log(1, ch->bc->port, " %s\n", buf);
+ }
}
static int send_event (void *p, int event)
@@ -964,78 +1061,6 @@
return re;
}
-#if 0
-enum event_log_elements {
- L_CHANNEL = 1 << 0,
- L_OAD = 1 << 1,
- L_DAD = 1 << 2,
- L_CAD = 1 << 3,
- L_RAD = 1 << 4,
- L_PID = 1 << 5,
- L_MODE = 1 << 6,
- L_CAUSE = 1 << 7,
- L_OCAUSE = 1 << 8,
- L_DNUMPLAN = 1 << 9,
- L_RNUMPLAN = 1 << 10,
- L_CPNNUMPLAN = 1 << 11,
- L_INFODAD = 1 << 12,
- L_PRES = 1 << 13,
- L_SCREEN = 1 << 14,
- L_STATE = 1 << 15,
- L_BCSTATE = 1 << 16,
- L_CONTEXT = 1 << 17,
-};
-#endif
-
-static inline void event_info_string (char *buf, int bufsize, struct chan_list *ch, int *elems, int num)
-{
- int first = 0;
- char tmpbuf[256];
-
-#define IF_INFO(i,fmt,parm) \
- if (*elems & (i) && num) { \
- *elems &= ~(i); \
- --num; \
- snprintf(tmpbuf, sizeof(tmpbuf), "%s" fmt, !(first--) ? "" : " ", parm); \
- strncat(buf, tmpbuf, bufsize); \
- buf[bufsize - 1] = 0; \
- }
-
- IF_INFO(L_CHANNEL, "ch:%d", ch->bc->channel);
- IF_INFO(L_OAD, "oad:%s", ch->bc->oad);
- IF_INFO(L_DAD, "dad:%s", ch->bc->dad);
- IF_INFO(L_PID, "pid:%d", ch->bc->pid);
- IF_INFO(L_MODE, "mode:%s", ch->bc->nt ? "nt" : "te");
- IF_INFO(L_SCREEN, "screen:%d", ch->bc->screen);
- IF_INFO(L_CONTEXT, "ctx:%s", ch->context);
-}
-
-static void log_event (void *p, int direction, int state, int event)
-{
- struct chan_list *ch = p;
- const struct event_log_info *info = geteventinfo(event);
- int elems;
- char buf[1024] = "";
-
- elems = info->elements;
- if (elems)
- event_info_string(buf, sizeof(buf), ch, &elems, 7);
- chan_misdn_log(1, ch->bc->port, "%c%s %s%s%s%s",
- event > EVENT_NOTHING && event < EVENT_UNKNOWN ? 'I' : '*',
- direction == LOG_RECEIVE ? "->" : "<-",
- info->name,
- info->elements ? " (" : "",
- info->elements ? buf : "",
- info->elements ? ")\n" : "\n");
-
- elems = info->additional;
- while (elems) {
- *buf = 0;
- event_info_string(buf, sizeof(buf), ch, &elems, 3);
- chan_misdn_log(1, ch->bc->port, " %s\n", buf);
- }
-}
-
/* Channel Selection */
static void * misdn_occupy (void *priv)
{
@@ -1438,52 +1463,6 @@
return tmp;
return NULL;
-}
-
-static char * get_ch_state (struct chan_list *p)
-{
- struct ch_state {
- enum misdn_chan_state state;
- char txt[255] ;
- };
- static struct ch_state ch_states[] = {
- { MISDN_NOTHING, "NOTHING" }, /* at beginning */
- { MISDN_WAITING4DIGS, "WAITING4DIGS" }, /* when waiting for infos */
- { MISDN_EXTCANTMATCH, "EXTCANTMATCH" }, /* when asterisk couldnt match our ext */
- { MISDN_DIALING, "DIALING" }, /* when pbx_start */
- { MISDN_PROGRESS, "PROGRESS" }, /* when pbx_start */
- { MISDN_PROCEEDING, "PROCEEDING" }, /* when pbx_start */
- { MISDN_CALLING, "CALLING" }, /* when misdn_call is called */
- { MISDN_CALLING_ACKNOWLEDGE, "CALLING_ACKNOWLEDGE" }, /* when misdn_call is called */
- { MISDN_ALERTING, "ALERTING" }, /* when Alerting */
- { MISDN_BUSY, "BUSY" }, /* when BUSY */
- { MISDN_CONNECTED, "CONNECTED" }, /* when connected */
- { MISDN_PRECONNECTED, "PRECONNECTED" }, /* when connected */
- { MISDN_DISCONNECTED, "DISCONNECTED" }, /* when connected */
- { MISDN_RELEASED, "RELEASED" }, /* when connected */
- { MISDN_BRIDGED, "BRIDGED" }, /* when bridged */
- { MISDN_CLEANING, "CLEANING" }, /* when hangup from * but we were connected before */
- { MISDN_HUNGUP_FROM_MISDN, "HUNGUP_FROM_MISDN" }, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
- { MISDN_HOLDED, "HOLDED" }, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
- { MISDN_HOLD_DISCONNECT, "HOLD_DISCONNECT" }, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
- { MISDN_FIXUP, "FIXUP"}, /* when DISCONNECT/RELEASE/REL_COMP cam from misdn */
- { MISDN_HUNGUP_FROM_AST, "HUNGUP_FROM_AST" } /* when DISCONNECT/RELEASE/REL_COMP came out of */
- };
-
- int i;
- static char state[8];
-
- if (!p)
- return NULL;
-
- for (i = 0; i < sizeof(ch_states) / sizeof(struct ch_state); ++i) {
- if (ch_states[i].state == state_machine_get_state(p->sm))
- return ch_states[i].txt;
- }
-
- snprintf(state, sizeof(state), "%d", state_machine_get_state(p->sm));
-
- return state;
}
static char * get_bearer_str (int cap)
@@ -1604,7 +1583,7 @@
ast ? AST_CID_P(ast) : "",
bc->rad,
ast ? ast->context : "",
- get_ch_state(help));
+ get_state_string(state_machine_get_state(help->sm)));
if (misdn_debug[bc->port] > 0)
ast_cli(fd,
@@ -1963,7 +1942,7 @@
if (ast && MISDN_ASTERISK_TECH_PVT(ast)) {
chan_misdn_log(2, bc->port, "* RELEASING CHANNEL pid:%d ctx:%s dad:%s oad:%s state: %s\n",
- bc->pid, ast->context, ast->exten, AST_CID_P(ast), get_ch_state(ch));
+ bc->pid, ast->context, ast->exten, AST_CID_P(ast), get_state_string(state_machine_get_state(ch->sm)));
chan_misdn_log(3, bc->port, " --> * State Down\n");
MISDN_ASTERISK_TECH_PVT(ast) = NULL;
if (ast->_state != AST_STATE_RESERVED) {
@@ -2731,6 +2710,10 @@
print_numplan(bc->port, bc->cpnnumplan, "CTON");
ch->overlap_dial = 0;
} else {
+ pbx_builtin_setvar_helper(ch->ast, "TRANSFERCAPABILITY", ast_transfercapability2str(bc->capability));
+ ch->ast->transfercapability = bc->capability;
+ pbx_builtin_setvar_helper(ch->ast, "CALLTYPE", bc->capability == INFO_CAPABILITY_DIGITAL_UNRESTRICTED ? "DIGITAL" : "SPEECH");
+
if (strstr(faxdetect, "incoming") || strstr(faxdetect, "both")) {
if (strstr(faxdetect, "nojump"))
ch->faxdetect = 2;
@@ -3191,7 +3174,8 @@
state == MISDN_HOLD_DISCONNECT) {
/* between request and call */
if (!bc)
- ast_log(LOG_WARNING,"Hangup with private but no bc ? state:%s l3id:%x\n", get_ch_state(p), p->l3id);
+ ast_log(LOG_WARNING,"Hangup with private but no bc ? state:%s l3id:%x\n",
+ get_state_string(state_machine_get_state(p->sm)), p->l3id);
if (option_debug)
ast_log(LOG_DEBUG, "State Reserved (or nothing) => chanIsAvail\n");
cl_dequeue_chan(&cl_te, p);
@@ -3214,17 +3198,19 @@
}
chan_misdn_log(2, bc->port,
- "* IND : HANGUP\tpid:%d ctx:%s dad:%s oad:%s State:%s\n"
- " --> l3id:%x\n --> cause:%d\n --> out_cause:%d\n --> state:%s\n",
- p->bc ? p->bc->pid : -1, ast->context, ast->exten, AST_CID_P(ast), get_ch_state(p),
- p->l3id, bc->cause, bc->out_cause, get_ch_state(p));
+ "* IND : HANGUP\tpid:%d ctx:%s dad:%s oad:%s state:%s\n"
+ " --> l3id:%x\n --> cause:%d\n --> out_cause:%d\n",
+ p->bc ? p->bc->pid : -1, ast->context, ast->exten, AST_CID_P(ast),
+ get_state_string(state_machine_get_state(p->sm)),
+ p->l3id, bc->cause, bc->out_cause);
if ((re = state_machine_run(p->sm, AEVENT_HANGUP))) {
chan_misdn_log(0, bc->port, "state_machine_run failed on AEVENT_HANGUP: %d!\n", re);
return -1;
}
- chan_misdn_log(2, bc->port, "Channel: %s hanguped new state:%s\n", ast->name, get_ch_state(p));
+ chan_misdn_log(2, bc->port, "Channel: %s hanguped new state:%s\n", ast->name,
+ get_state_string(state_machine_get_state(p->sm)));
return 0;
}
@@ -3484,7 +3470,8 @@
if (!ch->dropped_frame_cnt)
chan_misdn_log(5, ch->bc->port,
"BC not active (nor bridged) droping: %d frames addr:%x exten:%s cid:%s ch->state:%s bc_state:%d l3id:%x\n",
- frame->samples, ch->bc->addr, ast->exten, ast->cid.cid_num, get_ch_state(ch), ch->bc->bc_state, ch->bc->l3_id);
+ frame->samples, ch->bc->addr, ast->exten, ast->cid.cid_num, get_state_string(state_machine_get_state(ch->sm)),
+ ch->bc->bc_state, ch->bc->l3_id);
ch->dropped_frame_cnt++;
if (ch->dropped_frame_cnt > 100) {
ch->dropped_frame_cnt = 0;
@@ -3620,7 +3607,7 @@
if (!ast || !(p = MISDN_ASTERISK_TECH_PVT(ast)))
return -1;
- chan_misdn_log(2, p->bc ? p->bc->port : 0, "* IND: Got Fixup State:%s L3id:%x\n", get_ch_state(p), p->l3id);
+ chan_misdn_log(2, p->bc ? p->bc->port : 0, "* IND: Got Fixup State:%s L3id:%x\n", get_state_string(state_machine_get_state(p->sm)), p->l3id);
p->ast = ast;
state_machine_set_state(p->sm, MISDN_FIXUP);
return 0;
@@ -3651,11 +3638,6 @@
ch->ast->rings = 1;
ast_setstate(ch->ast, AST_STATE_RINGING);
- pbx_builtin_setvar_helper(ch->ast, "TRANSFERCAPABILITY", ast_transfercapability2str(bc->capability));
- ch->ast->transfercapability = bc->capability;
- pbx_builtin_setvar_helper(ch->ast, "CALLTYPE", bc->capability == INFO_CAPABILITY_DIGITAL_UNRESTRICTED ? "DIGITAL" : "SPEECH");
-
- cl_queue_chan(&cl_te, ch) ;
if (!strstr(ch->allowed_bearers, "all")) {
for (i = 0; i < sizeof(allowed_bearers) / sizeof(struct allowed_bearer); ++i) {
if (allowed_bearers[i].cap == bc->capability && !strstr(ch->allowed_bearers, allowed_bearers[i].name)) {
@@ -3667,14 +3649,14 @@
}
}
- return EVENT_NONE;
-}
-
-static int handle_mevent_setup_folowup (void *p, int state, int event)
+ return EVENT_DEFAULT;
+}
+
+static int handle_mevent_setup_followup (void *p, int state, int event)
{
struct chan_list *ch = p;
struct misdn_bchannel *bc = ch->bc;
- int im,
+ int im,
dad_len;
/* Check for Pickup Request first */
@@ -3765,7 +3747,7 @@
return EVENT_BREAK;
}
-static int handle_mevent_information(void *p, int state, int event)
+static int handle_mevent_information (void *p, int state, int event)
{
struct chan_list *ch = p;
struct misdn_bchannel *bc = ch->bc;
@@ -3781,10 +3763,10 @@
strncpy(ch->ast->exten, bc->dad, sizeof(ch->ast->exten));
ch->ast->exten[sizeof(ch->ast->exten) - 1] = 0;
- return EVENT_NONE;
-}
-
-static int handle_mevent_information_dtmf(void *p, int state, int event)
+ return EVENT_DEFAULT;
+}
+
+static int handle_mevent_information_dtmf (void *p, int state, int event)
{
struct chan_list *ch = p;
struct misdn_bchannel *bc = ch->bc;
@@ -3801,7 +3783,8 @@
fr.subclass = bc->info_dad[0] ;
fr.delivery = ast_tv(0, 0);
ast_queue_frame(ch->ast, &fr);
- return EVENT_NONE;
+
+ return EVENT_DEFAULT;
}
static int handle_mevent_setup_acknowledge (void *p, int state, int event)
@@ -4011,7 +3994,7 @@
if (event != EVENT_BCHAN_DATA && event != EVENT_TONE_GENERATE) { /* Debug Only Non-Bchan */
chan_misdn_log((event == EVENT_CLEANUP && !user_data) ? 5 : 2, bc->port, "I IND :%s oad:%s dad:%s pid:%d state:%s\n",
- manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch ? get_ch_state(ch) : "none");
+ manager_isdn_get_info(event), bc->oad, bc->dad, bc->pid, ch ? get_state_string(state_machine_get_state(ch->sm)) : "none");
if ((event != EVENT_CLEANUP || user_data)) {
misdn_lib_log_ies(bc);
chan_misdn_log(4, bc->port, " --> bc_state:%s\n", bc_state2str(bc->bc_state));
@@ -4178,6 +4161,8 @@
config_ch(ch, ORG_MISDN);
config_ch_pres_screen(ch);
export_chan(ch->ast, bc, ch);
+
+ cl_queue_chan(&cl_te, ch) ;
}
if (event == EVENT_NEW_BC) {
@@ -4206,7 +4191,7 @@
case EVENT_BCHAN_ERROR:
case EVENT_TIMEOUT:
if (ch && bc)
- chan_misdn_log(2, bc->port, "--> state: %s\n", get_ch_state(ch));
+ chan_misdn_log(2, bc->port, "--> state: %s\n", get_state_string(state_machine_get_state(ch->sm)));
switch (state_machine_get_state(ch->sm)) {
case MISDN_DIALING:
case MISDN_PROGRESS:
More information about the asterisk-commits
mailing list