aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src
diff options
context:
space:
mode:
authorDaniel Willmann <daniel@totalueberwachung.de>2011-07-28 19:25:32 +0200
committerDaniel Willmann <daniel@totalueberwachung.de>2011-08-22 19:24:34 +0200
commit9748a9c1c08f27726100855f76d6e2a7fd57ea73 (patch)
tree04cc4e4d6cc856f808b405df66e5223a66d62c09 /openbsc/src
parentd13f32ccd8aee2a0ef06ebee4fcec3a17b901f86 (diff)
osmo-bsc: Only send a TRAP if the location changes
Diffstat (limited to 'openbsc/src')
-rw-r--r--openbsc/src/osmo-bsc/osmo_bsc_main.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/openbsc/src/osmo-bsc/osmo_bsc_main.c b/openbsc/src/osmo-bsc/osmo_bsc_main.c
index e0ea5f7c2..627534170 100644
--- a/openbsc/src/osmo-bsc/osmo_bsc_main.c
+++ b/openbsc/src/osmo-bsc/osmo_bsc_main.c
@@ -196,6 +196,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);
void cleanup_locations()
@@ -250,7 +256,7 @@ int get_net_loc(struct ctrl_cmd *cmd, void *data)
int set_net_loc(struct ctrl_cmd *cmd, void *data)
{
char *saveptr, *lat, *lon, *height, *age, *valid, *tmp;
- struct location *myloc;
+ struct location *myloc, *lastloc;
int ret;
struct gsm_network *gsmnet = (struct gsm_network *)data;
@@ -279,12 +285,17 @@ 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);
- osmo_bsc_send_trap(cmd, gsmnet->msc_data->msc_con);
+
+ if (!location_equal(myloc, lastloc))
+ osmo_bsc_send_trap(cmd, gsmnet->msc_data->msc_con);
+
+ cleanup_locations();
return ret;