- protocol = (nt)?L3_PROTOCOL_DSS1_NET:L3_PROTOCOL_DSS1_USER;
- prop = (1 << MISDN_FLG_L2_CLEAN);
- if (ptp) // ptp forced
- prop |= (1 << MISDN_FLG_PTP);
- if (nt) // supports hold/retrieve on nt-mode
- prop |= (1 << MISDN_FLG_NET_HOLD);
- if (l1hold) // supports layer 1 hold
- prop |= (1 << MISDN_FLG_L1_HOLD);
- if (l2hold) // supports layer 2 hold
- prop |= (1 << MISDN_FLG_L2_HOLD);
- /* open layer 3 and init upqueue */
- /* 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,
- ifport->interface,
- NULL,
- NULL,
- DIRECTION_NONE,
- CATEGORY_CH,
- 0,
- "PORT (open failed)");
- end_trace();
- mISDNport_close(mISDNport);
- return(NULL);
+ if (!pots) {
+ /* ISDN */
+ protocol = (nt)?L3_PROTOCOL_DSS1_NET:L3_PROTOCOL_DSS1_USER;
+ prop = (1 << MISDN_FLG_L2_CLEAN);
+ if (ptp) // ptp forced
+ prop |= (1 << MISDN_FLG_PTP);
+ if (nt) // supports hold/retrieve on nt-mode
+ prop |= (1 << MISDN_FLG_NET_HOLD);
+ if (l1hold) // supports layer 1 hold
+ prop |= (1 << MISDN_FLG_L1_HOLD);
+ if (l2hold) // supports layer 2 hold
+ prop |= (1 << MISDN_FLG_L2_HOLD);
+ /* open layer 3 and init upqueue */
+ /* 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,
+ ifport->interface,
+ NULL,
+ NULL,
+ DIRECTION_NONE,
+ CATEGORY_CH,
+ 0,
+ "PORT (open failed)");
+ end_trace();
+ mISDNport_close(mISDNport);
+ return(NULL);
+ }
+ } else {
+#ifdef ISDN_P_FXS_POTS
+ /* POTS */
+ int sock, ret;
+ struct sockaddr_mISDN addr;
+ struct mISDNhead act;
+
+ /* open socket */
+ /* queue must be initializes, because even pots interfaces are checked at mISDN_upqueue loop */
+ mqueue_init(&mISDNport->upqueue);
+ sock = socket(PF_ISDN, SOCK_DGRAM, (nt) ? ISDN_P_FXS_POTS : ISDN_P_FXO_POTS);
+ if (sock < 0) {
+ PERROR_RUNTIME("Cannot open mISDN due to '%s'.\n", strerror(errno));
+ return NULL;
+ }
+ /* bind socket to dchannel */
+ addr.family = AF_ISDN;
+ addr.dev = port;
+ addr.channel = 0;
+ ret = bind(sock, (struct sockaddr *)&addr, sizeof(addr));
+ if (ret < 0) {
+ PERROR_RUNTIME("Error: Failed to bind pots control channel\n");
+ start_trace(port,
+ ifport->interface,
+ NULL,
+ NULL,
+ DIRECTION_NONE,
+ CATEGORY_CH,
+ 0,
+ "PORT (open failed)");
+ end_trace();
+ return(NULL);
+ }
+ act.prim = PH_ACTIVATE_REQ;
+ act.id = 0;
+ ret = sendto(sock, &act, MISDN_HEADER_LEN, 0, NULL, 0);
+ if (ret <= 0)
+ PERROR("Failed to send to socket %d\n", sock);
+ mISDNport->pots_sock.fd = sock;
+ register_fd(&mISDNport->pots_sock, LCR_FD_READ, pots_sock_callback, mISDNport, i);
+#endif