blob: f9746c2a4354a092de31941abd5fca654c709fc8 [file] [log] [blame]
Harald Welte59b04682009-06-10 05:40:52 +08001/* ip.access nanoBTS configuration tool */
2
3/* (C) 2009 by Harald Welte <laforge@gnumonks.org>
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +01004 * (C) 2009 by Holger Hans Peter Freyther
5 * (C) 2009 by On Waves
Harald Welte59b04682009-06-10 05:40:52 +08006 * All Rights Reserved
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; if not, write to the Free Software Foundation, Inc.,
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 */
23
24#include <unistd.h>
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <getopt.h>
29#include <sys/types.h>
30
31#include <sys/socket.h>
32#include <netinet/in.h>
33#include <arpa/inet.h>
34
35
36#include <openbsc/select.h>
37#include <openbsc/timer.h>
38#include <openbsc/ipaccess.h>
39#include <openbsc/gsm_data.h>
40#include <openbsc/e1_input.h>
41#include <openbsc/abis_nm.h>
Holger Hans Peter Freyther72baef32009-07-07 12:40:07 +020042#include <openbsc/signal.h>
Harald Welte0bf8e302009-08-08 00:02:36 +020043#include <openbsc/debug.h>
Harald Welte59b04682009-06-10 05:40:52 +080044
45static struct gsm_network *gsmnet;
46
Harald Welte12a721e2009-08-10 11:39:47 +020047static int net_listen_testnr;
Harald Welte59b04682009-06-10 05:40:52 +080048static int restart;
49static char *prim_oml_ip;
50static char *unit_id;
Harald Welte21460f02009-07-03 11:26:45 +020051static u_int16_t nv_flags;
52static u_int16_t nv_mask;
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +010053static char *software = NULL;
Holger Hans Peter Freyther0e15b932009-12-28 12:18:37 +010054static int sw_load_state = 0;
55
56struct sw_load {
57 u_int8_t file_id[255];
58 u_int8_t file_id_len;
59
60 u_int8_t file_version[255];
61 u_int8_t file_version_len;
62};
63
64static struct sw_load *sw_load1 = NULL;
65static struct sw_load *sw_load2 = NULL;
Harald Welte59b04682009-06-10 05:40:52 +080066
67/*
68static u_int8_t prim_oml_attr[] = { 0x95, 0x00, 7, 0x88, 192, 168, 100, 11, 0x00, 0x00 };
69static u_int8_t unit_id_attr[] = { 0x91, 0x00, 9, '2', '3', '4', '2', '/' , '0', '/', '0', 0x00 };
70*/
71
Holger Hans Peter Freyther72baef32009-07-07 12:40:07 +020072/*
73 * Callback function for NACK on the OML NM
74 *
75 * Currently we send the config requests but don't check the
76 * result. The nanoBTS will send us a NACK when we did something the
77 * BTS didn't like.
78 */
Harald Welte6a21c732009-11-17 06:09:56 +010079static int ipacc_msg_nack(u_int8_t mt)
Holger Hans Peter Freyther72baef32009-07-07 12:40:07 +020080{
81 fprintf(stderr, "Failure to set attribute. This seems fatal\n");
82 exit(-1);
83 return 0;
84}
85
Holger Hans Peter Freyther257b8db2009-12-29 11:26:38 +010086static int ipacc_msg_ack(u_int8_t mt)
87{
88 if (sw_load_state == 1) {
89 fprintf(stderr, "The new software is activaed.\n");
90 exit(0);
91 }
92
93 return 0;
94}
95
Harald Welte0bf8e302009-08-08 00:02:36 +020096struct ipacc_ferr_elem {
97 int16_t freq_err;
98 u_int8_t freq_qual;
99 u_int8_t arfcn;
100} __attribute__((packed));
101
Harald Welte12a721e2009-08-10 11:39:47 +0200102struct ipacc_cusage_elem {
103 u_int16_t arfcn:10,
104 rxlev:6;
105} __attribute__ ((packed));
106
Harald Welte0bf8e302009-08-08 00:02:36 +0200107static int test_rep(void *_msg)
108{
109 struct msgb *msg = _msg;
110 struct abis_om_fom_hdr *foh = msgb_l3(msg);
111 u_int16_t test_rep_len, ferr_list_len;
112 struct ipacc_ferr_elem *ife;
Harald Weltec73d9832009-11-13 14:43:15 +0100113 struct ipac_bcch_info binfo;
114 int i, rc;
Harald Welte0bf8e302009-08-08 00:02:36 +0200115
116 DEBUGP(DNM, "TEST REPORT: ");
117
118 if (foh->data[0] != NM_ATT_TEST_NO ||
119 foh->data[2] != NM_ATT_TEST_REPORT)
120 return -EINVAL;
121
122 DEBUGPC(DNM, "test_no=0x%02x ", foh->data[1]);
123 /* data[2] == NM_ATT_TEST_REPORT */
124 /* data[3..4]: test_rep_len */
125 test_rep_len = ntohs(*(u_int16_t *) &foh->data[3]);
126 /* data[5]: ip.access test result */
Harald Welte12a721e2009-08-10 11:39:47 +0200127 DEBUGPC(DNM, "test_res=%s\n", ipacc_testres_name(foh->data[5]));
Harald Welte0bf8e302009-08-08 00:02:36 +0200128
129 /* data[6]: ip.access nested IE. 3 == freq_err_list */
130 switch (foh->data[6]) {
Harald Weltec73d9832009-11-13 14:43:15 +0100131 case NM_IPAC_EIE_FREQ_ERR_LIST:
Harald Welte0bf8e302009-08-08 00:02:36 +0200132 /* data[7..8]: length of ferr_list */
133 ferr_list_len = ntohs(*(u_int16_t *) &foh->data[7]);
134
135 /* data[9...]: frequency error list elements */
136 for (i = 0; i < ferr_list_len; i+= sizeof(*ife)) {
137 ife = (struct ipacc_ferr_elem *) (foh->data + 9 + i);
138 DEBUGP(DNM, "==> ARFCN %4u, Frequency Error %6hd\n",
139 ife->arfcn, ntohs(ife->freq_err));
140 }
141 break;
Harald Weltec73d9832009-11-13 14:43:15 +0100142 case NM_IPAC_EIE_CHAN_USE_LIST:
Harald Welte12a721e2009-08-10 11:39:47 +0200143 /* data[7..8]: length of ferr_list */
144 ferr_list_len = ntohs(*(u_int16_t *) &foh->data[7]);
145
146 /* data[9...]: channel usage list elements */
147 for (i = 0; i < ferr_list_len; i+= 2) {
148 u_int16_t *cu_ptr = (u_int16_t *)(foh->data + 9 + i);
149 u_int16_t cu = ntohs(*cu_ptr);
150 DEBUGP(DNM, "==> ARFCN %4u, RxLev %2u\n",
151 cu & 0x3ff, cu >> 10);
152 }
153 break;
Harald Weltec73d9832009-11-13 14:43:15 +0100154 case NM_IPAC_EIE_BCCH_INFO_TYPE:
155 break;
156 case NM_IPAC_EIE_BCCH_INFO:
157 rc = ipac_parse_bcch_info(&binfo, foh->data+6);
158 if (rc < 0) {
159 DEBUGP(DNM, "BCCH Info parsing failed\n");
160 break;
161 }
162 DEBUGP(DNM, "==> ARFCN %u, RxLev %2u, RxQual %2u: %3d-%d, LAC %d CI %d\n",
163 binfo.arfcn, binfo.rx_lev, binfo.rx_qual,
164 binfo.cgi.mcc, binfo.cgi.mnc,
165 binfo.cgi.lac, binfo.cgi.ci);
166 break;
Harald Welte0bf8e302009-08-08 00:02:36 +0200167 default:
168 break;
169 }
170
171 return 0;
172}
173
Holger Hans Peter Freyther72baef32009-07-07 12:40:07 +0200174static int nm_sig_cb(unsigned int subsys, unsigned int signal,
175 void *handler_data, void *signal_data)
176{
Harald Welte6a21c732009-11-17 06:09:56 +0100177 u_int8_t *msg_type;
178
Holger Hans Peter Freyther72baef32009-07-07 12:40:07 +0200179 switch (signal) {
180 case S_NM_IPACC_NACK:
Harald Welte6a21c732009-11-17 06:09:56 +0100181 msg_type = signal_data;
182 return ipacc_msg_nack(*msg_type);
Holger Hans Peter Freyther257b8db2009-12-29 11:26:38 +0100183 case S_NM_IPACC_ACK:
184 msg_type = signal_data;
185 return ipacc_msg_ack(*msg_type);
Harald Welte0bf8e302009-08-08 00:02:36 +0200186 case S_NM_TEST_REP:
187 return test_rep(signal_data);
Holger Hans Peter Freyther72baef32009-07-07 12:40:07 +0200188 default:
189 break;
190 }
191
192 return 0;
193}
194
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100195/* callback function passed to the ABIS OML code */
196static int percent;
197static int percent_old;
Holger Hans Peter Freyther0e15b932009-12-28 12:18:37 +0100198static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *_msg,
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100199 void *data, void *param)
200{
Holger Hans Peter Freyther0e15b932009-12-28 12:18:37 +0100201 struct msgb *msg;
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100202 struct gsm_bts *bts;
203
204 if (hook != GSM_HOOK_NM_SWLOAD)
205 return 0;
206
207 bts = (struct gsm_bts *) data;
208
209 switch (event) {
210 case NM_MT_LOAD_INIT_ACK:
211 fprintf(stdout, "Software Load Initiate ACK\n");
212 break;
213 case NM_MT_LOAD_INIT_NACK:
214 fprintf(stderr, "ERROR: Software Load Initiate NACK\n");
215 exit(5);
216 break;
217 case NM_MT_LOAD_END_ACK:
218 fprintf(stderr, "LOAD END ACK...");
Holger Hans Peter Freyther0e15b932009-12-28 12:18:37 +0100219 /* now make it the default */
220 sw_load_state = 1;
221
222 msg = msgb_alloc(1024, "sw: nvattr");
223 msg->l2h = msgb_put(msg, 3);
224 msg->l3h = &msg->l2h[3];
225
226 /* activate software */
227 if (sw_load1) {
228 msgb_v_put(msg, NM_ATT_SW_DESCR);
229 msgb_tl16v_put(msg, NM_ATT_FILE_ID, sw_load1->file_id_len, sw_load1->file_id);
230 msgb_tl16v_put(msg, NM_ATT_FILE_VERSION, sw_load1->file_version_len,
231 sw_load1->file_version);
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100232 }
Holger Hans Peter Freyther0e15b932009-12-28 12:18:37 +0100233
234 if (sw_load2) {
235 msgb_v_put(msg, NM_ATT_SW_DESCR);
Holger Hans Peter Freytherf81445e2009-12-29 11:12:00 +0100236 msgb_tl16v_put(msg, NM_ATT_FILE_ID, sw_load2->file_id_len, sw_load2->file_id);
Holger Hans Peter Freyther0e15b932009-12-28 12:18:37 +0100237 msgb_tl16v_put(msg, NM_ATT_FILE_VERSION, sw_load2->file_version_len,
238 sw_load2->file_version);
239 }
240
241 /* fill in the data */
242 msg->l2h[0] = NM_ATT_IPACC_CUR_SW_CFG;
243 msg->l2h[1] = msgb_l3len(msg) >> 8;
244 msg->l2h[2] = msgb_l3len(msg) & 0xff;
245 printf("Foo l2h: %p l3h: %p... length l2: %u l3: %u\n", msg->l2h, msg->l3h, msgb_l2len(msg), msgb_l3len(msg));
246 abis_nm_ipaccess_set_nvattr(bts, msg->l2h, msgb_l2len(msg));
247 msgb_free(msg);
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100248 break;
249 case NM_MT_LOAD_END_NACK:
250 fprintf(stderr, "ERROR: Software Load End NACK\n");
251 exit(3);
252 break;
253 case NM_MT_ACTIVATE_SW_NACK:
254 fprintf(stderr, "ERROR: Activate Software NACK\n");
255 exit(4);
256 break;
257 case NM_MT_ACTIVATE_SW_ACK:
258 break;
259 case NM_MT_LOAD_SEG_ACK:
260 percent = abis_nm_software_load_status(bts);
261 if (percent > percent_old)
262 printf("Software Download Progress: %d%%\n", percent);
263 percent_old = percent;
264 break;
Holger Hans Peter Freyther61f814d2009-12-28 12:23:02 +0100265 case NM_MT_LOAD_ABORT:
266 fprintf(stderr, "ERROR: Load aborted by the BTS.\n");
267 exit(6);
268 break;
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100269 }
270 return 0;
271}
272
Harald Welte59b04682009-06-10 05:40:52 +0800273static void bootstrap_om(struct gsm_bts *bts)
274{
275 int len;
276 static u_int8_t buf[1024];
Harald Welte21460f02009-07-03 11:26:45 +0200277 u_int8_t *cur = buf;
Harald Welte59b04682009-06-10 05:40:52 +0800278
279 printf("OML link established\n");
280
281 if (unit_id) {
282 len = strlen(unit_id);
283 if (len > sizeof(buf)-10)
284 return;
285 buf[0] = NM_ATT_IPACC_UNIT_ID;
286 buf[1] = (len+1) >> 8;
287 buf[2] = (len+1) & 0xff;
288 memcpy(buf+3, unit_id, len);
289 buf[3+len] = 0;
290 printf("setting Unit ID to '%s'\n", unit_id);
291 abis_nm_ipaccess_set_nvattr(bts, buf, 3+len+1);
292 }
293 if (prim_oml_ip) {
294 struct in_addr ia;
Harald Welte59b04682009-06-10 05:40:52 +0800295
296 if (!inet_aton(prim_oml_ip, &ia)) {
297 fprintf(stderr, "invalid IP address: %s\n",
298 prim_oml_ip);
299 return;
300 }
301
302 /* 0x88 + IP + port */
303 len = 1 + sizeof(ia) + 2;
304
Harald Welte4206d982009-07-12 09:33:54 +0200305 *cur++ = NM_ATT_IPACC_PRIM_OML_CFG_LIST;
Harald Welte59b04682009-06-10 05:40:52 +0800306 *cur++ = (len) >> 8;
307 *cur++ = (len) & 0xff;
308 *cur++ = 0x88;
309 memcpy(cur, &ia, sizeof(ia));
310 cur += sizeof(ia);
311 *cur++ = 0;
312 *cur++ = 0;
313 printf("setting primary OML link IP to '%s'\n", inet_ntoa(ia));
314 abis_nm_ipaccess_set_nvattr(bts, buf, 3+len);
315 }
Harald Welte21460f02009-07-03 11:26:45 +0200316 if (nv_mask) {
317 len = 4;
318
319 *cur++ = NM_ATT_IPACC_NV_FLAGS;
320 *cur++ = (len) >> 8;
321 *cur++ = (len) & 0xff;
322 *cur++ = nv_flags & 0xff;
323 *cur++ = nv_mask & 0xff;
324 *cur++ = nv_flags >> 8;
325 *cur++ = nv_mask >> 8;
326 printf("setting NV Flags/Mask to 0x%04x/0x%04x\n",
327 nv_flags, nv_mask);
328 abis_nm_ipaccess_set_nvattr(bts, buf, 3+len);
329 }
Harald Welte59b04682009-06-10 05:40:52 +0800330
331 if (restart) {
332 printf("restarting BTS\n");
333 abis_nm_ipaccess_restart(bts);
334 }
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100335
Harald Welte59b04682009-06-10 05:40:52 +0800336}
337
338void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
339{
340 switch (event) {
341 case EVT_E1_TEI_UP:
342 switch (type) {
343 case E1INP_SIGN_OML:
344 bootstrap_om(trx->bts);
345 break;
346 case E1INP_SIGN_RSL:
347 /* FIXME */
348 break;
349 default:
350 break;
351 }
352 break;
353 case EVT_E1_TEI_DN:
354 fprintf(stderr, "Lost some E1 TEI link\n");
355 /* FIXME: deal with TEI or L1 link loss */
356 break;
357 default:
358 break;
359 }
360}
361
362int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
363 struct gsm_nm_state *old_state, struct gsm_nm_state *new_state)
364{
Harald Welte0bf8e302009-08-08 00:02:36 +0200365 if (evt == EVT_STATECHG_OPER &&
366 obj_class == NM_OC_RADIO_CARRIER &&
Holger Hans Peter Freytherf6dbf7f2009-12-28 07:27:43 +0100367 new_state->availability == 3) {
Harald Welte0bf8e302009-08-08 00:02:36 +0200368 struct gsm_bts_trx *trx = obj;
Holger Hans Peter Freytherf6dbf7f2009-12-28 07:27:43 +0100369
370 if (net_listen_testnr) {
371 u_int8_t phys_config[] = { 0x02, 0x0a, 0x00, 0x01, 0x02 };
372 abis_nm_perform_test(trx->bts, 2, 0, 0, 0xff,
373 net_listen_testnr, 1,
374 phys_config, sizeof(phys_config));
375 } else if (software) {
376 int rc;
377 printf("Attempting software upload with '%s'\n", software);
378 rc = abis_nm_software_load(trx->bts, software, 19, 0, swload_cbfn, trx->bts);
379 if (rc < 0) {
380 fprintf(stderr, "Failed to start software load\n");
381 exit(-3);
382 }
383 }
Harald Welte0bf8e302009-08-08 00:02:36 +0200384 }
Harald Welte59b04682009-06-10 05:40:52 +0800385 return 0;
386}
387
Holger Hans Peter Freyther5bcfb4f2009-07-04 11:53:10 +0200388static void print_usage(void)
389{
390 printf("Usage: ipaccess-config\n");
391}
392
393static void print_help(void)
394{
395 printf(" -u --unit-id UNIT_ID\n");
396 printf(" -o --oml-ip ip\n");
397 printf(" -r --restart\n");
Harald Welte0bf8e302009-08-08 00:02:36 +0200398 printf(" -n flags/mask\tSet NVRAM attributes.\n");
Holger Hans Peter Freythera4434c22009-11-16 19:53:08 +0100399 printf(" -l --listen testnr \tPerform specified test number\n");
Holger Hans Peter Freyther5bcfb4f2009-07-04 11:53:10 +0200400 printf(" -h --help this text\n");
Holger Hans Peter Freyther2e021c62009-10-27 03:41:09 +0100401 printf(" -s --stream-id ID\n");
Holger Hans Peter Freyther7d646df2009-12-30 06:55:38 +0100402 printf(" -d --software firmware\n");
Holger Hans Peter Freyther5bcfb4f2009-07-04 11:53:10 +0200403}
404
Harald Welte59b04682009-06-10 05:40:52 +0800405int main(int argc, char **argv)
406{
407 struct gsm_bts *bts;
408 struct sockaddr_in sin;
Holger Hans Peter Freyther2e021c62009-10-27 03:41:09 +0100409 int rc, option_index = 0, stream_id = 0xff;
Holger Hans Peter Freytherc8d862e2009-12-22 22:32:51 +0100410 struct debug_target *stderr_target;
411
412 debug_init();
413 stderr_target = debug_target_create_stderr();
414 debug_add_target(stderr_target);
415 debug_set_all_filter(stderr_target, 1);
Harald Welte (local)19497042009-12-28 23:15:36 +0100416 debug_set_log_level(stderr_target, 0);
417 debug_parse_category_mask(stderr_target, "DNM,0");
Harald Welte59b04682009-06-10 05:40:52 +0800418
419 printf("ipaccess-config (C) 2009 by Harald Welte\n");
420 printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n");
421
422 while (1) {
423 int c;
Harald Welte21460f02009-07-03 11:26:45 +0200424 unsigned long ul;
425 char *slash;
Harald Welte59b04682009-06-10 05:40:52 +0800426 static struct option long_options[] = {
427 { "unit-id", 1, 0, 'u' },
428 { "oml-ip", 1, 0, 'o' },
429 { "restart", 0, 0, 'r' },
Holger Hans Peter Freyther5bcfb4f2009-07-04 11:53:10 +0200430 { "help", 0, 0, 'h' },
Harald Welte12a721e2009-08-10 11:39:47 +0200431 { "listen", 1, 0, 'l' },
Holger Hans Peter Freyther2e021c62009-10-27 03:41:09 +0100432 { "stream-id", 1, 0, 's' },
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100433 { "software", 1, 0, 'd' },
Harald Welte59b04682009-06-10 05:40:52 +0800434 };
435
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100436 c = getopt_long(argc, argv, "u:o:rn:l:hs:d:", long_options,
Harald Welte59b04682009-06-10 05:40:52 +0800437 &option_index);
438
439 if (c == -1)
440 break;
441
442 switch (c) {
443 case 'u':
444 unit_id = optarg;
445 break;
446 case 'o':
447 prim_oml_ip = optarg;
448 break;
449 case 'r':
450 restart = 1;
451 break;
Harald Welte21460f02009-07-03 11:26:45 +0200452 case 'n':
453 slash = strchr(optarg, '/');
454 if (!slash)
455 exit(2);
456 ul = strtoul(optarg, NULL, 16);
457 nv_flags = ul & 0xffff;
458 ul = strtoul(slash+1, NULL, 16);
459 nv_mask = ul & 0xffff;
460 break;
Harald Welte0bf8e302009-08-08 00:02:36 +0200461 case 'l':
Harald Welte12a721e2009-08-10 11:39:47 +0200462 net_listen_testnr = atoi(optarg);
Harald Welte0bf8e302009-08-08 00:02:36 +0200463 break;
Holger Hans Peter Freyther2e021c62009-10-27 03:41:09 +0100464 case 's':
465 stream_id = atoi(optarg);
Holger Hans Peter Freyther2e021c62009-10-27 03:41:09 +0100466 break;
Holger Hans Peter Freyther4b513382009-12-28 03:11:33 +0100467 case 'd':
468 software = strdup(optarg);
469 break;
Holger Hans Peter Freyther5bcfb4f2009-07-04 11:53:10 +0200470 case 'h':
471 print_usage();
472 print_help();
473 exit(0);
Harald Welte59b04682009-06-10 05:40:52 +0800474 }
475 };
476
477 if (optind >= argc) {
Holger Hans Peter Freyther5bcfb4f2009-07-04 11:53:10 +0200478 fprintf(stderr, "you have to specify the IP address of the BTS. Use --help for more information\n");
Harald Welte59b04682009-06-10 05:40:52 +0800479 exit(2);
480 }
481
Harald Weltee712a5f2009-06-21 16:17:15 +0200482 gsmnet = gsm_network_init(1, 1, NULL);
Harald Welte59b04682009-06-10 05:40:52 +0800483 if (!gsmnet)
484 exit(1);
485
Mike Haben66e0ba02009-10-02 12:19:34 +0100486 bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_NANOBTS, HARDCODED_TSC,
Harald Weltee712a5f2009-06-21 16:17:15 +0200487 HARDCODED_BSIC);
Harald Welte (local)19497042009-12-28 23:15:36 +0100488 /* ip.access supports up to 4 chained TRX */
489 gsm_bts_trx_alloc(bts);
490 gsm_bts_trx_alloc(bts);
491 gsm_bts_trx_alloc(bts);
Holger Hans Peter Freyther2e021c62009-10-27 03:41:09 +0100492 bts->oml_tei = stream_id;
Harald Welte59b04682009-06-10 05:40:52 +0800493
Holger Hans Peter Freyther72baef32009-07-07 12:40:07 +0200494 register_signal_handler(SS_NM, nm_sig_cb, NULL);
Harald Welte59b04682009-06-10 05:40:52 +0800495 printf("Trying to connect to ip.access BTS ...\n");
496
497 memset(&sin, 0, sizeof(sin));
498 sin.sin_family = AF_INET;
499 inet_aton(argv[optind], &sin.sin_addr);
500 rc = ia_config_connect(bts, &sin);
501 if (rc < 0) {
502 perror("Error connecting to the BTS");
503 exit(1);
504 }
505
506 while (1) {
507 rc = bsc_select_main(0);
508 if (rc < 0)
509 exit(3);
510 }
511
512 exit(0);
513}
514