[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.
This commit is contained in:
Holger Hans Peter Freyther 2009-12-30 08:38:43 +01:00
parent f9811defe2
commit 2e83782b1c
3 changed files with 34 additions and 10 deletions

View File

@ -124,6 +124,11 @@ struct scall_signal_data {
void *data;
};
struct ipacc_ack_signal_data {
struct gsm_bts *bts;
u_int8_t msg_type;
};
/* Management */
int register_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);
void unregister_signal_handler(unsigned int subsys, signal_cbfn *cbfn, void *data);

View File

@ -2721,6 +2721,7 @@ static int abis_nm_rx_ipacc(struct msgb *msg)
struct abis_om_fom_hdr *foh;
u_int8_t idstrlen = oh->data[0];
struct tlv_parsed tp;
struct ipacc_ack_signal_data signal;
if (strncmp((char *)&oh->data[1], ipaccess_magic, idstrlen)) {
LOGP(DNM, LOGL_ERROR, "id string is not com.ipaccess !?!\n");
@ -2803,10 +2804,14 @@ static int abis_nm_rx_ipacc(struct msgb *msg)
case NM_MT_IPACC_RSL_CONNECT_NACK:
case NM_MT_IPACC_SET_NVATTR_NACK:
case NM_MT_IPACC_GET_NVATTR_NACK:
dispatch_signal(SS_NM, S_NM_IPACC_NACK, &foh->msg_type);
signal.bts = msg->trx->bts;
signal.msg_type = foh->msg_type;
dispatch_signal(SS_NM, S_NM_IPACC_NACK, &signal);
break;
case NM_MT_IPACC_SET_NVATTR_ACK:
dispatch_signal(SS_NM, S_NM_IPACC_ACK, &foh->msg_type);
signal.bts = msg->trx->bts;
signal.msg_type = foh->msg_type;
dispatch_signal(SS_NM, S_NM_IPACC_ACK, &signal);
break;
default:
break;

View File

@ -55,6 +55,7 @@ static u_int16_t nv_flags;
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 @@ static int ipacc_msg_nack(u_int8_t mt)
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 test_rep(void *_msg)
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 @@ static void bootstrap_om(struct gsm_bts *bts)
*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 @@ static void bootstrap_om(struct gsm_bts *bts)
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);
}