[ipaccess] Restart only after setting the OML IP, software load
* Do not issue the restart right aways if we have OML IP or
software load in the queue (hint, we need a real queue of operations
to carry out... with one big state machine)
* Change the signal_data of ipacc ACK/NACK to contain the msg type
and the bts pointer.
* Issue a restart for software load and OML and use the BTS pointer
we got out of the new signal data.
diff --git a/openbsc/src/ipaccess/ipaccess-config.c b/openbsc/src/ipaccess/ipaccess-config.c
index 7591614..29b9a9b 100644
--- a/openbsc/src/ipaccess/ipaccess-config.c
+++ b/openbsc/src/ipaccess/ipaccess-config.c
@@ -55,6 +55,7 @@
static u_int16_t nv_mask;
static char *software = NULL;
static int sw_load_state = 0;
+static int oml_state = 0;
struct sw_load {
u_int8_t file_id[255];
@@ -87,11 +88,23 @@
return 0;
}
-static int ipacc_msg_ack(u_int8_t mt)
+static int ipacc_msg_ack(u_int8_t mt, struct gsm_bts *bts)
{
if (sw_load_state == 1) {
fprintf(stderr, "The new software is activaed.\n");
- exit(0);
+
+ if (restart) {
+ abis_nm_ipaccess_restart(bts);
+ } else {
+ exit(0);
+ }
+ } else if (oml_state == 1) {
+ fprintf(stderr, "Set the primary OML IP.\n");
+ if (restart) {
+ abis_nm_ipaccess_restart(bts);
+ } else {
+ exit(0);
+ }
}
return 0;
@@ -178,15 +191,15 @@
static int nm_sig_cb(unsigned int subsys, unsigned int signal,
void *handler_data, void *signal_data)
{
- u_int8_t *msg_type;
+ struct ipacc_ack_signal_data *ipacc_data;
switch (signal) {
case S_NM_IPACC_NACK:
- msg_type = signal_data;
- return ipacc_msg_nack(*msg_type);
+ ipacc_data = signal_data;
+ return ipacc_msg_nack(ipacc_data->msg_type);
case S_NM_IPACC_ACK:
- msg_type = signal_data;
- return ipacc_msg_ack(*msg_type);
+ ipacc_data = signal_data;
+ return ipacc_msg_ack(ipacc_data->msg_type, ipacc_data->bts);
case S_NM_TEST_REP:
return test_rep(signal_data);
default:
@@ -315,6 +328,7 @@
*cur++ = 0;
*cur++ = 0;
printf("setting primary OML link IP to '%s'\n", inet_ntoa(ia));
+ oml_state = 1;
abis_nm_ipaccess_set_nvattr(bts, buf, 3+len);
}
if (nv_mask) {
@@ -332,7 +346,7 @@
abis_nm_ipaccess_set_nvattr(bts, buf, 3+len);
}
- if (restart) {
+ if (restart && !prim_oml_ip && !software) {
printf("restarting BTS\n");
abis_nm_ipaccess_restart(bts);
}