-static msg_t *create_l3msg(int prim, int mt, int dinfo, int size, int ntmode)
-{
- int i = 0;
- msg_t *dmsg;
- Q931_info_t *qi;
- iframe_t *frm;
-
- if (!ntmode)
- size = sizeof(Q931_info_t)+2;
-
- while(i < 10)
- {
- if (ntmode)
- {
- dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL);
- if (dmsg)
- {
- return(dmsg);
- }
- } else
- {
- dmsg = alloc_msg(size+256+mISDN_HEADER_LEN+DEFAULT_HEADROOM);
- if (dmsg)
- {
- memset(msg_put(dmsg,size+mISDN_HEADER_LEN), 0, size+mISDN_HEADER_LEN);
- frm = (iframe_t *)dmsg->data;
- frm->prim = prim;
- frm->dinfo = dinfo;
- qi = (Q931_info_t *)(dmsg->data + mISDN_HEADER_LEN);
- qi->type = mt;
- return(dmsg);
- }
- }
-
- if (!i)
- PERROR("cannot allocate memory, trying again...\n");
- i++;
- usleep(50000);
- }
- PERROR("cannot allocate memory, system overloaded.\n");
- exit(-1);
-}
-
-msg_t *create_l2msg(int prim, int dinfo, int size) /* NT only */
-{
- int i = 0;
- msg_t *dmsg;
-
- while(i < 10)
- {
- dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL);
- if (dmsg)
- return(dmsg);
-
- if (!i)
- PERROR("cannot allocate memory, trying again...\n");
- i++;
- usleep(50000);
- }
- PERROR("cannot allocate memory, system overloaded.\n");
- exit(-1);
-}
-
-/* isdn messaging */
-static struct isdn_message {
- char *name;
- unsigned long value;
-} isdn_message[] = {
- {"TIMEOUT", CC_TIMEOUT},
- {"SETUP", CC_SETUP},
- {"SETUP_ACK", CC_SETUP_ACKNOWLEDGE},
- {"PROCEEDING", CC_PROCEEDING},
- {"ALERTING", CC_ALERTING},
- {"CONNECT", CC_CONNECT},
- {"CONNECT RES", CC_CONNECT},
- {"CONNECT_ACK", CC_CONNECT_ACKNOWLEDGE},
- {"DISCONNECT", CC_DISCONNECT},
- {"RELEASE", CC_RELEASE},
- {"RELEASE_COMP", CC_RELEASE_COMPLETE},
- {"INFORMATION", CC_INFORMATION},
- {"PROGRESS", CC_PROGRESS},
- {"NOTIFY", CC_NOTIFY},
- {"SUSPEND", CC_SUSPEND},
- {"SUSPEND_ACK", CC_SUSPEND_ACKNOWLEDGE},
- {"SUSPEND_REJ", CC_SUSPEND_REJECT},
- {"RESUME", CC_RESUME},
- {"RESUME_ACK", CC_RESUME_ACKNOWLEDGE},
- {"RESUME_REJ", CC_RESUME_REJECT},
- {"HOLD", CC_HOLD},
- {"HOLD_ACK", CC_HOLD_ACKNOWLEDGE},
- {"HOLD_REJ", CC_HOLD_REJECT},
- {"RETRIEVE", CC_RETRIEVE},
- {"RETRIEVE_ACK", CC_RETRIEVE_ACKNOWLEDGE},
- {"RETRIEVE_REJ", CC_RETRIEVE_REJECT},
- {"FACILITY", CC_FACILITY},
- {"STATUS", CC_STATUS},
- {"RESTART", CC_RESTART},
- {"RELEASE_CR", CC_RELEASE_CR},
- {"NEW_CR", CC_NEW_CR},
- {"DL_ESTABLSIH", DL_ESTABLSIH},
- {"DL_RELEASE", DL_RELEASE},
- {"PH_ACTICATIE", PH_ACTICATIE},
- {"PH_DEACTICATIE", PH_DEACTICATIE},
-
- {NULL, 0},
-};
-
-static char *isdn_prim[4] = {
- " REQUEST",
- " CONFIRM",
- " INDICATION",
- " RESPONSE",
-};
-
-
-/*
- * isdn trace header
- */
-void Pdss1::l1l2l3_trace_header(unsigned long prim, int direction_out)
-{
- int i;
- char msgtext[64] = "<<UNKNOWN MESSAGE>>";
-
- /* select message and primitive text */
- i = 0;
- while(isdn_message[i].name)
- {
- if (isdn_message[i].value == (prim&0xffffff00))
- {
- SCPY(msgtext, isdn_message[i].name);
- break;
- }
- i++;
- }
- SCAT(msgtext, isdn_prim[prim&0x00000003]);
-
- /* add direction */
- if (direction && (prim&0xffffff00)!=CC_NEW_CR && (prim&0xffffff00)!=CC_RELEASE_CR)
- {
- if (p_m_ntmode)
- {
- if (direction == DIRECTION_OUT)
- SCAT(msgtext, " N->U");
- else
- SCAT(msgtext, " N<-U");
- } else
- {
- if (direction == DIRECTION_OUT)
- SCAT(msgtext, " U->N");
- else
- SCAT(msgtext, " U<-N");
- }
- }
-
- /* init trace with given values */
- start_trace(p_m_mISDNport->portnum,
- p_m_mISDNport->ifport->interface,
- nationalize(p_callerinfo.id, p_callerinfo.ntype),
- p_dialinginfo.number,
- direction,
- CATEGORY_L3,
- p_serial,
- msgtext);
-}
-
-
-void Pdss1::chan_trace_header(char *msgtext)