From 7dc10dcae129d2ef7f40a455aba45179eb68d1d8 Mon Sep 17 00:00:00 2001 From: Super User Date: Sun, 3 Jun 2007 12:11:09 +0200 Subject: [PATCH] backup --- action.cpp | 365 +++++++++++++++++++++++++++++++++----------------- apppbx.cpp | 439 +++++++++++++++++++++++++++++++------------------------------ dss1.cpp | 226 ++++++++++++++----------------- main.c | 1 + route.c | 5 +- route.h | 5 +- trace.c | 26 +++- trace.h | 11 +- 8 files changed, 598 insertions(+), 480 deletions(-) diff --git a/action.cpp b/action.cpp index 3655032..20a8c54 100644 --- a/action.cpp +++ b/action.cpp @@ -181,8 +181,9 @@ void EndpointAppPBX::action_dialing_internal(void) /* check if extension exists AND only if not multiple extensions */ if (!read_extension(&ext, dialinginfo.number) && !strchr(dialinginfo.number,',')) { - printlog("%3d action INTERN dialed extension %s doesn't exist.\n", ea_endpoint->ep_serial, dialinginfo.number); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): extension %s doesn't exist\n", ea_endpoint->ep_serial, dialinginfo.number); + trace_header("ACTION extension (extension doesn't exist)", DIRECTION_NONE); + add_trace("extension", NULL, dialinginfo.number); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_86"); @@ -191,8 +192,9 @@ void EndpointAppPBX::action_dialing_internal(void) /* check if internal calls are denied */ if (e_ext.rights < 1) { - printlog("%3d action INTERN access to internal phones are denied for this caller.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): internal call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION extension (dialing to extension denied)", DIRECTION_NONE); + add_trace("extension", NULL, dialinginfo.number); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_81"); @@ -200,7 +202,9 @@ void EndpointAppPBX::action_dialing_internal(void) } /* add or update internal call */ - printlog("%3d action INTERN call to extension %s.\n", ea_endpoint->ep_serial, dialinginfo.number); + trace_header("ACTION extension (calling)", DIRECTION_NONE); + add_trace("extension", NULL, dialinginfo.number); + end_trace(); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_SETUP); memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info)); memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info)); @@ -324,8 +328,8 @@ void EndpointAppPBX::action_dialing_external(void) /* check if local calls are denied */ if (e_ext.rights < 2) { - printlog("%3d action EXTERN calls are denied for this caller.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): external call from terminal denied: %s\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION extern (calling denied)", DIRECTION_NONE); + end_trace(); release(RELEASE_CALL, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, 0); set_tone(portlist, "cause_82"); denied: @@ -341,8 +345,8 @@ void EndpointAppPBX::action_dialing_external(void) /* check if national calls are denied */ if (e_ext.rights < 3) { - printlog("%3d action EXTERN national calls are denied for this caller.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): national call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION extern (national calls denied)", DIRECTION_NONE); + end_trace(); release(RELEASE_CALL, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, 0); set_tone(portlist, "cause_83"); goto denied; @@ -355,8 +359,8 @@ void EndpointAppPBX::action_dialing_external(void) /* check if international calls are denied */ if (e_ext.rights < 4) { - printlog("%3d action EXTERN international calls are denied for this caller.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): international call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION extern (international calls denied)", DIRECTION_NONE); + end_trace(); release(RELEASE_CALL, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, 0); set_tone(portlist, "cause_84"); goto denied; @@ -364,7 +368,11 @@ void EndpointAppPBX::action_dialing_external(void) } /* add or update outgoing call */ - printlog("%3d action EXTERN call to destination %s.\n", ea_endpoint->ep_serial, dialinginfo.number); + trace_header("ACTION extern (calling)", DIRECTION_NONE); + add_trace("number", NULL, dialinginfo.number); + if (dialinginfo.interfaces[0]) + add_trace("interfaces", NULL, dialinginfo.interfaces); + end_trace(); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_SETUP); memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info)); memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info)); @@ -378,7 +386,8 @@ void EndpointAppPBX::action_dialing_chan(void) { struct port_list *portlist = ea_endpoint->ep_portlist; - printlog("%3d action channel API not implemented.\n", ea_endpoint->ep_serial); + trace_header("ACTION channel (not implemented)", DIRECTION_NONE); + end_trace(); message_disconnect_port(portlist, CAUSE_UNIMPLEMENTED, LOCATION_PRIVATE_LOCAL, ""); new_state(EPOINT_STATE_OUT_DISCONNECT); set_tone(portlist,"cause_4f"); @@ -401,8 +410,8 @@ void EndpointAppPBX::action_dialing_vbox_record(void) /* check for given extension */ if (!(rparam = routeparam(e_action, PARAM_EXTENSION))) { - printlog("%3d action VBOX-RECORD extension not given by parameter.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): cannot record, because no 'extension' parameter has been specified.\n", ea_endpoint->ep_serial); + trace_header("ACTION vbox-record (no extension given by parameter)", DIRECTION_NONE); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); @@ -413,21 +422,20 @@ void EndpointAppPBX::action_dialing_vbox_record(void) /* check if extension exists */ if (!read_extension(&ext, rparam->string_value)) { - printlog("%3d action VBOX-RECORD given extension %s doesn't exist.\n", ea_endpoint->ep_serial, rparam->string_value); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): extension %s doesn't exist\n", ea_endpoint->ep_serial, rparam->string_value); + trace_header("ACTION vbox-record (given extension does not exists)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", rparam->string_value); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_86"); return; } - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s dialing extension: %s\n", ea_endpoint->ep_serial, e_ext.number, rparam->string_value); - /* check if internal calls are denied */ if (e_ext.rights < 1) { - printlog("%3d action VBOX-RECORD calls are denied for this caller.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): internal call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION vbox-record (internal calls are denied)", DIRECTION_NONE); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_81"); @@ -454,7 +462,9 @@ void EndpointAppPBX::action_dialing_vbox_record(void) } /* add or update internal call */ - printlog("%3d action VBOX-RECORD call to extension %s.\n", ea_endpoint->ep_serial, dialinginfo.number); + trace_header("ACTION vbox-record (calling)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", dailinginfo.number); + end_trace(); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_SETUP); memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info)); memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info)); @@ -482,8 +492,8 @@ void EndpointAppPBX::action_init_partyline(void) /* check for given extension */ if (!(rparam = routeparam(e_action, PARAM_ROOM))) { - printlog("%3d action PARTYLINE no 'room' parameter given at routing.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): missing parameter 'room'.\n", ea_endpoint->ep_serial); + trace_header("ACTION partyline (no room parameter)", DIRECTION_NONE); + end_trace(); noroom: new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); @@ -492,7 +502,9 @@ void EndpointAppPBX::action_init_partyline(void) } if (rparam->integer_value <= 0) { - printlog("%3d action PARTYLINE 'room' value must be greate 0.\n", ea_endpoint->ep_serial); + trace_header("ACTION partyline (illegal room parameter)", DIRECTION_NONE); + add_trace("room", NULL, "%d", rparam->integer_value); + end_trace(); PDEBUG(DEBUG_EPOINT, "EPOINT(%d): invalid value for 'room'.\n", ea_endpoint->ep_serial); goto noroom; } @@ -516,12 +528,8 @@ void EndpointAppPBX::action_init_partyline(void) PDEBUG(DEBUG_EPOINT, "EPOINT(%d): Creating new call instance.\n", ea_endpoint->ep_serial); if (!(call = new CallPBX(ea_endpoint))) { - nores: - /* resource not available */ - message_disconnect_port(portlist, CAUSE_RESSOURCEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); - new_state(EPOINT_STATE_OUT_DISCONNECT); - set_tone(portlist,"cause_22"); - return; + PERROR("no memory for call, exitting"); + exit(-1); } } else { @@ -529,7 +537,8 @@ void EndpointAppPBX::action_init_partyline(void) /* add relation to existing call */ if (!(relation=callpbx->add_relation())) { - goto nores; + PERROR("no memory for call relation, exitting"); + exit(-1); } relation->type = RELATION_TYPE_SETUP; relation->channel_state = CHANNEL_STATE_CONNECT; @@ -540,8 +549,6 @@ void EndpointAppPBX::action_init_partyline(void) } ea_endpoint->ep_call_id = call->c_serial; - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s dialing room: %d\n", ea_endpoint->ep_serial, e_ext.number, partyline); - set_tone(portlist, "proceeding"); message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING); message_put(message); @@ -549,7 +556,9 @@ void EndpointAppPBX::action_init_partyline(void) new_state(EPOINT_STATE_IN_PROCEEDING); /* send setup to call */ - printlog("%3d action PARTYLINE call to room %d.\n", ea_endpoint->ep_serial, partyline); + trace_header("ACTION partyline (calling)", DIRECTION_NONE); + add_trace("room", NULL, "%d", partylind); + end_trace(); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_SETUP); message->param.setup.partyline = partyline; memcpy(&message->param.setup.dialinginfo, &e_dialinginfo, sizeof(struct dialing_info)); @@ -567,7 +576,8 @@ void EndpointAppPBX::action_hangup_call(void) { int i; - printlog("%3d action CALL to '%s' hangs up.\n", ea_endpoint->ep_serial, e_dialinginfo.number); + trace_header("ACTION hangup", DIRECTION_NONE); + end_trace(); /* check */ if (e_ext.number[0] == '\0') { @@ -624,8 +634,9 @@ void EndpointAppPBX::action_dialing_login(void) return; if (!read_extension(&e_ext, extension)) { - printlog("%3d action LOGIN given extension %s doesn't exist.\n", ea_endpoint->ep_serial, extension); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): given extension %s not found.\n", ea_endpoint->ep_serial, extension); + trace_header("ACTION login (extension doesn't exist)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", extension); + end_trace(); /* extension doesn't exist */ new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, ""); @@ -640,8 +651,9 @@ void EndpointAppPBX::action_dialing_login(void) return; if (!read_extension(&e_ext, extension)) { - printlog("%3d action LOGIN given extension %s incomplete or not found..\n", ea_endpoint->ep_serial, extension); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): extension %s incomplete or not found\n", ea_endpoint->ep_serial, extension); + trace_header("ACTION login (extension incomplete or does not exist)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", extension); + end_trace(); return; } } @@ -679,7 +691,9 @@ void EndpointAppPBX::action_dialing_login(void) if (!(rparam = routeparam(e_action, PARAM_NOPASSWORD))) { /* make call state to enter password */ - printlog("%3d action LOGIN to extension %s, ask for password.\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION login (ask for password)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", e_ext.number); + end_trace(); new_state(EPOINT_STATE_IN_OVERLAP); e_ruleset = NULL; e_rule = NULL; @@ -719,7 +733,8 @@ void EndpointAppPBX::action_init_change_callerid(void) if (!e_ext.change_callerid) { /* service not available */ - printlog("%3d action CHANGE-CALLERID denied for this caller.\n", ea_endpoint->ep_serial); + trace_header("ACTION change-callerid (denied for this caller)", DIRECTION_NONE); + end_trace(); message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); new_state(EPOINT_STATE_OUT_DISCONNECT); set_tone(portlist,"cause_87"); @@ -734,6 +749,8 @@ void EndpointAppPBX::_action_callerid_calleridnext(int next) struct port_list *portlist = ea_endpoint->ep_portlist; struct route_param *rparam; char buffer[64], *callerid; + char old_id[64] = "", new_id[64] = ""; + int old_type=0, new_type=0, old_present=0, new_present=0; if ((rparam = routeparam(e_action, PARAM_CALLERID))) { @@ -774,10 +791,12 @@ void EndpointAppPBX::_action_callerid_calleridnext(int next) } /* caller id complete, dialing with new caller id */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing callerid '%s' for all following calls.\n", ea_endpoint->ep_serial, e_ext.number, callerid); /* write new parameters */ if (read_extension(&e_ext, e_ext.number)) { + old_present = (!next)?e_ext.callerid_present:e_ext.id_next_call_present; + old_type = (!next)?e_ext.callerid_type:e_ext.id_next_call_type; + SCPY(old_id, (!next)?e_ext.callerid:e_ext.id_next_call); if (callerid[0] == '\0') { /* no caller id */ @@ -799,11 +818,22 @@ void EndpointAppPBX::_action_callerid_calleridnext(int next) if (!next) e_ext.id_next_call_type = -1; PDEBUG(DEBUG_EPOINT, "EPOINT(%d): nationalized callerid: '%s' type=%d\n", ea_endpoint->ep_serial, (!next)?e_ext.callerid:e_ext.id_next_call, (!next)?e_ext.callerid_type:e_ext.id_next_call_type); } + new_present = (!next)?e_ext.callerid_present:e_ext.id_next_call_present; + new_type = (!next)?e_ext.callerid_type:e_ext.id_next_call_type; + SCPY(new_id, (!next)?e_ext.callerid:e_ext.id_next_call); write_extension(&e_ext, e_ext.number); } /* function activated */ - printlog("%3d action CHANGE-CALLERID caller changes caller id%s to '%s'.\n", ea_endpoint->ep_serial, next?" of next call":"", callerid); + if (next) + trace_header("ACTION change-callerid (only next call)", DIRECTION_NONE); + else + trace_header("ACTION change-callerid (all future calls)", DIRECTION_NONE); + add_trace("old", "caller id", "%s", numberrize_callerinfo(old_id, old_type)); + add_trace("old", "present", "%s", (old_present==INFO_PRESENT_RESTRICTED)?"restricted":"allowed"); + add_trace("new", "caller id", "%s", numberrize_callerinfo(new_id, new_type)); + add_trace("new", "present", "%s", (new_present==INFO_PRESENT_RESTRICTED)?"restricted":"allowed"); + end_trace(); message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, ""); new_state(EPOINT_STATE_OUT_DISCONNECT); set_tone(portlist,"activated"); @@ -833,7 +863,8 @@ void EndpointAppPBX::action_init_change_forward(void) if (!e_ext.change_forward) { - printlog("%3d action CHANGE-FORWARD denied for this caller.\n", ea_endpoint->ep_serial); + trace_header("ACTION change-forward (denied for this caller)", DIRECTION_NONE); + end_trace(); /* service not available */ message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); new_state(EPOINT_STATE_OUT_DISCONNECT); @@ -873,21 +904,30 @@ void EndpointAppPBX::action_dialing_forward(void) switch(diversion) { case INFO_DIVERSION_CFU: - printlog("%3d action CHANGE-FORWARD changing CFU (unconditional) to '%s'.\n", ea_endpoint->ep_serial, dest); + trace_header("ACTION change-forward (new CFU=unconditional)", DIRECTION_NONE); + add_trace("destin'", NULL, "%s", dest); + end_trace(); SCPY(e_ext.cfu, dest); break; case INFO_DIVERSION_CFB: - printlog("%3d action CHANGE-FORWARD changing CFB (busy) to '%s'.\n", ea_endpoint->ep_serial, dest); + trace_header("ACTION change-forward (new CFB=busy)", DIRECTION_NONE); + add_trace("destin'", NULL, "%s", dest); + end_trace(); SCPY(e_ext.cfb, dest); break; case INFO_DIVERSION_CFNR: if ((rparam = routeparam(e_action, PARAM_DELAY))) e_ext.cfnr_delay = rparam->integer_value; - printlog("%3d action CHANGE-FORWARD changing CFNR (no response) to '%s' with delay=%d.\n", ea_endpoint->ep_serial, dest, e_ext.cfnr_delay); + trace_header("ACTION change-forward (new CFNR=no response)", DIRECTION_NONE); + add_trace("destin'", NULL, "%s", dest); + add_trace("delay", NULL, "%s", e_ext.cfnr_delay); + end_trace(); SCPY(e_ext.cfnr, dest); break; case INFO_DIVERSION_CFP: - printlog("%3d action CHANGE-FORWARD changing CFP (parallel) to '%s'.\n", ea_endpoint->ep_serial, dest); + trace_header("ACTION change-forward (new CFP=parallel)", DIRECTION_NONE); + add_trace("destin'", NULL, "%s", dest); + end_trace(); SCPY(e_ext.cfp, dest); break; } @@ -912,8 +952,8 @@ void EndpointAppPBX::action_init_redial_reply(void) e_select = 0; if (!e_ext.last_out[0]) { - printlog("%3d action REDIAL/REPLY no number available to dial.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): no stored last number.\n", ea_endpoint->ep_serial); + trace_header("ACTION redial/reply (no last number stored)", DIRECTION_NONE); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_3f"); @@ -969,7 +1009,13 @@ void EndpointAppPBX::_action_redial_reply(int in) if (e_extdialing[0]=='0' || e_extdialing[0]=='2') { nodisplay: - printlog("%3d action REDIAL/REPLY dialing '%s'.\n", ea_endpoint->ep_serial, last); + if (in) + trace_header("ACTION reply (dialing)", DIRECTION_NONE); + else + trace_header("ACTION redial (dialing)", DIRECTION_NONE); + add_trace("number", NULL, "%s", last); + add_trace("last but", NULL, "%d", e_select); + end_trace(); SCPY(e_dialinginfo.number, last); e_extdialing = e_dialinginfo.number; e_action = NULL; @@ -1024,8 +1070,8 @@ void EndpointAppPBX::action_dialing_powerdial(void) /* power dialing only possible if we have a last dialed number */ if (!e_ext.last_out[0]) { - printlog("%3d action POWERDIAL no number available to redial.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): no stored last number.\n", ea_endpoint->ep_serial); + trace_header("ACTION powerdial (no last number stored)", DIRECTION_NONE); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_3f"); @@ -1056,8 +1102,10 @@ void EndpointAppPBX::action_dialing_powerdial(void) if (e_powerdelay < 1) e_powerdelay = 0.2; - printlog("%3d action POWERDIAL to '%s' with delay=%d.\n", ea_endpoint->ep_serial, e_ext.last_out[0], (int)e_powerdelay); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): powerdialing to '%s' (delay=%d).\n", ea_endpoint->ep_serial, e_ext.last_out[0], (int)e_powerdelay); + trace_header("ACTION powerdial (dialing)", DIRECTION_NONE); + add_trace("number", NULL, "%s", e_ext.last_out[0]); + add_trace("delay", NULL, "%d", e_powerdelay); + end_trace(); /* send connect to avoid overlap timeout */ // new_state(EPOINT_STATE_CONNECT); connect may prevent further dialing @@ -1090,10 +1138,11 @@ void EndpointAppPBX::action_dialing_callback(void) /* check given extension */ if (!(rparam = routeparam(e_action, PARAM_EXTENSION))) { - printlog("%3d action CALLBACK no extension was specified in routing.conf.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): rejecting callback, because no extension was specified in routing.conf\n", ea_endpoint->ep_serial); - + noextension: + trace_header("ACTION callback (no extension defined)", DIRECTION_NONE); + end_trace(); disconnect: + new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_3f"); @@ -1105,26 +1154,24 @@ void EndpointAppPBX::action_dialing_callback(void) /* if extension is given */ SCPY(e_cbcaller, rparam->string_value); if (e_cbcaller[0] == '\0') - { - printlog("%3d action CALLBACK extension specified in routing.conf is an empty string.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): rejecting callback, because given extension is an empty string.\n", ea_endpoint->ep_serial); - goto disconnect; - } + goto noextension; /* read callback extension */ memset(&cbext, 0, sizeof(cbext)); if (!read_extension(&cbext, e_cbcaller)) { - printlog("%3d action CALLBACK extension '%s' specified in routing.conf doesn't exist.\n", ea_endpoint->ep_serial, e_cbcaller); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): rejecting callback, because given extension does not exist.\n", ea_endpoint->ep_serial); + trace_header("ACTION callback (extension doesn't exist)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", e_cbcaller); + end_trace(); goto disconnect; } /* if password is not given */ if (cbext.password[0] == '\0') { - printlog("%3d action CALLBACK extension '%s' has no password specified.\n", ea_endpoint->ep_serial, e_cbcaller); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): rejecting callback, because no password is available in given extension (%s).\n", ea_endpoint->ep_serial, e_cbcaller); + trace_header("ACTION callback (no password set)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", e_cbcaller); + end_trace(); goto disconnect; } @@ -1133,16 +1180,19 @@ void EndpointAppPBX::action_dialing_callback(void) SCPY(e_cbto, rparam->string_value); if (e_cbto[0]) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): callback to given number: '%s'\n", ea_endpoint->ep_serial, e_cbto); - printlog("%3d action CALLBACK callback to given number: '%s'\n", ea_endpoint->ep_serial, e_cbto); + trace_header("ACTION callback (alternative caller id)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", e_cbcaller); + add_trace("callerid", NULL, "%s", e_cbto); + end_trace(); SCPY(e_callerinfo.id, e_cbto); e_callerinfo.ntype = INFO_NTYPE_UNKNOWN; e_callerinfo.present = INFO_PRESENT_ALLOWED; } if (e_callerinfo.id[0]=='\0' || e_callerinfo.present==INFO_PRESENT_NOTAVAIL) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): rejecting callback, because no caller id is available\n", ea_endpoint->ep_serial); - printlog("%3d action CALLBACK not possible because caller ID is not available.\n", ea_endpoint->ep_serial); + trace_header("ACTION callback (no caller ID available)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", e_cbcaller); + end_trace(); goto disconnect; } /* present id */ @@ -1170,8 +1220,12 @@ void EndpointAppPBX::action_hangup_callback(void) else SCPY(e_cbdialing, e_extdialing); - printlog("%3d action CALLBACK extension=%s callerid='%s' delay='%d' dialing after callback='%s' .\n", ea_endpoint->ep_serial, e_cbcaller, e_callerinfo.id, delay, e_cbdialing); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): caller '%s', callerid '%s', dialing '%s', delay %d\n", ea_endpoint->ep_serial, e_cbcaller, e_callerinfo.id, e_cbdialing, delay); + trace_header("ACTION callback (dialing)", DIRECTION_NONE); + add_trace("extension", NULL, "%s", e_cbcaller); + add_trace("caller id", NULL, "%s", e_callerinfo.id); + add_trace("delay", NULL, "%d", delay); + add_trace("dialing", NULL, "%s", e_cbdialing); + end_trace(); /* set time to callback */ e_callback = now_d + delay; @@ -1192,7 +1246,8 @@ void EndpointAppPBX::action_dialing_abbrev(void) /* abbrev dialing is only possible if we have a caller defined */ if (!e_ext.number[0]) { - printlog("%3d action ABBREVIATION only possible for internal callers.\n", ea_endpoint->ep_serial); + trace_header("ACTION abbreviation (only for extension)", DIRECTION_NONE); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_3f"); @@ -1206,7 +1261,9 @@ void EndpointAppPBX::action_dialing_abbrev(void) result = parse_phonebook(e_ext.number, &abbrev, &phone, &name); if (result == 0) { - printlog("%3d action ABBREVIATION '%s' not found.\n", ea_endpoint->ep_serial, abbrev); + trace_header("ACTION abbreviation (not found)", DIRECTION_NONE); + add_trace("abbrev", NULL, "%s", abbrev); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_UNALLOCATED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_01"); @@ -1218,7 +1275,12 @@ void EndpointAppPBX::action_dialing_abbrev(void) } /* dial abbreviation */ - printlog("%3d action ABBREVIATION mapping '%s' to '%s' (%s), dialing...\n", ea_endpoint->ep_serial, abbrev, phone, name?name:"unknown"); + trace_header("ACTION abbreviation (dialing)", DIRECTION_NONE); + add_trace("abbrev", NULL, "%s", abbrev); + add_trace("number", NULL, "%s", phone); + if (name) if (name[0]) + add_trace("name", NULL, "%s", name); + end_trace(); SCPY(e_dialinginfo.number, phone); e_extdialing = e_dialinginfo.number; e_action = NULL; @@ -1246,7 +1308,9 @@ void EndpointAppPBX::action_dialing_test(void) switch(testcode[0]) { case '1': - printlog("%3d action TESTMODE executing 'proceeding' test.\n", ea_endpoint->ep_serial); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "proceeding"); + end_trace(); new_state(EPOINT_STATE_IN_PROCEEDING); set_tone(portlist, "proceeding"); message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_PROCEEDING); @@ -1255,7 +1319,9 @@ void EndpointAppPBX::action_dialing_test(void) break; case '2': - printlog("%3d action TESTMODE executing 'alerting' test.\n", ea_endpoint->ep_serial); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "alerting"); + end_trace(); new_state(EPOINT_STATE_IN_ALERTING); set_tone(portlist, "ringpbx"); message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_ALERTING); @@ -1264,7 +1330,9 @@ void EndpointAppPBX::action_dialing_test(void) break; case '3': - printlog("%3d action TESTMODE executing 'echo connect' test.\n", ea_endpoint->ep_serial); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "echo"); + end_trace(); new_state(EPOINT_STATE_CONNECT); if (e_ext.number[0]) e_dtmf = 1; @@ -1294,7 +1362,9 @@ void EndpointAppPBX::action_dialing_test(void) break; case '4': - printlog("%3d action TESTMODE executing 'tone connect' test.\n", ea_endpoint->ep_serial); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "tone"); + end_trace(); new_state(EPOINT_STATE_CONNECT); if (e_ext.number[0]) e_dtmf = 1; @@ -1306,7 +1376,9 @@ void EndpointAppPBX::action_dialing_test(void) break; case '5': - printlog("%3d action TESTMODE executing 'hold music' test.\n", ea_endpoint->ep_serial); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "hold music"); + end_trace(); new_state(EPOINT_STATE_CONNECT); if (e_ext.number[0]) e_dtmf = 1; @@ -1324,7 +1396,10 @@ void EndpointAppPBX::action_dialing_test(void) cause = atoi(testcode+1); if (cause > 255) cause = 0; - printlog("%3d action TESTMODE executing 'announcement' test with cause %d.\n", ea_endpoint->ep_serial, cause); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "announcement"); + add_trace("cause", NULL, "%d", cause); + end_trace(); new_state(EPOINT_STATE_CONNECT); if (e_ext.number[0]) e_dtmf = 1; @@ -1343,7 +1418,10 @@ void EndpointAppPBX::action_dialing_test(void) cause = atoi(testcode+1); if (cause > 127) cause = 0; - printlog("%3d action TESTMODE executing 'disconnect' test with cause %d.\n", ea_endpoint->ep_serial, cause); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "disconnect"); + add_trace("cause", NULL, "%d", cause); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); SPRINT(causestr,"cause_%02x",cause); message_disconnect_port(portlist, cause, LOCATION_PRIVATE_LOCAL, ""); @@ -1351,21 +1429,26 @@ void EndpointAppPBX::action_dialing_test(void) break; case '8': /* release */ - printlog("%3d action TESTMODE executing 'release' test.\n", ea_endpoint->ep_serial); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "release"); + add_trace("cause", NULL, "16"); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "release"); break; case '9': /* text callerid test */ - printlog("%3d action TESTMODE executing 'caller id' test.\n", ea_endpoint->ep_serial); + trace_header("ACTION test", DIRECTION_NONE); + add_trace("test", NULL, "callerid"); + end_trace(); new_state(EPOINT_STATE_CONNECT); if (e_ext.number[0]) e_dtmf = 1; memset(&e_connectinfo, 0, sizeof(e_connectinfo)); SCPY(e_connectinfo.id, "12345678"); - SCPY(e_connectinfo.name, "Welcome to Linux"); - SCPY(e_connectinfo.display, "Welcome to Linux"); + SCPY(e_connectinfo.name, "Welcome to LCR"); + SCPY(e_connectinfo.display, "Welcome to LCR"); e_connectinfo.ntype = INFO_NTYPE_UNKNOWN; e_connectinfo.present = INFO_PRESENT_ALLOWED; message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT); @@ -1388,8 +1471,8 @@ void EndpointAppPBX::action_init_play(void) /* check given sample */ if (!(rparam = routeparam(e_action, PARAM_SAMPLE))) { - printlog("%3d action PLAY no sample given.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): cannot play, because no sample has been specified\n", ea_endpoint->ep_serial); + trace_header("ACTION play (no sample given)", DIRECTION_NONE); + end_trace(); disconnect: new_state(EPOINT_STATE_OUT_DISCONNECT); @@ -1402,8 +1485,8 @@ void EndpointAppPBX::action_init_play(void) /* if sample is given */ if (rparam->string_value[0] == '\0') { - printlog("%3d action PLAY sample name with empty string given.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): cannot play, because given sample is an empty string.\n", ea_endpoint->ep_serial); + trace_header("ACTION play (no sample given)", DIRECTION_NONE); + end_trace(); goto disconnect; } @@ -1688,8 +1771,8 @@ void EndpointAppPBX::_action_goto_menu(int mode) if (!(rparam = routeparam(e_action, PARAM_RULESET))) { no_ruleset: - printlog("%3d action GOTO/MENU no ruleset ginven in options.conf\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): no ruleset was secified for action '%s' in routing.conf\n", ea_endpoint->ep_serial, (mode)?"menu":"goto"); + trace_header("ACTION goto/menu (no ruleset given)", DIRECTION_NONE); + end_trace(); disconnect: new_state(EPOINT_STATE_OUT_DISCONNECT); @@ -1703,29 +1786,39 @@ void EndpointAppPBX::_action_goto_menu(int mode) e_ruleset = getrulesetbyname(rparam->string_value); if (!e_ruleset) { - printlog("%3d action GOTO/MENU given ruleset '%s' not found in options.conf\n", ea_endpoint->ep_serial, rparam->string_value); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): given ruleset '%s' for action '%s' was not found in routing.conf\n", ea_endpoint->ep_serial, rparam->string_value, (mode)?"menu":"goto"); + trace_header("ACTION goto/menu (ruleset not found)", DIRECTION_NONE); + add_trace("ruleset", "NULL", "%s", praram->string_value); + end_trace(); goto disconnect; } - printlog("%3d action GOTO/MENU changing to ruleset '%s'\n", ea_endpoint->ep_serial, rparam->string_value); /* if the 'menu' was selected, we will flush all digits */ if (mode) { - //SCPY(e_dialinginfo.number, e_extdialing); e_dialinginfo.number[0] = 0; e_extdialing = e_dialinginfo.number; } else { + /* remove digits that are required to match the rule */ + if (!(rparam = routeparam(e_action, PARAM_STRIP))) + { + if (e_extdialing) + SCPY(e_dialinginfo.number, e_extdialing); + e_extdialing = e_dialinginfo.number; + } } /* play sample */ + trace_header("ACTION goto/menu (change to)", DIRECTION_NONE); + add_trace("ruleset", "NULL", "%s", e_ruleset->name); + if (e_dialinginfo.number[0]) + add_trace("dialing", "NULL", "%s", e_dialinginfo.number); if ((rparam = routeparam(e_action, PARAM_SAMPLE))) { - printlog("%3d action GOTO/MENU start playing sample '%s'\n", ea_endpoint->ep_serial, rparam->string_value); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): playing sample '%s'\n", ea_endpoint->ep_serial, rparam->string_value); + add_trace("sample", "NULL", "%s", praram->string_value); set_tone(ea_endpoint->ep_portlist, rparam->string_value); } + end_trace(); /* do dialing with new ruleset */ e_action = NULL; @@ -1790,7 +1883,14 @@ void EndpointAppPBX::action_dialing_disconnect(void) } /* disconnect only if connect parameter is not given */ - printlog("%3d action DISCONNECT with cause %d, location %d, sample '%s', display '%s'\n", ea_endpoint->ep_serial, cause, location, cause_string, display); + trace_header("ACTION disconnect", DIRECTION_NONE); + add_trace("cause", "value", "%d", cause); + add_trace("cause", "location", "%d", location); + if (cause_string[0]) + add_trace("sample", NULL, "%s", cause_string); + if (display[0]) + add_trace("display", NULL, "%s", display); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); set_tone(portlist, cause_string); if (!(rparam = routeparam(e_action, PARAM_CONNECT))) @@ -1919,12 +2019,13 @@ void EndpointAppPBX::action_hangup_execute(void) command = rparam->string_value; if (command[0] == '\0') { - printlog("%3d action EXECUTE no 'execute' parameter given at routing.conf.\n", ea_endpoint->ep_serial); - PERROR("EPOINT(%d): terminal %s: NO PARAMETER GIVEN for 'execute' action. see routing.conf\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION execute (no parameter given)", DIRECTION_NONE); + end_trace(); return; } - printlog("%3d action EXECUTE command='%s'\n", ea_endpoint->ep_serial, command); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: executing '%s'.\n", ea_endpoint->ep_serial, e_ext.number, command); + trace_header("ACTION execute", DIRECTION_NONE); + add_trace("command", NULL, "%s", command); + end_trace(); argv[0] = command; while(strchr(argv[0], '/')) @@ -1970,18 +2071,23 @@ void EndpointAppPBX::action_hangup_file(void) mode = "w"; if (file[0] == '\0') { - printlog("%3d action FILE no filename given.\n", ea_endpoint->ep_serial); - PERROR("EPOINT(%d): terminal %s: NO FILENAME GIVEN for 'file' action. see routing.conf\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("ACTION file (no filename given)", DIRECTION_NONE); + end_trace(); return; } if (!(fp = fopen(file, mode))) { - printlog("%3d action FILE file '%s' cannot be opened. (errno = %d)\n", ea_endpoint->ep_serial, file, errno); - PERROR("EPOINT(%d): terminal %s: given file '%s' cannot be opened. see routing.conf\n", ea_endpoint->ep_serial, e_ext.number, file); + trace_header("ACTION file (failed to open)", DIRECTION_NONE); + add_trace("file", "name", "%s", file); + add_trace("file", "mode", "%s", (mode[0]=='w')?"write":"append"); + end_trace(); return; } - printlog("%3d action FILE file='%s' content='%s'\n", ea_endpoint->ep_serial, file, content); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: writing file '%s' with content '%s'.\n", ea_endpoint->ep_serial, e_ext.number, file, content); + trace_header("ACTION file", DIRECTION_NONE); + add_trace("file", "name", "%s", file); + add_trace("file", "mode", "%s", (mode[0]=='w')?"write":"append"); + add_trace("content", NULL, "%s", content); + end_trace(); fprintf(fp, "%s\n", content); fclose(fp); } @@ -1998,7 +2104,10 @@ void EndpointAppPBX::action_init_pick(void) if ((rparam = routeparam(e_action, PARAM_EXTENSIONS))) extensions = rparam->string_value; - printlog("%3d action PICK\n", ea_endpoint->ep_serial); + trace_header("ACTION pick", DIRECTION_NONE); + if (extensions) if (extensions[0]) + add_trace("extensions", NULL, "%s", file); + end_trace(); pick_call(extensions); } @@ -2029,8 +2138,9 @@ void EndpointAppPBX::action_dialing_password(void) /* check the password */ if (e_ext.password[0]=='\0' || (strlen(e_ext.password)==strlen(e_extdialing) && !!strcmp(e_ext.password,e_extdialing))) { - printlog("%3d action PASSWORD WRITE password wrong\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): password wrong %s\n", ea_endpoint->ep_serial, e_extdialing); + trace_header("ACTION password_write (wrong password)", DIRECTION_NONE); + add_trace("dialed", NULL, "%s", e_extdialing); + end_trace(); e_connectedmode = 0; e_dtmf = 0; new_state(EPOINT_STATE_OUT_DISCONNECT); @@ -2044,7 +2154,9 @@ void EndpointAppPBX::action_dialing_password(void) if (e_action->index == ACTION_PASSWORD_WRITE) { append_callbackauth(e_ext.number, &e_callbackinfo); - printlog("%3d action PASSWORD WRITE password written\n", ea_endpoint->ep_serial); + trace_header("ACTION password_write (written)", DIRECTION_NONE); + add_trace("dialed", NULL, "%s", e_extdialing); + end_trace(); } /* make call state */ @@ -2094,7 +2206,9 @@ void EndpointAppPBX::process_dialing(void) /* check nesting levels */ if (++e_rule_nesting > RULE_NESTING) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): rules are nesting too deep. (%d levels) check for infinite loops in routing.conf\n", ea_endpoint->ep_serial, e_rule_nesting); + trace_header("ACTION (nesting too deep)", DIRECTION_NONE); + add_trace("max-levels", NULL, "%d", RULE_NESTING); + end_trace(); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_UNSPECIFIED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_3f"); @@ -2131,7 +2245,6 @@ void EndpointAppPBX::process_dialing(void) set_tone(portlist, "cause_3f"); goto end; } - PDEBUG(DEBUG_ROUTE|DEBUG_EPOINT, "EPOINT(%d): continueing with action '%s'.\n", ea_endpoint->ep_serial, action_defs[e_action->index].name); goto action_timeout; } @@ -2222,8 +2335,10 @@ void EndpointAppPBX::process_dialing(void) e_match_timeout = 0; e_action = e_match_to_action; e_extdialing = e_match_to_extdialing; - printlog("%3d routing TIMEOUT processing action '%s' (line %d)\n", ea_endpoint->ep_serial, action_defs[e_action->index].name, e_action->line); - + trace_header("ROUTING (timeout)", DIRECTION_NONE); + add_trace("action", NULL, "%s", action_defs[e_action->index].name); + add_trace("line", NULL, "%d", e_action->line); + end_trace(); } else { //PDEBUG(~0, "HANG-BUG-DEBUGGING: before routing\n"); @@ -2233,12 +2348,20 @@ void EndpointAppPBX::process_dialing(void) { e_action = route(e_ruleset); if (e_action) - printlog("%3d routing MATCH processing action '%s' (line %d)\n", ea_endpoint->ep_serial, action_defs[e_action->index].name, e_action->line); + { + trace_header("ACTION (match)", DIRECTION_NONE); + add_trace("action", NULL, "%s", action_defs[e_action->index].name); + add_trace("line", NULL, "%d", e_action->line); + end_trace(); + } } else { e_action = &action_disconnect; if (e_action) - printlog("%3d routing NO MAIN RULESET, DISCONNECTING! '%s'\n", ea_endpoint->ep_serial, action_defs[e_action->index].name); + { + trace_header("ACTION (no main ruleset, disconnecting)", DIRECTION_NONE); + end_trace(); + } } //PDEBUG(~0, "HANG-BUG-DEBUGGING: after routing\n"); } diff --git a/apppbx.cpp b/apppbx.cpp index 15fa438..ddfb2b0 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -144,31 +144,14 @@ void EndpointAppPBX::trace_header(char *name, int direction) SCPY(msgtext, name); - /* add direction */ - if (direction) - { - if (p_m_ntmode) - { - if (direction == DIRECTION_OUT) - SCAT(msgtext, " N->U"); - else - SCAT(msgtext, " N<-U"); - } else - { - if (direction == DIRECTION_OUT) - SCAT(msgtext, " U->N"); - else - SCAT(msgtext, " U<-N"); - } - } - /* init trace with given values */ - start_trace(0, + start_trace(e_serial, NULL, nationalize(e_callerinfo.id, e_callerinfo.ntype), e_dialinginfo.number, direction, - CATEGORY_AP, + CATEGORY_EP, + e_serial, msgtext); } @@ -179,12 +162,15 @@ EPOINT_STATE_NAMES */ void EndpointAppPBX::new_state(int state) { +#if 0 if (e_state != state) { trace_header("NEW STATE", DIRECTION_NONE); add_trace("state", "old", "%s", state_name[e_state]); add_trace("state", "new", "%s", state_name[state]); + end_trace(); } +#endif e_state = state; } @@ -718,7 +704,9 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) if (!strcasecmp(interface->name, ifname)) { /* found explicit interface */ - printlog("%3d interface %s found as given\n", ea_endpoint->ep_serial, ifname); + trace_header("CHANNEL SELECTION (found interface)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", ifname); + end_trace(); goto found; } @@ -727,7 +715,9 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) if (!interface->extension) { /* found non extension */ - printlog("%3d interface %s found, that is not an extension\n", ea_endpoint->ep_serial, interface->name); + trace_header("CHANNEL SELECTION (found non extension interface)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", interface->name); + end_trace(); goto found; } } @@ -739,7 +729,9 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) if (!interface->ifport) { /* no ports */ - printlog("%3d interface %s has no active ports, skipping.\n", ea_endpoint->ep_serial, interface->name); + trace_header("CHANNEL SELECTION (interface has no active ports, skipping)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", interface->name); + end_trace(); interface = interface->next; goto checknext; } @@ -754,7 +746,10 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) ifport_start = ifport_start->next; i++; } - printlog("%3d starting with port#%d position %d (round-robin)\n", ea_endpoint->ep_serial, ifport_start->portnum, index); + trace_header("CHANNEL SELECTION (starting round-robin)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport_start->portnum); + add_trace("position", NULL, "%d", index); + end_trace(); } /* loop ports */ @@ -764,7 +759,10 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) /* see if port is available */ if (!ifport->mISDNport) { - printlog("%3d port#%d position %d is not available, skipping.\n", ea_endpoint->ep_serial, ifport->portnum, index); + trace_header("CHANNEL SELECTION (port not available, skipping)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + end_trace(); goto portbusy; } mISDNport = ifport->mISDNport; @@ -774,15 +772,20 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) /* see if port is administratively blocked */ if (ifport->block) { - printlog("%3d port#%d position %d is administratively blocked, skipping.\n", ea_endpoint->ep_serial, ifport->portnum, index); + trace_header("CHANNEL SELECTION (port blocked by admin, skipping)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + end_trace(); goto portbusy; } /* see if link is up */ if (mISDNport->ptp && !mISDNport->l2link) { - printlog("%3d port#%d position %d is ptp but layer 2 is down.\n", ea_endpoint->ep_serial, ifport->portnum, index); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) skipping because it is PTP with L2 down\n", ea_endpoint->ep_serial); + trace_header("CHANNEL SELECTION (port is ptp with layer 2 down, skipping)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + end_trace(); goto portbusy; } @@ -803,7 +806,11 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) if (mISDNport->b_port[i] == NULL) { *channel = i+1+(i>=15); - printlog("%3d port#%d position %d selecting free channel %d\n", ea_endpoint->ep_serial, ifport->portnum, index, *channel); + trace_header("CHANNEL SELECTION (selecting free channel)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + add_trace("channel", NULL, "%d", *channel); + end_trace(); break; } i++; @@ -815,12 +822,18 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) { break; /* all channel in use or reserverd */ } - printlog("%3d port#%d position %d using with 'any channel'\n", ea_endpoint->ep_serial, ifport->portnum, index); + trace_header("CHANNEL SELECTION (using 'any channel')", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + end_trace(); *channel = SEL_CHANNEL_ANY; break; case CHANNEL_NO: /* call waiting */ - printlog("%3d port#%d position %d using with 'no channel'\n", ea_endpoint->ep_serial, ifport->portnum, index); + trace_header("CHANNEL SELECTION (using 'no channel', call-waiting)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + end_trace(); *channel = SEL_CHANNEL_NO; break; @@ -833,7 +846,11 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) if (mISDNport->b_port[i] == NULL) { *channel = selchannel->channel; - printlog("%3d port#%d position %d selecting given channel %d\n", ea_endpoint->ep_serial, ifport->portnum, index, *channel); + trace_header("CHANNEL SELECTION (selecting given channel)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + add_trace("channel", NULL, "%d", *channel); + end_trace(); break; } break; @@ -858,7 +875,10 @@ static struct mISDNport *EndpointAppPBX::hunt_port(char *ifname, int *channel) return(mISDNport); } - printlog("%3d port#%d position %d skipping, because no channel found.\n", ea_endpoint->ep_serial, ifport->portnum, index); + trace_header("CHANNEL SELECTION (skipping, no channel found)", DIRECTION_NONE); + add_trace("port", NULL, "%d", ifport->portnum); + add_trace("position", NULL, "%d", index); + end_trace(); portbusy: /* go next port, until all ports are checked */ @@ -1040,8 +1060,9 @@ void EndpointAppPBX::out_setup(void) mISDNport = hunt_port(ifname, &channel); if (!mISDNport) { - printlog("%3d endpoint INTERFACE '%s' not found or busy\n", ea_endpoint->ep_serial, ifname); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) given interface: '%s' not found or too busy to accept calls.\n", ea_endpoint->ep_serial, e_ext.interfaces); + trace_header("INTERFACE (not found or busy)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", ifname); + end_trace(); continue; } /* creating INTERNAL port */ @@ -1168,8 +1189,9 @@ void EndpointAppPBX::out_setup(void) /* if PTP, skip all down links */ if (mISDNport->ptp && !mISDNport->l2link) { - printlog("%3d endpoint INTERFACE Layer 2 of interface '%s' is down.\n", ea_endpoint->ep_serial, mISDNport->interface_name); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) skipping because it is PTP with L2 down\n", ea_endpoint->ep_serial); + trace_header("INTERFACE (layer 2 is down)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", mISDNport->interface_name); + end_trace(); mISDNport = mISDNport->next; continue; } @@ -1187,14 +1209,17 @@ void EndpointAppPBX::out_setup(void) } if (use >= mISDNport->b_num) { - printlog("%3d endpoint INTERFACE Interface '%s' has no free channel.\n", ea_endpoint->ep_serial, mISDNport->interface_name); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) skipping because it is not single link port_list NT-modem OR no channel available.\n", ea_endpoint->ep_serial); + trace_header("INTERFACE (no free channel)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", mISDNport->interface_name); + end_trace(); mISDNport = mISDNport->next; continue; } } /* found interface */ - printlog("%3d endpoint INTERFACE Interface '%s' found for external call.\n", ea_endpoint->ep_serial, mISDNport->interface_name); + trace_header("INTERFACE (found)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", mISDNport->interface_name); + end_trace(); break; } mISDNport = mISDNport->next; @@ -1208,8 +1233,9 @@ void EndpointAppPBX::out_setup(void) } else { port = NULL; - printlog("%3d endpoint INTERFACE External interface not found or busy.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) given interface: '%s' too busy to accept calls.\n", ea_endpoint->ep_serial, e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface"); + trace_header("INTERFACE (too busy)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface"); + end_trace(); } } if (!port) @@ -1260,8 +1286,8 @@ void EndpointAppPBX::out_setup(void) /* now we have all ports created */ if (!anycall) { - printlog("%3d endpoint INTERFACE No port or no parallel forwarding defined. Nothing to call to.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) no port or no cfp defined for extension, nothing to dial.\n", ea_endpoint->ep_serial); + trace_header("INTERFACE (no extension's interface)", DIRECTION_NONE); + end_trace(); if (!ea_endpoint->ep_call_id) break; release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, cause, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); /* RELEASE_TYPE, call, port */ @@ -1296,8 +1322,9 @@ void EndpointAppPBX::out_setup(void) /* if PTP, skip all down links */ if (mISDNport->ptp && !mISDNport->l2link) { - printlog("%3d endpoint INTERFACE Layer 2 of interface '%s' is down.\n", ea_endpoint->ep_serial, mISDNport->interface_name); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) skipping because it is PTP with L2 down\n", ea_endpoint->ep_serial); + trace_header("INTERFACE (layer 2 is down)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", mISDNport->interface_name); + end_trace(); mISDNport = mISDNport->next; continue; } @@ -1315,22 +1342,26 @@ void EndpointAppPBX::out_setup(void) } if (use >= mISDNport->b_num) { - printlog("%3d endpoint INTERFACE Interface '%s' has no free channel.\n", ea_endpoint->ep_serial, mISDNport->interface_name); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) skipping because it is not single link port_list NT-modem OR no channel available.\n", ea_endpoint->ep_serial); + trace_header("INTERFACE (no free channel)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", mISDNport->interface_name); + end_trace(); mISDNport = mISDNport->next; continue; } } /* found interface */ - printlog("%3d endpoint INTERFACE Interface '%s' found for external call.\n", ea_endpoint->ep_serial, mISDNport->interface_name); + trace_header("INTERFACE (found)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", mISDNport->interface_name); + end_trace(); break; } mISDNport = mISDNport->next; } if (!mISDNport) { - printlog("%3d endpoint INTERFACE External interface not found or busy.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) given interface: '%s' too busy to accept calls.\n", ea_endpoint->ep_serial, e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface"); + trace_header("INTERFACE (too busy)", DIRECTION_NONE); + add_trace("interface", NULL, "%s", e_dialinginfo.interfaces[0]?e_dialinginfo.interfaces:"any interface"); + end_trace(); goto check_anycall_extern; } /* creating EXTERNAL port*/ @@ -1338,8 +1369,8 @@ void EndpointAppPBX::out_setup(void) port = new Pdss1((mISDNport->ntmode)?PORT_TYPE_DSS1_NT_OUT:PORT_TYPE_DSS1_TE_OUT, mISDNport, portname, &port_settings); if (!port) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) no external port available\n", ea_endpoint->ep_serial); - goto check_anycall_extern; + PERROR("EPOINT(%d) no memory for external port, exitting\n", ea_endpoint->ep_serial); + exit(-1); } PDEBUG(DEBUG_EPOINT, "EPOINT(%d) created port %s\n", ea_endpoint->ep_serial, port->p_name); memset(&dialinginfo, 0, sizeof(dialinginfo)); @@ -1378,8 +1409,8 @@ void EndpointAppPBX::out_setup(void) /* now we have all ports created */ if (!anycall) { - printlog("%3d endpoint INTERFACE No free port found for making any call.\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) no port found which is idle for at least one number\n", ea_endpoint->ep_serial); + trace_header("INTERFACE (no free ports found)", DIRECTION_NONE); + end_trace(); if (!ea_endpoint->ep_call_id) break; release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NOCHANNEL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); /* RELEASE_TYPE, call, port */ @@ -1543,7 +1574,8 @@ int EndpointAppPBX::handler(void) e_rule = e_ruleset->rule_first; e_action = NULL; PDEBUG(DEBUG_EPOINT, "EPOINT(%d) password timeout %s\n", ea_endpoint->ep_serial, e_extdialing); - printlog("%3d endpoint PASSWORD timeout\n", ea_endpoint->ep_serial); + trace_header("PASSWORD timeout", DIRECTION_NONE); + end_trace(); e_connectedmode = 0; e_dtmf = 0; new_state(EPOINT_STATE_OUT_DISCONNECT); @@ -1570,8 +1602,8 @@ void EndpointAppPBX::hookflash(void) notify_active(); e_tx_state = NOTIFY_STATE_ACTIVE; - printlog("%3d endpoint HOOKFLASH\n", ea_endpoint->ep_serial); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) dtmf hookflash detected.\n", ea_endpoint->ep_serial); + trace_header("HOOKFLASH DTMF", DIRECTION_NONE); + end_trace(); if (ea_endpoint->ep_use > 1) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cannot hooflash while child process is running.\n", ea_endpoint->ep_serial); @@ -1652,16 +1684,21 @@ colp, outclip, outcolp { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call is external or voip\n", ea_endpoint->ep_serial); } - printlog("%3d incoming %s='%s'%s%s%s%s dialing='%s'\n", - ea_endpoint->ep_serial, - (e_callerinfo.intern[0])?"SETUP from extension":"SETUP from extern", - (e_callerinfo.intern[0])?e_callerinfo.intern:e_callerinfo.id, - (e_callerinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"", - (e_redirinfo.id[0])?"redirected='":"", - e_redirinfo.id, - (e_redirinfo.id[0])?"'":"", - e_dialinginfo.number - ); + trace_header("SETUP", DIRECTION_IN); + if (e_callerinfo.intern[0]) + add_trace("extension", NULL, "%s", e_callerinfo.intern); + add_trace("caller id", "number", "%s", numberrize_callerinfo(e_callerinfo.id, e_callerinfo.ntype)); + if (e_callerinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("caller id", "present", "restricted"); + if (e_redirinfo.id[0]) + { + add_trace("redir'ing", "number", "%s", numberrize_callerinfo(e_redirinfo.id, e_redirinfo.ntype)); + if (e_redirinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("redir'ing", "present", "restricted"); + } + if (e_dialinginfo.number) + add_trace("dialing", "number", "%s", e_dialinginfo.number)); + end_trace(); if (e_callerinfo.itype == INFO_ITYPE_INTERN) { @@ -1671,8 +1708,9 @@ colp, outclip, outcolp if (!read_extension(&e_ext, e_ext.number)) { /* extension doesn't exist */ - printlog("%3d endpoint EXTENSION '%s' doesn't exist, please check or create.\n", ea_endpoint->ep_serial, e_callerinfo.id); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) rejecting call from not existing extension: '%s'\n", ea_endpoint->ep_serial, e_ext.number); + trace_header("EXTENSION (not created)", DIRECTION_IN); + add_trace("extension", NULL, "%s", e_ext.number); + end_trace(); message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, ""); new_state(EPOINT_STATE_OUT_DISCONNECT); set_tone(portlist, "cause_80"); /* pbx cause: extension not authorized */ @@ -1788,10 +1826,11 @@ colp, outclip, outcolp /* port MESSAGE_INFORMATION */ void EndpointAppPBX::port_information(struct port_list *portlist, int message_type, union parameter *param) { - printlog("%3d incoming INFORMATION information='%s'\n", - ea_endpoint->ep_serial, - param->information.number - ); + trace_header("INFORMATION", DIRECTION_IN); + add_trace("dialing", NULL, "%s", param->information.number); + if (param->information.sending_complete) + add_trace("complete", NULL, NULL); + end_trace(); e_overlap = 1; /* turn off dtmf detection, in case dtmf is sent with keypad information */ @@ -1864,10 +1903,9 @@ void EndpointAppPBX::port_information(struct port_list *portlist, int message_ty /* port MESSAGE_DTMF */ void EndpointAppPBX::port_dtmf(struct port_list *portlist, int message_type, union parameter *param) { - printlog("%3d incoming DTMF digit='%c'\n", - ea_endpoint->ep_serial, - param->dtmf - ); + trace_header("DTMF", DIRECTION_IN); + add_trace("digit", NULL, "%c", param->dtmf); + end_trace(); /* only if dtmf detection is enabled */ if (!e_dtmf) { @@ -1997,9 +2035,8 @@ void EndpointAppPBX::port_overlap(struct port_list *portlist, int message_type, /* signal to call tool */ admin_call_response(e_adminid, ADMIN_CALL_SETUP_ACK, "", 0, 0, 0); - printlog("%3d incoming SETUP ACKNOWLEDGE\n", - ea_endpoint->ep_serial - ); + trace_header("SETUP ACKNOWLEDGE", DIRECTION_IN); + end_trace(); if (e_dialing_queue[0] && portlist) { /* send what we have not dialed yet, because we had no setup complete */ @@ -2051,9 +2088,8 @@ void EndpointAppPBX::port_proceeding(struct port_list *portlist, int message_typ /* signal to call tool */ admin_call_response(e_adminid, ADMIN_CALL_PROCEEDING, "", 0, 0, 0); - printlog("%3d incoming PROCEEDING\n", - ea_endpoint->ep_serial - ); + trace_header("PROCEEDING", DIRECTION_IN); + end_trace(); e_state = EPOINT_STATE_OUT_PROCEEDING; /* check if pattern is availatle */ if (!ea_endpoint->ep_portlist->next && (portlist->earlyb || portlist->port_type==PORT_TYPE_VBOX_OUT)) /* one port_list relation and tones available */ @@ -2094,9 +2130,8 @@ void EndpointAppPBX::port_alerting(struct port_list *portlist, int message_type, /* signal to call tool */ admin_call_response(e_adminid, ADMIN_CALL_ALERTING, "", 0, 0, 0); - printlog("%3d incoming ALERTING\n", - ea_endpoint->ep_serial - ); + trace_header("ALERTING", DIRECTION_IN); + end_trace(); new_state(EPOINT_STATE_OUT_ALERTING); /* check if pattern is available */ if (!ea_endpoint->ep_portlist->next && (portlist->earlyb || portlist->port_type==PORT_TYPE_VBOX_OUT)) /* one port_list relation and tones available */ @@ -2142,11 +2177,13 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, admin_call_response(e_adminid, ADMIN_CALL_CONNECT, numberrize_callerinfo(param->connectinfo.id,param->connectinfo.ntype), 0, 0, 0); memcpy(&e_connectinfo, ¶m->connectinfo, sizeof(e_connectinfo)); - printlog("%3d incoming CONNECT id='%s'%s\n", - ea_endpoint->ep_serial, - (e_connectinfo.intern[0])?e_connectinfo.intern:e_connectinfo.id, - (e_connectinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"" - ); + trace_header("CONNECT", DIRECTION_IN); + if (e_connectinfo.intern[0]) + add_trace("extension", NULL, "%s", e_connectinfo.intern); + add_trace("connect id", "number", "%s", numberrize_callerinfo(e_connectinfo.id, e_connectinfo.ntype)); + if (e_connectinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("connect id", "present", "restricted"); + end_trace(); PDEBUG(DEBUG_EPOINT, "EPOINT(%d) removing all other ports (start)\n", ea_endpoint->ep_serial); while(ea_endpoint->ep_portlist->next) /* as long as we have at least two ports */ { @@ -2349,14 +2386,10 @@ void EndpointAppPBX::port_disconnect_release(struct port_list *portlist, int mes /* signal to call tool */ admin_call_response(e_adminid, (message_type==MESSAGE_DISCONNECT)?ADMIN_CALL_DISCONNECT:ADMIN_CALL_RELEASE, "", param->disconnectinfo.cause, param->disconnectinfo.location, 0); - printlog("%3d incoming %s cause='%d' (%s) location='%d' (%s)\n", - ea_endpoint->ep_serial, - (message_type==MESSAGE_DISCONNECT)?"DISCONNECT":"RELEASE", - param->disconnectinfo.cause, - (param->disconnectinfo.cause>0 && param->disconnectinfo.cause<128)?isdn_cause[param->disconnectinfo.cause].english:"-", - param->disconnectinfo.location, - (param->disconnectinfo.location>=0 && param->disconnectinfo.location<16)?isdn_location[param->disconnectinfo.location].english:"-" - ); + trace_header((message_type==MESSAGE_DISCONNECT)?"DISCONNECT":"RELEASE", DIRECTION_IN); + add_trace("cause", "value", "%d", param->disconnectinfo.cause); + add_trace("cause", "location", "%d", param->disconnectinfo.location); + end_trace(); //#warning does this work? only disconnect when incoming port hat not already disconnected yet? if (e_state==EPOINT_STATE_IN_DISCONNECT && message_type!=MESSAGE_RELEASE)// || e_state==EPOINT_STATE_OUT_DISCONNECT || e_state==EPOINT_STATE_IDLE) @@ -2487,48 +2520,57 @@ void EndpointAppPBX::port_timeout(struct port_list *portlist, int message_type, { char cause[16]; - printlog("%3d incoming TIMEOUT\n", - ea_endpoint->ep_serial - ); + trace_header("TIMEOUT", DIRECTION_IN); message_type = MESSAGE_DISCONNECT; switch (param->state) { case PORT_STATE_OUT_SETUP: case PORT_STATE_OUT_OVERLAP: + add_trace("state", NULL, "outgoing setup/dialing"); + end_trace(); /* no user responding */ release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NOUSER, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); return; /* must exit here */ case PORT_STATE_IN_SETUP: case PORT_STATE_IN_OVERLAP: + add_trace("state", NULL, "incoming setup/dialing"); param->disconnectinfo.cause = CAUSE_INVALID; /* number incomplete */ param->disconnectinfo.location = LOCATION_PRIVATE_LOCAL; break; case PORT_STATE_OUT_PROCEEDING: + add_trace("state", NULL, "outgoing proceeding"); + end_trace(); param->disconnectinfo.cause = CAUSE_NOUSER; /* no user responding */ param->disconnectinfo.location = LOCATION_PRIVATE_LOCAL; release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NOUSER, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); return; /* must exit here */ case PORT_STATE_IN_PROCEEDING: + add_trace("state", NULL, "incoming proceeding"); param->disconnectinfo.cause = CAUSE_NOUSER; param->disconnectinfo.location = LOCATION_PRIVATE_LOCAL; /* no user responding */ break; case PORT_STATE_OUT_ALERTING: + add_trace("state", NULL, "outgoing alerting"); + end_trace(); param->disconnectinfo.cause = CAUSE_NOANSWER; /* no answer */ param->disconnectinfo.location = LOCATION_PRIVATE_LOCAL; release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NOANSWER, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); return; /* must exit here */ case PORT_STATE_IN_ALERTING: + add_trace("state", NULL, "incoming alerting"); param->disconnectinfo.cause = CAUSE_NOANSWER; param->disconnectinfo.location = LOCATION_PRIVATE_LOCAL; break; case PORT_STATE_IN_DISCONNECT: case PORT_STATE_OUT_DISCONNECT: + add_trace("state", NULL, "disconnect"); + end_trace(); PDEBUG(DEBUG_EPOINT, "EPOINT(%d) in this special case, we release due to disconnect timeout.\n", ea_endpoint->ep_serial); release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); return; /* must exit here */ @@ -2537,6 +2579,7 @@ void EndpointAppPBX::port_timeout(struct port_list *portlist, int message_type, param->disconnectinfo.cause = 31; /* normal unspecified */ param->disconnectinfo.location = LOCATION_PRIVATE_LOCAL; } + end_trace(); /* release call, disconnect isdn */ e_call_pattern = 0; new_state(EPOINT_STATE_OUT_DISCONNECT); @@ -2681,16 +2724,22 @@ void EndpointAppPBX::port_notify(struct port_list *portlist, int message_type, u logtext = "CALL_IS_DIVERTING"; break; default: - SPRINT(buffer, "indicator=%d", param->notifyinfo.notify - 0x80); + SPRINT(buffer, "%d", param->notifyinfo.notify - 0x80); logtext = buffer; } - printlog("%3d incoming NOTIFY notify='%s' id='%s'%s\n", - ea_endpoint->ep_serial, - logtext, - param->notifyinfo.id, - (param->notifyinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"" - ); + trace_header("NOTIFY", DIRECTION_IN); + if (param->notifyinfo.notify) + add_trace("indicator", NULL, "%s", logtext); + if (param->notifyinfo.id) + { + add_trace("redir'on", "number", "%s", numberrize_callerinfo(param->notifyinfo.id, param->notifyinfo.ntype)); + if (param->notifyinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("redir'on", "present", "restricted"); + } + if (param->notifyinfo.display[0]) + add_trace("display", NULL, "%s", param->notifyinfo.display); + end_trace(); /* notify call if available */ if (ea_endpoint->ep_call_id) @@ -2707,10 +2756,8 @@ void EndpointAppPBX::port_facility(struct port_list *portlist, int message_type, { struct message *message; - printlog("%3d incoming FACILITY len='%d'\n", - ea_endpoint->ep_serial, - param->facilityinfo.len - ); + trace_header("FACILITY", DIRECTION_IN); + end_trace(); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_FACILITY); memcpy(&message->param.facilityinfo, ¶m->facilityinfo, sizeof(struct facility_info)); @@ -2721,9 +2768,8 @@ void EndpointAppPBX::port_facility(struct port_list *portlist, int message_type, /* NOTE: before supending, the inactive-notification must be done in order to set call mixer */ void EndpointAppPBX::port_suspend(struct port_list *portlist, int message_type, union parameter *param) { - printlog("%3d incoming SUSPEND\n", - ea_endpoint->ep_serial - ); + trace_header("SUSPEND", DIRECTION_IN); + end_trace(); /* epoint is now parked */ ea_endpoint->ep_park = 1; memcpy(ea_endpoint->ep_park_callid, param->parkinfo.callid, sizeof(ea_endpoint->ep_park_callid)); @@ -2737,9 +2783,8 @@ void EndpointAppPBX::port_suspend(struct port_list *portlist, int message_type, /* NOTE: before resume, the active-notification must be done in order to set call mixer */ void EndpointAppPBX::port_resume(struct port_list *portlist, int message_type, union parameter *param) { - printlog("%3d incoming RESUME\n", - ea_endpoint->ep_serial - ); + trace_header("RESUME", DIRECTION_IN); + end_trace(); /* epoint is now resumed */ ea_endpoint->ep_park = 0; @@ -4196,99 +4241,60 @@ void EndpointAppPBX::logmessage(struct message *message) switch(message->type) { case MESSAGE_SETUP: - port = find_port_id(message->id_to); - if (!port) - return; - if (port->p_type == PORT_TYPE_DSS1_NT_OUT) - { - pdss1 = (class Pdss1 *)port; - printlog("%3d outgoing SETUP from %s='%s'%s%s%s%s to intern='%s' port='%d' (NT)\n", - ea_endpoint->ep_serial, - (message->param.setup.callerinfo.intern[0])?"intern":"extern", - (message->param.setup.callerinfo.intern[0])?e_callerinfo.intern:e_callerinfo.id, - (message->param.setup.callerinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"", - (message->param.setup.redirinfo.id[0])?"redirected='":"", - message->param.setup.redirinfo.id, - (message->param.setup.redirinfo.id[0])?"'":"", - message->param.setup.dialinginfo.number, - pdss1->p_m_mISDNport->portnum - ); - } - if (port->p_type == PORT_TYPE_DSS1_TE_OUT) + trace_header("SETUP", DIRECTION_OUT); + if (message->param.setup.callerinfo.intern[0]) + add_trace("extension", NULL, "%s", message->param.setup.callerinfo.intern); + add_trace("caller id", "number", "%s", numberrize_callerinfo(message->param.setup.callerinfo.id, message->param.setup.callerinfo.ntype)); + if (message->param.setup.callerinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("caller id", "present", "restricted"); + if (message->param.setup.redirinfo.number[0]) { - pdss1 = (class Pdss1 *)port; - printlog("%3d outgoing SETUP from %s='%s'%s%s%s%s to extern='%s' port='%d' (TE)\n", - ea_endpoint->ep_serial, - (message->param.setup.callerinfo.intern[0])?"intern":"extern", - (message->param.setup.callerinfo.intern[0])?e_callerinfo.intern:e_callerinfo.id, - (message->param.setup.callerinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"", - (message->param.setup.redirinfo.id[0])?"redirected='":"", - message->param.setup.redirinfo.id, - (message->param.setup.redirinfo.id[0])?"'":"", - message->param.setup.dialinginfo.number, - pdss1->p_m_mISDNport->portnum - ); - } - if (port->p_type == PORT_TYPE_VBOX_OUT) - { - printlog("%3d outgoing SETUP from %s='%s'%s%s%s%s to vbox='%s'\n", - ea_endpoint->ep_serial, - (message->param.setup.callerinfo.intern[0])?"intern":"extern", - (message->param.setup.callerinfo.intern[0])?e_callerinfo.intern:e_callerinfo.id, - (message->param.setup.callerinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"", - (message->param.setup.redirinfo.id[0])?"redirected='":"", - message->param.setup.redirinfo.id, - (message->param.setup.redirinfo.id[0])?"'":"", - message->param.setup.dialinginfo.number - ); + add_trace("redir'ing", "number", "%s", numberrize_callerinfo(message->param.setup.redirinfo.id, message->param.setup.redirinfo.ntype)); + if (message->param.setup.redirinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("redir'ing", "present", "restricted"); } + if (message->param.setup.dialinginfo.number[0]) + add_trace("dialing", NULL, "%s", message->param.setup.dialinginfo.number); + end_trace(); break; case MESSAGE_OVERLAP: - printlog("%3d outgoing SETUP ACKNOWLEDGE\n", - ea_endpoint->ep_serial - ); + trace_header("SETUP ACKNOWLEDGE", DIRECTION_OUT); + end_trace(); break; case MESSAGE_PROCEEDING: - printlog("%3d outgoing PROCEEDING\n", - ea_endpoint->ep_serial - ); + trace_header("PROCEEDING", DIRECTION_OUT); + end_trace(); break; case MESSAGE_ALERTING: - printlog("%3d outgoing ALERTING\n", - ea_endpoint->ep_serial - ); + trace_header("ALERTING", DIRECTION_OUT); + end_trace(); break; case MESSAGE_CONNECT: - printlog("%3d outgoing CONNECT id='%s'%s\n", - ea_endpoint->ep_serial, - message->param.connectinfo.id, - (message->param.connectinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"" - ); + trace_header("CONNECT", DIRECTION_OUT); + if (message->param.connectinfo.intern[0]) + add_trace("extension", NULL, "%s", message->param.connectinfo.intern); + add_trace("connect id", "number", "%s", numberrize_callerinfo(message->param.connectinfo.id, message->param.connectinfo.ntype)); + if (message->param.connectinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("connect id", "present", "restricted"); + end_trace(); break; case MESSAGE_DISCONNECT: - printlog("%3d outgoing DISCONNECT cause='%d' (%s) location='%d' (%s) display='%s'\n", - ea_endpoint->ep_serial, - message->param.disconnectinfo.cause, - (message->param.disconnectinfo.cause>0 && message->param.disconnectinfo.cause<128)?isdn_cause[message->param.disconnectinfo.cause].english:"-", - message->param.disconnectinfo.location, - (message->param.disconnectinfo.location>=0 && message->param.disconnectinfo.location<16)?isdn_location[message->param.disconnectinfo.location].english:"-", - message->param.disconnectinfo.display - ); + trace_header("DISCONNECT", DIRECTION_OUT); + add_trace("cause", "value", "%d", message->param.disconnectinfo.cause); + add_trace("cause", "location", "%d", message->param.disconnectinfo.location); + end_trace(); break; case MESSAGE_RELEASE: - printlog("%3d outgoing RELEASE cause='%d' (%s) location='%d' (%s)\n", - ea_endpoint->ep_serial, - message->param.disconnectinfo.cause, - (message->param.disconnectinfo.cause>0 && message->param.disconnectinfo.cause<128)?isdn_cause[message->param.disconnectinfo.cause].english:"-", - message->param.disconnectinfo.location, - (message->param.disconnectinfo.location>=0 && message->param.disconnectinfo.location<16)?isdn_location[message->param.disconnectinfo.location].english:"-" - ); + trace_header("RELEASE", DIRECTION_OUT); + add_trace("cause", "value", "%d", message->param.disconnectinfo.cause); + add_trace("cause", "location", "%d", message->param.disconnectinfo.location); + end_trace(); break; case MESSAGE_NOTIFY: @@ -4367,39 +4373,44 @@ void EndpointAppPBX::logmessage(struct message *message) logtext = "CALL_IS_DIVERTING"; break; default: - SPRINT(buffer, "indicator=%d", message->param.notifyinfo.notify - 0x80); + SPRINT(buffer, "%d", message->param.notifyinfo.notify - 0x80); logtext = buffer; } - printlog("%3d outgoing NOTIFY notify='%s' id='%s'%s display='%s'\n", - ea_endpoint->ep_serial, - logtext, - message->param.notifyinfo.id, - (message->param.notifyinfo.present==INFO_PRESENT_RESTRICTED)?" anonymous":"", - message->param.notifyinfo.display - ); + trace_header("NOTIFY", DIRECTION_OUT); + if (message->param.notifyinfo.notify) + add_trace("indicator", NULL, "%s", logtext); + if (message->param.notifyinfo.number[0]) + { + add_trace("redir'on", "number", "%s", numberrize_callerinfo(message->param.notifyinfo.id, message->param.notifyinfo.ntype)); + if (message->param.notifyinfo.present == INFO_PRESENT_RESTRICTED) + add_trace("redir'on", "present", "restricted"); + } + if (message->param.notifyinfo.display[0]) + add_trace("display", NULL, "%s", message->param.notifyinfo.display); + end_trace(); break; case MESSAGE_INFORMATION: - printlog("%3d outgoing INFORMATION information='%s'\n", - ea_endpoint->ep_serial, - message->param.information.number - ); + trace_header("INFORMATION", DIRECTION_OUT); + add_trace("dialing", NULL, "%s", message->param.information.number); + end_trace(); break; case MESSAGE_FACILITY: - printlog("%3d outgoing FACILITY len='%d'\n", - ea_endpoint->ep_serial, - message->param.facilityinfo.len - ); + trace_header("FACILITY", DIRECTION_OUT); + end_trace(); break; case MESSAGE_TONE: - printlog("%3d outgoing TONE dir='%s' name='%s'\n", - ea_endpoint->ep_serial, - message->param.tone.dir, - message->param.tone.name - ); + trace_header("TONE", DIRECTION_OUT); + if (message->param.tone.name[0]) + { + add_trace("directory", NULL, "%s", message->param.tone.dir[0]?message->param.tone.dir:"default"); + add_trace("name", NULL, "%s", message->param.tone.name); + } else + add_trace("off", NULL, NULL); + end_trace(); break; default: diff --git a/dss1.cpp b/dss1.cpp index c1feb73..cbb622d 100644 --- a/dss1.cpp +++ b/dss1.cpp @@ -172,6 +172,10 @@ static struct isdn_message { {"RESTART", CC_RESTART}, {"RELEASE_CR", CC_RELEASE_CR}, {"NEW_CR", CC_NEW_CR}, + {"DL_ESTABLSIH", DL_ESTABLSIH}, + {"DL_RELEASE", DL_RELEASE}, + {"PH_ACTICATIE", PH_ACTICATIE}, + {"PH_DEACTICATIE", PH_DEACTICATIE}, {NULL, 0}, }; @@ -187,7 +191,7 @@ static char *isdn_prim[4] = { /* * isdn trace header */ -void Pdss1::l3_trace_header(unsigned long prim, int direction_out) +void Pdss1::l1l2l3_trace_header(unsigned long prim, int direction_out) { int i; char msgtext[64] = "<>"; @@ -230,6 +234,24 @@ void Pdss1::l3_trace_header(unsigned long prim, int direction_out) p_dialinginfo.number, direction, CATEGORY_L3, + p_serial, + msgtext); +} + + +void Pdss1::chan_trace_header(char *msgtext) +{ + int i; + + + /* init trace with given values */ + start_trace(p_m_mISDNport->portnum, + p_m_mISDNport->ifport->interface, + nationalize(p_callerinfo.id, p_callerinfo.ntype), + p_dialinginfo.number, + 0, + CATEGORY_L3, + p_serial, msgtext); } @@ -260,13 +282,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex if (p_state != PORT_STATE_OUT_SETUP) return(0); - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_OUT, - CATEGORY_CH, - "CHANNEL SELECTION (first reply to setup)"); + chan_trace_header("CHANNEL SELECTION (first reply to setup)"); add_trace("channel", "request", "%d (forced)", p_m_b_channel); add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel); @@ -294,13 +310,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex if (p_state != PORT_STATE_OUT_SETUP) return(0); - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_OUT, - CATEGORY_CH, - "CHANNEL SELECTION (first reply to setup)"); + chan_trace_header("CHANNEL SELECTION (first reply to setup)"); add_trace("channel", "request", "%d (suggest)", p_m_b_channel); add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel); @@ -348,13 +358,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex if (p_state != PORT_STATE_OUT_SETUP) return(0); - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_OUT, - CATEGORY_CH, - "CHANNEL SELECTION (first reply to setup)"); + chan_trace_header("CHANNEL SELECTION (first reply to setup)"); add_trace("channel", "request", "any"); add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel); /* if no channel was replied */ @@ -388,13 +392,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex /* if not the first reply, but a connect, we are forced */ if (prim==(CC_CONNECT | INDICATION) && p_state!=PORT_STATE_OUT_SETUP) { - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_OUT, - CATEGORY_CH, - "CHANNEL SELECTION (connect)"); + chan_trace_header("CHANNEL SELECTION (connect)"); add_trace("channel", "request", "no-channel"); add_trace("channel", "reply", (channel>=0)?"%d%s":"(none)", channel, exclusive?" (forced)":""); if (channel > 0) @@ -423,13 +421,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex if (p_state != PORT_STATE_OUT_SETUP) return(0); - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_OUT, - CATEGORY_CH, - "CHANNEL SELECTION (first reply to setup)"); + chan_trace_header("CHANNEL SELECTION (first reply to setup)"); add_trace("channel", "request", "no-channel"); add_trace("channel", "reply", (channel>=0)?"%d":"(none)", channel); /* if first reply has no channel, we are done */ @@ -462,7 +454,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex channelerror: dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, p_m_d_l3id, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode); - l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen); enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret); @@ -502,7 +494,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) PERROR("fatal software error: l3-stack gives us a process id 0xff00-0xffff\n"); exit(-1); } - l3_trace_header(CC_NEW_CR | INDICATION, DIRECTION_IN); + l1l2l3_trace_header(CC_NEW_CR | INDICATION, DIRECTION_IN); if (p_m_d_l3id) add_trace("callref", "old", "0x%x", p_m_d_l3id); add_trace("callref", "new", "0x%x", dinfo); @@ -513,7 +505,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) p_m_d_ces = setup->ces; } - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_calling_pn(setup->CALLING_PN, (Q931_info_t *)((unsigned long)data+headerlen), &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id)); dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &called_type, &called_plan, (unsigned char *)p_dialinginfo.number, sizeof(p_dialinginfo.number)); dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad)); @@ -537,7 +529,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) printlog("--- port#%d is blocked.\n", mISDNport->ifport->portnum); dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, dinfo, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode); - l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen); enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */ add_trace("reason", NULL, "port blocked"); @@ -725,13 +717,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) } /* process channel */ - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_IN, - CATEGORY_CH, - "CHANNEL SELECTION (setup)"); + chan_trace_header("CHANNEL SELECTION (setup)"); if (exclusive<0) exclusive = 0; if (channel == CHANNEL_NO) @@ -861,7 +847,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) RELEASE_COMPLETE_t *release_complete; dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, dinfo, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode); - l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen); enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret); end_trace(); @@ -886,7 +872,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data) RELEASE_COMPLETE_t *release_complete; dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, dinfo, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode); - l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen); enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 41); /* temporary failure */ end_trace(); @@ -930,7 +916,7 @@ void Pdss1::information_ind(unsigned long prim, unsigned long dinfo, void *data) unsigned char keypad[32] = ""; struct message *message; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, (unsigned char *)p_dialinginfo.number, sizeof(p_dialinginfo.number)); dec_ie_keypad(information->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad)); dec_ie_complete(information->COMPLETE, (Q931_info_t *)((unsigned long)data+headerlen), &p_dialinginfo.sending_complete); @@ -969,7 +955,7 @@ void Pdss1::setup_acknowledge_ind(unsigned long prim, unsigned long dinfo, void int ret; struct message *message; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_channel_id(setup_acknowledge->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel); dec_ie_progress(setup_acknowledge->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &location, &progress); end_trace(); @@ -1005,7 +991,7 @@ void Pdss1::proceeding_ind(unsigned long prim, unsigned long dinfo, void *data) int notify = -1, type, plan, present; char redir[32]; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_channel_id(proceeding->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel); dec_ie_progress(proceeding->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &location, &progress); dec_ie_notify(NULL/*proceeding->NOTIFY*/, (Q931_info_t *)((unsigned long)data+headerlen), ¬ify); @@ -1088,7 +1074,7 @@ void Pdss1::alerting_ind(unsigned long prim, unsigned long dinfo, void *data) int notify = -1, type, plan, present; char redir[32]; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_channel_id(alerting->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel); dec_ie_progress(alerting->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &location, &progress); dec_ie_notify(NULL/*alerting->NOTIFY*/, (Q931_info_t *)((unsigned long)data+headerlen), ¬ify); @@ -1175,7 +1161,7 @@ void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data) if (p_m_d_ntmode) p_m_d_ces = connect->ces; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_channel_id(connect->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel); dec_ie_connected_pn(connect->CONNECT_PN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id)); #ifdef CENTREX @@ -1245,7 +1231,7 @@ void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data) /* send connect acknowledge */ dmsg = create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, dinfo, sizeof(CONNECT_ACKNOWLEDGE_t), p_m_d_ntmode); - l3_trace_header(CC_CONNECT | RESPONSE, DIRECTION_OUT); + l1l2l3_trace_header(CC_CONNECT | RESPONSE, DIRECTION_OUT); connect_acknowledge = (CONNECT_ACKNOWLEDGE_t *)(dmsg->data + headerlen); /* if we had no bchannel before, we send it now */ if (!bchannel_before && p_m_b_channel) @@ -1269,7 +1255,7 @@ void Pdss1::disconnect_ind(unsigned long prim, unsigned long dinfo, void *data) int coding, proglocation, progress; struct message *message; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_progress(disconnect->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &proglocation, &progress); dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause); end_trace(); @@ -1285,7 +1271,7 @@ void Pdss1::disconnect_ind(unsigned long prim, unsigned long dinfo, void *data) dmsg = create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, dinfo, sizeof(RELEASE_t), p_m_d_ntmode); release = (RELEASE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RELEASE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE | REQUEST, DIRECTION_OUT); enc_ie_cause(&release->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 16); /* normal */ add_trace("reason", NULL, "no remote patterns"); end_trace(); @@ -1334,7 +1320,7 @@ void Pdss1::disconnect_ind_i(unsigned long prim, unsigned long dinfo, void *data int location, cause; /* cause */ - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); if (p_m_d_collect_cause > 0) { add_trace("old-cause", "location", "%d", p_m_d_collect_location); @@ -1383,7 +1369,7 @@ void Pdss1::release_ind(unsigned long prim, unsigned long dinfo, void *data) int location, cause; struct message *message; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_cause(release->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause); end_trace(); @@ -1409,7 +1395,7 @@ void Pdss1::release_ind(unsigned long prim, unsigned long dinfo, void *data) dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, dinfo, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode); release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 16); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -1427,7 +1413,7 @@ void Pdss1::release_complete_ind(unsigned long prim, unsigned long dinfo, void * int location, cause; struct message *message; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_cause(release_complete->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause); end_trace(); @@ -1479,7 +1465,7 @@ void Pdss1::notify_ind(unsigned long prim, unsigned long dinfo, void *data) struct message *message; int notify, type, plan, present; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_notify(notifying->NOTIFY, (Q931_info_t *)((unsigned long)data+headerlen), ¬ify); dec_ie_redir_dn(notifying->REDIR_DN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, &present, (unsigned char *)message->param.notifyinfo.id, sizeof(message->param.notifyinfo.id)); end_trace(); @@ -1540,14 +1526,14 @@ void Pdss1::hold_ind(unsigned long prim, unsigned long dinfo, void *data) msg_t *dmsg; // class Endpoint *epoint; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); end_trace(); if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold) { dmsg = create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT, dinfo, sizeof(HOLD_REJECT_t), p_m_d_ntmode); hold_reject = (HOLD_REJECT_t *)(dmsg->data + headerlen); - l3_trace_header(CC_HOLD_REJECT | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_HOLD_REJECT | REQUEST, DIRECTION_OUT); enc_ie_cause(&hold_reject->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */ add_trace("reason", NULL, "no endpoint"); end_trace(); @@ -1563,13 +1549,7 @@ void Pdss1::hold_ind(unsigned long prim, unsigned long dinfo, void *data) message_put(message); /* deactivate bchannel */ - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_OUT, - CATEGORY_CH, - "CHANNEL RELEASE (hold)"); + chan_trace_header("CHANNEL RELEASE (hold)"); add_trace("disconnect", "channel", "%d", p_m_b_channel); end_trace(); free_bchannel(); @@ -1589,7 +1569,7 @@ pr /* acknowledge hold */ dmsg = create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE, dinfo, sizeof(HOLD_ACKNOWLEDGE_t), p_m_d_ntmode); hold_acknowledge = (HOLD_ACKNOWLEDGE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_HOLD_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_HOLD_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); } @@ -1607,7 +1587,7 @@ void Pdss1::retrieve_ind(unsigned long prim, unsigned long dinfo, void *data) msg_t *dmsg; int ret; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_channel_id(retrieve->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel); end_trace(); @@ -1618,7 +1598,7 @@ void Pdss1::retrieve_ind(unsigned long prim, unsigned long dinfo, void *data) dmsg = create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT, dinfo, sizeof(RETRIEVE_REJECT_t), p_m_d_ntmode); retrieve_reject = (RETRIEVE_REJECT_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RETRIEVE_REJECT | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RETRIEVE_REJECT | REQUEST, DIRECTION_OUT); enc_ie_cause(&retrieve_reject->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -1645,13 +1625,7 @@ mach den channel-kram, wie beim setup /* channel_id */ - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_IN, - CATEGORY_CH, - "CHANNEL SELECTION (retrieve)"); + chan_trace_header("CHANNEL RELEASE (retrieve)"); if (exclusive<0) exclusive = 0; alle channels richtig convertieren @@ -1702,7 +1676,7 @@ alle channels richtig convertieren /* acknowledge retrieve */ dmsg = create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE, dinfo, sizeof(RETRIEVE_ACKNOWLEDGE_t), p_m_d_ntmode); retrieve_acknowledge = (RETRIEVE_ACKNOWLEDGE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); enc_ie_channel_id(&retrieve_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -1722,7 +1696,7 @@ void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data) msg_t *dmsg; int ret = -31; /* normal, unspecified */ - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_call_id(suspend->CALL_ID, (Q931_info_t *)((unsigned long)data+headerlen), callid, &len); end_trace(); @@ -1731,7 +1705,7 @@ void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data) reject: dmsg = create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT, dinfo, sizeof(SUSPEND_REJECT_t), p_m_d_ntmode); suspend_reject = (SUSPEND_REJECT_t *)(dmsg->data + headerlen); - l3_trace_header(CC_SUSPEND_REJECT | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_SUSPEND_REJECT | REQUEST, DIRECTION_OUT); enc_ie_cause(&suspend_reject->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -1765,13 +1739,7 @@ void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data) message_put(message); /* deactivate bchannel */ - start_trace(p_m_mISDNport->portnum, - p_m_mISDNport->ifport->interface, - nationalize(p_callerinfo.id, p_callerinfo.ntype), - p_dialinginfo.number, - DIRECTION_OUT, - CATEGORY_CH, - "CHANNEL RELEASE (suspend)"); + chan_trace_header("CHANNEL RELEASE (suspend)"); add_trace("disconnect", "channel", "%d", p_m_b_channel); end_trace(); free_bchannel(); @@ -1790,7 +1758,7 @@ void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data) /* sending SUSPEND_ACKNOWLEDGE */ dmsg = create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE, dinfo, sizeof(SUSPEND_ACKNOWLEDGE_t), p_m_d_ntmode); suspend_acknowledge = (SUSPEND_ACKNOWLEDGE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_SUSPEND_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_SUSPEND_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -1822,7 +1790,7 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data) PERROR("fatal software error: l3-stack gives us a process id 0xff00-0xffff\n"); exit(-1); } - l3_trace_header(CC_NEW_CR | INDICATION, DIRECTION_IN); + l1l2l3_trace_header(CC_NEW_CR | INDICATION, DIRECTION_IN); if (p_m_d_l3id) add_trace("callref", "old", "0x%x", p_m_d_l3id); add_trace("callref", "new", "0x%x", dinfo); @@ -1833,7 +1801,7 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data) p_m_d_ces = setup->ces; } - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_call_id(resume->CALL_ID, (Q931_info_t *)((unsigned long)data+headerlen), callid, &len); end_trace(); @@ -1861,7 +1829,7 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data) reject: dmsg = create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT, dinfo, sizeof(RESUME_REJECT_t), p_m_d_ntmode); resume_reject = (RESUME_REJECT_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RESUME_REJECT | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RESUME_REJECT | REQUEST, DIRECTION_OUT); enc_ie_cause(&resume_reject->CAUSE, dmsg, (p_m_d_ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret); if (ret == -27) add_trace("reason", NULL, "port blocked"); @@ -1916,7 +1884,7 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data) /* sending RESUME_ACKNOWLEDGE */ dmsg = create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE, dinfo, sizeof(RESUME_ACKNOWLEDGE_t), p_m_d_ntmode); resume_acknowledge = (RESUME_ACKNOWLEDGE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RESUME_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RESUME_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); enc_ie_channel_id(&resume_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -1934,7 +1902,7 @@ void Pdss1::facility_ind(unsigned long prim, unsigned long dinfo, void *data) int facil_len; struct message *message; - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); dec_ie_facility(facility->FACILITY, (Q931_info_t *)((unsigned long)data+headerlen), facil, &facil_len); end_trace(); @@ -1962,7 +1930,7 @@ void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data) switch (prim) { case CC_TIMEOUT | INDICATION: - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); if (p_m_d_ntmode) { int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN; @@ -1984,7 +1952,7 @@ void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data) case CC_SETUP | CONFIRM: if (p_m_d_ntmode) { - l3_trace_header(CC_NEW_CR | INDICATION, DIRECTION_IN); + l1l2l3_trace_header(CC_NEW_CR | INDICATION, DIRECTION_IN); add_trace("callref", "old", "0x%x", p_m_d_l3id); /* nt-library now gives us a new id via CC_SETUP_CONFIRM */ if ((p_m_d_l3id&0xff00) != 0xff00) @@ -2103,7 +2071,7 @@ void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data) break; case CC_RELEASE_CR | INDICATION: - l3_trace_header(CC_RELEASE_CR | INDICATION, DIRECTION_IN); + l1l2l3_trace_header(CC_RELEASE_CR | INDICATION, DIRECTION_IN); add_trace("callref", NULL, "0x%x", p_m_d_l3id); end_trace(); if (p_m_d_ntmode) @@ -2132,7 +2100,7 @@ void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data) break; case CC_NEW_CR | INDICATION: - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); if (p_m_d_l3id) add_trace("callref", "old", "0x%x", p_m_d_l3id); if (p_m_d_ntmode) @@ -2150,7 +2118,7 @@ void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data) break; default: - l3_trace_header(prim, DIRECTION_IN); + l1l2l3_trace_header(prim, DIRECTION_IN); add_trace("unhandled", "prim", "0x%x", prim); end_trace(); } @@ -2241,7 +2209,7 @@ void Pdss1::message_information(unsigned long epoint_id, int message_id, union p if (param->information.number[0]) /* only if we have something to dial */ { dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode); - l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); information = (INFORMATION_t *)(dmsg->data + headerlen); enc_ie_called_pn(&information->CALLED_PN, dmsg, 0, 1, (unsigned char *)param->information.number); end_trace(); @@ -2296,7 +2264,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet /* sending information */ dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode); information = (INFORMATION_t *)(dmsg->data + headerlen); - l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); if (p_m_d_ntmode) enc_ie_display(&information->DISPLAY, dmsg, (unsigned char *)p_callerinfo.display); end_trace(); @@ -2335,7 +2303,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet channel = CHANNEL_NO; /* creating l3id */ - l3_trace_header(CC_NEW_CR | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_NEW_CR | REQUEST, DIRECTION_OUT); if (p_m_d_ntmode) { i = 0; @@ -2383,7 +2351,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet /* preparing setup message */ dmsg = create_l3msg(CC_SETUP | REQUEST, MT_SETUP, p_m_d_l3id, sizeof(SETUP_t), p_m_d_ntmode); - l3_trace_header(CC_SETUP | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_SETUP | REQUEST, DIRECTION_OUT); setup = (SETUP_t *)(dmsg->data + headerlen); /* channel information */ if (channel >= 0) /* it should */ @@ -2571,7 +2539,7 @@ void Pdss1::message_facility(unsigned long epoint_id, int message_id, union para /* sending facility */ dmsg = create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, p_m_d_l3id, sizeof(FACILITY_t), p_m_d_ntmode); facility = (FACILITY_t *)(dmsg->data + headerlen); - l3_trace_header(CC_FACILITY | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_FACILITY | REQUEST, DIRECTION_OUT); enc_ie_facility(&facility->FACILITY, dmsg, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -2653,7 +2621,7 @@ void Pdss1::message_notify(unsigned long epoint_id, int message_id, union parame /* sending notification */ dmsg = create_l3msg(CC_NOTIFY | REQUEST, MT_NOTIFY, p_m_d_l3id, sizeof(NOTIFY_t), p_m_d_ntmode); notification = (NOTIFY_t *)(dmsg->data + headerlen); - l3_trace_header(CC_NOTIFY | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_NOTIFY | REQUEST, DIRECTION_OUT); enc_ie_notify(¬ification->NOTIFY, dmsg, notify); /* sending redirection number only in ntmode */ if (type >= 0 && p_m_d_ntmode) @@ -2668,7 +2636,7 @@ void Pdss1::message_notify(unsigned long epoint_id, int message_id, union parame /* sending information */ dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode); information = (INFORMATION_t *)(dmsg->data + headerlen); - l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); enc_ie_display(&information->DISPLAY, dmsg, (unsigned char *)param->notifyinfo.display); end_trace(); msg_queue_tail(&p_m_mISDNport->downqueue, dmsg); @@ -2685,7 +2653,7 @@ void Pdss1::message_overlap(unsigned long epoint_id, int message_id, union param /* sending setup_acknowledge */ dmsg = create_l3msg(CC_SETUP_ACKNOWLEDGE | REQUEST, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, sizeof(SETUP_ACKNOWLEDGE_t), p_m_d_ntmode); setup_acknowledge = (SETUP_ACKNOWLEDGE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_SETUP_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_SETUP_ACKNOWLEDGE | REQUEST, DIRECTION_OUT); /* channel information */ if (p_state == PORT_STATE_IN_SETUP) enc_ie_channel_id(&setup_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel); @@ -2711,7 +2679,7 @@ void Pdss1::message_proceeding(unsigned long epoint_id, int message_id, union pa /* sending proceeding */ dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode); proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen); - l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); /* channel information */ if (p_state == PORT_STATE_IN_SETUP) enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel); @@ -2742,7 +2710,7 @@ void Pdss1::message_alerting(unsigned long epoint_id, int message_id, union para /* sending proceeding */ dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode); proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen); - l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); /* channel information */ enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel); /* progress information */ @@ -2758,7 +2726,7 @@ void Pdss1::message_alerting(unsigned long epoint_id, int message_id, union para /* sending alerting */ dmsg = create_l3msg(CC_ALERTING | REQUEST, MT_ALERTING, p_m_d_l3id, sizeof(ALERTING_t), p_m_d_ntmode); alerting = (ALERTING_t *)(dmsg->data + headerlen); - l3_trace_header(CC_ALERTING | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_ALERTING | REQUEST, DIRECTION_OUT); /* channel information */ if (p_state == PORT_STATE_IN_SETUP) enc_ie_channel_id(&alerting->CHANNEL_ID, dmsg, 1, p_m_b_channel); @@ -2792,7 +2760,7 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param /* sending proceeding */ dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode); proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen); - l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); /* channel information */ enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel); // /* progress information */ @@ -2815,7 +2783,7 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param /* sending information */ dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode); information = (INFORMATION_t *)(dmsg->data + headerlen); - l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_INFORMATION | REQUEST, DIRECTION_OUT); if (p_m_d_ntmode) enc_ie_display(&information->DISPLAY, dmsg, (unsigned char *)p_connectinfo.display); end_trace(); @@ -2832,7 +2800,7 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param /* preparing connect message */ dmsg = create_l3msg(CC_CONNECT | REQUEST, MT_CONNECT, p_m_d_l3id, sizeof(CONNECT_t), p_m_d_ntmode); connect = (CONNECT_t *)(dmsg->data + headerlen); - l3_trace_header(CC_CONNECT | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_CONNECT | REQUEST, DIRECTION_OUT); /* connect information */ plan = 1; switch (p_connectinfo.ntype) @@ -2931,7 +2899,7 @@ void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union pa /* sending release */ dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, p_m_d_l3id, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode); release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT); /* send cause */ enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_d_ntmode && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause); end_trace(); @@ -2949,7 +2917,7 @@ void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union pa /* sending proceeding */ dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode); proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen); - l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); /* channel information */ enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel); /* progress information */ @@ -2965,7 +2933,7 @@ void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union pa /* sending disconnect */ dmsg = create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, p_m_d_l3id, sizeof(DISCONNECT_t), p_m_d_ntmode); disconnect = (DISCONNECT_t *)(dmsg->data + headerlen); - l3_trace_header(CC_DISCONNECT | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_DISCONNECT | REQUEST, DIRECTION_OUT); /* progress information */ if (p_capainfo.bearer_capa==INFO_BC_SPEECH || p_capainfo.bearer_capa==INFO_BC_AUDIO @@ -3002,7 +2970,7 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param /* sending release */ dmsg = create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, p_m_d_l3id, sizeof(RELEASE_t), p_m_d_ntmode); release = (RELEASE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RELEASE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE | REQUEST, DIRECTION_OUT); /* send cause */ enc_ie_cause(&release->CAUSE, dmsg, (p_m_d_ntmode && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause); end_trace(); @@ -3011,7 +2979,7 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param /* remove epoint */ remove_endpoint: free_epointid(epoint_id); - l3_trace_header(CC_RELEASE_CR | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE_CR | REQUEST, DIRECTION_OUT); add_trace("callref", "new", "0x%x", p_m_d_l3id); end_trace(); if (p_m_d_ntmode) @@ -3032,7 +3000,7 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param /* sending release */ dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, p_m_d_l3id, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode); release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen); - l3_trace_header(CC_RELEASE | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_RELEASE | REQUEST, DIRECTION_OUT); /* send cause */ enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_d_ntmode && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause); end_trace(); @@ -3049,7 +3017,7 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param /* sending proceeding */ dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode); proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen); - l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_PROCEEDING | REQUEST, DIRECTION_OUT); /* channel information */ enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel); /* progress information */ @@ -3064,7 +3032,7 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param /* sending disconnect */ dmsg = create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, p_m_d_l3id, sizeof(DISCONNECT_t), p_m_d_ntmode); disconnect = (DISCONNECT_t *)(dmsg->data + headerlen); - l3_trace_header(CC_DISCONNECT | REQUEST, DIRECTION_OUT); + l1l2l3_trace_header(CC_DISCONNECT | REQUEST, DIRECTION_OUT); /* progress information */ if (p_capainfo.bearer_capa==INFO_BC_SPEECH || p_capainfo.bearer_capa==INFO_BC_AUDIO @@ -3167,6 +3135,8 @@ int Pdss1::message_epoint(unsigned long epoint_id, int message_id, union paramet act.dinfo = 0; act.len = 0; mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC); + l1l2l3_trace_header(act.prim, DIRECTION_OUT); + end_trace(); // /* set timeout */ // p_m_mISDNport->l1timeout = now+3; } @@ -3330,7 +3300,9 @@ int stack2manager_nt(void *dat, void *arg) case DL_ESTABLISH | INDICATION: case DL_ESTABLISH | CONFIRM: ss_estab: - PDEBUG(DEBUG_ISDN, "establish data link (DL) NT portnum=%d TEI=%d\n", mISDNport->portnum, hh->dinfo); + l1l2l3_trace_header(prim, DIRECTION_IN); + add_trace("tei", NULL, "%d", hh->dinfo); + end_trace(); if (mISDNport->ptp && hh->dinfo == 0) { if (mISDNport->l2establish) @@ -3347,7 +3319,9 @@ int stack2manager_nt(void *dat, void *arg) case DL_RELEASE | INDICATION: case DL_RELEASE | CONFIRM: ss_rel: - PDEBUG(DEBUG_ISDN, "release data link (DL) NT portnum=%d TEI=%d\n", mISDNport->portnum, hh->dinfo); + l1l2l3_trace_header(prim, DIRECTION_IN); + add_trace("tei", NULL, "%d", hh->dinfo); + end_trace(); if (mISDNport->ptp && hh->dinfo == 0) { mISDNport->l2link = 0; diff --git a/main.c b/main.c index 19d2c8d..9bf22e8 100644 --- a/main.c +++ b/main.c @@ -105,6 +105,7 @@ static void debug(const char *function, int line, char *prefix, char *buffer) debug_newline = 1; } +muss ins trace void printlog(const char *fmt, ...) { char buffer[4096]; diff --git a/route.c b/route.c index 7bbae0c..c950587 100644 --- a/route.c +++ b/route.c @@ -222,6 +222,9 @@ struct param_defs param_defs[] = { { PARAM_NOPASSWORD, "nopassword", PARAM_TYPE_NULL, "nopassword", "Don't ask for password. Be sure to authenticate right via real caller ID."}, + { PARAM_STRIP, + "strip", PARAM_TYPE_NULL, + "strip", "Remove digits that were required to match this rule."}, { 0, NULL, 0, NULL, NULL} }; @@ -309,7 +312,7 @@ struct action_defs action_defs[] = { // "Caller calls the timer."}, { ACTION_GOTO, "goto", NULL, &EndpointAppPBX::action_dialing_goto, NULL, - PARAM_CONNECT | PARAM_RULESET | PARAM_SAMPLE, + PARAM_CONNECT | PARAM_RULESET | PARAM_STRIP | PARAM_SAMPLE, "Jump to given ruleset and optionally play sample. Dialed digits are not flushed."}, { ACTION_MENU, "menu", NULL, &EndpointAppPBX::action_dialing_menu, NULL, diff --git a/route.h b/route.h index 7ed536d..e89fb89 100644 --- a/route.h +++ b/route.h @@ -111,9 +111,7 @@ enum { /* how to parse text file during startup */ #define PARAM_INTERFACES (1LL<<19) #define PARAM_ADDRESS (1LL<<20) #define PARAM_SAMPLE (1LL<<21) -#ifdef PBX #define PARAM_ANNOUNCEMENT (1LL<<22) -#endif #define PARAM_RULESET (1LL<<23) #define PARAM_CAUSE (1LL<<24) #define PARAM_LOCATION (1LL<<25) @@ -132,9 +130,8 @@ enum { /* how to parse text file during startup */ #define PARAM_CALLTO (1LL<<38) #define PARAM_ROOM (1LL<<39) #define PARAM_TIMEOUT (1LL<<40) -#ifdef PBX #define PARAM_NOPASSWORD (1LL<<41) -#endif +#define PARAM_STRIP (1LL<<42) /* action index diff --git a/trace.c b/trace.c index bb63ec2..999a6fe 100644 --- a/trace.c +++ b/trace.c @@ -32,7 +32,7 @@ static char *spaces[11] = { * initializes a new trace * all values will be reset */ -void start_trace(int port, char *interface, char *caller, char *dialing, int direction, char *category, char *name); +void start_trace(int port, char *interface, char *caller, char *dialing, int direction, int category, int serial, char *name); { if (trace.name[0]) PERROR("trace already started (name=%s)\n", trace.name); @@ -45,8 +45,8 @@ void start_trace(int port, char *interface, char *caller, char *dialing, int dir if (dialing) if (dialing[0]) SCPY(trace.dialing, dialing); trace.direction = direction; - if (category) if (category[0]) - SCPY(trace.category, category); + trace.category = category; + trace.serial = serial; if (name) if (name[0]) SCPY(trace.name, name); trace.sec = now_tv.tv_sec; @@ -104,7 +104,7 @@ void end_trace(void); /* process log file */ if (options.log[0]) { - string = print_trace(1, 0, NULL, NULL, NULL, -1, "AP", NULL); + string = print_trace(1, 0, NULL, NULL, NULL, -1, "AP", CATEGORY_EP); fwrite(string, strlen(string), 1, fp); } @@ -116,7 +116,7 @@ void end_trace(void); * prints trace to socket or log * detail: 1 = brief, 2=short, 3=long */ -static char *print_trace(int detail, int port, char *interface, char *caller, char *dialing, char *category); +static char *print_trace(int detail, int port, char *interface, char *caller, char *dialing, int category); { trace_string[0] = '\0'; char buffer[256]; @@ -198,8 +198,20 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch SCAT(trace_string, "------------------------------------------------------------------------------\n"); } - /* "L3: CC_SETUP (net->user)" */ - SPRINT(buffer, "%s: %s", trace.category[0]?trace.category:"--", trace.name[0]?trace.name:""); + /* "CH(45): CC_SETUP (net->user)" */ + switch (trace.category) + { case CATEGORY_CH: + SCAT(trace_string, "CH"); + break; + + case CATEGORY_EP: + SCAT(trace_string, "EP"); + break; + + default: + SCAT(trace_string, "--"); + } + SPRINT(buffer, "(%d): %s", trace.serial, trace.name[0]?trace.name:""); SCAT(trace_string, buffer); /* elements */ diff --git a/trace.h b/trace.h index 427eb97..e7012e0 100644 --- a/trace.h +++ b/trace.h @@ -27,6 +27,7 @@ struct trace { /* type */ char category[4]; + int serial; char name[64]; /* elements */ @@ -35,13 +36,9 @@ struct trace { }; -#define CATEGORY_L1 0x01 -#define CATEGORY_L2 0x02 -#define CATEGORY_L3 0x04 -#define CATEGORY_CH 0x08 -#define CATEGORY_EP 0x10 -#define CATEGORY_AP 0x20 -#define CATEGORY_RO 0x40 + +#define CATEGORY_CH 0x01 +#define CATEGORY_EP 0x02 void start_trace(int port, char *interface, char *caller, char *dialing, int direction, char *category, char *name); -- 2.13.6