blob: fae6b0ddcf39ff33c6674422ae663cb64238ead5 [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
289 fprintf(stdout, "BCHAN RX: ");
290 hexdump(msgb_l2(msg), ret - MISDN_HEADER_LEN);
291 if (!e1h->ts2_fd)
292 e1h->ts2_fd = open("/tmp/ts2.dump", O_WRONLY|O_APPEND|O_CREAT, 0660);
293
294 write(e1h->ts2_fd, msgb_l2(msg), ret - MISDN_HEADER_LEN);
295
296 break;
297 default:
298 DEBUGP(DMIB, "got unexpected 0x%x prim\n", hh->prim);
299 break;
300 }
301 return ret;
Harald Welte52b1f982008-12-23 20:25:15 +0000302}
303
Harald Welte8470bf22008-12-25 23:28:35 +0000304static int handle_tsX_write(struct bsc_fd *bfd)
Harald Welte52b1f982008-12-23 20:25:15 +0000305{
306 /* FIXME: write to a B channel TS */
Holger Freyther059c2542008-12-27 09:39:48 +0000307 return -1;
Harald Welte52b1f982008-12-23 20:25:15 +0000308}
309
310/* callback from select.c in case one of the fd's can be read/written */
Harald Welte8470bf22008-12-25 23:28:35 +0000311static int misdn_fd_cb(struct bsc_fd *bfd, unsigned int what)
Harald Welte52b1f982008-12-23 20:25:15 +0000312{
313 unsigned int e1_ts = bfd->priv_nr;
314 int rc = 0;
315
316 switch (e1_ts) {
317 case 1:
318 if (what & BSC_FD_READ)
319 rc = handle_ts1_read(bfd);
320 if (what & BSC_FD_WRITE)
321 rc = handle_ts1_write(bfd);
322 break;
323 default:
324 if (what & BSC_FD_READ)
325 rc = handle_tsX_read(bfd);
326 if (what & BSC_FD_WRITE)
327 rc = handle_tsX_write(bfd);
328 break;
329 }
330
331 return rc;
332}
333
Harald Welte8470bf22008-12-25 23:28:35 +0000334int abis_rsl_sendmsg(struct msgb *msg)
Harald Welte52b1f982008-12-23 20:25:15 +0000335{
Harald Welte8470bf22008-12-25 23:28:35 +0000336 struct mi_e1_handle *e1h = global_e1h;
337
Harald Weltead384642008-12-26 10:20:07 +0000338 msg->l2h = msg->data;
Harald Welte8470bf22008-12-25 23:28:35 +0000339 msgb_enqueue(&e1h->rsl_tx_list, msg);
340 e1h->fd[0].when |= BSC_FD_WRITE;
341
342 return 0;
343}
344
Harald Weltead384642008-12-26 10:20:07 +0000345int _abis_nm_sendmsg(struct msgb *msg)
Harald Welte8470bf22008-12-25 23:28:35 +0000346{
347 struct mi_e1_handle *e1h = global_e1h;
348
Harald Weltead384642008-12-26 10:20:07 +0000349 msg->l2h = msg->data;
Harald Welte8470bf22008-12-25 23:28:35 +0000350 msgb_enqueue(&e1h->oml_tx_list, msg);
351 e1h->fd[0].when |= BSC_FD_WRITE;
352
353 return 0;
354}
355
Harald Weltee9a82612008-12-27 16:45:29 +0000356static int activate_bchan(struct mi_e1_handle *e1h, int ts)
357{
358 struct mISDNhead hh;
359 int ret;
360 struct bsc_fd *bfd = &e1h->fd[ts-1];
361
362 fprintf(stdout, "activate bchan\n");
363 hh.prim = PH_ACTIVATE_REQ;
364 hh.id = MISDN_ID_ANY;
365 ret = sendto(bfd->fd, &hh, sizeof(hh), 0, NULL, 0);
366 if (ret < 0) {
367 fprintf(stdout, "could not send ACTIVATE_RQ %s\n",
368 strerror(errno));
369 return 0;
370 }
371
372 return ret;
373}
374
Harald Welte8470bf22008-12-25 23:28:35 +0000375static int mi_e1_setup(struct mi_e1_handle *e1h)
376{
377 int ts, sk, ret, cnt;
378 struct mISDN_devinfo devinfo;
Harald Welte52b1f982008-12-23 20:25:15 +0000379
380 sk = socket(PF_ISDN, SOCK_RAW, ISDN_P_BASE);
Harald Welte8470bf22008-12-25 23:28:35 +0000381 if (sk < 0) {
Harald Welte52b1f982008-12-23 20:25:15 +0000382 fprintf(stderr, "could not open socket %s\n", strerror(errno));
383 return sk;
384 }
385
386 ret = ioctl(sk, IMGETCOUNT, &cnt);
387 if (ret) {
388 fprintf(stderr, "error getting interf count: %s\n",
389 strerror(errno));
390 close(sk);
391 return -ENODEV;
392 }
Harald Weltead384642008-12-26 10:20:07 +0000393 //DEBUGP(DMI,"%d device%s found\n", cnt, (cnt==1)?"":"s");
394 printf("%d device%s found\n", cnt, (cnt==1)?"":"s");
395#if 1
396 devinfo.id = e1h->cardnr;
Harald Welte52b1f982008-12-23 20:25:15 +0000397 ret = ioctl(sk, IMGETDEVINFO, &devinfo);
398 if (ret < 0) {
399 fprintf(stdout, "error getting info for device %d: %s\n",
Harald Weltead384642008-12-26 10:20:07 +0000400 e1h->cardnr, strerror(errno));
Harald Welte52b1f982008-12-23 20:25:15 +0000401 return -ENODEV;
402 }
403 fprintf(stdout, " id: %d\n", devinfo.id);
404 fprintf(stdout, " Dprotocols: %08x\n", devinfo.Dprotocols);
405 fprintf(stdout, " Bprotocols: %08x\n", devinfo.Bprotocols);
406 fprintf(stdout, " protocol: %d\n", devinfo.protocol);
407 fprintf(stdout, " nrbchan: %d\n", devinfo.nrbchan);
408 fprintf(stdout, " name: %s\n", devinfo.name);
409#endif
410
411 /* TS0 is CRC4, don't need any fd for it */
412 for (ts = 1; ts < NUM_E1_TS; ts++) {
Harald Welte8470bf22008-12-25 23:28:35 +0000413 unsigned int idx = ts-1;
Harald Welte52b1f982008-12-23 20:25:15 +0000414 struct bsc_fd *bfd = &e1h->fd[idx];
415 struct sockaddr_mISDN addr;
416
Harald Welte8470bf22008-12-25 23:28:35 +0000417 bfd->data = e1h;
418 bfd->priv_nr = ts;
419 bfd->cb = misdn_fd_cb;
420
421 if (ts == 1) {
Harald Weltead384642008-12-26 10:20:07 +0000422 bfd->fd = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_LAPD_NT);
Harald Welte8470bf22008-12-25 23:28:35 +0000423 bfd->when = BSC_FD_READ;
424 } else
Harald Welte52b1f982008-12-23 20:25:15 +0000425 bfd->fd = socket(PF_ISDN, SOCK_DGRAM, ISDN_P_B_RAW);
426
Harald Welte8470bf22008-12-25 23:28:35 +0000427 if (bfd->fd < 0) {
Harald Welte52b1f982008-12-23 20:25:15 +0000428 fprintf(stderr, "could not open socket %s\n",
429 strerror(errno));
430 return bfd->fd;
431 }
432
433 memset(&addr, 0, sizeof(addr));
434 addr.family = AF_ISDN;
435 addr.dev = e1h->cardnr;
436 if (ts == 1) {
437 addr.channel = 0;
438 addr.sapi = 0;/* SAPI not supported yet in kernel */
439 addr.tei = TEI_L2ML;
440 } else
441 addr.channel = ts;
442
443 ret = bind(bfd->fd, (struct sockaddr *) &addr, sizeof(addr));
444 if (ret < 0) {
Harald Welte8470bf22008-12-25 23:28:35 +0000445 fprintf(stderr, "could not bind l2 socket %s\n",
Harald Welte52b1f982008-12-23 20:25:15 +0000446 strerror(errno));
447 return -EIO;
448 }
Harald Welte8470bf22008-12-25 23:28:35 +0000449
Harald Weltee9a82612008-12-27 16:45:29 +0000450 if (ts == 2) {
451 bfd->when = BSC_FD_READ;
452 activate_bchan(e1h, ts);
453 }
454
Harald Welte8470bf22008-12-25 23:28:35 +0000455 ret = bsc_register_fd(bfd);
456 if (ret < 0) {
457 fprintf(stderr, "could not register FD: %s\n",
458 strerror(ret));
459 return ret;
460 }
Harald Welte52b1f982008-12-23 20:25:15 +0000461 }
Harald Welte8470bf22008-12-25 23:28:35 +0000462
463 return 0;
Harald Welte52b1f982008-12-23 20:25:15 +0000464}
465
Harald Weltead384642008-12-26 10:20:07 +0000466int mi_setup(struct gsm_bts *bts, int cardnr,
467 void (cb)(int event, struct gsm_bts *bts))
Harald Welte8470bf22008-12-25 23:28:35 +0000468{
469 struct mi_e1_handle *e1h;
470
471 e1h = malloc(sizeof(*e1h));
472 memset(e1h, 0, sizeof(*e1h));
473
474 e1h->cardnr = cardnr;
475 e1h->bts = bts;
Harald Weltead384642008-12-26 10:20:07 +0000476 e1h->cb = cb;
Harald Welte8470bf22008-12-25 23:28:35 +0000477 INIT_LLIST_HEAD(&e1h->oml_tx_list);
478 INIT_LLIST_HEAD(&e1h->rsl_tx_list);
479
480 global_e1h = e1h;
481
482 return mi_e1_setup(e1h);
483}