[mod_sofia] Keep noreg gateways as NOREG, mark unregistered gateways as DOWN.

Co-authored-by: Mike Jerris <mike@signalwire.com>
This commit is contained in:
Andrey Volk 2020-10-29 00:14:00 +04:00
parent aa91b46d3f
commit a746d12f6c
3 changed files with 24 additions and 13 deletions

View File

@ -2740,6 +2740,7 @@ const char *sofia_state_names[] = {
"FAIL_WAIT",
"EXPIRED",
"NOREG",
"DOWN",
"TIMEOUT",
NULL
};
@ -3653,15 +3654,19 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
if (!strcasecmp(gname, "all")) {
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGED;
if (gateway_ptr->state != REG_STATE_NOREG) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGED;
}
}
stream->write_function(stream, "+OK\n");
} else if ((gateway_ptr = sofia_reg_find_gateway(gname))) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGED;
stream->write_function(stream, "+OK\n");
sofia_reg_release_gateway(gateway_ptr);
if (gateway_ptr->state != REG_STATE_NOREG) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGED;
stream->write_function(stream, "+OK\n");
sofia_reg_release_gateway(gateway_ptr);
}
} else {
stream->write_function(stream, "Invalid gateway!\n");
}
@ -3680,15 +3685,19 @@ static switch_status_t cmd_profile(char **argv, int argc, switch_stream_handle_t
if (!strcasecmp(gname, "all")) {
for (gateway_ptr = profile->gateways; gateway_ptr; gateway_ptr = gateway_ptr->next) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGISTER;
if (gateway_ptr->state != REG_STATE_NOREG) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGISTER;
}
}
stream->write_function(stream, "+OK\n");
} else if ((gateway_ptr = sofia_reg_find_gateway(gname))) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGISTER;
stream->write_function(stream, "+OK\n");
sofia_reg_release_gateway(gateway_ptr);
if (gateway_ptr->state != REG_STATE_NOREG) {
gateway_ptr->retry = 0;
gateway_ptr->state = REG_STATE_UNREGISTER;
stream->write_function(stream, "+OK\n");
sofia_reg_release_gateway(gateway_ptr);
}
} else {
stream->write_function(stream, "Invalid gateway!\n");
}

View File

@ -432,6 +432,7 @@ typedef enum {
REG_STATE_FAIL_WAIT,
REG_STATE_EXPIRED,
REG_STATE_NOREG,
REG_STATE_DOWN,
REG_STATE_TIMEOUT,
REG_STATE_LAST
} reg_state_t;

View File

@ -398,6 +398,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
}
switch (ostate) {
case REG_STATE_DOWN:
case REG_STATE_NOREG:
if (!gateway_ptr->ping && !gateway_ptr->pinging && gateway_ptr->status != SOFIA_GATEWAY_UP) {
gateway_ptr->status = SOFIA_GATEWAY_UP;
@ -432,7 +433,7 @@ void sofia_reg_check_gateway(sofia_profile_t *profile, time_t now)
case REG_STATE_UNREGISTER:
sofia_reg_kill_reg(gateway_ptr);
gateway_ptr->state = REG_STATE_NOREG;
gateway_ptr->state = REG_STATE_DOWN;
gateway_ptr->status = SOFIA_GATEWAY_DOWN;
break;
case REG_STATE_UNREGED: