blob: b7382a73b1260f4277e0d8e95225ecabab31e2c2 [file] [log] [blame]
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +02001/* OpenBSC Abis input driver for DAHDI */
2
3/* (C) 2008-2011 by Harald Welte <laforge@gnumonks.org>
4 * (C) 2009 by Holger Hans Peter Freyther <zecke@selfish.org>
5 * (C) 2010 by Digium and Matthew Fredrickson <creslin@digium.com>
6 *
7 * All Rights Reserved
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 *
23 */
24
Harald Welte3bc78852011-08-24 08:32:38 +020025#include "../../config.h"
26
27#ifdef HAVE_DAHDI_USER_H
28
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020029#include <stdio.h>
30#include <unistd.h>
31#include <stdlib.h>
32#include <errno.h>
33#include <string.h>
34#include <time.h>
35#include <sys/fcntl.h>
36#include <sys/socket.h>
37#include <sys/ioctl.h>
38#include <arpa/inet.h>
39#include <dahdi/user.h>
40
41#include <osmocom/core/select.h>
42#include <osmocom/core/msgb.h>
Pablo Neira Ayuso0b9ed9a2011-07-02 17:25:19 +020043#include <osmocom/core/logging.h>
Pablo Neira Ayusoa20762a2011-07-02 19:01:58 +020044#include <osmocom/core/signal.h>
Harald Welte95e5dec2011-08-16 14:41:32 +020045#include <osmocom/core/rate_ctr.h>
Pablo Neira Ayuso0b9ed9a2011-07-02 17:25:19 +020046#include <osmocom/abis/subchan_demux.h>
47#include <osmocom/abis/e1_input.h>
Harald Welte71d87b22011-07-18 14:49:56 +020048#include <osmocom/core/talloc.h>
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020049
Pablo Neira Ayuso355ce692011-07-05 14:53:37 +020050#include <osmocom/abis/lapd.h>
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +020051
52#define TS1_ALLOC_SIZE 300
53
Harald Weltec2889512011-09-13 23:49:04 +010054struct span_cfg {
55 struct llist_head list;
56
57 unsigned int span_nr;
58 unsigned int chan_base;
59 unsigned int chan_num;
60};
61
62static struct span_cfg *span_cfgs[DAHDI_MAX_SPANS];
63
64static int reread_span_cfgs(void)
65{
66 struct dahdi_spaninfo si;
67 unsigned int basechan = 1;
Harald Weltee2bd6852011-09-26 23:03:12 +020068 int i, span_nr;
Harald Weltec2889512011-09-13 23:49:04 +010069 int fd;
70
71 if ((fd = open("/dev/dahdi/ctl", O_RDWR)) < 0) {
72 LOGP(DLMI, LOGL_ERROR, "Unable to open DAHDI ctl: %s\n",
73 strerror(errno));
74 return -EIO;
75 }
76
Harald Weltee2bd6852011-09-26 23:03:12 +020077 for (span_nr = 1; span_nr < DAHDI_MAX_SPANS; span_nr++) {
Harald Weltec2889512011-09-13 23:49:04 +010078 struct span_cfg *scfg;
Harald Weltee2bd6852011-09-26 23:03:12 +020079 /* our array index starts at 0, but DAHDI span at 1 */
80 int i = span_nr - 1;
Harald Weltec2889512011-09-13 23:49:04 +010081
82 /* clear any old cached information */
83 if (span_cfgs[i]) {
84 talloc_free(span_cfgs[i]);
85 span_cfgs[i] = NULL;
86 }
87
88 memset(&si, 0, sizeof(si));
Harald Weltee2bd6852011-09-26 23:03:12 +020089 si.spanno = span_nr;
Harald Weltec2889512011-09-13 23:49:04 +010090 if (ioctl(fd, DAHDI_SPANSTAT, &si))
91 continue;
92
93 /* create and link new span_cfg */
94 scfg = talloc_zero(NULL, struct span_cfg);
95 if (!scfg) {
96 close(fd);
97 return -ENOMEM;
98 }
Harald Weltee2bd6852011-09-26 23:03:12 +020099 scfg->span_nr = span_nr;
Harald Weltec2889512011-09-13 23:49:04 +0100100 scfg->chan_num = si.totalchans;
101 scfg->chan_base = basechan;
102 span_cfgs[i] = scfg;
103
104 basechan += si.totalchans;
105 }
106
107 close(fd);
108
109 return 0;
110}
111
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200112/* Corresponds to dahdi/user.h, only PRI related events */
113static const struct value_string dahdi_evt_names[] = {
114 { DAHDI_EVENT_NONE, "NONE" },
115 { DAHDI_EVENT_ALARM, "ALARM" },
116 { DAHDI_EVENT_NOALARM, "NOALARM" },
117 { DAHDI_EVENT_ABORT, "HDLC ABORT" },
118 { DAHDI_EVENT_OVERRUN, "HDLC OVERRUN" },
119 { DAHDI_EVENT_BADFCS, "HDLC BAD FCS" },
120 { DAHDI_EVENT_REMOVED, "REMOVED" },
121 { 0, NULL }
122};
123
124static void handle_dahdi_exception(struct e1inp_ts *ts)
125{
126 int rc, evt;
Harald Welte95e5dec2011-08-16 14:41:32 +0200127 struct e1inp_line *line = ts->line;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200128 struct input_signal_data isd;
129
130 rc = ioctl(ts->driver.dahdi.fd.fd, DAHDI_GETEVENT, &evt);
131 if (rc < 0)
132 return;
133
Harald Weltecc2241b2011-07-19 16:06:06 +0200134 LOGP(DLMI, LOGL_NOTICE, "Line %u(%s) / TS %u DAHDI EVENT %s\n",
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200135 ts->line->num, ts->line->name, ts->num,
136 get_value_string(dahdi_evt_names, evt));
137
138 isd.line = ts->line;
139
140 switch (evt) {
141 case DAHDI_EVENT_ALARM:
142 /* we should notify the code that the line is gone */
Pablo Neira Ayusode668912011-08-16 17:26:23 +0200143 osmo_signal_dispatch(SS_L_INPUT, S_L_INP_LINE_ALARM, &isd);
Harald Welte95e5dec2011-08-16 14:41:32 +0200144 rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_ALARM]);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200145 break;
146 case DAHDI_EVENT_NOALARM:
147 /* alarm has gone, we should re-start the SABM requests */
Pablo Neira Ayusode668912011-08-16 17:26:23 +0200148 osmo_signal_dispatch(SS_L_INPUT, S_L_INP_LINE_NOALARM, &isd);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200149 break;
Harald Welte95e5dec2011-08-16 14:41:32 +0200150 case DAHDI_EVENT_ABORT:
151 rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_HDLC_ABORT]);
152 break;
153 case DAHDI_EVENT_OVERRUN:
154 rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_HDLC_OVERR]);
155 break;
156 case DAHDI_EVENT_BADFCS:
157 rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_HDLC_BADFCS]);
158 break;
159 case DAHDI_EVENT_REMOVED:
160 rate_ctr_inc(&line->rate_ctr->ctr[E1I_CTR_REMOVED]);
161 break;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200162 }
163}
164
165static int handle_ts1_read(struct osmo_fd *bfd)
166{
167 struct e1inp_line *line = bfd->data;
168 unsigned int ts_nr = bfd->priv_nr;
169 struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
170 struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE, "DAHDI TS1");
Harald Weltefd44a5f2011-08-21 00:48:54 +0200171 int ret;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200172
173 if (!msg)
174 return -ENOMEM;
175
176 ret = read(bfd->fd, msg->data, TS1_ALLOC_SIZE - 16);
177 if (ret == -1)
178 handle_dahdi_exception(e1i_ts);
179 else if (ret < 0) {
180 perror("read ");
181 }
182 msgb_put(msg, ret - 2);
183 if (ret <= 3) {
184 perror("read ");
185 }
186
Harald Weltefd44a5f2011-08-21 00:48:54 +0200187 return e1inp_rx_ts_lapd(e1i_ts, msg);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200188}
189
190static int ts_want_write(struct e1inp_ts *e1i_ts)
191{
192 /* We never include the DAHDI B-Channel FD into the
193 * writeset, since it doesn't support poll() based
194 * write flow control */
195 if (e1i_ts->type == E1INP_TS_TYPE_TRAU) {
196 fprintf(stderr, "Trying to write TRAU ts\n");
197 return 0;
198 }
199
200 e1i_ts->driver.dahdi.fd.when |= BSC_FD_WRITE;
201
202 return 0;
203}
204
205static void timeout_ts1_write(void *data)
206{
207 struct e1inp_ts *e1i_ts = (struct e1inp_ts *)data;
208
209 /* trigger write of ts1, due to tx delay timer */
210 ts_want_write(e1i_ts);
211}
212
213static void dahdi_write_msg(uint8_t *data, int len, void *cbdata)
214{
215 struct osmo_fd *bfd = cbdata;
216 struct e1inp_line *line = bfd->data;
217 unsigned int ts_nr = bfd->priv_nr;
218 struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
219 int ret;
220
221 ret = write(bfd->fd, data, len + 2);
222 if (ret == -1)
223 handle_dahdi_exception(e1i_ts);
224 else if (ret < 0)
Harald Weltecc2241b2011-07-19 16:06:06 +0200225 LOGP(DLMI, LOGL_NOTICE, "%s write failed %d\n", __func__, ret);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200226}
227
228static int handle_ts1_write(struct osmo_fd *bfd)
229{
230 struct e1inp_line *line = bfd->data;
231 unsigned int ts_nr = bfd->priv_nr;
232 struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
233 struct e1inp_sign_link *sign_link;
234 struct msgb *msg;
235
236 bfd->when &= ~BSC_FD_WRITE;
237
238 /* get the next msg for this timeslot */
239 msg = e1inp_tx_ts(e1i_ts, &sign_link);
240 if (!msg) {
241 /* no message after tx delay timer */
242 return 0;
243 }
244
Harald Weltecc2241b2011-07-19 16:06:06 +0200245 DEBUGP(DLMI, "TX: %s\n", osmo_hexdump(msg->data, msg->len));
Harald Weltefd44a5f2011-08-21 00:48:54 +0200246 lapd_transmit(e1i_ts->lapd, sign_link->tei,
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200247 sign_link->sapi, msg->data, msg->len);
248 msgb_free(msg);
249
250 /* set tx delay timer for next event */
251 e1i_ts->sign.tx_timer.cb = timeout_ts1_write;
252 e1i_ts->sign.tx_timer.data = e1i_ts;
253 osmo_timer_schedule(&e1i_ts->sign.tx_timer, 0, 50000);
254
255 return 0;
256}
257
258
259static int invertbits = 1;
260
261static uint8_t flip_table[256];
262
263static void init_flip_bits(void)
264{
265 int i,k;
266
267 for (i = 0 ; i < 256 ; i++) {
268 uint8_t sample = 0 ;
269 for (k = 0; k<8; k++) {
270 if ( i & 1 << k ) sample |= 0x80 >> k;
271 }
272 flip_table[i] = sample;
273 }
274}
275
276static uint8_t * flip_buf_bits ( uint8_t * buf , int len)
277{
278 int i;
279 uint8_t * start = buf;
280
281 for (i = 0 ; i < len; i++) {
282 buf[i] = flip_table[(uint8_t)buf[i]];
283 }
284
285 return start;
286}
287
288#define D_BCHAN_TX_GRAN 160
289/* write to a B channel TS */
290static int handle_tsX_write(struct osmo_fd *bfd)
291{
292 struct e1inp_line *line = bfd->data;
293 unsigned int ts_nr = bfd->priv_nr;
294 struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
295 uint8_t tx_buf[D_BCHAN_TX_GRAN];
296 struct subch_mux *mx = &e1i_ts->trau.mux;
297 int ret;
298
299 ret = subchan_mux_out(mx, tx_buf, D_BCHAN_TX_GRAN);
300
301 if (ret != D_BCHAN_TX_GRAN) {
302 fprintf(stderr, "Huh, got ret of %d\n", ret);
303 if (ret < 0)
304 return ret;
305 }
306
Harald Weltecc2241b2011-07-19 16:06:06 +0200307 DEBUGP(DLMIB, "BCHAN TX: %s\n",
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200308 osmo_hexdump(tx_buf, D_BCHAN_TX_GRAN));
309
310 if (invertbits) {
311 flip_buf_bits(tx_buf, ret);
312 }
313
314 ret = write(bfd->fd, tx_buf, ret);
315 if (ret < D_BCHAN_TX_GRAN)
316 fprintf(stderr, "send returns %d instead of %d\n", ret,
317 D_BCHAN_TX_GRAN);
318
319 return ret;
320}
321
322#define D_TSX_ALLOC_SIZE (D_BCHAN_TX_GRAN)
323/* FIXME: read from a B channel TS */
324static int handle_tsX_read(struct osmo_fd *bfd)
325{
326 struct e1inp_line *line = bfd->data;
327 unsigned int ts_nr = bfd->priv_nr;
328 struct e1inp_ts *e1i_ts = &line->ts[ts_nr-1];
329 struct msgb *msg = msgb_alloc(D_TSX_ALLOC_SIZE, "DAHDI TSx");
330 int ret;
331
332 if (!msg)
333 return -ENOMEM;
334
335 ret = read(bfd->fd, msg->data, D_TSX_ALLOC_SIZE);
336 if (ret < 0 || ret != D_TSX_ALLOC_SIZE) {
337 fprintf(stderr, "read error %d %s\n", ret, strerror(errno));
338 return ret;
339 }
340
341 if (invertbits) {
342 flip_buf_bits(msg->data, ret);
343 }
344
345 msgb_put(msg, ret);
346
347 msg->l2h = msg->data;
Harald Weltecc2241b2011-07-19 16:06:06 +0200348 DEBUGP(DLMIB, "BCHAN RX: %s\n",
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200349 osmo_hexdump(msgb_l2(msg), ret));
350 ret = e1inp_rx_ts(e1i_ts, msg, 0, 0);
351 /* physical layer indicates that data has been sent,
352 * we thus can send some more data */
353 ret = handle_tsX_write(bfd);
354 msgb_free(msg);
355
356 return ret;
357}
358
359/* callback from select.c in case one of the fd's can be read/written */
360static int dahdi_fd_cb(struct osmo_fd *bfd, unsigned int what)
361{
362 struct e1inp_line *line = bfd->data;
363 unsigned int ts_nr = bfd->priv_nr;
364 unsigned int idx = ts_nr-1;
365 struct e1inp_ts *e1i_ts = &line->ts[idx];
366 int rc = 0;
367
368 switch (e1i_ts->type) {
369 case E1INP_TS_TYPE_SIGN:
370 if (what & BSC_FD_EXCEPT)
371 handle_dahdi_exception(e1i_ts);
372 if (what & BSC_FD_READ)
373 rc = handle_ts1_read(bfd);
374 if (what & BSC_FD_WRITE)
375 rc = handle_ts1_write(bfd);
376 break;
377 case E1INP_TS_TYPE_TRAU:
378 if (what & BSC_FD_EXCEPT)
379 handle_dahdi_exception(e1i_ts);
380 if (what & BSC_FD_READ)
381 rc = handle_tsX_read(bfd);
382 if (what & BSC_FD_WRITE)
383 rc = handle_tsX_write(bfd);
384 /* We never include the DAHDI B-Channel FD into the
385 * writeset, since it doesn't support poll() based
386 * write flow control */
387 break;
388 default:
389 fprintf(stderr, "unknown E1 TS type %u\n", e1i_ts->type);
390 break;
391 }
392
393 return rc;
394}
395
Pablo Neira Ayuso4e862cb2011-08-19 18:43:38 +0200396static int dahdi_e1_line_update(struct e1inp_line *line);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200397
398struct e1inp_driver dahdi_driver = {
399 .name = "dahdi",
400 .want_write = ts_want_write,
401 .line_update = &dahdi_e1_line_update,
402};
403
404void dahdi_set_bufinfo(int fd, int as_sigchan)
405{
406 struct dahdi_bufferinfo bi;
407 int x = 0;
408
409 if (ioctl(fd, DAHDI_GET_BUFINFO, &bi)) {
410 fprintf(stderr, "Error getting bufinfo\n");
411 exit(-1);
412 }
413
414 if (as_sigchan) {
415 bi.numbufs = 4;
416 bi.bufsize = 512;
417 } else {
418 bi.numbufs = 8;
419 bi.bufsize = D_BCHAN_TX_GRAN;
420 bi.txbufpolicy = DAHDI_POLICY_WHEN_FULL;
421 }
422
423 if (ioctl(fd, DAHDI_SET_BUFINFO, &bi)) {
424 fprintf(stderr, "Error setting bufinfo\n");
425 exit(-1);
426 }
427
428 if (!as_sigchan) {
429 if (ioctl(fd, DAHDI_AUDIOMODE, &x)) {
430 fprintf(stderr, "Error setting bufinfo\n");
431 exit(-1);
432 }
433 } else {
434 int one = 1;
435 ioctl(fd, DAHDI_HDLCFCSMODE, &one);
436 /* we cannot reliably check for the ioctl return value here
437 * as this command will fail if the slot _already_ was a
438 * signalling slot before :( */
439 }
440}
441
442static int dahdi_e1_setup(struct e1inp_line *line)
443{
Harald Weltec2889512011-09-13 23:49:04 +0100444 struct span_cfg *scfg;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200445 int ts, ret;
446
Harald Weltec2889512011-09-13 23:49:04 +0100447 reread_span_cfgs();
448
449 scfg = span_cfgs[line->port_nr];
Harald Welte0cf55142011-09-26 23:06:18 +0200450 if (!scfg) {
451 LOGP(DLMI, LOGL_ERROR, "Line %u(%s): DAHDI Port %u (Span %u) "
452 "doesn't exist\n", line->num, line->name, line->port_nr,
453 line->port_nr+1);
Harald Weltec2889512011-09-13 23:49:04 +0100454 return -EIO;
Harald Welte0cf55142011-09-26 23:06:18 +0200455 }
Harald Weltec2889512011-09-13 23:49:04 +0100456
457 line->num_ts = scfg->chan_num;
458
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200459 /* TS0 is CRC4, don't need any fd for it */
Harald Weltec2889512011-09-13 23:49:04 +0100460 for (ts = 1; ts <= scfg->chan_num; ts++) {
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200461 unsigned int idx = ts-1;
462 char openstr[128];
463 struct e1inp_ts *e1i_ts = &line->ts[idx];
464 struct osmo_fd *bfd = &e1i_ts->driver.dahdi.fd;
Harald Weltef3ca61c2011-08-09 11:21:23 +0200465 int dev_nr;
466
Harald Weltecfc9f1f2011-08-24 09:45:36 +0200467 /* unregister FD if it was already registered */
468 if (bfd->list.next && bfd->list.next != LLIST_POISON1)
469 osmo_fd_unregister(bfd);
470
Harald Weltef3ca61c2011-08-09 11:21:23 +0200471 /* DAHDI device names/numbers just keep incrementing
472 * even over multiple boards. So TS1 of the second
473 * board will be 32 */
Harald Weltec2889512011-09-13 23:49:04 +0100474 dev_nr = scfg->chan_base + idx;
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200475
476 bfd->data = line;
477 bfd->priv_nr = ts;
478 bfd->cb = dahdi_fd_cb;
Harald Weltef3ca61c2011-08-09 11:21:23 +0200479 snprintf(openstr, sizeof(openstr), "/dev/dahdi/%d", dev_nr);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200480
481 switch (e1i_ts->type) {
482 case E1INP_TS_TYPE_NONE:
Harald Weltecfc9f1f2011-08-24 09:45:36 +0200483 /* close/release LAPD instance, if any */
484 if (e1i_ts->lapd) {
485 lapd_instance_free(e1i_ts->lapd);
486 e1i_ts->lapd = NULL;
487 }
488 if (bfd->fd) {
489 close(bfd->fd);
490 bfd->fd = 0;
491 }
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200492 continue;
493 break;
494 case E1INP_TS_TYPE_SIGN:
Harald Weltecfc9f1f2011-08-24 09:45:36 +0200495 if (!bfd->fd)
496 bfd->fd = open(openstr, O_RDWR | O_NONBLOCK);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200497 if (bfd->fd == -1) {
498 fprintf(stderr, "%s could not open %s %s\n",
499 __func__, openstr, strerror(errno));
500 exit(-1);
501 }
502 bfd->when = BSC_FD_READ | BSC_FD_EXCEPT;
503 dahdi_set_bufinfo(bfd->fd, 1);
Harald Weltecfc9f1f2011-08-24 09:45:36 +0200504 if (!e1i_ts->lapd)
505 e1i_ts->lapd = lapd_instance_alloc(1, dahdi_write_msg, bfd);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200506 break;
507 case E1INP_TS_TYPE_TRAU:
Harald Weltecfc9f1f2011-08-24 09:45:36 +0200508 /* close/release LAPD instance, if any */
509 if (e1i_ts->lapd) {
510 lapd_instance_free(e1i_ts->lapd);
511 e1i_ts->lapd = NULL;
512 }
513 if (!bfd->fd)
514 bfd->fd = open(openstr, O_RDWR | O_NONBLOCK);
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200515 if (bfd->fd == -1) {
516 fprintf(stderr, "%s could not open %s %s\n",
517 __func__, openstr, strerror(errno));
518 exit(-1);
519 }
520 dahdi_set_bufinfo(bfd->fd, 0);
521 /* We never include the DAHDI B-Channel FD into the
522 * writeset, since it doesn't support poll() based
523 * write flow control */
524 bfd->when = BSC_FD_READ | BSC_FD_EXCEPT;// | BSC_FD_WRITE;
525 break;
526 }
527
528 if (bfd->fd < 0) {
529 fprintf(stderr, "%s could not open %s %s\n",
530 __func__, openstr, strerror(errno));
531 return bfd->fd;
532 }
533
534 ret = osmo_fd_register(bfd);
535 if (ret < 0) {
536 fprintf(stderr, "could not register FD: %s\n",
537 strerror(ret));
538 return ret;
539 }
540 }
541
542 return 0;
543}
544
Pablo Neira Ayuso4e862cb2011-08-19 18:43:38 +0200545static int dahdi_e1_line_update(struct e1inp_line *line)
Pablo Neira Ayuso0ba77d52011-06-05 18:32:44 +0200546{
547 if (line->driver != &dahdi_driver)
548 return -EINVAL;
549
550 return dahdi_e1_setup(line);
551}
552
553int e1inp_dahdi_init(void)
554{
555 init_flip_bits();
556
557 /* register the driver with the core */
558 return e1inp_driver_register(&dahdi_driver);
559}
Harald Welte3bc78852011-08-24 08:32:38 +0200560
561#endif /* HAVE_DAHDI_USER_H */