mirror of
https://gitea.osmocom.org/cellular-infrastructure/osmo-mgw.git
synced 2025-11-03 21:43:32 +00:00
osmo-bsc: Change variable name to better reflect current/last location
This commit is contained in:
@@ -108,17 +108,17 @@ static void cleanup_locations()
|
|||||||
CTRL_CMD_DEFINE(net_loc, "location");
|
CTRL_CMD_DEFINE(net_loc, "location");
|
||||||
static int get_net_loc(struct ctrl_cmd *cmd, void *data)
|
static int get_net_loc(struct ctrl_cmd *cmd, void *data)
|
||||||
{
|
{
|
||||||
struct location *myloc;
|
struct location *curloc;
|
||||||
|
|
||||||
if (llist_empty(&locations)) {
|
if (llist_empty(&locations)) {
|
||||||
cmd->reply = talloc_asprintf(cmd, "0,invalid,0,0,0");
|
cmd->reply = talloc_asprintf(cmd, "0,invalid,0,0,0");
|
||||||
return CTRL_CMD_REPLY;
|
return CTRL_CMD_REPLY;
|
||||||
} else {
|
} else {
|
||||||
myloc = llist_entry(locations.next, struct location, list);
|
curloc = llist_entry(locations.next, struct location, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd->reply = talloc_asprintf(cmd, "%lu,%s,%f,%f,%f", myloc->tstamp,
|
cmd->reply = talloc_asprintf(cmd, "%lu,%s,%f,%f,%f", curloc->tstamp,
|
||||||
get_value_string(valid_names, myloc->valid), myloc->lat, myloc->lon, myloc->height);
|
get_value_string(valid_names, curloc->valid), curloc->lat, curloc->lon, curloc->height);
|
||||||
if (!cmd->reply) {
|
if (!cmd->reply) {
|
||||||
cmd->reply = "OOM";
|
cmd->reply = "OOM";
|
||||||
return CTRL_CMD_ERROR;
|
return CTRL_CMD_ERROR;
|
||||||
@@ -130,7 +130,7 @@ static int get_net_loc(struct ctrl_cmd *cmd, void *data)
|
|||||||
static int set_net_loc(struct ctrl_cmd *cmd, void *data)
|
static int set_net_loc(struct ctrl_cmd *cmd, void *data)
|
||||||
{
|
{
|
||||||
char *saveptr, *lat, *lon, *height, *tstamp, *valid, *tmp;
|
char *saveptr, *lat, *lon, *height, *tstamp, *valid, *tmp;
|
||||||
struct location *myloc, *lastloc;
|
struct location *curloc, *lastloc;
|
||||||
int ret;
|
int ret;
|
||||||
struct gsm_network *gsmnet = (struct gsm_network *)data;
|
struct gsm_network *gsmnet = (struct gsm_network *)data;
|
||||||
|
|
||||||
@@ -138,12 +138,12 @@ static int set_net_loc(struct ctrl_cmd *cmd, void *data)
|
|||||||
if (!tmp)
|
if (!tmp)
|
||||||
goto oom;
|
goto oom;
|
||||||
|
|
||||||
myloc = talloc_zero(tall_bsc_ctx, struct location);
|
curloc = talloc_zero(tall_bsc_ctx, struct location);
|
||||||
if (!myloc) {
|
if (!curloc) {
|
||||||
talloc_free(tmp);
|
talloc_free(tmp);
|
||||||
goto oom;
|
goto oom;
|
||||||
}
|
}
|
||||||
INIT_LLIST_HEAD(&myloc->list);
|
INIT_LLIST_HEAD(&curloc->list);
|
||||||
|
|
||||||
|
|
||||||
tstamp = strtok_r(tmp, ",", &saveptr);
|
tstamp = strtok_r(tmp, ",", &saveptr);
|
||||||
@@ -152,21 +152,21 @@ static int set_net_loc(struct ctrl_cmd *cmd, void *data)
|
|||||||
lon = strtok_r(NULL, ",", &saveptr);
|
lon = strtok_r(NULL, ",", &saveptr);
|
||||||
height = strtok_r(NULL, "\0", &saveptr);
|
height = strtok_r(NULL, "\0", &saveptr);
|
||||||
|
|
||||||
myloc->tstamp = atol(tstamp);
|
curloc->tstamp = atol(tstamp);
|
||||||
myloc->valid = get_string_value(valid_names, valid);
|
curloc->valid = get_string_value(valid_names, valid);
|
||||||
myloc->lat = atof(lat);
|
curloc->lat = atof(lat);
|
||||||
myloc->lon = atof(lon);
|
curloc->lon = atof(lon);
|
||||||
myloc->height = atof(height);
|
curloc->height = atof(height);
|
||||||
talloc_free(tmp);
|
talloc_free(tmp);
|
||||||
|
|
||||||
lastloc = llist_entry(locations.next, struct location, list);
|
lastloc = llist_entry(locations.next, struct location, list);
|
||||||
|
|
||||||
/* Add location to the end of the list */
|
/* Add location to the end of the list */
|
||||||
llist_add(&myloc->list, &locations);
|
llist_add(&curloc->list, &locations);
|
||||||
|
|
||||||
ret = get_net_loc(cmd, data);
|
ret = get_net_loc(cmd, data);
|
||||||
|
|
||||||
if (!location_equal(myloc, lastloc))
|
if (!location_equal(curloc, lastloc))
|
||||||
osmo_bsc_send_trap(cmd, gsmnet->msc_data->msc_con);
|
osmo_bsc_send_trap(cmd, gsmnet->msc_data->msc_con);
|
||||||
|
|
||||||
cleanup_locations();
|
cleanup_locations();
|
||||||
|
|||||||
Reference in New Issue
Block a user