- case B_EVENT_EXPORTREQUEST:
- /* special case where the bchannel is requested by remote */
- if (!p_m_remote_ref) {
- PERROR("export request without remote channel set, please correct.\n");
- break;
- }
- switch(state) {
- case B_STATE_IDLE:
- /* in case, the bchannel is exported right after seize_bchannel */
- /* export bchannel */
- /* p_m_remote_id is set, when this event happens. */
- message_bchannel_to_remote(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
- chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
- add_trace("type", NULL, "assign");
- add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
- end_trace();
- state = B_STATE_EXPORTING;
- mISDNport->b_remote_id[i] = p_m_remote_id;
- mISDNport->b_remote_ref[i] = p_m_remote_ref;
- break;
-
- case B_STATE_ACTIVATING:
- case B_STATE_EXPORTING:
- /* do nothing, because it is already activating */
- break;
-
- case B_STATE_DEACTIVATING:
- case B_STATE_IMPORTING:
- /* do nothing, because we must wait until we can reactivate */
- break;
-
- case B_STATE_ACTIVE:
- /* bchannel is active, so we deactivate */
- _bchannel_activate(mISDNport, i, 0);
- state = B_STATE_DEACTIVATING;
- timer = now_d + B_TIMER_DEACTIVATING;
- break;
-
- default:
- /* problems that might ocurr:
- * ... when channel already in use.
- * bchannel exported, but not freed by other port
- */
- PERROR("Illegal event %d at state %d, please correct.\n", event, state);
- }
- break;
-
- case B_EVENT_IMPORTREQUEST:
- /* special case where the bchannel is released by remote */
- if (p_m_remote_ref) {
- PERROR("import request with remote channel set, please correct.\n");
- break;
- }
- switch(state) {
- case B_STATE_IDLE:
- case B_STATE_ACTIVE:
- /* bchannel is not exported */
- break;
-
- case B_STATE_ACTIVATING:
- case B_STATE_EXPORTING:
- /* do nothing because we must wait until bchanenl is active before deactivating */
- break;
-
- case B_STATE_REMOTE:
- /* bchannel is exported, so we re-import */
- message_bchannel_to_remote(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
- chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
- add_trace("type", NULL, "remove");
- add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
- end_trace();
- state = B_STATE_IMPORTING;
- break;
-
- case B_STATE_DEACTIVATING:
- case B_STATE_IMPORTING:
- /* we may have taken an already deactivating bchannel, but do not require it anymore, so we do nothing */
- break;
-
- default:
- PERROR("Illegal event %d at state %d, please correct.\n", event, state);
- }
- break;