X-Git-Url: http://git.eversberg.eu/gitweb.cgi?p=lcr.git;a=blobdiff_plain;f=dss1.cpp;h=707cfc2be0315c26f8e7bf77e9fcac7950582923;hp=bb32c41b04830f615e0bf1eadbfe69e450ce1fee;hb=fb6e219eda69fe19fdd16457570dd51d07099320;hpb=ee848d3a9e333b3b91c0e40679c9d0512d511fc2 diff --git a/dss1.cpp b/dss1.cpp index bb32c41..707cfc2 100644 --- a/dss1.cpp +++ b/dss1.cpp @@ -30,7 +30,7 @@ Pdss1::Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_ p_m_d_tespecial = mISDNport->tespecial; p_m_d_l3id = 0; p_m_d_ces = -1; - p_m_d_queue = NULL; + p_m_d_queue[0] = '\0'; p_m_d_notify_pending = NULL; p_m_d_collect_cause = 0; p_m_d_collect_location = 0; @@ -45,9 +45,6 @@ Pdss1::Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_ Pdss1::~Pdss1() { /* remove queued message */ - if (p_m_d_queue) - message_free(p_m_d_queue); - if (p_m_d_notify_pending) message_free(p_m_d_notify_pending); } @@ -428,6 +425,7 @@ use_channel: void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) { int calling_type, calling_plan, calling_present, calling_screen; + int calling_type2, calling_plan2, calling_present2, calling_screen2; int called_type, called_plan; int redir_type, redir_plan, redir_present, redir_screen, redir_reason; int hlc_coding, hlc_presentation, hlc_interpretation, hlc_hlc, hlc_exthlc; @@ -463,7 +461,7 @@ void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) end_trace(); l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN); - dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id)); + dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id), &calling_type2, &calling_plan2, &calling_present2, &calling_screen2, (unsigned char *)p_callerinfo.id2, sizeof(p_callerinfo.id2)); dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id)); dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad)); /* te-mode: CNIP (calling name identification presentation) */ @@ -516,9 +514,10 @@ void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) switch (calling_type) { case -1: + p_callerinfo.ntype = INFO_NTYPE_NOTPRESENT; + break; + case 0x0: p_callerinfo.ntype = INFO_NTYPE_UNKNOWN; - p_callerinfo.present = INFO_PRESENT_NOTAVAIL; - p_callerinfo.screen = INFO_SCREEN_NETWORK; break; case 0x1: p_callerinfo.ntype = INFO_NTYPE_INTERNATIONAL; @@ -536,6 +535,50 @@ void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) p_callerinfo.isdn_port = p_m_portnum; SCPY(p_callerinfo.interface, p_m_mISDNport->ifport->interface->name); + /* caller info2 */ + switch (calling_present2) + { + case 1: + p_callerinfo.present2 = INFO_PRESENT_RESTRICTED; + break; + case 2: + p_callerinfo.present2 = INFO_PRESENT_NOTAVAIL; + break; + default: + p_callerinfo.present2 = INFO_PRESENT_ALLOWED; + break; + } + switch (calling_screen2) + { + case 0: + p_callerinfo.screen2 = INFO_SCREEN_USER; + break; + default: + p_callerinfo.screen2 = INFO_SCREEN_NETWORK; + break; + } + switch (calling_type2) + { + case -1: + p_callerinfo.ntype2 = INFO_NTYPE_NOTPRESENT; + break; + case 0x0: + p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN; + break; + case 0x1: + p_callerinfo.ntype2 = INFO_NTYPE_INTERNATIONAL; + break; + case 0x2: + p_callerinfo.ntype2 = INFO_NTYPE_NATIONAL; + break; + case 0x4: + p_callerinfo.ntype2 = INFO_NTYPE_SUBSCRIBER; + break; + default: + p_callerinfo.ntype2 = INFO_NTYPE_UNKNOWN; + break; + } + /* dialing information */ SCAT(p_dialinginfo.id, (char *)keypad); switch (called_type) @@ -600,9 +643,10 @@ void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) switch (redir_type) { case -1: + p_redirinfo.ntype = INFO_NTYPE_NOTPRESENT; + break; + case 0x0: p_redirinfo.ntype = INFO_NTYPE_UNKNOWN; - p_redirinfo.present = INFO_PRESENT_NULL; /* not redirecting */ - p_redirinfo.reason = INFO_REDIR_UNKNOWN; break; case 0x1: p_redirinfo.ntype = INFO_NTYPE_INTERNATIONAL; @@ -774,6 +818,9 @@ void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_ int coding, location, progress; int ret; struct lcr_msg *message; + int max = p_m_mISDNport->ifport->dialmax; + char *number; + l3_msg *nl3m; l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN); dec_ie_channel_id(l3m, &exclusive, &channel); @@ -797,6 +844,21 @@ void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_ message_put(message); new_state(PORT_STATE_OUT_OVERLAP); + + number = p_m_d_queue; + while (number[0]) /* as long we have something to dial */ + { + if (max > strlen(number) || max == 0) + max = strlen(number); + + nl3m = create_l3msg(); + l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT); + enc_ie_called_pn(nl3m, 0, 1, (unsigned char *)number, max); + end_trace(); + p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, nl3m); + number += max; + } + p_m_d_queue[0] = '\0'; } /* CC_PROCEEDING INDICATION */ @@ -859,8 +921,7 @@ void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3 switch (type) { case -1: - message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN; - message->param.notifyinfo.present = INFO_PRESENT_NULL; + message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT; break; case 1: message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL; @@ -940,8 +1001,7 @@ void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) switch (type) { case -1: - message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN; - message->param.notifyinfo.present = INFO_PRESENT_NULL; + message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT; break; case 1: message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL; @@ -1016,9 +1076,8 @@ void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) } switch (type) { - case 0x0: - p_connectinfo.present = INFO_PRESENT_NULL; /* no COLP info */ - p_connectinfo.ntype = INFO_NTYPE_UNKNOWN; + case -1: + p_connectinfo.ntype = INFO_NTYPE_NOTPRESENT; break; case 0x1: p_connectinfo.ntype = INFO_NTYPE_INTERNATIONAL; @@ -1280,8 +1339,7 @@ void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m) switch (type) { case -1: - message->param.notifyinfo.ntype = INFO_NTYPE_UNKNOWN; - message->param.notifyinfo.present = INFO_PRESENT_NULL; + message->param.notifyinfo.ntype = INFO_NTYPE_NOTPRESENT; break; case 1: message->param.notifyinfo.ntype = INFO_NTYPE_INTERNATIONAL; @@ -1884,16 +1942,25 @@ int Pdss1::handler(void) void Pdss1::message_information(unsigned int epoint_id, int message_id, union parameter *param) { l3_msg *l3m; + char *display = param->information.display; + char *number = param->information.id; + int max = p_m_mISDNport->ifport->dialmax; - if (param->information.id[0]) /* only if we have something to dial */ + while (number[0]) /* as long we have something to dial */ { + if (max > strlen(number) || max == 0) + max = strlen(number); + l3m = create_l3msg(); l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT); - enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id); - if (p_m_d_ntmode || p_m_d_tespecial) - enc_ie_display(l3m, (unsigned char *)param->information.display); + enc_ie_called_pn(l3m, 0, 1, (unsigned char *)number, max); + if ((p_m_d_ntmode || p_m_d_tespecial) && display[0]) { + enc_ie_display(l3m, (unsigned char *)display); + display = ""; + } end_trace(); p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m); + number += max; } new_state(p_state); } @@ -1907,9 +1974,11 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete l3_msg *l3m; int ret; int plan, type, screen, present, reason; + int plan2, type2, screen2, present2; int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc; int channel, exclusive; struct epoint_list *epointlist; + int max = p_m_mISDNport->ifport->dialmax; /* release if port is blocked */ if (p_m_mISDNport->ifport->block) @@ -1933,6 +2002,7 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete // 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.id2, sizeof(p_callerinfo.id2), &p_callerinfo.ntype2, &p_callerinfo.present2, 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) @@ -2012,6 +2082,9 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete plan = 1; switch (p_callerinfo.ntype) { + case INFO_NTYPE_UNKNOWN: + type = 0x0; + break; case INFO_NTYPE_INTERNATIONAL: type = 0x1; break; @@ -2021,8 +2094,8 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete case INFO_NTYPE_SUBSCRIBER: type = 0x4; break; - default: /* INFO_NTYPE_UNKNOWN */ - type = 0x0; + default: /* INFO_NTYPE_NOTPRESENT */ + type = -1; break; } switch (p_callerinfo.screen) @@ -2036,22 +2109,66 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete } switch (p_callerinfo.present) { + case INFO_PRESENT_ALLOWED: + present = 0; + break; case INFO_PRESENT_RESTRICTED: present = 1; break; - case INFO_PRESENT_NOTAVAIL: + default: /* INFO_PRESENT_NOTAVAIL */ present = 2; break; - default: /* INFO_PRESENT_ALLOWED */ - present = 0; + } + /* caller information 2 */ + plan2 = 1; + switch (p_callerinfo.ntype2) + { + case INFO_NTYPE_UNKNOWN: + type2 = 0x0; + break; + case INFO_NTYPE_INTERNATIONAL: + type2 = 0x1; + break; + case INFO_NTYPE_NATIONAL: + type2 = 0x2; + break; + case INFO_NTYPE_SUBSCRIBER: + type2 = 0x4; + break; + default: /* INFO_NTYPE_NOTPRESENT */ + type2 = -1; + break; + } + switch (p_callerinfo.screen2) + { + case INFO_SCREEN_USER: + screen2 = 0; + break; + default: /* INFO_SCREEN_NETWORK */ + screen2 = 3; + break; + } + switch (p_callerinfo.present2) + { + case INFO_PRESENT_ALLOWED: + present2 = 0; + break; + case INFO_PRESENT_RESTRICTED: + present2 = 1; + break; + default: /* INFO_PRESENT_NOTAVAIL */ + present2 = 2; break; } if (type >= 0) - enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id); + enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id, type2, plan2, present2, screen2, (unsigned char *)p_callerinfo.id2); /* dialing information */ if (p_dialinginfo.id[0]) /* only if we have something to dial */ { - enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id); + if (max > strlen(p_dialinginfo.id) || max == 0) + max = strlen(p_dialinginfo.id); + enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id, max); + SCPY(p_m_d_queue, p_dialinginfo.id + max); } /* sending complete */ if (p_dialinginfo.sending_complete) @@ -2065,6 +2182,9 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete plan = 1; switch (p_redirinfo.ntype) { + case INFO_NTYPE_UNKNOWN: + type = 0x0; + break; case INFO_NTYPE_INTERNATIONAL: type = 0x1; break; @@ -2074,8 +2194,8 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete case INFO_NTYPE_SUBSCRIBER: type = 0x4; break; - default: /* INFO_NTYPE_UNKNOWN */ - type = 0x0; + default: /* INFO_NTYPE_NOTPRESENT */ + type = -1; break; } switch (p_redirinfo.screen) @@ -2110,22 +2230,15 @@ void Pdss1::message_setup(unsigned int epoint_id, int message_id, union paramete } switch (p_redirinfo.present) { - case INFO_PRESENT_NULL: /* no redir at all */ - present = -1; - screen = -1; - reason = -1; - plan = -1; - type = -1; + case INFO_PRESENT_ALLOWED: + present = 0; break; case INFO_PRESENT_RESTRICTED: present = 1; break; - case INFO_PRESENT_NOTAVAIL: + default: /* INFO_PRESENT_NOTAVAIL */ present = 2; break; - default: /* INFO_PRESENT_ALLOWED */ - present = 0; - break; } /* sending redirecting number only in ntmode */ if (type >= 0 && (p_m_d_ntmode || p_m_d_tespecial)) @@ -2195,7 +2308,7 @@ void Pdss1::message_notify(unsigned int epoint_id, int message_id, union paramet { l3_msg *l3m; int notify; - int plan, type = -1, present; + int plan = 0, type = -1, present = 0; if (param->notifyinfo.notify>INFO_NOTIFY_NONE) notify = param->notifyinfo.notify & 0x7f; @@ -2211,6 +2324,9 @@ void Pdss1::message_notify(unsigned int epoint_id, int message_id, union paramet plan = 1; switch (param->notifyinfo.ntype) { + case INFO_NTYPE_UNKNOWN: + type = 0; + break; case INFO_NTYPE_INTERNATIONAL: type = 1; break; @@ -2221,25 +2337,20 @@ void Pdss1::message_notify(unsigned int epoint_id, int message_id, union paramet type = 4; break; default: /* INFO_NTYPE_UNKNOWN */ - type = 0; + type = -1; break; } switch (param->notifyinfo.present) { - case INFO_PRESENT_NULL: /* no redir at all */ - present = -1; - plan = -1; - type = -1; + case INFO_PRESENT_ALLOWED: + present = 0; break; case INFO_PRESENT_RESTRICTED: present = 1; break; - case INFO_PRESENT_NOTAVAIL: + default: /* INFO_PRESENT_NOTAVAIL */ present = 2; break; - default: /* INFO_PRESENT_ALLOWED */ - present = 0; - break; } } @@ -2431,6 +2542,9 @@ void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parame plan = 1; switch (p_connectinfo.ntype) { + case INFO_NTYPE_UNKNOWN: + type = 0x0; + break; case INFO_NTYPE_INTERNATIONAL: type = 0x1; break; @@ -2440,8 +2554,8 @@ void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parame case INFO_NTYPE_SUBSCRIBER: type = 0x4; break; - default: /* INFO_NTYPE_UNKNOWN */ - type = 0x0; + default: /* INFO_NTYPE_NOTPRESENT */ + type = -1; break; } switch (param->connectinfo.screen) @@ -2455,21 +2569,15 @@ void Pdss1::message_connect(unsigned int epoint_id, int message_id, union parame } switch (p_connectinfo.present) { - case INFO_PRESENT_NULL: /* no colp at all */ - present = -1; - screen = -1; - plan = -1; - type = -1; + case INFO_PRESENT_ALLOWED: + present = 0; break; case INFO_PRESENT_RESTRICTED: present = 1; break; - case INFO_PRESENT_NOTAVAIL: + default: /* INFO_PRESENT_NOTAVAIL */ present = 2; break; - default: /* INFO_PRESENT_ALLOWED */ - present = 0; - break; } if (type >= 0) enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id); @@ -2675,8 +2783,6 @@ wirklich erst proceeding?: */ int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union parameter *param) { - struct lcr_msg *message; - if (PmISDN::message_epoint(epoint_id, message_id, param)) return(1); @@ -2800,7 +2906,7 @@ int Pdss1::message_epoint(unsigned int epoint_id, int message_id, union paramete break; default: - PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message); + PERROR("Pdss1(%s) isdn port with (caller id %s) received a wrong message: %d\n", p_name, p_callerinfo.id, message_id); } return(1); @@ -2950,56 +3056,6 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi } -#if 0 -/* - * sending message that were queued during L1 activation - * or releasing port if link is down - */ -void setup_queue(struct mISDNport *mISDNport, int link) -{ - class Port *port; - class Pdss1 *pdss1; - struct lcr_msg *message; - - if (!mISDNport->ntmode) - return; - - /* check all port objects for pending message */ - port = port_first; - while(port) - { - if ((port->p_type&PORT_CLASS_mISDN_MASK) == PORT_CLASS_mISDN_DSS1) - { - pdss1 = (class Pdss1 *)port; - if (pdss1->p_m_mISDNport == mISDNport) - { - if (pdss1->p_m_d_queue) - { - if (link) - { - PDEBUG(DEBUG_ISDN, "the L1 became active, so we send queued message for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name); - /* LAYER 1 is up, so we send */ - pdss1->message_setup(pdss1->p_m_d_queue->id_from, pdss1->p_m_d_queue->type, &pdss1->p_m_d_queue->param); - message_free(pdss1->p_m_d_queue); - pdss1->p_m_d_queue = NULL; - } else - { - PDEBUG(DEBUG_ISDN, "the L1 became NOT active, so we release port for portnum=%d (%s).\n", mISDNport->portnum, pdss1->p_name); - message = message_create(pdss1->p_serial, pdss1->p_m_d_queue->id_from, PORT_TO_EPOINT, MESSAGE_RELEASE); - message->param.disconnectinfo.cause = 27; - message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL; - message_put(message); - pdss1->new_state(PORT_STATE_RELEASE); - pdss1->p_m_delete = 1; - } - } - } - } - port = port->next; - } -} - -#endif