Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 1 | /* OpenBSC Abis interface to E1 */ |
| 2 | |
| 3 | /* (C) 2008-2009 by Harald Welte <laforge@gnumonks.org> |
| 4 | * |
| 5 | * All Rights Reserved |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License along |
| 18 | * with this program; if not, write to the Free Software Foundation, Inc., |
| 19 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <stdio.h> |
| 24 | #include <unistd.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <errno.h> |
| 27 | #include <string.h> |
| 28 | #include <time.h> |
| 29 | #include <sys/fcntl.h> |
| 30 | #include <sys/types.h> |
| 31 | #include <sys/socket.h> |
| 32 | #include <sys/ioctl.h> |
| 33 | #include <arpa/inet.h> |
| 34 | #include <mISDNif.h> |
| 35 | |
| 36 | //#define AF_COMPATIBILITY_FUNC |
| 37 | //#include <compat_af_isdn.h> |
Holger Freyther | 66e092b | 2009-03-31 12:13:50 +0000 | [diff] [blame] | 38 | #ifndef AF_ISDN |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 39 | #define AF_ISDN 34 |
| 40 | #define PF_ISDN AF_ISDN |
Holger Freyther | 66e092b | 2009-03-31 12:13:50 +0000 | [diff] [blame] | 41 | #endif |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 42 | |
| 43 | #include <openbsc/select.h> |
| 44 | #include <openbsc/msgb.h> |
| 45 | #include <openbsc/debug.h> |
| 46 | #include <openbsc/gsm_data.h> |
| 47 | #include <openbsc/e1_input.h> |
| 48 | #include <openbsc/abis_nm.h> |
| 49 | #include <openbsc/abis_rsl.h> |
| 50 | #include <openbsc/linuxlist.h> |
| 51 | #include <openbsc/subchan_demux.h> |
| 52 | #include <openbsc/trau_mux.h> |
| 53 | |
| 54 | #define NUM_E1_TS 32 |
| 55 | |
| 56 | /* list of all E1 drivers */ |
Harald Welte | 44d542e | 2009-03-10 18:24:35 +0000 | [diff] [blame] | 57 | LLIST_HEAD(e1inp_driver_list); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 58 | |
| 59 | /* list of all E1 lines */ |
Harald Welte | 44d542e | 2009-03-10 18:24:35 +0000 | [diff] [blame] | 60 | LLIST_HEAD(e1inp_line_list); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 61 | |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 62 | /* to be implemented, e.g. by bsc_hack.c */ |
| 63 | void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx); |
| 64 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 65 | /* |
| 66 | * pcap writing of the misdn load |
| 67 | * pcap format is from http://wiki.wireshark.org/Development/LibpcapFileFormat |
| 68 | */ |
| 69 | #define DLT_LINUX_LAPD 177 |
| 70 | #define PCAP_INPUT 0 |
| 71 | #define PCAP_OUTPUT 1 |
| 72 | |
| 73 | struct pcap_hdr { |
| 74 | u_int32_t magic_number; |
| 75 | u_int16_t version_major; |
| 76 | u_int16_t version_minor; |
| 77 | int32_t thiszone; |
| 78 | u_int32_t sigfigs; |
| 79 | u_int32_t snaplen; |
| 80 | u_int32_t network; |
| 81 | } __attribute__((packed)); |
| 82 | |
| 83 | struct pcaprec_hdr { |
| 84 | u_int32_t ts_sec; |
| 85 | u_int32_t ts_usec; |
| 86 | u_int32_t incl_len; |
| 87 | u_int32_t orig_len; |
| 88 | } __attribute__((packed)); |
| 89 | |
| 90 | struct fake_linux_lapd_header { |
| 91 | u_int16_t pkttype; |
| 92 | u_int16_t hatype; |
| 93 | u_int16_t halen; |
| 94 | u_int64_t addr; |
| 95 | int16_t protocol; |
| 96 | } __attribute__((packed)); |
| 97 | |
| 98 | struct lapd_header { |
| 99 | u_int8_t ea1 : 1; |
| 100 | u_int8_t cr : 1; |
| 101 | u_int8_t sapi : 6; |
| 102 | u_int8_t ea2 : 1; |
| 103 | u_int8_t tei : 7; |
| 104 | u_int8_t control_foo; /* fake UM's ... */ |
| 105 | } __attribute__((packed)); |
| 106 | |
| 107 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->hatype == 2, hatype_offset); |
| 108 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->halen == 4, halen_offset); |
| 109 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->addr == 6, addr_offset); |
| 110 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->protocol == 14, proto_offset); |
| 111 | static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size); |
| 112 | |
| 113 | |
| 114 | static int pcap_fd = -1; |
| 115 | |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 116 | void e1_set_pcap_fd(int fd) |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 117 | { |
| 118 | int ret; |
| 119 | struct pcap_hdr header = { |
| 120 | .magic_number = 0xa1b2c3d4, |
| 121 | .version_major = 2, |
| 122 | .version_minor = 4, |
| 123 | .thiszone = 0, |
| 124 | .sigfigs = 0, |
| 125 | .snaplen = 65535, |
| 126 | .network = DLT_LINUX_LAPD, |
| 127 | }; |
| 128 | |
| 129 | pcap_fd = fd; |
| 130 | ret = write(pcap_fd, &header, sizeof(header)); |
| 131 | } |
| 132 | |
| 133 | /* This currently only works for the D-Channel */ |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 134 | static void write_pcap_packet(int direction, int sapi, int tei, |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 135 | struct msgb *msg) { |
| 136 | if (pcap_fd < 0) |
| 137 | return; |
| 138 | |
| 139 | int ret; |
| 140 | time_t cur_time; |
| 141 | struct tm *tm; |
| 142 | |
| 143 | struct fake_linux_lapd_header header = { |
| 144 | .pkttype = 4, |
| 145 | .hatype = 0, |
| 146 | .halen = 0, |
| 147 | .addr = direction == PCAP_OUTPUT ? 0x0 : 0x1, |
| 148 | .protocol = ntohs(48), |
| 149 | }; |
| 150 | |
| 151 | struct lapd_header lapd_header = { |
| 152 | .ea1 = 0, |
| 153 | .cr = direction == PCAP_OUTPUT ? 1 : 0, |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 154 | .sapi = sapi & 0x3F, |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 155 | .ea2 = 1, |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 156 | .tei = tei & 0x7F, |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 157 | .control_foo = 0x03 /* UI */, |
| 158 | }; |
| 159 | |
| 160 | struct pcaprec_hdr payload_header = { |
| 161 | .ts_sec = 0, |
| 162 | .ts_usec = 0, |
| 163 | .incl_len = msg->len + sizeof(struct fake_linux_lapd_header) |
| 164 | + sizeof(struct lapd_header) |
| 165 | - MISDN_HEADER_LEN, |
| 166 | .orig_len = msg->len + sizeof(struct fake_linux_lapd_header) |
| 167 | + sizeof(struct lapd_header) |
| 168 | - MISDN_HEADER_LEN, |
| 169 | }; |
| 170 | |
| 171 | |
| 172 | cur_time = time(NULL); |
| 173 | tm = localtime(&cur_time); |
| 174 | payload_header.ts_sec = mktime(tm); |
| 175 | |
| 176 | ret = write(pcap_fd, &payload_header, sizeof(payload_header)); |
| 177 | ret = write(pcap_fd, &header, sizeof(header)); |
| 178 | ret = write(pcap_fd, &lapd_header, sizeof(lapd_header)); |
| 179 | ret = write(pcap_fd, msg->data + MISDN_HEADER_LEN, |
| 180 | msg->len - MISDN_HEADER_LEN); |
| 181 | } |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 182 | |
Harald Welte | d256d4f | 2009-03-10 19:44:48 +0000 | [diff] [blame] | 183 | static const char *sign_types[] = { |
| 184 | [E1INP_SIGN_NONE] = "None", |
| 185 | [E1INP_SIGN_OML] = "OML", |
| 186 | [E1INP_SIGN_RSL] = "RSL", |
| 187 | }; |
| 188 | const char *e1inp_signtype_name(enum e1inp_sign_type tp) |
| 189 | { |
| 190 | if (tp >= ARRAY_SIZE(sign_types)) |
| 191 | return "undefined"; |
| 192 | return sign_types[tp]; |
| 193 | } |
| 194 | |
| 195 | static const char *ts_types[] = { |
| 196 | [E1INP_TS_TYPE_NONE] = "None", |
| 197 | [E1INP_TS_TYPE_SIGN] = "Signalling", |
| 198 | [E1INP_TS_TYPE_TRAU] = "TRAU", |
| 199 | }; |
| 200 | |
| 201 | const char *e1inp_tstype_name(enum e1inp_ts_type tp) |
| 202 | { |
| 203 | if (tp >= ARRAY_SIZE(ts_types)) |
| 204 | return "undefined"; |
| 205 | return ts_types[tp]; |
| 206 | } |
| 207 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 208 | /* callback when a TRAU frame was received */ |
| 209 | static int subch_cb(struct subch_demux *dmx, int ch, u_int8_t *data, int len, |
| 210 | void *_priv) |
| 211 | { |
| 212 | struct e1inp_ts *e1i_ts = _priv; |
| 213 | struct gsm_e1_subslot src_ss; |
| 214 | |
| 215 | src_ss.e1_nr = e1i_ts->line->num; |
| 216 | src_ss.e1_ts = e1i_ts->num; |
| 217 | src_ss.e1_ts_ss = ch; |
| 218 | |
| 219 | return trau_mux_input(&src_ss, data, len); |
| 220 | } |
| 221 | |
| 222 | int abis_rsl_sendmsg(struct msgb *msg) |
| 223 | { |
| 224 | struct e1inp_sign_link *sign_link; |
| 225 | struct e1inp_driver *e1inp_driver; |
| 226 | |
| 227 | msg->l2h = msg->data; |
| 228 | |
| 229 | if (!msg->trx || !msg->trx->rsl_link) { |
| 230 | fprintf(stderr, "rsl_sendmsg: msg->trx == NULL\n"); |
| 231 | return -EINVAL; |
| 232 | } |
| 233 | |
| 234 | sign_link = msg->trx->rsl_link; |
| 235 | msgb_enqueue(&sign_link->tx_list, msg); |
| 236 | |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 237 | /* dump it */ |
| 238 | write_pcap_packet(PCAP_OUTPUT, sign_link->sapi, sign_link->tei, msg); |
| 239 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 240 | /* notify the driver we have something to write */ |
| 241 | e1inp_driver = sign_link->ts->line->driver; |
| 242 | e1inp_driver->want_write(sign_link->ts); |
| 243 | |
| 244 | return 0; |
| 245 | } |
| 246 | |
| 247 | int _abis_nm_sendmsg(struct msgb *msg) |
| 248 | { |
| 249 | struct e1inp_sign_link *sign_link; |
| 250 | struct e1inp_driver *e1inp_driver; |
| 251 | |
| 252 | msg->l2h = msg->data; |
| 253 | |
| 254 | if (!msg->trx || !msg->trx->bts || !msg->trx->bts->oml_link) { |
Holger Freyther | fb3f519 | 2009-02-09 23:09:15 +0000 | [diff] [blame] | 255 | fprintf(stderr, "nm_sendmsg: msg->trx == NULL\n"); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 256 | return -EINVAL; |
| 257 | } |
Holger Freyther | fb3f519 | 2009-02-09 23:09:15 +0000 | [diff] [blame] | 258 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 259 | sign_link = msg->trx->bts->oml_link; |
| 260 | msgb_enqueue(&sign_link->tx_list, msg); |
| 261 | |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 262 | /* dump it */ |
| 263 | write_pcap_packet(PCAP_OUTPUT, sign_link->sapi, sign_link->tei, msg); |
| 264 | |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 265 | /* notify the driver we have something to write */ |
| 266 | e1inp_driver = sign_link->ts->line->driver; |
| 267 | e1inp_driver->want_write(sign_link->ts); |
| 268 | |
| 269 | return 0; |
| 270 | } |
| 271 | |
| 272 | /* Timeslot */ |
| 273 | |
| 274 | /* configure and initialize one e1inp_ts */ |
| 275 | int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line, |
| 276 | enum e1inp_ts_type type) |
| 277 | { |
| 278 | ts->type = type; |
| 279 | ts->line = line; |
| 280 | |
| 281 | switch (type) { |
| 282 | case E1INP_TS_TYPE_SIGN: |
| 283 | INIT_LLIST_HEAD(&ts->sign.sign_links); |
| 284 | break; |
| 285 | case E1INP_TS_TYPE_TRAU: |
| 286 | subchan_mux_init(&ts->trau.mux); |
| 287 | ts->trau.demux.out_cb = subch_cb; |
| 288 | ts->trau.demux.data = ts; |
| 289 | subch_demux_init(&ts->trau.demux); |
| 290 | break; |
| 291 | default: |
| 292 | fprintf(stderr, "unsupported E1 timeslot type %u\n", |
| 293 | ts->type); |
| 294 | return -EINVAL; |
| 295 | } |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | static struct e1inp_line *e1inp_line_get(u_int8_t e1_nr) |
| 300 | { |
| 301 | struct e1inp_line *e1i_line; |
| 302 | |
| 303 | /* iterate over global list of e1 lines */ |
Harald Welte | 44d542e | 2009-03-10 18:24:35 +0000 | [diff] [blame] | 304 | llist_for_each_entry(e1i_line, &e1inp_line_list, list) { |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 305 | if (e1i_line->num == e1_nr) |
| 306 | return e1i_line; |
| 307 | } |
| 308 | return NULL; |
| 309 | } |
| 310 | |
| 311 | static struct e1inp_ts *e1inp_ts_get(u_int8_t e1_nr, u_int8_t ts_nr) |
| 312 | { |
| 313 | struct e1inp_line *e1i_line; |
| 314 | |
| 315 | e1i_line = e1inp_line_get(e1_nr); |
| 316 | if (!e1i_line) |
| 317 | return NULL; |
| 318 | |
| 319 | return &e1i_line->ts[ts_nr-1]; |
| 320 | } |
| 321 | |
| 322 | struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr) |
| 323 | { |
| 324 | struct e1inp_ts *e1i_ts = e1inp_ts_get(e1_nr, ts_nr); |
| 325 | |
| 326 | if (!e1i_ts) |
| 327 | return NULL; |
| 328 | |
| 329 | return &e1i_ts->trau.mux; |
| 330 | } |
| 331 | |
| 332 | /* Signalling Link */ |
| 333 | |
| 334 | struct e1inp_sign_link *e1inp_lookup_sign_link(struct e1inp_ts *e1i, |
| 335 | u_int8_t tei, u_int8_t sapi) |
| 336 | { |
| 337 | struct e1inp_sign_link *link; |
| 338 | |
| 339 | llist_for_each_entry(link, &e1i->sign.sign_links, list) { |
| 340 | if (link->sapi == sapi && link->tei == tei) |
| 341 | return link; |
| 342 | } |
| 343 | |
| 344 | return NULL; |
| 345 | } |
| 346 | |
| 347 | /* create a new signalling link in a E1 timeslot */ |
| 348 | |
| 349 | struct e1inp_sign_link * |
| 350 | e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type, |
| 351 | struct gsm_bts_trx *trx, u_int8_t tei, |
| 352 | u_int8_t sapi) |
| 353 | { |
| 354 | struct e1inp_sign_link *link; |
| 355 | |
| 356 | if (ts->type != E1INP_TS_TYPE_SIGN) |
| 357 | return NULL; |
| 358 | |
| 359 | link = malloc(sizeof(*link)); |
| 360 | if (!link) |
| 361 | return NULL; |
| 362 | |
| 363 | memset(link, 0, sizeof(*link)); |
| 364 | |
| 365 | link->ts = ts; |
| 366 | link->type = type; |
| 367 | INIT_LLIST_HEAD(&link->tx_list); |
| 368 | link->trx = trx; |
Holger Freyther | fb3f519 | 2009-02-09 23:09:15 +0000 | [diff] [blame] | 369 | link->tei = tei; |
| 370 | link->sapi = sapi; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 371 | |
| 372 | llist_add_tail(&link->list, &ts->sign.sign_links); |
| 373 | |
| 374 | return link; |
| 375 | } |
| 376 | |
| 377 | /* the E1 driver tells us he has received something on a TS */ |
| 378 | int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, |
| 379 | u_int8_t tei, u_int8_t sapi) |
| 380 | { |
| 381 | struct e1inp_sign_link *link; |
| 382 | int ret; |
| 383 | |
| 384 | switch (ts->type) { |
| 385 | case E1INP_TS_TYPE_SIGN: |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 386 | /* consult the list of signalling links */ |
Holger Freyther | 0469cf6 | 2009-03-31 12:14:16 +0000 | [diff] [blame] | 387 | write_pcap_packet(PCAP_INPUT, sapi, tei, msg); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 388 | link = e1inp_lookup_sign_link(ts, tei, sapi); |
| 389 | if (!link) { |
| 390 | fprintf(stderr, "didn't find singalling link for " |
| 391 | "tei %d, sapi %d\n", tei, sapi); |
| 392 | return -EINVAL; |
| 393 | } |
| 394 | switch (link->type) { |
| 395 | case E1INP_SIGN_OML: |
| 396 | msg->trx = link->trx; |
| 397 | ret = abis_nm_rcvmsg(msg); |
| 398 | break; |
| 399 | case E1INP_SIGN_RSL: |
| 400 | msg->trx = link->trx; |
| 401 | ret = abis_rsl_rcvmsg(msg); |
| 402 | break; |
| 403 | default: |
| 404 | ret = -EINVAL; |
| 405 | fprintf(stderr, "unknown link type %u\n", link->type); |
| 406 | break; |
| 407 | } |
| 408 | break; |
| 409 | case E1INP_TS_TYPE_TRAU: |
Harald Welte | 9e78331 | 2009-02-17 19:02:29 +0000 | [diff] [blame] | 410 | ret = subch_demux_in(&ts->trau.demux, msg->l2h, msgb_l2len(msg)); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 411 | break; |
| 412 | default: |
| 413 | ret = -EINVAL; |
| 414 | fprintf(stderr, "unknown TS type %u\n", ts->type); |
| 415 | break; |
| 416 | } |
| 417 | |
| 418 | return ret; |
| 419 | } |
| 420 | |
| 421 | #define TSX_ALLOC_SIZE 4096 |
| 422 | |
| 423 | /* called by driver if it wants to transmit on a given TS */ |
| 424 | struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, |
| 425 | struct e1inp_sign_link **sign_link) |
| 426 | { |
| 427 | struct e1inp_sign_link *link; |
| 428 | struct msgb *msg = NULL; |
| 429 | int len; |
| 430 | |
| 431 | switch (e1i_ts->type) { |
| 432 | case E1INP_TS_TYPE_SIGN: |
| 433 | /* FIXME: implement this round robin */ |
| 434 | llist_for_each_entry(link, &e1i_ts->sign.sign_links, list) { |
| 435 | msg = msgb_dequeue(&link->tx_list); |
| 436 | if (msg) { |
| 437 | if (sign_link) |
| 438 | *sign_link = link; |
| 439 | break; |
| 440 | } |
| 441 | } |
| 442 | break; |
| 443 | case E1INP_TS_TYPE_TRAU: |
| 444 | msg = msgb_alloc(TSX_ALLOC_SIZE); |
| 445 | if (!msg) |
| 446 | return NULL; |
| 447 | len = subchan_mux_out(&e1i_ts->trau.mux, msg->data, 40); |
| 448 | msgb_put(msg, 40); |
| 449 | break; |
| 450 | default: |
| 451 | fprintf(stderr, "unsupported E1 TS type %u\n", e1i_ts->type); |
| 452 | return NULL; |
| 453 | } |
| 454 | return msg; |
| 455 | } |
| 456 | |
| 457 | /* called by driver in case some kind of link state event */ |
| 458 | int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi) |
| 459 | { |
| 460 | struct e1inp_sign_link *link; |
| 461 | |
| 462 | link = e1inp_lookup_sign_link(ts, tei, sapi); |
| 463 | if (!link) |
| 464 | return -EINVAL; |
| 465 | |
| 466 | /* FIXME: report further upwards */ |
Holger Freyther | ff9592f | 2009-03-09 16:17:14 +0000 | [diff] [blame] | 467 | input_event(evt, link->type, link->trx); |
| 468 | return 0; |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 469 | } |
| 470 | |
| 471 | /* register a driver with the E1 core */ |
| 472 | int e1inp_driver_register(struct e1inp_driver *drv) |
| 473 | { |
Harald Welte | 44d542e | 2009-03-10 18:24:35 +0000 | [diff] [blame] | 474 | llist_add_tail(&drv->list, &e1inp_driver_list); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 475 | return 0; |
| 476 | } |
| 477 | |
| 478 | /* register a line with the E1 core */ |
| 479 | int e1inp_line_register(struct e1inp_line *line) |
| 480 | { |
| 481 | int i; |
| 482 | |
Harald Welte | d256d4f | 2009-03-10 19:44:48 +0000 | [diff] [blame] | 483 | for (i = 0; i < NUM_E1_TS; i++) { |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 484 | line->ts[i].num = i+1; |
Harald Welte | d256d4f | 2009-03-10 19:44:48 +0000 | [diff] [blame] | 485 | line->ts[i].line = line; |
| 486 | } |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 487 | |
Harald Welte | 44d542e | 2009-03-10 18:24:35 +0000 | [diff] [blame] | 488 | llist_add_tail(&line->list, &e1inp_line_list); |
Harald Welte | 1fa60c8 | 2009-02-09 18:13:26 +0000 | [diff] [blame] | 489 | |
| 490 | return 0; |
| 491 | } |