- /* channel_id */ jolly todo
- dec_ie_channel_id(setup->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
- if (exclusive<0)
- exclusive = 0;
- if (channel==CHANNEL_NO && p_type==PORT_TYPE_DSS1_TE_IN)
- PDEBUG(DEBUG_BCHANNEL, "- no channel is given by the network, causing to fail, since CW is not possible for external lines\n");
- if (channel <= 0) /* not given, no channel, whatever.. */
- channel = CHANNEL_ANY; /* any channel */
- if (channel == CHANNE_ANY)
- {
- PDEBUG(DEBUG_BCHANNEL, "- any channel is assumed from the %s, so we need to return the a channel from our list\n", (p_m_d_ntmode)?"user":"network");
- /* check for any channel form selection list */
- channel = 0;
- selchannel = ifport->channel_in;
- while(selchannel)
- {
- switch(selchannel->channel)
- {
- case CHANNEL_FREE: /* free channel */
- if (mISDNport->b_inuse >= mISDNport->b_num)
- break; /* all channel in use or reserverd */
- /* find channel */
- i = 0;
- while(i < mISDNport->b_num)
- {
- if (mISDNport->b_port[i] == NULL)
- {
- channel = i+1+(i>=15);
- //printlog("%3d port#%d position %d selecting free channel %d\n", ea_endpoint->ep_serial, ifport_start->portnum, index, *channel);
- break;
- }
- i++;
- }
- break;
-
- default:
- if (selchannel->channel<1 || selchannel->channel==16)
- break; /* invalid channels */
- i = selchannel->channel-1-(selchannel->channel>=17);
- if (i >= mISDNport->b_num)
- break; /* channel not in port */
- if (mISDNport->b_port[i] == NULL)
- {
- channel = selchannel->channel;
- //printlog("%3d port#%d position %d selecting given channel %d\n", ea_endpoint->ep_serial, ifport_start->portnum, index, *channel);
- break;
- }
- break;
- }
- if (channel)
- break; /* found channel */
- //printlog("%3d port#%d position %d skipping, because no channel found.\n", ea_endpoint->ep_serial, ifport_start->portnum, index);
- selchannel = selchannel->next;
- }
- if (!channel)
- {
- ret = -34; // no channel
- goto no_channel;
- }
- }
- if (channel > 0)
- /* check for given channel in selection list */
- selchannel = ifport->channel_in;
- while(selchannel)
- {
- if (selchannel->channel == channel || selchannel->channel == CHANNEL_FREE)
- break;
- //printlog("%3d port#%d position %d skipping, because no channel found.\n", ea_endpoint->ep_serial, ifport_start->portnum, index);
- selchannel = selchannel->next;
- }
- if (!selchannel)
- channel = 0;
-
- if (exclusive)
- {
- if (!channel)
- {
- PDEBUG(DEBUG_BCHANNEL, "- exclusive channel %d is selected, but not in list of incomming channel.\n", channel);
- ret = 6; // unacceptable
- goto no_channel;
- }
- PDEBUG(DEBUG_BCHANNEL, "- exclusive channel %d is selected, as in list of incomming channels.\n", channel);
- } else
- if (channel)
- {
- PDEBUG(DEBUG_BCHANNEL, "- channel %d given, found in list.\n", channel);
- i = selchannel->channel-1-(selchannel->channel>=17);
- if (mISDNport->b_port[i] == NULL)
- {
- goto use_channel;
- }
- goto inuse_search_differnt;
- } else
- {
- inuse_search_different:
- PDEBUG(DEBUG_BCHANNEL, "- channel %d given, but not in list of incomming channels.\n", channel);
-
- /* check for first free channel in list */
- selchannel = ifport->channel_in;
- while(selchannel)
- {
- switch(selchannel->channel)
- {
- case CHANNEL_FREE: /* free channel */
- if (mISDNport->b_inuse >= mISDNport->b_num)
- break; /* all channel in use or reserverd */
- /* find channel */
- i = 0;
- while(i < mISDNport->b_num)
- {
- if (mISDNport->b_port[i] == NULL)
- {
- channel = i+1+(i>=15);
- //printlog("%3d port#%d position %d selecting free channel %d\n", ea_endpoint->ep_serial, ifport_start->portnum, index, *channel);
- break;
- }
- i++;
- }
- break;