aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/osmo-bsc/osmo_bsc_main.c
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-07-28 19:25:32 +0200
committerHolger Hans Peter Freyther <zecke@selfish.org>2012-09-11 14:46:48 +0200
commitd5eb431c47e681152ea35ffc7fc1e7f8f513d947 (patch)
treeb0fa700a2c44842af37c3063f63dc932cbb54ed6 /openbsc/src/osmo-bsc/osmo_bsc_main.c
parentadcde9f8f55d753e46db16e415d28da749fff083 (diff)
osmo-bsc: Only send a TRAP if the location changes
Diffstat (limited to 'openbsc/src/osmo-bsc/osmo_bsc_main.c')
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_main.c18
1 files 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;