Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [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> |
| 38 | #ifndef AF_ISDN |
| 39 | #define AF_ISDN 34 |
| 40 | #define PF_ISDN AF_ISDN |
| 41 | #endif |
| 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_frame.h> |
| 53 | #include <openbsc/trau_mux.h> |
Harald Welte | a837977 | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 54 | #include <openbsc/talloc.h> |
Holger Hans Peter Freyther | 735cd9e | 2009-08-10 07:54:02 +0200 | [diff] [blame] | 55 | #include <openbsc/misdn.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 56 | |
| 57 | #define NUM_E1_TS 32 |
| 58 | |
| 59 | /* list of all E1 drivers */ |
| 60 | LLIST_HEAD(e1inp_driver_list); |
| 61 | |
| 62 | /* list of all E1 lines */ |
| 63 | LLIST_HEAD(e1inp_line_list); |
| 64 | |
Harald Welte | a837977 | 2009-06-20 22:36:41 +0200 | [diff] [blame] | 65 | static void *tall_sigl_ctx; |
| 66 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 67 | /* to be implemented, e.g. by bsc_hack.c */ |
| 68 | void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx); |
| 69 | |
| 70 | /* |
| 71 | * pcap writing of the misdn load |
| 72 | * pcap format is from http://wiki.wireshark.org/Development/LibpcapFileFormat |
| 73 | */ |
| 74 | #define DLT_LINUX_LAPD 177 |
| 75 | #define PCAP_INPUT 0 |
| 76 | #define PCAP_OUTPUT 1 |
| 77 | |
| 78 | struct pcap_hdr { |
| 79 | u_int32_t magic_number; |
| 80 | u_int16_t version_major; |
| 81 | u_int16_t version_minor; |
| 82 | int32_t thiszone; |
| 83 | u_int32_t sigfigs; |
| 84 | u_int32_t snaplen; |
| 85 | u_int32_t network; |
| 86 | } __attribute__((packed)); |
| 87 | |
| 88 | struct pcaprec_hdr { |
| 89 | u_int32_t ts_sec; |
| 90 | u_int32_t ts_usec; |
| 91 | u_int32_t incl_len; |
| 92 | u_int32_t orig_len; |
| 93 | } __attribute__((packed)); |
| 94 | |
| 95 | struct fake_linux_lapd_header { |
| 96 | u_int16_t pkttype; |
| 97 | u_int16_t hatype; |
| 98 | u_int16_t halen; |
| 99 | u_int64_t addr; |
| 100 | int16_t protocol; |
| 101 | } __attribute__((packed)); |
| 102 | |
| 103 | struct lapd_header { |
| 104 | u_int8_t ea1 : 1; |
| 105 | u_int8_t cr : 1; |
| 106 | u_int8_t sapi : 6; |
| 107 | u_int8_t ea2 : 1; |
| 108 | u_int8_t tei : 7; |
| 109 | u_int8_t control_foo; /* fake UM's ... */ |
| 110 | } __attribute__((packed)); |
| 111 | |
| 112 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->hatype == 2, hatype_offset); |
| 113 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->halen == 4, halen_offset); |
| 114 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->addr == 6, addr_offset); |
| 115 | static_assert((int)&((struct fake_linux_lapd_header*)NULL)->protocol == 14, proto_offset); |
| 116 | static_assert(sizeof(struct fake_linux_lapd_header) == 16, lapd_header_size); |
| 117 | |
| 118 | |
| 119 | static int pcap_fd = -1; |
| 120 | |
| 121 | void e1_set_pcap_fd(int fd) |
| 122 | { |
| 123 | int ret; |
| 124 | struct pcap_hdr header = { |
| 125 | .magic_number = 0xa1b2c3d4, |
| 126 | .version_major = 2, |
| 127 | .version_minor = 4, |
| 128 | .thiszone = 0, |
| 129 | .sigfigs = 0, |
| 130 | .snaplen = 65535, |
| 131 | .network = DLT_LINUX_LAPD, |
| 132 | }; |
| 133 | |
| 134 | pcap_fd = fd; |
| 135 | ret = write(pcap_fd, &header, sizeof(header)); |
| 136 | } |
| 137 | |
| 138 | /* This currently only works for the D-Channel */ |
| 139 | static void write_pcap_packet(int direction, int sapi, int tei, |
| 140 | struct msgb *msg) { |
| 141 | if (pcap_fd < 0) |
| 142 | return; |
| 143 | |
| 144 | int ret; |
| 145 | time_t cur_time; |
| 146 | struct tm *tm; |
Andreas Eversberg | b5a3e41 | 2009-06-10 14:47:33 +0200 | [diff] [blame] | 147 | int mi_head = (direction==PCAP_INPUT) ? MISDN_HEADER_LEN : 0; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 148 | |
| 149 | struct fake_linux_lapd_header header = { |
| 150 | .pkttype = 4, |
| 151 | .hatype = 0, |
| 152 | .halen = 0, |
| 153 | .addr = direction == PCAP_OUTPUT ? 0x0 : 0x1, |
| 154 | .protocol = ntohs(48), |
| 155 | }; |
| 156 | |
| 157 | struct lapd_header lapd_header = { |
| 158 | .ea1 = 0, |
| 159 | .cr = direction == PCAP_OUTPUT ? 1 : 0, |
| 160 | .sapi = sapi & 0x3F, |
| 161 | .ea2 = 1, |
| 162 | .tei = tei & 0x7F, |
| 163 | .control_foo = 0x03 /* UI */, |
| 164 | }; |
| 165 | |
| 166 | struct pcaprec_hdr payload_header = { |
| 167 | .ts_sec = 0, |
| 168 | .ts_usec = 0, |
| 169 | .incl_len = msg->len + sizeof(struct fake_linux_lapd_header) |
| 170 | + sizeof(struct lapd_header) |
Andreas Eversberg | b5a3e41 | 2009-06-10 14:47:33 +0200 | [diff] [blame] | 171 | - mi_head, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 172 | .orig_len = msg->len + sizeof(struct fake_linux_lapd_header) |
| 173 | + sizeof(struct lapd_header) |
Andreas Eversberg | b5a3e41 | 2009-06-10 14:47:33 +0200 | [diff] [blame] | 174 | - mi_head, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 175 | }; |
| 176 | |
| 177 | |
Andreas Eversberg | b5a3e41 | 2009-06-10 14:47:33 +0200 | [diff] [blame] | 178 | printf("Packet of: %d\n", direction); |
| 179 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 180 | cur_time = time(NULL); |
| 181 | tm = localtime(&cur_time); |
| 182 | payload_header.ts_sec = mktime(tm); |
| 183 | |
| 184 | ret = write(pcap_fd, &payload_header, sizeof(payload_header)); |
| 185 | ret = write(pcap_fd, &header, sizeof(header)); |
| 186 | ret = write(pcap_fd, &lapd_header, sizeof(lapd_header)); |
Andreas Eversberg | b5a3e41 | 2009-06-10 14:47:33 +0200 | [diff] [blame] | 187 | ret = write(pcap_fd, msg->data + mi_head, |
| 188 | msg->len - mi_head); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 189 | } |
| 190 | |
| 191 | static const char *sign_types[] = { |
| 192 | [E1INP_SIGN_NONE] = "None", |
| 193 | [E1INP_SIGN_OML] = "OML", |
| 194 | [E1INP_SIGN_RSL] = "RSL", |
| 195 | }; |
| 196 | const char *e1inp_signtype_name(enum e1inp_sign_type tp) |
| 197 | { |
| 198 | if (tp >= ARRAY_SIZE(sign_types)) |
| 199 | return "undefined"; |
| 200 | return sign_types[tp]; |
| 201 | } |
| 202 | |
| 203 | static const char *ts_types[] = { |
| 204 | [E1INP_TS_TYPE_NONE] = "None", |
| 205 | [E1INP_TS_TYPE_SIGN] = "Signalling", |
| 206 | [E1INP_TS_TYPE_TRAU] = "TRAU", |
| 207 | }; |
| 208 | |
| 209 | const char *e1inp_tstype_name(enum e1inp_ts_type tp) |
| 210 | { |
| 211 | if (tp >= ARRAY_SIZE(ts_types)) |
| 212 | return "undefined"; |
| 213 | return ts_types[tp]; |
| 214 | } |
| 215 | |
| 216 | /* callback when a TRAU frame was received */ |
| 217 | static int subch_cb(struct subch_demux *dmx, int ch, u_int8_t *data, int len, |
| 218 | void *_priv) |
| 219 | { |
| 220 | struct e1inp_ts *e1i_ts = _priv; |
| 221 | struct gsm_e1_subslot src_ss; |
| 222 | |
| 223 | src_ss.e1_nr = e1i_ts->line->num; |
| 224 | src_ss.e1_ts = e1i_ts->num; |
| 225 | src_ss.e1_ts_ss = ch; |
| 226 | |
| 227 | return trau_mux_input(&src_ss, data, len); |
| 228 | } |
| 229 | |
| 230 | int abis_rsl_sendmsg(struct msgb *msg) |
| 231 | { |
| 232 | struct e1inp_sign_link *sign_link; |
| 233 | struct e1inp_driver *e1inp_driver; |
| 234 | struct e1inp_ts *e1i_ts; |
| 235 | |
| 236 | msg->l2h = msg->data; |
| 237 | |
| 238 | if (!msg->trx || !msg->trx->rsl_link) { |
| 239 | fprintf(stderr, "rsl_sendmsg: msg->trx == NULL\n"); |
Harald Welte | ed83184 | 2009-06-27 03:09:08 +0200 | [diff] [blame] | 240 | talloc_free(msg); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 241 | return -EINVAL; |
| 242 | } |
| 243 | |
| 244 | sign_link = msg->trx->rsl_link; |
| 245 | e1i_ts = sign_link->ts; |
| 246 | if (!bsc_timer_pending(&e1i_ts->sign.tx_timer)) { |
| 247 | /* notify the driver we have something to write */ |
| 248 | e1inp_driver = sign_link->ts->line->driver; |
| 249 | e1inp_driver->want_write(e1i_ts); |
| 250 | } |
| 251 | msgb_enqueue(&sign_link->tx_list, msg); |
| 252 | |
| 253 | /* dump it */ |
| 254 | write_pcap_packet(PCAP_OUTPUT, sign_link->sapi, sign_link->tei, msg); |
| 255 | |
| 256 | return 0; |
| 257 | } |
| 258 | |
| 259 | int _abis_nm_sendmsg(struct msgb *msg) |
| 260 | { |
| 261 | struct e1inp_sign_link *sign_link; |
| 262 | struct e1inp_driver *e1inp_driver; |
| 263 | struct e1inp_ts *e1i_ts; |
| 264 | |
| 265 | msg->l2h = msg->data; |
| 266 | |
| 267 | if (!msg->trx || !msg->trx->bts || !msg->trx->bts->oml_link) { |
| 268 | fprintf(stderr, "nm_sendmsg: msg->trx == NULL\n"); |
| 269 | return -EINVAL; |
| 270 | } |
| 271 | |
| 272 | sign_link = msg->trx->bts->oml_link; |
| 273 | e1i_ts = sign_link->ts; |
| 274 | if (!bsc_timer_pending(&e1i_ts->sign.tx_timer)) { |
| 275 | /* notify the driver we have something to write */ |
| 276 | e1inp_driver = sign_link->ts->line->driver; |
| 277 | e1inp_driver->want_write(e1i_ts); |
| 278 | } |
| 279 | msgb_enqueue(&sign_link->tx_list, msg); |
| 280 | |
| 281 | /* dump it */ |
| 282 | write_pcap_packet(PCAP_OUTPUT, sign_link->sapi, sign_link->tei, msg); |
| 283 | |
| 284 | return 0; |
| 285 | } |
| 286 | |
| 287 | /* Timeslot */ |
| 288 | |
| 289 | /* configure and initialize one e1inp_ts */ |
| 290 | int e1inp_ts_config(struct e1inp_ts *ts, struct e1inp_line *line, |
| 291 | enum e1inp_ts_type type) |
| 292 | { |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 293 | if (ts->type == type && ts->line && line) |
| 294 | return 0; |
| 295 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 296 | ts->type = type; |
| 297 | ts->line = line; |
| 298 | |
| 299 | switch (type) { |
| 300 | case E1INP_TS_TYPE_SIGN: |
| 301 | INIT_LLIST_HEAD(&ts->sign.sign_links); |
| 302 | break; |
| 303 | case E1INP_TS_TYPE_TRAU: |
| 304 | subchan_mux_init(&ts->trau.mux); |
| 305 | ts->trau.demux.out_cb = subch_cb; |
| 306 | ts->trau.demux.data = ts; |
| 307 | subch_demux_init(&ts->trau.demux); |
| 308 | break; |
| 309 | default: |
| 310 | fprintf(stderr, "unsupported E1 timeslot type %u\n", |
| 311 | ts->type); |
| 312 | return -EINVAL; |
| 313 | } |
| 314 | return 0; |
| 315 | } |
| 316 | |
| 317 | static struct e1inp_line *e1inp_line_get(u_int8_t e1_nr) |
| 318 | { |
| 319 | struct e1inp_line *e1i_line; |
| 320 | |
| 321 | /* iterate over global list of e1 lines */ |
| 322 | llist_for_each_entry(e1i_line, &e1inp_line_list, list) { |
| 323 | if (e1i_line->num == e1_nr) |
| 324 | return e1i_line; |
| 325 | } |
| 326 | return NULL; |
| 327 | } |
| 328 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 329 | struct e1inp_line *e1inp_line_get_create(u_int8_t e1_nr) |
| 330 | { |
| 331 | struct e1inp_line *line; |
| 332 | int i; |
| 333 | |
| 334 | line = e1inp_line_get(e1_nr); |
| 335 | if (line) |
| 336 | return line; |
| 337 | |
| 338 | line = talloc_zero(tall_bsc_ctx, struct e1inp_line); |
| 339 | if (!line) |
| 340 | return NULL; |
| 341 | |
| 342 | line->num = e1_nr; |
| 343 | for (i = 0; i < NUM_E1_TS; i++) { |
| 344 | line->ts[i].num = i+1; |
| 345 | line->ts[i].line = line; |
| 346 | } |
| 347 | llist_add_tail(&line->list, &e1inp_line_list); |
| 348 | |
| 349 | return line; |
| 350 | } |
| 351 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 352 | static struct e1inp_ts *e1inp_ts_get(u_int8_t e1_nr, u_int8_t ts_nr) |
| 353 | { |
| 354 | struct e1inp_line *e1i_line; |
| 355 | |
| 356 | e1i_line = e1inp_line_get(e1_nr); |
| 357 | if (!e1i_line) |
| 358 | return NULL; |
| 359 | |
| 360 | return &e1i_line->ts[ts_nr-1]; |
| 361 | } |
| 362 | |
| 363 | struct subch_mux *e1inp_get_mux(u_int8_t e1_nr, u_int8_t ts_nr) |
| 364 | { |
| 365 | struct e1inp_ts *e1i_ts = e1inp_ts_get(e1_nr, ts_nr); |
| 366 | |
| 367 | if (!e1i_ts) |
| 368 | return NULL; |
| 369 | |
| 370 | return &e1i_ts->trau.mux; |
| 371 | } |
| 372 | |
| 373 | /* Signalling Link */ |
| 374 | |
| 375 | struct e1inp_sign_link *e1inp_lookup_sign_link(struct e1inp_ts *e1i, |
| 376 | u_int8_t tei, u_int8_t sapi) |
| 377 | { |
| 378 | struct e1inp_sign_link *link; |
| 379 | |
| 380 | llist_for_each_entry(link, &e1i->sign.sign_links, list) { |
| 381 | if (link->sapi == sapi && link->tei == tei) |
| 382 | return link; |
| 383 | } |
| 384 | |
| 385 | return NULL; |
| 386 | } |
| 387 | |
| 388 | /* create a new signalling link in a E1 timeslot */ |
| 389 | |
| 390 | struct e1inp_sign_link * |
| 391 | e1inp_sign_link_create(struct e1inp_ts *ts, enum e1inp_sign_type type, |
| 392 | struct gsm_bts_trx *trx, u_int8_t tei, |
| 393 | u_int8_t sapi) |
| 394 | { |
| 395 | struct e1inp_sign_link *link; |
| 396 | |
| 397 | if (ts->type != E1INP_TS_TYPE_SIGN) |
| 398 | return NULL; |
| 399 | |
Harald Welte | 857e00d | 2009-06-26 20:25:23 +0200 | [diff] [blame] | 400 | link = talloc_zero(tall_sigl_ctx, struct e1inp_sign_link); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 401 | if (!link) |
| 402 | return NULL; |
| 403 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 404 | link->ts = ts; |
| 405 | link->type = type; |
| 406 | INIT_LLIST_HEAD(&link->tx_list); |
| 407 | link->trx = trx; |
| 408 | link->tei = tei; |
| 409 | link->sapi = sapi; |
| 410 | |
| 411 | llist_add_tail(&link->list, &ts->sign.sign_links); |
| 412 | |
| 413 | return link; |
| 414 | } |
| 415 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 416 | void e1inp_sign_link_destroy(struct e1inp_sign_link *link) |
| 417 | { |
| 418 | llist_del(&link->list); |
| 419 | talloc_free(link); |
| 420 | } |
| 421 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 422 | /* the E1 driver tells us he has received something on a TS */ |
| 423 | int e1inp_rx_ts(struct e1inp_ts *ts, struct msgb *msg, |
| 424 | u_int8_t tei, u_int8_t sapi) |
| 425 | { |
| 426 | struct e1inp_sign_link *link; |
| 427 | int ret; |
| 428 | |
| 429 | switch (ts->type) { |
| 430 | case E1INP_TS_TYPE_SIGN: |
| 431 | /* consult the list of signalling links */ |
| 432 | write_pcap_packet(PCAP_INPUT, sapi, tei, msg); |
| 433 | link = e1inp_lookup_sign_link(ts, tei, sapi); |
| 434 | if (!link) { |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 435 | fprintf(stderr, "didn't find signalling link for " |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 436 | "tei %d, sapi %d\n", tei, sapi); |
| 437 | return -EINVAL; |
| 438 | } |
| 439 | switch (link->type) { |
| 440 | case E1INP_SIGN_OML: |
| 441 | msg->trx = link->trx; |
| 442 | ret = abis_nm_rcvmsg(msg); |
| 443 | break; |
| 444 | case E1INP_SIGN_RSL: |
| 445 | msg->trx = link->trx; |
| 446 | ret = abis_rsl_rcvmsg(msg); |
| 447 | break; |
| 448 | default: |
| 449 | ret = -EINVAL; |
| 450 | fprintf(stderr, "unknown link type %u\n", link->type); |
| 451 | break; |
| 452 | } |
| 453 | break; |
| 454 | case E1INP_TS_TYPE_TRAU: |
| 455 | ret = subch_demux_in(&ts->trau.demux, msg->l2h, msgb_l2len(msg)); |
| 456 | break; |
| 457 | default: |
| 458 | ret = -EINVAL; |
| 459 | fprintf(stderr, "unknown TS type %u\n", ts->type); |
| 460 | break; |
| 461 | } |
| 462 | |
| 463 | return ret; |
| 464 | } |
| 465 | |
| 466 | #define TSX_ALLOC_SIZE 4096 |
| 467 | |
| 468 | /* called by driver if it wants to transmit on a given TS */ |
| 469 | struct msgb *e1inp_tx_ts(struct e1inp_ts *e1i_ts, |
| 470 | struct e1inp_sign_link **sign_link) |
| 471 | { |
| 472 | struct e1inp_sign_link *link; |
| 473 | struct msgb *msg = NULL; |
| 474 | int len; |
| 475 | |
| 476 | switch (e1i_ts->type) { |
| 477 | case E1INP_TS_TYPE_SIGN: |
| 478 | /* FIXME: implement this round robin */ |
| 479 | llist_for_each_entry(link, &e1i_ts->sign.sign_links, list) { |
| 480 | msg = msgb_dequeue(&link->tx_list); |
| 481 | if (msg) { |
| 482 | if (sign_link) |
| 483 | *sign_link = link; |
| 484 | break; |
| 485 | } |
| 486 | } |
| 487 | break; |
| 488 | case E1INP_TS_TYPE_TRAU: |
Harald Welte | 9cfc935 | 2009-06-26 19:39:35 +0200 | [diff] [blame] | 489 | msg = msgb_alloc(TSX_ALLOC_SIZE, "TRAU_TX"); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 490 | if (!msg) |
| 491 | return NULL; |
| 492 | len = subchan_mux_out(&e1i_ts->trau.mux, msg->data, 40); |
| 493 | msgb_put(msg, 40); |
| 494 | break; |
| 495 | default: |
| 496 | fprintf(stderr, "unsupported E1 TS type %u\n", e1i_ts->type); |
| 497 | return NULL; |
| 498 | } |
| 499 | return msg; |
| 500 | } |
| 501 | |
| 502 | /* called by driver in case some kind of link state event */ |
| 503 | int e1inp_event(struct e1inp_ts *ts, int evt, u_int8_t tei, u_int8_t sapi) |
| 504 | { |
| 505 | struct e1inp_sign_link *link; |
| 506 | |
| 507 | link = e1inp_lookup_sign_link(ts, tei, sapi); |
| 508 | if (!link) |
| 509 | return -EINVAL; |
| 510 | |
| 511 | /* FIXME: report further upwards */ |
| 512 | input_event(evt, link->type, link->trx); |
| 513 | return 0; |
| 514 | } |
| 515 | |
| 516 | /* register a driver with the E1 core */ |
| 517 | int e1inp_driver_register(struct e1inp_driver *drv) |
| 518 | { |
| 519 | llist_add_tail(&drv->list, &e1inp_driver_list); |
| 520 | return 0; |
| 521 | } |
| 522 | |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 523 | int e1inp_line_update(struct e1inp_line *line) |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 524 | { |
Harald Welte | 6286888 | 2009-08-08 16:12:58 +0200 | [diff] [blame] | 525 | return mi_e1_line_update(line); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 526 | } |
Harald Welte | 932e20d | 2009-07-28 00:41:45 +0200 | [diff] [blame] | 527 | |
| 528 | static __attribute__((constructor)) void on_dso_load_e1_inp(void) |
| 529 | { |
| 530 | tall_sigl_ctx = talloc_named_const(tall_bsc_ctx, 1, |
| 531 | "e1inp_sign_link"); |
| 532 | } |