- mISDNport = mISDNport_first;
- port = NULL;
- while(mISDNport)
- {
- /* check for external or given interface */
- if (((!e_dialinginfo.interfaces[0])&&mISDNport->iftype==IF_EXTERN) || !strcmp(mISDNport->interface_name, e_dialinginfo.interfaces))
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d) interface '%s' found\n", ea_endpoint->ep_serial, mISDNport->interface_name);
- cause = CAUSE_NOCHANNEL; /* when failing: out of channels */
- /* if PTP, skip all down links */
- if (mISDNport->ptp && !mISDNport->l2link)
- {
- trace_header("INTERFACE (layer 2 is down)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- mISDNport = mISDNport->next;
- continue;
- }
- /* if no channel is available */
- if (mISDNport->multilink || !mISDNport->ntmode || mISDNport->ptp)
- {
- use = 0;
- i = 0;
- ii = mISDNport->b_num;
- while(i < ii)
- {
- if (mISDNport->b_state[i])
- use++;
- i++;
- }
- if (use >= mISDNport->b_num)
- {
- trace_header("INTERFACE (no free channel)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- mISDNport = mISDNport->next;
- continue;
- }
- }
- /* found interface */
- trace_header("INTERFACE (found)", DIRECTION_NONE);
- add_trace("interface", NULL, "%s", mISDNport->interface_name);
- end_trace();
- break;
- }
- mISDNport = mISDNport->next;
- }