nat: Verify that the configured LACs are unique across the nat
diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c
index 6959037..6dae0d6 100644
--- a/openbsc/src/nat/bsc_nat_vty.c
+++ b/openbsc/src/nat/bsc_nat_vty.c
@@ -154,6 +154,7 @@
 DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>",
       "Set the Location Area Code (LAC) of this BSC\n")
 {
+	struct bsc_config *tmp;
 	struct bsc_config *conf = vty->index;
 
 	int lac = atoi(argv[0]);
@@ -170,6 +171,14 @@
 		return CMD_WARNING;
 	}
 
+	/* verify that the LACs are unique */
+	llist_for_each_entry(tmp, &_nat->bsc_configs, entry) {
+		if (tmp->lac == lac) {
+			vty_out(vty, "%% LAC %d is already used.%s", lac, VTY_NEWLINE);
+			return CMD_ERR_INCOMPLETE;
+		}
+	}
+
 	conf->lac = lac;
 
 	return CMD_SUCCESS;