2009-04-30 15:53:07 +00:00
|
|
|
/* ip.access nanoBTS configuration tool */
|
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
/* (C) 2009-2010 by Harald Welte <laforge@gnumonks.org>
|
|
|
|
* (C) 2009-2010 by Holger Hans Peter Freyther
|
|
|
|
* (C) 2009-2010 by On Waves
|
2009-04-30 15:53:07 +00:00
|
|
|
* All Rights Reserved
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <getopt.h>
|
split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB
The library currently includes the following modules:
bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist
msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
2010-02-20 15:24:02 +00:00
|
|
|
#include <errno.h>
|
2009-12-30 06:08:39 +00:00
|
|
|
#include <sys/fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
2009-04-30 15:53:07 +00:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include <sys/socket.h>
|
|
|
|
#include <netinet/in.h>
|
|
|
|
#include <arpa/inet.h>
|
|
|
|
|
|
|
|
|
split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB
The library currently includes the following modules:
bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist
msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
2010-02-20 15:24:02 +00:00
|
|
|
#include <osmocore/select.h>
|
|
|
|
#include <osmocore/timer.h>
|
2009-04-30 15:53:07 +00:00
|
|
|
#include <openbsc/ipaccess.h>
|
|
|
|
#include <openbsc/gsm_data.h>
|
|
|
|
#include <openbsc/e1_input.h>
|
|
|
|
#include <openbsc/abis_nm.h>
|
2009-07-07 10:40:07 +00:00
|
|
|
#include <openbsc/signal.h>
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
#include <openbsc/debug.h>
|
2010-03-05 18:36:20 +00:00
|
|
|
#include <openbsc/network_listen.h>
|
split 'libosmocore' from openbsc codebase
This library is intended to collect all generic/common funcitionality
of all Osmocom.org projects, including OpenBSC but also OsmocomBB
The library currently includes the following modules:
bitvec, comp128, gsm_utils, msgb, select, signal, statistics, talloc, timer,
tlv_parse, linuxlist
msgb allocation error debugging had to be temporarily disabled as it depends on
'debug.c' functionality which at the moment remains in OpenBSC
2010-02-20 15:24:02 +00:00
|
|
|
#include <osmocore/talloc.h>
|
2009-04-30 15:53:07 +00:00
|
|
|
|
|
|
|
static struct gsm_network *gsmnet;
|
|
|
|
|
add support for more nanoBTS 12.21 tests
* perform a channel usage test
$ ./ipaccess-config -l 64 192.168.100.100
paccess-config.c:142 ==> ARFCN 3, RxLev 16
[...]
<0020> ipaccess-config.c:142 ==> ARFCN 4, RxLev 33
<0020> ipaccess-config.c:142 ==> ARFCN 8, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 5, RxLev 16
<0020> ipaccess-config.c:142 ==> ARFCN 11, RxLev 5
<0020> ipaccess-config.c:142 ==> ARFCN 12, RxLev 8
<0020> ipaccess-config.c:142 ==> ARFCN 10, RxLev 6
[...]
* perform a BCCH usage test
$ ./ipaccess-config -l 65 192.168.100.100
[...]
<0020> ipaccess-config.c:107 TEST REPORT: test_no=0x41 test_res=SUCCESS
<0020> ipaccess-config.c:142 ==> ARFCN 4, RxLev 32
<0020> ipaccess-config.c:142 ==> ARFCN 8, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 12, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 20, RxLev 9
<0020> ipaccess-config.c:142 ==> ARFCN 31, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 37, RxLev 23
<0020> ipaccess-config.c:142 ==> ARFCN 49, RxLev 7
<0020> ipaccess-config.c:142 ==> ARFCN 53, RxLev 14
<0020> ipaccess-config.c:142 ==> ARFCN 57, RxLev 19
<0020> ipaccess-config.c:142 ==> ARFCN 60, RxLev 63
<0020> ipaccess-config.c:142 ==> ARFCN 71, RxLev 15
<0020> ipaccess-config.c:142 ==> ARFCN 90, RxLev 4
* perform a frequency sync test
$ ./ipaccess-config -l 66 192.168.100.100
[...]
<0020> ipaccess-config.c:107 TEST REPORT: test_no=0x42 test_res=SUCCESS
<0020> ipaccess-config.c:130 ==> ARFCN 4, Frequency Error -2
<0020> ipaccess-config.c:130 ==> ARFCN 8, Frequency Error -40
<0020> ipaccess-config.c:130 ==> ARFCN 20, Frequency Error -21
<0020> ipaccess-config.c:130 ==> ARFCN 31, Frequency Error 1
<0020> ipaccess-config.c:130 ==> ARFCN 37, Frequency Error -4
<0020> ipaccess-config.c:130 ==> ARFCN 45, Frequency Error -4
<0020> ipaccess-config.c:130 ==> ARFCN 53, Frequency Error 22
<0020> ipaccess-config.c:130 ==> ARFCN 57, Frequency Error 3
<0020> ipaccess-config.c:130 ==> ARFCN 60, Frequency Error 0
<0020> ipaccess-config.c:130 ==> ARFCN 69, Frequency Error 2
<0020> ipaccess-config.c:130 ==> ARFCN 73, Frequency Error 30
<0020> ipaccess-config.c:130 ==> ARFCN 89, Frequency Error 44
<0020> ipaccess-config.c:130 ==> ARFCN 90, Frequency Error 8
<0020> ipaccess-config.c:130 ==> ARFCN 123, Frequency Error 27
2009-08-10 09:39:47 +00:00
|
|
|
static int net_listen_testnr;
|
2009-04-30 15:53:07 +00:00
|
|
|
static int restart;
|
|
|
|
static char *prim_oml_ip;
|
2010-06-28 13:17:57 +00:00
|
|
|
static char *bts_ip_addr, *bts_ip_mask, *bts_ip_gw;
|
2009-04-30 15:53:07 +00:00
|
|
|
static char *unit_id;
|
2009-07-03 09:26:45 +00:00
|
|
|
static u_int16_t nv_flags;
|
|
|
|
static u_int16_t nv_mask;
|
2009-12-28 02:11:33 +00:00
|
|
|
static char *software = NULL;
|
2009-12-28 11:18:37 +00:00
|
|
|
static int sw_load_state = 0;
|
2009-12-30 07:38:43 +00:00
|
|
|
static int oml_state = 0;
|
2010-03-22 10:22:54 +00:00
|
|
|
static int dump_files = 0;
|
2010-03-24 04:26:24 +00:00
|
|
|
static char *firmware_analysis = NULL;
|
2010-05-12 08:44:01 +00:00
|
|
|
static int found_trx = 0;
|
2009-12-28 11:18:37 +00:00
|
|
|
|
|
|
|
struct sw_load {
|
|
|
|
u_int8_t file_id[255];
|
|
|
|
u_int8_t file_id_len;
|
|
|
|
|
|
|
|
u_int8_t file_version[255];
|
|
|
|
u_int8_t file_version_len;
|
|
|
|
};
|
|
|
|
|
2009-12-30 07:11:18 +00:00
|
|
|
static void *tall_ctx_config = NULL;
|
2009-12-28 11:18:37 +00:00
|
|
|
static struct sw_load *sw_load1 = NULL;
|
|
|
|
static struct sw_load *sw_load2 = NULL;
|
2009-04-30 15:53:07 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
static u_int8_t prim_oml_attr[] = { 0x95, 0x00, 7, 0x88, 192, 168, 100, 11, 0x00, 0x00 };
|
|
|
|
static u_int8_t unit_id_attr[] = { 0x91, 0x00, 9, '2', '3', '4', '2', '/' , '0', '/', '0', 0x00 };
|
|
|
|
*/
|
|
|
|
|
2009-07-07 10:40:07 +00:00
|
|
|
/*
|
|
|
|
* Callback function for NACK on the OML NM
|
|
|
|
*
|
|
|
|
* Currently we send the config requests but don't check the
|
|
|
|
* result. The nanoBTS will send us a NACK when we did something the
|
|
|
|
* BTS didn't like.
|
|
|
|
*/
|
2009-11-17 05:09:56 +00:00
|
|
|
static int ipacc_msg_nack(u_int8_t mt)
|
2009-07-07 10:40:07 +00:00
|
|
|
{
|
|
|
|
fprintf(stderr, "Failure to set attribute. This seems fatal\n");
|
|
|
|
exit(-1);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-05-12 15:34:51 +00:00
|
|
|
static void check_restart_or_exit(struct gsm_bts_trx *trx)
|
2010-05-12 15:16:59 +00:00
|
|
|
{
|
|
|
|
if (restart) {
|
2010-05-12 15:34:51 +00:00
|
|
|
abis_nm_ipaccess_restart(trx);
|
2010-05-12 15:16:59 +00:00
|
|
|
} else {
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-05-12 15:34:51 +00:00
|
|
|
static int ipacc_msg_ack(u_int8_t mt, struct gsm_bts_trx *trx)
|
2009-12-29 10:26:38 +00:00
|
|
|
{
|
|
|
|
if (sw_load_state == 1) {
|
|
|
|
fprintf(stderr, "The new software is activaed.\n");
|
2010-05-12 15:34:51 +00:00
|
|
|
check_restart_or_exit(trx);
|
2009-12-30 07:38:43 +00:00
|
|
|
} else if (oml_state == 1) {
|
2010-06-28 12:41:09 +00:00
|
|
|
fprintf(stderr, "Set the NV Attributes.\n");
|
2010-05-12 15:34:51 +00:00
|
|
|
check_restart_or_exit(trx);
|
2009-12-29 10:26:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-03-06 10:38:05 +00:00
|
|
|
const uint8_t phys_conf[] = { 0x02, 0x0a, 0x00, 0x01, 0x02 };
|
|
|
|
|
2010-03-05 18:36:20 +00:00
|
|
|
static int nwl_sig_cb(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data)
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
{
|
2010-03-05 18:36:20 +00:00
|
|
|
struct gsm_bts_trx *trx;
|
|
|
|
|
|
|
|
switch (signal) {
|
|
|
|
case S_IPAC_NWL_COMPLETE:
|
|
|
|
trx = signal_data;
|
2010-03-06 10:38:05 +00:00
|
|
|
DEBUGP(DNM, "received S_IPAC_NWL_COMPLETE signal\n");
|
|
|
|
rxlev_stat_dump(&trx->ipaccess.rxlev_stat);
|
|
|
|
DEBUGP(DNM, "starting next test\n");
|
|
|
|
ipac_nwl_test_start(trx, net_listen_testnr, phys_conf,
|
|
|
|
sizeof(phys_conf));
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-07 10:40:07 +00:00
|
|
|
static int nm_sig_cb(unsigned int subsys, unsigned int signal,
|
|
|
|
void *handler_data, void *signal_data)
|
|
|
|
{
|
2009-12-30 07:38:43 +00:00
|
|
|
struct ipacc_ack_signal_data *ipacc_data;
|
2009-11-17 05:09:56 +00:00
|
|
|
|
2009-07-07 10:40:07 +00:00
|
|
|
switch (signal) {
|
|
|
|
case S_NM_IPACC_NACK:
|
2009-12-30 07:38:43 +00:00
|
|
|
ipacc_data = signal_data;
|
|
|
|
return ipacc_msg_nack(ipacc_data->msg_type);
|
2009-12-29 10:26:38 +00:00
|
|
|
case S_NM_IPACC_ACK:
|
2009-12-30 07:38:43 +00:00
|
|
|
ipacc_data = signal_data;
|
2010-05-12 15:34:51 +00:00
|
|
|
return ipacc_msg_ack(ipacc_data->msg_type, ipacc_data->trx);
|
2009-12-30 08:00:01 +00:00
|
|
|
case S_NM_IPACC_RESTART_ACK:
|
|
|
|
printf("The BTS has acked the restart. Exiting.\n");
|
|
|
|
exit(0);
|
|
|
|
break;
|
|
|
|
case S_NM_IPACC_RESTART_NACK:
|
|
|
|
printf("The BTS has nacked the restart. Exiting.\n");
|
|
|
|
exit(0);
|
|
|
|
break;
|
2009-07-07 10:40:07 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-28 02:11:33 +00:00
|
|
|
/* callback function passed to the ABIS OML code */
|
|
|
|
static int percent;
|
|
|
|
static int percent_old;
|
2009-12-28 11:18:37 +00:00
|
|
|
static int swload_cbfn(unsigned int hook, unsigned int event, struct msgb *_msg,
|
2009-12-28 02:11:33 +00:00
|
|
|
void *data, void *param)
|
|
|
|
{
|
2009-12-28 11:18:37 +00:00
|
|
|
struct msgb *msg;
|
2010-05-12 16:14:46 +00:00
|
|
|
struct gsm_bts_trx *trx;
|
2009-12-28 02:11:33 +00:00
|
|
|
|
|
|
|
if (hook != GSM_HOOK_NM_SWLOAD)
|
|
|
|
return 0;
|
|
|
|
|
2010-05-12 16:14:46 +00:00
|
|
|
trx = (struct gsm_bts_trx *) data;
|
2009-12-28 02:11:33 +00:00
|
|
|
|
|
|
|
switch (event) {
|
|
|
|
case NM_MT_LOAD_INIT_ACK:
|
|
|
|
fprintf(stdout, "Software Load Initiate ACK\n");
|
|
|
|
break;
|
|
|
|
case NM_MT_LOAD_INIT_NACK:
|
|
|
|
fprintf(stderr, "ERROR: Software Load Initiate NACK\n");
|
|
|
|
exit(5);
|
|
|
|
break;
|
|
|
|
case NM_MT_LOAD_END_ACK:
|
|
|
|
fprintf(stderr, "LOAD END ACK...");
|
2009-12-28 11:18:37 +00:00
|
|
|
/* now make it the default */
|
|
|
|
sw_load_state = 1;
|
|
|
|
|
|
|
|
msg = msgb_alloc(1024, "sw: nvattr");
|
|
|
|
msg->l2h = msgb_put(msg, 3);
|
|
|
|
msg->l3h = &msg->l2h[3];
|
|
|
|
|
|
|
|
/* activate software */
|
|
|
|
if (sw_load1) {
|
|
|
|
msgb_v_put(msg, NM_ATT_SW_DESCR);
|
|
|
|
msgb_tl16v_put(msg, NM_ATT_FILE_ID, sw_load1->file_id_len, sw_load1->file_id);
|
|
|
|
msgb_tl16v_put(msg, NM_ATT_FILE_VERSION, sw_load1->file_version_len,
|
|
|
|
sw_load1->file_version);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sw_load2) {
|
|
|
|
msgb_v_put(msg, NM_ATT_SW_DESCR);
|
2009-12-29 10:12:00 +00:00
|
|
|
msgb_tl16v_put(msg, NM_ATT_FILE_ID, sw_load2->file_id_len, sw_load2->file_id);
|
2009-12-28 11:18:37 +00:00
|
|
|
msgb_tl16v_put(msg, NM_ATT_FILE_VERSION, sw_load2->file_version_len,
|
|
|
|
sw_load2->file_version);
|
2009-12-28 02:11:33 +00:00
|
|
|
}
|
2009-12-28 11:18:37 +00:00
|
|
|
|
|
|
|
/* fill in the data */
|
|
|
|
msg->l2h[0] = NM_ATT_IPACC_CUR_SW_CFG;
|
|
|
|
msg->l2h[1] = msgb_l3len(msg) >> 8;
|
|
|
|
msg->l2h[2] = msgb_l3len(msg) & 0xff;
|
|
|
|
printf("Foo l2h: %p l3h: %p... length l2: %u l3: %u\n", msg->l2h, msg->l3h, msgb_l2len(msg), msgb_l3len(msg));
|
2010-05-12 16:14:46 +00:00
|
|
|
abis_nm_ipaccess_set_nvattr(trx, msg->l2h, msgb_l2len(msg));
|
2009-12-28 11:18:37 +00:00
|
|
|
msgb_free(msg);
|
2009-12-28 02:11:33 +00:00
|
|
|
break;
|
|
|
|
case NM_MT_LOAD_END_NACK:
|
|
|
|
fprintf(stderr, "ERROR: Software Load End NACK\n");
|
|
|
|
exit(3);
|
|
|
|
break;
|
|
|
|
case NM_MT_ACTIVATE_SW_NACK:
|
|
|
|
fprintf(stderr, "ERROR: Activate Software NACK\n");
|
|
|
|
exit(4);
|
|
|
|
break;
|
|
|
|
case NM_MT_ACTIVATE_SW_ACK:
|
|
|
|
break;
|
|
|
|
case NM_MT_LOAD_SEG_ACK:
|
2010-05-12 16:14:46 +00:00
|
|
|
percent = abis_nm_software_load_status(trx->bts);
|
2009-12-28 02:11:33 +00:00
|
|
|
if (percent > percent_old)
|
|
|
|
printf("Software Download Progress: %d%%\n", percent);
|
|
|
|
percent_old = percent;
|
|
|
|
break;
|
2009-12-28 11:23:02 +00:00
|
|
|
case NM_MT_LOAD_ABORT:
|
|
|
|
fprintf(stderr, "ERROR: Load aborted by the BTS.\n");
|
|
|
|
exit(6);
|
|
|
|
break;
|
2009-12-28 02:11:33 +00:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
static void nv_put_ip_if_cfg(struct msgb *nmsg, uint32_t ip, uint32_t mask)
|
|
|
|
{
|
|
|
|
msgb_put_u8(nmsg, NM_ATT_IPACC_IP_IF_CFG);
|
|
|
|
|
|
|
|
msgb_put_u32(nmsg, ip);
|
|
|
|
msgb_put_u32(nmsg, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv_put_gw_cfg(struct msgb *nmsg, uint32_t addr, uint32_t mask, uint32_t gw)
|
|
|
|
{
|
|
|
|
msgb_put_u8(nmsg, NM_ATT_IPACC_IP_GW_CFG);
|
|
|
|
msgb_put_u32(nmsg, addr);
|
|
|
|
msgb_put_u32(nmsg, mask);
|
|
|
|
msgb_put_u32(nmsg, gw);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv_put_unit_id(struct msgb *nmsg, const char *unit_id)
|
|
|
|
{
|
|
|
|
msgb_tl16v_put(nmsg, NM_ATT_IPACC_UNIT_ID, strlen(unit_id)+1,
|
|
|
|
(const uint8_t *)unit_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv_put_prim_oml(struct msgb *nmsg, uint32_t ip, uint16_t port)
|
2009-04-30 15:53:07 +00:00
|
|
|
{
|
|
|
|
int len;
|
2010-06-28 13:17:57 +00:00
|
|
|
|
|
|
|
/* 0x88 + IP + port */
|
|
|
|
len = 1 + sizeof(ip) + sizeof(port);
|
|
|
|
|
|
|
|
msgb_put_u8(nmsg, NM_ATT_IPACC_PRIM_OML_CFG_LIST);
|
|
|
|
msgb_put_u16(nmsg, len);
|
|
|
|
|
|
|
|
msgb_put_u8(nmsg, 0x88);
|
|
|
|
|
|
|
|
/* IP address */
|
|
|
|
msgb_put_u32(nmsg, ip);
|
|
|
|
|
|
|
|
/* port number */
|
|
|
|
msgb_put_u16(nmsg, port);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void nv_put_flags(struct msgb *nmsg, uint16_t nv_flags, uint16_t nv_mask)
|
|
|
|
{
|
|
|
|
msgb_put_u8(nmsg, NM_ATT_IPACC_NV_FLAGS);
|
|
|
|
msgb_put_u16(nmsg, sizeof(nv_flags) + sizeof(nv_mask));
|
|
|
|
msgb_put_u8(nmsg, nv_flags & 0xff);
|
|
|
|
msgb_put_u8(nmsg, nv_mask & 0xff);
|
|
|
|
msgb_put_u8(nmsg, nv_flags >> 8);
|
|
|
|
msgb_put_u8(nmsg, nv_mask >> 8);
|
|
|
|
}
|
|
|
|
|
2010-06-28 13:52:56 +00:00
|
|
|
/* human-readable names for the ip.access nanoBTS NVRAM Flags */
|
|
|
|
static const struct value_string ipa_nvflag_strs[] = {
|
|
|
|
{ 0x0001, "static-ip" },
|
|
|
|
{ 0x0002, "static-gw" },
|
|
|
|
{ 0x0004, "no-dhcp-vsi" },
|
|
|
|
{ 0x0008, "dhcp-enabled" },
|
|
|
|
{ 0x0040, "led-disabled" },
|
|
|
|
{ 0x0100, "secondary-oml-enabled" },
|
|
|
|
{ 0x0200, "diag-enabled" },
|
|
|
|
{ 0x0400, "cli-enabled" },
|
|
|
|
{ 0x0800, "http-enabled" },
|
|
|
|
{ 0x1000, "post-enabled" },
|
|
|
|
{ 0x2000, "snmp-enabled" },
|
|
|
|
{ 0, NULL }
|
|
|
|
};
|
|
|
|
|
|
|
|
/* set the flags in flags/mask according to a string-identified flag and 'enable' */
|
|
|
|
static int ipa_nvflag_set(uint16_t *flags, uint16_t *mask, const char *name, int en)
|
|
|
|
{
|
|
|
|
int rc;
|
|
|
|
rc = get_string_value(ipa_nvflag_strs, name);
|
|
|
|
if (rc < 0)
|
|
|
|
return rc;
|
|
|
|
|
|
|
|
*mask |= rc;
|
|
|
|
if (en)
|
|
|
|
*flags |= rc;
|
|
|
|
else
|
|
|
|
*flags &= ~rc;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
static void bootstrap_om(struct gsm_bts_trx *trx)
|
|
|
|
{
|
2010-06-28 12:41:09 +00:00
|
|
|
struct msgb *nmsg = msgb_alloc(1024, "nested msgb");
|
2010-06-28 13:17:57 +00:00
|
|
|
int need_to_set_attr = 0;
|
|
|
|
int len;
|
2009-04-30 15:53:07 +00:00
|
|
|
|
2010-05-12 08:44:01 +00:00
|
|
|
printf("OML link established using TRX %d\n", trx->nr);
|
2009-04-30 15:53:07 +00:00
|
|
|
|
|
|
|
if (unit_id) {
|
|
|
|
len = strlen(unit_id);
|
2010-06-28 12:41:09 +00:00
|
|
|
if (len > nmsg->data_len-10)
|
|
|
|
goto out_err;
|
2009-04-30 15:53:07 +00:00
|
|
|
printf("setting Unit ID to '%s'\n", unit_id);
|
2010-06-28 13:17:57 +00:00
|
|
|
nv_put_unit_id(nmsg, unit_id);
|
|
|
|
need_to_set_attr = 1;
|
2009-04-30 15:53:07 +00:00
|
|
|
}
|
|
|
|
if (prim_oml_ip) {
|
|
|
|
struct in_addr ia;
|
|
|
|
|
|
|
|
if (!inet_aton(prim_oml_ip, &ia)) {
|
|
|
|
fprintf(stderr, "invalid IP address: %s\n",
|
|
|
|
prim_oml_ip);
|
2010-06-28 12:41:09 +00:00
|
|
|
goto out_err;
|
2009-04-30 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
printf("setting primary OML link IP to '%s'\n", inet_ntoa(ia));
|
|
|
|
nv_put_prim_oml(nmsg, ntohl(ia.s_addr), 0);
|
|
|
|
need_to_set_attr = 1;
|
|
|
|
}
|
|
|
|
if (nv_mask) {
|
|
|
|
printf("setting NV Flags/Mask to 0x%04x/0x%04x\n",
|
|
|
|
nv_flags, nv_mask);
|
|
|
|
nv_put_flags(nmsg, nv_flags, nv_mask);
|
|
|
|
need_to_set_attr = 1;
|
|
|
|
}
|
|
|
|
if (bts_ip_addr && bts_ip_mask) {
|
|
|
|
struct in_addr ia_addr, ia_mask;
|
2010-06-28 12:41:09 +00:00
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
if (!inet_aton(bts_ip_addr, &ia_addr)) {
|
|
|
|
fprintf(stderr, "invalid IP address: %s\n",
|
|
|
|
bts_ip_addr);
|
|
|
|
goto out_err;
|
|
|
|
}
|
2010-06-28 12:41:09 +00:00
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
if (!inet_aton(bts_ip_mask, &ia_mask)) {
|
|
|
|
fprintf(stderr, "invalid IP address: %s\n",
|
|
|
|
bts_ip_mask);
|
|
|
|
goto out_err;
|
|
|
|
}
|
2010-06-28 12:41:09 +00:00
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
printf("setting static IP Address/Mask\n");
|
|
|
|
nv_put_ip_if_cfg(nmsg, ntohl(ia_addr.s_addr), ntohl(ia_mask.s_addr));
|
|
|
|
need_to_set_attr = 1;
|
2009-04-30 15:53:07 +00:00
|
|
|
}
|
2010-06-28 13:17:57 +00:00
|
|
|
if (bts_ip_gw) {
|
|
|
|
struct in_addr ia_gw;
|
2009-07-03 09:26:45 +00:00
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
if (!inet_aton(bts_ip_gw, &ia_gw)) {
|
|
|
|
fprintf(stderr, "invalid IP address: %s\n",
|
|
|
|
bts_ip_gw);
|
|
|
|
goto out_err;
|
|
|
|
}
|
2010-06-28 12:41:09 +00:00
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
printf("setting static IP Gateway\n");
|
|
|
|
/* we only set the default gateway with zero addr/mask */
|
|
|
|
nv_put_gw_cfg(nmsg, 0, 0, ntohl(ia_gw.s_addr));
|
|
|
|
need_to_set_attr = 1;
|
2009-07-03 09:26:45 +00:00
|
|
|
}
|
2009-04-30 15:53:07 +00:00
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
if (need_to_set_attr) {
|
|
|
|
abis_nm_ipaccess_set_nvattr(trx, nmsg->head, nmsg->len);
|
|
|
|
oml_state = 1;
|
|
|
|
}
|
2010-06-28 12:41:09 +00:00
|
|
|
|
2009-12-30 07:38:43 +00:00
|
|
|
if (restart && !prim_oml_ip && !software) {
|
2009-04-30 15:53:07 +00:00
|
|
|
printf("restarting BTS\n");
|
2010-05-12 15:34:51 +00:00
|
|
|
abis_nm_ipaccess_restart(trx);
|
2009-04-30 15:53:07 +00:00
|
|
|
}
|
2009-12-28 02:11:33 +00:00
|
|
|
|
2010-06-28 12:41:09 +00:00
|
|
|
out_err:
|
|
|
|
msgb_free(nmsg);
|
2009-04-30 15:53:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void input_event(int event, enum e1inp_sign_type type, struct gsm_bts_trx *trx)
|
|
|
|
{
|
|
|
|
switch (event) {
|
|
|
|
case EVT_E1_TEI_UP:
|
|
|
|
switch (type) {
|
|
|
|
case E1INP_SIGN_OML:
|
|
|
|
break;
|
|
|
|
case E1INP_SIGN_RSL:
|
|
|
|
/* FIXME */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case EVT_E1_TEI_DN:
|
|
|
|
fprintf(stderr, "Lost some E1 TEI link\n");
|
|
|
|
/* FIXME: deal with TEI or L1 link loss */
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int nm_state_event(enum nm_evt evt, u_int8_t obj_class, void *obj,
|
2010-05-12 16:37:48 +00:00
|
|
|
struct gsm_nm_state *old_state, struct gsm_nm_state *new_state,
|
|
|
|
struct abis_om_obj_inst *obj_inst)
|
2009-04-30 15:53:07 +00:00
|
|
|
{
|
2010-05-12 08:44:01 +00:00
|
|
|
if (obj_class == NM_OC_BASEB_TRANSC) {
|
|
|
|
if (!found_trx && obj_inst->trx_nr != 0xff) {
|
|
|
|
struct gsm_bts_trx *trx = container_of(obj, struct gsm_bts_trx, bb_transc);
|
|
|
|
bootstrap_om(trx);
|
|
|
|
found_trx = 1;
|
|
|
|
}
|
|
|
|
} else if (evt == EVT_STATECHG_OPER &&
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
obj_class == NM_OC_RADIO_CARRIER &&
|
2009-12-28 06:27:43 +00:00
|
|
|
new_state->availability == 3) {
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
struct gsm_bts_trx *trx = obj;
|
2009-12-28 06:27:43 +00:00
|
|
|
|
2010-03-05 18:36:20 +00:00
|
|
|
if (net_listen_testnr)
|
2010-03-06 10:38:05 +00:00
|
|
|
ipac_nwl_test_start(trx, net_listen_testnr, phys_conf,
|
|
|
|
sizeof(phys_conf));
|
2010-03-05 18:36:20 +00:00
|
|
|
else if (software) {
|
2009-12-28 06:27:43 +00:00
|
|
|
int rc;
|
|
|
|
printf("Attempting software upload with '%s'\n", software);
|
2010-05-12 16:14:46 +00:00
|
|
|
rc = abis_nm_software_load(trx->bts, trx->nr, software, 19, 0, swload_cbfn, trx);
|
2009-12-28 06:27:43 +00:00
|
|
|
if (rc < 0) {
|
|
|
|
fprintf(stderr, "Failed to start software load\n");
|
|
|
|
exit(-3);
|
|
|
|
}
|
|
|
|
}
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
}
|
2009-04-30 15:53:07 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-30 08:31:31 +00:00
|
|
|
static struct sw_load *create_swload(struct sdp_header *header)
|
|
|
|
{
|
|
|
|
struct sw_load *load;
|
|
|
|
|
|
|
|
load = talloc_zero(tall_ctx_config, struct sw_load);
|
|
|
|
|
|
|
|
strncpy((char *)load->file_id, header->firmware_info.sw_part, 20);
|
|
|
|
load->file_id_len = strlen(header->firmware_info.sw_part) + 1;
|
|
|
|
|
|
|
|
strncpy((char *)load->file_version, header->firmware_info.version, 20);
|
|
|
|
load->file_version_len = strlen(header->firmware_info.version) + 1;
|
|
|
|
|
|
|
|
return load;
|
|
|
|
}
|
|
|
|
|
2010-03-22 08:50:56 +00:00
|
|
|
static int find_sw_load_params(const char *filename)
|
2009-12-30 07:11:18 +00:00
|
|
|
{
|
|
|
|
struct stat stat;
|
|
|
|
struct sdp_header *header;
|
|
|
|
struct llist_head *entry;
|
|
|
|
int fd;
|
|
|
|
void *tall_firm_ctx = 0;
|
|
|
|
|
|
|
|
entry = talloc_zero(tall_firm_ctx, struct llist_head);
|
|
|
|
INIT_LLIST_HEAD(entry);
|
|
|
|
|
|
|
|
fd = open(filename, O_RDONLY);
|
|
|
|
if (!fd) {
|
|
|
|
perror("nada");
|
2010-03-22 08:50:56 +00:00
|
|
|
return -1;
|
2009-12-30 07:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* verify the file */
|
|
|
|
if (fstat(fd, &stat) == -1) {
|
|
|
|
perror("Can not stat the file");
|
2010-03-22 08:50:56 +00:00
|
|
|
return -1;
|
2009-12-30 07:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ipaccess_analyze_file(fd, stat.st_size, 0, entry);
|
|
|
|
if (close(fd) != 0) {
|
|
|
|
perror("Close failed.\n");
|
2010-03-22 08:50:56 +00:00
|
|
|
return -1;
|
2009-12-30 07:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* try to find what we are looking for */
|
|
|
|
llist_for_each_entry(header, entry, entry) {
|
|
|
|
if (ntohs(header->firmware_info.more_more_magic) == 0x1000) {
|
2009-12-30 08:31:31 +00:00
|
|
|
sw_load1 = create_swload(header);
|
2009-12-30 07:11:18 +00:00
|
|
|
} else if (ntohs(header->firmware_info.more_more_magic) == 0x2001) {
|
2009-12-30 08:31:31 +00:00
|
|
|
sw_load2 = create_swload(header);
|
2009-12-30 07:11:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-22 08:50:56 +00:00
|
|
|
if (!sw_load1 || !sw_load2) {
|
|
|
|
fprintf(stderr, "Did not find data.\n");
|
|
|
|
talloc_free(tall_firm_ctx);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-12-30 07:11:18 +00:00
|
|
|
talloc_free(tall_firm_ctx);
|
2010-03-22 08:50:56 +00:00
|
|
|
return 0;
|
2009-12-30 07:11:18 +00:00
|
|
|
}
|
|
|
|
|
2010-03-22 10:22:54 +00:00
|
|
|
static void dump_entry(struct sdp_header_item *sub_entry, int part, int fd)
|
|
|
|
{
|
|
|
|
int out_fd;
|
|
|
|
int copied;
|
|
|
|
char filename[4096];
|
|
|
|
off_t target;
|
|
|
|
|
|
|
|
if (!dump_files)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (sub_entry->header_entry.something1 == 0)
|
|
|
|
return;
|
|
|
|
|
|
|
|
snprintf(filename, sizeof(filename), "part.%d", part++);
|
|
|
|
out_fd = open(filename, O_WRONLY | O_CREAT, 0660);
|
|
|
|
if (out_fd < 0) {
|
|
|
|
perror("Can not dump firmware");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-03-22 10:50:30 +00:00
|
|
|
target = sub_entry->absolute_offset + ntohl(sub_entry->header_entry.start) + 4;
|
2010-03-22 10:22:54 +00:00
|
|
|
if (lseek(fd, target, SEEK_SET) != target) {
|
|
|
|
perror("seek failed");
|
|
|
|
close(out_fd);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (copied = 0; copied < ntohl(sub_entry->header_entry.length); ++copied) {
|
|
|
|
char c;
|
|
|
|
if (read(fd, &c, sizeof(c)) != sizeof(c)) {
|
|
|
|
perror("copy failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (write(out_fd, &c, sizeof(c)) != sizeof(c)) {
|
|
|
|
perror("write failed");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
close(out_fd);
|
|
|
|
}
|
|
|
|
|
2009-12-30 06:08:39 +00:00
|
|
|
static void analyze_firmware(const char *filename)
|
|
|
|
{
|
|
|
|
struct stat stat;
|
|
|
|
struct sdp_header *header;
|
|
|
|
struct sdp_header_item *sub_entry;
|
|
|
|
struct llist_head *entry;
|
|
|
|
int fd;
|
|
|
|
void *tall_firm_ctx = 0;
|
2010-03-22 10:22:54 +00:00
|
|
|
int part = 0;
|
2009-12-30 06:08:39 +00:00
|
|
|
|
|
|
|
entry = talloc_zero(tall_firm_ctx, struct llist_head);
|
|
|
|
INIT_LLIST_HEAD(entry);
|
|
|
|
|
|
|
|
printf("Opening possible firmware '%s'\n", filename);
|
|
|
|
fd = open(filename, O_RDONLY);
|
|
|
|
if (!fd) {
|
|
|
|
perror("nada");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* verify the file */
|
|
|
|
if (fstat(fd, &stat) == -1) {
|
|
|
|
perror("Can not stat the file");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ipaccess_analyze_file(fd, stat.st_size, 0, entry);
|
|
|
|
|
|
|
|
llist_for_each_entry(header, entry, entry) {
|
|
|
|
printf("Printing header information:\n");
|
|
|
|
printf("more_more_magic: 0x%x\n", ntohs(header->firmware_info.more_more_magic));
|
|
|
|
printf("header_length: %u\n", ntohl(header->firmware_info.header_length));
|
|
|
|
printf("file_length: %u\n", ntohl(header->firmware_info.file_length));
|
|
|
|
printf("sw_part: %.20s\n", header->firmware_info.sw_part);
|
|
|
|
printf("text1: %.64s\n", header->firmware_info.text1);
|
|
|
|
printf("time: %.12s\n", header->firmware_info.time);
|
|
|
|
printf("date: %.14s\n", header->firmware_info.date);
|
|
|
|
printf("text2: %.10s\n", header->firmware_info.text2);
|
|
|
|
printf("version: %.20s\n", header->firmware_info.version);
|
|
|
|
printf("subitems...\n");
|
|
|
|
|
|
|
|
llist_for_each_entry(sub_entry, &header->header_list, entry) {
|
|
|
|
printf("\tsomething1: %u\n", sub_entry->header_entry.something1);
|
|
|
|
printf("\ttext1: %.64s\n", sub_entry->header_entry.text1);
|
|
|
|
printf("\ttime: %.12s\n", sub_entry->header_entry.time);
|
|
|
|
printf("\tdate: %.14s\n", sub_entry->header_entry.date);
|
|
|
|
printf("\ttext2: %.10s\n", sub_entry->header_entry.text2);
|
|
|
|
printf("\tversion: %.20s\n", sub_entry->header_entry.version);
|
|
|
|
printf("\tlength: %u\n", ntohl(sub_entry->header_entry.length));
|
|
|
|
printf("\taddr1: 0x%x\n", ntohl(sub_entry->header_entry.addr1));
|
|
|
|
printf("\taddr2: 0x%x\n", ntohl(sub_entry->header_entry.addr2));
|
|
|
|
printf("\tstart: 0x%x\n", ntohl(sub_entry->header_entry.start));
|
2010-03-22 10:22:54 +00:00
|
|
|
printf("\tabs. offset: 0x%lx\n", sub_entry->absolute_offset);
|
2009-12-30 06:08:39 +00:00
|
|
|
printf("\n\n");
|
2010-03-22 10:22:54 +00:00
|
|
|
|
|
|
|
dump_entry(sub_entry, part++, fd);
|
2009-12-30 06:08:39 +00:00
|
|
|
}
|
|
|
|
printf("\n\n");
|
|
|
|
}
|
|
|
|
|
2010-03-22 10:22:54 +00:00
|
|
|
if (close(fd) != 0) {
|
|
|
|
perror("Close failed.\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-12-30 06:08:39 +00:00
|
|
|
talloc_free(tall_firm_ctx);
|
|
|
|
}
|
|
|
|
|
2009-07-04 09:53:10 +00:00
|
|
|
static void print_usage(void)
|
|
|
|
{
|
|
|
|
printf("Usage: ipaccess-config\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print_help(void)
|
|
|
|
{
|
2010-06-28 13:52:56 +00:00
|
|
|
#if 0
|
|
|
|
printf("Commmands for reading from the BTS:\n");
|
|
|
|
printf(" -D --dump\t\t\tDump the BTS configuration\n");
|
|
|
|
printf("\n");
|
|
|
|
#endif
|
|
|
|
printf("Commmands for writing to the BTS:\n");
|
2010-06-28 13:17:57 +00:00
|
|
|
printf(" -u --unit-id UNIT_ID\t\tSet the Unit ID of the BTS\n");
|
|
|
|
printf(" -o --oml-ip IP\t\tSet primary OML IP (IP of your BSC)\n");
|
|
|
|
printf(" -i --ip-address IP/MASK\tSet static IP address + netmask of BTS\n");
|
|
|
|
printf(" -g --ip-gateway IP\t\tSet static IP gateway of BTS\n");
|
|
|
|
printf(" -r --restart\t\t\tRestart the BTS (after other operations)\n");
|
2010-06-28 13:52:56 +00:00
|
|
|
printf(" -n --nvram-flags FLAGS/MASK\tSet NVRAM attributes\n");
|
|
|
|
printf(" -S --nvattr-set FLAG\tSet one additional NVRAM attribute\n");
|
|
|
|
printf(" -U --nvattr-unset FLAG\tSet one additional NVRAM attribute\n");
|
2010-06-28 13:17:57 +00:00
|
|
|
printf(" -l --listen TESTNR\t\tPerform specified test number\n");
|
|
|
|
printf(" -s --stream-id ID\t\tSet the IPA Stream Identifier for OML\n");
|
|
|
|
printf(" -d --software FIRMWARE\tDownload firmware into BTS\n");
|
2010-06-28 13:52:56 +00:00
|
|
|
printf("\n");
|
|
|
|
printf("Miscellaneous commands:\n");
|
|
|
|
printf(" -h --help\t\t\tthis text\n");
|
2010-06-28 13:17:57 +00:00
|
|
|
printf(" -f --firmware FIRMWARE\tProvide firmware information\n");
|
|
|
|
printf(" -w --write-firmware\t\tThis will dump the firmware parts to the filesystem. Use with -f.\n");
|
2009-07-04 09:53:10 +00:00
|
|
|
}
|
|
|
|
|
2010-05-13 18:54:40 +00:00
|
|
|
extern void bts_model_nanobts_init();
|
|
|
|
|
2009-04-30 15:53:07 +00:00
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
struct gsm_bts *bts;
|
|
|
|
struct sockaddr_in sin;
|
2009-10-27 02:41:09 +00:00
|
|
|
int rc, option_index = 0, stream_id = 0xff;
|
2010-03-26 13:28:59 +00:00
|
|
|
struct log_target *stderr_target;
|
|
|
|
|
|
|
|
log_init(&log_info);
|
|
|
|
stderr_target = log_target_create_stderr();
|
|
|
|
log_add_target(stderr_target);
|
|
|
|
log_set_all_filter(stderr_target, 1);
|
|
|
|
log_set_log_level(stderr_target, 0);
|
|
|
|
log_parse_category_mask(stderr_target, "DNM,0");
|
2010-01-10 17:37:38 +00:00
|
|
|
bts_model_nanobts_init();
|
2009-04-30 15:53:07 +00:00
|
|
|
|
2010-06-28 13:17:57 +00:00
|
|
|
printf("ipaccess-config (C) 2009-2010 by Harald Welte and others\n");
|
2009-04-30 15:53:07 +00:00
|
|
|
printf("This is FREE SOFTWARE with ABSOLUTELY NO WARRANTY\n\n");
|
|
|
|
|
|
|
|
while (1) {
|
|
|
|
int c;
|
2009-07-03 09:26:45 +00:00
|
|
|
unsigned long ul;
|
|
|
|
char *slash;
|
2009-04-30 15:53:07 +00:00
|
|
|
static struct option long_options[] = {
|
|
|
|
{ "unit-id", 1, 0, 'u' },
|
|
|
|
{ "oml-ip", 1, 0, 'o' },
|
2010-06-28 13:17:57 +00:00
|
|
|
{ "ip-address", 1, 0, 'i' },
|
|
|
|
{ "ip-gateway", 1, 0, 'g' },
|
2009-04-30 15:53:07 +00:00
|
|
|
{ "restart", 0, 0, 'r' },
|
2010-06-28 13:17:57 +00:00
|
|
|
{ "nvram-flags", 1, 0, 'n' },
|
2010-06-28 13:52:56 +00:00
|
|
|
{ "nvattr-set", 1, 0, 'S' },
|
|
|
|
{ "nvattr-unset", 1, 0, 'U' },
|
2009-07-04 09:53:10 +00:00
|
|
|
{ "help", 0, 0, 'h' },
|
add support for more nanoBTS 12.21 tests
* perform a channel usage test
$ ./ipaccess-config -l 64 192.168.100.100
paccess-config.c:142 ==> ARFCN 3, RxLev 16
[...]
<0020> ipaccess-config.c:142 ==> ARFCN 4, RxLev 33
<0020> ipaccess-config.c:142 ==> ARFCN 8, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 5, RxLev 16
<0020> ipaccess-config.c:142 ==> ARFCN 11, RxLev 5
<0020> ipaccess-config.c:142 ==> ARFCN 12, RxLev 8
<0020> ipaccess-config.c:142 ==> ARFCN 10, RxLev 6
[...]
* perform a BCCH usage test
$ ./ipaccess-config -l 65 192.168.100.100
[...]
<0020> ipaccess-config.c:107 TEST REPORT: test_no=0x41 test_res=SUCCESS
<0020> ipaccess-config.c:142 ==> ARFCN 4, RxLev 32
<0020> ipaccess-config.c:142 ==> ARFCN 8, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 12, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 20, RxLev 9
<0020> ipaccess-config.c:142 ==> ARFCN 31, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 37, RxLev 23
<0020> ipaccess-config.c:142 ==> ARFCN 49, RxLev 7
<0020> ipaccess-config.c:142 ==> ARFCN 53, RxLev 14
<0020> ipaccess-config.c:142 ==> ARFCN 57, RxLev 19
<0020> ipaccess-config.c:142 ==> ARFCN 60, RxLev 63
<0020> ipaccess-config.c:142 ==> ARFCN 71, RxLev 15
<0020> ipaccess-config.c:142 ==> ARFCN 90, RxLev 4
* perform a frequency sync test
$ ./ipaccess-config -l 66 192.168.100.100
[...]
<0020> ipaccess-config.c:107 TEST REPORT: test_no=0x42 test_res=SUCCESS
<0020> ipaccess-config.c:130 ==> ARFCN 4, Frequency Error -2
<0020> ipaccess-config.c:130 ==> ARFCN 8, Frequency Error -40
<0020> ipaccess-config.c:130 ==> ARFCN 20, Frequency Error -21
<0020> ipaccess-config.c:130 ==> ARFCN 31, Frequency Error 1
<0020> ipaccess-config.c:130 ==> ARFCN 37, Frequency Error -4
<0020> ipaccess-config.c:130 ==> ARFCN 45, Frequency Error -4
<0020> ipaccess-config.c:130 ==> ARFCN 53, Frequency Error 22
<0020> ipaccess-config.c:130 ==> ARFCN 57, Frequency Error 3
<0020> ipaccess-config.c:130 ==> ARFCN 60, Frequency Error 0
<0020> ipaccess-config.c:130 ==> ARFCN 69, Frequency Error 2
<0020> ipaccess-config.c:130 ==> ARFCN 73, Frequency Error 30
<0020> ipaccess-config.c:130 ==> ARFCN 89, Frequency Error 44
<0020> ipaccess-config.c:130 ==> ARFCN 90, Frequency Error 8
<0020> ipaccess-config.c:130 ==> ARFCN 123, Frequency Error 27
2009-08-10 09:39:47 +00:00
|
|
|
{ "listen", 1, 0, 'l' },
|
2009-10-27 02:41:09 +00:00
|
|
|
{ "stream-id", 1, 0, 's' },
|
2009-12-28 02:11:33 +00:00
|
|
|
{ "software", 1, 0, 'd' },
|
2009-12-30 06:08:39 +00:00
|
|
|
{ "firmware", 1, 0, 'f' },
|
2010-03-22 10:22:54 +00:00
|
|
|
{ "write-firmware", 0, 0, 'w' },
|
2010-04-20 14:22:00 +00:00
|
|
|
{ 0, 0, 0, 0 },
|
2009-04-30 15:53:07 +00:00
|
|
|
};
|
|
|
|
|
2010-06-28 13:52:56 +00:00
|
|
|
c = getopt_long(argc, argv, "u:o:i:g:rn:S:U:l:hs:d:f:w", long_options,
|
2009-04-30 15:53:07 +00:00
|
|
|
&option_index);
|
|
|
|
|
|
|
|
if (c == -1)
|
|
|
|
break;
|
|
|
|
|
|
|
|
switch (c) {
|
|
|
|
case 'u':
|
|
|
|
unit_id = optarg;
|
|
|
|
break;
|
|
|
|
case 'o':
|
|
|
|
prim_oml_ip = optarg;
|
|
|
|
break;
|
2010-06-28 13:17:57 +00:00
|
|
|
case 'i':
|
|
|
|
slash = strchr(optarg, '/');
|
|
|
|
if (!slash)
|
|
|
|
exit(2);
|
|
|
|
bts_ip_addr = optarg;
|
2010-06-28 13:52:56 +00:00
|
|
|
*slash = 0;
|
2010-06-28 13:17:57 +00:00
|
|
|
bts_ip_mask = slash+1;
|
|
|
|
break;
|
|
|
|
case 'g':
|
|
|
|
bts_ip_gw = optarg;
|
|
|
|
break;
|
2009-04-30 15:53:07 +00:00
|
|
|
case 'r':
|
|
|
|
restart = 1;
|
|
|
|
break;
|
2009-07-03 09:26:45 +00:00
|
|
|
case 'n':
|
|
|
|
slash = strchr(optarg, '/');
|
|
|
|
if (!slash)
|
|
|
|
exit(2);
|
|
|
|
ul = strtoul(optarg, NULL, 16);
|
|
|
|
nv_flags = ul & 0xffff;
|
|
|
|
ul = strtoul(slash+1, NULL, 16);
|
|
|
|
nv_mask = ul & 0xffff;
|
|
|
|
break;
|
2010-06-28 13:52:56 +00:00
|
|
|
case 'S':
|
|
|
|
if (ipa_nvflag_set(&nv_flags, &nv_mask, optarg, 1) < 0)
|
|
|
|
exit(2);
|
|
|
|
break;
|
|
|
|
case 'U':
|
|
|
|
if (ipa_nvflag_set(&nv_flags, &nv_mask, optarg, 0) < 0)
|
|
|
|
exit(2);
|
|
|
|
break;
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
case 'l':
|
add support for more nanoBTS 12.21 tests
* perform a channel usage test
$ ./ipaccess-config -l 64 192.168.100.100
paccess-config.c:142 ==> ARFCN 3, RxLev 16
[...]
<0020> ipaccess-config.c:142 ==> ARFCN 4, RxLev 33
<0020> ipaccess-config.c:142 ==> ARFCN 8, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 5, RxLev 16
<0020> ipaccess-config.c:142 ==> ARFCN 11, RxLev 5
<0020> ipaccess-config.c:142 ==> ARFCN 12, RxLev 8
<0020> ipaccess-config.c:142 ==> ARFCN 10, RxLev 6
[...]
* perform a BCCH usage test
$ ./ipaccess-config -l 65 192.168.100.100
[...]
<0020> ipaccess-config.c:107 TEST REPORT: test_no=0x41 test_res=SUCCESS
<0020> ipaccess-config.c:142 ==> ARFCN 4, RxLev 32
<0020> ipaccess-config.c:142 ==> ARFCN 8, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 12, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 20, RxLev 9
<0020> ipaccess-config.c:142 ==> ARFCN 31, RxLev 6
<0020> ipaccess-config.c:142 ==> ARFCN 37, RxLev 23
<0020> ipaccess-config.c:142 ==> ARFCN 49, RxLev 7
<0020> ipaccess-config.c:142 ==> ARFCN 53, RxLev 14
<0020> ipaccess-config.c:142 ==> ARFCN 57, RxLev 19
<0020> ipaccess-config.c:142 ==> ARFCN 60, RxLev 63
<0020> ipaccess-config.c:142 ==> ARFCN 71, RxLev 15
<0020> ipaccess-config.c:142 ==> ARFCN 90, RxLev 4
* perform a frequency sync test
$ ./ipaccess-config -l 66 192.168.100.100
[...]
<0020> ipaccess-config.c:107 TEST REPORT: test_no=0x42 test_res=SUCCESS
<0020> ipaccess-config.c:130 ==> ARFCN 4, Frequency Error -2
<0020> ipaccess-config.c:130 ==> ARFCN 8, Frequency Error -40
<0020> ipaccess-config.c:130 ==> ARFCN 20, Frequency Error -21
<0020> ipaccess-config.c:130 ==> ARFCN 31, Frequency Error 1
<0020> ipaccess-config.c:130 ==> ARFCN 37, Frequency Error -4
<0020> ipaccess-config.c:130 ==> ARFCN 45, Frequency Error -4
<0020> ipaccess-config.c:130 ==> ARFCN 53, Frequency Error 22
<0020> ipaccess-config.c:130 ==> ARFCN 57, Frequency Error 3
<0020> ipaccess-config.c:130 ==> ARFCN 60, Frequency Error 0
<0020> ipaccess-config.c:130 ==> ARFCN 69, Frequency Error 2
<0020> ipaccess-config.c:130 ==> ARFCN 73, Frequency Error 30
<0020> ipaccess-config.c:130 ==> ARFCN 89, Frequency Error 44
<0020> ipaccess-config.c:130 ==> ARFCN 90, Frequency Error 8
<0020> ipaccess-config.c:130 ==> ARFCN 123, Frequency Error 27
2009-08-10 09:39:47 +00:00
|
|
|
net_listen_testnr = atoi(optarg);
|
implement nanoBTS frequency error test
This helps us to detect the frequency error of BS-11 if it is located
next to the nanoBTS 900.
If 'ipaccess-config -l' is called, it will produce a report like
<0020> ipaccess-config.c:85 TEST REPORT: test_no=0x42 test_res=0
<0020> ipaccess-config.c:108 ==> ARFCN 220, Frequency Error 22
<0020> ipaccess-config.c:108 ==> ARFCN 1, Frequency Error -37
<0020> ipaccess-config.c:108 ==> ARFCN 10, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 20, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 53, Frequency Error 5
<0020> ipaccess-config.c:108 ==> ARFCN 63, Frequency Error -4
<0020> ipaccess-config.c:108 ==> ARFCN 84, Frequency Error 11
<0020> ipaccess-config.c:108 ==> ARFCN 101, Frequency Error 0
<0020> ipaccess-config.c:108 ==> ARFCN 123, Frequency Error -52
where in this case the ARFCN 123 is the BS-11 with a frequency error
larger than all the other (regular) BTS in the vicinity.
2009-08-07 22:02:36 +00:00
|
|
|
break;
|
2009-10-27 02:41:09 +00:00
|
|
|
case 's':
|
|
|
|
stream_id = atoi(optarg);
|
|
|
|
break;
|
2009-12-28 02:11:33 +00:00
|
|
|
case 'd':
|
|
|
|
software = strdup(optarg);
|
2010-03-22 08:50:56 +00:00
|
|
|
if (find_sw_load_params(optarg) != 0)
|
|
|
|
exit(0);
|
2009-12-28 02:11:33 +00:00
|
|
|
break;
|
2009-12-30 06:08:39 +00:00
|
|
|
case 'f':
|
2010-03-24 04:26:24 +00:00
|
|
|
firmware_analysis = optarg;
|
|
|
|
break;
|
2010-03-22 10:22:54 +00:00
|
|
|
case 'w':
|
|
|
|
dump_files = 1;
|
|
|
|
break;
|
2009-07-04 09:53:10 +00:00
|
|
|
case 'h':
|
|
|
|
print_usage();
|
|
|
|
print_help();
|
|
|
|
exit(0);
|
2009-04-30 15:53:07 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-03-24 04:26:24 +00:00
|
|
|
if (firmware_analysis)
|
|
|
|
analyze_firmware(firmware_analysis);
|
|
|
|
|
2009-04-30 15:53:07 +00:00
|
|
|
if (optind >= argc) {
|
2010-03-24 04:26:24 +00:00
|
|
|
/* only warn if we have not done anything else */
|
|
|
|
if (!firmware_analysis)
|
|
|
|
fprintf(stderr, "you have to specify the IP address of the BTS. Use --help for more information\n");
|
2009-04-30 15:53:07 +00:00
|
|
|
exit(2);
|
|
|
|
}
|
|
|
|
|
2009-06-21 14:17:15 +00:00
|
|
|
gsmnet = gsm_network_init(1, 1, NULL);
|
2009-04-30 15:53:07 +00:00
|
|
|
if (!gsmnet)
|
|
|
|
exit(1);
|
|
|
|
|
2009-10-02 11:19:34 +00:00
|
|
|
bts = gsm_bts_alloc(gsmnet, GSM_BTS_TYPE_NANOBTS, HARDCODED_TSC,
|
2009-06-21 14:17:15 +00:00
|
|
|
HARDCODED_BSIC);
|
2009-12-28 22:15:36 +00:00
|
|
|
/* ip.access supports up to 4 chained TRX */
|
|
|
|
gsm_bts_trx_alloc(bts);
|
|
|
|
gsm_bts_trx_alloc(bts);
|
|
|
|
gsm_bts_trx_alloc(bts);
|
2009-10-27 02:41:09 +00:00
|
|
|
bts->oml_tei = stream_id;
|
2009-04-30 15:53:07 +00:00
|
|
|
|
2009-07-07 10:40:07 +00:00
|
|
|
register_signal_handler(SS_NM, nm_sig_cb, NULL);
|
2010-03-05 18:36:20 +00:00
|
|
|
register_signal_handler(SS_IPAC_NWL, nwl_sig_cb, NULL);
|
|
|
|
|
|
|
|
ipac_nwl_init();
|
|
|
|
|
2009-04-30 15:53:07 +00:00
|
|
|
printf("Trying to connect to ip.access BTS ...\n");
|
|
|
|
|
|
|
|
memset(&sin, 0, sizeof(sin));
|
|
|
|
sin.sin_family = AF_INET;
|
|
|
|
inet_aton(argv[optind], &sin.sin_addr);
|
|
|
|
rc = ia_config_connect(bts, &sin);
|
|
|
|
if (rc < 0) {
|
|
|
|
perror("Error connecting to the BTS");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (1) {
|
2009-05-23 06:07:04 +00:00
|
|
|
rc = bsc_select_main(0);
|
2009-04-30 15:53:07 +00:00
|
|
|
if (rc < 0)
|
|
|
|
exit(3);
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(0);
|
|
|
|
}
|
|
|
|
|