-#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);
-}
-#endif // stacktomanager
-
-/* 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);
-}
-
-
-/*
- * 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 message *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;
- }
-}