From: Super User Date: Sat, 5 Jan 2008 21:58:22 +0000 (+0100) Subject: fixes, screen in and out works, fixed release problem in mISDNuser X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=commitdiff_plain;h=83477c7faf66a160530f5a01c1bf3016e2127a4d fixes, screen in and out works, fixed release problem in mISDNuser modified: Makefile modified: README modified: action.cpp modified: apppbx.cpp modified: apppbx.h modified: dss1.cpp modified: extension.c modified: interface.c modified: interface.h modified: main.c modified: port.cpp modified: tones.c modified: trace.c modified: trace.h --- diff --git a/Makefile b/Makefile index fe9e712..e40e094 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,8 @@ GEN = ./gentones GENW = ./genwave GENRC = ./genrc GENEXT = ./genextension -CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\" +CFLAGS = -DINSTALL_DATA=\"$(INSTALL_DATA)\" -I/usr/include/mISDNuser/ +#CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\" ifdef WITH-CRYPTO CFLAGS += -DCRYPTO endif @@ -272,10 +273,21 @@ endif @if test -a $(INSTALL_DATA)/directory.list ; then \ echo "NOTE: directory.list already exists, not changed." ; else \ cp -v default/directory.list $(INSTALL_DATA) ; fi - cp -a tones_* $(INSTALL_DATA) - cp -a vbox_english/ $(INSTALL_DATA) - cp -a vbox_german/ $(INSTALL_DATA) - cp -a tones_efi/ $(INSTALL_DATA) + @if test -a $(INSTALL_DATA)/tones_american ; then \ + echo "NOTE: american tones already exists, not overwritten." ; else \ + cp -a tones_american $(INSTALL_DATA) ; fi + @if test -a $(INSTALL_DATA)/tones_german ; then \ + echo "NOTE: german tones already exists, not overwritten." ; else \ + cp -a tones_german $(INSTALL_DATA) ; fi + @if test -a $(INSTALL_DATA)/vbox_german ; then \ + echo "NOTE: german vbox tones already exists, not overwritten." ; else \ + cp -a vbox_german $(INSTALL_DATA) ; fi + @if test -a $(INSTALL_DATA)/vbox_english ; then \ + echo "NOTE: english vbox tones already exists, not overwritten." ; else \ + cp -a vbox_english $(INSTALL_DATA) ; fi + @if test -a $(INSTALL_DATA)/tones_efi ; then \ + echo "NOTE: special efi tones already exists, not overwritten." ; else \ + cp -a tones_efi $(INSTALL_DATA) ; fi sync clean: diff --git a/README b/README index 89ba4cc..8aaf592 100644 --- a/README +++ b/README @@ -404,4 +404,7 @@ Changes in Version 0.3 - Added timeouts for testcall feature. (lcradmin) -> You can run scripts, that generate testcalls of multiple destinations. - Added origin flag to correctly process last_in and last_out call logging. +- Tones and annoucements are not overwritten if exist, during installation. +- Screening now also works for outgoing calls (to interface) +TODO: recording crashes!! (vbox, audio recording) diff --git a/action.cpp b/action.cpp index 23af732..0bb68cd 100644 --- a/action.cpp +++ b/action.cpp @@ -698,7 +698,7 @@ void EndpointAppPBX::action_dialing_login(void) message->param.connectinfo.present = INFO_PRESENT_RESTRICTED; else message->param.connectinfo.present = e_ext.callerid_present; /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); + apply_callerid_restriction(&e_ext, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); /* display callerid if desired for extension */ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name)); message->param.connectinfo.ntype = e_ext.callerid_type; @@ -1373,7 +1373,7 @@ void EndpointAppPBX::action_dialing_test(void) message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT); memcpy(&message->param.connectinfo, &e_connectinfo, sizeof(struct connect_info)); /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); + apply_callerid_restriction(&e_ext, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); /* display callerid if desired for extension */ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name)); message_put(message); diff --git a/apppbx.cpp b/apppbx.cpp index e5f0e0d..c7803ac 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -38,7 +38,15 @@ EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint, int origin) : EndpointApp /* initialize */ memset(&e_ext, 0, sizeof(struct extension)); + // *************** NOTE: also change value in read_extension() ************** e_ext.rights = 4; /* international */ + e_ext.tout_setup = 120; + e_ext.tout_dialing = 120; + e_ext.tout_proceeding = 120; + e_ext.tout_alerting = 120; + e_ext.tout_disconnect = 120; +// e_ext.tout_hold = 900; +// e_ext.tout_park = 900; e_ext.rxvol = e_ext.txvol = 256; e_state = EPOINT_STATE_IDLE; e_ext.number[0] = '\0'; @@ -173,158 +181,6 @@ void EndpointAppPBX::new_state(int state) } -/* screen caller id - * out==0: incomming caller id, out==1: outgoing caller id - */ -void EndpointAppPBX::screen(int out, char *id, int idsize, int *type, int *present, struct interface *interface) -{ - char *msn1; - struct interface_msn *ifmsn; - struct interface_screen *ifscreen; - char suffix[64]; - - /* screen incoming caller id */ - if (!out) - { - /* check for MSN numbers, use first MSN if no match */ - msn1 = NULL; - ifmsn = interface->ifmsn; - while(ifmsn) - { - if (!msn1) - msn1 = ifmsn->msn; - if (!strcmp(ifmsn->msn, id)) - { - break; - } - ifmsn = ifmsn->next; - } - if (ifmsn) - { - trace_header("SCREEN (found in MSN list)", DIRECTION_IN); - add_trace("msn", NULL, "%s", id); - end_trace(); - } - if (!ifmsn && msn1) // not in list, first msn given - { - trace_header("SCREEN (not found MSN in list)", DIRECTION_IN); - add_trace("msn", "given", "%s", id); - add_trace("msn", "used", "%s", msn1); - end_trace(); - UNCPY(id, msn1, idsize); - id[idsize-1] = '\0'; - } - } - - /* check screen list */ - if (out) - ifscreen = interface->ifscreen_out; - else - ifscreen = interface->ifscreen_in; - while (ifscreen) - { - if (ifscreen->match_type==-1 || ifscreen->match_type==*type) - if (ifscreen->match_present==-1 || ifscreen->match_present==*present) - { - if (strchr(ifscreen->match,'%')) - { - if (!strncmp(ifscreen->match, id, strchr(ifscreen->match,'%')-ifscreen->match)) - break; - } else - { - if (!strcmp(ifscreen->match, id)) - break; - } - } - ifscreen = ifscreen->next; - } - if (ifscreen) // match - { - trace_header("SCREEN (found in screen list)", out?DIRECTION_OUT:DIRECTION_IN); - switch(*type) - { - case INFO_NTYPE_UNKNOWN: - add_trace("given", "type", "unknown"); - break; - case INFO_NTYPE_SUBSCRIBER: - add_trace("given", "type", "subscriber"); - break; - case INFO_NTYPE_NATIONAL: - add_trace("given", "type", "national"); - break; - case INFO_NTYPE_INTERNATIONAL: - add_trace("given", "type", "international"); - break; - } - switch(*present) - { - case INFO_PRESENT_ALLOWED: - add_trace("given", "present", "allowed"); - break; - case INFO_PRESENT_RESTRICTED: - add_trace("given", "present", "restricted"); - break; - case INFO_PRESENT_NOTAVAIL: - add_trace("given", "present", "not available"); - break; - } - add_trace("given", "id", "%s", id[0]?id:""); - if (ifscreen->result_type != -1) - { - *type = ifscreen->result_type; - switch(*type) - { - case INFO_NTYPE_UNKNOWN: - add_trace("used", "type", "unknown"); - break; - case INFO_NTYPE_SUBSCRIBER: - add_trace("used", "type", "subscriber"); - break; - case INFO_NTYPE_NATIONAL: - add_trace("used", "type", "national"); - break; - case INFO_NTYPE_INTERNATIONAL: - add_trace("used", "type", "international"); - break; - } - } - if (ifscreen->result_present != -1) - { - *present = ifscreen->result_present; - switch(*present) - { - case INFO_PRESENT_ALLOWED: - add_trace("used", "present", "allowed"); - break; - case INFO_PRESENT_RESTRICTED: - add_trace("used", "present", "restricted"); - break; - case INFO_PRESENT_NOTAVAIL: - add_trace("used", "present", "not available"); - break; - } - } - if (strchr(ifscreen->match,'%')) - { - SCPY(suffix, strchr(ifscreen->match,'%') - ifscreen->match + id); - UNCPY(id, ifscreen->result, idsize); - id[idsize-1] = '\0'; - if (strchr(id,'%')) - { - *strchr(id,'%') = '\0'; - UNCAT(id, suffix, idsize); - id[idsize-1] = '\0'; - } - } else - { - UNCPY(id, ifscreen->result, idsize); - id[idsize-1] = '\0'; - } - add_trace("used", "id", "%s", id[0]?id:""); - end_trace(); - } -} - /* release join and port (as specified) */ void EndpointAppPBX::release(int release, int joinlocation, int joincause, int portlocation, int portcause) @@ -450,7 +306,7 @@ void EndpointAppPBX::release(int release, int joinlocation, int joincause, int p /* cancel callerid if restricted, unless anon-ignore is enabled at extension or port is of type external (so called police gets caller id :)*/ -void apply_callerid_restriction(int anon_ignore, char *id, int *ntype, int *present, int *screen, char *extension, char *name) +void apply_callerid_restriction(struct extension *ext, char *id, int *ntype, int *present, int *screen, char *extension, char *name) { PDEBUG(DEBUG_EPOINT, "id='%s' ntype=%d present=%d screen=%d extension='%s' name='%s'\n", (id)?id:"NULL", (ntype)?*ntype:-1, (present)?*present:-1, (screen)?*screen:-1, (extension)?extension:"NULL", (name)?name:"NULL"); @@ -459,13 +315,11 @@ void apply_callerid_restriction(int anon_ignore, char *id, int *ntype, int *pres return; /* only extensions are restricted */ - if (!extension) - return; - if (!extension[0]) + if (!ext->number[0]) return; /* if we enabled anonymouse ignore */ - if (anon_ignore) + if (ext->anon_ignore) return; /* else we remove the caller id */ @@ -866,6 +720,8 @@ foundif: } i++; } + if (*channel) + break; trace_header("CHANNEL SELECTION (no channel is 'free')", DIRECTION_NONE); add_trace("port", NULL, "%d", ifport->portnum); add_trace("position", NULL, "%d", index); @@ -1177,8 +1033,8 @@ void EndpointAppPBX::out_setup(void) //terminal if (e_dialinginfo.id) //terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.id); /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name); - apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL); + apply_callerid_restriction(&e_ext, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name); + apply_callerid_restriction(&e_ext, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL); /* display callerid if desired for extension */ SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name)); //printf("\n\ndisplay = %s\n\n\n",message->param.setup.callerinfo.display); @@ -1296,8 +1152,8 @@ void EndpointAppPBX::out_setup(void) //terminal if (e_dialinginfo.id) //terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.id); /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name); - apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL); + apply_callerid_restriction(&e_ext, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name); + apply_callerid_restriction(&e_ext, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL); /* display callerid if desired for extension */ SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name)); message_put(message); @@ -1371,8 +1227,8 @@ void EndpointAppPBX::out_setup(void) //terminal if (e_dialinginfo.id) //terminal SCPY(message->param.setup.to_terminal, e_dialinginfo.id); /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name); - apply_callerid_restriction(e_ext.anon_ignore, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL); + apply_callerid_restriction(&e_ext, message->param.setup.callerinfo.id, &message->param.setup.callerinfo.ntype, &message->param.setup.callerinfo.present, &message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name); + apply_callerid_restriction(&e_ext, message->param.setup.redirinfo.id, &message->param.setup.redirinfo.ntype, &message->param.setup.redirinfo.present, 0, message->param.setup.redirinfo.extension, NULL); /* display callerid if desired for extension */ SCPY(message->param.setup.callerinfo.display, apply_callerid_display(message->param.setup.callerinfo.id, message->param.setup.callerinfo.itype, message->param.setup.callerinfo.ntype, message->param.setup.callerinfo.present, message->param.setup.callerinfo.screen, message->param.setup.callerinfo.extension, message->param.setup.callerinfo.name)); message_put(message); @@ -1649,7 +1505,7 @@ void EndpointAppPBX::port_setup(struct port_list *portlist, int message_type, un interface = interface->next; } if (interface) - screen(0, e_callerinfo.id, sizeof(e_callerinfo.id), &e_callerinfo.ntype, &e_callerinfo.present, interface); + do_screen(0, e_callerinfo.id, sizeof(e_callerinfo.id), &e_callerinfo.ntype, &e_callerinfo.present, interface); /* process extension */ if (e_callerinfo.itype == INFO_ITYPE_ISDN_EXTENSION) @@ -2187,7 +2043,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, interface = interface->next; } if (interface) - screen(0, e_connectinfo.id, sizeof(e_connectinfo.id), &e_connectinfo.ntype, &e_connectinfo.present, interface); + do_screen(0, e_connectinfo.id, sizeof(e_connectinfo.id), &e_connectinfo.ntype, &e_connectinfo.present, interface); /* screen connected name */ if (e_ext.name[0]) @@ -3111,7 +2967,6 @@ void EndpointAppPBX::join_alerting(struct port_list *portlist, int message_type, void EndpointAppPBX::join_connect(struct port_list *portlist, int message_type, union parameter *param) { struct message *message; - struct interface *interface; new_state(EPOINT_STATE_CONNECT); // UCPY(e_join_tone, ""); @@ -3123,19 +2978,6 @@ void EndpointAppPBX::join_connect(struct port_list *portlist, int message_type, { message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_CONNECT); memcpy(&message->param, param, sizeof(union parameter)); - /* screen incoming caller id */ - interface = interface_first; - while(interface) - { - if (!strcmp(e_connectinfo.interface, interface->name)) - { - break; - } - interface = interface->next; - } - if (interface) - screen(1, e_connectinfo.id, sizeof(e_connectinfo.id), &e_connectinfo.ntype, &e_connectinfo.present, interface); - memcpy(&message->param.connectinfo, &e_connectinfo, sizeof(e_connectinfo)); /* screen clip if prefix is required */ if (e_ext.number[0] && message->param.connectinfo.id[0] && e_ext.clip_prefix[0]) @@ -3153,7 +2995,7 @@ void EndpointAppPBX::join_connect(struct port_list *portlist, int message_type, } /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); + apply_callerid_restriction(&e_ext, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); /* display callerid if desired for extension */ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name)); @@ -3389,19 +3231,6 @@ void EndpointAppPBX::join_setup(struct port_list *portlist, int message_type, un memcpy(&e_redirinfo, ¶m->setup.redirinfo, sizeof(e_redirinfo)); memcpy(&e_capainfo, ¶m->setup.capainfo, sizeof(e_capainfo)); - /* screen incoming caller id */ - interface = interface_first; - while(interface) - { - if (!strcmp(e_callerinfo.interface, interface->name)) - { - break; - } - interface = interface->next; - } - if (interface) - screen(1, e_callerinfo.id, sizeof(e_callerinfo.id), &e_callerinfo.ntype, &e_callerinfo.present, interface); - /* process (voice over) data calls */ if (e_ext.datacall && e_capainfo.bearer_capa!=INFO_BC_SPEECH && e_capainfo.bearer_capa!=INFO_BC_AUDIO) { @@ -3484,7 +3313,7 @@ void EndpointAppPBX::join_notify(struct port_list *portlist, int message_type, u message = message_create(ea_endpoint->ep_serial, portlist->port_id, EPOINT_TO_PORT, MESSAGE_NOTIFY); memcpy(&message->param.notifyinfo, ¶m->notifyinfo, sizeof(struct notify_info)); /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.notifyinfo.id, &message->param.notifyinfo.ntype, &message->param.notifyinfo.present, 0, message->param.notifyinfo.extension, NULL); + apply_callerid_restriction(&e_ext, message->param.notifyinfo.id, &message->param.notifyinfo.ntype, &message->param.notifyinfo.present, 0, message->param.notifyinfo.extension, NULL); /* display callerid if desired for extension */ SCPY(message->param.notifyinfo.display, apply_callerid_display(message->param.notifyinfo.id, message->param.notifyinfo.itype, message->param.notifyinfo.ntype, message->param.notifyinfo.present, 0, message->param.notifyinfo.extension, NULL)); message_put(message); @@ -3896,7 +3725,7 @@ reject: message->param.connectinfo.itype = eapp->e_callerinfo.itype; message->param.connectinfo.ntype = eapp->e_callerinfo.ntype; /* handle restricted caller ids */ - apply_callerid_restriction(e_ext.anon_ignore, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); + apply_callerid_restriction(&e_ext, message->param.connectinfo.id, &message->param.connectinfo.ntype, &message->param.connectinfo.present, &message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name); /* display callerid if desired for extension */ SCPY(message->param.connectinfo.display, apply_callerid_display(message->param.connectinfo.id, message->param.connectinfo.itype, message->param.connectinfo.ntype, message->param.connectinfo.present, message->param.connectinfo.screen, message->param.connectinfo.extension, message->param.connectinfo.name)); message_put(message); @@ -4346,10 +4175,10 @@ void EndpointAppPBX::logmessage(int message_type, union parameter *param, unsign add_trace("cause", "location", "3-Transit"); break; case LOCATION_PUBLIC_REMOTE: - add_trace("cause", "location", "4-Remote-PBX"); + add_trace("cause", "location", "4-Remote-Exchange"); break; case LOCATION_PRIVATE_REMOTE: - add_trace("cause", "location", "5-Remote-Exchange"); + add_trace("cause", "location", "5-Remote-PBX"); break; case LOCATION_INTERNATIONAL: add_trace("cause", "location", "7-International-Exchange"); diff --git a/apppbx.h b/apppbx.h index b0d45f3..0dc3626 100644 --- a/apppbx.h +++ b/apppbx.h @@ -347,13 +347,12 @@ class EndpointAppPBX : public EndpointApp void message_disconnect_port(struct port_list *portlist, int cause, int location, char *display); void logmessage(int message_type, union parameter *param, unsigned long port_id, int dir); void trace_header(char *name, int direction); - void screen(int out, char *id, int idsize, int *type, int *present, struct interface *interface); }; char *nationalize_callerinfo(char *string, int *type); char *numberrize_callerinfo(char *string, int type); -void apply_callerid_restriction(int anon_ignore, char *id, int *ntype, int *present, int *screen, char *extension, char *name); +void apply_callerid_restriction(struct extension *ext, char *id, int *ntype, int *present, int *screen, char *extension, char *name); void send_mail(char *filename, char *callerid, char *callerintern, char *callername, char *vbox_email, int vbox_year, int vbox_mon, int vbox_mday, int vbox_hour, int vbox_min, char *terminal); diff --git a/dss1.cpp b/dss1.cpp index 523ab32..e64ccce 100644 --- a/dss1.cpp +++ b/dss1.cpp @@ -353,9 +353,9 @@ int Pdss1::hunt_bchannel(int channel, int exclusive) } if (channel <= 0) /* not given, no channel, whatever.. */ channel = CHANNEL_ANY; /* any channel */ + add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved); if (p_m_mISDNport->b_reserved >= p_m_mISDNport->b_num) // of out chan.. { - add_trace("channel", "reserved", "%d", p_m_mISDNport->b_reserved); add_trace("conclusion", NULL, "all channels are reserved"); end_trace(); return(-34); // no channel @@ -2056,6 +2056,8 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo)); memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo)); // SCPY(&p_m_tones_dir, param->setup.ext.tones_dir); + /* screen outgoing caller id */ + do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, p_m_mISDNport->ifport->interface); /* only display at connect state: this case happens if endpoint is in connected mode */ if (p_state==PORT_STATE_CONNECT) @@ -2573,6 +2575,8 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param /* copy connected information */ memcpy(&p_connectinfo, ¶m->connectinfo, sizeof(p_connectinfo)); + /* screen outgoing caller id */ + do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, p_m_mISDNport->ifport->interface); /* only display at connect state */ if (p_state == PORT_STATE_CONNECT) diff --git a/extension.c b/extension.c index f498438..470cf15 100644 --- a/extension.c +++ b/extension.c @@ -62,6 +62,7 @@ int read_extension(struct extension *ext, char *num) /* default values */ memset(ext, 0, sizeof(struct extension)); SCPY(ext->number, number); +// ********** NOTE: also change value in apppbx constructor ext->rights = 4; /* international */ ext->tout_setup = 120; ext->tout_dialing = 120; diff --git a/interface.c b/interface.c index 6f95fb0..e95d613 100644 --- a/interface.c +++ b/interface.c @@ -490,6 +490,7 @@ static int inter_screen(struct interface_screen **ifscreenp, struct interface *i while(*ifscreenp) ifscreenp = &((*ifscreenp)->next); *ifscreenp = ifscreen; +// printf("interface=%s\n", interface->name); /* get match */ p = value; while(*p) @@ -534,7 +535,7 @@ static int inter_screen(struct interface_screen **ifscreenp, struct interface *i } ifscreen->match_present = INFO_PRESENT_ALLOWED; } else - if (!strcasecmp(el, "restricted")) + if (!strcasecmp(el, "restrict") || !strcasecmp(el, "restricted")) { if (ifscreen->match_present != -1) goto presenterror; @@ -593,7 +594,7 @@ static int inter_screen(struct interface_screen **ifscreenp, struct interface *i goto presenterror; ifscreen->result_present = INFO_PRESENT_ALLOWED; } else - if (!strcasecmp(el, "restricted")) + if (!strcasecmp(el, "restrict") || !strcasecmp(el, "restricted")) { if (ifscreen->result_present != -1) goto presenterror; @@ -1152,3 +1153,156 @@ void doc_interface(void) } } + +/* screen caller id + * out==0: incomming caller id, out==1: outgoing caller id + */ +void do_screen(int out, char *id, int idsize, int *type, int *present, struct interface *interface) +{ + char *msn1; + struct interface_msn *ifmsn; + struct interface_screen *ifscreen; + char suffix[64]; + + /* screen incoming caller id */ + if (!out) + { + /* check for MSN numbers, use first MSN if no match */ + msn1 = NULL; + ifmsn = interface->ifmsn; + while(ifmsn) + { + if (!msn1) + msn1 = ifmsn->msn; + if (!strcmp(ifmsn->msn, id)) + { + break; + } + ifmsn = ifmsn->next; + } + if (ifmsn) + { + start_trace(0, interface, numberrize_callerinfo(id, *type), NULL, DIRECTION_IN, 0, 0, "SCREEN (fount in MSN list)"); + add_trace("msn", NULL, "%s", id); + end_trace(); + } + if (!ifmsn && msn1) // not in list, first msn given + { + start_trace(0, interface, numberrize_callerinfo(id, *type), NULL, DIRECTION_IN, 0, 0, "SCREEN (not fount in MSN list)"); + add_trace("msn", "given", "%s", id); + add_trace("msn", "used", "%s", msn1); + end_trace(); + UNCPY(id, msn1, idsize); + id[idsize-1] = '\0'; + } + } + + /* check screen list */ + if (out) + ifscreen = interface->ifscreen_out; + else + ifscreen = interface->ifscreen_in; + while (ifscreen) + { + if (ifscreen->match_type==-1 || ifscreen->match_type==*type) + if (ifscreen->match_present==-1 || ifscreen->match_present==*present) + { + if (strchr(ifscreen->match,'%')) + { + if (!strncmp(ifscreen->match, id, strchr(ifscreen->match,'%')-ifscreen->match)) + break; + } else + { + if (!strcmp(ifscreen->match, id)) + break; + } + } + ifscreen = ifscreen->next; + } + if (ifscreen) // match + { + start_trace(0, interface, numberrize_callerinfo(id, *type), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (fount in screen list)"); + switch(*type) + { + case INFO_NTYPE_UNKNOWN: + add_trace("given", "type", "unknown"); + break; + case INFO_NTYPE_SUBSCRIBER: + add_trace("given", "type", "subscriber"); + break; + case INFO_NTYPE_NATIONAL: + add_trace("given", "type", "national"); + break; + case INFO_NTYPE_INTERNATIONAL: + add_trace("given", "type", "international"); + break; + } + switch(*present) + { + case INFO_PRESENT_ALLOWED: + add_trace("given", "present", "allowed"); + break; + case INFO_PRESENT_RESTRICTED: + add_trace("given", "present", "restricted"); + break; + case INFO_PRESENT_NOTAVAIL: + add_trace("given", "present", "not available"); + break; + } + add_trace("given", "id", "%s", id[0]?id:""); + if (ifscreen->result_type != -1) + { + *type = ifscreen->result_type; + switch(*type) + { + case INFO_NTYPE_UNKNOWN: + add_trace("used", "type", "unknown"); + break; + case INFO_NTYPE_SUBSCRIBER: + add_trace("used", "type", "subscriber"); + break; + case INFO_NTYPE_NATIONAL: + add_trace("used", "type", "national"); + break; + case INFO_NTYPE_INTERNATIONAL: + add_trace("used", "type", "international"); + break; + } + } + if (ifscreen->result_present != -1) + { + *present = ifscreen->result_present; + switch(*present) + { + case INFO_PRESENT_ALLOWED: + add_trace("used", "present", "allowed"); + break; + case INFO_PRESENT_RESTRICTED: + add_trace("used", "present", "restricted"); + break; + case INFO_PRESENT_NOTAVAIL: + add_trace("used", "present", "not available"); + break; + } + } + if (strchr(ifscreen->match,'%')) + { + SCPY(suffix, strchr(ifscreen->match,'%') - ifscreen->match + id); + UNCPY(id, ifscreen->result, idsize); + id[idsize-1] = '\0'; + if (strchr(id,'%')) + { + *strchr(id,'%') = '\0'; + UNCAT(id, suffix, idsize); + id[idsize-1] = '\0'; + } + } else + { + UNCPY(id, ifscreen->result, idsize); + id[idsize-1] = '\0'; + } + add_trace("used", "id", "%s", id[0]?id:""); + end_trace(); + } +} + diff --git a/interface.h b/interface.h index 1022e38..4085ebe 100644 --- a/interface.h +++ b/interface.h @@ -112,5 +112,5 @@ void free_interfaces(struct interface *interface_start); void relink_interfaces(void); void load_port(struct interface_port *ifport); void doc_interface(void); - +void do_screen(int out, char *id, int idsize, int *type, int *present, struct interface *interface); diff --git a/main.c b/main.c index 3481245..09d6a6f 100644 --- a/main.c +++ b/main.c @@ -658,7 +658,7 @@ free: if (options.schedule > 1) { memset(&schedp, 0, sizeof(schedp)); - schedp.sched_priority = 0; + schedp.sched_priority = options.schedule; sched_setscheduler(0, SCHED_OTHER, &schedp); } /* reset signals */ diff --git a/port.cpp b/port.cpp index d9f07c3..02d8dc3 100644 --- a/port.cpp +++ b/port.cpp @@ -807,7 +807,7 @@ void Port::close_record(int beep) PDEBUG(DEBUG_PORT, "data still in record buffer: %d (dir %d)\n", (p_record_buffer_writep - p_record_buffer_readp) & RECORD_BUFFER_MASK, p_record_buffer_dir); memcpy(&callerinfo, &p_callerinfo, sizeof(struct caller_info)); - apply_callerid_restriction(p_record_anon_ignore, callerinfo.id, &callerinfo.ntype, &callerinfo.present, &callerinfo.screen, callerinfo.extension, callerinfo.name); +// apply_callerid_restriction(p_record_anon_ignore, callerinfo.id, &callerinfo.ntype, &callerinfo.present, &callerinfo.screen, callerinfo.extension, callerinfo.name); SCPY(number, p_dialinginfo.id); SCPY(callerid, numberrize_callerinfo(callerinfo.id, callerinfo.ntype)); diff --git a/tones.c b/tones.c index e5f2c75..783c83b 100644 --- a/tones.c +++ b/tones.c @@ -217,7 +217,7 @@ int open_tone(char *file, int *codec, signed long *length, signed long *left) *length = ((signed long)chunk)>>1; if (left) *left = ((signed long)chunk)>>1; - printf("left=%d\n",*left); +// printf("left=%d\n",*left); } else if (bytes==2 && channels==2) { diff --git a/trace.c b/trace.c index 2bd2119..2f640a9 100644 --- a/trace.c +++ b/trace.c @@ -32,10 +32,10 @@ static char *spaces[11] = { * initializes a new trace * all values will be reset */ -void start_trace(int port, struct interface *interface, char *caller, char *dialing, int direction, int category, int serial, char *name) +void _start_trace(const char *__file, int __line, int port, struct interface *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); + PERROR("trace already started (name=%s) in file %s line %d\n", trace.name, __file, __line); memset(&trace, 0, sizeof(struct trace)); trace.port = port; if (interface) @@ -59,12 +59,12 @@ void start_trace(int port, struct interface *interface, char *caller, char *dial * if subelement is given, element will also contain a subelement * if multiple subelements belong to same element, name must be equal for all subelements */ -void add_trace(char *name, char *sub, const char *fmt, ...) +void _add_trace(const char *__file, int __line, char *name, char *sub, const char *fmt, ...) { va_list args; if (!trace.name[0]) - PERROR("trace not started\n"); + PERROR("trace not started in file %s line %d\n", __file, __line); /* check for required name value */ if (!name) @@ -280,7 +280,7 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch * trace ends * this function will put the trace to sockets and logfile, if requested */ -void end_trace(void) +void _end_trace(const char *__file, int __line) { char *string; FILE *fp; @@ -288,7 +288,7 @@ void end_trace(void) struct admin_queue *response, **responsep; /* response pointer */ if (!trace.name[0]) - PERROR("trace not started\n"); + PERROR("trace not started in file %s line %d\n", __file, __line); if (options.deb || options.log[0]) { diff --git a/trace.h b/trace.h index b7a4720..dcedbe2 100644 --- a/trace.h +++ b/trace.h @@ -42,9 +42,12 @@ struct trace { //#define CATEGORY_BC 0x04 check lcradmin help -void start_trace(int port, struct interface *interface, char *caller, char *dialing, int direction, int category, int serial, char *name); -void add_trace(char *name, char *sub, const char *fmt, ...); -void end_trace(void); +#define start_trace(port, interface, caller, dialing, direction, category, serial, name) _start_trace(__FUNCTION__, __LINE__, port, interface, caller, dialing, direction, category, serial, name) +#define add_trace(name, sub, fmt, arg...) _add_trace(__FUNCTION__, __LINE__, name, sub, fmt, ## arg) +#define end_trace() _end_trace(__FUNCTION__, __LINE__) +void _start_trace(const char *__file, int line, int port, struct interface *interface, char *caller, char *dialing, int direction, int category, int serial, char *name); +void _add_trace(const char *__file, int line, char *name, char *sub, const char *fmt, ...); +void _end_trace(const char *__file, int line); //char *print_trace(int port, char *interface, char *caller, char *dialing, int direction, char *category, char *name);