- channel->b_sock = -1;
- return(0);
- }
-
-#if 0
- chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL create socket", DIRECTION_OUT);
- add_trace("channel", NULL, "%d", i+1+(i>=15));
- add_trace("socket", NULL, "%d", mISDNport->b_socket[i]);
- end_trace();
-#endif
-#else
- layer_info_t li;
- mISDN_pid_t pid;
-
- if (bchannel->b_stid)
- {
- PERROR("Error: stack already created for address 0x%lx\n", bchannel->b_stid);
- return(0);
- }
-
- if (bchannel->b_addr)
- {
- PERROR("Error: stack already created for address 0x%lx\n", bchannel->b_addr);
- return(0);
- }
-
- /* create new layer */
- PDEBUG("creating new layer for stid 0x%lx.\n" , bchannel->handle);
- memset(&li, 0, sizeof(li));
- memset(&pid, 0, sizeof(pid));
- li.object_id = -1;
- li.extentions = 0;
- li.st = bchannel->handle;
- strcpy(li.name, "B L4");
- li.pid.layermask = ISDN_LAYER((4));
- li.pid.protocol[4] = ISDN_PID_L4_B_USER;
- ret = mISDN_new_layer(bchannel_device, &li);
- if (ret)
- {
- failed_new_layer:
- PERROR("mISDN_new_layer() failed to add bchannel for stid 0x%lx.\n", bchannel->handle);
- goto failed;
- }
- if (!li.id)
- {
- goto failed_new_layer;
- }
- bchannel->b_stid = bchannel->handle;
- bchannel->b_addr = li.id;
- PDEBUG("new layer (b_addr=0x%x)\n", bchannel->b_addr);
-
- /* create new stack */
- pid.protocol[1] = ISDN_PID_L1_B_64TRANS;
- pid.protocol[2] = ISDN_PID_L2_B_TRANS;
- pid.protocol[3] = ISDN_PID_L3_B_DSP;
- pid.protocol[4] = ISDN_PID_L4_B_USER;
- pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)) | ISDN_LAYER((4));
- ret = mISDN_set_stack(bchannel_device, bchannel->b_stid, &pid);
- if (ret)
- {
- stack_error:
- PERROR("mISDN_set_stack() failed (ret=%d) to add bchannel stid=0x%lx\n", ret, bchannel->b_stid);
- mISDN_write_frame(bchannel_device, buff, bchannel->b_addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
- goto failed;