From 39ee87783f049daa40941aa25742d27ac2d79c96 Mon Sep 17 00:00:00 2001 From: Holger Hans Peter Freyther Date: Tue, 30 Mar 2010 06:08:56 +0200 Subject: [PATCH] nat: Verify that the configured LACs are unique across the nat --- openbsc/src/nat/bsc_nat_vty.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/openbsc/src/nat/bsc_nat_vty.c b/openbsc/src/nat/bsc_nat_vty.c index 695903775..6dae0d65c 100644 --- a/openbsc/src/nat/bsc_nat_vty.c +++ b/openbsc/src/nat/bsc_nat_vty.c @@ -154,6 +154,7 @@ DEFUN(cfg_bsc_token, cfg_bsc_token_cmd, "token TOKEN", "Set the token") 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 @@ DEFUN(cfg_bsc_lac, cfg_bsc_lac_cmd, "location_area_code <0-65535>", 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;