- PERROR("unhandled message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, msg->len);
- 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_NT_IN, mISDNport, name, NULL, 0, 0)))
- {
- RELEASE_COMPLETE_t *release_complete;
- msg_t *dmsg;
-
- PERROR("FATAL ERROR: cannot create port object.\n");
- dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, frm->dinfo, sizeof(RELEASE_COMPLETE_t), mISDNport->ntmode);
- release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + mISDN_HEADER_LEN);
- l1l2l3_trace_header(mISDNport, NULL, CC_RELEASE_COMPLETE | REQUEST, DIRECTION_OUT);
- enc_ie_cause_standalone(mISDNport->ntmode?&release_complete->CAUSE:NULL, dmsg, (mISDNport->ntmode)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
- end_trace();
- msg_queue_tail(&mISDNport->downqueue, dmsg);
- free_msg(msg);
- return(0);
- }
- /* 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))
- {
- PERROR("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;
- }
- }