+#ifdef SOCKET_MISDN
+ /* process given callref */
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
+ add_trace("callref", "new", "0x%x", pid);
+ if (p_m_d_l3id)
+ {
+ /* release in case the ID is already in use */
+ add_trace("error", NULL, "callref already in use");
+ end_trace();
+ l3m = create_l3msg();
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
+ enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 47);
+ add_trace("reason", NULL, "callref already in use");
+ end_trace();
+ p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, pid, l3m);
+ new_state(PORT_STATE_RELEASE);
+ p_m_delete = 1;
+ return;
+ }
+ p_m_d_l3id = pid;
+ p_m_d_ces = pid >> 16;
+ end_trace();
+#else
+ /* callref from nt-lib */
+ if (p_m_d_ntmode)
+ {
+ /* nt-library now gives us the id via CC_SETUP */
+ if (dinfo&(~0xff) == 0xff00)
+ FATAL("l3-stack gives us a process id 0xff00-0xffff\n");
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_CR_IND, DIRECTION_IN);
+ if (p_m_d_l3id)
+ add_trace("callref", "old", "0x%x", p_m_d_l3id);
+ add_trace("callref", "new", "0x%x", dinfo);
+ end_trace();
+ if (p_m_d_l3id&(~0xff) == 0xff00)
+ p_m_mISDNport->procids[p_m_d_l3id&0xff] = 0;
+ p_m_d_l3id = dinfo;
+ p_m_d_ces = setup->ces;
+ }
+#endif
+
+ l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
+#ifdef SOCKET_MISDN
+ dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
+ dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
+ dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
+ /* te-mode: CNIP (calling name identification presentation) */
+ if (!p_m_d_ntmode)
+ dec_facility_centrex(l3m, (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
+ dec_ie_useruser(l3m, &useruser_protocol, useruser, &useruser_len);
+ dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
+ dec_ie_redir_nr(l3m, &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
+ dec_ie_channel_id(l3m, &exclusive, &channel);
+ dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
+ dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
+#else
+ dec_ie_calling_pn(setup->CALLING_PN, (Q931_info_t *)((unsigned long)data+headerlen), &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
+ dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
+ dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad));
+ /* te-mode: CNIP (calling name identification presentation) */
+ if (!p_m_d_ntmode)
+ dec_facility_centrex(setup->FACILITY, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
+ dec_ie_useruser(setup->USER_USER, (Q931_info_t *)((unsigned long)data+headerlen), &useruser_protocol, useruser, &useruser_len);
+ dec_ie_complete(setup->COMPLETE, (Q931_info_t *)((unsigned long)data+headerlen), &p_dialinginfo.sending_complete);
+ dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)((unsigned long)data+headerlen), &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
+ dec_ie_channel_id(setup->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
+ dec_ie_hlc(setup->HLC, (Q931_info_t *)((unsigned long)data+headerlen), &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
+ dec_ie_bearer(setup->BEARER, (Q931_info_t *)((unsigned long)data+headerlen), &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
+#endif
+ end_trace();
+
+ /* if blocked, release call with MT_RELEASE_COMPLETE */