From d5eb431c47e681152ea35ffc7fc1e7f8f513d947 Mon Sep 17 00:00:00 2001 From: Daniel Willmann Date: Thu, 28 Jul 2011 19:25:32 +0200 Subject: osmo-bsc: Only send a TRAP if the location changes --- openbsc/src/osmo-bsc/osmo_bsc_main.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c index 7a47fbcb7..8afd6ccd1 100644 --- a/openbsc/src/osmo-bsc/osmo_bsc_main.c +++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c @@ -205,6 +205,12 @@ struct location { double height; }; +static int location_equal(struct location *a, struct location *b) +{ + return ((a->age == b->age) && (a->valid == b->valid) && (a->lat == b->lat) && + (a->lon == b->lon) && (a->height == b->height)); +} + static LLIST_HEAD(locations); static void cleanup_locations() @@ -260,7 +266,7 @@ static int set_net_loc(struct ctrl_cmd *cmd, void *data) { char *saveptr, *lat, *lon, *height, *age, *valid, *tmp; struct osmo_msc_data *msc; - struct location *myloc; + struct location *myloc, *lastloc; int ret; struct gsm_network *gsmnet = (struct gsm_network *)data; @@ -289,14 +295,18 @@ static int set_net_loc(struct ctrl_cmd *cmd, void *data) myloc->height = atof(height); talloc_free(tmp); + lastloc = llist_entry(locations.next, struct location, list); + /* Add location to the end of the list */ llist_add(&myloc->list, &locations); - cleanup_locations(); ret = get_net_loc(cmd, data); - llist_for_each_entry(msc, &gsmnet->bsc_data->mscs, entry) - osmo_bsc_send_trap(cmd, msc->msc_con); + if (!location_equal(myloc, lastloc)) + llist_for_each_entry(msc, &gsmnet->bsc_data->mscs, entry) + osmo_bsc_send_trap(cmd, msc->msc_con); + + cleanup_locations(); return ret; -- cgit v1.2.3