From: Super User Date: Wed, 23 May 2007 09:19:25 +0000 (+0200) Subject: backup X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=996f984d61d412e9371cb503963de6a1f48e31d4 backup --- diff --git a/action.cpp b/action.cpp index 003dcf4..3655032 100644 --- a/action.cpp +++ b/action.cpp @@ -192,7 +192,7 @@ void EndpointAppPBX::action_dialing_internal(void) 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_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): internal call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_81"); @@ -229,7 +229,7 @@ void EndpointAppPBX::action_dialing_external(void) if (strchr(e_extdialing, '#')) { e_extdialing[0] = '\0'; - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): '#' detected: terminal '%s' selected caller id '%s' and continues dialing: '%s'\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, e_extdialing); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): '#' detected: terminal '%s' selected caller id '%s' and continues dialing: '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, e_extdialing); } /* eliminate digits before '*', which is a delete digit */ @@ -245,7 +245,7 @@ void EndpointAppPBX::action_dialing_external(void) } UCPY(p, p+1); /* remove '*' */ } - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s deleted digits and got new string: %s\n", ea_endpoint->ep_serial, e_terminal, e_extdialing); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s deleted digits and got new string: %s\n", ea_endpoint->ep_serial, e_ext.number, e_extdialing); } } @@ -325,7 +325,7 @@ void EndpointAppPBX::action_dialing_external(void) 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_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): external call from terminal denied: %s\n", ea_endpoint->ep_serial, e_ext.number); release(RELEASE_CALL, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, 0); set_tone(portlist, "cause_82"); denied: @@ -342,7 +342,7 @@ void EndpointAppPBX::action_dialing_external(void) 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_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): national call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); release(RELEASE_CALL, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, 0); set_tone(portlist, "cause_83"); goto denied; @@ -356,7 +356,7 @@ void EndpointAppPBX::action_dialing_external(void) 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_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): international call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); release(RELEASE_CALL, LOCATION_PRIVATE_LOCAL, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, 0); set_tone(portlist, "cause_84"); goto denied; @@ -421,13 +421,13 @@ void EndpointAppPBX::action_dialing_vbox_record(void) return; } - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s dialing extension: %s\n", ea_endpoint->ep_serial, e_terminal, rparam->string_value); + 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_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): internal call from terminal %s denied.\n", ea_endpoint->ep_serial, e_ext.number); new_state(EPOINT_STATE_OUT_DISCONNECT); message_disconnect_port(portlist, CAUSE_REJECTED, LOCATION_PRIVATE_LOCAL, ""); set_tone(portlist, "cause_81"); @@ -540,7 +540,7 @@ 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_terminal, partyline); + 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); @@ -569,29 +569,29 @@ void EndpointAppPBX::action_hangup_call(void) printlog("%3d action CALL to '%s' hangs up.\n", ea_endpoint->ep_serial, e_dialinginfo.number); /* check */ - if (e_terminal[0] == '\0') + if (e_ext.number[0] == '\0') { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because caller is unknown (not internal).\n", ea_endpoint->ep_serial, e_terminal, e_dialinginfo.number); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because caller is unknown (not internal).\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number); return; } - if (!(read_extension(&e_ext, e_terminal))) + if (!(read_extension(&e_ext, e_ext.number))) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because cannot read settings.\n", ea_endpoint->ep_serial, e_terminal, e_dialinginfo.number); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because cannot read settings.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number); return; } if (e_dialinginfo.number[0] == '\0') { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number because nothing was dialed.\n", ea_endpoint->ep_serial, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number because nothing was dialed.\n", ea_endpoint->ep_serial, e_ext.number); return; } if (!strcmp(e_dialinginfo.number, e_ext.last_out[0])) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_terminal, e_dialinginfo.number); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number); return; } /* insert */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_terminal, e_dialinginfo.number); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number); i = MAX_REMEMBER-1; while(i) { @@ -601,7 +601,7 @@ void EndpointAppPBX::action_hangup_call(void) SCPY(e_ext.last_out[0], e_dialinginfo.number); /* write extension */ - write_extension(&e_ext, e_terminal); + write_extension(&e_ext, e_ext.number); } @@ -647,7 +647,7 @@ void EndpointAppPBX::action_dialing_login(void) } /* we changed our extension */ - SCPY(e_terminal, extension); + SCPY(e_ext.number, extension); new_state(EPOINT_STATE_CONNECT); e_dtmf = 1; e_connectedmode = 1; @@ -679,7 +679,7 @@ 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_terminal); + printlog("%3d action LOGIN to extension %s, ask for password.\n", ea_endpoint->ep_serial, e_ext.number); new_state(EPOINT_STATE_IN_OVERLAP); e_ruleset = NULL; e_rule = NULL; @@ -774,9 +774,9 @@ 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_terminal, callerid); + 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_terminal)) + if (read_extension(&e_ext, e_ext.number)) { if (callerid[0] == '\0') { @@ -799,7 +799,7 @@ 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); } - write_extension(&e_ext, e_terminal); + write_extension(&e_ext, e_ext.number); } /* function activated */ @@ -867,8 +867,8 @@ void EndpointAppPBX::action_dialing_forward(void) dest = e_extdialing; } - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing forwarding to '%s'.\n", ea_endpoint->ep_serial, e_terminal, dest); - if (read_extension(&e_ext, e_terminal)) + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing forwarding to '%s'.\n", ea_endpoint->ep_serial, e_ext.number, dest); + if (read_extension(&e_ext, e_ext.number)) { switch(diversion) { @@ -891,7 +891,7 @@ void EndpointAppPBX::action_dialing_forward(void) SCPY(e_ext.cfp, dest); break; } - write_extension(&e_ext, e_terminal); + write_extension(&e_ext, e_ext.number); } /* function (de)activated */ message_disconnect_port(portlist, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, ""); @@ -993,7 +993,7 @@ void EndpointAppPBX::_action_redial_reply(int in) SPRINT(message->param.notifyinfo.display, "(%d) %s vbox", e_select+1, last+5); else SPRINT(message->param.notifyinfo.display, "(%d) %s", e_select+1, (last[0])?last:"- empty -"); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s sending display:%s\n", ea_endpoint->ep_serial, e_terminal, message->param.notifyinfo.display); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s sending display:%s\n", ea_endpoint->ep_serial, e_ext.number, message->param.notifyinfo.display); message_put(message); logmessage(message); } @@ -1061,7 +1061,7 @@ void EndpointAppPBX::action_dialing_powerdial(void) /* send connect to avoid overlap timeout */ // new_state(EPOINT_STATE_CONNECT); connect may prevent further dialing - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; memset(&e_connectinfo, 0, sizeof(e_connectinfo)); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT); @@ -1190,7 +1190,7 @@ void EndpointAppPBX::action_dialing_abbrev(void) portlist = ea_endpoint->ep_portlist; /* abbrev dialing is only possible if we have a caller defined */ - if (!e_terminal[0]) + if (!e_ext.number[0]) { printlog("%3d action ABBREVIATION only possible for internal callers.\n", ea_endpoint->ep_serial); new_state(EPOINT_STATE_OUT_DISCONNECT); @@ -1203,7 +1203,7 @@ void EndpointAppPBX::action_dialing_abbrev(void) abbrev = e_extdialing; phone = NULL; name = NULL; - result = parse_phonebook(e_terminal, &abbrev, &phone, &name); + 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); @@ -1266,7 +1266,7 @@ void EndpointAppPBX::action_dialing_test(void) case '3': printlog("%3d action TESTMODE executing 'echo connect' test.\n", ea_endpoint->ep_serial); new_state(EPOINT_STATE_CONNECT); - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; set_tone(portlist, NULL); memset(&e_connectinfo, 0, sizeof(e_connectinfo)); @@ -1296,7 +1296,7 @@ void EndpointAppPBX::action_dialing_test(void) case '4': printlog("%3d action TESTMODE executing 'tone connect' test.\n", ea_endpoint->ep_serial); new_state(EPOINT_STATE_CONNECT); - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; memset(&e_connectinfo, 0, sizeof(e_connectinfo)); message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT); @@ -1308,7 +1308,7 @@ void EndpointAppPBX::action_dialing_test(void) case '5': printlog("%3d action TESTMODE executing 'hold music' test.\n", ea_endpoint->ep_serial); new_state(EPOINT_STATE_CONNECT); - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; memset(&e_connectinfo, 0, sizeof(e_connectinfo)); message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT); @@ -1326,7 +1326,7 @@ void EndpointAppPBX::action_dialing_test(void) cause = 0; printlog("%3d action TESTMODE executing 'announcement' test with cause %d.\n", ea_endpoint->ep_serial, cause); new_state(EPOINT_STATE_CONNECT); - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; SPRINT(causestr,"cause_%02x",cause); memset(&e_connectinfo, 0, sizeof(e_connectinfo)); @@ -1360,7 +1360,7 @@ void EndpointAppPBX::action_dialing_test(void) case '9': /* text callerid test */ printlog("%3d action TESTMODE executing 'caller id' test.\n", ea_endpoint->ep_serial); new_state(EPOINT_STATE_CONNECT); - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; memset(&e_connectinfo, 0, sizeof(e_connectinfo)); SCPY(e_connectinfo.id, "12345678"); @@ -1407,7 +1407,7 @@ void EndpointAppPBX::action_init_play(void) goto disconnect; } - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; set_tone(ea_endpoint->ep_portlist, rparam->string_value); @@ -1662,7 +1662,7 @@ void EndpointAppPBX::action_dialing_calculator(void) /* display dialing */ message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY); SPRINT(message->param.notifyinfo.display, ">%s", e_extdialing); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s displaying interpreted dialing '%s' internal values: %f %f\n", ea_endpoint->ep_serial, e_terminal, e_extdialing, value1, value2); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s displaying interpreted dialing '%s' internal values: %f %f\n", ea_endpoint->ep_serial, e_ext.number, e_extdialing, value1, value2); message_put(message); logmessage(message); @@ -1872,7 +1872,7 @@ void EndpointAppPBX::action_dialing_help(void) //SCAT(dialing, e_dialinginfo.number); SCPY(e_dialinginfo.number, dialing); e_extdialing = e_dialinginfo.number+strlen(numbering->prefix); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' dialing: %s\n", ea_endpoint->ep_serial, e_terminal, numb_actions[numbering->action], e_dialinginfo.number); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' dialing: %s\n", ea_endpoint->ep_serial, e_ext.number, numb_actions[numbering->action], e_dialinginfo.number); nesting?: process_dialing(); return; @@ -1881,7 +1881,7 @@ nesting?: /* send display message to port */ message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY); SPRINT(message->param.notifyinfo.display, ">%s %s%s%s", numbering->prefix, numb_actions[numbering->action], (numbering->param[0])?" ":"", numbering->param); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' sending display:%s\n", ea_endpoint->ep_serial, e_terminal, numb_actions[numbering->action], message->param.notifyinfo.display); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s selected a new menu '%s' sending display:%s\n", ea_endpoint->ep_serial, e_ext.number, numb_actions[numbering->action], message->param.notifyinfo.display); message_put(message); logmessage(message); #endif @@ -1920,11 +1920,11 @@ void EndpointAppPBX::action_hangup_execute(void) 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_terminal); + PERROR("EPOINT(%d): terminal %s: NO PARAMETER GIVEN for 'execute' action. see routing.conf\n", ea_endpoint->ep_serial, e_ext.number); 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_terminal, command); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: executing '%s'.\n", ea_endpoint->ep_serial, e_ext.number, command); argv[0] = command; while(strchr(argv[0], '/')) @@ -1971,17 +1971,17 @@ void EndpointAppPBX::action_hangup_file(void) 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_terminal); + PERROR("EPOINT(%d): terminal %s: NO FILENAME GIVEN for 'file' action. see routing.conf\n", ea_endpoint->ep_serial, e_ext.number); 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_terminal, file); + PERROR("EPOINT(%d): terminal %s: given file '%s' cannot be opened. see routing.conf\n", ea_endpoint->ep_serial, e_ext.number, file); 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_terminal, 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); fprintf(fp, "%s\n", content); fclose(fp); } @@ -2043,7 +2043,7 @@ void EndpointAppPBX::action_dialing_password(void) if (e_action) if (e_action->index == ACTION_PASSWORD_WRITE) { - append_callbackauth(e_terminal, &e_callbackinfo); + append_callbackauth(e_ext.number, &e_callbackinfo); printlog("%3d action PASSWORD WRITE password written\n", ea_endpoint->ep_serial); } @@ -2081,7 +2081,7 @@ void EndpointAppPBX::process_dialing(void) if (!portlist) { portlist_error: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): note: dialing call requires exactly one port object to process dialing. this case could happen due to a parked call. we end dialing here.\n", ea_endpoint->ep_serial, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): note: dialing call requires exactly one port object to process dialing. this case could happen due to a parked call. we end dialing here.\n", ea_endpoint->ep_serial, e_ext.number); e_action_timeout = 0; e_match_timeout = 0; return; @@ -2218,7 +2218,7 @@ void EndpointAppPBX::process_dialing(void) if (e_match_timeout && now_d>=e_match_timeout) { /* return timeout rule */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', timeout in ruleset '%s'\n", ea_endpoint->ep_serial, e_terminal, e_dialinginfo.number, e_ruleset->name); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', timeout in ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number, e_ruleset->name); e_match_timeout = 0; e_action = e_match_to_action; e_extdialing = e_match_to_extdialing; @@ -2228,7 +2228,7 @@ void EndpointAppPBX::process_dialing(void) { //PDEBUG(~0, "HANG-BUG-DEBUGGING: before routing\n"); /* check for matching rule */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', checking matching rule of ruleset '%s'\n", ea_endpoint->ep_serial, e_terminal, e_dialinginfo.number, e_ruleset->name); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' dialing: '%s', checking matching rule of ruleset '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.number, e_ruleset->name); if (e_ruleset) { e_action = route(e_ruleset); @@ -2244,7 +2244,7 @@ void EndpointAppPBX::process_dialing(void) } if (!e_action) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): no rule within the current ruleset matches yet.\n", ea_endpoint->ep_serial, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): no rule within the current ruleset matches yet.\n", ea_endpoint->ep_serial, e_ext.number); goto display; } @@ -2291,7 +2291,7 @@ void EndpointAppPBX::process_dialing(void) if (action_defs[e_action->index].init_func) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a init function, so we call it...\n", ea_endpoint->ep_serial, e_terminal, action_defs[e_action->index].name); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a init function, so we call it...\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name); (this->*(action_defs[e_action->index].init_func))(); } if (e_state!=EPOINT_STATE_IN_SETUP @@ -2303,11 +2303,11 @@ void EndpointAppPBX::process_dialing(void) } /* show what we are doing */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' action: %s (dialing '%s')\n", ea_endpoint->ep_serial, e_terminal, action_defs[e_action->index].name, e_extdialing); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s' action: %s (dialing '%s')\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name, e_extdialing); /* go to action's dialing function */ if (action_defs[e_action->index].dialing_func) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a dialing function, so we call it...\n", ea_endpoint->ep_serial, e_terminal, action_defs[e_action->index].name); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a dialing function, so we call it...\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name); (this->*(action_defs[e_action->index].dialing_func))(); } @@ -2339,7 +2339,7 @@ void EndpointAppPBX::process_dialing(void) SPRINT(message->param.notifyinfo.display, "%s%s%s", action_defs[e_action->index].name, (e_extdialing[0])?" ":"", e_extdialing); } - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s displaying interpreted dialing '%s'\n", ea_endpoint->ep_serial, e_terminal, message->param.notifyinfo.display); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s displaying interpreted dialing '%s'\n", ea_endpoint->ep_serial, e_ext.number, message->param.notifyinfo.display); message_put(message); logmessage(message); } @@ -2356,10 +2356,10 @@ void EndpointAppPBX::process_hangup(int cause, int location) char callertext[256], dialingtext[256]; int writeext = 0, i; - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s'\n", ea_endpoint->ep_serial, e_terminal); - if (e_terminal[0]) + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal '%s'\n", ea_endpoint->ep_serial, e_ext.number); + if (e_ext.number[0]) { - if (read_extension(&e_ext, e_terminal)) + if (read_extension(&e_ext, e_ext.number)) writeext = 0x10; if (!e_start) @@ -2369,7 +2369,7 @@ void EndpointAppPBX::process_hangup(int cause, int location) } else if (!e_stop) time(&e_stop); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): writing connect from %s to %s into logfile of %s\n", ea_endpoint->ep_serial, e_callerinfo.id, e_dialinginfo.number, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): writing connect from %s to %s into logfile of %s\n", ea_endpoint->ep_serial, e_callerinfo.id, e_dialinginfo.number, e_ext.number); switch(e_dialinginfo.itype) { case INFO_ITYPE_CHAN: @@ -2396,7 +2396,7 @@ void EndpointAppPBX::process_hangup(int cause, int location) UNPRINT(strchr(callertext,'\0'), sizeof(callertext)-1+strlen(callertext), " (intern %s)", e_callerinfo.intern); if (e_callerinfo.voip[0]) /* add voip if present */ UNPRINT(strchr(callertext,'\0'), sizeof(callertext)-1+strlen(callertext), " (voip %s)", e_callerinfo.voip); - write_log(e_terminal, callertext, dialingtext, e_start, e_stop, 0, cause, location); + write_log(e_ext.number, callertext, dialingtext, e_start, e_stop, 0, cause, location); /* store last received call for reply-list */ if (e_callerinfo.id[0] || e_callerinfo.intern[0]) @@ -2416,21 +2416,21 @@ void EndpointAppPBX::process_hangup(int cause, int location) } SCPY(e_ext.last_in[0], callertext); writeext |= 1; /* store extension later */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last received caller id '%s'.\n", ea_endpoint->ep_serial, e_terminal, e_ext.last_in[0]); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last received caller id '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_ext.last_in[0]); } else - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last received id '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_terminal, callertext); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last received id '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, callertext); } } /* write extension if needed */ if (writeext == 0x11) - write_extension(&e_ext, e_terminal); + write_extension(&e_ext, e_ext.number); if (e_action) { if (action_defs[e_action->index].hangup_func) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a hangup function, so we call it...\n", ea_endpoint->ep_serial, e_terminal, action_defs[e_action->index].name); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: current action '%s' has a hangup function, so we call it...\n", ea_endpoint->ep_serial, e_ext.number, action_defs[e_action->index].name); (this->*(action_defs[e_action->index].hangup_func))(); } } diff --git a/action_efi.cpp b/action_efi.cpp index ce0253f..5b679cb 100644 --- a/action_efi.cpp +++ b/action_efi.cpp @@ -72,7 +72,7 @@ void EndpointAppPBX::efi_message_eof(void) struct message *message; struct port_list *portlist = ea_endpoint->ep_portlist; - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s end of file during state: %d\n", ea_endpoint->ep_serial, e_terminal, e_vbox_state); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s end of file during state: %d\n", ea_endpoint->ep_serial, e_ext.number, e_vbox_state); switch(e_efi_state) { @@ -130,7 +130,7 @@ void EndpointAppPBX::efi_message_eof(void) break; default: - PERROR("efi_message_eof(ep%d): terminal %s unknown state: %d\n", ea_endpoint->ep_serial, e_terminal, e_vbox_state); + PERROR("efi_message_eof(ep%d): terminal %s unknown state: %d\n", ea_endpoint->ep_serial, e_ext.number, e_vbox_state); } } @@ -156,6 +156,6 @@ void EndpointAppPBX::set_tone_efi(char *tone) SCPY(message->param.tone.name, tone); message_put(message); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set tone '%s'\n", ea_endpoint->ep_serial, e_terminal, tone); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set tone '%s'\n", ea_endpoint->ep_serial, e_ext.number, tone); } diff --git a/action_vbox.cpp b/action_vbox.cpp index afdbc6e..b2f06d9 100644 --- a/action_vbox.cpp +++ b/action_vbox.cpp @@ -84,7 +84,7 @@ void EndpointAppPBX::action_init_vbox_play(void) struct port_list *portlist = ea_endpoint->ep_portlist; /* get extension */ - SCPY(e_vbox, e_terminal); + SCPY(e_vbox, e_ext.number); if ((rparam = routeparam(e_action, PARAM_EXTENSION))) SCPY(e_vbox, rparam->string_value); if (e_vbox[0] == '\0') @@ -98,7 +98,7 @@ void EndpointAppPBX::action_init_vbox_play(void) /* connect, but still accept more digits */ new_state(EPOINT_STATE_IN_OVERLAP); - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT); message_put(message); @@ -327,7 +327,7 @@ void EndpointAppPBX::action_dialing_vbox_play(void) if (port) { port->close_record(6000); /* append beep */ - port->open_record(CODEC_MONO, 1, 5000, e_terminal, 0, "", 0); /* record announcement, skip the first 5000 samples */ + port->open_record(CODEC_MONO, 1, 5000, e_ext.number, 0, "", 0); /* record announcement, skip the first 5000 samples */ } e_vbox_state = VBOX_STATE_RECORD_RECORD; if (e_ext.vbox_language) @@ -677,7 +677,7 @@ void EndpointAppPBX::vbox_handler(void) e_vbox_display_refresh = 0; message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY); SPRINT(message->param.notifyinfo.display, e_vbox_display, counter); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s pending display:%s\n", ea_endpoint->ep_serial, e_terminal, message->param.notifyinfo.display); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s pending display:%s\n", ea_endpoint->ep_serial, e_ext.number, message->param.notifyinfo.display); message_put(message); logmessage(message); } @@ -693,7 +693,7 @@ void EndpointAppPBX::vbox_message_eof(void) char buffer[32]; int language = e_ext.vbox_language; - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s end of file during state: %d\n", ea_endpoint->ep_serial, e_terminal, e_vbox_state); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s end of file during state: %d\n", ea_endpoint->ep_serial, e_ext.number, e_vbox_state); switch(e_vbox_state) { @@ -887,7 +887,7 @@ void EndpointAppPBX::vbox_message_eof(void) break; default: - PERROR("vbox_message_eof(ep%d): terminal %s unknown state: %d\n", ea_endpoint->ep_serial, e_terminal, e_vbox_state); + PERROR("vbox_message_eof(ep%d): terminal %s unknown state: %d\n", ea_endpoint->ep_serial, e_ext.number, e_vbox_state); } } @@ -913,7 +913,7 @@ void EndpointAppPBX::set_tone_vbox(char *tone) SCPY(message->param.tone.name, tone); message_put(message); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set tone '%s'\n", ea_endpoint->ep_serial, e_terminal, tone); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set tone '%s'\n", ea_endpoint->ep_serial, e_ext.number, tone); } @@ -948,7 +948,7 @@ void EndpointAppPBX::set_play_vbox(char *file, int offset) message->param.play.offset = offset; message_put(message); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set play '%s'\n", ea_endpoint->ep_serial, e_terminal, filename); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set play '%s'\n", ea_endpoint->ep_serial, e_ext.number, filename); } @@ -968,7 +968,7 @@ void EndpointAppPBX::set_play_speed(int speed) message->param.speed = speed; message_put(message); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set speed '%d'\n", ea_endpoint->ep_serial, e_terminal, speed); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) terminal %s set speed '%d'\n", ea_endpoint->ep_serial, e_ext.number, speed); } diff --git a/admin_server.c b/admin_server.c index 1d8f400..9ccc18e 100644 --- a/admin_server.c +++ b/admin_server.c @@ -662,7 +662,7 @@ int admin_state(struct admin_queue **responsep) response->am[num].u.e.state = ADMIN_STATE_IDLE; } /* terminal */ - SCPY(response->am[num].u.e.terminal, apppbx->e_terminal); + SCPY(response->am[num].u.e.terminal, apppbx->e_ext.number); /* callerid */ SCPY(response->am[num].u.e.callerid, apppbx->e_callerinfo.id); /* dialing */ diff --git a/apppbx.cpp b/apppbx.cpp index bdec698..880129d 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -42,8 +42,8 @@ EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint) : EndpointApp(epoint) e_ext.rights = 4; /* international */ e_ext.rxvol = e_ext.txvol = 256; e_state = EPOINT_STATE_IDLE; - e_terminal[0] = '\0'; - e_terminal_interface[0] = '\0'; + e_ext.number[0] = '\0'; + e_extension_interface[0] = '\0'; memset(&e_callerinfo, 0, sizeof(struct caller_info)); memset(&e_dialinginfo, 0, sizeof(struct dialing_info)); memset(&e_connectinfo, 0, sizeof(struct connect_info)); @@ -326,12 +326,12 @@ void EndpointAppPBX::release(int release, int calllocation, int callcause, int p memcpy(&e_callbackinfo, &e_callerinfo, sizeof(e_callbackinfo)); memset(&e_dialinginfo, 0, sizeof(e_dialinginfo)); /* create dialing by callerinfo */ - if (e_terminal[0] && e_terminal_interface[0]) + if (e_ext.number[0] && e_extension_interface[0]) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) preparing callback to internal: %s interface %s\n", ea_endpoint->ep_serial, e_terminal, e_terminal_interface); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) preparing callback to internal: %s interface %s\n", ea_endpoint->ep_serial, e_ext.number, e_extension_interface); /* create callback to the current terminal */ - SCPY(e_dialinginfo.number, e_terminal); - SCPY(e_dialinginfo.interfaces, e_terminal_interface); + SCPY(e_dialinginfo.number, e_ext.number); + SCPY(e_dialinginfo.interfaces, e_extension_interface); e_dialinginfo.itype = INFO_ITYPE_ISDN_EXTENSION; e_dialinginfo.ntype = INFO_NTYPE_UNKNOWN; } else @@ -564,7 +564,7 @@ void EndpointAppPBX::keypad_function(char digit) { /* we must be in a call, in order to send messages to the call */ - if (e_terminal[0] == '\0') + if (e_ext.number[0] == '\0') { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) IGNORING keypad received not from extension.\n", ea_endpoint->ep_serial); return; @@ -889,7 +889,7 @@ void EndpointAppPBX::out_setup(void) while(atemp) { if (atemp != this) - if (!strcmp(atemp->e_terminal, e_terminal)) + if (!strcmp(atemp->e_ext.number, e_ext.number)) break; atemp = atemp->next; } @@ -943,7 +943,7 @@ void EndpointAppPBX::out_setup(void) { if (checkapp != this) /* any other endpoint except our own */ { - if (!strcmp(checkapp->e_terminal, e_terminal)) + if (!strcmp(checkapp->e_ext.number, e_ext.number)) { /* present to forwarded party */ if (e_ext.anon_ignore && e_callerinfo.id[0]) @@ -1037,7 +1037,7 @@ void EndpointAppPBX::out_setup(void) memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info)); memcpy(&message->param.setup.callerinfo, &e_callerinfo, sizeof(struct caller_info)); memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info)); -//terminal SCPY(message->param.setup.from_terminal, e_terminal); +//terminal SCPY(message->param.setup.from_terminal, e_ext.number); //terminal if (e_dialinginfo.number) //terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.number); /* handle restricted caller ids */ @@ -1087,7 +1087,7 @@ void EndpointAppPBX::out_setup(void) { /* only if vbox should be dialed, and terminal is given */ earlyb = 0; - if (!strcmp(p, "vbox") && e_terminal[0]) + if (!strcmp(p, "vbox") && e_ext.number[0]) { /* go to the end of p */ p += strlen(p); @@ -1101,7 +1101,7 @@ void EndpointAppPBX::out_setup(void) break; } PDEBUG(DEBUG_EPOINT, "EPOINT(%d) allocated port %s\n", ea_endpoint->ep_serial, port->p_name); - UCPY(cfp, e_terminal); /* cfp or any other direct forward/vbox */ + UCPY(cfp, e_ext.number); /* cfp or any other direct forward/vbox */ } else { cfp[0] = '\0'; @@ -1195,12 +1195,12 @@ void EndpointAppPBX::out_setup(void) if (e_ext.clip==CLIP_HIDE && port->p_type!=PORT_TYPE_VBOX_OUT) { SCPY(message->param.setup.callerinfo.id, e_ext.callerid); - SCPY(message->param.setup.callerinfo.intern, e_terminal); + SCPY(message->param.setup.callerinfo.intern, e_ext.number); message->param.setup.callerinfo.ntype = e_ext.callerid_type; message->param.setup.callerinfo.present = e_ext.callerid_present; } memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info)); -//terminal SCPY(message->param.setup.from_terminal, e_terminal); +//terminal SCPY(message->param.setup.from_terminal, e_ext.number); //terminal if (e_dialinginfo.number) //terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.number); /* handle restricted caller ids */ @@ -1318,7 +1318,7 @@ void EndpointAppPBX::out_setup(void) memcpy(&message->param.setup.redirinfo, &e_redirinfo, sizeof(struct redir_info)); memcpy(&message->param.setup.callerinfo, &e_callerinfo, sizeof(struct caller_info)); memcpy(&message->param.setup.capainfo, &e_capainfo, sizeof(struct capa_info)); -//terminal SCPY(message->param.setup.from_terminal, e_terminal); +//terminal SCPY(message->param.setup.from_terminal, e_ext.number); //terminal if (e_dialinginfo.number) //terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.number); /* handle restricted caller ids */ @@ -1603,8 +1603,8 @@ colp, outclip, outcolp PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call is extension\n", ea_endpoint->ep_serial); /* port makes call from extension */ SCPY(e_callerinfo.intern, e_callerinfo.id); - SCPY(e_terminal, e_callerinfo.intern); - SCPY(e_terminal_interface, e_callerinfo.interface); + SCPY(e_ext.number, e_callerinfo.intern); + SCPY(e_extension_interface, e_callerinfo.interface); } else { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call is external or voip\n", ea_endpoint->ep_serial); @@ -1622,18 +1622,18 @@ colp, outclip, outcolp if (e_callerinfo.itype == INFO_ITYPE_INTERN) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call from extension '%s'\n", ea_endpoint->ep_serial, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call from extension '%s'\n", ea_endpoint->ep_serial, e_ext.number); /* get extension's info about caller */ - if (!read_extension(&e_ext, e_terminal)) + 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_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) rejecting call from not existing extension: '%s'\n", ea_endpoint->ep_serial, e_ext.number); 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 */ - e_terminal[0] = '\0'; /* no terminal */ + e_ext.number[0] = '\0'; /* no terminal */ return; } writeext = 0; @@ -1678,7 +1678,7 @@ colp, outclip, outcolp /* extension is written */ if (writeext) - write_extension(&e_ext, e_terminal); + write_extension(&e_ext, e_ext.number); /* set volume of rx and tx */ if (param->setup.callerinfo.itype == INFO_ITYPE_INTERN) @@ -1695,21 +1695,21 @@ colp, outclip, outcolp if (e_ext.record!=CODEC_OFF && (e_capainfo.bearer_capa==INFO_BC_SPEECH || e_capainfo.bearer_capa==INFO_BC_AUDIO)) { /* check if we are a terminal */ - if (e_terminal[0] == '\0') + if (e_ext.number[0] == '\0') PERROR("Port(%d) cannot record because we are not a terminal\n", ea_endpoint->ep_serial); else { port = find_port_id(portlist->port_id); if (port) - port->open_record(e_ext.record, 0, 0, e_terminal, e_ext.anon_ignore, "", 0); + port->open_record(e_ext.record, 0, 0, e_ext.number, e_ext.anon_ignore, "", 0); } } } else { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call from external port\n", ea_endpoint->ep_serial); /* no terminal identification */ - e_terminal[0] = '\0'; - e_terminal_interface[0] = '\0'; + e_ext.number[0] = '\0'; + e_extension_interface[0] = '\0'; memset(&e_ext, 0, sizeof(e_ext)); e_ext.rights = 4; /* right to dial internat */ } @@ -1726,7 +1726,7 @@ colp, outclip, outcolp set_tone(portlist, "dialing"); } else { - if (e_terminal[0]) + if (e_ext.number[0]) set_tone(portlist, "dialpbx"); else set_tone(portlist, "dialtone"); @@ -1754,7 +1754,7 @@ void EndpointAppPBX::port_information(struct port_list *portlist, int message_ty /* turn off dtmf detection, in case dtmf is sent with keypad information */ if (e_dtmf) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) received dialing information, so dtmf is now disabled, to prevent double detection by keypad+dtmf.\n", ea_endpoint->ep_serial, param->information.number, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) received dialing information, so dtmf is now disabled, to prevent double detection by keypad+dtmf.\n", ea_endpoint->ep_serial, param->information.number, e_ext.number, e_callerinfo.id); e_dtmf = 0; } @@ -2138,16 +2138,16 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, SCPY(e_connectinfo.name, e_ext.name); /* add internal id to colp */ - SCPY(e_connectinfo.intern, e_terminal); + SCPY(e_connectinfo.intern, e_ext.number); /* we store the connected port number */ - SCPY(e_terminal_interface, e_connectinfo.interfaces); + SCPY(e_extension_interface, e_connectinfo.interfaces); /* for internal and am calls, we get the extension's id */ if (portlist->port_type==PORT_TYPE_VBOX_OUT || e_ext.colp==COLP_HIDE) { SCPY(e_connectinfo.id, e_ext.callerid); - SCPY(e_connectinfo.intern, e_terminal); + SCPY(e_connectinfo.intern, e_ext.number); e_connectinfo.itype = INFO_ITYPE_INTERN; e_connectinfo.ntype = e_ext.callerid_type; e_connectinfo.present = e_ext.callerid_present; @@ -2171,7 +2171,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, } e_cfnr_call = e_cfnr_release = 0; - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; /* allow dtmf */ // if (call_countrelations(ea_endpoint->ep_call_id) == 2) { @@ -2203,15 +2203,15 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, { /* callback */ PDEBUG(DEBUG_EPOINT, "EPOINT(%d) we have a callback, so we create a call with cbcaller: \"%s\".\n", ea_endpoint->ep_serial, e_cbcaller); - SCPY(e_terminal, e_cbcaller); + SCPY(e_ext.number, e_cbcaller); new_state(EPOINT_STATE_IN_OVERLAP); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) callback from extension '%s'\n", ea_endpoint->ep_serial, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) callback from extension '%s'\n", ea_endpoint->ep_serial, e_ext.number); /* get extension's info about terminal */ - if (!read_extension(&e_ext, e_terminal)) + if (!read_extension(&e_ext, e_ext.number)) { /* extension doesn't exist */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) rejecting callback from not existing extension: '%s'\n", ea_endpoint->ep_serial, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) rejecting callback from not existing extension: '%s'\n", ea_endpoint->ep_serial, e_ext.number); 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 */ @@ -2226,7 +2226,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, /* use caller id (or if exist: id_next_call) for this call */ e_callerinfo.screen = INFO_SCREEN_NETWORK; - SCPY(e_callerinfo.intern, e_terminal); + SCPY(e_callerinfo.intern, e_ext.number); if (e_ext.id_next_call_present >= 0) { SCPY(e_callerinfo.id, e_ext.id_next_call); @@ -2234,7 +2234,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, e_callerinfo.ntype = e_ext.id_next_call_type; e_ext.id_next_call_present = -1; /* extension is written */ - write_extension(&e_ext, e_terminal); + write_extension(&e_ext, e_ext.number); } else { SCPY(e_callerinfo.id, e_ext.callerid); @@ -2246,7 +2246,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, e_dtmf = 1; /* check if caller id is NOT authenticated */ - if (!parse_callbackauth(e_terminal, &e_callbackinfo)) + if (!parse_callbackauth(e_ext.number, &e_callbackinfo)) { /* make call state to enter password */ new_state(EPOINT_STATE_IN_OVERLAP); @@ -2280,16 +2280,16 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, } /* start recording if enabled, not when answering machine answers */ - if (param->connectinfo.itype!=INFO_ITYPE_VBOX && e_terminal[0] && e_ext.record!=CODEC_OFF && (e_capainfo.bearer_capa==INFO_BC_SPEECH || e_capainfo.bearer_capa==INFO_BC_AUDIO)) + if (param->connectinfo.itype!=INFO_ITYPE_VBOX && e_ext.number[0] && e_ext.record!=CODEC_OFF && (e_capainfo.bearer_capa==INFO_BC_SPEECH || e_capainfo.bearer_capa==INFO_BC_AUDIO)) { /* check if we are a terminal */ - if (e_terminal[0] == '\0') + if (e_ext.number[0] == '\0') PERROR("Port(%d) cannot record because we are not a terminal\n", ea_endpoint->ep_serial); else { port = find_port_id(portlist->port_id); if (port) - port->open_record(e_ext.record, 0, 0, e_terminal, e_ext.anon_ignore, "", 0); + port->open_record(e_ext.record, 0, 0, e_ext.number, e_ext.anon_ignore, "", 0); } } } @@ -2724,7 +2724,7 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un return; } -// PDEBUG(DEBUG_EPOINT, "received message %d (terminal %s, caller id %s)\n", message, e_terminal, e_callerinfo.id); +// PDEBUG(DEBUG_EPOINT, "received message %d (terminal %s, caller id %s)\n", message, e_ext.number, e_callerinfo.id); switch(message_type) { case MESSAGE_DATA: /* data from port */ @@ -2786,19 +2786,19 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un /* PORT sends INFORMATION message */ case MESSAGE_INFORMATION: /* additional digits received */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call dialing more=%s (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->information.number, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming call dialing more=%s (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->information.number, e_ext.number, e_callerinfo.id); port_information(portlist, message_type, param); break; /* PORT sends FACILITY message */ case MESSAGE_FACILITY: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming facility (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) incoming facility (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); port_facility(portlist, message_type, param); break; /* PORT sends DTMF message */ case MESSAGE_DTMF: /* dtmf digits received */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) dtmf digit=%c (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->dtmf, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) dtmf digit=%c (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->dtmf, e_ext.number, e_callerinfo.id); port_dtmf(portlist, message_type, param); break; @@ -2810,7 +2810,7 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un /* PORT sends MORE message */ case MESSAGE_OVERLAP: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call is accepted [overlap dialing] (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call is accepted [overlap dialing] (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_state != EPOINT_STATE_OUT_SETUP) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) ignored because we are not in setup state (for port_list: another portlist might have changed the state already).\n", ea_endpoint->ep_serial); @@ -2821,7 +2821,7 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un /* PORT sends PROCEEDING message */ case MESSAGE_PROCEEDING: /* port is proceeding */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call is proceeding (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call is proceeding (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_state!=EPOINT_STATE_OUT_SETUP && e_state!=EPOINT_STATE_OUT_OVERLAP) { @@ -2833,7 +2833,7 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un /* PORT sends ALERTING message */ case MESSAGE_ALERTING: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call is ringing (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call is ringing (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_state!=EPOINT_STATE_OUT_SETUP && e_state!=EPOINT_STATE_OUT_OVERLAP && e_state!=EPOINT_STATE_OUT_PROCEEDING) @@ -2846,7 +2846,7 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un /* PORT sends CONNECT message */ case MESSAGE_CONNECT: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call connected to %s (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_connectinfo.id, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) outgoing call connected to %s (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, e_connectinfo.id, e_ext.number, e_callerinfo.id); if (e_state!=EPOINT_STATE_OUT_SETUP && e_state!=EPOINT_STATE_OUT_OVERLAP && e_state!=EPOINT_STATE_OUT_PROCEEDING @@ -2860,43 +2860,43 @@ void EndpointAppPBX::ea_message_port(unsigned long port_id, int message_type, un /* PORT sends DISCONNECT message */ case MESSAGE_DISCONNECT: /* port is disconnected */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call disconnect with cause=%d location=%d (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->disconnectinfo.cause, param->disconnectinfo.location, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) call disconnect with cause=%d location=%d (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->disconnectinfo.cause, param->disconnectinfo.location, e_ext.number, e_callerinfo.id); port_disconnect_release(portlist, message_type, param); break; /* PORT sends a RELEASE message */ case MESSAGE_RELEASE: /* port releases */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) release with cause=%d location=%d (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->disconnectinfo.cause, param->disconnectinfo.location, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) release with cause=%d location=%d (terminal '%s', caller id '%s')\n", ea_endpoint->ep_serial, param->disconnectinfo.cause, param->disconnectinfo.location, e_ext.number, e_callerinfo.id); /* portlist is release at port_disconnect_release, thanx Paul */ port_disconnect_release(portlist, message_type, param); break; /* PORT sends a TIMEOUT message */ case MESSAGE_TIMEOUT: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received timeout (state=%d).\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, param->state); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received timeout (state=%d).\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->state); port_timeout(portlist, message_type, param); break; /* release */ /* PORT sends a NOTIFY message */ case MESSAGE_NOTIFY: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received notify.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received notify.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); port_notify(portlist, message_type, param); break; /* PORT sends a SUSPEND message */ case MESSAGE_SUSPEND: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received suspend.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received suspend.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); port_suspend(portlist, message_type, param); break; /* suspend */ /* PORT sends a RESUME message */ case MESSAGE_RESUME: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received resume.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received resume.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); port_resume(portlist, message_type, param); break; default: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received a wrong message: %d\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, message); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received a wrong message: %d\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, message); } /* Note: this endpoint may be destroyed, so we MUST return */ @@ -2930,7 +2930,7 @@ void EndpointAppPBX::call_crypt(struct port_list *portlist, int message_type, un break; default: - PERROR("EPOINT(%d) epoint with terminal '%s' (caller id '%s') unknown crypt message: '%d'\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, param->crypt.type); + PERROR("EPOINT(%d) epoint with terminal '%s' (caller id '%s') unknown crypt message: '%d'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->crypt.type); } } @@ -2991,7 +2991,7 @@ void EndpointAppPBX::call_overlap(struct port_list *portlist, int message_type, set_tone(portlist, "dialtone"); return; } - if (e_terminal[0]) + if (e_ext.number[0]) set_tone(portlist, "dialpbx"); else set_tone(portlist, "dialtone"); @@ -3054,7 +3054,7 @@ void EndpointAppPBX::call_alerting(struct port_list *portlist, int message_type, set_tone(portlist, "ringing"); return; } - if (e_terminal[0]) + if (e_ext.number[0]) set_tone(portlist, "ringpbx"); else set_tone(portlist, "ringing"); @@ -3067,7 +3067,7 @@ void EndpointAppPBX::call_connect(struct port_list *portlist, int message_type, new_state(EPOINT_STATE_CONNECT); // UCPY(e_call_tone, ""); - if (e_terminal[0]) + if (e_ext.number[0]) e_dtmf = 1; /* allow dtmf */ e_powerdialing = 0; memcpy(&e_connectinfo, ¶m->connectinfo, sizeof(e_callerinfo)); @@ -3084,7 +3084,7 @@ void EndpointAppPBX::call_connect(struct port_list *portlist, int message_type, memcpy(&message->param.connnectinfo, e_connectinfo); /* screen clip if prefix is required */ - if (e_terminal[0] && message->param.connectinfo.id[0] && e_ext.clip_prefix[0]) + if (e_ext.number[0] && message->param.connectinfo.id[0] && e_ext.clip_prefix[0]) { SCPY(message->param.connectinfo.id, e_ext.clip_prefix); SCAT(message->param.connectinfo.id, numberrize_callerinfo(e_connectinfo.id,e_connectinfo.ntype)); @@ -3092,7 +3092,7 @@ void EndpointAppPBX::call_connect(struct port_list *portlist, int message_type, } /* use internal caller id */ - if (e_terminal[0] && e_connectinfo.intern[0] && (message->param.connectinfo.present!=INFO_PRESENT_RESTRICTED || e_ext.anon_ignore)) + if (e_ext.number[0] && e_connectinfo.intern[0] && (message->param.connectinfo.present!=INFO_PRESENT_RESTRICTED || e_ext.anon_ignore)) { SCPY(message->param.connectinfo.id, e_connectinfo.intern); message->param.connectinfo.ntype = INFO_NTYPE_UNKNOWN; @@ -3145,7 +3145,7 @@ void EndpointAppPBX::call_disconnect_release(struct port_list *portlist, int mes e_call_pattern = 0; } set_tone(ea_endpoint->ep_portlist, "redial"); - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') redialing in %d seconds\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, (int)e_powerdelay); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') redialing in %d seconds\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, (int)e_powerdelay); /* send proceeding when powerdialing and still setup (avoid dialing timeout) */ if (e_state==EPOINT_STATE_IN_OVERLAP) { @@ -3315,14 +3315,14 @@ void EndpointAppPBX::call_setup(struct port_list *portlist, int message_type, un } /* if an internal extension is dialed, copy that number */ if (param->setup.dialinginfo.itype==INFO_ITYPE_INTERN || param->setup.dialinginfo.itype==INFO_ITYPE_VBOX) - SCPY(e_terminal, param->setup.dialinginfo.number); + SCPY(e_ext.number, param->setup.dialinginfo.number); /* if an internal extension is dialed, get extension's info about caller */ - if (e_terminal[0]) + if (e_ext.number[0]) { - if (!read_extension(&e_ext, e_terminal)) + if (!read_extension(&e_ext, e_ext.number)) { - e_terminal[0] = '\0'; - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) the called terminal='%s' is not found in directory tree!\n", ea_endpoint->ep_serial, e_terminal); + e_ext.number[0] = '\0'; + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) the called terminal='%s' is not found in directory tree!\n", ea_endpoint->ep_serial, e_ext.number); } } @@ -3341,7 +3341,7 @@ void EndpointAppPBX::call_setup(struct port_list *portlist, int message_type, un /* process (voice over) data calls */ if (e_ext.datacall && e_capainfo.bearer_capa!=INFO_BC_SPEECH && e_capainfo.bearer_capa!=INFO_BC_AUDIO) { - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) handling data call as audio call: '%s'\n", ea_endpoint->ep_serial, e_terminal); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) handling data call as audio call: '%s'\n", ea_endpoint->ep_serial, e_ext.number); memset(&e_capainfo, 0, sizeof(e_capainfo)); e_capainfo.bearer_capa = INFO_BC_AUDIO; e_capainfo.bearer_mode = INFO_BMODE_CIRCUIT; @@ -3460,30 +3460,30 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un } } -// PDEBUG(DEBUG_EPOINT, "EPOINT(%d) received message %d for active call (terminal %s, caller id %s state=%d)\n", ea_endpoint->ep_serial, message, e_terminal, e_callerinfo.id, e_state); +// PDEBUG(DEBUG_EPOINT, "EPOINT(%d) received message %d for active call (terminal %s, caller id %s state=%d)\n", ea_endpoint->ep_serial, message, e_ext.number, e_callerinfo.id, e_state); switch(message_type) { /* CALL SENDS CRYPT message */ case MESSAGE_CRYPT: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received crypt message: '%d'\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, param->crypt.type); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received crypt message: '%d'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->crypt.type); call_crypt(portlist, message_type, param); break; /* CALL sends INFORMATION message */ case MESSAGE_INFORMATION: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received more digits: '%s'\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, param->information.number); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received more digits: '%s'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, param->information.number); call_information(portlist, message_type, param); break; /* CALL sends FACILITY message */ case MESSAGE_FACILITY: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received facility\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received facility\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); call_facility(portlist, message_type, param); break; /* CALL sends OVERLAP message */ case MESSAGE_OVERLAP: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received 'more info available'\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received 'more info available'\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_state!=EPOINT_STATE_IN_SETUP && e_state!=EPOINT_STATE_IN_OVERLAP) { @@ -3495,7 +3495,7 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un /* CALL sends PROCEEDING message */ case MESSAGE_PROCEEDING: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s (caller id '%s') received proceeding\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s (caller id '%s') received proceeding\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if(e_state!=EPOINT_STATE_IN_OVERLAP) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) ignored because we are not in setup state.\n", ea_endpoint->ep_serial); @@ -3506,7 +3506,7 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un /* CALL sends ALERTING message */ case MESSAGE_ALERTING: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received alerting\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received alerting\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_state!=EPOINT_STATE_IN_OVERLAP && e_state!=EPOINT_STATE_IN_PROCEEDING) { @@ -3518,7 +3518,7 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un /* CALL sends CONNECT message */ case MESSAGE_CONNECT: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received connect\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received connect\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_state!=EPOINT_STATE_IN_OVERLAP && e_state!=EPOINT_STATE_IN_PROCEEDING && e_state!=EPOINT_STATE_IN_ALERTING) @@ -3532,7 +3532,7 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un /* CALL sends DISCONNECT/RELEASE message */ case MESSAGE_DISCONNECT: /* call disconnect */ case MESSAGE_RELEASE: /* call releases */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received %s with cause %d location %d\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, (message_type==MESSAGE_DISCONNECT)?"disconnect":"release", param->disconnectinfo.cause, param->disconnectinfo.location); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received %s with cause %d location %d\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, (message_type==MESSAGE_DISCONNECT)?"disconnect":"release", param->disconnectinfo.cause, param->disconnectinfo.location); call_disconnect_release(portlist, message_type, param); break; @@ -3545,13 +3545,13 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un /* CALL sends special mISDNSIGNAL message */ case MESSAGE_mISDNSIGNAL: /* isdn message to port */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received mISDNsignal message.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received mISDNsignal message.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); call_mISDNsignal(portlist, message_type, param); break; /* CALL has pattern available */ case MESSAGE_PATTERN: /* indicating pattern available */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received pattern availability.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received pattern availability.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (!e_call_pattern) { PDEBUG(DEBUG_EPOINT, "-> pattern becomes available\n"); @@ -3576,7 +3576,7 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un /* CALL has no pattern available */ case MESSAGE_NOPATTERN: /* indicating no pattern available */ - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received pattern NOT available.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received pattern NOT available.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); if (e_call_pattern) { PDEBUG(DEBUG_EPOINT, "-> pattern becomes unavailable\n"); @@ -3591,7 +3591,7 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un #if 0 /* CALL (dunno at the moment) */ case MESSAGE_REMOTE_AUDIO: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received audio remote request.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received audio remote request.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_call_id, EPOINT_TO_CALL, MESSAGE_CHANNEL); message->param.channel = param->channel; message_put(message); @@ -3600,12 +3600,12 @@ void EndpointAppPBX::ea_message_call(unsigned long call_id, int message_type, un /* CALL sends a notify message */ case MESSAGE_NOTIFY: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received notify.\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received notify.\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id); call_notify(portlist, message_type, param); break; default: - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received a wrong message: #%d\n", ea_endpoint->ep_serial, e_terminal, e_callerinfo.id, message); + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) epoint with terminal '%s' (caller id '%s') received a wrong message: #%d\n", ea_endpoint->ep_serial, e_ext.number, e_callerinfo.id, message); } } @@ -3674,7 +3674,7 @@ void EndpointAppPBX::pick_call(char *extensions) { if (port->p_type == PORT_TYPE_VBOX_OUT) { - if (match_list(extensions, eapp->e_terminal)) + if (match_list(extensions, eapp->e_ext.number)) { found = eapp; vbox = 1; @@ -3683,7 +3683,7 @@ void EndpointAppPBX::pick_call(char *extensions) } if ((port->p_type==PORT_TYPE_DSS1_NT_OUT || port->p_type==PORT_TYPE_DSS1_TE_OUT) && port->p_state==PORT_STATE_OUT_ALERTING) - if (match_list(extensions, eapp->e_terminal)) + if (match_list(extensions, eapp->e_ext.number)) { found = eapp; } @@ -3883,7 +3883,7 @@ void EndpointAppPBX::join_call(void) PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cannot join: we have no port.\n", ea_endpoint->ep_serial); return; } - if (!e_terminal[0]) + if (!e_ext.number[0]) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) cannot join: we are not internal extension.\n", ea_endpoint->ep_serial); return; @@ -3910,8 +3910,8 @@ void EndpointAppPBX::join_call(void) other_eapp = other_eapp->next; continue; } - PDEBUG(DEBUG_EPOINT, "EPOINT(%d) comparing other endpoint candiate: (ep%d) terminal='%s' port=%s call=%d.\n", ea_endpoint->ep_serial, other_eapp->ea_endpoint->ep_serial, other_eapp->e_terminal, (other_eapp->ea_endpoint->ep_portlist)?"YES":"NO", other_eapp->ea_endpoint->ep_call_id); - if (other_eapp->e_terminal[0] /* has terminal */ + PDEBUG(DEBUG_EPOINT, "EPOINT(%d) comparing other endpoint candiate: (ep%d) terminal='%s' port=%s call=%d.\n", ea_endpoint->ep_serial, other_eapp->ea_endpoint->ep_serial, other_eapp->e_ext.number, (other_eapp->ea_endpoint->ep_portlist)?"YES":"NO", other_eapp->ea_endpoint->ep_call_id); + if (other_eapp->e_ext.number[0] /* has terminal */ && other_eapp->ea_endpoint->ep_portlist /* has port */ && other_eapp->ea_endpoint->ep_call_id) /* has call */ { @@ -4049,7 +4049,7 @@ int EndpointAppPBX::check_external(char **errstr, class Port **port) *errstr = "No Call"; return(1); } - if (!e_terminal[0]) + if (!e_ext.number[0]) { PDEBUG(DEBUG_EPOINT, "EPOINT(%d) error: we are not internal extension.\n", ea_endpoint->ep_serial); *errstr = "No Call"; diff --git a/apppbx.h b/apppbx.h index a93a285..b9b40c0 100644 --- a/apppbx.h +++ b/apppbx.h @@ -68,7 +68,7 @@ class EndpointAppPBX : public EndpointApp /* states */ int e_state; /* state of endpoint */ - char e_terminal_interface[32];/* current internal isdn interface (usefull for callback to internal phone) */ + char e_extension_interface[32];/* current internal isdn interface (usefull for callback to internal phone) */ struct caller_info e_callerinfo; /* information about the caller */ struct dialing_info e_dialinginfo; /* information about dialing */ struct connect_info e_connectinfo; /* information about connected line */ diff --git a/crypt.cpp b/crypt.cpp index 2babfb7..65890c3 100644 --- a/crypt.cpp +++ b/crypt.cpp @@ -1833,7 +1833,7 @@ void EndpointAppPBX::encrypt_shared(void) /* check the key for the call */ if (port->p_type==PORT_TYPE_DSS1_TE_OUT || port->p_type==PORT_TYPE_DSS1_NT_OUT || port->p_type==PORT_TYPE_SIP_OUT) - ret = parse_secrets((char *)e_terminal, (char *)port->p_dialinginfo.number, &auth_pointer, &crypt_pointer, &key_pointer); + ret = parse_secrets((char *)e_ext.number, (char *)port->p_dialinginfo.number, &auth_pointer, &crypt_pointer, &key_pointer); else { if (!port->p_callerinfo.id[0]) @@ -1842,7 +1842,7 @@ void EndpointAppPBX::encrypt_shared(void) errstr = "No Remote ID"; goto reject; } - ret = parse_secrets((char *)e_terminal, (char *)numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype), &auth_pointer, &crypt_pointer, &key_pointer); + ret = parse_secrets((char *)e_ext.number, (char *)numberrize_callerinfo(port->p_callerinfo.id, port->p_callerinfo.ntype), &auth_pointer, &crypt_pointer, &key_pointer); } if (!ret) { diff --git a/extension.c b/extension.c index 38dfd4d..e19ec2a 100644 --- a/extension.c +++ b/extension.c @@ -33,9 +33,10 @@ char *ext_yesno[] = { * * reads extension from given extension number and fills structure */ -int read_extension(struct extension *ext, char *number) +int read_extension(struct extension *ext, char *num) { FILE *fp=NULL; + char number[32]; char filename[256]; char *p; char option[32]; @@ -44,6 +45,9 @@ int read_extension(struct extension *ext, char *number) char buffer[1024]; int last_in_count = 0, last_out_count = 0; + /* save number, so &ext and ext.number can be given as parameters - without overwriting itself */ + SCPY(number, num); + if (number[0] == '\0') return(0); @@ -57,6 +61,7 @@ int read_extension(struct extension *ext, char *number) /* default values */ memset(ext, 0, sizeof(struct extension)); + SCPY(ext->number, number); ext->rights = 4; /* international */ ext->tout_setup = 120; ext->tout_dialing = 120; diff --git a/mISDN.cpp b/mISDN.cpp index dfb8a6d..f2e4490 100644 --- a/mISDN.cpp +++ b/mISDN.cpp @@ -276,7 +276,7 @@ static void bchannel_deactivate(struct mISDNport *mISDNport, int i) /* reset dsp features */ if (mISDNport->b_port[i]) { - if (mISDNport->b_port[i]->p_m_delay) + if (mISDNport->b_port[i]->p_m_txdata) { PDEBUG(DEBUG_BCHANNEL, "during deactivation, we reset txdata from txdata=%d.\n", mISDNport->b_port[i]->p_m_txdata); ph_control(mISDNport->b_addr[i], CMX_TXDATA_OFF, 0); @@ -514,8 +514,9 @@ int PmISDN::handler(void) if ((ret = Port::handler())) return(ret); + inbuffer = (p_fromup_buffer_writep - p_fromup_buffer_readp) & FROMUP_BUFFER_MASK /* send tone data to isdn device only if we have data */ - if (p_tone_fh>=0 || p_tone_fetched || p_m_crypt_msg_loops) + if (p_tone_fh>=0 || p_tone_fetched || p_m_crypt_msg_loops || inbuffer) { /* calculate how much to transmit */ if (!p_last_tv.sec) @@ -533,22 +534,62 @@ int PmISDN::handler(void) } if (elapsed >= ISDN_TRANSMIT) { - unsigned char buf[mISDN_HEADER_LEN+(ISDN_PRELOAD<<3)]; + unsigned char buf[mISDN_HEADER_LEN+(ISDN_PRELOAD<<3)], *p = buf; iframe_t *frm = (iframe_t *)buf; - length = read_audio(buffer, elapsed); p_last_tv_sec = now_tv.sec; p_last_tv_msec = now_tv.usec/1000; + /* read tones */ + length = read_audio(buffer, elapsed); + + /* + * get data from up + * the fromup_buffer data is written to the beginning of the buffer + * the part that is filles with tones (length) is skipped, so tones have priority + * the length value is increased by the number of data copied from fromup_buffer + */ + if (inbuffer) + { + /* inbuffer might be less than we skip due to audio */ + if (inbuffer <= length) + { + /* clear buffer */ + p_fromup_buffer_readp = p_fromup_buffer_writep; + inbuffer = 0; + } else + { + /* skip what we already have with tones */ + p_fromup_buffer_readp = (p_fromup_buffer_readp + length) & FROMUP_BUFFER_MASK; + inbuffer -= length; + } + /* if we have more in buffer, than we send this time */ + if (inbuffer > (elapsed-length)) + inbuffer = elapsed - length; + /* set length to what we actually have */ + length = length + inbuffer; + /* now fill up with fromup_buffer */ + while (inbuffer) + { + *p++ = p_fromup_buffer[p_fromup_buffer_readp]; + p_fromup_buffer_readp = (p_fromup_buffer_readp + 1) & FROMUP_BUFFER_MASK; + inbuffer--; + } + } + + /* overwrite buffer with crypto stuff */ if (p_m_crypt_msg_loops) { /* send pending message */ int tosend; + + /* we need full length */ + length = elapsed; check!! tosend = p_m_crypt_msg_len - p_m_crypt_msg_current; if (tosend > length) tosend = length; - memcpy(p, p_m_crypt_msg+p_m_crypt_msg_current, tosend); + memcpy(buffer, p_m_crypt_msg+p_m_crypt_msg_current, tosend); p_m_crypt_msg_current += tosend; if (p_m_crypt_msg_current == p_m_crypt_msg_len) { @@ -572,7 +613,6 @@ int PmISDN::handler(void) } } else { - p_last_tv.sec = p_last_tv.msec = 0; /* flag that we don't transmit data */ if (!cwp_debug_nothingtosend) { p_debug_nothingtosend = 1; @@ -641,32 +681,57 @@ void PmISDN::bchannel_receive(iframe_t *frm) if (frm->prim == (PH_CONTROL | INDICATION)) { + if (frm->len < 4) + { + PERROR("SHORT READ OF PH_CONTROL INDICATION\n"); + return; + } cont = *((unsigned long *)&frm->data.p); // PDEBUG(DEBUG_PORT, "PmISDN(%s) received a PH_CONTROL INDICATION 0x%x\n", p_name, cont); if ((cont&(~DTMF_TONE_MASK)) == DTMF_TONE_VAL) { message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DTMF); message->param.dtmf = cont & DTMF_TONE_MASK; - PDEBUG(DEBUG_PORT, "PmISDN(%s) PH_CONTROL DTMF digit '%c'\n", p_name, message->param.dtmf); + PDEBUG(DEBUG_PORT, "PmISDN(%s) PH_CONTROL INDICATION DTMF digit '%c'\n", p_name, message->param.dtmf); message_put(message); + return; } switch(cont) { case BF_REJECT: message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CRYPT); message->param.crypt.type = CC_ERROR_IND; - PDEBUG(DEBUG_PORT, "PmISDN(%s) PH_CONTROL reject of blowfish.\n", p_name); + PDEBUG(DEBUG_PORT, "PmISDN(%s) PH_CONTROL INDICATION reject of blowfish.\n", p_name); message_put(message); break; case BF_ACCEPT: message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CRYPT); message->param.crypt.type = CC_ACTBF_CONF; - PDEBUG(DEBUG_PORT, "PmISDN(%s) PH_CONTROL accept of blowfish.\n", p_name); + PDEBUG(DEBUG_PORT, "PmISDN(%s) PH_CONTROL INDICATION accept of blowfish.\n", p_name); message_put(message); break; + + case CMX_TX_DATA: + if (!p_m_txdatad) + { + /* if rx is off, it may happen that fifos send us pending informations, we just ignore them */ + PDEBUG(DEBUG_BCHANNEL, "PmISDN(%s) ignoring rx data, because 'txdata' is turned off\n", p_name); + return; + } + if (p_record) + record(&(cont+1), frm->len - 4, 1); // from up + break; + + default: + PDEBUG(DEBUG_PORT, "PmISDN(%s) PH_CONTROL INDICATION unknown 0x%x.\n", p_name, cont); } return; + } + if (frm->prim != (PH_DATA | INDICATION)) + { + PERROR("Bchannel received unknown primitve: 0x%x\n", frm->prim); + return; } /* calls will not process any audio data unless @@ -691,6 +756,10 @@ void PmISDN::bchannel_receive(iframe_t *frm) return; } + /* record data */ + if (p_record) + record((unsigned char *)&frm->data.p, frm->len, 0); // from down + /* randomize and listen to crypt message if enabled */ if (p_m_crypt_listen) { @@ -1081,33 +1150,58 @@ int mISDN_handler(void) i = 0; while(i < mISDNport->b_num) { - if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) + isdnport=mISDNport->b_port[i]; + /* call bridges in user space OR crypto OR recording */ + if (isdnport->p_m_calldata || isdnport->p_m_crypt_msg_loops || isdnport->p_m_crypt_listen || isdnport->p_record) { - isdnport=mISDNport->b_port[i]; - if (isdnport->p_m_calldata || isdnport->p_m_crypt_msg_loops || isdnport->p_m_crypt_listen || isdnport->p_record) + /* rx IS required */ + if (isdnport->p_m_rxoff) { - /* rx IS required */ - if (isdnport->p_m_rxoff) - { - /* turn on RX */ - isdnport->p_m_rxoff = 0; - PDEBUG(DEBUG_BCHANNEL, "%s: receive data is required, so we turn them on\n"); + /* turn on RX */ + isdnport->p_m_rxoff = 0; + PDEBUG(DEBUG_BCHANNEL, "%s: receive data is required, so we turn them on\n"); + if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) ph_control(isdnport->p_m_b_addr, CMX_RECEIVE_ON, 0); - return(1); - } - } else + return(1); + } + } else + { + /* rx NOT required */ + if (!isdnport->p_m_rxoff) { - /* rx NOT required */ - if (!isdnport->p_m_rxoff) - { - /* turn off RX */ - isdnport->p_m_rxoff = 1; - PDEBUG(DEBUG_BCHANNEL, "%s: receive data is not required, so we turn them off\n"); + /* turn off RX */ + isdnport->p_m_rxoff = 1; + PDEBUG(DEBUG_BCHANNEL, "%s: receive data is not required, so we turn them off\n"); + if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) ph_control(isdnport->p_m_b_addr, CMX_RECEIVE_OFF, 0); - return(1); - } + return(1); } } + /* recordin */ + if (isdnport->p_record) + { + /* txdata IS required */ + if (!isdnport->p_m_txdata) + { + /* turn on RX */ + isdnport->p_m_txdata = 1; + PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is required, so we turn them on\n"); + if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) + ph_control(isdnport->p_m_b_addr, CMX_TXDATA_ON, 0); + return(1); + } + } else + { + /* txdata NOT required */ + if (isdnport->p_m_txdata) + { + /* turn off RX */ + isdnport->p_m_txdata = 0; + PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is not required, so we turn them off\n"); + if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE) + ph_control(isdnport->p_m_b_addr, CMX_TXDATA_OFF, 0); + return(1); + } i++; } #if 0 diff --git a/message.h b/message.h index afc14fb..1c2df57 100644 --- a/message.h +++ b/message.h @@ -241,8 +241,8 @@ struct park_info { struct param_data { unsigned char data[512]; /* audio/hdlc data */ int len; /* audio/hdlc data */ - unsigned long port_id; /* to identify the source of this data */ - int port_type; /* type of the source's port */ +// unsigned long port_id; /* to identify the source of this data */ +// int port_type; /* type of the source's port */ }; struct param_play { diff --git a/port.cpp b/port.cpp index 0c043df..8692020 100644 --- a/port.cpp +++ b/port.cpp @@ -672,9 +672,8 @@ int Port::message_epoint(unsigned long epoint_id, int message_id, union paramete set_tone(param->tone.dir,param->tone.name); return(1); - case MESSAGE_DATA: -//printf("port=%s, epoint=%d\n",p_cardname, epoint->e_serial); - mixer(param); + case MESSAGE_DATA: /* tx-data from upper layer */ + fromup(param->data.data, param->data.len); return(1); case MESSAGE_VBOX_TONE: /* play tone of answering machine */ @@ -742,18 +741,18 @@ struct fmt { * written before close, because we do not know the size yet) * type=1 record annoucement, type=0 record audio stream, type=2 record vbox */ -int Port::open_record(int type, int vbox, int skip, char *terminal, int anon_ignore, char *vbox_email, int vbox_email_file) +int Port::open_record(int type, int vbox, int skip, char *extension, int anon_ignore, char *vbox_email, int vbox_email_file) { /* RIFFxxxxWAVEfmt xxxx(fmt-size)dataxxxx... */ char dummyheader[8+4+8+sizeof(fmt)+8]; char filename[256]; - if (!terminal) + if (!extension) { - PERROR("Port(%d) not a terminal\n", p_serial); + PERROR("Port(%d) not an extension\n", p_serial); return(0); } - SCPY(p_record_extension, terminal); + SCPY(p_record_extension, extension); p_record_anon_ignore = anon_ignore; SCPY(p_record_vbox_email, vbox_email); p_record_vbox_email_file = vbox_email_file; @@ -1003,12 +1002,6 @@ void Port::close_record(int beep) else SPRINT(filename, "%s_%s-%s.isdn", p_record_filename, callerid, number); break; - - default: - if (p_record_vbox == 1) - SPRINT(filename, "%s.unknown", p_record_filename); - else - SPRINT(filename, "%s_%s-%s.unknown", p_record_filename, callerid, number); } fclose(p_record); @@ -1052,4 +1045,256 @@ void Port::close_record(int beep) } +/* + * recording function + * Records all data from down and from up into one single stream. + * Both streams may have gaps or jitter. + * A Jitter buffer for both streams is used to compensate jitter. + * + * If one stream (dir) received packets, they are stored to a + * buffer to wait for the other stream (dir), so both streams can + * be combined. If the buffer is full, it's read pointer is written + * without mixing stream. + * A flag is used to indicate what stream is currently in buffer. + * + * NOTE: First stereo sample (odd) is from down, second is from up. + */ +alle buffer initialisieren +record nur aufrufen, wenn recorded wird. +restlicher buffer wegschreiben beim schliessen +void Port::record(char *data, int length, int dir_fromup) +{ + unsigned char write_buffer[1024], *d; + signed short *s; + int r, w; + signed long sample; + + /* no recording */ + if (!p_record || !length) + return; + + free = ((p_record_buffer_readp - p_record_buffer_writep - 1) & RECORD_BUFFER_MASK); + + /* the buffer stores the same data stream */ + if (dir_fromup == p_record_buffer_dir) + { + same_again: + + /* first write what we can to the buffer */ + while(free && length) + { + p_record_buffer[p_record_buffer_writep] = audio_law_to_s32(*data++); + p_record_buffer_writep = (p_record_buffer_writep + 1) & RECORD_BUFFER_MASK; + free--; + length--; + } + /* all written, so we return */ + if (!length) + return; + /* still data left, buffer is full, so we need to write to file */ + switch(p_record_type) + { + case CODEC_MONO: + s = (signed short *)write_buffer; + i = 0; + while(i < 256) + { + *s++ = p_record_buffer[p_record_buffer_readp]; + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + i++; + } + fwrite(write_buffer, 512, 1, p_record); + break; + + case CODEC_STEREO: + s = (signed short *)write_buffer; + if (p_record_buffer_dir) + { + i = 0; + while(i < 256) + { + *s++ = 0; /* nothing from down */ + *s++ = p_record_buffer[p_record_buffer_readp]; + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + i++; + } + } else + { + i = 0; + while(i < 256) + { + *s++ = p_record_buffer[p_record_buffer_readp]; + *s++ = 0; /* nothing from up */ + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + i++; + } + } + fwrite(write_buffer, 1024, 1, p_record); + break; + + case CODEC_8BIT: + d = write_buffer; + i = 0; + while(i < 256) + { + *d++ = (p_record_buffer[p_record_buffer_readp]+0x8000) >> 8; + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + i++; + } + fwrite(write_buffer, 512, 1, p_record); + break; + + case CODEC_LAW: + d = write_buffer; + i = 0; + while(i < 256) + { + *d++ = audio_s16_to_law[p_record_buffer[p_record_buffer_readp] & 0xffff]; + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + i++; + } + fwrite(write_buffer, 256, 1, p_record); + break; + } + /* because we still have data, we write again */ + free += sizeof(write_buffer); + goto same_again; + } + + /* the buffer store the other stream */ + different_again: + + /* if buffer empty, change it */ + if (p_record_buffer_readp == p_record_buffer_writep) + { + p_record_buffer_dir = dir_fromup; + goto same_again; + } + /* how much data can we mix ? */ + ii = (p_record_buffer_writep - p_record_buffer_readp) & RECORD_BUFFER_MASK; + if (length < ii) + ii = length; + /* write data mixed with the buffer */ + switch(p_record_type) + { + case CODEC_MONO: + s = (signed short *)write_buffer; + i = 0; + while(i < ii) + { + sample = p_record_buffer[p_record_buffer_readp] + + audio_law_to_s32(*data++); + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + if (sample < 32767) + sample = -32767; + if (sample > 32768) + sample = 32768; + *s++ = sample; + i++; + } + fwrite(write_buffer, ii<<1, 1, p_record); + break; + + case CODEC_STEREO: + s = (signed short *)write_buffer; + if (p_record_buffer_dir) + { + i = 0; + while(i < ii) + { + *s++ = audio_law_to_s32(*data++); + *s++ = p_record_buffer[p_record_buffer_readp]; + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + i++; + } + } else + { + i = 0; + while(i < ii) + { + *s++ = p_record_buffer[p_record_buffer_readp]; + *s++ = audio_law_to_s32(*data++); + i++; + } + } + fwrite(write_buffer, ii<<2, 1, p_record); + break; + + case CODEC_8BIT: + d = write_buffer; + i = 0; + while(i < ii) + { + sample = p_record_buffer[p_record_buffer_readp] + + audio_law_to_s32(*data++); + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + if (sample < 32767) + sample = -32767; + if (sample > 32768) + sample = 32768; + *d++ = (sample+0x8000) >> 8; + i++; + } + fwrite(write_buffer, ii, 1, p_record); + break; + + case CODEC_LAW: + d = write_buffer; + i = 0; + while(i < ii) + { + sample = p_record_buffer[p_record_buffer_readp] + + audio_law_to_s32(*data++); + p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK; + if (sample < 32767) + sample = -32767; + if (sample > 32768) + sample = 32768; + *d++ = audio_s16_to_law[sample & 0xffff]; + i++; + } + fwrite(write_buffer, ii, 1, p_record); + break; + } + length -= ii; + /* data, but buffer empty */ + if (length) + { + p_record_buffer_dir = dir_fromup; + goto same_again; + } + /* no data (maybe buffer) */ + return; + +} + + +/* + * enque data from upper buffer + */ +iniialisieren der werte +void Port::txfromup(unsigned char *data, int length) +{ + + /* no recording */ + if (!length) + return; + + /* get free samples in buffer */ + free = ((p_fromup_buffer_readp - p_fromup_buffer_writep - 1) & FROMUP_BUFFER_MASK); + if (free < length) + { + PDEBUG(DEBUG_PORT, "Port(%d): fromup_buffer overflows, this shall not happen under normal conditions\n", p_serial); + return; + } + + /* write data to buffer and return */ + while(length) + { + p_fromup_buffer[p_fromup_buffer_writep] = *data++; + p_fromup_buffer_writep = (p_fromup_buffer_writep + 1) & FROMUP_BUFFER_MASK; + length--; + } + return; // must return, because length is 0 +} diff --git a/route.c b/route.c index b39d2e0..7bbae0c 100644 --- a/route.c +++ b/route.c @@ -2013,12 +2013,12 @@ struct route_action *EndpointAppPBX::route(struct route_ruleset *ruleset) switch(cond->match) { case MATCH_EXTERN: - if (!e_terminal[0]) + if (!e_ext.number[0]) istrue = 1; break; case MATCH_INTERN: - if (e_terminal[0]) + if (e_ext.number[0]) istrue = 1; break; diff --git a/todo.txt b/todo.txt index ad0b9fc..d2e5912 100644 --- a/todo.txt +++ b/todo.txt @@ -1,14 +1,9 @@ - define and change dsp conference ids make asterisk call implementation new interface.conf (add remove ports by admin) -reduce mixer - -call recording - call to multiple endpoints (extensions) trace with layers and filters @@ -24,7 +19,8 @@ avoid disconnect-collision (release if disconnect from both sides) display message during nothing/play - +Port -> Channel +Call -> Link diff --git a/vbox.cpp b/vbox.cpp index a1f371a..d0f124d 100644 --- a/vbox.cpp +++ b/vbox.cpp @@ -141,9 +141,8 @@ int VBoxPort::handler(void) /* start recording, if not already */ if (p_vbox_mode == VBOX_MODE_NORMAL) { - /* send recording start message */ - message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_VBOX_RECORD); - message_put(message); + /* recording start */ + open_record(p_vbox_ext.vbox_codec, 2, 0, p_vbox_ext.number, p_vbox_ext.anon_ignore, p_vbox_ext.vbox_email, p_vbox_ext.vbox_email_file); } else // else!! if (p_vbox_mode == VBOX_MODE_ANNOUNCEMENT) { @@ -158,6 +157,8 @@ int VBoxPort::handler(void) } } else { + if (p_record) + record(buffer, tosend, 0); // from down message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DATA); message->param.data.port_type = p_type; message->param.data.port_id = p_serial; @@ -276,15 +277,14 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para new_state(PORT_STATE_IN_ALERTING); } - /* start recording during announcement */ - /* start parallel recording if desired */ - p_vbox_mode = p_vbox_ext.vbox_mode; - p_vbox_record_limit = p_vbox_ext.vbox_time; /* play the announcement */ if ((p_vbox_announce_fh = open_tone(filename, &p_vbox_announce_codec, &p_vbox_announce_size, &p_vbox_announce_left)) >= 0) { fhuse++; } + /* start recording if desired */ + p_vbox_mode = p_vbox_ext.vbox_mode; + p_vbox_record_limit = p_vbox_ext.vbox_time; if (!p_vbox_announce_fh || p_vbox_mode==VBOX_MODE_PARALLEL) { PDEBUG(DEBUG_VBOX, "PORT(%s) parallel mode OR no announcement found at: '%s' so we start recording now.\n", p_name, filename);