-#else
-/* NOTE: nt mode use mISDNuser_head_t as header */
-int stack2manager_nt(void *dat, void *arg)
-{
- class Port *port;
- class Pdss1 *pdss1;
- manager_t *mgr = (manager_t *)dat;
- msg_t *msg = (msg_t *)arg;
- mISDNuser_head_t *hh;
- struct mISDNport *mISDNport;
- char name[32];
-
- if (!msg || !mgr)
- return(-EINVAL);
-
- /* note: nst is the first data feld of mISDNport */
- mISDNport = (struct mISDNport *)mgr->nst;
-
- hh = (mISDNuser_head_t *)msg->data;
- PDEBUG(DEBUG_ISDN, "prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, msg->len);
-
- /* find Port object of type ISDN */
- port = port_first;
- while(port)
- {
- if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
- {
- pdss1 = (class Pdss1 *)port;
-//PDEBUG(DEBUG_ISDN, "comparing dinfo = 0x%x with l3id 0x%x\n", hh->dinfo, pdss1->p_m_d_l3id);
- /* check out correct stack */
- if (pdss1->p_m_mISDNport == mISDNport)
- /* check out correct id */
- if ((pdss1->p_m_d_l3id&0x0000ff00) != 0x000ff00)
- {
- /* a single process */
- if (hh->dinfo == pdss1->p_m_d_l3id)
- {
- /* found port, the message belongs to */
- break;
- }
- } else
- {
- /* a broadcast process */
- if ((hh->dinfo&0xffff0000) == (pdss1->p_m_d_l3id&0xffff0000))
- {
- /* found port, the message belongs to */
- break;
- }
- }
- }
- port = port->next;
- }
- if (port)
- {
-//printf("%x %x\n", hh->dinfo, pdss1->p_m_d_l3id);
- /* if process id is master process, but a child disconnects */
- if ((hh->dinfo&0x0000ff00)!=0x0000ff00 && (pdss1->p_m_d_l3id&0x0000ff00)==0x0000ff00)
- {
- if (hh->prim == (CC_DISCONNECT|INDICATION))
- {
- /* send special indication for child disconnect */
- pdss1->disconnect_ind_i(hh->prim, hh->dinfo, msg->data);
- free_msg(msg);
- return(0);
- }
- // ignoring other messages from child processes
- free_msg(msg);
- return(0);
- }
- /* if process id and layer 3 id matches */
- if (hh->dinfo == pdss1->p_m_d_l3id)
- {
- pdss1->message_isdn(hh->prim, hh->dinfo, msg->data);
- free_msg(msg);
- return(0);
- }
- }
-
- /* d-message */
- switch(hh->prim)
- {
- case MGR_SHORTSTATUS | INDICATION:
- case MGR_SHORTSTATUS | CONFIRM:
- switch(hh->dinfo) {
- case SSTATUS_L2_ESTABLISHED:
- goto ss_estab;
- case SSTATUS_L2_RELEASED:
- goto ss_rel;
- }
- break;
-
- case DL_ESTABLISH | INDICATION:
- l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN);
- goto ss_estab;
- case DL_ESTABLISH | CONFIRM:
- l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_CON, DIRECTION_IN);
- ss_estab:
- add_trace("tei", NULL, "%d", hh->dinfo);
- end_trace();
- if (mISDNport->ptp && hh->dinfo == 0)
- {
- if (mISDNport->l2establish)
- {
- mISDNport->l2establish = 0;
- PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n");
- }
- mISDNport->l2link = 1;
- if (mISDNport->pri);
- mISDNport->l1link = 1; /* this is a hack, we also assume L1 to be active */
- }
- break;
-
- case DL_RELEASE | INDICATION:
- l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN);
- goto ss_rel;
- case DL_RELEASE | CONFIRM:
- l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_CON, DIRECTION_IN);
- ss_rel:
- add_trace("tei", NULL, "%d", hh->dinfo);
- end_trace();
- if (mISDNport->ptp && hh->dinfo == 0)
- {
- mISDNport->l2link = 0;
- time(&mISDNport->l2establish);
- PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n");
- }
- break;
-
- case CC_SETUP | INDICATION:
- /* creating port object */
- SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
- if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
-
- FATAL("Cannot create Port instance.\n");
- pdss1->message_isdn(hh->prim, hh->dinfo, msg->data);
- break;
-
- case CC_RESUME | INDICATION:
- /* creating port object */
- SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
- if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
- FATAL("Cannot create Port instance.\n");
- pdss1->message_isdn(hh->prim, hh->dinfo, msg->data);
- break;
-
- case CC_RELEASE_CR | INDICATION:
- PERROR("unhandled message from stack: call ref released (l3id=0x%x)\n", hh->dinfo);
- break;
-
- case CC_RELEASE_COMPLETE | INDICATION:
- break;
-
- case CC_FACILITY | INDICATION:
- break;
-
- default:
- PERROR("unhandled message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, msg->len);
- port = port_first;
- while(port)
- {
- if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
- {
- pdss1 = (class Pdss1 *)port;
- //PDEBUG(DEBUG_ISDN, "comparing dinfo = 0x%x with l3id 0x%x\n", hh->dinfo, pdss1->p_m_d_l3id);
- /* check out correct stack */
- if (pdss1->p_m_mISDNport == mISDNport)
- /* check out correct id */
- PERROR("unhandled message: dinfo=%x is not associated with port-dinfo=%x\n",hh->dinfo,pdss1->p_m_d_l3id);
- }
- port = port->next;
- }
- return(-EINVAL);
- }
- free_msg(msg);
- return(0);
-}
-
-/* NOTE: te mode use iframe_t as header */
-int stack2manager_te(struct mISDNport *mISDNport, msg_t *msg)
-{
- class Port *port;
- class Pdss1 *pdss1;
- iframe_t *frm;
- char name[32];
-
- if (!msg || !mISDNport)
- return(-EINVAL);
- frm = (iframe_t *)msg->data;
- PDEBUG(DEBUG_ISDN, "prim(0x%x) dinfo(0x%x) msg->len(%d)\n", frm->prim, frm->dinfo, msg->len);
-
- /* find Port object of type ISDN */
- port = port_first;
- while(port)
- {
- if (port->p_type == PORT_TYPE_DSS1_TE_IN || port->p_type == PORT_TYPE_DSS1_TE_OUT)
- {
- pdss1 = (class Pdss1 *)port;
- /* check out correct stack */
- if (pdss1->p_m_mISDNport == mISDNport)
- /* check out correct id */
- if (frm->dinfo == pdss1->p_m_d_l3id)
- {
- /* found port, the message belongs to */
- break;
- }
- }
- port = port->next;
- }
- if (port)
- {
- pdss1->message_isdn(frm->prim, frm->dinfo, msg->data);
- free_msg(msg);
- return(0);
- }
-
- /* process new cr (before setup indication) */
-//printf("prim = 0x%x, looking for 0x%x\n",frm->prim, (CC_NEW_CR | INDICATION));
- if (frm->prim == (CC_NEW_CR | INDICATION))
- {
-
- /* creating port object */
- SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
- if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_TE_IN, mISDNport, name, NULL, 0, 0)))
- FATAL("Cannot create Port instance.\n");
- /* l3id will be set from dinfo at message_isdn */
- pdss1->message_isdn(frm->prim, frm->dinfo, msg->data);
- free_msg(msg);
- return(0);
- }
-
- if (frm->prim == (CC_RELEASE_CR | INDICATION))
- {
- PDEBUG(DEBUG_ISDN, "unhandled message from stack: call ref released (l3id=0x%x)\n", frm->dinfo);
- free_msg(msg);
- return(0);
- }
- PERROR("unhandled message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", frm->prim, frm->dinfo, msg->len);
- return(-EINVAL);
-}
-
-#endif // stacktomanager