💾 Archived View for gemini.spam.works › mirrors › textfiles › phreak › SWITCHES › bctj1.05 captured on 2022-07-17 at 11:11:52.

View Raw

More Information

⬅️ Previous capture (2022-06-12)

-=-=-=-=-=-=-



 $%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$
 %$%                                                                     %$%
 $%$                       ISDN  "c" file                                $%$
 %$%                                                                     %$%
 $%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$%$







/* ISDN layer 3 msg parameter- cause-                  */
/* Feberuary 11, 1985                                  */

char *cocausemsg[0x65] = {

/* LOCUSER */   "User side",               
/* LOCPNET */   "Local private network",   
/* LOCLNET */   "Local network",
/* LOCTNET */   "Transit network",
/* LOCRNET */   "Remote local network",
/* LOCRPNET*/   "Remote private network",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* ABANDON */   "Call abandoned",
/* ORIFRAUD*/   "Invalid calling directory number",
/* NORMTR  */   "Normal call termination",
/* USERBUSY*/   "User busy",           
/* NORESPON*/   "No user responding", 
/* WAITDEST*/   "This call waiting at destination",
/* CIROPER */   "Circuit operational",
/* CALLREJ */   "Call rejected",        
/* NUMCHANG*/   "Destination number changed", 
/* RCHARREJ*/   "Reverse charging rejected",
/* CALLSUSP*/   "Call suspend",
/* CALLRESU*/   "Call resumed",    
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* MSGOUT  */   "Messages out-of-sync",
/* RESFAIL */   "Line restriction fails",
/* SPARE   */   "",
/* CIROUT  */   "Circuit out-of-order",   
/* NOCHANN */   "No channel available",          
/* NODESTOB*/   "Destination not obtainable",
/* DESTOUT */   "Destination out of order",
/* DEGRADE */   "Degraded service(excessive error rate)",
/* TNETOUT */   "Transit network out of order",
/* TDELAY  */   "Transit delay range cannot be achieved",
/* THROUPUT*/   "Throughput range cannot be achieved",
/* NETFAIL */   "Network failure",
/* NETCONG */   "Network congestion",
/* INFODIS */   "User info discarded locally",
/* CHANOTCO*/   "Incompatible channel id",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* NOVERLAP*/   "Overlap sending not allowed",
/* NOFACISU*/   "Requested facility not subscribed",
/* NOREVERS*/   "Reverse charging not allowed",
/* OUTBARRE*/   "Outgoing calls barred",
/* OUTBACUG*/   "Outgoing calls barred with CUG",
/* INBARRE */   "Incoming calls barred",
/* INBACUG */   "Incoming calls barred with CUG",
/* NOWAITSU*/   "Call waiting not subscribed",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* NOBEARER*/   "Bearer capability not implemented",
/* NOCHTYPE*/   "Channel type not implemented",
/* NOTRANSI*/   "Transit network selection not implement",
/* NOMESSIM*/   "Message not implemented",
/* NOFACIRE*/   "Requested facility not implemented",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* NOCREF  */   "No call reference available",
/* INVACREF*/   "Invalid call reference value",
/* NOCHANID*/   "Identified channel does not exist",
/* NOCALLID*/   "Call identity does not exist",
/* CALLIDUS*/   "Call identity in use",
/* INVDIGIT*/   "Invalid digit value for number",
/* NOCUGID */   "Non-existent closed user group",
/* NODESTCU*/   "Destination address not member of CUG",
/* INCOMDET*/   "Incompatible destination",
/* NOABBRE */   "Non-existent abbreviated address entry",
/* DESTMISS*/   "Destination address( direct call )misssing",
/* TRANSNEX*/   "Transit network does not exist",
/* IFACIPAR*/   "Invalid facility parameter",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* SPARE   */   "",
/* NOMESSTY*/   "Message type non-existent or not implement",
/* MESSCLST*/   "Message not compatible with call state",
/* NOINFELE*/   "Information element non-existent",
/* INELECON*/   "Invalid information element contents"







.c
#include "ctsk.h"
#include "co.dbse.h"

#define VINIT   0       /* verbose initially off */
sq}@~
int msgdelay = 1;       /* 1 means no delay */
int msgerrors = 1;      /* 1 means no errors */

int cocpvrb = VINIT;
int col3vrb = VINIT;
int col2avrb = VINIT;
int col2bvrb = VINIT;
int col1a1vrb = VINIT;
int col1a2vrb = VINIT;
int col1b1vrb = VINIT;

int acctme = 0;
int acctca = 0;
int acctcc = 0;
int acctcp = 0;
int acctl3 = 0;
int acctl2 = 0;
int acctl1 = 0;

/************************/
/*                      */
/*      CENTRAL OFFICE  */
/*                      */
/************************/

cocon(){
char *p,bfr[BLEN];
int  i,j,k,len;
        /* clear the screen */
        fprintf(COCON,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
        fprintf(COCON,"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");

        fprintf(COCON,"****************************************\n");
        fprintf(COCON,"****************************************\n");
        fprintf(COCON,"**                                    **\n");
        fprintf(COCON,"**  ISDN Technology Transfer Package  **\n");
        fprintf(COCON,"**           Copyright 1985           **\n");
        fprintf(COCON,"** Bell Communications Research, Inc. **\n");
        fprintf(COCON,"**                                    **\n");
        fprintf(COCON,"****************************************\n");
        fprintf(COCON,"****************************************\n\n");



        fprintf(COCON,"****************************************\n");
        fprintf(COCON,"****************************************\n");
        fprintf(COCON,"**                                    **\n");
        fprintf(COCON,"**     ISDN Exchange Emulation        **\n");
        fprintf(COCON,"**                                    **\n");
        fprintf(COCON,"****************************************\n");
        fprintf(COCON,"****************************************\n\n");
        while(1){
                if(len=string(IPCTTY,BLEN,p=bfr)){
                        if(sscanf(&p,"*stat*")){
                                fprintf(COCON,"Call Attmpts %6d\n",acctca);
                                fprintf(COCON,"Call Cmpltns %6d\n\n",acctcc);
                                fprintf(COCON,"L1 Sent/Rcvd %6d\n",acctl1);
                                fprintf(COCON,"Link Failure %6d\n\n",acctme);
                                fprintf(COCON,"L2 Processed %6d\n",acctl2);
                                fprintf(COCON,"L3 Processed %6d\n",acctl3);
                                fprintf(COCON,"CP Processed %6d\n",acctcp);
                                fprintf(COCON,"All L2+L3+CP %6d\n\n",acctl2+acctl3+cctcp);
                                if(sscanf(&p,"*clr*")){
                                        acctme = 0;
                                        acctca = 0;
                                        acctcc = 0;
                                        acctcp = 0;
                                        acctcp = 0;
                                        acctl3 = 0;
                                        acctl2 = 0;
                                        acctl1 = 0;
                                        fprintf(COCON,"Cleared\n");
                                }
                        }
                        else if(sscanf(&p,"*vrb*")){
                                cocpvrb = 0;
                                col3vrb = 0;
                                col2avrb = 0;
                                col2bvrb = 0;
                                col1a1vrb = 0;
                                col1a2vrb = 0;
                                col1b1vrb = 0;
                                while(*p){
                                        if(sscanf(&p,"*cp*"))
                                                cocpvrb = 1;
                                        else if(sscanf(&p,"*l3*"))
                                                col3vrb = 1;
                                        else if(sscanf(&p,"*l2*"))
                                                col2avrb=col2bvrb = 1;
                                        else if(sscanf(&p,"*l1*"))
                                                col1a1vrb=col1a2vrb=col1b1vrb=1;
                                        else
                                                while((*p)&&(*p!=' '))
                                                        ++p;
                                }
                        }
                        else if(sscanf(&p,"*delay*",&i)){
                                if(sscanf(&p,"*on*",&i))
                                        msgdelay = 0;
                                else if(sscanf(&p,"*off*",&i))
                                        msgdelay = 1;
                                if(msgdelay == 0)
                                        fprintf(COCON,"Line delay on\n\n");
                                else
                                        fprintf(COCON,"Line delay off\n\n");
                        }
                        else if(sscanf(&p,"*err*",&i)){
                                if(sscanf(&p,"*on*",&i))
                                        msgerrors = 0;
                                else if(sscanf(&p,"*off*",&i))
                                        msgerrors = 1;
                                if(msgerrors == 0)
                                        fprintf(COCON,"Line errors on\n\n");
                                else
                                        fprintf(COCON,"Line errors off\n\n");
                        }
                        /* print out stack area sizes for all process id */
                        else if(sscanf(&p,"*stk*",&i)){
                                dmpstk(COCON);
                        }
                        /* send a message to the MSP */
                        else if(sscanf(&p,"*msp*",&i)){
                                fprintf(COPRPH,"%s",p);
                        }
                        else if(sscanf(&p,"*admin*",&i)){
                                fprintf(COPRPH,"AD START",p);
                                fprintf(COPRPH,"AD CHTG",p);
                                fprintf(COPRPH,"AD GLOC",p);
                                fprintf(COPRPH,"AD 0050",p);
                                fprintf(COPRPH,"AD DEL",p);
                                fprintf(COPRPH,"AD WNKI",p);
                                fprintf(COPRPH,"AD",p);
                                fprintf(COPRPH,"AD CHTG",p);
                                fprintf(COPRPH,"AD GLOC",p);
                                fprintf(COPRPH,"AD 0050",p);
                                fprintf(COPRPH,"AD DEL",p);
                                fprintf(COPRPH,"AD WNKO",p);
                                fprintf(COPRPH,"AD",p);
                                fprintf(COPRPH,"AD END",p);
                        }
                        /* printout the call records */
                        else if(sscanf(&p,"*cr*",&i)){
                                if(sscanf(&p,"%d*",&i))
                                        dpcallrec(i);
                                else{
                                        if(ncallrecs)
                                                for(i=0;i<ncallrecs;++i)
                                                        dpcallrec(sort[i]);
                                        else
                                                fprintf(COCON,"No calls\n");
                                }
                                fprintf(COCON,"\n");
                        }
                        /* print out the directory records */
                        else if(sscanf(&p,"*dr*",&i)){
                                if(sscanf(&p,"%d*",&i))
                                        dpdnrec(i);
                                else{
                                        if(ndnrecs)
                                                for(i=0;i<ndnrecs;++i)
                                                        dpdnrec(i);
                                        else
                                                fprintf(COCON,"No directory numbers\n");
                                }
                                fprintf(COCON,"\n");
                        }
                        /* print out the line records */
                        else if(sscanf(&p,"*lr*",&i)){
                                if(sscanf(&p,"%d*",&i))
                                        dplinerec(i);
                                else{
                                        if(nlinerecs)
                                                for(i=0;i<nlinerecs;++i)
                                                        dplinerec(i);
                                        else
                                                fprintf(COCON,"No lines\n");
                                }
                                fprintf(COCON,"\n");
                        }
                        /* print out the MSP port records */
                        else if(sscanf(&p,"*pr*",&i)){
                                for(i=0;i<nportrecs;++i){
                                        fprintf(COCON,"(M%d,",portrec[i].module);
                                        fprintf(COCON,"L%d,",portrec[i].line);
                                        fprintf(COCON,"B%d)",portrec[i].bch);
                                        fprintf(COCON,"[%04x]\n",portrec[i].port);
                                }
                                fprintf(COCON,"\n");
                        }
                        /* print out the suspended records */
                        else if(sscanf(&p,"*sr*",&i)){
                                if(sscanf(&p,"%d*",&i))
                                        dpsuscall(i);
                                else{
                                        if(nsuscalls)
                                                for(i=0;i<nsuscalls;++i)
                                                        dpsuscall(i);
                                        else
                                                fprintf(COCON,"No suspended calls\n");
                                }
                                fprintf(COCON,"\n");
                        }
                        else if(sscanf(&p,"*hlp*",&i)){
                                fprintf(COCON,"Command syntax:\n");
                                fprintf(COCON,"    cr [#]\n");
                                fprintf(COCON,"    dr [#]\n");
                                fprintf(COCON,"    sr [#]\n");
                                fprintf(COCON,"    lr [#]\n");
                                fprintf(COCON,"    pr\n");
                                fprintf(COCON,"    msp cmnd\n");
                                fprintf(COCON,"    stk\n");
                                fprintf(COCON,"    err [on/off]\n");
                                fprintf(COCON,"    delay [on/off]\n");
                                fprintf(COCON,"\n");
                        }
                        else
                                fprintf(COCON,"???\n");
                }
                sleep();
        }






#include "verbose.h"

#if     VRBCP
#define LX      if(cocpvrb){
#define RX      }
#else
#define LX      /X*     
#define RX      *X/
#define X
#endif

#include "ctsk.h"
#include "co.dbse.h"
#include "co.fcns.h"

extern  int  cocpvrb;

#define NOBCH           -1
#define NTANYCH         -2

/* MSG DEF BETWEEN L3 AND CALL PROCESSOR */
#define NTSETUP     0x01    /* Network SETUP       */
#define NTALERT     0x02    /* Network ALERTING    */
#define NTCONNE     0x03    /* Network CONNECT     */
#define NTCONACK    0x04    /* Network CONNECT ACK */
#define NTRLCOMP    0x05    /* Network RELEASE COMP*/
#define NTCLEAR     0x06    /* Network CLEAR       */
#define NTRELEASE   0x07    /* Network RELEASE     */
#define NTDETACH    0x08    /* Network DETACH      */
#define NTSUSPEN    0x09    /* Network SUSPEND     */
#define NTSUSACK    0x0a    /* Network SUSPEND ACK */
#define NTSUSREJ    0x0b    /* Network SUSPEND REJ */
#define NTRESUME    0x0c    /* Network RESUME      */
#define NTRESACK    0x0d    /* Network RESUME ACK  */
#define NTRESREJ    0x0e    /* Network RESUME REJ  */
#define NTUSINFO    0x0f    /* Network USERINFO    */
#define NTSTATUS    0x10    /* Network STATUS      */
#define NTFACI      0x11    /* Network FACILITY    */
#define NTFACIAK    0x12    /* Network FACILITY ACK*/
#define NTFACIRJ    0x13    /* Network FACILITY REJ*/

/* CAUSE FOR TERMINATION */
#define LOCUSER     0x00    /* user side                   */
#define LOCLNET     0x02    /* location at local network   */
#define NORMTR      0x10    /* normal call termination     */
#define NODESTOB    0x23    /* no dir number exists        */
#define NETCONG     0x2a    /* database is full            */
#define NOCREF      0x50    /* no callref available        */
#define IFACIPAR    0x5c    /* invalid facility parameter  */
#define ORIFRAUD    0x0f    /* security check fails        */
#define RESFAIL     0x1f    /* restriction code fails on outgoing calls */

/* MSG DEF BETWEEN CALL PROCESSOR AND MSP */
#define MSP_DISC    0x00    /* disconnect message to MSP   */
#define MSP_CONN    0x01    /* connect message to MSP      */

/* STATE DEF FOR CALL PROCESSOR */
#define NULL        0x00    /* NULL STATE          */   
#define SETUP       0x01    /* SETUP STATE         */
#define ALERT       0x02    /* ALERT STATE         */
#define CONNECT     0x03    /* CONNECT STATE       */
#define CLEAR       0x04    /* CLEAR STATE         */
#define FINAL       0x05    /* FINAL STATE         */
#define SUSPEND     0x06    /* SUSPEND STATE       */

char *cpstname[7] = { 
        "NULL   ",
        "SETUP  ",
        "ALERT  ",
        "CONNECT",
        "CLEAR  ",
        "FINAL  ",
        "SUSPEND"};


char *l3msgname[20]= {
        "","SETUP","ALERT","CONNECT",
        "CONNECT ACK","RELEASE COMP","CLEAR","RELEASE","DETACH",
        "SUSPEND","SUSPEND ACK","SUSPEND REJ","RESUME",
        "RESUME ACK","RESUME REJ","USERINFO","STATUS",
        "FACILITY","FACILITY ACK","FACILITY REJ"};

char *mspmsgname[2]={
        "DISCONNECT","CONNECT"};

send_l3(cm,i,l,ca,u)
int  i;
char cm,l,ca,*u;
{
        char *p;
        struct{
                char cmnd;
                int  index;
                char location;
                char causeval;
                char usinform[128];
        }
        msg;
        msg.cmnd= cm;
        msg.index= i;
        msg.location= l;
        msg.causeval= ca;
        p= msg.usinform;
        while(*p++ = *u++);
        put(COL3,sizeof(msg),&msg);
LX      fprintf(COCON,"%s indication to ",l3msgname[msg.cmnd]); RX
LX      fprintf(COCON,"L3 [%d]\n",i);   RX
}

send_msp(c,i,j)
int i,j;
char c;
{
        struct{
                char cmnd;
                int  module[2];
                int  line[2];
                int  bch[2];
                int  type;
        }
        msg;
        msg.cmnd=c;
        msg.module[0] = callrec[i].module;
        msg.module[1] = callrec[j].module;
        msg.line[0] = callrec[i].line;
        msg.line[1] = callrec[j].line;
        msg.bch[0] = callrec[i].bch;
        msg.bch[1] = callrec[j].bch;
        msg.type = callrec[i].bcap[1]&0x1f;
        put(COPRPH,sizeof(msg),&msg);
LX      fprintf(COCON,"%s indication to MSP\n",mspmsgname[msg.cmnd]);   RX
}

#define TEION   0

cocp(){
        int i,j,k,x,len;
        int bfr[BLEN];
        struct{
                char cmnd;
                int index;
                char loca;
                char caus;
                char usinf[128];
        }
        l3msg;
        while(1){
                while(len=get(COL3,sizeof(l3msg),&l3msg)){
LX                      fprintf(COCON,"CP: ");  RX
LX                      dpcallrec(l3msg.index); RX
LX                      fprintf(COCON,"STATE: %s\n",cpstname[callrec[l3msg.index].cpstate]);    RX
                        switch(callrec[i=l3msg.index].cpstate){
                        case NULL:
                                switch(l3msg.cmnd){
                                case NTSETUP:
LX                                      fprintf(COCON,"SETUP request from L3\n");       RX
                                        if(!sec_check(i)){ /* security check on the calling directory number  */
LX                                              fprintf(COCON,"Security validation fails (");   RX
LX                                              fprintf(COCON,"M%d,",callrec[i].module);        RX
LX                                              fprintf(COCON,"L%d,",callrec[i].line);  RX
LX                                              fprintf(COCON,"T%d,",callrec[i].tei);   RX
LX                                              fprintf(COCON,"S%d,",callrec[i].sapi);  RX
LX                                              fprintf(COCON,"%s)\n",callrec[i].dn);   RX
                                                send_l3(NTRELEASE,i,LOCLNET,ORIFRAUD,"");
                                                callrec[i].cpstate=FINAL;
LX                                              fprintf(COCON,"NEXT STATE: FINAL\n\n"); RX
                                                break;
                                        }
LX                                      fprintf(COCON,"Calling dn: %s is validated\n",callrec[i].dn);   RX
                                        switch(j=link(i)){
                                        case DB_FULL:
                                                send_l3(NTRELEASE,i,LOCLNET,NETCONG,"");
                                                callrec[i].cpstate=FINAL;
LX                                              fprintf(COCON,"NEXT STATE: FINAL\n\n"); RX
                                                break;
                                        case NO_CREF:
                                                send_l3(NTRELEASE,i,LOCLNET,NOCREF,"");
                                                callrec[i].cpstate=FINAL;
LX                                              fprintf(COCON,"NEXT STATE: FINAL\n\n"); RX
                                                break;
                                        case NO_DIR:
                                                send_l3(NTRELEASE,i,LOCLNET,NODESTOB,"");
                                                callrec[i].cpstate=FINAL;
LX                                              fprintf(COCON,"NEXT STATE: FINAL\n\n"); RX
                                                break;
                                        case LINE_RES:
                                                send_l3(NTRELEASE,i,LOCLNET,RESFAIL,"");
                                                callrec[i].cpstate=FINAL;
LX                                              fprintf(COCON,"NEXT STATE: FINAL\n\n"); RX
                                                break;
                                        default:
                                                if(callrec[i].bch == NOBCH)
                                                        callrec[j].bch = NOBCH;
                                                send_l3(NTSETUP,j,l3msg.loca,l3msg.caus,l3msg.usinf);
                                                callrec[i].cpstate=callrec[j].cpstate=SETUP;
LX                                              fprintf(COCON,"NEXT STATE: SETUP\n\n"); RX
                                                break;
                                        } /* end of the switch on j */
                                        break; /* end of case NTSETUP */
                                case NTFACI:
LX                                      fprintf(COCON,"FACILITY request from L3\n");    RX
LX                                      fprintf(COCON,"Passwd Check: %s\n",&l3msg.usinf[1]);    RX
                                        if((j=lopasswd(callrec[i].dn,callrec[i].sapi,&l3msg.usinf[1])) >= 0){
LX                                              fprintf(COCON,"Password validation succeeds\n",i);      RX
                                                dnrec[j].module=callrec[i].module;
                                                dnrec[j].line=callrec[i].line;
                                                if(dnrec[j].tei != 127)
                                                        dnrec[j].tei=callrec[i].tei;
                                                dnrec[j].rscode=l3msg.usinf[0];
                                                send_l3(NTFACIAK,i,NULL,NULL,"");
LX                                              fprintf(COCON,"NEXT STATE: NULL\n\n");  RX
                                                break;
                                        }
LX                                      fprintf(COCON,"WARNING: Password validation fails\n",i);        RX
                                        send_l3(NTFACIRJ,i,LOCUSER,IFACIPAR,"");
LX                                      fprintf(COCON,"NEXT STATE: NULL\n\n");  RX
                                        break; /* end of case NTFACI */
                                case NTRLCOMP:
LX                                      fprintf(COCON,"RELEASE COMP request from L3\n");        RX
                                        if((j=callrec[i].link) != IDLE){
                                                if(callrec[j].link==i){
                                                        send_l3(NTRELEASE,j,l3msg.loca,l3msg.caus,l3msg.usinf);
                                                        callrec[j].link= IDLE;
                                                        callrec[j].cpstate=FINAL;
                                                }
                                        }
                                        callrec[i].cpstate = NULL;
                                        callrec[i].link = IDLE;
LX                                      fprintf(COCON,"NEXT STATE: NULL\n");    RX
                                        delete(i);
LX                                      fprintf(COCON,"Deallocate Call Record (%d)\n\n",i);     RX
                                        break;
                                case NTALERT:
LX                                      fprintf(COCON,"ALERT request from L3\n");       RX
                                        if((j=search_callrec(callrec[i].module,callrec[i].line,callrec[i].sapi,callrec[i].callref,127,TEION))>=0){
                                                j = sort[j];
                                                callrec[i].bch=callrec[j].bch;
                                                for(k=0;k<=(callrec[j].bcap[0]&255);++k)
                                                        callrec[i].bcap[k]=callrec[j].bcap[k];
                                                for(k=0;k<=(callrec[j].lowcomp[0]&255);++k)
                                                        callrec[i].lowcomp[k]=callrec[j].lowcomp[k];
                                                for(k=0;k<NUM_DIG;k++){
                                                        callrec[i].lnkdn[k]=callrec[j].lnkdn[k];
                                                        callrec[i].dn[k]=callrec[j].dn[k];
                                                }
                                                k=callrec[i].link=callrec[j].link;
                                                if(callrec[j].cpstate == SETUP){
                                                        send_l3(NTALERT,k,l3msg.loca,l3msg.caus,l3msg.usinf);
                                                        callrec[k].cpstate=callrec[j].cpstate=ALERT;
                                                }
                                                callrec[i].cpstate=ALERT;
LX                                              fprintf(COCON,"NEXT STATE: ALERT\n\n"); RX
                                                break;
                                        }
                                        send_l3(NTRELEASE,i,LOCLNET,NORMTR,"");
                                        callrec[i].cpstate=FINAL;
                                        callrec[i].link = IDLE;
LX                                      fprintf(COCON,"NEXT STATE: FINAL\n\n"); RX
                                        break;
                                case NTCONNE:
LX                                      fprintf(COCON,"CONNECT request from L3\n");     RX
                                        if((j=search_callrec(callrec[i].module,callrec[i].line,callrec[i].sapi,callrec[i].callref,127,TEION))>=0){
                                                callrec[i].bch=callrec[j=sort[j]].bch;
                                                for(k=0;k<=(callrec[j].bcap[0]&255);++k)
                                                        callrec[i].bcap[k]=callrec[j].bcap[k];
                                                for(k=0;k<=(callrec[j].lowcomp[0]&255);++k)
                                                        callrec[i].lowcomp[k]=callrec[j].lowcomp[k];
                                                for(k=0;k<NUM_DIG;k++){
                                                        callrec[i].lnkdn[k]=callrec[j].lnkdn[k];
                                                        callrec[i].dn[k]=callrec[j].dn[k];
                                                }
                                                k=callrec[i].link=callrec[j].link;
                                                callrec[k].link = i;
                                                send_l3(NTCONACK,i,l3msg.loca,l3msg.caus,l3msg.usinf);
                                                send_l3(NTCONNE,k,l3msg.loca,l3msg.caus,l3msg.usinf);
                                                if(callrec[i].bch != NOBCH)
                                                        send_msp(MSP_CONN,i,j);
                                                delete(j);
LX                                              fprintf(COCON,"Deallocate Call Record (%d)\n",j);       RX
                                                callrec[i].cpstate=callrec[k].cpstate=CONNECT;
LX                                              fprintf(COCON,"NEXT STATE: CONNECT\n\n");       RX
                                                break;
                                        }
                                        send_l3(NTRELEASE,i,LOCLNET,NORMTR,l3msg.usinf);
                                        callrec[i].cpstate=FINAL;
                                        callrec[i].link = IDLE;
LX                                      fprintf(COCON,"NEXT STATE: FINAL\n\n"); RX
                                        break;
                                default:
                                        fprintf(COCON,"ERROR: Unexpected %s msg from L3 (ignored)\n\n",l3msgname[l3msg.cmnd]);
                                        break;
                                } /* end of the switch on l3msg.cmnd */
                                break; /* end of case NULL */
                        case SETUP:
                                switch(l3msg.cmnd){
                                case  NTCONNE:
LX                                      fprintf(COCON,"CONNECT request from L3\n");     RX
                                        send_l3(NTCONACK,i,l3msg.loca,l3msg.caus,l3msg.usinf);
                                        send_l3(NTCONNE,j=callrec[i].link,l3msg.loca,l3msg.caus,l3msg.usinf);
                                        callrec[j].link = i;
                                        if(callrec[i].bch != NOBCH)
                                                send_msp(MSP_CONN,i,j);
                                        for(j=0;j<127;++j)
                                                if(j!=callrec[i].tei)
                                                        if((k=search_callrec(callrec[i].module,callrec[i].line,callrec[i].sapi,callrec[i].callref,j,TEION))>=0){
                                                                send_l3(NTRELEASE,k=sort[k],LOCLNET,NORMTR,l3msg.usinf);
                                                                callrec[k].cpstate=FINAL;