blob: e4d9202326566b81892f9dc2295b1efdeb1b8c72 [file] [log] [blame]
Harald Welte8470bf22008-12-25 23:28:35 +00001/* OpenBSC Abis interface to mISDNuser */
2
3/* (C) 2008 by Harald Welte <laforge@gnumonks.org>
Harald Welte52b1f982008-12-23 20:25:15 +00004 *
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>
Harald Weltee9a82612008-12-27 16:45:29 +000028#include <sys/fcntl.h>
Harald Welte52b1f982008-12-23 20:25:15 +000029#include <sys/types.h>
30#include <sys/socket.h>
31#include <sys/ioctl.h>
32#include <mISDNif.h>
33
Harald Welte8470bf22008-12-25 23:28:35 +000034//#define AF_COMPATIBILITY_FUNC
35//#include <compat_af_isdn.h>
36#define AF_ISDN 34
37#define PF_ISDN AF_ISDN
38
39#include <openbsc/select.h>
40#include <openbsc/msgb.h>
41#include <openbsc/debug.h>
42#include <openbsc/gsm_data.h>
43#include <openbsc/abis_nm.h>
44#include <openbsc/abis_rsl.h>
Harald Welte52b1f982008-12-23 20:25:15 +000045
46#define NUM_E1_TS 32
47
48/* data structure for one E1 interface with A-bis */
49struct mi_e1_handle {
50 struct gsm_bts *bts;
Harald Welte52b1f982008-12-23 20:25:15 +000051 /* The mISDN card number of the card we use */
52 int cardnr;
Harald Welte52b1f982008-12-23 20:25:15 +000053 /* The RSL adress */
54 struct sockaddr_mISDN l2addr;
Harald Welte52b1f982008-12-23 20:25:15 +000055 /* The OML adress */
56 struct sockaddr_mISDN omladdr;
Harald Welte8470bf22008-12-25 23:28:35 +000057 /* list (queue) of to-be-sent msgb's */
58 struct llist_head rsl_tx_list;
59 struct llist_head oml_tx_list;
Harald Welte52b1f982008-12-23 20:25:15 +000060
Harald Weltead384642008-12-26 10:20:07 +000061 void (*cb)(int event, struct gsm_bts *bts);
Harald Welte8470bf22008-12-25 23:28:35 +000062 struct bsc_fd fd[NUM_E1_TS];
Harald Weltee9a82612008-12-27 16:45:29 +000063
64 int ts2_fd;
Harald Welte52b1f982008-12-23 20:25:15 +000065};
66
Harald Welte8470bf22008-12-25 23:28:35 +000067/* FIXME: this needs to go */
68static struct mi_e1_handle *global_e1h;
69
Harald Welte52b1f982008-12-23 20:25:15 +000070#define SAPI_L2ML 0
71#define SAPI_OML 62
Harald Weltead384642008-12-26 10:20:07 +000072#define SAPI_RSL 0 /* 63 ? */
Harald Welte52b1f982008-12-23 20:25:15 +000073
74#define TEI_L2ML 127
75#define TEI_OML 25
76#define TEI_RSL 1
77
Harald Welte702d8702008-12-26 20:25:35 +000078void hexdump(unsigned char *buf, int len)
Harald Welte52b1f982008-12-23 20:25:15 +000079{
80 int i;
81 for (i = 0; i < len; i++) {
82 fprintf(stdout, "%02x ", buf[i]);
83 }
84 fprintf(stdout, "\n");
85}
86
87#define TS1_ALLOC_SIZE 300
88
89static int handle_ts1_read(struct bsc_fd *bfd)
90{
91 struct mi_e1_handle *e1h = bfd->data;
92 struct msgb *msg = msgb_alloc(TS1_ALLOC_SIZE);
Harald Welte8470bf22008-12-25 23:28:35 +000093 struct sockaddr_mISDN l2addr;
94 struct mISDNhead *hh;
Harald Welte52b1f982008-12-23 20:25:15 +000095 socklen_t alen;
Harald Welte8470bf22008-12-25 23:28:35 +000096 int ret;
Harald Welte52b1f982008-12-23 20:25:15 +000097
98 if (!msg)
99 return -ENOMEM;
100
Harald Welte8470bf22008-12-25 23:28:35 +0000101 hh = (struct mISDNhead *) msg->data;
102
103 /* FIXME: Map TEI/SAPI to TRX */
104 msg->trx = e1h->bts->c0;
Harald Welte52b1f982008-12-23 20:25:15 +0000105
106 alen = sizeof(l2addr);
107 ret = recvfrom(bfd->fd, msg->data, 300, 0,
108 (struct sockaddr *) &l2addr, &alen);
109 if (ret < 0) {
110 fprintf(stderr, "recvfrom error %s\n", strerror(errno));
111 return ret;
112 }
113
114 if (alen != sizeof(l2addr))
115 return -EINVAL;
116
117 msgb_put(msg, ret);
118
119 DEBUGP(DMI, "alen =%d, dev(%d) channel(%d) sapi(%d) tei(%d)\n",
120 alen, l2addr.dev, l2addr.channel, l2addr.sapi, l2addr.tei);
121
122 DEBUGP(DMI, "<= len = %d, prim(0x%x) id(0x%x)\n",
123 ret, hh->prim, hh->id);
124
125 switch (hh->prim) {
126 case DL_INFORMATION_IND:
127 DEBUGP(DMI, "got DL_INFORMATION_IND\n");
Harald Welte8470bf22008-12-25 23:28:35 +0000128 struct sockaddr_mISDN *sa = NULL;
Harald Welte52b1f982008-12-23 20:25:15 +0000129 char *lstr = "UNKN";
130
131 switch (l2addr.tei) {
132 case TEI_OML:
133 sa = &e1h->omladdr;
134 lstr = "OML";
135 break;
136 case TEI_RSL:
137 sa = &e1h->l2addr;
138 lstr = "RSL";
139 break;
140 default:
Harald Welte8470bf22008-12-25 23:28:35 +0000141 break;
Harald Welte52b1f982008-12-23 20:25:15 +0000142 }
Harald Welte8470bf22008-12-25 23:28:35 +0000143 if (sa) {
144 DEBUGP(DMI, "%s use channel(%d) sapi(%d) tei(%d) for now\n",
145 lstr, l2addr.channel, l2addr.sapi, l2addr.tei);
146 memcpy(sa, &l2addr, sizeof(l2addr));
147 }
Harald Welte52b1f982008-12-23 20:25:15 +0000148 break;
149 case DL_ESTABLISH_IND:
150 DEBUGP(DMI, "got DL_ESTABLISH_IND\n");
151 break;
152 case DL_ESTABLISH_CNF:
153 DEBUGP(DMI, "got DL_ESTABLISH_CNF\n");
154 break;
155 case DL_RELEASE_IND:
Harald Weltead384642008-12-26 10:20:07 +0000156 DEBUGP(DMI, "got DL_RELEASE_IND: E1 Layer 1 disappeared?\n");
Harald Welte52b1f982008-12-23 20:25:15 +0000157 break;
158 case MPH_ACTIVATE_IND:
159 DEBUGP(DMI, "got MPH_ACTIVATE_IND\n");
Harald Weltead384642008-12-26 10:20:07 +0000160 if (l2addr.tei == TEI_OML && l2addr.sapi == SAPI_OML)
161 e1h->cb(EVT_E1_OML_UP, e1h->bts);
162 else if (l2addr.tei == TEI_RSL && l2addr.sapi == SAPI_RSL)
163 e1h->cb(EVT_E1_RSL_UP, e1h->bts);
Harald Welte52b1f982008-12-23 20:25:15 +0000164 break;
165 case MPH_DEACTIVATE_IND:
Harald Weltead384642008-12-26 10:20:07 +0000166 DEBUGP(DMI, "got MPH_DEACTIVATE_IND: TEI link closed?\n");
167 if (l2addr.tei == TEI_OML && l2addr.sapi == SAPI_OML)
168 e1h->cb(EVT_E1_OML_DN, e1h->bts);
169 else if (l2addr.tei == TEI_RSL && l2addr.sapi == SAPI_RSL)
170 e1h->cb(EVT_E1_RSL_DN, e1h->bts);
171 break;
Harald Welte52b1f982008-12-23 20:25:15 +0000172 case DL_DATA_IND:
173 DEBUGP(DMI, "got DL_DATA_IND\n");
Harald Weltead384642008-12-26 10:20:07 +0000174
Harald Weltead384642008-12-26 10:20:07 +0000175 msg->l2h = msg->data + MISDN_HEADER_LEN;
176
177 fprintf(stdout, "RX: ");
Harald Welte52b1f982008-12-23 20:25:15 +0000178 hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN);
179 switch (l2addr.tei) {
180 case TEI_OML:
181 ret = abis_nm_rcvmsg(msg);
182 break;
183 case TEI_RSL:
184 ret = abis_rsl_rcvmsg(msg);
185 break;
186 default:
187 fprintf(stderr, "DATA_IND for unknown TEI\n");
188 break;
189 }
190 break;
191 default:
192 DEBUGP(DMI, "got unexpected 0x%x prim\n", hh->prim);
193 break;
194 }
195 return ret;
196}
197
198static int handle_ts1_write(struct bsc_fd *bfd)
199{
200 struct mi_e1_handle *e1h = bfd->data;
Harald Welte8470bf22008-12-25 23:28:35 +0000201 struct msgb *msg;
202 struct mISDNhead *hh;
Harald Weltead384642008-12-26 10:20:07 +0000203 int ret, no_oml = 0;
Harald Welte52b1f982008-12-23 20:25:15 +0000204
Harald Weltead384642008-12-26 10:20:07 +0000205 msg = msgb_dequeue(&e1h->oml_tx_list);
Harald Welte8470bf22008-12-25 23:28:35 +0000206 if (!msg)
Harald Weltead384642008-12-26 10:20:07 +0000207 no_oml = 1;
Harald Welte8470bf22008-12-25 23:28:35 +0000208 else {
Harald Weltead384642008-12-26 10:20:07 +0000209 u_int8_t *l2_data = msg->data;
210
Harald Welte8470bf22008-12-25 23:28:35 +0000211 /* prepend the mISDNhead */
212 hh = (struct mISDNhead *) msgb_push(msg, sizeof(*hh));
213 hh->prim = DL_DATA_REQ;
Harald Welte52b1f982008-12-23 20:25:15 +0000214
Harald Weltead384642008-12-26 10:20:07 +0000215 fprintf(stdout, "OML TX: ");
216 hexdump(l2_data, msg->len - MISDN_HEADER_LEN);
217
Harald Welte8470bf22008-12-25 23:28:35 +0000218 ret = sendto(bfd->fd, msg->data, msg->len, 0,
Harald Welte5d2f8ec2008-12-26 10:46:24 +0000219 (struct sockaddr *)&e1h->omladdr,
220 sizeof(e1h->omladdr));
Harald Weltee571fb82008-12-25 23:50:30 +0000221 msgb_free(msg);
Harald Welte8470bf22008-12-25 23:28:35 +0000222 usleep(100000);
Harald Weltead384642008-12-26 10:20:07 +0000223 /* we always dequeue all OML messages */
224 return ret;
Harald Welte8470bf22008-12-25 23:28:35 +0000225 }
Harald Weltead384642008-12-26 10:20:07 +0000226
Harald Welte8470bf22008-12-25 23:28:35 +0000227 msg = msgb_dequeue(&e1h->rsl_tx_list);
228 if (!msg) {
Harald Weltead384642008-12-26 10:20:07 +0000229 if (no_oml)
Harald Welte8470bf22008-12-25 23:28:35 +0000230 bfd->when &= ~BSC_FD_WRITE;
231 } else {
Harald Weltead384642008-12-26 10:20:07 +0000232 u_int8_t *l2_data = msg->data;
233
Harald Welte8470bf22008-12-25 23:28:35 +0000234 /* prepend the mISDNhead */
235 hh = (struct mISDNhead *) msgb_push(msg, sizeof(*hh));
236 hh->prim = DL_DATA_REQ;
237
Harald Weltead384642008-12-26 10:20:07 +0000238 fprintf(stdout, "RSL TX: ");
239 hexdump(l2_data, msg->len - MISDN_HEADER_LEN);
240
Harald Welte8470bf22008-12-25 23:28:35 +0000241 ret = sendto(bfd->fd, msg->data, msg->len, 0,
Harald Welte5d2f8ec2008-12-26 10:46:24 +0000242 (struct sockaddr *)&e1h->l2addr,
243 sizeof(e1h->l2addr));
Harald Weltee571fb82008-12-25 23:50:30 +0000244 msgb_free(msg);
Harald Welteb2750422008-12-27 11:24:23 +0000245 usleep(10000);
Harald Welte702d8702008-12-26 20:25:35 +0000246 //sleep(1);
Harald Welte8470bf22008-12-25 23:28:35 +0000247 }
248
249 return ret;
Harald Welte52b1f982008-12-23 20:25:15 +0000250}
251
Harald Weltee9a82612008-12-27 16:45:29 +0000252#define TSX_ALLOC_SIZE 4096
253
254/* FIXME: read from a B channel TS */
Harald Welte52b1f982008-12-23 20:25:15 +0000255static int handle_tsX_read(struct bsc_fd *bfd)
256{
Harald Weltee9a82612008-12-27 16:45:29 +0000257 struct mi_e1_handle *e1h = bfd->data;
258 struct msgb *msg = msgb_alloc(TSX_ALLOC_SIZE);
259 struct mISDNhead *hh;
260 int ret;
261
262 if (!msg)
263 return -ENOMEM;
264
265 hh = (struct mISDNhead *) msg->data;
266
267 /* FIXME: Map TEI/SAPI to TRX */
268 msg->trx = e1h->bts->c0;
269
270 ret = recv(bfd->fd, msg->data, TSX_ALLOC_SIZE, 0);
271 if (ret < 0) {
272 fprintf(stderr, "recvfrom error %s\n", strerror(errno));
273 return ret;
274 }
275
276 msgb_put(msg, ret);
277
278 DEBUGP(DMIB, "<= BCHAN len = %d, prim(0x%x) id(0x%x)\n", ret, hh->prim, hh->id);
279
280 switch (hh->prim) {
281 case PH_CONTROL_IND:
282 DEBUGP(DMIB, "got PH_CONTROL_IND\n");
283 break;
284 case PH_DATA_IND:
285 DEBUGP(DMIB, "got PH_DATA_IND\n");
286
287 msg->l2h = msg->data + MISDN_HEADER_LEN;
288
Harald Welte75a983f2008-12-27 21:34:06 +0000289#if 0
Harald Weltee9a82612008-12-27 16:45:29 +0000290 fprintf(stdout, "BCHAN RX: ");
291 hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN);
Harald Welte75a983f2008-12-27 21:34:06 +0000292#endif
Harald Weltee9a82612008-12-27 16:45:29 +0000293 if (!e1h->ts2_fd)
294 e1h->ts2_fd = open("/tmp/ts2.dump", O_WRONLY|O_APPEND|O_CREAT, 0660);
295
296 write(e1h->ts2_fd, msgb_l2(msg), ret - MISDN_HEADER_LEN);
297
298 break;
299 default:
300 DEBUGP(DMIB, "got unexpected 0x%x prim\n", hh->prim);
301 break;
302 }
Harald Weltee27bb342008-12-29 06:06:35 +0000303 /* FIXME: don't free it if we still hold reference! */
304 msgb_free(msg);
305
Harald Weltee9a82612008-12-27 16:45:29 +0000306 return ret;
Harald Welte52b1f982008-12-23 20:25:15 +0000307}
308
Harald Welte8470bf22008-12-25 23:28:35 +0000309static int handle_tsX_write(struct bsc_fd *bfd)
Harald Welte52b1f982008-12-23 20:25:15 +0000310{
311 /* FIXME: write to a B channel TS */
Holger Freyther059c2542008-12-27 09:39:48 +0000312 return -1;
Harald Welte52b1f982008-12-23 20:25:15 +0000313}
314
315/* callback from select.c in case one of the fd's can be read/written */
Harald Welte8470bf22008-12-25 23:28:35 +0000316static int misdn_fd_cb(struct bsc_fd *bfd, unsigned int what)
Harald Welte52b1f982008-12-23 20:25:15 +0000317{
318 unsigned int e1_ts = bfd->priv_nr;
319 int rc = 0;
320
321 switch (e1_ts) {
322 case 1:
323 if (what & BSC_FD_READ)
324 rc = handle_ts1_read(bfd);
325 if (what & BSC_FD_WRITE)
326 rc = handle_ts1_write(bfd);
327 break;
328 default:
329 if (what & BSC_FD_READ)
330 rc = handle_tsX_read(bfd);
331 if (what & BSC_FD_WRITE)
332 rc = handle_tsX_write(bfd);
333 break;
334 }
335
336 return rc;
337}
338
Harald Welte8470bf22008-12-25 23:28:35 +0000339int abis_rsl_sendmsg(struct msgb *msg)
Harald Welte52b1f982008-12-23 20:25:15 +0000340{
Harald Welte8470bf22008-12-25 23:28:35 +0000341 struct mi_e1_handle *e1h = global_e1h;
342
Harald Weltead384642008-12-26 10:20:07 +0000343 msg->l2h = msg->data;
Harald Welte8470bf22008-12-25 23:28:35 +0000344 msgb_enqueue(&e1h->rsl_tx_list, msg);
345 e1h->fd[0].when |= BSC_FD_WRITE;
346
347 return 0;
348}
349
Harald Weltead384642008-12-26 10:20:07 +0000350int _abis_nm_sendmsg(struct msgb *msg)
Harald Welte8470bf22008-12-25 23:28:35 +0000351{
352 struct mi_e1_handle *e1h = global_e1h;
353
Harald Weltead384642008-12-26 10:20:07 +0000354 msg->l2h = msg->data;
Harald Welte8470bf22008-12-25 23:28:35 +0000355 msgb_enqueue(&e1h->oml_tx_list, msg);
356 e1h->fd[0].when |= BSC_FD_WRITE;
357
358 return 0;
359}
360
Harald Weltee9a82612008-12-27 16:45:29 +0000361static int activate_bchan(struct mi_e1_handle *e1h, int ts)
362{
363 struct mISDNhead hh;
364 int ret;
365 struct bsc_fd *bfd = &e1h->fd[ts-1];
366
367 fprintf(stdout, "activate bchan\n");
368 hh.prim = PH_ACTIVATE_REQ;
369 hh.id = MISDN_ID_ANY;
370 ret = sendto(bfd->fd, &hh, sizeof(hh), 0, NULL, 0);
371 if (ret < 0) {
372 fprintf(stdout, "could not send ACTIVATE_RQ %s\n",
373 strerror(errno));
374 return 0;
375 }
376
377 return ret;
378}
379
Harald Welte8470bf22008-12-25 23:28:35 +0000380static int mi_e1_setup(struct mi_e1_handle *e1h)
381{
382 int ts, sk, ret, cnt;
383 struct mISDN_devinfo devinfo;
Harald Welte52b1f982008-12-23 20:25:15 +0000384
385 sk = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
Harald Welte8470bf22008-12-25 23:28:35 +0000386 if (sk < 0) {
Harald Welte52b1f982008-12-23 20:25:15 +0000387 fprintf(stderr, "could not open socket %s\n", strerror(errno));
388 return sk;
389 }
390
391 ret = ioctl(sk, IMGETCOUNT, &cnt);
392 if (ret) {
393 fprintf(stderr, "error getting interf count: %s\n",
394 strerror(errno));
395 close(sk);
396 return -ENODEV;
397 }
Harald Weltead384642008-12-26 10:20:07 +0000398 //DEBUGP(DMI,"%d device%s found\n", cnt, (cnt==1)?"":"s");
399 printf("%d device%s found\n", cnt, (cnt==1)?"":"s");
400#if 1
401 devinfo.id = e1h->cardnr;
Harald Welte52b1f982008-12-23 20:25:15 +0000402 ret = ioctl(sk, IMGETDEVINFO, &devinfo);
403 if (ret < 0) {
404 fprintf(stdout, "error getting info for device %d: %s\n",
Harald Weltead384642008-12-26 10:20:07 +0000405 e1h->cardnr, strerror(errno));
Harald Welte52b1f982008-12-23 20:25:15 +0000406 return -ENODEV;
407 }
408 fprintf(stdout, " id: %d\n", devinfo.id);
409 fprintf(stdout, " Dprotocols: %08x\n", devinfo.Dprotocols);
410 fprintf(stdout, " Bprotocols: %08x\n", devinfo.Bprotocols);
411 fprintf(stdout, " protocol: %d\n", devinfo.protocol);
412 fprintf(stdout, " nrbchan: %d\n", devinfo.nrbchan);
413 fprintf(stdout, " name: %s\n", devinfo.name);
414#endif
415
416 /* TS0 is CRC4, don't need any fd for it */
417 for (ts = 1; ts < NUM_E1_TS; ts++) {
Harald Welte8470bf22008-12-25 23:28:35 +0000418 unsigned int idx = ts-1;
Harald Welte52b1f982008-12-23 20:25:15 +0000419 struct bsc_fd *bfd = &e1h->fd[idx];
420 struct sockaddr_mISDN addr;
421
Harald Welte8470bf22008-12-25 23:28:35 +0000422 bfd->data = e1h;
423 bfd->priv_nr = ts;
424 bfd->cb = misdn_fd_cb;
425
426 if (ts == 1) {
Harald Weltead384642008-12-26 10:20:07 +0000427 bfd->fd = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_LAPD_NT);
Harald Welte8470bf22008-12-25 23:28:35 +0000428 bfd->when = BSC_FD_READ;
429 } else
Harald Welte52b1f982008-12-23 20:25:15 +0000430 bfd->fd = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_RAW);
431
Harald Welte8470bf22008-12-25 23:28:35 +0000432 if (bfd->fd < 0) {
Harald Welte52b1f982008-12-23 20:25:15 +0000433 fprintf(stderr, "could not open socket %s\n",
434 strerror(errno));
435 return bfd->fd;
436 }
437
438 memset(&addr, 0, sizeof(addr));
439 addr.family = AF_ISDN;
440 addr.dev = e1h->cardnr;
441 if (ts == 1) {
442 addr.channel = 0;
443 addr.sapi = 0;/* SAPI not supported yet in kernel */
444 addr.tei = TEI_L2ML;
445 } else
446 addr.channel = ts;
447
448 ret = bind(bfd->fd, (struct sockaddr *) &addr, sizeof(addr));
449 if (ret < 0) {
Harald Welte8470bf22008-12-25 23:28:35 +0000450 fprintf(stderr, "could not bind l2 socket %s\n",
Harald Welte52b1f982008-12-23 20:25:15 +0000451 strerror(errno));
452 return -EIO;
453 }
Harald Welte8470bf22008-12-25 23:28:35 +0000454
Harald Weltee9a82612008-12-27 16:45:29 +0000455 if (ts == 2) {
456 bfd->when = BSC_FD_READ;
457 activate_bchan(e1h, ts);
458 }
459
Harald Welte8470bf22008-12-25 23:28:35 +0000460 ret = bsc_register_fd(bfd);
461 if (ret < 0) {
462 fprintf(stderr, "could not register FD: %s\n",
463 strerror(ret));
464 return ret;
465 }
Harald Welte52b1f982008-12-23 20:25:15 +0000466 }
Harald Welte8470bf22008-12-25 23:28:35 +0000467
468 return 0;
Harald Welte52b1f982008-12-23 20:25:15 +0000469}
470
Harald Weltead384642008-12-26 10:20:07 +0000471int mi_setup(struct gsm_bts *bts, int cardnr,
472 void (cb)(int event, struct gsm_bts *bts))
Harald Welte8470bf22008-12-25 23:28:35 +0000473{
474 struct mi_e1_handle *e1h;
475
476 e1h = malloc(sizeof(*e1h));
477 memset(e1h, 0, sizeof(*e1h));
478
479 e1h->cardnr = cardnr;
480 e1h->bts = bts;
Harald Weltead384642008-12-26 10:20:07 +0000481 e1h->cb = cb;
Harald Welte8470bf22008-12-25 23:28:35 +0000482 INIT_LLIST_HEAD(&e1h->oml_tx_list);
483 INIT_LLIST_HEAD(&e1h->rsl_tx_list);
484
485 global_e1h = e1h;
486
487 return mi_e1_setup(e1h);
488}