Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 1 | /* ip.access nanoBTS configuration tool */ |
| 2 | |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 3 | /* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org> |
Holger Hans Peter Freyther | 69dbdee | 2011-04-11 19:32:35 +0200 | [diff] [blame] | 4 | * (C) 2009-2011 by Holger Hans Peter Freyther |
Holger Hans Peter Freyther | 5180844 | 2010-10-06 20:37:09 +0800 | [diff] [blame] | 5 | * (C) 2009-2010 by On-Waves |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 6 | * All Rights Reserved |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 9 | * it under the terms of the GNU Affero General Public License as published by |
| 10 | * the Free Software Foundation; either version 3 of the License, or |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 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 |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 16 | * GNU Affero General Public License for more details. |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 17 | * |
Harald Welte | 0e3e88e | 2011-01-01 15:25:50 +0100 | [diff] [blame] | 18 | * You should have received a copy of the GNU Affero General Public License |
| 19 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 20 | * |
| 21 | */ |
| 22 | |
| 23 | #include <unistd.h> |
| 24 | #include <stdio.h> |
| 25 | #include <stdlib.h> |
| 26 | #include <string.h> |
| 27 | #include <getopt.h> |
Harald Welte | f4625b1 | 2010-02-20 16:24:02 +0100 | [diff] [blame] | 28 | #include <errno.h> |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 29 | #include <sys/fcntl.h> |
| 30 | #include <sys/stat.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 31 | |
| 32 | #include <sys/socket.h> |
| 33 | #include <netinet/in.h> |
| 34 | #include <arpa/inet.h> |
| 35 | |
| 36 | |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 37 | #include <osmocom/core/select.h> |
| 38 | #include <osmocom/core/timer.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 39 | #include <openbsc/ipaccess.h> |
| 40 | #include <openbsc/gsm_data.h> |
| 41 | #include <openbsc/e1_input.h> |
| 42 | #include <openbsc/abis_nm.h> |
Holger Hans Peter Freyther | 72baef3 | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 43 | #include <openbsc/signal.h> |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 44 | #include <openbsc/debug.h> |
Harald Welte | 0f31775 | 2010-03-05 19:36:20 +0100 | [diff] [blame] | 45 | #include <openbsc/network_listen.h> |
Pablo Neira Ayuso | dd5fff4 | 2011-03-22 16:47:59 +0100 | [diff] [blame] | 46 | #include <osmocom/core/talloc.h> |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 47 | |
| 48 | static struct gsm_network *gsmnet; |
| 49 | |
Harald Welte | 12a721e | 2009-08-10 11:39:47 +0200 | [diff] [blame] | 50 | static int net_listen_testnr; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 51 | static int restart; |
| 52 | static char *prim_oml_ip; |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 53 | static char *bts_ip_addr, *bts_ip_mask, *bts_ip_gw; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 54 | static char *unit_id; |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 55 | static uint16_t nv_flags; |
| 56 | static uint16_t nv_mask; |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 57 | static char *software = NULL; |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 58 | static int sw_load_state = 0; |
Holger Hans Peter Freyther | 0fc5ab4 | 2009-12-30 08:38:43 +0100 | [diff] [blame] | 59 | static int oml_state = 0; |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 60 | static int dump_files = 0; |
Holger Hans Peter Freyther | 70c67d5 | 2010-03-24 05:26:24 +0100 | [diff] [blame] | 61 | static char *firmware_analysis = NULL; |
Holger Hans Peter Freyther | f39ff07 | 2010-05-12 16:44:01 +0800 | [diff] [blame] | 62 | static int found_trx = 0; |
Holger Hans Peter Freyther | 69dbdee | 2011-04-11 19:32:35 +0200 | [diff] [blame] | 63 | static int loop_tests = 0; |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 64 | |
| 65 | struct sw_load { |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 66 | uint8_t file_id[255]; |
| 67 | uint8_t file_id_len; |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 68 | |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 69 | uint8_t file_version[255]; |
| 70 | uint8_t file_version_len; |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 71 | }; |
| 72 | |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 73 | static void *tall_ctx_config = NULL; |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 74 | static struct sw_load *sw_load1 = NULL; |
| 75 | static struct sw_load *sw_load2 = NULL; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 76 | |
| 77 | /* |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 78 | static uint8_t prim_oml_attr[] = { 0x95, 0x00, 7, 0x88, 192, 168, 100, 11, 0x00, 0x00 }; |
| 79 | static uint8_t unit_id_attr[] = { 0x91, 0x00, 9, '2', '3', '4', '2', '/' , '0', '/', '0', 0x00 }; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 80 | */ |
| 81 | |
Holger Hans Peter Freyther | 72baef3 | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 82 | /* |
| 83 | * Callback function for NACK on the OML NM |
| 84 | * |
| 85 | * Currently we send the config requests but don't check the |
| 86 | * result. The nanoBTS will send us a NACK when we did something the |
| 87 | * BTS didn't like. |
| 88 | */ |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 89 | static int ipacc_msg_nack(uint8_t mt) |
Holger Hans Peter Freyther | 72baef3 | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 90 | { |
| 91 | fprintf(stderr, "Failure to set attribute. This seems fatal\n"); |
| 92 | exit(-1); |
| 93 | return 0; |
| 94 | } |
| 95 | |
Holger Hans Peter Freyther | 3778384 | 2010-05-12 23:34:51 +0800 | [diff] [blame] | 96 | static void check_restart_or_exit(struct gsm_bts_trx *trx) |
Holger Hans Peter Freyther | 98d6de0 | 2010-05-12 23:16:59 +0800 | [diff] [blame] | 97 | { |
| 98 | if (restart) { |
Holger Hans Peter Freyther | 3778384 | 2010-05-12 23:34:51 +0800 | [diff] [blame] | 99 | abis_nm_ipaccess_restart(trx); |
Holger Hans Peter Freyther | 98d6de0 | 2010-05-12 23:16:59 +0800 | [diff] [blame] | 100 | } else { |
| 101 | exit(0); |
| 102 | } |
| 103 | } |
| 104 | |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 105 | static int ipacc_msg_ack(uint8_t mt, struct gsm_bts_trx *trx) |
Holger Hans Peter Freyther | 257b8db | 2009-12-29 11:26:38 +0100 | [diff] [blame] | 106 | { |
| 107 | if (sw_load_state == 1) { |
| 108 | fprintf(stderr, "The new software is activaed.\n"); |
Holger Hans Peter Freyther | 3778384 | 2010-05-12 23:34:51 +0800 | [diff] [blame] | 109 | check_restart_or_exit(trx); |
Holger Hans Peter Freyther | 0fc5ab4 | 2009-12-30 08:38:43 +0100 | [diff] [blame] | 110 | } else if (oml_state == 1) { |
Harald Welte | bfd40a8 | 2010-06-28 14:41:09 +0200 | [diff] [blame] | 111 | fprintf(stderr, "Set the NV Attributes.\n"); |
Holger Hans Peter Freyther | 3778384 | 2010-05-12 23:34:51 +0800 | [diff] [blame] | 112 | check_restart_or_exit(trx); |
Holger Hans Peter Freyther | 257b8db | 2009-12-29 11:26:38 +0100 | [diff] [blame] | 113 | } |
| 114 | |
| 115 | return 0; |
| 116 | } |
| 117 | |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 118 | static const uint8_t phys_conf_min[] = { 0x02 }; |
| 119 | |
| 120 | static uint16_t build_physconf(uint8_t *physconf_buf, const struct rxlev_stats *st) |
| 121 | { |
| 122 | uint16_t *whitelist = (uint16_t *) (physconf_buf + 4); |
| 123 | int num_arfcn; |
| 124 | unsigned int arfcnlist_size; |
| 125 | |
| 126 | /* Create whitelist from rxlevels */ |
| 127 | physconf_buf[0] = phys_conf_min[0]; |
| 128 | physconf_buf[1] = NM_IPAC_EIE_ARFCN_WHITE; |
Harald Welte | 8b39d73 | 2010-07-22 20:12:09 +0200 | [diff] [blame] | 129 | num_arfcn = ipac_rxlevstat2whitelist(whitelist, st, 0, 100); |
Harald Welte | c294597 | 2010-07-22 18:14:58 +0200 | [diff] [blame] | 130 | arfcnlist_size = num_arfcn * 2; |
Harald Welte | 8b39d73 | 2010-07-22 20:12:09 +0200 | [diff] [blame] | 131 | *((uint16_t *) (physconf_buf+2)) = htons(arfcnlist_size); |
| 132 | DEBUGP(DNM, "physconf_buf (%s)\n", hexdump(physconf_buf, arfcnlist_size+4)); |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 133 | return arfcnlist_size+4; |
| 134 | } |
Harald Welte | b31c9df | 2010-03-06 11:38:05 +0100 | [diff] [blame] | 135 | |
Harald Welte | 0f31775 | 2010-03-05 19:36:20 +0100 | [diff] [blame] | 136 | static int nwl_sig_cb(unsigned int subsys, unsigned int signal, |
| 137 | void *handler_data, void *signal_data) |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 138 | { |
Harald Welte | 0f31775 | 2010-03-05 19:36:20 +0100 | [diff] [blame] | 139 | struct gsm_bts_trx *trx; |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 140 | uint8_t physconf_buf[2*NUM_ARFCNS+16]; |
| 141 | uint16_t physconf_len; |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 142 | |
Harald Welte | 0f31775 | 2010-03-05 19:36:20 +0100 | [diff] [blame] | 143 | switch (signal) { |
| 144 | case S_IPAC_NWL_COMPLETE: |
| 145 | trx = signal_data; |
Harald Welte | b31c9df | 2010-03-06 11:38:05 +0100 | [diff] [blame] | 146 | DEBUGP(DNM, "received S_IPAC_NWL_COMPLETE signal\n"); |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 147 | switch (trx->ipaccess.test_nr) { |
| 148 | case NM_IPACC_TESTNO_CHAN_USAGE: |
| 149 | /* Dump RxLev results */ |
Harald Welte | ee0bd11 | 2010-07-30 22:34:25 +0200 | [diff] [blame] | 150 | //rxlev_stat_dump(&trx->ipaccess.rxlev_stat); |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 151 | /* Create whitelist from results */ |
| 152 | physconf_len = build_physconf(physconf_buf, |
| 153 | &trx->ipaccess.rxlev_stat); |
| 154 | /* Start next test abbout BCCH channel usage */ |
| 155 | ipac_nwl_test_start(trx, NM_IPACC_TESTNO_BCCH_CHAN_USAGE, |
| 156 | physconf_buf, physconf_len); |
| 157 | break; |
| 158 | case NM_IPACC_TESTNO_BCCH_CHAN_USAGE: |
| 159 | /* Dump BCCH RxLev results */ |
Harald Welte | ee0bd11 | 2010-07-30 22:34:25 +0200 | [diff] [blame] | 160 | //rxlev_stat_dump(&trx->ipaccess.rxlev_stat); |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 161 | /* Create whitelist from results */ |
| 162 | physconf_len = build_physconf(physconf_buf, |
| 163 | &trx->ipaccess.rxlev_stat); |
| 164 | /* Start next test about BCCH info */ |
| 165 | ipac_nwl_test_start(trx, NM_IPACC_TESTNO_BCCH_INFO, |
| 166 | physconf_buf, physconf_len); |
| 167 | break; |
Harald Welte | 13772e8 | 2010-07-30 22:31:44 +0200 | [diff] [blame] | 168 | case NM_IPACC_TESTNO_BCCH_INFO: |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 169 | /* re-start full process with CHAN_USAGE */ |
Holger Hans Peter Freyther | 69dbdee | 2011-04-11 19:32:35 +0200 | [diff] [blame] | 170 | if (loop_tests) { |
| 171 | DEBUGP(DNM, "starting next test cycle\n"); |
| 172 | ipac_nwl_test_start(trx, net_listen_testnr, phys_conf_min, |
| 173 | sizeof(phys_conf_min)); |
| 174 | } else { |
| 175 | exit(0); |
| 176 | } |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 177 | break; |
| 178 | } |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 179 | break; |
| 180 | } |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 181 | return 0; |
| 182 | } |
| 183 | |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 184 | static int nm_state_event(int evt, uint8_t obj_class, void *obj, |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 185 | struct gsm_nm_state *old_state, struct gsm_nm_state *new_state, |
| 186 | struct abis_om_obj_inst *obj_inst); |
| 187 | |
Holger Hans Peter Freyther | 72baef3 | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 188 | static int nm_sig_cb(unsigned int subsys, unsigned int signal, |
| 189 | void *handler_data, void *signal_data) |
| 190 | { |
Holger Hans Peter Freyther | 0fc5ab4 | 2009-12-30 08:38:43 +0100 | [diff] [blame] | 191 | struct ipacc_ack_signal_data *ipacc_data; |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 192 | struct nm_statechg_signal_data *nsd; |
Harald Welte | 6a21c73 | 2009-11-17 06:09:56 +0100 | [diff] [blame] | 193 | |
Holger Hans Peter Freyther | 72baef3 | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 194 | switch (signal) { |
| 195 | case S_NM_IPACC_NACK: |
Holger Hans Peter Freyther | 0fc5ab4 | 2009-12-30 08:38:43 +0100 | [diff] [blame] | 196 | ipacc_data = signal_data; |
| 197 | return ipacc_msg_nack(ipacc_data->msg_type); |
Holger Hans Peter Freyther | 257b8db | 2009-12-29 11:26:38 +0100 | [diff] [blame] | 198 | case S_NM_IPACC_ACK: |
Holger Hans Peter Freyther | 0fc5ab4 | 2009-12-30 08:38:43 +0100 | [diff] [blame] | 199 | ipacc_data = signal_data; |
Holger Hans Peter Freyther | 3778384 | 2010-05-12 23:34:51 +0800 | [diff] [blame] | 200 | return ipacc_msg_ack(ipacc_data->msg_type, ipacc_data->trx); |
Holger Hans Peter Freyther | 9ef8e5a | 2009-12-30 09:00:01 +0100 | [diff] [blame] | 201 | case S_NM_IPACC_RESTART_ACK: |
| 202 | printf("The BTS has acked the restart. Exiting.\n"); |
| 203 | exit(0); |
| 204 | break; |
| 205 | case S_NM_IPACC_RESTART_NACK: |
| 206 | printf("The BTS has nacked the restart. Exiting.\n"); |
| 207 | exit(0); |
| 208 | break; |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 209 | case S_NM_STATECHG_OPER: |
| 210 | case S_NM_STATECHG_ADM: |
| 211 | nsd = signal_data; |
| 212 | nm_state_event(signal, nsd->obj_class, nsd->obj, nsd->old_state, |
| 213 | nsd->new_state, nsd->obj_inst); |
| 214 | break; |
Holger Hans Peter Freyther | 72baef3 | 2009-07-07 12:40:07 +0200 | [diff] [blame] | 215 | default: |
| 216 | break; |
| 217 | } |
| 218 | |
| 219 | return 0; |
| 220 | } |
| 221 | |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 222 | /* callback function passed to the ABIS OML code */ |
| 223 | static int percent; |
| 224 | static int percent_old; |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 225 | static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *_msg, |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 226 | void *data, void *param) |
| 227 | { |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 228 | struct msgb *msg; |
Holger Hans Peter Freyther | faeab8e | 2010-05-13 00:14:46 +0800 | [diff] [blame] | 229 | struct gsm_bts_trx *trx; |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 230 | |
| 231 | if (hook != GSM_HOOK_NM_SWLOAD) |
| 232 | return 0; |
| 233 | |
Holger Hans Peter Freyther | faeab8e | 2010-05-13 00:14:46 +0800 | [diff] [blame] | 234 | trx = (struct gsm_bts_trx *) data; |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 235 | |
| 236 | switch (event) { |
| 237 | case NM_MT_LOAD_INIT_ACK: |
| 238 | fprintf(stdout, "Software Load Initiate ACK\n"); |
| 239 | break; |
| 240 | case NM_MT_LOAD_INIT_NACK: |
| 241 | fprintf(stderr, "ERROR: Software Load Initiate NACK\n"); |
| 242 | exit(5); |
| 243 | break; |
| 244 | case NM_MT_LOAD_END_ACK: |
| 245 | fprintf(stderr, "LOAD END ACK..."); |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 246 | /* now make it the default */ |
| 247 | sw_load_state = 1; |
| 248 | |
| 249 | msg = msgb_alloc(1024, "sw: nvattr"); |
| 250 | msg->l2h = msgb_put(msg, 3); |
| 251 | msg->l3h = &msg->l2h[3]; |
| 252 | |
| 253 | /* activate software */ |
| 254 | if (sw_load1) { |
| 255 | msgb_v_put(msg, NM_ATT_SW_DESCR); |
| 256 | msgb_tl16v_put(msg, NM_ATT_FILE_ID, sw_load1->file_id_len, sw_load1->file_id); |
| 257 | msgb_tl16v_put(msg, NM_ATT_FILE_VERSION, sw_load1->file_version_len, |
| 258 | sw_load1->file_version); |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 259 | } |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 260 | |
| 261 | if (sw_load2) { |
| 262 | msgb_v_put(msg, NM_ATT_SW_DESCR); |
Holger Hans Peter Freyther | f81445e | 2009-12-29 11:12:00 +0100 | [diff] [blame] | 263 | msgb_tl16v_put(msg, NM_ATT_FILE_ID, sw_load2->file_id_len, sw_load2->file_id); |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 264 | msgb_tl16v_put(msg, NM_ATT_FILE_VERSION, sw_load2->file_version_len, |
| 265 | sw_load2->file_version); |
| 266 | } |
| 267 | |
| 268 | /* fill in the data */ |
| 269 | msg->l2h[0] = NM_ATT_IPACC_CUR_SW_CFG; |
| 270 | msg->l2h[1] = msgb_l3len(msg) >> 8; |
| 271 | msg->l2h[2] = msgb_l3len(msg) & 0xff; |
| 272 | printf("Foo l2h: %p l3h: %p... length l2: %u l3: %u\n", msg->l2h, msg->l3h, msgb_l2len(msg), msgb_l3len(msg)); |
Holger Hans Peter Freyther | faeab8e | 2010-05-13 00:14:46 +0800 | [diff] [blame] | 273 | abis_nm_ipaccess_set_nvattr(trx, msg->l2h, msgb_l2len(msg)); |
Holger Hans Peter Freyther | 0e15b93 | 2009-12-28 12:18:37 +0100 | [diff] [blame] | 274 | msgb_free(msg); |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 275 | break; |
| 276 | case NM_MT_LOAD_END_NACK: |
| 277 | fprintf(stderr, "ERROR: Software Load End NACK\n"); |
| 278 | exit(3); |
| 279 | break; |
| 280 | case NM_MT_ACTIVATE_SW_NACK: |
| 281 | fprintf(stderr, "ERROR: Activate Software NACK\n"); |
| 282 | exit(4); |
| 283 | break; |
| 284 | case NM_MT_ACTIVATE_SW_ACK: |
| 285 | break; |
| 286 | case NM_MT_LOAD_SEG_ACK: |
Holger Hans Peter Freyther | faeab8e | 2010-05-13 00:14:46 +0800 | [diff] [blame] | 287 | percent = abis_nm_software_load_status(trx->bts); |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 288 | if (percent > percent_old) |
| 289 | printf("Software Download Progress: %d%%\n", percent); |
| 290 | percent_old = percent; |
| 291 | break; |
Holger Hans Peter Freyther | 61f814d | 2009-12-28 12:23:02 +0100 | [diff] [blame] | 292 | case NM_MT_LOAD_ABORT: |
| 293 | fprintf(stderr, "ERROR: Load aborted by the BTS.\n"); |
| 294 | exit(6); |
| 295 | break; |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 296 | } |
| 297 | return 0; |
| 298 | } |
| 299 | |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 300 | static void nv_put_ip_if_cfg(struct msgb *nmsg, uint32_t ip, uint32_t mask) |
| 301 | { |
| 302 | msgb_put_u8(nmsg, NM_ATT_IPACC_IP_IF_CFG); |
| 303 | |
| 304 | msgb_put_u32(nmsg, ip); |
| 305 | msgb_put_u32(nmsg, mask); |
| 306 | } |
| 307 | |
| 308 | static void nv_put_gw_cfg(struct msgb *nmsg, uint32_t addr, uint32_t mask, uint32_t gw) |
| 309 | { |
| 310 | msgb_put_u8(nmsg, NM_ATT_IPACC_IP_GW_CFG); |
| 311 | msgb_put_u32(nmsg, addr); |
| 312 | msgb_put_u32(nmsg, mask); |
| 313 | msgb_put_u32(nmsg, gw); |
| 314 | } |
| 315 | |
| 316 | static void nv_put_unit_id(struct msgb *nmsg, const char *unit_id) |
| 317 | { |
| 318 | msgb_tl16v_put(nmsg, NM_ATT_IPACC_UNIT_ID, strlen(unit_id)+1, |
| 319 | (const uint8_t *)unit_id); |
| 320 | } |
| 321 | |
| 322 | static void nv_put_prim_oml(struct msgb *nmsg, uint32_t ip, uint16_t port) |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 323 | { |
| 324 | int len; |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 325 | |
| 326 | /* 0x88 + IP + port */ |
| 327 | len = 1 + sizeof(ip) + sizeof(port); |
| 328 | |
| 329 | msgb_put_u8(nmsg, NM_ATT_IPACC_PRIM_OML_CFG_LIST); |
| 330 | msgb_put_u16(nmsg, len); |
| 331 | |
| 332 | msgb_put_u8(nmsg, 0x88); |
| 333 | |
| 334 | /* IP address */ |
| 335 | msgb_put_u32(nmsg, ip); |
| 336 | |
| 337 | /* port number */ |
| 338 | msgb_put_u16(nmsg, port); |
| 339 | } |
| 340 | |
| 341 | static void nv_put_flags(struct msgb *nmsg, uint16_t nv_flags, uint16_t nv_mask) |
| 342 | { |
| 343 | msgb_put_u8(nmsg, NM_ATT_IPACC_NV_FLAGS); |
| 344 | msgb_put_u16(nmsg, sizeof(nv_flags) + sizeof(nv_mask)); |
| 345 | msgb_put_u8(nmsg, nv_flags & 0xff); |
| 346 | msgb_put_u8(nmsg, nv_mask & 0xff); |
| 347 | msgb_put_u8(nmsg, nv_flags >> 8); |
| 348 | msgb_put_u8(nmsg, nv_mask >> 8); |
| 349 | } |
| 350 | |
Holger Hans Peter Freyther | 657079e | 2011-04-11 20:33:05 +0200 | [diff] [blame] | 351 | /* human-readable test names for the ip.access tests */ |
| 352 | static const struct value_string ipa_test_strs[] = { |
| 353 | { 64, "ccch-usage" }, |
| 354 | { 65, "bcch-usage" }, |
| 355 | { 66, "freq-sync" }, |
| 356 | { 67, "rtp-usage" }, |
| 357 | { 68, "rtp-perf" }, |
| 358 | { 69, "gprs-ccch" }, |
| 359 | { 70, "pccch-usage" }, |
| 360 | { 71, "gprs-usage" }, |
| 361 | { 72, "esta-mf" }, |
| 362 | { 73, "uplink-mf" }, |
| 363 | { 74, "dolink-mf" }, |
| 364 | { 75, "tbf-details" }, |
| 365 | { 76, "tbf-usage" }, |
| 366 | { 77, "llc-data" }, |
| 367 | { 78, "pdch-usage" }, |
| 368 | { 79, "power-control" }, |
| 369 | { 80, "link-adaption" }, |
| 370 | { 81, "tch-usage" }, |
| 371 | { 82, "amr-mf" }, |
| 372 | { 83, "rtp-multiplex-perf" }, |
| 373 | { 84, "rtp-multiplex-usage" }, |
| 374 | { 85, "srtp-multiplex-usage" }, |
| 375 | { 86, "abis-traffic" }, |
| 376 | { 89, "gprs-multiplex-perf" }, |
| 377 | { 90, "gprs-multiplex-usage" }, |
| 378 | { 0, NULL }, |
| 379 | }; |
| 380 | |
Harald Welte | 901c819 | 2010-06-28 15:52:56 +0200 | [diff] [blame] | 381 | /* human-readable names for the ip.access nanoBTS NVRAM Flags */ |
| 382 | static const struct value_string ipa_nvflag_strs[] = { |
| 383 | { 0x0001, "static-ip" }, |
| 384 | { 0x0002, "static-gw" }, |
| 385 | { 0x0004, "no-dhcp-vsi" }, |
| 386 | { 0x0008, "dhcp-enabled" }, |
| 387 | { 0x0040, "led-disabled" }, |
| 388 | { 0x0100, "secondary-oml-enabled" }, |
| 389 | { 0x0200, "diag-enabled" }, |
| 390 | { 0x0400, "cli-enabled" }, |
| 391 | { 0x0800, "http-enabled" }, |
| 392 | { 0x1000, "post-enabled" }, |
| 393 | { 0x2000, "snmp-enabled" }, |
| 394 | { 0, NULL } |
| 395 | }; |
| 396 | |
| 397 | /* set the flags in flags/mask according to a string-identified flag and 'enable' */ |
| 398 | static int ipa_nvflag_set(uint16_t *flags, uint16_t *mask, const char *name, int en) |
| 399 | { |
| 400 | int rc; |
| 401 | rc = get_string_value(ipa_nvflag_strs, name); |
| 402 | if (rc < 0) |
| 403 | return rc; |
| 404 | |
| 405 | *mask |= rc; |
| 406 | if (en) |
| 407 | *flags |= rc; |
| 408 | else |
| 409 | *flags &= ~rc; |
| 410 | |
| 411 | return 0; |
| 412 | } |
| 413 | |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 414 | static void bootstrap_om(struct gsm_bts_trx *trx) |
| 415 | { |
Harald Welte | bfd40a8 | 2010-06-28 14:41:09 +0200 | [diff] [blame] | 416 | struct msgb *nmsg = msgb_alloc(1024, "nested msgb"); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 417 | int need_to_set_attr = 0; |
| 418 | int len; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 419 | |
Holger Hans Peter Freyther | f39ff07 | 2010-05-12 16:44:01 +0800 | [diff] [blame] | 420 | printf("OML link established using TRX %d\n", trx->nr); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 421 | |
| 422 | if (unit_id) { |
| 423 | len = strlen(unit_id); |
Harald Welte | bfd40a8 | 2010-06-28 14:41:09 +0200 | [diff] [blame] | 424 | if (len > nmsg->data_len-10) |
| 425 | goto out_err; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 426 | printf("setting Unit ID to '%s'\n", unit_id); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 427 | nv_put_unit_id(nmsg, unit_id); |
| 428 | need_to_set_attr = 1; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 429 | } |
| 430 | if (prim_oml_ip) { |
| 431 | struct in_addr ia; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 432 | |
| 433 | if (!inet_aton(prim_oml_ip, &ia)) { |
| 434 | fprintf(stderr, "invalid IP address: %s\n", |
| 435 | prim_oml_ip); |
Harald Welte | bfd40a8 | 2010-06-28 14:41:09 +0200 | [diff] [blame] | 436 | goto out_err; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 437 | } |
| 438 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 439 | printf("setting primary OML link IP to '%s'\n", inet_ntoa(ia)); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 440 | nv_put_prim_oml(nmsg, ntohl(ia.s_addr), 0); |
| 441 | need_to_set_attr = 1; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 442 | } |
Harald Welte | 21460f0 | 2009-07-03 11:26:45 +0200 | [diff] [blame] | 443 | if (nv_mask) { |
Harald Welte | 21460f0 | 2009-07-03 11:26:45 +0200 | [diff] [blame] | 444 | printf("setting NV Flags/Mask to 0x%04x/0x%04x\n", |
| 445 | nv_flags, nv_mask); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 446 | nv_put_flags(nmsg, nv_flags, nv_mask); |
| 447 | need_to_set_attr = 1; |
| 448 | } |
| 449 | if (bts_ip_addr && bts_ip_mask) { |
| 450 | struct in_addr ia_addr, ia_mask; |
| 451 | |
| 452 | if (!inet_aton(bts_ip_addr, &ia_addr)) { |
| 453 | fprintf(stderr, "invalid IP address: %s\n", |
| 454 | bts_ip_addr); |
| 455 | goto out_err; |
| 456 | } |
| 457 | |
| 458 | if (!inet_aton(bts_ip_mask, &ia_mask)) { |
| 459 | fprintf(stderr, "invalid IP address: %s\n", |
| 460 | bts_ip_mask); |
| 461 | goto out_err; |
| 462 | } |
| 463 | |
| 464 | printf("setting static IP Address/Mask\n"); |
| 465 | nv_put_ip_if_cfg(nmsg, ntohl(ia_addr.s_addr), ntohl(ia_mask.s_addr)); |
| 466 | need_to_set_attr = 1; |
| 467 | } |
| 468 | if (bts_ip_gw) { |
| 469 | struct in_addr ia_gw; |
| 470 | |
| 471 | if (!inet_aton(bts_ip_gw, &ia_gw)) { |
| 472 | fprintf(stderr, "invalid IP address: %s\n", |
| 473 | bts_ip_gw); |
| 474 | goto out_err; |
| 475 | } |
| 476 | |
| 477 | printf("setting static IP Gateway\n"); |
| 478 | /* we only set the default gateway with zero addr/mask */ |
| 479 | nv_put_gw_cfg(nmsg, 0, 0, ntohl(ia_gw.s_addr)); |
| 480 | need_to_set_attr = 1; |
Harald Welte | 21460f0 | 2009-07-03 11:26:45 +0200 | [diff] [blame] | 481 | } |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 482 | |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 483 | if (need_to_set_attr) { |
| 484 | abis_nm_ipaccess_set_nvattr(trx, nmsg->head, nmsg->len); |
| 485 | oml_state = 1; |
| 486 | } |
Harald Welte | bfd40a8 | 2010-06-28 14:41:09 +0200 | [diff] [blame] | 487 | |
Holger Hans Peter Freyther | 0fc5ab4 | 2009-12-30 08:38:43 +0100 | [diff] [blame] | 488 | if (restart && !prim_oml_ip && !software) { |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 489 | printf("restarting BTS\n"); |
Holger Hans Peter Freyther | 3778384 | 2010-05-12 23:34:51 +0800 | [diff] [blame] | 490 | abis_nm_ipaccess_restart(trx); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 491 | } |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 492 | |
Harald Welte | bfd40a8 | 2010-06-28 14:41:09 +0200 | [diff] [blame] | 493 | out_err: |
| 494 | msgb_free(nmsg); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 495 | } |
| 496 | |
Holger Hans Peter Freyther | 7eb8a9a | 2011-04-18 17:04:00 +0200 | [diff] [blame] | 497 | static int nm_state_event(int evt, uint8_t obj_class, void *obj, |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 498 | struct gsm_nm_state *old_state, struct gsm_nm_state *new_state, |
| 499 | struct abis_om_obj_inst *obj_inst) |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 500 | { |
Holger Hans Peter Freyther | f39ff07 | 2010-05-12 16:44:01 +0800 | [diff] [blame] | 501 | if (obj_class == NM_OC_BASEB_TRANSC) { |
| 502 | if (!found_trx && obj_inst->trx_nr != 0xff) { |
| 503 | struct gsm_bts_trx *trx = container_of(obj, struct gsm_bts_trx, bb_transc); |
| 504 | bootstrap_om(trx); |
| 505 | found_trx = 1; |
| 506 | } |
Harald Welte | 4c826f7 | 2011-01-14 15:55:42 +0100 | [diff] [blame] | 507 | } else if (evt == S_NM_STATECHG_OPER && |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 508 | obj_class == NM_OC_RADIO_CARRIER && |
Holger Hans Peter Freyther | f6dbf7f | 2009-12-28 07:27:43 +0100 | [diff] [blame] | 509 | new_state->availability == 3) { |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 510 | struct gsm_bts_trx *trx = obj; |
Holger Hans Peter Freyther | f6dbf7f | 2009-12-28 07:27:43 +0100 | [diff] [blame] | 511 | |
Harald Welte | 0f31775 | 2010-03-05 19:36:20 +0100 | [diff] [blame] | 512 | if (net_listen_testnr) |
Harald Welte | 432da6e | 2010-03-09 22:35:37 +0100 | [diff] [blame] | 513 | ipac_nwl_test_start(trx, net_listen_testnr, |
| 514 | phys_conf_min, sizeof(phys_conf_min)); |
Harald Welte | 0f31775 | 2010-03-05 19:36:20 +0100 | [diff] [blame] | 515 | else if (software) { |
Holger Hans Peter Freyther | f6dbf7f | 2009-12-28 07:27:43 +0100 | [diff] [blame] | 516 | int rc; |
| 517 | printf("Attempting software upload with '%s'\n", software); |
Holger Hans Peter Freyther | faeab8e | 2010-05-13 00:14:46 +0800 | [diff] [blame] | 518 | rc = abis_nm_software_load(trx->bts, trx->nr, software, 19, 0, swload_cbfn, trx); |
Holger Hans Peter Freyther | f6dbf7f | 2009-12-28 07:27:43 +0100 | [diff] [blame] | 519 | if (rc < 0) { |
| 520 | fprintf(stderr, "Failed to start software load\n"); |
| 521 | exit(-3); |
| 522 | } |
| 523 | } |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 524 | } |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 525 | return 0; |
| 526 | } |
| 527 | |
Holger Hans Peter Freyther | 39d4c8e | 2009-12-30 09:31:31 +0100 | [diff] [blame] | 528 | static struct sw_load *create_swload(struct sdp_header *header) |
| 529 | { |
| 530 | struct sw_load *load; |
| 531 | |
| 532 | load = talloc_zero(tall_ctx_config, struct sw_load); |
| 533 | |
| 534 | strncpy((char *)load->file_id, header->firmware_info.sw_part, 20); |
| 535 | load->file_id_len = strlen(header->firmware_info.sw_part) + 1; |
| 536 | |
| 537 | strncpy((char *)load->file_version, header->firmware_info.version, 20); |
| 538 | load->file_version_len = strlen(header->firmware_info.version) + 1; |
| 539 | |
| 540 | return load; |
| 541 | } |
| 542 | |
Holger Hans Peter Freyther | 3789c12 | 2010-03-22 09:50:56 +0100 | [diff] [blame] | 543 | static int find_sw_load_params(const char *filename) |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 544 | { |
| 545 | struct stat stat; |
| 546 | struct sdp_header *header; |
| 547 | struct llist_head *entry; |
| 548 | int fd; |
| 549 | void *tall_firm_ctx = 0; |
| 550 | |
| 551 | entry = talloc_zero(tall_firm_ctx, struct llist_head); |
| 552 | INIT_LLIST_HEAD(entry); |
| 553 | |
| 554 | fd = open(filename, O_RDONLY); |
| 555 | if (!fd) { |
| 556 | perror("nada"); |
Holger Hans Peter Freyther | 3789c12 | 2010-03-22 09:50:56 +0100 | [diff] [blame] | 557 | return -1; |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | /* verify the file */ |
| 561 | if (fstat(fd, &stat) == -1) { |
| 562 | perror("Can not stat the file"); |
Holger Hans Peter Freyther | 3789c12 | 2010-03-22 09:50:56 +0100 | [diff] [blame] | 563 | return -1; |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | ipaccess_analyze_file(fd, stat.st_size, 0, entry); |
| 567 | if (close(fd) != 0) { |
| 568 | perror("Close failed.\n"); |
Holger Hans Peter Freyther | 3789c12 | 2010-03-22 09:50:56 +0100 | [diff] [blame] | 569 | return -1; |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 570 | } |
| 571 | |
| 572 | /* try to find what we are looking for */ |
| 573 | llist_for_each_entry(header, entry, entry) { |
| 574 | if (ntohs(header->firmware_info.more_more_magic) == 0x1000) { |
Holger Hans Peter Freyther | 39d4c8e | 2009-12-30 09:31:31 +0100 | [diff] [blame] | 575 | sw_load1 = create_swload(header); |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 576 | } else if (ntohs(header->firmware_info.more_more_magic) == 0x2001) { |
Holger Hans Peter Freyther | 39d4c8e | 2009-12-30 09:31:31 +0100 | [diff] [blame] | 577 | sw_load2 = create_swload(header); |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 578 | } |
| 579 | } |
| 580 | |
Holger Hans Peter Freyther | 3789c12 | 2010-03-22 09:50:56 +0100 | [diff] [blame] | 581 | if (!sw_load1 || !sw_load2) { |
| 582 | fprintf(stderr, "Did not find data.\n"); |
| 583 | talloc_free(tall_firm_ctx); |
| 584 | return -1; |
| 585 | } |
| 586 | |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 587 | talloc_free(tall_firm_ctx); |
Holger Hans Peter Freyther | 3789c12 | 2010-03-22 09:50:56 +0100 | [diff] [blame] | 588 | return 0; |
Holger Hans Peter Freyther | f7f2712 | 2009-12-30 08:11:18 +0100 | [diff] [blame] | 589 | } |
| 590 | |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 591 | static void dump_entry(struct sdp_header_item *sub_entry, int part, int fd) |
| 592 | { |
| 593 | int out_fd; |
| 594 | int copied; |
| 595 | char filename[4096]; |
| 596 | off_t target; |
| 597 | |
| 598 | if (!dump_files) |
| 599 | return; |
| 600 | |
| 601 | if (sub_entry->header_entry.something1 == 0) |
| 602 | return; |
| 603 | |
| 604 | snprintf(filename, sizeof(filename), "part.%d", part++); |
| 605 | out_fd = open(filename, O_WRONLY | O_CREAT, 0660); |
| 606 | if (out_fd < 0) { |
| 607 | perror("Can not dump firmware"); |
| 608 | return; |
| 609 | } |
| 610 | |
Holger Hans Peter Freyther | c52dd36 | 2010-03-22 11:50:30 +0100 | [diff] [blame] | 611 | target = sub_entry->absolute_offset + ntohl(sub_entry->header_entry.start) + 4; |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 612 | if (lseek(fd, target, SEEK_SET) != target) { |
| 613 | perror("seek failed"); |
| 614 | close(out_fd); |
| 615 | return; |
| 616 | } |
| 617 | |
| 618 | for (copied = 0; copied < ntohl(sub_entry->header_entry.length); ++copied) { |
| 619 | char c; |
| 620 | if (read(fd, &c, sizeof(c)) != sizeof(c)) { |
| 621 | perror("copy failed"); |
| 622 | break; |
| 623 | } |
| 624 | |
| 625 | if (write(out_fd, &c, sizeof(c)) != sizeof(c)) { |
| 626 | perror("write failed"); |
| 627 | break; |
| 628 | } |
| 629 | } |
| 630 | |
| 631 | close(out_fd); |
| 632 | } |
| 633 | |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 634 | static void analyze_firmware(const char *filename) |
| 635 | { |
| 636 | struct stat stat; |
| 637 | struct sdp_header *header; |
| 638 | struct sdp_header_item *sub_entry; |
| 639 | struct llist_head *entry; |
| 640 | int fd; |
| 641 | void *tall_firm_ctx = 0; |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 642 | int part = 0; |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 643 | |
| 644 | entry = talloc_zero(tall_firm_ctx, struct llist_head); |
| 645 | INIT_LLIST_HEAD(entry); |
| 646 | |
| 647 | printf("Opening possible firmware '%s'\n", filename); |
| 648 | fd = open(filename, O_RDONLY); |
| 649 | if (!fd) { |
| 650 | perror("nada"); |
| 651 | return; |
| 652 | } |
| 653 | |
| 654 | /* verify the file */ |
| 655 | if (fstat(fd, &stat) == -1) { |
| 656 | perror("Can not stat the file"); |
| 657 | return; |
| 658 | } |
| 659 | |
| 660 | ipaccess_analyze_file(fd, stat.st_size, 0, entry); |
| 661 | |
| 662 | llist_for_each_entry(header, entry, entry) { |
| 663 | printf("Printing header information:\n"); |
| 664 | printf("more_more_magic: 0x%x\n", ntohs(header->firmware_info.more_more_magic)); |
| 665 | printf("header_length: %u\n", ntohl(header->firmware_info.header_length)); |
| 666 | printf("file_length: %u\n", ntohl(header->firmware_info.file_length)); |
| 667 | printf("sw_part: %.20s\n", header->firmware_info.sw_part); |
| 668 | printf("text1: %.64s\n", header->firmware_info.text1); |
| 669 | printf("time: %.12s\n", header->firmware_info.time); |
| 670 | printf("date: %.14s\n", header->firmware_info.date); |
| 671 | printf("text2: %.10s\n", header->firmware_info.text2); |
| 672 | printf("version: %.20s\n", header->firmware_info.version); |
| 673 | printf("subitems...\n"); |
| 674 | |
| 675 | llist_for_each_entry(sub_entry, &header->header_list, entry) { |
| 676 | printf("\tsomething1: %u\n", sub_entry->header_entry.something1); |
| 677 | printf("\ttext1: %.64s\n", sub_entry->header_entry.text1); |
| 678 | printf("\ttime: %.12s\n", sub_entry->header_entry.time); |
| 679 | printf("\tdate: %.14s\n", sub_entry->header_entry.date); |
| 680 | printf("\ttext2: %.10s\n", sub_entry->header_entry.text2); |
| 681 | printf("\tversion: %.20s\n", sub_entry->header_entry.version); |
| 682 | printf("\tlength: %u\n", ntohl(sub_entry->header_entry.length)); |
| 683 | printf("\taddr1: 0x%x\n", ntohl(sub_entry->header_entry.addr1)); |
| 684 | printf("\taddr2: 0x%x\n", ntohl(sub_entry->header_entry.addr2)); |
| 685 | printf("\tstart: 0x%x\n", ntohl(sub_entry->header_entry.start)); |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 686 | printf("\tabs. offset: 0x%lx\n", sub_entry->absolute_offset); |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 687 | printf("\n\n"); |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 688 | |
| 689 | dump_entry(sub_entry, part++, fd); |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 690 | } |
| 691 | printf("\n\n"); |
| 692 | } |
| 693 | |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 694 | if (close(fd) != 0) { |
| 695 | perror("Close failed.\n"); |
| 696 | return; |
| 697 | } |
| 698 | |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 699 | talloc_free(tall_firm_ctx); |
| 700 | } |
| 701 | |
Holger Hans Peter Freyther | 5bcfb4f | 2009-07-04 11:53:10 +0200 | [diff] [blame] | 702 | static void print_usage(void) |
| 703 | { |
| 704 | printf("Usage: ipaccess-config\n"); |
| 705 | } |
| 706 | |
| 707 | static void print_help(void) |
| 708 | { |
Harald Welte | 901c819 | 2010-06-28 15:52:56 +0200 | [diff] [blame] | 709 | #if 0 |
| 710 | printf("Commmands for reading from the BTS:\n"); |
| 711 | printf(" -D --dump\t\t\tDump the BTS configuration\n"); |
| 712 | printf("\n"); |
| 713 | #endif |
| 714 | printf("Commmands for writing to the BTS:\n"); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 715 | printf(" -u --unit-id UNIT_ID\t\tSet the Unit ID of the BTS\n"); |
| 716 | printf(" -o --oml-ip IP\t\tSet primary OML IP (IP of your BSC)\n"); |
| 717 | printf(" -i --ip-address IP/MASK\tSet static IP address + netmask of BTS\n"); |
| 718 | printf(" -g --ip-gateway IP\t\tSet static IP gateway of BTS\n"); |
| 719 | printf(" -r --restart\t\t\tRestart the BTS (after other operations)\n"); |
Harald Welte | 901c819 | 2010-06-28 15:52:56 +0200 | [diff] [blame] | 720 | printf(" -n --nvram-flags FLAGS/MASK\tSet NVRAM attributes\n"); |
| 721 | printf(" -S --nvattr-set FLAG\tSet one additional NVRAM attribute\n"); |
| 722 | printf(" -U --nvattr-unset FLAG\tSet one additional NVRAM attribute\n"); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 723 | printf(" -l --listen TESTNR\t\tPerform specified test number\n"); |
Holger Hans Peter Freyther | 657079e | 2011-04-11 20:33:05 +0200 | [diff] [blame] | 724 | printf(" -L --Listen TEST_NAME\t\tPerform specified test\n"); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 725 | printf(" -s --stream-id ID\t\tSet the IPA Stream Identifier for OML\n"); |
| 726 | printf(" -d --software FIRMWARE\tDownload firmware into BTS\n"); |
Harald Welte | 901c819 | 2010-06-28 15:52:56 +0200 | [diff] [blame] | 727 | printf("\n"); |
| 728 | printf("Miscellaneous commands:\n"); |
| 729 | printf(" -h --help\t\t\tthis text\n"); |
Holger Hans Peter Freyther | 5cf68da | 2011-04-11 20:16:52 +0200 | [diff] [blame] | 730 | printf(" -H --HELP\t\t\tPrint parameter details.\n"); |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 731 | printf(" -f --firmware FIRMWARE\tProvide firmware information\n"); |
| 732 | printf(" -w --write-firmware\t\tThis will dump the firmware parts to the filesystem. Use with -f.\n"); |
Holger Hans Peter Freyther | 69dbdee | 2011-04-11 19:32:35 +0200 | [diff] [blame] | 733 | printf(" -p --loop\t\t\tLoop the tests executed with the --listen command.\n"); |
Holger Hans Peter Freyther | 5bcfb4f | 2009-07-04 11:53:10 +0200 | [diff] [blame] | 734 | } |
| 735 | |
Holger Hans Peter Freyther | 5cf68da | 2011-04-11 20:16:52 +0200 | [diff] [blame] | 736 | static void print_value_string(const struct value_string *val, int size) |
| 737 | { |
| 738 | int i; |
| 739 | |
| 740 | for (i = 0; i < size - 1; ++i) { |
| 741 | char sep = val[i + 1].str == NULL ? '.' : ','; |
| 742 | printf("%s%c ", val[i].str, sep); |
| 743 | } |
| 744 | printf("\n"); |
| 745 | } |
| 746 | |
| 747 | static void print_options(void) |
| 748 | { |
| 749 | |
| 750 | printf("Options for NVRAM (-S,-U):\n "); |
| 751 | print_value_string(&ipa_nvflag_strs[0], ARRAY_SIZE(ipa_nvflag_strs)); |
Holger Hans Peter Freyther | 657079e | 2011-04-11 20:33:05 +0200 | [diff] [blame] | 752 | |
| 753 | printf("Options for Tests (-L):\n "); |
| 754 | print_value_string(&ipa_test_strs[0], ARRAY_SIZE(ipa_test_strs)); |
Holger Hans Peter Freyther | 5cf68da | 2011-04-11 20:16:52 +0200 | [diff] [blame] | 755 | } |
| 756 | |
Holger Hans Peter Freyther | b0e4679 | 2010-05-14 02:54:40 +0800 | [diff] [blame] | 757 | extern void bts_model_nanobts_init(); |
| 758 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 759 | int main(int argc, char **argv) |
| 760 | { |
| 761 | struct gsm_bts *bts; |
| 762 | struct sockaddr_in sin; |
Holger Hans Peter Freyther | 2e021c6 | 2009-10-27 03:41:09 +0100 | [diff] [blame] | 763 | int rc, option_index = 0, stream_id = 0xff; |
Harald Welte | 51d2a59 | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 764 | struct log_target *stderr_target; |
Holger Hans Peter Freyther | c8d862e | 2009-12-22 22:32:51 +0100 | [diff] [blame] | 765 | |
Harald Welte | 51d2a59 | 2010-03-26 21:28:59 +0800 | [diff] [blame] | 766 | log_init(&log_info); |
| 767 | stderr_target = log_target_create_stderr(); |
| 768 | log_add_target(stderr_target); |
| 769 | log_set_all_filter(stderr_target, 1); |
| 770 | log_set_log_level(stderr_target, 0); |
| 771 | log_parse_category_mask(stderr_target, "DNM,0"); |
Harald Welte | e462019 | 2010-01-10 18:37:38 +0100 | [diff] [blame] | 772 | bts_model_nanobts_init(); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 773 | |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 774 | printf("ipaccess-config (C) 2009-2010 by Harald Welte and others\n"); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 775 | printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n"); |
| 776 | |
| 777 | while (1) { |
| 778 | int c; |
Harald Welte | 21460f0 | 2009-07-03 11:26:45 +0200 | [diff] [blame] | 779 | unsigned long ul; |
| 780 | char *slash; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 781 | static struct option long_options[] = { |
| 782 | { "unit-id", 1, 0, 'u' }, |
| 783 | { "oml-ip", 1, 0, 'o' }, |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 784 | { "ip-address", 1, 0, 'i' }, |
| 785 | { "ip-gateway", 1, 0, 'g' }, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 786 | { "restart", 0, 0, 'r' }, |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 787 | { "nvram-flags", 1, 0, 'n' }, |
Harald Welte | 901c819 | 2010-06-28 15:52:56 +0200 | [diff] [blame] | 788 | { "nvattr-set", 1, 0, 'S' }, |
| 789 | { "nvattr-unset", 1, 0, 'U' }, |
Holger Hans Peter Freyther | 5bcfb4f | 2009-07-04 11:53:10 +0200 | [diff] [blame] | 790 | { "help", 0, 0, 'h' }, |
Holger Hans Peter Freyther | 5cf68da | 2011-04-11 20:16:52 +0200 | [diff] [blame] | 791 | { "HELP", 0, 0, 'H' }, |
Harald Welte | 12a721e | 2009-08-10 11:39:47 +0200 | [diff] [blame] | 792 | { "listen", 1, 0, 'l' }, |
Holger Hans Peter Freyther | 657079e | 2011-04-11 20:33:05 +0200 | [diff] [blame] | 793 | { "Listen", 1, 0, 'L' }, |
Holger Hans Peter Freyther | 2e021c6 | 2009-10-27 03:41:09 +0100 | [diff] [blame] | 794 | { "stream-id", 1, 0, 's' }, |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 795 | { "software", 1, 0, 'd' }, |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 796 | { "firmware", 1, 0, 'f' }, |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 797 | { "write-firmware", 0, 0, 'w' }, |
Harald Welte | a45efec | 2010-07-30 20:25:48 +0200 | [diff] [blame] | 798 | { "disable-color", 0, 0, 'c'}, |
Holger Hans Peter Freyther | 69dbdee | 2011-04-11 19:32:35 +0200 | [diff] [blame] | 799 | { "loop", 0, 0, 'p' }, |
Holger Hans Peter Freyther | 8616525 | 2010-04-20 22:22:00 +0800 | [diff] [blame] | 800 | { 0, 0, 0, 0 }, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 801 | }; |
| 802 | |
Holger Hans Peter Freyther | 657079e | 2011-04-11 20:33:05 +0200 | [diff] [blame] | 803 | c = getopt_long(argc, argv, "u:o:i:g:rn:S:U:l:L:hs:d:f:wcpH", long_options, |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 804 | &option_index); |
| 805 | |
| 806 | if (c == -1) |
| 807 | break; |
| 808 | |
| 809 | switch (c) { |
| 810 | case 'u': |
| 811 | unit_id = optarg; |
| 812 | break; |
| 813 | case 'o': |
| 814 | prim_oml_ip = optarg; |
| 815 | break; |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 816 | case 'i': |
| 817 | slash = strchr(optarg, '/'); |
| 818 | if (!slash) |
| 819 | exit(2); |
| 820 | bts_ip_addr = optarg; |
Harald Welte | 901c819 | 2010-06-28 15:52:56 +0200 | [diff] [blame] | 821 | *slash = 0; |
Harald Welte | ecb2b41 | 2010-06-28 15:17:57 +0200 | [diff] [blame] | 822 | bts_ip_mask = slash+1; |
| 823 | break; |
| 824 | case 'g': |
| 825 | bts_ip_gw = optarg; |
| 826 | break; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 827 | case 'r': |
| 828 | restart = 1; |
| 829 | break; |
Harald Welte | 21460f0 | 2009-07-03 11:26:45 +0200 | [diff] [blame] | 830 | case 'n': |
| 831 | slash = strchr(optarg, '/'); |
| 832 | if (!slash) |
| 833 | exit(2); |
| 834 | ul = strtoul(optarg, NULL, 16); |
| 835 | nv_flags = ul & 0xffff; |
| 836 | ul = strtoul(slash+1, NULL, 16); |
| 837 | nv_mask = ul & 0xffff; |
| 838 | break; |
Harald Welte | 901c819 | 2010-06-28 15:52:56 +0200 | [diff] [blame] | 839 | case 'S': |
| 840 | if (ipa_nvflag_set(&nv_flags, &nv_mask, optarg, 1) < 0) |
| 841 | exit(2); |
| 842 | break; |
| 843 | case 'U': |
| 844 | if (ipa_nvflag_set(&nv_flags, &nv_mask, optarg, 0) < 0) |
| 845 | exit(2); |
| 846 | break; |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 847 | case 'l': |
Harald Welte | 12a721e | 2009-08-10 11:39:47 +0200 | [diff] [blame] | 848 | net_listen_testnr = atoi(optarg); |
Harald Welte | 0bf8e30 | 2009-08-08 00:02:36 +0200 | [diff] [blame] | 849 | break; |
Holger Hans Peter Freyther | 657079e | 2011-04-11 20:33:05 +0200 | [diff] [blame] | 850 | case 'L': |
| 851 | net_listen_testnr = get_string_value(ipa_test_strs, |
| 852 | optarg); |
| 853 | if (net_listen_testnr < 0) { |
| 854 | fprintf(stderr, |
| 855 | "The test '%s' is not known. Use -H to" |
| 856 | " see available tests.\n", optarg); |
| 857 | exit(2); |
| 858 | } |
Holger Hans Peter Freyther | 2e021c6 | 2009-10-27 03:41:09 +0100 | [diff] [blame] | 859 | case 's': |
| 860 | stream_id = atoi(optarg); |
Holger Hans Peter Freyther | 2e021c6 | 2009-10-27 03:41:09 +0100 | [diff] [blame] | 861 | break; |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 862 | case 'd': |
| 863 | software = strdup(optarg); |
Holger Hans Peter Freyther | 3789c12 | 2010-03-22 09:50:56 +0100 | [diff] [blame] | 864 | if (find_sw_load_params(optarg) != 0) |
| 865 | exit(0); |
Holger Hans Peter Freyther | 4b51338 | 2009-12-28 03:11:33 +0100 | [diff] [blame] | 866 | break; |
Holger Hans Peter Freyther | f3d4a1b | 2009-12-30 07:08:39 +0100 | [diff] [blame] | 867 | case 'f': |
Holger Hans Peter Freyther | 70c67d5 | 2010-03-24 05:26:24 +0100 | [diff] [blame] | 868 | firmware_analysis = optarg; |
| 869 | break; |
Holger Hans Peter Freyther | c6f57c5 | 2010-03-22 11:22:54 +0100 | [diff] [blame] | 870 | case 'w': |
| 871 | dump_files = 1; |
| 872 | break; |
Harald Welte | a45efec | 2010-07-30 20:25:48 +0200 | [diff] [blame] | 873 | case 'c': |
| 874 | log_set_use_color(stderr_target, 0); |
| 875 | break; |
Holger Hans Peter Freyther | 69dbdee | 2011-04-11 19:32:35 +0200 | [diff] [blame] | 876 | case 'p': |
| 877 | loop_tests = 1; |
| 878 | break; |
Holger Hans Peter Freyther | 5bcfb4f | 2009-07-04 11:53:10 +0200 | [diff] [blame] | 879 | case 'h': |
| 880 | print_usage(); |
| 881 | print_help(); |
| 882 | exit(0); |
Holger Hans Peter Freyther | 5cf68da | 2011-04-11 20:16:52 +0200 | [diff] [blame] | 883 | case 'H': |
| 884 | print_options(); |
| 885 | exit(0); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 886 | } |
| 887 | }; |
| 888 | |
Holger Hans Peter Freyther | 70c67d5 | 2010-03-24 05:26:24 +0100 | [diff] [blame] | 889 | if (firmware_analysis) |
| 890 | analyze_firmware(firmware_analysis); |
| 891 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 892 | if (optind >= argc) { |
Holger Hans Peter Freyther | 70c67d5 | 2010-03-24 05:26:24 +0100 | [diff] [blame] | 893 | /* only warn if we have not done anything else */ |
| 894 | if (!firmware_analysis) |
| 895 | fprintf(stderr, "you have to specify the IP address of the BTS. Use --help for more information\n"); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 896 | exit(2); |
| 897 | } |
| 898 | |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 899 | gsmnet = gsm_network_init(1, 1, NULL); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 900 | if (!gsmnet) |
| 901 | exit(1); |
| 902 | |
Mike Haben | 66e0ba0 | 2009-10-02 12:19:34 +0100 | [diff] [blame] | 903 | bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_NANOBTS, HARDCODED_TSC, |
Harald Welte | e712a5f | 2009-06-21 16:17:15 +0200 | [diff] [blame] | 904 | HARDCODED_BSIC); |
Harald Welte (local) | 1949704 | 2009-12-28 23:15:36 +0100 | [diff] [blame] | 905 | /* ip.access supports up to 4 chained TRX */ |
| 906 | gsm_bts_trx_alloc(bts); |
| 907 | gsm_bts_trx_alloc(bts); |
| 908 | gsm_bts_trx_alloc(bts); |
Holger Hans Peter Freyther | 2e021c6 | 2009-10-27 03:41:09 +0100 | [diff] [blame] | 909 | bts->oml_tei = stream_id; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 910 | |
Pablo Neira Ayuso | ef717c6 | 2011-05-06 12:12:31 +0200 | [diff] [blame] | 911 | osmo_signal_register_handler(SS_NM, nm_sig_cb, NULL); |
| 912 | osmo_signal_register_handler(SS_IPAC_NWL, nwl_sig_cb, NULL); |
Harald Welte | 0f31775 | 2010-03-05 19:36:20 +0100 | [diff] [blame] | 913 | |
| 914 | ipac_nwl_init(); |
| 915 | |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 916 | printf("Trying to connect to ip.access BTS ...\n"); |
| 917 | |
| 918 | memset(&sin, 0, sizeof(sin)); |
| 919 | sin.sin_family = AF_INET; |
| 920 | inet_aton(argv[optind], &sin.sin_addr); |
| 921 | rc = ia_config_connect(bts, &sin); |
| 922 | if (rc < 0) { |
| 923 | perror("Error connecting to the BTS"); |
| 924 | exit(1); |
| 925 | } |
| 926 | |
Holger Hans Peter Freyther | 038834b | 2010-04-26 16:02:04 +0800 | [diff] [blame] | 927 | bts->oml_link->ts->sign.delay = 10; |
| 928 | bts->c0->rsl_link->ts->sign.delay = 10; |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 929 | while (1) { |
Pablo Neira Ayuso | 04d24cd | 2011-05-06 12:11:23 +0200 | [diff] [blame] | 930 | rc = osmo_select_main(0); |
Harald Welte | 59b0468 | 2009-06-10 05:40:52 +0800 | [diff] [blame] | 931 | if (rc < 0) |
| 932 | exit(3); |
| 933 | } |
| 934 | |
| 935 | exit(0); |
| 936 | } |
| 937 | |