diff --git a/apppbx.cpp b/apppbx.cpp index fff80ce..12b5c11 100644 --- a/apppbx.cpp +++ b/apppbx.cpp @@ -1520,8 +1534,8 @@ void EndpointAppPBX::port_setup(struct port_list *portlist, int message_type, un interface = interface->next; } if (interface) { - do_screen(0, e_callerinfo.id, sizeof(e_callerinfo.id), &e_callerinfo.ntype, &e_callerinfo.present, interface); - do_screen(0, e_callerinfo.id2, sizeof(e_callerinfo.id2), &e_callerinfo.ntype2, &e_callerinfo.present2, interface); + do_screen(0, e_callerinfo.id, sizeof(e_callerinfo.id), &e_callerinfo.ntype, &e_callerinfo.present, &e_callerinfo.screen, interface); + do_screen(0, e_callerinfo.id2, sizeof(e_callerinfo.id2), &e_callerinfo.ntype2, &e_callerinfo.present2, &e_callerinfo.screen2, interface); } /* process extension */ @@ -2034,7 +2048,7 @@ void EndpointAppPBX::port_connect(struct port_list *portlist, int message_type, interface = interface->next; } if (interface) - do_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, &e_connectinfo.screen, interface); /* screen connected name */ if (e_ext.name[0]) diff --git a/dss1.cpp b/dss1.cpp index c819835..ed207a5 100644 --- a/dss1.cpp +++ b/dss1.cpp @@ -1968,8 +1968,8 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo)); memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo)); /* 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); - do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface); + do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, &p_callerinfo.screen, p_m_mISDNport->ifport->interface); + do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, &p_callerinfo.screen2, 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) { @@ -2473,7 +2473,7 @@ void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parame /* 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); + do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, &p_connectinfo.screen, p_m_mISDNport->ifport->interface); /* only display at connect state */ if (p_state == PORT_STATE_CONNECT) diff --git a/gsm.cpp b/gsm.cpp index 07746f7..a476602 100644 --- a/gsm.cpp +++ b/gsm.cpp @@ -748,7 +748,7 @@ void Pgsm::message_connect(unsigned int epoint_id, int message_id, union paramet /* 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); + do_screen(1, p_connectinfo.id, sizeof(p_connectinfo.id), &p_connectinfo.ntype, &p_connectinfo.present, &p_connectinfo.screen, p_m_mISDNport->ifport->interface); /* send connect */ mncc = create_mncc(MNCC_SETUP_RSP, p_m_g_callref); diff --git a/gsm_bs.cpp b/gsm_bs.cpp index a8f7730..2111ff7 100644 --- a/gsm_bs.cpp +++ b/gsm_bs.cpp @@ -631,7 +631,7 @@ void Pgsm_bs::message_setup(unsigned int epoint_id, int message_id, union parame // 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); + do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, &p_callerinfo.screen, p_m_mISDNport->ifport->interface); /* attach only if not already */ epointlist = p_epointlist; diff --git a/interface.c b/interface.c index 4b894cf..7cda533 100644 --- a/interface.c +++ b/interface.c @@ -1628,32 +1628,59 @@ void doc_interface(void) /* screen caller id * out==0: incoming caller id, out==1: outgoing caller id */ -void do_screen(int out, char *id, int idsize, int *type, int *present, struct interface *interface) +void do_screen(int out, char *id, int idsize, int *type, int *present, int *screen, struct interface *interface) { char *msn1; struct interface_msn *ifmsn; struct interface_screen *ifscreen; char suffix[64]; + unsigned char len1, len2; /* screen incoming caller id */ if (!out) { /* check for MSN numbers, use first MSN if no match */ msn1 = NULL; + len1 = strlen(id); + while (id[0]=='0') { + memmove(id,id+1,len1--); + } ifmsn = interface->ifmsn; while(ifmsn) { if (!msn1) msn1 = ifmsn->msn; - if (!strcmp(ifmsn->msn, id)) { + len2 = strlen(ifmsn->msn); + if (len2>len1) { + if (!strcmp(ifmsn->msn+len2-len1, id)) { + break; + } + } else { + if (!strcmp(ifmsn->msn, id+len1-len2)) { break; } + if (ifmsn->msn[0]=='+' || ifmsn->msn[0]=='0') { + if (!strcmp(ifmsn->msn+1, id+len1-len2+1)) { + break; + } + if (ifmsn->msn[1]=='0') { + if (!strcmp(ifmsn->msn+2, id+len1-len2+2)) { + break; + } + } + } + } ifmsn = ifmsn->next; } if (ifmsn) { + *screen = INFO_SCREEN_USER_VERIFIED_PASSED; start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)"); - add_trace("msn", NULL, "%s", id); + add_trace("msn", "given", "%s", id); + add_trace("msn", "used", "%s", ifmsn->msn); end_trace(); + UNCPY(id, ifmsn->msn, idsize); + id[idsize-1] = '\0'; } if (!ifmsn && msn1) { // not in list, first msn given + *screen = INFO_SCREEN_NETWORK; start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)"); add_trace("msn", "given", "%s", id); add_trace("msn", "used", "%s", msn1); diff --git a/interface.h b/interface.h index eea6915..1a3aa16 100644 --- a/interface.h +++ b/interface.h @@ -132,5 +132,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); +void do_screen(int out, char *id, int idsize, int *type, int *present, int *screen, struct interface *interface); diff --git a/ss5.cpp b/ss5.cpp index 09f97eb..7e686a9 100644 --- a/ss5.cpp +++ b/ss5.cpp @@ -1740,8 +1740,8 @@ void Pss5::message_setup(unsigned int epoint_id, int message_id, union parameter memcpy(&p_capainfo, ¶m->setup.capainfo, sizeof(p_capainfo)); memcpy(&p_redirinfo, ¶m->setup.redirinfo, sizeof(p_redirinfo)); /* 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); - do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, p_m_mISDNport->ifport->interface); + do_screen(1, p_callerinfo.id, sizeof(p_callerinfo.id), &p_callerinfo.ntype, &p_callerinfo.present, &p_callerinfo.screen, p_m_mISDNport->ifport->interface); + do_screen(1, p_callerinfo.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, &p_callerinfo.screen2, p_m_mISDNport->ifport->interface); /* parse dial string */ dash = 0; /* dash must be used next time */