-#if 0
- /* if ntmode, establish L1 to send the tei removal during start */
- if (mISDNport->ntmode)
- {
- iframe_t act;
- /* L1 */
- act.prim = PH_ACTIVATE | REQUEST;
- act.addr = mISDNport->upper_id | FLG_MSG_DOWN;
- printf("UPPER ID 0x%x, addr 0x%x\n",mISDNport->upper_id, act.addr);
- act.dinfo = 0;
- act.len = 0;
- mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
- usleep(10000); /* to be sure, that l1 is up */
+ if (devinfo.nrbchan < 8) {
+ PERROR_RUNTIME("GSM port %d must have at least 8 b-channels.\n", port);
+ mISDNport_close(mISDNport);
+ return(NULL);
+ }
+
+ if ((mISDNport->lcr_sock = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_NT_S0)) < 0) {
+ PERROR_RUNTIME("GSM port %d failed to open socket.\n", port);
+ mISDNport_close(mISDNport);
+ return(NULL);
+ }
+ /* set nonblocking io */
+ if (ioctl(mISDNport->lcr_sock, FIONBIO, &on) < 0) {
+ PERROR_RUNTIME("GSM port %d failed to set socket into nonblocking io.\n", port);
+ mISDNport_close(mISDNport);
+ return(NULL);
+ }
+ /* bind socket to dchannel */
+ memset(&addr, 0, sizeof(addr));
+ addr.family = AF_ISDN;
+ addr.dev = port;
+ addr.channel = 0;
+ if (bind(mISDNport->lcr_sock, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+ PERROR_RUNTIME("GSM port %d failed to bind socket. (errno %d)\n", port, errno);
+ mISDNport_close(mISDNport);
+ return(NULL);
+ }
+ } else {
+ /* queue must be initializes, because l3-thread may send messages during open_layer3() */
+ mqueue_init(&mISDNport->upqueue);
+ mISDNport->ml3 = open_layer3(port, protocol, prop , do_layer3, mISDNport);
+ if (!mISDNport->ml3) {
+ mqueue_purge(&mISDNport->upqueue);
+ PERROR_RUNTIME("open_layer3() failed for port %d\n", port);
+ start_trace(port,
+ interface,
+ NULL,
+ NULL,
+ DIRECTION_NONE,
+ CATEGORY_CH,
+ 0,
+ "PORT (open failed)");
+ end_trace();
+ mISDNport_close(mISDNport);
+ return(NULL);
+ }